akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <iostream>
#include <map>
#include <queue>
#include <string>

// https://atcoder.jp/contests/abc123/tasks/abc123_d

using namespace std;
typedef tuple<int, int, int> T;
typedef pair<long long int, T> P;

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

int main() {
  int X, Y, Z, K;
  long long int a[1000], b[1000], c[1000];

  cin >> X >> Y >> Z >> K;
  for (int i = 0; i < X; i++) {
    cin >> a[i];
  }
  for (int i = 0; i < Y; i++) {
    cin >> b[i];
  }
  for (int i = 0; i < Z; i++) {
    cin >> c[i];
  }
  sort(a, a + X, std::greater<long long int>());
  sort(b, b + Y, std::greater<long long int>());
  sort(c, c + Z, std::greater<long long int>());

  map<long long int, bool> checked;
  std::priority_queue<P> que;

  que.push(P(a[0] + b[0] + c[0], T(0, 0, 0)));

  for (int i = 0; i < K; i++) {
    P p = que.top();
    que.pop();

    cout << p.first << endl;
    T t = p.second;

    int x = get<0>(t);
    int y = get<1>(t);
    int z = get<2>(t);

    for (int j = 0; j < 3; j++) {
      int _x = x + dx[j];
      int _y = y + dy[j];
      int _z = z + dz[j];
      if (!checked[1000 * 1000 * (_x) + 1000 * (_y) + (_z)] && (_x) < X &&
          (_y) < Y && (_z) < Z) {
        checked[1000 * 1000 * (_x) + 1000 * (_y) + (_z)] = true;
        que.push(P(a[_x] + b[_y] + c[_z], T(_x, _y, _z)));
      }
    }
  }

  return 0;
}


Measured memory_bytes: 896
mod=10**9+7

