akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <algorithm>
using namespace std;

const int STUDENT_MAX_NUM = 50;
const int EXAM_MAX = 50;
const int RE_EXAM_MAX = 100;

class Student{
  private:
    char grade;
    int intermidateExam;
    int finalExam;
    int reExam;
  public:
    Student();
    void setExamResult(int ie, int fe, int re);
    char getGrade();
};

Student::Student(){
}

void Student::setExamResult(int ie, int fe, int re){
  intermidateExam = min(ie, EXAM_MAX);
  intermidateExam = max(ie, -1);
  finalExam = min(fe, EXAM_MAX);
  finalExam = max(fe, -1);
  reExam = min(re, RE_EXAM_MAX);
  reExam = max(re, -1);

  switch(intermidateExam+finalExam){
    case 80 ... 100:
      grade = 'A';
      break;
    case 65 ... 79:
      grade = 'B';
      break;
    case 50 ... 64:
      grade = 'C';
      break;
    case 30 ... 49:
      if(reExam >= 50){
        grade = 'C';
      } else {
        grade = 'D';
      }
      break;
    default:
      grade = 'F';
      break;
  }
  if(intermidateExam == -1 || finalExam == -1) grade = 'F';
}

char Student::getGrade(){
  return grade;
}

int main(){
  Student *students = new Student[STUDENT_MAX_NUM];
  int a,b,c;
  int count = 0;
  for(int i=0;i<STUDENT_MAX_NUM;i++){
    scanf("%d",&a);
    scanf("%d",&b);
    scanf("%d",&c);
    if(a == -1 && b == -1 && c == -1)
      break;
    students[i].setExamResult(a,b,c);
    count++;
  }

  for(int i=0; i<count;i++){
    printf("%c\n",students[i].getGrade());
  }
  return 0;
}


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

const ll MOD=1e9+7;
const double EPS=1e-9;
const double PI=acos(-1.0);
//const long double PI=acos(-1.0L);

struct Point{
    double x,y;
    Point(){}
    Point(double x,double y):x(x),y(y){}

    Point operator +(const Point &b) const {return Point(x+b.x,y+b.y);}
    Point operator -(const Point &b) const {return Point(x-b.x,y-b.y);}
    Point operator *(const double b) const {return Point(x*b,y*b);}
    Point operator /(const double b) const {return Point(x/b,y/b);}
};

struct Line{
    Point a,b;
    Line(){}
    Line(Point a,Point b):a(a),b(b){}
};

int sgn(double a) {return (a>EPS)-(a<-EPS);}
int sgn(double a,double b) {return sgn(a-b);}

double dot(const Point &a,const Point &b) {return (a.x*b.x+a.y*b.y);}
double cross(const Point &a,const Point &b) {return (a.x*b.y-a.y*b.x);}
double norm(const Point &p) {return dot(p,p);}
double abs(const Point &p) {return sqrt(norm(p));}

Point projection(const Point &p,const Line &l){
    double r=dot(p-l.a,l.b-l.a)/norm(l.b-l.a);
    return l.a+(l.b-l.a)*r;
}

Point reflection(const Point &p,const Line &l){
    return p+(projection(p,l)-p)*2;
}

//1:Counter_Clockwise -1:Clockwise
//2:a-b-c -2:c-a-b 0:a-c-b
int ccw(const Point &p,const Point &q){
    int s=sgn(cross(p,q));
    if(s!=0) return s;
    if(dot(p,q)<0) return -2;
    if(norm(p)<norm(q)) return 2;
    return 0;
}
int ccw(const Point &a,const Point &b,const Point &c){return ccw(b-a,c-a);}

int main(){
    Point P1,P2;
    cin>>P1.x>>P1.y>>P2.x>>P2.y;
    int Q;
    cin>>Q;

    Line L(P1,P2);
    for(int q=0;q<Q;q++){
        Point p;
        cin>>p.x>>p.y;

        int type=ccw(P1,P2,p);
        switch(type){
            case 1: cout<<"COUNTER_CLOCKWISE"<<endl;break;
            case -1: cout<<"CLOCKWISE"<<endl;break;
            case 2: cout<<"ONLINE_FRONT"<<endl;break;
            case -2: cout<<"ONLINE_BACK"<<endl;break;
            case 0: cout<<"ON_SEGMENT"<<endl;break;
        }
    }

    return 0;
}



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

int main(){
  string s;
  cin >> s;
  int length;
  if ( s.size() % 2 == 0){
    length = s.size()/2;
  } else {
    length = s.size()/2;
  }

  int cnt = 0;
  for ( int i = 0; i < length; i++){
    if ( s[i] != s[s.size()-1-i]){
      cnt++;
    }
  }

  cout << cnt << endl;

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0;i < (n);++i)
#define reps(i,n) for(int i = 1;i <= (n);++i)
using namespace std;
int main(){
  int n,a;
  cin >> n >> a;
  if(n % 500 <= a) cout << "Yes\n";
  else cout << "No\n";
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
  int n, k;
  scanf("%d", &n);
  scanf("%d", &k);
  int a[n];
  int i = 0;
  while (i < n)
  {
    scanf("%d", &a[i]);
    i++;
  }
  
  i = 0;
  int sum = 0;
  while (i < n)
  {
    if (a[i] <= k - a[i])
    {
      sum += a[i] * 2;
    }
    else
    {
      sum += (k - a[i]) * 2;
    }
    i++;
  }
  printf("%d", sum);
  return 0;
}


Measured memory_bytes: 128
#include<stdio.h> 

int main(void) 
{ 
    int  j,temp=0; 
    int height[10]; 
    
    for(j=0;j<10;j++) 
	{ 
 	    scanf("%d", &height[j]); 
 	} 
    
    
    
    
    int sorted = 0;
    while (sorted==0)
	{
	    sorted=1;
	    
	    for(j=0; j<9 ; j++)
		{
		    if(height[j]<height[j+1])
			{
			    temp=height[j];
			    height[j]=height[j+1];
			    height[j+1]=temp;
			    sorted=0;
			    
			}
		}
	    
	    
	    if (sorted) break;
	}
    for(j=0;j<3;j++)
	{
	    printf("%d\n", height[j]);
	    
	}
    return 0;
    
}

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

int main() {
  int N, K, total = 0;
  cin >> N;
  cin >> K;
  for (int i = 0; i < N; i++) {
    int  x;
    cin >> x;
    if (K <= x)
      total +=  (x - K) * 2;
    else if (x >= K - x)
      total += (K - x) * 2;
    else 
      total += x * 2;
  }
  cout << total << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include<iomanip>
#include<tuple>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main() {
    int n;
    string s;
    cin>>n>>s;
    vector<int>v;
    vector<int>w;
    vector<int>a;
    
    v.push_back(0);
    
    for(int i=0;i<n;i++){
        if(s[i]=='W'){
            v.push_back(1+v[i]);
        }
        else{
            v.push_back(v[i]);
        }
    }
    w.push_back(0);
     for(int i=0;i<n;i++){
        if(s[n-1-i]=='E'){
            w.push_back(1+w[i]);
        }
        else{
            w.push_back(w[i]);
        }
    }   
    for(int i=1;i<n+1;i++){

        a.push_back(v[i-1]+w[n-i]);
        //cout<<w[i-1]<<endl;

}
sort(a.begin(),a.end());
cout<<a[0]<<endl;

    return 0;
}

