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

#define ASC(vec) vec.begin(), vec.end()		// 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend()	// 降順ソート 例:sort(DESC(vec));
#define rep(i, n) for(int i = 0; i < n; i++)
#define Rep(i, n) for(int i = 1; i < n; i++)
#define In(vec) rep(i, n) cin>>vec[i];
#define ANS(s) cout << s << endl
#define inc(a, b) cin >> a >> b;

const int mod = 1000000007;
const int inf = (int)1e9 + 7;
const long long INF = 1LL << 60;

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vd = vector<double>;
using vvi = vector<vector<int>>;
using vii = vector<pair<int, int>>;

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

ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
int round_int(int a, int b) { return (a + (b - 1)) / b; }


// 4,8方向に探索する際に用いる配列
//int dx[4] = { 0,  0, 1, -1 };
//int dy[4] = { 1, -1, 0,  0 };
//int dx[8] = { 1, 0, -1,  0, 1, -1, -1,  1 };
//int dy[8] = { 0, 1,  0, -1, 1,  1, -1, -1 };

constexpr auto MAX = 100010;

// ────────────────────────────────────────────────────

int main() {
	int x, a, b;
	cin >> x >> a >> b;
	if (abs(a - x) > abs(b - x)) cout << "B" << endl;
	else cout << "A" << endl;
}

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

int main(void){
	int n,m,max,count,x,y;
	char s[200][20],t[200][20];
	
	scanf("%d",&n);
	
	for(int i=0;i<n;i++){
		scanf("%s",s[i]);
	}
	
	scanf("%d",&m);
	
	for(int i=0;i<m;i++){
		scanf("%s",t[i]);
	}
	
	max=0;
	
	
	for(int i=0;i<n;i++){
		
		count=0;
		
		for(int j=0;j<n;j++){
			
			if(strcmp(s[i],s[j])==0){
				count++;
			}
		}
		
		for(int j=0;j<m;j++){
			
			if(strcmp(s[i],t[j])==0){
				count--;
			}
		}
		
		if(count>max){
			max=count;
		}
	}
	printf("%d\n",max);
	
	return 0;
}
	

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

int main() {
    int a,b;
    while(true){
        cin >> a >> b;
        if(a == 0 && b == 0)break;
        for(int i = 0;i < a;i++){
            if(i % 2 == 0){
                for(int k = 0;k < b;k++){
                    if(k % 2 == 0){
                        cout << "#";
                    }
                    if(k % 2 == 1){
                        cout << ".";
                        
                    }
                }
            }
            if(i % 2 == 1){ 
                for(int j = 0;j < b;j++){
                    if(j % 2 == 0){
                        cout << ".";
                    }
                    if(j % 2 == 1){
                        cout << "#";
                    }
                }
            }
            cout << endl;
        }
        cout << endl;
    }
}


Measured memory_bytes: 3112
#include<stdio.h>
int a,b,c;
int main(void){
  scanf("%d%d%d",&a,&b,&c);
  if((a==b&&b!=c&&c!=a)||(b==c&&a!=b&&c!=a)||(c==a&&b!=c&&b!=a)){
    printf("Yes\n");
  }
  else{
    printf("No\n");
  }
    return 0;
  }
  
        
  

Measured memory_bytes: 128
/*|In The Name Of Allah|*/

#include <bits/stdc++.h>

using namespace std;

const int N = 6e3+5;
const int MOD = 1e9+7;

int n;
int t;
int mem[N][N];
// time , De.
vector < pair < int , int > > D;

long long power(long long x, long long y){
    long long res = 1;
    while (y > 0) {
        if (y & 1){
            res = res * x;
            res %= MOD;
        }
        y = y >> 1;
        x %= MOD;
        x = x * x;
        x %= MOD;
    }
    return res;
}

int go(int idx , int time){
    if(time >= t)
        return -1e9;
    if(time < t && idx == n+1){
        return 0;
    }
    if(mem[idx][time] != -1)
        return mem[idx][time];
    int best = 0;
    best = go(idx + 1 , time + D[idx - 1].first) + D[idx - 1].second;
    best = max(best , go(n + 1 , time ) + D[idx - 1].second);
    best = max(best , go(idx + 1 , time));
    return mem[idx][time] = best;
}

int main() {
    scanf("%d%d" , &n , &t);
    for(int i = 1; i <= n; i++){
        int a, b;
        scanf("%d%d" , &a , &b);
        D.push_back({a , b});
    }
    memset(mem , -1 , sizeof mem);
    sort(D.begin() , D.end());
    printf("%d\n" , go(1 , 0));
}


Measured memory_bytes: 141312
$<.readlines.map(&:chomp).each do |given|
  po = 0
  text = ""
  while po < given.length
    if given[po] == "@"
      text += given[po + 2] * given[po + 1].to_i
      po += 3
    else
      text += given[po]
      po += 1
    end
  end
  puts text
end


Measured memory_bytes: 6856
#include <stdio.h>
#include <math.h>

int main(void) {

  long n,m;
  scanf("%ld %ld", &n, &m);
  long a[m],b,c[m][n+1],tmp;
  for (long i = 0; i < m; i++) {
    scanf("%ld %ld", &a[i], &b);
    for (long j = 0; j < n+1; j++) {
      c[i][j] = 0;
    }
    for (long j = 0; j < b; j++) {
      scanf("%ld", &tmp);
      c[i][tmp] = 1;
    }
  }
  long cost;
  long size = pow(2,n);
  long dp[m][size];
  long bit[n];
  for (long i = 1; i <= n; i++) {
    if (c[0][i] == 1) {
      bit[i] = 1;
    } else {
      bit[i] = 0;
    }
  }
  long num = bit[n];
  for (long i = n-1; i >= 1; i--) {
    num *= 2;
    num += bit[i];
  }
  dp[0][0] = 0;
  for (long i = 1; i < size; i++) {
    if (i == num) {
      dp[0][i] = a[0];
    } else {
      dp[0][i] = -1;
    }
  }
  for (long i = 1; i < m; i++) {
    for (long j = 0; j < size; j++) {
      dp[i][j] = dp[i-1][j];
    }
    for (long j = 0; j < size; j++) {
      if (dp[i-1][j] == -1) {
        continue;
      }
      bit[1] = j;
      for (long k = 2; k <= n; k++) {
        bit[k] = bit[k-1]/2;
        bit[k-1] %= 2;
      }
      for (long k = 1; k <= n; k++) {
        if (c[i][k] == 1) {
          bit[k] = 1;
        }
      }
      num = bit[n];
      for (long k = n-1; k >= 1; k--) {
        num *= 2;
        num += bit[k];
      }
      cost = dp[i-1][j]+a[i];
      if (dp[i][num] == -1 || cost < dp[i][num]) {
        dp[i][num] = cost;
      }
    }
  }
  printf("%ld\n", dp[m-1][size-1]);

  return 0;
}

