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

using namespace std;

typedef long double ld;
typedef long long ll;

#define sz(x) (int)(x).size()
#define pb push_back
#define mp make_pair
#define f first
#define s second

template<typename T, typename U> bool ckmin(T &a, U b){ return b < a ? a = b, true : false; }
template<typename T, typename U> bool ckmax(T &a, U b){ return b > a ? a = b, true : false; }

const int MAXN = 1e7 + 5;

int spf[MAXN];
void sieve() { 
    spf[1] = 1; 
    for (int i=2; i<MAXN; i++) 
        spf[i] = i; 
    for (int i=4; i<MAXN; i+=2) 
        spf[i] = 2; 
    for (int i=3; i*i<MAXN; i++) { 
        if (spf[i] == i) { 
            for (int j=i*i; j<MAXN; j+=i) 
                if (spf[j]==j) 
                    spf[j] = i; 
        } 
    } 
} 
ll qry(int x) { 
    vector<int> v;
    while (x != 1) {
        int cur = spf[x];
        v.pb(1); x /= cur;
        while(x % cur == 0){
            v.back()++;
            x = x / cur; 
        }
    } 
    ll cur = 1;
    for(auto i : v){
        cur *= (i + 1);
    }
    return cur;
} 

int n;
ll res = 0;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n;
    sieve();
    for(int i = 1; i <= n; ++i){
        res += i * qry(i);
    }
    cout << res;
    return 0;
}

Measured memory_bytes: 42604
N ,M = map(int,input().split(' '))
X = list(map(int,input().split(' ')))
X.sort()

Xd = [0]
for i in range(len(X)-1):
    Xd.append(X[i+1]-X[i])
Xd.sort()

# 幅の小さい順にソートして、小さい方から移動にする
if N >= M:
    print(0)
else:
    print(sum(Xd[0:M-N+1]))


Measured memory_bytes: 13960
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    n=int(input())
    l=list(map(int,input().split()))
    c1=0
    c2=0
    c4=0
    for i in l:
        if i%2==1:
            c1+=1
        else:
            if i%4==0:
                c4+=1
            else:
                c2+=1
    if c2==0:
        if c1<=c4+1:
            print('Yes')
        else:
            print('No')
    else:
        if c1<=c4:
            print('Yes')
        else:
            print('No')
resolve()

Measured memory_bytes: 62576
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
//#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread_unlocked(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}

int to[200001], ne[200001], he[100001];
int u, v, Taka, kotae;
pair<bool, int> dfs(int A, int mae, int d) {
	int ret = d;
	bool ita = 0;
	if (A == u) {
		Taka = d;
		ita = 1;
	}
	for (int t = he[A]; t; t = ne[t]) {
		if (to[t] != mae) {
			auto p = dfs(to[t], A, d + 1);
			chmax(ret, p.second);
			ita |= p.first;
		}
	}
	if (ita && d == Taka / 2 + 1) kotae = ret;
	return mp(ita, ret);
}


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


	int N = getint();
	u = getint();
	v = getint();
	int k = 1;
	rep(i, N - 1) {
		int a = getint(), b = getint();
		to[k] = b;
		ne[k] = he[a];
		he[a] = k++;
		to[k] = a;
		ne[k] = he[b];
		he[b] = k++;
	}
	dfs(v, 0, 0);
	if (kotae - 1 <= 0) printf("0");
	else printf("%d", kotae - 1);

	Would you please return 0;
}

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

#define ff first
#define ss second
#define mp make_pair

using namespace std;

typedef long long ll;

pair<int,int> v[10];

double dist(pair<int,int> a, pair<int,int> b) {
	double aux = a.ff-b.ff, aux2 = a.ss-b.ss;
	return sqrt(aux*aux + aux2*aux2);
}

int main() {
	int n;

	scanf("%d", &n);

	for(int i = 0; i < n; i++)
		scanf("%d%d",&v[i].ff, &v[i].ss);

	sort(v, v+n);

	double ans = 0;
	int cnt = 0;
	do {
		double cur = 0;

		for(int i = 1; i < n; i++) {
			cur += dist(v[i], v[i-1]);
		}
		cnt++;
		ans += cur;
	}while(next_permutation(v, v+n));

	printf("%.15lf\n", ans/cnt);

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}


struct FastIO{
  FastIO(){
    cin.tie(0);
    ios::sync_with_stdio(0);
  }
}fastio_beet;

int MOD;

template<typename T>
struct Mint{
  T v;
  Mint():v(0){}
  Mint(signed v):v(v){}
  Mint(long long t){v=t%MOD;if(v<0) v+=MOD;}

  Mint pow(long long k){
    Mint res(1),tmp(v);
    while(k){
      if(k&1) res*=tmp;
      tmp*=tmp;
      k>>=1;
    }
    return res;
  }

  static Mint add_identity(){return Mint(0);}
  static Mint mul_identity(){return Mint(1);}

  Mint inv(){return pow(MOD-2);}

  Mint& operator+=(Mint a){v+=a.v;if(v>=MOD)v-=MOD;return *this;}
  Mint& operator-=(Mint a){v+=MOD-a.v;if(v>=MOD)v-=MOD;return *this;}
  Mint& operator*=(Mint a){v=1LL*v*a.v%MOD;return *this;}
  Mint& operator/=(Mint a){return (*this)*=a.inv();}

