akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define rep(i,s,n) for (int i = (ll)s; i < (ll)n; i++)
#define rrep(i,n,e) for (int i = (ll)n-1; i >= (ll)e; i--)
#define ll long long
#define ld long double
#define pb push_back
#define eb emplace_back
#define All(x) x.begin(), x.end()
#define Range(x, i, j) x.begin() + i, x.begin() + j
#define lbidx(x, y) lower_bound(x.begin(), x.end(), y) - x.begin()
#define ubidx(x, y) upper_bound(x.begin(), x.end(), y) - x.begin()
#define llbidx(x, y, z) lower_bound(x.begin(), x.end(), z) - lower_bound(x.begin(), x.end(), y) // 二要素間の距離
// #define M_PI 3.14159265358979323846 // CFでは定義しておく必要あり
#define deg2rad(deg) ((((double)deg)/((double)360)*2*M_PI))
#define rad2deg(rad) ((((double)rad)/(double)2/M_PI)*(double)360)
#define Find(set, element) set.find(element) != set.end()
#define Decimal(x) cout << fixed << setprecision(10) << x << endl; // 小数点を10桁まで表示
// debug用
#define PrintVec(x) for (auto elementPrintVec: x) { cout << elementPrintVec << " "; } cout << "\n";
#define debug(x) cerr << #x << ": " << (x) << "\n";
#define endl "\n"
// gcj print用
#define Case(x) printf("Case #%d: ", x);

typedef pair<int, int> PI;
typedef pair<ll, ll> PLL;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<vector<int>>> vvvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<int>>> vvvl;
typedef vector<PI> vpi;
typedef vector<vector<PI>> vvpi;
typedef vector<vector<vector<PI>>> vvvpi;
typedef vector<PLL> vpl;
typedef vector<vector<PLL>> vvpl;
typedef vector<vector<vector<PLL>>> vvvpl;

int POWINT(int x, int n) {
  int ret = 1;
  while (n > 0) {
    if (n & 1) ret *= x;
    x *= x;
    n >>= 1;
  }
  return ret;
};

ll POWLL(ll x, int n) {
  ll ret = 1;
  while (n > 0) {
    if (n & 1) ret *= x;
    x *= x;
    n >>= 1;
  }
  return ret;
};

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;
};

void print() {
  cout << endl;
};

template <class T>
void print(vector<T> &vec) {
  for (auto& a : vec) {
    cout << a;
    if (&a != &vec.back()) cout << " ";
  }
  cout << endl;
};

template <class T>
void print(vector<T> &vec, ll k){
   ll n = vec.size();
   k = min(k, n);
   rep(i, 0, k-1) cout << vec[i] << " ";
   cout << vec[k-1] << endl;
};

template <class T>
void print(vector<vector<T>> &df) {
  for (auto& vec : df) {
    print(vec);
  }
};

template<class T, class U>
void print(pair<T,U> &p){
  cout << p.first << " " << p.second << "\n";
};

vi towers(999);
void init() {
  towers[0] = 1;
  rep(i, 1, 1000) {
    towers[i] = towers[i-1]+i+1;
  }
};

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

  int a, b; cin >> a >> b;
  init();
  int x = -1;
  rep(i, 0, 999) {
    if (towers[i] - a == towers[i+1] - b) {
      x = towers[i] - a;
      if (x >= 0) break;
    }
  }

  cout << x << endl;

  return 0;
};


Measured memory_bytes: 256
inf = 10**20
H, W = map(int, input().split())
A = []
for i in range(H):
    a = list(map(int, input().split()))
    #a.append(sum(a))
    A.append(a)
#aH = []
#for j in range(W):
#    a = 0
#    for i in range(H):
#        a += A[i][j]
#    aH.append(a)
#A.append(aH)
        
def cost(A, i, j):
    c = 0
    for k in range(H):
        for l in range(W):
            if (k == i or l == j):
                pass
            else:
                c += min(abs(i-k), abs(j-l))*A[k][l]
    return c
c1 = inf
for i in range(H):
    for j in range(W):
        c1 = min(c1, cost(A, i, j))
print(c1)

        


Measured memory_bytes: 5604
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cstdio>
#include <cmath>
#include <cstring>

#define ll long long
#define scani(x) scanf("%i", &x)
#define scanll(x) scanf("%I64d", &x)
#define scanfl(x) scanf("%f", &x)
#define scanch(x) scanf("%c", &x)
#define scans(x) scanf("%s", x);
#define printi(x) printf("%i", x);
#define printll(x) printf("%I64d", x);
#define printfl(x) printf("%f", x);
#define printch(x) printf("%c", x);
#define prints(x) printf("%s", x);
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define INFI (1 << 29)
#define INFL (1LL << 62)
#define sz(x) int(x.size())
#define fi first
#define se second
#define forn(i, n) for(ll i = 0; i < n; i++)
#define for1(i, n) for(ll i = 1; i <= n; i++)
#define ford(i, n) for(ll i = (n - 1); i >= 0; i--)
#define fori(i, n) for(ll i = n; i >= 1; i--)
#define fore(i, l, r) for(ll i = l; i <= r; i++)

using namespace std;

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

	ll n, a, b;

	cin >> n >> a >> b;

	cout << (ll)min(b, (n * a)) << "\n";

    return 0;
}


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

int main() {
    int n, m;
    cin >> n >> m;

    int a[100][100];
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            cin >> a[i][j];
        }
    }

    int b[100];
    for (int i = 0; i < m; i++) {
        cin >> b[i];
    }

    for (int i = 0; i < n; i++) {
        int c = 0;
        for (int j = 0; j < m; j++) {
            c += a[i][j] * b[j];
        }
        cout << c << endl;
    }

    return 0;
}


Measured memory_bytes: 3160
#include<iostream>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<algorithm>
#include<map>
#include<stack>
#include<queue>  
#include<vector>
#define ll long long
using namespace std;
 
struct Edge{
	int from,to;
	ll dist;
	Edge(int u,int v,ll d):from(u),to(v),dist(d){}
};
vector<int>G[100005];
vector<Edge>edges;
int flag=1,s;
ll d[100005];
int done[100005];
int ind[100005],ind2[100005];

