akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <bitset>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <utility>
using namespace std;

#define ABS(a) (((a) >= 0) ? (a) : -(a))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) > (b) ? (b) : (a))
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define RFOR(i, a, b) for (int i = a; i > b; --i)
#define REP(i, n) for (int i = 0; i < n; ++i)
#define int long long

typedef long long ll;
typedef pair<int, int> Pair;

const int kMaxN = 2*100000;

int N;
int A[kMaxN];
int ans = 0;

signed main() {
  cin >> N;
  REP(i, N) { cin >> A[i]; }

  REP(i, N) { A[i] -= i+1; }
  sort(A, A+N);
  int b = A[N/2];
  REP(i, N) { ans += ABS(A[i]-b); }

  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1792
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

typedef long long ll;

template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

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

    string S;
    cin >> S;

    int count = 0;
    for (int i = 0; i < N - 2; i++) {
        if (S[i] == 'A' && S[i+1] == 'B' && S[i+2] == 'C') {
            count++;
        }
    }

    cout << count << endl;

    return 0;
}


Measured memory_bytes: 256
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <queue>
#include <string>
using namespace std;

int main(){
	int n,x;
	cin >> n >> x;
	int a[n];
	for(int i=0;i<n;i++){
		cin >> a[i];
	}
	long cnt=0;
	if(a[0]>x){
		cnt+=a[0]-x;
		a[0]=x;
	}
	for(int i=0;i<n-1;i++){
		if(a[i]+a[i+1]>x){
			int exceed = a[i+1]+a[i]-x;
			a[i+1]-=exceed;
			cnt += exceed;
		}
	}
	cout << cnt << "\n";
	return 0;
}


Measured memory_bytes: 640
h, w = map(int,input().split())


# 配列への入力 簡単な書き方があった

field = []

for _ in range(h):
    ii = list(input())   ## inputのあとの()を忘れてた
    field.append(ii)


## 4方向の差分を表現する配列
dxdy = [[1,0],[0,1],[0,-1],[-1,0]]

result = 'Yes'
for i in range(h):
    for j in range(w):
        countOK = 0
        countNG = 0
        cell1 = field[i][j]

        if cell1 == '#':

            ## 4方向のうちどこかひとつでも黒があればOK
            ## ひとつも黒がなかったらNG
            for k in range(4):
                dx = dxdy[k][0]
                dy = dxdy[k][1]
                if i+dx <0:
                    continue
                if i+dx >h-1 :
                    continue
                if j+dy <0:
                    continue
                if j+dy >w-1:
                    continue

                cell2 = field[i+dx][j+dy]

                if cell2 == '#':
                    countOK += 1
                else:
                    countNG += 1

            
            if countOK == 0:
                result = 'No'


print(result)







Measured memory_bytes: 68204
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,x,n) for(int i=x;i<n;i++)
#define ALL(v) (v).begin(),(v).end()
#define MP(a,b) make_pair(a,b)
typedef long long LL;
typedef pair<int, int> PI;
typedef vector<int> VI;
const LL MOD = 1000000007LL;
int main() {
	int N;
	cin >> N;
	int odd = 0;
	rep(i, N) {
		int A;
		cin >> A;
		if (A % 2 == 1) odd++;
	}
	if (odd % 2 == 0) cout << "YES" << endl;
	else cout << "NO" << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>

int main( void )
{
    int n;
    int i;
    double s[1001];
    double m,sum;
    
    while( 1 ) {
        scanf( "%d", &n );
        if( 0== n ) { break; }
        m=0;
        for( i=0; i<n; i++ ) {
            scanf( "%lf", &s[i] );
            m+=s[i];
        }
        m/=n;
        sum=0;
        for( i=0; i<n; i++ ) {
            sum += pow( (s[i]-m), 2 );
        }
        sum=sum/n;
        printf( "%.4lf\n", sqrt( sum ) );
    }
    
    return 0;
}

Measured memory_bytes: 668
def make_dict(S):
  dic = dict()
  for s in S:
    if s in dic:
      dic[s] += 1
    else:
      dic[s] = 1
  return dic

N = int(input())
S = [input() for i in range(N)]
M = int(input())
T = [input() for i in range(M)]
blue = make_dict(S)
red = make_dict(T)
ans = 0
for s in blue.keys():
  tmp = blue[s]
  if s in red:
    tmp -= red[s]
  ans = max(ans,tmp)
print(ans)

Measured memory_bytes: 3064
# coding:utf-8

import sys
import math
import time
#import numpy as np
import collections
from collections import deque
from collections import Counter
import queue
import copy
import bisect
import heapq
import itertools


#sys.setrecursionlimit(10**7)
#N, Q = map(int, input().split())
#G = [list(input()) for i in range(H)]
#INF = V * 10001
#A = [int(i) for i in input().split()]
#AB = [list(map(int, input().split())) for _ in range(K)]

N= int(input())
A = [int(i) for i in input().split()]
ans = 1000
stock = 0

for i in range(N-1):
  if(A[i]<A[i+1]):
    stock += ans//A[i]
    ans = ans%A[i]
  else:
    ans += stock*A[i]
    stock = 0

if(stock != 0):
  ans += stock*A[N-1]


print(ans)


Measured memory_bytes: 68660
while True:
    n,m = map(int,input().split())
    if n==m==0: break
    price = list(map(int,input().split()))
    mx = 0
    
    for i in range(n-1):
        for j in range(i+1,n):
            if mx<price[i]+price[j]<=m:
                mx = price[i]+price[j]
    
    if mx==0: print("NONE")
    else: print(mx)
            


Measured memory_bytes: 5624
#include<iostream>
#include<iomanip>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<algorithm>
using namespace std;
int main()
{  int n,l;
   string a[10005];
   scanf("%d%d",&n,&l);
   for(int i=1;i<=n;i++)cin>>a[i];
   sort(a+1,a+n+1);
   for(int i=1;i<=n;i++)cout<<a[i];
   return 0;
}

Measured memory_bytes: 384
#include <cstdio>
#include <algorithm>

using namespace std;

int ap[128];

inline void out ()
{
    printf ("Impossible\n");
    exit (0);
}

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

    int n;
    scanf ("%d", &n);

    int ma = 0;
    for (int i = 1; i <= n; ++i)
    {
        int x;
        scanf ("%d", &x);
        ++ap[x];

        ma = max (ma, x);
    }

    int mi = (ma + 1) >> 1;

    for (int i = 1; i < mi; ++i)
        if (ap[i]) out ();

    for (int i = mi + 1; i <= ma; ++i)
        if (ap[i] <= 1) out ();

    if (ap[mi] != (ma & 1) + 1) out ();

    printf ("Possible\n");

    return 0;
}


