akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<vector>
const int N=1e5+6,V=2e5+6;
struct edge{int v,c,nxt;}g[800003];
int n,m,head[V],k,iter[V],S,T,d[V],q[V],l,r,f[N],x[N],vis[N];
std::vector<int>e[N];
inline void Insert(int u,int v){
	g[k]=(edge){v,1,head[u]},head[u]=k++;
	g[k]=(edge){u,0,head[v]},head[v]=k++;
}
inline bool Bfs(){
	int u,v;
	for(u=1;u<=T;u++)d[u]=0;
	d[q[l=r=0]=S]=1;
	for(;l<=r;){
	  u=q[l++];
	  for(int i=head[u];~i;i=g[i].nxt)if(g[i].c&&!d[v=g[i].v])
		d[v]=d[u]+1,q[++r]=v;
	}return d[T];
}
int Dfs(int u,int f){
	if(!f||u==T)return f;
	int v,res=0,tmp;
	for(int&i=iter[u];~i;i=g[i].nxt)
	  if(g[i].c&&d[v=g[i].v]>d[u]&&(tmp=Dfs(v,std::min(f,g[i].c)))){
		g[i].c-=tmp,g[i^1].c+=tmp;
		f-=tmp,res+=tmp;
		if(!f)return res;
	  }
	return res;
}
inline int Maxflow(){
	int res=0;
	for(;;){
	  if(!Bfs())return res;
	  for(int u=1;u<=T;u++)iter[u]=head[u];
	  res+=Dfs(S,n-1);
	}
}
void Ans(int u){
	vis[u]=1;
	for(int i=0;i<e[u].size();i++)if(!vis[f[e[u][i]]])
	  x[e[u][i]]=u,Ans(f[e[u][i]]);
}
int main(){
	int u;
	scanf("%d",&n);
	S=n+n-1,T=n+n;
	for(u=1;u<=T;u++)head[u]=-1;
	for(int i=1;i<n;i++){
	  scanf("%d",&m);
	  for(;m--;){
		scanf("%d",&u);
		if(u<n)Insert(u,i+n-1);
		e[u].push_back(i);
	  }
	  Insert(i+n-1,T);
	}
	for(u=1;u<n;u++)Insert(S,u);
	if(Maxflow()!=n-1)return 0*puts("-1");
	for(int u=1;u<n;u++)
	  for(int i=head[u];~i;i=g[i].nxt)if(!g[i].c)
		f[g[i].v-n+1]=u;
	Ans(n);
	for(int u=1;u<=n;u++)if(!vis[u])return 0*puts("-1");
	for(int i=1;i<n;i++)printf("%d %d\n",x[i],f[i]);
	return 0;
}

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

int k, s, pattern = 0, ans = 0, num = 0;

int main(){

	cin >> k >> s;

	if (s > k * 2){
		num = s - k * 2;
		k -= num;
		s -= num * 3;
	}

	for (int i = 0; i <= min(k, s); i++){
		for (int j = i; j <= min(k, s - i); j++){
			if (s - (i + j) >= j && s - (i + j) <= k){
				pattern = 0;

				pattern += 6;
				if (i == j){
					pattern -= 3;
				}
				if (j == s - (i + j)){
					pattern -= 3;
				}
				if (pattern == 0){
					pattern = 1;
				}

				ans += pattern;
			}
		}
	}

	cout << ans;

	return 0;
}

Measured memory_bytes: 256
#ifdef BUILT_LOCAL

#include "niklib.h"

#endif

#include <iostream>
#include <utility>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <string>
#include <cstdio>
#include <map>
#include <cmath>
#include <set>
#include <list>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef __int128 lll;
constexpr ll mod = 1000000007;

#define bs(n) (1u<<(unsigned)(n))

int main() {
    int n;
    cin >> n;
    vector<int> p(n);
    vector<set<int>> s(n);
    for (int i = 0; i < n; i++) {
        int k;
        cin >> k;
        for (int j = 0; j < k; j++) {
            int c;
            cin >> c;
            p[c] = i;
            s[i].insert(c);
        }
    }
    vector<int> d(n, 0);
    queue<int> q;
    q.push(0);
    while (!q.empty()) {
        int t = q.front();
        q.pop();
        for (auto &e:s[t]) {
            d[e] = d[t] + 1;
            q.push(e);
        }
    }
    vector<array<int, 20>> h(n);
    for (int i = 0; i < n; i++) {
        h[i][0] = p[i];
    }
    for (int i = 1; i < 20; i++) {
        for (int j = 0; j < n; j++) {
            h[j][i] = h[h[j][i - 1]][i - 1];
        }
    }
    int k;
    cin >> k;
    auto get_ancestor = [&h](int n, int d) {
        for (int i = 0; i < 20; i++) {
            if (d & bs(i)) {
                n = h[n][i];
            }
        }
        return n;
    };
    for (int i = 0; i < k; i++) {
        int u, v;
        cin >> u >> v;
        if (d[u] > d[v]) swap(u, v);
        v = get_ancestor(v, d[v] - d[u]);
        int l = -1, r = d[u];
        while (r - l > 1) {
            int m = (r + l) / 2;
            int uu = get_ancestor(u, m);
            int vv = get_ancestor(v, m);
            if (uu == vv) r = m;
            else l = m;
        }
        cout << get_ancestor(u, r) << endl;
    }
}



Measured memory_bytes: 21272
#include<stdio.h>
int main()
{
    int x,y,z;
    
    for(;scanf("%d %d",&x,&y);)
    {
        if(x==0 && y==0)
        break;
        else if(x>y)
      {  z=x;
        x=y;
        y=z;
         }
        
        printf("%d %d\n",x,y);
    }
    
    return 0;
}


