akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <queue>
#include <stack>
#include <string>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cmath>

#define rep(i, n) for(int i = 0; i < n; i ++)
#define ALL(T) T.begin(), T.end()
#define mp make_pair
#define pb push_back
#define T first
#define H second

using namespace std;

typedef pair<int, int> pii;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<string> vs;

const int INF = 1 << 24;

int main(void){
    for(int n, m; cin >> n >> m, n;){
        pii s;
        vi t(n); rep(i, n) cin >> t[i], s.T += t[i];
        vi h(m); rep(i, m) cin >> h[i], s.H += h[i];

        pii res = mp(INF, INF);
        rep(i, n)
            rep(j, m)
                if(s.T - t[i] + h[j] == s.H - h[j] + t[i] &&
                   t[i] + h[j] < res.T + res.H)
                    res = mp(t[i], h[j]);

        if(res.T == INF) cout << -1 << endl;
        else cout << res.T << " " << res.H << endl;
    }

    return 0;
}

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

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

    string s;
    cin >> s;
    
    int ans = 0;
    for (int i = 1; i < n; i++){
        if (s[i] == s[i - 1])
            ans += 1;
    }

    cout << min(n - 1, ans + k * 2) << '\n';

    return 0;
}


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

int main() {
    int sum = 0;
    int rest_sum = 0;
    int max_rest = 0;
    for (int i = 0; i < 5; i++) {
        int a;
        cin >> a;
        sum += a;
        int rest = 10 - a % 10;
        if (rest != 10) {
            rest_sum += rest;
            max_rest = max(max_rest, rest);
        }
    }
    cout << sum + rest_sum - max_rest << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i,a,b) for(ll i=(a);i<=(b);++i)
#define FOD(i,a,b) for(ll i=(a);i>=(b);--i)
#define name "a"
#define pb push_back
typedef pair < ll , ll > ii;
const ll maxn=1e5+7,oo=1e18,mod=1e9+7;
ll n,m,a[maxn];
double s,tmp;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //freopen(name".inp","r",stdin);
    //freopen(name".out","w",stdout);
    cin>>n>>m;
    FOR(i,1,n)
    {
        cin>>a[i];
        s+=a[i];
    }
    tmp=s/(4*m);
    sort(a+1,a+1+n);
    FOD(i,n,n-m+1)
        if(a[i]-tmp<0)
        {
            cout<<"No";
            return 0;
        }
    cout<<"Yes";
}


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

using namespace std;
typedef pair<int,int> P;
const int MAXN=2e5+10;
map<P,int> mp;
struct edge{int nxt,to;}e[MAXN<<2];
int c1[MAXN],c2[MAXN],sum1[MAXN],sum2[MAXN];
int n,k,l,x,y,head[MAXN],vis[MAXN],res[MAXN],tot,cnt;

void add_edge(int from,int to)
{
	e[++tot].nxt=head[from];e[tot].to=to;head[from]=tot;
	e[++tot].nxt=head[to];e[tot].to=from;head[to]=tot;
}

void dfs(int x,int c,int* col)
{
	vis[x]=true;col[x]=c;
	for(int i=head[x];i;i=e[i].nxt)
		if(!vis[e[i].to]) dfs(e[i].to,c,col);
}

void solve(int esum,int* col)
{
	tot=cnt=0;
	memset(head,0,sizeof(head));
	memset(vis,false,sizeof(vis));
	for(int i=1;i<=esum;i++)
		scanf("%d%d",&x,&y),add_edge(x,y);
	for(int i=1;i<=n;i++)
		if(!vis[i]) dfs(i,++cnt,col);
}

int main()
{
	scanf("%d%d%d",&n,&k,&l);
	memset(res,0x3f,sizeof(res));
	solve(k,c1);solve(l,c2);
	for(int i=1;i<=n;i++)
		sum1[c1[i]]++,sum2[c2[i]]++;
	for(int i=1;i<=n;i++) 
		mp[P(c1[i],c2[i])]++;
	for(int i=1;i<=n;i++)
		printf("%d ",mp[P(c1[i],c2[i])]);
	
	return 0;
}

Measured memory_bytes: 20352
#include <bits/stdc++.h>
using namespace std;
#define SORT(a) sort((a).begin(), (a).end())
#define RSORT(a) reverse((a).begin() z, (a).end())
#define rep(i, n) for (int i = 0; i < n; i++)
typedef long long ll;
const long long MOD = 1000000007;
const long long INF = 1LL << 60;
// const int INF = 1001001001;

int main() {
  vector<vector<string>> a(3, vector<string>(3));
  rep(i, 3) {
    rep(j, 3) { cin >> a[i][j]; }
  }
  vector<string> s(8);
  s[0] = "." + a[0][0] + "." + a[1][1] + "." + a[2][2] + ".";
  s[1] = "." + a[0][2] + "." + a[1][1] + "." + a[2][0] + ".";
  s[2] = "." + a[0][0] + "." + a[1][0] + "." + a[2][0] + ".";
  s[3] = "." + a[0][1] + "." + a[1][1] + "." + a[2][1] + ".";
  s[4] = "." + a[0][2] + "." + a[1][2] + "." + a[2][2] + ".";
  s[5] = "." + a[0][0] + "." + a[0][1] + "." + a[0][2] + ".";
  s[6] = "." + a[1][0] + "." + a[1][1] + "." + a[1][2] + ".";
  s[7] = "." + a[2][0] + "." + a[2][1] + "." + a[2][2] + ".";
  int n;
  cin >> n;
  bool ans = false;
  vector<string> b(n);
  rep(i, n) cin >> b[i];
  rep(i, 8) {
    int count = 0;
    rep(j, n) {
      if (s[i].find("." + b[j] + ".") != string ::npos) {
        count++;
      }
    }
    if (count == 3) ans = true;
  }
  if (ans)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

Measured memory_bytes: 256
// Problem : A - Guess The Number
// Contest : Virtual Judge - Showdown
// URL : https://vjudge.net/contest/391413#problem/A
// Memory Limit : 1048 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)


/*ヽ｀、ヽ｀｀、ヽ｀ヽ｀、、ヽ ｀ヽ 、ヽ｀MOON｀ヽヽ｀ヽ、ヽ｀
ヽ｀、ヽ｀｀、ヽ 、｀｀、 ｀、ヽ｀ 、｀ ヽ｀ヽ、ヽ ｀、ヽ｀｀、
ヽ、｀｀、｀、ヽ｀｀、 、ヽヽ｀、｀、、ヽヽ、｀｀、 、 ヽ｀、 
ヽ｀｀、 ヽ｀ヽ｀、、ヽ ｀ヽ 、 MANヽ｀｀｀｀ヽヽヽ｀、、ヽ｀、、ヽ*/

// #pragma GCC optimize ("O3")
// #pragma GCC target ("sse4")

#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
 
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,b,a) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
#define trav(a,x) for (auto& a : x)
 
