akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h> //C++の標準ライブラリを一行で一括でインクルードする
#include <math.h> //数学関数と数学定数を利用する
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}
int gcd(int a, int b){//ユークリッドの互除法
  if (a < b) gcd(b,a); //aの方がbよりでかいのが前提
  if (b == 0) return a; //aをbで割り切れたらreturn
  else gcd(b, a % b);
}

int main(){
  int n; cin >> n;
  map<int,int> mp;
  rep(i,n){
    int tmp; cin >> tmp;
    mp[tmp]++;
  }
  
  int cnt = 0;
  for(auto m:mp){
    if(m.second%2==0) cnt++;
  }
  
  if(cnt%2) cout << mp.size()-1 << endl;
  else cout << mp.size() << endl;
  
  return 0;
}

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

#define NDEBUG
#ifdef DEBUG
#include "../cout11.h"
#undef NDEBUG
#endif
#include <cassert>

typedef long long ll;
typedef long double Double;
typedef unsigned long long ull;
typedef pair<int,int> ii;
typedef pair<ll,ll> llll;
typedef pair<double,double> dd;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ii> vii;
typedef vector<vector<ii>> vvii;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<long double> vD;

#define sz(a)  int((a).size())
#define pb  push_back
#define FOR(var,from,to) for(int var=(from);var<=(to);++var)
#define rep(var,n)  for(int var=0;var<(n);++var)
#define rep1(var,n)  for(int var=1;var<=(n);++var)
#define repC2(vari,varj,n)  for(int vari=0;vari<(n)-1;++vari)for(int varj=vari+1;varj<(n);++varj)
#define ALL(c)  (c).begin(),(c).end()
#define RALL(c)  (c).rbegin(),(c).rend()
#define tr(i,c)  for(auto i=(c).begin(); i!=(c).end(); ++i)
#define found(s,e)  ((s).find(e)!=(s).end())
#define mset(arr,val)  memset(arr,val,sizeof(arr))
#define mid(x,y) ((x)+((y)-(x))/2)
#define IN(x,a,b) ((a)<=(x)&&(x)<=(b))
#define cons make_pair



void solve(int N, string& s) {
    int pre = 0;
    int level = 0;
    rep(i,N){
        if (s[i] == ')') {
            --level;
            if (level < 0) {
                ++pre; level = 0;
            }
        } else {
            ++level;
        }
    }

    rep(i, pre) cout << '(';
    cout << s;
    rep(i, level) cout << ')';
    cout << endl;
}