  Mint operator+(Mint a) const{return Mint(v)+=a;}
  Mint operator-(Mint a) const{return Mint(v)-=a;}
  Mint operator*(Mint a) const{return Mint(v)*=a;}
  Mint operator/(Mint a) const{return Mint(v)/=a;}

  Mint operator-() const{return v?Mint(MOD-v):Mint(v);}

  bool operator==(const Mint a)const{return v==a.v;}
  bool operator!=(const Mint a)const{return v!=a.v;}
  bool operator <(const Mint a)const{return v <a.v;}

  static Mint comb(long long n,int k){
    Mint num(1),dom(1);
    for(int i=0;i<k;i++){
      num*=Mint(n-i);
      dom*=Mint(i+1);
    }
    return num/dom;
  }
};
template<typename T>
ostream& operator<<(ostream &os,Mint<T> m){os<<m.v;return os;}

//INSERT ABOVE HERE

const int MAX = 5050;

using M = Mint<int>;
M dp[MAX]={};

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

  dp[0]=M(1);
  for(int k=0;k<=(n-1)/2;k++)
    for(int j=0;j+k+1<=n;j++)
      dp[j+k+1]+=dp[j];

  for(int k=0;k<=n/2-1;k++)
    for(int j=0;j+k+1<=n;j++)
      dp[j+k+1]+=dp[j];

  M ans{0};
  for(int k=0;k<n;k++) ans+=dp[k];

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


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

int main()
{
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    cout<<min(a,b)+min(c,d)<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>
#include <functional>

using namespace std;
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
template<typename T> using VT = vector<T>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define EB emplace_back
#define GREATER(T) T, VT<T> greater<T>
template<typename T> inline bool chmax(T &a, T b){if (a < b){a = b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if (a > b){a = b;return true;}return false;}

const int INF = 1e9;
const int MOD = INF + 7;
const LL LLINF = 1e18;

const int MAX = 1e5 + 10;
int N;
int takahashi, aoki;
VI G[MAX];

VI calc_dist(int cur) {
    VI dist(N, -1);
    queue<PII> que;
    que.emplace(cur, 0);
    while (!que.empty()) {
        const auto cur = que.front();
        que.pop();
        dist[cur.first] = cur.second;
        FORE(e, G[cur.first]) if (dist[e] == -1) {
            que.emplace(e, cur.second + 1);
        }
    }
    return dist;
}


int main(void) {
    cin >> N;
    cin >> takahashi >> aoki;
    takahashi--; aoki--;
    REP(i, N - 1) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        G[a].EB(b);
        G[b].EB(a);
    }

    int ans = 0;
    const auto t_t = calc_dist(takahashi);
    const auto t_a = calc_dist(aoki);
    REP(i, N) {
        if (G[i].size() > 1) {
            continue;
        }
        if (t_t[i] <= t_a[i]) {
            chmax(ans, t_a[i] - 1);
        }
    }
    cout << ans << endl;
}


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

#include <iostream>
#include <fstream>

#include <iostream>

class ADodecagon {
public:
    void solve(std::istream &in, std::ostream &out) {
        long long r;
        in >> r;
        out << 3 * r * r;
    }
};


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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef pair<string , int> s_i;
typedef vector<ll> vel;
typedef vector<int> vei;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> ve_vel;
typedef vector<vector<int>> ve_vei;
typedef vector<vector<char>> ve_vec;
typedef vector<vector<bool>> ve_veb;
typedef vector<vector<string>> ve_ves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pub push_back
#define puf push_front
#define pob pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
//#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
const int64 INF = 1LL << 58;
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; }
template<typename T> void remove(T & vector, unsigned int index){vector.erase(vector.begin() + index);}

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

    int N; cin >> N;
    vel a(N); rep(i,N) cin >> a[i];

    ll cnt = 1;
    int index = 0;
    rep2(i,N) {
        ll diff1 = a[i - 1] - a[i];
        ll diff2 = a[index] - a[i - 1];
       if ( ( diff1 < 0 and diff2 > 0) or ( diff1 > 0 and diff2 < 0) ) {
           cnt++;
           index = i;
           i++;
       }
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define endl '\n'
using namespace std;

int A, B, C, D;

void Solution() {

    while(true) {
        C -= B;
        if (C < 1) break;
        A -= D;
        if (A < 1) break;
    }

    if (A >= 1) cout << "Yes" << endl;
    else if (A < 1) cout << "No" << endl;
}

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

    cin >> A >> B >> C >> D;
    Solution();

    return 0;
}


Measured memory_bytes: 3636
# -*- coding: utf-8 -*-
# 入力
N = int(input())
T = input().split()
for i in range(0, N):
    T[i] = int(T[i])
M = int(input())
for i in range(0, M):
    p, x = input().split()
    p = int(p)
    x = int(x)
    Time = sum(T) - T[p - 1] + x
    print(Time)

Measured memory_bytes: 3060
n,y=[int(i) for i in input().split()]

#aの上限
a_num=y//10000
#bの上限
b_num=y//5000

com=[]
for a in range(a_num+1):
    for b in range(b_num+1):
        if 10000*a+5000*b+1000*(n-(a+b))==y and 0<=n-(a+b):
            com.append([a,b,n-(a+b)])
            break