Measured memory_bytes: 1996
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
long long n, a[400000], b[400000], x[531441], x2[533141];
vector<pair<long long, long long>>vec, vec2;
void add(long long p, long long r) { while (p <= 524287) { x[p] += r; p += p&-p; } }
long long sum(long long t) { long long cnt = 0; while (t >= 1) { cnt += x[t]; t -= t&-t; }return cnt; }
void add2(long long p, long long r) { while (p <= 524287) { x2[p] += r; p += p&-p; } }
long long sum2(long long t) { long long cnt = 0; while (t >= 1) { cnt += x2[t]; t -= t&-t; } return cnt; }
int main() {
	cin >> n; for (int i = 0; i < n; i++) { cin >> a[i] >> b[i]; vec.push_back(make_pair(b[i], i)); vec2.push_back(make_pair(a[i], i)); }
	sort(vec.begin(), vec.end()); sort(vec2.begin(), vec2.end());
	long long maxn = 0;
	for (int i = vec.size() - 1; i >= 0; i--) {
		long long num = vec[i].second;
		long long pos1 = lower_bound(vec2.begin(), vec2.end(), make_pair(a[num], num)) - vec2.begin();
		add(pos1 + 1, a[num]); add2(pos1 + 1, 1);
		long long L = 0, R = 320000, M;
		while (true) {
			M = (L + R) / 2;
			long long T1 = sum(M), T2 = sum2(M);
			long long U1 = sum(M + 1), U2 = sum2(M + 1);
			long long V1 = 0; if (T2 > 0)V1 = (T1 + T2 - 1) / T2;
			long long V2 = 0; if (U2 > 0)V2 = (U1 + U2 - 1) / U2;
			if (V1 <= vec[i].first && V2 > vec[i].first) { maxn = max(maxn, T2); break; }
			if (V1 > vec[i].first)R = M;
			if (V2 <= vec[i].first)L = M;
			if (M == 319999) { maxn = max(maxn, T2); break; }
		}
	}
	cout << maxn << endl;
	return 0;
}

Measured memory_bytes: 21916
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int r = sc.nextInt();
		int d = sc.nextInt();
        int x = sc.nextInt();
        for(int i=0 ;i<10 ;i++){
          x = r * x - d;
          System.out.println(x);
        }
	}
}


Measured memory_bytes: 22484
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {

    static public void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int h = sc.nextInt();
        int w = sc.nextInt();

        Map<Character, Integer> count = new HashMap<>();
        for (int i = 0; i < h; i++) {
            char[] chs = sc.next().toCharArray();
            for (char ch: chs) count.put(ch, count.getOrDefault(ch, 0) + 1);
        }

        int count4 = 0;
        int count2 = 0;
        int countOther = 0;
        for (int c : count.values()) {
            if(c % 4 == 0) count4++;
            else if(c % 2 == 0) count2++;
            else countOther++;
        }


        boolean valid = true;
        if(h % 2 == 0 && w % 2 == 0) {
            if(count2 > 0 || countOther > 0) valid = false;
        } else if(h % 2 != 0 && w % 2 != 0) {
            if(countOther > 1 || count2 > h / 2 + w / 2) valid = false;
        } else if(h % 2 == 0 && w % 2 != 0){
            if(count2 > h / 2 || countOther > 0) valid = false;
        } else {
            if(count2 > w / 2 || countOther > 0) valid = false;
        }
        if(valid) System.out.println("Yes");
        else System.out.println("No");
    }
}

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

    // Your code here!
    char getGrade(int m, int f, int r){
        int sum=m+f;
        char grade;
        if(m==-1 || f==-1){
            grade = 'F';
        } else if(80 <=sum){
            grade = 'A';
        } else if(65 <=sum && sum<80){
            grade = 'B';
        } else if(50 <=sum && sum<65){
            grade = 'C';
        } else if(30 <=sum && sum<50){
          if( 50 <= r) grade= 'C';
          else  grade = 'D';
        }   else if(sum<30){
            grade ='F';
        }
    
    return grade;
}

int main(){
    int m, f,r;
    while(1){
        cin >> m >> f>> r;
        if(m==-1 && f== -1 && r==-1)break;
        cout << getGrade(m,f,r) << endl;
        
    }
    return 0;
}



Measured memory_bytes: 3104
#include <iostream>
#include <math.h>
using namespace std;

typedef struct point{
    double x;
    double y;
}vect;

double dot(vect a,vect b){
    return a.x*b.x+a.y*b.y;
}

double cross(vect a,vect b){
    return a.x*b.y-a.y*b.x;
}

double norm(vect a){
    return a.x*a.x+a.y*a.y;
}

double ab(vect a){
    return sqrt(norm(a));
}

point project(point p1,point p2,point p){
    vect v1,v2;
    point px;
    v1.x=p.x-p1.x;
    v1.y=p.y-p1.y;

    v2.x=p2.x-p1.x;
    v2.y=p2.y-p1.y;

    double t=dot(v1,v2)/norm(v2);

    px.x=p1.x+t*v2.x;
    px.y=p1.y+t*v2.y;
    return px;
}

point reflect(point p1,point p2,point p){
    point px=project(p1,p2,p);

    vect ppx,ppx_2;
    ppx.x=px.x-p.x;
    ppx.y=px.y-p.y;

    ppx_2.x=2*ppx.x;
    ppx_2.y=2*ppx.y;

    point pr;
    pr.x=ppx_2.x+p.x;
    pr.y=ppx_2.y+p.y;

    return pr;
}

int main() {
    int q;
    point p1,p2,p,pr;
    cin>>p1.x>>p1.y>>p2.x>>p2.y;
    cin>>q;
    for (int i = 0; i < q; ++i) {
        cin>>p.x>>p.y;
        pr=reflect(p1,p2,p);
        printf("%.8lf %.8lf\n",pr.x,pr.y);
    }
    return 0;
}

Measured memory_bytes: 3216
#![allow(unused_macros)]
#![allow(dead_code)]
#![allow(unused_imports)]

use itertools::Itertools;
use text_io::*;

fn main() {
    const U_INF: usize = 1 << 60;
    const I_INF: isize = 1 << 60;
    const MOD: i128 = 1000000007;

    let n: usize = read!();
    let k: usize = read!();
    let mut a = Vec::new();
    for _ in 0..n {
        let ai: usize = read!();
        a.push(ai);
    }
    //
    // let mut dp = vec![vec![0; k + 10]; n + 10];
    // for j in 0..=k {
    //     dp[0][j] = 1;
    // }
    // for i in 1..=n {
    //     for j in 0..=k {
    //         // dp[i-1]は累積和になっていると想定する
    //         let right = dp[i - 1][j];
    //         let left = if j < (a[i - 1] + 1) {
    //             0
    //         } else {
    //             dp[i - 1][j - a[i - 1] - 1]
    //         };
    //         dp[i][j] = (right - left) % MOD;
    //     }
    //
    //     if i != n {
    //         for j in 1..=k {
    //             dp[i][j] += dp[i][j - 1];
    //             dp[i][j] %= MOD;
    //         }
    //     }
    // }
    //
    // println!("{}", dp[n][k]);

    let mut dp = vec![vec![0; k * 3 + 10]; n + 10];
    dp[0][0] = 1;
    for i in 0..n {
        for j in 0..=k {
            let dij = dp[i][j];
            let ai = a[i];
            let ai = ai.min(k - j);
            dp[i + 1][j] += dij;
            dp[i + 1][j] %= MOD;
            dp[i + 1][j + ai + 1] -= dij;
            dp[i + 1][j + ai + 1] %= MOD;
            dp[i + 1][j + ai + 1] += MOD;
            dp[i + 1][j + ai + 1] %= MOD;
        }

        for j in 0..k {
            dp[i + 1][j + 1] += dp[i + 1][j];
            dp[i + 1][j + 1] %= MOD;
        }
    }
    println!("{}", dp[n][k]);
}


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

