akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
int lcs(vector<vector<int>> &l, vector<vector<int>> &state, string &s, string &t, int m, int n){
    if(m < 0 || n < 0){
        return 0;
    }
    if(state[m][n] != -1){
        return l[m][n];
    }
    if(s[m] == t[n]){
        state[m][n] = 0;
        return l[m][n] = 1 + lcs(l, state, s, t, m-1, n-1);
    }
    else{
        if(lcs(l, state, s, t, m-1, n) > lcs(l, state, s, t, m, n-1)){
            state[m][n] = 1;
            return l[m][n] = lcs(l, state, s, t, m-1, n);
        }
        else{
            state[m][n] = 2;
            return l[m][n] = lcs(l, state, s, t, m, n-1);
        }
    }
}

string print(vector<vector<int>> &state, string &s, int i, int j){
    if(i < 0 || j < 0){
        return "";
    }
    if(state[i][j] == 0){
        string temp = print(state, s, i-1, j-1);
        temp.push_back(s[i]);
        return temp;
    }
    else if(state[i][j] == 1){
        return print(state, s, i-1, j);
    }
    return print(state, s, i, j-1);
}

int main(){
    string s, t;
    cin>>s>>t;
    vector<vector<int>> state(s.size(), vector<int> (t.size(), -1)), l(s.size(), vector<int> (t.size(), -1));
    int anslen = lcs(l, state, s, t, s.size() -1 , t.size() -1);
    cout<<print(state, s, s.size()-1, t.size()-1);
    return 0;
}


Measured memory_bytes: 74188
import java.util.*;
import java.lang.*;
import java.math.*;

public class Main {
	Scanner sc = new Scanner(System.in);

	class br implements Comparable<br> {
		int a;
		int b;
		int c;

		br(int a, int b, int c) {
			this.a = a;
			this.b = b;
			this.c = c;
		}

		public int compareTo(br t) {
			return this.c - t.c;
		}
	}

