akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

int main() {

    string S;
    cin >> S;
    int cnt = 0;

    if (S.at(0) == 'R') {
        if (S.at(1) == 'R') {
            if (S.at(2) == 'R') {
                cnt = 3;
            } else {
                cnt = 2;
            }
        } else {
            cnt = 1;
        }
    } else {
        if (S.at(1) == 'R') {
            if (S.at(2) == 'R') {
                cnt = 2;
            } else {
                cnt = 1;
            }
        } else {
            if (S.at(2) == 'R') {
                cnt = 1;
            } else {
                cnt = 0;
            }
        }
    };


    cout << cnt << endl;

}

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

using namespace std;

#define int long long
#define endl "\n"

constexpr long long INF = (long long)1e18;
constexpr long long MOD = 1'000'000'007; 

string yn(bool f){return f?"Yes":"No";}
string YN(bool f){return f?"YES":"NO";}



signed main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);
	
	string s;
	int n, ans = 0;
	
	cin>>s;
	
	n = s.size(); 
	
	for(int i = 0; i < n/2; i++) {
		if(s[i] != s[n-i-1]) ans++;
	}
	
	cout<<ans<<endl;
	
	
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
#include <functional>
#include <queue>
#include <stack>
#include <string.h>
#include <list>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define all(a)  (a).begin(), (a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define rep(i,n) for(int i = 0; i < n; i++)
#define repR(i,n) for(int i = n-1; i >= 0; i--)
#define FOR(i,m,n) for(int i = m; i < n; i++)
#define PB push_back
#define MP make_pair
#define EPS (1e-7)
#define INF (1e12)
#define PI (acos(-1))

int main(){
    int a, b, x = 0;
    cin >> a >> b;
    rep(i,b-a) x += i;
    cout << x - a << endl;
    return 0;
}


Measured memory_bytes: 256
length = int(input())
first = input().split(" ")
second = input().split(" ")
i = 0
sweet = 0
sugars = 0
while i < length:
    j = i
    k = 0
    while k<=i:
        sweet = sweet + int(first[k])
        k = k + 1
    while j < length:
        sweet = sweet + int(second[j])
        j = j + 1
    if sweet > sugars:
        sugars = sweet
    sweet = 0
    i = i + 1
print(sugars)

Measured memory_bytes: 3064
import java.util.*;
import java.io.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        FastScanner sc = new FastScanner(System.in);
        int n = sc.nextInt();
        ArrayList<Restaurant> rl = new ArrayList<>();
        for(int i = 0; i < n; i++){
            String s = sc.next();
            int p = sc.nextInt();
            rl.add(new Restaurant(p,i+1,s));
        }
        Collections.sort(rl);
        for(Restaurant r : rl){
            System.out.println(r.i);
        }
    }
}

class Restaurant implements Comparable<Restaurant>{
    int p,i;
    String c;
    public Restaurant(int p,int i,String c){
        this.p = p;
        this.i = i;
        this.c = c;
    }
    
    public int compareTo(Restaurant r){
        if(this.c.compareTo(r.c) <= -1){
            return -1;
        }else if(this.c.compareTo(r.c) >= 1){
            return 1;
        }else{
            if(this.p > r.p){
                return -1;   
            }else if(this.p < r.p){
                return 1;
            }else{
                return 0;
            }
        }
    }
}

class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;
    
    public FastScanner(InputStream in) {
        reader = new BufferedReader(new InputStreamReader(in));
        tokenizer = null;
    }

    public String next() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    public String nextLine() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                return reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
            return tokenizer.nextToken("\n");
    }

    public long nextLong() {
        return Long.parseLong(next());
    }
    
    public int nextInt() {
        return Integer.parseInt(next());
    }
    public double nextDouble() {
         return Double.parseDouble(next());
    }

    public int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++) a[i] = nextInt();
        return a;
    }

    public long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++) a[i] = nextLong();
        return a;
    } 
}


Measured memory_bytes: 20820
#include <stdio.h>

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

    s = N/1000;
    if (N > s*1000){
        s+=1;
        total = s*1000 - N;
    }
    total = s*1000 - N;

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



Measured memory_bytes: 1680
using System;
using System.IO;
using System.Collections.Generic;
using System.Linq;

namespace AtCoder.Contest.B
{
	static class Program
	{
		public static void Solve(Scanner cin)
		{
			int now = 0;
			int max = 0;
			int n = cin.ReadInt();
			string s = cin.ReadString();
			for (int i = 0; i < n; i++)
			{
				now += s[i] == 'I' ? 1 : -1;
				max = Math.Max(now, max);
			}
			Console.WriteLine(max);
		}

		public static void Main(string[] args)
		{
			var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
			Console.SetOut(sw);
			var cin = new Scanner();
			Solve(cin);
			Console.Out.Flush();
		}
	}

	class Scanner
	{
		string[] s;
		int i;

		char[] cs = new char[] { ' ' };

		public Scanner()
		{
			s = new string[0];
			i = 0;
		}

		public string Read() => ReadString();

		public string ReadString()
		{
			if (i < s.Length) return s[i++];
			string st = Console.ReadLine();
			while (st == "") st = Console.ReadLine();
			s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
			if (s.Length == 0) return ReadString();
			i = 0;
			return s[i++];
		}

		public string[] ReadStringArray(int N)
		{
			string[] Array = new string[N];
			for (int i = 0; i < N; i++)
			{
				Array[i] = ReadString();
			}
			return Array;
		}

		public int ReadInt()
		{
			return int.Parse(ReadString());
		}

		public int[] ReadIntArray(int N, int add = 0)
		{
			int[] Array = new int[N];
			for (int i = 0; i < N; i++)
			{
				Array[i] = ReadInt() + add;
			}
			return Array;
		}

		public long ReadLong()
		{
			return long.Parse(ReadString());
		}

		public long[] ReadLongArray(int N, long add = 0)
		{
			long[] Array = new long[N];
			for (int i = 0; i < N; i++)
			{
				Array[i] = ReadLong() + add;
			}
			return Array;
		}

		public double ReadDouble()
		{
			return double.Parse(ReadString());
		}

		public double[] ReadDoubleArray(int N, double add = 0)
		{
			double[] Array = new double[N];
			for (int i = 0; i < N; i++)
			{
				Array[i] = ReadDouble() + add;
			}
			return Array;
		}

		public T1 ReadValue<T1>() => (T1)Convert.ChangeType(ReadString(), typeof(T1));
	}
}