#define bug(x) cout<<#x<<"="<<x<<endl; 
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert
 
template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
const ld pii=3.14159265359; 
const int MOD = 1000000007;
const char nl = '\n';
const int MX = 200001; //check the limits, dummy
 
int main() 
{
	ios_base::sync_with_stdio(0); cin.tie(0);    
	int N,M;
	cin>>N>>M;
	vi ans(N,-1);
	F0R(x,M)
	{
		int in,val;
		cin>>in>>val;
		in--;
		if(ans[in]!=-1 && ans[in]!=val)
		{
			cout<<-1;
			return 0;
		}
		ans[in]=val;
	}
	if(N==1)
	{
		if(ans[0]==-1)
			ans[0]=0;
		cout<<ans[0];
		return 0;
	}
	if(ans[0]==0)
		cout<<-1;
	else
	{
		if(ans[0]==-1)
			ans[0]=1;
		cout<<ans[0];
		FOR(x,1,N)
		{
			if(ans[x]==-1)
				ans[x]=0;
			cout<<ans[x];
		}
	}
	return 0;
}
 
// read the question correctly (ll vs int)
// template by bqi343

Measured memory_bytes: 3624
def main():
    import sys
    import math
    input = sys.stdin.readline
    K = int(input())
    A,B=map(int,input().split())
    
    answer="OK"
    for x in range(A,B+1):
        if x%K==0:
            print(answer)
            sys.exit()
        
    answer="NG"
    print(answer)



if __name__ == '__main__':
    main()


Measured memory_bytes: 9180
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vint = vector<int>;
using vvint = vector<vint>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vchar = vector<char>;
using vvchar = vector<vchar>;
using vp = vector<P>;
using vpp = vector<pair<P, P>>;
using vvp = vector<vp>;

#define rep(i, n) for (int i = 0; i < n; ++i)
#pragma region Debug
istream &operator>>(istream &is, P &a)
{
    return is >> a.first >> a.second;
}
ostream &operator<<(ostream &os, const P &a) { return os << "(" << a.first << "," << a.second << ")"; }

template <typename T>
void view(const std::vector<T> &v)
{
    for (const auto &e : v)
    {
        std::cout << e << " ";
    }
    std::cout << std::endl;
}
template <typename T>
void view(const std::vector<std::vector<T>> &vv)
{
    for (const auto &v : vv)
    {
        view(v);
    }
}
#pragma endregion

const double PI = 3.1415926535897932384;

int main()
{
    double r;
    cin >> r;

    cout.precision(15);
    cout << fixed << 2 * r * PI << endl;

    return 0;
}

Measured memory_bytes: 3788
import sys
import numpy as np
from collections import deque, Counter
int1 = lambda x: int(x) - 1
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(500000)

N, X, Y = map(int, read().split())
dist = []
for i in range(1, N):
    node = np.arange(i + 1, N + 1)

    d = np.abs(node - i)
    dd = np.abs(i - X) + np.abs(Y - node) + 1
    ddd = np.abs(i - Y) + np.abs(X - node) + 1

    acc = np.minimum(np.minimum(d, dd), ddd)

    dist.append(acc)

dist = np.concatenate(dist)

cnt = np.bincount(dist, minlength=N)
for i in range(1, N):
    print(cnt[i])

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

using namespace std;

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()
#define F first
#define S second
#define forn(i, n) for (int i = 0; i < (int)n; i++)
#define pb push_back
#define fastIO ios::sync_with_stdio(0), cin.tie(0)
#define endl '\n'
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
void debug_out() {
    cerr << endl;
}
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << to_string(H), debug_out(T...);
}

