akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
public class Main {
    static boolean[] f  = new boolean[100001];
    //素数判定


    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int Q = sc.nextInt();
        /*int[] l = new int[Q];
        int[] r = new int[Q];
        for(int i=0;i<Q;i++){
            l[i] = sc.nextInt();
            r[i] = sc.nextInt();
        }
        int[] answer = new int[Q];*/
        f[0] = f[1]=true;
        for(int i=2;i<=100000;i++){
            if(!f[i]){
                for(int j=i*2;j<=100000;j=j+i){
                    f[j] = true;
                }
            }
        }
        int[] c = new int[100002];
        c[0] = 0;
        c[1] = 0;
        c[2] = 0;
        for(int i=3;i<=100000;i+=2){
            if(!f[i]&&!f[(i+1)/2]) c[i]++;
        }
        for(int i=3;i<=100000;i++) c[i] += c[i-1];

        for(int i=0;i<Q;i++){/*
            int p = l[i] + 1;
            int q = r[i] + 1;
            p = p/2;
            q = q/2;
            for(int j=p;j<=q;j++){
                if(f[j]==false && f[2*j-1]==false) {
                    answer[i]++;
                }
            }
            System.out.println(answer[i]);*/
            int p = sc.nextInt();
            int q = sc.nextInt();
            System.out.println(c[q]-c[p-1]);
        }



    }

}


Measured memory_bytes: 63280
#include <iostream>

using namespace std;

int main() {
  string s, t;
  cin >> s >> t;
  int a, b;
  cin >> a >> b;
  string f;
  cin >> f;
  if (f == s) cout << a - 1 << " " << b << '\n';
  else cout << a << " " << b - 1 << '\n';
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<deque>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#include<unordered_set>
#include<iomanip>
#include<cassert>
#include<regex>
#include<bitset>
#include<complex>
#include<chrono>
#include<random>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(),x.end()
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;

ll gcd(ll n, ll m) {
	ll tmp;
	while (m!=0) {
		tmp = n % m;
		n = m;
		m = tmp;
	}
	return n;
}

ll lcm(ll n, ll m) {
	return abs(n) / gcd(n, m)*abs(m);//gl=xy
}
 
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
 
using namespace std;

int n;
vector<string>ans;

void dfs(int v,string s,int num){
  if(v==n){
    ans.pb(s);
    return;
  }
  rep(i,num+1){
    dfs(v+1,s+char('a'+i),num+(i==num));
  }
}
void solve(){
  cin>>n;
  dfs(1,"a",1);
  for(auto x:ans){
    cout<<x<<endl;
  }
}

int main(){
	ios::sync_with_stdio(false);
  cin.tie(0);
	cout<<fixed<<setprecision(15);
  solve();
	return 0;
}


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

class DisjointSet{
public:
    vector<int> rank,p;
    DisjointSet(){}
    DisjointSet(int size){
        rank.resize(size,0);
        p.resize(size,0);
        for(int i=0; i<size; i++) makeSet(i);
    }
    void makeSet(int x){
        p[x] = x;
        rank[x] = 0;
    }
    
    bool same(int x,int y){
        return findSet(x) == findSet(y);
    }
    
    void unite(int x,int y){
        link(findSet(x), findSet(y));
    }
    
    void link(int x,int y){
        if(rank[x] > rank[y]){
            p[y] = x;
        }else{
            p[x] = y;
            if(rank[x] == rank[y]){
                rank[y]++;
            }
        }
    }
    
    int findSet(int x){
        if(x != p[x]){
            p[x] = findSet(p[x]);
        }
        return p[x];
    }
};

int main(){
    int n,a,b,q;
    int t;
    
    cin >> n >> q;
    DisjointSet ds = DisjointSet(n);
    
    for(int i=0; i<q; i++){
        cin >> t >> a >> b;
        if(t==0) ds.unite(a,b);
        else if(t==1){
            if(ds.same(a, b)) cout << 1 << endl;
            else cout << 0 << endl;
        }
    }
    
    return 0;
}

Measured memory_bytes: 3180
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int top, stack[1000];

void push(int);
int pop(void);

int main(){
  int a, b, x, top=0;
  char s[100];
  
  while( scanf("%s", s) != EOF ){
    if ( s[0] == '+' ){
      a = pop();
      b = pop();
      push(a+b);
    } else if ( s[0] == '-' ){
      a = pop();
      b = pop();
      push(b-a);
    } else if ( s[0] == '*' ){
      a = pop();
      b = pop();
      push(a*b);
    } else {
      x = atoi(s);
      push(x);
    }
  }

  printf("%d\n", pop());
  
  return 0;
}

void push(int x){
  top++;
  stack[top] = x;
}

int pop(){
  top--;
  return stack[top+1];
}

Measured memory_bytes: 548
#include<bits/stdc++.h>
typedef long long ll;
typedef long double ld;
using namespace std;

using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

#define REP(i, l, n) for(int i=(l), i##_len=(n); i<i##_len; ++i)
#define ALL(x) (x).begin(),(x).end()
#define pb push_back

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

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

char alpha[26] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};

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

