akhauriyash/Code-Regression huggingface dataset:
import collections
import sys
import math
sys.setrecursionlimit(10 ** 7)
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def LIST()  : return list(MAP())
def NIJIGEN(H): return [list(input()) for i in range(H)]
H,W,M=map(int,input().split())
A=list()
B=list()
for i in range(M):
  a,b=map(int,input().split())
  A.append(a)
  B.append(b)
c = collections.Counter(A)
s=c.most_common()
k=s[0][0]
t=s[0][1]
L=list()
for i in range(M):
  if A[i]!=k:
    L.append(B[i])
c = collections.Counter(L)
s=c.most_common()
if len(s)!=0:
  ans=s[0][1]+t
else:
  ans=t
c = collections.Counter(B)
s=c.most_common()
k=s[0][0]
t=s[0][1]
L=list()
for i in range(M):
  if B[i]!=k:
    L.append(A[i])
c = collections.Counter(L)
s=c.most_common()
if len(s)!=0:
  q=s[0][1]+t
else:
  q=t
ans=max(ans,q)
print(ans)

Measured memory_bytes: 106696
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

template <typename TYPE>
void print_vec(const vector<TYPE>& v){
	for(int i=0; i<v.size(); i++){
		cout << v[i] << " ";
	}
	cout << endl;
}

template <typename TYPE>
void print_vec2(const vector<vector<TYPE>>& v){
  cout << endl;
  for(int i=0; i<v[0].size(); i++) cout << i << "   "; 
  cout << endl;
	for(int i=0; i<v.size(); i++){
		cout << "i=" << i << ":   " << endl;
		for(int j=0; j<v[i].size(); j++){
			if(v[i][j] == 0) cout << "\x1B[0m" << v[i][j] << "   ";
      else cout << "\x1B[31m" << v[i][j] << "   ";//https://stackoverrun.com/ja/q/12618775
		}
		cout << "\x1B[0m" << endl;
	}
}
 
int main(){
	int N, X, Y;
	cin >> N >> X >> Y;
	X--; Y--;

	//ダイクストラ法で解いてみる
	typedef pair<int, int> P;
	//vec[i]: ノードiと隣接してるノードと辺のコストの列
	vector<vector<P>> vec(N, vector<P>());
	
	for(int i=0; i<N-1; i++){
		vec[i].push_back(P(i+1, 1));//今回のコストはすべて1
		vec[i+1].push_back(P(i, 1));
	}
	vec[X].push_back(P(Y, 1));
	vec[Y].push_back(P(X, 1));
	vector<ll> ans(N+1, 0);//ans[k]:手数kかかる組み合わせ
	const ll MAX = 1001001001;
	for(int s=0; s<N; s++){
		vector<ll> cost(N, MAX);//ノードsからの最小手数
		queue<P> q;// first:注目ノード, second:注目ノードの親
		q.push(P(s, -1));
		cost[s] = 0;
		while(!q.empty()){
			int node = q.front().first;
			int parent = q.front().second;
			q.pop();
			for(int j=0; j<vec[node].size(); j++){
				int child = vec[node][j].first;
				int yen = vec[node][j].second;
				//if(child == parent) continue;
				if(cost[child] <= cost[node]+yen) continue;
				cost[child] = cost[node]+yen;
				q.push(P(child, node));
			}
		}
		for(int i=0; i<cost.size(); i++){
			ans[cost[i]]++;
		}

	}
	for(int i=1; i<=N-1; i++){
		cout << ans[i]/2 << endl;
	}

	// //BFS解法
	// //vec[i]: ノードiと隣接してるノードの列
	// vector<vector<ll>> vec(N, vector<ll>());
	// for(int i=0; i<N-1; i++){
	// 	vec[i].push_back(i+1);
	// 	vec[i+1].push_back(i);
	// }
	// vec[X].push_back(Y);
	// vec[Y].push_back(X);
	// //cout << " vec:" << endl; print_vec2(vec);
	// vector<ll> ans(N+1, 0);//ans[k]:手数kかかる組み合わせ
	// typedef pair<int, int> P;
	// for(int s=0; s<N; s++){
	// 	vector<ll> cost(N, -1);//ノードsからの最小手数
	// 	queue<P> q;// first:注目ノード, second:注目ノードの親
	// 	q.push(P(s, -1));
	// 	cost[s] = 0;
	// 	while(!q.empty()){
	// 		int node = q.front().first;
	// 		int parent = q.front().second;
	// 		q.pop();
	// 		for(int j=0; j<vec[node].size(); j++){
	// 			int child = vec[node][j];
	// 			//if(child == parent) continue;//
	// 			if(cost[child] != -1) continue;//
	// 			cost[child] = cost[node] + 1;
	// 			q.push(P(child, node));
	// 		}
	// 		//if(s==0){cout << " cost: "; print_vec(cost);}
	// 	}

	// 	for(int i=0; i<cost.size(); i++){
	// 		ans[cost[i]]++;
	// 	}

	// }
	// for(int i=1; i<=N-1; i++){
	// 	cout << ans[i]/2 << endl;
	// }




	//数学的な解法 //解説PDFの解法
	// vector<ll> ans(N+1, 0);//cnt[k]:歩数kかかる組み合わせ
	// for(int s=0; s<=N-2; s++){
	// 	for(int g=s+1; g<=N-1; g++){
	// 		ll steps1 = g - s;//XYの道を使わない歩数
	// 		ll steps2 = abs(s-X) + 1 + abs(Y-g); //XYの道を使う歩数
	// 		ll mn = (steps1 < steps2) ? steps1 : steps2;
	// 		ans[mn]++;
	// 	}
	// }

	// for(int i=1; i<=N-1; i++){
	// 	cout << ans[i] << endl;
	// }

}


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

int cost[10][10];
int grid[200][200];

