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

typedef long long ll;


#define all(c) (c).begin(),(c).end()
#define loop(s) for(int i = 0; s > i; i++)
#define rep(i,q) for(int i = 0; (q) > i; i++)
#define repp(i,a,q) for(int i = a; q > i; i++)
#define pb push_back
#define int ll
#define MAX 1000000000
#define mod 1000000007
/*
確認ポイント
to_string() はC++11以降の実装;
length(),size()に括弧をつけ忘れてないか;
大文字小文字間違えてないか
*/
signed main() { 
    string S,T;
    vector<char> ue;
    vector<char> sita;
    char alpha[26] = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
    cin >> S >> T;
    bool outt = false;
    
    rep(i,26){
      int hatu = 0;
      rep(j,S.size()){
        // if(alpha[i] != S[j]) continue;
        // if(hatu != 0){
        //   repp(i,ue.size()-hatu,ue.size()){
        //     if(sita[i] == T[j]) continue;
        //     outt = true;
        //     break;
        //   }
        // }
        if(S[j] == alpha[i]){
          ue.pb(S[j]);sita.pb(T[j]);
        }
      }
    }
    rep(i,26){
      char seikai =  '-';
      rep(j,sita.size()){
        if(alpha[i] == sita[j]){
          if(seikai == '-'){
            seikai = ue[j];
          } else {
            if(seikai != ue[j]){
              outt = true;
            }
          }
        }
      }
    }
    rep(i,26){
      char seikai = '-';
      rep(j,ue.size()){
        if(alpha[i] == ue[j]){
          if(seikai == '-'){
            seikai = sita[j];
          } else {
            if(seikai != sita[j]){
              outt = true;
            }
          }
        }
      }
    }
    if(outt) cout << "No" << endl;
    else cout << "Yes" << endl;
    return 0; 
} 

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

typedef long long ll;

int main(){

    ios::sync_with_stdio(false);
    cin.tie(0);

    ll n;
    cin >> n;
    ll arr[n];
    bool flag = true;
    for(ll i=0; i<n; i++){
        cin >> arr[i];
        if(arr[i]==0 && flag){
            flag = false;
        }
    }
    if(!flag){
        cout << 0 << '\n';
    }
    else{

        ll ans=1;
        flag = true;
        ll maxl = 0;
        for(ll i=0; i<n; i++){
            ans = ans*arr[i];
            if(ans>1000000000000000000){
                flag = false;
                break;
            }
        }
        if(ans<=1000000000000000000 && ans>0 && flag) cout << ans << '\n';
        else cout << (-1) << '\n';

    }

    return 0;
}


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