void dfs(int u){
	if (flag==0) return;
	done[u]=1;
	for (int i=0;i<G[u].size();i++){
		if (flag==0) return;
		Edge& e=edges[G[u][i]];
		if (!done[e.to]){
			d[e.to]=d[e.from]+e.dist;
			dfs(e.to);
		}else{
			if (d[e.to]!=d[u]+e.dist){
				flag=0;
				return;
			}
		}
	}
}

void is_loop(int u){
	if (flag==0) return;
	done[u]=1;
	for (int i=0;i<G[u].size();i++){
		if (flag==0) return;
		Edge& e=edges[G[u][i]];
		if (done[e.to]==0){
			is_loop(e.to);
		}
		else if (done[e.to]==1){
			flag=0;
			return;
		}
	}	
	done[u]=2;
}

int main(){
	int n,m;
	scanf("%d%d",&n,&m); 
	for (int i=0;i<m;i++){
		int l,r,d;
		scanf("%d%d%d",&l,&r,&d);
		edges.push_back(Edge(l,r,d));
		G[l].push_back(i);
		ind[r]++;
	}
	
	for (int i=1;i<=n;i++){
		if (flag==0) break;
		if (!done[i]) is_loop(i);
	}	
	
	
	for (int i=1;i<=n;i++){
		if (flag==0) break;
		if ((!G[i].empty())&&ind[i]==0){
			s=i;
			memset(d,0,sizeof(d));
			memset(done,0,sizeof(done));
			dfs(s);
		}
	}
	if (flag) cout<<"Yes";
	else cout<<"No";
}

Measured memory_bytes: 13552
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			char[] s = scanner.nextLine().toCharArray();
			int count1 = 0, count2 = 0;
			char s1, s2;
			for (int i = 0; i < s.length; i++) {
				if (i % 2 == 0) {
					s1 = '0';
					s2 = '1';
				} else {
					s1 = '1';
					s2 = '0';
				}
				if (s[i] != s1) {
					count1++;
				}
				if (s[i] != s2) {
					count2++;
				}
			}
			System.out.println(Math.min(count1, count2));
		}
	}
}


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

int times(int b,int k){
	int i=0;
	while(b<k){
		b*=2;
		i++;
	}
	return i;
}
int main(){
	int n,k;
	cin >>n>>k;
	vector<long double> p(n);
	rep(i,n){
		int t = times(i+1,k);
		p[i] = 1000*(1/(long double)n) * (long double)1/pow(2,t);
	}
	long double ans=0;
	rep(i,n)
	{
		ans+=p[i]/1000;
	}
	//cout <<ans<<endl;
	printf("%.15Lf",ans);
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i < (n); i++)
#define lower(s) transform(s.begin(), s.end(), s.begin(), ::tolower)
using namespace std;
using ll = long long;
int INF = 1001001001;
ll m = 1000000007;