if com==[]:
    print("-1 -1 -1")
else:
    print(com[0][0],com[0][1],com[0][2])
    

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

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define ll long long
const ll mod = 1e9+7;
int inf = 1000000000; //10e9
 
int main() {
    
    ll H, W;
    cin >> H >> W;
    ll ans = 0;

    if(H==1 || W==1){
        ans = 1;
    }else{
        ans = (H*W+1)/2;
    }

    cout << ans << endl;
}

Measured memory_bytes: 3584
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        // TODO 自動生成されたメソッド・スタブ
        Scanner sc = new Scanner(System.in);

        double t = Double.parseDouble(sc.next());
        double x = Double.parseDouble(sc.next());
        System.out.println(t / x);
    }

}


Measured memory_bytes: 23636
#include<stdio.h>

int main(void)
{
  int i,j,tmp;
  int n,s[100];
  int sum;

  while(1){
    scanf("%d ",&n);
    if(n==0)break;

    for(i=0;i<n;i++){
      scanf("%d ",&s[i]);
    }

    for(i=n-1;i>0;i--){
      for(j=0;j<i;j++){
	if(s[j]<s[j+1]){
	  tmp = s[j];
	  s[j] = s[j+1];
	  s[j+1] = tmp;
	}
      }
    }
    sum = 0;
    for(i=1;i<n-1;i++){
      sum += s[i];
    }

    printf("%d\n",sum/(n-2));

  }

  return 0;
}

Measured memory_bytes: 0
from collections import deque

a = input()
b = input()
c = input()

q_a = deque(a)
q_b = deque(b)
q_c = deque(c)

target = q_a

while True:
    if len(target) == 0:
        ans = value
        break
    else:
        value = target.popleft()
        if value == 'a':
            target = q_a
        elif value == 'b':
            target = q_b
        else:
            target = q_c

print(value.upper())
    

