akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define watch(x) cout << (#x) << " is " << (x) << endl
#define fast                          \
	ios_base::sync_with_stdio(false); \
	cin.tie(NULL);
#define openfile freopen("input.txt", "r" ,stdin); freopen("output.txt", "w", stdout); 
#define FOR(n) for(int i(0);i<n;++i)
#define ASC(i,a,b) for(int i(a); i <=b; ++i)
#define DESC(i,a,b) for(int i(a);i>=b;i--)
#define WL(t) while(t--)
#define SZ(a) int((a).size())
#define PB push_back
#define MP make_pair
#define FF first
#define SS second
#define BB begin()
#define EE end()
#define all(c) c.BB, c.EE
#define present(container, element) (container.find(element) != container.end())
// ^^for set,map etc
#define cpresent(container, element) (find(all(container), element) != container.end())
// for vector,array etc
#define tr(container, it) for (auto it = container.begin(); it != container.end(); it++)
#define gcd(a, b) __gcd((a), (b))
#define lcm(a, b) ((a) * (b)) / gcd((a), (b))
typedef long long LL;
typedef long double LD;
typedef vector<int> vi;
typedef vector<LL> vl;
typedef map<char,int> mci;
typedef pair<int, int> pii;
typedef map<int,pii> ipii;
const float INF = numeric_limits<float>::infinity();
const int MOD = 1e9 + 7;
const double PI = 3.14159265358979323846264338;
const LL big=998244353;

#ifdef _DEBUG
freopen(input.txt,"r",stdin);
freopen(output.txt,"w",stdout);
#endif

int main(){
	int n;
	string s;
	cin >> n >> s;
	if(n<3200) cout << "red";
	else cout << s;
}

Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

use std::cmp::max;

fn main() {
    let a: i64 = read();
    let b: i64 = read();
    let c: i64 = read();
    let x: i64 = read();
    let y: i64 = read();
    let mut minv = std::i64::MAX;

    for i in 0..2 * max(x, y) + 4 {
        let mut ans = c * i;
        ans += max(x - (i / 2), 0) * a;
        ans += max(y - (i / 2), 0) * b;
        if ans < minv {
            minv = ans;
        }
    }
    println!("{}", minv);
}


Measured memory_bytes: 4352
import java.util.Arrays;
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		player player1[] = new player[8];
		player player2[] = new player[8];
		player player3[] = new player[8];
        for(int i=0; i<8; i++)player1[i] = new player(sc.nextInt() , sc.nextDouble());
        for(int i=0; i<8; i++)player2[i] = new player(sc.nextInt() , sc.nextDouble());
        for(int i=0; i<8; i++)player3[i] = new player(sc.nextInt() , sc.nextDouble());
        
        Arrays.sort(player1);
        System.out.println(player1[0] + "\n" + player1[1]);
        player1[0].record = 50;
        player1[1].record = 50;
         
        Arrays.sort(player2);
        System.out.println(player2[0] + "\n" + player2[1]);
        player2[0].record = 50;
        player2[1].record = 50;
         
        Arrays.sort(player3);
        System.out.println(player3[0] + "\n" + player3[1]);
        player3[0].record = 50;
        player3[1].record = 50;
        
        Arrays.sort(player1);
        Arrays.sort(player2);
        Arrays.sort(player3);
        player player4[]= new player[6];
        player4[0] = new player(player1[0].playerNumber,player1[0].record);
        player4[1] = new player(player1[1].playerNumber,player1[1].record);
        player4[2] = new player(player2[0].playerNumber,player2[0].record);
        player4[3] = new player(player2[1].playerNumber,player2[1].record);
        player4[4] = new player(player3[0].playerNumber,player3[0].record);
        player4[5] = new player(player3[1].playerNumber,player3[1].record);
        Arrays.sort(player4);
        System.out.println(player4[0] + "\n" + player4[1]);
    }
}
	class player implements Comparable<player>{
		int playerNumber;
	    double record;
	    player(int playerNumber, double record){
	        this.playerNumber = playerNumber;
	        this.record = record;
	    }
	    @Override
	    public String toString(){
	        return  playerNumber + " " + record;
	    }
	    @Override
	    public int compareTo(player o) {
	    	return new Double(record).compareTo(o.record);
	    }
}

Measured memory_bytes: 28292
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll MOD = 1'000'000'007;
const ld PI = acos(-1);  
const ld EPS = 0.0000000001;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define REP(i, n) for(ll i=0; i<(ll)(n); i++)
#define REPD(i, n) for(ll i=n-1; 0<=i; i--)
#define FOR(i, a, b) for(ll i=a; i<(ll)(b); i++)
#define FORD(i, a, b) for(ll i=a; (ll)(b)<=i; i--)
#define ALL(x) x.begin(), x.end()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
int main(){
    ll n;   cin >> n;
    ll sz=0;
    REP(i, n)
        if((i+2)*(i+1)/2 == n){
            sz=i+1;   break;
        }
    if(!sz) cout << "No" << endl;
    else{
        cout << "Yes" << endl;
        cout << sz+1 << endl;   
        vector<vector<ll>>  v(sz+1);
        ll index=0;
        REP(i, sz+1){
            REP(j, sz-i){
                v[i].push_back(index);
                v[i+j+1].push_back(index++);
            }
        }
        REP(i, sz+1){
            cout << v[i].size() << ' ';
            REP(j, sz)  cout << v[i][j]+1 << ' ';
            cout << endl;
        }
    }
}

Measured memory_bytes: 5064
using System;
 
public class Hello{
	public static void Main(){
      string[] s = Console.ReadLine().Split(' ');
      int N = int.Parse(s[0]);
      int M = int.Parse(s[1]);
      int C_1,C_2;
      C_1=N*(N-1)/2;
      C_2=M*(M-1)/2;
      Console.WriteLine(C_1+C_2);
	}
} 

Measured memory_bytes: 13140
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<string.h>
#include<math.h>
#include<map>

#define MOD 1e9+7;
#define INF 1e17+9;
#define PI acos(-1);

using namespace std;

