akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define len(v) ll(v.size())
#define fi first
#define se second

template <class T>
void cout_vec(const vector<T> &vec){
  for(auto itr:vec) cout<<itr<<' ';
  cout<<endl;
}

typedef pair<ll,ll> P;
const ll mod=1e9+7;
const ll inf=1e15;

vector<ll> zalgo(string s){
  vector<ll> ret(s.size());
  ll c=0;
  FOR(i,1,s.size()){
    if(i+ret[i-c]<c+ret[c]) ret[i]=ret[i-c];
    else{
      ll j=max(0ll,c+ret[c]-i);
      while(i+j<s.size() && s[j]==s[i+j]) j++;
      ret[i]=j;
      c=i;
    }
  }
  ret[0]=s.size();
  return ret;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n;
  string s;
  cin>>n>>s;
  ll ans=0;
  rep(i,n){
    string t=s.substr(i,n-i);
    vector<ll> ret=zalgo(t);
    rep(j,n-i) ans=max(ans,min(j,ret[j]));
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 384
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cassert>
#include <complex>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <sstream>
#include <ctime>
#include <cctype>
#include <set>
#include <map>
#include <queue>
#include <bitset>
#include <deque>
#include <stack>
#include <memory.h>
using namespace std;
int a[200005],n,b[200005];
int main()
{
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	int eo=(n-1)%2;
	int cnt1=0;
	int cnt2=1;
	for(int i=n-1;i>=0;i--){
		if(i%2==eo){
			b[cnt1]=a[i];
			cnt1++;
		}
		if(i%2!=eo){
			b[n-cnt2]=a[i];
			cnt2++;
		}
	}
	for(int i=0;i<n;i++){
		cout<<b[i]<<" ";
	}
    return 0;
}

Measured memory_bytes: 3712
#include <cstdio>
#include <map>
typedef long long lld;
const int MAXN = 2e5+5;
const int MOD = 1e9+7;
int size[MAXN][2]{ };
int  two[MAXN];
lld A, B;
int K, N;
int ret, zero;

template <typename T> T gcd(T a, T b) { return (b) ? gcd(b, a % b) : a; }

struct Frac {
  lld A, B;

  // Overflow potential  
  bool operator < (const Frac& o) const {
    return (A != o.A) ? (A < o.A) : (B < o.B);
  }

  void reduce() {
    lld G = gcd(A, B);
    A /= G;
    B /= G;
    return this->sign();
  }

  void sign() {
    if (B > 0) return;
    if ((A >= 0) && (B >= 0)) return;
    // Skip: [+,+] [+,=] [=,+] [=,=] [-,+]
    // Flip: [+,-] [=,-] [-,=] [-,-]
    A *= -1;
    B *= -1;
  }
};
std::map<Frac, int> C;
Frac f;

void compute(int i) {
  if (!f.A && !f.B) {
    ++zero;
    return;
  }
  f.reduce();
  if (C.count(f)) {
    ++size[C.at(f)][0];
    return;
  }
  Frac g = {-f.B, f.A};
  g.sign();
  if (C.count(g)) {
    ++size[C.at(g)][1];
    return;
  }
  C[f] = K++;
  ++size[C.at(f)][0];
}

void init() {
  two[0] = 1;
  for (int i = 1; i <= N; ++i) {
    two[i] = 2LL * two[i-1] % MOD;
  }
}

int main() {
  scanf("%d", &N);
  init();

  zero = 0;
  for (int i = 1; i <= N; ++i) {
    scanf(" %lld%lld", &f.A, &f.B);
    compute(i);
  }

  ret = 1;
  for (int i = 0; i < K; ++i) {
    int cnt = (1LL * two[size[i][0]] + two[size[i][1]] - 1 + MOD) % MOD;
    ret = 1LL * ret * cnt % MOD;
  }
  ret = (1LL * ret - 1 + MOD) % MOD;
  ret = (1LL * ret + zero) % MOD;

  printf("%d\n", ret);
  return 0;
}

Measured memory_bytes: 17848
import java.util.*;
import java.io.*;
public class Main{

 static class Reader{ 
        BufferedReader br; 
        StringTokenizer st; 
  
        public Reader(){ 
            br = new BufferedReader(new InputStreamReader(System.in)); 
        } 
       
        String next(){ 
            while (st == null || !st.hasMoreElements()){ 
                try{ 
                    st = new StringTokenizer(br.readLine()); 
                } 
                catch (IOException  e){ 
                    e.printStackTrace(); 
                } 
            } 
            return st.nextToken(); 
        } 
  
        int nextInt(){ 
            return Integer.parseInt(next()); 
        } 
  
        long nextLong(){ 
            return Long.parseLong(next()); 
        } 
  
        double nextDouble(){ 
            return Double.parseDouble(next()); 
        } 
        
        String nextLine(){ 
            String str = ""; 
            try{ 
                str = br.readLine(); 
            } 
            catch (IOException e) { 
                e.printStackTrace(); 
            } 
            return str; 
        } 
    } 


  
    public static void main(final String [] args)throws IOException{
       Reader sc=new Reader();
       int n=sc.nextInt();
       int [] a=new int[n];
       for(int i=0;i<n;i++)a[i]=sc.nextInt();
       int xor=a[0];
       for(int i=1;i<n;i++)xor=xor^a[i];
       for(int i=0;i<n;i++){
           System.out.print((xor^a[i])+" ");
       }


    }
}




Measured memory_bytes: 61656
#include<bits/stdc++.h>							
typedef long long ll;
#define pb push_back
#define mod 1000000007ll
const ll maxn = 9e18;
using namespace std;
const ll maxsize = 100000009;



void solve() {
	int n;
	cin >> n; 
	int a[100005], b[100005];
	ll ans = 0;
	for(int  i = 0; i < n  + 1; ++i) cin >> a[i];
	for(int i = 0; i < n; ++i) cin >> b[i];
	for(int i = 0; i < n; ++i) {
		int x = min(a[i], b[i]);
		ans += x;
		b[i] -= x;
		x = min(a[i + 1], b[i]);
		a[i + 1] -= x;
		ans += x;
		}
		cout << ans << endl;
}
	
	

int main() {
	ios_base :: sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cout.precision(35);
	int t;
	solve();
	return 0;
}
 
 
 
 


Measured memory_bytes: 4352
n, a, b=gets.strip.split.map(&:to_i)
h = readlines.map {|line| line.strip.to_i }
c=a-b

ok=h.inject(:+)
ng=0

until ok-ng==1
  mid = (ok+ng)/2
  remains = h.map {|e| e-mid*b }.select {|e| e>0 }
  r_c = remains.map {|e| e/c + ((e.ceil%c).zero? ? 0 : 1) }.inject(0, :+)
  if r_c > mid
    ng=mid.to_i
  else
    ok=mid.to_i
  end
end

p ok

Measured memory_bytes: 62084
#include<iostream>
#include<cstdio>
using namespace std;
int main(){
  int a[4] = {0};
  for(;;){
    char s[3];
    if(scanf("%*d,%s%*c",s) == EOF) break;
    if(s[0] == 'A' && s[1]!='B') a[0]++;
    else if(s[0] == 'B') a[1]++;
    else if(s[0] == 'O') a[3]++;
    else a[2]++;
  }
  for(int i=0; i<4; i++) cout <<a[i]<<endl;
  return 0;
}

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

long long judge(vector<int> &v, int n, long long ans) {
    int acount = 0; int bcount = 0;
    for (int i = 0; i < n; i++) {
        if (v[i] && v[i+n]) {
            return ans;
        }
        if (v[i]) acount++;
        if (v[i+n]) bcount++;
    }
    if (!acount || !bcount) {
        return ans;
    }
    return 1e18;
}

int main() {
    int n; cin >> n;
    deque<pair<long long, int>> p;
    for (int i = 0; i < n; i++) {
        long long a, b; cin >> a >> b;
        p.emplace_back(a, i);
        p.emplace_back(b, i+n);
    }
    sort(p.begin(), p.end());
    vector<int> v(2*n, 0);
    long long ans = 0;
    for (int i = 0; i < n; i++) {
        ans += p[i].first;
        v[p[i].second]++;
    }
    long long z[4];
    z[0] = judge(v, n, ans); // n-1, n
    v[p[n+1].second]++; v[p[n-1].second]--;
    ans += p[n+1].first - p[n-1].first;
    z[1] = judge(v, n, ans); // n-1, n+2
    v[p[n+1].second]--; v[p[n].second]++;
    ans += p[n].first - p[n+1].first;
    z[2] = judge(v, n, ans); // n-1, n+1
    v[p[n-2].second]--; v[p[n-1].second]++;
    ans += p[n-1].first - p[n-2].first;
    z[3] = judge(v, n, ans); // n, n+1
    sort(z, z+4);
    cout << z[0] << endl;
    return 0;
}

Measured memory_bytes: 4352
using System;
using System.Collections;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Collections.Generic;
namespace Collections
{
	class program
	{
    //static long MAX_LONG = 5000000000000000;
		static void Main(string[] args)
		{

			// 入力
      int[] input = Console.ReadLine().Split().Select(p => int.Parse(p)).ToArray();
      int N = input[0];
      int M = input[1];
      int Q = input[2];

      // 都市iを出発してjの距離を走る電車の数をtrain[i][j]に記録する
      int[,] train = new int[N+1, N+1];
      for(int i=0; i<M; i++)
      {
          input = Console.ReadLine().Split().Select(p => int.Parse(p)).ToArray();
          int L = input[0];
          int R = input[1];
          train[L, R-L] += 1;
      }

      // 都市iを出発して、jの距離以下を走る電車の数をあらかじめ求めておく(部分和)
      int[,] partsum = new int[N+1, N+1];
      for(int i=1; i<=N; i++)
      {
        for(int j=0; j<=N; j++)
        {
          if(j==0)
          {
            partsum[i,j] = train[i,j];
          }
          else
          {
            partsum[i,j] = partsum[i, j-1] + train[i,j];
          }
        }
      }

      //質問に答える
      // pから出発してqまでに到着する電車の数は
      // 都市pを出発してq-p以下の距離を走る電車の数＋都市p+1を出発して・・・
      for(int q =0; q<Q; q++)
      {
        input = Console.ReadLine().Split().Select(p => int.Parse(p)).ToArray();
        int L = input[0];
        int R = input[1];

        int ans = 0;
        for(int i=L; i<=R; i++)
        {
          ans += partsum[i,R-i];
        }
        Console.WriteLine(ans + "");
      }
    }
	}
}


Measured memory_bytes: 19700
import sys, math
input = sys.stdin.readline
rs = lambda: input().strip()
ri = lambda: int(input())
rl = lambda: list(map(int, input().split()))
mod = 10**9 + 7

A, B, N = rl()

def f(x):
	return math.floor(A * x / B) - A * math.floor(x/B)

if N < B-1:
	print(f(N))
else:
	print(f(B-1))


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

int main(){
  int a,b;
  cin >>a >>b;
  int fir = b*a;
  if(fir%2 == 0) cout << "Even" << endl;
  else cout << "Odd" << endl;
  return 0;
}


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

int main(){
  string s;
  cin >> s;
  int count_0 = 0;
  int count_1 = 0;
  for (int i = 0; i<s.size(); i++){
    if (s.at(i) == '0'){
      count_0 ++;
    }
    else{
      count_1 ++;
    }
  }
  cout << min(count_0, count_1) * 2 << endl;
}

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

int main() {
  long N;
  cin>>N;
  int a;
  a=sqrt(N)/1;
  
  for (long i =a; i >0; i--) {
    long b=(double)N/i;
      if(i*b==N){
        cout<<i+b-2<<endl;
        break;
      }
  }
  
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
using namespace std;
typedef long long LL;
inline int read()
{
	char c=getchar(); int num=0,f=1;
	while (c<'0'||c>'9') { if (c=='-') f=-1; c=getchar(); }
	while (c<='9'&&c>='0') { num=num*10+c-'0'; c=getchar(); }
	return num*f;
}
inline LL readl()
{
	char c=getchar(); LL num=0,f=1;
	while (c<'0'||c>'9') { if (c=='-') f=-1; c=getchar(); }
	while (c<='9'&&c>='0') { num=num*10+c-'0'; c=getchar(); }
	return num*f;
}
LL A,B,C,K;
int main()
{
	A=readl(); B=readl(); C=readl(); K=readl();
	if (K&1) cout<<B-A; else cout<<A-B;
	return 0;
}

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

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

  int d;
  cin >> d;
  string s = "Christmas";
  switch (d) {
  case 22:
    s += " Eve";
  case 23:
    s += " Eve";
  case 24:
    s += " Eve";
  default:
    ;
  }
  cout << s << "\n";
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define db(x) cerr<<__LINE__<<": "<<#x<<" = "<<(x)<<'\n'
const int N = 2e5;
int A[N+9];

int main() {
	ios_base::sync_with_stdio(0);
	int a,b,n,k,T,cas=0;
	cin>>n>>k;
	for(int i=0;i<n;++i) cin>>A[i];
	sort(A, A+n, greater<int>());
	long long s=0;
	for(int i=k;i<n;++i) s+=A[i];
	cout<<s;
	return 0;
}

Measured memory_bytes: 1024
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;
using static System.Console;
using static System.Math;
class Z { static void Main() => new K(); }
class K
{
	int F => int.Parse(Str);
	long FL => long.Parse(Str);
	int[] G => Strs.Select(int.Parse).ToArray();
	long[] GL => Strs.Select(long.Parse).ToArray();
	string Str => ReadLine();
	string[] Strs => Str.Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
	const int MOD = 1000000007;
	public K()
	{
		SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
		Solve();
		Out.Flush();
	}
	void Solve()
	{
		var I = G;
		WriteLine(I.Sum() + 9 * I.Max());
	}
}


Measured memory_bytes: 13268
#include <iostream>
#include <iomanip>

using namespace std ;
int main ()
{
	int  c=0 , d=0 , f=0 , g=0 ;
	double a=0 , b=0 , e=0 ;
	cin >> a >> b ;
	f=a ;
	g=b ;
	c=a/b ;
	d=f%g ;
	e=a/b ;
	cout << c << " " << d << " " << fixed << setprecision(5) << e << endl ;
}



Measured memory_bytes: 3264
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
#include <math.h>

int main(void){
    int n,ans=0;
    scanf("%d",&n);
    int a[n];
    for (int i=0; i<n; i++){
        scanf("%d",&a[i]);
    }
    for (int i=0; i<n; i++){
        if (i+1==a[a[i]-1]){
            ans++;
        }
    }
    printf("%d\n",ans/2);
	return 0 ;
}

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

#pragma GCC optimize "O3"
#define rep(i,a,n) for(long long i=a; i<n; i++)
typedef long long ll;
typedef pair<int,int> P;
const ll MOD = (int)1e9+7;
const ll INF = MOD*MOD;
const double EPS = 1e-9;
const ll powll = 1LL<<1;

/*
while(!frag && cin >> a >>b, a|b)
*/

int main(void){
    int a; cin >> a;
    cout << 1-a << "\n";
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define nmax 101
using namespace std;

int n,x,d[nmax],aux,may;

main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    d[1]=0;
    cin>>n>>x;
    for(int i=1;i<=n;i++){
        cin>>aux;
        d[i+1]=d[i]+aux;
        if(d[i+1]<=x && d[i+1]>d[may]) may=i+1;
    }
    cout<<may;
}


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

#define fr(i,n) _back
#define pb	push_back
#define eb	emplace_back
#define mk	make_pair
#define fi	first
#define se	second
#define endl	'\n'

typedef long long ll;
typedef pair<int,int> ii;
typedef vector<ii> vii;
const int INF = 0x3f3f3f3f;
const double PI = acos(-1.0);

int main() {
    ios_base::sync_with_stdio(false);
    string s; cin >> s;
    cout << (s=="ABC"?"ARC":"ABC") << endl;

    return 0;
}



Measured memory_bytes: 3580
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))

ans = 0
for i in range(n-1, -1,-1):
    if(a[i+1] >= b[i]):
        ans += b[i]
        continue
    ans += a[i+1]
    b[i] -= a[i+1]
    tmp = min(a[i], b[i])
    ans += tmp
    a[i] -= tmp

print(ans)

Measured memory_bytes: 18624
#include<bits/stdc++.h>
using namespace std;
int a,b,c,i,j,n,s;
int main(){
	int a,b,c,n,s;
    cin>>a>>b>>c>>n;
    for(int i=0;i<=a;i++)
        for (int j=0;j<=b;j++)
            if ((n-i*500-j*100>=0)&&(n-i*500-j*100<=c*50)) ++s;
    cout<<s<<endl;
    return 0;
}

Measured memory_bytes: 256
import sys
from collections import defaultdict

def solve(n, s):
    s_sorted = sorted(s.items(), key=lambda x: -x[1])
    pre = s_sorted[0][1]
    ans = []
    for word, count in s_sorted:
        if count != pre:
             break
        ans.append(word)
    for a in sorted(ans):
        print(a)
        

if __name__ == "__main__":
    n = int(sys.stdin.readline().strip())
    s = defaultdict(int)
    for _ in range(n):
        s_i = sys.stdin.readline().strip()
        s[s_i] += 1
    solve(n, s)

Measured memory_bytes: 47616
#include<bits/stdc++.h>
using namespace std;
const int maxm=2e5+5;
vector<int>g[maxm];
int ans[maxm];
int d[maxm],len;
int a[maxm];
void dfs(int x,int fa){
    int f=0;
    int pos=0;
    int temp=0;
    if(a[x]>d[len]){
        d[++len]=a[x];
        f=1;
    }else{
        int l=1,r=len;
        while(l<=r){//二分插入位置
            int mid=(l+r)/2;
            if(a[x]<=d[mid])pos=mid,r=mid-1;
            else l=mid+1;
        }
        temp=d[pos];
        d[pos]=a[x];
    }
    ans[x]=len;
    for(int v:g[x]){
        if(v==fa)continue;
        dfs(v,x);
    }
    if(f){//回溯的时候撤销
        len--;
    }else{
        d[pos]=temp;
    }
}
signed main(){
    int n;scanf("%d",&n);
    for(int i=1;i<=n;i++)scanf("%d",&a[i]);
    for(int i=1;i<n;i++){
        int a,b;scanf("%d%d",&a,&b);
        g[a].push_back(b);
        g[b].push_back(a);
    }
    dfs(1,-1);
    for(int i=1;i<=n;i++){
        printf("%d\n",ans[i]);
    }
    return 0;
}


Measured memory_bytes: 30488
#include<cstdio>
#include<iostream>
#include<cstring>
#define RG register
#define LL long long
using namespace std;
const LL mod=1e9+7;
int h,w,k,endd,to[10];
LL dp[105][10];
template<typename I> inline void read(I &ot){
	I ch=getchar(), x=0, f=1;
	while(ch<'0' || ch>'9'){if(ch=='-') f=-1; ch=getchar();	}
	while(ch>='0' && ch<='9'){x=x*10+ch-'0'; ch=getchar();	}
	ot=x*f;}
template<typename I, typename... U> inline void read(I &x,U&... y){read(x); read(y...);}
template<typename I>inline void swp(I&a,I&b){a^=b; b^=a; a^=b;}
int main()
{
	//freopen("Number of Amidakuji.in","r",stdin);
	//freopen(".out","w",stdout);
	read(h,w,k); endd=(1<<w-1)-1;// k--;
	dp[0][1]=1;
	for(int i=0;i<h;i++)
	 for(int j=0;j<=endd;j++)
	 {
		int flg=0;
		for(int s=j;s && !flg;s>>=1) if((s&3)==3) flg=1;
		if(flg) continue;
		for(int l=1;l<=w;l++) to[l]=l;
		for(int l=1;l<w;l++) if(j&(1<<l-1)) swp(to[l],to[l+1]);
		for(int l=1;l<=w;l++) (dp[i+1][to[l]]+=dp[i][l])%=mod;
	 }
	printf("%lld\n",dp[h][k]);
	//fclose(stdin); fclose(stdout);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n,i,j,flag=0,k,flag1=0,flag2=0;
    string s;
    cin>>s;
    n=s.length();
    for(i=0;i<n/2;i++)
    {
        if(s[i]!=s[n-1-i])
        {
            flag=1;
            break;
        }
    }
    if(flag==1)
       cout<<"No";
    else
    {
        for(j=0;j<(n-1)/4;j++)
        {
            if(s[j]!=s[((n-1)/2)-1-j])
            {
                flag1=1;
                break;
            }
        }
        for(k=((n+3)/2)-1;k<n/2;k++)
        {
            if(s[k]!=s[n-1-k])
            {
                flag2=1;
                break;
            }
        }
        if(flag1==0&&flag2==0)
            cout<<"Yes";
        else
            cout<<"No";
    }

}


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

int main(){
  int N;
  cin >> N;
  vector<int> A(N);
  for(int i=0;i<N;i++){
    cin >> A.at(i);
  }
  int ans = 1;
  for(int i=0;i<N;i++){
    if(A.at(i)%2==1){
      continue;
    }
    if(A.at(i)%3!=0 && A.at(i)%5 != 0){ 
      ans = 2;
    }
  }
  if(ans==1){
    cout<<"APPROVED"<<endl;
  }
  else{
    cout<<"DENIED"<<endl;
  }
  return 0;
}
 
  

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

typedef long long ll;
const ll MOD = 1e9 + 7;
const ll inf = 1LL<<60;
const double eps = 1e-9;

typedef pair<ll, ll> P;

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

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

    for (int i = 0; i <= n; i++) {
        for (int j = 0; j <= n; j++) {
            if (i + j > n) continue;
            int tmp = n - i - j;
            if (10000*i + 5000*j + 1000*tmp == y) {
                cout << i << " " << j << " " << tmp << endl;
                return 0;
            }
        }
    }
    cout << -1 << " " << -1 << " " << -1 << endl;
	return 0;
}