Measured memory_bytes: 13140
#include<bits/stdc++.h>
using namespace std;
int main(){
    int nAB=0,nAend=0,nBhead=0,nNone=0;
    int N;
    int flag;
    int nExcept=0;
    string Input;
    cin >> N;
    for(int i=0; i<N; i++){
        flag=0;
        cin >> Input;
        if(Input.at(0)=='B'){nBhead++; flag++;}
        if(Input.at(Input.length()-1)=='A'){nAend++; flag++;}
        for(int j=0; j<Input.length()-1; j++){
            if(Input.at(j)=='A'&&Input.at(j+1)=='B') nAB++;
        }
        if(flag==0) nExcept++; 
    }
    int answer;
    //cout << nAB << " " <<min(nBhead,nAend)<<endl;
    answer = nAB + min(nAend,nBhead);
    if(min(nAend,nBhead)==N-nExcept && min(nAend,nBhead)>0) answer--;
    cout << answer;
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace atcorder_keyence_2019
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] lineArr = Console.ReadLine().Split(' ');
            bool flg1 = false;
            bool flg9 = false;
            bool flg7 = false;
            bool flg4 = false;
            for (int i = 0; i < 4; i++)
            {
                if ("1" == lineArr[i]){ flg1 = true; }
                else if ("9" == lineArr[i]) { flg9 = true; }
                else if ("7" == lineArr[i]) { flg7 = true; }
                else if ("4" == lineArr[i]) { flg4 = true; }
                    
            }
            string ret = "NO";
            if (flg1 && flg9 && flg7 && flg4)
            {
                ret = "YES";
            }
            Console.WriteLine(ret);
        }
    }
}


Measured memory_bytes: 11092
import collections

def searchRoot(n):
    par = parList[n]
    if n == par:
        if len(q) > 0:
            rootIn(q,n)
        return n
    else:
        q.append(n)
        return(searchRoot(par))

def rootIn(q,root):
    while len(q) > 0:
        parList[q.popleft()] = root

n,m = list(map(int,input().split()))
q = collections.deque()

parList = [i for i in range(n+1)]

for i in range(m):
    a,b = list(map(int,input().split()))
    aRoot = searchRoot(a)
    bRoot = searchRoot(b)
    if aRoot != bRoot:
        parList[max(aRoot,bRoot)] = min(aRoot,bRoot)
    

ansDic = dict()
rootSet = set()
for i in range(1,n+1):
    root = searchRoot(i)
    if root in rootSet:
        ansDic[root] += 1
    else:
        rootSet.add(root)
        ansDic[root] = 1
print(len(rootSet) - 1)


Measured memory_bytes: 98940
#!/usr/bin/env python3

# from numba import njit

# from collections import Counter
# from itertools import accumulate
# import numpy as np
# from heapq import heappop,heappush
# from bisect import bisect_left

# @njit
def solve(n,a,b,s):
  ans = [""]*n
  japaneseStudents = 0
  foreignStudents = 0
  for i in range(n):
    if s[i] == "a" and japaneseStudents + foreignStudents < a+b:
      ans[i] = "Yes"
      japaneseStudents += 1
    elif s[i] == "b" and japaneseStudents + foreignStudents < a+b and foreignStudents < b:
      ans[i] = "Yes"
      foreignStudents += 1
    else:
      ans[i] = "No"
  return ans



def main():
  N,A,B = map(int,input().split())
  s = input()
  ans = solve(N,A,B,s)
  for i in range(N):
    print(ans[i])
  return

if __name__ == '__main__':
  main()


Measured memory_bytes: 9780
import java.util.*;
public class Main {
	static Scanner sc = new Scanner(System.in);
	static int h, w;
	static char[][] field;
	static boolean[][] isPassed;
	public static void main(String[] args) {
		while(read()){
			solve();
		}
	}

	static boolean read(){
		h = sc.nextInt();
		w = sc.nextInt();
		
		if(h == 0 && w == 0)return false;
		
		field = new char[h][w];
		isPassed = new boolean[h][w];
		
		for(int i = 0; i < field.length; i++)field[i] = sc.next().toCharArray();
		for(boolean[] arrays: isPassed)Arrays.fill(arrays, false);
		
		return true;
	}
	
	static void solve(){
		int gx = 0, gy = 0, nx = 0, ny = 0;
		int[] dx = {0, 1, 0, -1}, dy = {-1, 0, 1, 0};//up, right, down, left
		boolean isLoop = false;
		
		isPassed[0][0] = true;
		while(true){
			if(field[ny][nx] == '^'){
				nx = nx + dx[0]; ny = ny + dy[0];
			}else if(field[ny][nx] == '>'){
				nx = nx + dx[1]; ny = ny + dy[1];
			}else if(field[ny][nx] == 'v'){
				nx = nx + dx[2]; ny = ny + dy[2];
			}else if(field[ny][nx] == '<'){
				nx = nx + dx[3]; ny = ny + dy[3];
			}else{
				gx = nx; gy = ny;
				break;
			}
			if(isPassed[ny][nx]){isLoop = true; break;}
			isPassed[ny][nx] = true;
		}
		
		if(isLoop){
			System.out.println("LOOP");
		}else{
			System.out.println(gx + " " + gy);
		}
			
	}
}

Measured memory_bytes: 12000
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>
#include <numeric>
#include <queue>
#include <stack>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9) + 7;

int main(void) {	
	int n, q;
	cin >> n >> q;
	
	queue< pair<string, int> > que;
	for(int i = 0; i < n; ++i) {
		string name;
		int time;
		cin >> name >> time;
		
		que.push( {name, time} );
	}
	
	int t = 0;
	vector< pair<string, int> > res;
	
	while( !que.empty() ) {
		pair<string, int> now_proc = que.front();
		que.pop();
		
		t += q;
		if( q < now_proc.second ) {
			now_proc.second -= q;
			que.push( now_proc );
		} else {
			res.push_back( {now_proc.first, t - q + now_proc.second} );
			t = t - q + now_proc.second;
		}
	}
	
	for(auto& ans : res) {
		cout << ans.first << " " << ans.second << endl;
	}
	
	return 0;
}