int main() {
	int a,b;
	cin >> a >> b;
	for(int i=1;i<=20000;i++){
		if(i*2/25==a && i/10==b){
			cout << i << endl;
			return 0;
		}
	}
	cout << "-1" << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef long long LD;
typedef pair<int,int> PII;
const int N=503001;
const int M=2*N;
const LL MOD1=98764321261LL;
const LL MOD=998244353LL;

inline int lowbit(int x){
    return x&(-x);
}

struct fenwick {
    LL a[N];
    int n;
    void init(int n){
        for(int i=0;i<=n;++i)
            a[i]=0;
        this->n=n;
    }
    void add(int x,LL v) {
        for(int i=x;i<=n;i+=lowbit(i))
            a[i]+=v;
    }
    LL query(int x) {
        LL ret=0;
        for(int i=x;i;i^=lowbit(i))
            ret+=a[i];
        return ret;
    }
    void rangeadd(int l,int r,LL v) {
        add(l,v);
        add(r+1,-v);
    }
    LL rangequery(int l,int r) {
        l=max(l,1);
        r=min(r,n);
        if(r<l)return 0;
        LL ret=query(r);
        ret-=query(l-1);
        return ret;
    }
};

inline LL powmod(LL x,LL y,LL MOD){
    LL ret=1;
    while(y){
        if(y&1LL)ret=ret*x%MOD;
        x=x*x%MOD;
        y=y>>1;
    }
    return ret;
}

struct graph{
    int head[N],next[M],to[M];
    int tot;
    inline void init(int n){
        for(int i=0;i<=n;++i)
            head[i]=-1;
        tot=0;
    }
    inline void addedge(int x,int y){
        to[tot]=y;
        next[tot]=head[x];
        head[x]=tot;
        ++tot;
    }
};

struct point{
    LD x,y;
    point(){}
    point(LD x,LD y):x(x),y(y){}

    void read(){
        scanf("%lld%lld",&x,&y);
    }

    point operator + (const point &rhs)const{
        return point(x+rhs.x,y+rhs.y);
    }

    point operator - (const point &rhs)const{
        return point(x-rhs.x,y-rhs.y);
    }

    LD operator ^ (const point &rhs)const{
        return x*rhs.y-y*rhs.x;
    }

    bool operator < (const point &rhs)const{
        if(y!=rhs.y)return y<rhs.y;
        return x<rhs.x;
    }
};

LL phi(LL x)
{
    LL res=x;
    for(LL i=2;i*i<=x;++i)
    {
        if(x%i==0)
        {
            res=res/i*(i-1);
            while(x%i==0) x/=i;
        }
    }
    if(x>1) res=res/x*(x-1);
    return res;
}


int n,m,k;
LL a[N],b[N];

int main(){
    int cases=1;
    //init();
    //scanf("%d",&cases);
    for(int iii=1;iii<=cases;++iii){
        LL ans=0;
        scanf("%d",&n);
        for(int i=0;i<n;++i){
            int x;
            scanf("%d",&x);
            b[i]=x;
            ans+=a[x];
            ++a[x];
        }
        for(int i=0;i<n;++i){
            printf("%lld\n",ans-(a[b[i]]-1));
        }

    }



}
/*
1
4 8
1 2 1
2 3 1
3 4 1
4 1 1
1 2 2
2 3 2
3 4 2
4 1 2
*/


Measured memory_bytes: 8192
N, K = map(int, input().split())
x = list(map(int, input().split()))

ans = 10 ** 10
for i in range(N-K+1):
    l = x[i]
    r = x[i+K-1]
    ans = min(ans, abs(l) + abs(r-l), abs(r) + abs(l-r))
print(ans)
    

Measured memory_bytes: 15020
n,t=map(int,input().split())
t1=list(map(int,input().split()))
s=t
k=0
for i in range(1,n):
    if t1[i]-k>=t:
        s=s+t
    else:
        s=s+t1[i]-k
    k=t1[i]
print(s)

Measured memory_bytes: 25200
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <string>
#include <bitset>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define fin(ans) cout<<(ans)<<endl
#define STI(s) atoi(s.c_str())
#define mp(p,q) make_pair(p,q)
#define pb(n) push_back(n)
#define Sort(a) sort(a.begin(),a.end())
#define Rort(a) sort(a.rbegin(),a.rend())
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
const int P = 1000000007;
const int INF = INT_MAX;
const long long LLINF = 1LL<<60;
//g++ -std=c++1z main.cpp
//.\a.exe

int main(void){ios::sync_with_stdio(false);cin.tie(0);
////////////////////////////////////////////////////////
int n,a=0,b;
cin >> n;
b = n;
while(n>0){
   a++;
   n = n/10;
}

if(a==1){
	cout << b << endl;
}
else if(a==2){
	cout << 9 << endl;
}
else if(a==3){
	cout << 9+b-100+1 << endl;
}
else if(a==4){
	cout << 909 << endl;
}
else if(a==5){
	cout << 909+b-10000+1 << endl;
}
else if(a==6){
	cout << 90909 << endl;
}
////////////////////////////////////////////////////////
return 0;}

Measured memory_bytes: 256
H,W = map(int,input().split())
M = []
M.append('.'*(W+2))
for _ in range(H):
    M.append('.'+input()+'.')
M.append('.'*(W+2))
for i in range(1,H+1):
    for j in range(1,W+1):
        if M[i][j] == '#':
            if M[i-1][j] == '.' and M[i+1][j] == '.' and M[i][j-1] == '.' and M[i][j+1] == '.':
                print('No')
                exit()
print('Yes')

Measured memory_bytes: 3064
sa = input()
sb = input()
sc = input()
next = sa[0]
while True:
  if next == 'a':
    if len(sa) == 0:
      print('A')
      break
    else:
      next = sa[0]
      sa = sa[1:]
  elif next == 'b':
    if len(sb) == 0:
      print('B')
      break
    else:
      next = sb[0]
      sb = sb[1:]
  else:
    if len(sc) == 0:
      print('C')
      break
    else:
      next = sc[0]
      sc = sc[1:]
     

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

using namespace std;

#define rep(i , j , k) for (int i = j; i < (int)k; i++)
#define pb push_back
#define mt make_tuple
#define all(x) x.begin(),x.end()

typedef long long ll;
typedef pair<int , int> pii;
typedef pair<ll, ll> pll;
typedef long double ld;
typedef complex<ld> point;
typedef pair<ld , ld> pld;
typedef vector<int> vi;

inline void fileIO(string s) {
	//	freopen((s + ".in").c_str(), "r", stdin);
	freopen((s + ".out").c_str(), "w", stdout);
}

template<class T , class S>
inline bool smin(T &a, S b) { return (T)b < a ? a = b , 1 : 0; }
template<class T , class S>
inline bool smax(T &a, S b) { return a < (T)b ? a = b , 1 : 0; }

constexpr int N = 2e5 + 10;
constexpr int MOD = 1e9;

template<typename T>
inline T mod(T &v) { return v = (v % MOD + MOD) % MOD; }
template<typename S, typename T>
inline S add(S &l, T r) { return mod(l += r); }

int n , m ;
vi zoj, fard;

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

	cin >> n >> m;
	rep(i , 0 , m) 
	{
		int a;
		cin >> a;
		if (a & 1) 
			fard.pb(a);
		else
			zoj.pb(a);
	}

	if (fard.size() > 2) return cout << "Impossible\n", 0;
	if (fard.size() == 2) {
		cout << fard[0] << ' ';
		for (auto e : zoj) cout << e << ' ';
		cout << fard[1] << '\n';
		cout << fard[0] / 2 + fard[1] / 2 + 1 + zoj.size() << '\n';
		rep(i , 0 , fard[0] / 2 + 1)
			cout << 2 <<' ';
		for (auto e : zoj) cout << e << ' ';
		rep(i , 0 , fard[1] / 2)
			cout << 2 << ' ';
	}

	else if (fard.size() == 1) {
		for (auto e : zoj) cout << e << ' ';
		cout << fard[0] << '\n';
		cout << zoj.size() + 1 + fard[0] / 2 << '\n';
		cout << 1 << ' ';
		for (auto e : zoj) cout << e << ' ';
		rep(i , 0, fard[0] / 2)
			cout << 2 << ' ';
	}
	else {
		for (auto e : zoj) cout << e << ' ';
		cout << '\n';
		cout << zoj.size() + 1 << '\n';
		cout << 1 << ' ';
		int last = zoj.back();
		zoj.pop_back();
		for (auto e : zoj) cout << e << ' ';
		cout << last - 1 << '\n';
	}	

	return 0;
}


