akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;
public class Main{

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		String s = sc.next();
		
		if(s.equals("Sunny")) {
			System.out.println("Cloudy");
		}
		if(s .equals("Cloudy")) {
			System.out.println("Rainy");
		}
		if(s.equals("Rainy")) {
			System.out.println("Sunny");
		}
	}

}


Measured memory_bytes: 21204
#include <bits/stdc++.h>
#define FOR(i,k,n) for (int (i)=(k); (i)<(n); ++(i))
#define RFOR(i,k,n) for (int (i)=(n)-1; (i)>=(k); --(i))
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define pb push_back
#define mp make_pair
#define fst first
#define snd second
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define debug(x) cerr << #x <<": "<<x<<endl
#define debug2(x,y) cerr << #x <<": "<< x <<", "<< #y <<": "<< (y) << endl
#define answer(x) cout << x <<endl
#define answer_fixed(x, p) cout << fixed << setprecision(p) << x << endl
using namespace std;
typedef vector<int> VI;

int main() {
  int N, M;
  cin >> N;
  VI D(N);
  REP(i, N) { scanf("%d", &D[i]); }
  cin >> M;
  VI T(M);
  REP(i, M) { scanf("%d", &T[i]); }
  sort(all(D));
  VI used(N, 0);
  REP(i, M) {
    auto itr = lower_bound(all(D), T[i]);
    int j = distance(D.begin(), itr);
    if(*itr != T[i]) {
      cout << "NO" << endl;
      return 0;
    }
    else if(used[j]) {
      while(*(itr++) == T[i] && used[j++]) {}
      if(*(--itr) != T[i]) {
        cout << "NO" << endl;
        return 0;
      }
      else { used[--j] = 1; }
    }
    else { used[j] = 1; }
  }
  cout << "YES" << endl;
  return 0;
}


Measured memory_bytes: 2560
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define INF ((1LL<<62)-(1LL<<31))
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define bit(n,m)(((n)>>(m))&1)
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}
ll pom(ll a,ll n,int m){ll x=1;for(a%=m;n;n/=2)n&1?x=x*a%m:0,a=a*a%m;return x;}
//#define MOD 998244353
#define MOD 1000000007
#define invp(a,p)pom(a,p-2,p)


//セグ木ここから
//*
//↓ここを変える
typedef struct atai{ll a,b;}atai;
atai xx(atai x,atai y){
	atai r;
	r.a=min(x.a,y.a);
	r.b=max(x.b,y.b);
	return r;
}
atai aid={INF,-1};
//↑ここを変える

int segNUM;
atai *segN,*seg;
void seguse(int n){
	segN=(atai*)calloc(2*n,sizeof(atai));
	segNUM=n;
	seg=segN+segNUM;
	rep(i,1,2*segNUM)segN[i]=aid;
}
//seg[]に値を与えてから初期化
void seginit(){for(int node=segNUM-1;node;node--)segN[node]=xx(segN[node*2],segN[node*2+1]);}
void segupdate(int node,atai x){
	//seg[node]をxに更新
	node+=segNUM;
	segN[node]=x;
	while(node/=2)segN[node]=xx(segN[node*2],segN[node*2+1]);
}

atai segcalcsub(int l,int r,int k,int cl,int cr){
	if(l>=r)return aid;
	//完全に含むとき
	if(l<=cl&&cr<=r)return segN[k];

	int cm=(cl+cr)/2;
	//左側だけ
	if(r<=cm)return segcalcsub(l,r,2*k  ,cl,cm);
	//右側だけ
	if(cm<=l)return segcalcsub(l,r,2*k+1,cm,cr);
	//両方
	return xx(segcalcsub(l,r,2*k,cl,cm),segcalcsub(l,r,2*k+1,cm,cr));
}
atai segcalc(int l,int r){return segcalcsub(l,r,1,0,segNUM);}
//セグ木ここまで
//*/

int main(){
	seguse(1<<18);
	int n,k;
	scanf("%d%d",&n,&k);
	rep(i,0,n){
		int t;
		scanf("%d",&t);
		seg[i].a=t;
		seg[i].b=t;
	}
	seginit();
	int ans=1;
	rep(i,1,n-k+1){
		ans++;
		if(segcalc(i-1,i-1+k).a==seg[i-1].a && segcalc(i,i+k).b==seg[i+k-1].b)ans--;
	}
	
	int cnt=0,crr=1e9,flag=0;
	rep(i,0,n){
		if(seg[i].a>crr)cnt++;
		else cnt=1;
		crr=seg[i].a;
		if(cnt==k)ans-=!!flag++;
	}
	
	printf("%d",ans);
	
}

Measured memory_bytes: 8320
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cassert>
#include <vector>
#include <string>
#include <cmath>
#include <map> 
using namespace std;
#define MAX 10000

#define loop(i,a,b) for(int i = a ; i < b ; i ++)
#define rep(i,a) loop(i,0,a)
#define all(a) (a).begin(),(a).end()
#define ll long long int
#define gcd(a,b) __gcd(a,b)

int GCD(int a, int b) {if(!b) return a; return gcd(b, a%b);}
int lcm(int a, int b) {return a*b / gcd(a, b);}

int main(void){
  int a,b;
  while(cin>>a>>b){
    int h[MAX] = {0};
    h[a] ++; h[b] ++;
    while(cin>>a>>b,a+b){
      h[a] ++; h[b] ++;
    }
    int han = 0;
    loop(i,0,MAX)
      if(h[i]%2)han++;
    if(h[1]%2==1&&h[2]%2==1&&han==2)cout<<"OK"<<endl;
    else cout<<"NG"<<endl;
  }
}

Measured memory_bytes: 1200
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include "bits/stdc++.h"
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

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

int main(){
    ll N,M,cnt=0;
    cin>>N>>M;
    if(2*N>=M){
        cout<<M/2<<endl;
    }
    else{
        M=M-2*N;
        cnt+=N;
        cnt+=M/4;
        cout<<cnt<<endl;
    }
    
 }

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

int h, w;
int dx[4] = {1, 0, -1,  0};
int dy[4] = {0, 1,  0, -1};
char **data;