Measured memory_bytes: 6008
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <algorithm>
#include <utility>
#include <cmath>
using namespace std;
using ll=long long;
using P=pair<int,int>;
#define rep(i,a,b) for(ll i=a;i<ll(b);i++)
#define repr(i,a,b) for(ll i=a;i>=ll(b);i--)
#define el '\n'
#define ALL(x) x.begin(),x.end()
#define ALLR(x) x.rbegin(),x.rend()
#define INF 1e9
#define DEBUG(x) cout<<"debug: "<<x<<endl
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}

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

    int ans = 0;
    rep(i, 1, n){
        int t = (n + (i-1)) / i;
        t--;
        ans += t;
    }
    cout << ans << el;
    return 0;
}


Measured memory_bytes: 3220
n = int(input())
a = [list(map(int, input().split())) for i in range(n)]
x=0
y=0
for i in range(n):
    if x<=a[i][0] and y<=a[i][1]:
        x=a[i][0]
        y=a[i][1]
    else:
        v=-(x//-a[i][0])
        w=-(y//-a[i][1])
        u=max(v,w)
        x=u*a[i][0]
        y=u*a[i][1]

print(x+y)

Measured memory_bytes: 39280
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for (ll i=0; i<n; ++i)
#define all(c) begin(c),end(c)
template<typename T1, typename T2>
bool chmax(T1 &a,T2 b){if(a<b){a=b;return true;}else return false;}
template<typename T1, typename T2>
bool chmin(T1 &a,T2 b){if(a>b){a=b;return true;}else return false;}
/*

*/
int main(){
  cin.tie(0);
  ios::sync_with_stdio(0);
  
  ll N; cin>>N;
  map<char, ll> M; cin >> M['A'] >> M['B'] >> M['C'];
  vector<string> S(N, "");
  vector<char> ans(0, 0);
  rep(i, N) cin >> S[i];
  rep(i, N){
    char c1, c2, n1, n2;
    c1 = S[i][0];
    c2 = S[i][1];
    if (i < N-1){
      n1 = S[i+1][0];
      n2 = S[i+1][1];
    }
    if (M[c1] == 0 && M[c2] == 0){
      cout<<"No"<<endl;
      return 0;
    }
    if (M[c1] > M[c2]){
      ans.push_back(c2);
      M[c2]++;
      M[c1]--;
    }
    else if (M[c1] < M[c2]){
      ans.push_back(c1);
      M[c1]++;
      M[c2]--;
    }
    else if (M[c1] == M[c2] && i < N-1){
      if (c1 == n1 || c1 == n2){
        ans.push_back(c1);
        M[c1]++;
        M[c2]--;
      }
      else{
        ans.push_back(c2);
        M[c2]++;
        M[c1]--;
      }
    }
    else{
      ans.push_back(c1);
      M[c1]++;
      M[c2]--;
    }
  }
  cout<<"Yes"<<endl;
  rep(i, N) cout<< ans[i] << endl;
}


Measured memory_bytes: 6700
import java.util.*;

public class Main {

    Scanner sc = new Scanner(System.in);

    int MOD = (int)1e9+7;
    int n = sc.nextInt();
    int a = sc.nextInt();
    int b = sc.nextInt();

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

    void run() {
        Comb cb = new Comb(n, MOD);

        long sum = cb.modpow(2, n);

        long comA = cb.nck(n, a);
        long comB = cb.nck(n, b);

        long ans = sum-comA-comB-1+MOD*2;

        System.out.println(ans%MOD);

    }

    public class Comb {
        int n;   //　要素数
        int MOD = (int)1e9+7;
        long[] facts;

        public Comb(int n, int MOD){
            this.n = n;
            this.MOD = MOD;
//            facts = new long[n+1];
//            facts[0] = 1;
//            for (int i=1; i<n+1; i++){
//                facts[i] = facts[i-1] * i % MOD;
//            }
        }

        public long modpow(long a, long b){  // 計算量はlog(MOD);
            if (b==0) return 1;
            else if (b==1) return a;
            long x = modpow(a, b/2);
            return b%2 == 0 ? x * x % MOD : x * (x*a%MOD) % MOD;
        }
        public long inv(long n){ // 逆元。x^(-1)≡x^(p-2) (MOD p)
            return modpow(n, MOD-2);
        }
        public long nck(int n, int k){
            long ret = 1;
            for (int i=0; i<k; i++) {
                ret = ret * (n - i) % MOD * inv(k - i);
                ret %= MOD;
            }
            return ret % MOD;
//            return n < k ? 0: facts[n] * (inv(facts[n-k]) * inv(facts[k]) % MOD) % MOD;
        }


    }
}



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

int form(char a, char b, char c){
    int ans  = 0;
    int xa = a - '0';
    int xb = b  - '0';
    int xc = c - '0';

    ans = (100 * xa) + (10 * xb) + (xc);
    return ans;
}
int m = INT_MAX;
int main(){
    string s;cin>> s;
    for(int i=0;i<s.size()-2;i++){
        m = min (m , abs(form(s[i],s[i+1],s[i+2]) - 753 ));
    }
    cout << m << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int n,m,u,k,i,j,g[100][100];

int main(){

  for(i=0;i<100;i++)
    for(j=0;j<100;j++)g[i][j]=0;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d%d",&m,&u);
    for(j=0;j<u;j++){
      scanf("%d",&k);
      g[m-1][k-1]=1;
    }
  }
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      printf("%d",g[i][j]);
      if(j!=n-1)printf(" ");
    }
    printf("\n");
  }
  return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
using namespace std;
typedef long long ll;
#define rep(i,a,n)	for(int i=a;i<n;i++)
#define rrep(i,a,n) for(int i=(a-1);i>=n;i--)
 
ll gcd(ll a,ll b){
	if(b==0)return a;
	return gcd(b,a%b);
}
ll lcm(ll a,ll b){
	ll g=gcd(a,b);
	return a/g*b;
}
 
ll digitsum(ll a){
	ll x=0;
	while(a>0){
		x+=a%10;
		a/=10;
	}
	return x;
}
int main(){
	ll a,b,c;
	cin>>a>>b>>c;
	ll x=min(a+b,a+c);
	cout<<min(x,b+c)<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const ll mod=1e9+7;
void solve(){
	ll n,k;
	cin>>n>>k;
	vector<ll>a(n);
	for(ll i=0;i<n;i++) cin>>a[i];
	ll prod=1;
	sort(a.begin(),a.end());
	if(a[n-1]==0&&k%2==1) {cout<<0;return;}
	if(a[n-1]<0&&k&1){
		for(ll i=n-1;i>=n-k;i--){
			prod=(a[i]*prod)%mod;
		}
		cout<<((prod%mod)+mod)%mod;return;
	}
	if(a[n-1]<0&&k%2==0){
		for(ll i=0;i<k;i++){
			prod=(a[i]*prod)%mod;
		}
		cout<<((prod%mod)+mod)%mod;return;
	}
	ll i=0;ll j=n-1;
	if(a[n-1]>0&&k&1){
		prod=(prod*a[n-1])%mod;
		j--;k--;
	}
	k=k>>1;
	for(ll itr=0;itr<k;itr++){
		ll lprod=a[i]*a[i+1];
		ll rprod=a[j]*a[j-1];
		if(lprod>rprod){
			prod=prod*a[i]%mod*a[i+1]%mod;
			i+=2;
		}
		else{
			prod=prod*a[j]%mod*a[j-1]%mod;
			j-=2;
		}
	}
	if(prod<0) cout<<((prod%mod)+mod)%mod;
	else cout<<prod%mod;
} 
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL);	 
	int T=1;
	// cin>>T;
	while(T--){
		solve();
	}
	return 0;
}

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