Measured memory_bytes: 128
N = int(input())
l = list(map(int, input().split()))
 
check_list = []
for num in l:
    if num % 2 == 0:
        check_list.append(num)
 
n = len(check_list)
i = 0
while i < n:
    if (check_list[i] % 3 == 0) or (check_list[i] % 5 == 0):
        i += 1
    else: break
if i == n:
    print('APPROVED')
else: print('DENIED')

Measured memory_bytes: 3064
n, m = map(int, input().split())
ps = [list(input().split()) for _ in range(m)]

ac = [0 for _ in range(n+1)]
wa = [0 for _ in range(n+1)]

result_ac, result_wa = 0, 0

for p, s in ps:
    p = int(p)
    if s=="WA":
        wa[p] += 1
    elif ac[p] == 0:
        ac[p] += 1
        result_ac += 1
        result_wa += wa[p]
    else:
        continue
print(result_ac, result_wa)

Measured memory_bytes: 27640
#include <bits/stdc++.h>
using namespace std;
int main(){
    string S;
    cin >> S;
    int count = 0;
    char sta = S.at(0);
    for (int i = 0; i < S.size(); i++){
        if (S.at(i)!=sta){
            count++;
            sta = S.at(i);
        }
    }
    cout << count << endl;
}

Measured memory_bytes: 512
gets
xm,xM,ym,yM=2e9,0,2e9,0
XY = []
 
$<.map do |l|
  a = l.split.map &:to_i
  x, y = a.minmax
  XY << [x, y]
  xm = [x, xm].min
  xM = [x, xM].max
  ym = [y, ym].min
  yM = [y, yM].max
end
XY.sort!
 
k, l, yl = 2e9, XY[-1][0], 2e9;
XY.map do |a|
  x, y = a
  if x > yl
      k = [k, l - yl].min
      break
  end
  yl = [yl, y].min
  k = [k, l - x].min
  l = [l, y].max
end
 
p [(yM - ym) * (xM - xm), (yM - xm) * k].min


Measured memory_bytes: 20880
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

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

    vector<int> B, A;
    for(int i=0; i<N-1; i++){
        int t;
        cin >> t;
        B.push_back(t);
    }

    A.push_back(B[0]);
    for(int i=0; i<N-2; i++){
        A.push_back(min(B[i], B[i+1]));
    }
    A.push_back(B[N-2]);

    int sum = 0;
    for(int i=0; i<N; i++){
        sum += A[i];
    }

    cout << sum;
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define lli long long int
#define pb push_back
#define mod 1000000007
#pragma GCC optimize ("-O2")
#define mod2 998244353
#define MAXN 1000000000
#define v32 vector<int>
#define v64 vector<lli>
#define v1024 vector <vector <int>>
#define v4096 vector <vector <lli>>
#define vt vector
#define f(x, y, z) for (lli x = y; x < z; x++)
#define fd(x, y, z) for (lli x = y; x > z; x--)
#define lb lower_bound
#define ld long double
#define m64 map<lli,lli>
#define m32 map<int,int>
#define m64it map<lli,lli>::iterator
#define m32it map<int,int>::iterator
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define ist insert
#define endl "\n"
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
#define p_q priority_queue 
#define min_p_q priority_queue <int,vt <int>,greater <int>>
using namespace std;
using namespace __gnu_pbds; 
template <typename T> 

void DEBUG_ARR(vt<T> a)
{
	f(i,0,a.size())cout<<a[i]<<" ";
	cout<<"\n";
}

lli tmod(lli x,lli m){return (x%m+m)%m;}//USE AT YOUR OWN RISK
lli power(lli x, lli y) 
{
    lli res = 1;  
   
    while (y > 0) 
    { 
        if (y & 1) 
            res = (res*x)%mod; 
        y = y>>1; 
        x = (x*x)%mod;  
    }
    if(res<0)
       res+=mod; 
    return res; 
}
v32 Tree[200001];
v64 ssize(200001,0);
lli ans=0;
void dfs(int u,int p,int n){
    for(auto x:Tree[u]){
        if(x==p)continue;
        dfs(x,u,n);
        ssize[u]+=ssize[x];
    }
    ssize[u]++;
    lli val=power(2,mod-2);
    //    cout<<ans<<"\n";
    ans=(ans+val+((lli)Tree[u].size()-1)*power(val,n))%mod;
    lli sum=0;
    for(auto x:Tree[u]){
        if(x==p)continue;
        ans=(ans-power(val,n-ssize[x]))%mod;
        sum+=ssize[x];
    }
    sum=n-sum-1;
    if(p!=0)ans=(ans-power(val,n-sum))%mod;
    // cout<<u<<" "<<p<<" "<<ans<<"\n";
}

int main() 
{ 
  fastio;
  int n;cin>>n;
  f(i,0,n-1){
      int a,b;
      cin>>a>>b;
      Tree[a].pb(b);
      Tree[b].pb(a);
  }
  int leaf=1;
  f(i,1,n+1)if(Tree[i].size()==1)leaf=i;
  dfs(leaf,0,n);
  cout<<tmod(ans,mod);
  return 0; 	
}


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

// ローリングハッシュ
struct RollingHash {
    static const int base1 = 1007, base2 = 2009;
    static const int mod1 = 1000000007, mod2 = 1000000009;
    vector<long long> hash1, hash2, power1, power2;

    // construct
    RollingHash(const string &S) {
        int n = (int)S.size();
        hash1.assign(n+1, 0);
        hash2.assign(n+1, 0);
        power1.assign(n+1, 1);
        power2.assign(n+1, 1);
        for (int i = 0; i < n; ++i) {
            hash1[i+1] = (hash1[i] * base1 + S[i]) % mod1;
            hash2[i+1] = (hash2[i] * base2 + S[i]) % mod2;
            power1[i+1] = (power1[i] * base1) % mod1;
            power2[i+1] = (power2[i] * base2) % mod2;
        }
    }