main = do
    n <- getLine >>= return . read
    ss <- mapM (\_ -> getLine) [1..n]
    let g = map (\x -> (head x, length x)) $ group $ sort ss
    putStrLn ("AC x " ++ show (a "AC" g))
    putStrLn ("WA x " ++ show (a "WA" g))
    putStrLn ("TLE x " ++ show (a "TLE" g))
    putStrLn ("RE x " ++ show (a "RE" g))

a code g = if isJust c then snd (fromJust c) else 0
    where
        c = b code g

b code g = find (\x -> (fst x) == code ) g

Measured memory_bytes: 38948
#include <bits/stdc++.h>
#define fi first
#define se second
#define maxn 200003
#define mod 1000000007
#define pb push_back
using namespace std;
typedef long long LL;
typedef pair<int,int> pi;

int n;
int a[maxn];
int b[maxn];
int ans[maxn];
int remA[maxn];
int remB[maxn];
vector<pi> v;
vector<int> others;
map<int,int> hashCntA,hashCntB;
map<int,vector<int> > indicesA,indicesB;

int main() {
	scanf("%d",&n);
	for( int i = 1 ; i <= n ; i++ ) {
		scanf("%d",&a[i]);
		remA[a[i]]++;
		hashCntA[a[i]]++;
		indicesA[a[i]].pb(i);
	}
	for( int i = 1 ; i <= n ; i++ ) {
		scanf("%d",&b[i]);
		if(remA[b[i]]) {
			remB[b[i]]++;
			hashCntB[b[i]]++;
			indicesB[b[i]].pb(i);
		}
		else
			others.pb(b[i]);
	}
	set<pi> s;
	set<pi>::iterator sit;
	map<int,int>::iterator mit;
	for( mit = hashCntA.begin() ; mit != hashCntA.end() ; mit++ ) {
		v.pb( pi( mit->second , mit->first ) );
		if(remB[mit->first])
			s.insert( pi( mit->second , mit->first ) );
	}
	sort(v.begin(),v.end());
	for( int i = 0 ; i < v.size() ; i++ ) {
		int num = v[i].se;
		int times = v[i].fi;
		//printf("%d %d - %d %d\n",num,times,remA[num],remB[num]);
		if(remB[num])
			s.erase(pi(remA[num],num));
		for( int tt = 0 ; tt < times ; tt++ ) {
			int idx = indicesA[num][tt];
			//printf("idx = %d\n",idx);
			if(s.empty()) {
				//puts("S is empty");
				if(others.empty()) {
					puts("No");
					return 0;
				}
				int x = others.back();
				others.pop_back();
				ans[idx] = x;
			}
			else {
				sit = s.end();
				sit--;
				int num2 = sit->se;
				int times2 = sit->fi;
				//printf("%d %d\n",num2,times2);
				s.erase( pi(times2,num2) );
				remA[num2]--;
				remB[num2]--;
				if(remB[num2])
					s.insert( pi(times2-1,num2) );
				ans[idx] = num2;
			}
		}
		for( int i = 0 ; i < remB[num] ; i++ )
			others.pb(num);
	}
	puts("Yes");
	for( int i = 1 ; i <= n ; i++ )
		printf("%d ",ans[i]);
	puts("");
	return 0;
}

Measured memory_bytes: 80400
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;
using msi = map<string, int>;
using mii = map<int, int>;
using psi = pair<string, int>;
using pii = pair<int, int>;
using vlai = valarray<int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF 1E9
#define EPS 1E-9
#define MOD 1000000007
#define PI 3.1415926535897932384

std::ostream &operator<<(std::ostream &out, const vector<int> &tgt)
{
	string s;
	for (int i = 0; i<tgt.size(); i++) {
		s += (to_string(tgt[i]) + ((i != tgt.size() - 1) ? " " : ""));
	}
	out << s;
	return out;
}

int main() {
	int n, a, b, aa=0, bb=0;
	cin >> n >> a >> b;
	string s;
	cin >> s;
	rep(i, s.size()) {
		if (s[i] == 'a') {
			if (aa < a + b) {
				aa++;
				cout << "Yes" << endl;
			}
			else cout << "No" << endl;
		}
		else if (s[i] == 'b') {
			if (aa < a + b && bb < b) {
				aa++;
				bb++;
				cout << "Yes" << endl;
			}
			else cout << "No" << endl;
		}
		else cout << "No" << endl;
	}
	
}

Measured memory_bytes: 896
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Twinkle Twinkle Little Star
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        ARounding solver = new ARounding();
        solver.solve(1, in, out);
        out.close();
    }

    static class ARounding {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int a = in.nextInt(), b = in.nextInt();
            if (a >= b) out.println(10);
            else
                out.println(0);
        }

    }
}



Measured memory_bytes: 23764
import java.util.*;

class Main {
public static void main(String[] args){

Scanner sc = new Scanner(System.in);
int x = sc.nextInt();
int a = sc.nextInt();
int b = sc.nextInt();
int A = x - a;
if(A < 0){
    A *= -1;
}
int B = x - b;
if(B < 0){
    B *= -1;
}
if(A < B){
  System.out.println("A");
}else{
  System.out.println("B");
}

}
}