//fType:WKO fruit now
void dfs(int x, int y, char fType)
{
	data[y][x] = 0;

	int i=0;
	for (i=0; i<4; i++) {
		int nx = x + dx[i];
		int ny = y + dy[i];
		if (nx>=0 && nx<w && ny>=0 && ny<h && data[ny][nx]==fType)
			dfs(nx, ny, fType);
	}
}

int main()
{
	while (1) {
		int res;
		int i, j;

		//jnput
		scanf("%d%d ", &h, &w);
		if (!h && !w) break;

		//Allocate memory
		data = (char **)calloc(h, sizeof(char *));
		for (i=0; i<h; i++)
			data[i] = (char *)calloc(w, sizeof(char));

		for (i=0; i<h; i++)
			for (j=0; j<w; j++)
			scanf("%c ", &(data[i][j]));

		//dfs
		res = 0;
		for (i=0; i<h; i++)
			for (j=0; j<w; j++)
				if (data[i][j]) {
					dfs(j, i, data[i][j]);
					res++;
				}

		//output
		printf("%d\n", res);

		//Free memory
		for (i=0; i<h; i++)
			free(data[i]); 
		free(data);
	}




	return 0;
}

Measured memory_bytes: 1516
#include<iostream>
#include<cstdio>
#include<cctype>
using namespace std;
int main(){ 
    char ch;
    while(1){
        scanf("%c",&ch);
        if (ch=='\n') break;
        else  if(isalpha(ch)){
            if(isupper(ch)) printf("%c",tolower(ch));
            else if(islower(ch)) printf("%c",toupper(ch));
        }else printf("%c",ch);
    }
    printf("\n");
    return 0;
}
    


Measured memory_bytes: 3148
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <string.h>
#define s(n)                        scanf("%d",&n)
#define sc(n)                       scanf("%c",&n)
#define sl(n)                       scanf("%I64d",&n)
#define sf(n)                       scanf("%lf",&n)
#define ss(n)                       scanf("%s",n)
#define INF                         (int)1e9
#define EPS                         1e-9
#define bitcount                    __builtin_popcount
#define gcd                         __gcd
#define forall(i,a,b)               for(int i=a;i<b;i++)
#define foreach(v, c)               for( typeof( (c).begin()) v = (c).begin();  v != (c).end(); ++v)
#define all(a)                      a.begin(), a.end()
#define in(a,b)                     ( (b).find(a) != (b).end())
#define pb                          push_back
#define fill(a,v)                    memset(a, v, sizeof a)
#define sz(a)                       ((int)(a.size()))
#define mp                          make_pair
#define MOD                         1000000007
typedef long long ll;
/*For you see , each day i love you
 more.Today more than yesterday
  less than tomorrow.*/
using namespace std;

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

	ll val = 100;
	
	for(int i = 1;i<=3761;i++)
	{
		val = val + (val/100);
		if(val >= x)
		{
			printf("%d\n" , i);
			return 0;	
		}	
	}
	
	return 0;
}

Measured memory_bytes: 3764
N, K = map(int, input().split())
S = input()
cnt = 1
counts = []

if S[0]=='0':
  counts.append(0)
if N == 1:
  counts.append(1)
  
for i in range(1,N):
  if S[i-1]!=S[i]:
    counts.append(cnt)
    cnt = 1
  else:
    cnt += 1
  #print(i)
  if i == N-1:
    counts.append(cnt)

