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

# define Rep(i,a,b) for(int i=a;i<=b;i++)
# define _Rep(i,a,b) for(int i=a;i>=b;i--)
# define RepG(i,u) for(int i=head[u];~i;i=e[i].next)

typedef long long ll;

const int N=4e5+5;

template<typename T> void read(T &x){
   x=0;int f=1;
   char c=getchar();
   for(;!isdigit(c);c=getchar())if(c=='-')f=-1;
   for(;isdigit(c);c=getchar())x=(x<<1)+(x<<3)+c-'0';
    x*=f;
}

# define int long long

int n;
int a[N],b[N],sz;
int head[N],cnt;
int f[N];
int ans;
int d[N];

struct Edge{
    int to,next;
}e[N<<1];

void add(int x,int y){
    e[++cnt]=(Edge){y,head[x]},head[x]=cnt;
}

void dfs(int u,int fa)
{
    int tmp=lower_bound(d,d+n,a[u])-d;
    f[u]=tmp+1;
    f[u]=max(f[u],f[fa]);
    int t=d[tmp];
    d[tmp]=a[u];
    RepG(i,u){
        int v=e[i].to;
        if(v==fa)continue;
        dfs(v,u);
    }
    d[tmp]=t;
}

signed main()
{
    memset(d,0x3f,sizeof(d));
    memset(head,-1,sizeof(head));
    read(n);
    Rep(i,1,n)read(a[i]),b[i]=a[i];
    sort(b+1,b+n+1);
    sz=unique(b+1,b+n+1)-b-1;
    Rep(i,1,n)a[i]=lower_bound(b+1,b+sz+1,a[i])-b;
    Rep(i,1,n-1){
        int x,y;
        read(x),read(y);
        add(x,y),add(y,x);
    }
    // build(1,1,sz);
    dfs(1,0);
    Rep(i,1,n)printf("%lld\n",f[i]);
    return 0;
}

Measured memory_bytes: 35132
#include <bits/stdc++.h>
#define SORT(a) sort(a.begin(), a.end())
#define RSORT(a) sort(a.rbegin(), a.rend())
#define REP(i, n) for (long long i = 0; i < n; i++)
#define RREP(i, n) for (long long i = n - 1; 0 <= i; i--)
#define FOR(i, start, end) for (long long i = start; i < end; i++)
#define RFOR(i, start, end) for (long long i = start - 1; 0 <= i; i--)
#define ALL(a) a.begin(), a.end()
using ll = long long;
using namespace std;
const int INF32       = 1'050'000'000;
const long long INF64 = 4'000'000'000'000'000'000;
const int MOD7        = 1'000'000'007;
const int MOD9        = 1'000'000'009;
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;
}
void print() { std::cout << '\n'; }
template <class H, class... T> void print(H &&head, T &&... args) {
    std::cout << head;
    sizeof...(args) == 0 ? std::cout << "" : std::cout << ' ';
    print(std::forward<T>(args)...);
}
template <class T> void print(std::vector<T> &v) {
    for (int i = 0; i < v.size(); i++) {
        std::cout << v[i];
        i == v.size() - 1 ? std::cout << '\n' : std::cout << ' ';
    }
}
template <class T> void print(std::vector<std::vector<T>> &v) {
    for (int i = 0; i < v.size(); i++) {
        for (int j = 0; j < v[i].size(); j++) {
            std::cout << v[i][j];
            j == v[i].size() - 1 ? std::cout << '\n' : std::cout << ' ';
        }
    }
}

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

    int a, b, c, d, e, f;
    cin >> a >> b >> c >> d >> e >> f;
    a *= 100;
    b *= 100;

    set<int> wat, sat;
    REP(i, f) {
        REP(j, f) {
            int sum = a * i + b * j;
            if (sum <= f && sum != 0)
                wat.insert(sum);
        }
    }
    REP(i, f) {
        REP(j, f) {
            int sum = c * i + d * j;
            if (sum <= f)
                sat.insert(sum);
        }
    }
    int ans = 0, sato = 0;
    double mxnode = -1.0;
    double mxe    = (double)100 * e / (100 + e);
    for (auto &&i : wat) {
        for (auto &&j : sat) {
            int sum = i + j;
            if (f < sum || sum == 0)
                continue;
            double node = (double)100 * j / sum;
            if (j <= i * e / 100 && chmax(mxnode, node)) {
                ans  = sum;
                sato = j;
            }
        }
    }
    print(ans, sato);

    return 0;
}

Measured memory_bytes: 384
#include <vector>
#include <math.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <queue>
#include <iomanip>
#include <deque>
#include <map>

typedef long long ll;
#define rep(i, a, n) for(int i = a; i<n; i++)
#define ALL(a) begin(a), end(a)
#define mii map<int, int>
#define msi map<string, int>
#define vi vector<int>
#define vl vector<ll>
#define MOD 1000000007
#define INF 1e9
#define showVector(v) rep(i,0,v.size()){p(v[i]);p(" ")} pl("")
#define p(s) std::cout << s ;
#define pl(s)  std::cout << s << endl;
using namespace std;

// 素数判定 O(√n)
bool is_prime(int n){
    for(int i = 2; i * i <= n; i++){
        if(n % i == 0) return false;
    }
    return true;
}