int main() {
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
    freopen("in.txt", "r", stdin);
    // freopen("out.txt", "w", stdout);
#else
#define debug(...) 3
    fastIO;
#endif
    string s, t;
    cin >> s >> t;
    int ans = 0;
    forn(i, sz(s)) {
        if(s[i] != t[i])ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3756
n = int(input())
s = list(input())

counter = [0] * n

counter[0] = s[1:].count('E')

for i in range(1, n):
    n = 0
    if s[i - 1] == 'W':
        n += 1
    if s[i] == 'E':
        n -= 1
    counter[i] = counter[i - 1] + n

print(min(counter))


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

using namespace std;
typedef long long int ll;
typedef pair<ll,ll> P;

#define repi(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,a) repi(i,0,a)
#define rrep(i,a) for(ll i=a-1;i>=0;i--)
#define MOD 1000000007

//debug
#define debug(arr) cerr<<#arr<<"(l"<<__LINE__<<") : ";for(auto x:arr)cerr<<x<<" ";cerr<<endl;

ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

ll kaijo(ll n){
  ll res = 1;
  repi(i, 1, n+1) res = res * i % MOD;
  return res;
}

ll comb(ll n, ll r) {
  ll res = 1;
  res = res * kaijo(n) % MOD;
  res = res * modinv(kaijo(r), MOD) % MOD;
  res = res * modinv(kaijo(n-r), MOD) % MOD;
  return res;
}

int main(){
  ll N, K;
  cin >> N >> K;
  ll A[N];
  rep(i, N) cin >> A[i];
  sort(A, A+N);

  ll ans = 0;
  if(K > 1){
    ll comblist[N] = {};
    rep(i, N){
      if(i+1 == K) comblist[i] = 1;
      else if(i+1 > K) comblist[i] = comblist[i-1] * (i-1) % MOD * modinv(i-K+1, MOD) % MOD;
    }
    rep(i, N-1) comblist[i+1] = (comblist[i] + comblist[i+1]) % MOD;
    rep(i, N) ans = (ans + (comblist[i] - comblist[N-i-1]) * A[i]) % MOD;
    ans = (ans + MOD) % MOD;
    // rep(i, N) cout << comblist[i] << endl;
  }
  cout << ans << endl;
  return 0;
}


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

#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")

/* debugging */
#define TRACE

#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cout << name << ": " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<"| ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif


#define boost ios::sync_with_stdio(0); cin.tie(0);
#define int long long

const int N = 2e3 + 2;
const int mod = 1e9 + 7;

int L[N][N] , R[N][N] , U[N][N] , D[N][N];
char a[N][N];
int n , m;

void print(int b[N][N]){

	for(int i = 1 ; i <= n ; ++i){
		for(int j = 1 ; j <= m ; ++j){
			cout << b[i][j] << " ";
		}cout << "\n";
	}

	cout << "endprint\n";
}

int32_t main(){
    boost;
    
    //code
    cin >> n >> m;
   	
   	for(int i = 1 ; i <= n ; ++i){
   		for(int j = 1 ; j <= m; ++j){
   			cin >> a[i][j];
   		}
   	}

   	for(int i = 1; i <= n ; ++i){
   		for(int j = 1 ; j <= m ; ++j){
   			if(a[i][j] == '#')
   				L[i][j] = 0;
   			else
   				L[i][j] = L[i][j-1] + 1;
   		}
   	}

   	for(int i = 1 ; i <= n; ++i){
   		for(int j = m ; j >= 1 ; --j){
   			if(a[i][j] == '#')
   				R[i][j] = 0;
   			else
   				R[i][j] = R[i][j+1] + 1;
   		}
   	}

   	for(int j = 1 ; j <= m ; ++j){
   		for(int i = 1 ; i <= n ; ++i){
   			if(a[i][j] == '#')
   				U[i][j] = 0;
   			else
   				U[i][j] = U[i-1][j] + 1;
   		}
   	}

   	for(int j = 1 ; j <= m ; ++j){
   		for(int i = n ; i >= 1 ; --i){
   			if(a[i][j] == '#')
   				D[i][j] = 0;
   			else
   				D[i][j] = D[i+1][j] + 1;
   		}
   	}

   	int ans = 0;
   	for(int i = 1 ; i <= n ; ++i)
   		for(int j = 1 ; j <= m ; ++j)
   			ans = max(ans, U[i][j]+D[i][j]+L[i][j]+R[i][j] - 3);
   	cout << ans << endl;
    return 0;
}

Measured memory_bytes: 129408
#include <stdio.h>

#define TRUE 1
#define FALSE -1
#define M 36

typedef struct{
  char mark;
  int value;
}TRUMP;

int isStable(TRUMP *, TRUMP *,int);

int main(){
  TRUMP C1[M],C2[M],in[M];
  char m;
  int i,j,v,minj,N;

  scanf("%d",&N);
 
  for(i=0;i<N;i++){
    scanf(" %c%d",&C1[i].mark,&C1[i].value);
    C2[i]=C1[i];
    in[i]=C1[i];
  }

  /*
  for(i=0;i<N;i++) printf("%c%d ",C1[i].mark,C1[i].value);
  printf("\n");
  for(i=0;i<N;i++) printf("%c%d ",C2[i].mark,C2[i].value);
  printf("\n");
  for(i=0;i<N;i++) printf("%c%d ",in[i].mark,in[i].value);
  printf("\n");
  */

  //BubbleSort(C,N)
  for(i=0;i<N;i++){
    for(j=N-1;j>i;j--){
      if(C1[j].value < C1[j-1].value){
	//swap_v(&C1[j].value,&C1[j-1].value);
	v=C1[j].value;
	C1[j].value=C1[j-1].value;
	C1[j-1].value=v;
	//swap(&C[j].mark,&C[j-1].mark);
	m=C1[j].mark;
	C1[j].mark=C1[j-1].mark;
	C1[j-1].mark=m;
      }
    }
  }
  
  for(i=0;i<N;i++){
    printf("%c%d",C1[i].mark,C1[i].value);
    if(i!=N-1) printf(" ");
  }
  printf("\n");
  if(isStable(in,C1,N)==TRUE) printf("Stable\n");
  else printf("Not stable\n");


	 
  //SelectionSort(C,N)
  for(i=0;i<N;i++){
    minj=i;
    for(j=i;j<N;j++){
      if(C2[j].value < C2[minj].value) minj=j;
    }
    //swap_v(&C2[i].value,&C2[minj].value);
    v=C2[i].value;
    C2[i].value=C2[minj].value;
    C2[minj].value=v;
    //swap(&C2[i].mark,&C2[minj].mark);
    m=C2[i].mark;
    C2[i].mark=C2[minj].mark;
    C2[minj].mark=m;
  }

  for(i=0;i<N;i++){
    printf("%c%d",C2[i].mark,C2[i].value);
    if(i!=N-1) printf(" ");
  }
  printf("\n");
  if(isStable(in,C2,N)==TRUE) printf("Stable\n");
  else printf("Not stable\n");

  
  return 0;
}

int isStable(TRUMP *in, TRUMP *out, int N){
  int i,j,a,b;
  for(i=0;i<N-1;i++){
    for(j=i+1;j<N-1;j++){
      for(a=0;a<N-1;a++){
	for(b=a+1;b<N-1;b++){
	  if(in[i].value==in[j].value && //in[i].mark==in[j].mark &&
	     in[i].value==out[b].value && in[i].mark==out[b].mark &&
	     in[j].value==out[a].value && in[j].mark==out[a].mark) return FALSE;
	}
      }
    }
  }
  return TRUE;
}



Measured memory_bytes: 2128
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<list>
#include <array>
#include <complex>
using namespace std;
#define i64  long long
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807
#define INF I64_MAX
#define MOD 1000000007
#define MEM_SIZE = 1e5+5;

template<typename T> void DEBUG(T e){std::cout << e << std::endl;}
template<class T> void DEBUG(string str, T e){std::cout <<str << ">>" << e << std::endl;}
template<typename T> void DEBUG(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ DEBUG(v); } }
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}




//-----CODE------//
//-----CODE------//


void solve(void)
{
  int K,S;
  cin>>K>>S;
  int X,Y,Z;
  int ANS = 0;
  for (int x = 0; x <= K; x++)
  {
    for (int y = 0; y <= K; y++)
    {
      int z = S - x - y;
      if((0 <=z)&&(z <= K))
      {
        ANS++;
      }
    }
  }
  cout<<ANS<<endl;
  
  
  
  return; 
}


int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();

 
  return 0;
}

Measured memory_bytes: 256
N, W=map(int, input().split())
WV=[list(map(int, input().split())) for i in range(N)]
dp = [-1] * (W+1)
dp[0] = 0
for w, v in WV:
    for i in range(W, w-1, -1):
        if dp[i-w] == -1:
            continue
        dp[i] = max(dp[i], dp[i-w] + v)
print(max(dp))


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

int main(){
    int a, b, k;
    cin >> a >> b >> k;
    vector<int> intersection;
    int limit = max(a, b);

    for(int i = 1; i <= limit; i++){
        if (a % i == 0 && b % i == 0) {
            intersection.push_back(i);
        }
    }

    cout << intersection[intersection.size() - k] << "\n";
}

Measured memory_bytes: 256
n = int(input())
Edge = [list(map(int,input().split())) for i in range(n-1)]