int main(){
	int H,W;	cin>>H>>W;
	for(int i=0;i<10;i++){
		for(int j=0;j<10;j++){
			cin>>cost[i][j];
		}
	}
	for(int i=0;i<H;i++){
		for(int j=0;j<W;j++){
			cin>>grid[i][j];
		}
	}

	for(int k=0;k<10;k++){
		for(int i=0;i<10;i++){
			for(int j=0;j<10;j++){
				cost[i][j]=min(cost[i][j], cost[i][k]+cost[k][j]);
			}
		}
	}

	long long ans=0;
	for(int i=0;i<H;i++){
		for(int j=0;j<W;j++){
			if(grid[i][j]==-1)continue;

			ans+=cost[grid[i][j]][1];
		}
	}
	cout<<ans<<endl;


	return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h> 
using namespace std;
#define rep(i, N) for(int i=0; i<N; i++)
typedef long long ll;
#define dump(x) cerr<<#x<<"="<<x<<endl
using P = pair<int, int>;

int main() {
    int n; cin >> n;
    vector<string> s(n);
    rep(i, n){
        cin >> s.at(i);
    }

    if(n==1){
        sort(s.at(0).begin(), s.at(0).end());
        cout << s.at(0) << endl;
        return 0;
    }

    string v = "";
    for(int i=0; i<s.at(0).size(); i++){
        bool ok = false;
        for(int j=1; j<n; j++){
            bool notok = false;
            for(int k=0; k<s.at(j).size(); k++){
                if(s.at(0).at(i)==s.at(j).at(k)) {
                    s.at(j).at(k) = '!'; 
                    break;
                }

                if(k==s.at(j).size()-1){
                   notok = true; 
                }
            }
            if(notok) break;

            if(j==n-1){
                ok = true;
            }
        }
        if(ok){
            v.push_back(s.at(0).at(i));
        }
    }

    if(v.size()!=0) {
        sort(v.begin(), v.end());
        cout << v << endl;
    }
    else cout << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <string>
#include <bitset>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define fin(ans) cout<<(ans)<<endl
#define STI(s) atoi(s.c_str())
#define mp(p,q) make_pair(p,q)
#define pb(n) push_back(n)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define Sort(a) sort(a.begin(),a.end())
#define Rort(a) sort(a.rbegin(),a.rend())
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;}
const int P = 1000000007;
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;



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

    int n;
    string s;
    cin>>n>>s;
    if(n<3200)fin("red");
    else fin(s);

//////////////////////////////////////////////////////
return 0;}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <utility>
#include <stack>
#include <vector>
#include <queue>
#include <algorithm>
#include <map>
#include <climits>
#include <set>
#include <cmath>
#include <cfloat>
#include <numeric>
#include <iomanip>