#print(counts)
K = min(K,len(counts)//2)
for i in range(len(counts)//2-K+1):
  if i == 0:
    s = sum(counts[:2*K+1])
    m = s
  else:
    s += sum(counts[2*(i+K)-1:2*(i+K)+1])-sum(counts[2*i-2:2*i])
    m = max(m,s)
  #print(s)
print(m)


Measured memory_bytes: 4596
#include<bits/stdc++.h>
using namespace std;
int book[1001];
#define e endl
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;
inline int read(){
	int f=1,x=0;char ch;
	do{
		ch=getchar();
		if(ch=='-'){
			f=-1;
		}
	}while(ch<'0'||ch>'9');
	do{
		x=x*10+ch-48;
		ch=getchar();
	}while(ch>='0'&&ch<='9');
	return f*x;
}
inline void print(int x){
	if(x<0){
		putchar('-');
		x=-x;
	}
	if(x>9){
		print(x/10);
	}
	putchar(x%10+48);
}
int main(){
	string s;
	ios::sync_with_stdio(0);
	getline(cin,s);
	for(int i=0;i<s.length();++i){
	    if(s[i]==','){
	        cout<<" ";
	    }
	    else{
	        cout<<s[i];
	    }
	}
	cout<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define endl "\n"
#include <cmath>

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

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll n;
    cin>>n;
    vector<ll> v(n-1);
    for(ll i=0;i<n-1;i++){
        cin>>v[i];
    }
    sort(v.begin(),v.end());
    for(ll i=1;i<=n;i++){
        auto r=equal_range(v.begin(),v.end(),i);
        cout<<r.second-r.first<<endl;
    }

    return 0;
}


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

using namespace std;

#define FOR(i,n) for(int i=0; i<n; ++i)
#define FORR(i,a,n) for(int i=a; i<n; ++i)
#define ALL(c) (c).begin(), (c).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

const int INF = 0x3f3f3f3f;

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<int,int> PI;
typedef pair<ll,ll> PL;
 
//int in() { int x; scanf("%d", &x); return x; }
//ll lin() { ll x; scanf("%lld", &x); return x; }
//void printfv(VI a){ int n = a.size(); FOR(i, n) cout << a[i] << " "; }

const ll MAX = 1e18;

int main(void){
    std::ios_base::sync_with_stdio(false);

    int n;
    cin >> n;

    ll ans = 1;
    bool ng = false;
    FOR(i, n){
    	ll tmp;
    	cin >> tmp;

    	if(tmp == 0){
    		cout << 0 << endl;
    		return 0;
    	}

    	if(ng || (MAX+1)/ans < tmp || ans*tmp > MAX){
    		ng = true;
    	}

    	ans *= tmp;    	
    }

    if(ng) 
    	cout << -1 << endl;
	else
    	cout << ans;

    return 0;
}

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

int main(){
    ll n, a, b;
    cin >> n >> a >> b;
    ll ans = (ll)(n/(a+b))*a;
    ans += min(n%(a+b),a);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
a = list(map(int, input().split()))

ans5 = 0
ans7 = 0
for i in range(3):
  if (a[i] == 5):
    ans5 += 1
  elif (a[i] == 7):
    ans7 += 1

if (ans5 == 2 and ans7 == 1):
  print("YES")
else:
  print("NO")

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <ctime>
#include <sstream>
#define weewoo ios::sync_with_stdio(false);cin.tie(0)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define ld long double
#define ll long long
#define se second
#define fi first
#define ctoi(x) x-'0'
#define pi (acos(-1))
#define llputin(a,n) for(int i=0;i<n;i++){ll x;cin >> x;a.push_back(x);}
#define iputin(a,n) for(int i=0;i<n;i++){int x;cin >> x;a.push_back(x);}

#define MOD ((ll) 1e9 + (ll) 7)
using namespace std;

ll pw(ll x,ll a){
    if(a==0)
        return 1;
    ll t = pw(x,a/2);
    if(a%2==0)
        return (t*t);
    else
        return (t*t*x);
}

bool prime(int x)
{
    if(x < 2) return false;
        for(int i=2; i<= sqrt(x); i++) {
            if ((x%i) == 0) return false;
        }
    return true;
}

vector<ll>a;
int main()
{
    weewoo;
    ll n,k;
    cin >> n >> k;
    ll ans=0;
    for(int i=0;i<n;i++){
        ll x;cin >> x;
        a.push_back(x);
        ans+=x;
    }
    sort(a.rbegin(),a.rend());
    int i=0;
    for(;i<n&&k>0;i++){
        k--;
        ans-=a[i];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 2420
#include <stdio.h>
#include <iostream>
#include <map>
#include <vector>
#include <string>
#include <algorithm>





using namespace std;


int main() {
	int k;
	string s;
	cin >> k >> s;
	
	if (s.length() > k) {
		string s2 = s.substr(0, k) + "...";
		cout << s2;
		return 0;
	}
	cout << s;

	return 0;
}

Measured memory_bytes: 3124
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include <fstream>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <bitset>
#include <array>
#include <vector>
#include <queue>
#include <set>
#include <cmath> // 変数名にy1が使えなくなるかも…。
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <limits>
#include <string>

typedef __int128_t int128_t;
std::istream &operator>>(std::istream& input, int128_t& value) { // int128_tの入力。入力が64bitに収まる前提。
    long long tmp; input >> tmp; value = tmp;
    return input;
}
std::ostream &operator<<(std::ostream& output, const int128_t value) { // int128_tの出力。出力が64bitに収まる前提。
    output << (long long)value;
    return output;
}

const int MAX_N = 12;
const int MAX_D = 12;
int N, D;
int X[MAX_N][MAX_D];

int main(int argc, char **argv) {
    std::cin >> N >> D;

    for (int i = 1; i <= N; i++) {
        for (int k = 1; k <= D; k++) {
            std::cin >> X[i][k];
        }
    }

    int max = 0;
    std::unordered_map<int, int> mp;
    for (int i = 1; i <= N; i++) {
        for (int j = i + 1; j <= N; j++) {
            int tmp = 0;
            for (int k = 1; k <= D; k++) {
                tmp += (X[i][k] - X[j][k]) * (X[i][k] - X[j][k]);
            }
            mp[tmp]++;
            max = std::max(max, tmp);
        }
    }

    int ret = 0;
    int t = 1;
    while (t*t <= max) {
        ret += mp[t*t];
        t++;
    }

    std::cout << ret << std::endl;
    return 0;
}

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

using namespace std;
int main(int argc, char const *argv[])
{
    int X, Y, A, B, C;
    cin >> X >> Y >> A >> B >> C;
    vector<int> P(A);
    vector<int> Q(B);
    vector<int> R(C);
    for (int i = 0; i < A; i++)
    {
        cin >> P.at(i);
    }
    for (int i = 0; i < B; i++)
    {
        cin >> Q.at(i);
    }
    for (int i = 0; i < C; i++)
    {
        cin >> R.at(i);
    }
    sort(P.begin(), P.end());
    reverse(P.begin(), P.end());

    sort(Q.begin(), Q.end());
    reverse(Q.begin(), Q.end());

    for (int i = 0; i < X; i++)
    {
        R.push_back(P.at(i));
    }
    for (int i = 0; i < Y; i++)
    {
        R.push_back(Q.at(i));
    }
    sort(R.begin(), R.end());
    reverse(R.begin(), R.end());

    long long result = 0;
    for (int i = 0; i < X + Y; i++)
    {
        result += R.at(i);
    }

    cout << result << endl;
    return 0;
}


Measured memory_bytes: 2552
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {

    Scanner sc = new Scanner(System.in);

    int n = sc.nextInt();
    String s = sc.next();
    String[] str = new String[1000];
    int cnt = 0;

    for (int i = 0; i < 10; i++) {
      str[i] = "00" + i;
    }

    for (int i = 10; i < 100; i++) {
      str[i] = "0" + i;
    }

    for (int i = 100; i < 1000; i++) {
      str[i] = "" + i;
    }

    for (int i = 0; i < 1000; i++) {
      int j = 0;
      while ((j < n) && (s.charAt(j) != str[i].charAt(0))) {
        j++;
      }
      j++;
      while ((j < n) && (s.charAt(j) != str[i].charAt(1))) {
        j++;
      }
      j++;
      while ((j < n) && (s.charAt(j) != str[i].charAt(2))) {
        j++;
      }
      if (j < n) {
        cnt++;
      }

    }
    
    System.out.println(cnt);

  }

}

Measured memory_bytes: 23508
/******************************************
* AUTHOR : AMAN SAXENA *
* "There's some good in this world, and it's worth fighting for." *
* INSTITUTION : KIET Group of Institutions *
******************************************/
#include <bits/stdc++.h>

const long long MODULO=1000000007;
#define FOR(i,a,n) for(int i=a;i<n;i++)
#define FOR1(i,a,n) for(int i=a;i<=n;i++)
#define FOR2(i,a,n) for(int i=a;i>=n;i--)
#define pb push_back
#define mp make_pair
#define ll long long 
#define ull unsigned long long
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define pi 3.14159265359

using namespace std;

template <typename TYPE> void in(TYPE &x){cin>>x;}

void solve()
{
    ll n, k, ans = 0;
    cin>>n>>k;
    ll i,a[n];
    FOR(i,0,n) cin>>a[i];
    sort(a,a+n);
    FOR(i,0,k)
    {
        ans+=a[i];
    }
    cout << ans << '\n';
}

void test()
{
    int t;
    cin>>t;
    while(t--) //for(int j=1;j<=t;j++) cout << "Case #" << j << ": ";
    {
        solve();
    }
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
    // test();
    solve();
    
    return 0;
}

Measured memory_bytes: 3616
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int t = sc.nextInt();
		System.out.println(x - t > 0 ? x - t : 0);
		sc.close();
	}
}

Measured memory_bytes: 21716
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  int test = 0;
  cin >> n;
  int a[100];
  for(int i = 0;i < n;i++) {
    cin >> a[i];
  }
  for(int i = 0;i < n;i++) {
    if(a[i] % 2 == 0 && a[i] % 3 != 0 && a[i] % 5 != 0){
      cout << "DENIED" << endl; 
      test++;
      break;
    }
  }
  if(test == 0){
    cout  << "APPROVED" << endl;
  }

}

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

using namespace std;

string a[32] = {"101", "000000", "000011", "10010001", "010001", "000001", "100101", "10011010", "0101", "0001", "110", "01001", "10011011", "010000", "0111", "10011000", "0110", "00100", "10011001", "10011110", "00101", "111", "10011111", "1000", "00110", "00111", "10011100", "10011101", "000010", "10010010", "10010011", "10010000"};
string b = " ',-.?ABCDEFGHIJKLMNOPQRSTUVWXYZ";
string c[32] = {"00000", "00001", "00010", "00011", "00100", "00101", "00110", "00111", "01000", "01001", "01010", "01011", "01100", "01101", "01110", "01111", "10000", "10001", "10010", "10011", "10100", "10101", "10110", "10111", "11000", "11001", "11010", "11011", "11100", "11101", "11110", "11111"};
string d = "ABCDEFGHIJKLMNOPQRSTUVWXYZ .,-'?";

int main(){
    string s;
    map<string, string> p, q;
    for(int i=0; i< 32; i++){p[b.substr(i, 1)] = a[i]; q[c[i]] = d.substr(i, 1);}
    while(getline(cin, s)){
        string t, ret;
        for(int i=0; i< s.size(); i++) t += p[s.substr(i, 1)];
        int diff = 5-t.size()%5;
        if(diff != 5)for(int i=0; i < diff; i++) t+="0";
        for(int i=0; i < t.size(); i+=5) ret += q[t.substr(i, 5)];
        cout << ret << endl;
    }
}

Measured memory_bytes: 1212
//by Top1
#include <bits/stdc++.h>
          
#define f first
#define s second
#define int long long
#define ld long double
#define ull unsigned long long
#define pii pair <int, int>
#define pll pair <long, long>
#define mp make_pair
#define pb push_back
#define pf push_front
#define pp pop_back
#define cerr cout
#define rev reverse
#define all(s) s.begin(), s.end()
#define sz(s) (int)s.size()
#define forn(i, a, b) for (int i = a; i <= b; i++)
#define boost ios_base::sync_with_stdio(false); cin.tie(0),cout.tie(0);
#define nxtp next_permutation
#define pvtp prev_permutation
#define KZ return 
#define x1 x21212121
#define y1 y21212121
#define sqr(x) x * x 
      
const int inf = (1e9) + 1;
const int mod = 479001599;
const int maxn = 1e6 + 111;
        
using namespace std;          

int n, a[maxn], b[5];
string s;   	

void solve(){
	cin >> n;

	cout << n / 2 + n % 2;
}                              
      
main(){
    boost;
    
    int q = 1;
 
    //cin >> q;
    
    while (q--){
        solve();
    }
}

Measured memory_bytes: 256
mod = 10 ** 9 + 7
sl = list(input())

a = 0
ab = 0
abc = 0
p = 1
for s in sl:
    if s == "A":
        a += p
        a %= mod
    elif s == "B":
        ab += a
        ab %= mod
    elif s == "C":
        abc += ab
        abc %= mod
    elif s == "?":
        abc = 3*abc + ab
        abc %= mod
        ab = 3*ab + a
        ab %= mod
        a = 3*a + p
        a %= mod
        p *= 3
        p %= mod
print(abc)



Measured memory_bytes: 49904
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

int n,k;
vvi g;

int main(){
	cin>>n>>k;
	int S=(n-1)*(n-2)/2;
	if(k>S){
		cout<<-1<<endl;
		return 0;
	}
	int I=2,J=3;
	cout<<n-1+S-k<<endl;
	for(int i=1;i<n;i++) cout<<1<<' '<<i+1<<endl;
	for(int i=0;i<S-k;i++){
		cout<<I<<' '<<J<<endl;
		if(J==n){
			I++;
			J=I+1;
		}
		else J++;
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int, int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define irep(it, stl) for (auto it = stl.begin(); it != stl.end(); it++)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define mes(a) cout << (a) << endl
#define dmes(a, b) cout << (a) << " " << (b) << endl
#define re0 return 0
#define mp(p, q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define rSort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
int dx[8] = { 1, 0, -1, 0, 1, -1, -1, 1 };
int dy[8] = { 0, 1, 0, -1, 1, 1, -1, -1 };
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; }
struct io { io() { ios::sync_with_stdio(false); cin.tie(0); } };
const int INF = INT_MAX;
const ll LLINF = 1LL << 60;
const ll MOD = 1000000007;
const double EPS = 1e-9;


signed main(void) 
{
    ll a, b;
    cin >> a >> b;
    mes(6-a-b);
    
    


}


Measured memory_bytes: 3596
#include <iostream>
#include <queue>
#include <string>
#include <utility>
using namespace std;

int main(){
    queue<pair<string, int> > process;
    int n, q, time;
    pair<string, int> p;
	string name;
	cin >> n >> q;
    for (int i = 0; i < n; i++){
		cin >> name;
		cin >> time;
        p = make_pair(name, time);
		process.push(p);
	}
    int t = 0;
    while (!process.empty()){
        if (process.front().second > q){
            t += q;
            process.front().second -= q;
            process.push(process.front());
            process.pop();
        }else{
            t += process.front().second;
            cout << process.front().first << ' ' << t << endl;
            process.pop();
        }
    }
}

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

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<long,long> pll;
typedef vector<int> vi;
typedef vector<long long> vll;

#define forn(i, n) for(int i=0; i<n; i++)
#define mp makepair
#define pb push_back

int main(){
    int n,k;
    int arr[100000+7];
    scanf("%d%d",&n,&k);
    forn(i,n)scanf("%d", arr+i);
    ll dp[100000+7];
    dp[0] = 0;
    for(int i = 1; i < n; i++) {
        dp[i] = 1L << 63 - 1;
        for(int j = 1; j<=k; j++) {
            if (i - j >= 0)
                dp[i] = min(dp[i], dp[i-j] + abs(arr[i] - arr[i-j]));
        }
    }
    cout<<dp[n-1]<<endl;
}


Measured memory_bytes: 1408
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#include<algorithm>//next_permutation
#define rep(i,n) for (int i = 0;i < (n);i++)
#define all(v) v.begin(),v.end()
#define dec(n) cout << fixed << setprecision(n);
#define large "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
#define small "abcdefghijklmnopqrstuvwxyz"
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vl>;

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

const ll MOD = 1000000007;
const ll MAX = 2000001;

ll mod(ll a){
  return a % MOD;
}

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


int main(){
  ll x; cin >> x;
  
  if(x % 11 <= 6 and x % 11 != 0) cout << (x+10)/11 * 2 - 1 << endl;
  else cout << (x+10)/11 *2  << endl;
  
}

Measured memory_bytes: 3528
#include <bits/stdc++.h>
using namespace std;
const double eps = 1e-8;
#define LL long long
#define INF 0x3f3f3f3f

const int MAXN = 1e5 + 5;
const LL MOD = 1e9+7;

int c[10][10];
int a[1000][1000];

int main() 
{
#ifndef ONLINE_JUDGE
    //freopen("in.txt", "r", stdin);
#endif

    int n, m;
    cin >> n >> m;
    for(int i = 0; i < 10; i++)
    {
        for(int j = 0; j < 10; j++)
        {
            scanf("%d", &c[i][j]);
        }
    }
    for(int i = 0; i < n; i++)
    {
        for(int j = 0; j < m; j++)
        {
            scanf("%d", &a[i][j]);
        }
    }
    for(int k = 0; k < 10; k++)
    {
        for(int i = 0; i < 10; i++)
        {
            for(int j = 0; j < 10; j++)
            {
                c[i][j] = min(c[i][j], c[i][k]+c[k][j]);
            }
        }
    }
    int sum = 0;
    for(int i = 0; i < n; i++)
    {
        for(int j = 0; j < m; j++)
        {
            if(a[i][j] != -1)
                sum += c[a[i][j]][1];
        }
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define sqr(x) ((x)*(x))
#define mp make_pair
#define uint unsigned
#define PI pair<int,int>
inline char gc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
inline ll read(){
	ll x = 0; char ch = gc(); bool positive = 1;
	for (; !isdigit(ch); ch = gc())	if (ch == '-')	positive = 0;
	for (; isdigit(ch); ch = gc())	x = x * 10 + ch - '0';
	return positive ? x : -x;
}
inline void write(ll a){
    if(a<0){
    	a=-a; putchar('-');
	}
    if(a>=10)write(a/10);
    putchar('0'+a%10);
}
inline void writeln(ll a){write(a); puts("");}
inline void wri(ll a){write(a); putchar(' ');}
inline ull rnd(){
	return ((ull)rand()<<30^rand())<<4|rand()%4;
}
const int N=505,M=100005,x[4]={1,-1,0,0},y[4]={0,0,1,-1};
ll ans[N][N],tot;
int n,p[M],vis[M],q[M];
#define ld long double
ll lcm(ll x,ll y){
	if(x==0)return y; if(y==0)return x;//cout<<x<<" "<<y<<endl;
	//if((ld)x/__gcd(x,y)*y>(1e15))while(1);
	return x/__gcd(x,y)*y;
}
signed main(){
	n=500;
	for(int i=2;i<M;i++)if(!vis[i]){
		q[++tot]=i; for(int j=i;j<M;j+=i)vis[j]=1;
	}
	for(int i=1;i<=1000;i++)if(i&1)p[i]=q[(i+1)/2]; else p[i]=q[1001-i/2];
	int tx=248,ty=249;
	for(int i=1;i<=n*2;i+=2){
		if(i<=n){tx+=2; ty+=1;} else {tx++; if(i!=n+1)ty--;}
		int x=i<=n?1:i-n+1,y=i<=n?n-i+1:1;
		int t=min(n-x+1,n-y+1); 
		for(int j=0;j<t;j++){
			ans[x+j][y+j]=p[tx]*p[ty-j]; //if(x+j==500)cout<<y+j<<" "<<tx<<" "<<ty-j<<endl;
			//if(abs(x+j-2)+abs(y+j-2)==1)cout<<tx<<" "<<ty-j<<endl;
		}
	}
	for(int i=1;i<=n;i++)for(int j=1;j<=n;j++)if((i+j)%2==0){
	//cout<<i<<" "<<j<<endl;
		for(int k=0;k<4;k++)ans[i][j]=lcm(ans[i][j],ans[i+x[k]][j+y[k]]);
		ans[i][j]++;
	}
	//set<ll> s;
	//for(int i=1;i<=n;i++)for(int j=1;j<=n;j++){ s.insert(ans[i][j]);}
	//cout<<s.size()<<endl;
	n=read();
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++){
			write(ans[i][j]); putchar(' ');
		}
		puts("");
	}
}
/*

 
*/

Measured memory_bytes: 5504
import sys
sys.setrecursionlimit(10**6)
input = sys.stdin.readline

def dfs(ve, add):
  global seen
  global r
  seen[ve] = True
  r[ve] = add
  a = len(ki[ve])
  for i in range(a):
    b = ki[ve][i]
    if not seen[b]:
      dfs(b, add+ook[b])

N,Q = map(int, input().split())
side = [list(map(int, input().split())) for _ in range(N-1)]
op = [list(map(int, input().split())) for _ in range(Q)]
ki = [[] for _ in range(N)]
ook = [0]*N
seen = [False]*N
r = [0]*N

for i in range(N-1):
  a = side[i][0] -1
  b = side[i][1] -1
  ki[a].append(b)
  ki[b].append(a)
  
for i in range(Q):
  ook[op[i][0] -1] += op[i][1]
  
for i in range(N):
  if seen[i]:
    continue
  dfs(i, ook[i])
    
print(" ".join(map(str,r)))

Measured memory_bytes: 325604
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rep3(i, l, n) for (int i = l; i < n; ++i)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define out(a) cout << a << endl
#define outa(a, n) rep(_, n) cout << a[_] << " "; cout << endl
#define SZ(v) (int)v.size()
#define inf (int)(1e9+7)

int main() {
    int n;
    cin >> n;
    vector<int> a(n + 1);
    for (auto& ai : a) cin >> ai;
    vector<int> b(n);
    for (auto& bi : b) cin >> bi;
    ll sum = 0;
    rep(i, n) {
        int tmp = min(a[i], b[i]);
        // out(tmp);
        sum += tmp;
        b[i] -= tmp;
        sum += min(a[i + 1], b[i]);
        a[i + 1] -= min(a[i + 1], b[i]);
    }
    out(sum);
    
}


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

int main() {
    int n;
    cin >> n;
    map<char, int> mp;
    for (int i = 0; i < n; ++i) {
        char s;
        cin >> s;
        mp[s]++;
    }
    cout << (mp.size() == 4 ? "Four" : "Three") << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		int ac=0,wa=0,tle=0,re=0;
		
		for (int i = 0; i < n; i++) {
			String s=sc.next();
			
			if(s.equals("AC")) ac++;
			else if(s.equals("WA")) wa++;
			else if(s.equals("TLE")) tle++;
			else re++;
		}
		System.out.println("AC x "+ac);
		System.out.println("WA x "+wa);
		System.out.println("TLE x "+tle);
		System.out.println("RE x "+re);
	}
}


Measured memory_bytes: 58780
#include <iostream>
#include <string>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <map>
#include <cmath>
#include <queue>
#include <utility>
#include <functional>
#include <deque>
#include <cctype>
#include <stack>

using ll = long long;
typedef std::pair<int, int>p;

ll min(ll a, ll b) {
	if (a >= b)return b;
	else return a;
}
ll max(ll a, ll b) {
	if (a >= b)return a;
	else return b;
}
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a%b);
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}