Measured memory_bytes: 32256
import sys
input = sys.stdin.readline

def main():
    x = int(input())
    l = set()
    l.add(1)

    if x == 1:
        print(1)
        exit()

    for i in range(1000):
        for j in range(2, 1000):
            if i ** j > 1000:
                break
            l.add(i ** j)

    x = set(range(x + 1, 1001))
    l = l - x
    print(max(l))

if __name__ == "__main__":
    main()

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

struct edge{
  int64_t from;
  int64_t to;
  int64_t cost;
};

int main(){
  int64_t N, M, P;
  cin >> N >> M >> P;
  vector<edge> G(M);
  for(int i=0; i<M; i++){
    int64_t a, b, c;
    cin >> a >> b >> c;
    a--; b--;
    c -= P;
    edge add;
    add.from = a;
    add.to = b;
    add.cost = c*-1;
    G.at(i) = add;
  }
  int64_t INF = 1e18;
  vector<int64_t> dist(N,INF);
  dist.at(0) = 0;
  vector<bool> inf(N,false);
  for(int i=0; i<2*N; i++){
    for(int j=0; j<M; j++){
      edge e = G.at(j);
      if(dist.at(e.from) != INF && dist.at(e.to) > dist.at(e.from) + e.cost){
        dist.at(e.to) = dist.at(e.from) + e.cost;
        if(i >= N-1){
          dist.at(e.to) = -INF;
        }
      }
    }
  }
  if(dist.at(N-1) == -INF){
    cout << -1 << endl;
  }
  else{
    cout << max((int64_t)0,dist.at(N-1)*-1) << endl;
  }
}



Measured memory_bytes: 512
#include<iostream>
#include<string>
#include<queue>
#include<algorithm>
#include<map>
#include<set>
#include<vector>
#include<math.h>

using namespace std;

#define INF 1000000007
#define LINF (1LL << 62)

typedef long long i64;
typedef pair<i64,i64> P;


int T, n, m, to[10101], f[404];
vector<int> v[404];
vector<P> G[404];
vector<vector<int>> dist(404, vector<int>(404, INF));
vector<int> route[404][404];
int now_t = 0;
int now = 1, next_t = 0;
int have[404] = {0};

int para[2] = {333, 100};

void floyd(){
	for(int i = 1; i <= n; i++){
		for(int j = 1; j <= n; j++){
			for(int k = 1; k <= n; k++){
				if(dist[j][k] > dist[j][i] + dist[i][k]){
					//route[j][k] = route[j][i]+route[i][k];
					route[j][k] = route[j][i];
					route[j][k].insert(route[j][k].end(),route[i][k].begin(),route[i][k].end());
					dist[j][k] = dist[j][i] + dist[i][k];
				}
			}
		}
	}
}

void input(){
	int a,b,c;
	cin >> a;
	for(int i = 0; i < a; i++){
		cin >> b >> c;
		v[c].push_back(now_t);
		to[now_t] = c;
	}
	cin >> a;
	for(int i = 0; i < a; i++){
		cin >> b;
	}
	now_t++;
}

void result(){
	string s;
	int a,b;
	cin >> s;
	cin >> a;
	for(int i = 0; i < a; i++){
		cin >> b;
	}
}

P choice_next(int start, int t){
	i64 ma = -1, k = -1;
	for(int i = 2; i <= n; i++){
		if(!have[i]) continue;
		if(dist[start][i] >= T-t) continue;
		int cnt = 0;
		for(int j = 0; j < route[start][i].size(); j++){
			cnt += have[route[start][i][j]];
		}
		if(ma < cnt * para[0] / (dist[start][i])){
			ma = cnt * para[0] / (dist[start][i]);
			k = i;
		}
	}
	return P(ma, k);
}

int Move(int start, int next_t){
	P choice = choice_next(start, next_t);
	int ma = choice.first, k = choice.second;
	if(ma >= para[1]){
		int npos = route[start][k][0];
		have[npos] = 0;
		for(int i = 0; i < dist[now][npos]; i++){
			if(next_t >= T) break;
			next_t++;
			cout << npos << endl;
			result();
			if(next_t != T) input();
		}
		now = npos;
		next_t = Move(now, next_t);
		
		return next_t;
	}
	for(int i = route[1][now].size()-2; i >= -1; i = route[1][now].size()-2){
		int npos;
		if(i == -1) npos = 1;
		else npos = route[1][now][i];
		for(int j = 0; j < dist[now][npos]; j++){
			if(next_t >= T) break;
			next_t++;
			cout << npos << endl;
			result();
			if(next_t != T) input();
		}
		now = npos;
	}
	return next_t;
}

int main(){
	cin >> n >> m;
	for(int i = 0; i <= n; i++){
		dist[i][i] = 0;
	}
	for(int i = 0; i < m; i++){
		int a,b,c;
		cin >> a >> b >> c;
		G[a].push_back(P(b,c));
		G[b].push_back(P(a,c));
		dist[a][b] = c;
		dist[b][a] = c;
		route[a][b].push_back(b);
		route[b][a].push_back(a);
	}
	for(int i = 1; i <= n; i++){
		cin >> f[i];
	}
	cin >> T;
	
	floyd();
	
	input();
	
	
	for(int t = 0; t < T; t++){
		if(now == 1) have[to[t]]++;
		if(next_t > t) continue;
		next_t = Move(1, t);
		if(next_t == t){
			cout << -1 << endl;
			result();
			if(t != T-1) input();
		}
	}
	
	return 0;
}