Measured memory_bytes: 384
#include<cstring>
#include<cstdlib>
#include<cstdio>
#include<cmath>
#include<iostream>
#include<algorithm>
#define N 110000
#define LL long long
using namespace std;
struct node{int y,nex;}a[2*N];
int fir[N],len,n,m,cnt,u,v,o,num;
LL ans,f[N],g[N],c[N],A[N];
void ins(int x,int y)
{
	a[++len].y=y;a[len].nex=fir[x];fir[x]=len;
}
void dfs(int x,int fa)
{
	for(int k=fir[x];k;k=a[k].nex)
	{
		int y=a[k].y;
		if(y==fa) continue;
		if(c[y]==0)
		{
			c[y]=-c[x];
			dfs(y,x);
		}
		else
		{
			u=x;v=y;
			if(c[x]==c[y]) o=1;
			else o=0;
		}
	}
}
void dp(int x,int fa)
{
	f[x]=c[x];
	for(int k=fir[x];k;k=a[k].nex)
	{
		int y=a[k].y;
		if(y==fa || (x==u && y==v) || (x==v && y==u)) continue;
		dp(y,x);
		f[x]+=f[y];
		g[x]+=g[y];
	}
}
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;i++)
	{
		int x,y;scanf("%d%d",&x,&y);
		ins(x,y);ins(y,x);
	}
	c[1]=1;
	dfs(1,0);
	if(m==n-1)
	{
		dp(1,0);
		if(f[1]) {printf("-1\n");return 0;}
		for(int i=1;i<=n;i++) ans+=abs(f[i]);
		printf("%lld\n",ans);
	}
	else if(o==1)
	{
		dp(1,0);
		if(f[1]%2) {printf("-1\n");return 0;}
		LL t=f[1];
		c[u]-=t/2;c[v]-=t/2;ans=abs(t/2);
		dp(1,0);
		for(int i=1;i<=n;i++) ans+=abs(f[i]);
		printf("%lld\n",ans);
	}
	else
	{
		g[u]++;g[v]--;
		dp(1,0);
		if(f[1]) {printf("-1\n");return 0;}
		for(int i=1;i<=n;i++)
			if(g[i]==0) ans+=abs(f[i]);
			else if(g[i]==1) A[++num]=-f[i];
			else A[++num]=f[i];
		A[++num]=0;
		sort(A+1,A+num+1);
		LL t=A[(num+1)/2];
		for(int i=1;i<=num;i++) ans+=abs(t-A[i]);
		printf("%lld\n",ans);
	}
	return 0;
}

Measured memory_bytes: 10240
// Problem : A - Frog 1
// Contest : AtCoder - Educational DP Contest
// URL : https://atcoder.jp/contests/dp/tasks/dp_a
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
#define ll long long
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL)
#define fr(i,a,b) for(ll i=a;i<b;i++)
#define frr(i,a,b) for(int i=a;i>=b;i--)
//vector
#define pb push_back
#define vi vector<int>
#define vl vector<ll>
#define pp pop_back
//pair
#define pi pair<int ,int >
#define mk make_pair
#define ff first
#define ss second
//set
#define si set<int>
#define sit set<int>::iterator 
#define inf 1e9
using namespace std;
ll mincost(vl v,ll n)
{
	vl dp(n);
	dp[0]=0;
	fr(i,1,n)
	{
		int opt1=abs(v[i-1]-v[i])+dp[i-1];
		int opt2=(i==1)? inf : abs(v[i-2]-v[i])+dp[i-2];
		dp[i]=min(opt1,opt2);
	}
	return dp[n-1];
}
int main()
{
fast;
ll n;cin>>n;
vl a(n);
fr(i,0,n) cin>>a[i];
cout<<mincost(a,n);
return 0;
}

Measured memory_bytes: 5528
#include <iostream>
#include <vector>
#include <functional>
#include <algorithm>
#include <numeric>
#include <string>
#include <map>
#include <queue>
#include <bitset>
#include <sstream>
#include <iomanip>

using namespace std;
typedef long long ll;