Graph = [[] for i in range(n)]
for edge in Edge:
    Graph[edge[0]-1].append(edge[1]-1)
    Graph[edge[1]-1].append(edge[0]-1)

Distance_1 = [-1 for i in range(n)]
Distance_1[0] = 0
Distance_n = [-1 for i in range(n)]
Distance_n[n-1] = 0

stack = [0]
while stack:
    node = stack.pop()
    for adj in Graph[node]:
        if Distance_1[adj] == -1:
            Distance_1[adj] = Distance_1[node] + 1
            stack.append(adj)

stack = [n-1]
while stack:
    node = stack.pop()
    for adj in Graph[node]:
        if Distance_n[adj] == -1:
            Distance_n[adj] = Distance_n[node] + 1
            stack.append(adj)

count = 0
for i in range(n):
    if Distance_1[i]<=Distance_n[i]:
        count += 1

if count > n-count:
    print('Fennec')
else:
    print('Snuke')

Measured memory_bytes: 79064
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define int long long

const int N=1e5+5;

int dist[N];
vector<pair<int, int> > g[N];

int32_t main()
{
    IOS;
   	int n;
   	cin>>n;
   	for(int i=0;i<n;i++)
   	{
   		dist[i]=1e18;
   		int v=(i+1)%n;
   		g[i].pb(mp(v, 1));
   	}
   	for(int i=0;i<n;i++)
   	{
   		int v=(i*10)%n;
   		g[i].pb(mp(v, 0));
   	}
   	int source=1;
   	dist[source]=0;
   	deque<int> d;
   	d.push_front(source);
   	while(!d.empty())
   	{
   		int u=d.front();
   		d.pop_front();
   		for(auto it:g[u])
   		{
   			int v=it.ff;
   			if(dist[u]+it.ss<dist[v])
   			{
   				dist[v]=dist[u]+it.ss;
   				if(it.ss)
   				{
   					d.push_back(v);
   				}
   				else
   				{
   					d.push_front(v);
   				}
   			}
   		}
   	}
   	cout<<dist[0]+1;
    return 0;
} 

Measured memory_bytes: 8448
s=list(input())
u=[int(s[0]+s[1]),int(s[2]+s[3])]
if(0<u[0]<=12):
    m1=1
    if(0<u[1]<=12):                                                                                                                                                                                                    m2=1
    else:
        m2=0
else:
    m1=0
    if(0<u[1]<=12):
        m2=1
    else:
        m2=0
if(m1==1 and m2==0):
    print('MMYY')
elif(m1==1 and m2==1):
    print('AMBIGUOUS')
elif(m1==0 and m2==0):
    print('NA')
else:
    print('YYMM')

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main(void){
    long long int a,b,c,d;
    cin>>a>>b>>c>>d;
    long long int tmp_c=c,tmp_d=d;
    while (tmp_c%tmp_d!=0) {
        long long int tmp=tmp_d;
        tmp_d=tmp_c%tmp_d;
        tmp_c=tmp;
    }
    long long int lcm=(c*d)/tmp_d;
    long long int tmp1=b/c-a/c,tmp2=b/d-a/d;
    long long int tmp3=b/lcm-a/lcm;
    //cout<<tmp1<<" "<<tmp2<<" "<<tmp3<<endl;
    long long int ans=b-a+1-tmp1-tmp2+tmp3;
    if (a%c==0) {
        ans--;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
from collections import defaultdict
n=int(input())
a=list(map(int,input().split()))

ld=defaultdict(int)
rd=defaultdict(int)
for i in range(n):
    l=i+a[i]
    r=i-a[i]
    ld[l]+=1
    rd[r]+=1
ans=0
for i,j in ld.items():
    ans+=j*rd[i]

print(ans)


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

using namespace std;
typedef long long ll;


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

    string s;
    int ac = 0, tle = 0, wa = 0, re = 0;

    while (n--) {
        cin >> s;
        if (s=="AC") ac++;
        else if (s=="TLE") tle++;
        else if (s=="WA") wa++;
        else re++;
    }

    cout << "AC x " << ac << "\nWA x " << wa <<
    "\nTLE x " << tle << "\nRE x " << re << endl;


    return 0;
}



Measured memory_bytes: 3644
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <iomanip>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define pie 3.141592653589793238462643383279
#define INF 1000000007
#define ggr getchar(); getchar();return 0;
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}

int n, k, a[100010], ta;

signed main() {
	cin >> n >> k;
	rep(i, n)cin >> a[i];
	sort(a, a + n);
	if (k > a[n - 1]) {
		cout << "IMPOSSIBLE" << endl;
		ggr
	}
	ta = gcd(a[0], a[1]);
	for (int i = 2; i < n; i++) {
		ta = gcd(ta, a[i]);
	}
	if ((k - a[0]) % ta == 0) {
		cout << "POSSIBLE" << endl;
	}
	else {
		cout << "IMPOSSIBLE" << endl;
	}
	ggr
}

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

typedef pair<int, int> P;
#define rep(i, n) for (int i=0; i<(n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007

int N, K;
int A[5000];
bool dp[5000];

bool f(int x) {
  if (A[x] >= K) return true;

  rep(i, K) dp[i] = false;
  dp[0] = true;
  rep(i, N) {
    if (i == x) continue;
    for (int j=K-1; j>=0; j--) {
      if (j >= A[i] && dp[j-A[i]]) dp[j] = true;
    }
  }
  for (int i=K-A[x]; i<K; i++) {
    if (dp[i]) return true;
  }
  return false;
}

signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  cin >> N >> K;
  rep(i, N) cin >> A[i];
  sort(A, A+N);

  int lo = -1, hi = N;
  while (hi - lo > 1) {
    int mid = (lo + hi) / 2;
    if (f(mid)) hi = mid;
    else lo = mid;
  }
  cout << hi << "\n";
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
// type alias
typedef long long LL;
typedef pair<int,int> II;
typedef tuple<int,int,int> III;
typedef vector<int> VI;
typedef vector<string> VS;
typedef unordered_map<int,int> MAPII;
typedef unordered_set<int> SETI;
template<class T> using VV=vector<vector<T>>;
// minmax
template<class T> inline T SMIN(T& a, const T b) { return a=(a>b)?b:a; }
template<class T> inline T SMAX(T& a, const T b) { return a=(a<b)?b:a; }
// repetition
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n)  for(int i=0;i<=(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORR(x,arr) for(auto& x:arr)
#define SZ(a) int((a).size())
// collection
#define ALL(c) (c).begin(),(c).end()
// DP
#define MINUS(dp) memset(dp, -1, sizeof(dp))
#define ZERO(dp) memset(dp, 0, sizeof(dp))
// stdout
#define println(args...) fprintf(stdout, ##args),putchar('\n');
// debug cerr
template<class Iter> void __kumaerrc(Iter begin, Iter end) { for(; begin!=end; ++begin) { cerr<<*begin<<','; } cerr<<endl; }
void __kumaerr(istream_iterator<string> it) { (void)it; cerr<<endl; }
template<typename T, typename... Args> void __kumaerr(istream_iterator<string> it, T a, Args... args) { cerr<<*it<<"="<<a<<", ",__kumaerr(++it, args...); }
template<typename S, typename T> std::ostream& operator<<(std::ostream& _os, const std::pair<S,T>& _p) { return _os<<"{"<<_p.first<<','<<_p.second<<"}"; }
#define __KUMATRACE__ true
#ifdef __KUMATRACE__
#define dump(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); __kumaerr(_it, args); }
#define dumpc(ar) { cerr<<#ar<<": "; FORR(x,(ar)) { cerr << x << ','; } cerr << endl; }
#define dumpC(beg,end) { cerr<<"~"<<#end<<": "; __kumaerrc(beg,end); }
#else
#define dump(args...)
#define dumpc(ar)
#define dumpC(beg,end)
#endif

// $ cp-batch Test | diff Test.out -
// $ g++ -std=c++14 -Wall -O2 -D_GLIBCXX_DEBUG -fsanitize=address Test.cpp && ./a.out

/*

 6/28/2020

 9:00-9:22

 */

LL N;

bool ok(LL n, LL k) {
  while(n%k==0) n/=k;
  return (n-1)%k==0;
}

void solve() {
  set<LL> res;
  LL n=N-1;
  auto add=[&](LL k) {
    if(k>=2&&k<=N) res.emplace(k);
  };
  for(LL p=1; p*p<=n; ++p) if(n%p==0) {
    add(p),add(n/p);
  }
  for(LL p=1; p*p<=N; ++p) if(N%p==0) {
    if(p!=1&&ok(N,p)) add(p);
    if(ok(N,N/p)) add(N/p);
  }
  cout<<SZ(res)<<endl;
}

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

  cin>>N;
  solve();

  return 0;
}


Measured memory_bytes: 3624
import java.util.*;
import java.lang.*;

public class Main {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long[] a = new long[n + 1];
        long[] b = new long[n];
        
        for (int i = 0; i < n + 1; i++) {
            a[i] = sc.nextLong();
        }
        for (int i = 0; i < n; i++) {
            b[i] = sc.nextLong();
        }
        
        long sum = 0, residue = 0, ability;
        for (int i = 0; i < n + 1; i++) {
            if (i != n) {
                ability = b[i] + residue;
                residue = Math.min(ability - a[i], b[i]);
                residue = Math.max(residue, 0);
            } else {
                ability = residue;
            }
            
            if (a[i] < ability) {
                sum += a[i];
            } else {
                sum += ability;
            }
        }
        System.out.println(sum);
    }
    
}

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

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0);
	int cnt[26] = {0};
	int n, k; cin >> n >> k;
	for (int i = 0; i < n; ++i) {
		string a; cin >> a;
		++cnt[a[0] - 'A'];
	}
	priority_queue<int> pq;
	for (int i = 0; i < 26; ++i) {
		if (cnt[i]) pq.push(cnt[i]);
	}
	int ans = 0;
	while (pq.size() >= k) {
		vector<int> tmp;
		for (int i = 0; i < k; ++i) {
			tmp.push_back(pq.top());
			pq.pop();
		}
		for (int i = 0; i < k; ++i) if (tmp[i] > 1) pq.push(tmp[i] - 1);
		++ans;
	}
	cout << ans << '\n';
}


Measured memory_bytes: 256
import itertools

N = int(input())
S = "MARCH"
dic = {s: 0 for s in S}
for s in filter(lambda s: s in S, [input()[0] for _ in range(N)]):
    dic[s] += 1

print(sum([dic[a] * dic[b] * dic[c]
           for (a, b, c) in itertools.product(S, repeat=3) if a < b < c]))


