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

int main()
{
    int a, b;
    while (1)
    {
        cin >> a >> b;
        if (a == 0 && b == 0)
            break;
        for (int i = 0; i < a; i++)
        {
            for (int j = 0; j < b; j++)
            {
                if((i+j)%2==0 || i+j == 0)cout << '#';
                else if((i+j)%2 == 1 || i+j == 1)cout << '.';
            }
            cout << endl;
        }
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 3088
import java.util.Arrays;
import java.util.Scanner;

public class Main {
  Scanner sc;

  void run() {
    for ( ;; ) {
      int n = ni();
      int m = ni();

      if ( ( n | m ) == 0 )
        break;

      int[] t = new int[n];
      int[] h = new int[m];

      int sumt = 0;
      for ( int i = 0; i < n; ++i ) {
        t[ i ] = ni();
        sumt += t[ i ];
      }
      int sumh = 0;
      for ( int i = 0; i < m; ++i ) {
        h[ i ] = ni();
        sumh += h[ i ];
      }

      int min = 1 << 28;
      int mintidx = 0;
      int minhidx = 0;
      boolean f = false;
      for ( int i = 0; i < n; ++i ) {
        for ( int j = 0; j < m; ++j ) {
          if ( ( sumt - t[ i ] + h[ j ] ) == ( sumh - h[ j ] + t[ i ] ) ) {
            f |= true;
            if ( t[ i ] + h[ j ] < min ) {
              min = t[ i ] + h[ j ];
              mintidx = i;
              minhidx = j;
            }
          }
        }
      }

      if ( f ) {
        System.out.println( t[ mintidx ] + " " + h[ minhidx ] );
      } else {
        System.out.println( -1 );
      }
    }
  }

  Main() {
    sc = new Scanner( System.in );
  }

  int ni() {
    return sc.nextInt();
  }

  public static void main(String[] args) {
    new Main().run();
  }

  void debug(Object... os) {
    System.err.println( Arrays.deepToString( os ) );
  }
}

Measured memory_bytes: 21056
#include <bits/stdc++.h>
#define REP(i, n) for (int (i) = 0; (i) < (int)(n); i++) 
#define FOR(i, a, b) for(int (i) = a; (i) < (int)b; i++)
#define RREP(i, n) for(int (i)=((int)(n)-1); (i)>=0; i--)
#define RFOR(i, a, b) for(int (i) =((int)(b)-1); (i)>=(int)a; i--)
#define ALL(v) (v).begin(),(v).end()
#define MOD 1000000007
#define F first
#define S second

using namespace std ;
typedef long long ll;
typedef vector<int> vint;
typedef vector<vint> vvint;
typedef pair<int, int> pint;

int main()
{
  int n, t, a ;
  cin >> n >> t >> a ;
  vector<double> hei(n) ;
  vector<double> tmp(n) ;
  double min = 10000000 ;
  int ans = 0 ;
  
  
  REP(i,n){
    cin >> hei.at(i) ;
  }
  
  REP(i,n){
    tmp.at(i) = t - hei.at(i)*0.006 ;
  }
  REP(i,n){
    if(abs(a-tmp.at(i))<min){
      min = abs(a-tmp.at(i)) ;
      ans = i+1 ;
    }
  }
  
  cout << ans <<endl ;

  return 0 ;
}




Measured memory_bytes: 256
n = int(raw_input())
base = 196471
year = 195
month = [20,19,20,19,20,19,20,19,20,19]
for _ in xrange(n):
  Y,M,D = map(int, raw_input().split())
  days = 0
  days += (Y-1) * year + (Y-1) / 3 * 5
  for i in xrange(M-1):
    if Y%3 == 0:
      days += 20
    else:
      days += month[i]
  days += D
  print base - days

Measured memory_bytes: 6280
#include <stdio.h>

long long int factrial(long long int n) {
    if(n == 1) {
        return(1);
    } else {
        return(n * factrial(n - 1));
    }
}

int main(void) {
    long long int n;

    scanf("%lld", &n);
    printf("%lld\n", factrial(n));
    
    return(0);
}

Measured memory_bytes: 592
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll mod=1e9+7;
ll dp[1050][1050];
int main()
{
    ll n, m; cin >> n >> m;
    char grid[n][m];
    dp[0][0]=1;
    for (int i=0 ; i<n ; i++)
    {
        for (int j=0 ; j<m ; j++)
        {
            cin >> grid[i][j];
            if (grid[i][j]=='#')
            {
                dp[i][j]=0;
                continue;
            }
            if (i)dp[i][j]+=dp[i-1][j];
            if (j)dp[i][j]+=dp[i][j-1];
            dp[i][j]%=mod;
        }
    }
    cout << dp[n-1][m-1];
    return 0;
}


Measured memory_bytes: 9472
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false), cin.tie(0)
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, a, b) for (int i = a; i < b; i++)
#define ALL(x) (x).begin(), (x).end()
#define dump(x) cout << (x) << endl
#define LMAX 9223372036854775807LL
#define LMIN -9223372036854775807LL
using ll = long long;
template<typename T>
using vec = vector<T>;
using P = pair<ll, ll>;
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
	fill((T *)array, (T *)(array + N), val);
}

const ll INF = 1e16;
const ll MOD = 1e9 + 7;
//int dx[4] = {1,0,-1,0};
//int dy[4] = {0,1,0,-1};
//ll pas[51][52];

signed main(){
	IOS;
	ll n, k;
	cin >> n >> k;
	vec<ll> h(n);
	REP(i,n)cin >> h[i];
	sort(ALL(h));
	ll ans = INF;
	for(int i = 0;i < n - k + 1;i++){
		ans = min(ans,h[i + k - 1] - h[i]);
	}
	dump(ans);
}	

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

using namespace std;
typedef long long ll;
typedef vector<ll> VL;
typedef vector<VL> VVL;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()