Measured memory_bytes: 3316
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<map>
#include<assert.h>
#define fo(i,a,b) for(int i=(a);i<=(b);++i)
#define fd(i,b,a) for(int i=(b);i>=(a);--i)
#define bfo(i,v,u) for(int i=BB[v],u=B[i][1];i;u=B[i=B[i][0]][1])
#define mset(a,x) memset(a,x,sizeof(a))
#define mcpy(a,b) memcpy(a,b,sizeof(b))
template<typename T> bool chkmin(T &a,const T &b) {return b<a?a=b,1:0;}
template<typename T> bool chkmax(T &a,const T &b) {return b>a?a=b,1:0;}
using namespace std;
typedef long long ll;
int read(){int n=0,p=1;char ch;for(ch=getchar();ch<'0' || ch>'9';ch=getchar())if(ch=='-') p=-1;for(;'0'<=ch && ch<='9';ch=getchar()) n=n*10+ch-'0';return n*p;}
const int N=2e5+5;
int n,a[N];
map<int,int> c;
int main()
{
	n=read();
	fo(i,1,n) a[i]=read(),c[a[i]]++;
	sort(a+1,a+n+1);
	int ans=0;
	fd(i,n,1)
	{
		int x=1;
		while(x<=a[i]) x<<=1;
		if(a[i]==x-a[i])
		{
			if(c[a[i]]>=2) ++ans,c[a[i]]-=2;
		}
		else
		{
			if(c[a[i]] && c[x-a[i]]) ++ans,c[a[i]]--,c[x-a[i]]--;
		}
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 19712
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;

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

    long long int n, k;
    cin >> n >> k;

    cout << (long long int)(k * pow(k-1, n-1)) << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main() {
  int x1,y1,x2,y2; cin >> x1 >> y1 >> x2 >> y2;
  cout << x2+y1-y2 << " " << x2-x1+y2 << " " << x1+y1-y2 << " " << x2-x1+y1 << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <iostream>
#include <numeric>
#include <math.h>
#define ll  long long
#define ull unsigned long
#define mpa make_pair
#define pb push_back
#define ff first
#define pii pair<ll,ll>
#define dd double
#define trace(x) cerr << #x << " : " << x << endl
#define ss second
#define boost ios_base::sync_with_stdio(0)
#define forp(i,a,b) for(ll i=a;i<=b;i++)
#define rep(i,n)    for(ll i=0;i<n;++i)
#define ren(i,n)    for(ll i=n-1;i>=0;i--)
#define forn(i,a,b) for(ll i=a;i>=b;i--)
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for(typeof((c).begin()) i = (c).begin(); i != (c).end();
#define sc(x) scanf("%lld",&x)
#define clr(x,val) memset(x,val,sizeof(x))
#define pr(x) printf("%lld\n",x) 
#define gc getchar
#define pdd pair<dd,dd>
#define prec(x) cout<<fixed<<setprecision(x)
using namespace std;

int main(){
    ll n,m;
    cin>>n>>m;
    
    cout<<n*m;
    
	
	
	
	
	
	
	  	  
    
}

Measured memory_bytes: 3636
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int N;
long long int a[200005];

int main(void) {

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

	long long int tmp = 0;

	for (int i = 1; i <= N; i++) {
		tmp ^= a[i];
	}

	for (int i = 1; i <= N; i++) {
		if (i != 1) { cout << " "; }
		cout << (tmp^a[i]);
	}cout << endl;

	return 0;
}

Measured memory_bytes: 5148
#include<iostream>
#include<vector>
#include<string>
#include<deque>
#include<unordered_map>
#include<queue>
#include<algorithm>
#include<cmath>
using namespace std;

typedef long long LL;

LL solve(){
    int n;
    cin>>n;
    string str;
    cin>>str;
    string re;
    n = n%26;
    for(auto item:str){
        re += (item-'A'+n)%26+'A';
    }
    cout<<re<<endl;
    return 0;
}

int main(){
    int T = 1;
    while(T--){
        solve();
    }
    return 0;
}

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

int ans=1000;
int main(){
  int N,A[200];
  cin>>N;
  for (int i=0;i<N;i++){
    int A,temp=0;
    cin>>A;
    if (A%2==1){
      ans=0;
      break;
    }
    while(A%2==0){
      temp++;
      A/=2;
    }
    if(temp<ans) ans=temp;
    temp=0;
  }
  cout<<ans<<endl;
}
  

Measured memory_bytes: 3612
#include<stdio.h>
#include<math.h>
int main()
{
   int i,j;

   for(i=1;i<=9;i++)
   {
       for(j=1;j<=9;j++)
       {
           printf("%dx%d=%d\n",i,j,i*j);
       }
   }
   return 0;
}

Measured memory_bytes: 520
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <string.h>

using namespace std;

int main()
{
    string s;
    int a, b;
    cin >> a >> b;
    cin >> s;
    
    string ans = "Yes";
    for (int i=0; i<a+b+1; i++) {
        if (i == a) {
            if (s[i] != '-') {
                ans = "No";
                break;
            }
        }
        else {
            if (s[i] == '-') {
                ans = "No";
                break;
            }
        }
   }
   cout << ans << '\n';
   
   return 0;
}

Measured memory_bytes: 3632
#include"bits/stdc++.h"
#include<boost/multi_array.hpp>
#include<boost/optional.hpp>
#include<boost/range/irange.hpp>
#include<boost/range/algorithm.hpp>
#include<boost/range/adaptors.hpp>

namespace adaptor = boost::adaptors;

void solve()
{
    int64_t X, N;
	std::cin >> X >> N;

	if (N == 0)
	{
		std::cout << X << std::endl;
		return;
	}

	std::vector<int64_t> num(102);
	for (int64_t i = 0; i <= 101; i++)
	{
		num[i] = i;
	}

	for (int64_t i = 0; i < N; i++)
	{
		int64_t value_to_remove;
		std::cin >> value_to_remove;
		num.erase(std::remove(num.begin(), num.end(), value_to_remove), num.end());
	}
	std::sort(num.begin(), num.end());

	int64_t ans;
	int64_t ans_abs = 1000;
	for (int64_t i : num)
	{
		int64_t i_abs = abs(i - X);
		if (i_abs < ans_abs)
		{
			ans_abs = i_abs;
			ans = i;
		}
	}

	std::cout << ans << std::endl;

}

int main()
{
	std::cin.tie(nullptr);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	solve();
}


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

using namespace std;

int main()
{
    int n;
    string s;
    cin >> n;
    cin >> s;
    int c = 0;
    for (int l = 0, r = n - 1; l < r; ) {
        for (; s[l] != 'W' && l < n; l++)
            ;
        for (; s[r] != 'R' && r >= 0; r--)
            ;
        if (l < r) {
            swap(s[l], s[r]);
            c++;
            l++;
            r--;
        }
    }
    cout << c << endl;
    return 0;
}

Measured memory_bytes: 3744
from math import sqrt
n,d = map(int,input().split())
x,y = [],[]
answer = 0
for i in range(n):
	ii = list(map(int,input().split()))
	x.append(ii[0])
	y.append(ii[1])
for k in range(n):
	if sqrt((x[k])**2 + (y[k])**2) <= d:
		answer += 1
print(answer)

Measured memory_bytes: 24872
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<cmath>
#include<string>
#include<cstring>
using namespace std;
int main()
{
	int a,b,d;
	cin>>a>>b>>d;
	if(a==5&&b==5&&d==7)cout<<"YES"<<endl;
	else if(a==5&&b==7&&d==5)cout<<"YES"<<endl;
	else if(a==7&&b==5&&d==5)cout<<"YES"<<endl;
	else cout<<"NO"<<endl;

}

Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <set>
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)

using namespace std;
typedef long long ll;

const int COST[10] = {6,2,5,5,4, 5,6,3,7,6};

int gcd(int a, int b) {
  return b == 0 ? a : gcd(b, a % b);
}

bool canUse[10];

const int IMPOSSIBLE = -2;
int memo[10000+10];
int solve(int n) {
  if(n < 0) {
    return IMPOSSIBLE;
  }
  int &res = memo[n];
  if(res == -1) {
    if(n == 0) {
      res = 0;
    } else {
      res = IMPOSSIBLE;
      REP(d, 10) {
        if(!canUse[d]) {
          continue;
        }
        int tmp = solve(n - COST[d]);
        if(tmp != IMPOSSIBLE) {
          res = max(res, tmp + 1);
        }
      }
    }
    // cerr << ">>" << n << " " << res << endl;
  }
  return res;
}

int main(void) {
  int n, m;
  cin >> n >> m;
  REP(i, m) {
    int d;
    cin >> d;
    canUse[d] = true;
  }
  memset(memo, -1, sizeof memo);
  int len = solve(n);
  cerr << ">" << len << endl;
  REP(i, len) {
    for(int d = 9; d > 0; --d) {
      if(canUse[d] && solve(n - COST[d]) == len-1-i) {
        printf("%d", d);
        n -= COST[d];
        break;
      }
    }
  }
  puts("");

  return 0;
}


Measured memory_bytes: 512
#include<iostream>
using namespace std;
const long long mod=998244353;
long long a,b,n,m;
long long f[3005][3005];
int main(){
	cin>>a>>b>>n>>m;
	f[a][b]=1;
	for(long long i=a;i<=n;i++)
	for(long long j=b;j<=m;j++){
		if(i==a&&j==b) continue;
		if(b==j) {
			f[i][j]=f[i-1][j]*j%mod;
			continue;
		}
		if(a==i){
			f[i][j]=i*f[i][j-1]%mod;
			continue;
		}
		f[i][j]=(long long)j*f[i-1][j]+(long long)i*f[i][j-1]-(long long)(j-1)*(i-1)%mod*f[i-1][j-1]%mod;
		f[i][j]=(long long)f[i][j]%mod;
	}
/*	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			cout<<f[i][j]<<' ';
		}
		cout<<endl;
	}*/
	cout<<f[n][m]<<endl;
	return 0;
	
}

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

using namespace std;

int main()
{
    int n, a[110],ans=1e9,s=0;
    cin>>n;
    for(int i=1;i<=n;i++) cin>>a[i];
    sort(a+1,a+n+1);
    for(int x=a[1];x<=a[n];x++)
    {
        s=0;
        for(int i=1;i<=n;i++)
            s+=(a[i]-x)*(a[i]-x);
        ans=min(ans,s);
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            new ABC129().SolveA(new ConsoleInput(Console.In, ' '));
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
    }
  
  class ABC129
    {
        public void SolveA(ConsoleInput cin)
        {
            var p = cin.ReadInt;
            var q = cin.ReadInt;
            var r = cin.ReadInt;
            var group = new int[3] { p, q, r };
            WriteLine(group.Sum() - group.Max());
            ReadLine();
        }
    }
  
}


Measured memory_bytes: 13396
it = input()
it = it.split()

a = int(it[0])
b = int(it[1])
c = int(it[2])
k = int(it[3])

j = k
ot = 0

if a:
    if a < k:
        ot += a
        j -= a
    elif a >= k:
        ot += k 
        j = 0
    

if b and j != 0:
    if b >= j:
        j = 0
    elif b < j:
        j -= b

if c and j != 0:
    if c >= j:
        ot -= j
        j = 0
    elif j > c:
        ot -= c
        j -= c

print(ot)

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

int main(){
  int n;
  cin>>n;
  int p[n];
  rep(i,0,n){
    cin>>p[i];
  }
  sort(p,p+n);
  int ans=0;
  rep(i,0,n-1){
    ans+=p[i];
  }
  cout<<ans+p[n-1]/2<<endl;
}

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

#define PI 3.14159265358979

int main() {
	double a, b, c;
	cin >> a >> b >> c;
	printf("%.5f\n", a * b * sin(c * PI / 180) * 0.5);
	printf("%.5f\n", a + b + sqrt(pow(a, 2) + pow(b, 2) - (2 * a * b * cos(c * PI / 180))));
	printf("%.5f\n", b * sin(c * PI / 180));
	return 0;
}

Measured memory_bytes: 3512
k = int(input())
arr = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(arr[k-1])

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

class Main{
        static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        public static void main(String[] args) throws IOException{
                int n1 = Integer.parseInt(br.readLine());
                int[] a1 = new int[n1];
                String[] s1 = br.readLine().split(" ");
                for(int i=0; i<n1; i++)
                        a1[i] =  Integer.parseInt(s1[i]);
                int n2 = Integer.parseInt(br.readLine());
                int[] a2 = new int[n2];
                String[] s2 = br.readLine().split(" ");
                for(int i=0; i<n2; i++)
                        a2[i] = Integer.parseInt(s2[i]);

                int ans = 0;
                for(int i: a2){
                        int l = 0;
                        int r = n1-1;
                        int m = (r-l)/2;
                        for(int j=0; j<a1.length; j++){
                                if(a1[m] == i){
                                        ans++;
                                        break;
                                }
                                if(a1[m]>i)
                                        r=m;
                                else
                                        l=m;
                                if(r==l)
                                        break;
                                m=r-(r-l)/2;
                        }
                }
                System.out.println(ans);
        }
}

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

using namespace std;

int main() {

	long n;
	cin >> n;

	string s, t;
	cin >> s >> t;

	for (long i = 0; i < n; i++) {
		cout << s[i] << t[i];
	}

	cout << endl;

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<math.h>
#include<queue>
#include<vector>
#include<map>
#include<utility>
using namespace std;

int n,nketa;
string s;
long long int ans=0;
map<pair<int, int>,int> mp;


pair<int,int> f(int x){
    int xf = x%10;
    while(x/10!=0){
        //cout << x << endl;
        x = x/10;
    }
    int xs = x;
    return pair<int,int> (xs,xf);
}

int main(){
    cin >> n;
    for(int i=1;i<=n;i++){
        pair<int, int> x;
        x = f(i);
        mp[x]++;
    }

    for(int i=1;i<=n;i++){
        pair<int,int> y;
        pair<int ,int> z;
        y = f(i);
        //cout << y.first << " " << y.second << " " << i << endl;
        z = pair<int,int> (y.second,y.first);
        ans += mp[z];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  
  int odd = 0;
  for (int i=0; i<N; i++) {
    int A; 
    cin >> A;
    if (A%2 == 1) odd++;
  }
  
  if ( odd%2 ) cout << "NO" << endl;
  else cout << "YES" << endl;
  
}

Measured memory_bytes: 256
N, M = map(int, input().split())

AB = []
for i in range(N):
    AB.append(list(map(int, input().split())))
AB.sort(key=lambda x: x[0])
count = 0
ans = 0
for ab in AB:
    if M > count+ab[1]:
        count += ab[1]
        ans += ab[0]*ab[1]
    else:
        ans += ab[0] * (M-count)
        break
print(ans)


Measured memory_bytes: 29024
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

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

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

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

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        n:usize,
        a: [i64;n]
    }
    // let mut cur = vec![];
    let mut sum = 0;
    let mut res = 0;
    for j in 0..n/2 {
        res+=a[(1+2*j)%n];
    }
    // cur.push(res);
    for i in 0..n {
        sum+=a[i];
    }
    let a1 = sum - 2*res;
    // println!("{}", a1);

    let mut ans = vec![];
    let mut now = a1;
    ans.push(a1);
    for i in 0..n-1 {
        ans.push(2*(a[i]-now/2));
        now = 2*(a[i]-now/2);
    }
    // println!("{:?}", cur);
    // println!("{:?}", ans);
    for i in ans {
        print!("{} ", i);
    }
}

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

// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
// using namespace __gnu_pbds; 
  
// #define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 

#define ll long long
#define fill fill_n
#define pf push_front
#define pb push_back
#define FOR(i,l,r) for(int i=l;i<r;i++)
#define ROF(i,r,l) for(int i=r;i>=l;i--)
#define comp(v) (v).begin(),(v).end()
#define ff first
#define ss second
#define infile freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
typedef vector<int> vi;
typedef vector<ll> vli;
typedef vector<pair<int,int>> vpi;

const int M = 1e9+7;
const int N = 2e5;
ll po(int,int);

ll f(ll x,ll k,ll d){
    if(k==0) return abs(x);
    
    if(x>=0){
       ll y = (ll)ceil((double)x/d);
       if(y>=k){
           x -= k*d;
           
           return f(x,0,d);
           
       }
       else{
           k-=y;
           x -= y*d;
           if(y==0){
              if(k%2==0) return abs(x);
              else return abs(x-d);
           }
           else
           return f(x,k,d);
       }
   }
   else{
       ll y = abs(x)/d;
       if(y>=k){
           x += k*d;
           return f(x,0,d);
       }
       else{
           k-=y;
           x+=y*d;
           if(y==0){
               if(k%2==0) return abs(x);
               else return abs(x+d);
           }
           else
           return f(x,k,d);
       }
   }

}
void solve(){
   ll x,k,d;
   cin>>x>>k>>d;
   cout<<f(x,k,d);
   
    
}





int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
    int t=1;
    //cin>>t;
    FOR(i,1,t+1){
        //cout<<"Case #"<<i<<": "; 
        solve();
    }
    
	return 0;
	
	
}


ll po(int a,int b){
    if(b==0) return 1;
    ll ans=1;
    if(b%2==0){
        ans = po(a,b/2)%M;
        ans=(ans%M * ans%M)%M;
    }
    else{
        ans = po(a,(b-1)/2)%M;
        ans = (ans%M * ans%M * a)%M;
    }
    return ans%M;
}


Measured memory_bytes: 3720
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Vl = vector<ll>;

Vl f(ll n) {
  Vl v;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      v.emplace_back(i);
      if (i * i != n) v.emplace_back(n / i);
    }
  }
  sort(v.begin(), v.end());
  return v;
}