Measured memory_bytes: 23764
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define fo(a,b) for(int a=0;a<b;a++)
#define Sort(a) sort(a.begin(),a.end())
#define rev(a) reverse(a.begin(),a.end())
#define fi first
#define se second
#define co(a) cout<<a<<endl
#define sz size()
#define bgn begin()
#define en end()
#define pb(a) push_back(a)
#define pop pop_back
#define V vector
#define P pair
#define V2(a,b,c) V<V<int>> a(b,V<int>(c))
#define V2a(a,b,c,d) V<V<int>> a(b,V<int>(c,d))
#define incin(a) int a; cin>>a
#define yuko(a) setprecision(a)
//#define min min<int>
//#define max max<int>
template<class T>
 void cou(vector<vector<T>> a){
  int b=a.size();
  int c=a[0].size();
  fo(i,b){
    fo(j,c){
      cout<<a[i][j];
      if(j==c-1)
        cout<<endl;
      else
        cout<<' ';
    }
  }
}
/*template<>
 void cou(vector<vector<char>> a){
  int b=a.size();
  int c=a[0].size();
  fo(i,b){
    fo(j,c){
      cout<<a[i][j];
      if(j==c-1)
        cout<<endl;
      else
        cout<<' ';
    }
  }
}*/
 int wari(int a,int b) {
   if(a%b==0)
     return a/b;
   else
     return a/b+1;
 }
 int keta(int a){
  double b=a;
  b=log10(b);
  int c=b;
  return c+1;
 }
 int souwa(int a){
  return a*(a+1)/2;
 }
 /*int lcm(int a,int b){
  int d=a,e=b,f;
  if(a<b)
    swap(a,b);
  int c,m=1;
  while(m){
    c=a%b;
    if(c==0){
       f=b;
      m--;
    }
    else{
      a=b;
      b=c;
 }
  }
  return d*e/f;
    }
  int gcm(int a,int b){
      int d=a,e=b,f;
  if(a<b)
    swap(a,b);
  int c,m=1;
  while(m){
    c=a%b;
    if(c==0){
       f=b;
      m--;
    }
    else{
      a=b;
      b=c;
 }
  }
  return f;
  }*/
 bool prime(int a){
   if(a<2)
     return false;
   else if(a==2)
     return true;
   else if(a%2==0)
     return false;
   double b=sqrt(a);
    for(int i=3;i<=b;i+=2){
      if(a%i==0){
        return false;
      }
    }
   return true;
 }