namespace ABC084
{
    class D
    {
        static void Main(string[] args)
        {
            int Q = int.Parse(Console.ReadLine());

            int[] l = new int[Q];
            int[] r = new int[Q];
            string[] input;
            for (int i = 0; i < Q; i++)
            {
                input = Console.ReadLine().Split(' ');
                l[i] = int.Parse(input[0]);
                r[i] = int.Parse(input[1]);
            }

            int Max = r.Max();
            int[] s = new int[Max + 1];
            s[0] = 0;
            for (int i = 1; i <= Max; i++)
            {
                if ((i % 2) != 0)
                {
                    // i が奇数
                    if (IsPrimeNumber(i) && IsPrimeNumber((i + 1) / 2))
                    {
                        s[i] = s[i - 1] + 1;
                    }
                }

                if (s[i] == 0)
                {
                    s[i] = s[i - 1];
                }
            }

            int k = 0;
            for (int j = 0; j < Q; j++)
            {
                k = s[r[j]] - s[l[j] - 1];
                if (r[j] == l[j] && (IsPrimeNumber(r[j]) && IsPrimeNumber((r[j] + 1) / 2))) { k = 1; }
                Console.WriteLine(k);
            }
        }

        static bool IsPrimeNumber(int number)
        {
            double i = number;

            // 平方根を求める
            double x = Math.Sqrt(i);

            // 平方根以下の値で割り切れるのか確認する
            // 最小値は2
            for (double j = 2; j <= x; j++)
            {
                if ((number % j) == 0) { return false; }
            }

            if (number == 1) { return false; }

            return true;

        }

    }
}

Measured memory_bytes: 16708
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		long mod = (long)Math.pow(10, 9)+7;

		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		sc.close();
		long power = 1L;
		for(int i = 2;i <= N;i++) {
			power = ((power%mod)*i)%mod;
		}
		System.out.println(power);
	}
}

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

S = [0] * (N+1)
for i in range(N+1):
    if S_raw[i] == '1':
        S[N-i] = 1

left0 = list(range(N+1))
for i in range(1, N+1):
    if S[i] == 1:
        left0[i] = left0[i-1]

ans = []
i = 0
while True:
    if i + M >= N:
        ans.append(N - i)
        break
    j = left0[i + M]
    if j == i:
        print(-1)
        exit()
    ans.append(j-i)
    i = j

ans = reversed(ans)
print(*ans)


Measured memory_bytes: 50336
fac=[1]*505050
inv=[1]*505050
finv=[1]*505050
mod=1000000007
for i in range(2,500010):
  fac[i]=fac[i-1]*i%mod
  inv[i]=-inv[mod%i]*(mod//i)%mod
  finv[i]=finv[i-1]*inv[i]%mod

def C(n,r):
  if n<0 or r<0 or n<r: return 0
  return fac[n]*finv[n-r]%mod*finv[r]%mod

N,M=map(int,input().split())
ans=0
for i in range(N+1):
  ans+=C(N,i)*fac[M]%mod*finv[M-i]%mod*((fac[M-i]*finv[M-N])**2%mod)*(1 if i%2==0 else -1)%mod
  ans%=mod
print(ans%mod)


Measured memory_bytes: 101984
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin>>n;
    string a,b; cin>>a;
    if(n%2){
        cout<<"No\n";
        return 0;
    }
    for(int i=0; i<n/2; i++){
        if(a[i]!=a[i+n/2]){
            cout<<"No\n";  return 0;
        }
    }
    cout<<"Yes\n";
    
}

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

#define int long long
const int MN = 2e5+5;
multiset<int> arr;
int n, i, j, ans;