signed main(void) {
  ll n, k, l, r, a[45];
  cin >> n >> k >> l >> r;
  REP(i, n) cin >> a[i];
  ll n2 = n / 2;
  //ps1[i] = i個選択したときのコインの合計価格の集合
  VVL ps1(n2 + 1), ps2(n - n2 + 1);

  //前半分を全列挙
  REP(i, 1 << n2) {
    ll vl = 0, cnt = 0;
    REP(j, n2) if (i >> j & 1) {vl += a[j]; ++cnt;}
    ps1[cnt].push_back(vl);
  }
  //後半分を全列挙
  REP(i, 1 << (n - n2)) {
    ll vl = 0, cnt = 0;
    REP(j, n - n2) if (i >> j & 1) {vl += a[n2 + j]; ++cnt;}
    ps2[cnt].push_back(vl);
  }
  //前半分をソート
  REP(i, n2) sort(ALL(ps1[i]));

  ll ret = 0;
  FOR(i, max((ll)0, k - n2), min(k, n - n2) + 1) {
    REP(j, ps2[i].size()) {
      //二分探索で個数を求める
      ret += (ll)(upper_bound(ALL(ps1[k - i]), r - ps2[i][j]) -
                  lower_bound(ALL(ps1[k - i]), l - ps2[i][j]));
    }
  }
  cout << ret << endl;
  return 0;
}


Measured memory_bytes: 23432
#include <bits/stdc++.h>
#include <math.h>
#include <cmath>

using namespace std;
using ll =long long;
using vi = vector<int>; 
using vvi = vector<vi>; 
using vl = vector<ll>; 
using vvl = vector<vl>; 
using vs = vector<string>;
using vvs = vector<vs>; 
using vc = vector<char>;
using vvc = vector<vc>; 
using vb = vector<bool>;
using vvb = vector<vb>; 

#define rep(i,n) ;for( int i =0; i < n ; i ++)
#define all(a) a.begin(),a.end()
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define f(i,a,b) for(int i=a;i<b;i++)
#define pri(a)  printf("%.14lf\n",a);
#define MOD 1000000007
bool is_int_lround(double x){
  return std::lround(x)==x;
}
ll keta(ll x){
  int n=0;
  while(x>0){
    x /=10 ;
    n ++;
  }
  return n;
}

ll conbi(int n,int m){
  
  cin>>n>>m;
  vector<ll> a(100);
  a[0] =1;
  for(int i=0;i<14;i++){
    a[i+1]=a[i]*(i+1);
  }
  return a[n] /(a[m] *a[n-m]);
}

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
int main(){
  ll a,b,k;cin>>a>>b>>k;
  cout<< max(a-k,0LL)<<" "<< max(min(b,b-k+a),0LL)<<endl;
  
}
  


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <unordered_set>
#include <unordered_map>
#include <set>
#include <map>
#include <list>
#include <algorithm>
#include <iterator>
#include <utility>
using namespace std;

int main(){
    int n,x,t;
    cin>>n>>x>>t;
    if(n%x==0)
        cout<<n/x * t;
    else
    {
            cout<<n/x * t + t;
    }
    
	return 0;
}


Measured memory_bytes: 3596
import java.util.Scanner;

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

		double cosC = Math.cos(C * (Math.PI / 180));
		double sinC = Math.sin(C * (Math.PI / 180));
		double S = a * b * sinC / 2;
		double x2 = b*cosC;
		double y2 = b*sinC;

		double L1=(x2-a)*(x2-a);
		double L2=(y2)*(y2);

		System.out.println(S);
		double L = Math.sqrt(L1 + L2);
		System.out.println(L + a + b);
		System.out.println(b * sinC);
    }
}


Measured memory_bytes: 27892
#include<bits/stdc++.h>
const int maxk=100001;
using namespace std;
int main()
{
   int a,b,c;
   cin>>a>>b>>c;
   int jud=0;
   for(int i=b;i<=c;i++)
   {
       if(i%a==0)
           jud=1;
   }
   if(jud==1) cout<<"OK";
   else cout<<"NG";

}

Measured memory_bytes: 3636
/*https://atcoder.jp/contests/abc127/tasks/abc127_c*/
#include<bits/stdc++.h>
using namespace std;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
#ifndef ONLINE_JUDGE
	// for getting input from input.txt
	freopen("input.txt", "r", stdin);
	// for writing output to output.txt
	freopen("output.txt", "w", stdout);
#endif
	int n, m;
	cin >> n >> m;
	int l[m], r[m], lmax = 0, rmin = 0;
	for (int i = 0; i < m; i++)
		cin >> l[i] >> r[i];
	sort(l, l + m);
	sort(r, r + m);
	lmax = l[m - 1], rmin = r[0];
	cout << max(0, rmin - lmax + 1);
}

Measured memory_bytes: 4372
#include <bits/stdc++.h>
using namespace std;
using pii=pair<int,int>;
using ll=long long;
using pll=pair<ll,ll>;

#define fi first
#define se second
#define pb push_back
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#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 (b<a) { a=b; return 1; } return 0; }

int main() {
	string s;
	int k;
	cin >> k >> s;
	if(s.length() <= k) cout << s << endl;
	else {
		rep(i,k) cout << s[i];
		cout << "..." << endl;
	}

  return 0;
}


Measured memory_bytes: 3628
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>
#include <time.h>
#include <tuple>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e12;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define rep(i,N) for(ll i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1
#define MAX_N 100100

ll sq(ll num) { return num*num; }
ll mod_pow(ll x, ll n) {
	if (n == 0)return 1;
	if (n == 1)return x%MOD;
	ll res = sq(mod_pow(x, n / 2));
	res %= MOD;
	if (n % 2 == 1) {
		res *= x;
		res %= MOD;
	}
	return res;
}
ll mod_add(ll a, ll b) { return (a + b) % MOD; }
ll mod_sub(ll a, ll b) { return (a - b + MOD) % MOD; }
ll mod_mul(ll a, ll b) { return a*b % MOD; }

ll n, m, c, s, g;
ll p[50], q[50][100], r[50][100];
ll dp[50][110][110];
ll cost[110][110];
ll dc[50][20100];