struct Union{
  vector<int> par;
  Union(int a){
	par= vector<int>(a,-1);
  }
  int find(int a){
    if(par[a]<0)
      return a;
    else
      return par[a]=find(par[a]);
  }
  bool same(int a,int b){
    return find(a)==find(b);
  }
  int Size(int a){
    return -par[find(a)];
  }
  void unite(int a,int b){
    a=find(a);
    b=find(b);
    if(a==b)
      return;
    if(Size(b)>Size(a))
      swap<int>(a,b);
    par[a]+=par[b];
    par[b]=a;
  }
};
int ketas(int a){
  string b=to_string(a);
  int c=0;
  fo(i,keta(a)){
    c+=b[i]-'0';
  }
  return c;
}
int gcm(int a,int b){
    if(b==0)
        return a;
    return gcm(b,a%b);
}
int lcm(int a,int b){
    return a/gcm(a,b)*b;
}
/*struct aa{
	vector<int> gt;
  aa(int n){
	gt= vector<int>(n, 1);
  }
	void c(V<int> d,int b){
	if(d[b]==0){
		gt[d[b]-1]++;
		gt[gt.sz-1]++;
	}
	else{
		gt[d[b]-1]++;
		c(d,d[d[b]]-1);
	}
}
void cok(int a){
	cout<<gt[a-1]<<endl;
	fo(i,a-1)
	cout<<gt[i]<<endl;
}
};
*/
signed main(){
	int a;
	cin>>a;
	int b,c;
	cin>>b;
	fo(i,a-1){
	cin>>c;
	b=lcm(b,c);
}
cout<<b<<endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<cstring>
#include<algorithm>

char s[100], t[100];

using namespace std;

bool cmpminu(char &a, char &b) {
    return a > b;
}

int main ()
{

    scanf("%s\n%s", s, t);

    sort(s, s + strlen(s));

    //printf("%s\n", s);
    sort(t, t + strlen(t), cmpminu);
    //printf("%s\n", t);

    if(strcmp(s, t) < 0) {
        printf("Yes");
    } else {
        printf("No");
    }

    return 0;
}


Measured memory_bytes: 128
#include<cstdio>
#include<bits/stdc++.h>
typedef long long int ll;
#define REP(i, n) for(int i = 0; i < (n); i++)
#define FOR_IN(i, a, b) for(int i = (a); i < (b); i++)
#define BETWEEN(x, a, b) ((x) >= (a) && (x) <= (b))
#define BIT(b, i) (((b) >> (i)) & 1)
#define LOG_F 1
#define LOG(...) if(LOG_F) fprintf(stderr, __VA_ARGS__)

using namespace std;

ll pow(int x, int n){
  return n == 0 ? 1 : x * pow(x, n - 1);
}


/*
n
v1 ... vn

n 10^5 even
vi 10^5
 */
#define MAX 100000
int n,v[100000];
int even[MAX+1], odd[MAX+1];

template<class T>
auto comp_idx(T* ptr){
  return [ptr](int l_idx, int r_idx){
    return ptr[l_idx] > ptr[r_idx];
  };
}

int main(){
  cin>>n;
  REP(i,n){
    cin>>v[i];
    if(i%2==0){
      even[v[i]]++;
      cerr<<"hoge"<<endl;
    } else {
      odd[v[i]]++;      
    }
  }

  int even_idx[MAX+1], odd_idx[MAX+1];
  REP(i,MAX+1){
    even_idx[i] = i;
    odd_idx[i] = i;
  }
  
  sort(even_idx, even_idx+MAX+1, comp_idx(even));
  sort(odd_idx, odd_idx+MAX+1, comp_idx(odd));

  int sub=0;
  if(even_idx[0]==odd_idx[0]){
    sub = max(even[even_idx[0]]+odd[odd_idx[1]], even[even_idx[1]]+odd[odd_idx[0]]);
  } else {
    sub = even[even_idx[0]]+odd[odd_idx[0]];
  }

  cout<<n-sub<<endl;
  return 0;
}


Measured memory_bytes: 2304
#include <iostream>
#include <string.h>
#include <cmath>
#include <algorithm>
using namespace std;

int h[100000], d[100000];

int main() {

	int n;
	cin >> n;

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

	memset(d, 0, 100000);

	d[1] = abs(h[1] - h[0]);

	for(int i = 2; i < n; i++)
		d[i] = min(d[i - 2] + abs(h[i] - h[i - 2]), d[i - 1] + abs(h[i] - h[i - 1]));

	cout << d[n - 1] << endl;

	return 0;
}

Measured memory_bytes: 1024
#include<iostream>//数据过水，不剪枝即可AC 
#include<cstring>
#include<cstdio>
using namespace std;
char s[100005];
int win=0,los=0,len,maxn=1000000,pa,ro;
void dfs(int k)
{
	if(s[k]=='g'){
		if(pa+1<=ro){
			win++;
			pa++;
			dfs(k+1);
			pa--;
			win--;
		}
		else{
				ro++;
				dfs(k+1);
				ro--;
			}
	}
	if(s[k]=='p'){
		if(pa+1<=ro){
			pa++;
			dfs(k+1);
			pa--;
		}
		else{
			los++;
			ro++;
			dfs(k+1);
			ro--;
			los--;
		}
	}
	if(k==len&&pa<=ro){
		if(maxn>(win-los))maxn=(win-los);
	}
	
}
int  main(){
	scanf("%s",&s);
len=strlen(s);
	dfs(0);
cout<<maxn;
}

Measured memory_bytes: 3456
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>

#define ll long long
#define ull unsigned long long

using namespace std;

int main() {
    int n, m;
    cin >> n >> m;
    vector< set<int> > rule(n+1);
    for (int i = 0; i < m; i++) {
        int s, c;
        cin >> s >> c;
        rule[s].insert(c);
    }

    string ans(n, '0');
    bool possible = true;
    for (int i = 1; i <= n; i++) {
        if (rule[i].size() > 1) {
            possible = false;
            break;
        } else if (!rule[i].empty()) {
            ans[i-1] = '0' + *rule[i].begin();
        }
    }

//    bool all0 = true;
//    for (char c: ans) {
//        all0 &= (c == '0');
//    }
//
//    if (n > 1 && all0) {
//        possible = false;
//    }

    if (n > 1 && ans[0] == '0') {
        if (rule[1].empty()) {
            ans[0] = '1';
        } else {
            possible = false;
        }
    }

    cout << (possible ? ans : "-1");
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
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 long long INF = 1LL << 60;
 
typedef pair<ll,ll> pairs;
vector<pairs> p;
bool pairCompare(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.first < secondElof.first;
}
#define MAX_N 1000100
bool x[MAX_N];
ll num[MAX_N];
ll fibl[MAX_N]={0};
 
ll fib(ll a){
    if (fibl[a]!=0)return fibl[a];
    if (a==0){
        return 0;
    }else if (a==1){
        return 1;
    }
    return fibl[a]=fib(a-1)+fib(a-2);
}
 
ll eratosthenes(ll n) {
    int p = 0;
    for (ll i=0; i<=n; ++i) x[i] = true;
    x[0] = x[1] = false;
    for(int i=2; i<=n; ++i) {
        if(x[i]) {
            p++;
            for(int j=2*i; j<=n; j+=i) x[j] = false;
        }
        
        num[i] = p;
    }
    return p;
}
 
ll gcd(ll a,ll b){
    if (a%b==0)return(b);
    else return(gcd(b,a%b));
}
 
ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

int main(){
    ll n;
    cin >> n;
    
    if(n%2 == 0)cout << n << endl;
    else cout << n*2 << endl;
    
    return 0;
}



Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    int r, c, a;
    int A[102][102] = {};
    cin >> r >> c;
    for(int i = 1; i <= r; i++){
        for(int j = 1; j <= c; j++){
            cin >> a;
            A[i][j] = a;
            A[i][c+1] += a;
            A[r+1][j] += a;
            A[r+1][c+1] += A[i][j];
        }
        
    }
    for(int i = 1; i <= r+1; i++){
        for(int j = 1; j <= c+1; j++){
            if (j != 1){
               cout << " "; 
            }
            cout << A[i][j];
        }
        cout << endl;
    }
    return 0;
}


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

    ll cnt0 = 0, cnt1 = 0;
    ll posR = -1;
    vl ans(n);
    rep(i, n) {
        if(i%2 == 0) {
            cnt0++;
        }
        else if(i%2 == 1) {
            cnt1++;
        }
        if(i < n-1 && s[i] == 'R' && s[i+1] == 'L') {
            posR = i;
        }
        if(i < n-1 && s[i] == 'L' && s[i+1] == 'R') {
            if(posR%2 == 0) {
                ans[posR] = cnt0;
                ans[posR+1] = cnt1;
            }
            else if(posR%2 == 1) {
                ans[posR] = cnt1;
                ans[posR+1] = cnt0;
            }
            cnt0 = 0;
            cnt1 = 0;
        }
    }
    if(posR%2 == 0) {
        ans[posR] = cnt0;
        ans[posR+1] = cnt1;
    }
    else if(posR%2 == 1) {
        ans[posR] = cnt1;
        ans[posR+1] = cnt0;
    }
    
    for(auto p : ans) {
        cout << p << " ";
    }
    
    cout << endl;
    re0;
}

Measured memory_bytes: 1408
#include <iostream>
#include <vector>
#include <algorithm>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n,k;
  long long ans = 0;
  int a[200010] = {0};
  cin >> n >> k;
  rep(i,n){
    int t;
    cin >> t;
    a[t]++;
  }
  sort(a,a+200001,greater<int>());
  // int *pos;
  // pos = lower_bound(a,a+200001,1);
  rep(i,n){
    ans += a[i];
    k--;
    if(k<=0) break;
  }
  cout << n-ans << endl;
  return 0;
}


Measured memory_bytes: 1024
#include "bits/stdc++.h"
using namespace std;
#define watch(x) cout << (#x) << " is " << (x) << endl

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  double r;
  cin>>r;
  double ans;
  ans=2*M_PI*r;
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 3804
#include <iostream>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <random>
#include <chrono>
#include <string>
#include <bitset>
#include <cassert>
#include <queue>
#include <memory>

//#pragma comment(linker, "/STACK:16777216")
//#pragma GCC optimize("O3")
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC optimize("unswitch-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,sse4.1,sse4.2,abm,mmx,avx,avx2,popcnt,tune=native")

using namespace std;

//mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