signed main(){
    for(scanf("%lld",&n),i=1;i<=n;i++){
        int x; scanf("%lld",&x);
        arr.insert(x);
    }
    while(arr.size()){
        auto it = arr.end(); it--;
        int cur = *it; arr.erase(it);
        for(i=0;(1LL<<i)<=cur;i++){}
        int rem = (1LL<<i)-cur;
        if(arr.find(rem)!=arr.end()){
            ans++;
            arr.erase(arr.find(rem));
        }
    }
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 9728
#include <iostream>
#include <cstdio>
#include <vector>
#include <map>
#include <queue>
#include <string>
#include <set>
#include <algorithm>
#include <utility>
#include <cstring>
#include <cmath>
using namespace std;


int main() {
    int64_t r,d,x;
    cin>>r>>d>>x;
    for(int i=0;i<10;++i){
        x=r*x-d;
        cout<<x<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cstdio>
#include <cstring>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>

typedef long long ll;
using namespace std;

#define FALSE printf("false\n");
#define TRUE printf("true\n");
#define all(x) (x).begin(),(x).end()
#define print(x) cout<<(x)<<endl
#define rep(i,n) for(int i = 0;i < ((int)(n));++i)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define SUM(vec) accumulate(all(vec),0LL)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define test(a) cout<<"line:"<<__LINE__<<"["<<(#a)<<": "<<(a)<<"]"<<endl

const int INF = 1e9+7;
const ll INFL = 9*1e18;

ll inline digit(ll num){int tmp = 0;while(num){tmp++;num/=10;}return tmp;}
template<typename T>inline T digitSum(T num){T sum = 0;while(num){sum+=num%10;num/=10;}return sum;} // 各桁の和
template<typename T>inline T gcd(T a,T b){if(b == 0)return a;return gcd(b,a%b);}
template<typename T>inline T lcm(T a, T b){T g = gcd(a,b);return a/g*b;}
template<typename T>inline T power(T a,T b){T tmp=1;rep(i,b){tmp*=a;}return tmp;}


bool isOk(ll key,ll value){
  return key >= value;
}

ll binary_search(vector<ll> a,ll key){
  ll ok = a.size()-1;
  ll ng = 0;

  while(abs(ok - ng) > 1){
    ll mid = (ok + ng) / 2;
    if(isOk(key,a[mid]))ok = mid;
    else ng = mid;
  }
  return ok;
}

bool isPrime(ll n) {
	for (int i = 2; n >= i * i; ++i) {
		if(!(n % i))return false;
	}
  return true;
}

int main() {
  cin.tie(0); ios::sync_with_stdio(0);
  int n;cin>>n;
  vector<int> a(n);rep(i,n)cin>>a[i];
  sort(all(a));
  int tmp = 0;
  int ans = 0;
  rep(i,n){
    if(i != 0 && a[i] != a[i-1]){
      ans += tmp%2;
      tmp = 0;
    }
    ++tmp;
  }
  ans += tmp%2;
  print(ans);
  return 0;
}

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

using namespace std;

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

#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()

#define DUMP(x) cerr<<#x<<" = "<<(x)<<endl
#define DEBUG(x) cerr<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<<endl;

template<class T>
ostream &operator<<(ostream &os, const vector <T> &v) {
    os << "[";
    REP(i, SZ(v)) {
        if (i) os << ", ";
        os << v[i];
    }
    return os << "]";
}

template<class T, class U>
ostream &operator<<(ostream &os, const pair <T, U> &p) {
    return os << "(" << p.first << " " << p.second << ")";
}

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

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

using ll = long long;
using ull = unsigned long long;
using ld = long double;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vi>;
using vvll = vector<vll>;

const ll MOD = 1e9 + 7;
const int INF = INT_MAX / 2;
const ll LINF = LLONG_MAX / 2;
const ld eps = 1e-9;


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    // ifstream in("in.txt");
    // cin.rdbuf(in.rdbuf());

    string s; cin >> s;

    cout << s.substr(0, 3) << endl;

    return 0;
}


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

#define EB emplace_back
#define int long long
#define F first
#define S second
#define N 100005
#define ALL(x) x.begin(),x.end()
#define endl '\n'
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)


using namespace std;

bool OK(string a, string b)
{
	for(int i = 0; i < (int)a.size(); i++)
	{
		if(a[i] == '?') continue;
		if(a[i] != b[i]) return false;
	}
	return true;
}

int32_t main()
{
    IOS;

    int tt=1;
    //cin>>tt;
    while(tt--)
    {
		string s,t; cin>>s>>t;
		reverse(ALL(s));
		reverse(ALL(t));
		int i = 0;
		int ans = 0;
		int len = t.size();
		int n = s.size();
		while (i < n - len + 1)
		{
			string temp = s.substr(i,len);
			if(OK(temp,t))
			{
				ans = 1;
				string a = s.substr(0,i);
				string b = s.substr(i+len);
				s = "";
				s = a + t + b;
				break;
			}
			i++;
		}
		if (ans)
		{
			for(auto &x : s) if(x == '?') x = 'a';
			reverse(ALL(s));
			cout<<s;
		}
		else cout<<"UNRESTORABLE";
    }
    return 0;

}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {

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

		for(int i = 0 ; i < n ; i++) {
			road[i] = 0;
		}

		for(int i = 0 ; i < m ; i++) {
			a[i] = sc.nextInt();
			b[i] = sc.nextInt();
		}

		for(int i = 0 ; i < m ; i++) {
			for(int j = 0 ; j < n ; j++) {
				if(a[i] == j + 1) {
					road[j] += 1;
				}
				if(b[i] == j + 1) {
					road[j] += 1;
				}
			}
		}

		for(int i = 0 ; i < n ; i++) {
			System.out.println(road[i]);
		}
	}
}


Measured memory_bytes: 23764
#include <string>
#include <vector>
#include <utility>
#include <iostream>
#include <algorithm>

using namespace std;

int H, W, N;

bool ok(vector<string> S)
{
	int dotcount = 0;

	for (int i = 0; i < H; i++)
	{
		for (int j = 0; j < W; j++)
		{
			if (S[i][j] == '.')
			{
				dotcount += 1;
			}
		}
	}

	if (dotcount == H * W)
	{
		return true;
	}

	vector<string> S2(S.begin(), S.end());

	for (int i = 0; i < H; i++)
	{
		for (int j = 0; j < W; j++)
		{
			int count_ = 1;

			char target = S[i][j];

			if (target != '.')
			{
				for (int k = j + 1; k < W; k++)
				{
					if (S[i][k] == target)
					{
						count_ += 1;
					}
					else
					{
						break;
					}
				}
			}

			if (count_ >= N)
			{
				for (int k = j; k < j + count_; k++)
				{
					S2[i][k] = '+';
				}
			}
		}
	}

	for (int i = 0; i < H; i++)
	{
		for (int j = 0; j < W; j++)
		{
			int count_ = 1;

			char target = S[i][j];

			if (target != '.')
			{
				for (int k = i + 1; k < H; k++)
				{
					if (S[k][j] == target)
					{
						count_ += 1;
					}
					else
					{
						break;
					}
				}
			}

			if (count_ >= N)
			{
				for (int k = i; k < i + count_; k++)
				{
					S2[k][j] = '+';
				}
			}
		}
	}

	int pluscount = 0;

	for (int i = 0; i < H; i++)
	{
		for (int j = 0; j < W; j++)
		{
			if (S2[i][j] == '+')
			{
				pluscount += 1;
			}
		}
	}

	if (pluscount == 0)
	{
		return false;
	}

	for (int i = 0; i < H; i++)
	{
		for (int j = 0; j < W; j++)
		{
			if (S2[i][j] == '+')
			{
				for (int k = i; k > 0; k--)
				{
					S2[k][j] = S2[k - 1][j];
				}

				S2[0][j] = '.';
			}
		}
	}

	return ok(S2);
}

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

	vector<string> M(H);

	for (int i = 0; i < H; i++)
	{
		cin >> M[i];
	}

	bool clear = false;

	if (ok(M) == true)
	{
		clear = true;
	}

	for (int i = 0; i < H; i++)
	{
		for (int j = 0; j < W - 1; j++)
		{
			vector<string> M2(M.begin(), M.end());

			if (M2[i][j] != M2[i][j + 1])
			{
				swap(M2[i][j], M2[i][j + 1]);

				for (int k = 1; k < H; k++)
				{
					for (int l = 0; l < W; l++)
					{
						if (M2[k][l] == '.')
						{
							for (int m = k; m > 0; m--)
							{
								M2[m][l] = M2[m - 1][l];
							}
							
							M2[0][l] = '.';
						}
					}
				}

				if (ok(M2) == true)
				{
					clear = true;
				}
			}
		}
	}

	cout << (clear == true ? "YES" : "NO") << endl;

	return 0;
}