Measured memory_bytes: 3892
#include <bits/stdc++.h>
#define int long long
#define REP(i,n) for(int i = 0; i < (int)(n); ++i)
#define DEBUG(x) cerr << #x << " = " << x << endl
using namespace std;
const int INF = (int)1e9;
signed main() {
  ios::sync_with_stdio(false);
  int N; cin >> N;
  vector<int> A(N);
  REP(i,N) cin >> A[i];
  map<int, int> cnt;
  int minval = INF;
  int maxval = 0;
  REP(i,N) {
    cnt[A[i]]++;
    minval = min(minval, A[i]);
    maxval = max(maxval, A[i]);
  }
  bool ok;
  if(cnt[minval] == 1) {
    if(maxval != minval * 2) ok = false;
    else {
      ok = true;
      for(int i = minval + 1; i <= maxval; ++i) {
        if(cnt[i] < 2) ok = false;
      }
    }
  }
  else if(cnt[minval] == 2) {
    if(maxval != minval * 2 - 1) ok = false;
    else {
      ok = true;
      for(int i = minval + 1; i <= maxval; ++i) {
        if(cnt[i] < 2) ok = false;
      }
    }
  }
  else {
    ok = false;
  }
  cout << (ok ? "Possible" : "Impossible" ) << endl;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define ll long long
inline ll read() {
    ll x=0,f=1; char ch=getchar();
    for(;ch<'0'||ch>'9';ch=getchar())
        if(ch=='-')f=-f;
    for(;ch>='0'&&ch<='9';ch=getchar())
        x=x*10+ch-'0';
    return x*f;
}
inline void chkmin( int &a,int b ) { if(a>b) a=b; }
inline void chkmax( int &a,int b ) { if(a<b) a=b; }
#define _ read()
int top,S[1000005];
int main() {
	string s; cin>>s;
	int n=s.length();
	for( int i=0;i<n;i++ ) {
		if(s[i]!=s[S[top]]&&top) top--;
		else S[++top]=i;
	}
	cout<<n-top;
}

Measured memory_bytes: 896
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(signed i=0;i<n;++i)
#define repi(n) rep(i,n)
#define int long long
#define str string
#define vint vector<int>
#define pint pair<int,int>
#define pb(a) push_back(a)
#define all(v) v.begin(),v.end()
#define yn(b) cout<<((b)?"Yes":"No")<<endl
#define YN(b) cout<<((b)?"YES":"NO")<<endl
#define call(a) for(auto t:a)cout<<t<<" ";cout<<endl
#define ENDL printf("\n");
#define debg(a) cout<<#a<<":"<<a<<endl;
#define SORT(a) sort(all(a));
#define INF 1LL<<60
#define inf INF
#define out(i) cout<<i<<endl;
int min(int a,int b){if(a>b)return b;return a;}
int max(int a,int b){if(a>b)return a;return b;}

class unionFind{
public:  
  vector<int> parent;
  
  unionFind(int n){
    parent = vector<int>(n,-1);
  }

  int root(int a){
    if(parent[a]<0)return a;
    return (parent[a]=root(parent[a]));
  }

  int size(int a){
    return (-parent[root(a)]);
  }

  bool connect(int a,int b){
    a=root(a);
    b=root(b);
    if(a==b){return false;}
    if(size(a)<size(b))swap(a,b);
    parent[a]+=parent[b];
    parent[b]=a;
    return true;
  }
};

signed main(){
  int n,m;
  cin>>n>>m;
  vint a(m),b(m);
  rep(i,m)cin>>a[i]>>b[i];
  rep(i,m)a[i]--,b[i]--;
  vint ans(m);
  ans[m-1]=n*(n-1)/2;
  unionFind uni(n);
  for(int i=m-1;i>0;--i){
    ans[i-1]=ans[i];
    if(uni.root(a[i])!=uni.root(b[i])){
      ans[i-1]-=uni.size(a[i])*uni.size(b[i]);
      uni.connect(a[i],b[i]);
    }
  }
  for(auto i:ans)cout<<i<<endl;
  

  return 0;
}



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

/* MACROS SAMPAH */
#define Jehian using
#define Norman namespace
#define Saviero std
#define cepet {ios_base::sync_with_stdio(0);cin.tie(0);}

Jehian Norman Saviero;

/* MACROS FOR TYPE */
typedef long l;
typedef long double ld;
typedef long long ll;
typedef unsigned long ul;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<l> vl;
typedef vector<ll> vll;
typedef pair<int, int> pi;
typedef pair<l,l> pl;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pld;

/* MACROS FOR PRINT */
#define nl printf("\n");
#define sp printf(" ");

/* MACROS FOR FUNCTION AND METHOD */
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define mp make_pair
#define eb emplace_back
#define RESET(x) memset((x), 0, sizeof(x))
#define SET(x,y) for(int _je = sizeof(x)/sizeof(x[0]); _je--;) x[_je] = y
#define SQR(x) (x)*(x)
#define CUBE(x) SQR(x)*(x)

/* MACROS FOR ATTRIBUTE */
#define fi first
#define se second

/* MACROS FOR SCAN */
#define scc(x) scanf("%c", &x)
#define scd(x) scanf("%Lf", &x)
#define scf(x) scanf("%f", &x)
#define sci(x) scanf("%d", &x)
#define scl(x) scanf("%ld", &x)
#define scll(x) scanf("%lld", &x)
#define scld(x) scanf("%Lf", &x)
#define scui(x) sci(x)
#define scul(x) scl(x)
#define scull(x) scll(x)

vll res;
int cnt = 10;
void toBit(ll i){
	res.clear();
	cnt = 10;
	while(cnt--){
		res.pb(i%2);
		i /= 2;
	}
}

int main(){
	ll N;
	scll(N);
	ll F[N][10];
	ll P[N][11];
	ll cnt[N];
	bool isAll[N];
	RESET(cnt);
	RESET(isAll);
	for (ll i = 0; i < N; ++i){
		for (ll j = 0; j < 10; ++j){
			scll(F[i][j]);
		}
	}

	for (ll i = 0; i < N; ++i){
		for (ll j = 0; j <= 10; ++j){
			scll(P[i][j]);
		}
	}

	vll sol;
	for (ll i = 1; i < 1024; ++i){
		RESET(cnt);
		toBit(i);
		for (ll k = 0; k < N; ++k){
			for (ll j = 0; j < res.size(); ++j){
				if (res[j] && F[k][j]){
					++cnt[k];
				}
			}
		}
		ll res = 0;
		for (ll k = 0; k < N; ++k){
			res += P[k][cnt[k]];
		}
		sol.pb(res);
	}
	cout << *max_element(sol.begin(),sol.end()) << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)  for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define pb emplace_back
#define eb emplace_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
#define pi M_PI
#define PQ(T) priority_queue<T>
#define SPQ(T) priority_queue<T,vector<T>,greater<T>>
#define dame(a) {out(a);return 0;}
#define decimal cout<<fixed<<setprecision(15);
#define dupli(a) {sort(all(a));a.erase(unique(all(a)),a.end());}
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef tuple<ll,ll,ll,ll> PPP;
typedef multiset<ll> S;
using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;
using vvvvi=vector<vvvi>;
using vp=vector<P>;
using vvp=vector<vp>;
using vb=vector<bool>;
using vvb=vector<vb>;
const ll inf=1001001001001001001;
const ll INF=1001001001;
const ll mod=1000000007;
const double eps=1e-10;
template<class T> bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<class T> bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T> void out(T a){cout<<a<<'\n';}
template<class T> void outp(T a){cout<<'('<<a.fi<<','<<a.se<<')'<<'\n';}
template<class T> void outvp(T v){rep(i,v.size())cout<<'('<<v[i].fi<<','<<v[i].se<<')';cout<<'\n';}
template<class T> void outvvp(T v){rep(i,v.size())outvp(v[i]);}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<'\n';}
template<class T> void outvv(T v){rep(i,v.size())outv(v[i]);}
template<class T> bool isin(T x,T l,T r){return (l)<=(x)&&(x)<=(r);}
template<class T> void yesno(T b){if(b)out("yes");else out("no");}
template<class T> void YesNo(T b){if(b)out("Yes");else out("No");}
template<class T> void YESNO(T b){if(b)out("YES");else out("NO");}
template<class T> void noyes(T b){if(b)out("no");else out("yes");}
template<class T> void NoYes(T b){if(b)out("No");else out("Yes");}
template<class T> void NOYES(T b){if(b)out("NO");else out("YES");}
void outs(ll a,ll b){if(a>=inf-100)out(b);else out(a);}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll modpow(ll a,ll b){ll res=1;a%=mod;while(b){if(b&1)res=res*a%mod;a=a*a%mod;b>>=1;}return res;}

int main(){
    ll n;cin>>n;
    vi cnt(100005);
    ll ans=0;
    rep(i,n){
        ll a;cin>>a;if(cnt[a]==0)ans++;
        cnt[a]++;
    }
    if(ans%2==0)ans--;
    out(ans);
}

Measured memory_bytes: 4048
#include <algorithm>
#include <climits>
#include <complex>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