Measured memory_bytes: 256
let s = Scanf.scanf " %c%c%c%c" @@ fun a b c d -> [|a; b; c; d|]
let _ =
  Array.sort compare s;
  print_endline @@ if s.(0) = s.(1) && s.(2) = s.(3) && s.(1) <> s.(2) then "Yes" else "No"

Measured memory_bytes: 384
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <bitset>
using namespace std;
typedef long long ll;
typedef unsigned long long int ull;
#define rep(i,a,n) for(ll i = (a);i < (n);i++)
#define per(i,a,n) for(ll i = (a);i > (n);i--)
#define lep(i,a,n) for(ll i = (a);i <= (n);i++)
#define pel(i,a,n) for(ll i = (a);i >= (n);i--)
#define all(v) (v).begin(),(v).end()
#define clr(a,b) memset((a),(b),sizeof(a))
#define sz size()
#define pb push_back
#define print(x) cout << x << endl
int n,m;
int ans;
string s,t;
// int w[1000],v[1000];
// int d[1001],dp[1001][1001];
vector<int> vec;

int main(){
  cin >> s;
  rep(i,0,s.sz){
    if(i % 2 == 0)t += s[i];
  }
  print(t);
  return 0;
}


Measured memory_bytes: 512
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<time.h>

using namespace std;

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