const ll Z = 1000000007;
const ll INF = 1 << 30;
const ll INF2 = 9000000000000000000LL;
bool flag = true;
bool fl = true;
bool used[210];
bool graph[100][100];

int main() {
	int n, b[9] = { 0 }, min = 0, max = 0;
	std::cin >> n;
	for (int i = 0;i < n;i++) {
		int a;
		std::cin >> a;
		if (1 <= a && a <= 399) b[0]++;
		if (400 <= a && a <= 799)b[1]++;
		if (800 <= a && a <= 1199)b[2]++;
		if (1200 <= a && a <= 1599) b[3]++;
		if (1600 <= a && a <= 1999) b[4]++;
		if (2000 <= a && a <= 2399) b[5]++;
		if (2400 <= a && a <= 2799) b[6]++;
		if (2800 <= a && a <= 3199) b[7]++;
		if (3200 <= a && a <= 4800) b[8]++;
	}
	int c = 0;
	for (int i = 0;i < 8;i++) {
		if (b[i] != 0)c++;
	}
	if (c == 0) {
		min = 1;
		max += b[8];
	}
	else {
		min += c;
		max += c + b[8];
	}
	std::cout << min << ' ' << max << std::endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

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

        int a = sc.nextInt();
        int b = sc.nextInt();

        int ans = solve2(a, b);
        System.out.println(ans);
    }

    private static int solve(int a, int b) {
        int d = b - a;
        int sum = 0;

        for (int i=1; i<d; i++) {
            sum += i;
        }

        return sum - a;
    }

    private static int solve2(int a, int b) {
        int d = b-a;

        return d*(d-1)/2 - a;
    }
}