    // get hash of S[left:right]
    inline pair<long long, long long> get(int l, int r) const {
        long long res1 = hash1[r] - hash1[l] * power1[r-l] % mod1;
        if (res1 < 0) res1 += mod1;
        long long res2 = hash2[r] - hash2[l] * power2[r-l] % mod2;
        if (res2 < 0) res2 += mod2;
        return {res1, res2};
    }
};

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

    // ロリハ
    RollingHash rh(S);

    // 二分探索判定
    auto check = [&](int d) -> bool {
        map<pair<long long, long long>, int> ma;
        for (int i = 0; i + d <= N; ++i) {
            auto p = rh.get(i, i+d);
            if (ma.count(p)) {
                if (i - ma[p] >= d) return true;
            }
            else ma[p] = i;
        }
        return false;
    };

    // 二分探索
    for (int length = (N >> 1); length > 0; --length) {
        if (check(length)) {
            cout << length << endl;
            return 0;
        }
    }
    cout << 0 << endl;
}

Measured memory_bytes: 4088
#include<bits/stdc++.h>
using namespace std;
signed main()
{
	ios::sync_with_stdio(0);
    cin.tie(0);
	int a,b,c;
	cin>>a>>b>>c;
	cout<<max(max(a,b),c)-min(min(a,b),c);
    return 0;
}


Measured memory_bytes: 3620
#include<cstdio>
#include<list>
#include<algorithm>
using namespace std;

int main() {
  int q, x;
  char com[20];
  list<int> v;
  scanf("%d", &q);
  for ( int i = 0; i < q; i++ ) {
    scanf("%s", &com);
    if ( com[0] == 'i' ) {
      scanf("%d", &x);
      v.push_front(x);
    } else if ( com[6] == 'L' ) {
      v.pop_back();
    } else if ( com[6] == 'F' ) {
      v.pop_front();
    } else {
      scanf("%d", &x);
      for ( list<int>::iterator it = v.begin(); it != v.end(); it++ )
        if ( *it == x ) {
          v.erase(it);
          break;
        }
    }
  }
  int i = 0;
  for ( list<int>::iterator it = v.begin(); it != v.end(); it++ ) {
    if ( i++ ) printf(" ");
    printf("%d", *it);
  }
  printf("\n");

  return 0;
}


Measured memory_bytes: 33900
#include<stdio.h>
int IN(void)
{
  int x=0,f=0,c=getchar();while(c<48||c>57){f^=c==45,c=getchar();}
  while(c>47&&c<58){x=x*10+c-48,c=getchar();}return f?-x:x;
}
int main()
{
  int N=IN(),i=0,A,B,C,Q,count[100000]={0};
  long long sum=0;
  while(i<N){A=IN();count[A-1]++;sum+=A;i++;}
  Q=IN();i=0;
  while(i<Q)
  {
    B=IN(),C=IN();
    sum-=1ll*count[B-1]*B;
    sum+=1ll*count[B-1]*C;
    count[C-1]+=count[B-1];
    count[B-1]=0;
    printf("%lld\n",sum);
    i++;
  }
}

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

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

const ll mod =  1000000007;
const int inf = 1e9;
const long long INF = 1LL << 60;   // INFの値は1152921504606846976

int main()
{
    int n,k;cin >> n >> k;
    int a[n];
    int x = 0, y = 0;
    rep(i,n){
        cin >> a[i];
        if(a[i] == 1){
            x = i;
            y = n-i-1;
        }
    }
    int ans = inf;
    rep(i,k){
        int tmp = 1;
        int r_sub = k-1-i;
        int l_sub = i;
        int div = k-1;
        int r = x - r_sub;
        int l = y - l_sub;
        if(r % div == 0) tmp += r/div;
        else tmp += ((r/div) + 1);
        if(l % div == 0) tmp += l/div;
        else tmp += ((l/div) + 1);
        ans = min(ans,tmp);
    }
    cout << ans << endl;
}


Measured memory_bytes: 640
#include "bits/stdc++.h"

#define REP(i,num) for(int i=0;i<(num);++i)
#define LOOP(i) while(i--)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto pitr=c.begin();pitr!=c.end();++pitr){cout<<*pitr;if(next(pitr,1)!=c.end())cout<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);

	ll S=in<ll>();

	ll X1=0,Y1=0,X2=atcoder_mod-7LL,Y2=1,X3,Y3;
	ll A = S%X2;
	ll B = S/X2;
	if(!A){
		X3 = 0,Y3=B;
	}
	else{
		X3 = X2-A;
		Y3 = (S+X3)/X2;
	}
	
	out(X1,Y1,X2,Y2,X3,Y3);
	return 0;
}


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

int s, a[1000001] = {};
map<int, int> cnt_map;