Measured memory_bytes: 30540
#include <bits/stdc++.h>
using namespace std;
#define Rep(i,N) for(int i = 0;i < N;i++)
int main(){
  int W,H,N;
  cin >> W >> H >> N;
  bool flag[100][100] = {0};
  int x,y,a;
  Rep(i,N){
    cin >> x >> y >> a;
    if(a == 1){
      for(int i = 0;i < H;i++){
	for(int j = 0;j < x;j++){
	  flag[i][j] = true;
	}
      }
    }else if(a == 2){
      for(int i = 0;i < H;i++){
	for(int j = x;j < W;j++){
	  flag[i][j] = true;
	}
      }
    }else if(a == 3){
      for(int i = 0;i < y;i++){
	for(int j = 0;j < W;j++){
	  flag[i][j] = true;
	}
      }
    }else if(a == 4){
      for(int i = y;i < H;i++){
	for(int j = 0;j < W;j++){
	  flag[i][j] = true;
	}
      }
    }
  }
  int cnt = 0;
  Rep(i,H){
    Rep(j,W){
      cnt += flag[i][j];
    }
  }
  cout << W * H - cnt << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=(0);i<(n);i++)

using namespace std;

typedef long long ll;

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

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

	string s;
	cin >> s;

	int n = s.size();
	string ans;
	rep(i, n){
		if(s[i] == '?') ans.push_back('D');
		else ans.push_back(s[i]);
	}

	cout << ans << endl;
}


Measured memory_bytes: 3816
from itertools import product


def solve(bit):
    for i, j in enumerate(bit):
        if j == 1:
            for x, y in xy[i]:
                if bit[x - 1] != y:
                    return 0
    return sum(bit)


n = int(input())
xy = [[] for i in range(n)]

for i in range(n):
    for j in range(int(input())):
        xy[i].append(list(map(int, input().split())))

ans = 0
for bit in product([0, 1], repeat=n):
    ans = max(ans, solve(bit))
print(ans)

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

using namespace std;

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

const int N = (int)1e5;
vector<pair<int, int> > e[N];
int c[N];

int dfs(int q, int p, int u) {
  int k = 1;
  rep(i,e[q].size()) {
    int id = e[q][i].first;
    int r = e[q][i].second;
    if(r == p) continue;
    if(k == u) k++;
    c[id] = k;
    dfs(r, q, k);
    k++;
  }
  return 0;
}

int main() {
  int n;
  cin >> n;
  rep(i,n-1) {
    int a, b;
    cin >> a >> b;
    e[a-1].push_back(make_pair(i, b-1));
    e[b-1].push_back(make_pair(i, a-1));
  }

  dfs(0, 0, 0);

  int k = 0;
  rep(i,n-1) k = max(k, c[i]);

  cout << k << endl;
  rep(i,n-1) cout << c[i] << endl;
  return 0;
}



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

