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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> Pi;
typedef vector<ll> Vec;
typedef vector<int> Vi;
typedef vector<string> Vs;
typedef vector<vector<ll>> VV;
typedef vector<vector<int>> VVi;

#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
const ll INF=1e16+18;
const ll MAX=100005;
const ll MOD=1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;
#define ALL(v) v.begin(), v.end()
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a,b)
#define Each(a,b) for(auto &a :b)
#define REPM(i, mp) for (auto i = mp.begin(); i != mp.end(); ++i)
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define dbgmap(mp) cerr << #mp << ":"<<endl; for (auto i = mp.begin(); i != mp.end(); ++i) { cerr << i->first <<":"<<i->second << endl;}
#define dbgarr(n,m,arr) rep(i,n){rep(j,m){cerr<<arr[i][j]<<" ";}cerr<<endl;}
#define dbgdp(n,arr) rep(i,n){cerr<<arr[i]<<" ";}cerr<<endl;
#define sum(v) accumulate(ALL(v),0)
#define fi first
#define se second

template<typename T1, typename T2>
ostream &operator<<(ostream &s, const pair<T1, T2> &p) { return s<<"("<<p.first<<", "<<p.second<<")"; }

// vector
template<typename T>
ostream &operator<<(ostream &s, const vector<T> &v) {
    int len=v.size();
    for(int i=0; i<len; ++i) {
        s<<v[i];
        if(i<len-1) s<<"	";
    }
    return s;
}

// 2 dimentional vector
template<typename T>
ostream &operator<<(ostream &s, const vector<vector<T> > &vv) {
    int len=vv.size();
    for(int i=0; i<len; ++i) {
        s<<vv[i]<<endl;
    }
    return s;
}

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

    ll n;
    string a,b,c;
    cin>>n>>a>>b>>c;
    ll ans=0;

    rep(i,n){
        ll x = a[i]-'a';
        ll y = b[i]-'a';
        ll z = c[i]-'a';

        if(x==y && y==z){

        }else if(x==y||y==z||x==z){
            ans += 1;
        }else{
            ans += 2;
        }
    }
    cout<<ans<<endl;
    return  0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		String s = sc.next();
		sc.close();

		int mod = 998244353;
		long ans = 1;
		int r = 0;
		int g = 0;
		int b = 0;
		int rg = 0;
		int gb = 0;
		int br = 0;
		for (int i = 0; i < s.length(); i++) {
			char ch = s.charAt(i);
			if (ch == 'R') {
				if (gb > 0) {
					ans = ans * gb % mod;
					gb--;
				} else if (g > 0) {
					ans = ans * g % mod;
					g--;
					rg++;
				} else if (b > 0) {
					ans = ans * b % mod;
					b--;
					br++;
				} else {
					r++;
				}
			} else if (ch == 'G') {
				if (br > 0) {
					ans = ans * br % mod;
					br--;
				} else if (b > 0) {
					ans = ans * b % mod;
					b--;
					gb++;
				} else if (r > 0) {
					ans = ans * r % mod;
					r--;
					rg++;
				} else {
					g++;
				}
			} else {
				if (rg > 0) {
					ans = ans * rg % mod;
					rg--;
				} else if (r > 0) {
					ans = ans * r % mod;
					r--;
					br++;
				} else if (g > 0) {
					ans = ans * g % mod;
					g--;
					gb++;
				} else {
					b++;
				}
			}
		}

		long p = 1;
		for (int i = 2; i <= n; i++) {
			p = p * i % mod;
		}
		System.out.println(ans * p % mod);
	}
}


Measured memory_bytes: 29016
#include<bits/stdc++.h>
#define N 3
using namespace std;
typedef unsigned long long ull;
bool im[1010][1010],pa[110][110];
int w,h,p,ans;
vector<ull> used;

void ppp(){
 ull a=0;
 ull roll[1001][1001]={};
 for(int i=0;i<p;i++)
   for(int j=0;j<p;j++)a=a*N+pa[i][j];
 for(int i=0;i<used.size();i++)
   if(used[i]==a)return;
 used.push_back(a); 
 for(int j=0;j<h;j++){
   ull b=0,g=1;
   for(int i=0;i<p;i++)b=b*N+im[j][i],g*=N;
   roll[j][p-1]=b;
   for(int i=p;i<w;i++){
     b=b*N+im[j][i]-im[j][i-p]*g;
     roll[j][i]=b;
   }
 }
 for(int j=p-1;j<w;j++){
   ull b=0,g=1,n=1;
   for(int i=0;i<p;i++)n*=N;
   for(int i=0;i<p;i++)b=b*n+roll[i][j],g*=n;
   if(b==a)ans++;
   for(int i=p;i<h;i++){
     b=b*n+roll[i][j]-roll[i-p][j]*g; 
     if(b==a)ans++;
   }
 }
}

void ch(){
 bool npa[110][110];
 for(int i=0;i<p;i++)
   for(int j=0;j<p;j++)npa[i][j]=pa[j][p-i-1];
 for(int i=0;i<p;i++)
   for(int j=0;j<p;j++)pa[i][j]=npa[i][j];
}

void ch1(){
 for(int i=0;i<p;i++)
   for(int j=0;j<p/2;j++)swap(pa[i][j],pa[i][p-j-1]);
}

int main(){
 int D[256];
 for(int i='A';i<='Z';i++)D[i]=i-'A';
 for(int i='a';i<='z';i++)D[i]=i-'a'+26;
 for(int i='0';i<='9';i++)D[i]=i-'0'+52;
 D['+']=62,D['/']=63;
 while(cin>>w>>h>>p,w){
   string s;
   memset(im,0,sizeof(im));
   memset(pa,0,sizeof(pa));
   used.clear();
   for(int i=0;i<h;i++){
     cin>>s;
     for(int j=0;j<s.size();j++){
	int t=D[s[j]];
	int a=5;
	while(t){
	  im[i][j*6+a]=t%2;
	  t/=2,a--;
	}
     }
   }
   for(int i=0;i<p;i++){
     cin>>s;
     for(int j=0;j<s.size();j++){
	int t=D[s[j]];
	int a=5;
	while(t){
	  pa[i][j*6+a]=t%2;
	  t/=2,a--;
	}
     }
   }
   ans=0;
    for(int i=0;i<4;i++){
     ppp();
     ch1();
     ppp();
     ch1();
     ch();
   }
   cout<<ans<<endl;
 }

 return 0;
}

Measured memory_bytes: 10068
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll dp[5555][301];

struct Okashi{
  ll e;
  ll c;
};