using namespace std;
long long A[100000];
pair <long long, int> CB[100000];
int main(){
    int N;
    int M;
    cin >> N >> M;
    for(int i = 0; i < N; i++){
        cin >> A[i];
    }
    sort(A, A + N);
    reverse(A, A + N);

    for(int i = 0; i < M; i++){
        cin >> CB[i].second >> CB[i].first;
    }
    sort(CB, CB + M);
    reverse(CB, CB + M);

    long long ans = 0;
    int a_ind = 0;
    int cb_ind = 0;
    for(int i = 0; i < N; i++){
        if(a_ind < N && cb_ind < M){
            if(A[a_ind] > CB[cb_ind].first){
                ans += A[a_ind];
                a_ind ++;
            } else {
                ans += CB[cb_ind].first;
                if(CB[cb_ind].second == 1){
                    cb_ind ++;
                } else {
                    CB[cb_ind].second --;
                }
            }
        } else if(a_ind < N){
            ans += A[a_ind];
            a_ind ++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 2688
import sys
input = lambda: sys.stdin.readline().rstrip()

N, K = map(int, input().split())

s = [0] * N

for i in range(K):
    d = int(input())
    A = list(map(int, input().split()))

    for num in A:
        s[num-1] += 1
print(s.count(0))

Measured memory_bytes: 67064
#include <cstdio>
#include <iostream>
#include <algorithm>
using namespace std;
const int MAX_N = 100000;
long long n,m;
long long maxm, minm;
pair<long long, long long> red[MAX_N], blue[MAX_N];
long long a[MAX_N], b[MAX_N], c[MAX_N], d[MAX_N], t[MAX_N];
long long solve(){
    sort(t, t+m);
    for(int i=0 ; i<m-1 ; i++){
        a[i] = t[i+1] - t[i];
    }
    sort(a, a+m-1);
    reverse(a, a+m-1);
    long long D = maxm - minm;
    for(int i=0 ; i<n-1 ; i++){
        D -= a[i];
    }
    return D;
}
int main(){
    cin >> n >> m >> t[0];
    maxm = minm = t[0];
    for(int i=1 ; i<m ; i++){
        cin >> t[i];
        maxm = max(maxm, t[i]);
        minm = min(minm, t[i]);
    }
    if(n >= m){
        cout << 0 <<endl;
    }else{
    cout << solve() << endl;
    }
    return 0;
}

Measured memory_bytes: 3072
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<cctype>
#include<climits>
#include<string>
#include<bitset>
#include<cfloat>
#include<iomanip>
#include<numeric>

//#define int long long
#define repi(i,start,end) for(int (i)=(start),TemPNuM=(int)(end);(i)<TemPNuM;++(i))
#define rep(i,end) repi((i),0,(end))
#define rfor(x,v) for(auto& (x) : (v))
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define fsort(v,lambda) sort(all((v)),(lambda))
#define vin(v) rep(i,(v).size())cin >> (v)[i];
#define vpin(v) rep(i,(v).size())cin>>v[i].first>>v[i].second

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

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; }
template<class T>void put_double(T a){if(cout.precision()!=12)cout<<setprecision(12);cout<<a<<endl;}
template<class T>void print(T a){cout << a << endl;}
//lambda: [](int x, int y){return x<y;}

bool is_prime(int n) {
    if(n < 2) return false;
    for(int i = 2; i * i <= n; ++i) {
        if(n % i == 0) {
            return false;
        }
    }
    return true;
}

signed main(void) {
    int q; cin >> q;
    vpint lr(q); vpin(lr);
    vint primes;
    repi(n, 3, 1e5 + 1) {
        if(is_prime(n)) primes.push_back(n);
    }
    vint similar(1e5 + 1, 0);
    rfor(x, primes) {
        int mid = (x + 1) / 2;
        if(is_prime(mid)) similar[x] = 1;
    }

    //rfor(x, similar) cout << x << " ";
    //print("");
    vint sum(1e5 + 1, 0);
    rep(i, 1e5) {
        sum[i + 1] = sum[i];
        if(similar[i + 1] == 1) sum[i + 1]++;
    }
    rfor(p, lr) {
        int l = p.first, r = p.second;
        print(sum[r] - sum[l - 1]);
    }




    return 0;
}


Measured memory_bytes: 2304
<?php
$res = 0;

fscanf (STDIN, "%d %d", $H , $W);
// $c = [];
for ($i = 0; $i < 10; $i++) {
    $c[$i] = array_map('intval', explode(' ', trim(fgets(STDIN))));
}
for ($k = 0; $k < 10; $k++) {
    for ($i = 0; $i < 10; $i++) {
        for ($j = 0; $j < 10; $j++) {
            if ($c[$i][$j] > $c[$i][$k]+ $c[$k][$j]) $c[$i][$j] = $c[$i][$k]+ $c[$k][$j];
        }
    }
}
for ($i = 0; $i < $H; $i++) {
    $x = array_map('intval', explode(' ', trim(fgets(STDIN))));
    foreach ($x as $A) {
        if ($A >= 0) $res += $c[$A][1];
    }
}
printf ("%d", $res);


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

using std::cin;
using std::cout;
using std::endl;

using std::string;
using std::pair;

using std::vector;
using std::sort;
using std::lower_bound;
using std::upper_bound;
using std::find_if;
using std::copy;
using std::copy_if;

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

    if(a==b){
        cout << c << endl;
    }
    else if(a==c){
        cout << b << endl;
    }
    else{
        cout << a << endl;
    }
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const long long LINF = 1e18;
const long long MOD = 1e9 + 7;

signed main(){
    int x;
    cin >> x;
    if(x >= 2000){
        cout << 1 << endl;
        return 0;
    }
    for(int i = 1; i <= 19; i++){
        if(i * 100 <= x && x <= i * 100 + i * 5){
            cout << 1 << endl;
            return 0;
        }
    }
    cout << 0 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
using vi = vector<int>;
using vii = vector<vi>;

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

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

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

	ll ans = 0;
	rep(i, 1, n) ans += i;

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main()
{
	int	H, W;
	
	while(1){
		scanf("%d %d", &H, &W);
		if(H == 0 && W == 0)break;
		int i, j;
		for(i = 0; i < H; ++i){
			for(j = 0; j < W; ++j){
				if((j + i) % 2 == 0){
					printf("#");
				}else{
					printf(".");
				}
				
			}
			printf("\n");
		}
		printf("\n");
	}
	
	return 0;
}

Measured memory_bytes: 572
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define mp make_pair
#define si(x) int(x.size())
const int mod=1000000007,MAX=1000005,INF=1<<30;

ll gcd(ll a,ll b){
    if(b==0) return a;
    return gcd(b,a%b);
}

int cnt[MAX];

vector<int> prime;//i番目の素数
bool is_prime[MAX+1];

void sieve(int n){
    for(int i=0;i<=n;i++){
        is_prime[i]=true;
    }
    
    is_prime[0]=is_prime[1]=false;
    
    for(int i=2;i<=n;i++){
        if(is_prime[i]){
            prime.push_back(i);
            for(int j=2*i;j<=n;j+=i){
                is_prime[j] = false;
            }
        }
    }
}

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    sieve(MAX-2);
    
    int N;cin>>N;
    vector<int> A(N);
    for(int i=0;i<N;i++){
        cin>>A[i];
        cnt[A[i]]++;
    }
    
    bool check=true;
    
    for(int p:prime){
        int sum=0;
        for(int i=p;i<MAX;i+=p){
            sum+=cnt[i];
            if(sum>=2) break;
        }
        if(sum>=2) check=false;
        
        if(!check) break;
    }
    
    if(check){
        cout<<"pairwise coprime"<<endl;
    }else{
        int g=0;
        for(int i=0;i<N;i++){
            g=gcd(g,A[i]);
        }
        
        if(g==1) cout<<"setwise coprime"<<endl;
        else cout<<"not coprime"<<endl;
    }
}




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

using namespace std;

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

int main() {
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	int s1 = a * b, s2 = c * d;
	if (s1 > s2) {
		cout << s1 << endl;
	} else {
		cout << s2 << endl;
	}
	
	return 0;	
}

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

#define N 500500

int n, m, fac[N], rfac[N], ri[N];
const int mod = 998244353;

inline int C(int n, int m) {
    if (n < m) return 0;
    return 1ll * rfac[m] * rfac[n-m] % mod * fac[n] % mod;
}

int powmod(int x, int n) {
    int rlt = 1;
    while (n) {
        if (n & 1) rlt = 1ll * rlt * x % mod;
        x = 1ll * x * x % mod, n >>= 1;
    }
    return rlt;
}

int main() {
    fac[0] = rfac[0] = ri[1] = 1;
    for (int i = 1; i < N; i ++) {
        fac[i] = 1ll * i * fac[i-1] % mod;
        if (i > 1) ri[i] = 1ll * (mod - mod / i) * ri[mod%i] % mod;
        rfac[i] = 1ll * ri[i] * rfac[i-1] % mod;
    }
    scanf("%d %d", &n, &m);
    int rlt = 0;
    for (int k = 0, pn = powmod(n + 1, m), pm = powmod(m + 1, n), sg = 1; k <= min(n, m); k ++) {
        rlt = (rlt + 1ll * C(n, k) * C(m, k) % mod * pn % mod * pm % mod * sg * fac[k]) % mod;
        sg *= -1, pn = 1ll * pn * ri[n+1] % mod, pm = 1ll * pm * ri[m+1] % mod;
    }
    if (rlt < 0) rlt += mod;
    printf("%d\n", rlt);

    return 0;
}


Measured memory_bytes: 6144
N_M = [int(x.strip()) for x in input().split()]
price_l = [[int(i) for i in input().split()] for i in range(0, N_M[0])]
price_l.sort(key=lambda x: x[0])
total = 0
remain = N_M[1]
while remain > 0:
    if len(price_l)<1:
        break
    price_n = price_l.pop(0)
    total += price_n[0] * min(price_n[1], remain)
    remain -= min(price_n[1], remain)
print(total)

Measured memory_bytes: 22760
#include <bits/stdc++.h>
#define REP(i, a, n) for (int i = (a); i < (int)(n); ++i)
#define REPC(i, a, n) for (int i = (a); i <= (int)(n); ++i)
#define ALL(t) t.begin(), t.end()
#define RALL(t) t.rbegin(), t.rend()
#define MATINIT(type, row, col, init) \
  vector<vector<type>>(row, vector<type>(col, init));
#define Yes(cond) cout << (cond ? "Yes" : "No") << endl;
#define YES(cond) cout << (cond ? "YES" : "NO") << endl;
using namespace std;
using LL = long long;
using ULL = unsigned long long;
template <class T>
using VEC = std::vector<T>;
template <class T>
using MAT = std::vector<std::vector<T>>;
void DUMP() { cerr << endl; }
template <class Head, class... Tail>
void DUMP(Head &&head, Tail &&... tail) {
  cerr << head << ", ";
  DUMP(std::move(tail)...);
}
template <typename T>
ostream &operator<<(ostream &os, vector<T> &vec) {
  os << "{";
  for (auto v : vec) os << v << ",";
  os << "}";
  return os;
}
template <typename T>
ostream &operator<<(ostream &os, set<T> &s) {
  os << "{";
  for (auto p : s) os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, map<T1, T2> &m) {
  os << "{";
  for (auto p : m) os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, pair<T1, T2> p) {
  os << "[" << p.first << " " << p.second << "]";
  return os;
}

int main() {
  int a,b,c;
  cin>>a>>b>>c;
  if(a==b && b==c &&c==a){
    cout<<"Yes";
  }else cout<<"No";

  return 0;
}


Measured memory_bytes: 256
import collections
import itertools
import numpy as np
import sys
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

s = S()
l = [i for i in s]
A = l[1:]

ans = 0
for i in range(1 << len(A)):
	for j in range(len(A)):
		if ((i >> j) & 1) == 1:
			if f == 1:
				continue
			f = 1
		else:
			f = 0
	else:
		s = l[0]
		for j in range(len(A)):
			if ((i >> j) & 1) == 1:
				ans += int(s)
				s = A[j]
			else:
				s += A[j]
		else:
			ans += int(s)

print(ans)

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

using namespace std;

int main(void)
{
	string s, t;
	string s_, t_;
	cin >> s;
	cin >> t;

	int s_i[26], t_i[26];

	for(int i=0;i<26;i++)
	{
		s_i[i] = 0;
		t_i[i] = 0;
	}

	for(int i=0;i<s.size();i++)
	{
		s_i[s[i] - 'a']++;
	}

	for(int i=0;i<t.size();i++)
	{
		t_i[t[i] - 'a']++;
	}

	for(int i=0;i<26;i++)
	{
		while(s_i[i] > 0)
		{
			s_.push_back('a' + i);
			s_i[i]--;
		}

		while(t_i[25 - i] > 0)
		{
			t_.push_back('a' + (25 - i));
			t_i[25 - i]--;
		}
	}

	for(int i=0;i<min(s.size(), t.size());i++)
	{
		if(s_[i] > t_[i])
		{
			cout << "No" << endl;
			return 0;
		}
		else if(s_[i] < t_[i]){
			cout << "Yes" << endl;			
			return 0;
		}
	}

	if(s.size() >= t.size())
		cout << "No" << endl;
	else
		cout << "Yes" << endl;			

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <sstream>
#include <utility>
#define ll long long int
#define rep(i,x,y) for(int i=x;i<y;i++)
#define rel(i,x,y) for(int i=x-1;i>=y;i--)
#define all(x) x.begin(),x.end()

using namespace std;
int cnt=0;

void dfs(ll a,ll n,bool thr,bool fiv,bool seven){
	if(a>n) return;
	ll tmpa = a;
	if(thr && fiv && seven) cnt++;
	dfs(a*10+3,n,true,fiv,seven);
	dfs(a*10+5,n,thr,true,seven);
	dfs(a*10+7,n,thr,fiv,true);
}

int main(){
	ll n;
	cin >> n;
	dfs(0,n,false,false,false);
	cout << cnt << endl;
}


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

int main()
{
    int s;
    cin >> s;

    vector<int> numCnt(100100, 0);
    numCnt[s]++;
    int a = s;
    int ans = 1;
    while (1)
    {
        ++ans;
        if (a % 2)
        {
            a = 3 * a + 1;
            numCnt[a]++;
        }
        else
        {
            a /= 2;
            numCnt[a]++;
        }

        if (numCnt[a] >= 2)
        {
            cout << ans << endl;
            return 0;
        }
    }

    return 0;
}

Measured memory_bytes: 3720
import sys
input = sys.stdin.readline
from collections import defaultdict


def read():
    N, X, M = map(int, input().strip().split())
    return N, X, M


def solve(N, X, M):
    S = [-1 for i in range(M)]
    A = [0 for i in range(M+2)]
    na = X
    # i=1の時にA1=Xとなることを記録
    i = 1
    S[na] = i
    A[i] = X
    for i in range(2, min(N+1, M+1)):
        # i=kの時にAk=a*a%Mとなることを記録
        A[i] = A[i-1] * A[i-1] % M
        a = A[i-1]
        na = A[i]

        if S[na] == -1:
            S[na] = i
        else:
            # 再出現したとき、周期[S[na], S[a]]となる
            period_start = S[na]
            period_end = S[a]
            period_length = S[a] - S[na] + 1
            # 何周するかと、余りを求める
            n_loop, left = divmod(N - S[na] + 1, period_length)
            # 一周当たりの加算
            loop_sum = sum(A[S[na]:i])
            left_sum = sum(A[S[na]:S[na]+left])
            ans = sum(A[:S[na]]) + n_loop * loop_sum + left_sum
            return ans
        if na == 0:
            break
    return sum(A)


if __name__ == '__main__':
    inputs = read()
    outputs = solve(*inputs)
    if outputs is not None:
        print("%s" % str(outputs))


Measured memory_bytes: 14316
import Data.List
import Data.Maybe

main = interact $ show . sol . read

sol :: Int -> Int
sol n = sum . sig n $ takeWhile (\p -> p*p <= n) primes
  where
  f n = floor $ sqrt (2*fromIntegral n+0.25)-0.5
  sig 1  _ = []
  sig _ [] = [1]
  sig n (p:ps) 
    | e > 0     = f e:sig (n `div` p^e) ps
    | otherwise = sig n ps 
    where
    e = pred . fromJust $ find ((>0) . mod n . (p^)) [1..]

primes = sm++lg
  where
  1:p:cs = f $ foldl g (1,[1]) sm
  sm = [2,3,5,7]
  lg = p:filter pr cs
  pr n = all ((>0) . (n `mod`)) $ takeWhile (\p -> p*p <= n) lg
  f (n,rs) = [n*k+r | k <- [0..], r <- rs]
  g (n,rs) p = (p*n,[r2 | k <- [0..(p-1)], r <- rs, let r2 = n*k+r, r2 `mod` p>0])

Measured memory_bytes: 22164
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class T>
using Table = vector<vector<T>>;
const ld eps=1e-9;

//// < "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\a.txt" > "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\b.answer"
int main() {
	while (1) {
		string st; cin >> st;
		if (st == "0")break;
		int a = 0, b = 0;
		for (int i = 1; i < st.size(); ++i) {
			if (st[i] == 'A') {
				a++;
			}
			else {
				b++;
			}
		}
		if (a > b)a++;
		else b++;
		cout << a << " " << b << endl;
	}
	return 0;
}

Measured memory_bytes: 3120
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ALDS1_10_C
{
    public class Program

    {
        public static void Main(string[] args)
        {
            int n = ReadInt();
            for (int i = 0 ; i < n ; i++)
            {
                string str1 = ReadSt();
                string str2 = ReadSt();

                Console.WriteLine(GetLCSLength(str1, str2).ToString());

            }
        }

        private static int GetLCSLength(string str1, string str2)
        {

            int n = str1.Length;
            int m = str2.Length;

            int[,] dp = new int[n + 1, m + 1];

            for (int i = 0 ; i < n ; i++)
            {
                for (int j = 0 ; j < m ; j++)
                {
                    dp[i + 1, j + 1] = (str1[i] == str2[j]) ? dp[i, j] + 1 : Math.Max(dp[i, j + 1], dp[i + 1, j]);
                }
            }
            return dp[n, m];
        }

        static string ReadSt() { return Console.ReadLine(); }
        static int ReadInt() { return int.Parse(Console.ReadLine()); }
        static long ReadLong() { return long.Parse(Console.ReadLine()); }
        static double ReadDouble() { return double.Parse(Console.ReadLine()); }
        static string[] ReadStAr(char sep = ' ') { return Console.ReadLine().Split(sep); }
        static int[] ReadIntAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Split(sep), e => int.Parse(e)); }
        static long[] ReadLongAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Split(sep), e => long.Parse(e)); }
        static double[] ReadDoubleAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Split(sep), e => double.Parse(e)); }

    }

}



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