int main() {
	while (cin >> n >> m >> c >> s >> g&&n + m + c + s + g) {
		s--; g--;
		rep(i, 50) {
			rep(j, 110) {
				rep(k, 110) {
					if (j == k) {
						dp[i][j][k] = 0;
						cost[j][k] = 0;
					}
					else {
						dp[i][j][k] = INF;
						cost[j][k] = INF;
					}
				}
			}
			rep(j, 20100)dc[i][j] = 0;
		}
		rep(i, m) {
			ll x, y, d, cc;
			cin >> x >> y >> d >> cc;
			x--; y--; cc--;
			dp[cc][x][y] = min(d, dp[cc][x][y]);
			dp[cc][y][x] = min(d, dp[cc][y][x]);
		}
		rep(ii, c) {
			rep(k, n) {
				rep(i, n) {
					rep(j, n) {
						dp[ii][i][j] = min(dp[ii][i][j], dp[ii][i][k] + dp[ii][k][j]);
					}
				}
			}
		}
		//cout << "!" << c << endl;
		//rep(ii, c) {
		//	rep(i, n) {
		//		rep(j, n) {
		//			cout << dp[ii][i][j] << " ";
		//		}
		//		cout << endl;
		//	}
		//	cout << endl;
		//}

		rep(i, c) {
			cin >> p[i];
		}
		rep(i, c) {
			//cout << "!" << p[i] << endl;
			rep(j, p[i] - 1)cin >> q[i][j];
			q[i][p[i] - 1] = INF;
			rep(j, p[i])cin >> r[i][j];
		}
		rep(i, c) {
			ll cnt = 0;
			rep(j, 20090) {
				dc[i][j + 1] = dc[i][j] + r[i][cnt];
				if (j + 1 == q[i][cnt])cnt++;
			}
		}
		//rep(i, c) {
		//	rep(j, 10)cout << dc[i][j] << " ";
		//	cout << endl;
		//}
		rep(i, c) {
			rep(j, n) {
				rep(k, n) {
					ll d = dp[i][j][k];
					if (d == INF)continue;
					cost[j][k] = min(cost[j][k], dc[i][d]);
				}
				//cout << endl;
			}
			//cout << endl;
		}
		//rep(i, n) {
		//	rep(j, n)cout << cost[i][j] << " ";
		//	cout << endl;
		//}

		rep(k, n) {
			rep(i, n) {
				rep(j, n)cost[i][j] = min(cost[i][j], cost[i][k] + cost[k][j]);
			}
		}
		//cout << "!!!ans";
		if (cost[s][g] != INF)cout << cost[s][g] << endl;
		else cout << -1 << endl;
	}
}


Measured memory_bytes: 15816
#include <stdlib.h>
#include <string>
#include <iostream>

using namespace std;

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

    int b_count=0;
    int e_count=0;
    int count=0;

    for(int i=0;i<N;i++){
        if(S[i] == '('){
            count++;
        }
        else{
            count--;
            if(count == -1){
                count=0;
                b_count++;
            }
        }
        e_count = count;
    }
    for(int i=0;i<b_count;i++){
        cout << "(";
    }
    cout << S;
    for(int i=0;i<e_count;i++){
        cout << ")";
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
///AJoy Sarker ,CSE JAHANGIRNAGAR UNIVERSITY 48 Batch
#include<bits/stdc++.h>
using namespace std;
#define SORT(c) sort((c).begin(),(c).end());
#define inf INT_MAX/3
#define pb push_back
#define MP make_pair
#define pii pair<int,int>
#define pcc pair<char,char>
#define pic pair<int,char>
#define pci pair<char,int>
#define VS vector<string>
#define VI vector<int>
#define MIN(a,b) (a>b?b:a)
#define MAX(a,b) (a>b?a:b)
#define pi 3.141592653589793
#define in scanf
#define out printf
#define ll long long
#define ull unsigned long long
#define w(x) int x;cin>>x;while(x--)
#define fast ios_base::sync_with_stdio(0)
typedef unsigned long long UL;
template<typename T>inline T  S(T a)
{
    return a*a;
}
template<class T>inline string tostring(T a)
{
    ostringstream os("");
    os << a;
    return os.str();
}
template<typename T>inline ll tolong(T a)
{
    ll res;
    istringstream os(a);
    os>>res;
    return res;
}
template<typename T>inline T gcd(T a, T b)
{
    if (b == 0)return a;
    else return gcd(b, a % b);
}
template<typename T>inline T bigmod(T a, T b, T m)
{
    if (b == 0)return 1;
    else if (b % 2 == 0)return S(bigmod(a, b / 2, m)) % m;
    else return (a % m*bigmod(a, b - 1, m)) % m;
}

char a[59];

map<pair<int,int>,int> mp;
int vis[159];
int main()
{
    fast;
    string s;
    cin>>s;
    bool ok=0;
    for(int i=0;i<s.size();i++)
    {
        if(s[i]=='7') ok=1;
    }
    cout<<(ok?"Yes\n":"No\n");
    return 0;

}




Measured memory_bytes: 3612
import sys
sys.setrecursionlimit(10**7)

readline = sys.stdin.buffer.readline
def readstr():return readline().rstrip().decode()
def readstrs():return list(readline().decode().split())
def readint():return int(readline())
def readints():return list(map(int,readline().split()))
def printrows(x):print('\n'.join(map(str,x)))
def printline(x):print(' '.join(map(str,x)))


import bisect

n,k = readints()

a = readints()

place = [[] for i in range(max(a)+1)]

for i,x in enumerate(a):
    place[x].append(i)

now = 0
i = 1
while k>1:
    x = a[now]
    if now >= place[x][-1]:
        i+=1
        k-=1
        now = place[x][0]+1
    else:
        now = place[x][bisect.bisect_right(place[x],now)] + 1
    if now == n:
        now = 0
        k-=1
        k%=i
        if k<1:
            k+=i

ans = []
while now <= n-1:
    x = a[now]
    if now >= place[x][-1]:
        ans.append(x)
        now += 1
    else:
        now = place[x][bisect.bisect_right(place[x],now)] + 1

printline(ans)


















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

using namespace std;

long long int MOD = 1e9 + 7;
long long int f[200001]={0,};
long long int inv[200001]={0,};

long long int pow(long long int a,long long int n)
{
	long long int res = 1;
	while(n>0)
	{
		if(n%2==1)
		{
			res = (res%MOD)*(a%MOD);
			res%=MOD;
		}
		a = (a%MOD)*(a%MOD);
		a%=MOD;
		n/=2;
	}

	return res;
}

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

	int h,w,a,b;

	f[0]=1;
	for(int i=1;i<=200000;i++)
	{
		f[i] = (f[i-1]%MOD)*(i%MOD);
		f[i]%=MOD;
	}

	inv[200000] = pow(f[200000],MOD-2);
	inv[200000]%=MOD;
	for(int i=200000-1;i>=0;i--)
	{
		inv[i] = ((i+1)%MOD)*(inv[i+1]%MOD);
		inv[i]%=MOD;
	}

	cin >> h >> w >> a >> b;
	long long int res = 0;

	for(int i=1;i<=h-a;i++)
	{
		long long int y = (i-1);
		long long int x = (b-1);
		long long int t = f[x+y]%MOD;
		t = (t%MOD)*(inv[x]%MOD);
		t%=MOD;
		t = (t%MOD)*(inv[y]%MOD);
		t%=MOD;
		//cout << y << ' ' << x << ' ' << t << '\n';
		y = (h-i);
		x = (w-b-1);
		t = (t%MOD)*(f[x+y]%MOD);
		t%=MOD;
		t = (t%MOD)*(inv[x]%MOD);
		t%=MOD;
		t = (t%MOD)*(inv[y]%MOD);
		t%=MOD;
		//cout << y << ' ' << x << ' ' << t << '\n';
		res = (res%MOD) + (t%MOD);		
		res%=MOD;
	}

	cout << res << '\n';
	return 0;
}