int main() {
  cin >> s;
  a[1] = s; 
  cnt_map[s]++;
  
  for (int i = 1; i < 1000000; ++i) {
    int mod = a[i] % 2;
    if (mod == 0) a[i + 1] = a[i] / 2;
    else a[i + 1] = 3 * a[i] + 1;
    
    if (cnt_map[a[i + 1]] > 0) {
      cout << i + 1 << endl;
      break;
    }
    cnt_map[a[i + 1]]++;
  }
  
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<cstdlib>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<queue>

using namespace std;
typedef pair<int, int> P;
const int MAX = 51;
int H, W;
int sx, sy, gx, gy;
char f[MAX][MAX];
int d[MAX][MAX];
int x[] = {1, -1, 0, 0};
int y[] = {0, 0, 1, -1};

int bfs() {
   queue<P> que;
   que.push(P(sx, sy));
   d[sx][sy] = 1;
   
   while (que.size()) {
      P p = que.front();
      que.pop();
      if (p.first == gx && p.second == gy) break;
      
      for (int i = 0; i < 4; i++) {
         int nx = p.first + x[i];
         int ny = p.second + y[i];

         if (nx < 0 || nx >= H || ny < 0 || ny >= W) continue;
         if (f[nx][ny] == '#') continue;
         if (d[nx][ny] != -1) continue;
         que.push(P(nx, ny));
         d[nx][ny] = d[p.first][p.second] + 1;
      }
   }
   return d[gx][gy];
}

int main() {
   cin >> H >> W;
   sx = 0;
   sy = 0;
   gx = H - 1;
   gy = W - 1;
   int cnt = 0;
   for (int h = 0; h < H; h++) {
      for (int w = 0; w < W; w++) {
         cin >> f[h][w];
         if (f[h][w] == '#') cnt++;
      }
   }
   memset(d, -1, sizeof(d));
   int ans = bfs();
   if (ans != -1) ans = H * W - ans - cnt;
   cout << ans << endl;
   return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>//解けなかった(1/21)
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;
const long long INF = 1LL << 60;

int main(){
    int N,K;
    cin >> N >> K;
    long long h[100010];
    long long dp[100010];
    for(int i=0;i<N;i++) cin >> h[i];
    for(int i=0;i<N;i++) dp[i] = INF;

    dp[0] = 0;
    for(int i=1;i<N;i++){
        for(int j=1;j<=K;j++){
            if(i>=j) chmin(dp[i],dp[i-j] + abs(h[i-j]-h[i]));
        }
    }
    cout << dp[N-1] << endl;
    return 0;

}

Measured memory_bytes: 1792
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cout << #x << " = " << (x) << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
//#define int long long

void solve() {
	int n; cin >> n;
    vector<int> a(n);
    set<int> se[100100];
    int res = 0;
    rep(i, n) {
        cin >> a[i];
        --a[i];
        if(se[i].find(a[i]) != se[i].end()) ++res;
        se[a[i]].insert(i);
    }
    cout << res << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//init();
	solve();
	//cout << "finish" << endl;
    return 0;
}

Measured memory_bytes: 9984
#include <iostream>
#include <vector>
#include <string>
#include <numeric>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <queue>
#include <deque>

using namespace std;
using ll = long long;

#define rep(countName, left, right, up) for (ll countName = left; countName < right; countName += up)
#define rev(countName, right, left, down) for (ll countName = right - 1; countName >= left; countName -= down)

auto solve1(void)
{
    int n, m;
    cin >> n >> m;

    if (n == m)
    {
        return "Yes";
    }
    else
    {
        return "No";
    }
}

int main(void)
{
    cout << solve1() << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>

#define REP(i,x) for(int i=0; i<(int)(x); i++)       // 0 <= i < x
#define REPS(i,x) for(int i=1; i<=(int)(x); i++)     // 0 < i <= x
#define RREP(i,x) for(int i=((int)(x)-1); i>=0; i--) // x > i >= 0
#define RREPS(i,x) for(int i=((int)(x)); i>0; i--)   // x >= i > 0
#define INF 999999999
#define ll long long

using namespace std;

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

int main(void){
	int n;
	scanf("%d", &n);

	int temp = (int) sqrt((double) n);

	printf("%d\n", temp*temp);

	return 0;
}


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

signed main(){
	int a,b;double cnt=0;
	cin>>a>>b;
	for(int i=1;i<=a;i++){
		double tot=1.0/a;int now=i;
		while(now<b){
			now*=2;//翻倍 
			tot/=2;//几率减半 
		}
		cnt+=tot;
	}
	cout<<fixed<<setprecision(12)<<cnt<<endl;
	return 0;
}



Measured memory_bytes: 256
#include <stdio.h>

int main(){
    unsigned long long x,add;
    int n,k;
    int i;
    scanf("%d %d",&n,&k);
    x = 0;
    for(i=1;i<n;i++){
        add = (x+k)/(k-1);
        x += add;
        if(!(x%k))x--;
    }
    printf("%llu\n",x);
}

Measured memory_bytes: 1028
#include <bits/stdc++.h>
#include<iostream>
#include<vector>
#include<map>
#include<math.h>
#include<algorithm>

#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rep2(i,a,n) for(int i = (int)(a); i <= (int)(n); i++)
#define rrep(i,n) for(int i = (int)(n-1); i > -1; i--)
#define rrep2(i,n,a) for(int i = (int)(n); i >= (int)(a); i--)

#define fi first
#define se second

using namespace std;

using ll = long long;
using v_int = vector<int>;
using v2_int = vector<v_int>;
using v_ll = vector<ll>;
using v2_ll = vector<v_ll>;
using v_string = vector<string>;
using v_bool = vector<bool>;
using v2_bool = vector<v_bool>;
using pii = pair<int, int>;
using mii = map<int, int>;

const double PI = 3.1415926535897932;
const int INF = (int)2e9;
const ll LINF = (ll)2e18;
const ll MOD = 1000000007;
const int dc[8] = {1, -1, 0,  0, 1, -1,  1, -1};
const int dr[8] = {0,  0, 1, -1, 1,  1, -1, -1};

template<typename T, typename U> inline
ostream& operator<<(ostream &o, pair<T,U> &p) {
    return o << "{" << p.first << "," << p.second << "}";
}
template<typename T> inline
istream& operator>>(istream &is, vector<T> &vec) {
    for(auto &v : vec) { is >> v; }
    return is;
}
template<typename T> inline
ostream& operator<<(ostream &os, vector<T> &vec) {
    for(auto &v : vec) { os << v << ",";}
    return os;
}
template<typename T> inline
ostream& operator<<(ostream &os, vector<vector<T> > &mat) {
    for(auto &row : mat) { os << row << endl; }
    return os;
}

template<typename T> inline
void chmin(T &a, T b) { a = min(a, b); }
template<typename T> inline
void chmax(T &a, T b) { a = max(a, b); }

int main(void)
{
    int a, b;
    cin >> a >> b;

    if(b==1) { cout << 0 << endl; return 0; }
    
    int cnt = a;
    int ans = 1;
    while(cnt < b) {
        cnt += (a-1);
        ans++;
    }
    cout << ans << endl;
    return 0;
} /*atcoder*/



Measured memory_bytes: 3604
#include<bits/stdc++.h>
#include<string.h>
using namespace std;
typedef long long int lli;
int main()
{
  ios_base::sync_with_stdio(false);
   cin.tie(NULL);
   cout.tie(NULL);
   string s;
   cin>>s;
   cout<<s.substr(0,3)<<"\n";
}

Measured memory_bytes: 3620
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

import static java.lang.System.in;


public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader reader = new BufferedReader(new InputStreamReader(in));
        String N = reader.readLine();
        if(N.contains("9")) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 20948
while True:
    N = input()
    if N == 0: break
    res = []
    for i in range(N):
        L = map(int, raw_input().split())
        m = 0
        s = 0
        for i, v in enumerate(L[1:]):
            if (i+1) % 2 == 0:
                s += v
            else:
                m += v
        else:
            s += (m*60)
            res.append([L[0], s])
    
    ans = sorted(res, key=lambda x: x[1])
    print ans[0][0]
    print ans[1][0]
    print ans[-2][0]

Measured memory_bytes: 5524
/*   --------------------
    |       LOSER        |
    |     ~NOOBOSS~      |
     --------------------
*/
#include <bits/stdc++.h>
using namespace std;

#define      inl(x)              scanf("%lld",&x)
#define      in(x)               scanf("%d",&x)
#define      mxx                 10000000000000
#define      mnn                 -10000000000000
#define      Y()                 cout<< "YES" <<endl
#define      N()                 cout << "NO"<<endl
#define      endl                "\n"
#define      max_3(a,b,c)        max(a, max(b,c))
#define      max_4(a,b,c,d)      max(a,max(b,max(c,d)))
#define      min_3(a,b,c)        min(a, min(b,c))
#define      min_4(a,b,c,d)      min(a,min(b,min(c,d)))
#define      gcd(a,b)            __gcd(a,b)
#define      lcm(a,b)           (a*b)/gcd(a,b)
#define      loser               return 0
#define      ll                  long long
#define      PI                  acos(-1)
#define      mem(a,v)            memset(a,v,sizeof(a))
#define      SORT(v)             sort(v.begin(),v.end())
#define      REV(v)              reverse(v.begin(),v.end())
#define      O(x)                cout<<x<<endl
#define      B                   begin()
#define      E                   end()
#define      V                   vector
#define      F                   first
#define      S                   second
#define      PSB                 push_back
#define      EMB                 emplace_back
#define      MP                  make_pair
#define      PII                 pair<int,int>
#define      MII                 map<int,int>
#define      InTheNameOfGod      ios::sync_with_stdio(0);cin.tie(0); cout.tie(0);
const ll MOD = 998244353;
//auto it=std:: unique(v.B,v.E);
//v.resize(std::distance(v.B,it));
int dx[] = {0,0,1,-1};
int dy[] = {1,-1,0,0};
/*-----*/
#define bug1(a)  cout<<a<<endl;
#define bug2(a,b)  cout<<a<<" "<<b<<endl;
#define bug3(a,b,c)  cout<<a<<" "<<b<<" "<<c<<endl;
/*----*/
ll power(ll n,ll p){if(p==0) return 1;if(p==1)return n;if(p%2)return power(n,p-1)*n;else{ll x=power(n,p/2);return x*x;}}
ll binpow(ll a, ll b){ll res = 1;while (b > 0) {if (b & 1)res*=a;a*=a;b>>=1;}return res;}
ll fact(ll num){ll fac=1;while(num!=1){fac=fac*num;num--;}return fac;}
string to_binary(int x) {string s;while(x > 0) {s += (x % 2 ? '1' : '0');x /= 2;}reverse(s.begin(), s.end());return s;}
ll nsum(ll num){return (num*(num+1))/2;}
/*-----*/
const int N=2e5+5;

/*-----*/
//vector<int> v[202];
ll fun(ll n){
   ll x=(n*(n+1)*(2*n+1))/6;
   return x;
}
/*-----*/
int main(){
   InTheNameOfGod

       ll test=1;
       //cin>>test;
       while(test--){
           ll i;
           ll n;
           string s;
           cin>>n;
           ll sum=0;
           for(i=1;i<=sqrt(n);++i){
            sum+=i*(i+((n)/i))*(((n)/i)+1-i)/2;
           }
     //      cout<<sum<<endl;
     //      sum=0;
     //       for(i=1;i<=sqrt(n);i++){
	 //      sum+=i*(i+floor(n/i))*(floor(n/i)+1-i)/2;
     //     }
           //cout<<sum<<endl;
           ll ans=2*sum-fun(sqrt(n));
           cout<<ans<<endl;
        }
	loser;
}
///////LeArN MoRe AnD Wait FoR ThE Result///////


Measured memory_bytes: 3680
n=int(input())
ans=0
for i in range(n):
    if (i+1)%3==0 and (i+1)%5==0:
        continue
    elif (i+1)%3==0:
        continue
    elif (i+1)%5==0:
        continue
    else:
        ans+=i+1
print(ans)

Measured memory_bytes: 9104
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace abc159_d
{
  class Program
  {
    static void Main(string[] args)
    {
      var N = CIn.ReadInt();
      var A = CIn.ReadIntArray(N);

      var count = new int[N + 1];

      for (int i = 0; i < N; i++)
      {
        count[A[i]]++;
      }

      var comSum = 0L;

      for (int i = 0; i <= N; i++)
      {
        comSum += (long)count[i] * (count[i] - 1) / 2;
      }

      for (int i = 0; i < N; i++)
      {
        var ans = comSum - count[A[i]] + 1;
        Console.WriteLine(ans);
      }
    }
  }

  static class CIn
  {
    private static readonly Queue<string> fieldBuffer = new Queue<string>();

    public static string Read()
    {
      if (fieldBuffer.Count == 0)
      {
        foreach (var field in Console.ReadLine().Split())
        {
          fieldBuffer.Enqueue(field);
        }
      }
      return fieldBuffer.Dequeue();
    }

    public static int ReadInt() => int.Parse(Read());
    public static long ReadLong() => long.Parse(Read());
    public static double ReadDouble() => double.Parse(Read());

    public static string[] ReadStringArray(int n)
    {
      var array = new string[n];
      for (var i = 0; i < n; i++)
      {
        array[i] = Read();
      }
      return array;
    }

    public static int[] ReadIntArray(int n)
    {
      var array = new int[n];
      for (var i = 0; i < n; i++)
      {
        array[i] = ReadInt();
      }
      return array;
    }

    public static long[] ReadLongArray(int n)
    {
      var array = new long[n];
      for (var i = 0; i < n; i++)
      {
        array[i] = ReadLong();
      }
      return array;
    }

    public static double[] ReadDoubleArray(int n)
    {
      var array = new double[n];
      for (var i = 0; i < n; i++)
      {
        array[i] = ReadDouble();
      }
      return array;
    }

    public static char[,] ReadCharMatrix(int h, int w)
    {
      var array = new char[h, w];
      for (var i = 0; i < h; i++)
      {
        var l = Console.ReadLine().ToCharArray();
        for (var j = 0; j < w; j++)
        {
          array[i, j] = l[j];
        }
      }
      return array;
    }
  }
}


Measured memory_bytes: 37540
package main

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

func main() {
	N := ReadInt()
	fmt.Println((1000 - N%1000) % 1000)
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int)       { Scan(&i); return }
func ReadString() (s string) { Scan(&s); return }
func ReadInts(n int) []int {
	v := make([]int, n)
	for i := 0; i < n; i++ {
		Scan(&v[i])
	}
	return v
}


Measured memory_bytes: 1844
#include <queue>
#include <vector>
#include <iostream>
using namespace std;
int main(){
    int n;
    cin>>n;
    int a[n],b[n],c[n],col[n];
    vector <pair <int,int> > v[n];
    for(int i=0;i<n-1;i++){
        col[i]=-1;
        cin>>a[i]>>b[i]>>c[i];
        v[a[i]-1].push_back({b[i]-1,c[i]});
        v[b[i]-1].push_back({a[i]-1,c[i]});
    }
    col[n-1]=-1;
    queue <int> q;
    q.push(1);
    col[1]=0;
    while(!q.empty()){
        int in=q.front();
        q.pop();
        for(int i=0;i<v[in].size();i++){
            if(col[v[in][i].first]==-1){
                q.push(v[in][i].first);
                if(v[in][i].second%2) col[v[in][i].first]=1-col[in];
                else col[v[in][i].first]=col[in];
            }
        }
    }
    for(int i=0;i<n;i++) cout<<col[i]<<endl;
}

Measured memory_bytes: 7936
package main

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

var sc *bufio.Scanner = func() *bufio.Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	return sc
}()

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func returnMax(a, b int) (max int) {
	add := a + b
	sub := a - b
	times := a * b
	return maxInt(times, maxInt(add, sub))
}

func maxInt(l, r int) int {
	if l < r {
		return r
	}
	return l
}

func main() {
	a, b := nextInt(), nextInt()
	max := returnMax(a, b)
	fmt.Println(max)
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define err(args...) {}
#ifdef DEBUG
#include "_debug.cpp"
#endif
using namespace std;
using ll = long long;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int a, b;
    cin >> a >> b;
    cout << (a - 1) * (b - 1) << endl;
    return 0;
}


Measured memory_bytes: 256
N = int(input())
ans = [0]*(N+1)
for x in range(1,100):
    for y in range(x,100):
        for z in range(y,100):
            tmp = x**2+y**2+z**2+x*y+y*z+z*x
            if 1<=tmp<=N:
                if x==y and y==z:
                    k = 1
                elif x==y or y==z or z==x:
                    k = 3
                else:
                    k = 6
                ans[tmp] += k
for x in ans[1:]:
    print(x)

Measured memory_bytes: 69276
import Control.Applicative
import Control.Monad
import Control.Monad.ST
import qualified Data.ByteString as BS
import Data.Functor
import Data.Function
import Data.Monoid
import Data.Maybe
import Data.List
import qualified Data.Foldable as Foldable
import qualified Data.Set as Set
--import qualified Data.Sequence as Sequence
import Data.List.Split
import Data.Bits
import Data.Char
import Data.Ix
import Data.Ratio
import Data.Ord
import Data.Tuple
import Data.Array
--import Data.Array.Unboxed
--import Data.Array.IArray
import Data.Array.MArray
import Data.Array.IO
import Data.Array.ST
import Data.IORef
import Data.STRef
-- import System.IO.Unsafe

-- templete
readInt = read :: String -> Int
readInteger = read :: String -> Integer
readDouble = read :: String -> Double
getInt = readLn :: IO Int
getInts = map readInt . words <$> getLine
getInteger = readLn :: IO Integer
getIntegers = map readInteger . words <$> getLine
getDouble = readLn :: IO Double
getDoubles = map readDouble . words <$> getLine
sjoin :: (Show a) => [a] -> String
sjoin = unwords . map show
cond :: a -> a -> Bool -> a
cond t f c = if c then t else f
apply2 :: (a -> a -> b) -> [a] -> b
apply2 f [x,y] = f x y
apply3 :: (a -> a -> a -> b) -> [a] -> b
apply3 f [x,y,z] = f x y z
apply4 :: (a -> a -> a -> a -> b) -> [a] -> b
apply4 f [x,y,z,w] = f x y z w
fnTuple :: (a -> b, a -> c) -> a -> (b, c)
fnTuple (f,g) a = (f a, g a)
replace :: (Eq a) => a -> a -> [a] -> [a]
replace x y = map (\z -> if z==x then y else z)
binMap :: (a -> a -> b) -> [a] -> [b]
binMap f (x:xs@(y:_)) = f x y : binMap f xs
binMap _ _ = []
splitRec :: Int -> [a] -> [[a]]
splitRec _ [] = []
splitRec n xs = let (y,ys) = splitAt n xs in y : splitRec n ys
infixl 7 `divCeil`
divCeil :: Integral a => a -> a -> a
x `divCeil` y = (x+y-1) `div` y
coverC :: Ord a => (a, a) -> a -> Bool
coverC (l,r) x = l<=x && x<=r
coverH :: Ord a => (a, a) -> a -> Bool
coverH (l,r) x = l<=x && x<r
ibsearch :: (Int -> Bool) -> (Int,Int) -> Int
ibsearch f (ok,ng) = if abs (ok-ng) <= 1 then ok else let mid = (ok + ng) `div` 2 in ibsearch f (if f mid then (mid,ng) else (ok,mid))
-- templete

infinity = Nothing
minJust (Just x) (Just y) = Just (min x y)
minJust mx my = mx <|> my


wf :: STArray s (Int,Int) (Maybe Int) -> Int -> ST s ()
wf arr n = do
    forM_ [0..n] $ \k -> do
        forM_ [0..n] $ \i -> do
            forM_ [0..n] $ \j -> do
                minJust <$> readArray arr (i,j) <*> (liftA2 (+) <$> readArray arr (i,k) <*> readArray arr (k,j)) >>= writeArray arr (i,j)

calc es = runST $ do
    arr <- newArray ((0,0),(9,9)) infinity :: ST s (STArray s (Int,Int) (Maybe Int))
    maxidx <- newSTRef 0
    forM_ [0..9] $ \i -> writeArray arr (i,i) (Just 0)
    forM_ es $ \[a,b,c] -> writeArray arr (a,b) (Just c) >> writeArray arr (b,a) (Just c) >> modifySTRef maxidx (max (max a b))
    m <- readSTRef maxidx
    wf arr m
    rarr <- freeze arr 
    return $ minimumBy (comparing snd) [(,) i $ sum [fromJust (rarr!(i,j)) | j <- [0..m]] | i <- [0..m]]

main = do
    n <- getInt
    unless (n==0) $ do
        es <- replicateM n getInts
        putStrLn $ (\(i,t) -> sjoin [i,t]) $ calc es
        main


Measured memory_bytes: 4768
#include<iostream>
#include<algorithm>
#include<vector>
#include<cmath>
#include<cstdio>
#include<string>
#include<cmath>
typedef long long int ll;
#define VI vector<int>

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

int n,m;

using namespace std;


int main(){
	int A=0,B=0,AB=0,O=0;
	while(1){
		int a;
		char b;
		string c;
		if(!(cin>>a>>b>>c))break;
		if(c=="A")A++;
		if(c=="B")B++;
		if(c=="AB")AB++;
		if(c=="O")O++;
		
	}
	cout<<A<<endl<<B<<endl<<AB<<endl<<O<<endl;

	return 0;
}

Measured memory_bytes: 1204
#include <stdio.h>
int main(){
  unsigned long i,n,a,result=1;
  int flag=0;
  
  scanf("%ld",&n);
  for(i=0;i<n;i++){
    scanf("%ld",&a);
    if(a==0){
      printf("%ld",a);
      return 0;
    } else {
      result*=a;
      if(result>1000000000000000000 || result<=0){
 //       printf("**%ld",result);
        result=-1;
        flag=1;
      }
    }
  }
  if(flag==1){
    printf("-1");
  } else {
    printf("%ld",result);
  }
}


Measured memory_bytes: 1736
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using System.Threading.Tasks;

class Program
{
    void Run()
    {
        var sc = new Scanner();
        int n = sc.NextInt();
        int[] w = new int[n];
        w[0] = sc.NextInt();
        for (int i = 1; i < n; i++) w[i] = sc.NextInt() + w[i - 1];
        int res = 1 << 29;
        for (int i = 0; i < n - 1; i++)
        {
            res = Math.Min(res, Math.Abs(w[i] - (w[n - 1] - w[i])));
        }
        Console.WriteLine(res);
    }

    static void Main(string[] args)
    {
        new Program().Run();
    }

    static long Gcd(long a, long b)

    {
        if (a < b) return Gcd(b, a);
        if (b == 0) return a;
        return Gcd(b, a % b);
    }
}

class Scanner
{
    int index = -1;
    string[] buf;

    public Scanner()
    {
    }

    public int NextInt()
    {
        CheckNext();
        return int.Parse(buf[index++]);
    }

    public long NextLong()
    {
        CheckNext();
        return long.Parse(buf[index++]);
    }

    public double NextDouble()
    {
        CheckNext();
        return double.Parse(buf[index++]);
    }

    public string NextString()
    {
        CheckNext();
        return buf[index++];
    }

    private void CheckNext()
    {
        if (index >= 0 && index < buf.Length) return;

        buf = Console.ReadLine().Split(' ');
        index = 0;
    }
}


Measured memory_bytes: 11092
//   _/                _/                 _/_/_/   _/
//_/_/_/_/   _/_/   _/_/_/_/   _/_/    _/       _/_/
// _/     _/    _/   _/     _/    _/  _/_/_/     _/
//_/     _/    _/   _/     _/    _/  _/    _/   _/
// _/_/   _/_/       _/_/   _/_/      _/_/     _/
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<queue>
#include<vector>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const double pi=3.14159265358979323846;
const int inf=2e9;
const ll INF=5e18;
typedef pair<int,int> P;
int main() {
  cin.tie(0),cout.tie(0);
  ios::sync_with_stdio(false);
  string s;
  int a[4]={},b[3]={};
  cin >> s;
  for(int i=0; i<4; i++) {
    a[i]=s[i]-'0';
  }
  for(int i=0; i<(1<<3); i++) {
    b[3]={};
    for(int j=0; j<3; j++) {
      if(i&(1<<j)) {
        b[j]=1;
      }
      else {
        b[j]=-1;
      }
    }
    if(a[0]+a[1]*b[0]+a[2]*b[1]+a[3]*b[2]==7) {
      cout << a[0] << (b[0]==1?'+':'-') << a[1] << (b[1]==1?'+':'-') << a[2] << (b[2]==1?'+':'-') << a[3] << "=7" << endl;
      return 0;
    }
  }
}


Measured memory_bytes: 256
import java.util.*;
 
class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int b = 2;
        int[]a = new int[b];
        for(int i = 0; i < b; i++){
            a[i] = sc.nextInt();
        }
        sc.close();
        //result(a)でa[]を送れる
        int re = result(a);
        System.out.println(re);
    }
 
    //判定
    private static int result(int a[]){
        int re = 0;
        if(a[0] < a[1]){
            re = 0;
        }else{
            re = 10;
        }
        return re;
    }
}