int main(){
        ll A, B, Q;
        cin >> A >> B >> Q;
        vector<ll> s(A), t(B);
        for(ll i=0; i<A; i++){
                cin >> s[i];
        }
        for(ll i=0; i<B; i++){
                cin >> t[i];
        }
        vector<ll> x(Q);
        for(ll i=0; i<Q; i++){
                cin >> x[i];
        }
        ll Count1, Count2, indexs, indext;
        ll k_ss, k_sg, k_ts, k_tg, Mod=1e14;
        for(ll i=0; i<Q; i++){
                auto ites_g = lower_bound(s.begin(), s.end(), x[i]);
                auto itet_g = lower_bound(t.begin(), t.end(), x[i]);
//cout << *ites_g << " " << *itet_g << endl;
//cout << "itet " << *itet_g<< "ites " << *ites_g<<endl;
                if(ites_g == s.begin()){
//cout << "ites_g==s.begin()\n";
                        k_ss = Mod;
                        k_sg = *ites_g-x[i];
                }
                else if(ites_g == s.end()){
//cout << "ites_g==s.end()\n";
                        k_ss = x[i]-*(ites_g-1);
                        k_sg = Mod;
                }
                else{
                        k_ss = x[i]-*(ites_g-1);
                        k_sg = *(ites_g)-x[i];
                }
                if(itet_g == t.begin()){
//cout << "itet_g==t.begin()\n";
                        k_ts = Mod;
                        k_tg = *itet_g-x[i];
                }
                else if(itet_g == t.end()){
//cout << "itet_g==t.end()\n";
                        k_ts = x[i]-*(itet_g-1);
                        k_tg = Mod;
                }
                else{
                        k_ts = x[i]-*(itet_g-1);
                        k_tg = *(itet_g)-x[i];
                }
//cout << k_ss << " " << k_sg << " " << k_ts << " " << k_tg << endl;
                if(k_ts >= k_ss && k_tg >= k_sg){
                        cout << min(k_ts, k_tg);
                }
                else if(k_ts <= k_ss && k_tg <= k_sg){
//cout << "check";
                        cout << min(k_ss, k_sg);
                }
                else if(k_ts > k_ss && k_tg < k_sg){
                        cout << min({k_ts, k_sg, 2*k_ss+k_tg, 2*k_tg+k_ss});
                }
                else{
                        cout << min({k_tg, k_ss, 2*k_sg+k_ts, 2*k_ts+k_sg});

                }
                cout << endl;


        }

}


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

int main() {
  int i = 1;
  int input = 1;
  while(1) {
    cin >> input;
    if (!input) {
      break;
    }
    cout << "Case " << i << ": " << input << endl;
    i++;
  }

  return 0;
}

Measured memory_bytes: 1160
#include <unordered_set>
#include <vector>
#include <cstdio>

void solve(int i, int n, int sum, std::vector<int> &a, std::unordered_set<int> &ans){
    if(i == n){
        ans.insert(sum);
        return;
    }
    solve(i+1, n, sum, a, ans);
    solve(i+1, n, sum + a[i], a, ans);
}

int main(){
    int n;
    std::scanf("%d", &n);
    std::vector<int> a(n, 0);
    for(int i = 0; i < n; ++i){
        std::scanf("%d", &a[i]);
    }
    std::unordered_set<int> ans;
    solve(0, n, 0, a, ans);

    int q;
    std::scanf("%d", &q);
    for(int i = 0; i < q; ++i){
        int m;
        std::scanf("%d", &m);
        if(ans.find(m) != ans.end()){
            std::printf("yes\n");
        } else {
            std::printf("no\n");
        }
    }

    return 0;
}


Measured memory_bytes: 2648
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007



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

    vector<int> P(N);
    vector<int> Q(N);

    for(int i = 0; i < N; i++) cin >> P.at(i);
    for(int i = 0; i < N; i++) cin >> Q.at(i);

    vector<int> kaijou(N+1, 1);
    for(int i = 1; i < N+1; i++) kaijou.at(i) = kaijou.at(i-1) * i;

    vector<int> temp(N+1);
    for(int i = 0; i < N+1; i++) temp.at(i) = i;

    int num, cnt = 0, cnt_2 = 0;

    for(int i = 0; i < N-2; i++){
        for(int j = 1; j <= N-i; j++){
            if(P.at(i) == temp.at(j)){
                num = j;
                temp.at(j) = 1000;
                break;
            }
        }

        cnt += (num-1) * kaijou.at(N-1-i) + 1;

        sort(temp.begin(), temp.end());
    }
    if(P.at(N-2) > P.at(N-1)) cnt++;

    for(int i = 0; i < N+1; i++) temp.at(i) = i;

    for(int i = 0; i < N-2; i++){
        for(int j = 1; j <= N-i; j++){
            if(Q.at(i) == temp.at(j)){
                num = j;
                temp.at(j) = 1000;
                break;
            }
        }

        cnt_2 += (num-1) * kaijou.at(N-1-i) + 1;

        sort(temp.begin(), temp.end());
    }
    if(Q.at(N-2) > Q.at(N-1)) cnt_2++;

    cout << max(cnt, cnt_2) - min(cnt, cnt_2) << endl;
}


Measured memory_bytes: 3556
#include<bits/stdc++.h>
using namespace std;
int main(){int N;cin>>N;vector<long>a(N),b(N);
           for(int i=0;i<N;i++)cin>>a.at(i)>>b.at(i);
   sort(a.begin(),a.end());sort(b.begin(),b.end());
long s,t;
           if(N%2==0){s=a.at(N/2-1)+a.at(N/2);t=b.at(N/2-1)+b.at(N/2);}
else{s=a.at((N-1)/2);t=b.at((N-1)/2);}
cout<<t-s+1<<endl;}

Measured memory_bytes: 6412
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define OUT(x) cout << (x) << endl;
#define REP(i, n) for (int i=0; i<n; ++i)