#define FOR(i,n) for(int (i)=0;(i)<(n);(i)++)
#define FOR1(i,n) for(int (i)=1;(i)<(n);(i)++)
#define eFOR(i,n) for(int (i)=0;(i)<=(n);(i)++)
#define eFOR1(i,n) for(int (i)=1;(i)<=(n);(i)++)
#define SORT(i) sort((i).begin(),(i).end())

vector<string> s;
int len;
ll n;
void sgs(string a) {
	if (a.length() == len) {
		if (stoi(a) <= n)s.push_back(a);
		return;
	}
	sgs(a + '7');
	sgs(a + '5');
	sgs(a + '3');
	s.push_back(a);
}

int main() {

	string N;
	cin >> N;
	n = stoi(N);
	len = N.length();
	sgs("7");
	sgs("5");
	sgs("3");
	int cnt = 0;
	FOR(i, s.size()) {
		string k = s[i];
		int s7 = 0, s5 = 0, s3 = 0;
		FOR(j, k.length()) {
			if (k[j] == '7')s7++;
			if (k[j] == '5')s5++;
			if (k[j] == '3')s3++;
		}
		if (s7 && s5 && s3)cnt++;
	}
	cout << cnt << endl;

	return 0;
}


Measured memory_bytes: 2172
s = input()
t=input()
s1=len(s)
t1=len(t)
def p(val):
    print(val)