#define ts(x) to_string(x).size()
void solve() {
  ll N;
  cin >> N;
  Vl d = f(N);
  int ans = 10;
  for (auto a : d) {
    int b = N / a;
    ans = min(ans, (int)max(ts(a), ts(b)));
  }
  cout << ans << endl;
}

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

Measured memory_bytes: 3644
#include<stdio.h>
int main(){
int i,a,b;
	for(i=0;i<7;i++){
	scanf("%d %d",&a,&b);
	if(b>a){
	b=b-a;
	}
	else{
	b=a-b;
	}
	printf("%d\n",b);
	}
	return 0;
}

Measured memory_bytes: 1028
#include<cstdio>
#include<set>
using namespace std;
set<int>s;
set<int>:: iterator it;

int ans=0,i,n,x;
int main()
{
	scanf("%d",&n);
	for (i=1;i<=n;i++)
	{
		scanf("%d",&x);
		//it=s.find(x);
		if (s.count(x)==1)
		{
			//it=s.find(x);
			s.erase(x);
			ans--;
		}
		else
		{
			ans++;
			s.insert(x);
		}
	}
	printf("%d\n",ans);
}

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

typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef vector<vector<long long>> VVL;
typedef pair<int,int> P;
typedef tuple<int,int,int> tpl;