int main(void){
    // Your code here!
    int64_t a , b;
    cin >> a >> b;
    int64_t result = 1;
    if (a > b) result =a;
    else result = b;
    if (abs(a-b) == 1) result = a*b;
    else {
        for (int i = 1;;i++) {
            if( result*i % a == 0 && result*i % b == 0) {
                result = result*i;
                break;
            }
    }
    }
    cout << result << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cerr << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cerr<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 500010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = (1 << 30) - 1;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
mt19937 rng; //use it by rng() % mod, shuffle(all(vec), rng)
///////////////////////////////////////////////////////////////////////////////////////////////////

void solve() {
	rep(i, 1, 6) {
		int a; cin >> a;
		if(a == 0) {
			cout << i << "\n";
			return;
		}
	}
}

uint32_t rd() {
	uint32_t res;
#ifdef __MINGW32__
	asm volatile("rdrand %0" :"=a"(res) ::"cc");
#else
	res = std::random_device()();
#endif
	return res;
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
    cerr << fixed;
	cerr.precision(6);
	rng.seed(rd());
#ifdef LOCAL
	//freopen("in.txt", "wt", stdout); //for tester
	if(!freopen("in.txt", "rt", stdin)) return 1;
#endif	
	solve();
    cerr << "Time: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
	return 0;
}




Measured memory_bytes: 3792
#include <bits/stdc++.h>
#define st first
#define nd second
#define pb push_back
#define NMAX 200005
using namespace std;
typedef long long ll;
ll x, k, n, ans, i;
string s;
void fast()
{
    ios_base::sync_with_stdio(false);
    cin.tie();
}
int main()
{
    fast();
    cin>>n>>s;
    for(i=2;i<n;i++)
        if(s[i]=='C'&&s[i-1]=='B'&&s[i-2]=='A')
        ans++;
    cout<<ans;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#define N 8
#define FREE 1
#define NOT_FREE -1
 
void printBoard(void );
void putQueen(int );
 
int row[N],col[N];
int dpos[15],dneg[15];
int X[N][N];
 
int main(){
  int i,j,r,c,k;
 
  for(i=0 ; i<N ; i++){
    for(j=0 ; j<N ; j++) X[i][j] = 0;
  }
 
  scanf("%d",&k);
  for(i=0; i<k; i++){
    scanf("%d%d",&r,&c);
    X[r][c] = 1;
  }
 
  for(i=0 ; i<N ; i++){
    row[i] = FREE;
    col[i] = FREE;
  }
  for(i=0 ; i<15 ; i++){
    dpos[i] = FREE;
    dneg[i] = FREE;
  }
 
  putQueen(0);
 
  return 0;
}
 
 
 
void putQueen(int i){
  int j;
  if(i == N){
    printBoard();
    return;
  }
  for(j = 0; j < N; j++){
    if(NOT_FREE == col[j] || NOT_FREE == dpos[i+j] || NOT_FREE == dneg[i-j+N-1]) continue;
    row[i] = j;
    col[j] = dpos[i+j] = dneg[i-j+N-1] = NOT_FREE;
    putQueen(i+1);
    row[i] = col[j] = dpos[i+j] = dneg[i-j+N-1] = FREE;
  }
}
 
 
void printBoard(){
  int i,j;
  for(i = 0; i < N; i++){
    for(j = 0; j < N; j++){
      if(X[i][j]){
    if(row[i] != j) return;
      }
    }
  }
  for(i=0 ; i<N ; i++){
    for(j=0 ; j<N ; j++){
      if(row[i] == j) printf("Q");
      else printf(".");
    }
    printf("\n");
  }
}

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

int main() {
  string S;
  cin >> S;
  
  for (int i = 0; i < (1 << 3); i++) { // 1 -> ＋を挿入 0 -> -を挿入
    int result = 0;
    result += S[0]-'0';
    string answer = "";
    
    answer += S[0];
    
    for (int j = 0; j < 3; j++) {
      if ((i >> j) & 1) {
        result += S[j+1]-'0';
        answer += "+";
        answer += S[j+1];
      } else {
        result -= S[j+1]-'0';
        answer += "-";
        answer += S[j+1];
      }
    }
    
    if (result == 7) {
      cout << answer + "=7" << endl;
      break;
    }
  }
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
n = int(input())

istart_jend = [[0 for _ in range(10)] for i in range(10)]
base = 1

for i in range(1,n+1):
    if i%(base*10)==0:
        base*=10
    istart_jend[i//base][i%10]+=1

ret = 0
for i in range(1,10):
    for j in range(1,10):
        ret += (istart_jend[i][j] * istart_jend[j][i])
print(ret)

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

using namespace std;
typedef long long ll;

int main() {
    int N, W; cin >> N >> W;
    vector<int> v(N), w(N);
    for (int i = 0; i < N; i++) {
        cin >> v[i] >> w[i];
    }

    vector<vector<int> > dp(N+1, vector<int>(W+1));
    for (int i = 0; i < N; i++) {
        for (int j = 0; j <= W; j++) {
            if (j - w[i] >= 0)
                dp[i+1][j] = max(dp[i][j], dp[i+1][j-w[i]] + v[i]);
            else dp[i+1][j] = dp[i][j];
        }
    }

    cout << dp[N][W] << endl;
}



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

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

    while (1) {

        c -= b;
        if (c <= 0) {
            cout << "Yes" << endl;
            break;
        }

        a -= d;
        if (a <= 0) {
            cout << "No" << endl;
            break;
        }
    }
}

Measured memory_bytes: 3556
from fractions import gcd
x=input().split()
N=int(x[0])
M=int(x[1])
S=input()
T=input()
D=gcd(M,N)
OK=True
for l in range(D):
  if S[(l*N)//D]!=T[(l*M)//D]:
    OK=False
    break  
if OK==False:
  print(-1)
else:
  print((M*N)//D)
  

Measured memory_bytes: 5432
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a,b;
  cin >> a>>b;
  int m=b-(a-1);
  int n=b+(a-1);
  for(int i=m;i<=n;i++){
    cout << i <<" ";
  }
  cout <<"\n";
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
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<(n); ++i)
#define FOR(i, a, b) for(int i=(a); i<(b); ++i)
#define FORR(i, a, b) for(int i=(b)-1; i>=(a); --i)

#define DEBUG(x) cout<<#x<<": "<<x<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

#define CHMIN(a, b) a=min((a), (b))
#define CHMAX(a, b) a=max((a), (b))

const ll MOD=1000000007ll;
// const ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-11;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, a;
	cin>>n;
	ll ans=0;
	REP(i, n){
		cin>>a;
		ans+=a-1;
	}
	cout<<ans<<'\n';
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
  int S[4];
  int N,M;
  scanf("%d %d %d",S,S+1,S+2);
  for(int i=0;i<3;i++)
    if(S[i]==5)
      N++;
    else
      M++;
  if(N==2 && M==1)
    printf("YES\n");
  else
    printf("NO\n");
  
  return 0;
}

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

using ll = long long;
using P = pair<int, int>;

const ll INF = 1e12;
const int MOD = 1e9 + 7;

ll tmp[15];

int main() {
  int N, M, X;
  cin >> N >> M >> X;
  int c[N];
  int a[N][M];
  for (int i = 0; i < N; i++) {
    cin >> c[i];
    for (int j = 0; j < M; j++) {
      cin >> a[i][j];
    }
  }

  ll ans = INF;
  for (int i = 0; i < (1 << N); i++) {
    fill(tmp, tmp + M, 0);
    ll mini = 0;
    for (int j = 0; j < N; j++) {
      if ((i >> j) & 1) {
        mini += c[j];
        for (int k = 0; k < M; k++) {
          tmp[k] += a[j][k];
        }
      }
    }

    bool flag = false;
    for (int j = 0; j < M; j++) {
      if (tmp[j] < X) flag = true;
    }
    if (!flag) {
      ans = min(ans, mini);
    }
  }

  cout << (ans == INF ? -1 : ans) << endl;
  return 0;
}

Measured memory_bytes: 3636
import java.util.*;
public class Main{
  public static void main(String[] args)
  {
    Scanner sc=new Scanner(System.in);
    int n=sc.nextInt();
    int[] a=new int[n*2];
    for(int i=0;i<n*2;i++)
    {
        a[i]=sc.nextInt();
    }
    int ans=0;
    for(int j=0;j<=(n*2)-6;j++)
    {
      if(a[j]==a[j+1])
      {
         if(a[j+2]==a[j+3])
         {
           if(a[j+4]==a[j+5])
           {
               ans=1;
             break;
           }
         }
      }
    }
    if(ans==1)
      	System.out.println("Yes");
    else
      System.out.println("No");
      
  }
}

Measured memory_bytes: 36228
#include<iostream>
#include<vector>
using namespace std;
#define int long long int
int count=0;
int answer=0;
void function(vector<int> &v,int initial,int final,int prev,int m,int arr[][4],int q)
{
	if(initial>final)
	{
		count++;
		int here=0;
		int j;
		for(j=0;j<q;j++)
		{
			int a=arr[j][0]-1;
			int b=arr[j][1]-1;
			int c=arr[j][2];
			int d=arr[j][3];
			if(v[b]-v[a]==c)
			{
				here+=d;
			}
		}
		answer=max(answer,here);
	}
	else
	{
		int j;
		for(j=prev;j<=m;j++)
		{
			v.push_back(j);
			function(v,initial+1,final,j,m,arr,q);
			v.pop_back();
		}
	}
}
int32_t main()
{
	int a,b,n;
	cin>>a>>b>>n;
	int val=b-1;
	if(val>n)
	{
		val=n;
	}
	int val1=(a*val)/b;
	int val2=a*(val/b);
	cout<<val1-val2<<endl;
}


Measured memory_bytes: 3636
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<functional>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
using namespace std;
#define MOD 998244353
#define f(i,n) for(long long i=0;i<(long long)(n);i++)
#define N 200100


int main() {
	long long r[N];
	long long b[N];
	bool c[40];
	vector<int>aa;
	char a[N + 1];
	f(i, N + 1)a[i] = 0;
	long long n, k;
	long long x, y, z;
	long long xx, yy, zz;
	char cc;
	long long s, ans;
	bool v = true;
	ans = 0;
	x = MOD - 2;
	f(i, 40) {
		if (x % 2 == 1)c[i] = true;
		else c[i] = false;
		x = x / 2;
	}
	f(i, N) {
		x = 1;
		y = i;
		f(j, 40) {
			if (c[j])x = (x*y) % MOD;
			y = (y*y) % MOD;
		}
		r[i] = x;
	}
	b[1] = 1;

	scanf("%lld", &n);
	scanf("%s", a);
	x = 1;
	while (x <= n) {
		if (n%x == 0)aa.push_back(x);
		x += 2;
	}
	f(i, aa.size()) {
		x = r[aa[i]];
		f(j, i) {
			if (aa[i] % aa[j] == 0)x = (x - b[aa[j]] + MOD) % MOD;
		}
		b[aa[i]] = x;
	}
	ans = 0;
	f(i, aa.size()) {
		x = aa[i];
		y = n / x;
		z = 0;
		f(i, y) {
			z = (z * 2) % MOD;
			if (a[i] == '1')z = (z + 1) % MOD;
		}
		zz = 0;
		f(j, n) {
			xx = j / y;
			yy = j % y;
			if (xx % 2 == 0) {
				cc = a[yy];
			}
			else {
				if (a[yy] == '0')cc = '1';
				else cc = '0';
			}
			if (cc == '1'&&a[j] == '0') {
				zz = -1;
				break;
			}
			else if (cc == '0'&&a[j] == '1') {
				zz = 1;
				break;
			}
		}
		if (zz >= 0)z = (z + 1) % MOD;
		s = (b[aa[i]]*z) % MOD;
		ans = (ans + s) % MOD;
	}
	ans = (ans * 2) % MOD;
	ans = (ans*n) % MOD;


	printf("%lld\n", ans);


	return 0;
}

Measured memory_bytes: 3584
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define LINF (ll)INF*INF
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef vector<pii> vp;

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

signed main(void) {
    int n;
    cin >> n;
    vi a(n);
    rep(i,n)cin >> a[i];
    int q;
    cin >> q;
    int ans = 0;
    vi sum(n);
    rep(_,q){
        int t,x,d;
        cin >> t >> x >> d;
        x--;
        if(ans)continue;
        if(t == 1){//収穫
            sum[x] += d;
            if(sum[x] > a[x])ans = x+1;
        }else{//出荷
            sum[x] -= d;
            if(sum[x] < 0)ans = x+1;
        }
    }
    cout << ans << endl;
}



Measured memory_bytes: 3144
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define INF 1e9
#define ALL(v) v.begin(), v.end()
#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;

int main()
{
    const double PI = acos(-1);
    int r;
    cin >> r;
    printf("%lf\n", 2 * r * PI);
    return 0;
}

Measured memory_bytes: 3724
import java.util.*;

class Main{

    public static void main(String args[]) throws Exception{
        Main main = new Main();
    }

    public Main(){
        Scanner scanner = new Scanner(System.in);
        int a, b;
        a = Integer.parseInt(scanner.next());
        b = Integer.parseInt(scanner.next());

        if(a < b){
            for(int i=0;i<b;i++)
                System.out.print(a);
        } else {
            for(int i=0;i<a;i++)
                System.out.print(b);
        }

        System.out.println("");
    }
}


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

using namespace std;

int ans = 0;

int dfs(int v, int pv, int k, vector<vector<int>>& g) {
  int max_d = 0;
  for (int u : g[v]) {
    max_d = max(max_d, 1 + dfs(u, v, k, g));
  }
  if (max_d == k - 1 && v != 0) {
    ans += pv > 0;
    max_d = -1;
  }
  return max_d;
}

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n, k;
  cin >> n >> k;
  vector<int> f(n);
  for (int i = 0; i < n; i++) {
    cin >> f[i];
    f[i]--;
  }
  ans = f[0] != 0;
  f[0] = -1;
  vector<vector<int>> g(n);
  for (int i = 1; i < n; i++) {
    g[f[i]].push_back(i);
  }
  dfs(0, -1, k, g);
  /*
  for (int i = 0; i < n; i++) {
    cerr << i + 1 << " is connected with :";
    for (int j : g[i]) {
      cerr << ' ' << j + 1;
    }
    cerr << endl;
  }
  */
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 13952
#include <iostream>
#include <cassert>

void ng (long long val = -1LL) {
    std::cout << val << '\n';
    exit(0);
}

int main() {
    int n;
    long long a, b, x = 0;
    std::cin >> n >> a >> b;
    for (int i = 2; i < n; i++) {
        long long e;
        std::cin >> e;
        x ^= e;
    }

    long long d = (a + b) - x;
    if (d < 0 or d % 2 == 1) ng();
    d >>= 1;
    for (int i = 0; i < 50; i++) {
        if ((x >> i & 1) and (d >> i & 1)) ng();
    }

    long long ans = 0;
    for (int i = 50; i --> 0;) {
        int bd = (d >> i & 1), bx = (x >> i & 1);
        if (bd == 1 and bx == 0) {
            ans += (1LL << i);
        }
    }
    for (int i = 50; i --> 0;) {
        int bd = (d >> i & 1), bx = (x >> i & 1);
        if (bd == 0 and bx == 1) {
            if (ans + (1LL << i) < a) ans += (1LL << i);
        }
    }

    if (ans == 0 or ans > a) ans = -1;
    else ans = (a - ans);
    std::cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
#include<math.h>
#include<algorithm> 
#define rep(i,n) for (int i = 0; i < (n) ; ++i)
using namespace std;
using ll = long long ;
using P = pair<int, int> ;
#define PI 3.14159265358979323846264338327950
#define INF 1e18 

int main(){
    int n ;
    cin >> n ;
    vector<int> p (n) ;
    vector<int> q (n) ;
    rep(i, n) cin >> p[i] ;
    rep(j, n) cin >> q[j] ;
    vector<int> v (n) ;
    int a = 0 ;
    int b = 0 ;
    rep(i, n){
        v[i] = i + 1 ;
    }
    int num = 1 ;
    do{
        if(p == v){
            a = num ;
        }
        if(q == v){
            b = num ;
        }
        if(a != 0 && b != 0){
            break; 
        }
        num++ ; 
    }while(next_permutation(v.begin(),v.end())) ;
    cout << abs(a - b) << endl ; 

} 

Measured memory_bytes: 3580
#include<iostream>
#include<iomanip>
#include<math.h>
#include<vector>
#include<string>
#include<stack>
#include<queue>
#include<map>
#include<algorithm>
#include<bitset>
#include<climits>
#include<set>
#include<bitset>
#include<random>
using namespace std;

typedef long long ll;
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define ff first
#define ss second
#define maxs(a,b) a = max(a,b)
#define mins(a,b) a = min(a,b)
#define rep(i,n) for(int i = 0;i < n;i++)

int main(void){
   int n;scanf("%d",&n);
   int k = 0;
   bool possible = false;
   for(k = 0;k*(k+1) <= 2 * n;k++){
      if(k * (k + 1) == 2* n){possible = true;break;}
   }
   if(!possible){
      printf("No\n");return 0;
   }else{
      printf("Yes\n");
      printf("%d\n",k + 1);
   }
   
   vector<int> a[1000];
  int start = 0;
  int block_num = 1;
  for(int i = 0;i < k;i++){
     for(int j = 0;j < block_num;j++){
        a[j].push_back(start + j + 1);
     }
     for(int j = 0;j < block_num;j++){
        a[i + 1].push_back(start + j + 1);
     }
     start += block_num++;
  }
  for(int i = k;i >= 0;i--){
     printf("%d ",k);
     for(auto j : a[i]) printf("%d ",j);
     printf("\n");
  }
  return 0;
}

Measured memory_bytes: 2304
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector> 
#include<limits>
#include<numeric>
#include<type_traits>
#include<math.h>
using namespace std;
typedef long long ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
#define in(x) cin >> x
#define out(str) cout << str << endl

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 A,B,X;

int main(){
    cin>>A>>B>>X;
    if(X>=A&&X<=A+B){
        out("YES");
    }
    else out("NO");
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <limits>
#include <algorithm>
#include <functional>

#include <vector>

using namespace std;

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

	int A, B, C;
	cin >> A >> B >> C;

	vector<int> value_list({ A, B, C });
	sort(value_list.begin(), value_list.end());

	if (value_list[0] != value_list[1])
	{
		cout << value_list[0];
	}
	else
	{
		cout << value_list[2];
	}

	return 0;
}


Measured memory_bytes: 3664
def main():
    n = int(input())
    ai = [int(i) for i in input().split()]

    for i in range(1,n+1):
        ai[i-1] -= i

    ai.sort()

    b = ai[n//2]
    m = sum([abs(i - b) for i in ai])
    print(m)
        
    
if __name__ == '__main__':
    main()


Measured memory_bytes: 97872
import java.util.Scanner;
 
public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		if (N == 7 || N == 5 || N == 3) {
			System.out.print("YES");
		} else {
			System.out.print("NO");
		}
	}
}

Measured memory_bytes: 21844
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int aSave = a;
		int b = sc.nextInt();
		int c = sc.nextInt();
		for(int i =1; i <= b;i++) {
			if(a %b == c) {
				System.out.println("YES");
				return;
			}
			a += aSave;
		}
		System.out.println("NO");
	}
}

Measured memory_bytes: 21844
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <unordered_map>
using namespace std;

#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v.begin(), v.end())
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)

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; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }

typedef long long  ll;

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



int N, M, R;
int r[10];
int road[210][210];
int dist[210][210];
int main()
{
    cin >> N >> M >> R;
    REP(i, R)
    {cin >> r[i], r[i]--;}
    REP(i, M)
    {
        int x, y, z;
        cin >> x >> y >> z;
        road[x-1][y-1] = z;
        road[y-1][x-1]=z;
    }
    REP(i,N){
        REP(j,N){

            if(road[i][j]==0) {
                road[i][j]=INF;
                road[j][i]=INF;
        }
        }
    }
    REP(k,N){
        REP(i,N){
            REP(j,N){
                road[i][j]=min(road[i][j],road[i][k]+road[k][j]);
            }
        }
    }    
    sort(r, r + R);
    ll ans = 1e18;

    do
    {
        ll cnt = 0;
        for(int i=0;i<R-1;i++) {
            cnt+=road[r[i]][r[i+1]];
            //cerr<<road[i][i+1]<<endl;
        }
        ans=min(ans,cnt);

    }while(next_permutation(r,r+R));
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <vector>
#include <cstring>
using namespace std;

#define MAX_WH 50

int w, h;
string field[MAX_WH];
bool wflag[MAX_WH][MAX_WH];
bool bflag[MAX_WH][MAX_WH];

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

void bdfs(int y, int x) {
	bflag[y][x] = true;
	for (int i = 0; i < 4; i++) {
		int ny = y + dy[i], nx = x + dx[i];
		if (0 <= ny && ny < h && 0 <= nx && nx < w && field[ny][nx] != 'W' && bflag[ny][nx] != true)
			bdfs(ny, nx);
	}
}

void wdfs(int y, int x) {
	wflag[y][x] = true;
	for (int i = 0; i < 4; i++) {
		int ny = y + dy[i], nx = x + dx[i];
		if (0 <= ny && ny < h && 0 <= nx && nx < w && field[ny][nx] != 'B' && wflag[ny][nx] != true)
			wdfs(ny, nx);
	}
}

int count_b() {
	int cnt = 0;
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			if (bflag[i][j] && !wflag[i][j] && field[i][j] == '.') cnt++;
		}
	}
	return cnt;
}