int main(){
    int n[3];
    cin >> n[0] >> n[1] >> n[2];
    sort(n, n + 3); // n2が最大になる

    int cnt = 0;
    while(1){
        if(n[2]-n[0]==0 || n[2]-n[0]==1) break;
        n[0]+=2;
        cnt++;
    }
    while(1){
        if(n[2]-n[1]==0 || n[2]-n[1]==1) break;
        n[1]+=2;
        cnt++;
    }
    sort(n, n + 3);
    if(n[0] == n[1] && n[1] == n[2]){
        // fin
    } else if(n[0] == n[1]){
        cnt++;
    } else {
        cnt+=2;
    }
    cout << cnt << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <fstream>
#include <sstream>
#include <iomanip>
#define ll long long

using namespace std;

long long MOD = 1000000007;

vector<long long> fact(200001,1);
void factorial(int N){
    for(int i=1; i<N; i++){
        fact[i+1]=(i+1)*fact[i]%MOD;
    }
}

map<long long, long long> inv_fact;
long long inv_factorial(long long x){
    if (inv_fact.count(x)){
        return inv_fact[x];
    }
    long long p=MOD-2;
    long long ret=1;
    long long tmp=x;
    while(p>0){
        if(p%2==1)ret=ret*tmp%MOD;
        tmp=tmp*tmp%MOD;
        p/=2;
    }
    inv_fact[x]=ret;
    return ret;
}

long long comb(int a, int b){
    if(b==0){
        return 1;
    }
    long long ret=fact[a]*inv_factorial(fact[a-b])%MOD;
    return ret*inv_factorial(fact[b])%MOD;
}

int main(){
    int n , k;
    cin >> n >> k;
    k=min(n-1,k);
    factorial(200001);

    ll ans=0;
    for(int i=0; i<=k; i++){
        ans+=(comb(n,i)*comb(n-1,i))%MOD;
        //cout << i << ' ' << comb(n,i) << ' ' << comb(n-1,i) << endl;
        ans%=MOD;
    }
    cout << ans << endl;
}

Measured memory_bytes: 15104
'use strict';
    (function(stdin) {
      //declare function

      //declare variable
      var inputs = stdin.toString().trim().split(' ');
      inputs.map(Number);
      var a = inputs[0];
      var b = inputs[1];
      var c = inputs[2];
      var result = '';
      //main
      if (a < b) {
        if (a < c) {
          if (b < c) {
            console.log(a, b, c);
          } else {
            console.log(a, c, b);
          }
        } else {
          console.log(c, a, b);
        }
      } else if (a > c) {
        if (b < c) {
          console.log(b, c, a);
        } else {
          console.log(c, b, a);
        }
      } else {
        console.log(b, a, c);
      }

      //display
      //console.log(inputs);
    })(require('fs').readFileSync('/dev/stdin', 'utf8'))

Measured memory_bytes: 15520
import java.util.*;

import static java.lang.System.*;

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

        long[] a = new long[N];
        for (int i = 0; i < N; i++) {
            a[i] = sc.nextLong() - (i + 1);
        }

        Arrays.sort(a);

        // determine the median
        long median;
        if (a.length % 2 == 0) {
            median = a[a.length / 2 - 1];
        } else {
            median = a[a.length / 2];
        }

        long ans = Long.MAX_VALUE;
        for (int j : new int[]{-1, 0, 1}) {
            long tmpAns = 0;
            for (int i = 0; i < N; i++) {
                tmpAns += Math.abs(a[i] - (median + j));
            }
            ans = Math.min(ans, tmpAns);
        }

        out.println(ans);
    }
}

Measured memory_bytes: 91592
N, A, B = map(int, input().split())
S = input().rstrip()

passA = 0
passB = 0
for i in range(N):
    if passA + passB >= A + B:
        print('No')
        continue
    if S[i] == 'c':
        print('No')
    if S[i] == 'b':
        if passB >= B:
            print('No')
        else:
            print('Yes')
            passB += 1
    if S[i] == 'a':
        print('Yes')
        passA += 1


Measured memory_bytes: 4016
#include <bits/stdc++.h>
using namespace std;
typedef long long int lld;
typedef pair<int,int> pi;
typedef pair<lld,lld> pl;
typedef pair<int,lld> pil;
typedef pair<lld,int> pli;
typedef vector<int> vit;
typedef vector<vit> vitt;
typedef vector<lld> vlt;
typedef vector<vlt> vltt;
typedef vector<pi> vpit;
typedef vector<vpit> vpitt;
typedef long double ld;
#define x first
#define y second
#define pb push_back
#define all(v) v.begin(), v.end()
#define sz(x) (int)x.size()
#define mk(a,b) make_pair(a,b)
bool isrange(int y,int x,int n,int m){
	 if(0<=y&&y<n&&0<=x&&x<m) return true;
	 return false;
}
int dy[4] = {1,0,-1,0},dx[4]={0,1,0,-1},ddy[8] = {1,0,-1,0,1,1,-1,-1},ddx[8] = {0,1,0,-1,1,-1,1,-1};

int main(void){
	lld d,t,s;
	cin >> d >> t >> s;
	if(t*s>=d) printf("Yes\n");
	else printf("No\n");
	return 0;
}


Measured memory_bytes: 3608
<?php
list($N)=sscanf(trim(fgets(STDIN)),"%d");
list($S,$T)=sscanf(trim(fgets(STDIN)),"%s %s");
$unchi="";

for($i=0; $i<$N; $i++){
    $unchi = $unchi.$S[$i].$T[$i];
    
}
printf($unchi);

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

#define INF INT_MAX/2;
#define MOD 1000000007

using namespace std;

using ll = long long;
using ull = unsigned long long ;

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

   int N;
   cin>>N;
   vector<int>a(N);
   for(int i=0;i<N;i++)cin>>a[i];
   vector<ll>sum(N);
   sum[0] = a[0];
   for(int i=1;i<N;i++)sum[i] += a[i]+sum[i-1];
   ll ans = ((1<<31)-1);
   for(int i=0;i<N-1;i++){
      ans = min(abs(sum[i]-(sum[N-1]-sum[i])),ans);
   }
   cout<<ans<<endl;
   return 0; 
}


Measured memory_bytes: 2560
/*
 * atcoder/abc102/c.cpp
 */

// C++ 14
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring> // memset
#include <cassert>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)
template <class T> bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false; }
template <class T> bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false; }

int N;
vector<ll> A, B;
void solve() {
  cin >> N;
  ll a;
  loop(n,0,N) {
    cin >> a;
    A.push_back(a);
    B.push_back(a - (n+1));
  }
  sort(B.begin(), B.end());
  ll b = B[B.size()/2];

  ll total = 0;
  loop(n,0,N) {
    total += abs(A[n] - (b + (n+1)));
  }
  cout << total << endl;
}
int main() {
  // cout.precision(15);
  // cout << fixed << double

  solve();

  return 0;
}


Measured memory_bytes: 3564
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <bitset>
#include <climits>
#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,n) for (int i=(n)-1;i>=0;i--)
#define RFOR(i,a,b) for (int i=(a)-1;i>=(b);i--)
#define ll long long
#define ull unsigned long long
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const int INF = 1e9;
const ll LL_INF = 1e18;
const int MOD = 1e9 + 7;