int main() {
    int A, B, C;
    cin >> A >> B >> C;

    if (A%2 or B%2 or C%2) {
        cout << 0 << endl;
        return 0;
    }

    if (A == B and B == C) {
        cout << -1 << endl;
        return 0;
    }

    ll ans = 0;
    for (int i=0; i<1000000; ++i) {
        int na = B/2+C/2;
        int nb = A/2+C/2;
        int nc = B/2+A/2;
        A = na, B = nb, C = nc;
        ans++;
        if (na%2 or nb%2 or nc%2) {
            cout << ans << endl;
            return 0;
        }
    }

    cout << -1 << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#ifndef d
#define d(...)
#endif
#define st first
#define nd second
#define pb push_back
#define siz(c) (int)(c).size()
#define all(c) (c).begin(), (c).end()
typedef long long LL;
typedef long double LD;
constexpr int INF=1e9+7;
constexpr LL INFL=1e18;
template<class L, class R> ostream &operator<<(ostream &os, pair<L,R> P) {
  return os << "(" << P.st << "," << P.nd << ")";
}
/*
#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, less<T>, rb_tree_tag,
         tree_order_statistics_node_update>;
*/



int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	
	int n;
	cin >> n;
	vector<int> A(n);
	for(auto& x:A) {
		cin >> x;
		x--;
	}
	
	auto nope = []() {
		cout << "-1\n";
		exit(0);
	};
	
	vector<int> ans;
	for(int i=0; i<n; i++) {
		int found = -1;
		for(size_t j=0; j<A.size(); j++)
			if(A[j] == j) found = j;
		if(found == -1) nope();
		ans.push_back(found);
		A.erase(A.begin() + found);
	}
	
	reverse(all(ans));
	for(auto a:ans)
		cout << a+1 << "\n";
	
	





	return 0;
}


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