count = 0
for i in range(s1-t1+1):
    miss = 0
    for j in range(t1):
        if s[j+i] != t[j]:
            miss +=1
    if i == 0:
        count = miss
    else:
        if count>=miss:
            count = miss

p(count)

Measured memory_bytes: 9060
#include <bits/stdc++.h>
using namespace std;
#define lll __int128
typedef long long ll; const int inf=2e9;
typedef double lf; const lf err=1e-7;
typedef pair<int,int> pii;
#define repeat(i,a,b) for(int i=(a),iE=(b);i<iE;i++)
#define repeat_back(i,a,b) for(int i=(b)-1,iE=(a);i>=iE;i--)
#define mst(a,x) memset((a),(x),sizeof(a))
#define Clear(a) {a=decltype(a)();}
#define qwq {cerr<<"qwq"<<endl;}
#define orz(x) {cerr<<#x": "<<x<<endl;}
ll read(){ll n; scanf("%lld",&n); return n;}
const int N=10010;
const int mod=1e9+7;
#define int ll
int n,a[N],inv[N];
ll qpow(ll a,ll b,ll mod){
	ll ans=1;
	while(b){
		if(b&1)ans=ans*a%mod; //必要时slow
		a=a*a%mod; //必要时slow
		b>>=1;
	}
	return ans;
}
struct fac{
	#define facN 1010
	ll a[facN]; set<ll> s;
	fac(){
		mst(a,0);
	}
	void lcm(ll n){
		repeat(i,2,facN)
		if(n%i==0){
			int cnt=0;
			while(n%i==0)
				cnt++,n/=i;
			a[i]=max(a[i],cnt);
		}
		if(n>1)s.insert(n);
	}
	ll value(){
		ll ans=1;
		repeat(i,2,facN)
		if(a[i]){
			ans=(ans*qpow(i,a[i],mod))%mod;
		}
		for(auto i:s)
			ans=ans*i%mod;
		return ans;
	}
}f;
void get_inv(int a[],int n){//求a[1..n]的逆元，存在inv[1..n]中
	static int pre[N]={1};
	repeat(i,1,n+1)
		pre[i]=1ll*pre[i-1]*a[i]%mod;
	int inv_pre=qpow(pre[n],mod-2,mod);
	repeat_back(i,1,n+1){
		inv[i]=1ll*pre[i-1]*inv_pre%mod;
		inv_pre=1ll*inv_pre*a[i]%mod;
	}
}
signed main(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin>>n;
	//cout<<f.value()<<endl;
	repeat(i,1,n+1){
		cin>>a[i];
		f.lcm(a[i]);
		//cout<<f.value()<<endl;
	}
	ll s=f.value();
	get_inv(a,n);
	ll ans=0;
	repeat(i,1,n+1)
		ans=(ans+s*inv[i]%mod)%mod;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1024
n,m=map(int,raw_input().split())
A,B=[],[]
c=0
for i in xrange(n):
	A.append(map(int,raw_input().split()))
for i in xrange(m):
	B.append(int(raw_input()))
for i in xrange(n):
	for j in xrange(m):
		c+=A[i][j]*B[j]
	print c
	c=0

Measured memory_bytes: 6552
#include <bits/stdc++.h>
#define  rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
typedef long int li;
typedef unsigned long long ull;
typedef vector<int> vi;


int main()
{
    string s,ans;
    cin>>s;
    for(char c:s){
        if(c!='B')ans+=c;
        else if(ans.size()!=0) ans=ans.substr(0,ans.size()-1);
    }
    cout<<ans<<endl;
    return 0;
}

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

int main(){
    int n;
    cin >> n;
    int cnt = 0;
    rep(i, n){
        ll a;
        cin >> a;
        if (a % 2 != 0) cnt ++;
    }
    if (cnt % 2 != 0) cout << "NO" << endl;
    else cout << "YES" << endl;
}

Measured memory_bytes: 256
factor_1, factor_2 = list(map(int, input().split()))

L = [i for i in input().split()]

D_pre = 0
count = 0

if(D_pre <= factor_2):
	count += 1


for i in range(len(L)):
	D_pre = D_pre + int(L.pop(0))
	
	if(D_pre <= factor_2):
		count += 1

print(count)


Measured memory_bytes: 3060
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int c = sc.nextInt();
    String ans = "No";
    int d = (a + b + c) / 2;
    if(d == a) ans = "Yes";
    if(d == b) ans = "Yes";
    if(d == c) ans = "Yes";
    if(((a + b + c) % 2) == 1) ans = "No";
    System.out.println(ans);
  }
}