Measured memory_bytes: 7088
#include<bits/stdc++.h>
//ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> ppll;
typedef pair<ll,pll> plpl;
typedef tuple<ll,ll,ll> tl;
ll mod=1000000007;
ll mod2=998244353;
ll mod3=1000003;
ll mod4=998244853;
ll inf=1000000000000000000;
long double pi=3.14159265358979323846L;
double eps=1e-12;
#define rep(i,m,n) for(int i=m;i<n;i++)
#define rrep(i,n,m) for(int i=n;i>=m;i--)
int dh[4]={1,-1,0,0};
int dw[4]={0,0,1,-1};
int ddh[8]={-1,-1,-1,0,0,1,1,1};
int ddw[8]={-1,0,1,-1,1,-1,0,1};
ll lmax(ll a,ll b){
    if(a<b)return b;
    else return a;
}
ll lmin(ll a,ll b){
    if(a<b)return a;
    else return b;
}
ll gcd(ll a,ll b){
    if(a<b)swap(a,b);
    if(b==0)return a;
    if(a%b==0)return b;
    return gcd(b,a%b);
}
ll Pow(ll n,ll k){
    ll ret=1;
    ll now=n;
    while(k>0){
        if(k&1)ret*=now;
        now*=now;
        k/=2;
    }
    return ret;
}
ll gya[1000010];
ll kai[1000010];
ll beki(ll n,ll k,ll md){
  ll ret=1;
  ll now=n;
  while(k>0){
    if(k%2==1){
      ret*=now;
      ret%=md;
    }
    now*=now;
    now%=md;
    k/=2;
  }
  return ret;
}
ll gyaku(ll n,ll md){
  return beki(n,md-2,md);
}
int main(){
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    ll n,D;cin>>n>>D;
    ll d[n];
    int u=-1;
    
    rep(i,0,n){
        cin>>d[i];
        if(d[i]==1)u=i;
    }
    ll q;cin>>q;
    ll dis[n+1];
    rrep(i,n,u+1)dis[i]=0;
    if(u>=0){
        dis[u]=1;
        ll now=1;
        
        rrep(i,u,1){
            dis[i]=now;
            //cout<<now<<" ";
            if(d[i-1]<=2*now+1){
                now+=d[i-1];
            }
        }
        dis[0]=now;
    }
    
    ll sum[n+1];
    sum[0]=D;
    rep(i,0,n){
        ll y=sum[i]-d[i];
        if(y<0)y=-y;
        y=min(y,sum[i]);
        sum[i+1]=y;
    }
    rep(i,0,n+1){
       // cout<<dis[i]<<" "<<sum[i]<<endl;
    }
    rep(i,0,q){
        ll r;cin>>r;
        ll ss=sum[r-1];
        ll p=dis[r];
        if(p>=ss)cout<<"NO"<<endl;
        else cout<<"YES"<<endl;
    }
}


Measured memory_bytes: 13696
#include <iostream>

using namespace std;

int main() {
	int r, c;
	int arr[101][101];

	cin >> r >> c;

	for (int i = 0; i < r; i++) {
		int sum = 0;
		for (int j = 0; j < c; j++) {
			cin >> arr[i][j];
			sum += arr[i][j];
		}
		arr[i][c] = sum;
	}



	for (int i = 0; i <= r; i++) {
		if (i != r) {
			for (int j = 0; j <= c; j++) {
				if (j == 0)
					cout << arr[i][j];
				else
					cout << " " << arr[i][j];
 				if (j == c)
					cout << endl;
			}
		}
		else {
			for (int k = 0; k <= c; k++) {
				int rsum = 0;
				for (int l = 0; l < r; l++)
					rsum += arr[l][k];
				if (k == 0)
					cout << rsum;
				else
					cout << " " << rsum;
			}
			cout << endl;				
		}

	}
}


Measured memory_bytes: 3112
#include <stdio.h>
#include <stdlib.h>

int main(){
  int i, j, x, p, q, n, tmp;

  scanf("%d", &n);
  int *a;
  a = malloc(sizeof(int) * n);
  for(i = 0; i < n; i++)
    scanf("%d", &a[i]);


  x = a[n-1];
  i = -1;
  for(j = 0; j < n-1; j++){
    if(a[j] <= x){
      i++;
      tmp = a[i];
      a[i] = a[j];
      a[j] = tmp;
    }
  }
  tmp = a[i+1];
  a[i+1] = a[n-1];
  a[n-1] = tmp;

  for(j = 0; j < i+1; j++)
      printf("%d ", a[j]);
  printf("[%d] ", a[j]);
  for(j = j+1; j < n-1; j++)
    printf("%d ", a[j]);
  printf("%d\n", a[j]);

  free(a);
  return 0;
}

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

template <typename _tp> inline void read(_tp&x){
	char ch=getchar(),ob=0;x=0;
	while(ch!='-'&&!isdigit(ch))ch=getchar();if(ch=='-')ob=1,ch=getchar();
	while(isdigit(ch))x=x*10+ch-'0',ch=getchar();if(ob)x=-x;
}

const int N = 211, M = 40013, oo = 1e9;
struct Edge {int v, w, nxt;} a[M];
int head[N], cur[N], dis[N];
char str[N];
int n, m, s, t, _ = 1;

inline void add(int x, int y, int z) {
	a[++_].v = y, a[_].w = z, a[_].nxt = head[x], head[x] = _;
	a[++_].v = x, a[_].w = 0, a[_].nxt = head[y], head[y] = _;
}

bool bfs() {
	static int q[N], he, ta;
	memset(dis, -1, t + 1 << 2);
	dis[q[he = ta = 1] = s] = 0;
	while(he <= ta) {
		int x = q[he++];
		for(int i=head[x];i;i=a[i].nxt)
			if(a[i].w > 0 and dis[a[i].v] == -1) {
				dis[a[i].v] = dis[x] + 1;
				q[++ta] = a[i].v;
				if(a[i].v == t) return true;
			}
	}
	return false;
}

int dfs(int x, int flw) {
	if(x == t or flw == 0) return flw;
	int res = 0, tmp;
	for(int&i=cur[x];i;i=a[i].nxt)
		if(dis[a[i].v] == dis[x] + 1 and a[i].w > 0)
		if(tmp = dfs(a[i].v, min(flw - res, a[i].w)))
			a[i].w -= tmp, a[i^1].w += tmp, res += tmp;
	if(!res) dis[x] = -1;
	return res;
}

int main() {
	read(n), read(m), s = n+m+1, t = s+1;
	for(int i=1;i<=n;++i) {
		scanf("%s", str+1);
		for(int j=1;j<=m;++j) {
			if(str[j] == 'o') {add(i, j+n, 1), add(j+n, i, 1); continue;}
			if(str[j] == 'S') add(s, i, +oo), add(s, j+n, +oo);
			if(str[j] == 'T') add(i, t, +oo), add(j+n, t, +oo);
		}
	}
	
	int Ans = 0;
	while(bfs()) {
		memcpy(cur, head, t + 1 << 2);
		Ans += dfs(s, +oo);
	}
	printf("%d\n", Ans > n * m ? -1 : Ans);
	return 0;
}

Measured memory_bytes: 768
from collections import deque
k = int(input())
ans=[]
# q = deque([[1],[2],[3],[4],[5],[6],[7],[8],[9]])
q = deque([1,2,3,4,5,6,7,8,9])
while q:
  a = q.popleft()
  ans.append(a)
  if len(ans) > k:
    break
  tmp = int(str(a)[-1])
  if tmp-1 >= 0:
    q.append(10*a + tmp-1)
  q.append(10*a + tmp)
  if tmp+1 <= 9:
    q.append(10*a + tmp+1)