using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll N, K;
  cin >> N >> K;
  ull ans = 0;
  REP(i, N + 1){
    if(i == 0) continue;
    if(i % K == 0) ans += N / K * (N / K);
    else if(K % 2 == 0 && i % K == K / 2) ans += ((N + K / 2) / K) * ((N + K / 2) / K);;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
/**
 * code generated by RHelper
 * More info: https://github.com/mkc1370/RHelper
 * @author 
 */

using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text;

public class BGoldenCoins
{
    private readonly StringReader cin;
    private readonly StringWriter cout;
    private readonly Scanner scanner;

    public BGoldenCoins(StringReader cin, StringWriter cout)
    {
        this.cin = cin;
        this.cout = cout;
        scanner = new Scanner(cin);
    }

    public void Solve()
    {
        var x = CINL;
        COUT(x / 500 * 1000 + (x % 500) / 5 * 5);
    }

    private long CINL => scanner.Long();
    private double CIND => scanner.Double();
    private string CINS => scanner.String();
    private static IEnumerable<T> Repeat<T>(T v, long n) => Enumerable.Repeat(v, (int)n);
    private List<long> CINVL(long n) => Repeat(0, n).Select(_ => CINL).ToList();
    private List<double> CINVD(long n) => Repeat(0, n).Select(_ => CIND).ToList();
    private List<string> CINVS(long n) => Repeat(0, n).Select(_ => CINS).ToList();

    private void COUT(object o) => cout.WriteLine(o);
}

public class Scanner
{
    public Scanner(StringReader stringReader)
    {
        this.stringReader = stringReader;
    }

    private readonly StringReader stringReader;
    private readonly char[] buffer = new char[1024];
    private int len, ptr;
    private bool isEof;

    private char Read()
    {
        if (isEof) throw new EndOfStreamException();
        if (ptr >= len)
        {
            ptr = 0;
            if ((len = stringReader.Read(buffer, 0, 1024)) <= 0)
            {
                isEof = true;
                return '\0';
            }
        }

        return buffer[ptr++];
    }

    public char Char()
    {
        char b;
        do b = Read();
        while (b < 33 || 126 < b);
        return b;
    }

    public string String()
    {
        var sb = new StringBuilder();
        for (char b = Char(); b >= 33 && b <= 126; b = Read())
            sb.Append(b);
        return sb.ToString();
    }

    public long Long()
    {
        long ret = 0;
        char b;
        var ng = false;
        do b = Read();
        while (b != '-' && (b < '0' || '9' < b));
        if (b == '-')
        {
            ng = true;
            b = Read();
        }

        for (;; b = Read())
        {
            if (b < '0' || '9' < b)
                return ng ? -ret : ret;
            else ret = ret * 10 + b - '0';
        }
    }

    public double Double()
    {
        return double.Parse(String(), CultureInfo.InvariantCulture);
    }
}


public class Output
{
	public static void Main()
	{
		var reader = new System.IO.StringReader(Console.In.ReadToEnd());
		var writer = new System.IO.StringWriter();
		var solver = new BGoldenCoins(reader, writer);
		solver.Solve();
		System.Console.Write(writer.GetStringBuilder().ToString());
	}
}


Measured memory_bytes: 13140
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

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

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

  int h, w;
  cin >> h >> w;

  vector<string> mp(h);
  rep(i, 0, h) cin >> mp[i];

  int sharp_count = 0;
  rep(i, 0, h) rep(j, 0, w) {
    if (mp[i][j] == '#')
      sharp_count++;
  }

  if (h + w - 1 != sharp_count) {
    cout << "Impossible" << endl;
    return 0;
  }

  vector<vector<int>> search(h, vector<int>(w, 0));
  search[0][0] = 1;
  queue<P> q;
  q.push(make_pair(0, 0));

  while (!q.empty()) {
    P p = q.front();
    q.pop();
    int y = p.first;
    int x = p.second;
    rep(i, 0, 4) {
      int ny = y + dy[i], nx = x + dx[i];
      if (ny < 0 || nx < 0 || ny >= h || nx >= w)
        continue;
      if (search[ny][nx] != 0)
        continue;
      if (mp[ny][nx] == '.')
        continue;
      search[ny][nx] = search[y][x] + 1;
      q.push(make_pair(ny, nx));
    }
  }

  if (h + w - 1 == search[h - 1][w - 1])
    cout << "Possible" << endl;
  else
    cout << "Impossible" << endl;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

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

		String[] box = buff.readLine().split(" ");
		int A = Integer.parseInt(box[0]);
		int B = Integer.parseInt(box[1]);

		if(A == B){
			System.out.println("Draw");
			return;
		}

		boolean flag = false;
		if(A < B){
			if(A == 1){
				flag = true;
			}else{
				flag = false;
			}
		}else if(A > B){
			if(B == 1){
				flag = false;
			}else{
				flag = true;
			}
		}

		if(flag){
			System.out.println("Alice");
		}else{
			System.out.println("Bob");
		}

	}

}


Measured memory_bytes: 8148
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define trav(var, container) for(auto& var: container)
#define all(x) x.begin(), x.end()
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define sz(x) (int)x.size()
using namespace std;
using namespace __gnu_pbds;
using ld = long double; 
using ll = long long;
using vi = vector<int>;
using pii = pair<int, int>;
struct chash { // large odd number for C
	const uint64_t C = ll(4e18 * acos(0)) | 71;
	ll operator()(ll x) const { return __builtin_bswap64(x*C); }
};


int main() {
  ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  int n;
  cin >> n;
  ll arr[n];
  for(auto& i: arr) cin >> i;
  cout << accumulate(arr, arr + n, 0) - n;
  return 0;
}

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

int p, q, a;

bool isClear(int total, int product, int i){
    return p*product*i == total*q*i + q*product;
}

int dfs(int step, int total, int product, int i){
    if(p*product < q*total) return 0;
    
    int cnt = 0;
    for(int j = i; j*product <= a; j++){
        if(isClear(total, product, j)){
            cnt++;
        } else if (step >= 1){
            cnt += dfs(step-1, j*total+product, j*product, j);
        }
    }
    return cnt;
}

int main(int argc, const char * argv[]) {
    while(1){
        int n; cin >> p >> q >> a >> n;
        if(!p && !q && !a && !n) break;

        cout << dfs(n-1, 0, 1, 1) << endl;
    }
}