Measured memory_bytes: 23764
import java.util.*;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int m1 = sc.nextInt();
		int d1 = sc.nextInt();
		int m2 = sc.nextInt();
		int d2 = sc.nextInt();
		sc.close();
		if (m1 == m2){
			System.out.println(0);
		} else {
			System.out.println(1);
		}
	}
}


Measured memory_bytes: 22868
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cstring>
#include <cctype>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_map>
#include <set>
#include <deque>
#include <map>
#include <bitset>
#include <functional>
#include <cmath>

#define INF 1000000000
using namespace std;

int main() {
    char c;
    cin >> c;
    if('a' <= c && c <= 'z'){
        cout << "a" << endl;
    }else{
        cout << "A" << endl;
    }
}


Measured memory_bytes: 3620
#include<iostream>
using namespace std;
int main(){
  int k;
  cin>>k;
  int a,b;
  cin>>a>>b;
  int f=0;
  for(int i=a;i<=b;i++){
    if(i%k==0){
      f=1;
      cout<<"OK";
      break;
    }
  }
  if(!f){
    cout<<"NG";
  }
}

Measured memory_bytes: 3100
#include<iostream>
#include<cstdio>
#include<algorithm>
	using namespace std;
int main()
{
	int s[5];
	scanf("%d%d%d",&s[1],&s[2],&s[3]);
	sort(s+1,s+3+1);
	printf("%d",(s[2]-s[1])+(s[3]-s[2]));
	return 0;
} 

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>

using namespace std;

int d[100001];

int main()
{
	int N, M; scanf("%d %d", &N, &M);

	for (int i = 1; i <= N - 1; ++i) {
		int s; scanf("%d", &s);
		d[i] = s + d[i - 1];
	}

	int ans = 0;

	int now = 0;

	for (int i = 0; i < M; ++i) {
		int a; scanf("%d", &a);
		int nxt = now + a;
		ans += d[max(now, nxt)] - d[min(now, nxt)];
		ans %= 100000;
		now = nxt;
	}

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

Measured memory_bytes: 1412
#include <iostream>
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    int N;
    cin >> N;
    vector<int> a(N);
    //for(int i=0; i<N; i++)cin >> a.at(i);
    for(int i=0; i<N; i++){
        scanf("%d", &a.at(i));
    }
    int push = 1;
    
    for(int i=0; i<N; i++){
        int next_push = a.at(push - 1);
        
        //if finished
        if(next_push == 2){
            cout << i + 1 << endl;
            exit(0);
        }
        push = next_push;
    }
    cout << -1 << endl;
}


Measured memory_bytes: 640
/*
  Warn - Don't change next line else you will get WA verdict. Online Judge is configured to give WA if next line is not present.
  Author - Aryan Choudhary (@aryanc403)
 
  const short DEBUG { 0 };
  #define debug(x) if (DEBUG) cout << #x << " = " << x << '\n'
*/

#pragma warning(disable:4996)
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize ("Ofast")
#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize ("-ffloat-store")

#include<iostream>
#include<bits/stdc++.h>
#include<stdio.h>
using namespace std;
#define fo(i,n)   for(i=0;i<(n);++i)
#define repA(i,j,n)   for(i=(j);i<=(n);++i)
#define repD(i,j,n)   for(i=(j);i>=(n);--i)
#define pb push_back
#define mp make_pair
#define X first
#define Y second
#define endl "\n"
#define PI 3.1415926535897932384626433832795
typedef long long int lli;
typedef long double mytype;
typedef pair<lli,lli> ii;
typedef vector<ii> vii;
typedef vector<lli> vi;

//const lli [3] ={ 999119999L,1000000007L,1000992299L};
//const lli [3] ={ 97L,101L,103L};
//const lli  = chrono::high_resolution_clock::now().time_since_epoch().count();
clock_t time_p=clock();
void aryanc403()
{
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}

class CMP
{
public:
    bool operator()(lli a , lli b) //For min priority_queue .
    {
        return ! ( a <= b );
    }
};

void add( map<lli,lli> &m, lli x,lli cnt=1)
{
    map<lli,lli> ::iterator jt;
    jt=m.find(x);
    if(jt==m.end())         m.insert(mp(x,cnt));
    else                    jt->Y+=cnt;
}

void del( map<lli,lli> &m, lli x,lli cnt=1)
{
    map<lli,lli> ::iterator jt;
    jt=m.find(x);
    if(jt->Y<=cnt)            m.erase(jt);
    else                      jt->Y-=cnt;
}

bool cmp(const ii &a,const ii &b)
{
    return a.X<b.X||(a.X==b.X&&a.Y<b.Y);
}
const lli INF = 0xFFFFFFFFFFFFFFFL;
const lli mod = 1000000007L;

    lli T,n,i,j,k,in,cnt,l,r;
    lli m;
    string s;
    vi a;
    vi :: iterator it;
    lli dp[100005];
    //priority_queue < lli , vector < lli > , CMP > pq;// min priority_queue .

int main(void) {
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    // freopen("txt.in", "r", stdin);
    // freopen("txt.out", "w", stdout);
// cout<<std::fixed<<std::setprecision(35);
// cin>>T;while(T--)
{

    cin>>n;
    a.clear();a.reserve(n);
    fo(i,n)
    {
        cin>>in;
        a.pb(in);
    }
    dp[0]=0;
    dp[1]=abs(a[0]-a[1]);
    repA(i,2,n-1)
        dp[i]=min(dp[i-1]+abs(a[i]-a[i-1]),dp[i-2]+abs(a[i]-a[i-2]));
    cout<<dp[n-1]<<endl;
}   aryanc403();
    return 0;
}