Measured memory_bytes: 3328
#include <iostream>
#include <cmath>
#include <algorithm>

using namespace std;

const int MAX = 1001;
 
int V,d;
int v[MAX];
 
void fibo(){
    v[0] = 1,v[1] = 2;
    for(int i = 2 ; i < MAX ; i++){
	v[i] = (v[i-1]+v[i-2])%MAX;
    }
}
 
int main(){
    while(cin >> V >> d){
	fibo();
	sort(v,v+V+1);
	int cnt = 1;
	for(int i = 2; i <= V ; i++){
	    if(v[i-1] + d <= v[i]) cnt++;
	}
	cout << cnt << endl;
    }
    return 0;
}

Measured memory_bytes: 3148
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>
#include <numeric>
#include <queue>
#include <stack>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9) + 7;

int main(void) {
	int n;
	cin >> n;
	
	map<int, int> mp;
	for(int i = 0; i < n; ++i) {
		int a;
		cin >> a;
		mp[a]++;
	}
	
	int ans = 0;
	for(auto& x : mp) {
		int tmp = x.second - x.first;
		
		if( tmp > 0 ) { 
			ans += tmp;
		} else if( tmp < 0 ){
			ans += x.second;
		}
	}
	
	cout << ans << endl;
	
	return 0;
}


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


#define ll unsigned long long
#define FASTIO ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
using namespace std;

const ll maxn = 501;
const int MOD = 1e9+7;


ll power(ll x, ll int y){
    int res = 1; // Initialize result

    while (y > 0) {
        // If y is odd, multiply x with result
        if (y & 1)
            res = (res * x + MOD)%MOD;

        // n must be even now
        y = y >> 1; // y = y/2
        x = (x * x)%MOD; // Change x to x^2
    }
    return res;
}


int main(){
    FASTIO
    int n,x;cin >> n >> x;
    vector<int> l(n+1);
    l[0] = 0;
    for(int i=1;i<=n;i++){
        cin >> l[i];
        l[i] += l[i-1];
    }
    int pos = lower_bound(l.begin(),l.end(),x) - l.begin();
    if(l[pos] == x) ++pos;
    cout << pos;
}

Measured memory_bytes: 256
t = int(input())
c0, c1, c2, c3 = 0, 0, 0, 0
for i in range(0, t):
    n = input()
    if n == 'AC':
        c0 += 1
    elif n == 'WA':
        c1 += 1
    elif n == 'TLE':
        c2 += 1
    elif n == 'RE':
        c3 += 1
print('AC x ' + str(c0))
print('WA x ' + str(c1))
print('TLE x ' + str(c2))
print('RE x ' + str(c3))

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


int main() {
  string s;
  cin >> s;
  if (s[3]=='7') s[3] = '8';
  cout << s << endl;
  return 0;
}

Measured memory_bytes: 256
# エラトステネスの篩
# https://qiita.com/takayg1/items/3769ab4cc62a231f4259

def eratosthenes_sieve(n):
    is_prime = [True]*(n + 1)
    is_prime[0] = is_prime[1] = False
    for p in range(2, n + 1):
        if is_prime[p]:
            for q in range(2*p, n + 1, p):
                is_prime[q] = False
    return is_prime

MAX_N=(10**6)
Primes = eratosthenes_sieve(MAX_N)

x = int(input())
while True:
    if Primes[x]:
        print(x)
        exit()
    x += 1

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

int soed(int i) {
	int sum = 0;
	string s = to_string(i);
	for (int j = 0; j < s.length(); j++) {
		sum += s[j] - '0';
	}
	return sum;
}