print(ans[k-1])

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

using namespace std;

#define endl "\n"
#define si(a) scanf("%d ",&a);
#define si2(a,b) scanf("%d %d ",&a,&b);
#define si3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define sll(a) scanf("%lld ",&a);
#define sll2(a,b) scanf("%lld%lld",&a,&b)
#define sll3(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define sf(a) scanf("%f ",&a);
#define sd(a) scanf("%lf ",&a);
#define sc(a) scanf("%c ",&a);
#define ss(a) scanf("%s ",a);
#define sf2(a,b) scanf("%f %f ",&a,&b);
#define sd2(a,b) scanf("%lf %lf ",&a,&b);
#define mp(a,b) make_pair(a,b)
#define pb(x) push_back(x)
#define all(a) a.begin(),a.end()
#define forn(i,n) for(int i=0;i<n;i++)
#define forq(i,q,n) for(int i=q;i<n;i++)
#define form(i,n) for(int i=n;i>=0;i--)
#define forp(i,q,n) for(int i=q;i>=n;i--)
#define fi first
#define se second
#define INF 1000000010
#define MOD 1000000007
#define MAXN
#define LL long long int

int a, b, c;

void init()
{
	si3(a, b, c);
	int aa = b - a;
	int bb = c - b;
	if(aa == bb)
	{
		printf("YES\n");
	}
	else {
		printf("NO\n");
	}

}

int main()
{

	#ifndef ONLINE_JUDGE
		//freopen("input.txt","r",stdin);
		//freopen("output.txt","w",stdout);
	#endif

	init();

	return 0;
}

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




#define mp make_pair
#define pb push_back
#define rep(i,port,sail) for(i=port;i<=sail;i++)
const int N = 100010;
typedef long long ll;

ll dp[N],vis[N];
ll mx = 0;
vector<int> adj[N];
void dfs(int i)
{
	vis[i]=1;
	for(int j:adj[i])
	{
		if(!vis[j])dfs(j);
		dp[i]=max(dp[i],dp[j]+1);

	}
	mx = max(mx,dp[i]);
}
int main()
{
	int n,i,j,k,t,u,v,m;
	ll W;
	cin>>n>>m;
	rep(i,1,m)
	{
		cin>>u>>v;
		adj[u].pb(v);
	}
	rep(i,1,n){
		if(!vis[i])dfs(i);
	}
	cout<<mx<<"\n";

	
	return 0;
}