Measured memory_bytes: 1792
#pragma GCC optimize(3,"Ofast","inline")
#pragma GCC target("avx")
#include <bits/stdc++.h>
using namespace std;
#ifdef ONLINE_JUDGE
#define getchar gc
inline char gc(){
	static char buf[1<<16],*p1=buf,*p2=buf;
	if(p1==p2){
		p2=(p1=buf)+fread(buf,1,1<<16,stdin);
		if(p2==p1) return EOF;
	}
	return *p1++;
}
#endif
template<class t> inline t read(t &x){
    char c=getchar();bool f=0;x=0;
    while(!isdigit(c)) f|=c=='-',c=getchar();
    while(isdigit(c)) x=(x<<1)+(x<<3)+(c^48),c=getchar();
    if(f) x=-x;return x;
}
template<class t> inline void write(t x){
    if(x<0) putchar('-'),write(-x);
    else{if(x>9) write(x/10);putchar('0'+x%10);}
}

#define int long long

int a,b,n;

signed main(){
	read(a);read(b);read(n);
	n=min(n,b-1);
	write(a*n/b-a*(n/b));
}

Measured memory_bytes: 3604
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int N=500;
const int mod=1e9+7;
ll ksm(ll a,ll b){
	ll res=1,t=a;
	while(b){
		if(b&1)res=(res*t)%mod;
		t=(t*t)%mod;
		b>>=1;
	}
	return res;
}
ll dp[N][N];
ll n,c;
ll a[N],b[N];
ll p[N][N];
ll sum[N][N];
void init(){
	for(int i=1;i<N;i++)
	for(int j=0;j<N;j++)p[i][j]=ksm(i,j);
	for(int k=0;k<N;k++){
		for(int i=1;i<N;i++)sum[i][k]=(sum[i-1][k]+p[i][k])%mod;
	}
}
int main()
{
	//freopen("H:\\c++1\\in.txt","r",stdin);
	//freopen("H:\\c++1\\out.txt","w",stdout);
	init();
	scanf("%lld%lld",&n,&c);
	for(int i=1;i<=n;i++)scanf("%lld",&a[i]);
	for(int i=1;i<=n;i++)scanf("%lld",&b[i]);
	dp[0][0]=1;
	for(int i=1;i<=n;i++)
	for(int j=0;j<=c;j++){
		for(int k=0;k<=j;k++){
			dp[i][j]=(dp[i][j]+(dp[i-1][j-k]*(sum[b[i]][k]-sum[a[i]-1][k]+mod)%mod))%mod;
		}
	}
	printf("%lld\n",dp[n][c]);
	return 0;
}

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

int x[100000], n, a, b;

bool ok(int m){
	ll an = 0;
	f(i, 0, n){
		ll t = x[i] - (ll)m * b;
		if (t > 0)an += (t + a - 1) / a;
	}
	return an <= m;
}

int main(){
	scanf("%d%d%d", &n, &a, &b);
	a -= b;
	f(i, 0, n)scanf("%d", x + i);
	int l = 1, r = 1e9;
	while (r > l){
		int m = l + r >> 1;
		if (ok(m))r = m;
		else l = m + 1;
	}
	printf("%d\n", l);
}

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

public class Main {

	/**
	 * ?????????????????§??????????????????????????°??£?????????????????????????\?????????? 10 ???????????????????????????????????¨??????????????????????????¨???????????????
	 * ???????\???????????????±????????¨??? 5% ???????????????????????????????????????????????? 1,000 ?????????????????????????????????
     *n ?????\???????????¨??????n ??±????????????????????????????????????????????????????????°?????????????????????????????????n ??? 100 ??\?????¨????????????
	 * @param args
	 * @throws IOException 
	 * @throws NumberFormatException 
	 */
	public static void main(String[] args) throws NumberFormatException, IOException {
		// TODO ?????????????????????????????????????????????
		InputStreamReader is = new InputStreamReader(System.in);       
        BufferedReader br = new BufferedReader(is);                   
  
        int weekNum = Integer.parseInt(br.readLine());
        
        
        int debt = 100000;	//????????????
        int roundUpNum =1000;	//?????????????????°???
        
        for(int i = 0;i < weekNum;i++) {
        	debt *= 1.05;
        	//1000???????????????????????????
        	debt = (int)Math.ceil((double)debt / roundUpNum) * roundUpNum;
        }
        System.out.println(debt);
        
        
        
	}
	
	

}

Measured memory_bytes: 16864
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<map>
#include<stack>
#include<queue>
#include<bitset>

#define ipair pair<int,int>
#define rep(i,n) for(i=0;i<n;i++)

using namespace std;

typedef long long int lli;
typedef long long ll;
typedef vector<int> vi;

int main() {
	string s;
	vector<ipair>l;
	vi a;
	int i, j, k, q, m, n;
	bool t;

	cin >> n >> q;
	cin >> s;
	rep(i, q) {
		cin >> j >> k;
		l.push_back(make_pair(j, k));
	}

	a.resize(n);
	a[0] = 0;
	rep(i, n) {
		if (s[i] == 'A') {
			t = true;
			if (i > 0)
				a[i] = a[i - 1];
		}
		else if (t && s[i] == 'C') {
			a[i] = a[i - 1] + 1;
			t = false;
		}
		else {
			t = false;
			a[i] = a[i - 1];
		}
	}

	rep(i, q) {
		cout << a[l[i].second-1] - a[l[i].first-1] << endl;
	}

	return 0;
}

Measured memory_bytes: 2292
#coding: utf-8
import math
import heapq
import bisect
import numpy as np
from collections import Counter
#from scipy.misc import comb

S = input()
T = input()

dict = {}
re_dict = {}
flg = 1
for i in range(len(S)):
    if S[i] in dict:
        if T[i] != dict[S[i]]:
            flg = 0
            break
    else:
        dict[S[i]] = T[i]
        if T[i] in re_dict:
            if re_dict[T[i]] != S[i]:
                flg = 0
                break
        else:
            re_dict[T[i]] = S[i]

if flg:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 14896
H, W = map(int, input().split())
S = [list(input()) for _ in range(H)]

Left = [[0] * W for _ in range(H)]
for y in range(H):
    count = 0
    for x in range(W):
        if S[y][x] == '#':
            count = 0
        else:
            count += 1
        Left[y][x] = count

Right = [[0] * W for _ in range(H)]
for y in range(H):
    count = 0
    for x in range(W-1, -1, -1):
        if S[y][x] == '#':
            count = 0
        else:
            count += 1
        Right[y][x] = count

Up = [[0] * W for _ in range(H)]
for x in range(W):
    count = 0
    for y in range(H):
        if S[y][x] == '#':
            count = 0
        else:
            count += 1
        Up[y][x] = count