int count_w() {
	int cnt = 0;
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			if (wflag[i][j] && !bflag[i][j] && field[i][j] == '.') cnt++;
		}
	}
	return cnt;
}


int main() {
	while (cin >> w >> h) {
		if (w == 0 && h == 0) break;
		memset(bflag, 0, sizeof(bflag));
		memset(wflag, 0, sizeof(wflag));
		for (int i = 0; i < h; i++) cin >> field[i];
		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				if (field[i][j] == 'B') bdfs(i, j);
				else if (field[i][j] == 'W') wdfs(i, j);
			}
		}
		cout << count_b() << ' ' << count_w() << endl;
//		for (int i = 0; i < h; i++) {
//			for (int j = 0; j < w; j++) {
//				if (bflag[i][j] && wflag[i][j]) cout << "x ";
//				else if (bflag[i][j]) cout << "b ";
//				else if (wflag[i][j]) cout << "w ";
//				else cout << "n ";
//			}
//			cout << endl;
//		}
	}
	return 0;
}

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

#define rep(i, n) for(int i = 0; i < (n); ++i)
#define repA(i, a, n) for(int i = a; i <= (n); ++i)
#define repD(i, a, n) for(int i = a; i >= (n); --i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
#define fill(a) memset(a, 0, sizeof (a))
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