int main() {
	int n;
	cin >> n;
	int a, b;
	int ans = 1e9;
	for (int i = 1; i < n; i++) {
		a = i; b = n - i;
		ans = min(ans, soed(a) + soed(b));
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define fr(i1,m) for(int i1=0;i1<m;i1++)
using namespace std;
int main()
{
       long x,y,z;
       while(cin>>x>>y>>z)
       {
           long a[10010]={0};
          a[x]++;
          a[y]++;
          a[z]++;
          if(a[5]==2&&a[7]==1)
          {
              cout<<"YES\n";
          }
          else
            cout<<"NO\n";
       }
        return 0;

}




Measured memory_bytes: 384
#include<bits/stdc++.h>
//ios::sync_with_stdio(false);
//cin.tie(0);
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> plpl;
typedef tuple<ll,ll,ll> tl;
ll mod2=1000000007;
ll mod=998244353;
ll inf=1000000000000000000;
double pi=2*acos(0);
#define rep(i,m,n) for(int i=m;i<n;i++)
#define rrep(i,n,m) for(int i=n;i>=m;i--)
int dh[4]={1,-1,0,0};
int dw[4]={0,0,1,-1};
int ddh[8]={-1,-1,-1,0,0,1,1,1};
int ddw[8]={-1,0,1,-1,1,-1,0,1};
ll lmax(ll a,ll b){
    if(a<b)return b;
    else return a;
}
ll lmin(ll a,ll b){
    if(a<b)return a;
    else return b;
}
int main(){
    ll n;cin>>n;
    ll a[n+1],b[n];
    rep(i,0,n+1)cin>>a[i];
    rep(i,0,n)cin>>b[i];
    ll ans=0;
    rep(i,0,n){
        if(a[i]>=b[i]){
            ans+=b[i];
        }
        else{
            ans+=a[i];
            b[i]-=a[i];
            if(a[i+1]>=b[i]){
                ans+=b[i];
                a[i+1]-=b[i];
            }
            else{
                ans+=a[i+1];
                a[i+1]=0;
            }
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 1792
N, P = map(int, input().split())
S = input()

res = 0

if P == 2 or P == 5:
    # Corner case
    for i in range(N):
        if int(S[N - i - 1]) % P == 0:
            res += N - i
else:
    val = [0] * P
    tenfactor = 1
    cur = 0
    val[cur] += 1
    for i in range(N):
        cur = (cur + int(S[N - i - 1]) * tenfactor) % P
        tenfactor = (tenfactor * 10) % P
        val[cur] += 1
        
    # Combination
    for p in range(P):
        res += val[p] * (val[p] - 1) // 2
    
print(res)



Measured memory_bytes: 41180
#!/usr/bin/env python3
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        if self.parents[x] > self.parents[y]:
            x, y = y, x
        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

(n, m), *q = [map(int, i.split()) for i in open(0)]
UF = UnionFind(n)
conv = [n * ~-n // 2]
for a, b in q[::-1]:
    a -= 1
    b -= 1
    if UF.same(a, b):
        conv += conv[-1],
    else:
        conv += conv[-1] - UF.size(a) * UF.size(b),
    UF.union(a, b)
del conv[-1]
for i in conv[::-1]:
    print(i)

Measured memory_bytes: 51556
package main

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

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

func scanString() string   { sc.Scan(); return sc.Text() }
func scanRunes() []rune    { return []rune(scanString()) }
func scanInt() int         { a, _ := strconv.Atoi(scanString()); return a }
func scanInt64() int64     { a, _ := strconv.ParseInt(scanString(), 10, 64); return a }
func scanFloat64() float64 { a, _ := strconv.ParseFloat(scanString(), 64); return a }

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

func debug(a ...interface{}) { fmt.Fprintln(os.Stderr, a...) }

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}
func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

//•*¨*•.¸¸♪main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)
func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1001001)

	n := scanInt()
	m := scanInt()
	g := make([][]int, n)
	for i := 0; i < m; i++ {
		a, b := scanInt()-1, scanInt()-1
		g[a] = append(g[a], b)
	}

	var dfs func(a int, arr []int) bool
	t := 0
	ts := make([]int, n)
	var ans []int
	var s int
	dfs = func(a int, arr []int) bool {
		if len(arr) != 0 && a == s {
			ans = arr
			return true
		}
		for _, b := range g[a] {
			if ts[b] == t {
				continue
			}
			ts[b] = t
			if dfs(b, append(arr, b)) {
				return true
			}
		}
		return false
	}

	for i := 0; i < n; i++ {
		t++
		s = i
		dfs(i, []int{})
	}

	if len(ans) == 0 {
		fmt.Fprintln(wr, -1)
		return
	}

	for {
		f := make([]bool, n)
		idx := map[int]int{}
		for i := 0; i < len(ans); i++ {
			f[ans[i]] = true
			idx[ans[i]] = i
		}
		a, b := -1, -1
		for i := 0; i < len(ans); i++ {
			next := ans[(i+1)%len(ans)]
			for _, v := range g[ans[i]] {
				if f[v] && v != next {
					a, b = i, idx[v]
					break
				}
			}
			if b != -1 {
				break
			}
		}
		// debug(ans, a, b)
		if b == -1 {
			fmt.Fprintln(wr, len(ans))
			for i := 0; i < len(ans); i++ {
				fmt.Fprintln(wr, ans[i]+1)
			}
			return
		}
		if a > b {
			ans = ans[b : a+1]
		} else {
			ans = append(ans[:a+1], ans[b:]...)
		}
	}
}


Measured memory_bytes: 5504
import java.util.Scanner;

public class Main {
   public static void main(String[] args) {
      Scanner sc = new Scanner(System.in);
      
      double max = 0.0;
      double min = 1000000.0;
      
      while(sc.hasNext()) {
         double height = Double.parseDouble(sc.nextLine());
         if (height > max) {
            max = height;
         }
         if (height < min) {
            min = height;
         }
      }
      
      System.out.println(max - min);
   }
}


Measured memory_bytes: 25908
#include<bits/stdc++.h>
typedef long long ll;
#define M 1000000007
#define endl "\n"
#define int long long 
using namespace std;
int32_t main()
{
    ios::sync_with_stdio(0);cin.tie(0);
    int n;
    cin>>n;
    int ar[n];
    for(int i=0;i<n;i++)
    {
    	cin>>ar[i];
    }

    int mi=2*M;
    int ind;
    for(int i=0;i<n;i++)
    {
    	if(abs(ar[i])<mi)
    	{
    		mi=abs(ar[i]);
    		ind=i;
    	}
    }
    for(int i=0;i<ind;i++)
    {
    	if(ar[i]<0)
    	{
    		ar[i]=-ar[i];
    		ar[i+1]=-ar[i+1];
    	}
    }
    for(int j=n-1;j>ind;j--)
    {
    	if(ar[j]<0)
    	{
    		ar[j]=-ar[j];
    		ar[j-1]=-ar[j-1];
    	}
    }
    int ans=0;
    for(int i=0;i<n;i++)
    {
    	ans+=ar[i];
    }
    cout<<ans;
}


Measured memory_bytes: 1024
import sys
from collections import deque
sys.setrecursionlimit(100000)
input = sys.stdin.readline

N, A, B, C, D = list(map(int, input().split()))
S = input()

def able(m, n, S):
    for i in range(m+1, n):
        if S[i] == '#' and S[i+1] == '#':
            return False
    return True

def able2(m, n, S):
    if not able(m, n, S):
        return False
    for i in range(m, n+1):
        if S[i] == '.' and S[i-1] == '.' and S[i+1] == '.':
            return True
    return False

if C>D:
    if able(A-1, C-1, S) and able2(B-1, D-1, S):
        print("Yes")
    else:
        print("No")
else:
    if able(A-1, C-1, S) and able(B-1, D-1, S):
        print("Yes")
    else:
        print("No")

Measured memory_bytes: 39664
#include <bits/stdc++.h>
//#include <atcoder/all>
#define rep(i, n) for (int i = 0; i < (n); ++i)
// using namespace atcoder;
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
//マクロ
// forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
// Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define FOR(i, a, b) for (ll i = a; i <= (ll)(b); i++)
// xにはvectorなどのコンテナ
#define ALL(x) (x).begin(), (x).end()  // sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size())       // sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))    //最大値を求める
#define MIN(x) *min_element(ALL(x))    //最小値を求める
//定数
#define INF 1000000000000  // 10^12:極めて大きい値,∞
#define inf 2147483647     // int値の最大値
#define MOD 1000000007     // 10^9+7:合同式の法
#define MAXR 100000        // 10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back                             // vectorヘの挿入
#define MP make_pair                             // pairのコンストラクタ
#define F first                                  // pairの一つ目の要素
#define S second                                 // pairの二つ目の要素
#define CST(x) cout << fixed << setprecision(x)  //小数点以下の桁数指定
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;
}
int gcd(int a, int b) {
    if (b == 0)
        return a;
    else
        return gcd(b, a % b);
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
//各桁の和
int sumDight(int x) {
    int sum = 0;
    while (x > 0) {
        sum += (x % 10);
        x /= 10;
    }
    return sum;
}
//回文数
int divideReverse(int x) {
    int reverse = 0;
    int r;
    while (x > 0) {
        r = x % 10;
        reverse = reverse * 10 + r;
        x /= 10;
    }
    return reverse;
}

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

    int n;
    cin >> n;
    vector<int> d(n);
    for (int i = 0; i < n; i++) {
        cin >> d.at(i);
    }
    sort(d.begin(), d.end());
    // reverse(a.begin(),a.end());
    int sum = 1;

    for (int i = 0; i < n - 1; i++) {
        if (d.at(i) < d.at(i + 1)) {
            sum++;
        }
    }
    cout << sum << endl;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main() {
	ll n;cin>>n;
	string ans="";
	while(n>0){
		int x=n%26;
		if(x==0) {
		ans+='z';n--;}
		else
		ans+='a'+(x-1);
		n=n/26;
	}
	reverse(ans.begin(),ans.end());
	cout<<ans;
}


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


int n, m;

map <string, int> mp;
int main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		string tmp;
		cin >> tmp;
		mp[tmp] += 1;
	}
	cin >> m;
	for (int i = 0; i < m; i++) {
		string tmp;
		cin >> tmp;
		mp[tmp] -= 1;
	}
	int mx = 0;
	for (auto itr = mp.begin(); itr != mp.end(); ++itr) {
		mx = max(mx, itr->second);
	}
	
	cout << mx << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define r0 return 0;
#define f(k,i,n,j) for(ll k=i;k<=n;k=k+j)
#define cin(a) cin>>a;
#define loop int t;cin>>t;while(t--)
#define vi vector<int>
#define vii vector<long long int>
#define SORT(v) sort(v.begin(),v.end());
#define mod (1e9+7)
#define crap ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define endl "\n"
signed main()
{
    int k,n;
 cin>>k>>n;
 int mx=0,s=0;
 int a[n];
 for(int i=0;i<n;i++)
 	cin>>a[i];
 for(int i=0;i<n-1;i++){
 	s+=abs(a[i+1]-a[i]);
 	mx=max(mx,abs(a[i+1]-a[i]));
 }
 s+=(k-a[n-1]+a[0]);
 mx=max(mx,k-a[n-1]+a[0]);
 cout<<s-mx;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
using ll = long long ;
using P = pair<int,int> ;
using pll = pair<long long,long long>;
constexpr int INF = 1e9;
constexpr long long LINF = 1e17;
constexpr int MOD = 1000000007;

int main(){
    ll a;
    long double b;
    cin >> a >> b;
    ll ans = floor(a*b);
    printf("%lld\n",ans);
    //cout << floor(a*b) << endl;
    return 0;
}

Measured memory_bytes: 3796
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
using namespace std;
int main(){
    int N, K;
    cin >> N >> K;
    int ans;
    for(int i=0;i<N;i++){
        int a;
        cin >> a;
        if(a>=K) ans++;
    }
    cout << ans << endl;
}

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

#define int long long int
#define ff first
#define ss second
#define pb push_back


int bexp(int a, int b, int mod)
{
    int res = 1;

    while (b)
    {
        if (b & 1) res = (res * a) % mod;

        a = (a * a) % mod; 
        b >>= 1;
    }
    return res;
}

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

#define N 100010
#define MOD 1000000007

struct comp {
    bool operator() (const pair<int, int> a, const pair<int, int> b) const
    {
        return a.ss > b.ss;
    }
};

int32_t main()
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.precision(10);

    int n, w;
    cin >> n >> w;

    pair<int, int> wv[n];
    for (int i = 0; i < n; ++i)
    {
        cin >> wv[i].ff >> wv[i].ss;
    }

    int dp[n][w + 1] = {};

    dp[0][wv[0].ff] = wv[0].ss;

    for (int i = 1; i < n; ++i)
    {
        for (int j = 0; j <= w; ++j)
        {
            if (wv[i].ff <= j)
                dp[i][j] = max(dp[i - 1][j - wv[i].ff] + wv[i].ss, dp[i - 1][j]);
            else
                dp[i][j] = dp[i - 1][j];
        }
    }

    cout << *max_element(dp[n - 1], dp[n - 1] + w + 1); 
    return 0;
}

Measured memory_bytes: 81672
#include <bits/stdc++.h>
using namespace std;
#define mod 998244353
#define MOD 1000000007
#define inf 0x3f3f3f3f
#define linf 0x3f3f3f3f3f3f3f3fll
typedef long long ll;
typedef pair<int,int> pii;
typedef unsigned long long ull;
int main()
{
	ll A,B,V,W,T;
	cin>>A>>V>>B>>W>>T;
	if(V<=W||(abs(A-B)>(V-W)*T))
	{
		cout<<"NO";
	}
	else
	{
		cout<<"YES";
	}
	return 0;
	
}

Measured memory_bytes: 3620
import bisect
A,B,Q=map(int,input().split())
inf=10**18
s=[-inf]+[int(input()) for i in range(A)]+[inf]
t=[-inf]+[int(input()) for i in range(B)]+[inf]

for i in range(Q):
  ans=inf
  x=int(input())
  b=bisect.bisect_left(s,x)
  d=bisect.bisect_left(t,x)
  for S in (s[b-1],s[b]):
    for T in (t[d-1],t[d]):
      ans=min(ans,abs(S-x)+abs(S-T),abs(T-x)+abs(S-T))
  print(ans)

Measured memory_bytes: 79592
from sys import stdin

N = stdin.readline().rstrip()
ans = 0

N = N[::-1]
N = N + '0'
kuriagari = 0

for i in range(len(N)):
    r = int(N[i])
    if kuriagari == 1:
        r += 1
    if 10 - r < r:
        kuriagari = 1
    else:
        kuriagari = 0
    if r == 5 and int(N[i + 1]) > 4:
        kuriagari = 1
    if r == 10:
        r = 0
    ans += min(r, 10 - r)

print(ans)


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

int N, C[400], S[400][26];

int main() {
	cin >> N;
	for (int i = 1; i <= N; i++) cin >> C[i];
	for (int i = 1; i <= N; i++) {
		for (int j = 1; j <= 26; j++) cin >> S[i][j];
	}
	for (int i = 1; i <= N; i++) {
		cout << ((i - 1) % 26) + 1 << endl;
	}
	return 0;
}

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

main(){
	int a=0,b,c=0,d,e,f,g,X,Y;
	int i;
	scanf("%d",&X);
	Y = X;
	a = Y%10;
	b = a+((Y/10)%10)*10;
	
	c = b/5;
	d = b-c*5;
	c = c+d/4;
	e = d-(d/4)*4;
	c = c+e/3;
	f = e-(e/3)*3;
	c = c+f/2;
	g = f-(f/2)*2;
	c = c+g/1;
	
	if(X>c*100){
		printf("1");
	} 
	else{
		printf("0");
	}
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define GET_REP(_1, _2, _3, NAME, ...) NAME
#define rep(...) GET_REP(__VA_ARGS__, irep, _rep)(__VA_ARGS__)
#define rep1(...) GET_REP(__VA_ARGS__, irep1, _rep1)(__VA_ARGS__)
#define _rep(i, n) irep (i, 0, n)
#define _rep1(i, n) irep1(i, 1, n)
#define irep(i, a, n) for (int i = a; i < (int)(n); ++i)
#define irep1(i, a, n) for (int i = a; i <= (int)(n); ++i)
#define rrep(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define rrep1(i, n) for (int i = (int)(n); i >= 1; --i)
#define allrep(X, x) for (auto &&X : x)
#define all(x) begin(x), end(x)
#ifdef LOCAL
  #include "../../Lib/cout_container.hpp"
  #define debug(x) cout << #x " => " << (x) << endl
#else
  #define debug(x) 0
#endif
using lint = long long;
constexpr int    INF  = 1 << 28;
constexpr lint   INFL = 1LL << 60;
constexpr int    MOD  = (int)1e9 + 7;
constexpr double EPS  = 1e-9;
using namespace std;
namespace { struct INIT { INIT() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(15); } } INIT; }

vector<vector<vector<lint>>> dp;
int main(void) {
  int n, k;
  cin >> n >> k;
  vector<int> h(n);
  rep (i, n) cin >> h[i];
  h.insert(h.begin(), 0);
  // dp[i個目まで見た][現在の高さがh[j]][l個選んだ]
  dp.assign(n + 1, vector<vector<lint>>(n + 1, vector<lint>(n + 1, LLONG_MAX)));
  dp[0][0][0] = 0;
  rep (i, n) {
    rep (j, i + 1) {
      rep (l, i + 1) {
        if (l > k) break;
        lint now = dp[i][j][l];
        if (now == LLONG_MAX) continue;
        dp[i + 1][j][l + 1] = min(dp[i + 1][j][l + 1], now);
        dp[i + 1][i + 1][l] = min(dp[i + 1][i + 1][l], now + max(0, h[i + 1] - h[j]));
      }
    }
  }
  lint mini = LLONG_MAX;
  rep (i, n + 1) {
    rep (j, k + 1) {
      lint tmp = dp[n][i][j];
      mini = min(mini, tmp);
    }
  }
  cout << mini << endl;
  return 0;
}

Measured memory_bytes: 216832
#include <iostream>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>
#include <string>

using namespace std;

int main() {
  int n,q;
  cin >> n >> q;
  string s;
  cin >> s;
  vector<int> dp(n,0);


  for (int i=1; i<n; i++) {
    if (i!=1) dp[i] = dp[i-1];
    if (s[i-1]=='A' && s[i]=='C') dp[i]++;
  }

  for (auto d : dp) cerr << d << " ";
    cerr << endl;

  for (int i=0; i<q; i++) {
    int l,r;
    cin >> l >> r;
    cout << dp[r-1] - dp[l-1] << endl;
  }
}


Measured memory_bytes: 1472
d = {}
r = []
max = 0

n = int(input())

for i in range(n):
  k = input()
  if k in d:
    d[k] += 1
    if max < d[k]:
      max = d[k]
  else:
    d[k] = 1
    if max == 0:
      max += 1

for i in d:
  if d[i] == max:
    r.append(i)

r.sort()

for i in r:
  print(i)

Measured memory_bytes: 32096
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
 
int main() {
  
  int N, K, AA;
  cin >> N >> K;
  vector<int> vec(100);
  
  
  for (int i = 0; i < N; i++) {
   cin >> vec.at(i);
  }
 for (int XX = 0; XX < 1000; XX++) {
  for (int X = 0; X < N; X++) {
   if (vec.at(X) <= vec.at(X + 1)) {
    swap (vec.at(X), vec.at(X + 1));
   }
  }
 }
  for (int B = 0; B < K; B++) {
    AA += vec.at(B);
  }
  cout << AA << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cassert>
#include <functional>
#include <numeric>
#include <limits>
#include <iomanip>
#include <queue>
#include <cmath>
#include <math.h>
#include <string>
#include <cmath>
#include <bitset>
#include <set>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const long long INF = 1LL << 60;
using pll = pair<long long, long long>;
typedef long long ll;
#define min(a, b) ((a) < (b) ? (a) : (b))
#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)

int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    // cout << std::fixed << std::setprecision(15);
    string S;cin >> S;
    int N = (int)S.length() - 1;
    
    long long res = 0;
    // 2^N通りのえ組み合わせ列挙
    for (int bit = 0; bit < (1 << N); ++bit) {
        long long tmp = S[0] - '0';
        for (int i = 0; i < N; ++i) {
            // 指定桁が1かどうか調べる。
            if(bit & (1 << i)){
                res += tmp;
                tmp = 0;
            }
            tmp = tmp * 10 + S[i+1] - '0';
        }
        res += tmp;
    }
    
    cout << res << endl;
}



Measured memory_bytes: 256
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)


N, M, K = map(int,input().split())
Friend_Net = UnionFind(N)
Friend = [[] for i in range(N)]
Block = [[] for i in range(N)]
friend = [0] * N

for i in range(M):
    A, B = map(int, input().split())
    friend[A-1] += 1
    friend[B-1] += 1
    Friend[A-1].append(B-1)
    Friend[B-1].append(A-1)
    Friend_Net.union(A-1, B-1)

for i in range(K):
    C, D = map(int, input().split())
    Block[C-1].append(D-1)
    Block[D-1].append(C-1)

for i in range(N):
    ans = Friend_Net.size(i) - friend[i]
    for b in Block[i]:
        if Friend_Net.same(i, b):
            ans -= 1
    print(ans-1)

Measured memory_bytes: 125856
#include<stdio.h>
#include<iostream>
using namespace std;
int main()
{
	long long n=50,k,x,cnt;
	scanf("%lld",&k);
	x=n+k/n-1;cnt=k%n;
	cout<<n<<endl;
	x-=cnt;
	for(int i=1;i<=n;i++)
	if(cnt>0){cout<<x+n<<" ";cnt--;}
	else cout<<x<<" ";
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ziyuutyou
{
    class Program
    {
        static void Main(string[] args)
        {
            var str = Console.ReadLine();
            var sum = 0;

            for (var x=0;x<str.Length;x++)
            {
                var aaa = str[x].ToString();
                if(aaa == "1")
                {
                    sum++;
                }
            }

            Console.WriteLine(sum);
        }
    }
}

Measured memory_bytes: 13140
#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 < (int)b; ++i)
#define rrep(i, n) for(int i = ((int)n - 1); i >= 0; --i)

using ll = long long;
using ld = long double;

const ll INF = 1e18;
const int Inf = 1e9;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(0);
    int n, m;
    cin >> n >> m;
    vector<pair<int, int> > s(n), c(m);
    rep (i, n) cin >> s[i].first >> s[i].second;
    rep (i, m) cin >> c[i].first >> c[i].second;

    rep (i, n) {
        int mi = Inf;
        int pos = 0;
        rep (j, m) {
            int dist = abs(s[i].first - c[j].first) + abs(s[i].second - c[j].second);
            if (mi > dist) {
                mi = dist;
                pos = j;
            }
        }
        cout << pos + 1 << endl;
    }
    
    return 0;
}



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

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

using namespace std;
using ll = long long;
int mod = 1000000007;

vector<int> edge(100001, 0);
vector<pair<int, int>> node[100001];

void dfs(int p, int color, int s){
    int c = 1;
    rep(i, node[s].size()){
        int to = node[s][i].first;
        int use_edge = node[s][i].second;
        if(to == p) continue;
        if(c == color) c++;
        edge[use_edge] = c;
        dfs(s, c, to);
        c++;
        
    }
}

int main(void){
    int N; cin >> N;
    rep(i, N-1){
        int a, b; cin >> a >> b;
        a--; b--;
        node[a].push_back(make_pair(b, i));
        node[b].push_back(make_pair(a, i));
    }
    int K = 0;
    int root = 0;
    rep(i, N){
        if(node[i].size() > K){
            K = node[i].size();
            root = i;
        }
    }
    cout << K << endl;
    dfs(-1, -1, root);

    
    rep(i, N-1) cout << edge[i] << endl;
    return 0;
}

Measured memory_bytes: 9472
import java.util.*;
class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		char[] charArray = S.toCharArray();
		for (int i = 0; i < S.length() - 8; i++) {
			System.out.print(charArray[i]);
		}
	}
}

Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define ld long double
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; }
using P=pair<long long,long long>;
#define rep(i,n) for(long long i=0; i<(long long)n; i++)
#define FOR(i,a,b) for(long long i=a; i<b; i++)
#define all(x) (x).begin(), (x).end()
#define SZ(x) ((long long)(x).size())
#define COUT(x) cout << x << endl
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define vint vector<int>
#define vvint vector<vector<int>>
#define vstr vector<string>
#define vp vector<pair<int,int>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define SUM(x) accumulate(x.begin(),x.end(),0)
#define MAX(x) *max_element(x.begin(),x.end())
#define MIN(x) *min_element(x.begin(),x.end())
#define couty cout<<"Yes"<<endl
#define coutn cout<<"No"<<endl
#define coutY cout<<"YES"<<endl
#define coutN cout<<"NO"<<endl
#define yn(x) cout<<(x?"Yes":"No")<<endl
#define YN(x) cout<<(x?"YES":"NO")<<endl
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
long long lcm(long long a, long long b){return a*b/gcd(a,b);}
const long long dx[4]={1,0,-1,0};
const long long dy[4]={0,1,0,-1};
const long long INF = 1e12;
const long long MOD = 1e9+7;

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(15);

    int n,x; cin >> n >> x;
    vint a(n);
    rep(i,n) cin >> a[i];
    int res=abs(a[0]-x);
    rep(i,n-1){
        res=gcd(res,abs(a[i+1]-x));
    }   
    cout<<res<<endl;
}