int main(){
    int n; cin >> n;
    ll sum = 1000, have = 0;
    vector<ll> lis(n), anslis(n);
    REP(i, 0, n){cin >> lis[i];}
    REP(i, 0, n-1){
        sum += have * lis[i];
        have = 0;
        if(lis[i] <= lis[i+1]){
            have += sum / lis[i];
            sum -= have * lis[i];
        }
        anslis[i] = have * lis[i] + sum;
    }
    anslis[n-1] = have * lis[n-1] + sum;
    ll ans = 0;
    REP(i, 0, n){
        chmax(ans, anslis[i]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
#define N 3010
inline int read() {
    int x=0;
    char ch=getchar();
    while (!isdigit(ch)) ch=getchar();
    while (isdigit(ch)) x=x*10+ch-'0',ch=getchar();
    return x;
}
int tot=1;
int fir[N],nex[N<<1],got[N<<1];
inline void AddEdge(int x,int y) { 
    nex[++tot]=fir[x],fir[x]=tot,got[tot]=y; 
}
int a[N],dp[N];
inline void dfs(int x,int fa) {
    dp[x]=false;
    for (int i=fir[x];i;i=nex[i]) {
        if (got[i]==fa) continue;
        dfs(got[i],x); if (!dp[got[i]] && a[got[i]]<a[x]) dp[x]=true;
    }
}
int main() {
    int n=read();
    for (int i=1;i<=n;i++) a[i]=read();
    for (int i=1;i<=n-1;i++) {
        int x=read(),y=read();
        AddEdge(x,y),AddEdge(y,x);
    }
    for (int i=1;i<=n;i++) {
        dfs(i,0); if (dp[i]) printf("%d ",i);
    }
    return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#define M 100005
#define N 405
using namespace std;
int n,m,x[M],y[M],G[N][N],ban[N],ans;
int main()
{
	int i,j,k;
	scanf("%d %d",&n,&m);
	for(i=1;i<=m;i++)
		scanf("%d %d",&x[i],&y[i]);
	for(i=1;i<=n;i++){
		G[i][i]=1;
		for(j=m;j>=1;j--)
			if(G[i][x[j]]&&G[i][y[j]]) ban[i]=1;
			else if(G[i][x[j]]) G[i][y[j]]=1;
			else if(G[i][y[j]]) G[i][x[j]]=1;
	  }
	for(i=1;i<=n;i++)
		for(j=i+1;j<=n;j++)
			if(!ban[i]&&!ban[j]){
				for(k=1;k<=n;k++)
					if(G[i][k]&&G[j][k]) break;
				ans+=(k>n);
			  }
	cout<<ans;
	return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

#define mp make_pair
#define pb push_back
#define ll long long

#define maxN 200011

int n, i;
ll a[maxN], sum, way;
ll ans[maxN];

ll act, rat;
ll aux[maxN];

void no_sol() {
    printf("NO");
    exit(0);
}

int main()
{
  //  freopen("test.in","r",stdin);

    scanf("%d", &n);
    for (i = 1; i <= n; i++) {
        scanf("%lld", &a[i]);
        sum += a[i];
    }

    way = 1LL * (n + 1) * n;
    way >>= 1;

    if (sum % way != 0)
        no_sol();

    sum /= way;
    a[0] = a[n];

    for (i = 1; i <= n; i++) {
        ll aux = a[i] - a[i - 1];
        aux -= sum;
        aux *= -1;

        if (aux < 0) no_sol();
        if (aux % n != 0) no_sol();

        ans[i] = aux / n;
    }

    act = rat = 0;
    for (i = 1; i <= 2 * n; i++) {
        rat += ans[i];
        act += rat;

        if (i > n) {
            act -= ans[i - n] * (n + 1);
            rat -= ans[i - n];
        }

        aux[i] = act;
    }

    for (i = 1; i <= n; i++)
        if (a[i] != aux[i] + aux[i + n])
            no_sol();

    printf("YES");


    return 0;
}


Measured memory_bytes: 3328
#include <iostream>
#include <string>
#include <math.h>
#include <algorithm>
using namespace std;
int main(){
  int N,M;
  cin>>N>>M;
  string A[50],B[50];
  int noexist=0;
  for(int i=0;i<N;i++) cin>>A[i];
  for(int i=0;i<M;i++) cin>>B[i];
  for(int i=0;i<=N-M;i++){
    for(int j=0;j<=N-M;j++){
      int judge=0;
      for(int k=0;k<M;k++){
        for(int l=0;l<M;l++){
          if(A[i+k][j+l]!=B[k][l]){
            judge++;
            l+=M;
          }
        }
      }
      if(judge==0){
        cout<<"Yes"<<endl;
        i+=2*N;
        j+=2*N;
        noexist++;
      }
    }
  }
  if(noexist==0) cout<<"No"<<endl;
  
  return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
using P = pair<ll, ll>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
#define ALL(obj) (obj).begin(), (obj).end()
#define MOD 1000000007
#define INF 1000000000

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

	ll N, K;
	string S;

	cin >> N >> K >> S;

	if (S[K - 1] == 'A') {
		S[K - 1] = 'a';
	}else if (S[K - 1] == 'B') {
		S[K - 1] = 'b';
	}else if (S[K - 1] == 'C') {
		S[K - 1] = 'c';
	}

	cout << S << "\n";
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<deque>
#include<map>
#include<set>
#include<string>
#include<sstream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<cctype>
#include<climits>
using namespace std;
#define REP(i, j) for(int i = 0; i < j; i++)
#define FOR(i, j, k) for(int i = j; i < k; i++)
#define P pair<int, int>
const int INF = INT_MAX / 2;

int main(){
    int n;
    cin >>n;
    REP(i, n){
        int a, b, c;
        cin >>a >>b >>c;
        bool ans = false;

        if(a * a + b * b == c * c) ans = true;
        if(a * a + c * c == b * b) ans = true;
        if(b * b + c * c == a * a) ans = true;

        if(ans) cout <<"YES" <<endl;
        else cout <<"NO" <<endl;
    }

    return 0;
}

Measured memory_bytes: 1152
#include<stdio.h>
int main(){
  int n,a,b,i,s,c=0;
  scanf("%d %d %d",&n,&a,&b);
  for(i=1;i<=n;i++){
    s = i%10 + i%100/10 + i%1000/100 + i%10000/1000 + i%100000/10000;
    if(s>=a && s<=b){
      c+=i;
    }
  }
  printf("%d\n",c);
  return 0;
}

Measured memory_bytes: 128
s = raw_input().strip()
i = s.find('KIH')
if i == -1:
    print 'NO'
    quit()
if s[:i] not in ('', 'A'):
    print 'NO'
    quit()
s = s[i+3:]
i = s.find('B')
if i == -1:
    print 'NO'
    quit()
if s[:i] not in ('', 'A'):
    print 'NO'
    quit()
s = s[i+1:]
i = s.find('R')
if i == -1:
    print 'NO'
    quit()
if s[:i] not in ('', 'A'):
    print 'NO'
    quit()
if s[i+1:] not in ('', 'A'):
    print 'NO'
    quit()
print 'YES'


Measured memory_bytes: 2568
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
struct edge{ll to,cost;};
const int inf = 1<<27;
const ll INF = 1LL<<60;
const int COMBMAX = 1001001;
const ll MOD = 1000000007;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define eachdo(v, e) for(const auto& e : (v))
#define all(v) (v).begin(), (v).end()
#define lower_index(v, e) (ll)distance((v).begin(), lower_bound((v).begin(), (v).end(), e))
#define upper_index(v, e) (ll)distance((v).begin(), upper_bound((v).begin(), (v).end(), e))
ll mpow(ll a, ll n, ll mod = MOD){ll res = 1; while(n > 0){if(n & 1)res = res * a % mod; a = a * a % mod; n >>= 1;} return res;}
void YesNo(bool j){cout << (j ? "Yes" : "No") << endl; return;}
void yesno(bool j){cout << (j ? "yes" : "no") << endl; return;}
template<class Head> void pt(Head&& head){cout << head << endl; return;}
template<class Head, class... Tail> void pt(Head&& head, Tail&&... tail){cout << head << " "; pt(forward<Tail>(tail)...);}
template<class T> void debug(T v){rep(i, v.size()) cout << v[i] << " " ; cout << endl;}
template<class T> void debug2(T v){rep(i, v.size()){rep(j, v[i].size()) cout << v[i][j] << " " ; cout << endl;}}
template<class T1, class T2> ll bcount(T1 v, T2 a){return upper_index(v, a) - lower_index(v, a);} 
template<class T1, class T2> inline bool chmin(T1 &a, T2 b){if(a > b){a = b; return true;} return false;}
template<class T1, class T2> inline bool chmax(T1 &a, T2 b){if(a < b){a = b; return true;} return false;}
template<class T1, class T2> void sortTwoVecter(vector<T1> &f, vector<T2> &s, bool isReverse = false){
    vector<pair<T1, T2>> p;
    rep(i, f.size()) p.emplace_back(make_pair(f[i], s[i]));
    if (!isReverse) sort(p.begin(), p.end());
    else sort(p.rbegin(), p.rend());
    rep(i, f.size()) tie(f[i], s[i]) = p[i];
    return;
}

int main(){
    ll N, K ,C; cin >> N >> K >> C;
    string sc; cin >> sc;;
    ll rem = 0;
    vector<ll> day;
    rep(i, N){
        rem--;
        if (rem < 0 && sc[i] == 'o'){
            day.emplace_back(i);
            rem = C;
        } 
    }
    vector<ll> need;
    // debug(day);
    vector<ll> rday;
    rday = day;
    reverse(all(rday));
    ll id = day.size();
    if (K < id){
        return 0;
    }
    eachdo(rday,d){
        id--;
        bool ok = true;
        for(ll i = d + C; d < i; i--){
            if (N <= i) continue;
            if (sc[i] == 'o'){
                if (lower_index(day, i) == upper_index(day, i + C)){
                    ok = false;
                    day[id] = i;
                }
            }
        }
        if (ok) need.emplace_back(d + 1);
    }
    reverse(all(need));
    eachdo(need, e) pt(e);
    return 0;
}

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

const static char *BUSLINE = "012345678954321";
const static int BUSLINE_LEN = 15;

int main() {
  int n;
  cin >> n;
  
  for( int i = 0; i < n; i++ ) {
    int ent, ext;
    int route = 1;
    vector<int> route1, route2;
    cin >> ent >> ext;

    for( int j = 0; j < BUSLINE_LEN; j++ ) {
      if( BUSLINE[ j ] == ent + '0' ) {
        for( int k = j; ; k = ( k + 1 ) % BUSLINE_LEN ) {
          if( route == 1 ) {
            route1.push_back( BUSLINE[ k ] - '0' );
          } else {
            route2.push_back( BUSLINE[ k ] - '0' );
          }
          if( BUSLINE[ k ] == ext + '0' ) {
            route++;
            break;
          }
        }
      }
    }

    vector<int>* vp;
    if( route2.size() == 0 || route1.size() < route2.size() ) {
      vp = &route1;
    } else {
      vp = &route2;
    }
    
    int len = vp->size();
    for( int i = 0; i < len; i++ ) {
      cout << vp->at(i) << flush;
      if( i == len - 1 ) { break; }
      cout << " " << flush;
    }
    cout << endl;
  }

  return EXIT_SUCCESS;
}

Measured memory_bytes: 1216
#include <iostream>
#include <algorithm>
using namespace std;
bool search(int A[], int n, int key);

int main(void){
    
    int n, q, key, sum = 0;
    int A[100000];
    
    cin >> n;
    for(int i = 0; i < n; i++)
        cin >> A[i];
    
    sort(A, A+n);
    
    cin >> q;
    for(int j = 0; j < q; j++){
        cin >> key;
        if(search(A, n, key)) sum++;
    }
    
    cout << sum << endl;
    
}

bool search(int A[], int n, int key){
    
    int left = 0;
    int right = n;
    int center;
    
    while(left < right){
        center = (left + right) / 2;                    // 計算：配列間の距離を求め　➡　2で割ると真ん中が分かる
        if(A[center] == key) return true;
        else if (A[center] < key) left = center + 1;    // 計算：左側の位置を中央から＋１つ移動させる
        else right = center;                            // 計算：右側の位置を中央に移動させる
    }
    
    return false;
    
}


Measured memory_bytes: 3440
#include<bits/stdc++.h>
using namespace std;
#define re register
struct eg{int to,nx,c,w;}e[200100];
int cnt=1,q[70010],la[3100],cur[3100],tot=6;
long long d[3100];
unsigned short hd,ta;
inline void addE(re int a,re int b,re int c,re int d)
{
	e[++cnt]=(eg){b,la[a],c,d};la[a]=cnt;
	e[++cnt]=(eg){a,la[b],0,-d};la[b]=cnt;
}
long long ans;
bool bo[3100],in[3100];
bool spfa()
{
	q[0]=ta=1;
	for(re int i=2;i<=tot;i++)d[i]=-1ll<<60,cur[i]=la[i];cur[1]=la[1];
	for(hd=0;hd!=ta;hd++)
	{
		re int x=q[hd];//printf("**%d %lld\n",x,d[x]);
		for(re int i=la[x];i;i=e[i].nx)if(e[i].c&&d[e[i].to]<d[x]+e[i].w)
		{//printf("*lll*%d %d %d\n",x,e[i].to,e[i].w);
			d[e[i].to]=d[x]+e[i].w;
			if(!in[e[i].to])q[ta++]=e[i].to,in[e[i].to]=1;
		}
		in[x]=0;
	}
	return d[2]>(-1ll<<60);
}
int dfs(re int a,re int fl)
{//printf("**qqq** %d %d\n",a,fl);
	if(a==2)return fl;
	re int fa=fl;
	bo[a]=1;
	for(re int&i=cur[a];i;i=e[i].nx)if(!bo[e[i].to]&&e[i].c&&d[e[i].to]==d[a]+e[i].w)
	{
		re int t=dfs(e[i].to,min(fa,e[i].c));
		fa-=t;e[i].c-=t;e[i^1].c+=t;ans+=(long long)t*e[i].w;
		if(!fa)return fl;
	}
	return fl-fa;
}
void flow()
{
	while(spfa())
	{
		memset(bo,0,sizeof(bo));
		dfs(1,1<<30);
	}
}
int main()
{
	re int n,x,y,c;
	scanf("%d",&n);
	for(re int i=1;i<=n;i++)
	{
		scanf("%d%d%d",&x,&y,&c);
		addE(1,++tot,c,0);
		addE(tot,3,c,x+y);
		addE(tot,4,c,-x-y);
		addE(tot,5,c,x-y);
		addE(tot,6,c,y-x);
	}
	for(re int i=1;i<=n;i++)
	{
		scanf("%d%d%d",&x,&y,&c);
		addE(++tot,2,c,0);
		addE(4,tot,c,x+y);
		addE(3,tot,c,-x-y);
		addE(6,tot,c,x-y);
		addE(5,tot,c,y-x);
	}
	flow();
	printf("%lld\n",ans);
}

Measured memory_bytes: 640
#include<map>
#include<cstdio>
#include<vector>
#include<algorithm>

#define	rep(i,n)	for(int i=0;i<n;i++)

using namespace std;

typedef	long long	ll;
typedef	vector<int>	vi;

const int INF=1<<29;

map<ll,int> memo[10];

int solve(int p,vi a,vi b){
	int n=a.size();

	ll key=0;
	for(int i=p;i<n;i++)	key=key*10+a[i];
	if(memo[p].count(key))	return memo[p][key];

	if(p==n-1)	return memo[p][key]=(a[p]!=b[p]);

	int ans=INF;
	int rot=(b[p]-a[p]+10)%10,cost=(rot!=0);
	for(int i=p;i<n;i++){
		a[i]=(a[i]+rot)%10;
		ans=min(ans,solve(p+1,a,b)+cost);
	}
	return memo[p][key]=ans;
}

int main(){
	for(int n;scanf("%d",&n),n;){
		char sa[16],sb[16];	scanf("%s%s",sa,sb);
		vi a(n),b(n);
		rep(i,n){
			memo[i].clear();
			a[i]=sa[i]-'0';
			b[i]=sb[i]-'0';
		}
		printf("%d\n",solve(0,a,b));
	}
	return 0;
}

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

typedef long long ll;

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define ANS(n) cout << (n) << endl

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORR(i,a,b) for(int i=(a);i>=(b);i--)

#define ALL(obj) (obj).begin(),(obj).end()

#define pii pair<int,int>

#define pb(a) push_back(a)
#define mp make_pair

int gcd(int n, int m)
{
	if(n % m == 0)return m;
	return gcd(m, n % m);
}

int main()
{
	int n,x;
	cin >> n >> x;
	int dist[n];
	FOR(i,0,n){
		int xi;
		cin >> xi;
		dist[i] = abs(xi - x);
	}
	int ans = dist[0];
	FOR(i,1,n)
		ans = gcd(ans, dist[i]);
	ANS(ans);
	return 0;
}


Measured memory_bytes: 640
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <queue>
#include <bitset>
#define MOD (1000000007l)
#define rep(i, n) for(long i = 0; i < (n); i++)

using namespace std;

void solve() {
  long N;
  string S;
  cin >> N >> S;

  long memo = 0;
  long before_open = 0;
  for (auto it: S) {
    if (it == '(') memo++;
    else memo--;
    if (memo < 0) {
      before_open++;
      memo++;
    }
  }

  rep(i, before_open) cout << '(';
  cout << S;
  rep(i, memo) cout << ')';
  cout << endl;
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout.precision(12);
  solve();
  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<queue>
#include<vector>
#include<ctime>
#include<map>
#include<bitset>
#include<set>
#define LL long long
#define mp(x,y) make_pair(x,y)
#define pll pair<long long,long long>
#define pii pair<int,int>
using namespace std;
inline LL read()
{
	LL f=1,x=0;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
int stack[20];
inline void write(LL x)
{
	if(x<0){putchar('-');x=-x;}
    if(!x){putchar('0');return;}
    int top=0;
    while(x)stack[++top]=x%10,x/=10;
    while(top)putchar(stack[top--]+'0');
}
inline void pr1(int x){write(x);putchar(' ');}
inline void pr2(LL x){write(x);putchar('\n');}
const int MAXN=100005;
priority_queue<pii> hp1;
bool v[MAXN];
int a[MAXN],b[MAXN],n;
int main()
{
	n=read();
	for(int i=1;i<=n;i++)a[i]=read(),b[i]=read();
	memset(v,true,sizeof(v));
	for(int i=1;i<=n;i++)hp1.push(mp(a[i]+b[i],i));
	LL ans=0;int nw=1;
	for(int i=1;i<=n;i++)
	{
		nw^=1;
		if(!nw)
		{
			int x=hp1.top().second;
			hp1.pop();ans+=a[x];
		}
		else
		{
			int x=hp1.top().second;
			hp1.pop();ans-=b[x];
		}
	}
	pr2(ans);
	return 0;
}



Measured memory_bytes: 2296
#include <bits/stdc++.h>
#define ll long long int
#define yorn(f) cout<<((f)?"Yes":"No")<<endl
#define YORN(f) cout<<((f)?"YES":"NO")<<endl
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
int main()
{
    int n;
    cin >> n;
 cout <<"ABC" <<  n  << endl;   
    return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <iomanip>
int n;
long double btc, ans = 0.0, yan;
char mo[5];
int main() {
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) {
		std::cin >> yan >> mo;
		if (mo[0] == 'B') {
			ans += yan * 380000.0;
		}
		else {
			ans += yan;
		}
	}
	std::cout << std::fixed << std::setprecision(8) << ans;
	return 0;
}

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

int main() {

	vector<vector<pair<int, bool>>> a(3, vector<pair<int, bool>>(3));
	for(int i = 0; i < 3; i++) {
		for(int j = 0; j < 3; j++) {
			scanf("%d", &a[i][j].first);
			a[i][j].second = false;
		}
	}
	int n;
	scanf("%d", &n);
	for(int i = 0; i < n; i++) {
		int b;
		scanf("%d", &b);
		for(int j = 0; j < 3; j++) {
			for(int k = 0; k < 3; k++) {
				if(a[j][k].first == b) {
					a[j][k].second = true;
				}
			}
		}
	}
	bool ans = false;
	for(int i = 0; i < 3; i++) {
		if(a[i][0].second == true && a[i][1].second == true && a[i][2].second == true) {
			ans = true;
		}
		if(a[0][i].second == true && a[1][i].second == true && a[2][i].second == true) {
			ans = true;
		}
	}
	if(a[0][0].second == true && a[1][1].second == true && a[2][2].second == true) {
		printf("%s\n", "Yes");
	}else if(a[0][2].second == true && a[1][1].second == true && a[2][0].second == true) {
		printf("%s\n", "Yes");
	}else if(ans) {
		printf("%s\n", "Yes");
	}else {
		printf("%s\n", "No");
	}
}

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

int main(){
	string s;
	cin >> s;
	for(int i = 0; i < s.size(); i+= 2){
		cout << s.at(i);
	}
	cout << endl;
}

Measured memory_bytes: 512
#include<stdio.h>

int main(){
	int a[3],temp;
	scanf("%d",&a[0]);
	scanf("%d",&a[1]);
	scanf("%d",&a[2]);
	
	for(int i=0;i<2;i++){
			if(a[i]>a[i+1]){
				temp =a[i];
				a[i]=a[i+1];
				a[i+1]=temp;	
			}
	}
	if(a[0]>a[1]){
		temp = a[1];
		a[1] = a[0];
		a[0] = temp;	
	}
printf("%d %d %d\n",a[0],a[1],a[2]);
	return 0;	
}


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

#define for_(i,a,b) for(int i=(a);i<(b);++i)
typedef pair< int, int > pii;

pii getRange(int w, int d, int x, int y, char f) {
	if (f == 'N') {
		int a = x - (d - y), b = (w - x) - (d - y);
		return pii(a, w - b);
	}
	
	if (f == 'E') {
		int a = (d - y) - (w - x), b = y - (w - x);
		return pii(w + a, w + d - b);
	}
	
	if (f == 'S') {
		int a = (w - x) - y, b = x - y;
		return pii(w + d + a, 2*w + d - b);
	}
	
	if (f == 'W') {
		int a = y - x, b = (d - y) - x;
		return pii(2*w + d + a, 2*w+2*d - b);
	}
	
	return pii(-1,-1);
}

int solve(int n, vector< vector< int > >& collision, vector< int >& order, int s) {
	int ret = 0;
	vector< bool > bad(n, false);
	for_(i,0,n) {
		int v = order[(s + i) % n];
		if (bad[v]) continue;
		++ret;
		for (int u : collision[v]) bad[u] = true;
	}
	return ret;
}

struct Rng {
	int id, L, R;
	Rng(int __id, pii p) : id(__id), L(p.first), R(p.second) {}
	bool operator < (const Rng& o) const { return R < o.R; }
};

int main() {
	int n, w, d;
	cin >> n >> w >> d;
	
	int UB = 2*w + 2*d;
	vector< Rng > vp;
	for_(i,0,n) {
		int x, y; char f;
		cin >> x >> y >> f;
		pii p = getRange(w, d, x, y, f);
		vp.push_back(Rng(i, p));
		vp.push_back(Rng(i, pii(p.first + UB, p.second + UB)));
	}
	
	sort(vp.begin(), vp.end());
	vector< int > order, vis(n, false);
	for (Rng r : vp) if (!vis[r.id]) order.push_back(r.id), vis[r.id] = true;
	
	vector< vector< int > > collision(n, vector< int >());
	for (Rng x : vp) for (Rng y : vp) {
		if (x.id == y.id) continue;
		if (x.R >= y.L && x.L <= y.R) collision[x.id].push_back(y.id);
	}
	
	cout << max(solve(n, collision, order, 0), max(solve(n, collision, order, 1), solve(n, collision, order, 2))) << endl;
}

Measured memory_bytes: 8788
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;

int main(){
    int N;
    cin >> N;
    int D, X;
    cin >> D >> X;
    vector<int> a(N);
    for(size_t i = 0; i < N; i++)
    {
        cin >> a[i];
    }
    int ret = X;
    for(size_t i = 0; i < N; i++)
    {
        int day = 1;
        while(day <= D){
            ret++;
            day += a[i];
        }
    }
    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String[]  args) {
		Scanner scanner = new Scanner(System.in);

		int n = scanner.nextInt();
		int m[][] = new int[n][n];
		boolean fixed[] = new boolean[n];
		int d[] = new int[n];
		
		for (int i = 0; i < n; i ++) {
			for (int j = 0; j < n; j ++) {
				m[i][j] = scanner.nextInt();
				if (m[i][j] < 0) m[i][j] = Integer.MAX_VALUE;
			}
			d[i] = Integer.MAX_VALUE;
		}
		
		scanner.close();
		
		d[0] = 0;
		int u = 0;
		int sum = 0;
		
		for(int i = 0; true; i ++) {
			int mincost = Integer.MAX_VALUE;
			
			for (int j = 0; j < n; j ++) {
				if (fixed[j] == false && d[j] < mincost) {
					mincost = d[j];
					u = j;
				}
			}
			
			fixed[u] = true;
			sum += mincost;
			if (i == n - 1) break;
			
			for (int j = 0; j < n; j ++) {
				if (fixed[j] == false && m[u][j] < d[j]) {
					d[j] = m[u][j];
				}
			}
		}
		
		System.out.println(sum);
	}
} 



Measured memory_bytes: 41112
/*** akshaykumar99 ***/
 
#include<bits/stdc++.h> 
using namespace std;
 
const long long MOD = 1e9+7;
const long double PI = acos(-1);
const long long N = 1e18+1;
 
typedef long long ll;
typedef long double ld;

void test_case()
{
    ll n, m;
    cin >> n >> m;
    set<ll> v[n+1];
    for(int i = 0; i < m; i++)
    {
    	ll x, y;
    	cin >> x >> y;
    	v[x].insert(y);
    	v[y].insert(x);
    }
    vector<bool> vis(n+1, 0);
    ll count = 0, ans = 0;
    function<void(ll)> dfs = [&](ll s)
    {
    	count ++;
    	vis[s] = 1;
    	for(auto u : v[s])
    	{
    		if(!vis[u])
    			dfs(u);
    	}
    };
    for(int i = 1; i <= n; i++)
    {
    	if(!vis[i])
    	{
    		count = 0;
    		dfs(i);
    		ans = max(ans, count);
    	}
    }
    cout << ans <<'\n';

}
 
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL); 
    ll tc=1;
    // cin>>tc;
    while(tc--)
        test_case();
    return 0;
}


Measured memory_bytes: 44304
#include<iostream>
#include<map>
#include<vector>
#include<algorithm>
using namespace std;

typedef pair<int, int> p;

bool second_comp(p p1, p p2){
  return p1.second < p2.second;
}

int main(){
  int count = 0;
  int n = 0;
  cin >> n;
  vector< p > r(n), b(n);

  for(int i = 0; i < n; i++){
    int x, y;
    cin >> x >> y;
    r[i] = make_pair(x, y);
  }
  for(int i = 0; i < n; i++){
    int x, y;
    cin >> x >> y;
    b[i] = make_pair(x, y);
  }
  sort(r.begin(), r.end(), second_comp);
  sort(b.begin(), b.end());

  /*for(int i = 0; i < n; i++){
    cout << r[i].first << r[i].second << endl;
  }*/
  for(int i = 0; i< n; i++){
    for(int j = n-1; j >= 0; j--){
      if(r[j].first < b[i].first && r[j].second < b[i].second){
        /*cout << "("<< r[j].first << "," << r[j].second << ")"
             << "("<< b[i].first << "," << b[i].second << ")" << endl;*/
        r[j] = make_pair(201,201);
        b[i] = make_pair(-1,-1);
        count++;

        break;
      }
    }
  }

  cout << count << endl;
}


Measured memory_bytes: 256
def factorize(n):#素因数分解
    fct = []  # prime factor
    b, e = 2, 0  # base, exponent
    while b * b <= n:
        while n % b == 0:
            n = n // b
            e = e + 1
        if e > 0:
            fct.append([b, e])
        b, e = b + 1, 0
    if n > 1:
        fct.append([n, 1])
    return fct

n = int(input())

l = factorize(n)

m = len(l)

ans = 0

for i in range(m):
    x = l[i][1]
    for j in range(1, 50):
        if x >= j:
            ans += 1
            x -= j
        else:
            break

print(ans)

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

using namespace std;


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

    int temp = 0, maxL = 0;
    for (int i = 0; i <= s.length(); i++) {
        if (s[i] == 'A' || s[i] == 'C' || s[i] == 'G' || s[i] == 'T') {
            temp++;
        } else {
            if (temp >= maxL) {
                maxL = temp;
                temp = 0;
            } else {
                temp = 0;
            }
        }
    }

    cout << maxL << endl;
}


Measured memory_bytes: 3596
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
namespace AtCoder
{
    class Program
    {
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }


        static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            var s = ReadLine();
            var ans = new List<char>();
            foreach(var c in s)
            {
                if (c == 'B')
                {
                    if (ans.Count != 0)
                        ans.RemoveAt(ans.Count - 1);
                }
                else
                {
                    ans.Add(c);
                }
            }
            WriteLine(ans.ToArray());
            //Out.Flush();
        }
    }
}

Measured memory_bytes: 11220
#include<bits/stdc++.h>
#define ll long long
#define MOD 1000000007
#define INF 0x7fffffff
#define IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace __gnu_pbds;
typedef tree<int,null_type,std::less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
using namespace std;
/*
ordered_set X;
X.insert(1);
cout<<*X.find_by_order(1)<<endl; Kth largest element
cout<<X.order_of_key(-5)<<endl;  number of elemets less than K
*/

int main(){
    //freopen(".txt", "w", stdout
    //IO;

    int n,w;
    scanf("%d%d",&n,&w);
    vector<ll> dp(w+1);
    for(int i = 0; i < n; i++){
        int we,va;
        scanf("%d%d",&we,&va);
        for(int x = w - we; x >= 0; x--){
            dp[x+we] = max(dp[x+we],dp[x] + va);
        }
    }
    ll answer = 0;
    for(int i = 0; i <= w; i++){
        answer = max(answer,dp[i]);
    }
    printf("%lld",answer);
    return 0;
}


Measured memory_bytes: 1024
import sys
N = int(input())
arr = []
for i in range(N):
    a, b = map(int, input().split())
    arr.append([b, a])

arr = sorted(arr)

sum = 0
for i in range(N):
    sum += arr[i][1]
    if sum > arr[i][0]:
        print("No")
        sys.exit()

print("Yes")

Measured memory_bytes: 37156
import sys

n = int(input())
a = list(map(int, input().split()))
aa = [0]
for i in range(n):
    aa.append(aa[i] + a[i])

ans = sys.maxsize

def getdiff(left, center, right):
    return abs((aa[center] - aa[left]) - (aa[right] - aa[center]))

L = 1
R = 3

for C in range(2, n):
    while L + 1 < C and getdiff(0, L, C) > getdiff(0, L + 1, C):
        L += 1
    while R + 1 < n and getdiff(C, R, n) > getdiff(C, R + 1, n):
        R += 1
    pqrs = [aa[L], aa[C] - aa[L], aa[R] - aa[C], aa[n] - aa[R]]
    pqrs.sort()
    ans = min(ans, pqrs[3] - pqrs[0])

print(ans)

Measured memory_bytes: 24684
n, m = map(int, input().split())
a = [list(input()) for i in range(n)]
b = [list(input()) for i in range(m)]

for i in range(n - m + 1):
    for j in range(n - m + 1):
        flag = True
        for k in range(m):
            for l in range(m):
                if a[i + k][j + l] != b[k][l]:
                    flag = False
        if flag:
            print("Yes")
            exit()

print("No")

Measured memory_bytes: 3064
n=int(input())
s=input()
accum=[0]*n
if s[0]=="#":
    accum[0]=1
for i in range(n-1):
    accum[i+1]+=accum[i]+(s[i+1]=="#")
accum=[0]+accum
ans=10**18
for i in range(n+1):
    ans=min(ans,accum[i]+n-i-accum[n]+accum[i])
#print(accum)
print(ans)

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

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

	int N[99];
	for (int i = 0; i < n; i++) {
		cin >> N[i];
	}

	for (int i = 0; i < n; i++) {
		cout << N[n - i -1];
		if (i == n - 1) break;
		cout << " ";
	}

	cout << endl;
}


Measured memory_bytes: 3108
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vel;
typedef vector<int> vei;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> ve_vel;
typedef vector<vector<int>> ve_vei;
typedef vector<vector<char>> ve_vec;
typedef vector<vector<bool>> ve_veb;
typedef vector<vector<string>> ve_ves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pub push_back
#define puf push_front
#define pob pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

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

    ll N,M,K; cin >> N >> M >> K;

    rep(k,N+1) {
        rep(l,M+1) {
            if(k*(M-l)+(N-k)*l == K) {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
    return 0;
}


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

int main() {
  int n;
  cin >> n;
  
  vector<ll> lucas(n + 1);
  lucas.at(0) = 2;
  lucas.at(1) = 1;
  for (int i = 2; i <= n; ++i)
    lucas.at(i) = lucas.at(i - 1) + lucas.at(i - 2);
  
  cout << lucas.at(n) << endl;
  
  return 0;
}

Measured memory_bytes: 256
fn main() {
    let k: i64 = read();
    let mut res: i64 = 0;
    for a in 1..k+1 {
        for b in 1..k+1 {
            for c in 1..k+1 {
                let d = gcd(a, b);
                res = res + gcd(d, c);
            }
        }
    }
    println!("{}", res);
}
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}
fn gcd(a: i64, b: i64) -> i64 {
    if b == 0 {
        a
    } else {
        gcd(b, a % b)
    }

}

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

void merge(vector<int> &A, int left, int mid, int right){
	int n1 = mid - left;
	int n2 = right - mid;
	vector<int> L, R;
	L.resize(n1 + 1);
	R.resize(n2 + 1);
	for(int i = 0; i < n1; i++){
		L[i] = A[left + i];
	}
	for(int i = 0; i < n2; i++){
		R[i] = A[mid + i];
	}
	L[n1] = numeric_limits<int>::max();
	R[n2] = numeric_limits<int>::max();
	int i = 0;
	int j = 0;
	for(int k = left; k < right; k++){
		if(L[i] <= R[j]){
			A[k] = L[i];
			i = i + 1;
		}else{
			A[k] = R[j];
			j = j + 1;
		}
	}
}

void mergeSort(vector<int> &A, int left, int right, int &count){
	if(left+1 < right){
	    int mid = (left + right)/2;
	    mergeSort(A, left, mid, count);
	    mergeSort(A, mid, right, count);
	    merge(A, left, mid, right);
		count += right - left;
	}
}

int main()
{
	int n;
	int count = 0;
	cin >> n;
	vector<int> S;
	S.resize(n);
	for(int i = 0; i < n; i++){
		cin >> S[i];
	}
	mergeSort(S, 0, n, count);
	for(int i = 0; i < n-1; i++){
		cout << S[i] << ' ';
	}
	cout << S[n-1] << endl << count << endl;
	return 0;
}

Measured memory_bytes: 6808
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
using namespace std;
#define int long long



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

    int n,r; cin >> n >> r;
    int ans;
    if(n > 9){
        ans = r;
    }else{
        ans = r + 100 * (10 - n);
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
d, n = map(int, input().split())

if n != 100:
    if d == 0:
        print(n)
    elif d == 1:
        print(n * 100)
    else :
        print(n * 10000)
else:
    if d == 0:
        print(101)
    elif d == 1:
        print(10100)
    else :
        print(1010000)

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

using namespace std;

typedef long long	ll;

const int N = int(2e3 + 10);
ll bit[N];
ll l[N];

int LSOne(int x){
	return x & (-x);
}

ll query(int x){
	ll sum = 0LL;

	while(x > 0){
		sum += bit[x];
		x -= LSOne(x);
	}

	return sum;
}

void update(int x, ll val){
	while(x < N){
		bit[x] += val;
		x += LSOne(x);
	}
}

ll rsq(int l, int r){
	return query(r) - query(l - 1);
}

int main(){
	int n;

	scanf("%d", &n);

	for(int i = 1 ; i <= n ; i++){
		scanf("%lld", &l[i]);
	}

	sort(l + 1, l + 1 + n);

	ll tot = 0LL;

	for(int i = 1 ; i <= n ; i++){
		tot += rsq(l[i] + 1, N - 1);

		for(int j = 1 ; j < i ; j++){
			update(l[i] + l[j], 1LL);
		}
	}

	printf("%lld\n", tot);

	return 0;
}

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

using namespace std;

int main()
{
	int N,count=0,j=0;
	bool judge = true;
	int H[100] = { 0 };
	int h[100] = { 0 };

	scanf("%d", &N);

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

	for (int i = 0; i < N; i++) {

		for (; h[i] < H[i]; count++) {

			for (j = i;; j++) {
				if (h[j] == H[j]||h[j]>h[j+1]) {
					break;
				}
			}

			for (int k = i; k <= j; k++) {
				h[k]++;
			}
		}
	}

	cout << count << endl;

	return 0;
}

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

const long long mod = 1e9 + 7;
vector <bool> B;
vector <long long> dp;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, m;
	cin >> n >> m;
	B.resize(n + 1, true);
	dp.resize(n + 1);
	dp[0] = 1;
	for (int i = 0; i < m; i++){
		int a;
		cin >> a;
		B[a] = false;
	}
	dp[1] = B[1] * 1;
	for (int i = 2; i <= n; i++){
		dp[i] = (dp[i - 1] + dp[i - 2]) * B[i];
		dp[i] %= mod;
	}
	cout << dp[n];
}

Measured memory_bytes: 1024
using System;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] s = Console.ReadLine().Split(' ');
            int a = int.Parse(s[0]);
            int b = int.Parse(s[1]);
            if (a < b)
            {
                Console.WriteLine("a < b");
            }
            else if(a > b)
            {

                Console.WriteLine("a > b");
            }else
            {
                Console.WriteLine("a == b");
            }
        }
    }
}