// using
using namespace std;

// typedef
typedef long long ll;

// define
#define FOR(i, a, b, c) for (int i = (int)(a); i < (int)(b); i += (int)(c))
#define REP(i, n) FOR(i, 0, n, 1)
#define RFOR(i, a, b, c) for (int i = (int)(a); i >= (int)(b); i -= (int)(c))
#define RREP(i, n) RFOR(i, n, 0, 1)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REVERSE(c) reverse(ALL(c))
#define UNIQ(c) unique(ALL(c))
#define LB(c, x) lower_bound(c.begin(), c.end(), x)
#define UB(c, x) upper_bound(c.begin(), c.end(), x)
#define LI(c, x) distance(c.begin(), LB(c, x))
#define UI(c, x) distance(c.begin(), UB(c, x))

// functions
template <class T> T ceil(T a, T b) {
    return (a + b - 1) / b;
}
template <class T> T round(T a, T b) {
    return (a + b / 2) / b;
}
template <class T> T gcd(T a, T b) {
    return b ? gcd(b, a % b) : a;
}
template <class T> T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}
template <class T> bool amax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> bool amin(T& a, const T& b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}

// main
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, Q;
    string S;
    cin >> N >> Q >> S;
    vector<int> cnt(N, 0);
    REP(i, N - 1) {
        if (S[i] == 'A' && S[i + 1] == 'C') {
            cnt[i + 1] = cnt[i] + 1;
        } else {
            cnt[i + 1] = cnt[i];
        }
    }
    vector<int> res(Q);
    REP(i, Q) {
        int l, r;
        cin >> l >> r;
        l--, r--;
        res[i] = cnt[r] - cnt[l];
    }
    REP(i, Q) {
        cout << res[i] << endl;
    }
    return 0;
}


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

typedef long long int ll;
typedef pair<int,int> pi;
priority_queue<pi, vector<pi>, greater<pi> > pq; //min heap

ll mini(ll a,ll b){	return a<b?a:b;}
ll maxi(ll a,ll b){	return a>b?a:b;}
ll gcd(ll a,ll b){	if(b == 0)	return a;return gcd(b,a%b);}
ll binpow(ll n,ll x){	ll ans = 1;while(x){if(x & 1)	ans *= n;n *= n;x >>= 1;}return ans;}

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

    int n;
    cin>>n;

    vector<ll> A(n,0);

    for(int i=0;i<n;++i)    cin>>A[i];

    ll ans = A[0];

    for(int i=1;i<n;++i)    ans = gcd(ans, A[i]);

    cout<<ans<<'\n';

    return 0;
}

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

int main()
{
    int N, C_0 = 0, C_1 = 0, C_2 = 0, C_3 = 0;
    cin >> N;

    for (int i = 0; i < N; i++)
    {
        string S_i;
        cin >> S_i;
        if (S_i == "AC")
        {
            C_0++;
        }
        else if (S_i == "WA")
        {
            C_1++;
        }
        else if (S_i == "TLE")
        {
            C_2++;
        }
        else
        {
            C_3++;
        }
    }
    cout << "AC x " << C_0 << endl;
    cout << "WA x " << C_1 << endl;
    cout << "TLE x " << C_2 << endl;
    cout << "RE x " << C_3 << endl;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll read() {
	ll x=0, f=1; char ch=' ';
	while(!isdigit(ch)) {ch=getchar(); if(ch=='-') f=-1;}
	while(isdigit(ch)) x=(x<<3)+(x<<1)+(ch^48), ch=getchar();
	return x*f;
}
int f[500005], n, m, maxn, cnt[500005];
int find(int x) {
	if(x==f[x]) return f[x];
	return f[x]=find(f[x]);
}
int main() {
	cin>>n>>m;
	for(int i=1;i<=n;i++) f[i]=i;
	for(int i=1;i<=m;i++) {
		int a=read(), b=read();
		int x=find(a), y=find(b);
		if(x!=y) f[x]=y;
	}
	for(int i=1;i<=n;i++) cnt[find(i)]++;
	for(int i=1;i<=n;i++) maxn=max(maxn, cnt[i]);
	cout<<maxn;
}


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

int main()
{
    int a, b;

    cin>>a>>b;

        if((b-1)%(a-1) == 0)
            cout<<(b-1)/(a-1);
        else
            cout<<((b-1)/(a-1))+1;


    return 0;
}


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

#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_CAT_I(x,y) x ## y
//#define CPP_STR(x) CPP_STR_I(x)
//#define CPP_STR_I(args...) #args
//#define ASSERT(expr...) assert((expr))

using i8 = int8_t;
using u8 = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
using f32 = float;
using f64 = double;
//using f80 = __float80;

constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
constexpr char EL[] = "\n";

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(),(x).end()
#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))
#define UNIQUE(x) (x).erase(unique(all(x)), (x).end());
#define REPIT(x) for(auto it=(x).begin(), end=(x).end(); it!=end; ++it)
#define perm(c) sort(all(c)); for(bool c##p=1;c##p;c##p=next_permutation(all(c)))

template<typename T = i64>
T IN() { T x; cin >> x; return (x); }

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }
template<typename T, size_t N>
i64 SIZE(const T(&)[N]) { return static_cast<i64>(N); }

template<typename T, typename U, typename Comp = less<>>
bool chmax(T& xmax, const U& x, Comp comp = {}) {
	if (comp(xmax, x)) {
		xmax = x;
		return true;
	}
	return false;
}
template<typename T, typename U, typename Comp = less<>>
bool chmin(T& xmin, const U& x, Comp comp = {}) {
	if (comp(x, xmin)) {
		xmin = x;
		return true;
	}
	return false;
}

void print() {
  cout << EL;
}
template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
  cout << head;
  if (sizeof...(tail) != 0) cout << " ";
  print(forward<Tail>(tail)...);
}
template <class T>
void print(vector<T> &vec) {
  for (auto& a : vec) {
	cout << a;
	if (&a != &vec.back()) cout << " ";
  }
  cout << EL;
}
template <class T>
void print(vector<vector<T>> &df) {
  for (auto& vec : df) {
	print(vec);
  }
}

struct ProconInit {
	static constexpr int IOS_PREC = 15;
	static constexpr bool AUTOFLUSH = false;

	ProconInit() {
		cin.tie(nullptr);
		ios::sync_with_stdio(false);
		cout << fixed << setprecision(IOS_PREC);
		if (AUTOFLUSH)
			cout << unitbuf;
	}
} PROCON_INIT;
#pragma endregion

