akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define REP(i,n,N) for(int i=n;i<(int)N;i++)
#define p(S) cout<<(S)<<endl
#define ck(n,a,b) (a<=(n)&&(n)<=b)
using namespace std;
const int inf=1e9;

struct RF{
	int id,from,to;
};
int main(){
	int N;
	while(cin>>N,N){
		vector<RF> seg;
		seg.push_back({-1,0,inf});
		REP(i,0,N){
			char c;
			int id,num;
			cin>>c;
			if(c=='W'){
				cin>>id>>num;
				int i=0;
				while(num>0){
					if(seg[i].id==-1){
						int from=seg[i].from,to=seg[i].to;
						if(to-from+1<=num){
							seg[i].id=id;
							num-=to-from+1;
						}else{
							seg[i]={id,from,from+num-1};
							seg.insert(seg.begin()+i+1,{-1,from+num,to});
							num=0;
						}
					}
					i++;
				}
			}else if(c=='D'){
				cin>>id;
				REP(i,0,seg.size()){
					if(seg[i].id==id) seg[i].id=-1;
				}
			}else if(c=='R'){
				cin>>num;
				for(auto v:seg){
					if(ck(num,v.from,v.to)){
						p(v.id);
						break;
					}
				}
			}
		}
		p("");
	}

	return 0;
}

Measured memory_bytes: 3172
#include <bits/stdc++.h>
using namespace std;

typedef pair<int, int> pii;
typedef long long ll;
typedef vector<int> vi;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()

const int MN = 500010;

int tor[MN][27]; //26 for ""
int nx[20][MN];

int main() {
	string s;
	cin >> s;
	int n = s.size();

	rep(i, 27) tor[n][i] = MN;

	for (int i = n-1; i >= 0; --i) {
		int c = s[i] - 'a';
		tor[i][c] = i + 1;

		for (int j = c + 1; j < 27; ++j) {
			tor[i][j] = (tor[i][j-1] == MN ? MN : tor[tor[i][j-1]][j-1]);
		}

		nx[0][i] = tor[i][26];

		for (int j = 0; j < c; ++j) {
			tor[i][j] = (tor[i][26] == MN ? MN : tor[tor[i][26]][j]);
		}
	}

	rep(i, 20) nx[i][n] = MN;

	rep(i, 19) {
		rep(j, n) {
			nx[i+1][j] = (nx[i][j] == MN ? MN : nx[i][nx[i][j]]);
		}
	}

	int q;
	cin >> q;
	while (q--) {
		int l, r;
		cin >> l >> r;
		--l;

		for (int i = 19; i >= 0; --i) {
			if (nx[i][l] <= r) {
				l = nx[i][l];
			}
		}

		puts(l == r ? "Yes" : "No");
	}

	return 0;
}

Measured memory_bytes: 93060
/*input
1
1

*/
 
/*
                                                    ______________
                                                          |       )
                                                          |   )   /
                                                          |______/
                                                    |     |      \
                                                    |     |   )   \
                                                    |_____|_______)
 
*/
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <iomanip>
#include <fstream>
#include <stack>

using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> PII;
typedef pair<ll , ll> PLL;
typedef long double ld;
 
#define pb push_back
#define all(c) c.begin(),c.end()
#define allr(c) c.rbegin(),c.rend()
int mod = 1000000007;
const int inf = 1034567891;
const ll LL_INF = 1234567890123456789ll;
#define PI 3.14159265
#define endl '\n'
#define F first
#define S second
#define debug(x) cout << #x << " = " << x << endl;
#define TRACE
 
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cout << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
 
#define out(container) for (auto it : container) cout << it << " "; cout << endl;
 
 
template < typename T > T GCD(T a, T b)            { ll t; while(a) { t = a; a = b % a; b = t; } return b; }
template < typename T > string toString(T a)       { return to_string(a); }
template < typename T > void toInt(string s, T &x) { stringstream str(s); str >> x;}
inline int add(int x, int y){ x += y; if(x >= mod) x -= mod; return x;}
inline int sub(int x, int y){ x -= y; if(x < 0) x += mod; return x;}
inline int mul(int x, int y){ return (x * 1ll * y) % mod;}
inline int powr(int a, ll b){
  int x = 1 % mod;
  while(b){
    if(b & 1) x = mul(x, a);
    a = mul(a, a);
    b >>= 1;
  }
  return x;
}
inline int inv(int a){ return powr(a, mod - 2);}

int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  
  string str;
  cin >> str;
  int sum = 0;
  for (auto it : str) {
    int x = it - '0';
    sum += x;
  }  

  cout << (sum % 9 == 0 ? "Yes" : "No") << endl;

  return 0;
}

Measured memory_bytes: 3780
#include <bits/stdc++.h>
using namespace std;