Down = [[0] * W for _ in range(H)]
for x in range(W):
    count = 0
    for y in range(H-1, -1, -1):
        if S[y][x] == '#':
            count = 0
        else:
            count += 1
        Down[y][x] = count

ans = 0
for i in range(H):
    for j in range(W):
        if S[i][j] == '#':
            continue
        else:
            res = Left[i][j] + Right[i][j] + Up[i][j] + Down[i][j] - 3
            ans = max(ans, res)

print(ans)

Measured memory_bytes: 312072
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<string>
#include<cstring>
#include<map>
#include<queue>
#include<stack>

using namespace std;

typedef long long ll;
const int maxx = 1e6 + 5;

struct node{
	int x;
	int y;
}a[10];

bool cmp(const node &A, const node &B){
	return A.y > B.y;
}

int main(){
	int ans = 0;
	int n, m, i, j, flag;
	for(i = 0; i < 5; i++){
		scanf("%d", &a[i].x);
		if(a[i].x % 10 != 0) a[i].y = a[i].x % 10;
		else a[i].y = 10;
	}
	sort(a, a + 5, cmp);
	for(i = 0; i < 4; i++){
		if(a[i].x % 10 == 0) ans += a[i].x;
		else ans += ((a[i].x / 10 + 1) * 10);
	}
	cout << ans + a[4].x << endl;
	return 0;
}

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

typedef long long llong;

llong gcd(llong m, llong n)
{
    if (n == 0) return m;
    return gcd(n, m % n);
}

llong lcm(llong m, llong n)
{
    return m * n / gcd(m, n);
}

int main(int argc, const char * argv[]) {
    llong A, B, C, D;
    
    cin >> A >> B >> C >> D;

    llong a1 = B / C;
    llong a2 = B / D;
    llong a3 = B / lcm(C, D);
    llong b1 = (A - 1) / C;
    llong b2 = (A - 1) / D;
    llong b3 = (A - 1) / lcm(C, D);
    
    llong ans1 = B - ((a1 + a2) - a3);
    llong ans2 = (A - 1) - ((b1 + b2) - b3);
    llong ans = ans1 - ans2;

    cout << ans << endl;

    return 0;
}

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

using namespace std;
using ll = long long;
#define N (ll)(1e9+7)
ll mypower(ll a, ll b, ll mod = N)
{
    ll ans = 1;
    while(b)
    {
        if(b%2)
            ans = (ans*a)%mod;
        b=b/2;
        a=(a*a)%mod;
    }
    return ans;
}
bool comp(pair<ll,ll> a, pair<ll,ll> b)
{
    return a.first > b.first;
}
int main() {
    ll x;
    cin >> x;
    cout << ((x/500)*1000 + 5*((x%500)/5));
    
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner scan = new Scanner(System.in);
        
        String s = scan.next();
        int l = s.length()-1;
        
        while(l>0)
        {
            if(CheckOString(s,l)==1)
            {
                System.out.println(l);
                return;
            }
            l--;
        }
        System.out.println("Error");
    }
    
    static int CheckOString(String s,int l){
        if(l%2==1)
        {
            return 0;
        }
        for(int i=0;i<l/2;i++)
        {    
            if(s.charAt(i)!=s.charAt(l/2+i))
            {
                return 0;
            }
        }
        return 1;
    }
}

Measured memory_bytes: 20948
#include<iostream>

int main(){

  long long R;

    std::cin >> R;
    if ( R < 1200 )
      std::cout << "ABC";
// else if ( R < 2800)がelse if (1199 < R < 2800)だと駄目な理由
    else if ( R < 2800)
      std::cout << "ARC" ;

    else
      std::cout << "AGC" ;

  return 0;

}


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


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

	int mae, usiro;
	mae = (s[0] - '0') * 10 + s[1] - '0';
	usiro = (s[2] - '0') * 10 + s[3] - '0';

	bool yymm = false;
	bool mmyy = false;
	if (mae >= 1 && mae <= 12) {
		mmyy = true;
	}
	if (usiro >= 1 && usiro <= 12) {
		yymm = true;
	}

	string ans;
	if (yymm == true && mmyy == true) {
		ans = "AMBIGUOUS";
	} else if (yymm == true && mmyy == false) {
		ans = "YYMM";
	} else if (yymm == false && mmyy == true) {
		ans = "MMYY";
	} else {
		ans = "NA";
	}

	cout << ans << endl;
}


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

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

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

const int MAX = 1e5 + 5;
const int INF = 1001001001;
const int MOD = 1e9 + 7;

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

    int r = 1;
    int N = 1;
    while (r * 2 <= L) {
        r *= 2;
        N++;
    }

    vector<vector<P>> G(N, vector<P>());
    r = 1;
    int M = 0;
    rep(i, N - 1) {
        G[i].emplace_back(i + 1, 0);
        G[i].emplace_back(i + 1, r);
        M += 2;
        r *= 2;
    }

    vector<int> nums(21);
    nums[0] = 1;
    rep(i, 20) nums[i + 1] = nums[i] * 2;

    for (int i = N - 2; i >= 0; --i) {
        if (r + nums[i] - 1 < L) {
            G[i].emplace_back(N - 1, r);
            r += nums[i];
            M++;
        }
    }

    cout << N << " " << M << endl;
    rep(i, N) {
        for (auto j : G[i]) {
            cout << i + 1 << " " << j.first + 1 << " " << j.second << endl;
        }
    }
}

Measured memory_bytes: 256
package main

import (
	"fmt"
	"sort"
)

func main() {

	v := make([]int, 3)
	for i := 0; i < 3; i++ {
		var a int
		fmt.Scan(&a)
		v[i] = a
	}
	sort.Ints(v)
	fmt.Println(v[0], v[1], v[2])
}



Measured memory_bytes: 1168
#include <iostream>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>
using namespace std;