void dbgprng(const vector<vector <Okashi> > &kind_of_okashi, ll s){
   for(ll j = 0; j < s; j++){
      for(ll i = 0; i < kind_of_okashi[j].size(); i++){
	cout << "eff=" << kind_of_okashi[j][i].e << " cost=" << kind_of_okashi[j][i].c << endl;
      }
      cout << "===" << endl;
    }
}

int main(void){
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll s, d, m;
  while(cin >> s >> d >> m){
    vector<Okashi> all_okashi;
    vector<vector< Okashi> > kind_of_okashi(s);
    for(ll i = 0; i < s; i++){
      ll k; cin >> k;
      vector<Okashi> tmp(k);
      for(ll j = 0; j < k; j++){
	ll w, p;
	cin >> w >> p;
	tmp[j].e = w;
	tmp[j].c = p;
      }
      kind_of_okashi[i] = tmp;
    }
    for(ll i = 0; i < d; i++){
      ll f; cin >> f;
      for(ll j = 0; j < kind_of_okashi[f].size(); j++){
	all_okashi.push_back(kind_of_okashi[f][j]);
      }
    }

    for(ll i = 0; i < 5555; i++) for(ll j = 0; j < 301; j++) dp[i][j] = 0;
    ll size = all_okashi.size();
    for(ll i = 0; i < size; i++){
      for(ll j = 0; j <= m; j++){
	if(j - all_okashi[i].c < 0){
	  dp[i+1][j] = dp[i][j];
	}else{
	  dp[i+1][j] = max(dp[i][j], dp[i][j - all_okashi[i].c] + all_okashi[i].e);
	}
      }
    }
    ll cost = 0;
    ll org = dp[size][m];
    for(ll i = m; i >= 0; i--){
      if(dp[size][i] != org){
	cost = i+1;
	break;
      }
    }
    cout << dp[size][m] << " " << cost << endl;
  }

  return 0;
}

Measured memory_bytes: 14416
// https://atcoder.jp/contests/abc063/tasks/arc075_b
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define FOR(i, a, b) for (int i = (a); i < (int)(b); ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
template <class T> void gc(T &x) {
    char c;
    int s = 0;
    x = 0;
    c = getchar_unlocked();
    if (c == '-')
        s = 1;
    else if ('0' <= c && c <= '9')
        x = c - '0';
    while (true) {
        c = getchar_unlocked();

        if (c < '0' || c > '9')
            break;
        x = x * 10 + (c - '0');
    }
    if (s)
        x = -x;
}
int n, a, b;
vector<int> v;
bool check(ll x) {
    ll c = 0;
    auto it = lower_bound(ALL(v), b * x);
    while (it != v.end()) {
        // 全体にbダメージ * x回
        ll h = *it - x * b;
        if (h > 0) {
            // a - b の追加ダメージ
            c += ceil((double)h / (a - b));
        }
        it++;
    }
    return c <= x;
}
int main() {
    gc(n), gc(a), gc(b);
    v.resize(n);
    REP(i, n) gc(v[i]);
    sort(ALL(v));
    int ng = 0, ok = v[n - 1] * 2;
    while (ng + 1 != ok) {
        int x = (ng + ok) / 2;
        if (check(x))
            ok = x;
        else
            ng = x;
    }
    cout << ok << endl;

    return 0;
}


Measured memory_bytes: 640
n = input()
if n[-1] == "2" or n[-1] == "4" or n[-1] == "5" or n[-1] == "7" or n[-1] == "9":
    print("hon")
elif n[-1] == "0" or n[-1] == "1" or n[-1] == "6" or n[-1] == "8":
    print("pon")
else:
    print("bon")

Measured memory_bytes: 9124
#include <bits/stdc++.h>
#include <unordered_map> 
using namespace std; 
#define FIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define PI1 3.14159265358979311599796346854418516159057617187500

typedef long long int ll;  
ll MOD = 1e9 + 7;

ll power(ll a , ll n)
{
    unsigned long long int result=1,x=a;
    while(n>0)
    {
        if(n % 2 ==1)
            result = (result * x)%MOD;
        x = (x * x)%MOD;
        n=n/2;
    }
    return result;
}

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

int main()
{
    FIO;
    int t;
    t=1;
    //cin >> t;
    while(t--)
    {
        int x;
        cin >> x;

        if(x>=400 && x<=599)
        {
            cout << "8" << endl;
            return 0;
        }
        if(x>=600 && x<=799)
        {
            cout << "7" << endl;
            return 0;
        }
        if(x>=800 && x<=999)
        {
            cout << "6" << endl;
            return 0;
        }
        if(x>=1000 && x<=1199)
        {
            cout << "5" << endl;
            return 0;
        }

        if(x>=1200 && x<=1399)
        {
            cout << "4" << endl;
            return 0;
        }
        if(x>=1400 && x<=1599)
        {
            cout << "3" << endl;
            return 0;
        }
        if(x>=1600 && x<=1799)
        {
            cout << "2" << endl;
            return 0;
        }
        if(x>=1800 && x<=1999)
        {
            cout << "1" << endl;
            return 0;
        }
    }   
    return 0;
}


Measured memory_bytes: 3648
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <queue>

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

using namespace std;

int main(){
    int n; cin >> n;
    long long count = 0;
    vector<long long> a(n);
    rep(i, n) cin >> a[i];
    rep(i, n) {
        while(a[i]%2 == 0){
            a[i] = a[i]/2;
            count++;
        }
    }
    cout << count << endl;
}



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

#define int long long int
#define endl '\n'
#define all(v) (v).begin(), (v).end()

void SolveTestCase()
{

	int n;
	cin >> n;
	
	vector < int > v(n);
	
	for(int &i : v)
		cin >> i;
	
	unordered_map < int, int > mp;
		
	sort(v.begin(), v.end());
	int cnt = 0;
	
	for(int i=0; i<n-2; i++)
	{
		for(int j=i+1; j<n-1; j++)
		{
			for(int k=j+1; k<n; k++)
			{
					if(v[i] != v[j] and v[j] != v[k] and v[i] != v[k])
						if(v[i]+v[j] > v[k]){
							cnt += 1;
							//break;
						}
			}
		}
	}
	
	cout << cnt << endl;
	
}

signed main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	
	SolveTestCase();
	
	return 0;
}