	void run() {
		for (;;) {
			int n = sc.nextInt();
			int m = sc.nextInt();

			if ((n | m) == 0) {
				break;
			}

//			int[][] map = new int[n][n];

			for (int i = 0; i < n; i++) {
//				Arrays.fill(map[i], 12345);
			}
			PriorityQueue<br> l = new PriorityQueue<br>();
			// LinkedList<br> l = new LinkedList<br>();

			for (int i = 0; i < m; i++) {
				int a = sc.nextInt();
				int b = sc.nextInt();
				int c = sc.nextInt();
				l.add(new br(a, b, c));
			}
			int count = n - 1;
			int ans = 0;

			int p[] = new int[n];
			for (int i = 0; i < n; i++) {
				p[i] = i;
			}
			for (;;) {
				if (count == 0) {
					break;
				}

				br s = l.poll();

				int a = s.a;

				int pa = p[a];
				while (p[pa] != pa) {
					int z = pa;
					pa = p[pa];
					p[z] = pa;
				}
				int b = s.b;
				int pb = p[b];
				while (p[pb] != pb) {
					int z = pb;
					pb = p[pb];
					p[z] = pb;
				}

				if (pb == pa) {
					continue;
				} else {
					p[pa] = pb;
					count--;
					ans += s.c;
				}

			}
			System.out.println(ans);
		}

	}

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

Measured memory_bytes: 12000
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
#include <queue>
#include <set>
#include <iomanip>
#include <sstream>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int MOD = 1000000007;
const int iINF = 1001001001;
const long long llINF = 1LL << 60;
int main()
{
	int n, m, k;
	cin >> n >> m >> k;
	bool ok = false;
	int cur = 0;
	rep(i, n + 1) {
		cur = i*m;
		rep(j, m + 1) {
			if (j != 0) {
				cur += n;
				cur -= 2 * i;
			}
			if (cur == k) {
				ok = true;
				break;
			}
		}
		if (ok) break;
	}
	if (ok) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 3600
#include <iostream>

using namespace std;

int main (void){
	int i;
	double a,b,c;

	cin>>i;
	while(i){
		cin>>a>>b>>c;

		if(a*a+b*b==c*c||a*a+c*c==b*b||b*b+c*c==a*a){
			cout<<"YES"<<endl;
		}
		else{
			cout<<"NO"<<endl;
		}
		i--;
		
	}
}

Measured memory_bytes: 1224
#include <cstdio>
#include <cstdlib>
#include <string>
#include <iostream>
using namespace std;

struct Node {
	int key;
	Node *right, *left, *parent;
};

Node *root, *NIL;

void insert(int k) {
	Node *y = NIL;
	Node *x = root;
	Node *z;
	
	z = (Node *)malloc(sizeof(Node));
	z->key   = k;
	z->left  = NIL;
	z->right = NIL;
	
	while(x != NIL) {
		y = x;
		if(z->key < x->key) {
			x = x->left;
		} else {
			x = x->right;
		}
	}
	
	z->parent = y;
	if(y == NIL) {
		root = z;
	} else {
		if( z->key < y->key) {
			y->left = z;
		} else {
			y->right = z;
		}
	}
}

void inorder(Node *u) {
	if(u == NIL) return;
	inorder(u->left);
	printf(" %d",u->key);
	inorder(u->right);
}
void preorder(Node *u) {
	if(u == NIL) return;
	printf(" %d",u->key);
	preorder(u->left);
	preorder(u->right);
}
	
int main(void) {
	int n, i, x;
	string com;
	scanf("%d",&n);
	
	for(i=0;i<n;i++) {
		cin >> com;
		if(com == "insert") {
			scanf("%d",&x);
			insert(x);
		} else if(com == "print") {
			inorder(root);
			printf("\n");
			preorder(root);
			printf("\n");
		}
	}

	return 0;
}


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

int main(){
  int N,M;
  cin >> N >> M;
  vector<pair<int,int>> ab(M);
  for(int i=0; i<M; i++){
    cin >> ab.at(i).first >> ab.at(i).second;
  }
  sort(ab.begin(),ab.end());
  int count=0;
  while(ab.size()>0){
    vector<int> a;
    for(int i=0; i<ab.size(); i++){
      if(ab.at(i).second>ab.back().first){
        a.push_back(i);
      }
    }
    for(int i=0; i<a.size(); i++){
      ab.erase(ab.begin()+a.at(i)-i);
    }
    count++;
  }
  cout << count << endl;
}

Measured memory_bytes: 1408
k = gets.to_i

if k % 2 == 0 or k % 5 == 0
  puts -1
  exit
end

if k % 7 == 0
  k /= 7
end

x = 1 % k
cnt = 1
while x != 0
  x = (x * 10 + 1) % k
  cnt += 1
end

p cnt

Measured memory_bytes: 14336
#include<stdio.h>
int main()
{
    char ch;
    scanf("%c",&ch);
    if(ch=='a'||ch=='e'||ch=='i'||ch=='o'||ch=='u')
    {
        printf("vowel\n");
    }
    else
    {
        printf("consonant\n");
    }
return 0;
}


Measured memory_bytes: 128
n = int(input())
a_li = list(map(int,input().split()))
b_li = list(map(int,input().split()))

cnt = 0
for i in range(n):
    if b_li[i] >= a_li[i]:
        cnt += a_li[i]
        b_li[i] -= a_li[i]
    else :
        cnt += b_li[i]
        b_li[i] = 0
        continue
    
    if b_li[i] >= a_li[i + 1]:
        cnt += a_li[i + 1]
        a_li[i + 1] = 0
    else :
        cnt += b_li[i]
        a_li[i + 1] -= b_li[i]
print(cnt)


Measured memory_bytes: 19156
#include <vector>
#include <iostream>
#include <algorithm>
#include <cmath>

using namespace std;

int main(){
    int a, b, c,d;
    cin >> a >> b >> c >> d;

    int turn = 0;
    while(a * c >0){
        if(turn==0){
            c -= b;
            turn = 1;
        }
        else{
            a -= d;
            turn = 0;
        }
    }

    cout << (turn == 1 ? "Yes" : "No") << endl;

    return 0;
}

Measured memory_bytes: 3624
#include<iostream>
#include<string>

using namespace std;

class Dice{
  public:
    int a[6], tmp, i;

    Dice(int input[6]){
      for (i = 0; i < 6; i++) {
        a[i] = input[i];
      }
    }

    void e() {
      tmp = a[2]; a[2] = a[0]; a[0] = a[3]; a[3] = a[5]; a[5] = tmp;
    }

    void n() {
      tmp = a[0]; a[0] = a[1]; a[1] = a[5]; a[5] = a[4]; a[4] = tmp;
    }

    void w() {
      tmp = a[0]; a[0] = a[2]; a[2] = a[5]; a[5] = a[3]; a[3] = tmp;
    }

    void s() {
      tmp = a[0]; a[0] = a[4]; a[4] = a[5]; a[5] = a[1]; a[1] = tmp;
    }
    void rightNum(int u, int f) {
      int count = 0;
      while(!(a[0] == u && a[1] == f)) {
        int random = count % 4;
        if (random == 0) e();
        else if (random == 1) n();
        else if (random == 2) w();
        else if (random == 3) s();
        if (count % 16 == 0) {
          n();
          n();
        }
        count++;
      }
      cout << a[2] << endl;
    }
};


int main(void)
{
  int i, in[6], q, up, front;
  for (i = 0; i < 6; i++) cin >>in[i];
  cin >> q;
  Dice d(in);
  for (i = 0; i < q; i++) {
    cin >> up >> front;
    d.rightNum(up, front);
  }
  return 0;
}

Measured memory_bytes: 1160
sum=0
s=0
A=input().split()
n=(int)(A[0])
m=(int)(A[1])
x=[0 for i in range(2*n)]
for i in range(n):
    B=input().split()
    k=2*i
    x[k]=(B[0])
    x[k+1]=(int)(B[1])
while len(x)>0:
    s=x[1]-m
    if s>0:
        sum+=m
        x.append(x[0])
        x.append(s)
        del x[0]
        del x[0]
    if s<=0:
        sum+=x[1]
        print( x[0],sum)
        del x[0]
        del x[0]


Measured memory_bytes: 9456
#include <bits/stdc++.h>
#define all(a) (a).begin(),(a).end()
#define rep(i,n) for(ll i=0,i##_len=(n);i<i##_len;i++)
#define rep2(i,a,b) for(ll i=(a),i##_len=(b);i<=i##_len;i++)
#define rrep(i,n) ll i=(n);ll now=-1;while(i--&&(now++||1))
#define Yes(n) cout<<((n)?Yes:No)<<"\n"
#define vll vector<ll>
#define pb push_back

using namespace std;
using ll = long long;

static inline void ignore_ret(int x) {x++;}
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(a>b){a=b;return true;}return false;}
template<class T> T gcd_vec(vector<T>v){T r=v.at(0);for(T i=1;i<v.size();i++)r=gcd(r,v.at(i));return r;}
template<class T> T lcm_vec(vector<T>v){T r=v.at(0);for(T i=1;i<v.size();i++)r=lcm(r,v.at(i));return r;}
template<class T> T factorial(T n){if(n==0)return 1;T r=1;for(T i=2;i<=n;i++)r*=i;return r;}
template<class T> T nCr(T n,T k){return factorial<T>(n)/(factorial<T>(k)*factorial<T>(n-k));}
template<class T> T dot_product(vector<T>u,vector<T>v){T r=0;for(T i=0;i<u.size();i++)r+=u.at(i)*v.at(i);return r;}
template<class T> T sum(vector<T>v){return reduce(all(v),0LL);}

// Template ends here

void solve(ll A, ll B){
    ll cnt = 0;

    rep2(i, A, B) {
        string S = to_string(i);
        bool flag = true;
        rep(j, S.size() / 2) {
            if (S.at(j) == S.at(int(S.size()) - j - 1)) continue;
            else {
                flag = false;
                break;
            }
        }
        cnt += flag;
    }

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

int main() {
    ll A;
    ignore_ret(scanf("%lld",&A));
    ll B;
    ignore_ret(scanf("%lld",&B));
    solve(A, B);
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int sc1 = sc.nextInt();
		int[] ary = new int[sc1];
		for(int i = 0; i < ary.length; i++) {
			ary[i] = sc.nextInt();
		}
		Numbers n = new Numbers(ary);
		n.disp();
	}
}
class Numbers{
	int numbers[];
	boolean isMinusOdd;
	int minIdx;
	Numbers(int[] ary){
		numbers = ary;
		isMinusOdd = false;
		for(int i = 0; i < numbers.length; i++) {
			if(numbers[i] < 0) {
				isMinusOdd = !isMinusOdd;
			}
			if(Math.abs(numbers[minIdx]) > Math.abs(numbers[i])) {
				minIdx = i;
			}
		}
	}
	void disp() {
		long point = 0;
		for(int i = 0; i < numbers.length; i++) {
			point += Math.abs(numbers[i]);
		}
		if(isMinusOdd) {
			point -= 2 * Math.abs(numbers[minIdx]);
		}
		System.out.println(point);
	}
}


Measured memory_bytes: 51256
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <unordered_map>
using namespace std;

#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v.begin(), v.end())
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)

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; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }

int N;
vector<int> a;

int main() {
    while (cin >> N) {
        a.resize(N);
        for (int i = 0; i < N; ++i) cin >> a[i];
        int over = 0;
        set<int> se;
        for (int i = 0; i < N; ++i) {
            int rate = a[i] / 400;
            if (rate >= 8) ++over;
            else se.insert(rate);
        }
        
        // COUT(se); COUT(over);
        
        int Min, Max;
        if (se.size() == 0) Min = 1;
        else Min = (int)se.size();
        
        Max = (int)se.size() + over;
        
        cout << Min << " " << Max << endl;
        
  }
}











Measured memory_bytes: 256
function main(input) {
  var N = input[0].split(" ").map(v=>v-0);
  var ans = "Yes";
  console.log(N[0]%2==0||N[1]%2==0?"No":"Yes");
}
main(require('fs').readFileSync('/dev/stdin', 'utf8').trim().split("\n"))


Measured memory_bytes: 7372
#!/usr/bin/env python3
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys
import collections
from decimal import Decimal # 10進数で考慮できる

mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000

d = collections.deque()
def LI(): return list(map(int, sys.stdin.readline().split()))

x, a, b = LI()

if abs(x - a) < abs(x -b):
    print("A")
else:
    print("B")

Measured memory_bytes: 10852
''' Hey stalker :) '''
INF = 10**10
def main():
    print = out.append
    ''' Cook your dish here! '''
    n, k = get_list()
    li = get_list()
    ans = sum(li[:k])
    sm = ans
    for i in range(n-k+1):
        ans = max(ans, sm)
        if i<n-k:
            sm += li[i + k] - li[i]
    print((ans+k)/2)



''' Pythonista fLite 1.1 '''
import sys
from collections import defaultdict, Counter
from bisect import bisect_left, bisect_right
#from functools import reduce
import math
input = iter(sys.stdin.buffer.read().decode().splitlines()).__next__
out = []
get_int = lambda: int(input())
get_list = lambda: list(map(int, input().split()))
main()
#[main() for _ in range(int(input()))]
print(*out, sep='\n')


Measured memory_bytes: 77852
#include<iostream>
#include<cmath>
#include <iomanip>
#include<string>
#include<algorithm>
#include<vector>

using namespace std;

string s, t;

bool res=true;

int main() {

	cin >> s >> t;

	for (int i = 0; i < s.size(); i++) {
		if (s[i] != t[i])res = false;
	}

	if (res)cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}

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

int main() {
    int N, temp;
    std::cin >> N;
    
    std::vector<int> a(8);
    int any = 0;
    for (auto i=0; i<N; ++i) {
        std::cin >> temp;
        if (temp >= 3200) {
            ++any;
        } else {
            temp /= 400;
            a[temp]++;
        }
    }
    
    int color = 0;
    for (auto elem : a) {
        if (elem != 0) ++color;
    }
    
    int min = 0;
    if (any > 0 && color == 0) {
        min = 1;
    }
    
    std::cout << (color + min) << " " << (color + any) << std::endl;
    
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
 
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        
        int n = sc.nextInt();
        String[] str = new String[n];
        int[] count = new int[n];
        String[] ans = new String[n];
        int max = 0;
        
        for(int i=0; i<n; i++){
            str[i] = sc.next();
            count[i]=0;
        }
        
        Arrays.sort(str);
        
        for(int i=0; i<n-1; i++){
        	for(int j=i+1; j<n; j++){
            	if(str[i].equals(str[j])){
                	count[i]++;
                }else{
                	break;
                }
            }
            max = Math.max(max, count[i]);
            i += count[i];
        }
        
        for(int i=0; i<n; i++){
        	if(max==count[i]){
            	System.out.println(str[i]);
            }
        }
   }
}


Measured memory_bytes: 73340
N = int(input())

def isOk(k):
    n = N
    while n % k == 0:
        n //= k
    return n % k == 1

# 約数の全列挙
def divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    # divisors.sort(reverse=True)  # ソート
    return divisors

divN = divisors(N)
divN1 = divisors(N - 1)

ans = len([0 for d in divN if d > 1 and isOk(d)]) + len([0 for d in divN1 if d > 1 and isOk(d)])

print(ans)


Measured memory_bytes: 3188
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;

namespace JKTX_AOJ2015
{
    class Program
    {
        static void Main(string[] args)
        {
            int n;
            List<int> data = new List<int>();

            n = int.Parse(Console.ReadLine());
            string[] str = Console.ReadLine().Split(' ');

            foreach(var item in str){
                data.Add(int.Parse(item));
            }

            data.Reverse();

            foreach (var item in data.Select((v, i) => new { v, i }))
            {
                Console.Write(item.v);
                /*
                 * foreach???????????????n???????????§?????£?????????
                 */

                if (item.i == n - 1)
                {
                    Console.Write("\n");
                }
                else
                {
                    Console.Write(" ");
                }
            }
        }
    }
}