#define ALL(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define EXIST(m,v) (m).find((v)) != (m).end()
#define LB(a,x) lower_bound((a).begin(), (a).end(), x) - (a).begin()
#define UB(a,x) upper_bound((a).begin(), (a).end(), x) - (a).begin()

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

#define en "\n"

constexpr double EPS = 1e-9;
constexpr double PI  = 3.1415926535897932;
constexpr int INF = 2147483647;
constexpr long long LINF = 1LL<<60;
constexpr long long MOD = 1000000007; // 998244353;

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

void Main(){
    string S; cin >> S;
    if(S.back() == 's') S += "es";
    else S += "s";
    cout << S << en;
    return;
}

int main(void){
    cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(0);cout<<fixed<<setprecision(15);
    int t=1; //cin>>t;
    REP(_,t) Main();
    return 0;
}

Measured memory_bytes: 3660
import string
while(1):
    try:
        text = input()
        words = text.split()
        stop = 0
        for i in range(26):
            if stop == 1:
                break
            a = []
            b = []
            for j in words:
                a.append("".join([chr((ord(k) + i - ord("a")) % 26 + ord("a")) if ord(k) >= ord("a") else k for k in j]))
                b.append("".join([chr((ord(k) + i - ord("a")) % 26 + ord("a")) for k in j if ord(k) >= ord("a")]))
            for j in b:
                if j in ["this","that","the"]:
                    print(" ".join(a))
                    stop = 1
                    break
    except EOFError:
        break