memo={0:1}
def solve(n):
    if n in memo:
        return memo[n]
    res=0
    if n%2==1:
        res+=2*solve(n//2)
        if n>=2:
            res+=solve(n//2-1)
        memo[n]=0
        memo[n]=res%mod
        return res%mod
    else:
        res+=solve(n//2)
        res+=solve((n-1)//2)*(1+(n>=2))
        memo[n]=0
        memo[n]=res%mod
        return res%mod

print(solve(int(input())))


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

int main() {
  string s;
  cin >> s;
  bool a = true;
  for(int i = 0; i+1 < s.size(); i++) {
    if(s.at(i) == s.at(i+1)) a = false;
  }
  if(a) cout << "Good" << endl;
  else cout << "Bad" << endl;
}


Measured memory_bytes: 256
S=input() # 偶文字列
lenS=len(S) # Sの長さ
i=0 # 削る量

# 削ってゆき、長さが0になったら終了、今回は解があることが保証されているので特別な処理はなし
while i<lenS:
    i+=1 # 削る量を増やしてゆく
    Si=S[:lenS-i] # Sを削ってゆく
    lenSi=len(Si) # 削った結果の長さ

    if lenSi%2==1: # もし長さが奇数の場合、次へ
        continue

    if Si[:lenSi//2]==Si[lenSi//2:]: # 偶文字列なら終了
        break

print(lenSi)

Measured memory_bytes: 3060
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
using namespace std;
char fa[1008];
int main(){
  int n,m;
  scanf("%s",fa+1);
  n=strlen(fa+1);
   int l=1,r=n; 
  int fk=1;
//  printf("%d\n",n);
  while(fk&&l<r){
  	if(fa[l]==fa[r]){
  		l++,r--;
	  }
	  else{
	  	fk=0;
	  }
  }
  if(!fk){
  	printf("No\n");
  	return 0;
  }
   l=1,r=n/2;
//  printf("%d\n",n);
  while(fk&&l<r){
  	if(fa[l]==fa[r]){
  		l++,r--;
	  }
	  else{
	  	fk=0;
	  }
  }
  if(!fk){
  	printf("No\n");
  	return 0;
  }
  l=n/2+2,r=n;
  while(fk&&l<r){
  	if(fa[l]==fa[r]){
  		l++,r--;
	  }
	  else{
	  	fk=0;
	  }
  }
  if(!fk){
  	printf("No\n");
  	return 0;
  }
  else{
  	printf("Yes\n");
  }
}



Measured memory_bytes: 256
#include<iostream>
#include<queue>
#include<string>
using namespace std;
struct Edge{
    int t;
    int l;
};
struct Node{
    int no;
    vector<Edge> edge;
    int dist;
};
int main(){
    int n;cin>>n;
    vector<Node> node(n+1);
    vector<bool> memo(n+1,true);
    for(int i=0;i<n-1;i++){
        int u,v,w;cin>>u>>v>>w;
        w%=2;
        Edge buf;
        buf.t=v;
        buf.l=w;
        node[u].edge.push_back(buf);
        buf.t=u;
        node[v].edge.push_back(buf);
    }
    for(int i=1;i<=n;i++){
        node[i].dist=0;
        node[i].no=i;
    }
    queue<Node> que;
    que.push(node[1]);
    while(!que.empty()){
        Node buf=que.front();
        que.pop();
        memo[buf.no]=false;
        int num=buf.edge.size();
        for(int i=0;i<num;i++){
            if(memo[buf.edge[i].t]){
                node[buf.edge[i].t].dist=buf.dist+buf.edge[i].l;
                que.push(node[buf.edge[i].t]);
            }
            //cout<<buf.no<<endl;
        }
    }
    for(int i=1;i<=n;i++){
        int ans=node[i].dist%2;
        cout<<ans<<endl;
    }
    return 0;
}

Measured memory_bytes: 10492
#include <stdio.h>

int main (void) {
    int N, M;

    scanf("%d%d", &N, &M);

    int A[M];
    int sum = 0;
    int i = 0;

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

    if (N - sum >= 0) {
        printf("%d\n", N - sum);
    } else {
        printf("-1\n");
    }

    return 0;
}

Measured memory_bytes: 1764
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
bool a[10001];
int main() {
	fill(a, a + 10001, true);
	a[0] = false; a[1] = false;
	for (int i = 2; i <= 10000; i++) {
		if (a[i]) {
			int j = 2;
			while (i*j <= 10000) {
				a[i*j] = false;
				j++;
			}
		}
	}
	int n;
	while (cin >> n) {
		int p = 0;
		for (int i = 1; i <= n; i++) {
			if (a[i] && a[n + 1 - i]) {
				p++;
			}
		}
		cout << p << endl;
	}
}

Measured memory_bytes: 3012
#include<cmath>
#include<algorithm>
#include<cstdio>
#include<iostream>
#include<cstring>
using namespace std;
int main()
{
    int a,b,c,d,e,f,g;
    cin>>a>>b;
    c=a+b;
    d=a-b;
    e=a*b;
    f=max(c,d);
    g=max(f,e);
    cout<<g<<endl;
    return 0;
}

Measured memory_bytes: 256
n, m = map(int, input().split())
res = [0,10**5]
for i in range(m):
    l, r = map(int, input().split())
    res[0] = max(res[0], l)
    res[1] = min(res[1], r)

print(max(res[1]-res[0]+1,0))

Measured memory_bytes: 3188
#include <iostream>
using namespace std;
int main(void){
    int l, i=0, a[2];
  
    while(cin>>l){
        a[i] = l;
        i++;
    }
  
  	cout << (a[0] + a[1] - 1) / a[1];
  
  	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define TEST int t;cin>>t;for(int i=1;i<=t;i++)
#define F first
#define S second
int main()
{
	long double a,b;
	cin>>a>>b;
	cout<<floor(a*b)<<endl;
	//main();
}


Measured memory_bytes: 3748
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = ll(1e12);
const ll mod = ll(1e9) + 7;
const double pi = acos(-1);
#define rep0(i,n) for(ll (i) = 0; (i) < (n); ++(i))
#define rrep0(i,n) for(ll (i) = (n) - 1; (i) >= 0; --(i))
#define rep1(i,n) for(ll (i) = 1; (i) <= (n); ++(i))
#define rrep1(i,n) for(ll (i) = (n); (i) >= 1; --(i))
#define nfor(i,a,b) for(ll (i) = (a); (i) < (b); ++(i))
#define pf(x) cout << (x) << endl
#define all(x) (x).begin(),(x).end()
#define yes pf("Yes")
#define no pf("No")

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

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

ll factorial(ll n){
    ll t = 1;
    rep1(i, n){
        t *= i;
        t %= mod;
    }
    return t;
}

ll power(ll a, ll b){
    a %= mod;
    if(b == 0){
        return 1;
    }
    ll ans = power(a, b / 2);
    ans = ans * ans % mod;
    if(b % 2 == 1){
        ans = ans * a % mod;
    }
    return ans;
}

ll combination(ll a, ll b){
    if((a == b) || (b == 0)){
        return 1;
    }
    if(a < b) return 0;
    ll ans = 1;
    for(ll i = 0; i < b; i++) {
        ans *= (a - i);
        ans /= (i + 1);
        ans %= mod;
    }
    return ans;
}


int main(){
    string s;
    cin >> s;
    ll dp[100001][13];
    rep0(i, 100001)rep0(j, 13)dp[i][j] = 0;
    dp[0][0] = 1;
    rep0(i, s.size()){
        if(s[i] == '?'){
            rep0(j, 13){
                rep0(k, 10){
                    dp[i + 1][(j * 10 + k) % 13] += dp[i][j];
                }
            }
        }else{
            rep0(j, 13){
                dp[i + 1][(j * 10 + s[i] - 48) % 13] += dp[i][j];
            }
        }
        rep0(j, 13)dp[i + 1][j] %= mod;
    }
    pf(dp[s.size()][5]);
    return 0;
}



Measured memory_bytes: 10624
#include <iostream>

using namespace std;

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


Measured memory_bytes: 3084
/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <list>
#include <stack>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#define   mod  998244353
#define   int  long long 
#define   ld   long double
#define   pb   push_back
#define   vi  vector<int> 
#define   dbg(x)  cerr << #x << " = " << x << '\n'
#define   sz(x)  (int)x.size()
#define   all(a) (a.begin(),a.end())
#define   ff   first
#define   ss   second
#define   pii  pair<int,int> 
#define   lcm(a,b) (a*b)/__gcd(a,b) 
using namespace std;

inline void solve(){
    int  n, x, ans = 0 ; 
    cin >> n >> x ; 
    vi a(n+1);
    for (int i=1;i<=n;i++) cin >> a[i] ; 
    int d= max(0LL,a[1]-x);
    a[1] -= d; ans += d ; 
    for (int i=2;i<=n;i++) {
        d = max(0LL,a[i]+a[i-1]-x);
        a[i] -= d;
        ans += d ; 
    }
    cout << ans << endl;
}

signed main()
{
    int n=1; // cin>>n;
    while (n--) solve();
    return 0;
}


Measured memory_bytes: 4056
#include <cstdio>
#include <iostream>
using namespace std;

const long N=51000;

int main(){
	int n, m, l;
	long s[N], t[N], e[N];
		
	//入力	
	scanf(" %d %d", &n ,&m);
	
	long count=0;
	while(1){	
		scanf(" %ld %ld %ld", &s[count], &t[count], &e[count]);
		if(s[count]==0 && t[count]==0 && e[count]==0) break;
		s[count]--;
		t[count]--;
		++count;
	}
	//printf("%ld\n", count);
	
	//計算
	scanf(" %d", &l);
	for(int i=0; i<l; ++i){
		long b[10000]; 
		long long c[10000];
		
		for(long j=0; j<n; ++j) c[j]=0; //初期化
		
		for(long j=0; j<m; ++j){
			scanf(" %ld", &b[j]);		
		}
		
		for(long j=0; j<count; ++j){
			c[s[j]] += e[j] * b[t[j]];
		}
		
		for(long j=0; j<n; ++j){
			if(j!=0) printf(" ");
			printf("%lld", c[j]);	
		}
		printf("\n");
	}	
	
	return 0;
}

Measured memory_bytes: 2532
// ABC153B.cpp
//#include "pch.h"
#include <iostream>
using namespace std;
int main()
{
	int H;
	cin >> H;
	int N;
	cin >> N;
	int ans = 0;
	int skill;
	for (int i = 0; i < N; i++)
	{
		cin >> skill;
		ans += skill;
	}
	if (ans>=H)
	{
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
//#define f(i,a,n) for(ll i=a;i<n;i++)
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)


 
int main() 
{
    fast;
    ll t=1;
    //cin>>t;
    while(t--)
    {
        ll x,n,p,q,miin=9999999999,k=0;
        cin>>x>>n;
        ll A[n],B[1000]={0},ans=99999999999;
        if(n==0)
        cout<<x;
        else
        {
        for(ll i=0;i<n;i++)
        {
            cin>>A[i];
            B[A[i]]++;
            
        }
        for(ll i=0;i<=101;i++)
        {
            if(B[i]==0)
            {
                
                //cout<<i<<" ";
                p=abs(x-i);
                //cout<<p<<" ";
                if(p<=miin)
                {
                    if(p==miin)
                    {
                    miin=p;
                    ans=min(i,ans);
                    //cout<<ans<<" ";
                    }
                    else
                    {
                        miin=p;
                        ans=i;
                    }
                }
            }
            
        }
        cout<<ans;
        }
    }
    return 0;
}

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

using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;

int main(void) {
    int n, m;
    cin >> n >> m;
    vector<P> p(m);
    vector<vector<P>> ans(n);
    rep(i, m) {
        cin >> p[i].first >> p[i].second;
        ans[p[i].first-1].push_back(P(p[i].second, i));
    }

    rep(i, n) {
        sort(ans[i].begin(),ans[i].end());
    }

    rep(i, n) {
        rep(j, ans[i].size()) {
            p[ans[i][j].second].second = j + 1;
        }
    }

    rep(i,m) {
        cout << setw(6) << setfill('0');
        cout << p[i].first;
        cout << setw(6) << setfill('0');
        cout << p[i].second << endl;;
    }
    return 0;
}


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

int main(){
int N;
  cin >> N;
  bool exist=false;
  for(int i=0;i<=N/4;i++){
    for(int j=0;j<=N/7;j++){
     if(4*i+7*j==N) {
       exist=true;
       break;
     }
    }
  }
  if(exist) cout << "Yes" << endl;
  else cout << "No" << endl;

}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define L long long
using namespace std;
int n;
bitset<4000010> f;
int main()
{
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	int i,j,k=0;
	scanf("%d",&n);
	f[0]=1;
	for(i=1;i<=n;i++)
	  {
       scanf("%d",&j);
       f|=f<<j;
       k+=j;
      }
    for(i=(k+1)/2;!f[i];i++);
    printf("%d\n",i);
	return 0;
}


Measured memory_bytes: 1664
#include<bits/stdc++.h>
#define ll long long
#define maxn 200005
#define inf 1e9
#define eps 1e-10
using namespace std;

inline int read()
{
	int x=0,w=1; char c=getchar();
	while(c<'0'||c>'9') {if(c=='-') w=-1; c=getchar();}
	while(c<='9'&&c>='0') {x=(x<<1)+(x<<3)+c-'0'; c=getchar();}
	return w==1?x:-x;
}

int n,q,d[maxn],nxt[maxn],ans[maxn],pre[maxn];
struct node{int s,t,x;}p[maxn];
struct node2{int x,id;};
set <int> s,tmp;
set <int>::iterator it1,it2;
map <int,int> mp;
vector <int> vec;

inline bool cmp(node a,node b){return a.x<b.x;}

int main()
{
	n=read(); q=read();
	for(int i=1;i<=n;i++) p[i].s=read(),p[i].t=read()-1,p[i].x=read();
	sort(p+1,p+n+1,cmp);
	for(int i=1;i<=q;i++) d[i]=read(),ans[i]=-1,s.insert(d[i]),mp[d[i]]=i;
	sort(d+1,d+q+1);
	for(int i=1;i<=n;i++)
	{
		vec.clear();
		it1=s.lower_bound(max(0,p[i].s-p[i].x));
		it2=s.upper_bound(max(0,p[i].t-p[i].x));
		//cout<<*it1<<" "<<*it2<<endl;
		if(it1==s.end()) continue;
		for(set <int>::iterator it=it1;it!=s.end()&&it!=it2;it++)
		{
			ans[mp[*it]]=p[i].x;
			vec.push_back(*it);
		}
		for(int i=0;i<vec.size();i++) s.erase(vec[i]);
	}
	for(int i=1;i<=q;i++) printf("%d\n",ans[i]);
	return 0;
}


Measured memory_bytes: 25592
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        int[] h = new int[n];
        for (int i = 0; i < n; i++) {
            h[i] = sc.nextInt();
        }

        int[] dp = new int[n];
        dp[0] = 0;
        dp[1] = Math.abs(h[1] - h[0]);
        for (int i = 2; i < n; i++) {
            int min = Integer.MAX_VALUE;
            int count = 0;
            for (int j = i - 1; j >= 0; j--) {
                if (count >= k) {
                    break;
                }
                min = Math.min(dp[j] + Math.abs(h[i] - h[j]), min);
                count++;
            }
            dp[i] = min;
        }
        System.out.println(dp[n - 1]);
    }

}


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

//vector…可変長、データの大きさに合わせてサイズを変える
//list…双方向リスト、要素を挿入、削除の多いとき
//forward_list
//array…固定長配列
//set…集合
//multiset
//bitset…2進数、固定長ビット列
//map…連想配列、キーと値を関連付ける
//multimap
//deque
//stack…FILO
//queue…FIFO
//priority_queue…格納された最大値から順に取り出す
//pair…二つの値を一組
//tuple…複数の値を一組

template<typename T>
void remove(std::vector<T>& vector, char index) {
    vector.erase(vector.begin() + index);
}

template<class T>
T ma(std::vector<T> &v) {
    T maxi = 0;
    for(auto &i:v) maxi = max(maxi, i);
    return maxi;
}

template<class T>
T mi(std::vector<T> &v) {
    T mini = 0;
    for(auto &i:v) mini = min(mini, i);
    return mini;
}

template <class T>
T pow(T x, T y, T n = numeric_limits<T>::max()) {
    if(y == 0) return 1;
    if(y % 2 == 0) return pow((x * x) % n, y / 2);
    return (x * pow(x, y - 1)) % n;
}

#define rep(i, n, m) for (int i = n; i <= m; i++)
#define Rep(i, n, m) for (int i = m; i >= 1; i--)

typedef long long ll;
typedef unsigned long long ull;

/*
int gcd(int x, int y) {
    if (x < y) swap(x, y);
    return !y ? x : gcd(x % y, y);
}
*/
int main() {
    int n;
    cin >> n;
    vector<int> W(n);
    rep(i, 0, n-1) cin >> W[i];
    int ans = 1000;

    int cnt = 0;

    rep(i, 0, n-1) {
        int l = 0, r = 0;
        rep(j, 0, cnt) {
            l += W[j];
        }
        rep(j, cnt+1, n-1) {
            r += W[j];
        }
        ans = min(ans, abs(r-l));
        cnt++;
    }
    cout << ans  << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<sstream>
#include<vector>
#include<set>
#include<map>
#include<algorithm>
#include<numeric>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<complex>
#include<cassert>

using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
#define rp(i,c) rep(i,(c).size())
#define fr(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define all(c) (c).begin(),(c).end()
#define mp make_pair
#define pb push_back
#define dbg(x) cerr<<#x<<" = "<<(x)<<endl

typedef complex<double> P;
const double INF=1e12,EPS=1e-9;

int n,m;
P d[10],dir[10]; double v[10];
P fp[1000],fv[1000];

double get(P &fp,P &fv,P &d,double v,int id){
	P dd=fp-d;
	double a=norm(fv)-v*v,b=dd.real()*fv.real()+dd.imag()*fv.imag(),
	c=norm(dd);
	if(abs(a)<EPS){
		if(abs(b)<EPS)return INF;
		double t=-c/2/b; if(t<0)return INF;
		dir[id]=(dd+fv*t)/t; return t;
	}
	double D=b*b-a*c; if(D<0)return INF;
	double t1=(-b+sqrt(D))/a,t2=(-b-sqrt(D))/a;
	if(t1<0)t1=INF; if(t2<0)t2=INF;
	double t=min(t1,t2); if(t==INF)return INF;
	dir[id]=(dd+fv*t)/t;
	return t;
}

int main()
{
	while(scanf("%d%d",&n,&m),n){
		rep(i,n)scanf("%lf%lf%lf",&d[i].real(),&d[i].imag(),v+i);
		rep(i,m)scanf("%lf%lf%lf%lf",&fp[i].real(),&fp[i].imag(),
			&fv[i].real(),&fv[i].imag());
		int ans[10]={};
		rep(i,m){
			double t[10],mnt=INF;
			rep(j,n)t[j]=get(fp[i],fv[i],d[j],v[j],j);
			rep(j,n)mnt=min(mnt,t[j]);
			rep(j,n){
				if(t[j]!=INF)d[j]+=dir[j]*mnt;
				if(t[j]==mnt)ans[j]++;
			}
		}
		rep(i,n)printf("%d%c",ans[i],i==n-1?'\n':' ');
	}
	return 0;
}

Measured memory_bytes: 964
#include <iostream>
#include <stdio.h>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
#include <set>
#include <map>
#include <deque>
#include <math.h>
#include <string>
#include <iomanip>
#include <locale>
#include <list>
#include <bitset>
#include <tuple>
using namespace std;
#define FORN(i,m,n) for(int i=(m); i<int(n); i++)
#define PRINTVEC(v) FORN(i,0,v.size()) cout<<v[i]<<" "; cout<<endl
#define PRINTMAT(m) FORN(j,0,m.size()) {PRINTVEC(m[j]);}
typedef long long ll;

const int ms = 1e5 + 5;
int n, m, k, comp[ms], cnt[ms];
vector<int> edges[ms], block[ms];

void dfs(int u, int c){
  comp[u] = c;
  cnt[c]++;
  for(int e : edges[u]) if(comp[e] == -1) dfs(e, c);
}

int main(){
  ios_base::sync_with_stdio(false); cin.tie(NULL);
  cin>>n>>m>>k;
  FORN(i,0,m){
    int a, b;
    cin>>a>>b;
    a--, b--;
    edges[a].push_back(b);
    edges[b].push_back(a);
  }
  FORN(i,0,k){
    int a, b;
    cin>>a>>b;
    a--, b--;
    block[a].push_back(b);
    block[b].push_back(a);
  }
  FORN(i,0,n) comp[i] = -1;
  int cur = 1;
  FORN(i,0,n) if(comp[i] == -1) dfs(i, cur++);
  FORN(i,0,n){
    int ans = cnt[comp[i]] - edges[i].size() - 1;
    for(int e : block[i]){
      if(comp[e] == comp[i]) ans--;
    }
    cout<<ans<<" ";
  }
  cout<<endl;
}

Measured memory_bytes: 12288
#include <iostream>
using namespace std;
int main()
{
    int n;
    cin >> n;
    int ar[n];
    for(int i = 0 ; i < n ; i++)
    {
        cin >> ar[i];
    }
    int flag = 0;
    for(int i = 0 ; i < n ; i++)
    {
        if(ar[i] % 2 == 0){
            if(ar[i] % 3 != 0 && ar[i] % 5 != 0){cout << "DENIED\n"; flag = 1;break;}
        }
    }
    if(flag == 0)
        cout << "APPROVED\n";
}


Measured memory_bytes: 256
import java.util.*;
public class Main {

  public static void main (String[] args) {
	
    Scanner sc = new Scanner(System.in);
    
    int N = sc.nextInt();
    
    Integer[] p = new Integer[N];
    
    for (int i = 0; i < N; i++) {
      p[i] = sc.nextInt();
    }

    sc.close();

    Integer[] p_ = p.clone();

    Arrays.sort(p);

    int count = 0;

    for (int i = 0; i < N; i++){
      if (p[i] != p_[i]){
        count++;
      }
    }

    if (count == 0 || count == 2){
      System.out.println("YES");
    } else {
      System.out.println("NO");
    }
    
  }

}

Measured memory_bytes: 23124
#include<iostream>

using namespace std;

int main() {

    string t;
    cin >> t;

    int len = t.length();
    int tmp,count = 0;
    for (int i = 0; i < (len / 2); ++i) {
        tmp = (len - i) - 1;
        if (t[i] != t[tmp]) {
            ++count;
        }
    }
    cout << count;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int s[366][26];
int heu = 1;
int smax[400];
int main() {

	int d;
	cin >> d;
	int c[26];
	int i, j, j2;
	for (i = 0; i < 26; i++) {
		cin >> c[i];
	}
	int smaxsum = 0;
	for (i = 0; i < d; i++) {
		for (j = 0; j < 26; j++) {
			cin >> s[i][j];
			if (s[i][j] > smax[i]) {
				smax[i] = s[i][j];
			}
			
		}
		smaxsum = smaxsum + smax[i];
	}
	int last[26];
	for (i = 0; i < 26; i++) {
		last[i] = 0;
	}
	int jmax, jindex, jindex2;
	int cjlmax = 0;
	for (i = 1; i <= d; i++) {
		jmax = 0;
		for (j = 0; j < 26; j++) {
			if (cjlmax < c[j] * (i - last[j])) {
				cjlmax = c[j] * (j - last[j]);
				jmax = j;
			}

		}

		jindex = -1;
		jindex2 = -1;
		/*for (j = 0; j < 26; j++) {
			if (c[j] *(i - last[j]) > jmax) {
				jmax = c[j] *(i - last[j]);
				jindex = j;
			}
			else if (c[j] *(i - last[j]) == jmax) {
				if (s[i - 1][j] > s[i - 1][jindex]) {
					jindex = j;
				}
			}
		}*/
		if ((smax[i] < smaxsum / (d * 2)) && (smax[i] < cjlmax * 2)) {
			last[jmax] = i;
			cout << jmax + 1 << endl;
		}
		else {

			jmax = 0;
			for (j = 0; j < 26; j++) {
				for (j2 = 0; j2 < 26; j2++) {
					if (j != j2) {
						if (s[i - 1][j] + heu * c[j] * (i - last[j]) + s[i][j2] + heu * c[j2] * (i + 1 - last[j2]) > jmax) {
							jmax = s[i - 1][j] + heu * c[j] * (i - last[j]) + s[i][j2] + heu * c[j2] * (i + 1 - last[j2]);
							jindex = j;
							jindex2 = j2;
						}
					}
					else {
						if (s[i - 1][j] + heu * c[j] * (i - last[j]) + s[i][j2] + heu * c[j2] > jmax) {
							jmax = s[i - 1][j] + heu * c[j] * (i - last[j]) + s[i][j2] + heu * c[j2];
							jindex = j;
							jindex2 = j2;
						}
					}
				}
			}
			/*for (j = 0; j < 26; j++) {
				if (s[i - 1][j] + 15 * c[j] * (i - last[j]) >= jmax) {
					jmax = s[i - 1][j] + 15 * c[j] * (i - last[j]);
					jindex = j;
				}
			}*/
			last[jindex] = i;
			cout << jindex + 1 << endl;

		}

	}
	return 0;


}

Measured memory_bytes: 3676
#include<cstdio>
#include<algorithm>
#include<map>
#include<set>
#define maxn 100003
using namespace std;
inline int read(){
	bool sgn=0;
	char c=getchar();
	while((c<'0'||c>'9')&&c!='-')c=getchar();
	if(c=='-')sgn=1,c=getchar();
	int x=0;
	while(c>='0'&&c<='9'){
		x=x*10+c-'0';
		c=getchar();
	}
	return sgn?-x:x;
}
inline void write(int x){
	if(x<0){
		putchar('-');
		write(-x);
	}
	else{
		if(x>=10)write(x/10);
		putchar(x%10+'0');
	}
}
int f[maxn];
void init(int n){
	for(int i=1;i<=n;i++)f[i]=i;
}
int find(int x){
	if(x!=f[x])f[x]=find(f[x]);
	return f[x];
}
void Union(int x,int y){
	int fx=find(x),fy=find(y);
	if(fx!=fy)f[fx]=fy;
}
bool same(int x,int y){
	return find(x)==find(y);
}
int a[maxn],b[maxn],buc[maxn];
int A[maxn],B[maxn];
map<int,int> mp;
int main(){
	int n=read();
	for(int i=1;i<=n;i++){
		a[i]=read();
		a[n+1]^=a[i];
		A[i]=a[i];
	}
	for(int i=1;i<=n;i++){
		b[i]=read();
		b[n+1]^=b[i];
		B[i]=b[i];
	}
	A[n+1]=a[n+1];
	B[n+1]=b[n+1];
	sort(A+1,A+n+2);
	sort(B+1,B+n+2);
	for(int i=1;i<=n+1;i++){
		if(A[i]!=B[i]){
			write(-1);
			return 0;
		}
	}
	int ans=0,cnt=0;
	for(int i=1;i<=n+1;i++){
		if(a[i]!=b[i]&&i!=n+1)ans++;
		if(i==n+1&&!ans){
			write(0);
			return 0;
		}
		if(a[i]!=b[i]||i==n+1){
			if(!mp.count(a[i]))mp[a[i]]=++cnt;
			if(!mp.count(b[i]))mp[b[i]]=++cnt;
		}
	}
	init(cnt);
	for(int i=1;i<=n+1;i++){
		if(a[i]!=b[i])Union(mp[a[i]],mp[b[i]]);
	}
	for(int i=1;i<=cnt;i++){
		if(i==find(i))ans++;
	}
	write(ans-1);
	return 0;
}

Measured memory_bytes: 8448
local n = io.read("*n")
local a, b = {}, {}
for i = 1, n do a[i] = io.read("*n") end
for i = 1, n do b[i] = io.read("*n") end
local asum, bsum = 0, 0
local c = {}
for i = 1, n do
  c[i] = b[i] - a[i]
  asum, bsum = asum + a[i], bsum + b[i]
end
table.sort(c)
local cnt = bsum - asum
for i = 1, n do
  if c[i] < 0 then
    cnt = cnt + c[i]
  elseif 0 < c[i] then
    if c[i] % 2 == 1 then cnt = cnt - 1 end
  end
end
print(0 <= cnt and "Yes" or "No")


Measured memory_bytes: 1144
k = int(input())
print([1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51][k - 1])

Measured memory_bytes: 3060
//ABC071C
#include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <numeric>
#include <math.h>
#include <stdio.h>
#include <climits>
#include <cfloat>
#include <string>
using namespace std;

int main(){
	long long int n;
	cin >> n;
	vector<long long int> a(n);
	for(int i=0;i<n;i++){
		cin >> a.at(i);
	}
	sort(a.begin(),a.end());
	vector<long long int> l(n);
	int i = n-1;
	int j = 0;
	while(i>0){
		if(a.at(i) ==  a.at(i-1)){
			l.at(j) = a.at(i);
			j++;
			i -= 2;
		}else{
			i--;
		}
		if(j == 2){
			long long int s = l.at(0)*l.at(1);
			cout << s << endl;
			return 0;
		}
	}
	cout << "0" << endl;
	return 0;
}


Measured memory_bytes: 1792
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
A = LIST()

cnt = [0] * (max(A)+2)
cnt[0] = 3
ans = 1
for a in A:
	ans *= cnt[a]-cnt[a+1]
	cnt[a+1] += 1
	ans %= mod
print(ans)


Measured memory_bytes: 15992
#include <stdio.h>
#include <stdlib.h>
int main(){
	int N;
	int min,tmp;
	scanf("%d",&N);
	int *L;
	L = (int *)malloc(sizeof(int)*N);
	for(int i=0;i<N;i++){
		scanf("%d",&L[i]);
	}

	for(int i=0;i<N;i++){
		for(int j=i;j<N;j++){
			if(L[i]<L[j]){
				min = L[i];
				L[i]=L[j];
				L[j] = min;
			}
		}
	}

	for(int i=1;i<N;i++){
		tmp += L[i];
	}

	if(L[0]<tmp){
		printf("Yes\n");
	}else{
		printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())

using namespace std;
typedef long long ll;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const int INF = 1001001001;
const long long INFL = (1LL<<60);
const double eps = (1e-9);


class SegmentTree {
  int n;             // 最下段のノード数
  vector<int> node;

 public:
  SegmentTree(const vector<int>& v) {
    int sz = v.size();
    n = 1;
    while (n < sz) n *= 2;   // N: 最下段の横幅
    node.resize(2 * n - 1, 0);  // 0 で初期化

    // 最下段に値を挿入
    rep(i, sz) node[(n - 1) + i] = v[i];

    // 最下段以外を更新していく
    for (int i = n - 2; i >= 0; i--) {
      node[i] = compare(node[i * 2 + 1], node[i * 2 + 2]);
    }
  }

  void update(int i, int x) {
    i += n - 1;  // i 番目の葉のノード番号
    node[i] = x;
    while (i > 0) {
      i = (i - 1) / 2;  // ノード i の親ノードの番号に変える
      node[i] = compare(node[i * 2 + 1], node[i * 2 + 2]);  // 左右の子の OR を計算し直す
    }
  }

  // [a, b) の区間に対するクエリについてノード k (区間 [l, r) 相当) が答える
  // 注意 [a, b) は半区間なので 区間 [m, n] の最小値を求めたい場合は find(m, n+1) とする
  int find(int a, int b, int k = 0, int l = 0, int r = -1) {
    if (r < 0) r = n;

    if (r <= a || b <= l) {
      return 0;  // 区間がかぶらない場合は 0 を返す
    }
    if (a <= l && r <= b) {
      return node[k];  // ノード k の担当範囲がクエリ区間 [a, b) に完全に含まれる
    } else {
      int c1 = find(a, b, 2 * k + 1, l, (l + r) / 2);  // 左の子に値を聞く
      int c2 = find(a, b, 2 * k + 2, (l + r) / 2, r);  // 右の子に値を聞く
      return compare(c1, c2);
    }
  }

 private:
  //
  int compare(const int& a, const int& b) {
    return (a | b);
  }
};

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

  int n;
  cin >> n;
  string s;
  cin >> s;
  vector<int> c(n);
  rep(i, n) {
    c[i] = 1 << (s[i] - 'a' + 1);
  }
  SegmentTree seg(c);
  int q;
  cin >> q;

  rep(i, q) {
    int x;
    cin >> x;
    if (x == 1) {
      int pos;
      char ch;
      cin >> pos >> ch;
      pos--;
      seg.update(pos, (1 << (ch - 'a' + 1)));
    } else {
      int l, r;
      cin >> l >> r;
      l--; r--;
      int tmp = seg.find(l, r + 1);
      bitset<32> bs(tmp);
      cout << bs.count() << endl;
    }
  }

  return 0;
}


Measured memory_bytes: 6940
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        while(scan.hasNext()){
        	double[] point = new double[8];
        	for(int i = 0;i < 8;i++){
        		point[i] = scan.nextDouble();
        	}
        	double a = (point[0] - point[2])*(point[4] - point[6]);;
        	double b = -(point[1] - point[3])*(point[5] - point[7]);
        	if(a == b){
        		System.out.println("YES");
        	}else{
        		System.out.println("NO");
        	}
        }
    }
}

Measured memory_bytes: 23284
import java.util.*;
import java.lang.*;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		String[] S = new String[N];
		for( int i=0; i<N; i++ ){
			S[i] = sc.next();
		}
		Arrays.sort(S);
		int count = 1;
		int countAns = 1;
		int maxium = 0;
		if( N == 1 ){
			System.out.println(S[0]);
		}else{

		for( int i=0; i<N-1; i++ ){
			if( S[i].equals(S[i+1]) ){
				count++;
			}
			if( !(S[i].equals(S[i+1])) || i==N-2 ){
				maxium = Math.max(count,maxium);
				count = 1;	
			}
		}
		for( int i=0; i<N-1; i++ ){
			if( S[i].equals(S[i+1]) ){
				countAns++;
			}
			if( !(S[i].equals(S[i+1])) || i==N-2 ){
				if( countAns==maxium ){
					System.out.println(S[i]);
				}
				countAns = 1;	
			}
			if( !(S[i].equals(S[i+1])) && maxium==1 && i==N-2 ){
				System.out.println(S[N-1]);              
            }              
		}

		}
	}
}

Measured memory_bytes: 72392
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <utility>
#include <functional>
#include <bitset>
#include <cstdint>

using namespace std;
using lli = long long int;
using i64 = int64_t;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0) 
{ v = vector<T>(n+o); for (lli i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> void read_n(T a[], size_t n, size_t o = 0)
{ for (lli i=o; i<n+o; ++i) cin >> a[i]; }
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs

i64 a[5], k;
int main() {
  read_n(a, 5); cin >> k;
  bool res = false;
  if (a[4] - a[0] > k) res = true;

  auto ans = res ? ":(" : "Yay!";
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <unordered_map>
#include <functional>
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cassert>
//#include <chrono>
//#include <random>
#include <bitset>
#include <cstdio>
#include <vector>
#include <string>
#include <ctime>
#include <tuple>
#include <stack>
#include <queue>
#include <cmath>
#include <ctime>
#include <list>
#include <map>
#include <set>

using namespace std;

const int N = 100005;
const int inf = 1000 * 1000 * 1000;
const int mod = 1000 * 1000 * 1000 + 7;

int n;
string s;

int q[30];

int main() {
	//mt19937 myrand(chrono::steady_clock::now().time_since_epoch().count());
	cin >> n >> s;
	for (int i = 0; i < n; i++) {
		int x = s[i] - 'a';
		q[x]++;
	}
	int pat = 1;
	for (int i = 0; i < 26; i++) {
		pat = pat * 1ll * (q[i] + 1) % mod;
	}
	pat = (pat + mod - 1) % mod;
	cout << pat << endl;
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define ll long long
#define rgi register int
#define rgl register long long
#define il inline

const int N = 2e5 + 10;

int n, tot, cnt, num[N], nxt[N], vis[N];
int a[N], sortA[N], rankA[N];
int b[N], sortB[N], posB[N];

il int read() {
	rgi x = 0, f = 0, ch;
	while(!isdigit(ch = getchar())) f |= ch == '-';
	while(isdigit(ch)) x = (x << 1) + (x << 3) + (ch ^ 48), ch = getchar();
	return f ? -x : x;
}

int main() {
	n = read();
	for(rgi i = 1; i <= n; ++i)	a[i] = num[++tot] = read();
	for(rgi i = 1; i <= n; ++i)	b[i] = num[++tot] = read();
	
	std::sort(num + 1, num + tot + 1);
	tot = std::unique(num + 1, num + tot + 1) - (num + 1);
	for(rgi i = 1; i <= n; ++i)	a[i] = std::lower_bound(num + 1, num + tot + 1, a[i]) - (num + 1) + 1;
	for(rgi i = 1; i <= n; ++i)	b[i] = std::lower_bound(num + 1, num + tot + 1, b[i]) - (num + 1) + 1;
	//Discrete
	
	for(rgi i = 1; i <= n; ++i)	sortA[i] = a[i];
	for(rgi i = 1; i <= n; ++i)	sortB[i] = b[i];
	std::sort(sortA + 1, sortA + n + 1);
	std::sort(sortB + 1, sortB + n + 1);
	//Smallest Permutation
	
	for(rgi i = 1; i <= n; ++i)	if(sortA[i] > sortB[i]) {
		puts("No");
		return 0;
	}
	
	for(rgi i = 1; i <= n - 1; ++i)	if(sortA[i + 1] <= sortB[i]) {
		puts("Yes");
		return 0;
	}
	//Exclusion
	
	for(rgi i = 1; i <= n; ++i)	posB[b[i]] = i;
	//pos in b[]
	
	for(rgi i = 1; i <= n; ++i) rankA[sortA[i]] = i;
	//rank in a[]
	
	for(rgi i = 1; i <= n; ++i) {
		nxt[i] = posB[sortB[rankA[a[i]]]];
	}
	//Add edges
	
	for(rgi i = 1; i <= n; ++i) {
		if(!vis[i]) {
			int cur = i;
			do {
				vis[cur] = 1;
				cur = nxt[cur];
			} while(!vis[cur]); 
			cnt++;
		}
	}
	
	puts(cnt == 1 ? "No" : "Yes");
	
	return 0;
}


Measured memory_bytes: 6656
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define EACH(i, c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s, e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

//#define LOCAL 0
//#ifdef LOCAL
//#define DEBUG(s) cout << (s) << endl
//#define dump(x)  cerr << #x << " = " << (x) << endl
//#define BR cout << endl;
//#else
//#define DEBUG(s) do{}while(0)
//#define dump(x) do{}while(0)
//#define BR
//#endif


//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 30)
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007
//ここから編集する
#define F "Female"
#define M "Male"
#define V "Vacant"
//#define F "F"
//#define M "M"

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

    int N;
    cin >> N;
    int L = 0;
    int R = N - 1;
    int mid;
    int said;
    string A;
    cout << 0 << endl;
    said = 0;
    cin >> A;
    if (A == V) {
        return 0;
    }

    mid = R / 2;
    if (mid % 2 == 0) mid--;

    string B;
    cout << mid << endl;
    said = mid;
    cin >> B;

    if (B == V) {
        return 0;
    } else {
        if (A != B) {
            A = B;
            L = mid;
//            R = N - 1;
        } else {
//            L = 1;
            R = mid - 1;
        }
    }


    while (true) {
        if (L == R) {
            mid = L;
        } else if (L + 1 == R) {
            cout << L << endl;
            said = L;
            cin >> B;
            if (B == V) {
                return 0;
            } else {
                cout << R << endl;
                said = R;
                cin >> B;
                return 0;
            }
        } else {
            if (L == mid) {
                mid = (L + R) / 2;
                if ((mid - L) % 2 == 0) {
                    mid++;
                }
            } else {
                mid = (L + R) / 2;
                if ((mid - L) % 2 == 0) {
                    mid--;
                }
            }


        }

        cout << mid << endl;
        said = mid;
        cin >> B;

        if (B == V) {
            return 0;
        } else {
            if (A != B) {
                L = mid;
//                R = R - 1;
                A = B;
            } else {
//                L = L + 1;
                R = mid - 1;
            }

        }
    }


    return 0;
}


Measured memory_bytes: 852
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a, b, c;
  cin >> a >> b >> c;
  if (a >= b && a >= c) {
    cout << 10 * a + b + c << endl;
  } else if (b > a && b >= c) {
    cout << 10 * b + a + c << endl;
  } else {
    cout << 10 * c + a + b << endl;
  }
}

Measured memory_bytes: 256
/*
 *
 * Copyright(c) 2017 Taikai Takeda <297.1951@gmail.com> All rights reserved.
 *
 */
//include
//------------------------------------------
#include <bits/stdc++.h>
using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long ll;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for(int i=(b-1);i>=(a);--i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int MOD = 1000000007;

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))


//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n;

    cin >> n;

    VI a(n);

    REP(i, n)
        cin >> a[i];

    int k = 0;
    sort(a.begin(), a.end());

    REP(i, n-1){
        if(a[i] == a[i+1])
            k++;
    }

    int ans = n - k;

    if (k & 1)
        ans -= 1;

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <string>
using namespace std;

int main(){
	int k;
	string s;
	cin >> s >> k;
	for(int i = 0;i < s.length();i++){
		if(s[i] != 'a' && 'z' - s[i] + 1 <= k){
			k -= 'z' - s[i] + 1;
			s[i] = 'a';
		}
	}
	s[s.length() - 1] += k % 26;
	if(s[s.length() - 1] > 'z') s[s.length() - 1] -= 26;
	cout << s << endl;
}

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

public class Hoge{
static int time_ = 0;
static void Main()
{
	//??\?????????
	var n = int.Parse( Console.ReadLine());
	var dic = new Dictionary<int, Point>();
	for (int i = 0; i < n; i++)
	{
		var numbers = Console.ReadLine().Split(' ');
		var one = int.Parse( numbers[0]);
		var two = int.Parse( numbers[1]);
		dic.Add(one, new Point(){u = one,
							dk = two,
							uArray = numbers.Skip(2).Take(two).Select (nu => int.Parse(nu)).ToArray(),
							visit = false
							});
	}
	
	//????????????Point???visit==true??????????????§??°?????????
	while(!dic.All (d => d.Value.visit == true)){
		var target = dic.First(d => d.Value.visit == false).Value;
		DFS(dic, target);
	}
	dic.ToList().ForEach(d =>
	{
		Console.WriteLine("{0} {1} {2}", d.Value.u, d.Value.findtime, d.Value.finishtime);
	});
}

public class Point{
	public int u{get;set;}
	public int dk{get;set;}
	public int[] uArray{get;set;}
	public bool visit{get;set;}
	public int findtime{get;set;}
	public int finishtime{get;set;}
}

public static void DFS(Dictionary<int, Point> dic, Point point)
{
	point.visit = true;
	point.findtime = ++time_;
	point.uArray.ToList().ForEach(u=>{
		if(!dic[u].visit){
			DFS(dic, dic[u]);
		}
	});
	point.finishtime = ++time_;
}
}

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

using namespace std;
 
int main() {
    int K, X;
    cin >> K >> X;
  for(int i = 0; i <= 2*K - 2 ; i++){
        int ans = X - K +1 + i; 
        cout << ans << endl;
    } 

}


Measured memory_bytes: 256
using System;
class three
{
    static void Main()
    {
        string a = Console.ReadLine();
        int b = int.Parse(a);
        bool[] c = new bool[b];
        for (int i = 0; i < b; i++)
        {
            string d = Console.ReadLine();
            string[] e = d.Split(' ');
            int[] f = new int[3];
            for(int j = 0; j < 3; j++)
            {
                f[j]=int.Parse(e[j]);
            }
            if (f[0] > f[1])
            {
                int w = f[0];
                f[0] = f[1];
                f[1] = w;
            }
             if (f[1] > f[2])
            {
                int w = f[1];
                f[1] = f[2];
                f[2] = w;
            }
            if (f[0] > f[2])
            {
                int w = f[0];
                f[0] = f[2];
                f[2] = w;
            }
            if (f[0] > f[1])
            {
                int w = f[0];
                f[0] = f[1];
                f[1] = w;
            }
            if (f[1] > f[2])
            {
                int w = f[1];
                f[1] = f[2];
                f[2] = w;
            }
            if (f[0] * f[0] + f[1] * f[1] == f[2] * f[2])
            {
                c[i] = true;
            }
            
        }
        for (int k = 0; k < b; k++)
            {
                if (c[k])
                {
                    Console.WriteLine("YES");
                }
                else
                {
                    Console.WriteLine("NO");
                }
            }
    }
}

Measured memory_bytes: 8844
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
 
 
namespace AtCoder
{
	class Program
	{
		static void Main(string[] args)
		{
			int[] arr = Console.ReadLine().Trim().Split(' ').Select(hogehoge => int.Parse(hogehoge)).ToArray<int>();
 
			int n = arr[0];
			int k = arr[1];
 
			List<long> list = Console.ReadLine().Trim().Split(' ').Select(hogehoge => long.Parse(hogehoge)).ToArray<long>().ToList<long>();
 
			list.Sort();
 
			long sum = 0;
 
			for (int i = 0; i < n - k; i++)
			{
				sum += list[i];
			}
 
 
			Console.WriteLine(sum);
		}
 
	}
 
}

Measured memory_bytes: 49340
n = int(input())

c = 0

import math
def is_prime(a):
    if a == 1: return False

    for k in range(2, int(math.sqrt(a)) + 1):
        if a % k == 0:
            return False

    return True

while(c == 0):
    if is_prime(n):
        print(n)
        break
    else:
        n += 1

Measured memory_bytes: 38384
c = raw_input().split()
d =raw_input().split()
 
 
a = list(c[0])
b = list(d[0])
 
 
size= len(a)
bsize = len(b)
 
numsum = 0
numsummax =0
 
for i in range(size): 
    numsum = 0
    for j in range(size): 
        
 
            
        if a[j] == b[(i+j)%size]: 
 
            numsum = numsum +1
            
        else:
            numsum = 0
            
        
    if numsummax<numsum:
            numsummax = numsum
 
if size == bsize and numsummax == size: 
    print "Yes" 
else: 
    print "No"

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

int main(){
  int m,f,b;
  cin >> m >> f >> b;
  if(b <= m) cout << '0' << endl;
  else if(b > (m + f)) cout << "NA" << endl;
  else cout << b - m << endl;

  return 0;
}



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

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root = NIL;

Node treeMinimum(Node x){


}

Node treeSearch(Node u, int k){
  Node i=u;
  while(i!=NIL){
    if(i->key==k)return i;
    else if(i->key<k)i=i->right;
    else i=i->left;
    
  }
  return NIL;
}

Node treeSuccessor(Node x){


}

void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y



}

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x!=NIL){
    y=x;
    if(z->key<x->key)x=x->left;
    else x=x->right;
  }
  z->parent=y;
  if(y==NIL)root=z;
  else if(z->key<y->key)y->left=z;
  else y->right=z;
  
}

void inorder(Node u){
  if(u==NIL)return;
  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);
}

void preorder(Node u){
  if(u==NIL)return;
  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);
}


int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    }
  }

  return 0;
}

Measured memory_bytes: 19364
#include <iostream>
#include <vector>
#include <array>
#include <deque>
#include <stack>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>
#include <iomanip>

using namespace std;
using ll=long long int;

int main() {
    int n, m, c;
    cin >> n >> m >> c;
    vector<int> b(m);
    for (auto &e: b) cin >> e;

    int ans = 0;
    for (int i = 0; i < n; ++i) {
        int p = c;
        for (int j = 0; j < m; ++j) {
            int a;
            cin >> a;
            p += b[j] * a;
        }
        if (p > 0) ++ans;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256