Measured memory_bytes: 9004
import java.util.Scanner;

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

		if ( N % 2 ==0 ) {
			ans = N;
		} else {
			ans = 2 * N;
		}
		System.out.println( ans );
	}
}

Measured memory_bytes: 21716
#include<stdio.h>
int main()
{
	int n;
	scanf("%d", &n);
	int i;
	int a[100005];
	for (i = 0; i < n; i++)
		scanf("%d", &a[i]);
	int b[100005];
	int l = 1;
	b[0] = a[0];
	int min, mid, max;
	for (i = 1; i < n; i++)
	{
		if (a[i] <= b[l - 1])
		{
			b[l] = a[i];
			l++;
		}
		else if (a[i] > b[0])
			b[0] = a[i];
		else
		{
			min = 0;
			max = n;
			while (max - min > 1)
			{
				mid = (max + min) / 2;
				if (b[mid] < a[i])
					max = mid;
				else
					min = mid;
			}
			b[max] = a[i];
		}
	}
	printf("%d\n", l);
	return 0;
}

Measured memory_bytes: 896
#include <bits/stdc++.h> 
#define int long long
#define deb(x) cout<<#x <<" = "<<x<<"\n";
using namespace std; 

signed main() 
{
	//freopen("input.txt", "r", stdin);
	
	int a, b, c; cin>>a>>b>>c;
	
	if(a == b && a != c) cout <<"Yes\n";
	else if(b == c && a != b) cout <<"Yes\n";
	else if(a == c && a != b) cout <<"Yes\n";
	else cout <<"No\n";
	
	
	
	
}