int main() {
  int n;
  cin >> n;
  vector<ll> a(n);
  rep(i, n) {
    cin >> a[i];
  }
  ll sum = 0;
  ll ans = 0;
  rep(i, n) sum += a[i];
  rep(i, n-1) {
    sum -= a[i];
    ans += ((a[i] % m) * (sum % m));
    ans %= m;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 4812
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<queue>
#include<cmath>
#include<map>
#include<set>
using namespace std;
const int INF = 1 << 29;
const double EPS = 1e-9;

typedef long long ll;

#define SORT(c) sort((c).begin(),(c).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)

int N;

int dp[1005];
long mod = 1e9 + 7;

int main(int argc, char * argv[])
{
    ios::sync_with_stdio(false);
    cin >> N;

    for (int i = 2; i <= N; i++) {
        int val = i;
        for (int j = 2; j <= i; j++) {
            while (val % j == 0) {
                dp[j]++;
                val /= j;
            }
        }
    }

    long long ret = 1;
    rep(i,N+1) {
        if (dp[i] != 0) {
            ret = (ret * (dp[i] + 1)) % mod;
        }
    }

    cout << ret << endl;


    return 0;
}




Measured memory_bytes: 256
h,w=map(int,input().split())
g=[]
for i in range(h):
    g.append(list(input()))
q=[]
v=[[0 for i in range(w)] for j in range(h)]
for i in range(h):
    for j in range(w):
        if g[i][j]=='#':
            q.append([i,j])
            v[i][j]=1
ans=0
while len(q)>0:
    tmp=[]
    for i in q:
        a=i[0]
        b=i[1]
        if a==0:
            hi=[1]
        elif a==h-1:
            hi=[-1]
        else:
            hi=[1,-1]
        if h==1:
            hi=[]
        if b==0:
            wi=[1]
        elif b==w-1:
            wi=[-1]
        else:
            wi=[1,-1]
        if w==1:
            wi=[]
        for c in hi:
            if v[a+c][b]==0:
                tmp.append([a+c,b])
                v[a+c][b]=1
        for d in wi:
            if v[a][b+d]==0:
                tmp.append([a,b+d])
                v[a][b+d]=1
    q=tmp
    ans+=1
print(ans-1)


Measured memory_bytes: 178408
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cassert>

using namespace std;

#define forsn(i,s,n) for(int i = (s);i < (int)(n);i++)
#define forn(i,n) forsn(i,0,n)
#define sq(x) ((x)*(x))
#define edge(x,y,c) edges[x].push_back({y,c}), tot++

typedef long long int tint;

int tot = 0;
vector<vector<pair<int,int>>> edges;
void f(int size, int from) {
	if (size <= 1) return;
	//~ if (from >= 20) assert(false);
	if (size % 2) {
		edge(from, 21, size - 1);
		f(size - 1, from);
	} else {
		edge(from, from + 1, 0);
		edge(from, from + 1, size / 2);
		f(size / 2, from + 1); 
	} 
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	edges = vector<vector<pair<int,int>>>(22, vector<pair<int,int>>());
	
	int l; cin >> l;
	f(l, 1);
	
	assert(tot <= 60);
	
	bool twentyOne = false;
	set<int> nonempty = {1}; forn(i, 21) for (auto edg : edges[i]) nonempty.insert(edg.first), twentyOne |= edg.first == 21;
	int nodes = nonempty.size() - twentyOne;
	cout << nodes << ' ' << tot << '\n';
	assert(tot <= 60);
	assert(nodes <= 20);
	forsn(i, 1, nodes + 1) for (auto edge : edges[i]) cout << i << ' ' << (edge.first == 21? nodes : edge.first) << ' ' << edge.second << '\n';
}




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

 
int main() {
   int64_t N, A, B, C, D, R;
   cin >>N >>A >>B;
   C = A+B;
   R = N/C;
   D = N - R * C;
   if(D>=A) cout << (R+1)*A << endl;
   if(D<A) cout << R*A+D << endl;


   }
   

Measured memory_bytes: 256
import sys
for line in sys.stdin:
  a,l,x=map(float,line.split())
  center=1/2*a*(l**2-(a/2)**2)**0.5
  side=1/2*l*(((l+x)/2)**2-(l/2)**2)**0.5
  print("{0:.10f}".format(center+side*2))

Measured memory_bytes: 6800
#include<bits/stdc++.h>
#define ll long long
#define inf 0x3f3f3f3f
#define fi first
#define se second
#define pb push_back
#define mkp make_pair
#define pa pair<int,int>
const int N=2e5+10;
const int mod=998244353;
using namespace std;

struct point{ int x,y;}p[N];
int xmi=inf,xma=-inf,ymi=inf,yma=-inf;
ll cross(point a,point b,point c){return 1LL*(b.x-a.x)*(c.y-a.y)-1LL*(c.x-a.x)*(b.y-a.y);}
int pnpoly(int x,int y,int n)
{
    if(x<xmi||x>xma||y<ymi||y>yma) return 0;
    int c=0;
    for(int i=0,j=n-1;i<n;j=i++)
    {
      if(p[i].x==x&&p[i].y==y) return 1;
      if(p[j].x==x&&p[j].y==y) return 1;

      if(1LL*(p[i].x-x)*(x-p[j].x)>=0&&1LL*(p[i].y-y)*(y-p[j].y)>=0&&cross(p[i],p[j],(point){x,y})==0) return 1;
      if((p[i].y>=y)!=(p[j].y>=y))
      {
        if(1LL*(x-p[i].x)*(p[j].y-p[i].y)==1LL*(p[j].x-p[i].x)*(y-p[i].y)) return 1;
        if(x<1.0*(p[j].x-p[i].x)*(y-p[i].y)/(p[j].y-p[i].y)+p[i].x) c^=1;
      }
    } 
    if(c) return 2; return 0;
}
int main()
{     
     int n; scanf("%d",&n);
     for(int i=0;i<n;i++)  
     {
       scanf("%d%d",&p[i].x,&p[i].y);
       xmi=min(xmi,p[i].x); xma=max(xma,p[i].x);
       ymi=min(ymi,p[i].y); yma=max(yma,p[i].y);
     } 
     int q; scanf("%d",&q);
     while(q--)
     {
        int x,y; scanf("%d%d",&x,&y);
        printf("%d\n",pnpoly(x,y,n));
     }
return 0;
}
/*

*/


Measured memory_bytes: 3228
import java.util.*;
import java.io.*;

public class Main {
    public static void main(String[] args) throws Exception{
        Scanner sc = new Scanner(System.in);
        int millenium = getDays(1000, 1, 1);
        int n = sc.nextInt();
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < n; i++) {
            int x = getDays(sc.nextInt(), sc.nextInt(), sc.nextInt());
            sb.append(millenium - x).append("\n");
        }
        System.out.print(sb);
    }
    
    static int[] DAYS = new int[]{20, 19, 20, 19, 20, 19, 20, 19, 20, 19};
    static int[] YEAR_DAYS = new int[]{0, 195, 195 * 2};
    static int THREE_YEARS = 195 * 2 + 200;
    static int getDays(int y, int m, int d) {
        int past = (y - 1) / 3 * THREE_YEARS;
        int mod = (y - 1) % 3;
        past += YEAR_DAYS[mod];
        if (mod == 2) {
            past += (m - 1) * 20;
        } else {
            for (int i = 0; i < m - 1; i++) {
                past += DAYS[i];
            }
        }
        past += d;
        return past;
    }
}


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

class MyClass
{
    public static void Main(string[] args)
    {
        var n = int.Parse(Console.ReadLine());
        var s = Console.ReadLine().Split().Select(int.Parse).ToArray();
        var q = int.Parse(Console.ReadLine());
        var t = Console.ReadLine().Split().Select(int.Parse).ToArray();
        Console.WriteLine(s.Distinct().Where(x => t.Contains(x)).Count());
    }
}


Measured memory_bytes: 20400
import qualified Data.ByteString.Char8 as B
import Data.List
readInt :: B.ByteString -> Int
readInt s = let Just (n,_) = B.readInt s in n
main :: IO ()
main = do
    _ <- getLine 
    params <- fmap (map (map readInt. B.words) . B.lines) B.getContents 
    let (ha_end,hb_end,hc_end) = foldl' step s0 params
        step (ha,hb,hc) [ai,bi,ci] = (ha', hb', hc')
            where ha' = ai + max hb hc
                  hb' = bi + max ha hc
                  hc' = ci + max ha hb
        s0 = (0, 0, 0)
    print (maximum [ha_end,hb_end,hc_end] :: Int)
    


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

using namespace std;

template <typename T> T gcd(T x, T y) {
  if (y == 0)
    return x;
  return gcd(y, x % y);
}

template <typename T> T lcm(T x, T y) {
  if (x == 0 || y == 0)
    return 0;
  return x / gcd(x, y) * y;
}

int main() {
  int A, B, C, X, Y;
  cin >> A >> B >> C >> X >> Y;
  C *= 2;

  long ans = 0;
  if (A + B > C) {
    int m = min(X, Y);
    ans += C * m;
    X -= m;
    Y -= m;
  }
  ans += min(A, C) * X;
  ans += min(B, C) * Y;
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
	int A, B;
	cin >> A >> B;

	if (A % 3 == 0 || B % 3 == 0 || (A + B) % 3 == 0)
	{
		cout << "Possible";
	}
	else {
		cout << "Impossible";
	}

	return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define Mod(n) n % 1000000007
const int dx[8] = {1, 0, -1, 0, -1, 1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, -1, -1, 1};

int main()
{
    string a,b;
    cin >> a >> b;
    string ans[3] = {"EQUAL","GREATER","LESS"};
    int is = 0;
    if(a.size() > b.size())
    {
        is = 1;
    }
    else if(a.size() < b.size())
    {
        is = 2;
    }
    else
    {
        for(int i = 0; i < a.size();i++)
        {
            if(a[i] > b[i])
            {
                is = 1;
                break;
            }
            if(a[i] < b[i])
            {
                is = 2;
                break;
            }
        }
    }
    cout << ans[is] << '\n';
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
long long mypow(long long x, long long y)
{
	long long result = 1;
	while (y != 0) {
		if (y%2 != 0) {
			result *= x;
			y -= 1;
		}	
		x *= x;
		y /= 2;
	}
	return result;
}
int main(void)
{
	int n, a, b, c;
	cin >> n >> a >> b >> c;
	int l[n];
	for (int i = 0; i < n; i++) {
		cin >> l[i];
	}
	int mp = 1e8;
	for (uint32_t i = 0; i < mypow(2, 2*n); i++) {
		int tmp = 0;
		int tmpa = 0, tmpb = 0, tmpc = 0;
		for (int j = 0; j < 2*n; j+=2) {
			int f = ((i>>j)&3);
			if (f == 0) {
				if (tmpa != 0)
					tmp += 10;
				tmpa += l[j/2];
			} else if (f == 1) {
				if (tmpb != 0)
					tmp += 10;
				tmpb += l[j/2];
			} else if (f == 2) {
				if (tmpc != 0)
					tmp += 10;
				tmpc += l[j/2];
			} else if (f== 3) {
			}
		}
		if (tmpa != 0 && tmpb != 0 && tmpc != 0) {
			mp = min(mp, tmp+abs(tmpa-a)+abs(tmpb-b)+abs(tmpc-c));
		}
	}
	cout << mp << endl;

	return 0;
}

Measured memory_bytes: 3636
#include <vector>
#include <list>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <queue>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <cstdio>
#include <climits>
#include <complex>
#include <cstdint>
#include <tuple>

#define M_PI       3.14159265358979323846

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(); }
inline int readInt() { int x; scanf("%d", &x); return x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<int, PII> TIII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

//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 SQ(a) ((a)*(a))
#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,s,n) for(int i=s;i<(int)n;++i)
#define REP(i,n) FOR(i,0,n)
#define MOD 1000000007

int main() {
    //cout << fixed << setprecision(8);

    int N, T; cin >> N >> T;
    int level[100010];
    REP(i, N) cin >> level[i];
    sort(level, level+N);

    LL ans = 1;
    REP(i, N) {
        ans *= (upper_bound(level, level+i, level[i]) - lower_bound(level, level+i, level[i]-T)+1);
        ans %= MOD;
    }
    cout << ans << endl;
    return 0;
}


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

int main(void) {
	int N;
	string S;
	cin >> N;
	cin >> S;

	int ans = 0;
	for (int i = 0; i <= 999; i++) {
		char c[3];
		c[0] = '0' + i/100;
		c[1] = '0' + i/10%10;
		c[2] = '0' + i%10;

		int search = 0;
		for (int pos = 0; pos < S.length(); pos++) {
			if (S[pos] == c[search]) {
				search++;
				if (search > 2) {
					ans++;
					break;
				}
			}
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<stdio.h>
 
using namespace std;
 
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define SWAP(a,b) (a += b,b = a - b,a -= b)
#define ll long long

const int MOD = 1e9 + 7;

int main()
{
    ll x;
    cin >> x;

    if(x % 11 == 0)
    {
        cout << x / 11 * 2 << endl;
    }
    else if(x % 11 >= 1 && x % 11 <= 6)
    {
        cout << x / 11 * 2 + 1 << endl;
    }
    else
    {
        cout  << x / 11 * 2 + 2 << endl;
    }


}

Measured memory_bytes: 256
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
	n,m = readline() |> split |> parseMap
	a = readline() |> split |> parseMap
	b = [a[i]>>1 for i in 1:n]
	y = gcd(a)
	f = 0
	for i in 1:n
		if b[i]%y==0
			f = 1
		end
	end
	x = lcm(b)
	if f == 0
		println((div(m,x)+1)>>1)
	else
		println(0)
	end
end

main()

Measured memory_bytes: 169872
#include<stdio.h>
int main()
{
    int n,c=0,i,j,min;
    scanf("%d",&n);
    int arr[n];
    for(i=0;i<n;i++)
    {
        scanf("%d",&arr[i]);
    }
    min=1000000;
    for(i=0;i<n;i++)
    {
        if(arr[i]<=min)
        {
            c++;
           min=arr[i];
        }
    }
    printf("%d\n",c);
    return 0;



}

Measured memory_bytes: 896
from collections import deque
h, w = map(int, input().split())
s = [input() for _ in range(h)]

INF = 1001001001
di = [-1, 0, 1, 0]
dj = [0, -1, 0, 1]

def update(i, j, x):
    global dist, s, q
    if(dist[i][j] != INF): return
    dist[i][j] = x
    q.append([i, j])

res = 0
for si in range(h):
    for sj in range(w):
        if(s[si][sj] == '#'): continue
        
        dist = [[INF for _ in range(w)] for _ in range(h)]
        q = deque()
        update(si, sj, 0)
        
        while(q):
            i, j = q.popleft()
            
            for idir, jdir in zip(di, dj):
                ni = i + idir
                nj = j + jdir
                
                if(ni<0 or ni>=h or nj<0 or nj>=w): continue
                if(s[ni][nj] == '#'): continue
                
                update(ni, nj, dist[i][j]+1)
        
        for i in range(h):
            for j in range(w):
                if(dist[i][j]==INF): continue
                res = max(res, dist[i][j])

print(res)

Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,n) for(long long i=0;i<n;++i)
#define REPP(i,m,n) for(long long i=m;i<n;++i)
#define rep(i,n) for(long long i = n-1;i>=0;--i)
#define repp(i,n,m) for(long long i = n-1; i >= m; --i)
#define ALL(N) (N.begin(),N.end())
#define de cout << "line : " << __LINE__ << " debug" << endl;
#define pb push_back
#define pq priority_queue
#define Dcout(N) cout << setprecision(20) << N << endl
constexpr int MOD = 1000000007;
constexpr int INF = 2147483647;
constexpr long long INFF = 9223372036854775807;

signed main() {
    cin.tie(0);
	ios::sync_with_stdio(false);
    int N,K,S;cin >> N >> K >> S;
    vector<int> V;
    REP(i,K){
        V.pb(S);
    }
    if(S > 100000){
        REPP(i,K,N){
            V.pb(1);
        }
    }
    else{
        REPP(i,K,N){
            V.pb(100000000);
        }
    }
    REP(i,N){
        cout << V[i] << ' ';
    }
    cout << endl;
}

Measured memory_bytes: 1912
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
typedef pair<int,int>P;
 
int main() {
  ll a;
  cin>>a;
  vector<ll>x1(4);
  for(ll i=0;i<a;i++){
    string s;
    cin>>s;
    if(s=="AC"){
      x1[0]++;
    }
    else if(s=="WA"){
      x1[1]++;
    }
    else if(s=="TLE"){
      x1[2]++;
    }
    else{
      x1[3]++;
    }
  }
  cout<<"AC"<<" "<<"x"<<" "<<x1[0]<<endl;
  cout<<"WA"<<" "<<"x"<<" "<<x1[1]<<endl;
  cout<<"TLE"<<" "<<"x"<<" "<<x1[2]<<endl;
  cout<<"RE"<<" "<<"x"<<" "<<x1[3]<<endl;
}
  
  



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

int main() {
  int A,B;
  cin >> A >> B;
  int c=-1;
    for(int i =10*B+9;i>10*B-1;i--){
      for(int j=25*(A+1)/2-1;j>(25*A+1)/2-1;j--){
        if(i==j){
          c=i;
          break;
        }
      }
    }
   cout << c << endl;
}


Measured memory_bytes: 256
#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>;
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);

    char a,b,c,d,sign[3];
    cin>>a>>b>>c>>d;
    int num[4];
    num[0]=a-'0';
    num[1]=b-'0';
    num[2]=c-'0';
    num[3]=d-'0';
    for(int bit=0;bit<(1<<3);++bit){
        int sum=num[0];
        rep(i,3){
            if(bit&(1<<i)){
                sum+=num[i+1];
                sign[i]='+';
            }
            else{
                sum-=num[i+1];
                sign[i]='-';
            }
        }
        if(sum==7){
            rep(j,3){
                cout<<num[j]<<sign[j];
            }
            cout<<num[3]<<"=7"<<endl;
            break;
        }
    }


    return 0;
}


Measured memory_bytes: 3600
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools
import time,random,resource

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)
def pe(s): return print(str(s), file=sys.stderr)
def JA(a, sep): return sep.join(map(str, a))
def JAA(a, s, t): return s.join(t.join(map(str, b)) for b in a)


def main():
    n,k = LI()
    a = sorted(LI())

    return sum(a[:k])


print(main())




Measured memory_bytes: 10900
nk = input().split(' ')
n = int(nk[0])
k = int(nk[1])

h = list(map(int, input().split(' ')))

h.sort()

if h[0] >= k:
	print(n)

elif h[n-1] < k:
	print(0)

else:
	m = n//2
	m_min = 0
	m_max = n-1
	while m_min != m:
		if h[m] < k:
			m_min = m
		else:
			m_max = m
		m = (m_min+m_max)//2
	
	print(n-m-1)

Measured memory_bytes: 11916
#include <iostream>
#include <vector>
using namespace std;

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

    vector<int> v(26, 0);
    for (int i = 0; i < s.size(); i++) {
        v[s[i] - 'a']++;
    }

    for (int i = 0; i < 26; i++) {
        if (v[i] >= 2) {
            cout << "no" << endl;
            return 0;
        }
    }
    cout << "yes" << endl;
    return 0;
}

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

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> TUP;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define mp(a,b) make_pair(a,b)
const ll MOD=1000000007;

ll maxx(ll x,ll y,ll z){
	return max(max(x,y),z);
}
ll minn(ll x,ll y,ll z){
	return min(min(x,y),z);
}
ll gcd(ll x,ll y){
	if(x%y==0) return y;
    else return gcd(y,x%y);
}
ll lcm(ll x,ll y){
	return x*(y/gcd(x,y));
}

int main(){
	string s; cin>>s;
    ll cnt=0;
    rep(i,s.size()){
        ll tmp;
        if(s[i]=='0') tmp=0;
        else tmp=1;

        if(i%2==0 && tmp==1) cnt++;
        else if(i%2==1 && tmp==0) cnt++; 
    }
    ll ans=cnt;
    cnt=0;
    rep(i,s.size()){
        ll tmp;
        if(s[i]=='0') tmp=0;
        else tmp=1;

        if(i%2==0 && tmp==0) cnt++;
        else if(i%2==1 && tmp==1) cnt++; 
    }
    ans=min(ans,cnt);
    cout<<ans;
}

Measured memory_bytes: 512
#include <algorithm>
#include <complex>
#include <iostream>
#include <numeric>
#include <string>
#include <vector>
using namespace std;

int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    sort(a.begin(), a.end());
    reverse(a.begin(), a.end());
    int asum = 0, bsum = 0;
    for (int i = 0; i < n; i++) {
        if (i % 2 == 0) asum += a[i];
        else bsum += a[i];
    }
    cout << asum - bsum << endl;
    return 0;
}

Measured memory_bytes: 256
#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 <bitset>
using namespace std;
#define rep(i,r) for(int i = 0; i < (r); i++)
#define pb push_back
#define all(a) a.begin(), a.end()
#define fastio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define int long long
#define uint unsigned long long
#define endl '\n'
using namespace std;

signed main() {
    fastio;
    string n;
    cin >> n;
    int len = n.size();
    int res = 0;
    for (int i = 0; i < len; i++) {
        res += n[i] - '0';
        if (res >= 9) res -= 9;
    }
    if (res == 0) {
        cout << "Yes" << endl;
    }
    else cout << "No" << endl;
    return 0;
}

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

int main()
{
    int X, Y, N;
    cin >> X >> Y >> N;
    vector<vector<bool>> v(X, vector<bool>(Y, false));
    for (int i = 0; i < N; i++)
    {
        int x, y, a;
        cin >> x >> y >> a;
        switch (a)
        {
        case 1:
            for (int i = 0; i < x; i++)
            {
                for (int j = 0; j < Y; j++)
                {
                    v.at(i).at(j) = true;
                }
            }
            break;

        case 2:
            for (int i = x; i < X; i++)
            {
                for (int j = 0; j < Y; j++)
                {
                    v.at(i).at(j) = true;
                }
            }
            break;

        case 3:
            for (int i = 0; i < X; i++)
            {
                for (int j = 0; j < y; j++)
                {
                    v.at(i).at(j) = true;
                }
            }
            break;

        case 4:
            for (int i = 0; i < X; i++)
            {
                for (int j = y; j < Y; j++)
                {
                    v.at(i).at(j) = true;
                }
            }
            break;
        }
    }

    int ans = X * Y;
    for (int i = 0; i < X; i++)
    {
        for (int j = 0; j < Y; j++)
        {
            if (v.at(i).at(j))
            {
                ans--;
            }
        }
    }
    cout << ans;
    return 0;
}


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

int main() {
  int H, W;
  cin >> H >> W;
  rep(j, W+2) {
    cout << '#';
  }
  cout << endl;
  rep(i, H) {
    string S;
    cin >> S;
    cout << '#' << S << '#' << endl;
  }
  rep(j, W+2) {
    cout << '#';
  }
  cout << endl;
}


Measured memory_bytes: 256
n,x=map(int,input().split())
a = [1]
p = [1]
for i in range(n):
    a.append(2*a[i]+3)
    p.append(2*p[i]+1)
def f(n,x):
    if n == 0:
        return 0 if x<=0 else 1
    else:
        if x < a[n-1]+2:
            return f(n-1,x-1)
        else:
            return p[n-1]+1+f(n-1,x-2-a[n-1])
print(f(n,x))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1e9;
const int MOD = 1000000007;
const double PI = acos(-1);
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};