#define ll long long
#define ull unsigned long long
//#define double long double
#define int ll
//#define int ull
//#define int short
//#define int unsigned short
//#define int unsigned int
#define mp make_pair
#define F first
#define S second
#define pii pair<int, int>
#define hash hash228
const int SZ = 2e5 + 4;
const double EPS = 1e-7;
const int mod = 998244353;
const int hashpow = 2;
const int inf = 2e9;

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

int n;

void read() {
    cin >> n;
}

void solve() {
    int ans = 0;
    for (int i = 1; i <= n; ++i) {
        for (int j = 1; j <= n; ++j) {
            for (int k = 1; k <= n; ++k) {
                ans += __gcd(i, __gcd(j, k));
            }
        }
    }

    cout << ans << "\n";
}

signed main() {

#ifdef __LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#else
    ios_base::sync_with_stdio(0);
    cin.tie(0);
#endif

//    int t;
//    cin >> t;
//    for (int i = 0; i < t; ++i) {
        read();
        solve();
//    }

    return 0;
}

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

int main() {
    int n, y;
    cin >> n >> y;
    y /= 1000;
    
    rep(i,y) rep(j,y) {
        int k = y - (10 * i + 5 * j);
        if (0 <= k && i+j+k == n) {
            printf("%d %d %d\n", i, j, k);
            return 0;
        }
    }
    cout << "-1 -1 -1" << endl;
    return 0;
}

Measured memory_bytes: 3700
#include<bits/stdc++.h>
using namespace std;
int main(void){
  int n,d;
  cin >> n >> d;
  int data[n][d];
  for(int i=0;i<n;i++){
    for(int j=0;j<d;j++){
      cin >> data[i][j];
    }
  }
  //処理
  int ans = 0;
  int sum=0;
  int i=0;
  int k=0;
  while(i<n){
    k=i+1;
    while(k<n){
      sum = 0;
      if(k>=n)k=0;
      for(int j=0;j<d;j++){
        sum += pow(data[i][j]-data[k][j],2.0);
      }
      float n = sqrt(sum);
      if (ceil(n) == floor(n))ans++;
      k++;
    }
    i++;
  }

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


Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
    public static void main (String [] args){
        Scanner sc =new Scanner(System.in);
        int i=1;
        while(true){
        
            int H =sc.nextInt();
            int W =sc.nextInt();

        if(H==0 && W==0)break;
        for(int b=0;b<H;b++){
            int n=b;
           for(int a=0;a<W;a++){
            
            if(n%2==0)System.out.printf("#");
            else     System.out.printf(".");
            n++;
        }
        System.out.println();
        }
        System.out.println();
    }       
        sc.close();
   }
 
}


Measured memory_bytes: 58552
def main():
  N = int(input())
  A = list(map(int,input(). split ()))

  if 0 in A:
    print(0)
    return

  prod = 1
  for a in A:
    prod *= a
    if prod > 1000000000000000000:
      print(-1)
      return
  print(prod)

main ()