Measured memory_bytes: 25044
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<queue>
#include<deque>
#include<cmath>
#include<map>
#include<unordered_map>
#include<set>
#include<cstring>
#include<iomanip> //cout << fixed << setprecision(15) << x << endl;

using namespace std;
typedef long long ll;
const ll INF = 1e9 + 6;
const ll MOD = 1e9 + 7;
const ll LLINF = 1LL<<60;
#define Pint pair<int, int>
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
/* -- template -- */

int main() {
    string s; cin >> s;
    string S;
    rep(i, s.size() - 1) {
        if(s[i] == 'B' && s[i + 1] == 'C') {
            S.pb('D');
            i += 1;
        }else {
            S.pb(s[i]);
        }
    }
    ll cntA = 0;
    ll ans = 0;
    rep(i, S.size()) {
        if(S[i] == 'B' || S[i] == 'C') {
            cntA = 0;
        }else {
            if(S[i] == 'A') ++cntA;
            else if(S[i] == 'D') ans += cntA;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 776
#include <bits/stdc++.h>
using namespace std;
typedef long long  ll;
const int N=2e5+5;
const int MOD=1e9+7;
int a[N];
int b[N];
int n,k,m;
int cmp(int a,int b)
{
    return a>b;
}

map <int,int> mp;
string s;
string t;

int main()
{
    cin>>s;
    cin>>t;
    int ls=s.size();
    int lt=t.size();
    int MAX=0;
    for(int i=0;i<ls;i++){
        if(i+lt-1>=ls) break;
        int cou=0;
        for(int j=0;j<lt;j++){
            if(t[j]==s[i+j]) cou++;
        }
        MAX=max(cou,MAX);
    }
    cout<<lt-MAX<<endl;
}






Measured memory_bytes: 3636
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <cstdio>
#include <string>
#include <cmath>
#include <queue>
#include <tuple>
#include <set>
#include <assert.h>
#include <sstream>
#include <string>
//#include <bits/stdc++.h>
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i,i0,n) for(int (i)=(i0);(i)<(n);(i)++)
#define FORR(i,i0,n) for(int (i)=(n)-1; (i)>=(i0);(i)--)
#define SORT(x) sort(x.begin(),x.end())
#define SORTR(x) sort(x.begin(),x.end(),greater <>())
#define rn return
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
using namespace std;
using ll = long long;
typedef std::pair<ll,ll> P;
//#include <boost/multiprecision/cpp_int.hpp>
//using bint = boost::multiprecision::cpp_int;



int main(){
    string s,t,u;
    int a,b;
    cin >> s >> t >> a >> b >> u;
    if (u==s) cout << a-1 << " " << b;
    else cout << a << " " << b-1;
    rn 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <string>

using namespace std;
int main()
{
    string a,b;
    int c=0;
    cin>>a>>b;
    if(a[0] == b[0]){
        c++;
    }
    if(a[1] == b[1]){
        c++;
    }
    if(a[2] == b[2]){
        c++;
    }
    cout<<c;

}

Measured memory_bytes: 3596
#include <stdio.h>

int main(void)
{
	int n;
	int age;
	int id;
	int count[7];
	int i;
	
	while (1){
		scanf("%d", &n);
		if (n == 0){
			break;
		}
		
		for (i = 0; i < 7; i++){
			count[i] = 0;
		}
		
		for (i = 0; i < n; i++){
			scanf("%d", &age);
			if (age >= 60){
				id = 6;
			}
			else {
				id = age / 10;
			}
			count[id]++;
		}
		
		for (i = 0; i < 7; i++){
			printf("%d\n", count[i]);
		}
	}
	
	return (0);
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
using LL = long long;
const LL LINF = 1e18;
const double EPS = 1e-10;
using namespace std;
#define COUT(v) cout<<(v)<<endl
#define COUTDOUBLE(v) cout << std::setprecision(10)<<(v)<<endl;
#define CIN(n)  int(n);cin >> (n)
#define LCIN(n) LL(n);cin >> (n)
#define SCIN(n) string(n);cin >> (n)
#define YES(n) cout<<((n)? "YES" : "NO")<<endl
#define Yes(n) cout<<((n)? "Yes" : "No")<<endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) <<endl

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

#define FOREACH(x,a) for(auto& (x) : (a) )

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

#define P pair<LL,LL>
#define I vector<int>
#define pb(v) push_back(v)
#define V vector
#define rt return
#define rmsame(a) sort(ALL(a)),a.erase(unique(ALL(a)), a.end())
#define ENDL cout<<endl
#define f first
#define s second

typedef string::const_iterator State;
class PalseError {};
class Edge{
public:
    int from,to,value;
    Edge(LL a,LL b,LL c){
        from = a;
        to = b;
        value = c;
    }
    Edge(LL a,LL b){
        from = a;
        to = b;
    }
};




int main(){
    double a,b;
    cin >> a >> b;
    COUTDOUBLE(1/(1/a+1/b));
    return 0;
}


Measured memory_bytes: 256
N = int(input())
monsters = list(map(int,input().split()))
monsters.sort()
while len(monsters)>1:
    for i in range(1,len(monsters)):
#        print(monsters)
        monsters[i] = monsters[i] % monsters[0]
    monsters = [i for i in monsters if i != 0]
    monsters.sort()
print(monsters[0])

Measured memory_bytes: 14252
fn main() {
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).ok();
    let mut v: Vec<u32> = buf.split_whitespace().map(|x| x.parse().unwrap()).collect();
    v.sort();

    let mut ans = (v[2] - v[1]) / 2 + (v[2] - v[0]) / 2;
    let rest = (v[2] - v[1]) % 2 + (v[2] - v[0]) % 2;
    ans += (3 - rest) % 3;
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
using namespace std;


int main(){
    int w,h,n;
    long long int ans=0;
    cin>>w>>h>>n;

    vector<pair<int,int>>a(10000);
    vector<pair<int,int>>b(10000);
    for(int i=0;i<n;i++){
        cin>>a[i].first>>a[i].second;
        if(i>0){
            b[i-1].first=a[i].first-a[i-1].first;
            b[i-1].second=a[i].second-a[i-1].second;
        }
    }
    for(int i=0;i<n-1;i++){
        if((b[i].first>0&&b[i].second>0)||(b[i].first<0&&b[i].second<0)){
            ans+=max(abs(b[i].first),abs(b[i].second));
        }
        else{
            ans+=abs(b[i].first)+abs(b[i].second);
        }
    }

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



Measured memory_bytes: 3216
#include<bits/stdc++.h>
using ll= long long;
using  INT = long long;

#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=ll(b);i--)
#define ALL(x) x.begin(),x.end()

#define INF (int)1e9 //10^9:∞
#define LLINF (long long)1e12
#define MOD (int)1e9+7 //10^9+7:合同式の法
#define PI 3.141592653589

#define YESNO(T) if(T){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define yesno(T) if(T){cout<<"yes"<<endl;}else{cout<<"no"<<endl;}
#define YesNo(T) if(T){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}

#define Graph vector<vector<int> >
#define PII pair<int,int>
#define VI vector<int>
#define VVI vector<vector<int> >
#define VPII vector<pair<int,int> >

#define DDD fixed<<setprecision(1)

using namespace std;
/*........................................Define functions.........................................*/


struct UnionFind {
	vector<int> d; //iが子ならd[i]は親のidでiが親ならd[i]は -サイズ
	UnionFind(int n): d(n, -1) {}
	int find(int x) {
		if (d.at(x) < 0)return x;//親なら自分自身の番号を返す
		else return d.at(x) = find(d.at(x)); //経路圧縮　メモ化
	}
	bool unite(int x, int y) { //voidでもいいが、くっつけられるか判定できた方が嬉しいときもある
		x = find(x); y = find(y); //根同士をくっつけるため
		if (x == y) return false;//統合できない(しない)
		if (-d.at(x) < -d.at(y)) swap(x, y);
		d.at(x)+= d.at(y); //親のサイズの更新 サイズが大きい方に小さい方を統合
		d.at(y) = x;//yは親ではなくなったのでyの親をｘに設定
		return true;//統合できた
	}
	int size(int x) {return -d.at(find(x));}
	bool same(int x, int y) {return find(x) == find(y);}
};


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


/*....................................Define global variables .....................................*/





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

int n,m;
	cin>>n>>m;
	UnionFind uf(n);
	REP(i,m){
		int a,b;
		cin>>a>>b;
		a--;b--;
		uf.unite(a,b);
	}
	int ans=0;
	REP(i,n){
		chmax(ans,uf.size(i));
	}
	cout<<ans<<endl;
	
 

	return 0;
}



Measured memory_bytes: 3964
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <memory.h>
#include <math.h>
#include <assert.h>
#include <queue>
#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <iostream>
#include <functional>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <bitset>

using namespace std;
typedef pair<int, int> pii;
typedef long long ll;
#define Fi first
#define Se second
#define pb(x) push_back(x)
#define sz(x) ((int)(x).size())
#define rep(i, n) for(int i=0;i<n;i++)
#define all(x) (x).begin(), (x).end()
typedef tuple<int, int, int> t3;
typedef pair<ll, ll> pll;
typedef long double ldouble;
typedef pair<double, double> pdd;

int N, p[200020], deg[200020];
int A[200020];
set <int> S[200020];
pii C[200020];

int get(set <int> &X) {
	for(int i=0;;i++) if(X.find(i) == X.end()) return i;
	return -1;
}

pii get2(set <int> &X) {
	pii res = pii(-1, -1);
	for(int i=0;;i++) if(X.find(i) == X.end()) {
		if(res.Fi == -1) res.Fi = i;
		else if(res.Se == -1) res.Se = i;
		else return res;
	}
}

int chk[200020];
void dfs2(int x,vector<int> &c){
	c.pb(x); chk[x] = 1;
	int e = p[x];
	if(deg[e] > 0 && chk[e] == 0) dfs2(e, c);
}

void solve(){
	scanf("%d", &N);
	for(int i=1;i<=N;i++) scanf("%d", p+i), deg[p[i]]++;
	queue <int> que;
	for(int i=1;i<=N;i++) {
		if(deg[i] == 0) que.push(i);
	}
	while(!que.empty()) {
		int t = que.front(); que.pop();
		A[t] = get(S[t]);
		S[p[t]].insert(A[t]);
		--deg[p[t]];
		if(deg[p[t]] == 0) {
			que.push(p[t]);
		}
	}
	vector <int> cyc;
	for(int i=1;i<=N;i++) if(deg[i] > 0) {
		dfs2(i, cyc);
		break;
	}
	for(int e : cyc) C[e] = get2(S[e]);
	A[cyc[0]] = C[cyc[0]].Fi;
	for(int i=1;i<sz(cyc);i++) {
		int a = A[cyc[i-1]];
		if(a == C[cyc[i]].Fi) A[cyc[i]] = C[cyc[i]].Se;
		else A[cyc[i]] = C[cyc[i]].Fi;
	}
	if(A[cyc[sz(cyc)-1]] != A[cyc[0]]) {
		puts("POSSIBLE");
		return;
	}
	A[cyc[0]] = C[cyc[0]].Se;
	for(int i=1;i<sz(cyc);i++) {
		int a = A[cyc[i-1]];
		if(a == C[cyc[i]].Fi) A[cyc[i]] = C[cyc[i]].Se;
		else A[cyc[i]] = C[cyc[i]].Fi;
	}
	if(A[cyc[sz(cyc)-1]] == C[cyc[0]].Fi) {
		puts("POSSIBLE");
		return;
	}
	puts("IMPOSSIBLE");
}

int main(){
	int Tc = 1; //scanf("%d\n", &Tc);
	for(int tc=1;tc<=Tc;tc++){
		// printf("Case #%d: ", tc);
		solve();
	}
	return 0;
}

Measured memory_bytes: 22656
n,m = map(int,input().split())
h = list(map(int,input().split()))

ma =[0] * n

for i in range(m):
  a,b =map(int,input().split())
  ma[a-1] = max(ma[a-1],h[b-1])
  ma[b-1] = max(ma[b-1],h[a-1])

ans = 0
for i in range(n):
  if ma[i] < h[i] :
    ans += 1

print(ans)

Measured memory_bytes: 20076
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N =0;
  long long D = 0;
  cin >> N >> D;
  int count = 0;
  
  for(int i = 0; i < N; i++){
  long long X, Y = 0;
  cin >> X >> Y;
  
 
  if(X*X + Y*Y <= D*D){
  count++;
  }
    
  }
 cout << count << endl;
}

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

#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a, 0, sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define SIZE(array) (sizeof(array) / sizeof(array[0]))

#define MAXAS(x,v) x = max(x,v)

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

#define PI 3.141592653589793

#define MOD 1000000007L
#define INF 100000000000

typedef pair<int, long> P;

bool sort_less(P &left, P &right){
    return left.first < right.first;
}

signed main() {
	int n;
	long k;
	cin >> n >> k;
	map<int, long> m;
	for (size_t i = 0; i < n ; i++) {
		int a, b;
		cin >> a >> b;
		m[a] += b;
	}
	vector<P> ps;
	for (auto &e: m) {
		ps.push_back(make_pair(e.first, e.second));
	}
	sort(ps.begin(), ps.end(), sort_less);

	long sum = 0;
	for (vector<P>::iterator it = ps.begin(); it != ps.end(); it++) {
		sum += it->second;
		if (sum >= k) {
			cout << it->first << endl;
			break;
		}
	}
}


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

#define REP(i, n) for(int i = 0; i < n; i++)
using namespace std;

int main()
{   
    int k, x;
    cin >> k >> x;

    for (int i = x-k+1; i <= x+k-1; i++) {
        if (i <= 1000000 && i >= -1000000)
            cout << i << " ";
    }
    cout << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String O = sc.next();
		String E = sc.next();
		sc.close();
		
		StringBuilder sb = new StringBuilder();
		for(int i = 0;i < Integer.min(O.length(), E.length());++i) {
			sb.append(O.charAt(i));
			sb.append(E.charAt(i));
		}
		if(O.length() != E.length()) {
			if(O.length() < E.length())
				sb.append(E.charAt(E.length()-1));
			else
				sb.append(O.charAt(O.length()-1));
		}
		System.out.println(sb.toString());
	}
}


Measured memory_bytes: 25044