void solve() {
	int n = 3;
	vector<int> v(n);
	rep(i,n) cin >> v[i];
	int k;
	cin >> k;
	rep(i, 2) {
		while (k > 0 && v[i] >= v[i + 1]) {
			v[i+1] *= 2;
			k--;
		}
	}
	if (v[0] < v[1] && v[1] < v[2]) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}
}

int main() {
	solve();
	return 0;
}

Measured memory_bytes: 3596
#include <iostream>
#include <stdio.h>
#include <math.h>
using namespace std;

int main() {
	int n,i,k,p,cn;
	double x[100],y[100],dx,dy,sx,sy,a,b,c,d,e;
	while(cin >> n) {
     if (n==0) break;
	 for (i=0;i<n;i++) scanf("%lf,%lf",&x[i],&y[i]);
     sy=-1000;
	 for (i=0;i<n;i++) if (y[i]>sy) { sy=y[i]; k=i;}
	 dx=x[k]-10; dy=y[k]; sx=x[k];  sy=y[k]; cn=0;
	 do {
        e=2; 
		for (i=0;i<n;i++) {
			if (!((x[i]==dx && y[i]==dy) || (x[i]==sx && y[i]==sy))) {
            c=sqrt((sx-dx)*(sx-dx)+(sy-dy)*(sy-dy));
			b=sqrt((x[i]-sx)*(x[i]-sx)+(y[i]-sy)*(y[i]-sy));
			a=sqrt((x[i]-dx)*(x[i]-dx)+(y[i]-dy)*(y[i]-dy));
            d=(b*b+c*c-a*a)/(2*b*c);
			if (d<e) { e=d; p=i; }
			}
		}
		dx=sx; dy=sy; sx=x[p]; sy=y[p];
        cn++;
	 } while(!(sx==x[k] && sy==y[k]));
	 cout << n-cn << endl;
	}
 return 0;
}