Measured memory_bytes: 12060
#include<bits/stdc++.h>
using namespace std;
struct shop{
  int gram,tanka,tekiyou,tanni;
};
int main(){
  int n;
  int nedan[10000]={};
  for(int i=0;i<10000;i++)
    nedan[i]=1000000000;
  struct shop a[3];
  a[0].gram=200;a[0].tanka=380;a[0].tekiyou=1520;a[0].tanni=1000;
  a[1].gram=300;a[1].tanka=550;a[1].tekiyou=1870;a[1].tanni=1200;
  a[2].gram=500;a[2].tanka=850;a[2].tekiyou=2244;a[2].tanni=1500;
  queue<pair<int,int> >nn;
  for(int i=0;i<3;i++){
    nn.push(make_pair(a[i].gram,a[i].tanka));nn.push(make_pair(a[i].tanni,a[i].tekiyou));
  }
  nedan[200]=380;nedan[300]=550;nedan[500]=850;nedan[1000]=1520;
  nedan[1200]=1870;nedan[1500]=2244;
  while(!nn.empty()){
    pair<int,int>now=nn.front();
    nn.pop();
    if(now.first>5000)
      continue;
    for(int i=0;i<3;i++){
      if(now.first+a[i].gram<=5000){
	if(nedan[now.first+a[i].gram]>nedan[now.first]+a[i].tanka){
	  nedan[now.first+a[i].gram]=nedan[now.first]+a[i].tanka;
	  nn.push(make_pair(now.first+a[i].gram,nedan[now.first+a[i].gram]));
	}
      }
      if(now.first+a[i].tanni<=5000){
	if(nedan[now.first+a[i].tanni]>nedan[now.first]+a[i].tekiyou){
	  nedan[now.first+a[i].tanni]=nedan[now.first]+a[i].tekiyou;
	  nn.push(make_pair(now.first+a[i].tanni,nedan[now.first+a[i].tanni]));
	}
      }
    }
  }
  while(cin>>n,n!=0)
    cout<<nedan[n]<<endl;
  return 0;
}

Measured memory_bytes: 3020
#include<bits/stdc++.h>
#define ford(i,a,b) for(int i=(a);i>=b;i--)
#define rep1(i,a,b) for(int i=(a);(i)<=(b);(i)++)
#define rep(i,a,b) for(int i=(a);(i)<(b);(i)++)
#define ll long long
#define mpi map<int,int>
#define N 200005
#define pql priority_queue<ll>
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
using namespace std;
int main() {
	char s;
	cin>>s;
	if(s=='A')cout<<'T';
	if(s=='T')cout<<'A';
	if(s=='G')cout<<'C';
	if(s=='C')cout<<'G';
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <numeric>
#include <tuple>
#include <stack>

#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define print(s) cout << s << endl
typedef long long ll;
using namespace std;

int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

int main() {
	string s; cin >> s;
	cout << s[0] << s.size()-2 << s[s.size()-1] << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#ifdef LOCAL
#include "lib/debug.hpp"
#else
#define debug(...) 1
#endif
#define ALL(a) (a).begin(), (a).end()
#define rep(i, n) REP(i, 0, (n))
#define repc(i, n) REPC(i, 0, (n))
#define REP(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define REPC(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define REPCM(i, n, m) for (int i = (int)(n); i >= (int)(m); i--)
using namespace std;
using ll = int_fast64_t;
using pr = pair<ll, ll>;
using vll = vector<ll>;
using vpr = vector<pr>;
template<class T> inline bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } else return false; }
template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } else return false; }

void answer() {
  char a;
  cin >> a;
  if('a' <= a && a <= 'z') cout << "a\n";
  else cout << "A\n";
}
int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  answer();
  return 0;
}

Measured memory_bytes: 3648
import java.util.*;

public class Main {

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

    void run() {
        Scanner sc = new Scanner(System.in);
        long L = sc.nextLong();
        long[][] g = new long[20][20];
        boolean[][] zero = new boolean[20][20];
        long tmp = -1;
        for(int i = 0; i < 20; ++i)
            for(int j = 0; j < 20; ++j)
                g[i][j] = -1;
        int s = 0;
        int t = 0;
        int N = 1;
        int M = 0;

        for(int i = 20; i >= 0; --i){
            if((1L << (i + 1)) > L) continue;
            for(int j = 0; j < 20; ++j)
                for(int k = 0; k < 20; ++k)
                    g[j][k] *= 2;
            tmp *= 2;
            g[t][t+1] = 1;
            zero[t][t+1] = true;
            ++t;
            ++N;
            M += 2;
            if( ((L & (1L << i))) > 0 ){
                if(g[s][t] > 0)
                    if(!(s == 0 && t == 1)) throw new AssertionError();
                    else{ tmp = (L >> i) - 1; }
                else g[s][t] = (L >> i) - 1;
                ++M;
            }
        }



        System.out.println(N + " " + M);
        for(int i = 0; i < N; ++i){
            for(int j = 0; j < N; ++j){
                if(g[i][j] > 0)
                    System.out.println((i + 1) + " " + (j + 1) + " " + g[i][j]);
                if(zero[i][j])
                    System.out.println((i + 1) + " " + (j + 1) + " " + 0);
            }
        }
        if(tmp > 0)
            System.out.println( 1 + " " + 2 + " " + tmp);
    }

    void tr(Object...objects){
        System.out.println(Arrays.deepToString(objects));
    }
}

Measured memory_bytes: 22100
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int max_n=1000005;
char s[max_n];
int n,a[max_n];
int solve(){
    int res=0;
    for(int i=0;i<n;i++)if((i&(n-1))==i)res+=a[i];
    return res&1;
}
int main(){
    scanf("%d %s",&n,s);
    for(int i=0;i<n;i++)a[i]=s[i]-'1';
    if(solve())printf("1\n");
    else{
        bool f=false;
        for(int i=0;i<n;i++)f|=a[i]==1;
        if(f)printf("0\n");
        else{
            for(int i=0;i<n;i++)a[i]/=2;
            if(solve())printf("2\n");
            else printf("0\n");
        }
    }
    return 0;
}

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

/* macro */
#define rep(i,a,b) for(int i=a;i<b;i++)
#define revrep(i,a,b) for(int i = a; i > b; i--)
#define int long long
#define exist(s,e) ((s).find(e)!=(s).end())
#define all(v) (v).begin(), (v).end()
#define each(s,itr) for(auto (itr) = s.begin(); (itr) != s.end(); (itr)++)
#define sum(v) accumulate(all(v), (0LL))
#define isin(a, b, c) (b <= a && a <= c)
#define println cout << "\n";
#define sz(v) (int)v.size()


/* alias */
template<class T> using vec = vector<T>;
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef tuple<int, int, int> ti;
typedef map<int, int> mi;
typedef set<int> si;


/* constant */
const int inf = 1LL << 62;
const int mod = 1e9 + 7;
const int dx[8]={1,0,-1,0,-1,1,-1,1};
const int dy[8]={0,1,0,-1,-1,-1,1,1};
const string alphabet = "abcdefghijklmnopqrstuvwxyz";