int main() {
	cin.sync_with_stdio(0); cin.tie(0);
	cin.exceptions(cin.failbit);
	int n; cin >> n;
	int c = 0;
	rep(i,n){
		int in; cin >> in;
		if(i%2 == 0 && in%2 == 1) c++;
	}
	cout << c << '\n';
	return 0;
}



Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n);i++)
#define sz(x) int(x.size())
typedef long long ll;
typedef pair<int,int> P;
constexpr int mod = 1e9+7;

int main(){
  string s;
  int D;
  cin >> s >> D;
  int n = sz(s);
  vector<vector<int>> dp(2,vector<int>(D,0));
  dp[0][0] = 1;
  for (int i = 0; i < n; i++) {
    int d = s[i] - '0';
    vector<vector<int>> next(2,vector<int>(D,0));
    for (int j = 0; j < D; j++) {
      for (int k = 0; k < 2; k++) {
        for (int c = 0; c <= (k ? 9 : d); c++) {
          (next[k | (c < d)][(j + c) % D] += dp[k][j] ) %= mod; 
        }
      }
    }
    dp = next;
  }
  cout << (dp[0][0] + dp[1][0] - 1 + mod ) % mod << endl; 
  return 0;
} 

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

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

    int cnt=0,l=n.length();
    for(int i=1;i<l;i++){
        if(n[i]=='9') cnt++;
    }

    int ans=0;
    if(cnt==l-1) ans=(int)(n[0]-'0')+9*(l-1);
    else ans=(int)(n[0]-'0')-1+9*(l-1);
    cout<<ans<<endl;
}

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

int main() {

  string s;
  cin >> s;
  
  s.erase(s.end()-2,s.end());
  
  while(s.size() > 0){
    int hantei = 1;
    for ( int i = 0; i < s.size()/2; i++){
      if ( s[i] != s[s.size()/2+i] ){
        hantei = 0;
        break;
      }
    }
    if ( hantei == 1){
      cout << s.size() << endl;
      return 0;
    }else{
      s.erase(s.end()-2,s.end());
    }
  }
 
}

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

#define ll long long
#define ar array
#define vi vector<int>
#define vvi vector<vector<int>>
#define forn(i,n) for(ll i=0; i<(n); i++)
#define fori(i,k,n) for(ll i=k; i<(n); i++) 

int t;

void solve(){
	int y, z ,x;
	cin >> y >> z >> x;
	cout << x << " " <<  y << " "<< z; 
}

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	// cin >> t;
	// while(t--)
	solve();
}

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

int main(){
  int N, M,cnt1,cnt2;
  cnt1 = 0;
  cnt2 = 0;
  string U[256],T[256];
  cin>>N;
  for(int i=0;i<N;i++) cin>>U[i];
  cin>>M;
  for(int j=0;j<M;j++) cin>>T[j];

  for(int j=0;j<M;j++){
  for(int i=0;i<N;i++){
 if(T[j] == U[i]) cnt1++;
 else cnt2++;
 }
if(cnt1 % 2 == 1 && cnt2 != N) cout<<"Opened by"<<" "<<T[j]<<endl;
if(cnt1 % 2 == 0 && cnt2 != N) cout<<"Closed by"<<" "<<T[j]<<endl;
if(cnt2 == N) cout<<"Unknown"<<" "<<T[j]<<endl;
cnt2 = 0;
}
 return 0;
}



Measured memory_bytes: 3212
mod io{
    use std::io::*;
    pub fn read<T: ::std::str::FromStr>()->T{
        let stdin=stdin();
        let ret=stdin.lock().bytes().map(|c|c.unwrap()as char)
        .skip_while(|c|c.is_whitespace())
        .take_while(|c|!c.is_whitespace())
        .collect::<String>().parse().ok().unwrap();
        ret
    }
}
use io::read;
fn main(){
    let n=read::<i32>();
    let s=read::<String>().bytes().collect::<Vec<u8>>();
    let mut ans=0;
    for i in 1..n{
        let mut cnt=0;
        for c in 97u8..123{
            let mut a=false;
            let mut b=false;
            for j in 0..i{
                if s[j as usize]==c{a=true}
            }
            for j in i..n{
                if s[j as usize]==c{b=true}
            }
            if a&&b{cnt+=1}
        }
        ans=if ans<cnt{cnt}else{ans}
    }
    println!("{}",ans)
}


Measured memory_bytes: 4352
#pragma optimization_level 3
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx")
#include<bits/stdc++.h>

using namespace std;
 
#define  GODSPEED       ios:: sync_with_stdio(0);cin.tie(0);cout.tie(0);cout<<fixed;cout<<setprecision(15);
#define  f              first                 
#define  s              second
#define  newl           cout<<"\n";
#define  pb             push_back  
#define  mset(a,x)      memset(a,x,sizeof(a))
#define  debv(a)        for(auto it: a)cout<<it<<" ";newl;
#define  deb1(a)        cout<<a<<"\n";
#define  deb2(a,b)      cout<<a<<" "<<b<<"\n";
#define  deb3(a,b,c)    cout<<a<<" "<<b<<" "<<c<<"\n";
#define  deb4(a,b,c,d)  cout<<a<<" "<<b<<" "<<c<<" "<<d<<"\n";
#define  uniq(a)        a.resize(unique(a.begin(), a.end()) - a.begin());
#define  all(a)         a.begin(),a.end()           
 