Measured memory_bytes: 6684
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (true) {
            int n = sc.nextInt();
            if (n == 0) {
                break;
            }
            int[] list = new int[n ];
            for (int i = 0; i < n + 1; i++) {
                if (i == n) {
                    int sum=0;
                    for (int j = 0; j < n; j++) {
                        sum+=list[j];
                        System.out.printf("%5d",list[j] );
                    }
                    System.out.printf("%5d\n",sum);                    
                } else {
                    int sum=0;
                    for (int j = 0; j < n; j++) {
                        int m = sc.nextInt();
                        sum += m;
                        list[j] += m;
                        System.out.printf("%5d",m);
                    }
                    System.out.printf("%5d\n",sum);
                }
            }
        }
    }
}


Measured memory_bytes: 32764
#include <stdio.h>
int main(void){
    
   int a,b,c,i,k=0;
   
   scanf("%d %d %d",&a,&b,&c);
   
   for(i=a;i<=b;i++){
       if(c%i==0) k++;
   }
   
   printf("%d\n",k);
   
    return 0;
    
}


Measured memory_bytes: 2128
#include<functional>
#include<algorithm>
#include<iostream>
#include<iomanip>
#include<cstring>
#include<cstdlib>
#include<utility>
#include<string>
#include<cstdio>
#include<vector>
#include<bitset>
#include<cmath>
#include<ctime>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
using namespace std;
const int inf=2147483647,dx[]={-1,0,1,0},dy[]={0,-1,0,1};// 上 左 下 右
const int N=100005,M=1000005,K=200005,mod=1000000007;
const long long llinf=9223372036854775807ll;
//int & long long
long long x,a,b;
int main(){
	cin>>x;
	for(a=0;a<=10000;a++)
		for(b=0;b<=10000;b++)
		{
			int A=a*a*a*a*a,B=b*b*b*b*b;
			if(A-B==x)
			{
				cout<<a<<' '<<b;
				return 0;
			}
			if(A+B==x)
			{
				cout<<a<<" -"<<b;
				return 0;
			}
		}
	return 0;
}

Measured memory_bytes: 3160
N = int(input())
lst = [int(s) for s in input().split(" ") ]

cnt = 0
flag = 0

while flag == 0:
    for i in range(0,N):
        if lst[i]%2 == 0:
            lst[i] = lst[i]/2
        else:
            flag = 1
    cnt += 1
    

print("{}".format(cnt-1))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
  