/* io_method */
int input(){int tmp;cin >> tmp;return tmp;}
string raw_input(){string tmp;cin >> tmp;return tmp;}
template<class T> void printx(T n){cout << n;}
template<class T, class U> void printx(pair<T, U> p){cout << "(" << p.first << "," << p.second << ")";}
template<class T, class U, class V> void printx(tuple<T, U, V> t){cout << "{" << get<0>(t) << "," << get<1>(t) <<"," << get<2>(t) << "}" << endl;}
template<class T> void printx(vector<T> v){cout << "{";rep(i,0,v.size()){printx(v[i]);if(i != v.size()-1)printx(",");}cout << "}";}
template<class T> void print(T n){printx(n);cout << endl;}
template<class T> void print(set<T> s){cout << "{";each(s, e){if(e != s.begin()) printx(",");printx(*e);}cout << "}" << endl;}
template<class T, class U> void print(map<T, U> mp){cout << "{";each(mp, e){cout << "(" << e -> first << "," << e -> second << ")";}cout << "}" << endl;}
template<class T> void printans(vec<T> v){rep(i,0,sz(v)){cout << v[i] << (i == sz(v) - 1 ? "" : " ");}cout << endl;}


/* general_method */
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<class T>T cut(T &a, int l, int r){return T(a.begin()+l, a.begin()+r);}

/* main */

int a, b, c;
void in(){
    cin >> a >> b >> c;
}

void solve(){

    print(min(c, b / a));


}

signed main(){

    cin.tie(0);
    ios::sync_with_stdio(false);
    in();
    solve();
    
}

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

int main() {
    int N,al=0,bb=0;
    cin >> N;
    vector<int> a(N);
    rep(i,N)
        cin >> a.at(i);
    sort(a.begin(), a.end(), greater<int>());

    rep(i,N)
        if(i%2)
            bb += a.at(i);
        else
            al += a.at(i);
    
    cout << al-bb << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>

using namespace std;

int main(void) {
    int X, Y;
    cin >> X >> Y;

    for(int i=0; i<500; i++) {
        for(int j=0; j<500; j++) {
            if(i+j == X && 2*i+4*j == Y) {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }

    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 3636
import itertools


N = int(input())

P = [list(map(int,input().split())) for i in range(N)]

S = 0


route = list(itertools.combinations(P, 2))

for i in route:
   
   S += ((i[0][0] - i[1][0])**2 + (i[0][1] - i[1][1])**2)**0.5
   
print(S*2/N)

Measured memory_bytes: 3064
import std.stdio;
void main() {
	float a,b,c,d,e,f;
	while ("%f %f %f %f %f %f\n".readf(&a,&b,&c,&d,&e,&f)) {
		float y = (c*d-a*f)/(b*d-a*e);
		float x = (c-b*y)/a;
		"%.3f %.3f".writefln(x, y);
	}
}

Measured memory_bytes: 2524
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
int PREP = (cin.tie(nullptr), ios::sync_with_stdio(false), cout << fixed << setprecision(9), 0);
//int SEGV = getenv("D") || (exit(system("D= SEGFAULT_SIGNALS=all catchsegv ./prog.exe") >> 8), 0);
int main() {
    Int N; cin >> N;
    Int ans = 0;
    for (int i = 1; i <= N; i++) {
        if (i % 3 != 0 && i % 5 != 0) ans += i;
    }
    cout << ans << '\n';
    return 0;
}


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

int main()
{
  int n;
  cin >> n;
  int max_profit = -2000000000, min_r = 2000000000;
  for (int i = 0; i < n; i++)
  {
    int r;
    cin >> r;
    max_profit = max(max_profit, r - min_r);
    min_r = min(min_r, r);
  }
  cout << max_profit << endl;
}


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

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] a = new int[N];
        for(int n=0;n<N;n++) a[n]=sc.nextInt();
        int magic=0;
        for(int i=1;i<N;i++){
        	if(a[i]==a[i-1]){
        	    magic++;
        	    a[i]=5000+i;
        	}
        }
        System.out.println(magic);
    }
}

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

using namespace std;

#define INF 1000007
#define MOD 1000000007 
#define maxn 100
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) FOR(i, 0, n)

typedef std::pair<int, int> P;

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

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

int mpow(int N, int P, int M) //繰り返し自乗法
{
    if (P == 0)
        return 1;
    if (P % 2 == 0) {
        int t = mpow(N, P / 2, M);
        return t * t % M;
    }
    return N * mpow(N, P - 1, M) % M;
}

int counter(int x) //bit計算
{
    if (x == 0)
        return 0;
    return counter(x >> 1) + (x & 1);
}

vector<bool> prime(maxn + 1, true); //素数テーブル
void prime_table(void) {
    prime[0] = false;
    prime[1] = false;
    for (int i = 2; i * i <= maxn; i++) {
        if (!prime[i]) {
            continue;
        }
        for (int j = i + i; j <= maxn; j += j + i) {
            prime[j] = false;
        }
    }
}

bool IsPrime(int num) //素数判定
{
    if (num < 2)
        return false;
    else if (num == 2)
        return true;
    else if (num % 2 == 0)
        return false;

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2) {
        if (num % i == 0) {
            return false;
        }
    }

    return true;
}