typedef  long long             ll;
typedef  long double           ld;
typedef  pair<ll,ll>           pll;
typedef  vector<ll>            vll;
typedef  vector<pll>           vpll;

const ll   N     =  2e5+5;
const ll   mod   =  1e9+7;
const ll   INF   =  0x7f7f7f7f7f7f7f7f;
const int  INFi  =  0x7f7f7f7f;
const ll   LEVEL =  log2(N)+1;

ll n, mx;
vector <pair<ll,pll>> ans;

void solve(){
	cin >> n; n--;
	for(int i = 20; i >= 0; i--){
		mx = i - 1;
		if((1 << i) - 1 <= n) break;
	}
	for(int i = 0; i <= mx; i++){
		ans.pb({i + 1, {i + 2, 0}});
		ans.pb({i + 1, {i + 2, (1 << (mx - i))}});
	}
	int last = (1 << (mx + 1)) - 1;
	while(last < n){
		int left = n - last - 1, mx1;
		for(int i = 20; i >= 0; i--){
			mx1 = i - 1;
			if((1 << i) - 1 <= left) break;
		}
		ans.pb({1, {mx + 1 - mx1, last + 1}});
		last += 1 + (1 << (mx1 + 1)) - 1;
	}
	deb2(mx + 2, ans.size())
	for(auto it : ans) deb3(it.f, it.s.f, it.s.s)
}

int main(){
	GODSPEED;
	int test = 1;
	//cin>>test;
	for(int i = 1; i <= test; i++){
		solve();
	}
	#ifndef ONLINE_JUDGE
	cout<<"\nTime Elapsed: " << 1.0*clock() / CLOCKS_PER_SEC << " sec\n";
	#endif
}

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

int main() {
    int a, b;
    double d_a, d_b;

    cin >> a >> b;
    d_a = a, d_b = b;
    cout << a/b << " " << a%b << " ";
    cout <<fixed<<setprecision(6)<< d_a/d_b << endl;
    return 0;
}


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

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;

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

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

int main(){
  string s;
  cin>>s;
  char c = s[0];
  if(c=='a' || c=='e' || c=='o' || c=='i' || c=='u'){
    puts("vowel");
  }else{
    puts("consonant");
  }
  return 0;
}


Measured memory_bytes: 256
def factorial_mod(n, mod):
    a = 1
    for i in range(1, n + 1):
        a *= i
        a %= mod
    return a


def comb_mod(n, k, mod):
    fact_n = factorial_mod(n, mod)
    fact_k = factorial_mod(k, mod)
    fact_n_k = factorial_mod(n - k, mod)
    return (fact_n * pow(fact_k, mod - 2, mod) * pow(fact_n_k, mod - 2, mod)) % mod


n, m, k = map(int, input().split())
s = 0
mod = 10 ** 9 + 7
for x in range(m):
    s += (m - x - 1) * (m - x) // 2 * n **2
for y in range(n):
    s += (n - y - 1) * (n - y) // 2 * m ** 2


print(s * comb_mod(n * m - 2, k - 2, mod) % mod)


Measured memory_bytes: 38784
#include <stdio.h>

int main()
{   int n;
    scanf("%d",&n);
    int a[n];
    for(int i=0;i<n;i++)
    scanf("%d",&a[i]);
    double ans=0;
    for(int i=0;i<n;i++){
        ans+=1.0/(float)a[i];
    }
    printf("%lf",1.0/ans);
    
    return 0;
}


Measured memory_bytes: 128
#include <stdio.h>
#include <limits.h>
int n,M[100][100];
void dijkstra();
int main(){
  int i,j,w,id,id2,k;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    for(j=0;j<n;j++)M[i][j]=INT_MAX;
  }
  for(i=0;i<n;i++){
    scanf("%d %d",&id,&k);
    for(j=0;j<k;j++){
      scanf("%d %d",&id2,&w);
      M[id][id2]=w;
    }
  }
  dijkstra();
  return 0;
}

void dijkstra(){
  int i,u,mincost,d[100],C[100];
  for(i=0;i<n;i++){
    d[i]=INT_MAX;
    C[i]=0;
  }
  d[0]=0;
  while(1){
    mincost=INT_MAX;
    for(i=0;i<n;i++){
      if(C[i]!=2&&d[i]<mincost){
	mincost=d[i];
	u=i;
      }
    }
    if(mincost==INT_MAX)break;
    C[u]=2;
    for(i=0;i<n;i++){
      if(C[i]!=2&&M[u][i]!=INT_MAX){
	if(d[u]+M[u][i]<d[i]){
	  d[i]=d[u]+M[u][i];
	  C[i]=1;
	}
      }
    }
  }
  for(i=0;i<n;i++){
    if(d[i]==INT_MAX)d[i]=-1;
    printf("%d %d\n",i,d[i]);
  }
}



Measured memory_bytes: 2112
#include<iostream>
#include<set>
#include<string>
using namespace std;
int main(){
	set<string> st;
	int n;
	cin >> n;
	for(int i=0;i<n;i++){
		string MODE,input;
		cin >> MODE >> input;
		if(MODE == "insert") st.insert(input);
		if(MODE == "find"){
			if(st.count(input)){cout << "yes" << endl; continue;}
			cout << "no" << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 32120
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)     for(int i = 0; i < (int)(n); i++)
#define rep2(i, m, n) for(int i = m; i <= (int)(n); i++)
#define MOD 1000000007
#define Graph vector<vector<int>>
typedef pair<int, int> PII;
typedef long long int ll;

int main(){
  string S;

  cin >> S;

  string ans = "";
  rep(i,S.size()){
    ans += "x";
  }


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


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

typedef long long ll;
typedef pair<int,int> ii;

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	string A,B,C; cin>>A>>B>>C;
	cout << (A.back()==B.front() && B.back()==C.front() ? "YES" : "NO") << endl;
	return 0;
}


Measured memory_bytes: 256