Measured memory_bytes: 256
import bisect

N = int(input())
L = sorted(list(map(int, input().split())))

ans = 0

for i in range(N - 2):
    for j in range(i + 1, N - 1):
        k = bisect.bisect_left(L, L[i] + L[j], j + 1) - 1
        ans += k - j

print(ans)



Measured memory_bytes: 3316
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String S = sc.next();

        if(S.length() < 6){
            System.out.print("No");
        }else{
            if(S.charAt(2) == S.charAt(3) && S.charAt(4) == S.charAt(5)) {
                System.out.print("Yes");
            }else {
                System.out.print("No");
            }
        }
    }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vel;
typedef vector<int> vei;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> ve_vel;
typedef vector<vector<int>> ve_vei;
typedef vector<vector<char>> ve_vec;
typedef vector<vector<bool>> ve_veb;
typedef vector<vector<string>> ve_ves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pub push_back
#define pob pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

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

    int N; cin >> N;
    vel A(N), B(N); rep(i,N) { cin >> A[i]; B[i] = A[i]; }
    sort(all(A));
    int ans = 0;
    rep(i,N) {
        if(i % 2 == 0) continue;
        int index = lower_bound(all(A), B[i]) - A.begin();
        if( ( index - i ) % 2 == 0) continue;
        else ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1920
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Scanner;

class Main {

    public static void main(final String[] args) {

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int numberOfPeople;
		try {
			numberOfPeople = Integer.parseInt(br.readLine());
		
        Long numberOfCoordinates[] = new Long[numberOfPeople];
        
        String string[] = br.readLine().split(" ");
        for (int i = 0; i < numberOfPeople; i++){
            numberOfCoordinates[i] = Long.parseLong(string[i]);
        }

        long output = Long.MAX_VALUE;

        for(int i = 0; i <= 100; i++){
            long cost = 0;
            for (int j = 0; j < numberOfPeople; j++){
                cost += Math.pow(numberOfCoordinates[j]-i,2);
            }
            output = Math.min(output,cost);
        }

        System.out.println(output);

    } catch (NumberFormatException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    }
  
}

Measured memory_bytes: 32512
# coding: utf-8
import sys
#from operator import itemgetter
sysread = sys.stdin.readline
read = sys.stdin.read
#from heapq import heappop, heappush
#from collections import defaultdict
sys.setrecursionlimit(10**7)
#import math
#from itertools import combinations
#import bisect# lower_bound etc
#import numpy as np
def run():
    N,K = map(int, sysread().split())
    P = list(map(int, sysread().split()))
    P = [(1+p)/2 for p in P]
    val = sum(P[:K])
    ret = val
    for i in range(1, N-K+1):
        val -= P[i-1]
        val += P[i+K-1]

        ret = max(ret, val)
    print(ret)



if __name__ == "__main__":
    run()

Measured memory_bytes: 25392
import Control.Monad
import Data.Bits

conv :: [Int] -> Int
conv [] = 0
conv (x:xs) = setBit (conv xs) x

bitCount :: Int -> Int
bitCount 0 = 0
bitCount n = 1 + bitCount (n .&. (n - 1))

main :: IO ()
main = do 
    line <- getLine

    let [n, m] = map read $ words line :: [Int]

    lines <- replicateM m getLine

    let switch = map (conv . drop 1 . map ((subtract 1).read)) $ map words lines :: [Int]

    line2 <- getLine

    let bits = map ( == "1"  ) $ words line2 :: [Bool]

    let z = zip switch bits

    let results = do
        i <- [0..(2 ^ n - 1)]

        let results = do
            (_switch,_bits) <- z
            return $ _bits == (odd $ bitCount $ i .&. _switch )
        
        return $ all id results 

    print $ length $ filter id results
 


Measured memory_bytes: 892
#include <iostream>
#include <set>
#include <string>

using namespace std;

int main()
{
    int n;
    string s, t;
    set<string> S;
    cin>>n;
    for (int i=0; i<n; i++)
    {
        cin>>s>>t;
        if (s=="insert") S.insert(t);
        if (s=="find") cout<<(S.count(t) ? "yes\n" : "no\n");
    }
    return 0;
}



Measured memory_bytes: 32600
using System;
using System.Collections.Generic;

namespace abc164_c
{
    class Program
    {
        static void Main(string[] args)
        {
            int n;
            string item;
            Dictionary<string, string> dictionary = new Dictionary<string, string>();
            n = Convert.ToInt32(Console.ReadLine());
            for (int i = 0; i < n; i++)
            {
                item = Console.ReadLine();
                if(!dictionary.ContainsKey(item))
                    dictionary.Add(item, item);
            }
            Console.WriteLine(dictionary.Count);
        }
    }
}


Measured memory_bytes: 45276