vector<int> divisor(int n) //約数列挙
{
    vector<int> ret;
    for (int i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ret.push_back(i - 1);
            if (i * i != n) {
                ret.push_back((n / i) - 1);
            }
        }
    }
    sort(ret.begin(), ret.end());
    return (ret);
}
int a,b;
void f(int x){
    a = x%10;
    b = 0;
    while(x){
        b = x;
        x /= 10;
    }
}
signed main() {
    int N;
    cin >> N;
    int count[10][10];
    rep(i, 10) {
        rep(j, 10) {
            count[i][j] = 0;
        }
    }
    int d = 1;
    for (int i = 1; i <= N; i++) {
        f(i);
        int head = b;
        int back = a;
        count[head][back]++;
    }
    int ans = 0;
    for (int i = 1; i <= N; i++) {
        f(i);
        int head = b;
        int back = a;
        /*if ((head == 0 || back == 0) && count[back][head] > 0) {
            cout << head <<" "<<back<<" "<<count[back][head]<<endl;
            cout << i << endl;
        }*/
        if (count[back][head] != 0) {
            ans += count[back][head];
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
from collections import deque


S = deque(input())
Q = int(input())
flag = 1

for _ in range(Q):
    q = input().split()
    if q[0] == "1":
        flag *= -1
    elif q[1] == "1":
        if flag == 1:
            S.appendleft(q[2])
        else:
            S.append(q[2])
    else:
        if flag == 1:
            S.append(q[2])
        else:
            S.appendleft(q[2])
s = list(S)
if flag == 1:
    print("".join(s))
else:
    for i in reversed(s):
        print(i, end="")

Measured memory_bytes: 9712
#include <stdio.h>
#include <iostream>
using namespace std;

int main()
{
    int n;
    string s;
    bool flag = false;
    cin >> n;

    for(int i=0;i<n;i++){
        cin >> s;
        if(s == "Y") flag = true;
    }

    if(flag) cout << "Four" << endl;
    else cout << "Three" << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
typedef unsigned int ui;
int main() {
	int n, q;
	while (cin >> n >> q, n) {
		map<int, pair<string, int>> mp;
		string x; int y, z; vector<int> a;
		for (int i = 0; i < n; i++) {
			cin >> x >> y >> z;
			a.push_back(z);
			mp[z] = make_pair(x, y);
		}
		sort(a.begin(), a.end());
		int b;
		for (int i = 0; i < q; i++) {
			cin >> b;
			int u = lower_bound(a.begin(), a.end(), b) - a.begin();
			if (u == n) {
				cout << "Unknown" << endl; continue;
			}
			int out = mp[a[u]].second - (a[u] - b);
			if (out > 0) {
				cout << mp[a[u]].first << " " << out << endl;
			}
			else cout << "Unknown" << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 3300
#define _GLIBCXX_DEBUG
#pragma GCC diagnostic ignored "-Wsign-compare"
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < int(n); ++i)

int n, k;
vector<int> W;

bool is_ok(int mid) {
    int need = 0, cur_sum = 0;
    for (auto &e : W) {
        if (mid < e) {
            return false;  // トラックに入らない
        }
        if (cur_sum + e <= mid) {
            cur_sum += e;
        } else {
            ++need;
            cur_sum = e;
        }
    }
    ++need;  // mid 以下のトラックが1台必要
    if (need <= k) {
        return true;
    } else {
        return false;
    }
}

int binary_search_meguru() {
    int ng = -1;
    int ok = 1e9 + 1;

    while (abs(ok - ng) > 1) {
        int mid = ng + (ok - ng) / 2;
        if (is_ok(mid))
            ok = mid;
        else
            ng = mid;
    }
    return ok;
}

void Main() {
    cin >> n >> k;
    W.resize(n);
    for (auto &e : W) {
        cin >> e;
    }
    cout << binary_search_meguru() << "\n";
}
int main() {
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
}


Measured memory_bytes: 3280
#include <iostream>
#include <cstdio>
#include <stdio.h>
using namespace std;
int main(){
	int x,y,s,count=0;
	int paper[14][14] = {0};
	while(scanf("%d,%d,%d",&x,&y,&s) != EOF){
		if(s==1 || s==2 || s==3){
			paper[x+2][y+2]++;
			paper[x+1][y+2]++;
			paper[x+3][y+2]++;
			paper[x+2][y+1]++;
			paper[x+2][y+3]++;
		}
		if(s==2 || s==3){
			paper[x+1][y+1]++;
			paper[x+1][y+3]++;
			paper[x+3][y+1]++;
			paper[x+3][y+3]++;
		}
		if(s==3){
			paper[x+4][y+2]++;
			paper[x+2][y+4]++;
			paper[x][y+2]++;
			paper[x+2][y]++;
		}
	}
	int a = 1;
	for(int i=2;i<12;i++){
		for(int j=2;j<12;j++){
			if(paper[i][j] == 0) count++;
			if(a<paper[i][j]) a = paper[i][j];
		}
	}
	cout<<count<<endl;
	cout<<a<<endl;
	return 0;
}

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

int main(){
    using namespace std;
    constexpr unsigned long MOD = 1000000007;
    const auto& modpow = [](unsigned long a, unsigned long n, unsigned long b = 1) -> unsigned long {
        a %= MOD;
        unsigned long r{b % MOD};
        while(n){
            if(n & 1)(r *= a) %= MOD;
            (a *= a) %= MOD;
            n >>= 1;
        }
        return r;
    };
    const auto& modbinom = [&modpow](unsigned long n, unsigned long r) -> unsigned long {
        unsigned long a{1}, b{1};
        for(unsigned long i{0}; i < r; ++i){
            (a *= i + 1) %= MOD;
            (b *= n - i) %= MOD;
        }
        return modpow(a, MOD - 2, b);
    };
    unsigned long n, a, b;
    cin >> n >> a >> b;
    cout << (modpow(2, n) + 2 * MOD - modbinom(n, a) - modbinom(n, b) - 1) % MOD << endl;
    return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#define INF 0x3f3f3f3f
#include <cstdio>
#include <iostream>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>
#include <cctype>
#include <utility>

using namespace std;

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

int tx[] = {0,1,0,-1};
int ty[] = {-1,0,1,0};

static const double EPS = 1e-8;

ll dp[20000][3];

ll nCr(int n,int r){
	return dp[n][r] != -1 ? dp[n][r] : 
		dp[n][r] = (r==0|| n==r) ? 1 : nCr(n-1,r) + nCr(n-1,r-1);
}


int main(){
	int n,S;
	memset(dp,-1,sizeof(dp));

	while(~scanf("%d %d",&n,&S)){
		if(n==0) break;
		vector<int> witch;
		for(int i=0;i<n;i++){
			int m;
			scanf("%d",&m);
			witch.push_back(m);
		}

		sort(witch.begin(),witch.end());

		ll res = 0;
		for(int m1=0;m1<=100;m1++){
			for(int m2=m1;m2<=100;m2++){
				if(m1+m2 <= S) continue;
				int num1 = upper_bound(witch.begin(),witch.end(),m1) - lower_bound(witch.begin(),witch.end(),m1);
				int num2 = upper_bound(witch.begin(),witch.end(),m2) - lower_bound(witch.begin(),witch.end(),m2);

				if(m1==m2 && num1 != 0) res += nCr(num1,2);
				else res += num1 * num2;
			}
		}


		printf("%lld\n",res);
	}
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define per(i,b,a) for(int i=b;i>=a;i--)
#define For(i,a,b) for(int i=a;i<=b;i++)
#define Forenska(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define sqr(x) ((x)*(x))
#define lowbit(x) ((x)&(-x))
#define GREATER(x) x,vector<x>,greater<x>
#define randIn(L,R) (((LL)rand()*rand())%(R-L)+L)
#define __lcm(a,b) ((a)/__gcd(a,b)*(b))
using namespace std;
typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pLL;
typedef vector<int> vec;
typedef vector<LL> vecL;
typedef vector<pii> vecP;
typedef vector<pLL> vecPL;
typedef vector<string> vecS;
typedef vector<vec> mat;
typedef complex<double> point;
const long double PI=3.14159265358979323846264338327950288419716939937510582097;
const LL INFLL=0x3f3f3f3f3f3f3f3f;
const int INF=0x3f3f3f3f;
const long double EPS=1e-10;
int read()
{
    int x=0;
    char ch=' ';
    bool flag=false;
    while(ch<'0' || ch>'9')
    {
        if(ch=='-')flag=true;
        ch=getchar();
    }
    while(ch>='0' && ch<='9')
    {
        x=(x<<3)+(x<<1)+ch-'0';
        ch=getchar();
    }
    return flag?-x:x;
}
#define int LL 
signed main()
{
//	freopen("input.txt","r",stdin);
	int Q;
	cin>>Q;
	while(Q--)
	{
		int a,b;
		cin>>a>>b;
		int t=sqrt(a*b);
		int ans=2*t-2;
		if(t*t+t<a*b)ans++;
		else if(t*t==a*b && a!=b)ans--;
		cout<<ans<<endl;
	}
	return 0;
}



Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<string>
#include<iostream>

using namespace std;

struct Node {
	int key;
	Node *left, *right,*parent;
};

Node *root, *NIL;

void insert(int k){
	Node* y = NIL;
	Node* x = root;
	Node* z;
	z = (Node*)malloc(sizeof(Node));
	z->key = k;
	z->left = NIL;
	z->right = NIL;
	while (x != NIL){
		y = x;
		if (z->key < x->key){
			x = x->left;
		}
		else {
			x = x->right;
		}
	}
	z->parent = y;
	if (y == NIL){
		root = z;
	}
	else{
		if (z->key < y->key){
			y->left = z;
		}
		else{
			y->right = z;
		}
	}
}

void inorder(Node* u){
	if (u == NIL)return;
	inorder(u->left);
	printf(" %d", u->key);
	inorder(u->right);
}

void preorder(Node* u){
	if (u == NIL)return;
	printf(" %d", u->key);
	preorder(u->left);
	preorder(u->right);
}
int main(){
	int n, i, x;
	string com;
	scanf("%d", &n);
	for (i = 0; i < n; i++){
		cin >> com;
		if (com == "insert"){
			scanf("%d", &x);
			insert(x);
		}
		else if (com == "print"){
			inorder(root);
			printf("\n");
			preorder(root);
			printf("\n");
		}
	}
	return 0;
}



Measured memory_bytes: 26744
#include <bits/stdc++.h>
#include <iostream>
#include <utility> // pair
#include <string>
#include <vector>
#define MAX_N 100001
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define REP(i, n) for(int i=0; i<n; i++)
#define RER(i, n) for(int i=n-1; i>=0; i--)
#define ALL(v) v.begin() v.end()
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
int n;
string s;

signed main(){
	cin >> s;
	n = s.size();
	if((n % 2 == 0) ^ (s[0] == s[n-1])) cout << "Second" << endl;
	else cout << "First" << endl;
    return 0;
}

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

typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P,ll> PLL;
typedef pair<P,P> PP;
typedef vector<ll> VECLL;
typedef vector<P> VECP;
typedef priority_queue<P,VECP,greater<P> > PQP;
typedef priority_queue<ll, VECLL, greater<ll> > PQll;

#define rep(i,a,n) for(ll i = a;i < n;i++)   
#define rrep(i,a,n) for(ll i = n; i >= a;i--)
#define index_check(i,n) if(i > n-1 || i < 0) continue; 
#define LINF (ll)1e18
#define INF (int)1e9
#define fs first
#define sc second

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

    ll r_cnt = 0;
    rep(i,0,s.size()){
        if(s[i] == 'R') r_cnt++;
    }

    ll ans = 0;
    rep(i,0,r_cnt){
        if(s[i] == 'W') ans++;
    }

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


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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int i = 0;i < (n);i++)
#define FOR(i, a, b) for(int i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-6;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

const int64 mod = 1e9+7;

int main(void){
	int32 R0, W0, C, R;
	while(cin >> R0 >> W0 >> C >> R && R0+W0+C+R){
		cout << max((int32)0, (C*W0-R0+R-1)/R) << endl;
	}
}


Measured memory_bytes: 3088
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair< ll, ll > Pi;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
#define rep3(i,i0,n) for(int i=i0;i<(n);i++)
#define pb push_back
#define mod 1000000007
const ll INF = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}
#define all(x) x.begin(), x.end()
#define mp make_pair
bool compare(Pi a, Pi b) {
    if(a.first != b.first){
        return a.first < b.first;
        
    }else{
        return a.second < b.second;
    }
}


bool In_map(ll y,ll x,ll h,ll w){
    if(y<0 || x<0 || y>=h || x>=w){
        return 0;
    }else{
        return 1;
    }
}
const vector<ll> dx{1,0,-1,0};
const vector<ll> dy{0,1,0,-1};


int main() {
    ll a,b,c;
    cin >>a>>b>>c;
    
    if(b-a==c-b){
        cout<<"YES"<<endl;
    }else{
        cout<<"NO"<<endl;
    }
    


    return 0;
    

}

Measured memory_bytes: 3584
n, q = map(int, input().split())
forest = [-1]*n


def get_root(x: int) -> int:
    if forest[x] < 0:
        return x
    else:
        forest[x] = get_root(forest[x])
        return forest[x]


def unite(x: int, y: int) -> None:
    root_x, root_y = get_root(x), get_root(y)
    if root_x != root_y:
        bigroot, smallroot = \
            (root_x, root_y) if forest[root_x] < forest[root_y]\
            else (root_y, root_x)
        forest[bigroot] += forest[smallroot]
        forest[smallroot] = bigroot

for _ in [None]*q:
    c, x, y = map(int, input().split())
    if c == 0:
        unite(x, y)
    else:
        print(1 if get_root(x) == get_root(y) else 0)

Measured memory_bytes: 8492
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <utility>
using namespace std;
using ll = long long;
 
int main() {
	vector <char> a(3);
	for (int i =0; i< 3; i++) {
		cin >> a[i];
	}
	sort(a.begin(), a.end());
	if (a[0] == 'a' && a[1] == 'b' && a[2] == 'c') cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <vector>
using namespace std;
int main() {
    int m;
    scanf("%d", &m);

    for (int n = 1; n * (n - 1) <= 2 * m; n++)
        if (n * (n - 1) == 2 * m) {
            vector<vector<int>> v(n);
            for (int i = 0, k = 0; i < n; i++)
                for (int j = 0; j < i; j++, k++) {
                    v[i].push_back(k);
                    v[j].push_back(k);
                }

            puts("Yes");
            printf("%d\n", n);

            for (int i = 0; i < n; i++) {
                printf("%zd", v[i].size());
                for (int j : v[i])
                    printf(" %d", j + 1);
                putchar('\n');
            }

            return 0;
        }

    puts("No");
    return 0;
}


Measured memory_bytes: 2304
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int N = scan.nextInt();
        List<String> list = new ArrayList<>();
        for (int i = 0; i < N; i++) list.add(scan.next());
        Collections.sort(list);
        int cnt = 0, now = 0;
        String before = "";
        for (int i = 0; i < N; i++) {
            if (!before.equals(list.get(i))) {
                cnt = Math.max(cnt, now);
                now = 1;
            } else {
                now++;
                cnt = Math.max(cnt, now);
            }
            before = list.get(i);
        }
        now = 0;
        before = "";
        for (int i = 0; i < N; i++) {
            if (!before.equals(list.get(i))) {
                now = 1;
                if (now == cnt) System.out.println(list.get(i));
            } else {
                now++;
                if (now == cnt) System.out.println(list.get(i));
            }
            before = list.get(i);
        }
    }
}

Measured memory_bytes: 75336
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i=0; i<(int)(n); i++)
int main(){
int N, K; cin >> N >> K; int A[N+2][301]={};
REP(i, N){ cin >> A[i+1][0]; }
if(K>300){
  REP(i, N){cout << N << " ";}
  cout << "\n"; return 0;
}
REP(i, K){ 
  REP(j, N){
   int l=max(1, j+1-A[j+1][i]), r=min(j+1+A[j+1][i], N);
   A[l][i+1]++; A[r+1][i+1]--;
  }
  REP(j, N){ A[j+1][i+1]+=A[j][i+1]; }
}
REP(i, N){ cout << A[i+1][K] << " "; }
cout << "\n";
}

Measured memory_bytes: 238680
#pragma GCC optimize(2)
#include<bits/stdc++.h>
using namespace std;
const int man = 4e3+10;
#define IOS ios::sync_with_stdio(0)
template <typename T>
inline T read(){T sum=0,fl=1;int ch=getchar();
for(;!isdigit(ch);ch=getchar())if(ch=='-')fl=-1;
for(;isdigit(ch);ch=getchar())sum=sum*10+ch-'0';
return sum*fl;}
template <typename T>
inline void write(T x) {static int sta[35];int top=0;
do{sta[top++]= x % 10, x /= 10;}while(x);
while (top) putchar(sta[--top] + 48);}
template<typename T>T gcd(T a, T b) {return b==0?a:gcd(b, a%b);}
template<typename T>T exgcd(T a,T b,T &g,T &x,T &y){if(!b){g = a,x = 1,y = 0;}
else {exgcd(b,a%b,g,y,x);y -= x*(a/b);}}
#ifndef ONLINE_JUDGE
#define debug(fmt, ...) {printf("debug ");printf(fmt,##__VA_ARGS__);puts("");}
#else
#define debug(fmt, ...)
#endif
typedef long long ll;
const ll mod = 1e9+7;
char str[man];
int pre1[man],pre2[man],pre3[man];
int hed1[man],hed2[man],hed3[man];

int main() {
	#ifndef ONLINE_JUDGE
		//freopen("in.txt", "r", stdin);
		//freopen("out.txt","w",stdout);
	#endif
	int n;
	cin >> n;
	cin >> str + 1;
	for(int i = 1;i <= n;i++){
		if(str[i]=='R')pre1[i] = 1;
		else if(str[i]=='G')pre2[i] = 1;
		else pre3[i] = 1;
		pre1[i] += pre1[i-1];
		pre2[i] += pre2[i-1];
		pre3[i] += pre3[i-1];
	}
	ll sum = 0;
	for(int i = 1;i <= n;i++){
		int qr = 0,qg = 0,qb = 0,hr = 0,hb = 0,hg = 0;
		ll ans = 0;
		qr = pre1[i-1];
		qg = pre2[i-1];
		qb = pre3[i-1];
		hr = pre1[n] - pre1[i];
		hg = pre2[n] - pre2[i];
		hb = pre3[n] - pre3[i];
		if(str[i]=='R'){
			ans += 1ll*qg*hb;
			ans += 1ll*hg*qb;
			int tp = 1;
			while(i-tp>=1&&i+tp<=n){
				if(str[i-tp]!='R'&&str[i+tp]!='R'&&str[i+tp]!=str[i-tp])ans--;
				tp++;
			}
		}else if(str[i]=='G'){
			ans += 1ll*qr*hb;
			ans += 1ll*hr*qb;
			int tp = 1;
			while(i-tp>=1&&i+tp<=n){
				if(str[i-tp]!='G'&&str[i+tp]!='G'&&str[i+tp]!=str[i-tp])ans--;
				tp++;
			}
		}else{
			ans += 1ll*qg*hr;
			ans += 1ll*hg*qr;
			int tp = 1;
			while(i-tp>=1&&i+tp<=n){
				if(str[i-tp]!='B'&&str[i+tp]!='B'&&str[i+tp]!=str[i-tp])ans--;
				tp++;
			}
		}
		sum += ans;
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 3652