Measured memory_bytes: 3288
#include<cstdio>
#include<cmath>
#include<vector>
using namespace std;
#define EPS (1e-10)
#define equals(a, b) (fabs(a-b)<EPS)

struct Point//???
{
    double x, y;
    Point(double x=0, double y=0):x(x), y(y){}
};
typedef Point Vector;//??????

struct Segment{ Point p1, p2; };//??????
typedef Segment Line;//??´???

class Circle//???
{
public:
    Point c;
    double r;
    Circle(Point c=Point(), double r=0.0):c(c), r(r){}
};

typedef vector<Point> Polygon;//????????¢

Point operator + (Point a, Point b){ return Point(a.x+b.x, a.y+b.y); }
Point operator - (Point a, Point b){ return Point(a.x-b.x, a.y-b.y); }
Point operator * (Point a, double p){ return  Point(a.x*p, a.y*p); }
Point operator / (Point a, double p){ return Point(a.x/p, a.y/p); }

double norm(Vector a){ return a.x*a.x+a.y*a.y; }//?????°????¨?????????????
double abs(Vector a){ return sqrt(norm(a)); }//?¨?
double dot(Vector a, Vector b){ return a.x*b.x+a.y*b.y; }//??????
double cross(Vector a, Vector b){ return a.x*b.y-a.y*b.x; }//??????

bool isOrthgonal(Vector a, Vector b){ return equals(dot(a, b), 0.0); }//???????????´????????????
bool isOrthgonal(Point a1, Point a2, Point b1, Point b2){ return isOrthgonal(a1-a2, b1-b2); }//???????????´???4?????????
bool isOrthgonal(Segment s1, Segment s2){ return equals(dot(s1.p2-s1.p1, s2.p2-s2.p1), 0.0); }//???????????´????????????

bool isParallel(Vector a, Vector b){ return equals(cross(a, b), 0.0); }//????????????????????????
bool isParallel(Point a1, Point a2, Point b1, Point b2){ return isParallel(a1-a2, b1-b2); }//???????????????4?????????
bool isParallel(Segment s1, Segment s2){ return equals(cross(s1.p2-s1.p1, s2.p2-s2.p1), 0.0); }//????????????????????????

Point project(Segment s, Point p)//?±?????¶?
{
    Vector base=s.p2-s.p1;
    double r=dot(p-s.p1, base)/norm(base);
    return s.p1+base*r;
}

Point reflect(Segment s, Point p)//?±??????°??´??????????§°???
{
    return p+(project(s, p)-p)*2.0;
}

int main()
{
    Segment T;
    int q;
    scanf("%lf%lf%lf%lf", &T.p1.x, &T.p1.y, &T.p2.x, &T.p2.y);
    scanf("%d", &q);
    while(q--)
    {
        Point s;
        scanf("%lf%lf", &s.x, &s.y);
        printf("%.10lf %.10lf\n", reflect(T, s).x, reflect(T, s).y);
    }
    return 0;
}

Measured memory_bytes: 2756
#include <bits/stdc++.h>
using namespace std;
const int INF = 1e8;
const int maxq = 1024;
const int maxn = 255;

int dp[maxq][maxn], l[maxn][maxn], s[maxn][maxn];
int a[maxq];
int n, m, q;

void init() {
    for(int k = 0; k < n; k ++) {
        for(int i = 0; i < n; i ++) {
            for(int j = 0; j < n; j ++) {
                l[i][j] = min(l[i][j], l[i][k] + l[k][j]);
                s[i][j] = min(s[i][j], s[i][k] + s[k][j]);
            }
        }
    }
}

void solve() {
    init();
    for(int i = 0; i < q; i ++)
        for(int j = 0; j < n; j ++)
            dp[i][j] = INF;
    for(int i = 0; i < n; i ++) 
        dp[0][i] = min(dp[0][i], s[a[0]][i] + l[i][a[0]]);
    for(int i = 1; i < q; i ++) {
        for(int j = 0; j < n; j ++) {
            for(int k = 0; k < n; k ++) {
                if(j != k)
                dp[i][k] = min(dp[i][k], dp[i-1][j] + l[a[i-1]][j] + s[j][k] + l[k][a[i]]);
                else 
                dp[i][j] = min(dp[i][j], dp[i-1][j] + l[a[i-1]][a[i]]);
            }
        }
    }
    int ans = INF;
    for(int i = 0; i < n; i ++)
        ans = min(ans, dp[q-1][i]);
    printf("%d\n", ans);
}
int main() {
    while(~scanf("%d%d", &n, &m)) {
        if(n==0 && m==0) break;
        for(int i = 0; i < n; i ++) 
            for(int j = 0; j < n; j ++) 
                l[i][j] = s[i][j] = (i==j)?0:INF;
        while(m --) {
            int u, v, w; char o[2];
            scanf("%d%d%d%s", &u, &v, &w, o); u--, v--;
            if(o[0] == 'L') l[u][v] = l[v][u] = min(l[u][v], w);
            else s[u][v] = s[v][u] = min(s[u][v], w);
        }   scanf("%d", &q);
        for(int i = 0; i < q; i ++) {
            scanf("%d" ,a+i);
            a[i] --;
        }
        solve();
    }
    return 0;
}

Measured memory_bytes: 4484
import sys

readline = sys.stdin.readline

def main():
    n = int(input())
    S = list(map(int, readline().split()))
    q = int(input())
    T = list(map(int, readline().split()))
    ans = 0
    for i in range(q):
        target = T[i]
        upper = len(S)-1
        lower = 0
        middle = (upper + lower) // 2
        while lower <= upper:
            if target == S[middle]:
                ans += 1
                break
            elif target < S[middle]:
                upper = middle - 1
            else:
                lower = middle + 1
            middle = (upper + lower) // 2

    print(ans)        


if __name__ == "__main__":
    main()



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

using namespace std;

typedef long long ll;
typedef long double ld;
signed main() {
    //freopen("input.txt", "r", stdin);
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    string s;
    int b = 0;
    int r = 0;
    cin >> n >> s;
    for (char c : s) {
        if (c == 'R') r++;
        else b++;
    }
    if (r > b) cout << "Yes";
    else cout << "No";
    return 0;
}

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

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

typedef long long ll;

const int INF = 1 << 30;
const ll LLINF = 1LL << 62;

int mod = 1000000007;

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int X; cin >> X;
    int ans = 1;
    for(int i = 2; i <= 50; i++){
        for(int j = i*i; j <= X; j*=i){
            ans = max(ans, j);
        }
    }
    cout << ans << endl;
    return 0;
}

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