int main() {
    int a, b, c;
    cin >> a >> b >> c;
    if (b - a == c - b) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
s=input()
ans="WA"

flag=False
slen=len(s)
s_3_2=s[2:slen-1]

if s[0]=="A":
    if s_3_2.count("C")==1:
        s=s.replace("A","")
        s=s.replace("C","")
        if s.islower():
            ans="AC"

print(ans)


Measured memory_bytes: 2940
#include <iostream>
#include <vector>

using namespace std;

void SelectionSort(int Seq[], int n){

    int mini;
    int cnt=0;

    for(int i=0; i<n; i++){
       mini = i;
       for(int j=i; j<n; j++){
           if(Seq[j] < Seq[mini]){
               mini = j;
           }
       }
       swap(Seq[i], Seq[mini]);
       if(i != mini) cnt++;
    }

    for(int i=0; i<n; i++){
        if(i != n-1){
            cout << Seq[i] << " ";
        }else{
            cout << Seq[i] << endl;
        }
    }

    cout << cnt << endl;

}


int main(){

    int n;
    cin >> n;

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

    SelectionSort(Seq, n);

    return  0;
}

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

vector<int> used;
vector<vector<int>> edges;
    vector<int> c;
    void dfs(int v){
        if(used[v]) return;
        used[v]=true;
        c.push_back(v);
        for(int i=0;i<edges[v].size();i++){
            int to=edges[v][i];
            dfs(to);
        }
        return;
    }
int main(){
    int n,m;
    cin>>n>>m;
    used.assign(n,0);
    edges.assign(n,vector<int>());
    vector<int> p(n);
    for(int i=0;i<n;i++){
        cin>>p[i];
        p[i]--;
    }
    
    set<pair<int,int>> s;
    for(int i=0;i<m;i++){
        int x,y;
        cin>>x>>y;
        x--,y--;
        s.insert({max(x,y),min(x,y)});
    }
    for(auto &e:s){
        edges[e.first].push_back(e.second);
        edges[e.second].push_back(e.first);
    }

    

    int res=0;
    for(int i=0;i<n;i++){
        if(!used[i]){
            c=vector<int>();
            dfs(i);
            set<int> nums;
            for(int j=0;j<c.size();j++){
                nums.insert(p[c[j]]);
            }
            
            for(int j=0;j<c.size();j++){
                res+=nums.count(c[j]);
            }
        }
    }
    cout<<res<<endl;
    
    return 0;
}

Measured memory_bytes: 18300
#include<iostream>
#include<algorithm>
#include<math.h>
#include<string>
#include<vector>
#define rep(j, n) for (int i = j; i < n; i++)
#define repd(j, n) for (int i = j; i > n; i--)
#define ll long long
using namespace std;

int main() {
	ll ans = 1;
	ll n, a, b;
	cin >> n >> a >> b;
	rep(0, n) {
		if (ans >= a&&b-a>2&&n-i>=2) {
			ans += b - a;
			i++;
		}
		else {
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
//  main.cpp
//  CppTest

#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
using namespace std;

int main(int argc, const char * argv[]) {
    
    
    // cinを高速にするためのおまじない
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    /////////////////////
    // Write code below /
    /////////////////////

    int H,W;
    cin>>H>>W;
    vector<string>S(H);
    vector<string>Output(H+2);
    for(int i=0;i<H+2;i++){
        for(int j=0;j<W+2;j++){
            Output.at(i)+="#";
        }
    }
    for (int i=0;i<H;i++){
        cin>>S.at(i);
        for(int j=0;j<W;j++){
            Output.at(i+1).at(j+1)=S.at(i).at(j);
        }
    }
    for(int i=0;i<H+2;i++){
        cout<<Output.at(i)<<endl;
    }
    
    
        return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define ll long long 
#define PB push_back
#define lc 2 * v
#define rc 2 * v + 1
#define mid (s + e) / 2
#define pii pair <int,  int>
#define pll pair <long long , long long>  
#define FAST ios::sync_with_stdio(false);cin.tie(0);
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,avx,avx2")

const int maxn = 1e3 + 10 , S = 1e4 , N = 3e4 + 30 , sig = 2e4 , INF = 1e9 , mod = 1e9 + 7;

int main() {
    ll x  , y;
    cin >> x>> y;
    if(y % 2 == 0) {
        y /= 2;
        if(y >= x && y - x <= x) {
            cout << "Yes" << endl;
        }
        else {
            cout << "No" << endl;
        } 
    }
    else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

void solve()
{
    int H,W,h,w;
    cin >>H >>W >>h >>w;
    if(H%h==0 && W%w==0)
    {
        printf("No\n");
        return;
    }

    vector<vector<int>> r(H,vector<int>(W));
    bool f = false;
    if(H%h==0)
    {
        f = true;
        swap(H,W);
        swap(h,w);
    }

    rep(i,H)
    {
        int v = -1000;
        if(i%h==0) v=h*1000-1001;
        rep(j,W)
        {
            if(f) r[j][i]=v;
            else r[i][j]=v;
        }
    }

    if(f) swap(H,W);
    printf("Yes\n");
    rep(i,H)
    {
        rep(j,W)
        {
            if(j) printf(" ");
            printf("%d", r[i][j]);
        }
        printf("\n");
    }
}

int main()
{
    solve();
    return 0;
}


Measured memory_bytes: 2688
// ARC094
// C - Same Integers

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;

int a[3];

int main() {
    cin >> a[0] >> a[1] >> a[2];
    sort(a, a + 3);

    int ans = 1e8;
    for (int n = a[0]; n <= a[2]; n++) {
        int l = 0, r = 0;
        for (int i = 0; i < 3; i++) {
            if (a[i] >= n) {
                r += a[i] - n;
            } else {
                l += (n - a[i] + 1) / 2 + (n - a[i]) % 2;
            }
        }
        ans = min(ans, l + r);
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define REP(i,m,n) for(int i = m; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a)  (a).rbegin(),(a).rend()
#define dup(x,y) (((x)+(y)-1) / (y)) //整数型のまま切り上げ演算する
#define PI 3.14159265359
typedef long long LL;
typedef vector<vector<int>> Graph;
template<class T> inline void chmax(T& a, T b) { if (a < b) { a = b; } }
template<class T> inline void chmin(T& a, T b) { if (a > b) { a = b; } }
template<class T> inline T gcd(T x, T y) { if (y == 0) { return x; } else if (x == 0) { return y; }return gcd(y, x % y); }
template<class T> inline T lcm(T x, T y) { return (x * y) / gcd(x, y); }
template<class T> inline vector<T> convert_to_binary_number(T x) { vector<T> binary_num; while (x != 1) { binary_num.push_back(x % 2); x /= 2; } binary_num.push_back(1); return binary_num; }
template<class T> inline void print_vector(vector<T> vec) { for (int i = 0; i < vec.size(); i++) { cout << vec[i] << " "; } cout << endl;}
vector<LL> make_divisors(LL n){vector<LL> divisors;for(int i = 1; i <= sqrt(n); i++) {if(n%i == 0){divisors.push_back(i);if(i != n/i){divisors.push_back(n / i);}}}return divisors;}
const LL MOD = 1e9 + 7;
const int INF = 1 << 30;
const LL LLINF = 1LL << 60;
using namespace std;


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

    for (int i = 1; i <= 9; i++)
    {
        for (int j = 1; j <= 9; j++)
        {
            if(N == i*j){
                cout << "Yes" << endl;
                return 0;
            }
        }
    }

    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
void trace(int *A,int N){                                  
    int i;
    for(i=0;i<N;i++){
        if(i>0)
            printf(" ");
        printf("%d",A[i]);        
    }   
    printf("\n");
}


void insertionSort(int *A,int N){ 
    int j,i,v;
    for(i=1;i<N;i++){
        v=A[i];
        j=i-1;
        while(j>=0&&A[j]>v){
            A[j+1]=A[j];
            j--;                
        }   
        A[j+1]=v;
        trace(A,N);

    }
        
}

int main(void){
    int N,i,j;
    int A[100];

    scanf("%d",&N);
    for(i=0;i<N;i++)
        scanf("%d",&A[i]);
    trace(A,N);
    insertionSort(A,N);
        
   return 0;
}


Measured memory_bytes: 2108
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define all(v) v.begin(), v.end()
using in = int64_t;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
const double PI=3.14159265358979323846;
const in MOD = 1000000007;
const in INF=1e18+7;
const int inf=1e9+7;
using P=pair<int,int>;
vector<int> dx={0,1,-1,0};
vector<int> dy={1,0,0,-1};

struct union_find{
    vector<int> par;
    vector<int> depth;
    vector<int> siz;
    int kid;

    union_find(int n) : par(n) , depth(n,0) , siz(n,1){
        rep(i,n) par[i]=i;
        kid=n;
    }

    int find(int x){
        if(par[x]==x) return x;
        return par[x]=find(par[x]);
    }

    void unite(int x,int y){
        x=find(x);
        y=find(y);
        if(x==y) return;
        kid --;
        siz[x] +=siz[y];
        siz[y] =siz[x];
        if(depth[x]<depth[y]) par[x]=par[y];
        else{
            par[y]=par[x];
            if(depth[x]==depth[y]) depth[x] ++;
        }
    }

    bool same(int x,int y){
        return find(x)==find(y);
    }
    int size(int x){
        return siz[find(x)];
    }
    int kind(){
        return kid;
    }
};

int main(){
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cout << fixed << setprecision(10);
    int n,m;
    cin>>n>>m;
    union_find uf(n);
    rep(i,m){
        int x,y;
        cin>>x>>y;
        x --, y --;
        uf.unite(x,y);

    }
    int ans=0;
    rep(i,n){
        int x = uf.size(i);
        ans = max(ans,x);
    }
    cout<<ans<<endl;
}/*
./problem.exe
*/

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

typedef long long ll;
typedef long double ld;

int n;

const int INF = 1000000000;

int dist[1005][1005];
vector <int> graf[1005];

void bfs(int root){
    for(int i=1; i<=n; i++){
        dist[root][i] = INF;
    }
    dist[root][root] = 0;
    queue <int> q;
    q.push(root);
    while(!q.empty()){
        int v = q.front();
        q.pop();
        for(auto c : graf[v]){
            if(dist[root][c] > dist[root][v] + 1){
                dist[root][c] = dist[root][v] + 1;
                q.push(c);
            }
        }
    }
}

void ispisi(int a, int b){
    cout << dist[a][b] + dist[b][a] << "\n";
    int x = a;
    while(x != b){
        cout << x << "\n";
        for(auto c : graf[x]){
            if(dist[c][b] == dist[x][b]-1){
                x = c;
                break;
            }
        }
    }
    x = b;
    while(x != a){
        cout << x << "\n";
        for(auto c : graf[x]){
            if(dist[c][a] == dist[x][a]-1){
                x = c;
                break;
            }
        }
    }
}

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

    int m;
    cin >> n >> m;
    for(int i=1; i<=m; i++){
        int a, b;
        cin >> a >> b;
        graf[a].push_back(b);
    }
    for(int i=1; i<=n; i++){
        bfs(i);
    }
    int mn = INF;
    for(int i=1; i<=n; i++){
        for(int j=i+1; j<=n; j++){
            mn = min(mn, dist[i][j] + dist[j][i]);
        }
    }
    if(mn == INF){
        cout << -1;
        return 0;
    }
    for(int i=1; i<=n; i++){
        for(int j=i+1; j<=n; j++){
            if(mn == dist[i][j] + dist[j][i]){
                ispisi(i, j);
                return 0;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 4224
#include <iostream>
#include <cstdio>
#include<cmath>
using namespace std;

int main(){
    double x1, y1, x2, y2, x, y, dx, dy, X, Y, k;
    int q;
    cin >> x1 >> y1 >> x2 >> y2 >> q;
    while (q--){
      cin >> x >> y;
      k=((x1-x2)*(x1-x)+(y1-y2)*(y1-y))/(pow(x1-x2,2)+pow(y1-y2,2));
      X = 2*(x1+k*(x2-x1))-x;
      Y = 2*(y1+k*(y2-y1))-y;
  		printf("%.10lf %.10lf\n",X,Y);
    }
}


Measured memory_bytes: 3292
#!/usr/bin/env python3
import sys
import math
from functools import lru_cache
import itertools

@lru_cache(maxsize=None)
def gcd(a: int, b: int):
    return math.gcd(a,b)

def solve(K: int):
    sum = 0

    # all same
    sum += K * (K+1) // 2

    # 2 same
    l = [ i for i in range(1, K+1)]

    for a, b in itertools.combinations(l, 2):
        sum += 6 * gcd(a,b)

    # all diff
    for a, b, c in itertools.combinations(l, 3):
        t = gcd(a,b)
        sum += 6 * gcd(t,c)


    # for a in range(1, K+1):
    #     for b in range(1, K+1):
    #         t = gcd(a,b)
    #         for c in range(1, K+1):
    #             sum += gcd(t,c)
    print(sum)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    K = int(next(tokens))  # type: int
    solve(K)

if __name__ == '__main__':
    main()


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

using i64=int64_t;

#define rep(i,x,y) for(i64 i=i64(x),i##_max_for_repmacro=i64(y); i<i##_max_for_repmacro; ++i)
#define debug(x) #x << "=" << (x)
 
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define print(x)
#endif
 
const int inf=1.01e9;
const i64 inf64=4.01e18;
const double eps=1e-9;
 
template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
    os << "[";
    for (const auto &v : vec) {
        os << v << ",";
    }
    os << "]";
    return os;
}

struct max_flow{
    struct edge{int to; i64 cap,rev;};
    vector<vector<edge>> graph;
    vector<bool> done;
    max_flow(int size):graph(size),done(size){}
    void add_edge(int from,int to,i64 cap){
        graph[from].push_back(edge{to,cap,(int)graph[to].size()});
        graph[to].push_back(edge{from,0,(int)graph[from].size()-1});
    }
    i64 dfs(int v,int t,i64 f){
        if(v==t) return f;
        done[v]=true;
        for(auto &e:graph[v]){
            if(done[e.to] or e.cap<=0) continue;
            int d=dfs(e.to,t,min(f,e.cap));
            if(d>0){
                e.cap-=d;
                graph[e.to][e.rev].cap+=d;
                return d;
            }
        }
        return 0;
    }
    i64 calc_max_flow(int s,int t){
        i64 flow=0;
        while(true){
            fill(done.begin(),done.end(),false);
            i64 f=dfs(s,t,inf);
            if(f==0) return flow;
            flow+=f;
        }
    }
};

void solve(){
    int N;
    cin >> N;

    vector<i64> a(N);
    rep(i,0,N) cin >> a[i];

    int s=N,t=N+1;
    max_flow mf(N+2);
    i64 ideal=0;
    rep(i,0,N){
        if(a[i]>0) ideal+=a[i];
        if(a[i]>=0) mf.add_edge(s,i,a[i]);
        else mf.add_edge(i,t,-a[i]);
        rep(j,i+1,N) if((j+1)%(i+1)==0) mf.add_edge(j,i,inf64/10000);
    }

    cout << ideal-mf.calc_max_flow(s,t) << endl;
}

int main(){
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    solve();
    return 0;
}


Measured memory_bytes: 256
# define _CRT_SECUREj_NO_WARNINGS 1
# define _USE_MATH_DEFINES
# include <iostream>
# include <numeric>
# include <string>
# include <bitset>
# include <vector>
# include <algorithm>
# include <cstdlib>
# include <cstdio>
# include <cstring>
# include <cstdlib>
# include <iomanip>
# include <queue>
# include <sstream>
# include <climits>
# include <cmath>
# include <list>
# include <functional>
# include <string>
# include <ctime>
# include <set>
# include <forward_list>
# include <map>
# include <stack>
using namespace std;
# define INF ((int)(1<<25))
# define REP(i,n) for(int i=0;i<(int)n;i++)
# define FOR(i,n) REP(i,n)
# define FORI(i,k,n) for(int i=k;i<(int)n;i++)
# define TORAD 2.0*M_PI/360.0
# define INT(x) int x;cin>>x;
# define ALL(x) (x).begin(),(x).end()
# define RALL(x) (x).rbegin(),(x).rend()
# define DEBUG(x) cout<<#x<<":"<<x<<endl;
# define EPS 1e-12
#ifdef _MSC_VER
#include <intrin.h>
#define __builtin_popcount __popcnt
#endif
typedef long long lint;
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef pair<int, pii> piii;
const int dx[4] = { 0,1,0,-1 }, dy[4] = { -1,0,1,0 };
template<class T> void debug(T a) { for (auto i : a)cout << i << endl; }

const int M = 100001;

vector<pii> a[M];
int ans[M];
int main()
{
	fill(begin(ans), end(ans), INT_MAX);
	int v, e, r;
	cin >> v >> e >> r;
	FOR(i, e)
	{
		int s, t, d;
		cin >> s >> t >> d;
		a[s].push_back(pii(t, d));
	}
	ans[r] = 0;
	queue<int> que; que.push(r);
	while (!que.empty())
	{
		int now = que.front(); que.pop();
		FOR(i, a[now].size())
		{
			int next = a[now][i].first;
			int p = ans[now] + a[now][i].second;
			if (ans[next] > p)
			{
				ans[next] = p;
				que.push(next);
			}
		}
	}

	FOR(i, v)
	{
		if (ans[i] == INT_MAX)cout << "INF" << endl;
		else cout << ans[i] << endl;
	}
}

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

int main()
{
    int a,x,n;cin>>x>>n;
    unordered_map<int,int> p;
    for(int i=0;i<n;i++){cin>>a;p[a]=1;}
    for(int d=0;d<=x;d++){
        if(!p[x-d]){
            cout<<x-d<<'\n';
            break;
        }else if(!p[x+d]){
            cout<<x+d<<'\n';
            break;
        }
    }
}

Measured memory_bytes: 3616
import sys, os, math, bisect, itertools, collections, heapq, queue
# from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall
from decimal import Decimal
from collections import defaultdict, deque
import copy

sys.setrecursionlimit(10000000)

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: (x * y) // math.gcd(x, y)

MOD = 10 ** 9 + 7
MAX = float('inf')


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N = ii()
    d = set()

    for _ in range(N):
        inst, str = sl()
        if inst == 'insert':
            d.add(str)
        elif inst == 'find' and str in d:
            print('yes')
        else:
            print('no')


if __name__ == '__main__':
    main()



Measured memory_bytes: 33336
#include <iostream>
#include <set>
#include <queue>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <cstring>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
#include <numeric>
#include <functional>

using namespace std;
#define ALL(x)              (x).begin(),(x).end()
#define REP(i, n)           for (int (i) = 0 ; (i) < (ll)(n) ; ++(i))
#define REPN(i, m, n)       for (int (i) = m ; (i) < (ll)(n) ; ++(i))
#define INF                 (int)2e9
#define MOD                 (1000 * 1000 * 1000 + 7)
#define Ceil(x, n)          (((((x))+((n)-1))/n))
#define CeilN(x, n)         (((((x))+((n)-1))/n)*n)
#define FloorN(x, n)        ((x)-(x)%(n))
#define IsOdd(x)            (((x)&0x01UL) == 0x01UL)
#define IsEven(x)           (!IsOdd((x)))
#define M_PI                3.14159265358979323846
typedef long long           ll;
typedef pair<ll, ll>	    P;

/*-----------------------------------------------------------------------------
　処理
 -----------------------------------------------------------------------------*/
int main()
{
	int N;
	cin >> N;

	vector<vector<int>> A(N, vector<int>(N));
	REP(i, N) {
		REP(j, N - 1) {
			cin >> A[i][j];
			A[i][j]--;
		}
	}

	queue<int> nowReq;
	REP(j, N) {
		nowReq.push(j);
	}
	vector<int> idxAll(N, 0);
	int ans = 0;
	while (!nowReq.empty()) {
		bool isExec = false;
		vector<int> isExecAll(N, false);
		queue<int> nextReq;
		while (!nowReq.empty()) {
			int idx1 = nowReq.front();
			nowReq.pop();
			if (idxAll[idx1] < N - 1) {
				int idx2 = A[idx1][idxAll[idx1]];
				int idx3 = A[idx2][idxAll[idx2]];
				if (idx1 == idx3) {
					if (!isExecAll[idx1] && !isExecAll[idx2]) {
						idxAll[idx1]++;
						idxAll[idx2]++;
						isExec = true;
						isExecAll[idx1] = true;
						isExecAll[idx2] = true;
						nextReq.push(idx1);
						nextReq.push(idx2);
					}
				}
			}
		}

		if (isExec) {
			ans++;
		}
		nowReq = nextReq;
	}

	REP(j, N) {
		if (idxAll[j] != N - 1) {
			ans = -1;
			break;
		}
	}

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


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

int main() {
  int a, b;
  cin >> a >> b;

  int dif = b - a;
  int height = 0;
  for (int i = 1; i < dif; i ++) {
    height += i;
  }
  int depth = height - a;

  cout << depth << endl;
}


Measured memory_bytes: 256
def LucasFib(n, memo={}):
    if n == 0:
        return 2
    if n == 1:
        return 1
    elif n in memo:
        return memo[n]
    else:
        memo[n] = LucasFib(n - 1, memo) + LucasFib(n - 2, memo)
        return memo[n]


def resolve():
    N = int(input())
    print(LucasFib(N))


resolve()


Measured memory_bytes: 9176
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Harshad
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>

using namespace std;

class A {
public:
	void solve(std::istream& in, std::ostream& out) {
        int a,b,c; in>>a>>b>>c;
        if(a==b) out<<c;
        if(b==c) out<<a;
        if(a==c) out<<b;
	}
};


int main() {
	A solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <math.h>
#include <vector>
#include <cstdlib>
#include <numeric>
#include <iomanip>
using namespace std;
#define MAX_N 100

template<class T> inline bool chmax(T& a, T b) { if(a < b) {a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if(a > b) {a = b; return true; } return false; }
const long long INF = 1LL << 60;

// Input
int A,B,H,M;

int main() {
  cin >> A >> B >> H >> M;
  double theta_M = 360 * M / 60;
  double theta_H = 360 * (double)(H+(M/60.0)) / 12;

  double theta = abs(theta_H - theta_M);
  theta = theta / 360 * 2*M_PI;
  
  double C = A*A + B*B - 2*A*B*cos(theta);
  cout << fixed << setprecision(20) << sqrt(C) << endl;
}


Measured memory_bytes: 4072
#include <bits/stdc++.h>
using namespace std;
using ll =long long;
#define all(v) v.begin(),v.end()
 
int main() {
  ll N;
  cin>>N;
  vector<ll> p(N);
  for(ll i=0;i<N;i++) {
cin>>p[i];
  }
  
  ll count=0;
  for(ll i=0;i<N;i++) {
if(p[i]!=i+1) {
swap(p[i],p[p[i]-1]) ;
  count++;
}
  }
  
  if(count<=1) {
cout<<"YES"<<endl;
  }
  else {
cout<<"NO"<<endl;
  }
}
     
     


Measured memory_bytes: 3608
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<iomanip>



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

using namespace std;
int a,b,c,d;
int k1,k2;
string s;

int main(){
  cin >> a >> b;
  if((a*b)%2==0) cout << "Even" << endl;
  else cout << "Odd" << endl;
  
  return 0;
}



Measured memory_bytes: 256
Ss = readlines.drop(1).map(&:to_i)

ss = Ss.sort
sum = ss.inject(:+)
if sum % 10 != 0
  puts sum
elsif ss.all?{|s| s % 10 == 0}
  puts 0
else
  begin
    ss.each do|s|
      if (sum - s) % 10 != 0
        puts sum - s
        exit
      end
    end
    sum -= ss.shift
  end
end

Measured memory_bytes: 1788
import java.util.Scanner;

public class Main {

	public static void main(String args[]) {
		 Scanner scan = new Scanner(System.in);
	     String str = scan.nextLine();
		if(str.equals("Sunny")) {
			System.out.println("Cloudy");
		}
		else if(str.equals("Cloudy")){
			System.out.println("Rainy");
		}
		else {
			System.out.println("Sunny");
		}
	}

}


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

int binarySearch(int N, vector<int> A)
{
  int X = -1, O = A.size(), C, R;
  
  while (abs(O - X) > 1)
  {
    C = (X + O) /2;
    if (A.at(C) >= N) O = C;
    else X = C;
  }
  
  return O;
}

int main() 
{
  int N;
  cin >> N;
  vector<int> A = {111, 222, 333,
                   444, 555, 666,
                   777, 888, 999};
  
  int ans = A.at(binarySearch(N, A));
  
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
//#define ll 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 (a>b) { a=b; return 1; } return 0; }
#define rep(i, n) REP(i, 0, n)
#define rep_rev(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
#define all(x) (x).begin(),(x).end()
ll t1,t2;
const ll mod = 1000000007;
const int INF = 1e9;
const ll INFLONG = 1e18;
void swap(ll *x,ll *y){
  ll tmp;
  tmp = *x;
  *x = *y;
  *y = tmp;
}
//bool slove(ll x){
//  ll sum = 0;
//
//  ll ok = 100000;
//  ll ng = -1;
//  while(abs(ok-ng) > 1){
//    ll mid = (ok + ng) / 2;
//    if(solve(mid)){
//      ok = mid;
//    }else{
//      ng = mid;
//    }
//  }
//}

int main(){
  string str;
  cin >> str;
  str = '0' + str;
  ll ans = 0;
  ull len = str.size();
  ll sta = 0;
//  rep(i,len/2){
//    char c = str[len - i-1];
//    str[len - i-1] = str[i];
//    str[i] = c;
//  }
  //cout << str << endl;
  rep_rev(i,len){
    if(str[i] < '5' || str[i] == '5' && str[i-1] <= '4'){
      ans += str[i] - '0';
    }else{
      ans += '9' - str[i] + ('1' - '0');
      ll piv = 1;
      while(str[i - piv] == '9'){
        str[i-piv] = '0';
        piv++;
      }
      //cout << i-piv << endl;
      str[i-piv] = str[i-piv] + '1' - '0';
    }
    //cout << ans << endl;
  }
//  if(str[0] > '5'){
//    ans += 1;
//    sta = 1;
//  }else{
//
//  }
//  rep(i,len-1){
//    if(sta == 0){
//      if(str[i+1] > '5'){
//        ans += str[i] - '0' + 1;
//        sta = 1;
//      }else{
//        ans += str[i] - '0';
//      }
//    }else{
//      str[i] = '9' - (str[i] - '0') + ('1' - '0');
//      if(str[i+1] > '5'){
//        ans += str[i] - '0' + 1;
//        sta = 1;
//      }else{
//        ans += str[i] - '0';
//      }
//    }
//  }
//  if(str[len-1] > '5'){
//    ans += 10 - (str[len-1] - '0');
//  }else{
//    ans += (str[len-1] - '0');
//  }
  cout << ans << endl;
}

Measured memory_bytes: 2436
n = input()
n = n[::-1]
a = "dream"
a = a[::-1]
b = "dreamer"
b = b[::-1]
c = "eraser"
c = c[::-1]
d = "erase"
d = d[::-1]
co = 0
su = 0

for i in range(len(n)):
    co += 1
    if co == 5:
        if n[su:su+co] == a or n[su:su+co] == d:
            su += 5
            co = 0
    elif co == 6:
        if n[su:su+co] == c:
            su += 6
            co = 0
    elif co == 7:
        if n[su:su+co] == b:
            su += 7
            co = 0
    elif co >= 8:
        break
if su == len(n):
    print("YES")
else:
    print("NO")


Measured memory_bytes: 40460
/*
 * Created by Timothy Wang on 5/9/2020.
 * C - Iroha's Obsession
 * https://atcoder.jp/contests/abc042/tasks/arc058_a
 */
#include<bits/stdc++.h>
using namespace std;

bool vis[10];

int main() {
    cin.sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    int N, K; cin >> N >> K;
    for(int i = 0; i < K; i++) {
        int D; cin >> D;
        vis[D] = true;
    }
    for(int i = N; i < INT_MAX; i++) {
        string s = to_string(i);
        bool flag = 1;
        for(int j = 0; j < s.size(); j++) {
            if(vis[s[j]-'0']) {
                flag = 0;
                break;
            }
        }
        if(flag) {
            cout << s << "\n";
            return 0;
        }
    }
    return 0;
}


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

using namespace std;

using int64 = long long;
const int mod = 1e9 + 7;

const int64 infll = (1LL << 62) - 1;
const int inf = (1 << 30) - 1;

struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
  }
} iosetup;


template< typename T1, typename T2 >
ostream &operator<<(ostream &os, const pair< T1, T2 > &p) {
  os << p.first << " " << p.second;
  return os;
}

template< typename T1, typename T2 >
istream &operator>>(istream &is, pair< T1, T2 > &p) {
  is >> p.first >> p.second;
  return is;
}

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

template< typename T >
istream &operator>>(istream &is, vector< T > &v) {
  for(T &in : v) is >> in;
  return is;
}

template< typename T1, typename T2 >
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }

template< typename T1, typename T2 >
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

template< typename T = int64 >
vector< T > make_v(size_t a) {
  return vector< T >(a);
}

template< typename T, typename... Ts >
auto make_v(size_t a, Ts... ts) {
  return vector< decltype(make_v< T >(ts...)) >(a, make_v< T >(ts...));
}

template< typename T, typename V >
typename enable_if< is_class< T >::value == 0 >::type fill_v(T &t, const V &v) {
  t = v;
}

template< typename T, typename V >
typename enable_if< is_class< T >::value != 0 >::type fill_v(T &t, const V &v) {
  for(auto &e : t) fill_v(e, v);
}

template< typename F >
struct FixPoint : F {
  explicit FixPoint(F &&f) : F(forward< F >(f)) {}

  template< typename... Args >
  decltype(auto) operator()(Args &&... args) const {
    return F::operator()(*this, forward< Args >(args)...);
  }
};

template< typename F >
inline decltype(auto) MFP(F &&f) {
  return FixPoint< F >{forward< F >(f)};
}

int main() {
  int N;
  cin >> N;
  for(int i = 1; i <= 9; i++) {
    for(int j = 1; j <= 9; j++) {
      if(i * j == N) {
        cout << "Yes\n";
        return 0;
      }
    }
  }
  cout << "No\n";
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define mp make_pair
#define pb(x) push_back(x)
#define vll vector<long long>
#define pll pair<long long, long long>
#define mll map<long long, long long>
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(), (v).end()
#define gcd __gcd
#define clr(x) memset(x, 0, sizeof(x))
#define mod 1000000007LL
#define mod2 998244353LL
#define INF 1e18

typedef long long ll;
typedef long double ld;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> o_tree;

const int N = 1e5 + 5;
ll fac[N];

void compute()
{
  ll i;
  fac[0] = 1;
  for (i = 1; i < N; i++)
  {
    fac[i] = fac[i - 1] * i;
    fac[i] %= mod;
  }
}

long long power(long long x, long long y, long long p)
{
  long long res = 1;

  x = x % p;

  while (y > 0)
  {
    if (y & 1)
      res = (res * x) % p;

    y = y >> 1;
    x = (x * x) % p;
  }
  return res;
}

long long modInverse(long long n, long long p)
{
  return power(n, p - 2, p);
}

long long ncrp(long long n, long long r, long long p)
{

  if (r == 0)
    return 1;

  return (fac[n] * modInverse(fac[r], p) % p * modInverse(fac[n - r], p) % p) % p;
}

void solve()
{
  ll n, k;
  cin >> n >> k;
  ll a[n];
  ll i, j;
  mll m;
  compute();
  for (i = 0; i < n; i++)
  {
    cin >> a[i];
    m[a[i]]++;
  }
  sort(a, a + n);
  ll res = 0;
  for (i = 0; i < n; i++)
  {
    // selecting all subseq where a[i] is max
    ll remm = i;
    // if(m[a[i]]>=k)
    // {
    //   ll tans = a[i]*(ncrp(m[a[i]],k,mod));
    //   tans%=mod;
    //   res+=tans;
    //   res%=mod;
    // }
    for (j = 1; j <= min(m[a[i]],k); j++)
    {
      ll rem = remm;
      if (rem >= k - j)
      {
        ll tans = ((ncrp(m[a[i]],j,mod)  * ncrp(rem, k - j, mod) )%mod) * a[i];
        tans %= mod;
        res += tans;
        res %= mod;
        // cout << a[i] << " min " << m[a[i]] * ncrp(rem, k - 1, mod) << "\n";
      }
    }
    while (i + 1 < n && a[i + 1] == a[i])
    {
      i++;
    }
  }
  for (i = 0; i < n; i++)
  {
    // selecting all subseq where a[i] is min
    ll remm = n - (i)-m[a[i]];
    
    for (j = 1; j <= min(m[a[i]],k); j++)
    {
      ll rem = remm;
      if (rem >= k - j)
      {
        ll tans = ((ncrp(m[a[i]],j,mod)  * ncrp(rem, k - j, mod) )%mod)* a[i];
        tans %= mod;
        res -= tans;
        res%=mod;
        res+=mod;
        res %= mod;
        // cout << a[i] << " min " << m[a[i]] * ncrp(rem, k - 1, mod) << "\n";
      }
    }
  
    while (i + 1 < n && a[i + 1] == a[i])
    {
      i++;
    }
  }
  cout << res << "\n";
}

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

  if (fopen("input.txt", "r"))
  {
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
  }
  cout << setprecision(20);

  ll t = 1;

  // cin>>t;

  while (t--)
  {
    solve();
  }

  return 0;
}

Measured memory_bytes: 10848
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 100000000

int main(){
    
	string S;
	cin>>S;
	set<char> A;
	for(int i=0;i<S.size();i++){
		A.insert(S[i]);
	}
	
	for(int i=0;i<26;i++){
		if(!A.count((char)'a'+i)){
			cout<<S+(char)('a'+i)<<endl;
			return 0;
		}
	}
	
	string T = S;
	if(!next_permutation(S.begin(),S.end())){
		cout<<-1<<endl;
		return 0;
	}
	
	string ans = "";
	for(int i=0;i<T.size();i++){
		ans += S[i];
		if(S[i]!=T[i])break;
	}
	
	cout<<ans<<endl;
	
    return 0;
}



Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

N=int(input())
ans=[0]*10**6
for i in range(1,int(N**0.5)+1):
    for j in range(1,int(N**0.5)+1):
        for k in range(1,int(N**0.5)+1):
            tmp=i**2+j**2+k**2+i*j+j*k+k*i
            ans[tmp]+=1
for i in range(1,N+1):
    print(ans[i])

Measured memory_bytes: 82836
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

signed main()
{
    int A,B,K; cin>>A>>B>>K;
    for(int i=min(A,B);i>=1;i--){
        if(A%i==0 and B%i==0){
            K--;
            if(K==0){
                cout<<i<<endl;
                return 0;
            }
        }
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int64_t a;
  cin >> a;
cout << 0 << " " << (a - 1) % 1000000000 + 1 << " " << (a - 1) / 1000000000 << " " << 0 << " " << (a - 1) / 1000000000 + 1 << " " << 1000000000 << endl;}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n, a, b, c;
int main()
{
    cin >> n;
    a = n / 100;
    c = n % 10;
    n /= 10;
    b = n % 10;
    if (a == 1)
        a = 9;
    else
        a = 1;
    if (b == 1)
        b = 9;
    else
        b = 1;

    if (c == 1)
        c = 9;
    else
        c = 1;
    cout << 100 * a + 10 * b + c << endl;
    return 0;
}

Measured memory_bytes: 256
/// {{{
#include "bits/stdc++.h"
#define   ALL(x)  x.begin(), x.end()
#define   iostreamBooster()  do{cin.tie(nullptr);ios::sync_with_stdio(false);}while(0)
using namespace std;
typedef long long i64;
typedef pair<int,int> pii;
template<class A, class B>inline bool chmax(A &a, const B &b){return b>a ? a=b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b<a ? a=b,1 : 0;}
constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int MOD = int(1e9) + 7;
// }}}

int H, W, K;

int dp[105][10];

bool isInvalid(const bitset<16> &bit)
{
  for (int i = 1; i < W-1; ++i) {
    if (bool(bit[i]) && bool(bit[i-1])) { return true; }
  }
  return false;
}

i64 slv(int y, int x)
{
  if (x < 0 || x >= W) abort();

  if (y >= H) {
    if (x == K)
      return 1;
    else
      return 0;
  }

  if (~dp[y][x]) return dp[y][x];

  i64 ans = 0;
  for (int b = 0; b < (1 << (W-1)); ++b) {
    bitset<16> bit(b);
    if (isInvalid(bit)) continue;

    if (bit[x])
      ans = (ans + slv(y+1, x+1)) % MOD;
    else if (bit[x-1])
      ans = (ans + slv(y+1, x-1)) % MOD;
    else
      ans = (ans + slv(y+1, x)) % MOD;
  }

  return dp[y][x] = ans % MOD;
}

signed main()
{
  cin >> H >> W >> K;
  --K;

  memset(dp, -1, sizeof(dp));

  cout << slv(0, 0) << endl;

  return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#define rep2(x,from,to) for(int x=(from);(x)<(to);(x)++)
#define rep(x,to) rep2(x,0,to)
using namespace std;
string color[6] =  {"Cyan", "Yellow", "Red", "Magenta", "Green", "Blue"};
int* south(int c[6]) {
	int buf = c[0];
	c[0] = c[1];
	c[1] = c[5];
	c[5] = c[4];
	c[4] = buf;
	return c;
}
int* east(int c[6]) {
	int buf = c[0];
	c[0] = c[2];
	c[2] = c[5];
	c[5] = c[3];
	c[3] = buf;
	return c;
}
int* round(int c[6]) {
	int buf = c[1];
	c[1] = c[2];
	c[2] = c[4];
	c[4] = c[3];
	c[3] = buf;
	return c;
}
bool check(int d1[6], int d2[6]) {
	rep(i,6) {
		if(i%2)d1 = south(d1);
		else d1 = east(d1);
		rep(j,4) {
			d1 = round(d1);
			bool f = 1;
			rep(k,6) {
				if(d1[k] != d2[k]) {
					f = 0;
					break;
				}
			}	
			if(f) return true;
		}
	}
	return false;
}
int main(){
	int n, d[30][6] = {};
	string s;
	while(cin >> n, n) {
		rep(i,n) {
			rep(j,6) {
				cin >> s;
				rep(k,6) {
					if(color[k] == s) d[i][j] = k;
				}
			}
		}
		int a[30];
		bool used[30] = {};
		rep(i,n) a[i] = i;
		rep(i,n) {
			rep2(j,i+1,n) {
				if(check(d[i],d[j])) {
					a[j] = i;
				}
			}
		}
		rep(i,n) {
			int x = i;
			while(a[x]!=x) {
				a[x] = a[a[x]];
				x = a[x];
			}
		}
		rep(i,n) used[a[i]] = true;
		int ret = 0;
		rep(i,n) {
			if(!used[i]) ret++;
		}
		cout << ret << endl;
	}
	return 0;
}

Measured memory_bytes: 1216
#include<iostream>
using namespace std;
int main(){
    
    int i = 1;
    int n;
    
    while (1){
        cin >> n;
        
        if (n == 0) break;
        
        
        cout <<"Case"<<" "<< i <<": "<< n <<endl;
        
        i++;
    }
    
    return 0;
}


Measured memory_bytes: 3092
#include<bits/stdc++.h>
using namespace std;
using ll = long long; 
using ull = unsigned long long;
using V = vector<int>;
using VV = vector<vector<int>>;
using VVV = vector<vector<vector<int>>>;
using VL = vector<ll>;
using VVL = vector<vector<ll>>;
using VVVL = vector<vector<vector<ll>>>;
template<class T> using pq = priority_queue<T>;
template<class T> using P = pair<T, T>;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define REP(i,k,n) for(int i=(k);i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define output(x,y) cout << fixed << setprecision(y) << x << endl;
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; }
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; }
const ll MOD = 1e9 + 7;
ll upper = MOD + MOD;
ll under = -upper;
ll UPPER = MOD * MOD;
ll UNDER = -MOD * MOD;
const long double pi = 3.141592653589793;
int main() { // 問題文はしっかり読め!!!
	string s;
	cin >> s;
	int n = s.size();
	VV dp(n + 1, V(2, upper)); // i桁目まで支払って、前の桁が繰り上がっていない/いるときの最小の枚数
	dp[0][0] = 0;
	reverse(all(s));
	rep(i, n) {
		rep(j, 2) {
			if (j == 0) { // 前の桁が繰り上がっていないとき
				chmin(dp[i + 1][j], dp[i][j] + (s[i] - '0')); // ぴったり支払う
				chmin(dp[i + 1][j + 1], dp[i][j] + (10 - (s[i] - '0'))); //桁を繰り上げる(店員に支払わせる)
			}
			if (j == 1) { // 前の桁が繰り上がっているとき
				chmin(dp[i + 1][j - 1], dp[i][j] + (s[i] - '0') + 1); // 前の桁の分まで支払う
				chmin(dp[i + 1][j], dp[i][j] + (10 - (s[i] - '0') - 1)); // また後回しにする
			}
		}
	}
	cout << min(dp[n][0], dp[n][1] + 1) << endl;
	return 0;
}

Measured memory_bytes: 55940
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <tuple>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 200010;

// aのn乗を求める。計算量はO(logn)
ll modpow(ll a, ll n) {
    if(n == 0) {
        return 1;
    }
    if(n%2 == 1) {
        return (a * modpow(a, n-1))%mod;
    }
    return (modpow(a, n/2) * modpow(a, n/2))%mod;
}

ll inverse(ll a) {
    return modpow(a, mod-2);
}

ll fact[MAX_N];  // fact[i] : iの階乗のmod
ll invfact[MAX_N];

void init() {
    fact[0] = invfact[0] = 1;
    for(ll i = 1; i < MAX_N; i++) {
        fact[i] = (i*fact[i-1])%mod;
        invfact[i] = inverse(fact[i]);
    }
}
 
ll Comb(ll n, ll r) {
    if(r < 0 || n < 0 || n < r) {
        return 0;
    }
    ll res = fact[n];
    res = (res * invfact[r])%mod;
    res = (res * invfact[n-r])%mod;
    return res;
}

//--- main関数でinit()を呼び出すのを忘れるな ---//
int main() {
    ll n;
    cin >> n;

    vl a(n+1);
    map<ll, ll> mp;
    rep(i, n+1) {
        cin >> a[i];
        mp[a[i]]++;
    }

    ll u;
    for(auto p : mp) {
        if(p.second == 2) {
            u = p.first;
            break;
        }
    }

    ll l = -1, r = -1;
    rep(i, n+1) {
        if(a[i] == u) {
            if(l == -1) {
                l = i;
            }
            else {
                r = n-i;
            }
        }
    }

    init();

    exrep(k, 1, n+1) {
        if(k == 1) {
            out(n);
        }
        else if(k == n+1) {
            out(1);
        }
        else {
            ll d = Comb(n+1, k);
            ll e = Comb(l+r, k-1);
            ll ans = d + mod - e;
            ans %= mod;
            out(ans);
        }
    }

    re0;
}

Measured memory_bytes: 11392
#010 または 101にするのにかかる変更数を考えればいいということになる
s=str(input())
n=len(s)
c1=0
c2=0
for i in range(n): #奇数のときに１、偶数で０にする場合
  if i%2==0:
    if s[i]=="1":
      c1+=1
  else:
    if s[i]=="0":
      c1+=1
for i in range(n): #奇数のときに１、偶数で０にする場合
  if i%2==0:
    if s[i]=="0":
      c2+=1
  else:
    if s[i]=="1":
      c2+=1
print(min(c1, c2))

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

#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
typedef long long ll ;
typedef long double ld ;

const ll MOD = 998244353, INF = 1E12 + 5 ;
const double PI = 2 * acos(0.0) ;
const long double EPS = 1.0E-14 ;

ll n, W, ans = 0, totalCost = 0 ;
ll arrW[105], arrC[105], dp[105][100005] ;

ll check(ll pos, ll cost)
{
    if (pos == 0) {
        if (cost == 0)  return dp[pos][cost] = 0 ;
        else    return dp[pos][cost] = 1E9 ;
    }
    if (dp[pos][cost] != INF)   return dp[pos][cost] ;
    if (arrC[pos] > cost) {
        dp[pos][cost] = min(dp[pos][cost], check(pos - 1, cost)) ;
    }
    else {
        dp[pos][cost] = min(dp[pos][cost], min(arrW[pos] + check(pos - 1, cost - arrC[pos]), check(pos - 1, cost))) ;
    }
    return dp[pos][cost] ;
}

int main()
{
    cin >> n >> W ;
    ll val ;
    for (int i = 1; i <= n; i++) {
        scanf("%lld %lld", &arrW[i], &arrC[i]) ;
        totalCost += arrC[i] ;
    }
    for (int i = 0; i <= n; i++) {
        for (int j = 0; j <= totalCost; j++) {
            dp[i][j] = INF ;
        }
    }
    for (ll i = totalCost; i >= 0; i--) {
        val = check(n, i) ;
        if (val <= W) {
            ans = max(ans, i) ;
        }
    }
    cout << ans ;

    return 0 ;
}


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

using namespace std;

const long long LIM = 1LL * 1000 * 1000 * 1000 * 1000 * 1000 * 1000;

long long solve(const vector<long long>& A)
{
	if (count(A.begin(), A.end(), 0) != 0) {
		return 0;
	}

	long long ans = 1;
	for (auto x : A) {
		if (ans > LIM / x) {
			return -1;
		}
		ans *= x;
	}
	return ans;
}

int main()
{
	int N;
	cin >> N;
	vector<long long> A(N);
	for (auto& x : A) {
		cin >> x;
	}
	cout << solve(A) << endl;
}


Measured memory_bytes: 3996
import java.util.*;
public class Main {
  public static void main(String[] args) {
       Scanner scan = new Scanner(System.in);
       int n = scan.nextInt();
       int[] l = new int[n];
       for(int i = 0; i < n ; i++){
           l[i] = scan.nextInt();
       }
        for (int i = l.length - 1; i >= 0; i--) {
            System.out.print(l[i]);
            if(i != 0){
                System.out.print(" ");
            }
        }
        System.out.println();
  }
}


Measured memory_bytes: 26500
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin >> n;
	for (int i=0;i<n;i++){
		int a[3];
		cin >> a[0] >> a[1] >> a[2];
		sort(a, a+3);
		if (a[0] * a[0] + a[1] * a[1] == a[2] * a[2]){
			cout << "YES" << endl;
		} else cout << "NO" << endl;
	}
}


Measured memory_bytes: 3148