int main() {
  int A,B,C;
  cin >> A >> B >> C;
  map<int,int> mp;
  mp[A]++;
  mp[B]++;
  mp[C]++;
  for(auto x:mp) {
    if(x.second == 1) {
      cout << x.first << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define f first
#define s second
#define mod 1000000007

ll power(ll x, ll y){
	if(y==0)return 1;
	ll ps = power(x, y/2)%mod;
	ll ss = (ps%mod*ps%mod)%mod;
	if(y&1)ss = (x%mod*ss%mod)%mod;
	return ss%mod;
}

int main(){
	
	ll n, k ; cin>> n >> k;
	ll dp[k+1]={0};
	for(ll i= k ;i>=1;i--){
		ll ps = k/i;
		ll ss= power(ps, n)%mod;
		ll sub=0;
		for(ll j= 2*i ;j<=k ;j+=i){
			sub=(sub%mod + dp[j]%mod)%mod;
		}
		dp[i]=(ss-sub+mod)%mod;
	}
	ll ans =0;
	for(ll i=1;i<=k ; i++){
		ans = (ans%mod + i*dp[i]%mod)%mod;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 4400
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, P> P1;
typedef pair<P, P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i, x) for (long long i = 0; i < x; i++)
#define repn(i, x) for (long long i = 1; i <= x; i++)
#define SORT(x) sort(x.begin(), x.end())
#define ERASE(x) x.erase(unique(x.begin(), x.end()), x.end())
#define POSL(x, v) (lower_bound(x.begin(), x.end(), v) - x.begin())
#define POSU(x, v) (upper_bound(x.begin(), x.end(), v) - x.begin())
vector<pair<string, P> > vec;
// vector<vector<int>> data(3, vector<int>(4));

void solve(long long X) { cout << X / 500 * 1000 + X % 500 / 5 * 5 << endl; }

int main() {
    long long X;
    scanf("%lld", &X);
    solve(X);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>

using namespace std;

int main() {
    long long int n;
    cin>>n;
    vector<long long> primes;
    long long t = n;
    while(t%2==0){
        primes.push_back(2);
        t = t/2;
    }
    for(int i = 3; i <= sqrt(t); i+=2){
        while(t%i == 0){
            primes.push_back(i);
            t = t/i;
        }
    }
    if(t>1)
        primes.push_back(t);
    map<long long, int> m;
    for(int i = 0; i < primes.size(); i++){
        m[primes[i]]++;
    }
    long long op = 0;
    map<long long, int>::iterator it;
    for(it = m.begin(); it != m.end(); it++){
        int s = it->second;
        int j = 1;
        while(s>=j && s){
            op++;
            s = s-j;
            j++;
        }
    }
    cout<<op<<endl;
}

Measured memory_bytes: 3728
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.NoSuchElementException;
import java.util.stream.IntStream;

public class Main {

	public static void main(String[] args) throws IOException {
		new Main().solve();
	}

	private void solve() throws IOException {
		try {
			//			solveA();
			solveB();
			//			 solveC();
			//			 solveD();
			//			 solveE();
			//			 solveF();
		} finally {
			if (in != null) {
				in.close();
			}
			if (out != null) {
				out.flush();
				out.close();
			}
		}

	}

	private void solveA() {
		int[] wk = IntStream.range(0, 3).map(i -> nextInt()).toArray();

		Arrays.sort(wk);

		out.println(wk[0] + wk[1]);
	}

	private void solveB() {
		String s = next();
		//後ろ1文字削除
		String wkS = s.substring(0, s.length() - 1);

		/*
		 * 半分にしてしまい、そこから同じ文字列が出現するかを調査
		 */
		for (int i = wkS.length() / 2; i > 0; i--) {
			//比較用文字列（前半分）
			String tmp = wkS.substring(0, i);
			//比較用文字列（後ろ半分。tmpと同じ文字列が、tmpの直後に出現するかの確認）
			String tmp2 = wkS.substring(i, i * 2);
			if (tmp.equals(tmp2)) {
				//0-iの文字列を二つ並べるので*2
				out.println(i * 2);
				return;
			}
		}

	}

	private void solveC() {
		int numN = nextInt();

		out.println("");
	}

	private void solveD() {
		int numN = nextInt();

		out.println("");
	}

	private void solveE() {
		int numN = nextInt();

		out.println("");
	}

	private void solveF() {
		int numN = nextInt();

		out.println("");
	}

	private final PrintWriter out = new PrintWriter(System.out);
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}

	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	private void skipUnprintable() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
	}

	public boolean hasNext() {
		skipUnprintable();
		return hasNextByte();
	}

	public int nextInt() {
		return Integer.parseInt(next());
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}
}

Measured memory_bytes: 22612
/**
 *    author:  tourist
 *    created: 13.06.2020 15:28:36       
**/
#include <bits/stdc++.h>

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> v(n), w(n);
  for (int i = 0; i < n; i++) {
    cin >> v[i] >> w[i];
  }
  const int MAX = 100001;
  int limit = min(512, n);
  vector<vector<int>> dp(limit, vector<int>(MAX));
  for (int j = 0; j < MAX; j++) {
    dp[0][j] = (j >= w[0] ? v[0] : 0);
  }
  for (int i = 1; i < limit; i++) {
    int p = (i - 1) / 2;
    for (int j = 0; j < MAX; j++) {
      dp[i][j] = dp[p][j];
      if (j >= w[i]) {
        dp[i][j] = max(dp[i][j], dp[p][j - w[i]] + v[i]);
      }
    }
  }
  int tt;
  cin >> tt;
  while (tt--) {
    int ver, L;
    cin >> ver >> L;
    --ver;
    vector<int> ids;
    while (ver >= limit) {
      ids.push_back(ver);
      ver = (ver - 1) / 2;
    }
    int sz = (int) ids.size();
    int ans = 0;
    for (int t = 0; t < (1 << sz); t++) {
      int sv = 0;
      int sw = 0;
      for (int i = 0; i < sz; i++) {
        if (t & (1 << i)) {
          sv += v[ids[i]];
          sw += w[ids[i]];
        }
      }
      if (sw <= L) {
        ans = max(ans, dp[ver][L - sw] + sv);
      }
    }
    cout << ans << '\n';
  }
  return 0;
}


Measured memory_bytes: 206480