class UnionFind {
private:
  int n;
  int *par, *rank;
public:
  UnionFind(int _n) : n(_n) {
    par = new int[n];
    rank = new int[n];
    for(int i = 0; i < n; ++i) {
      par[i] = i;
      rank[i] = 0;
    }
  }

  int find(int x) {
    return par[x] == x ? x : par[x] = find(par[x]);
  }

  bool same(int x, int y) {
    return find(x) == find(y);
  }

  void unite(int x, int y) {
    x = find(x);
    y = find(y);
    if(rank[x] < rank[y]) {
      par[x] = y;
    } else {
      par[y] = x;
      if(rank[x] == rank[y]) ++rank[x];
    }
  }
};

const int MAXN = 101;
int N, M;

int main() {
  while(cin >> N && N) {
    cin >> M;
    vector<pair<int,pair<int,int> > > v;
    while(M--) {
      string s;
      cin >> s;
      replace(s.begin(), s.end(), ',', ' ');
      stringstream ss(s);
      int a, b, c;
      ss >> a >> b >> c;
      v.push_back(make_pair(c/100-1, make_pair(a,b)));
    }
    sort(v.begin(), v.end());
    UnionFind uf(N);
    int res = 0;
    for(int i = 0; i < v.size(); ++i) {
      if(!uf.same(v[i].second.first, v[i].second.second)) {
        uf.unite(v[i].second.first, v[i].second.second);
        res += v[i].first;
      }
    }
    cout << res << endl;
  }
  return 0;
}

Measured memory_bytes: 1360
#include<cstdio>
typedef long long ll;
ll n,a,b,c,d,i;
ll abs(ll x){
	return x>0?x:-x;
}
int main(){
	scanf("%lld%lld%lld%lld%lld",&n,&a,&b,&c,&d);
	a*=2;b*=2;c*=2;d*=2;
	n--;
	for(i=1;i<=n;i++)
		if(a<b)
			a+=(c+d)/2;
		else
			a-=(c+d)/2;
	if(abs(a-b)<=n*(d-c)/2)
		printf("YES");
	else
		printf("NO");
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef vector<ll> vi;
typedef pair<ll, ll> pi;
typedef vector<pi> vpi;
typedef vector<string> vsi;
typedef map<ll, ll> mape;
#define rep(i, a, b) for(ll i=(ll)a;i<=(ll)b;i++)
#define per(i, a, b) for(ll i=(ll)a;i>=(ll)b;i--)
#define fastio {ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);}
#define all(v) v.begin(), v.end()
#define N 200010
#define pb push_back 
#define MAX 1234567890
#define mod 1000000007

vi edge[N];
vi visited(N);

ll dfs(ll n)
{
	visited[n] = 1;
	ll cnt = 0;
	for(ll i=0;i<edge[n].size();i++){
		if(!visited[edge[n][i]]) 
			cnt = cnt + dfs(edge[n][i]);
	}
	return 1ll+cnt;
}


int main()
{
    fastio;
    
    ll n, m;
    cin >> n >> m;
    ll x, y;
    rep(i, 0, m-1) {
    	cin >> x >> y;
    	edge[x].pb(y);
    	edge[y].pb(x);
	}
	ll mx = -1;
	rep(i, 1, n){
		if(!visited[i]) mx = max(mx, dfs(i));
	}
	cout << mx << endl;
    
    return 0;
}

Measured memory_bytes: 21820
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0;i < (n);i++)
#define all(v) v.begin(),v.end()
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vl>;

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

ll mod(ll a){
  return (a % 1000000007);
}

ll lcm(ll a,ll b){
  return (a*b)/gcd(a,b);
}


int main(){
  ll a,b,c,d; cin >> a >> b >> c >> d;
  if((a+d-1)/d < (c+b-1)/b) cout << "No" << endl;
  else cout << "Yes" << endl;
}

Measured memory_bytes: 3596
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
#include <set>
#include <map>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;

struct Info{
	char gesture[15];
	vector<int> V;
};

bool strCmp(char* base, char* comp){
	int length1,length2;
	for(length1=0;base[length1] != '\0';length1++);
	for(length2=0;comp[length2] != '\0';length2++);
	if(length1 != length2)return false;

	for(int i=0;base[i] != '\0'; i++){
		if(base[i] != comp[i])return false;
	}
	return true;
}

void strcpy(char* to,char* str){
	for(int i=0;str[i] != '\0';i++){
		to[i] = str[i];
		to[i+1] = '\0';
	}
}

int main(){

	Info info[15];

	strcpy(info[0].gesture,"Rock");
	for(int i = 8; i <= 14; i++)info[0].V.push_back(i);

	strcpy(info[1].gesture,"Gun");
	for(int i = 9; i <= 15; i++)info[1].V.push_back(i%15);

	strcpy(info[2].gesture,"Lightning");
	for(int i = 10; i <= 16; i++)info[2].V.push_back(i%15);

	strcpy(info[3].gesture,"Devil");
	for(int i = 11; i <= 17; i++)info[3].V.push_back(i%15);

	strcpy(info[4].gesture,"Dragon");
	for(int i = 12; i <= 18; i++)info[4].V.push_back(i%15);

	strcpy(info[5].gesture,"Water");
	for(int i = 13; i <= 19; i++)info[5].V.push_back(i%15);

	strcpy(info[6].gesture,"Air");
	for(int i = 14; i <= 20; i++)info[6].V.push_back(i%15);

	strcpy(info[7].gesture,"Paper");
	for(int i = 0; i <= 6; i++)info[7].V.push_back(i);

	strcpy(info[8].gesture,"Sponge");
	for(int i = 1; i <= 7; i++)info[8].V.push_back(i);

	strcpy(info[9].gesture,"Wolf");
	for(int i = 2; i <= 8; i++)info[9].V.push_back(i);

	strcpy(info[10].gesture,"Tree");
	for(int i = 3; i <= 9; i++)info[10].V.push_back(i);

	strcpy(info[11].gesture,"Human");
	for(int i = 4; i <= 10; i++)info[11].V.push_back(i);

	strcpy(info[12].gesture,"Snake");
	for(int i = 5; i <= 11; i++)info[12].V.push_back(i);

	strcpy(info[13].gesture,"Scissors");
	for(int i = 6; i <= 12; i++)info[13].V.push_back(i);

	strcpy(info[14].gesture,"Fire");
	for(int i = 7; i <= 13; i++)info[14].V.push_back(i);


	int N,num[15];
	bool is_win[15],is_lose[15];

	char buf[15];

	while(true){
		scanf("%d",&N);
		if(N == 0)break;

		for(int i = 0; i < 15; i++){
			num[i] = 0;
			is_win[i] = false;
			is_lose[i] = false;
		}

		for(int i = 0; i < N; i++){
			scanf("%s",buf);
			for(int k = 0; k < 15; k++){
				if(strCmp(info[k].gesture,buf)){
					num[k]++;
					break;
				}
			}
		}

		for(int i = 0; i < 15; i++){
			if(num[i] == 0)continue;
			for(int k = 0; k < info[i].V.size(); k++){
				if(num[info[i].V[k]] > 0){
					is_win[i] = true;
					is_lose[info[i].V[k]] = true;
				}
			}
		}

		bool FLG = false;

		for(int i = 0; i < 15; i++){
			if(is_win[i] == true && is_lose[i] == false){
				printf("%s\n",info[i].gesture);
				FLG = true;
				break;
			}
		}
		if(!FLG){
			printf("Draw\n");
		}
	}

	return 0;
}