Measured memory_bytes: 1272
#pragma GCC optimize("Ofast")
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define PI 3.141592
#define all(a) (a).begin(), (a).end()


int main(){
    int A, B;
  cin >> A >> B;
  cout << A * B << endl;
}


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

int main()
{
    int N;
    cin >> N;

    vector<int> X(N);
    for (size_t i = 0; i < N; i++)
    {
        cin >> X[i];
    }

    sort(X.begin(), X.end());

    int sum = 0;
    int min = 0;
    bool min_set_flag = false;
    for (size_t i = X[0]; i <= X[N - 1]; i++)
    {
        sum = 0;

        for (size_t j = 0; j < N; j++)
        {
            if (i > X[j])
            {
                sum += pow(i - X[j], 2);
            }
            else
            {
                sum += pow(X[j] - i, 2);
            }
        }

        if (min_set_flag == false)
        {
            min = sum;
            min_set_flag = true;
        }
        else
        {

            if (sum < min)
            {
                min = sum;
            }
        }
    }

    cout << min << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<bitset>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
typedef long long int ll;
typedef pair<int,int> P;
struct edge{int to,cost;};
#define REP(i,n) for(int i=0;i<(n);i++)
#define Endl endl
const int INF=100000000;
int main(){
	string s;
	cin>>s;
	cout<<s[0]<<s.size()-2<<s[s.size()-1]<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <algorithm>
using namespace std;

int main()
{
   int M;
  while(scanf("%d",&M)==1)
  {
      printf("%d\n",48-M);
  }
    return 0;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
	"bufio"
	"os"
	"strconv"
)

//=====I/O=====

var (
	sc = bufio.NewScanner(os.Stdin)
	wr = bufio.NewWriter(os.Stdout)
)

func scanInt() int {
	sc.Scan()
	a,_ := strconv.Atoi(sc.Text())
	return a
}

func scanInt64() int64 {
	sc.Scan()
	a,_ := strconv.ParseInt(sc.Text(),10,64)
	return a
}

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ { res[i] = scanInt() }
	return res
}

func scanText() string {
	sc.Scan()
	return sc.Text()
}

func printInts(a ...int) {
	for i, e := range a {
		fmt.Fprint(wr, e)
		if i != len(a)-1 { fmt.Fprint(wr, " ") }
	}
	fmt.Fprintln(wr)
	wr.Flush()
}

//=====main=====

func main() {
	sc.Split(bufio.ScanWords)

	c := scanText()
	fmt.Println(string(c[0]+1))
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
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 long long INF = 1e18;
//const ll mod = 1000000007;
ll ans = 1e18;
ll N, A;
ll mul(ll a, ll b) {
    if(a == 0 or b == 0) return 0;
    if(INF / a <= b) return INF;
    return a * b;
}

ll g(ll timer, ll interval) {
    ll factor = 1;
    ll now = 1;
    ll rest = timer;
    for(ll i = 1; i <= interval; i++) {
        ll nowtime = rest / (interval + 1 - i);
        rest -= nowtime;
        now = mul(factor, nowtime);
        factor = now;
        //cerr << i << " " << nowtime << " " << rest << " " << now << endl;
    }
    return now;
}

void f(ll interval) {
    ll ok = 1e12;
    ll ng = 0;
    while(abs(ok - ng) > 1) {
        ll mid = (ok + ng) / 2;
        if(g(mid, interval) >= N) ok = mid;
        else ng = mid;
    }
    ll nowans = ok + mul(interval - 1, A);
    //cerr << "f: " << interval << " " << ok << " " << nowans << endl;
    chmin(ans, nowans);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N >> A;
    //A++;
    for(ll i = 0; i <= 50; i++) f(i + 1);
    //for(ll i = 0; i <= 3; i++) f(i + 1);
    //cerr << g(10, 2) << endl;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<functional>
#include<utility>
#include<stack>
#include<queue>
#include<cmath>
#include<list>
#include<cstdint>
#include<vector>
#include<map>
#include<deque>
#define rep(i,rept)	for(int i = 0; i<(ll)rept;++i)
typedef long long ll;
using namespace std;


int main() {

	string s;
	bool flug_one = false, flug_ten = false, flug_hun = false;


	std::cin >> s;
	
	if (s[0] == '1') {
		s[0] = '9';
		flug_one = true;
	}
	if (s[1] == '1') {
		s[1] = '9';
		flug_ten = true;
	}
	if (s[2] == '1') {
		s[2] = '9';
		flug_hun = true;
	}
	if (s[0] == '9'&&!flug_one) {
		s[0] = '1';
	}
	if (s[1] == '9'&&!flug_ten) {
		s[1] = '1';
	}
	if (s[2] == '9'&&!flug_hun) {
		s[2] = '1';
	}

	cout << s << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<map>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
#include <functional>
#include<time.h>
#include <stack>
#include<iomanip>
using namespace std;
#define rep(i,a,n) for(ll i=(a);i<(n);i++)
#define ll long long
#define llint long long int
#define reverse(v)  reverse(v.begin(), v.end());
#define Yes(ans) if(ans)cout<<"Yes"<<endl; else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl; else cout<<"NO"<<endl;
#define hei(a) vector<a>
#define whei(a) vector<vector<a>>
#define UF  UnionFind 
#define Pint pair<llint,llint>
#define keta(a)  fixed << setprecision(a)
constexpr auto INF = 100000000000;
constexpr auto mod = 1000000007;
//辞書順はnext_permutation( begin( v ), end( v ) );やで！
struct edge { int to, cost; };

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

long long modpow(long long a, long long n, long long mod) {
	long long res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}

// mod. m での a の逆元 a^{-1} を計算するよ！
long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}


//aCbをmod.mで割った余りを求める
ll int c(ll int a, ll int b, ll int m) {
	ll int ans = 1;
	for (ll int i = 0; i < b; i++) {
		ans *= a - i;
		ans %= m;
	}
	for (ll int i = 1; i <= b; i++) {
		ans *= modinv(i, m);
		ans %= m;
	}
	return ans;
}
int main() {
	int n;
	cin >> n;
	hei(int)a(n);
	rep(i, 0, n)cin >> a[i];
	sort(a.begin(), a.end());
	int one = 0, two = 0;
	int x = 1;
	a.push_back(0);
	rep(i, 0, n) {
		if (a[i] == a[i + 1])x++;
		else {
			if (x % 2 == 0)two++;
			if (x % 2 == 1)one++;
			x = 1;
		}
	}
	int ans = one + (two / 2)*2;
	cout << ans << endl;
	
}


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

typedef enum{
	win,
	lose
}res;

int GCD(int a, int b){
	if(b == 0){
		return a;
	}
	else{
		return GCD(b, a % b);
	}
}

res judge(int *A, int N){
	int i, evennum = 0, onenum = 0, odd, gcd = A[0];
	for(i = 0; i < N; i++){
		gcd = GCD(A[i], gcd);
	}
	for(i = 0; i < N; i++){
		A[i] /= gcd;
		if(A[i] % 2 == 0){
			evennum++;
		}
		else if(A[i] == 1){
			onenum++;
		}
		else{
			odd = i;
		}
	}
	if(evennum % 2 == 1){
		return lose;
	}
	else if(evennum < N - 1 || onenum > 0){
		return win;
	}
	else{
		A[odd]--;
		return !judge(A, N);
	}
}

int main(){
	int N, i;
	scanf("%d", &N);
	int *A = (int *)malloc(sizeof(int) * N);
	for(i = 0; i < N; i++){
		scanf("%d", &A[i]);
	}
	if(judge(A, N) == win){
		printf("Second\n");
	}
	else{
		printf("First\n");
	}
	return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long int ll;
static const int MAX_N = 1000;
struct Cake{ll x, y, z;};

int N, M;
Cake c[MAX_N];

bool comp(const Cake &a, const Cake &b){
	return a.x + a.y + a.z > b.x + b.y + b.z;
}

int main(){
	cin >> N >> M;
	for(int i = 0; i < N; i++) cin >> c[i].x >> c[i].y >> c[i].z;
	ll ans = 0;
	for(int i = 0; i < (1 << 3); i++){
		if(i & 1) for(int j = 0; j < N; j++) c[j].x *= -1;
		if(i & 2) for(int j = 0; j < N; j++) c[j].y *= -1;
		if(i & 4) for(int j = 0; j < N; j++) c[j].z *= -1;
		sort(c, c + N, comp);
		ll sum = 0;
		for(int j = 0; j < M; j++) sum += c[j].x + c[j].y + c[j].z;
		ans = max(sum, ans);
		if(i & 1) for(int j = 0; j < N; j++) c[j].x *= -1;
		if(i & 2) for(int j = 0; j < N; j++) c[j].y *= -1;
		if(i & 4) for(int j = 0; j < N; j++) c[j].z *= -1;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = int64_t;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define all(v)    begin(v), end(v)
#define in        []{lint n; cin>>n; return n;}()

int main(){ cin.tie(0); ios::sync_with_stdio(false);
    lint N = in; // < 10^5
    vector<lint> A(N);
    rep( i, N ) A[i] = in;


    vector<lint> ans(N);
    rep( i, N ) ans[0] = A[i] - ans[0];

    for( int i=1; i<N; ++i ) {
        ans[i] = 2 * A[i-1] - ans[i-1];
    }

    rep( i, N-1 ) cout << ans[i] << " ";
    cout << ans[N-1] << "\n";
}


Measured memory_bytes: 2944
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <math.h>
using namespace std;

#define ll long long
//#define int long long
const int MOD = 1000000007;
const int INF = 1010000000;
const double EPS = 1e-10;

#define dump(x)  cerr << #x << " = " << (x) << endl; 
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl; 


typedef pair<int, int> P;
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};


signed main(){

	int N, OR=0;
	cin >> N;


	for (int i = 0; i < N; i++){
		int a;
		cin >> a;
		OR = OR | a;
	}

	int result = 0;
	while (OR % 2==0) { OR = OR >> 1; result++; }

	cout << result << endl;


	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

class Main{
    final static int LEN = 105;
    public static void main(String args[]){
	int[][] graph = new int[LEN][LEN];
	int[] minCost = new int[LEN];
	int count=0;
	int v;
	boolean[] used = new boolean[LEN];

	Scanner in = new Scanner(System.in);

	//read
	int n = in.nextInt();
	for(int i=0; i<n; i++){
	    for(int j=0; j<n; j++){
		int k = in.nextInt();
		graph[i][j]=(k==-1? Integer.MAX_VALUE : k);
	    }
	}

	//make prim
	for(int i=0; i<n; i++){
	    minCost[i]=Integer.MAX_VALUE;
	    used[i]=false;
	}

	minCost[0]=0;

	while(true){
	    v = -1;
	    for(int i=0; i<n; i++){
		if(!used[i] && (v==-1 || minCost[i] < minCost[v]))v=i;
	    }

	    if(v==-1)break;
	    used[v]=true;
	    count+=minCost[v];

	    for(int i=0; i<n; i++){
		minCost[i]=Math.min(minCost[i], graph[v][i]);
	    }
	}

	//print
	System.out.println(count);
    }
}

Measured memory_bytes: 13000
import sys
N = int(sys.stdin.readline().rstrip())
s = []
if N == 0:
    print(0)
    exit()
base = 1
cur = 2
while N != 0:
    r = N % cur
    r = r + cur if r < 0 else r
    if r > 0:
        s.append("1")
        N -= base
    else:
        s.append("0")
    cur *= 2
    base *= -2
print("".join(s[::-1]))

Measured memory_bytes: 3064
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
const int N=100005;
int n,m,v,p;
int a[N];
bool check(int x)
{
	if(x<=p) return true;
	if(a[x]+m<a[p]) return false;
	long long ret=1LL*m*v;
	ret-=m;
	ret-=1LL*(p-1)*m+1LL*(n-(x+1)+1)*m;
	for(int i=p;i<x;i++)
		ret-=min(m,a[x]+m-a[i]);
	return ret<=0;
}
int main()
{
	scanf("%d%d%d%d",&n,&m,&v,&p);
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	sort(a+1,a+n+1,greater<int>());
	int l=1,r=n,ans=-1;
	while(l<=r)
	{
		int mid=(l+r)/2;
		if(check(mid)) ans=mid,l=mid+1;
		else r=mid-1;
	}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 4152
#include<cstdio>
using namespace std;
int main(void)
{
	int n,m,A[101],B[101],cnt,i,j,ten[101];
	scanf("%d",&n);
	scanf("%d",&m);
	for(i=0;i<m;i++){
		scanf("%d",&A[i]);
	}
	for(i=1;i<=n;i++){
		ten[i]=0;
	}
	
	/*for(i=0;i<m;i++){
		for(j=1;j<=n;j++){
			scanf("%d",&B[j]);
			ten[i]=0;
//			printf("B=%d\n",B[j]);
		}
	}*/
	//for(j=1;j<=n;j++)	printf("bb=%d ",B[j]);	printf("\n");
	for(i=0;i<m;i++){
		for(j=1;j<=n;j++){	
			scanf("%d",&B[j]);
			if(A[i]==j){
				ten[A[i]]++;
			}
			else{ 
				//printf("a=%d b=%d\n",A[i],B[j]);
				if(A[i]==B[j]){
					ten[j]++;
				//	printf("aa%d\n",ten[j]);
				}
				else{
					ten[A[i]]++;
				//	printf("bb%d\n",ten[A[i]]);
				}
			}
			//printf("1=%d 2=%d 3=%d\n",ten[1],ten[2],ten[3]);
		}
	}
	for(i=1;i<=n;i++){
		printf("%d\n",ten[i]);
	}
	return 0;
}
	
				
				
	

Measured memory_bytes: 1024