Measured memory_bytes: 1160
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <cmath>
#include <stack>
#include <set>
#include <algorithm>
#include <sstream>
#include <map>
#include <unordered_map>
using namespace std;


using vc = vector<char>;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vector<int>> vvi;
typedef pair<int, int> pii;

void process(const string& t) {
}

int main() {
  int t, n;
  string s;
  int x, y;
  int k;
  while (cin >> n) {
    vector<long long> v(n);
    long long sum = 0;
    for (int i = 0; i < n; ++i) {
      cin >> v[i];
      sum ^= v[i];
    }
    for (int i = 0; i < n; ++i) {
      v[i] ^= sum;
    }
    for (auto it : v) cout << it << ' '; cout << endl;
  }
  return 0;
}


Measured memory_bytes: 4760
#include<iostream>
#include<queue>
using namespace std;
int main() {
	int a, b;
	cin >> a >> b;
	int count = 0;
	for (int i = a; i <= b; i++) {
		int c = i / 10000;
		int d = i / 1000 % 10;
		int e = i / 10 % 10;
		int f = i % 10;
		if (c == f && d == e) {
			count++;
		}
	}
	cout << count << endl;
	return 0;
}

Measured memory_bytes: 256
#! python3
# card_game.py

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

taro, hanako = 0, 0
for turn in turns:
    t, h = turn.split(' ')
    min_len = len(t) if len(t) <= len(h) else len(h)

    win_flag = 0 # -1: taro, 1: hanako, 0: draw
    for i in range(min_len):
        if ord(t[i]) < ord(h[i]):
            win_flag = 1
            break
        elif ord(h[i]) < ord(t[i]):
            win_flag = -1
            break

    if win_flag == 0:
        if len(t) < len(h):
            win_flag = 1
        elif len(h) < len(t):
            win_flag = -1

    if win_flag == -1:
        taro += 3
    elif win_flag == 1:
        hanako += 3
    else:
        taro += 1
        hanako += 1

print(taro, hanako)


Measured memory_bytes: 5608
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vin=vector<int>;
using vll=vector<long long>;
using vvin=vector<vector<int>>;
using vvll=vector<vector<long long>>;
using vstr=vector<string>;
using vvstr=vector<vector<string>>;
using vch=vector<char>;
using vvch=vector<vector<char>>;
using vbo=vector<bool>;
using vvbo=vector<vector<bool>>;
using vpii=vector<pair<int,int>>;
using pqsin=priority_queue<int,vector<int>,greater<int>>;
#define mp make_pair
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,s,n) for(int i=(s);i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define decp(n) cout<<fixed<<setprecision((int)n)
const int inf=1e9+7;
const ll INF=1e18;

int main(){
    int n,q;cin>>n>>q;
    vll a(n);rep(i,n)cin>>a[i];
    ll x,sum,ans;int res;
    vll num(q);
    rep(i,q){
        cin>>x;
        ans=(ll)0;sum=(ll)0;res=0;
        rep(j,n){
            while(res<n&&sum+a[res]<=x){
                sum+=a[res];
                res++;
            }
            ans+=res-j;
            if(res==j)res++;
            else sum-=a[j];
        }
        num[i]=ans;
    }
    rep(i,q)cout<<num[i]<<endl;
}


Measured memory_bytes: 3536
#include <iostream>
#include <algorithm>

using namespace std;

string S;

int main() {
    int flag = 0;
    int memo[2] = {0};
    cin >> S;
    for (int i = 0; i < S.size(); i++){
        if (S[i] == 'A' && flag == 0){
            flag++;
            memo[0] = i;
        } else if (S[i] == 'Z') {
            memo[1] = i;
        }
    }
    cout << memo[1] - memo[0] + 1 << endl;
    return 0;
}


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

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

    int A[2][100] = { { 0 } };
    for( int i = 0; i < 2; ++i )
        for( int j = 0; j < N; ++j )
            cin >> A[i][j];


    int ans = 0, tmp, idx;
    for( int i = 0; i < N; ++i ){
        tmp = 0;
        idx = 0;

        for( int j = 0; j < N; ++j ){
            tmp += A[idx][j];
            if( i == j ){
                idx = 1;
                tmp += A[idx][j];
            }
        }

        if( ans < tmp ){
            ans = tmp;
            // cout << "* " << i << endl;        
        }
    }


    cout << ans << endl;

    return 0;
}


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

int main() {
    for(int i=1; i<=5; i++){
        int num;
        cin >> num;
        if(num == 0) cout << i << endl;
    }
    return 0;
}

Measured memory_bytes: 3620
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <climits>
#include <sstream>

using namespace std;