int main(void){
    string s;
    cin >> s;
    string days[] = {"SUN","MON","TUE","WED","THU","FRI","SAT"};
    for (int i = 0; i < 7; i++){
        if (days[i]==s){
            cout << 7-i << endl;
            break;
        }
    }
    
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int MOD=1e9+7;

signed main() {
  int N;cin>>N;int K=-1;
  for(int i=1;i<1000;i++)if(i*(i-1)/2==N)K=i;
  if(K==-1){cout<<"No"<<endl;return 0;}
  cout<<"Yes"<<endl<<K<<endl;
  std::vector<int> v[K];
  int c=1;
  for(int i=0;i<K;i++){
    for(int j=i+1;j<K;j++){
      v[i].push_back(c);
      v[j].push_back(c++);
    }
  }
  for(int i=0;i<K;i++){
    cout<<K-1;
    for(int p:v[i])cout<<" "<<p;cout<<endl;
  }
}


Measured memory_bytes: 3200
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
const ll MOD = 1000000007;
const ll INF = 9999999999;
template<class T> inline bool chmin(T& a, T b){if (a>b){a = b; return true;}return false;}
template<class T> inline bool chmax(T& a, T b){if (a<b){a = b; return true;}return false;}
template<class T> inline T powerM(T a,T b){if (b==0) return 1;
  T tmp = powerM(a,b/2); if (b%2==0) return tmp*tmp%MOD; else return tmp*tmp%MOD*a%MOD; }


int main() {
  string s,t; cin >>s >>t;
  int n = s.size(), m = t.size();

  vector<vector<int>> dp(n+10, vector<int>(m+10, 0));
  for (int i=0; i<n; i++){
    for (int j=0; j<m; j++){
      if (s.at(i) == t.at(j)) chmax(dp.at(i+1).at(j+1), dp.at(i).at(j) + 1);
      chmax(dp.at(i+1).at(j+1), dp.at(i+1).at(j));
      chmax(dp.at(i+1).at(j+1), dp.at(i).at(j+1));
    }
  }

  string res = "";
  int i = n, j = m;
  while (i > 0 && j > 0){
    if (dp.at(i).at(j) == dp.at(i-1).at(j)){
      i--;
    }else if (dp.at(i).at(j) == dp.at(i).at(j-1)){
      j--;
    }else{
      res = s.at(i-1) + res;
      i--; j--;
    }
  }

  cout <<res <<endl;
}

Measured memory_bytes: 35712
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using namespace std;
using P = pair<int, int>; 
using ll = long long;

int main()
{
  int a,b,c;
  cin >>a>>b>>c;
  int ans = c - (a - b);
  if(ans <0 ) ans = 0;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3592
#include<stdio.h>
#include<stdlib.h>

typedef long long int int64;

void run(void){
  int n,k;
  scanf("%d%d",&n,&k);
  int64 *w=(int64 *)calloc(n,sizeof(int64));
  int *d=(int *)calloc(n,sizeof(int));
  int i;
  for(i=0;i<n;i++) scanf("%lld%d",w+i,d+i);
  int64 l=0;
  int64 r=w[0]+(int64)(k-1)*d[0];
  while(r-l>1){
    int64 m=(l+r)/2;
    int64 cnt=0;
    for(i=0;i<n;i++){
      if(w[i]>m) continue;
      cnt+=1+(m-w[i])/d[i];
      if(cnt>=k) break;
    }
    if(cnt<k){
      l=m;
    } else {
      r=m;
    }
  }
  printf("%lld\n",r);
}

int main(void){
  run();
  return 0;
}

Measured memory_bytes: 1280
#define _USE_MATH_DEFINES
#define MAX_N 1000000
#include <iostream>
#include <sstream>
#include <cmath>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>

using namespace std;

typedef long long ll;
typedef pair<int,string> P;

static const double eps = 1e-8;


static const char a[] = {'r','g','b'};

bool checkColor(const string& str){

	bool res = false;
	for(int i=0;i<3;i++){
		if(count(str.begin(),str.end(),a[i]) == str.size()) res=true;
	}

	return res;
}

int changeColor(string str,int cost,map<string,int>& visited){

	if(checkColor(str)) return 0;

	priority_queue<P,vector<P>,greater<P> > que;
	que.push(P(0,str));

	while(!que.empty()){
		int cost = que.top().first;
		string now = que.top().second;

		que.pop();
		for(int i=0;i+1<now.size();i++){
			string tmp = now;
			if(now[i] != now[i+1]){
				for(int j=0;j<3;j++){
					if(a[j] != now[i] && a[j] != now[i+1]){
						tmp[i] = a[j];
						tmp[i+1] = a[j];
						break;
					}
				}

				if(visited.find(tmp) == visited.end()) visited[tmp] = cost + 1;
				else if(visited[tmp] <= cost+1) continue;

				if(checkColor(tmp)) return cost+1;
				que.push(P(cost+1,tmp));
			}
		}
	}

	return -1;

}

int main(){
	string str;

	while(cin>>str){
		if(str.size() == 1 && str[0] == '0') break;
		map<string,int> visited;
		visited[str] = 0;

		int res = changeColor(str,0,visited);

		if(res==-1) printf("%s\n","NA");
		else printf("%d\n",res);
	}
}

Measured memory_bytes: 1816
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<string>
using namespace std;


int main(){
    int n;
    scanf("%d",&n);
    int a[100005],i;
    for(i=0;i<=100004;i++)a[i]=0;
    for(i=0;i<=n-1;i++){
        int c;
        scanf("%d",&c);
        a[c]++;
        a[c+1]++;
        if(c!=0)a[c-1]++;
    }
    int max=0;
    for(i=0;i<=100004;i++){
        if(max<a[i])max=a[i];
    }
    printf("%d",max);
    
    
    return 0;
}

Measured memory_bytes: 512
import java.util.Scanner;

class Main{
	public static void main(String args[]){
		
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();

		sc.close();

		if((a+b)<24){
			System.out.print(a+b);
		}else if((a+b)>=24){
			System.out.print((a+b)-24);
		}
	}
}

Measured memory_bytes: 23508
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<double,double> P;
const LL mod=1e9+7;
const LL LINF=1LL<<62;
const LL INF=1<<30;
int main(){
    int N;
    cin >> N;
    int dp[N+1];
    for(int i=0;i<N+1;i++){
        dp[i]=INF;
    }
    dp[0]=0;
    for(int i=0;i<N;i++){
        int s=1;
        while(1){
            if(i+s>N) break;
            dp[i+s]=min(dp[i+s],dp[i]+1);
            s*=6;
        }
        s=1;
        while(1){
            if(i+s>N) break;
            dp[i+s]=min(dp[i+s],dp[i]+1);
            s*=9;
        }
    }
    cout << dp[N] << endl;
    return 0;
}


Measured memory_bytes: 640
N = int(input())
numbers = list(map(int, input().split()))

summ, right, left = 0, 0, 0
ans = 0

for left in range(N):
    while (right < N and (summ + numbers[right]) == (summ ^ numbers[right])):
        summ += numbers[right]
        right += 1
    
    ans += right - left
    
    
    if (right == left):
        right += 1
    
    else:
        summ -= numbers[left]
        

print(ans)

Measured memory_bytes: 32388
"use strict"
const create = () => {
    const input = require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n");
    const res = {
        "list": input, "index": 0, "max": input.length,
        "hasNext": function () { return this.index < this.max },
        "next": function () { if (!this.hasNext()) { throw "ArrayIndexOutOfBoundsException"; } else { return this.list[this.index++]; } }
    };
    return res;
}
const o = create();
const next = () => o.next()
const nextInt = () => parseInt(o.next())
const nextStrArray = () => o.next().split(" ")
const nextIntArray = () => o.next().split(" ").map(el => parseInt(el))
const nextCharArray = () => o.next().split("")
const hasNext = () => o.hasNext()
const myout = (...x) => console.log(...x)
const Main = () => {
    let [a, b, c] = nextIntArray()
    let k = nextInt()
    let pat = []
    const fn = (num) => {
        for(let i = 0; i<= num; i++){
            pat.push([i, num-i])
        }
    }
    fn(k)
    for(let el of pat){
        let bt = b * Math.pow(2, el[0])
        let ct = c * Math.pow(2, el[1])
        if (bt > a && ct > bt) {
            console.log("Yes")
            return
        }
    }
    console.log("No")
}
Main()



Measured memory_bytes: 29636
#include <iostream>

using namespace std;

int main()
{
    int a, b, c, d, area1, area2;
    cin >> a >> b >> c >> d;
    area1= a*b;
    area2= c*d;
    if (1 <= a && a <= 10000 && 1 <= b && b <= 10000 && 1 <= c && c <= 10000 && 1 <= d && d <= 10000 )
    {
       if (area1 > area2)
            cout << area1;
       else if (area1 == area2)
            cout << area1;
       else if (area1 < area2)
            cout << area2;
    }
    return 0;


}

Measured memory_bytes: 256
def solve():
    N = int(input())
    A = list(map(int, input().split()))
    if 0 in A:
        print(0)
        return
    ans = 1
    for i in range(len(A)):
        ans *= A[i]
        if ans > 1000000000000000000:
            print(-1)
            return
    print(ans)
    return


solve()

Measured memory_bytes: 21548
n, a, b = map(int, input().split())
s = input()

cnt_t = 0
cnt_f = 0
for i in range(n):
    if s[i] == "a" and cnt_t < a+b:
        print("Yes")
        cnt_t += 1
    elif s[i] == "b" and cnt_t < a+b and cnt_f < b:
        print("Yes")
        cnt_t += 1
        cnt_f += 1
    else:
        print("No")

Measured memory_bytes: 9192
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define zero_pad(num) setfill('0') << std::right << setw(num)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;

int main() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    while(a > 0 && c > 0){
        c -= b;
        a -= d;
    }
    if(c <= 0)cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 3596
import Data.Functor( (<$>))
import Control.Monad( replicateM, filterM, (<=<))
import Data.List( foldl', unfoldr)

main = do
    rawOrders <- filterM (return . ("-"/=)) =<< lines <$> getContents
    let
	interprete list = unfoldr pack list
	  where
	    pack [] = Nothing
	    pack (str:num:shu)
	      = let
		    shuffleSize = read num
		    (shuffles, remain) = splitAt shuffleSize shu
		in
		    Just ((str,shuffles), remain)

	processPerOrder (orgStr, shuffles)
	  = let
		shuffle str n = b++a where (a,b) = splitAt (read n) str
	    in
		foldl' shuffle orgStr shuffles

    (putStrLn . processPerOrder) `mapM_` interprete rawOrders



Measured memory_bytes: 4092
import sys
from collections import deque


def main():
    N, M, *AB = map(int, sys.stdin.buffer.read().split())
    
    g = [[] for _ in range(N + 1)]

    for A, B in zip(*[iter(AB)] * 2):
        g[A].append(B)
        g[B].append(A)

        #print("->", g)

    queue = deque([1])
    d = [-1] * (N + 1)
    d[0] = 0
    d[1] = 0

    while queue:
        v = queue.popleft()
        for i in g[v]:
            if d[i] == -1:
                #d[i] = d[v] + 1
                d[i] = v
                queue.append(i)

    if -1 in d:
        print("No")
    else:
        print("Yes")
        print("\n".join(map(str, d[2:])))


if __name__ == '__main__':
	main()

exit()


Measured memory_bytes: 46432
# include<iostream>

using namespace std;
int main(){
	int a = 0;
	int b = 0;
	int c = 0;
	cin >> a >> b >> c;
	if (a < b && b < c){
		cout << "Yes" << endl;
	}
	else{
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 3088
#include <stdio.h>
#define max(p,q)((p)>(q)?(p):(q))

int ans;
int n,m,q;
int a[99],b[99],c[99],d[99];
int p[99];

void dfs(int pos){
	if(pos==n+1){
		int temp=0;
		for(int i=0;i<q;i++)if(p[b[i]]-p[a[i]]==c[i])temp+=d[i];
		ans=max(ans,temp);
		
	}else{
		for(int i=p[pos-1];i<=m;i++){
			p[pos]=i;
			dfs(pos+1);
		}
	}
}

int main(){
	scanf("%d%d%d",&n,&m,&q);
	for(int i=0;i<q;i++)scanf("%d%d%d%d",a+i,b+i,c+i,d+i);
	p[0]=1;
	dfs(1);
	printf("%d",ans);
}

Measured memory_bytes: 1732
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

const ll INF = ll(1e18) + 1;

int main()
{
  int n;
  cin >> n;
  vector<ll> X(n);
  rep(i, n) cin >> X[i];

  ll ans = INF;
  sort(X.begin(), X.end());
  // rep(i, n) cout << X[i] << " ";
  // cout << X[0] << endl;
  // cout << X[X.size() - 1] << endl;

  for (int i = X[0]; i <= X[X.size() - 1]; i++)
  {
    ll hp = 0;
    for (int j = 0; j < n; j++) {
      hp += pow((X[j] - i), 2);
      // cout << hp << endl;
    }
    ans = min(hp, ans);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
N, H = list(map(int, input().split()))
A = []
B = []

for i in range(N):
	a, b = list(map(int, input().split()))
	A.append(a)
	B.append(b)

ax = max(A)
B = sorted(B)

judge = "no"
c = 0
for i in range(N):
	if B[-1 - i] > ax:
		c += 1
		if B[-1 - i] >= H:
			judge = "des"
			break
		else:
			H -= B[-1 - i]
	else:
		break

if judge == "des":
	print(c)
else:
	if H % ax == 0:
		print(c + int(H // ax))
	else:
		print(c + 1 + int(H // ax))

Measured memory_bytes: 12132
#include<stdio.h>
void call(int);
int main(void)
{
  int n;
  scanf("%d",&n);
  call(n);
  printf("\n");
  return 0;
}
void call(int n)
{
  int i=1;
  int x;
  for(;;)
    {
      x=i;
      if(x%3==0)
        {
          printf(" %d",i);
        }
      else
        {
          for(;;)
            {
              if(x%10==3)
                {
                  printf(" %d",i);
                  break;
                }
              x/=10;
              if(x) continue;
              else break;
            }
        }
      if(++i<=n) continue;
      else break;
    }
}


Measured memory_bytes: 2108
#include<bits/stdc++.h>
using namespace std;
namespace QiFeng233{
	typedef long long ll;
	ll gcd(ll a,ll b){
		if(a<b)swap(a,b);
		return b?gcd(b,a%b):a;
	}
	ll k,ans;
	void solve(){
		scanf("%lld",&k);
		for(ll a=1;a<=k;++a)
			for(ll b=1;b<=k;++b)
				for(ll c=1;c<=k;++c)
					ans+=gcd(gcd(a,b),gcd(b,c));
		printf("%lld",ans);
	}
}
signed main(){
	QiFeng233::solve();
	return 0;
}

Measured memory_bytes: 3824
#include "bits/stdc++.h"
#define rep(i,a,n) for(int i = (a);i < (n);i++)
using namespace std;

struct start { start() {
cin.tie(0);
ios::sync_with_stdio(0);
cout << fixed << setprecision(10);
}; }start;

typedef long long ll;


int main(){
    int a,b;
    cin >> a >> b;
    cout << ((a < b)?"a < b":((a > b)?"a > b":"a == b")) << endl;
    return 0;
}


Measured memory_bytes: 3192
#include <bits/stdc++.h>
using namespace std;

int main() {
  int d, n; cin >> d >> n;
  int hk = 1;
  for (int i = 0; i < d; i++) {
    hk *= 100;
  }
  if (n == 100) n++;
  cout << n * hk << endl;
}


Measured memory_bytes: 256
import java.util.HashMap;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next(), t = sc.next();
		int N = s.length();
		HashMap<Character, Character> StoT = new HashMap<>();
		HashMap<Character, Character> TtoS = new HashMap<>();
		for (int i = 0; i < N; i++) {
			// First Observation for every character in S they can only map to one unique
			// character of T
			if (StoT.containsKey(s.charAt(i)) && StoT.get(s.charAt(i)) != t.charAt(i)) {
				System.out.println("No");
				return;
			}
			// Second Observation for every character in T they can only map to one unique
			// character of S
			if (TtoS.containsKey(t.charAt(i)) && TtoS.get(t.charAt(i)) != s.charAt(i)) {
				System.out.println("No");
				return;
			}
			StoT.put(s.charAt(i), t.charAt(i));
			TtoS.put(t.charAt(i), s.charAt(i));
		}
		System.out.println("Yes");
	}
}

Measured memory_bytes: 33076
#include<stdio.h>

int main(){
    int i,j,k;
    int A[4][4];
    int count=0;

    for(i=0;i<3;i++){
        for(j=0;j<3;j++){
            scanf("%d",&A[i][j]);
        }
    }

    int N;
    scanf("%d\n",&N);
    int b[N+1];

    for(i=0;i<N;i++){
        scanf("%d",&b[i]);
        for(j=0;j<3;j++){
            for(k=0;k<3;k++){
                if(b[i]==A[j][k]){
                    A[j][k]=0;
                }
            }
        }
    }

    for(i=0;i<3;i++){
        if((A[i][0]==A[i][1] && A[i][1]==A[i][2])||(A[0][i]==A[1][i] && A[1][i]==A[2][i])){
            count =1;
        }
    }
    if(A[0][0]==A[1][1] && A[1][1]==A[2][2]){
        count =1;
    }
    if(A[2][0]==A[1][1] && A[1][1]==A[0][2]){ 
        count =1;
    }
    
    if(count==1){
        printf("Yes");
    }
    else{
        printf("No");
    }
    return 0;
}





Measured memory_bytes: 128
N = int(input())
u = list(map(int,input().split()))
s_u = sorted(u)
for x in range(N-1):
  s_u = sorted(s_u)
  tmp = s_u.copy()
  val = (s_u[0] + s_u[1]) / 2
  if len(s_u) != 1:
    s_u.remove(tmp[0])
    s_u.remove(tmp[1])
  else:
    s_u.remove(tmp[0])
  s_u.insert(0,val)
print(s_u[0])


Measured memory_bytes: 3060
s=input()
l=len(s)
if l%2==0:
  s=s[:-1]
  l-=1
for i in range((l-1)//2):
  a=s[:l-1-i*2]
  if a[:len(a)//2]==a[len(a)//2:]:
    print(len(a))
    break

Measured memory_bytes: 3060
#include "bits/stdc++.h"
using namespace std;

int main() {
	static long long N, A, B[200010] = {}, ANS = 1000000000000;
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> A;
		B[i + 1] = B[i] + A;
	}
	for (int i = 2; i <= N - 2; i++) {
		long long P, Q, R, S;
		long long X = B[i], Y = B[N] - B[i];
		int Left = 0, Right = i;
		while (Right - Left > 1) {
			int Mid = (Left + Right) / 2;
			if (B[Mid] * 2 <= X) Left = Mid;
			else Right = Mid;
		}
		P = max(B[Left], X - B[Right]), Q = min(B[Right], X - B[Left]);
		Left = i, Right = N;
		while (Right - Left > 1) {
			int Mid = (Left + Right) / 2;
			if ((B[Mid] - B[i]) * 2 <= Y) Left = Mid;
			else Right = Mid;
		}
		R = max(B[Left] - X, B[N] - B[Right]), S = min(B[Right] - X, B[N] - B[Left]);
		ANS = min(ANS, max(Q, S) - min(P, R));
	}
	cout << ANS;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);

    int h, w;
    cin >> h >> w;
    char S[h][w];
    REP(i, h) REP(j, w) cin >> S[i][j];

    int dx[4] = {0, 0, -1, 1};
    int dy[4] = {-1, 1, 0, 0};

    bool f = true;
    REP(i, h){
        REP(j, w){
            int sc = 0, kc = 0, dc = 0;
            if(S[i][j] == '#') sc++;
            REP(k, 4){
                int nx, ny;
                nx = i + dx[k];
                ny = j + dy[k];
                if(nx < 0 or ny < 0 or nx >= h or ny >= w){
                    continue;
                }
                kc++;
                if(S[nx][ny] == '#') sc++;
                else if(S[nx][ny] == '.') dc++;
            }
            if(sc == 1 and dc == kc){
                f = false;
                break;
            }
        }
        if(f);
        else break;
    }
    if(f) cout << "Yes" << endl; 
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var lines = input.split('\n');

var line;
while (line = lines.shift()) {
	var vals = line.split(' ').map(function(n){return +n;});
	var a = vals[0];
	var b = vals[1];
	var c = vals[2];
	var d = vals[3];
	var e = vals[4];
	var f = vals[5];

	var D = a * e - b * d;
	var x = (e * c - b * f) / D;
	var y = (a * f - d * c) / D;

	console.log(x.toFixed(3) + ' ' + y.toFixed(3));
}

Measured memory_bytes: 7636
#include <bits/stdc++.h>
using namespace std;

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;

using f32 = float;
using f64 = double;

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) for(i64 i = 1; i <= n; ++i)
#define RREP(i, n) for(i64 i = n - 1; i >= 0 ; --i)
#define RREPS(i, n) for(i64 i = n; i >= 1; --i)

#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define pb push_back
#define mp make_pair
#define F first
#define S second

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }

template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }


struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;


int main() {
    i64 A, B;
    cin >> A >> B;
    REPS(i, 3) {
        if (i != A && i != B) {
            cout << i << endl;
            return 0;
        }
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;

int main() {
  string s;
  cin >> s;

  //文字分繰り返す
  int ans = 0;
  rep(i,s.size()/2) {
    //文字列の最初と最後を比較して違っていたらカウントアップ
    if (s[i] != s[s.size()-1-i]) ++ans;
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>

using namespace std;

#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a)  (a).begin(),(a).end()

class TEAM{
public:
    int pena[20];
    int sum;
    int time;
    int num;
    int point;
    
    
    TEAM(){
        rep(i,20)pena[i]=0;
        sum=time=num=point=0;
    }
};

int main(){
    int M,T,P,R;
    while(cin>>M>>T>>P>>R){
        TEAM team[100];
        
        
        if(M==0 && T==0 && P==0 && R==0)break;
        
        rep(i,T)team[i].num=i+1;
        
        rep(i,R){
            int m,t,p,j;
            cin>>m>>t>>p>>j;
            t--;
            if(j==0){
                team[t].sum++;
                team[t].time+=m+team[t].pena[p]*20;
            }else{
                team[t].pena[p]++;
            }
        }
        
        rep(i,T){
            team[i].point=team[i].sum*100000000 + 10000000-team[i].time;
        }

        for(int i=0;i<T-1;i++){
            for(int j=T-1;j>i;j--){
                if(team[j].point<team[j-1].point)swap(team[j],team[j-1]);
            }
        }
        
        cout<<team[T-1].num;
//        cout<<" "<<team[T-1].point<<endl;
        for(int i=T-2;i>=0;i--){
            if(team[i+1].point==team[i].point){
                cout<<"="<<team[i].num;
//                cout<<" "<<team[i].point<<endl;
            }
            else{
                cout<<","<<team[i].num;
//                cout<<" "<<team[i].point<<endl;
            }
        }
        cout<<endl;
    }
    return 0;
}

Measured memory_bytes: 1168
#include <bits/stdc++.h>
using namespace std;

#define pb push_back

using ll=long long;
using vll=vector<ll>;
using vvll=vector<vll>;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int,int>;
using vpii=vector<pii>;
using vvpii=vector<vpii>;
using QI = queue<int>;

const int MOD = 998244353;


bool twocolor(const vvi& adj, vi& color, int v) {
    for (int i=0; i<adj.size(); ++i) {
        if (adj[v][i] == 0)
            continue;
        if (color[i] == color[v])
            return false;
        if (color[i] < 0) {
            color[i] = 1-color[v];
            if (!twocolor(adj, color, i))
                return false;
        }
    }
    return true;
}

bool is_bipartite(const vvi& adj) {
    vi color(adj.size(), -1);
    color[0] = 0;
    return twocolor(adj, color, 0);
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int n;
    cin >> n;
    vvi adj(n, vi(n));
    for (int i=0; i<n; ++i) {
        string l;
        cin >> l;
        for (int j=0; j<n; ++j) {
            adj[i][j] = l[j] - '0';
        }
    }

    if (!is_bipartite(adj)) {
        cout << "-1\n";
        return 0;
    }

    const int INF = 1e6;
    vvi dists(n, vi(n, INF));
    for (int i=0; i<n; ++i) {
        for (int j=0; j<n; ++j) {
            if (adj[i][j])
                dists[i][j] = 1;
            else if (i == j)
                dists[i][j] = 0;
        }
    }
    for (int k=0; k<n; ++k) {
        for (int i=0; i<n; ++i) {
            for (int j=0; j<n; ++j) {
                if (dists[i][k] + dists[k][j] < dists[i][j])
                    dists[i][j] = dists[i][k] + dists[k][j];
            }
        }
    }

    int diam = 0;
    for (int i=0; i<n; ++i) {
        for (int j=0; j<n; ++j) {
            diam = max(diam, dists[i][j]);
        }
    }
    cout << diam+1 << "\n";
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
#define ll long long int
int main()
{
    ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	/*ll t;cin>>t;
	while(t-->0)
    {
    }*/
    ll a,b;
    cin>>a>>b;
    cout<<a*b<<"\n";
}

Measured memory_bytes: 3636
N=int(input())
A=list(map(int,input().split()))
for i in range(len(A)):
    if A[i]%2==0 and (A[i]%3==0 or A[i]%5==0):
        A[i]=1
    elif A[i]%2!=0:
        A[i]=1
    else:
        A[i]=0
B=[1]*N
if A==B:
    print('APPROVED')
else:
    print('DENIED')


Measured memory_bytes: 3064
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#include<algorithm>//next_permutation
#define rep(i,n) for (int i = 0;i < (n);i++)
#define all(v) v.begin(),v.end()
#define dec(n) cout << fixed << setprecision(n);
#define large "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
#define small "abcdefghijklmnopqrstuvwxyz"
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vl>;

ll gcd(ll a,ll b){
  if(b == 0) return a;
  return gcd(b , a % b);
}

const ll MOD = 1000000007;
const ll MAX = 2000001;

ll mod(ll a){
  return a % MOD;
}

ll lcm(ll a,ll b){
  return (a*b)/gcd(a,b);
}

ll fac[MAX], finv[MAX], inv[MAX];

void nCrprep() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

ll nCr(ll n, ll r){
    if (n < r) return 0;
    if (n < 0 || r < 0) return 0;
    return fac[n] * (finv[r] * finv[n - r] % MOD) % MOD;
}

ll nCrcheep(ll n,ll r){
  if(r == 0) return 1;
  else if(r == 1) return n;
  else return nCrcheep(n-1,r-1)*n/r;
}

vector<pair<ll,ll>> prime_factorize(ll n){
  vector<pair<ll,ll>> res;
  
  for(ll i=2; i*i <= n; i++){
    if(n % i != 0) continue;
    
    ll ex = 0;
    while(n % i == 0){
      ex++;
      n /= i;
    }
    
    res.push_back({i,ex});
  }
  
  if(n != 1) res.push_back({n,1});
  
  return res;
  
}




int main(){
  ll d; cin >> d;
  
  rep(i,d){
    cout << (365-i) % 26 + 1 << endl;
    
  }
  
  
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //これつけるとA[N]でもいいらしい
//for文のマクロ
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define big 1000000007
#define all(a) sort((a).begin(),(a).end()) //ソートのマクロ
int main(){
    int a,b;
    cin>>a>>b;
    if(a>0){
        cout<<"Positive"<<endl;
    }
    else if(a<=0&&b>=0){
        cout<<"Zero"<<endl;
    }
    else{
        if((b-a+1)%2==0){
            cout<<"Positive"<<endl;
        }
        else{
            cout<<"Negative"<<endl;
        }
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <stack>
#include <climits>
#include <algorithm>

constexpr int NUM = 16;
int dp[1 << NUM];
int cost[NUM][NUM + 1];//[????????????][?????¨] = ????±??????????

int main() {
	int n;
	while (std::cin >> n && n) {
		std::memset(dp, 0, sizeof(dp));
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n + 1; j++) {
				std::cin >> cost[i][j];
			}
		}

		int min = INT_MAX;
		std::stack<std::pair<int, int>> s; //first:????????¢?????????????????? second:?????????
		s.push(std::make_pair(0, 0));
		while (!s.empty()) {
			auto node = s.top(); s.pop();
			for (int i = 0; i < n; i++) { //??????????????????
				if ((node.first >> i) & 1) continue; //?????\??????
				for (int j = 0; j < n + 1; j++) { //?????¨??????
					//?????¨?????????
					if (j && !((node.first >> (j - 1)) & 1)) continue;

					auto next = node;
					next.second += cost[i][j];
					next.first |= 1 << i;

					if (dp[next.first] && dp[next.first] <= next.second) continue;
					dp[next.first] = next.second;

					s.push(next);

					if (next.first == (1 << n) - 1) {
						min = std::min(min, next.second);
					}
				}
			}
		}
		std::cout << min << std::endl;
	}

	return 0;
}

Measured memory_bytes: 3312
# https://atcoder.jp/contests/abc046/tasks/arc062_b
# 300点なのに水色diff
# AtCodeerくんの最善手はgpgpgpと交互に手を出すことである。任意のタイミングでpをgに変更したとき、負けることはあっても勝つことはない.
# (相手が何を出そうともpは負けることはない(悪化しない))

s = input()
ans = 0
for i, ss in enumerate(s):
    if i & 1:
        # Aはpである
        ans += ss == 'g'  # 相手がgだったら得点
    else:
        # Aはgである
        ans -= ss == 'p'  # 相手がpだったら減点
print(ans)


Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long ul;
// for文短縮類
#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPD(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i <= (ll)(b); i++)
#define FORD(i, a, b) for (ll i = a; i >= (ll)(b); i--)
// iteratorのbeginとendをまとめて渡す
#define ALL(x) (x).begin(), (x).end()
//略
#define PB push_back  // vectorヘの挿入
#define MP make_pair  // pairのコンストラクタ
#define F first       // pairの一つ目の要素
#define S second      // pairの二つ目の要素
//出力
#define COUT(x) cout << (x) << endl
#define SCOUT(x) cout << (x) << " "
#define ENDL cout << endl
/************ Combination wtih MOD ************
const int MAX = 510000;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];
// preprocess for some tables
void COMinit() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX; i++) {
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}
// combination
long long COM(int n, int k) {
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
*******************************************************/
int main(int argc, char *argv[]) {
  // input高速化。cinとcoutの結合解除。scanfとprintfは使えない。
  cin.tie(0);
  ios_base::sync_with_stdio(0);

  ll n;
  cin >> n;

  vector<ll> yakusu(n + 1);
  fill(ALL(yakusu), 1);

  for ( int i = 2; i < n + 1; i++){
      ll tmp = i;
      while(tmp < n + 1){
          yakusu[tmp] += 1;
          tmp += i;
      }
  }
  ll ans = 0;
  for (int i = 1; i < n + 1; i++){
      ans += i * yakusu[i];
  }
  cout << ans << endl;
}

Measured memory_bytes: 81308
#include <stdio.h>

int main(void)
{
	int n;
	
	while(scanf("%d", &n) != EOF){
	
	bool *d = new bool [n+1];
	int count = 0;

	for(int i = 0; i <= n; i++)
		d[i] = true;

	for(int i = 2; i <= n; i++){
		if(d[i]){
			count++;
			for(int j = i*2; j <= n; j+=i)
				d[j] = false;
		}
	}
	printf("%d\n", count);
	}


	return 0;
}

Measured memory_bytes: 15296
using System;
using System.Linq;
using System.Collections.Generic;

namespace Contest
{
    partial class Program
    {
        static void Main(string[] args)
        {
            ABC155_C();
        }

        static void ABC155_A()
        {
            var abc = ReadIntN();
            var A = abc[0];
            var B = abc[1];
            var C = abc[2];
            if (A == B && B == C) { Console.WriteLine("No");return; }
            if (A == B || A == C || B == C) { Console.WriteLine("Yes");return; }
            Console.WriteLine("No");
        }
        static void ABC155_B()
        {
            var N = ReadInt();
            var A = ReadIntN();
            for(int i = 0; i < N; ++i)
            { var a = A[i];
                if (a % 2 == 0 && (a % 3 > 0 && a % 5 > 0)) { Console.WriteLine("DENIED");return; }
            }
            Console.WriteLine("APPROVED");
        }
        static void ABC155_C()
        {
            var N = ReadInt();
            Dictionary<string, int> dict = new Dictionary<string, int>();
            for (int i = 0; i < N; ++i)
            {
                var s = Console.ReadLine();
                if (!dict.ContainsKey(s)) { dict.Add(s, 0); }
                dict[s] += 1;
            }
            var max = dict.Values.Max();
            var keys = dict.Where(x => x.Value == max).Select(x => x.Key).ToList();
            keys.Sort(StringComparer.OrdinalIgnoreCase);
            foreach (var s in keys)
            {
                Console.WriteLine(s);
            }
        }
        static void ABC155_D()
        {

        }
        static void ABC155_E()
        {

        }
        static void ABC155_F()
        {

        }

        static string ReadStr()
        {
            return Console.ReadLine();
        }
        static string[] ReadStrN()
        {
            return Console.ReadLine().Split(' ');
        }
        static int ReadInt()
        {
            return Convert.ToInt32(Console.ReadLine());
        }
        static int[] ReadIntN()
        {
            return Console.ReadLine().Split(' ').Select(s => Convert.ToInt32(s)).ToArray();
        }
        static long ReadLong()
        {
            return Convert.ToInt64(Console.ReadLine());
        }
        static long[] ReadLongN()
        {
            return Console.ReadLine().Split(' ').Select(s => Convert.ToInt64(s)).ToArray();
        }
        static Tuple<long, long>[]  ReadTupleLong(int n)
        {
            List<Tuple<long, long>> list = new List<Tuple<long, long>>();
            for (int i = 0; i < n; ++i)
            {
                var ab = ReadLongN();
                list.Add(new Tuple<long, long>(ab[0], ab[1]));
            }
            return list.ToArray();
        }
    }
}


Measured memory_bytes: 39900
#include<bits/stdc++.h>
using namespace std;
#define ull unsigned long long
#define ll long long
ll ans;
map<ull,ll>m;
const int maxn=200005;
vector<int>g[maxn];
ull dp[maxn];
const ull b=1000000007;
void dfs(int u,int p)
{
	dp[u]=1;
	for(int i=0;i<g[u].size();i++)
	{
		int v=g[u][i];
		if(v==p)
		continue;
		dfs(v,u);
		dp[u]+=dp[v]*b;
	}
	ans+=m[dp[u]];
	m[dp[u]]++;
}
int main()
{
	int n;
	scanf("%d",&n);
	for(int i=1;i<n;i++)
	{
		int u,v;
		scanf("%d%d",&u,&v);
		g[u].push_back(v);
		g[v].push_back(u);
	}
	dfs(1,-1);
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 29036
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N,K;
  cin >> N >> K;
  int sum=0;
  for(int i=0; i<N; i++){
    int x;
    cin >> x;
  if(x>K/2){
     sum+=K*2-x*2;}
    else{
    sum+=x*2;}
  }
  cout << sum <<endl;
}

Measured memory_bytes: 3512
#include <bits/stdc++.h>

using namespace std;

int N, M, P;
vector<int64_t> A, B, C;
vector<int64_t> gains;

int main() {
    cin >> N >> M >> P;
    A.resize(M);
    B.resize(M);
    C.resize(M);
    for (int i = 0; i < M; i++) {
        cin >> A[i] >> B[i] >> C[i];
        A[i]--;
        B[i]--;
    }

    gains = vector<int64_t >(N, INT64_MIN);
    gains[0] = 0;
    for (int c = 0; c < N; c++) {
        for (int ei = 0; ei < M; ei++) {
            int va = A[ei];
            int vb = B[ei];
            int64_t t = C[ei];
            if (gains[va] == INT64_MIN) continue;
            int64_t new_gain = gains[va] + t - P;
            if (new_gain > gains[vb]) gains[vb] = new_gain;
        }
    }

    int64_t prev_gain = gains[N - 1];
    for (int c = 0; c < N * 2; c++) {
        for (int ei = 0; ei < M; ei++) {
            int va = A[ei];
            int vb = B[ei];
            int64_t t = C[ei];
            if (gains[va] == INT64_MIN) continue;
            int new_gain = gains[va] + t - P;
            if (new_gain > gains[vb]) gains[vb] = new_gain;
        }
    }
    int64_t next_gain = gains[N - 1];
    if (next_gain == INT64_MIN) {
        cout << -1 << endl;
    } else if (prev_gain != next_gain) {
        cout << -1 << endl;
    } else {
        if (prev_gain < 0) {
            cout << 0 << endl;
        } else {
            cout << prev_gain << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define debug(var) do{cout << #var << " : "; view(var);}while(0)
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
template<class T> void view(T e) {cout << e << endl;}
template<class T> void view(const vector<T> &v) {for(const auto &e : v){cout << e << " ";} cout << endl;}
template<class T> void view(const vector<vector<T>> &vv) {for(const auto &v : vv){view(v);}}
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 1e5;

int main() {
    int a, b; cin >> a >> b;
    if (a > 0) cout << "Positive" << endl;
    else if (a == 0) cout << "Zero" << endl;
    else if (a < 0 && b >= 0) cout << "Zero" << endl;
    else {
        if ((b-a+1)&1) cout << "Negative" << endl;
        else cout << "Positive" << endl;
    }

}

Measured memory_bytes: 3612
import java.util.Scanner;

public class Main {
    public static void main(String args[] ) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        String s = sc.next();
        if (n >= 3200) {
        	System.out.println(s);
        } else {
        	System.out.println("red");
        }
    }
}


Measured memory_bytes: 21588
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		string[] str = Console.ReadLine().Split();
		int N = int.Parse(str[0]);
		int M = int.Parse(str[1]);
		string[] str2 = Console.ReadLine().Split();
		int[]A = new int[M];
		for(var i=0;i<M;i++){
			A[i] = int.Parse(str2[i]);
		}
		Array.Sort(A);
		var list = new List<int>();
		long sum = 0;
		for(var i=1;i<M;i++){
			int a = A[i]-A[i-1];
			list.Add(a);
			sum += a;
		}
		list.Sort((x,y)=>y-x);
		for(var i=0;i<Math.Min(M-1,N-1);i++){
			sum -= list[i];
		}
		Console.WriteLine(sum);
	}
}

Measured memory_bytes: 23644
object Main {

  def main(args: Array[String]): Unit = {
    val sc = new java.util.Scanner(System.in)
    val N, M = sc.nextInt
    val shop = new Array[(Long, Long)](N)
    for (i <- 0 until N) {
      shop(i) = (sc.nextLong, sc.nextLong())
    }
    val sorted = shop.sortBy(_._1)
    var rest: Long = M
    var result = 0L

    def buy(): Unit = {
      for (shop <- sorted) {
        val (price, count) = shop
        if (rest < count) {
          result += rest * price
          return
        } else {
          result += count * price
          rest -= count
        }
      }
    }

    buy()
    println(result)
  }
}

Measured memory_bytes: 74992
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<bool> vb;
typedef vector<vi> vvi;
#define INF (1e9)

vvi G;
vb visited;
vi ans;
queue<int> que;
void bfs(int v) {
    que.push(v);

    while (!que.empty()) {
        int v = que.front();
        que.pop();
        // visit node v


        for (auto nv : G[v]) {
            if (visited[nv]) continue;
            que.push(nv);
            ans[nv] = v;
            visited[nv] = true;
        }
    }
}

int main() {
    ll N, M;
    cin >> N >> M;
    visited = vb(N);
    ans = vi(N);
    G = vvi(N, vi(0));
    for (ll i = 0; i < M; i++) {
        ll a, b;
        cin >> a >> b;
        a--;
        b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    bfs(0);

    cout << "Yes" << endl;
    for (ll i = 1; i < N; i++) {
        cout << ans[i] + 1 << endl;
    }
}


Measured memory_bytes: 12636
#include <stdio.h>

int a[1000001];

int main(void)
{
	int p[10000], i, j, n, ph;
	
	for (i = 2; i <= 1000000; i++)a[i] = 1;
	
	for (i = 2; i * i <= 1000000; i++){
		if (a[i] == 1){
			for (j = i * 2; j <= 1000000; j += i)a[j] = 0;
		}
	}
	
	for(ph = 0, i = 2; ph <= 10000; i++){
		if (a[i] == 1)p[ph++] = i;
	}
	
	for (i = 0; i <= 10000; i++){
		if (i != 0)p[i] += p[i - 1];
	}
	
	while (scanf("%d", &n), n != 0){
		printf("%d\n", p[n - 1]);
	}
	
	
	return (0);
}

Measured memory_bytes: 4544
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<(int)(n); i++)
#define rep1(i, n) for(int i=1; i<=(int)(n); i++)
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> wi;
typedef vector<string> vs;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);

  string s;
  cin >> s;
  int n=(int)s.size();

  cout << s[0] << n-2 << s[n-1] << endl;

  return 0;
}

Measured memory_bytes: 3636
#include<iostream>
#include<string>
#include<cmath>
#include<array>
#include<algorithm>
#include<deque>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<list>
#include<bitset>

using namespace std;
using LLI = long long int;
LLI N;

//array<int, 8>dir_x = { 0,0,1,1,1,-1,-1,-1 };
//array<int, 8>dir_y = { 1,-1,1,0,-1,1,0,-1 };
//array<int, 4>dir_x2 = { 0,0,1,-1 };
//array<int, 4>dir_y2 = { 1,-1,0,0 };
//char alp[] = { 'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z' };

//class UnionFind {
//public:
//	vector<int>data;
//	UnionFind(int size) :data(size, -1) {};
//	bool unionset(int x, int y) {
//		x = root(x), y = root(y);
//		if (x != y) {
//			if (data[y] < data[x]) {
//				swap(x, y);
//			}
//			data[x] += data[y];
//			data[y] = x;
//		}
//		return x != y;
//	}
//	bool findset(int x, int y) {
//		return root(x) == root(y);
//	}
//	int root(int x) {
//		return data[x] < 0 ? x : data[x] = root(data[x]);
//	}
//	int size(int x) {
//		return -data[root(x)];
//	}
//};

//LLI gcd(LLI x, LLI y) {
//	LLI  r;
//	if (x < y) {
//		swap(x,y);
//	}
//	r = x % y;
//	while (r != 0) {
//		x = y;
//		y = r;
//		r = x % y;
//	}
//	return y;
//}
//LLI lcm(LLI x,LLI y) {
//	return x / gcd(x,y) * y;
//}

//long nCr(int n,int r) {
//	long ans = 1;
//	for (int i = n; i > n - r;i--) {
//		ans = ans * i;
//	}
//	for (int i = 1; i < r + 1;i++) {
//		ans = ans / i;
//	}
//	return ans;
//}

//const int n_max = 8;
//array<array<bool, n_max>, n_max>graph;
//int dfs(int v,int N,array<bool,n_max>visited) {
//	int ret = 0;
//	bool all_visited = true;
//	for (int i = 0; i < N;i++) {
//		if (visited[i] == false) {
//			all_visited = false;
//		}
//	}	
//	if (all_visited) {
//		return 1;
//	}
//	for (int i = 0; i < N;i++) {
//		if (graph[v][i] == false) {
//			continue;
//		}
//		if (visited[i] == true) {
//			continue;
//		}
//		visited[i] = true;
//		ret += dfs(i,N,visited);
//		visited[i] = false;
//	}
//	return ret;
//}

//vector<vector<int>>sub;
//int dfs(int id) {
//	if (sub[id].size() == 0) {
//		return 1;
//	}
//	int minP = (int)1e9;
//	int maxP = 0;
//	for (int i : sub[id]) {
//		int P = dfs(i);
//		minP = min(minP, P);
//		maxP = max(maxP, P);
//	}
//	return minP + maxP + 1;
//}

#define debug(x) cerr << #x << " : " << x << endl
#define debugv(x) cerr << #x << " : "; for(auto i:x) cerr << i << ", "; cerr<<endl

int main(void) {
	LLI A, B, C;
	vector<LLI>vec;
	cin >> A>>B>>C;
	if (A <= C && B >= C) {
		cout << "Yes" << endl;
	}
	else if(A >= C && B <= C){
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 256