Measured memory_bytes: 21716
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <climits>
#include <cstring>
#include <string>
#include <set>
#include <bitset>
#include <map>
#include <queue>
#include <stack>
#include <vector>
#include <list>
#define rep(i,m,n) for(i=m;i<=n;i++)
#define mod 1000000007
#define inf 0x3f3f3f3f
#define vi vector<int>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define ll long long
#define pi acos(-1.0)
#define pii pair<int,int>
#define Lson L, mid, ls[rt]
#define Rson mid+1, R, rs[rt]
#define sys system("pause")
#define intxt freopen("in.txt","r",stdin)
const int maxn=1e3+10;
using namespace std;
ll gcd(ll p,ll q){return q==0?p:gcd(q,p%q);}
ll qpow(ll p,ll q){ll f=1;while(q){if(q&1)f=f*p%mod;p=p*p%mod;q>>=1;}return f;}
inline void umax(int &p,int q){if(p<q)p=q;}
inline void umin(int &p,int q){if(p>q)p=q;}
inline ll read()
{
    ll x=0;int f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
int n,m,k,t,a,b,c,d;
ll C[maxn][maxn],dp[2][maxn];
void init()
{
    C[0][0]=1;
    for(int i=1;i<=n;i++)
    {
        C[i][0]=1;
        for(int j=1;j<=i;j++)
        {
            C[i][j]=(C[i-1][j-1]+C[i-1][j])%mod;
        }
    }
}
int main()
{
    int i,j;
    scanf("%d%d%d%d%d",&n,&a,&b,&c,&d);
    init();
    dp[t][n]=1;
    for(int i=a;i<=b;i++)
    {
        ll tmp=1;
        for(int j=0;j<=n;j++)dp[t^1][j]=dp[t][j];
        for(int j=1;j<=d;j++)
        {
            if(j*i>n)break;
            tmp=tmp*C[i*j][i]%mod*qpow(j,mod-2)%mod; // j^{p-1} = 1 (mod p)
            if(j<c)continue;
            for(int k=i*j;k<=n;k++)
            {
                dp[t^1][k-i*j]=(dp[t^1][k-i*j]+dp[t][k]*C[k][i*j]%mod*tmp%mod)%mod;
            }
        }
        t^=1;
    }
    printf("%lld\n",dp[t][0]);
    //system("Pause");
    return 0;
}

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

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define each(i, mp) for (auto &i : mp)
int main()
{
  int n;
  cin >> n;
  int a[n + 1];
  map<int, int> m;
  ll ans = 0;
  for (int i = 1; i <= n; i++)
  {
    cin >> a[i];
    ans += m[a[i] - i];
    m[-a[i] - i]++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 21352
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

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

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL


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


    int N;
    cin >> N;
    bool ans = true;
    int A;
    rep (i, N)
    {
        cin >> A;
        if (A % 2 == 0)
        {
            if (!(A % 3 == 0 || A % 5 == 0))
            {
                ans = false;
                break;
            }
        }
    }

    cout << (ans ? "APPROVED\n" : "DENIED\n");
    return 0;
}



Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    int A[100010];
    rep(i, N) cin >> A[i];
    int tmp = 0;
    rep(i, N) tmp += A[i];
    int ans = tmp;
    int K = 0;
    int negative = 0;
    int zero = 0;
    rep(i, N) {
        if (A[i] < 0) negative++;
        else if (A[i] == 0) zero++;
    }
    rep(i, N) K += abs(A[i]);
    if (zero > 0 || negative % 2 == 0) {
        cout << K << endl;
        return 0;
    }
    //dump(K);
    rep(i, N) {
        ans = max(ans, K - abs(A[i]) * 2);
    }
    cout << ans << endl;

    return 0;
}


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

Measured memory_bytes: 1700
#include <bits/stdc++.h>
#define F(i,a,b) for(int i=(a);i<=(b);++i)
#define F_(i,a,b) for(int i=(a);i>=(b);--i)
#define G(i,u) for(int i=Head[a];i;i=Next[i])

typedef long long ll;
typedef double db;
typedef long double ld;

template<typename T> inline T max(T& a, T b) { return a>b?a:a=b; }
template<typename T> inline T min(T& a, T b) { return a<b?a:a=b; }

const int N = 5005; 

std::vector<int> ch[26*10];
char s[N], ans[N];
int cnt = -1, k, n, tot = 1, siz;

bool dfs(int u) {
	cnt ++;
	if(cnt == k) {
		return true;
	}
	int t[26], sz = ch[u].size(); 
	memset(t,0,sizeof(t));
	F(i,0,sz-1) {
		int p = ch[u][i], v = s[p] - 'a';
		if(!t[v]) t[v] = ++tot;
		if(p<n) ch[t[v]].push_back(p+1);
	}
	F(i,0,25) if(t[i]) {
		if(dfs(t[i])) { ans[siz++] = 'a'+i; return true; }
	}
	return false;
}

int main() {
	scanf("%s%d", s+1, &k);
	n = strlen(s+1);
	F(i,1,n) ch[1].push_back(i);
	dfs(1);
	F_(i,siz-1,0) printf("%c", ans[i]);
	printf("\n");
	return 0;
}


Measured memory_bytes: 384
import sys

prime_table=[i for i in range(10010)]
prime_table[1]=0

for i in range(2,101):
    if prime_table[i]==i:
        k=2
        while k*i<10010:
            prime_table[k*i]=0
            k+=1

sum_list=[0]
k=0
for i in prime_table:
    if i!=0:
        k+=i
        sum_list.append(k)


while True:
    n=int(input())
    if n==0:
        sys.exit()
    count=0
    for i in sum_list:
        if i-n in sum_list:
            count+=1
    print(count)

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

int main(){
  int N;
  int a,b; // テつ静つカテつ地テつづδ古つ値テつ段テつ、テつトテつッテつピテつεつ禿つグテつづδ古つ値テつ段 1<= a,b <=1000
  int c;   // テつ静つカテつ地テつづδ古つカテつεつ催つεつ甘つー              1<= a,b <=1000  
  int d[100]; // テつトテつッテつピテつεつ禿つグテつづδ古つカテつεつ催つεつ甘つー     1<= d[i] <=10000


  cin >> N >> a >> b >> c;
  //  cout << N<<", "<<a<<", "<<b<<", "<<c<<endl;
  for( int i=0;i<N;i++ ){
    cin >> d[i];
    //    cout << d[i] << ",";
  }
  bool f;
  do{
    f=false;
    for( int i=1;i<N;i++ )
      if( d[i-1]<d[i] ){
	int buf=d[i-1]; d[i-1]=d[i]; d[i]=buf; f=true;
      }
  }while( f );

  int S=c, B=a; // S:テつ陛つェテつ子テつ、B:テつ陛つェテつ陛δェ
  for( int i=0;i<N;i++ ){
    //    cout <<i<<":"<< b*S/B << endl;
    if( B*d[i]> b*S ){
      //      cout << "use : "<< i<<endl;
      S+=d[i]; B+=b;
    }
  }
  //  cout <<"S="<<S<<", B="<<B<<endl;

  int p = S/B;
  cout << p << endl;

  return 0;
}

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;

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

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

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

string s;

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

    int del=2;
    while(true){//削っても偶文字列があることは保証されている
        int n = (s.size()-del) / 2;

        string s1=s.substr(0,n);
        string s2=s.substr(n,n);
        //  DEBUG(n);
        //  DEBUG2(s1,s2);

        if(s1.compare(s2)==0){
            cout << s.size()-del << endl;
            return 0;
        }

        del += 2;
    }
    
    return 0;
}

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

const int N = pow(10,5);

vector<bool> isp(N+1, true);

void sieve() {
  isp[0] = false;
  isp[1] = false;
  for (int i=2; pow(i,2)<=N; i++) {
    if (isp[i]) for(int j=2; i*j<=N; j++) isp[i*j] = false;
  }
}

int main() {
  int N;
  long long counter=0;
  int counter1,counter2=0;
  cin>>N;
  int a[50]={};
  sieve();
  for (long long i=2; i<=N; i++) {if (isp[i]) a[i]=1;
  else continue;}
  for(int j=2;j<50;j++){
  if(a[j]==1){
  for(int i=j;i<=N;i*=j){
  counter+=N/i;}
  a[j]=counter;
  counter=0;}
  else continue;}
  if(a[2]>=74){
  counter2++;}
  int count24=0;
  int count2=0;
  int count14=0;
  int count4=0;
  for(int j=2;j<50;j++){
  if(a[j]>=24){
  count24++;}
  if(a[j]>=14){
  count14++;}
  if(a[j]>=4){
  count4++;}
  if(a[j]>=2){
  count2++;}}
  counter2+=max(0,(count2-1)*count24)+max(0,(count14)*(count4-1))+max(0,count4*(count4-1)*(count2-2)/2);
  cout<<counter2<<endl;}

Measured memory_bytes: 256
from collections import Counter
N = int(input())

S = [input() for _ in range(N)]
SC = Counter(S)
Ans = []
num = -1
for ans, value in SC.most_common():
    if num == -1:
        num = value
        Ans.append(ans)
    else:
        if num != value:
            break
        else:
            Ans.append(ans)
Ans.sort()

for a in Ans:
    print(a)

Measured memory_bytes: 147388
n = int(input())
p = list(map(int, input().split()))
biggest = p[0]
smallest = p[0]
count = 1
for i in range(1, n):
    if p[i] < biggest and p[i] < smallest:
        smallest = p[i]
        count += 1
    elif p[i] > biggest:
        biggest = p[i]
print(count)


Measured memory_bytes: 75580
flag = 0
lst = input().split()
lst[0]=int(lst[0])
lst[1]=int(lst[1])
if lst[1]%2 == 1 :
    flag =1