int main(){
  int N;
  char S[110];

  cin >> N;
  for(int i = 0; i < N; i++) cin >> S[i];

  sort(S, S+N);

  if(S[N-1] == 'Y') cout << "Four" << endl;
  else cout << "Three" << endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdlib.h>
#include <cstring>
 
using namespace std;
 
int n,k;
int a[100005];
long long f[100005];
 
void khoitao(){
    for (int i = 1; i <= n; i ++ )
        f[i] = 1000000010;
    f[1] = 0;
    for (int i = 2; i <= k; i++)
    {
        for (int j = 1; j < i; j++)
        f[i] = min( f[i] , f[i-j] + abs(a[i] - a[i-j]) );
    }
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> n >> k;
    for (int i = 1; i <= n ; i++)
        cin >> a[i];
    /* (k > n) {
        cout << 0;
        return 0;
    }*/
    khoitao();
    for (int i = k+1; i <= n; i++){
        for (int j = 1; j <= k; j++)
        f[i] = min( f[i] , f[i-j] + abs(a[i] - a[i-j]) );
    }
    cout << f[n] ;
    return 0;
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
#define int long long
using namespace std;
signed main(){
  string S;
  cin>>S;
  for(int bi=0;bi<8;bi++){
    int ans=S[0]-'0';
    for(int i=0;i<3;i++){
      if((bi>>i) & 1)ans+=S[i+1]-'0';
      else ans-=S[i+1]-'0';
    }
    if(ans==7){
      cout<<S[0];
      if((bi>>0) & 1)cout<<'+';
      else cout<<'-';
      cout<<S[1];
      if((bi>>1) & 1)cout<<'+';
      else cout<<'-';
      cout<<S[2];
      if((bi>>2) & 1)cout<<'+';
      else cout<<'-';
      cout<<S[3];
      cout<<"=7\n";
      return 0;
    }
  }
}

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

import math
# 素数判定関数
def isPrime(num):
    # 2未満の数字は素数ではない
    if num < 2: return False
    # 2は素数
    elif num == 2: return True
    # 偶数は素数ではない
    elif num % 2 == 0: return False

    # 3 ~ numまでループし、途中で割り切れる数があるか検索
    # 途中で割り切れる場合は素数ではない
    for i in range(3, math.floor(math.sqrt(num))+1, 2):
        if num % i == 0:
            return False

    # 素数
    return True

pn=[]
for i in range(X, 10**5+4):
    if isPrime(i):
        pn.append(i)
print(min(pn))



Measured memory_bytes: 3352
import sys
input = lambda: sys.stdin.readline().rstrip()
a=set() ; b=[]
c=0
for i in input():
    a.add((i,c))
    c+=1
c=0
for i in input():
    b.append([i,c])
    c+=1
ans=0 ; cur=0
for num in range(len(a)-len(b)+1):
    cur=0
    for i in b:
        need=tuple([i[0],i[1]+num])
        if need in a:
            cur+=1
        ans=max(ans,cur)
print(len(b)-ans)
        
                
            
    

Measured memory_bytes: 81736
#include <bits/stdc++.h>
#define rep(i, n) for (lli i = 0; i < (n); i++)
#define rrep(i, n) for (lli i = (n)-1; i >= 0; i--)
using namespace std;
using lli = long long int;

pair<string, int> dp[200005] = {};
int main()
{
    int l;
    string s, t;
    cin >> l;
    cin >> s >> t;
    int x = s.size();
    int y = t.size();
    int ans = 0;
    if (x == y) {
        if (s > t) {
            swap(s, t);
        }
        rep(i, l / s.size()) cout << s;
        cout << endl;
    } else {
        string st = s + t;
        string ts = t + s;


        if (st > ts) {
            swap(s, t);
        }
        x = s.size();
        y = t.size();
        for (int i = 0; i * x <= l; i++) {
            if ((l - i * x) % y == 0) {
                ans = i;
            }
        }
        rep(i, ans)
        {
            cout << s;
        }
        rep(i, (l - x * ans) / y)
        {

            cout << t;
        }
        cout << endl;
    }
}


Measured memory_bytes: 4872
#include <bits/stdc++.h>
using namespace std;
#define lp(i, x, n) for (int i = x; i < (int)n; ++i)
#define all(v) (v).begin(), (v).end()
#define sz(v) (int)(v).size()
#define ll long long
#define N 123451

string s;
int main(){
        cin >> s;
        deque<int> q;
        lp (i, 0, sz(s)) {
                if (s[i] == 'B') {
                        if (q.empty()) continue;
                        else q.pop_back();
                } else
                        q.push_back(s[i]-'0');
        }
        while(q.size()) {
                cout << q.front();
                q.pop_front();
        }
        return 0;
}


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

namespace AtCoder
{
	class Program
	{
		static void Main(string[] args)
		{
			int n = int.Parse(Console.ReadLine());

			int[] arr = Console.ReadLine().Trim().Split(' ').Select(tmp => int.Parse(tmp)).ToArray<int>();
			int[] hero = Console.ReadLine().Trim().Split(' ').Select(tmp => int.Parse(tmp)).ToArray<int>();

			long num = 0;

			for (int i = 0; i < n; i++)
			{
				if (hero[i] > arr[i])
				{
					int diff = hero[i] - arr[i];

					// heroが大きすぎる
					if (diff > arr[i + 1])
					{
						num += arr[i] + arr[i + 1];
						arr[i + 1] = 0;
					}
					else
					{
						num += hero[i];
						arr[i + 1] -= diff;
					}
				}
				else
				{
					num += hero[i];
				}
			}


			Console.WriteLine(num.ToString());
		}
	}
}


Measured memory_bytes: 34908
import sys

read = sys.stdin.read
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7


def main():
    S = input()
    T = input()
    LS = len(S)
    LT = len(T)
    ans = 0
    for i in range(LS-LT+1):
        tmp = 0
        for s, t in zip(S[i:i+LT],T):
            if s==t:
                tmp += 1
        ans = max(ans, tmp)
    print(LT-ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9124
#include "bits/stdc++.h"
using namespace std;

#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()

constexpr auto inf = 1e9;

template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }

using ll = long long;

int main()
{
	int n, d;
	cin >> n >> d;
	int ans = n % (2 * d + 1) ? (n / (2 * d + 1)) + 1 : n / (2 * d + 1);
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
int dx[6] = { -1,-1,0,1,1,0 };
int dy[6] = { 0,-1,-1,0,1,1 };
struct aa {
	int x;
	int y;
	int t;
};
int main() {
	while (1) {
		int T, N; cin >> T >> N;
		if (!T)break;
		set<pair<int, int>>m;
		for (int i = 0; i < N; ++i) {
			int x, y; cin >> x >> y;
			m.emplace(x, y);
		}
		int u,v; cin >> u >> v;
		queue<aa>q;
		q.push(aa{ u,v,0 });
		m.emplace(u, v);
		while (q.size()) {
			aa atop(q.front());
			q.pop();
			if (atop.t == T)break;
			else {
				for (int i = 0; i < 6; ++i) {
					int nx = atop.x + dx[i];
					int ny = atop.y + dy[i];
					if (!m.count(make_pair(nx, ny))) {
						m.emplace(nx, ny);
						q.push(aa{ nx,ny,atop.t + 1 });
					}
				}
			}
		}
		cout << m.size() - N << endl;
	}
	return 0;
}

Measured memory_bytes: 3144
#include<bits/stdc++.h>
#define ll long long int
#define FOR(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define REP(i,n) FOR(i,0,n)
#define REP1(i,n) FOR(i,1,n)
using namespace std;
 
/*--------------------template--------------------*/

int main(){
    REP1(i,10){
        REP1(j,10){
            cout << i << 'x' << j << '=' << i*j << endl;
        }
    }
}

Measured memory_bytes: 3076
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << endl;
#define CFYN(n) cout << ( (n) ? "YES":"NO") << endl;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;

int main(void)
{
    IOS
    string s; cin >> s;
    cout << "ABC" << s << endl;

    return 0;
}

Measured memory_bytes: 256