int main(){
    int n;
    cin >> n;
    
    vector<int> a(n), b(n);
    for(int i=0 ; i < n ; i++ ){
        cin >> a[i];
        b[i] = i+1;
    }
    // d[v] := スタートからの距離, h[v] := ゴールからの距離
    map<vector<int>,int> d, h;
    // 解は最大でも n-1 
    int ans = n-1;
    // ゴールから探索
    {
        h[b] = 0;
        queue<vector<int> > q;
        q.push( b );
        while( !q.empty() ){
            vector<int> v = q.front();
            int cost = h[v];
            q.pop();
            
            if( v == a ){
                ans = cost;
                break;
            }
            if( cost >= 4 ) break;
            
            for(int i=0 ; i < n ; i++ ){
                for(int j=i+1 ; j < n ; j++ ){
                    vector<int> next = v;
                    reverse( next.begin()+i , next.begin()+j+1 );
                    if( !h.count(next) ){
                        h[next] = cost+1;
                        q.push(next);
                    }
                }
            }
        }
    }
    // スタートから探索
    {
        d[a] = 0;
        queue<vector<int> > q;
        q.push( a );
        while( !q.empty() ){
            vector<int> v = q.front();
            int cost = d[v];
            q.pop();
            
            if( h.count(v) ){
                ans = cost + h[v];
                break;
            }
            if( cost >= 4 ) break;
            
            for(int i=0 ; i < n ; i++ ){
                for(int j=i+1 ; j < n ; j++ ){
                    vector<int> next = v;
                    reverse( next.begin()+i , next.begin()+j+1 );
                    if( !d.count(next) ){
                        d[next] = cost+1;
                        q.push(next);
                    }
                }
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 81196
#include <stdio.h>
#include <stdlib.h>
#define MAX(x,y) ((x)<(y)?(y):(x))

typedef long long ll;
const ll INF = 1LL << 60;
 
int main(){
    int N;
    scanf("%d",&N);
    ll A[N];
    for(int i = 0;i<N;i++) scanf("%lld",&A[i]);
    ll dp[4][N/2];
    for(int i = 0;i<N/2;i++) dp[0][i] = (0LL-INF);
    for(int j = 0;j<N/2;j++){
        for(int i = 1;i<4;i++){
            if(j==0) dp[i][j]=MAX(dp[i-1][j],A[i-1]);
            else if(j>0) dp[i][j]=MAX(dp[i-1][j],dp[i][j-1]+A[2*j+i-1]);
        }
    }
  	if(!(N & 1))printf("%lld\n",dp[2][N/2-1]);
  	else printf("%lld\n",dp[3][N/2-1]);
    return 0;
}

Measured memory_bytes: 6396
#include <iostream>
#include <vector>
#include <cmath>
using namespace std;

int main() {
    int N;
    cin >> N;
    vector<int> a(N);
    for(int i=0; i<N; ++i) {
        cin >> a[i];
    }
    int ans = 1e9;
    for(int i=-100; i<=100; ++i) {
        int tmp = 0;
        for(int j=0; j<N; ++j) {
            tmp += (a[j] - i)*(a[j] - i);
        }
        ans = min(ans , tmp);
    }
    cout << ans << endl;
}


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

queue<pr>q;
int H,W;
char ss[1005][1005];
int vis[1005][1005];
int dx[4] = {0,-1,1,0};
int dy[4] = {1,0,0,-1};
int main() {
	scanf("%d%d",&H,&W);
	for(int i=1;i<=H;i++) {
			
		scanf("%s",&ss[i][1]);
			for(int j=1;j<=W;j++)
			if(ss[i][j]=='#') {
				vis[i][j] = 1;
				q.push(pr(i,j));
			}
		
	}
	int ans = 0;
	while(q.size()) {
		int x = q.front().first; int y = q.front().second;
		q.pop();
		ans = max(ans,vis[x][y]-1);
		for(int i=0;i<4;i++) {
			int nx = x+dx[i]; int ny = y+dy[i];
			if(nx>=1&&nx<=H&&ny>=1&&ny<=W&&!vis[nx][ny]) {
				vis[nx][ny] = vis[x][y]+1;
				q.push(pr(nx,ny));
			}
		}
	}
	cout<<ans;
}

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

using namespace std;

typedef long long ll;

const int mod = 1e9+7;

int main(){
	std::ios::sync_with_stdio(false);
    cin.tie(0);
    int a,b;
    cin >> a >> b;
    if(a<=9 && b<=9) cout << a*b;
    else cout << -1 << "\n";

	return 0;
} 


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

using namespace std;

int get_index(int value, int dice[]){
    for(int i = 0; i < 6; i++){
        if(dice[i] == value){
            return i + 1;
        }
    }
}

bool match_pattern(int upper_key, int front_key, int pattern[]){
    for(int i = 0; i < 5; i++){
        if(pattern[i] == upper_key){
            if(pattern[i+1] == front_key){ 
                return true;
            }
        }
    }
    return false;
}

int main(){
    int dice[6];
    int q;
    for(int i = 0; i < 6; i++) scanf("%d",&dice[i]);
	scanf("%d", &q);
    for(int i = 0; i < q; i++){
        int upper, front;
        scanf("%d", &upper);
        scanf("%d", &front);
        int upper_key = get_index(upper, dice);
        int front_key = get_index(front, dice);
        
        int pattern3 [5] = {1,2,6,5,1};
        int pattern4 [5] = {5,6,2,1,5};
        int pattern1 [5] = {4,2,3,5,4};
        int pattern6 [5] = {5,3,2,4,5};
        int pattern5 [5] = {1,3,6,4,1};
        int pattern2 [5] = {4,6,3,1,4};

        if(match_pattern(upper_key, front_key, pattern3)){
            printf("%d\n", dice[2]);
            continue;
        }else if(match_pattern(upper_key, front_key, pattern4)){
           printf("%d\n", dice[3]);
            continue;
        }else if(match_pattern(upper_key, front_key, pattern1)){
            printf("%d\n", dice[0]);
            continue;
        }else if(match_pattern(upper_key, front_key, pattern6)){
            printf("%d\n", dice[5]);
            continue;
        }else if(match_pattern(upper_key, front_key, pattern5)){
            printf("%d\n", dice[4]);
            continue;
        }else if(match_pattern(upper_key, front_key, pattern2)){
            printf("%d\n", dice[1]);
            continue;
        }
    
    }
}

/*
1 2 3 4 5 6
3
6 5
1 3
3 2

answer
3
5
6
*/


Measured memory_bytes: 2688
anslist = []

while True:
    n = int(input())
    if not n:
        break

    a = list(map(int, input().split()))

    ans = 10 ** 10
    for i in range(n):
        for j in range(n):
            if i != j:
                ans = min(ans, abs(a[i] - a[j]))

    anslist.append(ans)

for i in anslist:
    print(i)


Measured memory_bytes: 5644
#k = int(input())
#s = input()
#a, b = map(int, input().split())
#s, t = map(str, input().split())
#l = list(map(int, input().split()))
#l = [list(map(int,input().split())) for i in range(n)]
#a = [input() for _ in range(n)]

x,n = map(int, input().split())
p = list(map(int, input().split()))

ans = x
for i in range(x, 102):
    if i not in p:
        ans = i
        break

ans2 = x
for i in range(x-1, -1, -1):
    if i not in p:
        ans2 = i
        break

#print(ans,ans2)
tmp1 = abs(ans - x)
tmp2 = abs(x - ans2)

if (tmp1 < tmp2):
    print(ans)
elif (tmp1 == tmp2):
    print(min(ans, ans2))
else:
    print(ans2)





Measured memory_bytes: 9128
#include <stdio.h>
int main() {
    int i, h, min,max,j, n, d, k;
    scanf("%d", &h);
    min = 0;max=1000000001;
    for (i = 1; i <= h; i++) {
        scanf(" %d", &n);
    if (n > min) {
        min = n;
    }
    if(n<max){
        max=n;
    }
    }
    printf("%d\n", min-max);

    return 0;
}


Measured memory_bytes: 128