Measured memory_bytes: 21844
#include <iostream>
#include <cstdlib>

using namespace std;

int main(){
    int w,a,b,ans;
    cin >> w >> a >> b;

    int l1 = a+w;
    int l2 = b+w;

    if(l1 < b){
        ans = abs(l1-b);
    }else if(l2 < a){
        ans = abs(l2-a);
    }else{
        ans = 0;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
int x,y,i;
int R[100000];


scanf("%d %d",&x,&y);

if(x==y){
 printf("%d\n",x);

}else if(x>y){

  R[0]=y;
  R[1]=x%y;

 for(i=2;i<x;i++){
 if(R[i-1]==0){
  printf("%d\n",R[i-2]);
  break;
 }else if(R[i-1]==1){
  printf("1\n");
  break;
 }else{
  R[i]=R[i-2]%R[i-1];
 }
}






}else if(x<y){


  R[0]=x;
  R[1]=y%x;

 for(i=2;i<y;i++){
 if(R[i-1]==0){
  printf("%d\n",R[i-2]);
  break;
 }else if(R[i-1]==1){
  printf("1\n");
  break;
 }else{
  R[i]=R[i-2]%R[i-1];
 }
}



}




return 0;
}

Measured memory_bytes: 1852
#include <iostream>
#include <vector>
#include <cstdio>
#include <string>
#include <algorithm>

using namespace std;

int main() {
    int r, D, x;
    cin >> r >> D >> x;
    for (int i = 0; i < 10; i++)
    {
        int ans = r*x-D;
        x = ans;
        cout << ans << endl;
    }
    
    

    /*
    int a,B;
    cin >> a >> B;
    if (a >= 13)
    {
        cout << B << endl;
    } else if (a >= 6 && a <= 12){
        cout << B / 2 << endl;
    } else {
        cout << 0 <<endl; 
    }
    */
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cmath>

int main() {
	int A, B;
	scanf("%d%d", &A, &B);
	if (A + B == 0) puts("1");
	else if (abs(A) < abs(B)) printf("%d\n", abs(B) - abs(A) + (A < 0) + (B < 0));
	else printf("%d\n", abs(A) - abs(B) + (A > 0) + (B > 0));
	return 0;
}

Measured memory_bytes: 1732
#include<bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i= (a); i < (b); ++i)
typedef long long ll;
typedef pair<int,int> P;
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
int main() { int N, R;
  cin >> N >> R;
    if(10<=N){
      cout << R << endl;
    }else{
      cout << R + 100 * (10 - N) << endl;
    }
}

Measured memory_bytes: 256
var input = '';
var readable = process.stdin;
readable.resume();
readable.setEncoding( 'utf-8' );
readable.on( 'data', function( chunk ) {
  input += chunk;
});

readable.on( 'end', function() {
  var cards = { "S":[] , "H":[], "C":[], "D":[] };
  var shcd = [ 'S', 'H', 'C', 'D' ];
  for( var key in cards ) {
    for( var i=1; i<=13; i++ ) {
      cards[key].push( i );
    }
  }
  var data = input.split( '\n' );
  
  for( var i=1; i<data.length; i++ ) {
    var x = data[i].split( ' ' );

    var k = "S";
    if( 'S' === x[0] ) {
      k = 'S';
    } else if( 'H' === x[0] ) {
      k = 'H';
    } else if( 'C' === x[0] ) {
      k = 'C';
    } else if( 'D' === x[0] ) {
      k = 'D';
    }
    var res = cards[k].indexOf( Number( x[1] ) );
    if( -1 != res ) {
        cards[k].splice( res, 1 );
    }
  }
  for( var i=0; i<4; i++ ) {
    for( var j = 0; j<cards[ shcd[i] ].length; j++ ) {
      console.log( shcd[i]+" "+cards[ shcd[i] ][j] );
    }
  }
});

Measured memory_bytes: 7644
#include<iostream>
    using namespace std;
    int main()
    {
        int a,b;
      
      
      
        cin>>a>>b;
        int c,y,t;
      
      
        c=a*b;
        y=a-b;
        t=a+b;
        if(c>=t&&c>=y)
        {
            cout<<c;
        }
        else if(y>=c&&y>=t)
        {
            cout<<y;
        }
        else if(t>=c&&t>=y)
        {
            cout<<t;
        }
     
     
     
        return 0;
    }

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main() {
  string s, t;
  cin >> s >> t;
  auto const slen = s.size(), tlen = t.size();
  vector<int> sa(slen + 1), sb(slen + 1), ta(tlen + 1), tb(tlen + 1);
  for (int i = 1; i <= slen; i++) {
    if (s[i - 1] == 'A') {
      sa[i] = sa[i - 1] + 1;
      sb[i] = sb[i - 1];
    }
    else {
      sa[i] = sa[i - 1];
      sb[i] = sb[i - 1] + 1;
    }
  }
  for (int i = 1; i <= tlen; i++) {
    if (t[i - 1] == 'A') {
      ta[i] = ta[i - 1] + 1;
      tb[i] = tb[i - 1];
    }
    else {
      ta[i] = ta[i - 1];
      tb[i] = tb[i - 1] + 1;
    }
  }
  int q;
  cin >> q;
  for (int i = 0; i < q; i++) {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    int sacnt = sa[b] - sa[a - 1],
        sbcnt = sb[b] - sb[a - 1],
        tacnt = ta[d] - ta[c - 1],
        tbcnt = tb[d] - tb[c - 1];
    int sdiff = ((sacnt % 3 + 3) - (sbcnt % 3)) % 3,
        tdiff = ((tacnt % 3 + 3) - (tbcnt % 3)) % 3;
    cout << (sdiff == tdiff ? "YES" : "NO") << '\n';
  }
}


Measured memory_bytes: 2432
import sys
import numpy as np


def main():
    n, a, b, c, d = [int(x) for x in input().split()]
    a -= 1
    b -= 1
    c -= 1
    d -= 1
    nv = np.insert(np.array([1 if char == '#' else 0 for char in input()]).cumsum(), 0, 0)
    for i in range(a, max(c, d)):
        if nv[i + 2] - nv[i] == 2:
            print("No")
            sys.exit()
    if c < d:
        print("Yes")
        sys.exit()
    for i in range(b, d + 1):
        if nv[i + 2] - nv[i - 1] == 0:
            print("Yes")
            sys.exit()
    print("No")


main()


Measured memory_bytes: 15740
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")
#include <bits/stdc++.h>
using namespace std;
#define int                 long long   
#define double              long double
#define endl                "\n"
#define pb                  push_back
#define PI                  3.1415926535897932384626433832795l
#define F                   first
#define S                   second
#define mp                  make_pair
#define f(i,n)              for(int i=0;i<n;++i)
#define loop(i,a,b)         for (int i=a ; i<b ;++i)
#define fastio              ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define all(v)              (v).begin(),(v).end()
#define rall(v)             (v).rbegin(),(v).rend()
#define gcd(a,b)            __gcd((a),(b))
#define fill(a,value)       memset(a,value,sizeof(a));
#define minn(v)             *min_element(v.begin(), v.end());
#define maxx(v)             *max_element(v.begin(), v.end());
#define print(x)            cout<<(x)<<endl;
#define sum(v)+x            accumulate(v.begin(), v.end(),x);
typedef pair<int,int> pii;  
typedef vector<int> vi;

signed main() 
{
    fastio;
    cout << fixed << setprecision(12);
    int x,k,d;
    cin>>x>>k>>d;
    x=abs(x);
    int rem=x%d;
    int r2=abs(rem-d);
    int z=x/d;
    int pos=x-k*d;
    if(z>=k)
    {
        print(abs(pos))
    }
    else
    {
        int v=k-z;
        if(v%2)print(r2)
        else
        {
            print(rem)
        }
    }
    return 0;
}

Measured memory_bytes: 3644
N, M = map(int, input().split())
A = list(map(int, input().split()))
BC = [list(map(int, input().split())) for i in range(M)]

A = sorted(A)
BC = sorted(BC, key=lambda x: -x[1])

lenA = len(A)
i = 0
for bc in BC:
  for j in range(bc[0]):
    if i > lenA-1: break
    if A[i] > bc[1]: break
    A[i] = bc[1]
    i += 1

print(sum(A))

Measured memory_bytes: 36932
S = input()
T = input()

n, m = len(S), len(T)
maximum = 0
for i in range(n - m + 1):
    count = 0
    for j in range(m):
        if S[j + i] == T[j]:
            count += 1
    maximum = max(maximum, count)

ans = m - maximum

print(ans)

Measured memory_bytes: 9128