int main() {
  int n,m;
  cin>>n>>m;
  int h[n];
  for(int i=0;i<n;i++){
    cin>>h[i];
  }
  bool memo[n];
  for(int i=0;i<n;i++) memo[i]=true;
  for(int i=0;i<m;i++){
    int a,b;
    cin>>a>>b;
    a--;
    b--;
    if(h[a]>h[b]) memo[b]=false;
    else if(h[b]>h[a]) memo[a]=false;
    else {
      memo[a]=false;
      memo[b]=false;
    }
  }
  int ans=0;
  for(int i=0;i<n;i++){
    if(memo[i]) ans++;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 4124
import sys
sys.setrecursionlimit(10 ** 7)
S = input()

answer = 0
left = 0
right = len(S) - 1
while left < right:
    if S[left] == S[right]:
        left += 1
        right -= 1
    elif S[left] == 'x':
        left += 1
        answer += 1
    elif S[right] == 'x':
        right -= 1
        answer += 1
    else:
        print(-1)
        exit()
print(answer)

Measured memory_bytes: 3316
#include<bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
//long long int countt[200003];
#include<ext/pb_ds/assoc_container.hpp> // include the associative containers or group of templates such as set, multimap, map etc.
#include<ext/pb_ds/tree_policy.hpp> // include the tree_order_statistics_node update
using namespace __gnu_pbds; //necessary for the GNU based Policy based data structures.
typedef tree<pair<int,int> ,null_type,less<pair<int,int>>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
 
#define int long long
#define endl "\n"
 
 
 
signed main()
{
    FAST;
    int t;
    t=1;
    while(t--)
    {
        int i=0,j=0,k=0,n=0,m=0,count=0,temp=0;
        int temp1=0,temp2=0,temp3=0,x=0,l=0,y=0,sum=0;
        int left=0,up=0,down=0,start=0,end=0,r=0,q=0,total=0;
        int maxx=0,minn=0,curr=0,ans=0,places=0,zeroes=0,low=0,high=0;
        int prev=0,mid=0,z=0,d=0,val=0,pos=0,shift=0,h=0,right=0,var=0;
        
        int a;
        cin>>a;
        
        cout<<a + pow(a,2) + pow(a,3)<<endl;
    
    
        
    }
        
    
    
    
    
}

Measured memory_bytes: 4240
#include <iostream>
#include <cstdlib>
#include <string>
#include <vector>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <math.h>
#include <stdio.h>
#include <ctype.h>
#include <ios> 
#include <iomanip>
#include <cstdint>
#include <cstring>
using namespace std;

#define N_MAX   (100000)
#define LL_MAX_NUM (1LL<<60)
#define INF 1e7

typedef long long ll;
typedef long long int lli;

int main() {
    int N; cin >> N;
    int T[N], Tcp[N];
    
    for (int i = 0; i < N; i++) { cin >> T[i]; }
    int M; cin >> M;
    int PX[M][2];
    for (int i = 0; i < M; i++)
    {
        for (int j = 0; j < 2; j++)
        {
            cin >> PX[i][j];
        }
    }
    for (int i = 0; i < M; i++)
    {
       memcpy(&Tcp, &T, sizeof(int) * N);
       Tcp[PX[i][0]-1] = PX[i][1];
       int res = 0;
       for (int j = 0; j < N; j++)
       {
           res += Tcp[j];
       }
       cout << res << endl;
    }
	return 0;
}

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

int main(){
	string s;
	cin >> s;
	int ans = 0;
	for(int i = 0; i < 6; i++){
		ans += s[i] - '0';
	}
	cout << ans << endl;
	return 0;
}

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

int main(){
    ll X;
    cin >> X;
    while(1){
        ll flag = 0;
        for(int i = 2; i < X; i++){
            if(X % i == 0){
                flag = 1;
            }
        }
        if(flag == 0){
            cout << X << endl;
            return 0;
        }
        X++;
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <cmath>
#include <queue>
#include <numeric>
#include <climits>
#include <iterator>
#include <iomanip>
#include <stack>
#include <set>
#include <cstdio>
#include <bitset>
#include <functional>
#include <tuple>
#include <list>
#include <deque>
using namespace std;
typedef pair<int, int> P;

#define FOR(i, a, n) for (ll i = (ll)a; i<(ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)

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

int N, W;
int dp[110][100010];
int v[110], w[110];
int main() {
    cin.tie(0);
   	ios::sync_with_stdio(false);
    cin >> N >> W;
    REP(i, N) cin >> v[i] >> w[i]; 
    
    for(int i=0; i<N; ++i){
        for(int j=0; j<=W; ++j){
            if(j-w[i]>=0) dp[i][j] = max(dp[i][j], dp[i][j-w[i]] + v[i]);
            dp[i+1][j] = max(dp[i+1][j], dp[i][j]);
        }
    }
    int maxV=0;
    for(int i=0; i<N; ++i){
        maxV = max(maxV, dp[i][W]);
    }
    cout << maxV << endl;
	return 0;
}


Measured memory_bytes: 7496
#include <bits/stdc++.h>
using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod= int(1e9)+7;
//const int mod=998244353;
using P = pair<int,int>;
using Pl= pair<ll,ll>;
using ld=long double;
using V=vector<int>;
using Vl=vector<ll>;
using VV=vector<vector<int>>;
using VVl=vector<vector<ll>>;

int main(){
    ll n,m,x,s=0;
    cin >>n>>x>>m;
    vector<Pl>memo(m);
    for (ll i=0; i <n; ++i) {
        if(memo[x].first){//衝突したら
            auto t=i-memo[x].first,c=(n-1-i)/t;
            //t 周期　c 何回そのループできるか
            i+=t*c;
            s+=(s-memo[x].second)*c;
        }
        else {
            memo[x]={i,s};
        }
        s+=x;
        x*=x;x%=m;
    }
    cout <<s<<endl;
}

Measured memory_bytes: 4836
#include<stdio.h>

int main(void){
	double x=0,y=0;
	double a=0,b=0,c=0,d=0,e=0,f=0;
    
    while(scanf("%lf %lf %lf %lf %lf %lf",&a,&b,&c,&d,&e,&f) != EOF)
	{
		y = ( c * d - a * f ) / ( b * d - e * a );

        x = ( c - ( b * y ) ) / a;

		printf("%.3lf %.3lf\n",x,y);
	}
  return 0;
}

Measured memory_bytes: 1080
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define FORR(i,a,b) for (int i=(a);i>=(b);i--)
#define pb push_back
#define pcnt __builtin_popcount
#define show(x) cout<<#x<<" = "<<x<<endl;
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define fi first
#define se second
#define rng(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define sz(x) (int)(x).size()
#define mp make_pair

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef set<int> si;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pll> vpll;
typedef set<ll> sl;
typedef __int128_t lll;
typedef pair<lll,lll> plll;
typedef vector<lll> vlll;
template<typename T>string join(vector<T>&v)
{stringstream s;FOR(i,0,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename A, size_t N, typename T>void Fill(A (&array)[N], const T&v)
{fill((T*)array,(T*)(array+N),v);}
lll gcd(lll a,lll b,lll &x,lll &y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll gcd(ll a,ll b){lll x=0,y=0; return gcd(a, b, x, y);}
ll modpow(lll a,lll n,ll m){if(a==0)return a;lll p=1;for(;n>0;n/=2,a=a*a%m)if(n&1)p=p*a%m;return(ll)p;}
void dout(double d){printf("%.12f\n",d);}

const int iinf = 1e9;
const ll linf = 1e18;
const int mod = 1e9+7;
const double pi = acos(-1);
const double eps = 1e-10;
const int N = 0;
int a, b;
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> a >> b;
  cout << a-b+1<<endl;
  return 0;
}

Measured memory_bytes: 256
s = input()

size = len(s)
judge = 0
ki = ['R','U','D']
gu = ['L','U','D']


for i in range((size+1)//2):
    if s[i*2] not in ki:
        judge += 1

for i in range(size//2):
    if s[i*2+1] not in gu:
        judge += 1
        
if judge == 0:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 3060
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Comparator;

class Main
{

	public static void main(String[] args) throws NumberFormatException, IOException
	{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		ArrayList<Integer> lstInt = new ArrayList<Integer>();

		for (int i = 0; i < 10; ++i)
		{
			lstInt.add(Integer.parseInt(br.readLine()));
		}

		lstInt.sort(Comparator.reverseOrder());

		for (int i = 0; i < 3; ++i)
			System.out.println(lstInt.get(i));

	}

}

Measured memory_bytes: 24144
N,T = map(int,input().split())
c,t = [],[]
for i in range(N):
    cc,tt = map(int,input().split())
    c.append(cc)
    t.append(tt)

m = 9999
for i in range(N):
    if t[i] <= T:
        if c[i] < m:
            m = c[i]
if m == 9999:
    print("TLE")
    exit()

print(m)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  string S;
  cin >> S;
  
  if(S.at(0)==S.at(1)||S.at(1)==S.at(2)||S.at(2)==S.at(3)){
    cout << "Bad" <<endl;
  }else{
    cout << "Good" <<endl;
}
}

Measured memory_bytes: 256
N=int(input())
ans=10**17
for i in range(1,N//2+1):
  j=N-i
  i_str=str(i)
  j_str=str(j)
  tmp1=0
  tmp2=0
  for v1 in range(len(i_str)):
    tmp1+=int(i_str[v1])
  for v2 in range(len(j_str)):
    tmp2+=int(j_str[v2])
  ans=min(ans,tmp1+tmp2)
print(ans)

Measured memory_bytes: 3064
/*
    AUTHOR:hruday pabbisetty
    NIT ROURKElA(My_College_Sucks)
*/
#include <bits/stdc++.h>
using namespace std;
#define opt ios_base::sync_with_stdio(0)
#define lli long long int
#define ulli unsigned long long int
#define I int
#define S string
#define D double
#define rep(i,a,b) for(i=a;i<b;i++)
#define repr(i,a,b) for(i=a;i>b;i--)
#define in(n) scanf("%lld",&n)
#define in2(a,b) scanf("%lld %lld",&a,&b)
#define in3(a,b,c) scanf("%lld %lld %lld",&a,&b,&c)
#define out(n) printf("%lld\n",n)
#define inu(a) scanf("%lld",&a)
#define outu(a) printf("%llu",a)
#define ins(s) scanf("%s",&s)
#define outs(s) printf("%s",s)
#define nl printf("\n")
#define mod 1000000007
#define inf 100000000000000
typedef long long       ll;
typedef pair<lli,lli>  plli;
typedef vector<lli>     vlli;
typedef vector<ulli>    vulli;
typedef vector<ll>      vll;
typedef vector<string>  vs;
typedef vector<plli>     vplli;
#define MM(a,x)  memset(a,x,sizeof(a));
#define ALL(x)   (x).begin(), (x).end()
#define P(x)       cerr<<"{"#x<<" = "<<(x)<<"}"<<endl;
#define P2(x,y)       cerr<<"{"#x" = "<<(x)<<", "#y" = "<<(y)<<"}"<<endl;
#define P3(x,y,z)  cerr<<"{"#x" = "<<(x)<<", "#y" = "<<(y)<<", "#z" = "<<(z)<<"}"<<endl;
#define P4(x,y,z,w)cerr<<"{"#x" = "<<(x)<<", "#y" = "<<(y)<<", "#z" = "<<(z)<<", "#w" = "<<(w)<<"}"<<endl;
#define PP(x,i)     cerr<<"{"#x"["<<i<<"] = "<<x[i]<<"}"<<endl;
#define TM(a,b)     cerr<<"{"#a" -> "#b": "<<1000*(b-a)/CLOCKS_PER_SEC<<"ms}\n";
#define UN(v)    sort(ALL(v)), v.resize(unique(ALL(v))-v.begin())
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define sz() size()
#define nl cout<<"\n"
#define MX1 100005
#define MX2 1000005

#define bs binary_search
#define lb lower_bound
#define ub upper_bound

lli power(lli a,lli b)
    {
    lli value;
    if(b==0)
        {
        return 1;
    }
    else if(b%2==0)
        {
        value=power(a,b/2)%mod;
        return(value*value)%mod;
    }
    else
        {
        value=power(a,b/2)%mod;
        return ((a*value)%mod*(value))%mod;
    }
}
int main()
{
      /*  #ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
        #endif*/
    opt;
    string s;
    cin>>s;
    lli ans=0,i,j,k,l;
    l=s.sz();
    for(i=s.sz()-3;i>=1;i-=2)
    {
        l=(i+1)/2;
        string s1="",s2="";
        rep(j,0,l)
        {
            s1.pb(s[j]);
            s2.pb(s[l+j]);
        }
        if(s1==s2)
        {
            cout<<2*l;
            exit(0);
        }
    }
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		new Main().run();
	}
	
	void run() {
		Scanner sc=new Scanner(System.in);
		char[] cs=sc.next().toCharArray();
		boolean ans=cs[0]==cs[1]&&cs[1]==cs[2]&&cs[2]==cs[0];
		System.out.println(!ans?"Yes":"No");
	}
	
	void tr(Object...objects) {System.out.println(Arrays.deepToString(objects));}
}


Measured memory_bytes: 21844
#include <iostream> 
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mk make_pair
#define MAX 1000001
ll prime[MAX];
#define mod 1000000007

ll rec(vector<vector<ll> >& dp,vector<ll>& arr,int n,int i,int k,int w)
{
  ll ans=0;
  if(i>=n)
    return 0;

  if(dp[i][k]!=-1)
    return dp[i][k];


  if(k!=0)
  ans=max(rec(dp,arr,n,i+1,w,w),arr[i]+rec(dp,arr,n,i+1,k-1,w));
  else
  ans=max(rec(dp,arr,n,i+1,k,w),rec(dp,arr,n,i+1,w,w));

  return dp[i][k]=ans;

}

ll t[400008];
void build(vector<ll>& a, int v, int tl, int tr) {
    if (tl == tr) {
        t[v] = a[tl];
    } else {
        int tm = (tl + tr) / 2;
        build(a, v*2, tl, tm);
        build(a, v*2+1, tm+1, tr);
        t[v] = max(t[v*2] ,t[v*2+1]);
    }
}

ll maxi(int v, int tl, int tr, int l, int r) {
    if (l > r) 
        return 0;
    if (l == tl && r == tr) {
        return t[v];
    }
    int tm = (tl + tr) / 2;
    return max(maxi(v*2, tl, tm, l, min(r, tm)) ,maxi(v*2+1, tm+1, tr, max(l, tm+1), r));
}



void update(int v, int tl, int tr, int pos, ll new_val) {
    if (tl == tr) {
        t[v] = new_val;
    } else {
        int tm = (tl + tr) / 2;
        if (pos <= tm)
            update(v*2, tl, tm, pos, new_val);
        else
            update(v*2+1, tm+1, tr, pos, new_val);
        t[v] = max(t[v*2] ,t[v*2+1]);
    }
}

int main() { 

string s,t;
cin>>s>>t;
int ans=0;
for(int i=0;i<s.size();i++)
{
  if(s[i]!=t[i])
    ans++;
}
cout<<ans;
return 0;
}


Measured memory_bytes: 3852
import sys
import math
d,g=map(int,input().split())
p=[]
c=[]
s=[]
count=0
for i in range(d):
    pi,ci=map(int,input().split())
    p.append(pi)
    c.append(ci)
    s.append((i+1)*100*pi+ci)

l=2**d
count=10**6*d
for i in range(l):
    buf=g
    x=0
    n=0
    for j in range(d):
        if i & 1 ==1:
            x+=p[j]
            buf-=s[j]
        else:
            n=j
        i=i>>1
    if buf>=0:
        y=math.ceil(buf/((n+1)*100))
        if y>p[n]:
            continue
        x=x+y
    count=min(count,x)
print(count)

Measured memory_bytes: 40176
#include<stdio.h>
#include <string.h>
int main(){
char a[17];
char b[17] ="CODEFESTIVAL2016";
int i;
int x = 0;
scanf("%s",a);
for(i=0;i<16;i++){
if(a[i]!=b[i]){
x++;
}
}
printf("%d",x);
}

Measured memory_bytes: 128
import bisect
import sys
input = sys.stdin.readline
A,B,C =map(int,input().split())
s =[-10**11] + [int(input())for _ in range(A)] +[10**11]
t =[-10**11] + [int(input())for _ in range(B)] +[10**11]

for _ in range(C):
    x =int(input())
    ns = bisect.bisect_left(s,x)
    nt = bisect.bisect_left(t,x)
    sx =[s[ns-1],s[ns]]
    tx =[t[nt-1],t[nt]]
    lis =[sx,tx]
    ans = 10**11
    for i in range(8):
        p =i%2
        q =(i//2)%2
        r =i//4
        foo =abs(x-lis[p][q])+abs(lis[p][q]-lis[p-1][r])
        if foo < ans:
            ans = foo
    print(ans)

Measured memory_bytes: 12800
#include<cstdio>

using namespace std;

int main(){
	for(int n,a,b;scanf("%d%d%d",&n,&a,&b),n;){
		static bool made[1000001];
		for(int i=0;i<=n;i++)	made[i]=false;

		for(int i=0;i<=n;i+=a){
			for(int j=i;j<=n;j+=b){
				if(made[j])	break;
				made[j]=true;
			}
		}

		int cnt=n;
		for(int i=1;i<=n;i++)	cnt-=made[i];

		printf("%d\n",cnt);
	}

	return 0;
}

Measured memory_bytes: 0
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;文字列 -> 整数
(defn Int [s] (Integer/parseInt s))
;文字列 -> 文字列
(defn Str [s] s)

;scanf的なノリで1行をいい感じに読み取る
;定数が重いので注意
(defn input [varTypes]
    (mapv 
        (fn [f s] (f s)) ;文字列sに関数fを適用する
        varTypes         ;適用する関数
        (clojure.string/split 
            (read-line)  ;1行を読み込み
            #" "         ;区切り文字
        )
    )
)

;スペース区切りの整数を受け取る
;速い
(defn inputFast [varType]
    (map
        varType
        (clojure.string/split 
            (read-line)  ;1行を読み込み
            #" "         ;区切り文字
        )
    )
)

(defn floor [a b] (quot a b))
(defn ceil [a b] (floor (- (+ a b) 1) b))
(defn abs [a] (if (> 0 a) (- 0 a) a))


;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

(defn f [p pp lim]
    (if (>
            (* p pp)
            lim
        )
        (if (= p pp) 1 pp)
        (f p (* p pp) lim)
    )
)

;---main---
(dosync
    (def l1 (input [Int]))
    (def ret (ref 1))
    (let [[X] l1]
        (doseq [i (range 2 (+ 1 X))]
            (alter ret max (f i i X))
        )
    )
    (println (deref ret))
)





Measured memory_bytes: 66436
import java.io.*;
import java.util.*;

public class Main {
    public static void main(String[] args){
        String ANS = "No";
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt(), B = sc.nextInt(), C = sc.nextInt() ;
        int K = sc.nextInt();
        for(int i = 0; i <= K;i++){
            if(A < B){
                if (B < C){
                    ANS = "Yes";
                    break;
                }
                else{
                    C = C*2;
                }
            }
            else{
                B = B*2;
            }
        }
        System.out.println(ANS);
        

    }
}

Measured memory_bytes: 35636
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <numeric>
#include <iterator>

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int,int> PII;
typedef vector<PII> VPII;
typedef istringstream ISS;
typedef ostringstream OSS;

#define REP( i, m, n ) for ( int i = (int)( m ); i < (int)( n ); ++i )
#define FOR( v, c ) for ( auto &v : c )
#define EACH( it, c ) for ( auto it = c.begin(); it != c.end(); ++it )
#define ALL( c ) (c).begin(), (c).end()
#define DRANGE( c, p ) (c).begin(), (c).begin() + p, (c).end()

#define PB( n ) push_back( n )
#define MP( a, b ) make_pair( ( a ), ( b ) )
#define EXIST( c, e ) ( (c).find( e ) != (c).end() )

#define fst first
#define snd second

#define DUMP( x ) cerr << #x << " = " << ( x ) << endl
#define DEBUG( x ) cerr << __FILE__ << ":" << __LINE__ << ": " << #x << " = " << ( x ) << endl

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

	int n, q;
	cin >> n >> q;

	VI as( n );
	FOR( a, as )
	{
		cin >> a;
	}
	sort( ALL( as ) );

	REP( iteration, 0, q )
	{
		int b;
		cin >> b;
	
		int res = 0;
		for ( int k = 1; ; k++ )
		{
			int p = lower_bound( ALL( as ), b * k ) - as.begin();
			res = max( res, as[ p - 1 ] % b );

			if ( p == n )
			{
				break;
			}
		}

		cout << res << endl;
	}

	return 0;
}

Measured memory_bytes: 2316
a,b,c=map(int,input().split())
if a==b:
  if a!=c :
    print('Yes')
  else:
    print('No')
elif a==c:
  if a!=b :
    print('Yes')
  else:
    print('No')   
elif c==b:
  if a!=c :
    print('Yes')
  else:
    print('No')    
else:
  print('No')

Measured memory_bytes: 3060
import java.util.*;

public class Main {  
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    long[] a = new long[N];
    int con4 =0, con2 =0;
    for (int i =0; i<N; i++) {
      a[i] = sc.nextLong();
      if (a[i] % 4 ==0) {
        con4++;
      } else if (a[i] % 2 ==0) {
        con2++;
      }
    }
    if (N % 2 == 0) {
      if (con4 * 2 + con2 >= N) {
        System.out.print("Yes");
      } else {
        System.out.print("No");
      }
    }
    if (N % 2 == 1) {
      if (con4 * 3 + con2 >= N) {
        System.out.print("Yes");
      } else {
        System.out.print("No");
      }
    }
  }
}

Measured memory_bytes: 50244