// 各桁の和を計算する関数
int findSumOfDigits(int n) {
  int sum = 0;
  while (n > 0) { // n が 0 になるまで
    sum += n % 10;
    n /= 10;
  }
  return sum;
}

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

}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
int main() {
    string s;
    ll N;
    cin >> N;
    //vector<vector<int>> data(3, vector<int>(4));
    //初期値0
    //vector<int> data(i, 0);
    vl a(N);
    vl b(N);
    vl c(N);
    rep(i, 0, N) {
        cin>>a[i];
    }
    rep(i, 0, N) {
        cin>>b[i];
    }
    rep(i, 0, N) {
        cin>>c[i];
    }
    sort(a.begin(), a.end());
    sort(b.begin(), b.end());
    sort(c.begin(), c.end());
    ll res = 0;

    rep(i, 0, N) {
        ll pre = lower_bound(a.begin(), a.end(), b[i]) - a.begin();
        ll over = c.end() - upper_bound(c.begin(), c.end(), b[i]);
        res += pre * over;
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define ALL(a)  (a).begin(),(a).end()
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
template <typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
const int INT_INF = 1LL << 30;

double func(ll n){
  double nn = (double)n;
  return n * (n + 1.0) / (2.0 * n);
}

int main(){
  ll N, K;
  cin >> N >> K;
  vll p(N);
  vector<double> d(N), dd(N+1, 0);
  for(int i = 0; i < N; i++){
    cin >> p.at(i);
    d.at(i) = func(p.at(i));
    dd.at(i+1) = dd.at(i) + d.at(i);
  }
  double ans = 0;
  for(int i = 0; i + K - 1 < N; i++){
    chmax(ans, dd.at(i+K) - dd.at(i));
  }
  cout << fixed << setprecision(10) << ans << endl;
}

Measured memory_bytes: 4992
// Shinchan Loves Coding :)))
#include<bits/stdc++.h>
#include<map>
#include<set>
#include<stack>

using namespace std;

#define night_rider ios::sync_with_stdio(false);cin.tie(NULL);
#define int long long int
#define double long double
#define en "\n"
#define fi first
#define se second
#define MP make_pair
#define PB push_back
#define all(v) v.begin(),v.end()
#define allr(v) v.rbegin(),v.rend()
#define toUpper(x) transform(x.begin(), x.end(), x.begin(),::toupper);
#define toLower(x) transform(x.begin(), x.end(), x.begin(),::tolower);
#define rep(i,x,y) for(int i=x ; i<y ; i++)
#define erep(i,x,y) for(int i=x ; i<=y ; i++)
#define erepr(i,x,y) for(int i=x ; i>=y ; i--)
#define repr(i,x,y) for(int i=x ; i>y ; i--)
typedef vector<int> vi;
typedef vector<vector<int>> vii;
typedef pair<int,int> pi;
typedef vector<pair<int,int>> pii;
bool secdes(const pair<int,int>&a , const pair<int,int>&b){if(a.se==b.se){return a.fi>b.fi;}else{return a.se>b.se;}}//second descending !
bool sir(const pair<int,int>&a , const pair<int,int>&b){if(a.fi==b.fi){return a.se>b.se;}else{return a.first>b.first;}}//first descending !
bool bysec(const pair<int,int>&a , const pair<int,int>&b){if(a.se==b.se){return a.fi<b.fi;} else{return a.se<b.se;}}//second ascending !

//--------------------------------------------------------------------------------------------------------------------------------------------------------------

const int no=3e6+5;
const int modulo=1e9+7;
const int inf=1e18;
const int N=2001;
int ar[no],br[no],mat[N][N];
int dx[]={-1 , 0 , 1 , 0};
int dy[]={0 , 1 , 0 , -1};
char dc[]={'L', 'D' , 'R' ,'U'};

//--------------------------------------------------------------------------------------------------------------------------------------------------------------
int mul(int x , int y , int mod) {
	return ((x%mod)*(y%mod))%mod;
}

int powwmod(int x, int y , int mod) { int res=1; while (y) { if (y & 1){ y--; res=mul(res,x,mod); res%=mod; } else { y/=2; x=mul(x,x,mod); x%=mod; } } return res%mod; }

int poww(int x , int y) { int res=1; while(y) { if(y%2) { y--; res=res*x; } else { y/=2; x=x*x; } } return res; }

int div(int x , int y , int mod) {
	return x*poww(y,mod-2)%mod ;
}

bool comp(int x, int y) {
	return (x < y);   // MINIMUM
	return (x > y);   // MAXIMUM
}

int gcd(int x, int y) { if(y==0) return x; else return gcd(y,x%y); }

int lcm(int x, int y) { return (x*y)/gcd(x,y);}

//--------------------------------------------------------------------------------------------------------------------------------------------------------------
vi adj[no];
int used[no];

void solve (){
	int n,m,a,b,x,y;
	cin>>n;
	cout<<((powwmod(10,n,modulo)+modulo)+(-2*powwmod(9,n,modulo)+modulo)+(powwmod(8,n,modulo)+modulo))%modulo;
}

inline void runn(){
	#ifndef ONLINE JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	#endif
}

signed main()
{
	night_rider
	//runn();
	int t=1;
	//cin>>t;
	while(t--){
		solve();
	}
}


Measured memory_bytes: 73900
#include<bits/stdc++.h>
using namespace std;
int i,j,n,a,b,m,c;
int main(){
  cin>>n>>m;
  vector<vector<int>> d(n,vector<int>(n));
  for(i=0;i<n;i++)for(j=0;j<n;j++)d[i][j]=0;
  for(i=0;i<m;i++)cin>>a>>b,a--,b--,d[a][b]=1,d[b][a]=1;
  vector<int> o(n);
  for(i=0;i<n;i++)o[i]=i;
  do{
    bool res;
    for(res=true,i=1;i<n;i++)if(d[o[i]][o[i-1]]==0)res=false;
    if(res)c++;
  }while(next_permutation(o.begin()+1,o.end()));
  cout<<c;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

bool solve(const string& s, const string& t, const string& target)
{
    int N = target.size();
    int a = 0, b = 0, p = 0;    
    for (int i = 0; i < N; i++, p ^= 1) {
        char c = target[i];
        bool found = 0;
        if (p == 0) {
            while (a < N) {
                if (s[a++] == c) {
                    found = 1;
                    break;
                }
            }
        } else {
            while (b < N) {
                if (t[b++] == c) {
                    found = 1;
                    break;
                }
            }
        }
        if (!found) return 0;           
    }
    return 1;
}

int main()
{
    string s, t;
    cin >> s >> t;
    bool res = solve(s, t, s) | solve(t, s, s);
    cout << (res ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 3220
N,M=[int(i) for i in input().split(" ")]

blue=[0]
white=[0]
red=[0]
for i in range(N):
    S=input()
    blue.append(M-S.count("B")+blue[-1])
    white.append(M-S.count("W")+white[-1])
    red.append(M-S.count("R")+red[-1])

def paint(i,j):
    retval=0
    retval+=white[i]-white[0]
    retval+=blue[j]-blue[i]
    retval+=red[N]-red[j]
    return retval

retval=10**10
for i in range(1,N):
    for j in range(i+1,N):
        retval=min(paint(i,j),retval)

print(retval)



Measured memory_bytes: 5608
#include <bits/stdc++.h>
    using namespace std;
     
    int main()
    {
      	string a,b;
      	cin>>a>>b;
      	if(a[0]==b[2] && b[0]==a[2] && a[1]==b[1])
        cout<<"YES"<<endl;
      	else
        cout<<"NO"<<endl;
    	return 0;
    }

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

using lli = long long int;

template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

template <class T>ostream &operator<<(ostream &o,const pair<T, T>&p)
{o<<"("<<p.first<<", "<<p.second<<")";return o;}

lli mygcd(lli a, lli b){
    if(a < b) return mygcd(b, a);
    lli r;
    if(b == 0) return a;
    while(r = a%b){
        a = b;
        b = r;
    }
    return b;
}

int main(void){
    lli n;
    cin >> n;
    vector<lli> a(n);
    for(auto& i : a){
        cin >> i;
    }
    lli l[100010] = {};
    lli r[100010] = {};
    vector<lli> m;
    for(lli i = 0; i < n; i++){
        l[i+1] = mygcd(l[i], a.at(i));
    }
    for(lli i = n-1; i >= 0; i--){
        r[i] = mygcd(r[i+1], a.at(i));
    }
    for(lli i = 0; i < n; i++){
        m.push_back(mygcd(l[i], r[i+1]));
    }
    cout << *max_element(m.begin(), m.end()) << endl;
    return 0;
}


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

int a,b;
int cnt;
string adv;

void match(string str,int now,int A,int B){
  if(now == cnt) {
    cout << str << endl;
    return;
  }
  if(A == 5 && B < 4) return;
  if(A < 4 && B == 5) return;
  if(a>A) match(str+"A",now+1,A+1,B);
  if(b>B) match(str+"B",now+1,A,B+1);
  return;
}

int main(){
  cin >> a >> b;
  cnt = a+b;
  match("",0,0,0);
}

Measured memory_bytes: 3188
N, K = map(int, input().split())
R, S, P = map(int, input().split())
T = input()
rsp = [set() for i in range(3)]
ans = 0
for i in range(N):
    if T[i] == 'r' and i - K not in rsp[0]:
        ans += P
        rsp[0].add(i)
    elif T[i] == 's' and i - K not in rsp[1]:
        ans += R
        rsp[1].add(i)
    elif T[i] == 'p' and i - K not in rsp[2]:
        ans += S
        rsp[2].add(i)
print(ans)


Measured memory_bytes: 18260
#include<bits/stdc++.h>
using namespace std;
#ifdef LOCAL_DEBUG
  #include "LOCAL_DEBUG.hpp"
#endif
#define int long long

const int MOD = 1e9 + 7;

signed main(){

  int n; cin >> n;
  vector<vector<int>> G(n);
  for(int i = 0; i < n-1; i++){
    int x,y; cin >> x >> y;
    x--,y--;
    G[x].push_back(y);
    G[y].push_back(x);
  }

  static int dp[100001][2];
  function< void(int,int) > dfs =
  [&](int u,int pre){
    dp[u][0] = dp[u][1] = 1;
    for(int v : G[u]){
      if(v == pre) continue;
      dfs(v,u);
      dp[u][0] = (dp[u][0] * (dp[v][0] + dp[v][1])) % MOD;
      dp[u][1] = (dp[u][1] * dp[v][0]) % MOD;
    }
  };
  dfs(0,-1);

  int ans = (dp[0][0] + dp[0][1]) % MOD;
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 15616
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 924844033LL
#define pow DCXISSOHANDSOME

struct node { int t,next; }a[400010];

ll pow[20][262144],inv[524289],fac[200010],ifac[200010],f[524288],g[524288];
int head[200010],size[200010],cnt[200010],n,tot;

inline int rd()
{
	int x=0;char ch=getchar();
	for (;ch<'0'||ch>'9';ch=getchar());
	for (;ch>='0'&&ch<='9';ch=getchar()) x=x*10+ch-'0';
	return x;
}

inline void print(ll x)
{
	static char s[233];
	if (!x) { putchar('0');putchar('\n');return; }
	int tot=0;
	for (;x;x/=10) s[++tot]=x%10+'0';
	for (;tot;tot--) putchar(s[tot]);
	putchar('\n');
}

inline void add(int x,int y) { a[++tot].t=y;a[tot].next=head[x];head[x]=tot; }

inline ll pls(const ll x,const ll y) { return (x+y<mod)?x+y:x+y-mod; }
inline ll mns(const ll x,const ll y) { return (x-y<0)?x-y+mod:x-y; }
inline ll ksm(ll x,ll y) { ll res=1;for (;y;y>>=1,x=x*x%mod) if (y&1) res=res*x%mod;return res; }

inline void pre_gao()
{
	fac[0]=1;
	for (int i=1;i<=200000;i++) fac[i]=fac[i-1]*i%mod;
	ifac[200000]=ksm(fac[200000],mod-2);
	for (int i=199999;~i;i--) ifac[i]=ifac[i+1]*(i+1)%mod;
	inv[1]=1;
	for (int i=2;i<=524288;i++) inv[i]=(mod-mod/i)*inv[mod%i]%mod;
	for (int w=2,hh=1;w<=524288;w<<=1,hh++)
	{
		ll now=ksm(5,(mod-1)/w);
		pow[hh][0]=1;
		for (int j=1;j<(w>>1);j++) pow[hh][j]=pow[hh][j-1]*now%mod;
	}
}

inline void ntt(ll *a,int n,int on)
{
	static int rev[524288];
	for (int i=1;i<n;i++) rev[i]=(rev[i>>1]>>1)|((i&1)?(n>>1):0);
	for (int i=1;i<n;i++) if (i<rev[i]) swap(a[i],a[rev[i]]);
	for (int w=2,hh=1;w<=n;w<<=1,hh++) for (int k=0;k<n;k+=w) for (int j=k;j<k+(w>>1);j++)
	{
		ll u=a[j],t=a[j+(w>>1)]*pow[hh][j-k]%mod;
		a[j]=pls(u,t);a[j+(w>>1)]=mns(u,t);
	}
	if (on==-1)
	{
		reverse(a+1,a+n);
		for (int i=0;i<n;i++) a[i]=a[i]*inv[n]%mod;
	}
}

inline void dfs(int x,int y)
{
	size[x]=1;
	for (int i=head[x];i;i=a[i].next)
	{
		int t=a[i].t;
		if (t==y) continue;
		dfs(t,x);
		size[x]+=size[t];
		cnt[size[t]]++;cnt[n-size[t]]++;
	}
}

int main()
{
	n=rd();tot=0;
	for (int i=1;i<n;i++) { int x=rd(),y=rd();add(x,y);add(y,x); }
	pre_gao();
	dfs(1,0);
	int len=1;
	for (;len<=(n<<1);len<<=1);
	for (int i=0;i<=n;i++) f[i]=cnt[i]*fac[i]%mod,g[i]=ifac[i];
	reverse(f,f+n+1);
	ntt(f,len,1);ntt(g,len,1);
	for (int i=0;i<len;i++) f[i]=f[i]*g[i]%mod;
	ntt(f,len,-1);
	reverse(f,f+n+1);
	for (int i=1;i<=n;i++) f[i]=f[i]*ifac[i]%mod;
	for (int i=1;i<=n;i++) f[i]=mns(n*fac[n]%mod*ifac[i]%mod*ifac[n-i]%mod,f[i]);
	for (int i=1;i<=n;i++) print(f[i]);
	return 0;
}

Measured memory_bytes: 70144
import sys
from math import factorial
from fractions import Fraction
import heapq, bisect
import math
import itertools
sys.setrecursionlimit(10 ** 5 + 10)
INF = 10**15 +5
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
MOD = 10**9 + 7

a,b,c = MAP()
if a+b+c>=22:
    print('bust')
else:
    print('win')

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

using ll =  long long;
using pint =  pair<int,int>;
using vint = vector<int>;
using vvint = vector<vint>;
using vpint = vector<pint>;

#define repi(i,start,end) for(int (i)=(start),TemPNuM=(int)(end);(i)<TemPNuM;++(i))
#define rep(i,end) repi((i),0,(end))
#define rfor(x,v) for(auto& (x) : (v))
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define fsort(v,lambda) sort(all((v)),(lambda))
#define vin(v) rep(i,(v).size())cin >> (v)[i];
#define vpin(v) rep(i,(v).size())cin>>v[i].first>>v[i].second
//最終奥義 #define int long long
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
//lambda: [](int x, int y){return x<y;}

struct UnionFind {
    vint par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2
    vint size;
    UnionFind(int n) : par(n) { //最初は全てが根であるとして初期化
        rep(i,n) par[i] = i;
        size.resize(n);
        rep(i,n)size[i]=1;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
        int sum = size[rx] + size[ry];
        size[rx] = sum;
        size[ry] = sum;
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
    int count(int x){
        return size[root(x)];
    }
};

signed main(void){
    int n,m,k;cin>>n>>m>>k;
    UnionFind tree(n);
    vint vf(n,0),vb(n,0);
    rep(i,m){
        int a,b;
        cin>>a>>b;
        a--;b--;
        if(a>b)swap(a,b);
        tree.unite(a,b);
        vf[a]++;vf[b]++;
    }
    rep(i,k){
        int c,d;cin>>c>>d;
        c--;d--;
        if(c>d)swap(c,d);
        if(tree.same(c,d)){
            vb[c]++;
            vb[d]++;
        }
    }


    rep(i,n){
        //cout << tree.count(i) << " " << vf[i] << " " << vb[i] << endl;
        cout << tree.count(i)-vf[i]-vb[i]-1 << " ";
    }

    cout << endl;

    return 0;
}


Measured memory_bytes: 2944
#include<stdio.h>
#include<stdlib.h>
int main(void){
    int n,N,m,i,j,k=0;
    int p[10000];

    while(1){
    scanf("%d %d %d",&m,&n,&N);
    if(m==0){
        break;
    }
    for(i=0;i<m;i++){
        scanf("%d",&p[i]);
    }
   int temp=0;
   int q;
    for(i=n;i<=N;i++){
        int a=p[i-1]-p[i];
        if(temp<=a){
            temp=a;
            q=i;
        }
    }
    
    printf("%d\n",q);
    }
return 0;
}

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

struct Stack
{
        int data[100005];
        int size;
        Stack () : size(0) {}

        void push(int k) { data[size++] = k; }
        int pop() { return ( data[--size] ); }
};

int main()
{
        Stack st;

        string S;

        while ( cin >> S ) {
                if ( isdigit(S[0]) ) st.push(atoi(S.c_str()));
                else {
                        int a, b;
                        b = st.pop();
                        a = st.pop();
                        if      ( S == "+" ) st.push(a + b);    
                        else if ( S == "-" ) st.push(a - b);
                        else if ( S == "*" ) st.push(a * b);
                        else if ( S == "/" ) st.push(a / b);
                }
        }

        cout << st.pop() << endl;

        return ( 0 );
};



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

int main(){
    int H, W;

    while(1){
        cin >> H >> W;
        if(H == 0 && W == 0) break;
        for(int i=0; i<H; i++){
            for(int j=0; j<W; j++){
                if(i == 0 || i == H-1 || j == 0 || j == W-1) cout << "#";
                else cout << ".";
            }
            cout << endl;
        }
        cout << endl;
    }

    return 0;
}


Measured memory_bytes: 3084
#include<stdio.h>
#include<map>
#include<queue>
using namespace std;

int a[8] = {0};
int direction[4][2] = {{-1,0},{1,0},{0,-1},{0,1}};
map<int,int> exitmap;

struct array{
	int map[2][4];
	int step;
};

bool isInMap(int x,int y){
	if(x<0 || x>=2)return 0;
	if(y<0 || y>=4)return 0;
	else return 1;
}

void bfs(){
	array begin = {{0,1,2,3,4,5,6,7},0};
	queue<array> que;
	que.push(begin);
	exitmap.insert(make_pair(1234567,0));
	while(!que.empty()){
		int x,y;
		array temp = que.front();
		que.pop();
		for(int i = 0; i < 2; i++)
			for(int j = 0; j < 4; j++)
				if(temp.map[i][j] == 0)
				{x = i;y = j;}
		for(int k = 0; k < 4; k++)
		{
			if(isInMap(x+direction[k][0],y+direction[k][1])){
				array newarray = temp;
				int r = newarray.map[x][y];
				newarray.map[x][y] = newarray.map[x+direction[k][0]][y+direction[k][1]];
				newarray.map[x+direction[k][0]][y+direction[k][1]] = r;
				newarray.step = temp.step + 1;
				int num = 0;
				for(int i = 0; i < 2; i++)
					for(int j = 0; j < 4; j++)
						num = num * 10 + newarray.map[i][j];
				if(exitmap.find(num) == exitmap.end())
				{
					que.push(newarray);
					exitmap.insert(make_pair(num,newarray.step));
				}

			}
		}

	}

}

int main(){
	bfs();
	int temp;
	 while (~scanf("%d",&temp))  
    {  
		int num = temp;
		for(int i = 1; i < 8; i++)
		{
			scanf("%d",&temp);
			num = num * 10 + temp;
		}
		printf("%d\n",exitmap[num]);
       
    }  
	return 0;		
}

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

int main(int argc, char *argv[]) {
  ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);

  ll n;cin>>n;
  std::vector<ll> v(n);
  for(ll i=0;i<n;i++){
    cin>>v[i];
  }
  sort(v.rbegin(), v.rend());
  ll w=0,h=0;
  for(ll i=0;i<n-1;i++){
    if(v[i]==v[i+1]){
      w=v[i];
      v[i]=0;
      v[i+1]=0;
      break;
    }
  }
  sort(v.rbegin(), v.rend());
  for(ll i=0;i<n-1;i++){
    if(v[i]==v[i+1]){
      h=v[i];
      break;
    }
  }
  cout<<w*h<<endl;

  return 0;
}


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

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl





using ll = long long;


const int maxn = 1e6 + 5;


ll S(ll x) {
    ll res = 0;
    while (x) {
	res += (x%10);
	x /= 10;
    }
    return res;
}


bool snuke(ll n) {

    for (ll i=n+1; i<=n*10; i++) {
	if (n*S(i) > i*S(n)) return false;
    }
    return true;
}

ll k;

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

    cin>>k;

    // for (ll i=1; i<=100000; i++) {
    // 	if (snuke(i)) watch(i);
    // }


    // Let f(N): n>=N that minimizes n/S(n)
    // motivation: If we can build f(N), then we can repeatedly iterate on N to get all K terms.
    
    // Minimizing n/S(n) more or less means maximizing S(n),
    // so an intuitive guess for n would mean it has a lot of 9's.
    
    // In fact, n is of the form N1,N2,N3...d,9,9,9..9, where d is the first digit that differs from N.
    // Proof: Suppose for sake of contradiction that n doesn't have a suffix of all 9's,
    // so it looks like N1,N2,N3,d,9,9,..3,..9,9.
    // Let x < n, and x = N1,n2,n3,d-1,9,9,9,9...9.
    // but x < n and S(x) >= S(n), which means x/S(x) <= n/S(n), which violates our min criteria, so we've
    // come full circle on the fact that n actually contains a suffix of 9's.

    ll add = 1;

    cout<<1<<endl;
    ll cur=1;
    for (int it=2; it<=k; it++) {
	ll nxt=cur+add;
	ll nxt2 = nxt+add;
	if (nxt*S(nxt2) > nxt2*S(nxt)) {
	    add *= 10ll;
	    nxt = cur + add;
	}
	cur = nxt;
	cout<<cur<<"\n";
    }
    
    return 0;
}


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

int main() {
  int N, a;
  cin >> N;
  vector<int>vec(N);
  for(int i = 0; i < N; i++){
    cin >> vec.at(i);
  }
  sort(vec.begin(), vec.end());
  int max_difference = abs(vec.at(0) - vec.at(N - 1));
  cout << max_difference << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(void){
    ll A, B, K;
    cin >> K >> A >> B;
    for ( ll i = A; i <= B; i++ ) {
        if ( i % K == 0 ) {
            cout << "OK" << endl;
            return 0;
        }
    }
    cout << "NG" << endl;
    return 0;
}


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

int main() {
  int N;
  cin >> N;
  int B[N+1];
  B[0] = 100000;
  B[N] = 100000;
  
  for (int i = 1; i < N; i++) {
    cin >> B[i];
  }
  
  int ans = 0;
  for (int i = 0; i < N; i++) {
    ans += min(B[i], B[i+1]);
  }
  
  cout << ans << endl;
}


Measured memory_bytes: 256
l = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
n = int(input())

print(l[n-1])

Measured memory_bytes: 9136
class Factorial:
    def __init__(self, n, mod=10**9+7):
        self.fac = [0] * (n+1)
        self.ifac = [0] * (n+1)
        self.fac[0] = 1
        self.ifac[0] = 1
        self.mod = mod
        modmod = self.mod - 2
        for i in range(n):
            self.fac[i+1] = self.fac[i] * (i+1) % self.mod
            self.ifac[i+1] = self.ifac[i] * pow(i+1, modmod, self.mod) % self.mod

    def comb(self, n, r):
        if n == 0 and r == 0:
            return 1
        if n < r or n < 0:
            return 0
        tmp =  self.ifac[n-r] * self.ifac[r] % self.mod
        return tmp * self.fac[n] % self.mod

    def perm(self, n, r):
        if n == 0 and r == 0:
            return 1
        if n < r or n < 0:
            return 0
        return (self.fac[n] * self.ifac[n-r]) % self.mod

h,w,a,b = map(int, input().split())
mod = 10**9+7
fact = Factorial(h+w+1)
ans = 0
c,d = h-a, w-b
for i in range(b+1, w+1):
    d = w-i+1
#     print(i,i+c-2, c-1, fact.comb(i+c-2, c-1),  fact.comb(a+d-2, a-1))
    ans = (ans + fact.comb(i+c-2, c-1) * fact.comb(a+d-2, a-1)) % mod

print(ans)


Measured memory_bytes: 42736
import java.util.*;

class Index {
    String word;
    ArrayList<Integer> pages;

    Index(String word) {
        this.word = word;
        pages = new ArrayList<Integer>();
    }

    void addPage(int page) {
        pages.add(page);
        Collections.sort(pages);
    }

    void printPages() {
        for(int i = 0; i < pages.size(); i++) {
            if (i != pages.size() - 1) {
                System.out.printf("%d ", pages.get(i));
            } else {
                System.out.printf("%d\n", pages.get(i));
            }
        }
    }
}

class Main {


    public static void main (String [] args) {

        Scanner sc = new Scanner(System.in);
        ArrayList<Index> indices = new ArrayList<Index>();

        while (sc.hasNext()) {
            String [] line = sc.nextLine().split(" ");
            boolean found = false;
            for (Index ind : indices) {
                if (ind.word.equals(line[0])) {
                    found = true;
                    ind.addPage(Integer.parseInt(line[1]));
                    break;
                }
            }
            if (!found) {
                Index newInd = new Index(line[0]);
                newInd.addPage(Integer.parseInt(line[1]));
                indices.add(newInd);
            }
        }

        ArrayList<String> words = new ArrayList<String>();
        
        for (Index ind : indices) {
            words.add(ind.word);
        }

        Collections.sort(words);

        for (String w : words) {
            for (Index ind : indices) {
                if (w.equals(ind.word)) {
                    System.out.println(w);
                    ind.printPages();
                }
            }
        }

    }
}

Measured memory_bytes: 12000
#
import math

n=int(input())
N=n
if n==1:
    print(0)
    exit()
ans=0
z=[]
for i in range(2,int(math.sqrt(N))+1):
    if n%i==0:
        x=i#xは素数
        s=0
        while n>=1:
            if n%x==0:
                #print(n)
                n=n//x
                s+=1
                
            else:
                #print(n)
                z.append(s)
                break
    if n==1:
        break

#print(z)#各素数でわれる回数
if len(z)==0:
    print(1)
    exit()
for i in range(len(z)):
    j=1
    while z[i]>0:
        ans+=1
        z[i]-=j
        j+=1
        if z[i]<j:
            break
if n>math.sqrt(N):
    ans+=1

print(ans)

Measured memory_bytes: 9240
#include <bits/stdc++.h>
#include <stdio.h>
#include <numeric>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define repone(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define Rep(j,n) for(int j=0;j<(int)(n);++j)
#define Repo(j,o,n) for(int j=o;j<(int)(n);++j)
#define Repone(j,n) for(int j=1;j<(int)(n);++j)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define int long long
#define pb(a) push_back(a)
#define eraser(v,i) (v).erase(v.begin()+(i))
#define pbpair(a,b) push_back(make_pair(a,b))
#define MOD 1000000007
#define INF 9223372036854775807
#define pairint pair<int,int>
int num[12] = {31,28,31,30,31,30,31,31,30,31,30,31};
bool uru(int checkyear){if(checkyear%4==0){if(checkyear%100!=0||checkyear%400==0)return true;}return false;}
int gcd( int x, int y ){return y ? gcd(y, x%y) : x;}
bool pairCompare(const pairint& firstElof, const pairint& secondElof)
{
  if(firstElof.second!= secondElof.second)    return firstElof.second> secondElof.second;
  else return firstElof.first< secondElof.first;
}
signed main() {
int x=0,y=0,z=0,w=0,n=0,m=0;
string a;
std::cin >> a;
a[3]='8';
std::cout << a << '\n';
}


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

int main(){
    string S;
    cin >> S;
    int N = S.size();
    int l = 0;
    int ans[N] = {};
    while (l < N){
        int r = l + 1;
        if (S[l] == 'R'){
            while (r < N && S[r] == 'R') r += 1;
                ans[r-1] = r-l;
        }else{
            while (r < N && S[r] == 'L') r += 1;
            ans[l] = r-l;
        }
        l = r;
    }
    int i=0;
    while (i<N-1){
        if (ans[i] > 0 && ans[i+1] > 0){
            int R = ans[i]-1, L = ans[i+1]-1;
            int a, b, c, d;
            a = (R+1)/2;
            b = R/2;
            c = (L+1)/2;
            d = L/2;
            ans[i] = 1 + b + c;
            ans[i+1] = 1 + a + d;
            i += 2;
            continue;
        }
        i += 1;
    }
    for(int i=0;i<N;i++) cout << ans[i] << " ";
    cout << endl;

}

Measured memory_bytes: 1152
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <deque>
#include <stack>
#include <queue>
#include <bitset>
#include <cstdio>
#include <string>
#include <vector>
#include <random>
#include <chrono>
#include <utility>
#include <numeric>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <sstream>
#include <assert.h>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <unordered_map>
using namespace std;

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(bool x) {cerr << (x ? "true" : "false");}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}

template<typename T, typename V> void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i : x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";} void _print() {cerr << "]\n";}
template <typename T, typename... V>void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifdef HOME
#warning CHECK int:ll::INT_MAX:LLONG_MAX
#define maxn 20
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define maxn 2000006
#define gcd __gcd
#define debug(x...)
#endif

#define ff first
#define endl '\n'
#define ss second
#define inf 0x3f3f3f3f
#define MOD 1000000007
#define PI 3.14159265358979323846264338327950L
#define f(i,x,n) for(int i=x;i<=n;i++)
#define fr(i,x,n) for(int i=x;i>=n;i--)
struct _ { ios_base::Init i; _() { ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL); } } _;

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

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

int main() {

	long long a, b, c, d; cin >> a >> b >> c >> d;
	cout << b - a + 1 - (b / c - (a - 1) / c + b / d - (a - 1) / d - (b / lcm(c , d)) + ((a - 1) / lcm(c , d)));

	return 0;
}

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

int main() {
  int w, h;
  cin >> h >> w;
  vector<string> s(h);
  const int vx[] = {0, 1, 0, -1}, vy[] = {1, 0, -1, 0};
  int ans=-1;
  rep(i,h) cin >> s[i];
  rep(i,h){
    rep(j,w){
      if(s[i][j]=='#') continue;
      else{
        queue< pair< int, int > > que;
        vector< vector< int > > min_cost(h, vector< int >(w, -1));
        min_cost[i][j]=0;
        que.emplace(i, j);
         while(!que.empty()) {
           auto p = que.front();
           que.pop();
           for(int i = 0; i < 4; i++) {
             int ny = p.first + vy[i], nx = p.second + vx[i];
             if(nx < 0 || ny < 0 || nx >= w || ny >= h) continue;
             if(min_cost[ny][nx] != -1) continue;
             if(s[ny][nx] == '#') continue;
             min_cost[ny][nx] = min_cost[p.first][p.second] + 1;
             que.emplace(ny, nx);
             ans =max(min_cost[ny][nx], ans);
           }
         }
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <vector>
using namespace std;

const int SIZE = 100005;
int depth[SIZE];
int A[SIZE], B[SIZE];
bool visited[SIZE];
vector<int> adj[SIZE];
int d0=1, d1=0;
int cnt = 0;
void dfs(int here){
	visited[here] = true;
	for(int i=0; i<adj[here].size(); i++){
		int next = adj[here][i];
		if(visited[next])
			continue;
		depth[next] = depth[here] + 1;
		if(depth[next] % 2 == 0)
			d0++;
		else
			d1++;
		dfs(next);
	}
}

int main(){
	int N, M;
	scanf("%d %d", &N, &M);
	for(int i=0; i<M; i++){
		scanf("%d %d", &A[i], &B[i]);
		adj[A[i]].push_back(B[i]);
		adj[B[i]].push_back(A[i]);
	}
	dfs(1);
	int i;
	for(i=0; i<M; i++){
		if(depth[A[i]] % 2 == depth[B[i]] % 2){
			printf("%lld\n", 1LL * N * (N - 1) / 2 - M);
			return 0;
		}
	}
	printf("%lld\n", 1LL * d1 * d0 - M);
}

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

int main(){
    string s,t;
    cin >> s >> t;
    int len = s.length();
    int i;
    for(i=1;i<=len;i++){
        string s1 = s.substr(0,len-i);
        string s2 = s.substr(len-i,len);
        reverse(s1.begin(),s1.end());
        reverse(s2.begin(),s2.end());
        string temp = s1+s2;
        reverse(temp.begin(),temp.end());
        if(temp == t) {
            cout<<"Yes"<<endl;
            break;
        }
    }
    if(i > len) cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
class Program
{
    static void Main(string[] args)
    {
            // 入力
            string[] sS = Console.ReadLine().Trim().Split(' ');
            int iA = int.Parse(sS[0]);
            int iB = int.Parse(sS[1]);
            int iC = int.Parse(sS[2]);
            int iD = int.Parse(sS[3]);

            System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
            sw.Start();

            // 解析
            string sOut = "No";
            if (Math.Abs(iA - iC) <= iD) { sOut = "Yes"; }
            else
            {
                int iOk = 0;
                if (Math.Abs(iA - iB) <= iD) { iOk += 1; }
                if (Math.Abs(iB - iC) <= iD) { iOk += 1; }
                if (iOk >= 2) { sOut = "Yes"; }
            }

            // 出力
            Console.WriteLine("{0}", sOut.ToString().Trim());

            sw.Stop();
#if DEBUG
            Console.WriteLine();
            Console.WriteLine("{0}", sw.Elapsed.ToString());
            Console.WriteLine("続行するには何かキーを押してください．．．");
            Console.ReadKey();
#endif
    }

}


Measured memory_bytes: 11348
#include <bits/stdc++.h>
using namespace std;
#define int ll
#define inf 0x3f3f3f3f
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define ll long long
#define vi vector <int>
#define pii pair <int, int>
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#define rep(i,n) for (int i = 0; i < (int) (n); ++ i)
#define foreach(it,c) for (__typeof(c.begin()) it = c.begin(); it != c.end(); ++ it)

inline int read() {
	int x = 0, f = 1, c = getchar();
	for (;!isdigit(c);c = getchar()) if (c == '-') f ^= 1;
	for (; isdigit(c);c = getchar()) x = x * 10 + c - '0';
	return f ? x : -x;
}

string s, t;
string to2(int x) {string str; rep(i, 60) str = char('0' + (x >> i & 1)) + str; return str;}

int dp[60][2][2][2];

int DP(int id, int sml, int lgr, int fst) {
	if (id == 60) return 1;
	int & rem = dp[id][sml][lgr][fst];
	if (~rem) return rem;
	int res = 0;
	for (int a = lgr ? 0 : s[id] - '0'; a <= (sml ? 1 : t[id] - '0'); ++ a) {
		for (int b = lgr ? 0 : s[id] - '0'; b <= (sml ? 1 : t[id] - '0'); ++ b) {
			if (!fst && b && !a) continue;
			if (a > b) continue;
			res += DP(id + 1, sml | b < t[id] - '0', lgr | a > s[id] - '0', fst | b);
			if (res >= mod) res -= mod;
		}
	}
//	printf("%d %d %d %d = %d\n", id, sml, lgr, fst, res);
	return rem = res;
}

signed main() {
	int l, r;
	scanf("%lld %lld", &l, &r);
	s = to2(l), t = to2(r);
	memset(dp, -1, sizeof dp);
	printf("%lld\n", DP(0, 0, 0, 0));
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include <algorithm>
#include<float.h>
#include <limits>
#include <vector> 
#include <numeric>
#include <string.h>

#define rep(i,a,n) for(ll int (i) = (a);(i) < (n);(i)++)
#define urep(i,a,n) for(ll int (i) = (a);(i) > (n);(i)--)
#define MOD 1000000007
#define ll long long

using namespace::std;

int jo(ll int jxo, ll int jyo){
	ll int jhogeo = 1;
	rep(jinto,0,jyo) jhogeo=jhogeo*jxo;
	return jhogeo;
}
char tobig(char toxbig){
  return (toxbig-0x20);
}
char tolow(char toxlow){
  return (toxlow+0x20);
}
  


int main(){
  char a;
  cin>>a;
  if(a=='A') cout<<"T";
  else if(a=='T') cout<<"A";
  else if(a=='C') cout<<"G";
  else if(a=='G') cout<<"C";

}
// int *p = new int[N];

//  vector<int> 変数名(要素数);
//  sort(変数名.begin(),変数名.end());//昇順ソート

// vector<vector<int>> 変数名(左の個数, vector<int>(右の個数));

//


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
multiset<string> s;
int a, b, c;
int main() {
	scanf("%d%d%d", &a, &b, &c);
	for (int i = 0; i < a; i++) {
		s.insert("a");
	}
	for (int i = 0; i < b; i++) {
		s.insert("b");
	}
	for (int i = 0; i < c; i++) {
		s.insert("c");
	}
	while (s.size() > 1) {
		string t = *s.begin() + *--s.end();
		s.erase(s.begin());
		s.erase(--s.end());
		s.insert(t);
	}
	cout << *s.begin() << endl;
}

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

for i in range(N-1):
    a = [A[i], A[i+1]]
    a.sort(reverse=True)
    while True:
        tmp = a[0] % a[1]
        if tmp == 0:
            A[i+1] = a[1]
            break
        a[0], a[1] = a[1], tmp

print(a[1])


Measured memory_bytes: 14252
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
#pragma GCC target ("avx2")
#pragma GCC optimization ("unroll-loops")
#define rep(i, n) for(int i=0;i<(int)(n);++i)
template <typename T> ll gcd(T a, T b) {return b?gcd(b, a%b):a;}
template <typename T> ll lcm(T a, T b) {return a * b / gcd(a, b);};
template <typename T> inline void chmin(T &a, const T& b){if(a>b)a=b;}
template <typename T> inline void chmax(T &a, const T& b){if(a<b)a=b;}

inline bool isPrime(int x) {
  bool ans = true;
  if (x <= 1) ans = false;
  for (int i = 2; i * i <= x; ++i) {
    if (x % i == 0) {
      ans = false;
      break;
    }
  }
  return ans;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  for (int i = 31; i <= 55555; i += 30) {
    if (isPrime(i)) {
      cout << i;
      if (--n == 0) {
        break;
      }
      cout << " ";
    }
  }
  cout << '\n';
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cctype>
#include<cmath>
#include<string>
#include<set>
#include<map>
#include<queue>
#include<vector>
using namespace std;

int main() {
	int a,b,A,B;
	while(cin>>A>>B){
		a=A,b=B;

		if(a<b)swap(a,b);
		for(int r;(r=a-b)!=0;){
			a=b,b=r;
			if(a<b)swap(a,b);
		}

		int L=b,G=A*(B/L);
		cout<<L<<" "<<G<<endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include "bits/stdc++.h"
using namespace std;

long long N, U, V, ANS = 0;
vector<vector<long long> > G;
vector<long long> DistU, DistV;

void DFS(long long P, long long Q, vector<long long>& V) {
	for (long long NP : G[P]) {
		if (NP != Q) {
			V[NP] = V[P] + 1;
			DFS(NP, P, V);
		}
	}
}

int main() {
	cin >> N >> U >> V;
	U--, V--;
	G.resize(N);
	DistU.resize(N), DistV.resize(N);
	for (int i = 0; i < N - 1; i++) {
		long long A, B;
		cin >> A >> B;
		A--, B--;
		G[A].push_back(B);
		G[B].push_back(A);
	}
	DistU[U] = 0, DistV[V] = 0;
	DFS(U, -1, DistU), DFS(V, -1, DistV);
	for (int i = 0; i < N; i++) {
		if (DistU[i] < DistV[i]) {
			ANS = max(ANS, DistV[i] - 1);
		}
	}
	cout << ANS << endl;
}

Measured memory_bytes: 12544
#include <stdio.h>

int main(void)
{
	int i,j,k;
	int n,m,l;
	int a[100][100];
	int b[100][100];
	long int c[100][100];

	scanf("%d %d %d", &n,&m,&l);

	for(i = 0; i < n; i++){
		for(j = 0; j < m; j++){
			scanf("%d", &a[i][j]);
		}
	}
	for(i = 0; i < m; i++){
		for(j = 0; j < l; j++){
			scanf("%d", &b[i][j]);
		}
	}

	for(i = 0; i < n; i++){
		for(j = 0; j < l; j++){
			for(k = 0; k < m; k++){
				c[i][j] += a[i][k] * b[k][j];
			}
		}
	}

	for(i = 0; i < n; i++){
		for(j = 0; j < l; j++){
			printf("%ld",c[i][j]);
			if(j != l-1){
				printf(" ");
			}
		}
		printf("\n");
	}


	return 0;
}

Measured memory_bytes: 756
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#include<stdbool.h>
typedef long long ll;
typedef long double ld;
#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 rrep(i,l,r)for(ll i=(l);i>=(r);i--)
#define rrepp(i,l,r,k)for(ll i=(l);i>=(r);i-=(k))
#define INF (1LL<<60)
#define MOD1 1000000007
#define MAX_N (1 << 17)
#define YES printf("Yes\n")
#define NO printf("No\n")


void swap(ll *a, ll *b){ll c;c=*b;*b=*a;*a=c;}
ll max2(ll a,ll b){return a>=b?a:b;}
ll min2(ll a,ll b){return a>=b?b:a;}
ll minn(ll n, ll a[n]){ll b=INF;rep(i,0,n) b=min2(b,a[i]);return b;}
ll maxn(ll n, ll a[n]){ll b=-INF;rep(i,0,n) b=max2(b,a[i]);return b;}
ll ABS(ll a){return a>=0?a:(-a);}
ll POW(ll a, ll b){ll c=1;rep(i,0,b) c*=a;return c;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
ll mod(ll n){return n%=MOD1;}
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);}

typedef struct{
    ll aa;
    ll bb;
}frequent;

ll divi[1000005]={};
void makedivi(ll n){
    ll c=0;
    while(n%2==0){
        n/=2;
        c++;
    }
    divi[2]=c;
    // printf("%lld ",n);
    repp(i,3,1000001,2){
        // printf("%lld ",n);
        if(n<i) break;
        c=0;
        while(n%i==0){
            n/=i;
            c++;
        }
        // printf("%lld ",c);
        divi[i]=c;
    }
}

int main(void){
    // char ;
    ll n,p,ans=1;
    scanf("%lld%lld",&n,&p);
    if(n==1){
        printf("%lld\n",p);
        return 0;
    }
    makedivi(p);
    rrepp(i,1000001,3,2){
        // printf("%lld ",divi[i]);
        if(divi[i]>=n){
            ans*=POW(i,divi[i]/n);
        }
    }
    if(divi[2]>=n){
        ans*=POW(2,divi[2]/n);
    }
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 7936
import sys
import math
def i():return int(sys.stdin.readline().replace("\n",""))
def i2():return map(int,sys.stdin.readline().replace("\n","").split())
def s():return str(sys.stdin.readline().replace("\n",""))
def l():return list(sys.stdin.readline().replace("\n",""))
def intl():return [int(k) for k in sys.stdin.readline().replace("\n","").split()]
def lx():return list(map(lambda x:int(x)*-1,sys.stdin.readline().replace("\n","").split()))
def t():return tuple(map(int,sys.stdin.readline().replace("\n","").split()))

if __name__ == "__main__":pass
m = s()
for i in range(3):
    if m[i] == "7":
        print("Yes")
        exit()
print("No")

Measured memory_bytes: 62052
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        while(true){
        int n = sc.nextInt();
        int r = sc.nextInt();
        if(n==0 && r==0) break;
        int[] card = new int[n];
        int[] card2 = new int[n];
        for(int i=0;i<n;i++){
            card[i]=i+1;
        }
        for(int j=0;j<r;j++){
            int p = sc.nextInt();
            int c = sc.nextInt();

            for(int i=0;i<n-(p+c-1);i++){
                card2[i]=card[i];
            }
            for(int i=n-(p+c)+1;i<n-c;i++){
                card2[i]=card[c+i];
            }
            for(int i=n-c;i<n;i++){
                card2[i]=card[-p+1+i];
            }

            for(int i=0;i<n;i++){
                card[i]=card2[i];
            }
        }
        System.out.println(card2[n-1]);
        }
        sc.close();
    }
}


Measured memory_bytes: 37024