Measured memory_bytes: 3588
mycode = r'''
# distutils: language=c++
# cython: language_level=3, boundscheck=False, wraparound=False
# cython: cdivision=True
# False:Cython はCの型に対する除算・剰余演算子に関する仕様を、(被演算子間の符号が異なる場合の振る舞いが異なる)Pythonのintの仕様に合わせ、除算する数が0の場合にZeroDivisionErrorを送出します。この処理を行わせると、速度に 35% ぐらいのペナルティが生じます。 True:チェックを行いません。

ctypedef long long LL
from libc.stdio cimport scanf, printf

cdef LL a,b,c,_,i
cdef LL[3][3] C
for i in range(3):
    scanf('%lld %lld %lld', &C[i][0],&C[i][1],&C[i][2])

    
cdef LL a0,a1,a2,b0,b1,b2
cdef bint flg=0
for a0 in range(101):
    b0=C[0][0]-a0
    b1=C[0][1]-a0
    b2=C[0][2]-a0
    for a1 in range(101):
        for a2 in range(101):
            if b0 == C[1][0]-a1 and b1==C[1][1]-a1 and b2==C[1][2]-a1 and b0 == C[2][0]-a2 and b1==C[2][1]-a2 and b2==C[2][2]-a2:
                if flg==0:
                   printf("Yes")
                flg=1
if flg==0:
    printf('No')

'''

import sys
import os
if sys.argv[-1] == 'ONLINE_JUDGE':  # コンパイル時
    with open('mycode.pyx', 'w') as f:
        f.write(mycode)
    os.system('cythonize -i -3 -b mycode.pyx')

import mycode


