akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
//登録しよう！→ https://www.youtube.com/channel/UCRXsI3FL_kvaVL9zoolBfbQ
using namespace std;
using ll = long long;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}//a,bの最大公約数(gcd)を求める
ll lcm(ll a,ll b){return abs(a*b)/gcd(a,b);}//a,bの最小公倍数(lcm)を求める
vector<ll> enum_div(ll n){vector<ll> ret;for(int i=1 ; i*i<=n ; i++){if(n%i == 0){ret.push_back(i);if(i!=1 && i*i!=n)ret.push_back(n/i);}}ret.push_back(n);return ret;}
//↑nの約数を求める
vector<bool> IsPrime; void sieve(size_t max){if(max+1 > IsPrime.size())IsPrime.resize(max+1,true);IsPrime[0] = false;IsPrime[1] = false;for(size_t i=2; i*i<=max; ++i)if(IsPrime[i])for(size_t j=2; i*j<=max; ++j)IsPrime[i*j] = false;}
//↑エラトステネスの篩で素数を求める
#define roundup(divisor,dividend) (divisor + (dividend - 1)) / dividend //切り上げ割り算
#define all(x) (x).begin(),(x).end() //xの初めから終わりまでのポインタ
#define size_t ll //size_tは自動でllに変換される
#define pb(x) push_back(x)
#define gre greater //sortを降順にする
#define pri_queue priority_queue //優先度付きキュー
#define syo(x) fixed << setprecision(x) //iostreamで小数をx桁表示

void solve(long long X, long long Y, long long A, long long B, long long C, std::vector<long long> p, std::vector<long long> q, std::vector<long long> r){
  sort(all(p),gre<ll>());
  sort(all(q),gre<ll>());
  sort(all(r),gre<ll>());
  pri_queue<ll>n;
  for (int i = 0; i < X; i++) {
    n.push(p[i]);
  }
  for (int i = 0; i < Y; i++) {
    n.push(q[i]);
  }
  for (int i = 0; i < C; i++) {
    n.push(r[i]);
  }
  ll ans = 0;
  for (int i = 0; i < X+Y; i++) {
    ans += n.top();
    n.pop();
  }
  cout << ans << endl;
}

// 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 X;
    scanf("%lld",&X);
    long long Y;
    scanf("%lld",&Y);
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    long long C;
    scanf("%lld",&C);
    std::vector<long long> p(A);
    for(int i = 0 ; i < A ; i++){
        scanf("%lld",&p[i]);
    }
    std::vector<long long> q(B);
    for(int i = 0 ; i < B ; i++){
        scanf("%lld",&q[i]);
    }
    std::vector<long long> r(C);
    for(int i = 0 ; i < C ; i++){
        scanf("%lld",&r[i]);
    }
    solve(X, Y, A, B, C, std::move(p), std::move(q), std::move(r));
}


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



int main(){
    ll N,ans = 0,tmp_ans = 0;
    cin >> N;
    vector<ll> v(N, 0);
    for(int i = 0; i < N; i++) cin >> v[i];

    for(int i = 0; i < N - 1; i++){
        if(v[i] >= v[i + 1]){
            tmp_ans++;
            ans = max(ans ,tmp_ans);
        }else{
            tmp_ans = 0;
        }
    }

    cout << ans << endl;


}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef long double D;
typedef complex<D> P;
#define F first
#define S second
const ll MOD=1000000007;
//const ll MOD=998244353;

template<typename T,typename U>istream & operator >> (istream &i,pair<T,U> &A){i>>A.F>>A.S; return i;}
template<typename T>istream & operator >> (istream &i,vector<T> &A){for(auto &I:A){i>>I;} return i;}
template<typename T,typename U>ostream & operator << (ostream &o,const pair<T,U> &A){o<<A.F<<" "<<A.S; return o;}
template<typename T>ostream & operator << (ostream &o,const vector<T> &A){ll i=A.size(); for(auto &I:A){o<<I<<(--i?" ":"");} return o;}



int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll H,W;
  cin>>H>>W;
  vector<vector<int>> red(H,vector<int>(W,0));
  vector<vector<int>> blue(H,vector<int>(W,0));
  for(int i=0;i<H;i+=2){
    for(auto &I:red[i]){I=1;}
  }
  for(int i=1;i<H;i+=2){
    for(auto &I:blue[i]){I=1;}
  }
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      char c;
      cin>>c;
      if(c=='#'){red[i][j]=1; blue[i][j]=1;}
    }
  }
  for(auto &I:red){I[0]=1;}
  for(auto &I:blue){I.back()=1;}
  for(auto &I:blue){I[0]=0;}
  for(auto &I:red){I.back()=0;}
  for(auto &I:red){
    for(auto &J:I){
      cout<<(J?"#":".");
    }
    cout<<endl;
  }
  cout<<endl;
  for(auto &I:blue){
    for(auto &J:I){
      cout<<(J?"#":".");
    }
    cout<<endl;
  }
  


  return 0;
}


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

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

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

#define DEBUG(x) cout << #x << ": " << (x) << endl
#define DEBUG_VEC(v)                               \
  cerr << #v << ": ";                              \
  REP(__i, (v).size()) cerr << ((v)[__i]) << ", "; \
  cerr << endl
#define PRINT(x) cout << x << endl
#define all(x) x.begin(), x.end()
#define MM << " " <<
int main() {
    string s;
    cin >> s;

    if (s[s.size()-1]=='s'){
        cout << s+"es" << endl;
    }else{
        cout << s+'s' << endl;
    }



}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
#define rep(i,n) for(int i=0; i<n; i++)
#define pb(a) push_back(a)
#define mp make_pair

ll lcm(ll a, ll b);
ll gcd(ll a, ll b);
int main()
{
  ll a,b;

  cin >> a >> b;

  cout << lcm(a,b) << endl;

  return 0;

}

ll gcd(ll a, ll b)
{
  
  if (a < b) {
    a ^= b;
    b ^= a;
    a ^= b;
  }
  
  return b ? gcd(b, a % b) : a;
  
}

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


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

using namespace std;

int main()
{
	string S;

	while (cin >> S)
	{
		int JOI = 0, IOI = 0;

		for (int i = 0; i < S.size() - 2; i++)
		{
			string T = S.substr(i, 3);

			if (T == "JOI") { JOI++; }
			if (T == "IOI") { IOI++; }
		}

		cout << JOI << endl;
		cout << IOI << endl;
	}

	return 0;
}

Measured memory_bytes: 1212
#include <iostream>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <cstring>

#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))

#define INF (int)1e9+7

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

using namespace std;

typedef long long ll;