Measured memory_bytes: 3088
#include<queue>
#include<stack>
#include<math.h>
#include<cmath>
#include<bitset>
#include<stdio.h>
#include<string>
#include<map>
#include<algorithm>
#include<vector>
#include<iostream>
#include<utility>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int main(){
  ll dp[1010][1010],i,j;
  ll mod=1000000007;
  string s,t;
  cin >> s >> t;
  for(i=0;i<=t.size();i++){
    dp[i][0]=0;
  }
  for(i=0;i<=s.size();i++){
    dp[0][i]=1;
  }
  for(i=1;i<=t.size();i++){
    for(j=i;j<=s.size();j++){
      if(t[i-1]==s[j-1]){
        dp[i][j]+=dp[i][j-1]+dp[i-1][j-1];
      }
      else{
        dp[i][j]+=dp[i][j-1];
      }
      dp[i][j]=dp[i][j]%mod;
    }
  }
  printf("%lld\n",dp[t.size()][s.size()]);
  return 0;
}


Measured memory_bytes: 10224
#include <iostream>
#include <stdio.h>
#include <fstream>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <limits.h>
#include <math.h>
#include <functional>
#include <bitset>

#define repeat(i,n) for (long long i = 0; (i) < (n); ++ (i))
#define debug(x) cerr << #x << ": " << x << '\n'
#define debugArray(x,n) for(long long i = 0; (i) < (n); ++ (i)) cerr << #x << "[" << i << "]: " << x[i] << '\n'
#define debugArrayP(x,n) for(long long i = 0; (i) < (n); ++ (i)) cerr << #x << "[" << i << "]: " << x[i].first<< " " << x[i].second << '\n'

using namespace std;

typedef long long ll;
typedef pair<int,int> Pii;
typedef vector<int> vint;
typedef vector<ll> vll;
const ll INF = LLONG_MAX/10;
const ll MOD = 1e9+7;

int main(){
  string S;cin >>S;
  cout << (S.find("AC")!=-1? "Yes":"No") << endl;
  return 0;
}


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

typedef pair<int, int> P;
int N;

int main() {
  while (cin >> N) {
    if (N == 0) break;
    vector<P> v;
    v.push_back(P(0, 0));

    int lc = -1;
    for (int i=0; i<N; i++) {
      int c;
      cin >> c;
      if (c != lc) {
        v.push_back(P(c, 0));
        lc = c;
      }
      v[v.size()-1].second++;
    }
    v.push_back(P(0, 0));

    int L = v.size();
    int A = 0;
    for (int i=1; i<L-1; i++) {
      int c = v[i].first;
      for (int nc=1; nc<=3; nc++) {
        if (nc == c) continue;

        if (v[i].second == 1) {
          int l = i, r = i, s = 1;
          if (v[l-1].first == nc) l--, s+=v[l].second;
          if (v[r+1].first == nc) r++, s+=v[r].second;
          if (s >= 4) {
            A = max(A, s);
            while (v[l-1].first == v[r+1].first && v[l-1].second + v[r+1].second >= 4) {
              l--, r++;
              s += v[l].second + v[r].second;
              A = max(A, s);
            }
          }
        }
        else {
          int l = i, r = i;
          for (int k=0; k<2; k++) {
            int s = 1;
            vector<P> g(v.size()+1);
            for (int j=0; j<v.size(); j++) {
              if (j < i) g[j]   = v[j];
              if (j > i) g[j+1] = v[j];

              if (j == i) {
                if (k == 0) {
                  g[i] = P(nc, 1);
                  g[i+1] = P(v[i].first, v[i].second-1);
                }
                if (k == 1) {
                  l = i+1, r = i+1;
                  g[i] = P(v[i].first, v[i].second-1);
                  g[i+1] = P(nc, 1);
                }
              }
            }
            if (g[l-1].first == nc) l--, s+=g[l].second;
            if (g[r+1].first == nc) r++, s+=g[r].second;
            if (s >= 4) {
              A = max(A, s);
              while (g[l-1].first == g[r+1].first && g[l-1].second + g[r+1].second >= 4) {
                l--, r++;
                s += g[l].second + g[r].second;
                A = max(A, s);
              }
            }
          }
        }
      }
    }
    cout << N - A << "\n";
  }
  return 0;
}

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

int isPrime(int n)
{
    // Corner case
    if (n <= 1)
        return 0;

    // Check from 2 to n-1
    for (int i = 2; i < n; i++)
        if (n % i == 0)
            return 0;

    return 1;
}
int main()
{
    int z[100000];
    double sum=0.0;
//string a,b,c;
long long int c=0,d=0,a,b,t,i,j,k,max,min;
cin>>a;
cin>>b;
k=a*b;
cout<<k;

    return 0;

}



Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,k; cin>>n>>k;
	if(k>=n) {cout << 0; return 0;}
	std::vector<long long> h(n);
	for(int i=0;i<n;i++)cin>>h[i];
	sort(h.begin(),h.end(),greater<long long>());
	long long sum = accumulate(h.begin()+k,h.end(),1LL*0);
	cout << sum;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define ll long long int
#define mp make_pair
#define ld long double
#define MAX 100007
#define pb push_back
#define MOD 1000000007
using namespace std;

int main()
{
    ll n;
    cin>>n;
    ll a[n+7];
    ll i,flag=0,ans=0,mm=1e10,num=0;
    for(i=1;i<=n;i++)
    {
        cin>>a[i];
        if(a[i]<0)
        {
            num++;
            flag=1;
        }
        ans+=abs(a[i]);
        if(abs(a[i])<mm)
            mm=abs(a[i]);
    }
    if(flag==0||num%2==0)
    {
        cout<<ans;
    }
    else
    {
        cout<<ans-2*mm;
    }
    return 0;
}

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

int main() {
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    for (auto &e: a) cin >> e;
    
    int sum = accumulate(a.begin(), a.end(), 0);
    vector<int> divs;
    for (int i = 1; i*i <= sum; i++) {
        if (sum % i == 0) divs.push_back(i);
    }
    
    for (int i = divs.size()-1; i>=0; --i) {
        if (divs[i] != sum/divs[i]) {
            divs.push_back(sum/divs[i]);
        }
    }
    
    reverse(divs.begin(), divs.end());
    vector<int> mod(n);
    for (auto div: divs) {
        for (int i=0; i<n; i++) {
            mod[i] = a[i] % div;
        }
        sort(mod.begin(), mod.end());
        int ms = accumulate(mod.begin(), mod.end(), 0);
        int c = ms / div;
        int t = ms - accumulate(mod.rbegin(), mod.rbegin()+c, 0);
        if (t <= k) {
            cout << div << endl;
            return 0;
         }
    }

        
    return 0;
}


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