Measured memory_bytes: 9056
#include <bits/stdc++.h>
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge {c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "



int main() {
	int n, a, b;
	cin >> n >> a >> b;
	int diff = (b - a);
	if(abs(diff) % 2 == 0) puts("Alice");
	else puts("Borys");
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <array>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <tuple>
#include <cmath>
#include <algorithm>
#include <functional>
#include <numeric>
#include <cfloat>
#include <climits>
#include <cassert>
#include <random>
#include <bitset>
#include <memory>

int main() {
	int n; std::cin >> n;
	std::vector<int> position(n); for (auto& x : position) std::cin >> x;
	int min_use = INT_MAX;
	for (auto p = 1; p <= 100; ++p) {
		int sum = 0;
		for (const auto x : position) {
			sum += (x - p) * (x - p);
		}
		min_use = std::min(min_use, sum);
	}
	std::cout << min_use << '\n';
}


Measured memory_bytes: 888
N = int(input())
import math


def get_sieve_of_eratosthenes(n):
    if not isinstance(n, int):
        raise TypeError('n is int type.')
    if n < 2:
        raise ValueError('n is more than 2')
    prime = []
    limit = math.sqrt(n)
    data = [i + 1 for i in range(1, n)]
    while True:
        p = data[0]
        if limit <= p:
            return prime + data
        prime.append(p)
        data = [e for e in data if e % p != 0]
        
A = get_sieve_of_eratosthenes(55555)

ans = []
for a in A:
    if a%5 == 1:
        ans.append(a)
        if len(ans) == N : break
print(*ans)
        
    

Measured memory_bytes: 5528
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

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

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

int main(int argc, const char * argv[]) {
    
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int N;
    cin >> N;
    
    vector<int> a(N);
    rep(i, N)
    {
        cin >> a[i];
    }
    
    vector<int> lcgcd(N), rcgcd(N); // cummulative gcd
    lcgcd[0] = a[0];
    for (int i = 1; i < N; ++i)
    {
        lcgcd[i] = GCD(lcgcd[i - 1], a[i]);
    }
    rcgcd[N-1] = a[N-1];
    for (int i = N-2; i >= 0; --i)
    {
        rcgcd[i] = GCD(rcgcd[i + 1], a[i]);
    }
    
    int max_gcd = 0;
    for (int i = 0; i < N; ++i)
    {
        int left  = i != 0   ? lcgcd[i - 1] : 0;
        int right = i != N-1 ? rcgcd[i + 1] : 0;
        max_gcd =  max(max_gcd, GCD(left, right));
    }
    
    
    cout << max_gcd << endl;
    
    return 0;
}

Measured memory_bytes: 1408
import  java.util.Scanner;

public class Main
{
	public static void main(String arg[])
	{
		Scanner sc = new Scanner(System.in);
		int count =0;

		while(sc.hasNext())
		{
			String str = sc.next();

			for(int i=0; i<str.length(); i++)
			{
				if(str.charAt(i)==str.charAt(str.length()-1-i))
				{
					if(str.length()-1-i<= i)
					{
						count++;
						break;
					}
					continue;
				}
				else
					break;
			}
		}
		System.out.println(count);

	}

}

Measured memory_bytes: 12000
int main(){
	int n, m=0, a, arry[100001]={0};

    scanf("%d",&n);
	for(int i=0; i<n; i++){
		scanf("%d", &a);
		arry[a-1]++;
		arry[a  ]++;
		arry[a+1]++;
		if( a+1 >= m ){ m = a+1; }
	}

  	int max=0;
	for(int i=0; i<m; i++){
		if( arry[i] >= max ){ max = arry[i]; }
	}
	printf("%d\n", max);
	return 0;
}

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

public class MainClass
{
	public const long Giri = 1000000007;
	public const long DpInf = 99999999999999;

	public static void Main(string[] args)
	{
		var p = Input().ToInt();
		
		if((p[0]*100+p[1]*10+p[2])%4==0)
		{
			Console.WriteLine("YES");
		}
		else
		{
			Console.WriteLine("NO");
		}
	}
	

	
	static long GCD(long a, long b)
	{
		var v = new[] { a, b };
		while (v[1] != 0) { v = new[] { v[1], v[0] % v[1] }; }
		return v[0];
	}
	public static string[] Input() { return Console.ReadLine().Split(); }
}

public static class Smarter
{
	public static int ToInt(this string str) { return int.Parse(str); }
	public static long ToLong(this string str) { return long.Parse(str); }
	public static int[] ToInt(this string[] str, int offset = 0)
	{
		var r = new int[str.Length];
		for(int i = 0; i < str.Length; i++) r[i] = str[i].ToInt() + offset;
		return r;
	}
}

Measured memory_bytes: 11092
#include<iostream>
#include<string>
#include<vector>
#include<queue>
#include<algorithm>
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;

int main() {
	string s;
	int a;
	cin >> s >> a;
	for (int i = 0; i < s.size(); i += a) {
		cout << s[i];
	}
	cout << endl;
}

Measured memory_bytes: 256
input()
T,A = map(int,input().split())
a = list(map(int,input().split()))
#最小値
min_val = 100000
min_num=0
for i in range(len(a)):
    d = abs(T-0.006*a[i]-A)
    if d < min_val:
        min_val = d
        min_num = i
print(min_num+1)

Measured memory_bytes: 3060
#include<iostream>
#include<math.h>
#define Pi 3.1415926535898
#define ANGLE (Pi/180.0)
using namespace std;

int main(){
	double x, y;
	int a, b;
	double angle;
	char kanma;
	cin >> a >> kanma >> b;
	angle = 0;
	while(a || b){
		x += a*sin(angle*ANGLE);
		y += a*cos(angle*ANGLE);
		angle += b;
		cin >> a >> kanma >> b;
	}
	cout << (int)(x) << endl;
	cout << (int)(y) << endl;
	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#define ll long long int
using namespace std;

int main(){
  int n; cin >> n;
  vector<int> A(n);
  int s;
  for(int i=0;i<n;i++){
    cin >> A[i];
  }
  for(int l=0;l<n;l++){
    s += A[l];
  }
  int soa,a; s = s/2;
  for(int j=1;j<n-1;j+=2){
   soa += A[j];
 }
  a= s-soa;
  cout << 2*a << " ";
  for(int k=0;k<n-1;k++){
    a = A[k]-a;
    cout <<2*a << " ";
  }
}


Measured memory_bytes: 1664
cook = list(map(int, [input() for _ in range(5)]))

def hun(n):
  if n % 10 == 0:
    return n//10*10
  else:
    return (n//10 + 1) * 10

a=10
ans=0
for x in cook:
  ans += hun(x)
  if x % 10 != 0:
    a = min(a, x % 10)

print(ans - 10 + a)

Measured memory_bytes: 3060
#include <cstdio>
#include <functional>
#include <vector>
#include <algorithm>

int main()
{
    char s[101];

    scanf("%s", s);
    bool good_step = true;
    for (int i = 0; good_step && (i < sizeof(s)); ++i)
    {
        if (i % 2 != 0)
        {
            good_step = (s[i] != 'R');
        }
        else
        {
            good_step = (s[i] != 'L');
        }

        if (s[i+1] == '\0')
        {
            break;
        }
    }
    // Output
    printf("%s\n", good_step ? "Yes" : "No");
    return 0;
}


Measured memory_bytes: 128
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <sstream>
#include <cassert>
#include <list>
using namespace std;
static const double EPS = 1e-5;
typedef long long ll;
typedef pair<int,int> PI;
typedef vector<int> vi;
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define F first
#define S second


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

main(){
  int n;
  while(cin>>n,n){
    int grid[n][n],tate[n][n],yoko[n][n],lurd[n][n],ruld[n][n];
    char c;
    rep(i,n)rep(j,n){
      cin>>c;
      tate[i][j]=yoko[i][j]=lurd[i][j]=ruld[i][j]=grid[i][j]=c-'0';
    }
    

    int ans=0;
    rep(i,n){
      rep(j,n){
	if(grid[i][j]==0)continue;
	if(i&&j+1<n&&ruld[i-1][j+1])ruld[i][j]=max(ruld[i][j],ruld[i-1][j+1]+1);
	if(i&&tate[i-1][j])tate[i][j]=max(tate[i][j],tate[i-1][j]+1);
	if(i&&j&&lurd[i-1][j-1])lurd[i][j]=max(lurd[i][j],lurd[i-1][j-1]+1);
	if(j&&yoko[i][j-1])yoko[i][j]=max(yoko[i][j],yoko[i][j-1]+1);
	ans=max(ans,max(tate[i][j],max(yoko[i][j],max(lurd[i][j],ruld[i][j]))));
      }
    }
    rep(i,n){
      rep(j,n){
	//	printf("%2d",grid[i][j]);
      }
      //      cout<<endl;
    }
    cout<<ans<<endl;
  }
}

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

struct input {
    int n;
    input() {}
    input(int n) : n(n) { };
    template <class T> operator T() {
        T ret; cin >> ret; return ret;
    }
    template <class T> operator vector<T>() {
        vector<T> ret(n);
        for(int i=0; i<n; i++) cin>>ret[i];
        return ret;
    }
};

int main() {
    int N = input();
    vector<vector<int>> G(N);
    vector<pair<int, int>> edge;
    map<pair<int, int>, int> mp;
    
    for (int i = 0; i < N-1; i++) {
        int a = input(), b = input(); a--; b--;
        G[a].push_back(b); G[b].push_back(a);
        edge.emplace_back(a, b);
    }
    
    int K = 0;
    vector<int> used(N, 0); used[0] = 1;
    vector<int> cs(N, 0);
    queue<int> que; que.push(0);
    while (!que.empty()) {
        int now = que.front(); que.pop();
        if (K < G[now].size()) K = G[now].size();
        int cur = 1;
        for (auto v : G[now]) {
            if (used[v]) continue;
            if (cur == cs[now]) cur++;
            cs[v] = mp[make_pair(now, v)] = mp[make_pair(v, now)] = cur++;
            used[v] = 1;
            que.emplace(v);
        }
    }
    
    cout << K << endl;
    for (auto p : edge) cout << mp[p] << endl;
    return 0;
}

Measured memory_bytes: 20084
#include<stdio.h>
#include<string.h>
int A[2000000];
int cnt=0;
void insert(int i){
  int a;
  int tmp;
  cnt++;
  A[cnt] = i;
  a = cnt;
  while(a){
    if(A[a/2] < A[a]){
      //printf("a%d %d %d\n",a/2,A[a/2],A[a]);
      tmp = A[a];
      A[a] = A[a/2];
      A[a/2] = tmp;
      a/=2;
    }
    else break;
  }
}
void maxHeapify(int i){
  int l = i*2;
  int r = l+1;
  int largest;
  int tmp;
  if(l<=cnt && A[l]>A[i]){
    largest = l;
  }
  else largest = i;
  if(r<=cnt && A[r]>A[largest]){
    largest = r;
  }

  if(largest !=i){
    tmp = A[i];
    A[i] = A[largest];
    A[largest] = tmp;
    maxHeapify(largest);
  }
}
void extract(void){
  int tmp=A[1];
  printf("%d\n",tmp);
  A[1] = A[cnt];
  A[cnt--] = tmp;
  maxHeapify(1);
}
int main(){
  int i;
  char str[20];
  A[0]=1000000000;
  while(1){
    scanf("%s",str);
    if(!strcmp(str,"end")) break;
    if(str[0]=='i'){
      scanf("%d",&i);
      insert(i);
    }
    if(str[0]=='e'){
      extract();
    }
  }
  return 0;
}



Measured memory_bytes: 5604
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
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 ll INF=1LL<<60;
const int inf=1<<30;
const int mod=1e9+7;
const int MOD=998244353;
int gcd(int a,int b){
    return (b?gcd(b,a%b):a);
}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,k;cin >> n >> k;
    vector<int> a(n);
    int mx=0;
    for(int i=0;i<n;i++){
        cin >> a[i];
        chmax(mx,a[i]);
    }
    int g=0;
    for(int i=0;i<n;i++){
        g=gcd(g,a[i]);
    }
    if(k<=mx&&k%g==0){
        cout << "POSSIBLE" << endl;
    }
    else{
        cout << "IMPOSSIBLE" << endl;
    }
}

Measured memory_bytes: 640
#include<stdio.h>
int main(void){
    int oturi,n,ans,coin[6]={500,100,50,10,5,1},i,j;
    while(1){
        scanf("%d",&n);
        if(n==0)break;
        ans=0;
        oturi=1000-n;
        for(i=0;i<6;i++){
            ans+=oturi/coin[i];
            oturi=oturi%coin[i];
        }
        printf("%d\n",ans);
    }
    return 0;
}

Measured memory_bytes: 600
#include<iostream>
#include<algorithm>
#include<utility>
#include<vector>
#include<cmath>
using namespace std;

typedef pair<int, int> P;
typedef long long ll;
const int INF = 100000000;

ll gcd( ll a, ll b ){//最大公約数
    ll tmp;
    if( a < b ) { tmp = a; a = b; b = tmp; }
    if( b < 1 ) return -1;

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

ll lcm(ll a, ll b){//最小公倍数
    return a * b / gcd(a, b);
}


//入力
int main(){

    string s;
    cin >> s;

    int ans = 0;

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

    cout << ans << endl;


    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{

    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);

        // input
        final int NUM = scan.nextInt();
        int[] dp = new int[NUM+1];
        boolean[] broken = new boolean[NUM+1];
        int brokenNum = scan.nextInt();
        for(int i = 0; i < brokenNum; i++){
            broken[scan.nextInt()] = true;
        }

        // search
        dp[0] = 1;
        for(int i = 1; i <= NUM; i++){
            if(broken[i]){
               dp[i] = 0;
            } else {
                if(i == 1){
                    dp[i] = 1;
                } else {
                    dp[i] = dp[i - 1] % 1000000007+ dp[i - 2] % 1000000007;
                }
            }
        }

        // answer
        System.out.println(dp[NUM] % 1000000007);

    }
}

Measured memory_bytes: 47896
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws IOException {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskX solver = new TaskX();
		solver.solve(1, in, out);
		out.close();
	}

	static int INF = 1 << 30;
	static int MOD = 1000000007;
	static int[] mh4 = { 0, -1, 1, 0 };
	static int[] mw4 = { -1, 0, 0, 1 };
	static int[] mh8 = { -1, -1, -1, 0, 0, 1, 1, 1 };
	static int[] mw8 = { -1, 0, 1, -1, 1, -1, 0, 1 };

	static class TaskX {

		public void solve(int testNumber, InputReader in, PrintWriter out) {

			int n = in.nextInt();

			int count = 0;
			while (n > 0) {
				n /= 2;
				count++;
			}
			out.println((int)Math.pow(2, count-1));
		}
	}

	static class InputReader {
		BufferedReader in;
		StringTokenizer tok;

		public String nextString() {
			while (!tok.hasMoreTokens()) {
				try {
					tok = new StringTokenizer(in.readLine(), " ");
				} catch (IOException e) {
					throw new InputMismatchException();
				}
			}
			return tok.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(nextString());
		}

		public long nextLong() {
			return Long.parseLong(nextString());
		}

		public double nextDouble() {
			return Double.parseDouble(nextString());
		}

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

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

		public InputReader(InputStream inputStream) {
			in = new BufferedReader(new InputStreamReader(inputStream));
			tok = new StringTokenizer("");
		}
	}

}


Measured memory_bytes: 21332
#include <iostream>
#include <vector>

using namespace std;

class Solution {
public:
	/* time: O(n), space: O(1) */
	int maximalValue(const vector<int>& B) {
		const int n = B.size() + 1;
		int ans = 0;
		for (int i = 0; i < n; ++i) {
			if (i == 0)
				ans += B[i];
			else if (i == n - 1)
				ans += B[i - 1];
			else
				ans += min(B[i - 1], B[i]);
		}
		return ans;
	}
};

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

	vector<int> B(n - 1);
	for (int i = 0; i < n - 1; ++i)
		cin >> B[i];

	Solution sol;
	int ans = sol.maximalValue(B);
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
import math
import sys
from decimal import *

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

#left = 4 * a * b;
#right = (c - a - b) * (c - a - b)

getcontext().prec = 500

da = Decimal(a)
db = Decimal(b)
dc = Decimal(c)

left = da.sqrt() + db.sqrt()
right = dc.sqrt()

if left < right:
    print("Yes")
else:
    print("No")   

Measured memory_bytes: 60140
#include <cstdio>
using namespace std;
const int mod = 1e9 + 7;
int n, a, b;
int power(int x, int y) {
	int ret = 1;
	while (y) {
		if (y & 1) ret = 1ll * ret * x % mod;
		x = 1ll * x * x % mod;
		y >>= 1;
	}
	return ret;
}
int inv(int num) {
	int base = num, ci = mod - 2, ret = 1;
	while (ci) {
		if (ci & 1) ret = 1ll * ret * base % mod;
		base = 1ll * base * base % mod;
		ci >>= 1;
	}
	return ret;
}
int C(int down, int up) {
	int pro1 = 1, pro2 = 1;
	for (int i = down; i >= down - up + 1; --i)
		pro1 = 1ll * pro1 * i % mod;
	for (int i = 1; i <= up; ++i)
		pro2 = 1ll * pro2 * i % mod;
	return 1ll * pro1 * inv(pro2) % mod;
}
int Add(int fir, int sec) {
	return (fir + sec) % mod;
}
int main() {
	scanf("%d%d%d", &n, &a, &b);
//	printf("%d\n", fac());
	printf("%d\n", Add(power(2, n), Add(mod - Add(C(n, a), C(n, b)), mod - 1)));
	return 0;
}


Measured memory_bytes: 128
N = int(input())
s = [input() for i in range(N)]
M = int(input())
t = [input() for i in range(M)]
score = []
for i in range(N):
  score.append(s.count(s[i]) - t.count(s[i]))
if max(score) > 0:
  print(max(score))
else:
  print(0)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pii pair<int,int>
#define pll pair<long long,long long>
#define pb push_back
#define vc vector
void read(vector<int>& arr){
    for(int i=0;i<arr.size();i++)
        cin>>arr[i];
}
void solve(){
    int x;
    cin>>x;
    cout<<(x+1)%2;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t=1;
    // cin>>t;
    while(t--){
        solve();
    }
    return 0;
}

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

const int INF = 1001001001;
int dp[1000005][2];

void Main() {
  string s;
  cin >> s;
  reverse(s.begin(), s.end());
  s += '0';
  int n = s.size();
  for (int i = 0; i < n + 1; i++) {
    for (int j = 0; j < 2; j++) {
      dp[i][j] = INF;
    }
  }
  dp[0][0] = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 2; j++) {
      int x = s[i] - '0';
      x += j;
      for (int a = 0; a < 10; a++) {
        int ni = i + 1, nj = 0;
        int b = a - x;
        if (b < 0) {
          nj = 1;
          b += 10;
        }
        dp[ni][nj] = min(dp[ni][nj], dp[i][j] + a + b);
      }
    }
  }
  cout << dp[n][0] << endl;
}

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  Main();
  return 0;
}