int main(){
    int a,b,c;
    int x,y;

    cin >> a >> b >> c >> x >> y;

    int p = max(x, y);

    ll plan[4];
    plan[0] = a*x + b*y;
    plan[1] = a*abs(x-y) + 2*c*y;
    plan[2] = b*abs(x-y) + 2*c*x;
    plan[3] = 2*c*p;
    
    ll mini = INF;
    rep(i, 4){
        mini = min(mini, plan[i]);
    }
    cout << mini << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main(){
  string a,b;
  cin>>a>>b;
  for(int i=0;i<b.size();i++){
    cout<<a[i]<<b[i];
  }
  if(a.size()>b.size()) cout<<a[a.size()-1];
}

Measured memory_bytes: 256
def bellman_ford(graph, source):
    d = [INF] * n
    d[g] = ''

    for i in range(n * 6 + 1):
        update = False
        for e in graph:
            if d[e[1]] != INF and d[e[0]] > e[2] + d[e[1]]:
                d[e[0]] = e[2] + d[e[1]]
                update = True
        if len(d[s]) > n * 6:
            return None
        if not update:
            return d[s]
    else:
        return d[s]


INF = '{'
while True:
    n, a, s, g = (int(s) for s in input().split())
    if (n, a, s, g) == (0, 0, 0, 0):
        break

    flag = []
    edge = []
    es = []
    for i in range(a):
        xs, ys, labi = input().split()
        es.append((int(xs), int(ys), labi))

    spell = bellman_ford(es, g)
    if spell == INF or spell is None:
        print('NO')
    else:
        print(spell)

Measured memory_bytes: 8848
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=103,INF=1<<30;

int par[MAX],size[MAX];
bool ok[MAX];

void init(int n){
    for(int i=0;i<n;i++){
        par[i]=i;
        size[i]=1;
        ok[i]=0;
    }
}

int root(int a){
    if(par[a]==a) return a;
    else return par[a]=root(par[a]);
}

void unite(int a,int b){
    if(root(a)!=root(b)){
        ok[root(a)]|=ok[root(b)];
        size[root(a)]+=size[root(b)];
        par[root(b)]=root(a);
    }
}

bool check(int a,int b){
    return root(a)==root(b);
}

vector<int> dh={-1,-1,0,0,1,1},dw={-1,0,-1,1,0,1};

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    while(1){
        int N,M;cin>>N>>M;
        if(N+M==0) break;
        int ans=-INF;
        
        vector<vector<int>> A(N,vector<int>(N));
        
        for(int i=0;i<N;i++){
            for(int j=0;j<=i;j++){
                cin>>A[i][j];
            }
        }
        
        for(int i=0;i<N;i++){
            for(int j=0;j<=i;j++){
                if(A[i][j]) continue;
                
                A[i][j]=M;
                init(N*N);
                
                for(int h=0;h<N;h++){
                    for(int w=0;w<=h;w++){
                        if(A[h][w]==0) continue;
                        
                        for(int k=0;k<6;k++){
                            int toh=h+dh[k],tow=w+dw[k];
                            
                            if(toh<0||toh>=N||tow<0||tow>toh) continue;
                            
                            if(A[h][w]==A[toh][tow]) unite(h*N+w,toh*N+tow);
                            
                            if(A[toh][tow]==0) ok[root(h*N+w)]=1;
                        }
                    }
                }
                
                int score=0;
                
                for(int h=0;h<N;h++){
                    for(int w=0;w<=h;w++){
                        if(A[h][w]==0) continue;
                        
                        if(root(h*N+w)!=h*N+w) continue;
                        
                        if(!ok[h*N+w]){
                            if(A[h][w]==M) score-=size[h*N+w];
                            else score+=size[h*N+w];
                        }
                        
                        //cout<<h<<" "<<w<<endl;
                    }
                }
                
                ans=max(ans,score);
                
                A[i][j]=0;
            }
        }
        
        cout<<ans<<endl;
    }
}



Measured memory_bytes: 3060
import math

N = int(input())
A = list(map(int,input().split()))

def comb(n):
  r = 2
  if n <= 1:
    return 0
  if n - r < r: r = n - r
  if r == 0: return 1
  if r == 1: return n
  
  numerator = [n - r + k + 1 for k in range(r)]
  denominator = [k + 1 for k in range(r)]
  
  for p in range(2,r+1):
    pivot = denominator[p - 1]
    if pivot > 1:
      offset = (n - r) % p
      for k in range(p-1,r,p):
        numerator[k - offset] /= pivot
        denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result
dic = {}
#まず最初に、グルーピング(グルーピングの時点で辞書化が必要)
for a in A:
  if a in dic:
    dic[a][0] += 1
  else:
    dic[a] = [1]

#辞書にコンビネーションをvalueとして書き込んでいく
for v in dic.values():
  v.append(comb(v[0]))
  v.append(comb(v[0]-1))

#各グループのlen(g)C2を総計して変数grandとして保持しておく
grand = 0
for v in dic.values():
  grand += v[1]
  
for a in A:
  output = grand - dic[a][1] + dic[a][2]
  print(output)

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


_S = []
for s in S:
    _S.append(ord(s)-97)

_T = []
for t in T:
    _T.append(ord(t)-97)


s_len = len(_S)
t_len = len(_T)
flag = False
buff = 0
for i in range(s_len-t_len+1):
    count = 0
    for j in range(t_len):
        if _S[i+j] == _T[j] or _S[i+j] == -34:
            count += 1
        else:
            continue
    if count >= t_len:
        buff = i
        flag = True
        # break


_buff = []

if not flag:
    print("UNRESTORABLE")
    exit()
else:
    # print("seikou")
    for i in range(t_len):
        _S[buff+i] = _T[i]

for i in range(s_len):
    if _S[i] == -34:
        _S[i] = 0

ans = []

for i in range(s_len):
    ans.append(chr(97+_S[i]))

print(''.join(ans))

Measured memory_bytes: 38256
gets;P=*0..1e5;Q=[0]*2e5;F=->x{x==(p=P[x])?x:(s=F[p];Q[x]+=Q[p];P[x]=s)};puts$<.any?{|s|l,r,d=s.split.map &:to_i;x=F[l];y=F[r];x==y ?Q[l]+d!=Q[r]:!(P[y]=x;Q[y]=Q[l]+d-Q[r])}?:No: :Yes

Measured memory_bytes: 7036
#include <bits/stdc++.h>
#define REP(i, m, n) for(int (i) = (m); (i) < (n); ++i)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
using namespace std;
using Graph = vector<vector<int>>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
typedef long long ll;
typedef pair<ll, ll> P;
const int INF = 1e9+7;
const ll LINF = 1LL<<60;