int main(){
	int n,m,d,r=0;
	cin>>n>>m>>d;
	vector<string>v(n);
	for(int i=0;i<n;i++)cin>>v[i];
	for(int i=0;i<n;i++)for(int j=0;j<m;j++){
		if(i+d<=n){
			int e=0;
			for(;e<d;e++)if(v[i+e][j]=='#')break;
			if(e==d)r++;
		}
		if(j+d<=m){
			int e=0;
			for(;e<d;e++)if(v[i][j+e]=='#')break;
			if(e==d)r++;
		}
	}
	printf("%d\n",r);
	return 0;
}

Measured memory_bytes: 3260
#include<stdio.h>
#include<math.h>
#include<stdlib.h>

int two_times(int n){
    int counter = 0,val = n;
    while(val%2 == 0){
        counter++;
        val = val/2;
    }
    return counter;
}


int main(void){
    int val,N,i,counter = 0;
    scanf("%d",&N);
    for(i=0;i<N;i++){
        scanf("%d",&val);
        counter += two_times(val);
    }
    printf("%d\n",counter);

    return 0;
}

Measured memory_bytes: 128
use proconio::input;

fn main() {
    input! {
        mut a: usize,
        mut b: usize,
        mut c: usize,
        mut k: usize,
    }
    while a >= b && k > 0 {
        b *= 2;
        k -= 1;
    }
    while b >= c && k > 0 {
        c *= 2;
        k -= 1;
    }

    println!("{}", if a < b && b < c { "Yes" } else { "No" });
}


Measured memory_bytes: 2160
#include<bits/stdc++.h>
using namespace std;
#define MAX_N 111111
typedef long long int ll;
int N,K;
ll A[MAX_N];
ll sump[MAX_N];
ll sum[MAX_N];
int main()
{
	scanf("%d%d",&N,&K);
	for(int i=1;i<=N;i++){
		scanf("%lld",&A[i]);
	}
	for(int i=1;i<=N;i++){
		if(A[i]>0){
			sump[i]=sump[i-1]+A[i];
		}
		else{
			sump[i]=sump[i-1];
		}
		sum[i]=sum[i-1]+A[i];
		//printf("%d :%lld %lld\n",i,sum[i],sump[i]);
	}
	ll ans=0;
	for(int i=0;i<=N-K;i++){
		ll cou=sum[i+K]-sum[i];
		cou=max((ll)0,cou);
		cou+=sump[i]-sump[0];
		cou+=sump[N]-sump[i+K];
		ans=max(ans,cou);
	}
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 2560
alpha = {'a':'b','b':'c','c':'d','d':'e','e':'f','f':'g','g':'h','h':'i','i':'j','j':'k','k':'l','l':'n','n':'m','m':'o','o':'p','p':'q','q':'r','r':'s','s':'t','t':'u','u':'v','v':'w','w':'x','x':'y','y':'z'}
char = input()
print(alpha[char])



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

int main() {
	int l = 0, n, t, a;
	cin >> n >> t >> a;
	vector<int> h(n);
	for (int i = 0; i < n; i++) {
		cin >> h[i];
		if (abs(t - h[l] * 0.006 - a) > abs(t - h[i] * 0.006 - a))
			l = i;
	}
	cout << (l + 1) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm> // swap, sort, min, max,
#include <vector>
#include <utility> // pair<int, int>(x, y)
#define FOR(i, a, b) for(int i=(a); i<b; i++)
using namespace std;
typedef unsigned long ul;
typedef long long int ll;

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

  string s;
  cin >> s;
  int n = s.size();

  int num = 0, last = 0, max_num = 0;

  FOR(i, 0, n){
    if(s[i]=='A' || s[i]=='T' || s[i]=='G' || s[i]=='C'){
      last=i; num++;
    }else if(last==i-1){
      max_num = max(max_num, num);
      num=0;
    }
  }
  max_num = max(max_num, num);
  cout << max_num ;

  return 0;
}


Measured memory_bytes: 256
str = gets.chomp
n = gets.to_i

n.times do
  command = gets.chomp.split
  a, b = command[1].to_i, command[2].to_i

  case command[0]
  when 'print'
    puts str[a..b]
  when 'reverse'
    str[a..b] = str[a..b].reverse
  when 'replace'
    str[a..b] = command[3]
  end
end

Measured memory_bytes: 8724
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>
using namespace std;

int main() {
    long N;cin>>N;
    long ans = 0;
    for (long m = 1; m*m < N; m++) {
        if ((N-m)/m <= m)
            break;
        if ((N-m)%m == 0)
            ans += (N-m)/m;
    }
    cout << ans << endl;
    
    return 0;
}



Measured memory_bytes: 888
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ll n;
    cin>>n;

    set<ll>s;
    //s.insert(n);
    while(s.count(n)==0)
    {
        s.insert(n);
        if(n&1)
        {
           n=3*n+1;
        }
        else{
            n=n/2;
        }
    }
    cout<<s.size()+1<<endl;
}



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

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

  int A, B, C, X, Y; cin >> A >> B >> C >> X >> Y;
  if (A > B) {
    swap(A, B);
    swap(X, Y);
  }
  int ans = 0;
  if (A + B >= C * 2) {
    int z = min(X, Y);
    ans += C * 2 * z;
    X -= z;
    Y -= z;
  }
  if (B < C * 2) 
    ans += A * X + B * Y;
  else if (A < C * 2)
    ans += C * 2 * Y + A * max(0, X - Y);
  else
    ans += C * 2 * max(X, Y);
  cout << ans << "\n";
}

Measured memory_bytes: 256
use proconio::{fastout, input};
use std::collections::BTreeMap;

#[fastout]
fn main() {
    input! {
        n: usize,
        k: i64,
        q: usize,
        a: [i64; q]
    };

    let a: Vec<i64> = a.iter().map(|x| x - 1).collect();
    let mut map = BTreeMap::new();

    for i in a.iter() {
        let count = map.entry(i.to_string()).or_insert(0);
        *count += 1;
    }

    for i in 0..n {
        let x = map.get(&i.to_string());
        match x {
            Some(value) => {
                if k - (q as i64 - value) > 0 {
                    println!("Yes")
                } else {
                    println!("No")
                }
            }
            _ => {
                if k - q as i64 > 0 {
                    println!("Yes")
                } else {
                    println!("No")
                }
            }
        }
    }
}


Measured memory_bytes: 9292