Measured memory_bytes: 9116
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

// (行き先,容量,逆辺)
struct edge{ int to,cap,rev; };

const int MAX_V = 1000; // TODO:initialize
const int F_INF = 1234567; // TODO:initialize
vector<edge> G[MAX_V];
int level[MAX_V]; // sからの距離
int iter[MAX_V]; // どこまで調べ終わったか

void add_edge(int from, int to, int cap){
    G[from].pb({to,cap,(int)G[to].size()});
    G[to].pb({from,0,(int)G[from].size()-1});
}

void dinic_bfs(int s){
    memset(level,-1,sizeof(level));
    queue<int> que;
    level[s]=0;
    que.push(s);
    while(!que.empty()){
        int v = que.front();
        que.pop();
        rep(i,G[v].size()){
            edge &e = G[v][i];
            if(e.cap>0 && level[e.to]<0){
                level[e.to] = level[v]+1;
                que.push(e.to);
            }
        }
    }
}

// 増加パスをdfsで探す
int dinic_dfs(int v, int t, int f){
    if(v==t) return f;
    for(int &i=iter[v]; i<(int)G[v].size(); ++i){
        edge &e=G[v][i];
        if(e.cap>0 && level[v]<level[e.to]){
            int d = dinic_dfs(e.to,t,min(f,e.cap));
            if(d>0){
                e.cap -= d;
                G[e.to][e.rev].cap += d;
                return d;
            }
        }
    }
    return 0;
}