Measured memory_bytes: 9344
#include<iostream>
using namespace std;
int main(){
	int H, W, n; cin>>H>>W>>n; int a[n];
	for(int i=0; i<n; i++) cin>>a[i];
	int x[H][W], k=0;
	for(int i=0; i<H; i++){
		if(i%2==0){
			for(int j=0; j<W; j++){
				x[i][j] = k; a[k]--;
				if(a[k]==0) k++;
			}
		}
		else{
			for(int j=W-1; j>-1; j--){
				x[i][j] = k; a[k]--;
				if(a[k]==0) k++;
			}
		}
	}
	for(int i=0; i<H; i++){
		for(int j=0; j<W; j++){
			cout<<x[i][j]+1<<' ';
		}
		cout<<endl;
	}
	return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long> vl;
#define INF __INT32_MAX__
#define LINF __LONG_LONG_MAX__

class UnionFind
{
    private:
        vl parents;
        vl rank;

    public:
        UnionFind(ll n) {
            for (ll i = 0; i < n; i++) {
                parents.push_back(i);
            }
            rank.resize(n, 1);
        }

        ll root(ll a) {
            if (parents[a] == a) return a;

            ll r = root(parents[a]);
            parents[a] = r;
            return r;
        }

        bool unite(ll a, ll b) {
            ll ra = root(a);
            ll rb = root(b);
            if (ra == rb) return false;

            if (rank[ra] < rank[rb]) {
                rank[rb] += rank[ra];
                parents[ra] = rb;
            } else {
                rank[ra] += rank[rb];
                parents[rb] = ra;
            }
            return true;
        }

        bool same(ll a, ll b) {
            return root(a) == root(b);
        }
};

int main() {
    int N, Q;
    cin >> N >> Q;
    UnionFind uni(N);
    rep(i, Q) {
        int C, X, Y;
        cin >> C >> X >> Y;
        if (C == 0) {
            uni.unite(X, Y);
        } else {
            if (uni.same(X, Y)) {
                cout << 1 << endl;
            } else {
                cout << 0 << endl;
            }
        }
    }
}


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

template<typename First, typename Second, typename Third>
struct triple {
   First first;
   Second second;
   Third third;
};

using namespace std;

void solve(){
    int x,c;
    cin>>x>>c;
    cout<<max(x-c,0);
}

int main(){
       std::ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
      
       solve(); 
    return 0;
}


Measured memory_bytes: 256
<?php
// D
define("MOD", 10 ** 9 + 7);
fscanf(STDIN, '%d %d', $n, $k);
$ans = 0;
for ($i = $k; $i <= $n + 1; $i++) {
    $min = modDiv(modMul($i - 1, $i), 2);
    $max = modDiv(modMul(2 * $n - $i + 1, $i), 2);
    $ans = modAdd($ans, modSub($max + 1, $min));
}
echo $ans;

// 足し算
function modAdd($x, $y)
{
    return ($x + $y) % MOD;
}

// 引き算
function modSub($x, $y)
{
    return ($x + MOD - $y) % MOD;
}

// 掛け算
function modMul($x, $y)
{
    return ($x * $y) % MOD;
}

// 割り算
function modDiv($x, $y)
{
    return modMul($x, modPow($y, MOD - 2));
}

// 累乗（繰り返し二乗法）
function modPow($n, $x)
{
    if ($x === 0) return 1;
    $res = (modPow($n, $x >> 1) ** 2) % MOD;
    if ($x % 2 === 1) $res = modMul($res, $n);
    return $res;
}

// 階乗
function modFac($n)
{
    if ($n === 0) return 1;
    return modMul($n, modFac($n - 1));
}

// 順列
function nPr($n, $r)
{
    if ($r === 0) return 1;
    return modDiv(modFac($n), modFac($n - $r));
}

// 組み合わせ
function nCr($n, $r)
{
    $r = min($r, $n - $r);
    if ($r === 0) return 1;
    return modDiv(nPr($n, $r), modFac($r));
}

// nCr 前処理　配列を返す
function nCr2($max)
{
    $pascal[0][0] = 1;
    for ($j = 1; $j <= $max; $j++) {
        for ($i = 0; $i <= $j; $i++) {
            $pascal[$j][$i] = (($pascal[$j - 1][$i - 1] ?? 0) + ($pascal[$j - 1][$i] ?? 0)) % MOD;
        }
    }
    return $pascal;
}

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

string S;
int Q;
deque<char>st;
bool rev;

int main(){
	cin>>S>>Q;
	for(char c:S){
		st.push_back(c);
	}
	while(Q--){
		int t;
		cin>>t;
		if(t==1){
			rev^=1;
		}
		else{
			int f;
			char c;
			cin>>f>>c;
			f--;
			if(f^rev){
				st.push_back(c);
			}
			else{
				st.push_front(c);
			}
		}
	}
	if(rev){
		while(!st.empty()){
			cout<<st.back();
			st.pop_back();
		}
	}
	else{
		while(!st.empty()){
			cout<<st.front();
			st.pop_front();
		}
	}
	cout<<endl;
}


Measured memory_bytes: 896
n,m=map(int,input().split())
ans=[]
if n%2==1:
    for j in range(m):
        ans.append(((n-1)//2 - j, (n+1)//2 +j))
else:
    w = (n//2)//2
    u = (n//2)-1 -w
    #print(w,u)
    for j in range(w):
        p,q = n//2-1 -j,n//2 +j
        ans.append((p,q))
        
    for j in range(1,u+1):
        ans.append((p-j,q+1+j))
for i in range(m):
    print(*ans[i])

Measured memory_bytes: 73316
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const long long LINF = 1e18;
const long long MOD = 1e9 + 7;

using ll = long long;
template <ll MOD = 1000000007>
struct Mint{
    ll x;

    Mint() : x(0) {}
    Mint(ll t){
        x = t % MOD;
        if(x < 0) x += MOD;
    }
    
    Mint pow(ll n){
        Mint res(1), t(x);
        while(n > 0){
            if(n & 1) res *= t;
            t *= t;
            n >>= 1;
        }
        return res;
    }

    Mint inv() const {
        ll a = x, b = MOD, u = 1, v = 0, t;
        while(b > 0){
            t = a / b;
            a -= t * b;
            swap(a, b);
            u -= t * v;
            swap(u, v);
        }
        return Mint(u);
    }

    Mint & operator += (Mint a){
        x += a.x;
        if(x >= MOD) x -= MOD;
        return *this;
    }
    
    Mint & operator -= (Mint a){
        x += MOD - a.x;
        if(x >= MOD) x -= MOD;
        return *this;
    }

    Mint & operator *= (Mint a){
        x = 1LL * x * a.x % MOD;
        return *this;
    }

    Mint & operator /= (Mint a){
        return (*this) *= a.inv();
    }

    Mint operator + (Mint a) const { return Mint(x) += a; }
    Mint operator - (Mint a) const { return Mint(x) -= a; }
    Mint operator * (Mint a) const { return Mint(x) *= a; }
    Mint operator / (Mint a) const { return Mint(x) /= a; }

    Mint operator - () const{ return Mint(-x); }

    bool operator == (const Mint a){ return x == a.x; }
    bool operator != (const Mint a){ return x != a.x; }
    bool operator < (const Mint a){ return x < a.x; }

    friend ostream & operator << (ostream & os, const Mint &a){
        return os << a.x;
    }

    friend istream & operator >> (istream & is, Mint &a){
        ll t;
        is >> t;
        a = Mint<MOD>(t);
        return (is);
    }
};

map<long long, int> PrimeFactor(long long n){
    map<long long, int> mp;
    for(int i = 2; (long long)i * i <= n; i++){
        while(n % i == 0){
            mp[i]++;
            n /= i;
        }
    }
    if(n != 1) mp[n]++;
    return mp;
}

signed main(){
    int n;
    cin >> n;
    ll a[n];
    REP(i,n){
        cin >> a[i];
    }
    map<ll, int> all;
    map<ll, int> mp;
    REP(i,n){
        map<ll, int> mp = PrimeFactor(a[i]);
        for(auto j : mp){
            all[j.first] = max(all[j.first], j.second);
        }
    }
    Mint<> t = 1;
    for(auto j : all){
        t *= Mint<>(j.first).pow(j.second);
    }
    Mint<> ans = 0;
    REP(i,n){
        ans += t / Mint<>(a[i]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 896
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n; cin >> n;
  int t0 = 0, x0 = 0, y0 = 0;
  for(int i = 0; i < n; i++){
    int t,x,y; cin >> t >> x >> y;
    int dt = abs(t -t0),dx = abs(x - x0),dy = abs(y - y0);
    if(dt % 2 != (dx + dy) % 2 or dt < dx + dy){
      cout << "No";
      return 0;
    }
    t0 = t;
    x0 = x;
    y0 = y;
  }
  cout << "Yes";
}
  

Measured memory_bytes: 3604
function main(input) {
    const parsedInput = input.split('\n')[0].split(' ')[0];
    if (parsedInput == 'ABC') {
        console.log('ARC');
    } else if(parsedInput == 'ARC') {
        console.log('ABC');
    }
}
// test
// const Q1 = `ABC`;
// const Q2 = `ARC`;
// main(Q1);
// main(Q2);
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 29592
#include <iostream>
#define MOD 1000000007
using namespace std;

bool check(int a[], int b[], int n){
    if(n%2 == 1){
        for(int i = 0;i < n;i++){
            if(a[i] == 0) continue;
            if(b[a[i]] != 2) return false;
        }
        return b[0] == 1;
    }
    else {
        for(int i = 0;i < n;i++){
            if(a[i] == 0) continue;
            if(b[a[i]] != 2) return false;
        }
        return b[0] == 0;
    }
}
int main(){
    int n;
    int a[100001];
    int b[100001] = {};

    cin >> n;

    for(int i = 0; i < n; i++){
        cin >> a[i];
        b[a[i]]++;
    }
    bool result = check(a, b, n);

    long long ans = 1;
    for(int i = 1; i <= n/2; i++){
        ans = (ans*2)%MOD;
    }

    if(result) cout << ans << endl;
    else cout << 0 << endl;
    return 0;
}

Measured memory_bytes: 1024
def fact(n):
    mod = int(1e9)+7
    res = 1
    for i in range(1,n+1):
        res = (res*i)%mod
    return res

N,M = map(int,input().split())

if abs(N-M) >= 2:
    print(0)
    exit()

mod = int(1e9)+7

if N == M:
    print(2*fact(N)*fact(M)%mod)
else:
    print(fact(N)*fact(M)%mod)

Measured memory_bytes: 3060
#include<iostream>
#include<stdio.h>
#include<vector>
#include<ctype.h>
#include<string>
#include<cmath>
#include<string.h>
#include<sstream>
#include<limits.h>
#define rep(i,n) for(int i=0;i<(n);++i)
using namespace std;
typedef long long int ll;
typedef vector<int> vi;

//最大公約数
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;
}

//素数判定
bool isPrime(int x){
    if(x<2)return 0;
    else if(x==2)return 1;
    if(x%2==0)return 0;
    for(int i=3;i*i<=x;i+=2){
        if(x%i==0)return 0;
    }
    return 1;
}

//桁ごとの足し算
int digsum(int n){
    int res=0;
    while(n>0){
        res+=n%10;
        n/=10;
    }
    return res;
}

//約数列挙
vector<int> enum_div(int n){
    vector<int> ret;
    for(int i=1;i*i<=n;++i){
        if(n%i==0){
            ret.push_back(i);
            if(i*i !=n){
                ret.push_back(n/i);
            }
        }
    }
    return ret;
}

//累乗の計算とあまり,0で累乗そのまま出力
long long modpow(long long a,long long n,long long mod){
    if(mod==0)mod=__LONG_LONG_MAX__;
    long long res=1;
    while(n>0){
        if(n & 1)res=res*a%mod;
        a=a*a%mod;
        n>>=1;
    }
    return res;
}

string s;

int main(){
    cin>>s;
    int max=0;
    int count=0;
    for(int i=0;i<s.size();++i){
        if(s[i]=='R'){
            count++;
        }
        else count=0;

        if(count>max)max=count;
    }
    cout<<max<<endl;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
#define rep(X,N) for(ll X = 0; X < (N); X++)
#define PI (acos(-1.0))
#define pback push_back
#define mpair make_pair
#define MODN 1000000007
#define ALL(V) (V).begin(),(V).end()

typedef long long ll;

using namespace std;
using namespace boost::multiprecision;

int main(){

    int h,a;
    cin >> h >> a;

    cout << (h + a - 1) / a << endl;

    return 0;
}

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

using ll = long long;
using ld = long double;
using pii = pair<int, int>;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))

int dx4[4] = {1,0,-1,0}, dy4[4] = {0,1,0,-1};


int main()
{
    int n;
    ll ans=0,ls[5];
    cin >>n;
    m0(ls);
    string m = "MARCH";
    
    for(int i = 0; i < n; i++)
    {
        string s;
        cin>>s;
        char c = s[0];
        
        for(int j = 0; j < 5; j++)
        {
            if(c==m[j])
            {
                ls[j]++;
            }
        }
    }
    
    for(int i = 0; i < 5; i++)
    {
        
        for(int j = 0; j < i; j++)
        {
            
            for(int k = 0; k < j; k++)
            {
                ans+=ls[i]*ls[j]*ls[k];
            }
            
        }
        
    }
    

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

Measured memory_bytes: 256
s=input()
n=len(s)
ans=[0 for i in range(n)]
r=0
l=0

for i in range(n):
  if s[i]=="R":
    r+=1
  else:
    plus=r//2
    ans[i]+=plus
    ans[i-1]+=(r-plus)
    r=0

for i in range(n-1,-1,-1):
  if s[i]=="L":
    l+=1
  else:
    plus=l//2
    ans[i]+=plus
    ans[i+1]+=l-plus
    l=0
print(*ans)

Measured memory_bytes: 6400
import java.util.Scanner;


class Main{

	public static void main(String args[]){

		Scanner scan = new Scanner(System.in);

		int N =  scan.nextInt();
		int M = N;
		int keta = String.valueOf(N).length();		//桁数が返されるは"+
		int m = keta;
		int sum = 0;			//合計値


		for(int j = 0;j < m;j++){
			int waru = 1;
			if(keta != 0){
				for(int i = keta-1;i > 0;i--){
					waru *= 10;
					
				}
				
				
			}
			
			sum += N/waru;
			
			keta--;
			N -= (N/waru)*waru;
			
		}
		
		
		if(M%sum == 0){
			System.out.println("Yes");

		}else{
			System.out.println("No");
		}

	}
}

Measured memory_bytes: 23252
#include <iostream>
#include <climits>
using namespace std;
int main() {
    int n, k;
    cin >> n>>k;
    int a[n], dp[n];
    for(int i=0;i<n;i++){
        cin >> a[i];
        dp[i] = INT_MAX;
    }
    dp[0] = 0;
    for(int i=1;i<n;i++){
        for(int j=i;j>=max(0, i-k);j--){
            dp[i] = min(dp[i], dp[j]+abs(a[i]-a[j]));
        }
    }
    cout << dp[n-1]<< endl;
}

Measured memory_bytes: 4400
#include <cstring>
#include <iostream>
using namespace std;
int n;
int h[200], r[200];
int memo[200];

int solve(int x) {
	if (memo[x] != -1) return memo[x];
	int res = 0;
	for (int i = 0; i < n; i++) {
		if (h[x] < h[i] && r[x] < r[i]) {
			res = max(res, solve(i));
		}
	}
	return memo[x] = (res + 1);
}

int main () {
	while (cin >> n, n) {
		memset(memo, -1, sizeof(memo));
		for (int i = 0; i < n; i++) {
			cin >> h[i] >> r[i];
		}
		int m;
		cin >> m;
		for (int i = 0; i < m; i++) {
			cin >> h[n + i] >> r[n + i];
		}
		n += m;
		int res = 0;
		for (int i = 0; i < n; i++) {
			res = max(res, solve(i));
		}
		cout << res << endl;
	}
	return 0;
}

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


int main(void){
	int num[100001];	//
	int red[100001];

	//初期化
	for ( int i = 1 ; i <= 100000 ; i++ ) {
		num[i] = 1;
		red[i] = 0;
	}
	red[1] = 1;

	//データ読み込み
	int n, m;
	int x, y;

	cin >> n >> m;
	for ( int i = 0; i < m; i++) {
		cin >> x >> y;
		if (red[x] == 1){
			red[y] = 1;
		}
		num[x]--;
		num[y]++;
		
		if (num[x] == 0){
			red[x] = 0;
		}
	}

	//赤いコップの数を数える
	int cnt = 0;
	for ( int i = 1; i <= n; i++){
		if(red[i] == 1) cnt++;
	}

	//表示
	cout << cnt << endl;

	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std ;
 
#define lli long long int
#define pb push_back
 
int main ()
{
    int n ;
    cin >> n ;
    int array [n];

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

    int num_at = 1 , removed = 0;

    for (int i = 0 ; i < n ; i++)
    {
        if (array[i] == num_at)
        {
            num_at++;
        }
        else
        {
            removed++;
        }
        
    }

    if (num_at == 1)
    {
        cout << "-1" << endl ;
    }
    else
    {
        cout << removed << endl ;
    }
    

    return 0 ;
}

Measured memory_bytes: 1024
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repe(i,n) for (int i = 0; i <= (n); ++i)
#define repe1(i,n) for (int i = 0; i <= (n); ++i)
#define all(x) (x).begin(),(x).end()
#define pb(x) push_back(x)
#define eb(k,v) emplace_back(k,v)
#define ct(res) cout << res << "\n";
#define vi vector<int>
#define vl vector<ll>
using namespace std;
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; }
const int INF = 1e9;
const ll MOD = 1000000007;
using Graph = vector<vector<int>>;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int  n,y; cin >> n >> y;
    for(int i=0; i<=n; ++i) {
        for(int j=0; j<=n-i; ++j) {
            if (i*10000+j*5000+(n-i-j)*1000 == y) {
                cout << i << " " << j << " " << n-i-j << "\n";
                return 0;
            }
        }
    }
    cout << -1 << " " << -1 << " " << -1 << "\n";

}



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

using namespace std;

using ll = long long;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    ll h;
    cin >> n >> h;
    vector<ll> b(n);
    ll a = 0;
    for (int i = 0; i < n; i++) {
        ll x;
        cin >> x >> b[i];
        a = max(a, x);
    }
    sort(b.rbegin(), b.rend());
    ll cur = 0;
    ll ans = 0;
    for (int i = 0; i < n; i++) {
        if (a >= b[i]) break;
        cur += b[i];
        ans++;
        if (cur >= h) break;
    }
    if (cur < h) ans += (h - cur + a - 1) / a;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define intput(i) cout << i << endl
#define ll long long
#define stringput(s) cout << (string)(s) << endl

int main(){
  int k;
  cin >> k;
  int ans =((k+1)/2)*(k/2);
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
    int A,B,maior,i;
    scanf("%d %d",&A,&B);
    //printf("%d + %d = %d, %d - %d = %d, %d x %d = %d",A,B,A+B,A,B,A-B,A,B,A*B);
    maior=A+B;
    if(A-B>maior){
        maior=A-B;
    }
    if(A*B>maior){
        maior=A*B;
    }
    printf("%d",maior);
    return 0;
}

Measured memory_bytes: 128
import sys
input = sys.stdin.readline

N = int(input())
A = list(map(int, input().split()))
mod = 10**9+7

plist = [0]*1000
lcm = 1
nokori=set()
for a in A:
    for j in range(2, 1001):
        count_j=0
        while a % j == 0:
            count_j += 1
            a //= j
        plist[j-1]=max(plist[j-1],count_j)
    nokori |= {a}
for x in nokori:
    lcm *= x
    lcm %= mod


for i in range(1000):
    lcm *= pow(i+1, plist[i], mod)
    lcm %= mod

ans = 0

for a in A:
    ans += lcm * pow(a, mod-2, mod)
    ans %= mod

print(ans)


Measured memory_bytes: 43996
// This file is a "Hello, world!" in C++ language by GCC for wandbox.
#include <iostream>
#include <cstdlib>
using namespace std;

int max(int a, int b){
if( a>b ) return a;
else return b;
}

int main(){
//int
long long a,b,c,d;//int
long long ans=0;
scanf("%lld %lld %lld %lld",&a,&b,&c,&d);

ans=max(a*c, a*d);
ans=max(ans, b*c);
ans=max(ans, b*d);

//cout<<ans<<endl;
printf("%lld\n",ans);
}

// GCC reference:
//   https://gcc.gnu.org/

// C++ language references:
//   https://cppreference.com/
//   https://isocpp.org/
//   http://www.open-std.org/jtc1/sc22/wg21/

// Boost libraries references:
//   https://www.boost.org/doc/


Measured memory_bytes: 3828
fn main() {
    let mut t = String::new();
    std::io::stdin().read_line(&mut t).unwrap();
    let mut ws = t.trim().split_whitespace();
    let n: usize = ws.next().unwrap().parse().unwrap();

    let mut v: Vec<String> = Vec::with_capacity(n - 1);
    for _ in 0..n {
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).unwrap();
        v.push(s);
    }
    v.sort();
    let mut s = String::new();
    for i in 0..n {
        s += v[i].trim();
    }
    println!("{}", s);
}



Measured memory_bytes: 4352
#include <algorithm>
#include <cmath>
#include <deque>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <tuple>
#include <vector>

using namespace std;
typedef long long ll;

int main() {
  ll N;
  cin >> N;
  vector<ll> d(N);
  for (int i = 0; i < N; i++) {
    cin >> d[i];
  }
  ll ans = 0;
  for (int i = 0; i < N - 1; i++) {
    for (int j = i + 1; j < N; j++) ans += d[i] * d[j];
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ul;
typedef long long ll;

int main() {
  string S;
  cin >> S;
  if(S[S.length() - 1] == 's'){
    S += "es";
  }
  else{
    S += "s";
  }
  cout << S << endl;
}


Measured memory_bytes: 3624
N = int(input())
A = list(map(int, input().split()))

ans = 30
cnt = 0
for i in range(N):
    p = A[i]
    while p % 2 == 0 and cnt < ans:
        p = p / 2
        cnt += 1
    else:
        ans = cnt
        cnt = 0
print(ans)


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

int main() {
    ll X, Y, A, B, C; cin >> X >> Y >> A >> B >> C;
    vector<ll> va(A), vb(B), vc(C);
    for (int i = 0; i < A; i++) cin >> va[i];
    for (int i = 0; i < B; i++) cin >> vb[i];
    for (int i = 0; i < C; i++) cin >> vc[i];
    sort(va.begin(),va.end(), greater<ll>());
    sort(vb.begin(),vb.end(), greater<ll>());
    sort(vc.begin(),vc.end(), greater<ll>());
    vector<ll> v;
    v.insert(v.end(),va.begin(), va.begin()+X);
    v.insert(v.end(),vb.begin(), vb.begin()+Y);
    sort(v.begin(),v.end());

/*
    ll ok = -1;
    ll ng = min(vc.size(), v.size())+1;
    while(abs(ok-ng)>1){
        ll mid = (ok+ng)/2;
        if(v[mid]>vc[mid]) ng = mid;
        else ok = mid;  
    }
*/
    for (int i = 0, N=min(v.size(),vc.size()); i < N; i++)
    {
        if(v[i]<vc[i]) swap(v[i],vc[i]);
        else break;
    }
    
    cout << accumulate(v.begin(),v.end(),0LL) << endl;
}

Measured memory_bytes: 4736
import math
def sosu(n):
    if n == 1:
        return 1
    for k in range(2,int(math.floor(math.sqrt(n)))+1):
        if n%k == 0:
            return 1
    return 0
    
while True:
    n = int(input())
    
    if n == 0:
        break
    
    a = 0
    for i in range(n+1,2*n+1):
        if sosu(i) == 0:
            a += 1
    print(a)


Measured memory_bytes: 5664
N = int(input())
abc = [[int(j) for j in input().split()] for i in range(N)]
dp = [[0] * 3]
for day in range(N):
    dp += [[max([dp[-1][p] + abc[day][n] for p in range(3) if p != n]) for n in range(3)]]
print(max(dp[-1]))

Measured memory_bytes: 45664
n = int(input())
if 400<=n<=599:
    print("8")
if 600<=n<=799:
    print("7")
if 800<=n<=999:
    print("6")
if 1000<=n<=1199:
    print("5")
if 1200<=n<=1399:
    print("4")
if 1400<=n<=1599:
    print("3")
if 1600<=n<=1799:
    print("2")
if 1800<=n<=1999:
    print("1")

Measured memory_bytes: 9184
from math import ceil,floor,factorial,gcd,sqrt,log2,cos,sin,tan,acos,asin,atan,degrees,radians,pi,inf
from itertools import accumulate,groupby,permutations,combinations,product,combinations_with_replacement
from collections import deque,defaultdict,Counter
from bisect import bisect_left,bisect_right
from operator import itemgetter
from heapq import heapify,heappop,heappush
from queue import Queue,LifoQueue,PriorityQueue
from copy import deepcopy
from time import time
from functools import reduce
import string
import sys
sys.setrecursionlimit(10 ** 7)
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def MAP1()  : return map(lambda x:int(x)-1,input().split())
def LIST()  : return list(MAP())

def solve():
    H, W = MAP()
    a = [input() for _ in range(H)]
    d = defaultdict(int)

    for i in range(H):
        for j in range(W):
            d[a[i][j]] += 1
    
    mod4 = 0
    mod2 = 0
    for x in d.values():
        mod4 += x % 4
        mod2 += x % 2
    
    ans = "No"
    if H % 2 == 0:
        if W % 2 == 0:
            if mod4 == 0:
                ans = "Yes"
        else:
            if mod4 <= H and mod2 == 0:
                ans = "Yes"
    elif H % 2 == 1:
        if W % 2 == 0:
            if mod4 <= W and mod2 == 0:
                ans = "Yes"
        else:
            if mod4 <= W+H-1 and mod2 == 1:
                ans = "Yes"

    print(ans)

if __name__ == '__main__':
    solve()

Measured memory_bytes: 10312
#include <stdio.h>

int main(void)
{
	int n, i, f;
	int digitsdcount;
	int unevencount = 0;

	scanf("%d", &n);

	for (i = 0; i <= n; i++){
		digitsdcount = 0;
		f = i;
		//桁数を調べる
		while (f > 0) {
			f = f / 10;
			digitsdcount++;
		}
		//奇数ならカウント
		if (digitsdcount % 2 == 1) {
			unevencount++;
		}
	}

	printf("%d\n", unevencount);

	return 0;
}

Measured memory_bytes: 128
# coding: utf-8
# Your code here!

s = input()

if len(s) <= 1:
    print(0)
    exit()

n = len(s)
c = 0

base = s[0]

for i in range(1, n):

    if s[i] == base:
        c += 1
        if s[i] == '0':
            base = '1'
        else:
            base = '0'
        
        continue
    
    base = s[i]

print(c)


Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
///Welcome to Nasif's Code
#define bug printf("bug\n");
#define bug2(var) cout<<#var<<" "<<var<<endl;
#define co(q) cout<<q<<endl;
typedef long long int ll;
typedef unsigned long long int ull;
const int MOD = (int)1e9+7;
const int MAX = 1e6;
#define pi acos(-1)
#define inf 1000000000000000LL
#define FastRead    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int cost[500];
int main()
{
    FastRead
    //freopen("output.txt", "w", stdout);
    int n,m,p;
    cin>>n>>m>>p;
    for(int i=0; i<m; i++)
    {
        int a;
        cin>>a;
        cost[a]=1;
    }
    int x=0,y=0;
    for(int i=p;i>0;i--)
    {
        x+=cost[i];
    }
    for(int i=p;i<n;i++)
    {
        y+=cost[i];
    }
    cout<<min(x,y)<<endl;
    return 0;
}


Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define INF (int)1e9
#define EPS 1e-9
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef double ld;

int main() {
	// your code goes here
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.precision(20);
	long double a,b,h,m;
    cin >> a>>b>>h>>m;
    double rad = PI * 2 * (h/12.0 + m/(60.0*12) - m/60.0);
    std::cout << sqrt(a*a+b*b-2*a*b*cos(rad))<< "\n";
}


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

#define M 101
#define INF 100000003

#define min(a,b) (a<b?a:b)

int main() {
	int n, m, a, b, c, t, pn, p, q, r;
	int dc[M][M], dt[M][M];
	while(1) {
		cin >> n >> m;
		if(!n&&!m) break;
		for(int i=1; i<=m; ++i) {
			for(int j=1; j<=m; ++j) {
				dc[i][j] = dt[i][j] = INF;
			}
		}
		for(int i=0; i<n; ++i) {
			cin >> a >> b >> c >> t;
			dc[a][b] = dc[b][a] = c;
			dt[a][b] = dt[b][a] = t;
		}
		for(int k=1; k<=m; ++k) {
			for(int i=1; i<=m; ++i) {
				for(int j=1; j<=m; ++j) {
					dc[i][j] = min(dc[i][j], dc[i][k]+dc[k][j]);
					dt[i][j] = min(dt[i][j], dt[i][k]+dt[k][j]);
				}
			}
		}
		cin >> pn;
		for(int i=0; i<pn; ++i) {
			cin >> p >> q >> r;
			cout << (!r ? dc[p][q] : dt[p][q]) << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1240
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
/* ------------------------------------------------ */
ll fact(int i) {       //階乗
    if (i == 0) return 1;
    return (fact(i - 1)) * i;
}
ll gcm(ll a, ll b) {        //最大公約数
    if(b == 0) return a;
    return gcm(b, a % b); 
}
ll lcm(ll a, ll b) {      //最小公倍数
    return a * b / gcm(a, b);
}
int keta(ll n) {        //桁数を求める
    if(n == 0) return 1;
    int count = 0;
    while(n != 0) {
        n /= 10;
        count++;
    }
    return count;
}
ll ketasum(ll n) {    //各桁の和
    ll sum = 0;
    while(n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
/* ------------------------------------------------ */

int main() {
    vector<int> v(3);
    rep(i, 3) cin >> v[i];
    sort(v.begin(), v.end());
    int ans = 0;
    ans += (v[2] - v[1]) / 2;
    v[1] += ans * 2;
    ans += v[2] - v[1];
    v[0] += v[2] - v[1];
    v[1] = v[2];
    ans+= (v[2] - v[0]) / 2;
    v[0] += (v[2] - v[0]) / 2 * 2;
    if(v[0] == v[1] && v[1] == v[2]) cout << ans << endl;
    else cout << ans + 2 << endl;
    
}

Measured memory_bytes: 3564