int main()
{
    int x;
    cin >> x;
    
    int a = x / 500;
    int b = x % 500;
    int c = b / 5;

    cout << a * 1000 + c * 5 << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<double,int> pdi;

int main()
{
    int a, b;
    scanf("%d%d", &a, &b);
    int x = a+b, y = a-b, z = a*b;
    int ans = max(x,max(y,z));
    printf("%d\n", ans);
}









Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;
int main()
{
    string s;
    cin >> s;
    for(int i = 0;i < s.size();i++)
    {
        if(i != 3)
        {
            cout << s[i];
        }
        else
        {
            cout << "8";
        }
    }
    cout << "\n";
    
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N,W;scanf("%d%d",&N,&W);
    vector<int> v(N),w(N);
    for(int i=0;i<N;i++)scanf("%d%d",&v[i],&w[i]);
    vector<int> dp(W+1);
    for(int i=0;i<N;i++){
        vector<int> ndp(W+1);
        for(int j=0;j<W+1;j++){
            if(j<w[i])ndp[j]=dp[j];
            else ndp[j]=max(dp[j],dp[j-w[i]]+v[i]);
        }
        dp=ndp;
    }
    printf("%d\n",dp[W]);
    return 0;
}


Measured memory_bytes: 3348
#include<stdio.h>

int main(void){

int a, b, c, i, s ;

s=0;

scanf("%d %d %d", &a, &b, &c);

for(i= a ; i<= b ; i ++)

{

if(c%i == 0){

s=s+1;

}

}

printf("%d\n" ,s);

return 0;

} 

Measured memory_bytes: 596
#!/usr/bin/env python3

n=int(input())

x,y=map(int, input().split())
for i in range(n-1):
    t,a=map(int, input().split())
    if (x<=t and y<=a):
        x=t
        y=a
    else:
        tmp=0
        k=max(x//t,y//a)
        tk=t*k
        ak=a*k
        while 1:
#            print(tk+(tmp*t),ak+(tmp*a))
            if x<=tk+(tmp*t) and y<=ak+(tmp*a):
                x=tk+(tmp*t)
                y=ak+(tmp*a)
                break
            tmp+=1
print(x+y)


Measured memory_bytes: 3064
#include<stdio.h>
#include<queue>
#include<algorithm>
using namespace std;
char str[100][100];
int m[100][100];
int r[100];
int v[100][100];
int ABS(int a){return max(-a,a);}
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
int main(){
	int a,b,c,d;
	scanf("%d%d%d%d",&a,&b,&c,&d);
	for(int i=0;i<a;i++)scanf("%s",str[i]);
	for(int i=0;i<a;i++)
		for(int j=0;j<b;j++){
			if(str[i][j]!='#')m[i][j]=1;
		}
	for(int i=0;i<c;i++)scanf("%d",r+i+1);
	r[0]=-1;
	r[c+1]=10000;
	for(int i=0;i<d;i++){
		int x,y,z;
		scanf("%d%d%d",&y,&x,&z);
		for(int j=0;j<a;j++){
			for(int k=0;k<b;k++){
				int dist=max(ABS(x-j),ABS(y-k));
				if(dist<=r[z]||dist>r[z+1])m[j][k]=0;
			}
		}
	/*	for(int j=0;j<a;j++){
			for(int k=0;k<b;k++)printf("%d",m[j][k]);
			printf("\n");
		}
		printf("\n");*/
	}
	bool ok=false;
	for(int i=0;i<a;i++)
		for(int j=0;j<b;j++)if(m[i][j])ok=true;
	if(!ok){
		printf("Broken\n");
		return 0;
	}
	queue<pair<int,int> >Q;
	for(int i=0;i<a;i++){
		for(int j=0;j<b;j++){
			if(str[i][j]=='D'){
				v[i][j]=1;
				Q.push(make_pair(i,j));
			}
		}
	}
	while(Q.size()){
		int row=Q.front().first;
		int col=Q.front().second;
		Q.pop();
		for(int i=0;i<4;i++){
			if(0<=row+dx[i]&&row+dx[i]<a&&0<=col+dy[i]&&col+dy[i]<b&&!v[row+dx[i]][col+dy[i]]&&str[row+dx[i]][col+dy[i]]!='#'){
				v[row+dx[i]][col+dy[i]]=1;
				Q.push(make_pair(row+dx[i],col+dy[i]));
			}
		}
	}
	bool L=true;
	bool R=true;
	for(int i=0;i<a;i++)
		for(int j=0;j<b;j++)
			if(m[i][j]){
				if(v[i][j])L=false;
				else R=false;
			}
	if(L){
		printf("No\n");
	}else if(R){
		printf("Yes\n");
	}else printf("Unknown\n");
}

Measured memory_bytes: 1072
# -*- coding: utf-8 -*-
def  inpl(): return list(map(int, input().split()))
N, K = inpl()
A = inpl()

DP = [0]*41

for i in range(N):
    for j in range(41):
        DP[j] += (A[i] >> j)&1

NEED = [DP[i] < N//2 for i in range(41)]

default = [(N - DP[i]) * (2**i) if (K>>i)&1 == 1 else DP[i] * (2**i) for i in range(41)]
free = [max(DP[i] * (2**i), (N-DP[i])*(2**i)) for i in range(41)]

ans = sum([K^A[i] for i in range(N)])
for i in range(41):
    if (K >> i)&1 == 1:
        ans = max(ans,
                  sum(free[:i]) + DP[i]*(2**i) + sum(default[i+1:]))
print(ans)

Measured memory_bytes: 74128
from collections import Counter
N = int(input())
S = input()
ans = S.count('R') * S.count('G') * S.count('B')

for i in range(N):
    for j in range(1,N):
        if (i-j<0 or i+j>=N):
            break
        l = S[i-j]
        m = S[i]
        r = S[i+j]
        if l!=m and m!=r and r!=l:
            ans -= 1
print (ans)


Measured memory_bytes: 9468
def main() -> None:
    l = list(map(int, input().split()))
    ls = sorted(l, reverse=True)
    ans = 0
    for i in range(len(ls) - 1):
        ans = ans + abs(ls[i] - ls[i+1])

    print(ans)


if __name__ == '__main__':
    main()


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

#define MAX(a,b) (a > b) ? a : b
#define MIN(a,b) (a < b) ? a : b
const int inf = 1000000000; // 10^9

int main(){
   char s[20];scanf("%s",s);
   for(int i = 0;i < 19;i++){
      if(s[i] == ',')
         printf(" ");
      else
         printf("%c",s[i]);

   }
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
struct ios_accelerate { ios_accelerate() { ios::sync_with_stdio(false); cin.tie(nullptr); } } CALL;

#define REP(i, n) for(auto (i) = (n)*0; (i) < (n); (i)++)
#define RNG(i, a, b) for(auto (i) = (a); (i) < (b); (i)++)
#define RBF(i, v) for(auto& (i) : (v))
#define ALL(x) (x).begin(), (x).end()

using LL = long long;
using UL = unsigned long;
using ULL = unsigned long long;
template<typename T> using V = vector<T>;
template<typename T> using VV = vector<vector<T>>;
template<typename T> using P = pair<T, T>;

const double PI = 3.141592653589793;
const int MOD = 1000000007;
const LL INF64 = static_cast<LL>(1e18) + 2;
const int INF = static_cast<int>(1e9) + 2;

template<typename T> inline void upsort(vector<T>& x) { sort(x.begin(), x.end()); }
template<typename T> inline void downsort(vector<T>& x) { sort(x.begin(), x.end(), greater<T>()); }
template<typename T> inline void col(T x) { cout << x << '\n'; }
template<> inline void col(double x) { cout << fixed << setprecision(12) << x << '\n'; }

signed main() {
	int n;
	cin >> n;
	V<int> a(n);
	RBF(ai, a) cin >> ai;

	RBF(ai, a) {
		if (ai % 2 == 0) {
			if (ai % 3 != 0 && ai % 5 != 0) {
				col("DENIED");
				return 0;
			}
		}
	}

	col("APPROVED");
	return 0;
}


Measured memory_bytes: 3600
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <utility>
#include <cstdio>
typedef long long ll;
#define MAX 300000
using namespace std;

class UnionFind{
  int v[MAX];
  int deep[MAX];
  public:
  UnionFind(){
    for(int i=1;i<MAX;i++){
      v[i]=i;
      deep[i] = 0;
    }
  }

  int root(int x){
    if(v[x]==x)return x;
    else return v[x] = root(v[x]);
  }

  bool same(int x, int y){
    return (root(x) == root(y));
  }

  void unite(int x,int y){
    x = root(x);
    y = root(y);
    if(deep[x] > deep[y]){
      v[y] = x;
    }else{
      if(deep[x] == deep[y])deep[y]++;
      v[x] = y;
    }
    return;
  }
};

int main(){
  int i,j;
  int n,k,l;
  cin >> n >> k >> l;
  UnionFind uf1,uf2;
  for(i=0;i<k;i++){
    int p,q;
    cin >> p >> q;
    uf1.unite(p,q);
  }
  for(i=0;i<l;i++){
    int p,q;
    cin >> p >> q;
    uf2.unite(p,q);
  }

  map<pair<int,int>,int > mp;
  for(i=1;i<=n;i++){
    mp[make_pair(uf1.root(i),uf2.root(i))]++;
  }
  for(i=1;i<=n;i++){
    cout << mp[make_pair(uf1.root(i),uf2.root(i))];
    /*if(i==n)cout << endl;
    else cout << " ";*/
    printf("%c"," \n"[i==n]);
  }
  return 0;
}


Measured memory_bytes: 16768
def rui_sum(n,k):
    k_lsum = (k-1)*k//2
    k_usum = k*n - (k-1)*k//2    
    return k_usum - k_lsum + 1

n, k = map(int,input().split())

cnt = []

for i in range(k,n+2):
    cnt.append(rui_sum(n,i))
    
print(sum(cnt)%(10**9+7))

Measured memory_bytes: 20000
#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <vector>
#include <cstdio>
#include <bits/stdc++.h>
#include <set>
using namespace std;
using ll =long long;

int main (void) {
  set <char> s;
  char t;
  int N;
  cin >>N;
  for (int i=0; i<N; i++) {
    cin >> t;
    s.insert(t);
  }
  if(s.size()==3){
    cout << "Three";
    return 0;
  }
  else {
    cout << "Four";
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdlib>
using namespace std;
int main()
{	string s;

while (cin >> s){
	int p[10][10] = { 0 };

	char  in[2];
	for (int i = 0; i < s.size(); i++){
		in[0] = s[i];
		in[1] = '\0';
		p[0][i] = atoi(in);
	}
	for (int i = 0; i < 9; i++){
		for (int i2 = i; i2 < 9; i2++){
			int a = p[i][i2] + p[i][i2 + 1];
			if (a >= 10){
				p[i + 1][i2 + 1] = a % 10;
			}
			else{
				p[i + 1][i2 + 1] = a;
			}
		}
	}
	cout << p[9][9] << endl;
}
}

Measured memory_bytes: 1188
import Control.Applicative ((<$>), (<*>))
import Control.Monad
import Data.List
import Data.Char (ord, chr, isDigit, isUpper, isLower, digitToInt, intToDigit)

main :: IO ()
main = do
  solve <$> getLine <*> getl toInt >>= putStrLn

solve :: String -> Int -> String
solve ss k = f k ss
  where
    f n [x] = [rot (n `mod` 26) x]
    f n (x:xs)
      | dista x <= n = 'a' : f (n - dista x) xs
      | otherwise = x : f n xs

dista :: Char -> Int
dista c = (ord 'z' - ord c + 1) `mod` 26

rot :: Int -> Char -> Char
rot n c
  | ord c + n > ord 'z' = let m = ord c + n - ord 'z' - 1 in chr (ord 'a' + m)
  | otherwise = chr (ord c + n)

toInt :: String -> Int
toInt = read

getl :: (String -> a) -> IO a
getl f = f <$> getLine


Measured memory_bytes: 5116
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,-1,sizeof(x))
const int INF = 1000000001;

int main(){
  int a[3];
  rep(i, 3) cin >> a[i];
  sort(a, a+3);
  cout << a[0]*a[1]/2 <<endl;
}

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

int main()
{
	int A,B,answer;
	
	START:
	cin >> A >> B;
	if((A < 1 || 100 < A) || (B < 1 || 100 < B)){
		goto START;
	}
	
	answer = A-2*B;
	
	if(answer < 0){
		cout << "0";
	}else{
		cout << answer;
	}
	
	return 0;
}

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

#ifdef DEBUG
#define PRINT(x)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#x<<" = "<<(x)<<endl;
#define PRINTA(a,first,last)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#a<<"["<<(first)<<", "<<(last)<<")"<<endl;\
    for (int i=(first);i<(last);++i){cout<<#a<<"["<<i<<"] = "<<(a)[i]<<endl;}
#else
#define PRINT(x)
#define PRINTA(a,first,last)
#endif

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define MOD 1000000007

using namespace std;

using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;

template <class T, class U> void amax(T& x, U y) {if (x < y) x = y;}
template <class T, class U> void amin(T& x, U y) {if (x > y) x = y;}

class graph
{
    private:
        const size_t number_of_nodes;
        const bool is_directed;
    public:
        vector<size_t> *edges;
        graph(size_t number_of_nodes, bool is_directed = true): number_of_nodes(number_of_nodes), is_directed(is_directed) {
            edges = new vector<size_t>[number_of_nodes];
        }
        ~graph() {
            delete [] edges;
        }
        size_t size() const {
            return number_of_nodes;
        }
        void make_edge(size_t u, size_t v) {
            edges[u].push_back(v);
            if (!is_directed) {
                edges[v].push_back(u);
            }
        }
};

graph rooted_tree(graph &g, size_t root) {
    graph result(g.size());
    bool *used = new bool[g.size()]();
    queue<size_t> q;
    q.push(root);
    while (!q.empty()) {
        size_t u = q.front();
        q.pop();
        used[u] = true;
        for (size_t v: g.edges[u]) {
            if (!used[v]) {
                result.make_edge(u, v);
                q.push(v);
            }
        }
    }
    delete [] used;
    return result;
}

int main(void)
{
    constexpr int N_MAX = 100000;
    int N;
    cin >> N;
    graph undirected_g(N, false);
    REP(i, N - 1) {
        int x, y;
        cin >> x >> y;
        x--;
        y--;
        undirected_g.make_edge(x, y);
    }
    int root = 0;
    graph g = rooted_tree(undirected_g, root);
    /*
    REP(u, N) {
        for (int v: g.edges[u]) {
            printf("edge (%d, %d)\n", u, v);
        }
    }
    */
    
    ll dp[N_MAX][2];
    REP(i, N) REP(j, 2) dp[i][j] = -1;

    function<ll(int, bool)> f = [&](int v, bool is_black) -> ll {
        if (dp[v][is_black] != -1) {
            return dp[v][is_black];
        }
        ll result = 1;
        for (int child: g.edges[v]) {
            if (is_black) {
                result = (result * f(child, false)) % MOD;
            } else {
                result = (result * (f(child, true) + f(child, false))) % MOD;
            }
        }
        return dp[v][is_black] = result;
    };

    ll result = (f(root, true) + f(root, false)) % MOD;
    cout << result << endl;
    return 0;
}



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

using namespace std;

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

  int n, x;
  cin >> n >> x;
  vector<int> a(n);
  for (auto &e : a)
    cin >> e;
  uint64_t count = max(0, a[0] - x);
  a[0] = min(a[0], x);
  for (int i = 1; i < n; ++i) {
    int64_t diff = (a[i] + a[i-1]) - x;
    if (0 < diff) {
      count += diff;
      a[i] -= diff;
    }
  }
  cout << count << "\n";
}


Measured memory_bytes: 640
#include <stdio.h>
#include <stdlib.h>


int kaijo(int x) {
    int ans=1;
    int i;
    for(i=2;i<=x;i++){
        ans*=i;
    }
    return ans;
}

int main() {
    int N;
    scanf("%d", &N);
    int *P = (int*)malloc(N * sizeof(int));
    int *Q = (int*)malloc(N * sizeof(int));
    int i;
    for(i=0; i<N; i++) {
        scanf("%d", &P[i]);
    }
    for(i=0; i<N; i++) {
        scanf("%d", &Q[i]);
    }
    int a = 1;
    int b = 1;
    int j;
    for(i=0; i<N-1; i++) {
        a += (P[i] - 1) * kaijo(N-i-1);
        b += (Q[i] - 1) * kaijo(N-i-1);
        for(j=i+1; j<N; j++) {
            if(P[j] > P[i]) P[j]--;
            if(Q[j] > Q[i]) Q[j]--;
        }
    }
    printf("%d\n", abs(a-b));
    
    free(P);
    free(Q);
    return 0;
}

Measured memory_bytes: 128
N = int(input())
results = [input() for i in range(N)]

counts = {
    'AC': 0,
    'WA': 0,
    'TLE': 0,
    'RE': 0,
}
for result in results:
    if result == 'AC':
        counts['AC'] += 1
    elif result == 'WA':
        counts['WA'] += 1
    elif result == 'TLE':
        counts['TLE'] += 1
    elif result == 'RE':
        counts['RE'] += 1
answer = '''
AC x {}
WA x {}
TLE x {}
RE x {}
'''.format(counts['AC'], counts['WA'], counts['TLE'], counts['RE'])
print(answer)


Measured memory_bytes: 16324
// By Atul Rathore

#include<bits/stdc++.h>
using namespace std;

#define ll long long int
#define f(n) for(int i=0;i<n;i++)
#define p(x) cout<<x<<"\n";
#define fastio ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define mod 1000000007
 

int main()
{
	fastio;
	ll x;
	cin>>x;
	ll arr[3761];
	arr[0]=100;
	ll y=100;
	int ans=0;
	for(int i=1;i<3761;i++)
	{
		arr[i]=y+(y/100);
		y=y+y/100;
	}
	for(int i=1;i<3761;i++)
	{
		if(arr[i]>=x)
		{
			ans=i;
			break;
		}
	}
	cout<<ans;
	
	
	
	
	
	
}


Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int N=0,sum=0;
	cin>>N;
	for(int i=1;i<=N;i++)
	{
		
		sum=sum+i;
	}
	cout<<sum<<endl;
	return 0;
	
	
	
}

Measured memory_bytes: 256
/*
 * http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0006
 */
#include <iostream>
#include <string>

using namespace	std;

int
main()
{
	string str;
	cin >> str;
	for (string::reverse_iterator rit = str.rbegin(); rit != str.rend(); ++rit)
		cout << *rit;
	cout << endl;
	return 0;
}

Measured memory_bytes: 3120
#include<bits/stdc++.h>
typedef long long int LL;
typedef unsigned long long int ULL; 
typedef long double dd; 
#define endl "\n"
int dx[4]={1,-1,0,0};
int dy[4]={0,0,-1,1};
LL dp[2000001];
LL mod=1e9+7;
bool vis[100000];
using namespace std;
bool isPrime(LL n) {
  LL j; 
  for( j=2;j<=sqrt(n);j++){
    if(n%j==0){
      break;  
    } 
  }
  if(j>sqrt(n)){
    return 1; 
  }
  else{
    return 0; }
}
LL modexpo(LL a, LL b) {
  LL ans=1;
  a=a%mod;
  while(b>0){
    if((b&1)==1){
      ans=((ans%mod)*(a%mod))%mod;
    }
    b=b>>1;
    a=((a%mod)*(a%mod))%mod;
  }
  return ans; 
}
LL invmod(LL n){
  return modexpo(n,mod-2);
}
LL comb(LL n,LL r){
  if(r==0){
    return 1;
  }
  LL fact[n+1];
  fact[0] = 1; 
    for (LL i = 1; i <= n; i++){
       fact[i] = (fact[i - 1] * i) %mod;}
    return (fact[n] * invmod(fact[r]) % mod * invmod(fact[n - r]) % mod) %mod; 
}
LL gcd(LL a, LL b) {
  if (a == 0){
       return b;
       }  
    return gcd(b % a, a);  

}
LL lcm(LL a, LL b) {
  return (a*b)/gcd(a,b);
}
void solve(LL k){
LL n; 
cin>>n;
if(n==0){
  cout<<"1";
}
else{
  cout<<"0";
}
}
int main(){
  ios_base::sync_with_stdio(false);
    cin.tie(NULL);
 LL t=1;
//cin>>t;
 LL k=1;
while(k<=t){
   solve(k);
  k++;
  }
   return 0;
   }

Measured memory_bytes: 3640
N = int(input())
AB = [[i for i in map(int,input().split())] for j in range(N)]
AB.sort(key=lambda x:x[1])

now = 0
ok = 1
for i in range(N):
  now += AB[i][0]
  if now > AB[i][1]:
    ok=0
    break
    
if ok:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 41176
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ll long long 
#define REP(i, a, b) for (ll i = a; i < b; i++)
#define REPI(i, a, b) for (ll i = b - 1; i >= a; i--)
#define i_os ios::sync_with_stdio(0);  cin.tie(0);  cout.tie(0);
#define INF (ll)1e18 + 100
#define endl "\n"
#define p0(a) cout << a << " "
#define p1(a) cout << a << endl
#define p2(a, b) cout << a << " " << b << endl
#define p3(a, b, c) cout << a << " " << b << " " << c << endl
#define p4(a, b, c, d) cout << a << " " << b << " " << c << " " << d << endl
/*SOME BITMASK KNOWLEDGE
1)x & (x - 1):sets the last one bit of x to zero
power of two exactly when x & (x − 1) = 0.
2)x & -x:sets all the one bits to zero, except last one bit
3)x | (x - 1):inverts all the bits after the last one bit*/
#define o_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
#define o_setll tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>
typedef tree<pair<ll, ll>,null_type,less<pair<ll, ll>>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> indexed_set1;
//1. order_of_key(k) : number of elements strictly lesser than k
//2. find_by_order(k) : k-th element in the set

int main() 
{
	i_os;
	ll n;
	cin>>n;
	unordered_map<ll,ll> um;
	ll arr[n];
	REP(i,0,n){
		cin>>arr[i];
		um[arr[i]]++;
	}
	if(um.count(1) && um[1] > 1){
		cout<<0<<endl;
		return 0;
	}
	else if(um.count(1) && um[1] == 1){
		cout<<1<<endl;
		return 0;	
	}

	bool prime[1000001];
	REP(i,0,1000001) prime[i] = 1;
	prime[1] = 0;

	REP(i,2,sqrt(1000000) + 1){
		if(prime[i]){
			for(ll j=i;j<=1000001/i;j++){
				prime[i*j] = 0;
			}
		}
	}

	ll ct = n;
	REP(i,0,n){
		ll val = arr[i];
		REP(j,1,sqrt(arr[i]) + 1)
		{
			if(prime[val] && j > 1){
				break;
			}
			if(val % j == 0)
			{
				if(j == 1){
					if(um[val] > 1){
						// ans[i] = 0;
						ct--;
						break;
					}
					else if(val != j && um.count(j)){
						// ans[i] = 0;
						ct--;
						break;
					}
				}
				else {
					if(um.count(val/j)){
						// ans[i] = 0;
						ct--;
						break;	
					}
					else if(j != val && val/j != j && um.count(j)){
						// ans[i] = 0;
						ct--;
						break;
					}
				}
			}
		}
	}
	cout<<ct<<endl;
	return 0;
}

Measured memory_bytes: 13952
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<bitset>
#include<vector>
#include<deque>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cmath>
#include<iomanip>
#include <functional>
using namespace std;
typedef long long ll;
const int mod = 1000000007;
const double EPS = 1e-10;
const int INF = 2147483647;
//cout << fixed << std::setprecision(9)
//memset(a, 0, sizeof(a));
//--------------------------

int n, m, r;
int p[222];
ll g[222][222];

int main()
{
	for (int i = 0;i < 222;i++)
		for (int j = 0;j < 222;j++) {
			g[i][j] = (ll)INF;
			if(i==j) g[i][j] = 0;
		}

	cin >> n >> m >> r;

	for (int i = 1;i <= r;i++) {
		cin >> p[i];
	}

	for (int i = 0;i < m;i++) {
		int a, b; ll c;
		cin >> a >> b >> c;
		g[a][b] = g[b][a] = c;
	}

	//Warshall-Floyd
	for (int k = 1;k <= n;k++)
		for (int i = 1;i <= n;i++)
			for (int j = 1;j <= n;j++) {
				if (g[i][j] > g[i][k] + g[k][j]) g[i][j] = g[i][k] + g[k][j];
			}

	vector<int> b;

	for (int i = 1;i <= r;i++) b.push_back(i);

	ll ans = (ll) INF;

	do {
		ll temp = 0;

		for (int i = 0;i < r - 1;i++) {
			int start = p[b[i]];
			int end = p[b[i + 1]];
			temp += g[start][end];
		}
		ans = std::min(ans, temp);

	} while (std::next_permutation(b.begin(), b.end()));

	cout << ans << endl;

	return 0;
}


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

int main() {
	string N;
	cin >> N;
	string res = "No";
	if (N[0]=='7') res = "Yes";
	if (N[1]=='7') res = "Yes";
	if (N[2]=='7') res = "Yes";
	cout << res << "\n";
}


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

ll s,t,n;
vl a;

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin>>s>>t>>n;
	a=vl(n);
	ll sum=0,mn=0;
	for(int i=0;i<n;i++){
		cin>>a[i];
		sum+=a[i];
		mn=min(mn,sum);
	}
	ll d=s-t,res=(sum>=0?0:max(0LL,(d+mn)/(-sum)));
	d+=sum*res;
	res*=n;
	for(int i=0;i<3*n;i++){
		d+=a[i%n];
		if(d<=0){
			cout<<res+i+1<<endl;
			return 0;
		}
	}
	cout<<-1<<endl;
}


Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <random>
#include <cstdio>
#include <cmath>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int) n; i++)

int main() {
    string s; cin >> s;
    int ans = 700;
    rep(i,3) {
        if (s[i] == 'o')
        {
            ans += 100;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repI(i, d, n) for (int i = (d); i < (n); ++i)
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

using ll = long long;
using P = pair<int, int>;
using Pl = pair<ll, ll>;
using Pll = pair<ll, Pl>;
using Pv = pair<ll, vector<ll>>;
using Plv = pair<ll, Pv>;
using M = map<int, int>;
ll INF = 1ll<<61;
ll const MAX = 2500;
double pi = 3.141592653589793238;

int main() {
  ll n, m, s;
  cin >> n >> m >> s;

  s = min(s, MAX);

  vector<Pll> G[n];
  rep(i, m) {
    ll u, v, a, b;
    cin >> u >> v >> a >> b;
    u--; v--;
    G[u].push_back(Pll(v, Pl(a, b)));
    G[v].push_back(Pll(u, Pl(a, b)));
  }

  vector<Pl> exch(n);
  rep(i, n) {
    ll c, d;
    cin >> c >> d;
    exch[i] = Pl(c, d);
  }

  priority_queue<Pll, vector<Pll>, greater<Pll>> pq;

  pq.push(Pll(0, Pl(0, s)));
  ll dist[n][MAX+1];
  rep(i, n) rep(j, MAX+1) dist[i][j] = INF;
  dist[0][s] = 0;

  while(!pq.empty()) {
    ll time = pq.top().first;
    ll money = pq.top().second.second;
    ll pos = pq.top().second.first;
    pq.pop();
    // cout << "pos:time:money " << pos << " ";
    // cout << time << " " << money << endl;

    if (money + exch[pos].first <= MAX) {
      ll n_money = money + exch[pos].first;
      ll n_time = time + exch[pos].second;
      if (chmin(dist[pos][n_money], n_time)) {
        pq.push(Pll(n_time, Pl(pos, n_money)));
      }
    }
    // cout << "test1" << endl;

    rep(i, int(G[pos].size())) {

      ll to = G[pos][i].first;
      ll timeCost = G[pos][i].second.second;

      // cout << "pos:to:money:timeCost" << pos << " " << to <<" ";
      // cout << " " << money-G[pos][i].second.first <<" " <<  timeCost << endl;

      if (money < G[pos][i].second.first) continue;
      // cout << "test" << endl;
      if (chmin(dist[to][money-G[pos][i].second.first], dist[pos][money] + timeCost)) {
        // cout << "test2" << endl;
        pq.push(Pll(dist[pos][money] + timeCost, Pl(to, money-G[pos][i].second.first)));
      }
      // cout << "test3" << endl;
    }

    // cout << "test4" << endl;
  }
  // cout << "test5" << endl;

  repI(i, 1, n) {
    ll ans = INF;
    rep(j, MAX+1)  ans = min(ans, dist[i][j]);
    cout << ans << endl;
  }

  return 0;
}


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

using namespace std;

int main(){
    int n; cin >> n;
    vector<long long> v(n);
    vector<long long> sorted(n);
    for(int i =0; i < n; i++){
        cin >> v[i];
        sorted[i] = v[i];
    }
    sort(sorted.begin(), sorted.end());
    long long small = sorted[n/2-1];
    long long big = sorted[n/2];
    for(int i =0; i < n; i++){
        if(v[i] <= small)
            cout << big << endl;
        else
            cout << small << endl;
    }
}


Measured memory_bytes: 5376
#include <stdio.h>

int main(void){
	double a,b,c,d,e,f;
	double delta,x,y;
	while(1){
		if(scanf("%lf%lf%lf%lf%lf%lf",&a,&b,&c,&d,&e,&f) != EOF){
			delta = a * e - b * d;
			x = (c * e - b * f) / delta;
			y = (a * f - c * d) / delta;
			if(x <= 0 && x >= -0.0005){x = 0;}
			if(y <= 0 && y >= -0.0005){y = 0;}
			printf("%.3lf %.3lf\n",x,y);
		}else{
			return 0;
		}
	}
}

Measured memory_bytes: 0
#include<stdio.h>
char c[8][9];
int main(){
	for(int i=0;i<8;i++)scanf("%s",c[i]);
	printf("90\n");
	for(int i=0;i<8;i++){
		for(int j=0;j<8;j++){
			printf("%c",c[8-j-1][i]);
		}
		printf("\n");
	}
	printf("180\n");
	for(int i=0;i<8;i++){
		for(int j=0;j<8;j++){
			printf("%c",c[8-i-1][8-j-1]);
		}
		printf("\n");
	}
	printf("270\n");
	for(int i=0;i<8;i++){
		for(int j=0;j<8;j++){
			printf("%c",c[j][8-i-1]);
		}
		printf("\n");
	}
}

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

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;


void solve(void) {

	int n;
	cin >> n;

	vector<ll> A(n);
	for(ll& x : A) cin >> x;
	vector<ll> pre = {0};
	for(ll x : A) pre.push_back(pre.back() + x);

	vector<vector<ll>> dp(n, vector<ll>(n));

	for(int l = n - 1; l >= 0; l--) {
		for(int r = l + 1; r < n; r++) {
			dp[l][r] = pre[r+1] - pre[l];
			ll x = 1e18;
			for(int k = l; k < r; k++) {
				x = min(x, dp[l][k] + dp[k+1][r]);
			}
			if(x != 1e18) dp[l][r] += x;
		}
	}
	cout << dp[0][n-1] << '\n';
}

int main(void) {


	solve();
	return 0;
}


Measured memory_bytes: 1536
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;
 


public class Main {
	static int a1[]= {0,-1,0,1};
	static int b1[]= {-1,0,1,0};
	private static Scanner sc = new Scanner(System.in);
	//result = Math.pow(num1, num3)
	//StringBuffer str = new StringBuffer(hoge1);
	//String hoge2 = str.reverse().toString();
	//map.containsKey(A)

	//Map<String, Integer> map = new HashMap<String, Integer>(n);
	/*for ( キーのデータ型 key : マップの名前.keySet() ) {
		データのデータ型 data = マップの名前.get( key );
		
		// keyやdataを使った処理;
	}*/
	//int i = Integer.parseInt(s);
	//Queue<String> qq=new ArrayDeque<>(); //add,poll,peek
	//Deque<String> qq=new ArrayDeque<>();//push,pop,peek
	//ArrayList<String> cc = new ArrayList<>(n);
	//Collections.sort(list);
	//Array.sort(list);   cc.contains(tmp)
	//Arrays.asList(c).contains("a")
	//list.set(1,"walk");
	public static void main(String[] args) {
		String S=sc.next();
		String v="";
		int ctn=0;
		String past=""+S.charAt(0);
		ctn++;
		for(int i=1;i<S.length();i++){
			v+=S.charAt(i);
			if(v.equals(past))continue;
			else {
				past=v;
				v="";
				ctn++;
			}
		}
		p(ctn);
	}
	static void p(String ans) {System.out.println(ans);};
	static void p(int ans) {System.out.println(ans);};
	static void p() {System.out.println();};
	static void p(long ans) {System.out.println(ans);};
	static void p(double ans) {System.out.println(ans);};
}
	

Measured memory_bytes: 45272
#include<bits/stdc++.h>
#include<math.h>
using namespace std;
int main(void){
	int n,m,i,j,lt,rt,sum;
	cin >> n >> m;
	int l[m];
	int r[m];
	int record[n];
	sum = 0;
	for(i=0;i<n;i++){
		record[i] = 0;
	}
	for(i=0;i<m;i++){ //ゲート入力
		cin >> lt >> rt;
		l[i] = lt-1;
		r[i] = rt-1;
	}
	for(i=0;i<m;i++){
		record[l[i]] += 1;
		if(r[i]< n-1){
			record[r[i]+1] -=1;
		}
	}
	for(i=0;i<n;i++){
		if(record[i]>=m){
				sum += 1;
		}
		if(i+1==n){
			break;
		}
		record[i+1] = record[i+1] + record[i];
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 1408
n,m,x=map(int,input().split())
item=[list(map(int,input().split()))for i in range(n)]#金、アルゴリズムUp数
bag=[]#条件を満たす本の買い方
for i in range(2**n):#すべて調べる
    temp=[]#買う本
    job=[0]*m#理解度
    for s in range(n):#全桁を調べる
        if (i>>s)&1:#買うのであれば
            temp.append(s)#買う本を追加
            for y in range(m):
                job[y]+=item[s][y+1]#理解度を足す
    for s in range(len(job)):
        if job[s]<x:#もし、理解度がX未満であればbreak
            break
    else:#理解度がすべてX以上ならば
        money=0
        for s in temp:#合計金額を算出
            money+=item[s][0]
        bag.append(money)
#買う組み合わせが1以上なければ-1を出力
print(min(bag) if len(bag)>=1 else -1)

Measured memory_bytes: 9244
#include <bits/stdc++.h>
#define LOOP(n) for (int _i = 0; _i < (n); _i++)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define RREP(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, r, n) for (int i = (r); i < (n); ++i)
#define ALL(obj) begin(obj), end(obj)
using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;
using Graph = vector<vector<int>>;

const int INF = 2100100100;
const int MOD = 1e9 + 7;

// 多次元 vector 生成
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template <class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}

int N, M, K, Q, W, H, R, C;
int dp[100];

ll f(int n) {
    if (n <= 1) return 1;
    if (dp[n] != INF) return dp[n];
    ll ret = f(n - 1) + f(n - 2);
    dp[n] = ret;
    return ret;
}

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

    cin >> N;
    REP(i, 100) dp[i] = INF;
    cout << f(N) << endl;
    return 0;
}



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

using namespace std;

int main(void)
{
	int n,t;
	vector <int> x;
	int a=-1;
	cin.tie(0);
	ios::sync_with_stdio(false);

	cin >> n;

	for(int i=0;i<n;i++)
	{
		cin >> t;
		x.push_back(t);
		a = max(a,t);
	}

	int b=0;
	int diff=-1;
	for(int i=0;i<n;i++)
	{
		if(a==x[i])
		{
			continue;
		}
		int d = min(x[i],a-x[i]);
		if(diff<d)
		{
			diff=d;
			b=x[i];
		}
	}

	cout << a << ' ' << b << '\n';
	return 0;
}

Measured memory_bytes: 892
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>

using namespace std;
using ll = long long int;
const ll MOD = 1e9 + 7;

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

  vector<ll> town(N, 0);
  for (ll i = 0; i < N; i++) {
    town[i] = i;
  }

  vector<ll> townX(N, 0);
  vector<ll> townY(N, 0);
  for (ll i = 0; i < N; i++) {
    cin >> townX[i];
    cin >> townY[i];
  }

  long double ans = 0;
  auto dis = [](long double x1, long double y1, long double x2,
                long double y2) {
    return sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
  };

  long double sum = 0;
  long double cnt = 0;

  do {
    for (ll i = 0; i < N - 1; i++) {
      long double x1 = townX[town[i]];
      long double y1 = townY[town[i]];
      long double x2 = townX[town[i + 1]];
      long double y2 = townY[town[i + 1]];
      sum += dis(x1, y1, x2, y2);
    }
    cnt += 1;
  } while (next_permutation(town.begin(), town.end()));

  cout << fixed << setprecision(10) << (sum / cnt) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef double D;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
typedef long double ld;

#define rd(x) scanf("%d",&x)
#define rd2(x,y) scanf("%d %d",&x,&y)
#define rl(x) scanf("%lld",&x)
#define rl2(x,y) scanf("%lld %lld",&x,&y)
#define wd(x) printf("%d" ,x)
#define wd2(x,y) printf("%d %d",x,y)
#define wl(x) printf("%lld",x)
#define wl2(x,y) printf("%lld %lld",x,y)
#define PC(x) putchar(x)
#define GC() getchar()
#define NL printf("\n")
#define SP printf(" ")
 
#define SZ(a) (int)a.size()
#define ALL(a) a.begin(), a.end()
#define ITER(it,a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a,value) memset(a, value, sizeof(a))

#define F first
#define S second
#define MP make_pair
#define PB push_back

#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)
#define fr(i,s,e) for(int i=s;i<e;i++)
#define frl(i,s,e) for(ll i=s;i<e;i++)
#define frr(i,s,e) for(int i=s-1;i>=e;i--)
#define frv(i,a) for(int i = 0;i<(int)a.size();i++)
#define frvr(i,a) for(int i = a.size()-1;i>=0;i--)
#define tr(i,a) for(typeof(a.begin()) i = a.begin(); i != a.end();i++)

#define inf 10000000000000
#define mod 1000000007
#define maxn 100009
#define maxr 100009

void solve()
{
	ll n;
	rl(n);
	ll x=n/1.08;
	ll y=(n+1)/1.08;
	ll a=x*1.08;
	ll b=y*1.08;
	if(a==n)
	{
		cout<<x<<endl;
	}
	else if(b==n)
	{
		cout<<y<<endl;
	}
	else
		cout<<":("<<endl;
	return;
}
int main(){
	//sstd::ios::sync_with_stdio(false); cin.tie(NULL);
	solve();
	return 0;
}

Measured memory_bytes: 256