// sからtへの最大流
int max_flow(int s, int t){
    int flow = 0;
    while(1){
        dinic_bfs(s);
        if(level[t]<0) return flow;
        memset(iter,0,sizeof(iter));
        int f;
        while((f=dinic_dfs(s,t,F_INF))>0) flow+=f;
    }
}


bool vs[MAX_V],vt[MAX_V];
void dfs_s(int x){
    vs[x] = true;
    for(const auto &e:G[x]){
        if(e.cap>0 && !vs[e.to]) dfs_s(e.to);
    }
}
void dfs_t(int x){
    vt[x] = true;
    for(const auto &e:G[x]){
        if(e.cap==0 && !vt[e.to]) dfs_t(e.to);
    }
}

int main(){
    int n,m,s,t;
    while(scanf(" %d %d %d %d", &n, &m, &s, &t),n){
        rep(i,MAX_V) G[i].clear();
        fill(vs,vs+MAX_V,false);
        fill(vt,vt+MAX_V,false);

        --s;
        --t;

        vector<int> a(m),b(m);
        rep(i,m){
            scanf(" %d %d", &a[i], &b[i]);
            --a[i];
            --b[i];
            add_edge(a[i],b[i],1);
        }

        int f = max_flow(s,t);

        dfs_s(s);
        dfs_t(t);

        int num = 0;
        rep(i,m){
            if(vs[b[i]] && vt[a[i]]) ++num;
        }
        if(num) ++f;

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



Measured memory_bytes: 3764
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <math.h>
#include <iomanip>
using namespace std;

long long ab[1000010];
long long abc[3000010];


int main() {
  int x, y, z, k;
  long long a[1010], b[1010], c[1010];

  cin >> x >> y >> z >> k;
  for (int i = 0; i < x; i++) {
    cin >> a[i];
  }
  for (int i = 0; i < y; i++) {
    cin >> b[i];
  }
  for (int i = 0; i < z; i++) {
    cin >> c[i];
  }

  int cnt = 0;
  for (int i = 0; i < x; i++) {
    for (int j = 0; j < y; j++) {
      ab[cnt] = a[i] + b[j];
      cnt++;
    }
  }
  sort(ab, end(ab));
  reverse(ab, end(ab));

  cnt = 0;
  for (int i = 0; i < min(3000, min(k, x*y)); i++) {
    for (int j = 0; j < min(k, z); j++) {
      abc[cnt] = ab[i] + c[j];
      cnt++;
    }
  }
  sort(abc, end(abc));
  reverse(abc, end(abc));

  for (int i = 0; i < k; i++) {
    cout << abc[i] << endl;
  }
}


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

#pragma region template


// -type-
using ll = long long;
using pll = pair<ll, ll>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vs = vector<string>;


// -const-
const ll MOD = 1000000007;


const ll MAX = (ll)0x3f0000003f000000;
const double EPS = 1e-9;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1},
          dy[] = {1, 0, -1, 0, 1, -1, -1, 1};


// -define-
#define F first
#define S second

#define reps(i, k, n) for (int i = (k), i##_len = (n); i < i##_len; ++i)
#define rep(i, n) reps(i, 0, n)
#define all(o) begin(o), end(o)
#define sz(a) ((int)(a).size())
#define debug(x) cerr << x << " (L:" << __LINE__ << ")" << '\n';


// -functions-

inline bool in(string s, string c) {
    return (s.find(c) != string::npos);
}
inline bool in(string s, char c) {
    return (s.find(c) != string::npos);
}

template <class T>
void print(T& x) {
    cout << x << '\n';
}

struct setup_main {
    setup_main() {
        cin.tie(0);
        ios::sync_with_stdio(0);
        cout << fixed << setprecision(15);
    }
} setup_main_;

#pragma endregion

ll m = 0;
unordered_map<string, int> dic{};
vs ans(0, "");
void solve(long long N, std::vector<std::string> S) {
    for (auto&& str : S) {
        dic[str]++;
    }
    for (auto i : dic) {
        // print(i.first);
        if (i.second > m) {
            ans = {};
            m = i.second;
        }
        if (i.second >= m) {
            ans.push_back(i.first);
        }
    }
    sort(all(ans));
    for (auto& ss : ans) {
        print(ss);
    }
}
signed main() {
    long long N;
    cin >> N;
    std::vector<std::string> S(N);
    for (int i = 0; i < N; i++) {
        std::cin >> S[i];
    }
    solve(N, std::move(S));

    return 0;
}


Measured memory_bytes: 26948
#include <cmath>
#include <cstdio>
#include <algorithm>
#define rg register
#define llint long long
using namespace std;

struct ios{
	template <typename _tp>
	inline ios operator >> (_tp &x){
		char c = getchar();int f = 1;
		for(;c<'0'||c>'9';c=getchar()) if(c=='-') f = -1;
		for(;c>='0'&&c<='9';c=getchar()) x = (x<<1)+(x<<3)+(c^48);
		x *= f;
		return *this;
	}
	template <typename _tp>
	inline ios operator << (_tp x){
		char s[66];int dgt = 0;
		if(x==0) putchar('0');
		if(x<0) putchar('-'),x = -x;
		while(x)
			++dgt,s[dgt] = x%10+'0',x /= 10;
		while(dgt)
			putchar(s[dgt]),--dgt;
		return *this; 
	}
}io;

int a,b,c;

int main()
{
	io >> a >> b >> c;
	int qwq = a-b;
	c = max(c-qwq,0);
	io << c;
	return 0;
}

Measured memory_bytes: 128
s = input()
n = len(s)
dp = [[0]*13 for i in range(n+5)]
dp[0][0] = 1
mod = 10**9+7
for i in range(n):
	    for j in range(13):
	    	    if s[i] != '?':
	    	    	    x = int(s[i])
	    	    	    ni = i+1
	    	    	    nj = (j*10+x)%13
	    	    	    dp[ni][nj] += dp[i][j]
	    	    	    dp[ni][nj]%= mod
	    	    	    continue
	    	    for d in range(10):
	    	    	    ni = i+1
	    	    	    nj = (j*10+d)%13
	    	    	    dp[ni][nj] += dp[i][j]
	    	    	    dp[ni][nj]%= mod
print(dp[n][5])

Measured memory_bytes: 61916
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		System.out.println(lcm(2,n));

	}

	public static long gcd(long x, long y) {
		long temp;
		while (x % y != 0) {
			temp = y;
			y = x % y;
			x = temp;
		}
		return y;
	}

	public static long lcm(long x, long y) {
		return (x*y)/gcd(x,y);
	}
}