signed solve()
{
	string s1, s2, s3, s="";
	cin >> s1 >> s2 >> s3;
	s = s1.substr(0, 1) + s2.substr(0, 1) + s3.substr(0, 1);
	transform(s.begin(), s.end(), s.begin(), ::toupper);
	print(s);
	return 0;
}

#ifndef LOCALCODE
signed main()
{
	return solve();
}
#endif


Measured memory_bytes: 384
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 c=sc.nextInt();
		if((a==5&&b==5&&c==7)||(a==5&&b==7&&c==5)||(a==7&&b==5&&c==5)) {
			System.out.println("YES");
		}else {
			System.out.println("NO");
		}
	}
}


Measured memory_bytes: 35548
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<math.h>
#include<map>
#include<functional>
#include<queue>
using namespace std;
int main() {
    string a,b,c;
    cin>>a>>b>>c;
    cout<<a[0]<<b[0]<<c[0]<<endl;
}   



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

int main(){
  int N;
  cin >> N;
  vector<int> d(N);
  for(int i=0;i<N;i++)
    cin >> d.at(i);
  sort(d.begin(),d.end());
  int count = 1;
  for(int i=0;i<N-1;i++){
    if(d.at(i)<d.at(i+1))
      count++;
  }
  cout << count << endl;
  
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
ll dp[2004][2004];
struct node{
	ll id,act;
}a[2004];
bool cmp(node a,node b){
	if(a.act!=b.act)return a.act>b.act;
	else return a.id<b.id;
}
int main(){
	ll n;
	scanf("%lld",&n);
	for(ll i=0;i<n;i++){
		scanf("%lld",&a[i].act);
		a[i].id=i;
	}
	sort(a,a+n,cmp);
	ll ans=0;
	//已经有多少个人放到了左边 
	for(int l=0;l<n;l++){
		//已经有多少个人放到了右边 
		for(int r=0;r<n;r++){
			//现在面对的是第几个人 
			int i=l+r;
			if(i>=n)break;
			
			ll act=a[i].act;
			ll loc=a[i].id;
			
			//是把现在这个人放到左边 
			dp[l+1][r]=dp[l][r]+act*abs(l-loc);
			//还是把现在这个人放到右边 
			dp[l][r+1]=max(dp[l][r+1],dp[l][r]+act*abs((n-1)-loc-r));
			
			ans=max(ans,dp[l+1][r]);
			ans=max(ans,dp[l][r+1]);
		}
	}
	printf("%lld\n",ans);
}

Measured memory_bytes: 26464
#include <bits/stdc++.h>
#define INF 10e15
#define MONEY 1000000000000000
using namespace std;
typedef long long ll;
typedef pair<long long ,long long > edge;
typedef pair<long long, long long> P;
 // (to,cost)
void dijkstra(vector<vector<edge>> &G, vector<ll> &d, ll start_node  ){
    priority_queue<P,vector<P>,greater<P>> que;//最短距離、頂点番号のペア
    fill(d.begin(),d.end(),INF);
    d[start_node] = 0;
    que.push(make_pair(0,start_node));

    while(!que.empty()){
        auto p = que.top(); que.pop();
        ll v = p.second;
        if (d[v]<p.first) continue;
        for (const auto &e :G[v]){
            if(d[e.first] > d[v] + e.second){
                d[e.first] = d[v] + e.second;
                que.push(make_pair(d[e.first],e.first));
            }
        }

    }


}


void solve(long long n, long long m, long long s, long long t, std::vector<long long> u, std::vector<long long> v, std::vector<long long> a, std::vector<long long> b){
    vector<vector<edge>> G_a(n+1);
    vector<vector<edge>> G_b(n+1);
    vector<ll> d_a(n+1);
    vector<ll> d_b(n+1);
    for (ll i = 0;i<m;i++){
        G_a[u[i]].push_back( make_pair(v[i],a[i]));
        G_b[u[i]].push_back( make_pair(v[i],b[i]));
        G_a[v[i]].push_back(make_pair(u[i],a[i]));
        G_b[v[i]].push_back(make_pair(u[i],b[i]));
    }
    dijkstra(G_a,d_a,s);
    dijkstra(G_b,d_b,t);
    vector<ll> ans(n,0);
    priority_queue<ll,vector<ll>,greater<ll>> shortest;
    for (int i=0;i<n;i++){
        shortest.push(d_a[n-i]+d_b[n-i]);
        ans[n-1-i]=shortest.top();
    }
    for (int i=0;i<n;i++){
        printf("%lld\n",MONEY-ans[i]);
    }

}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long n;
    scanf("%lld",&n);
    long long m;
    scanf("%lld",&m);
    long long s;
    scanf("%lld",&s);
    long long t;
    scanf("%lld",&t);
    std::vector<long long> u(m);
    std::vector<long long> v(m);
    std::vector<long long> a(m);
    std::vector<long long> b(m);
    for(int i = 0 ; i < m ; i++){
        scanf("%lld",&u[i]);
        scanf("%lld",&v[i]);
        scanf("%lld",&a[i]);
        scanf("%lld",&b[i]);
    }
    solve(n, m, s, t, std::move(u), std::move(v), std::move(a), std::move(b));
    return 0;
}


Measured memory_bytes: 23808
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
int main(){
  ll h,w,n,i,j,k,l,m,a,b,d;
  cin>>h>>w>>n;
  ll c[10]={},x[9];
  c[0]=(h-2)*(w-2);
  set<P> st;
  for(i=0;i<n;i++){
    cin>>a>>b;
    for(k=0;k<9;k++) x[k]=0;
    bool f;
    for(j=-1;j<=1;j++){
      if(a+j<=0||h<a+j) continue;
      for(k=-1;k<=1;k++){
	f=false;d=0;
	if(b+k<=0||w<b+k) f=true;
	for(l=-1;l<=1;l++){
	  if(a+j+l<=0||h<a+j+l) f=true;
	  for(m=-1;m<=1;m++){
	    if(b+k+m<=0||w<b+k+m) f=true;
	    if(st.find(P(a+j+l,b+k+m))!=st.end()) d++;
	    if(f) break;
	  }
	  if(f) break;
	}
	if(f) continue;
	x[d]++;
      }
    }
    for(k=0;k<9;k++) c[k]-=x[k],c[k+1]+=x[k];
    st.insert(P(a,b));
  }
  for(i=0;i<10;i++) cout << c[i] << endl;
  return 0;
}


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

using namespace std;
long long mod=1000000007;
int main()
{
    long long n, k;
    cin>>n>>k;
    long long sum=0;
    for(int i=k; i<=n+1; i++)
    {
        sum+=(i*(n-i+1))%mod+1;
    }
    cout<<sum%mod;
    return 0;
}


Measured memory_bytes: 3612