if lst[0] < lst[1]/4 :
    flag = 1
if lst[0] > lst[1]/2 :
    flag = 1

if flag == 0:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 9176
#include<stdio.h>
int main(void){
    int a,b,c,k;
    scanf("%d%d%d%d",&a,&b,&c,&k);
    if(k<=a){
        printf("%d",k);
        return 0;
    }
    if(k>a&&k<=a+b){
        printf("%d",a);
        return 0;
    }
    if(a+b<k&&k<=a+b+c){
        printf("%d",2*a+b-k);
        return 0;
    }
}


Measured memory_bytes: 1668
var ans,n,m,i,j,tot,u,v:longint;
    last,pre,other:array[0..100007] of longint;
	vis:array[0..100007] of boolean;
procedure insert(u,v:longint);
begin
  inc(tot);
  other[tot]:=v;
  pre[tot]:=last[u];
  last[u]:=tot;
end;
procedure dfs(x,u:longint);
var q,v:longint;
begin
  if (x=n) then inc(ans) else
  begin
    q:=last[u];
    while (q>0) do
	begin
	  v:=other[q];
	  if not(vis[v]) then
	  begin
	    vis[v]:=true;
	    dfs(x+1,v);
	    vis[v]:=false;
	  end;
	  q:=pre[q];
	end;
  end;
end;
begin
  readln(n,m);
  tot:=0;
  fillchar(last,sizeof(last),0);
  fillchar(pre,sizeof(pre),0);
  fillchar(other,sizeof(other),0);
  for i:=1 to m do
  begin
    readln(u,v);
    insert(u,v);
    insert(v,u);
  end;
  ans:=0;
  fillchar(vis,sizeof(vis),false);
  vis[1]:=true;
  dfs(1,1);
  writeln(ans);
end.
  

Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
  int64_t n;
  cin >> n;
  vector<int64_t> a(n+1);
  rep(i,n){
    cin >> a.at(i);
  }
  a.at(n)=0;
  sort(a.begin(),a.end());
  reverse(a.begin(),a.end());
  int64_t p=0,q=0,i=0;
  while(a.at(i)!=0 && q==0){
    if(a.at(i)==a.at(i+1) && p==0){
      p=a.at(i);
      i+=2;
      continue;
    }
    if(a.at(i)==a.at(i+1)&& p!=0){
      q=a.at(i);
      break;
    }
    i++;
  }
  int64_t ans=p*q;
  cout << ans;
}


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

using namespace std;

#define MAX 300001
typedef unsigned long long ull;
const ull B = 1000000007ULL;

int main(){
    int N,M;
    char s[MAX];
    scanf("%d%d%s",&N,&M,s);
    vector<ull> p(N+1),hash(N+1);
    p[0] = 1; hash[0] = 0;
    for(int i = 0 ; i < N ; i++){
        hash[i+1] = hash[i]*B + s[i];
        p[i+1] = p[i]*B;
    }
    int L = 0, R = 0;
    unordered_set<ull> st;
    while(M--){
        scanf("%s",s);
        if(s[0] == 'L' && s[1] == '+'){
            L++;
        }else if(s[0] == 'L' && s[1] == '-'){
            L--;
        }else if(s[0] == 'R' && s[1] == '+'){
            R++;
        }else{
            R--;
        }
        st.insert(hash[R+1]-hash[L]*p[R-L+1]);
    }
    printf("%d\n",(int)st.size());
    return 0;
}

Measured memory_bytes: 20176
#include<bits/stdc++.h>
   using namespace std;
   #define bolt ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
   #define text_wali_bakchodi freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
   #define F first
   #define S second
   #define pb push_back
   #define lb lower_bound
   #define ub upper_bound
   #define endl "\n"
   typedef long long ll;
   typedef long double ld;
   const ll mod = 998244353 ;
   const ld pi=3.1415926535897932384626433;
   const ll inf = 1e18;
   bool isprime(ll n){for(ll i=2;i*i<=n;++i){if(n%i==0){return false;}}return true;}
   ll factorial(ll n){return (n==1 || n==0) ? 1:n*factorial(n-1);}
   ll power(ll x,ll y){ll res=1;x=x%mod;while(y>0){if(y&1)res=((res%mod)*(x%mod))%mod;y=y>>1;x=((x%mod)*(x%mod))%mod;}return res;}
   ll gcd(ll a,ll b){if (a==0)return b;return gcd(b%a,a);}
   ll lcm(ll a,ll b){return (a/gcd(a,b)*b);}
   ll max(ll a,ll b){ll sol=a>b?a:b;return sol;}
   ll min(ll a,ll b){ll sol=a<b?a:b;return sol;}
   ll mul(ll a,ll b){return ((a%mod)*(b%mod))%mod;}
   ll add(ll a,ll b){return ((a%mod)+(b%mod))%mod;}
   int main()
   {
      bolt;
      ll n;
      cin>>n;
      ll k=0;
      k+=(n/500);
      k*=1000;
      n%=500;
      ll ans=0;
      ans+=n/5;
      ans*=5;
      ans+=k;
      cout<<ans;
   }


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,m,i;
    cin>>n>>m;
    int sum=0;
    int arr[m];
    for(i=0;i<m;i++)
    {cin>>arr[i];
    sum+=arr[i];
    }
    if(sum>n)
    cout<<"-1"<<endl;
    else
    {
        cout<<n-sum<<endl;
    }
    
}

Measured memory_bytes: 3676
#include <iostream>
#include <string>
#include <cstring>
#include <fstream>
#include <cmath>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <map>
#include <deque>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <unordered_map>

using namespace std;

int main() {
    

    double x1,y1,x2,y2;
    cin >> x1 >> y1 >> x2 >> y2;
    cout << fixed;
    cout << setprecision(6);
    cout << sqrt(pow(x1-x2,2) + pow(y1-y2,2)) << endl;

}


Measured memory_bytes: 3296
import math

n, k = map(int, input().split())

p = 1000000007

b = k
r = n - k


def P(n, r):
    return (math.factorial(n) // math.factorial(n - r))


def C(n, r):
    return (P(n, r) // math.factorial(r))


for i in range(k):
    t = i + 1
    if (b - 1) < (t - 1):
        print("0")
    elif (r + 1) < t:
        print("0")
    else:
        x = C(b - 1, t - 1)
        y = C(r + 1, t)
        print((x * y) % p)


Measured memory_bytes: 3316