Measured memory_bytes: 21844
from collections import defaultdict
n = int(input())
paper = defaultdict(lambda : 0)
for _ in range(n):
    a = int(input())
    if paper[a] == 0:
        paper[a] = 1
    else:
        paper[a] =0
total = 0
for i in paper.values():
    if i > 0:
        total += 1
print(total)

Measured memory_bytes: 15460
a,b = map(int,input().split())

space = [0 for i in range(100*100)]
#半分で塗り分け 白0、黒1
for i in range(len(space)):
    if i >= 5000:
        space[i] = 1

while(True):
    for i in range(0,5000,6):
        if a > 1:
            space[i] = 1
            a -= 1
        else:
            break

    for j in range(5000,10000,6)[::-1]:
        if b > 1:
            space[j] = 0
            b -= 1
        else:
            break

    if a == 1 and b == 1:
        break

ans = ""

for (i,cell) in enumerate(space):
    if i % (100*(i//100)+99) == 0 and i != 0:
        if cell == 0:
            ans = ans + "#\n"
        else:
            ans = ans + ".\n"
    else:
        if cell == 0:
            ans = ans + "#"
        else:
            ans = ans + "."
print(100,100)
print(ans)


Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
#define N 100010
int n,m,a,b,c[N],d[N];
int main(){
    scanf("%d%d",&n,&m);
    for(int i=0;i<=n;i++)c[i]=n+1,d[i]=0;
    while(m--){
	scanf("%d%d",&a,&b);
	c[a]=min(c[a],b);
    }
    for(int i=0;i<=n;i++){
	d[i+1]=max(d[i+1],d[i]);
	d[c[i]]=max(d[c[i]],d[i]+1);
    }
    printf("%d",d[n]);
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <math.h>
#include <vector>
#include <map>
#include <queue>
#include <utility>
#include <algorithm>
#include <string>
#include <set>
#include <random>
using namespace std;

int main() {
  string S;
  cin >> S;
  long long ans = 0;
  long long b   = 0;
  for (int i = 0; i < S.length(); i++) {
	  if (S[i] == 'B') {
		  b++;
		}
	  else {
		  ans += b;
		}
	}
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 640
#include<cstdio>
#include<cstring>
#include<algorithm>
#define N 210
#define ll long long
#define mod 998244353
using namespace std;

struct data{int x, y;}b[N];
struct line{data a, b;}a[20010];
int n, l, ans;

inline data operator-(data a, data b){data x; x.x=a.x-b.x; x.y=a.y-b.y; return x;}
inline int operator*(data a, data b){return a.x*b.y-a.y*b.x;}

inline bool cmp(line A, line B){
	int x1=(A.b.y-A.a.y)*(B.b.x-B.a.x), x2=(B.b.y-B.a.y)*(A.b.x-A.a.x);
	if(x1!=x2)return x1<x2;
	return (A.a-B.a)*(A.b-B.a)<0;
}

inline int in(line A, data P){return (A.a-P)*(A.b-P)==0?1:0;}

inline void solve(line A){
	int sum=0, s;
	for(int i=1; i<=n; i++)if(in(A, b[i]))sum++;
	s=1; for(int i=1; i<=sum; i++)s=s*2%mod;
	s=(s-1-sum-sum*(sum-1)/2+mod)%mod;
	ans=(ans-s+mod)%mod;
}

int main(){
	scanf("%d", &n);
	for(int i=1; i<=n; i++)scanf("%d%d", &b[i].x, &b[i].y);
	l=0;
	for(int i=1; i<=n; i++)
		for(int j=i+1; j<=n; j++){
			l++; a[l].a=b[i]; a[l].b=b[j];
		}
	for(int i=1; i<=l; i++){
		if(a[i].a.x==a[i].b.x&&a[i].a.y>a[i].b.y)swap(a[i].a, a[i].b);
		if(a[i].a.x>a[i].b.x)swap(a[i].a, a[i].b);
	}
	sort(a+1, a+1+l, cmp);
	ans=1; for(int i=1; i<=n; i++)ans=ans*2%mod;
	ans=(ans-1-n-n*(n-1)/2+mod)%mod;
	solve(a[1]);
	for(int i=2; i<=l; i++)if(!in(a[i-1], a[i].a)||!in(a[i-1], a[i].b))solve(a[i]);
	printf("%d", ans);
	return 0;
}

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

ll N, K;


int main(){
	cin >> N >> K;
	vector<int> A(N+1);
	vector<int> last_visit_step(N+1);
	
	for ( int i = 1; i <= N; i++ ){
		cin >> A[i];
	}
	
	int pos = 1;
	for ( int step = 1; step <= K; step++ ){
		pos = A[pos];
		if ( last_visit_step[pos] ){
			ll period = step - last_visit_step[pos];
			K -= ((K-step)/period)*period;
		}
		last_visit_step[pos] = step;
	}
	
	cout << pos << endl;
	
	return 0;
}



Measured memory_bytes: 4852
import sys
sys.setrecursionlimit(500000)
input = sys.stdin.readline

N, Q = map(int, input().split())
G = [set() for _ in range(N)]
cnt = [0]*N
visited = [0]*N

for _ in range(N-1):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    G[a].add(b)
    G[b].add(a)

for i in range(Q):
    it = map(int, input().split())
    p = next(it) - 1
    x = next(it)
    cnt[p] += x

visited[0]=1
st = [0]
while st:
    v = st.pop()
    for u in G[v]:
        if visited[u]:
            continue
        visited[u] = 1
        cnt[u] += cnt[v]
        st.append(u)    

print(*cnt)


Measured memory_bytes: 80540
// general helpers
const debug = (message?: any, ...optionalParams: any[]) => {
  if (process.env.LOCAL_DEBUG === '1') console.log(message, ...optionalParams)
}

// helpers
const parseLines = (
  lines: string[]
): any => {
  let tmp = ``
  const N = lines[0]
  const Hn = lines[1].split(` `).map(H => +H)
  const obj = { N, Hn }
  debug(obj)
  return obj
}

// solver
export const solve = (lines: string[]): string => {
  const { N, Hn } = parseLines(lines)

  let pos = 0
  let tmp = 0
  for(let i = 0; i < N; i++) {
    if (Hn[i + 1] && Hn[i] >= Hn[i + 1]) {
      tmp++
    } else {
      if (pos < tmp) {
        pos = tmp
      }
      tmp = 0
    }
  }
  return `${pos}`
}

// main
const main = (lines: string[]) => {
  console.log(solve(lines))
}

// exec main function for submit
if (process.env.LOCAL_DEBUG !== '1') {
  const { stdin: input, stdout: output } = process
  input.resume()
  input.setEncoding('utf8')
  const lines: string[] = []
  require('readline')
    .createInterface({ input, output })
    .on('line', (line: string) => lines.push(line))
    .on('close', () => main(lines))
}

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

#define fi first
#define se second
#define pb push_back
#define int long long
#define all(x) (x).begin(), (x).end()

using LL = long long;
using LD = long double;
using pii = pair<int, int>;
using vii = vector<pii>;

const int INF = 1e18;
const int MOD = 1e9 + 7;
const int N = 1e5 + 5;

__int128_t p(__int128_t x) {
    return x*x*x*x*x;
}

int32_t main() {
    //ios::sync_with_stdio(false); cin.tie(nullptr);
    int x;
    cin >> x;
    for (int a = -4000; a <= 4000; a++) {
        for (int b = -4000; b <= 4000; b++) {
            if (p(a) - p(b) == (__int128_t) x) {
                cout << a << " " << b << "\n";
                return 0;
            }
        }
    }
}


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

typedef int i ;
typedef double d ;
typedef string s ;

int main ()
{
    i num1 , num2 , num3 , sumA[3] ;
    cin >> num1 >> num2 >> num3 ;

    sumA[0] = num1 + num2 ;
    sumA[1] = num2 + num3 ;
    sumA[2] = num1 + num3 ;
    sort (sumA + 0 , sumA + 3) ;

    cout << sumA[0] << endl ;
    //its_Rashid
    return 0 ;
}



Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        A solver = new A();
        solver.solve(1, in, out);
        out.close();
    }

    static class A {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 入力
            String S = in.next();
            int ans = 0;
            for (int i = 0; i < 6; i++) {
                if (S.charAt(i) == '1') ans++;
            }

            // 出力
            out.println(ans);

        }

    }
}



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

#define pb         push_back

typedef long long ll;
const ll INF = 1000000000ll;
const ll MOD = 1000000007ll;
const double EPS = 1e-8;

int main(void) {
	//ios_base::sync_with_stdio(false);
	//cin.tie(0);
	
	int h, w;
	cin >> h >> w;
	for(int i=0; i<h; i++){
		for(int j=0; j<w; j++){
			string s;
			cin >> s;
			if(s == "snuke"){
				printf("%c%d\n", 'A' + j, i+1);
				return 0;
			}
		}
	}


	return 0;
}


Measured memory_bytes: 764
//https://atcoder.jp/contests/abc053/tasks/arc068_b
#include <bits/stdc++.h>
using namespace std;
using ll=int64_t;
#define FOR(i,a,b) for(int64_t i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
int main() {
#if LOCAL&01
    std::ifstream in("./test/sample-1.in"); //input.txt
    std::cin.rdbuf(in.rdbuf());
#endif
    ll N; cin>>N;
    vector<ll> an(N);
    for(auto&& a:an){
        cin>>a;
    }
    sort(an.begin(),an.end());
    ll l=0, r=an.size()-1;
    auto check_idx = [&](ll v){
        return (v>=0 && v < an.size());
    };
    auto func_step = [&](ll &v,ll di){
        while(true){
			auto v0 = v;
			auto v1 = v + di;
            if (!check_idx(v0) || !check_idx(v1)) return;
			if(an.at(v0) == an.at(v1)) {
				return; //同じだったら戻る
			}
            v=v1;
		}
    };
    ll ans=0;
    while(true){
        // lrを移動
        func_step(l,1);
        func_step(r,-1);
        if (l>=r) break;
        if (r-l==1) {ans+=2;break;}
        ans+=2;
        ++l;
        --r;
        if (l>=r) break;
    }
    cout<<(an.size()-ans)<<endl;
    return 0;
}

Measured memory_bytes: 1024