Measured memory_bytes: 3948
n = int(input())
p = list(map(int, input().split(' ')))

count = 0

for i in range(1, n-1):
    if (p[i-1] < p[i] < p[i+1]) or (p[i+1] < p[i] < p[i-1]):
        count += 1

print(count)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define pb push_back
#define ll long long
#define hell 998244353
#define PI 3.14159265358979323846
using namespace std;

int main()
{
   ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t=1;
    //cin>>t;
    //int c=0;
    while(t--) {
     ll a,b,c,d;
     cin>>a>>b>>c>>d;
     ll x=a*c;
     ll y=b*d;
     ll mx=max(x,y);
     x=a*d;
     y=b*c;
     mx=max(mx,max(x,y));
     cout<<mx;
    }

}


Measured memory_bytes: 3644
#include<bits/stdc++.h>
#include<vector>
#include<list>
#include<stack>
#include<queue>
#include<algorithm>
using namespace std;


int main(){
    int n;
    scanf("%d",&n);
    list<int> lst;
    for(int i=0;i<n;i++){
        char c[11];
        int p;
        scanf("%s",&c);
        string s=c;
        if(s=="deleteFirst"){
            lst.pop_front();
        }else if(s=="deleteLast"){
            lst.pop_back();
        }else if(s=="insert"){
            scanf("%d",&p);
            lst.push_front(p);
        }else{
            scanf("%d",&p);
            for(auto itr=lst.begin(); itr!=lst.end();itr++){
                if(*itr==p){
                    lst.erase(itr);
                    break;
                }
            }
        }
    }
    int l=lst.size();
    for(int i=0;i<l-1;i++){
        printf("%d ",*lst.begin());
        lst.pop_front();
    }
    printf("%d\n",*lst.begin());
    return 0;
}

Measured memory_bytes: 32404
#include <bits/stdc++.h>
#define ll long long
using namespace std;
void fast()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
}
int main()
{
    fast();

    int n;cin>>n;
    string s,t;cin>>s>>t;
    for(int i=0,j1=0,j2=0;i<n*2;i++)
    {
        if(i%2)
        cout<<t[j1++];
        else cout<<s[j2++];
    }
    return 0;

}


Measured memory_bytes: 256