int main() {
    int N; cin >> N;
    string s; cin >> s;
    solve(N,s);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const long long INF=1e18,MOD=1e9+7;
int main(){
	ll mini=INF,ans=0,n,cnt=0;
	cin>>n;
	vector<ll>a(n);
	for(int i=0;i<n;i++){
		cin>>a[i];
		if(a[i]<0)cnt++;
		a[i]=abs(a[i]);
		mini=min(mini,a[i]);
		ans+=a[i];
	}
	if(cnt%2==1)ans-=mini*2;
	cout<<ans<<endl;

}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	int n, d;
	cin >> n >> d;
 
	int g[n][d];
 
	for (int k = 0; k < n; k++) {
		for (int l = 0; l < d; l++) {
			cin >> g[k][l];
		}
	}
 
	double ans = 0;
	int count = 0;
	for (int m = 0; m < n - 1; m++) {
		for (int p = 1; p < n - m; p++) {
			ans = 0;
			for (int o = 0; o < d; o++) {
				ans += (g[m][o] - g[m + p][o])*(g[m][o] - g[m + p][o]);
			}
			ans = sqrt(ans);
			if (ans - ceil(ans) == 0) count++;
		}
	}
	cout << count << endl;
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>

int main()
{
  int n;
  char s[101], t[101];
  scanf("%d%s%s", &n, s, t);
  for (int i = 0; i < n; ++i)
  {
    putchar(s[i]);
    putchar(t[i]);
  }
  putchar('\n');
  return 0;
}


Measured memory_bytes: 128
s=int(input())
S=[]
S.append(s)
n=s
    
while (1):
    if n%2==0:
        n=n/2
    else :
        n=3*n+1
    if n in S:
        break
    S.append(n)
# print(S)
# print(n)
print(len(S)+1)

Measured memory_bytes: 2940
#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>
#include<complex>

using namespace std;

#define ll long long
#define ld long double
#define EPS 1e-9
#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 pair<pii,int> ppi;
typedef pair<int,pii> pip;
typedef vector<pii> vp;
typedef vector<vi> vvi;

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


signed main(void) {
    int n;
    cin >> n;
    vi a(n);
    rep(i,n)cin >> a[i];
    int ans = 0;
    rep(bit,61){
        int x = 0;
        int t = 1LL << bit;
        rep(i,n)if(a[i]&t)x++;
        if(x == 0 || x == n)continue;
        t %= MOD;
        //cout << x << " " << n-x << " " << t << endl;
        int tmp = x * (n-x) % MOD;
        ans += tmp*t%MOD;
        ans %= MOD;
    }
    cout << ans << endl;
}


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

int x[110];
int main(void) {
  int N, K;
  cin >> N >> K;
  for (int i = 0; i < N; i++) {
	cin >> x[i];
  }
  int ans = 0;
  for (int i = 0; i < N; i++) {
	ans += 2 * min(x[i], K-x[i]);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
a,b=map(int,input().split())
c=[]
d=[]
if a % 2 == 0:
    s = int(100*a/8)
    t = int(100*(a+1)/8) + 1
else:
    s = int(100*a/8) + 1
    t = int(100*(a+1)/8) 
u = int(10*b) 
v = int(10*(b+1)) 
for i in range(s,t):
    c.append(i)
for j in range(u,v):
    d.append(j)
c_d = set(c) & set(d)
if (len(c_d)>0):
    print(min(c_d))
else:
    print(-1)



Measured memory_bytes: 3064
#include <iostream>
using namespace std;
int main(){
  int y, m, d;
  char a, b;
  cin >> y >> a >> m >> b >> d;
  if(m > 4){
    cout << "TBD" << endl;
  }else{
    cout << "Heisei" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <array>
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>

using namespace std;

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

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;

int main() {
  int n, m, ret = 0;
  scanf("%d%d", &n, &m);
  while (n--) {
    int x;
    scanf("%d", &x);
    ret += x >= m;
  }
  printf("%d\n", ret);
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N = 222, R = 10;
unsigned int mat[N][N];
int rs[R];
int n, m, r;
int main() {
    cin >> n >> m >> r;
    for(int i = 1; i <= r; i++) {
        cin >> rs[i];
    }
    for(int i = 1; i <= n; i++) {
        for(int j = 1; j <= n; j++) {
            mat[i][j] = 1 << 30;
        }
    }
    for(int i = 1; i <= m; i++) {
        int a, b, c;
        cin >> a >> b >> c;
        mat[a][b] = c;
        mat[b][a] = c;
    }
    for(int k = 1; k <= n; k++) {
        for(int i = 1; i <= n; i++) {
            for(int j = 1; j <= n; j++) {
                mat[i][j] = min(mat[i][j], mat[i][k] + mat[k][j]);
            }
        }
    }
    sort(rs + 1, rs + r + 1);
    int ans = 1 << 30;
    do {
        int cur = 0;
        for(int i = 1; i < r; i++) {
            cur += mat[rs[i]][rs[i + 1]];
        }
        ans = min(ans, cur);
    } while(next_permutation(rs + 1, rs + r + 1));
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <queue>
#include <algorithm>
#include <functional>
#include <string.h>

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

void solve()
{
	int a, b, c;
	scanf("%d/%d/%d", &a, &b, &c);
	int s = 10000 * a + 100 * b + c;
	if (s > 20190430)
	{
		cout << "TBD" << endl;
	}
	else
	{
		cout << "Heisei" << endl;
	}
}

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

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

int main(){
  int a,b,c,d;
  
  scanf(" %d %d %d %d",&a,&b,&c,&d);
  
  int ans = min(b,d) - max(a,c);
  
  if(ans < 0)printf("0\n");
  else printf("%d\n",ans);
     
  return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n,max=INT_MIN,sum=0;
cin>>n;vector<int> v(n);
for(int i=0;i<n;i++)
 {
 cin>>v[i];sum+=v[i];if(v[i]>max)max=v[i];
 }
cout<<(float)(sum-(float)(max/2));
return 0;
}

Measured memory_bytes: 256
#pragma region include
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
#include <queue>
#include <stack>
#include <cmath>
#include <set>
#include <cstdio>
#include <tuple>
#define ALL(obj) (obj).begin(),(obj).end()
#define RALL(obj) (obj).rbegin(),(obj).rend()
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define MOD 1000000007
#define INF 1000000000
#define LLINF 4000000000000000000
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
#pragma endregion

int main() {
    cin.tie(0); ios::sync_with_stdio(false);
    string s; cin >> s;
    ll ans = 0;
    bool f = true;// 前一致
    vector<vector<ll>> dp(s.size()+1, vector<ll>(2));
    dp[0][0] = 2;
    dp[0][1] = 1;
    for (int i = 1; i < s.size(); i++) {
        if (s[i] == '0') {
            dp[i][0] = dp[i-1][0];
            dp[i][1] = dp[i-1][1] * 3 % MOD;
        }
        else {
            dp[i][1] = dp[i-1][0] + dp[i-1][1] * 3;
            dp[i][1] %= MOD;
            dp[i][0] = dp[i-1][0] * 2 % MOD;
        }
    }
    cout << (dp[s.size()-1][0] + dp[s.size()-1][1]) % MOD << endl;
    getchar(); getchar();
}

Measured memory_bytes: 5840
#include<bits/stdc++.h>
#define rep(i, n) for(int i=0;i<(n);++i)
#define per(i, n) for(int i=(n)-1;i>=0;--i)
#define repa(i, n) for(int i=1;i<(n);++i)
#define foreach(i, n) for(auto &i:(n))
#define pii pair<int, int>
#define pll pair<long long, long long>
#define all(x) (x).begin(), (x).end()
#define bit(x) (1ll << (x))
using namespace std;
using ll = long long;
const ll MOD = (ll)1e9+7;
//const ll MOD = 998244353;
const int INF = (ll)1e9+7;
const ll INFLL = (ll)1e18;
using namespace std;
template<class t>
using vvector = vector<vector<t>>;
template<class t>
using vvvector = vector<vector<vector<t>>>;
template<class t>
using priority_queuer = priority_queue<t, vector<t>, greater<t>>;
template<class t, class u> bool chmax(t &a, u b){if(a<b){a=b;return true;}return false;}
template<class t, class u> bool chmin(t &a, u b){if(a>b){a=b;return true;}return false;}

#ifdef DEBUG
#define OUTPUT(x) (output(x), outendl())
#else
#define OUTPUT(x) (void)0
#endif

ll modpow(ll x, ll b){
	ll res = 1;
	while(b){
		if(b&1)res = res * x % MOD;
		x = x * x % MOD;
		b>>=1;
	}
	return res;
}

ll modinv(ll x){
	return modpow(x, MOD-2);
}

bool was_output = false;
template<class t>
void output(t a){
	if(was_output)cout << " ";
	cout << a;
	was_output = true;
}
void outendl(){
	was_output = false;
	cout << endl;
}

int n;
vector<int> hotel;
vector<ll> sum;
int l;

vvector<int> dp;

int func(int place, int remain){
	if(place==n+1)return n+1;
	if(dp[place][remain]>=0)return dp[place][remain];
	if(remain>0){
		return dp[place][remain] = func(func(place, remain-1), remain-1);
	}
	int p = upper_bound(all(sum), sum[place]+l) - sum.begin() - 1;
	return dp[place][remain] = p;
}

int main(){
	int h, w;
	cin >> h >> w;
	vector<vector<char>> R(h, vector<char>(w, '.')), B(h, vector<char>(w, '.'));
	rep(i, h){
		rep(j, w){
			char d;
			cin >> d;
			if(d=='#'){
				R[i][j] = '#';
				B[i][j] = '#';
			}
			if(i==0){
				R[i][j] = '#';
			}else if(i==h-1){
				B[i][j] = '#';
			}else if(j&1){
				R[i][j] = '#';
			}else{
				B[i][j] = '#';
			}
		}
	}
	foreach(i, R){
		foreach(j, i){
			cout << j;
		}
		cout << endl;
	}
	cout << endl;
	foreach(i, B){
		foreach(j, i){
			cout << j;
		}
		cout << endl;
	}
	return 0;
}


Measured memory_bytes: 1280
#pragma GCC optimize("Ofast")
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define rep2(i,n) for(int i=0;i<=n;i++)
#define repr(i,a,n) for(int i=a;i<n;i++)
#define all(a) a.begin(),a.end()
#define P pair<long long,long long>
#define uni(e) e.erase(unique(e.begin(),e.end()),e.end())
#define double long double
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; }
int INF=1e10;
int MOD=1e9+7;
template<class T> void out(T a){cout<<a<<'\n';}
template<class T> void yesno(T b){if(b)out("yes");else out("no");}
template<class T> void YesNo(T b){if(b)out("Yes");else out("No");}
template<class T> void YESNO(T b){if(b)out("YES");else out("NO");}
template<class T> void noyes(T b){if(b)out("no");else out("yes");}
template<class T> void NoYes(T b){if(b)out("No");else out("Yes");}
template<class T> void NOYES(T b){if(b)out("NO");else out("YES");}
int keta(int a){
  double b=a;
  b=log10(b);
  int c=b;
  return c+1;
}
int kurai(int a,int b){
  int m=pow(10,b),n=pow(10,b-1);
  return (a%m)/n;
}
int ketawa(int a){
  int k=0;
  rep(i,keta(a)){
  k+=kurai(a,i+1);
  }
  return k;
}
int gcd(int a,int b){
  if(a%b==0)
    return b;
  return gcd(b,a%b);
}
int lcm(int a,int b){
    return a/gcd(a,b)*b;
}
int mid(int a,int b,int c){
  vector<int> k(3);
  k[0]=a;k[1]=b;k[2]=c;
  sort(all(k));
  return k[1];
}
bool sosuu(int a){
  bool b=1;
  if(a<=1)
    return 0;
  else{
  rep1(i,sqrt(a)-1){
  if(a%(i+1)==0)
  b=0;
  }
  return b;
  }
}
int modpow(int a,int b,int m=MOD){
 if(!b)return 1; if(b&1)return modpow(a,b-1,m)*a%m;
 int memo = modpow(a,b>>1,m);
 return memo*memo%m;
}
int fact_mod(int n) {
    int f=1; 
for(int i=2;i<n+1;i++) f=f*(i%MOD)% MOD;
    return f;
}
int mod_pow(int x,int n) {
    int res=1;
    while(n>0){
        if(n&1) res=(res*x)%MOD; 
        x=(x*x)%MOD;        
n>>=1; 
    }
    return res;
}
int c_mod(int n, int r) {
    if(r>n-r) r=n-r;
    if(r==0) return 1;
    int a=1;
    rep(i,r) 
a=a*((n-i)%MOD)%MOD;
    int b=mod_pow(fact_mod(r), MOD-2);
    return (a%MOD)*(b%MOD)%MOD;
}
signed main(){
  int a;
  cin>>a;
  vector<int> b(a);
  rep(i,a)
    cin>>b[i];
  sort(all(b));
      reverse(all(b));
       int c=0,d=0;
       rep(i,a-1){
        
       if(b[i]==b[i+1]&&b[i]!=c){
         if(c!=0){
         d=b[i];
           break;
         }
       c=b[i];
       }
      
       }
  rep(i,a-4){
   if(b[i]==b[i+1]&&b[i]==b[i+2]&&b[i]==b[i+3]&&b[i]>d){
         c=b[i];
           d=b[i];
           break;
         }
  }
   out(c*d);
}


Measured memory_bytes: 4148
using System;
using System.Linq;

public class Test
{
	public static void Main()
	{
		// your code goes here
		int n = int.Parse(Console.ReadLine());
		var b = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();
		int counter = b[0] + b[n-2];
		
		for(int i=1;i!=n-1;i++){
			counter += Math.Min(b[i],b[i-1]);
		}
		
		Console.WriteLine(counter);
		
	}
}

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

int main(){
	int N,D;
	cin >> N >> D;
	vector<vector<int>> p(N,vector<int>(D));
	rep(i,N)rep(j,D){ cin >> p[i][j]; }

	int ans = 0;
	for(int i=0; i<N; i++){
		for(int j=i+1; j<N; j++){
			int d = 0;
			for(int k = 0; k<D; k++){
				d += pow(p[i][k]-p[j][k], 2);
			}
			
			for(int k=1; k*k<=40000; k++){
				if(d%k == 0 && d/k == k){ans++; break;}
			}
		}
	}

	cout << ans << endl;
}


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

#define ll long long

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    ll a, v, b, w, t;
    cin >> a >> v >> b >> w >> t;
    ll d = a>=b?a-b:b-a;
    cout << (d<=t*(v-w)?"YES\n":"NO\n");
    return 0;
}


Measured memory_bytes: 3652
#include<stdio.h>
 
template<typename T>
T gcd(T x,T y){return y?gcd(y,x%y):x;}
 
int main()
{
	int T; scanf("%d",&T);
	unsigned long int A,B,C,D;
	for(;0<T;T--)
	{
		scanf("%ld%ld%ld%ld",&A,&B,&C,&D);
		if(A<B||D<B||C<A%B||C<B-gcd(B,D)) puts("No");
		else puts("Yes");
	}
	return 0;
}

Measured memory_bytes: 128
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列
using namespace std;

typedef long long ll;

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000 //10^12
#define MOD 10000007 //10^9+7
#define MAXR 100000 //10^5:最大のrange(素数列挙などで使用)

int main(void){
    int n;
    cin >> n;
    int max_div = 0, max_i = 1;
    FOR(i, 1, n) {
        int tmp = i;
        int count = 0;
        while(tmp%2 == 0) {
            tmp /= 2;
            count++;
        }
        if(max_div < count) {
            max_div = count;
            max_i = i;
        }
    }
    cout << max_i << endl;
    return 0;
}

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

using namespace std;

int main() {
    array<array<int, 3>, 3> bingo{};
    for (auto && i : bingo) {
        for (int & j : i) {
            scanf("%d", &j);
        }
    }

    int n;
    scanf("%d", &n);
    for (int k = 0; k < n; ++k) {
        int tmp;
        scanf("%d", &tmp);
        for (auto && i : bingo) {
            for (int & j : i) {
                if (j == tmp) {
                    j = 0;
                }
            }
        }
    }

    if (bingo[0][0] + bingo[0][1] + bingo[0][2] == 0 ||
        bingo[1][0] + bingo[1][1] + bingo[1][2] == 0 ||
        bingo[2][0] + bingo[2][1] + bingo[2][2] == 0 ||
        bingo[0][0] + bingo[1][0] + bingo[2][0] == 0 ||
        bingo[0][1] + bingo[1][1] + bingo[2][1] == 0 ||
        bingo[0][2] + bingo[1][2] + bingo[2][2] == 0 ||
        bingo[0][0] + bingo[1][1] + bingo[2][2] == 0 ||
        bingo[0][2] + bingo[1][1] + bingo[2][0] == 0) {
        printf("Yes\n");
    }
    else {
        printf("No\n");
    }

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <utility>
#include <set>
#include <stack>
#include <climits>
#include <cmath>

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define rep1(i,n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
#define reps(i,s,n) for(int i=s, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define MEMSET(v, h) memset((v), h, sizeof(v))
typedef long long ll;
const char sp = ' ';


using namespace std;

int main(void){
    ll N;
    ll end, sur;
    vector<pair<ll, ll> > pa1, pa2, pa3;
    string S;
    cin>>N;
    rep(i, N){
        cin>>S;
        ll l=0, r=0;
        sur=-2000000;
        rep(j, S.size()){
            if(S[j]=='(') l++;
            else r++;
            sur=max(sur, r-l);
        }
        end=l-r;
        if(sur<0) pa1.push_back({sur, end});
        else if(end>0) pa2.push_back({sur, end});
        else pa3.push_back({sur+end, sur});
    }
    sort(all(pa3));
    sort(all(pa2));
    ll Maxim=0, th=0;
    rep(i, pa1.size()){
        th-=pa1[i].second;
    }
    rep(i, pa2.size()){
        Maxim=max(Maxim, th+pa2[i].first);
        th-=pa2[i].second;
    }
    rep(i, pa3.size()){
        ll t=pa3.size()-1-i;
        Maxim=max(Maxim, th+pa3[t].second);
        th-=(pa3[t].first-pa3[t].second);
    }
    cout<<((th==0 && Maxim<=0) ? "Yes" : "No")<<endl;
    return 0;
}


Measured memory_bytes: 18952
<?php
fscanf(STDIN, "%d",$N);
$aArray = explode(" ", trim(fgets(STDIN)));
$array = [[],[]];
for($i = 0; $i < $N; $i++){
    $array[$i % 2][] = $aArray[$i];
}
$resultArray = [];
if($N % 2 == 0)$array = array_reverse($array);
foreach($array as $i => $arr){
    if($i % 2 == 0)$arr = array_reverse($arr);
    foreach($arr as $num){
        $resultArray[] = $num;
    }
}
echo implode(" ", $resultArray);


Measured memory_bytes: 40688
#include <iostream>
#include <bits/stdc++.h>
#define ll long long
#define inf 100000000
#define mod 1000000007
#define ld long double
#define point complex<long double>
#define pi acos(-1)
#define IO                            \
	ios_base::sync_with_stdio(false); \
	cin.tie(NULL);                    \
	cout.tie(NULL);
using namespace std;
ll gcd(ll a,ll b)
{
	if(b==0)return a;
	return gcd(b,a%b);
}
int main()
{
	//cout<<gcd(12,18)<<endl;
	int n;
	cin>>n;
	ll arr[n];
	for(int i=0;i<n;i++)
	{
		cin>>arr[i];
	}
	if(n==2)
	{
		cout<<max(arr[0],arr[1])<<endl;
		return 0;
	}
	ll pre[n];
	ll suf[n];
	pre[0]=arr[0];
	for(int i=1;i<n;i++)
	{
		pre[i]=gcd(arr[i],pre[i-1]);
	}
	suf[n-1]=arr[n-1];
	for(int i=n-2;i>=0;i--)
	{
		suf[i]=gcd(suf[i+1],arr[i]);
	}
	ll res=1;
	
	res=max(suf[1],pre[n-2]);
	/*cout<<suf[1]<<endl;
	cout<<pre[n-2]<<endl;
	for(auto s:pre)
	{
		cout<<s<<" ";
	}
	cout<<endl;
	for(auto s:suf)
	{
		cout<<s<<" ";
	}
	cout<<endl;*/
	for(int i=1;i<=n-2;i++)
	{
		//cout<<gcd(suf[i+1],pre[i-1])<<endl;
		res=max(res,gcd(suf[i+1],pre[i-1]));
	}
	cout<<res<<endl;

	return 0;
}

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

ll findgcd(ll,ll);

int main(){
  int i,j;
  int N;
  cin >> N;
  ll maxgcd;
  vector<ll> lgcd(N+1),rgcd(N+1),gcd(N),a(N);
  //vector<ll> a(N),gcd(N);
  /*for(i=0;i<N;i++){
    cin >> a[i];
    if(i!=0) gcd[i] = a[i-1];
  }
  gcd[0] = a[1];
  for(i=0;i<N;i++){
    j=0;
    while(j<N){
      if(j==i) j++;
      else {
        gcd[i] = findgcd(gcd[i],a[j]);
        j++;
      }
    }
  }*/  //失敗
  
  //新ブロック
  for(i=0;i<N;i++) cin >> a[i];
  for(i=0;i<N;i++){
    lgcd[i+1] = findgcd(lgcd[i],a[i]);
  }
  for(i=N;i>0;i--){
    rgcd[i-1] = findgcd(rgcd[i],a[i-1]);
  }
  for(i=0;i<N;i++){
    gcd[i] = findgcd(lgcd[i],rgcd[i+1]);
  }
  
  maxgcd = *max_element(gcd.begin(),gcd.end());
  cout << maxgcd << endl;
}

ll findgcd(ll a,ll b){
  ll tmp,r;
  if(a<b){
    tmp = a;
    a = b;
    b = tmp;
  }
 
  if(b==0) return a;
  // 0とのgdcはその数そのものと定義
  
  /* ユークリッドの互除法 */
  r = a % b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }
  return b;
}

  

Measured memory_bytes: 3328
/*
// A - Something on it
#include <iostream>
using namespace std;

int main() {
  std::ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  string S;
  cin>>S;
  int ans=700;
  for (int i=0; i<3; i++) {
    ans+=S[i]=='o'?100:0;
  }
  cout<<ans<<endl;
  return 0;
}

// B - Bitter Alchemy
#include <iostream>
using namespace std;

int main() {
  std::ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int N,X;
  cin>>N>>X;
  int m[N];
  int ans=N,min_m=1000;
  for (int i=0; i<N; i++) {
    cin>>m[i];
    X-=m[i];
    min_m=min(min_m,m[i]);
  }
  ans+=X/min_m;
  cout<<ans<<endl;
  return 0;
}

// C - Half and Half
#include <iostream>
using namespace std;

int main() {
  std::ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int A,B,C,X,Y;
  cin>>A>>B>>C>>X>>Y;
  int ans=A*X+B*Y;
  for (int k=1; k<=100000; k++) {
    ans=min(ans,2*C*k+max(X-k,0)*A+max(Y-k,0)*B);
  }
  cout<<ans<<endl;
  return 0;
}

// D - Static Sushi O(N^2) 300
#include <iostream>
using namespace std;
using ll=long long;

int main() {
  std::ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ll N,C;
  cin>>N>>C;
  ll x[N],v[N],rx[N];
  for (int i=0; i<N; i++) {
    cin>>x[i]>>v[i];
    rx[i]=C-x[i];
  }
  ll cost=0,ans=0;
  for (int i=0; i<N; i++) {
    cost+=v[i];
    ll rcost=0;
    for (int j=N-1; j>i; j--) {
      rcost+=v[j];
      ans=max(ans,cost-2*x[i]+rcost-rx[j]);
    }
    ans=max(ans,cost-x[i]);
  }
  cost=0;
  for (int i=N-1; i>=0; i--) {
    cost+=v[i];
    ll rcost=0;
    for (int j=0; j<i; j++) {
      rcost+=v[j];
      ans=max(ans,cost-2*rx[i]+rcost-x[j]);
    }
    ans=max(ans,cost-rx[i]);
  }
  cout<<ans<<endl;
  return 0;
}
*/
// D - Static Sushi O(N) 500
#include <iostream>
using namespace std;
using ll=long long;

int main() {
  std::ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ll N,C;
  cin>>N>>C;
  ll x[N+2],v[N+2],sz[N+2],nz[N+2],sj[N+2],nj[N+2];
  for (int i=0; i<N+2; i++) {
    x[i]=v[i]=sz[i]=nz[i]=sj[i]=nj[i]=0;
  }
  for (int i=1; i<=N; i++) {
    cin>>x[i]>>v[i];
  }
  for (int i=1; i<=N; i++) {
    sj[i]=sj[i-1]+v[i];
    sz[i]=max(sz[i-1],sj[i]-x[i]);
  }
  for (int i=N; i>=1; i--) {
    nj[i]=nj[i+1]+v[i];
    nz[i]=max(nz[i+1],nj[i]-(C-x[i]));
  }
  ll ans=0;
  for (int i=1; i<=N; i++) {
    ans=max(ans,sz[i]);
    ans=max(ans,sj[i]+nz[i+1]-2*x[i]);
  }
  for (int i=N; i>=1; i--) {
    ans=max(ans,nz[i]);
    ans=max(ans,nj[i]+sz[i-1]-2*(C-x[i]));
  }
  cout<<ans<<endl;
  return 0;
}



Measured memory_bytes: 4992
// J4180449 三宅亮輔
// 問題名
// - Round Robin Scheduling
// 問題URL
// - https://onlinejudge.u-aizu.ac.jp/problems/ALDS1_3_B
// 所要時間
// - 30分
// 学んだこと
//  二分探索のやりかたを学んだ
//  lbを最初1に初期化しておりansが1になるケースで弾かれて悩んだ
//  荷物を積める作業で累積和を二分探索すればさらに計算量を減らせそうだと思った

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

typedef long long ll;
queue<int> q;

int N, Q;
string name[100000];
int t[100000];
int now = 0;

int main() {
    cin >> N >> Q;
    for(int i = 0; i < N; i++) {
        cin >> name[i] >> t[i];
        q.push(i);
    }
    while(!q.empty()) {
        int pi = q.front();
        q.pop();
        if(t[pi] <= Q) {
            now += t[pi];
            cout << name[pi] << " " << now << endl;
        } else {
            now += Q;
            t[pi] -= Q;
            q.push(pi);
        }
    }
}


Measured memory_bytes: 6208
def combs_mod(n,k,mod):
  #nC0からnCkまで
  inv = [1]*(k+1)
  for i in range(1,k+1):
    inv[i] = pow(i,mod-2,mod)
  ans = [1]*(k+1)
  for i in range(1,k+1):
    ans[i] = ans[i-1]*(n+1-i)*inv[i]%mod
  return ans

def solve():
  ans = 0
  mod = 998244353
  N, M, K = map(int, input().split())
  top = min(K,N-1)
  combs = combs_mod(N-1,top,mod)
  for k in range(top+1):
    ans += M*combs[k]*pow(M-1,N-1-k,mod)
    ans %= mod
  return ans
print(solve())

Measured memory_bytes: 24324
#include <iostream>

using namespace std;

int main()
{
    long a, b;
    long i;

    cin >> a >> b;
    if (a < b) {
        int tmp;

        tmp = a;
        a = b;
        b = tmp;
    }
    for (i = 1; i <= b; i++) {
        if (a * i % b == 0) {
            cout << a * i << endl;
            break;
        }
    }
    return 0;
}


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


const int N=1e7+5;
int mark[N];
void seive()
{
   
   for(int i=2;i*i<1e7+5;i++)
   {
       if(!mark[i])
       {
           for(int j=i*i;j<1e7+5;j+=i)
           mark[j]=i;
       }
   }
}
int div(int n)
{
    if(!mark[n])
    return n==1?1:2;   

    map<int,int> keep;
    while(mark[n])
    {
       keep[mark[n]]++;
       n/=mark[n];
    }

    if(n>1)
    keep[n]++;
    int ans=1;
    
    for(auto i:keep){ ans*=(i.second+1);}
    return ans;
}
int32_t main()
{
    seive();
    int x;
    cin>>x;
    int ans=0;
    for(int i=1;i<=x;i++)
    {
        ans+=i*div(i);
        
    }
   
 
    cout<<ans<<endl;
}

Measured memory_bytes: 81736
#!/usr/bin/env python3
import sys


def solve(N: int, A: "List[int]"):

    cost = abs(A[0]) + abs(A[-1])
    for i in range(1,len(A)):
        cost += abs(A[i-1]-A[i])

    for i in range(len(A)):
        cp = A[i]
        pp = 0
        np = 0
        if i>0:
            pp = A[i-1]
        if (i+1) < len(A):
            np = A[i+1]
                   
        if pp <= cp <= np or pp >= cp >= np:
            print(cost)
        elif np <= pp <= cp or cp <= pp <= np:
            print(cost - abs(pp-cp)*2)
        elif cp <= np <= pp or cp >= np >= pp:
            print(cost - abs(np-cp)*2)
        


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [ int(next(tokens)) for _ in range(N) ]  # type: "List[int]"
    solve(N, A)

if __name__ == '__main__':
    main()


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

int main(){
    int a[26] = {};
    char c;
    while(cin >> c){
        c = tolower(c);
        if(isalpha(c)) {
            a[c - 'a'] += 1;
        }
    }
    for(int i = 0 ; i < 26 ; i++){
        char d = i + 'a';
        cout << d << " : " << a[i] << endl;
    }
    return 0;
}


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

int main () {
  int N;
  cin >> N;
  int sum = 0;
  for (int i = 0; i < N ; i++){
    int l_i, r_i;
    cin >> l_i >> r_i;
    sum += r_i - l_i + 1;
  }
  cout << sum << endl;
}
    

Measured memory_bytes: 256
from collections import namedtuple


class UnionFind:
  def __init__(self, n):
    self.par = [i for i in range(n + 1)]
    self.size = [1] * (n + 1)

  def is_same(self, a, b):
    return self.find(a) == self.find(b)

  def unite(self, a, b):
    a = self.find(a)
    b = self.find(b)  
    if self.size[a] < self.size[b]:
      a, b = b, a
    self.par[b] = a
    self.size[a] += self.size[b]

  def size_of(self, a):
    return self.size[self.find(a)]

  def find(self, a):
    if a == self.par[a]:
      return a
    self.par[a] = self.find(self.par[a])
    return self.par[a]

Edge = namedtuple('Edge', 'w s t')
X = namedtuple('X', 'x i')
Y = namedtuple('Y', 'y i')

N = int(input())

edges = []
xg = []
yg = []

for i in range(N):
  x, y = map(int, input().split())
  xg.append(X(x, i))
  yg.append(Y(y, i))

xg.sort()
yg.sort()

for i in range(N - 1):
  x1, a = xg[i]
  x2, b = xg[i + 1]
  edges.append(Edge(abs(x1 - x2), a, b))

for i in range(N - 1):
  y1, a = yg[i]
  y2, b = yg[i + 1]
  edges.append(Edge(abs(y1 - y2), a, b))

edges.sort()

u = UnionFind(N)
cost = 0

for w, s, t in edges:
  if u.is_same(s, t):
    continue
  u.unite(s, t)
  cost += w

print(cost)


Measured memory_bytes: 57400
X = int(input())

A=[]
B=[]

for i in range(120):
    A.append(X+(i)**5)
    B.append(X-(i)**5)

ans1=0
ans2=0

for i in range(120):
    if i**5 in A:
        ans1=i
        ans2=A.index(i**5)
        break
    elif i**5 in B:
        ans1=i
        ans2=-B.index(i**5)
        break

print(ans1,ans2)

Measured memory_bytes: 9204
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define rep(i, n) for(int i = 0; i < n; i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define fi first
#define se second
#define pb push_back
template<class T> inline int chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline int chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = 1<<30;
const ll LINF = 1LL<<58;

ll beki(ll x, ll n, const ll &p) {
    ll ret = 1;
    while (n > 0) {
        if (n & 1) (ret *= x) %= p;
        (x *= x) %= p;
        n >>= 1;
    }
    return ret;
}

void solve() {
    string s;
    cin >> s;
    int cnt[2020] = {0};
    cnt[0] = 1;
    int n = s.size();
    reverse(all(s));
    int sum = 0;
    rep(i, n) {
        sum = (sum + beki(10, i, 2019) * (s[i] - '0')) % 2019;
        cnt[sum]++;
    }
    int ans = 0;
    rep(i, 2019) {
        ans += cnt[i] * (cnt[i] - 1) / 2;
    }
    cout << ans << endl;
    return;
}

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


Measured memory_bytes: 3760
import java.util.*;

public class Main {

	public static void main(String[] args) {

		Scanner scanner = new Scanner(System.in);

		int A = scanner.nextInt();
		int B = scanner.nextInt();

		int tap = 1;
		int emptyTap = A;

		while (emptyTap < B) {
				emptyTap = emptyTap + A - 1;
				tap++;
		}
		
		if(B == 1)
			tap = 0;

		System.out.println(tap);

	}

}


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

int main() {
    int a,b,k;cin>>a>>b>>k;
    int count[100];
    int j = 0;
    repd(i,1,min(a,b)+1){
        if(a%i==0&&b%i==0){
            count[j]=i;
            j++;
        }
    }
    cout<<count[j-k]<<endl;
}

Measured memory_bytes: 256
H, W = map(int, input().split())
c = [[int(i) for i in input().split()] for _ in range(10)]
A = [[int(i) for i in input().split()] for _ in range(H)]

for k in range(10) :
    for i in range(10) :
        for j in range(10) :
            c[i][j] = min(c[i][j], c[i][k] + c[k][j])
            
count = [0] * 10
for i in range(H) :
    for j in range(W) :
        if A[i][j] != -1 :
            count[A[i][j]] += 1
            
ret = 0
for i in range(10) :
    ret += count[i] * c[i][1]
print(ret)

Measured memory_bytes: 40172
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
using namespace std;

#define pb push_back
#define mp make_pair
#define fs first
#define se second
#define pi 2*acos(0)
#define PI 3.14159265358979323846264338

typedef long long ll;
typedef unsigned long long ull;
typedef pair < int , int > pii;
typedef pair < ll , ll > pll;

const int N = 100010;
const int MX = 123456;
const int mod = (int)1e9 + 7;
const int base = 1023456789;
const ull BS1 = 10000019ULL;
const int INF = (1 << 29);

template < class T > inline void fastScan(T &x) {
    register char c = getchar();
    int neg = 0; x = 0;
    for(   ; (c < 48 || c > 57) && (c != '-'); c = getchar());
    if(c == '-') { neg = 1; c = getchar(); }
    for(   ; c > 47 && c < 58; c = getchar()){
        x = (x << 1) + (x << 3) + c - 48;
    }
    if(neg) x = -x;
}

// OrderedSet
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
// template < typename T > using ordered_set = tree < T, null_type, greater < T >, rb_tree_tag, tree_order_statistics_node_update >;

int fx[] = {+1, -1, 0, 0};
int fy[] = {0, 0, +1, -1};

int H, W;

int kunt[1001][1001];

char s[1001][1001];

int isValid(int i, int j){
  if(i < 0 || j < 0) return 0;
  if(i >= H || j >= W) return 0;
  return 1;
}

int main(){
  fastScan(H);
  fastScan(W);
  for(int i = 0; i < H; i++){
    scanf("%s", s[i]);
  }
  queue < pii > Q;
  for(int i = 0; i < H; i++){
    for(int j = 0; j < W; j++){
      if(s[i][j] == '#'){
        kunt[i][j] = 0;
        Q.push(mp(i, j));
      } else {
        kunt[i][j] = 1e9;
      }
    }
  }
  while(!Q.empty()){
    pii u = Q.front();
    Q.pop();
    for(int i = 0; i < 4; i++){
      int ux = fx[i] + u.fs;
      int uy = fy[i] + u.se;
      if(isValid(ux, uy) && kunt[u.fs][u.se] + 1 < kunt[ux][uy]){
        kunt[ux][uy] = kunt[u.fs][u.se] + 1;
        Q.push(mp(ux, uy));
      }
    }
  }
  int ans = 0;
  for(int i = 0; i < H; i++){
    for(int j = 0; j < W; j++){
      if(kunt[i][j] > ans){
        ans = kunt[i][j];
      }
      //cout << kunt[i][j] << " ";
    }
    //cout << '\n';
  }
  printf("%d\n", ans);
}


Measured memory_bytes: 13328
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
typedef  unsigned long long int ull;
typedef pair<ll,ll> P;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
//const ll mod=998244353;
const ll mod=1000000007;
//ios_base::sync_with_stdio(false);
//cin.tie(NULL);
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c/gcd(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
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(){
int n,k;
cin>>n>>k;
V<ll> a(n),d(n);
V<double> tmp(n);
for(int i=0;i<n;i++){
    cin>>a[i];
    d[i]=(a[i]+1)*a[i]/2;
    tmp[i]=(double)d[i]/(double)a[i];
}
int j=0;
double ans=0.0,res=0.0;
while(j<k){res+=tmp[j];j++;}
chmax(ans,res);
for(int i=j;i<n;i++){
    res-=tmp[i-k];res+=tmp[i];
    chmax(ans,res);
}
cout<<ans<<endl;
}

Measured memory_bytes: 5504
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

func abs(a int) int {
	if a >= 0 {
		return a
	}
	return -a
}

func main() {
	sc.Split(bufio.ScanWords)
	N := getInt()
	s, t := getString(), getString()

	for i := 0; i < N; i++ {
		ss := s[i:]
		st := t[:N-i]
		if ss == st {
			out(len(s[:i] + t))
			return
		}
	}
	out(2 * N)
}


Measured memory_bytes: 640
using System;
using System.Collections.Generic;
using System.Linq;


namespace B
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] len = Console.ReadLine().Split(' ');
            List<string> input_str = new List<string>();
            for(int i = 0; i < int.Parse(len[0]); i++)
            {
                input_str.Add(Console.ReadLine());
            }

            input_str.Sort();

            Console.WriteLine(string.Join("",input_str));
        }
    }
}


Measured memory_bytes: 11412
#include <bits/stdc++.h>
#define rep(i,N) for (int i = 0; i < (N); ++i)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main(void){
  int N, D;
  cin >> N >> D;

  int range = 2 * D + 1;
  int ans = (N + range - 1) / range;
  cout << ans << endl;
}


Measured memory_bytes: 3600
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
#[allow(unused_macros)]
macro_rules! p {
    ($($x:expr),*) => {
        $(println!("{:?}", $x);)*
    };
}
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        #[allow(unused_mut)]
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };

    ($iter:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}
#[allow(unused_imports)]
use std::cmp::*;
trait Each: Iterator {
    fn each<F>(self, mut f: F)
    where
        Self: Sized,
        F: FnMut(Self::Item),
    {
        self.fold((), move |(), item| f(item));
    }
}
impl<T: Iterator> Each for T {}

#[derive(Clone, Debug)]
struct SimpleNode<T> {
    value: T,
    child: Vec<usize>,
    connect_root: bool,
}

fn main() {
    input! {
        n:usize1,
        q:usize,
        mut ab: [(usize, usize); n],
        px: [(usize,i32);q],
    }

    let mut tree = vec![
        SimpleNode {
            value: 0,
            child: vec![],
            connect_root: false
        };
        n + 1
    ];
    tree[0].connect_root = true;
    ab.sort_by_key(|x| x.0);
    
    loop {
        let mut ab_ = vec![];
        for &(a, b) in &ab {
            if tree[a - 1].connect_root {
                tree[b - 1].connect_root = true;
                tree[a - 1].child.push(b - 1);
            } else if tree[b - 1].connect_root {
                tree[a - 1].connect_root = true;
                tree[b - 1].child.push(a - 1);
            } else {
                ab_.push((a, b));
            }
        }

        ab = ab_;
        
        if ab.is_empty() {
            break;
        }
        ab.reverse();
    }

    px.iter().each(|&(p, x)| tree[p - 1].value += x);
    f(&mut tree, 0, 0);
    tree.iter().each(|x| print!("{} ", x.value));
}

fn f(tree: &mut [SimpleNode<i32>], i: usize, v: i32) {
    tree[i].value += v;
    let k = tree[i].child.clone();
    let l = tree[i].value.clone();
    k.iter().each(|x| f(tree, *x, l))
}


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


int main() {
    int a, b;
    cin >> a >> b;
    cout << (b*2) - a;
    
    cout << endl;
}


Measured memory_bytes: 256
import itertools as it
import collections as col
import fractions
from functools import reduce

def lcm(x, y):
    return x//fractions.gcd(x, y)*d

a,b,c,d=map(int,input().split())
A=(a-1)-(a-1)//c-(a-1)//d+(a-1)//lcm(c,d)
B=(b)-(b)//c-(b)//d+(b)//lcm(c,d)
print(B-A)


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

int x, y;

int main() {
  while (cin >> x >> y) {
    if(x == 0 && y == 0) break;
    if(x > y){
      cout << y <<  " " << x << endl;
    }else{
      cout << x <<  " " << y << endl;
    }
  }
}

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

int main()
{
    int nItem, index = 0;
    long long bagWeight, baseWeight, tmpWeight, tmpVal;
    cin>>nItem>>bagWeight;
    vector<long long> vArr0(1, 0), vArr1(1, 0), vArr2(1, 0), vArr3(1, 0);
    cin>>baseWeight>>tmpVal;
    vArr0.push_back(tmpVal);
    index ++;
    while(index < nItem)
    {
        cin>>tmpWeight>>tmpVal;
        int tmpIndex = int(tmpWeight - baseWeight);
        if(tmpIndex == 0) vArr0.push_back(tmpVal);
        else if(tmpIndex == 1) vArr1.push_back(tmpVal);
        else if(tmpIndex == 2) vArr2.push_back(tmpVal);
        else if(tmpIndex == 3) vArr3.push_back(tmpVal);
        index ++;
    }
    
    sort(vArr0.begin() + 1, vArr0.end(), greater<long long>());
    sort(vArr1.begin() + 1, vArr1.end(), greater<long long>());
    sort(vArr2.begin() + 1, vArr2.end(), greater<long long>());
    sort(vArr3.begin() + 1, vArr3.end(), greater<long long>());
    
    int len0 = int(vArr0.size()), len1 = int(vArr1.size()), len2 = int(vArr2.size()), len3 = int(vArr3.size());
    
    for(int i = 1; i<len0; i++) vArr0[i] += vArr0[i - 1];
    for(int i = 1; i<len1; i++) vArr1[i] += vArr1[i - 1];
    for(int i = 1; i<len2; i++) vArr2[i] += vArr2[i - 1];
    for(int i = 1; i<len3; i++) vArr3[i] += vArr3[i - 1];
    
    long long maxVal = 0, tmpV0 = 0, tmpV1 = 0, tmpV2 = 0, tmpV3 = 0;
    
    for(int i0 = 0; i0<len0 && (i0 * baseWeight) <= bagWeight; i0++)
    {
        long long tmp0 = i0 * baseWeight;
        tmpV0 = vArr0[i0];
        
        for(int i1 = 0; i1 < len1 && i1<= ((bagWeight - tmp0) >= 0 ? (bagWeight - tmp0): 0)/(baseWeight + 1); i1 ++)
        {
            long long tmp1 = i1 * (baseWeight + 1);
            tmpV1 = vArr1[i1];
            
            for(int i2 = 0; i2< len2 && i2<=((bagWeight - tmp0 - tmp1)>= 0? (bagWeight - tmp0 - tmp1): 0)/(baseWeight + 2); i2++)
            {
                long long tmp2 = i2 * (baseWeight + 2);
                tmpV2 = vArr2[i2];
                
                for(int i3 = 0; i3<len3 && i3<= ((bagWeight - tmp0 - tmp1 - tmp2)>= 0? (bagWeight - tmp0 - tmp1 - tmp2): 0)/(baseWeight + 3); i3++)
                {
                    tmpV3 = vArr3[i3];
                    
                    tmpVal = tmpV0 + tmpV1 + tmpV2 + tmpV3;
                    if(tmpVal > maxVal) maxVal = tmpVal;
                }
            }
        }
    }
    cout<< maxVal<<endl;
    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back
#define INF (1e9+1)
//#define INF (1LL<<59)

int main(){
	string s;
	cin>>s;
	int c=0;
	rep(i,s.size()-1){
		if(s.substr(i,2)=="BW"||s.substr(i,2)=="WB" )c++;
	}
	cout<<c<<endl;
}

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

int main(){
  long long A,B,C,K;
  cin >> A >> B >> C >> K;
  
  long long ans=0;
  if(A>=K) ans = K;
  else{
    K -= A;
    if(B>=K) ans = A;
    else{
      K -= B;
      ans = A - K;
    }
  }
  
  cout << ans << endl;
  return 0;
}


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

int main(){
    int N,X;
    cin >> N >> X;
    vector<int> vec(N);
    for (int i = 0; i<N; i++) cin >> vec.at(i);
    int sum = 0,count = 1;
    for (int i = 0; i<N; i++){
        sum += vec.at(i);
        if (sum > X) break;
        count++;
    }
    cout << count << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <queue>
#include <map>
#include <set>

#define REP(i,k,n) for(int i=k;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define INF 1<<30
#define mp make_pair

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

int main() {
	int n, a, b;
	while(cin >> n >> a >> b) {
		if(n == 0 && a == 0 && b == 0) break;

		vector<int> v(n);
		rep(i, n) cin >> v[i];
		v.push_back(v[n-1]);

		int ans = 0, id = 0;
		REP(i, a, b + 1) {
			if(ans <= v[i-1] - v[i]) {
				ans = v[i-1] - v[i];
				id = i;
			}
		}

		cout << id << endl;
	}
	return 0;
}

Measured memory_bytes: 1216
n=int(input())
if n==1:exit(print(0))
m=10**9+7
total=pow(10,n,m)
total=(total-pow(9,n,m))%m # without zeros
total=(total-pow(9,n,m))%m # without ones
total=(total+pow(8,n,m))%m # without zeros and ones
print(total)

Measured memory_bytes: 9088
#include<bits/stdc++.h>
#define rep(i,l,r) for (int i=l;i<=r;i++)
using namespace std;
const int maxn=100500;
int n,ans;
map<int,int> mp;
int a[maxn],b[maxn];
int main(){
    scanf("%d",&n);
    rep(i,1,n) scanf("%d",&a[i]),b[i]=a[i];
    sort(b+1,b+1+n);
    rep(i,1,n) mp[b[i]]=i;
    rep(i,1,n) {
        int x=i&1;
        int y=mp[a[i]]&1;
        ans+=x^y;
    }
    printf("%d\n",ans/2);
    return 0;
}

Measured memory_bytes: 5760
from sys import stdin


def main():
    input = lambda: stdin.readline()[:-1]
    N = int(input())
    X = list(map(int, input().split()))

    min_ = min(X)
    max_ = max(X)
    ans = float('inf')
    for p in range(min_, max_ + 1):
        n = 0
        for xi in X:
            n += (xi - p) ** 2
        ans = min(ans, n)
    print(ans)


main()


Measured memory_bytes: 3060