akhauriyash/Code-Regression huggingface dataset:
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.*;
import java.util.Calendar.Builder;



public class Main {
	static int INF = 2 << 27;
	static int N;
	static int M;
	static int A;
	static int B;
	static int C;
	static int T;
	static long[][] dp;
	public static void main(String[] args) {	
		//FastScanner sc = new FastScanner();
		Scanner sc = new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
		while(true) {
			int a = sc.nextInt();
			int b = sc.nextInt();
			int d = sc.nextInt();
			if(a == 0 && b == 0 && d == 0) break;
			int minWeight = INF;
			int minNumber = INF;
			int ansX = -1;
			int ansY = -1;
			for(int i = 0; i <= 50000; i++) {
				for(int j = 0; j < 50000; j++) {
					if(i + j > minNumber) break;
					if(a * i + b * j > minWeight) break;
					if(a * i + b * j > d && a * i < b * j && b * j - a * i > d) break;
					if(Math.abs(a * i - b * j) == d || (a * i + b * j) == d) {
						minWeight = a * i + b * j;
						minNumber = i + j;
						ansX = i;
						ansY = j;
					}
				}
			}
			System.out.println(ansX + " " + ansY);
		}
	}
}

Measured memory_bytes: 27740
N, K, S = map(int, input().split())

if S < 10 ** 9:
    ans = [str(S)] * K
    ans.extend([str(S + 1)] * (N - K))
else:
    ans = [str(S)] * K
    ans.extend([str(1)] * (N - K))

print(' '.join(ans))


Measured memory_bytes: 7028
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <functional>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <numeric>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cctype>
#include <cassert>
#include <sstream>

#define rep(i, a) REP(i, 0, a)
#define REP(i, a, b) for(int i = a; i < b; ++i)
#define rrep(i, a) RREP(i, a, 0)
#define RREP(i, a, b) for(int i = a; i >= b; --i)
#define repll(i, a) REPLL(i, 0, a)
#define REPLL(i, a, b) for(ll i = a; i < b; ++i)
#define rrepll(i, a) RREPLL(i, a, 0)
#define RREPLL(i, a, b) for(ll i = a; i >= b; --i)

typedef long long ll;
typedef unsigned long long ull;
typedef std::pair<int, int> P;
typedef std::pair<int, P> PP;
const double PI = 3.14159265358979323846;
const double eps = 1e-9;
const int infi = (int)1e+9 + 7;
const ll infll = (ll)1e+17 + 7;

int n;
ll ans, k;

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

	rep(i, n) {
		int x;
		std::cin >> x;

		ll p = (x + k) / 2;
		ans += (x + k) / 2;
		if(p)k = (x + k) % 2;
		else k = 0;
	}

	std::cout << ans << std::endl;

	return 0;
}

Measured memory_bytes: 256
//#include<bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <algorithm>
#include <utility>
#include <climits>
#define REP(i, n) for(int i = 0; i < n; ++i)
#define FOR(i, a, b) for(int i = a; i < b; ++i)
#define F first
#define S second
#define OUT(x) cout << x << "\n"
#define int long long
using namespace std;
using point = pair< int,int >;

signed main() {
    int d, c;
    cin >> d >> c;

    OUT(d * c);
    return 0;
}




Measured memory_bytes: 3100
#n=int(input())
#a,b=map(int,input().split())
#l=list(map(int,input().split()))
#l=[list(map(int,input().split())) for i in range(n)]

s=list(input())
n=len(s)
l=["A","C","G","T"]
ansl=[0]
for i in range(n):
    for j in range(n):
        if i>j:
            continue
        partial=s[i:j+1]
        flag=True
        for p in partial:
            if not p in l:
                flag=False
                break
        if flag:
            ansl.append(len(partial))
print(max(ansl))


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

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

    int H, W, N;
    cin >> H >> W >> N;

    vector<int> a(N);

    for(int i = 0; i < N; i++) cin >> a[i];

    vector<vector<int> > c(H, vector<int>(W));

    int y = 0;
    int x = 0;

    for(int i = 0; i < N; i++) {
        while(a[i] > 0) {
            a[i]--;
            c[y][x] = i + 1;
            if(y % 2) {
                if(x == 0) {
                    y++;
                } else {
                    x--;
                }
            } else {
                if(x == W - 1) {
                    y++;
                } else {
                    x++;
                }
            }
        }
    }

    for(int i = 0; i < H; i++) {
        for(int j = 0; j < W; j++) {
            cout << c[i][j] << " ";
        }
        cout << endl;
    }
}

Measured memory_bytes: 384
n = int(input())
c = input()
_w = c.count('W')
_r = c.count('R')
ans = min(_w, _r)
d = [0] * n # i番目までのwの個数
d[0] = 1 if c[0] == 'W' else 0
for i in range(n-1):
  d[i] = d[i-1] + 1 if c[i] == 'W' else d[i-1]
for i in range(1, n - 1):
  l = d[i-1] #c[:i].count('W')
  r = _r - (i-d[i-1])
  ans = min(ans,max(l,r))
print(ans)

Measured memory_bytes: 69844
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

n = inp()
s = input()
c = Counter(s)
if c['R'] > n//2:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 38292
import itertools
 
n = int(input())
p = list(input().split())
q = list(input().split())

def dic(z):
    # sorted(list(itertools.permutations(z))) の中に辞書順に並べられた順列が入っている
    return sorted(list(itertools.permutations(z))).index(tuple(z)) + 1
 
print(abs(dic(p) - dic(q)))

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

typedef long long ll;
const ll INF = 1e18;
const int BIG = 1e9 + 555;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	
	int n;
	string s;
	
	cin >> n;
	cin >> s;

	for(int i = 0; i < (int)s.size(); i++){
		int cur = s[i] - 'A';
		cur = (cur + n) % 26;
		char c = (char)(cur + 'A');
		cout << c;
	}
	cout << '\n';

	return 0;
}

Measured memory_bytes: 256
N=int(input())
H=list(map(int, input().split()))
flag="Yes"
maxi=0
for i in range(len(H)-1):
    if H[i]<H[i+1]:
        H[i+1]-=1
    else:
        pass
for i in range(len(H)-1):
    if H[i]<=H[i+1]:
        pass
    elif H[i]>H[i+1]:
        flag="No"
        break
print(flag)

Measured memory_bytes: 14396
#include <bits/stdc++.h>
#define endl '\n'
#define ll long long
using namespace std;
vector<vector<int>> ofo;
vector<vector<bool>>kayn;
int n;
void update(int a, int b){
	int sd=kayn[a][b]+ofo[a][b];
	if (a>0){
		if (ofo[a-1][b]>sd){
			ofo[a-1][b]=sd;
			update(a-1,b);
		}
	}
	if(a<n-1){
		if (ofo[a+1][b]>sd){
			ofo[a+1][b]=sd;
			update(a+1,b);
		}
	}
	if(b>0){
		if (ofo[a][b-1]>sd){
			ofo[a][b-1]=sd;
			update(a,b-1);
		}
	}
	if(b<n-1){
		if (ofo[a][b+1]>sd){
			ofo[a][b+1]=sd;
			update(a,b+1);
		}
	}
}
void lok(){
	cin>>n;
	ofo.resize(n);
	kayn.resize(n);
	for(int i=0;i<n;i++){
		ofo[i].resize(n);
		for(int o=0;o<n;o++){
			int ba=min(o,n-o-1);
			int da=min(i,n-i-1);
			ofo[i][o]=min(ba,da);
		}
	}
	for(int i=0;i<n;i++){
		kayn[i].resize(n);
		kayn[i].assign(kayn[i].size(),true);
	}
	int p;
	ll ans=0;
	for(ll o=0;o<n*n;o++){
		cin>>p;
		int y=(p-1)/n;
		int x=(p-1)%n;
		ans+=ofo[x][y];
		kayn[x][y]=false;
		update(x,y);
	}
	cout<<ans<<endl;
}

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	lok();
	return 0;
}


Measured memory_bytes: 31636
#pragma GCC optimize("O3")
#include<bits/stdc++.h>
#define ll long long int 
using namespace std;
int const MAXN=300100, MOD=1e9+7;
int suff[MAXN][62], scomp[MAXN][62];
ll ans=0;
ll rd()
{
    ll res = 0;
    char ch = 0;
    while(ch < '0') ch = getchar_unlocked();
    for(; ch >= '0'; ch = getchar_unlocked()) res = res * 10 + ch - '0';
    return res;
}
void wr(ll v)
{
    char buf[28];
    int p = 0;
    if(v == 0) buf[p++] = 0;
    for(; v; v /= 10) buf[p++] = v % 10;
    while(p--) putchar_unlocked(buf[p] + '0');
}
ll fastexp(long long a, long long b){
    long long res=1;
    while(b>0){
        if(b%2==1)
            res=(res*a)%MOD;
        b=b/2;
        a=(a*a)%MOD;  
    }
    return res;
}
void my_pow(int base, int esp, int times){
	if(times==0)
		return;
	ll val=fastexp(2,esp);
	ans=(ans+(val*times)%MOD)%MOD;
}
int main(){
	cin.tie(0),cin.sync_with_stdio(0),cout.tie(0),cout.sync_with_stdio(0);
	int n;
	n=rd();
	vector<ll> v(n);
	for(int i=0;i<n;i++)
		v[i]=rd();
	for(int i=0;i<n;i++){
		ll esp=1, p=0;
		while(esp<=v[i]){
			esp*=2;
			p++;
		}
		ll copy=v[i];
		while(copy){
			if(copy>=esp){
				copy-=esp;
				scomp[i][p]=1;
			}
			esp/=2;
			p--;
		}
	}
	for(int i=n-1;i>=0;i--){
		for(int j=0;j<62;j++)
			suff[i][j]=suff[i+1][j]+scomp[i][j];
	}
	for(int i=0;i<n;i++)
		for(int j=0;j<60;j++){
			if(scomp[i][j]){
				int times=n-i-suff[i][j];
				my_pow(2,j,times);
			}
			else{
				int times=suff[i][j];
				my_pow(2,j,times);
			}
		}
	wr(ans);
}

Measured memory_bytes: 147968
#include <iostream>
int main(int argc, const char * argv[]) {
    int a, b;
    int max;
    std::cin >> a >> b;
    if(a+b > a-b)
    {
        max = (a+b > a*b) ? a+b : a*b;
    }else{
        max = (a-b > a*b) ? a-b : a*b;
    }
    std::cout << max << std::endl;
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using vll = vector<ll>;
using vii = vector<int>;
using pii = pair<int, int>;

const ll INF = numeric_limits<ll>::max(),
         MOD = 1e9 + 7;

const int INF_i = numeric_limits<int>::max(),
          MAX = 1e6;

vector<vll> dp;

ll f(int i, int j) {
    if (i < 0 or j < 0) 
        return 0;
    ll &res = dp[i][j];
    if (res != -1) return res;
    res = (f(i - 1, j) + f(i, j - 1)) % MOD;
    return res;
}

int main() {
    cin.tie(NULL);
    ios_base::sync_with_stdio(false);
    // freopen("in.in", "r", stdin);
    int h, w;
    cin >> h >> w;
    dp.assign(h, vll(w, -1));
    dp[0][0] = 1;
    for (int i = 0; i < h; i++) {
        string s;
        cin >> s;
        for (int j = 0; j < w; j++) {
            if (s[j] == '#') dp[i][j] = 0;
        }
    }
    cout << f(h - 1, w - 1) << '\n';
}

Measured memory_bytes: 8192
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     @hamayanhamayan
　　　　／　　　＼　 　  |　|
　　　 /　　 /￣￣￣￣/　　|
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿
　 　　　＼/＿＿＿＿/　（u　⊃
---------------------------------------------------------------------------------------------------*/

int N;
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> N;
    int ans = N * N * N;
    cout << ans << endl;
}



Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <algorithm>
#define rep(i,st,ed) for (int i=st;i<=ed;++i)

typedef long long LL;
const int MOD=998244353;
const int N=200005;

struct pos {int x,y;} p[N];

pos operator -(pos a,pos b) {
	return (pos) {a.x-b.x,a.y-b.y};
}

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

LL bin[N];

int read() {
	int x=0,v=1; char ch=getchar();
	for (;ch<'0'||ch>'9';v=(ch=='-')?(-1):v,ch=getchar());
	for (;ch<='9'&&ch>='0';x=x*10+ch-'0',ch=getchar());
	return x*v;
}

bool line(pos a,pos b,pos c) {
	return (a-b)*(c-b)==0;
}

int main(void) {
	bin[0]=1; rep(i,1,N-1) bin[i]=bin[i-1]*2LL%MOD;
	int n=read();
	rep(i,1,n) p[i].x=read(),p[i].y=read();
	LL ans=bin[n]-n-1-(n-1)*n/2; ans=(ans%MOD+MOD)%MOD;
	rep(i,1,n) rep(j,i+1,n) {
		int s=0;
		rep(k,j+1,n) {
			s+=line(p[i],p[j],p[k]);
		}
		ans=(ans+MOD-bin[s]+1)%MOD;
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 1664
loop do
    n = gets.to_i
    break if n == 0
    p = n.times.map{gets.split.map(&:to_i)}.map{|pp| pp[1...pp.size]}
    k = gets.split.map(&:to_i)
    a = p.select{|pp| (k[1...k.size] - pp).size == 0}
    p a.size == 1 ? p.each.with_index(1).select{|pp, i| (k[1...k.size] - pp).size == 0}[0][1] : -1
end

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

int main()
{
string s ;
cin >> s ;
if(s.size()%2){
      cout << "No" << endl;
return 0;
}
rep(i,s.size()/2){
  if(!(s[i*2]=='h'&&s[i*2+1]=='i')){
    cout << "No" << endl;
return 0;
  }
}
cout << "Yes" << endl;
return 0;
}

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

int main(){
    string S,T; cin >> S >> T;
    int A,B; cin >> A >> B;
    string U; cin >> U;
    
    if (U==S) cout << A-1 << " " << B << endl;
    else cout << A << " " <<  B-1 << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<string>
#include<cstring>
#include<map>
#include<utility>
#include<cmath>
#include<queue>
#include<unordered_map>
#include<unordered_set>

using namespace std;
#define ll long long
#define mk make_pair
#define out freopen("out.txt", "w", stdout)
const int N = 1e5 + 10;
const int mod = 998244353;
const int inf = 0x3f3f3f3f;



int main()
{
	int n, m;
	cin >> n >> m;
	if (n == m)
		puts("Yes");
	else
		puts("No");
}

Measured memory_bytes: 256
#coding:utf-8
n,m = list(map(int,input().split()))
ki = []
sk = []
for _ in range(m):
    temp = list(map(int,input().split()))
    ki.append(temp[0])
    sk.append(temp[1:])
pm = list(map(int,input().split()))
# Mが10以下なので、全探索を行う

import copy
switch_mask = []
for i in range(2**(n)):
    switch_mask.append(format(i,"0{}b".format(n)))

def is_all_on(mask):
    for i,s in enumerate(sk):
        s_sum = 0
        for connected_switch in s:
            s_sum += int(mask[connected_switch-1])
        if s_sum % 2 != pm[i]:
            return 0
    return 1
ret = 0
for mask in switch_mask:
    ret += is_all_on(mask)
print(ret)

Measured memory_bytes: 3956
#include<stdio.h>
int main(){
	int a,b;
	scanf("%d %d",&a,&b);
	if(a<b){
		printf("a < b\n");
	}
	else if(a>b){
		printf("a > b\n");
	}
	else{
		printf("a == b\n");
	}
	return 0;
}

Measured memory_bytes: 2688
ac, wa, tle, re = 0, 0, 0, 0
t = gets.to_i
t.times do
  case gets.chomp
    when "AC"; ac += 1
    when "WA"; wa += 1
    when "TLE"; tle += 1
    when "RE"; re += 1
  end
end

puts <<EOF
AC x #{ac}
WA x #{wa}
TLE x #{tle}
RE x #{re}
EOF

Measured memory_bytes: 14312
#include "bits/stdc++.h"
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <map>
#include <vector>
#include <math.h>
#include <algorithm>
#include <queue>
#include <set>
#include <tuple>
using namespace std;

#define FOR(i,init,a) for(int i=init; i<a; i++)
#define rep(i,a) FOR(i,0,a)
#define rrep(i,a) for(int i=a; i>=0; i--)
#define rep1(i,a) for(int i=1; i<=a; i++)
#define cout1(a) cout << a << endl;
#define cout2(a,b) cout << a << " " << b << endl;
#define cout3(a,b,c) cout << a << " " << b << " " << c << endl;
#define cout4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << endl;
#define mem(a,n) memset( a, n, sizeof(a))
#define all(a) a.begin(),a.end()
#define chmin(a,b) a=min(a,b);
#define chmax(a,b) a=max(a,b);

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;
static const double pi = 3.141592653589793;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll x,y;
    cin>>x>>y;
    
    ll ans=abs(abs(x)-abs(y));
    if(abs(x)>=abs(y)){
        if(x>0) ans++;
        if(y>0) ans++;
    }else{
        if(x<0) ans++;
        if(y<0) ans++;
    }
    cout1(ans)
}

Measured memory_bytes: 256
from itertools import product

def cost(t):
    x, y, z = 0, 0, 0
    count_x, count_y, count_z = 0, 0, 0
    for i, v in zip(t, l):
        if i == 1:
            x += v
            count_x += 1
        elif i == 2:
            y += v
            count_y += 1
        elif i == 3:
            z += v
            count_z += 1
    if count_x == 0 or count_y == 0 or count_z == 0:
        return 1000000000
    return 10 * (count_x + count_y + count_z - 3) + abs(x - a) + abs(y - b) + abs(z - c)


if __name__ == '__main__':
    n, a, b, c = map(int, input().split())
    l = [int(input()) for _ in range(n)]
    print(min(map(cost, product(*[range(4)] * n))))





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

typedef long long ll;
ll MOD = 1000000007;

int F[1001], C[1001][1001], D[1001][1001];

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

vector<vector<int> > f(int N, ll t) {
	vector<int> d(N + 1);
	for (int k = 0; k <= N; k++)
		d[k] = gcd(k, t);
	vector<vector<int> > a(N + 1);
	for (int n = 1; n <= N; n++) {
		vector<int> dp(N / n + 1);
		dp[0] = 1;
		for (int i = 0; i <= N / n; i++)
			for (int j = 1; i + j <= N / n; j++) {
				if (d[j * n] != j) continue;
				ll x = dp[i];
				x = x * C[i + j - 1][j - 1] % MOD;
				x = x * F[j - 1] % MOD;
				x = x * D[n][j - 1] % MOD;
				dp[i + j] = (dp[i + j] + x) % MOD;
			}
		a[n] = dp;
	}
	return a;
}

int main() {
	F[0] = 1;
	for (int i = 1; i <= 1000; i++)
		F[i] = (ll)F[i - 1] * i % MOD;
	for (int i = 0; i <= 1000; i++) {
		C[i][0] = 1;
		for (int j = 1; j <= i; j++)
			C[i][j] = (C[i - 1][j - 1] + C[i - 1][j]) % MOD;
	}
	for (int i = 1; i <= 1000; i++) {
		D[i][0] = 1;
		for (int j = 1; j <= 1000; j++)
			D[i][j] = (ll)D[i][j - 1] * i % MOD;
	}
	int N; ll X, Y, Z;
	cin >> N >> X >> Y >> Z;
	vector<vector<int> > a = f(N, 2), b = f(N, abs(X - Y + Z));
	if (!X && !Y && !Z) {
		cout << (ll)a[1][N] * D[N][N] % MOD << endl;
		return 0;
	}
	vector<int> dp(N + 1);
	dp[0] = 1;
	for (int n = 1; n <= N; n++)
		for (int k = N; k >= 0; k--) {
			ll z = 1;
			for (int i = 1; k + i * n <= N; i++) {
				z = z * C[i * n - 1][n - 1] % MOD * F[n - 1] % MOD;
				ll x = dp[k];
				x = x * C[k + i * n][i * n] % MOD;
				x = x * z % MOD;
				x = x * a[n][i] % MOD;
				x = x * b[n][i] % MOD;
				dp[k + i * n] = (dp[k + i * n] + x) % MOD;
			}
		}
	cout << dp[N] << endl;
}

Measured memory_bytes: 11148
using System;
using Microsoft.VisualBasic;

public class Program
{
    public void Solve()
    {
        var sc = new Scanner();
        int N = sc.NextInt();
        int[] a = sc.IntArray();
        int startindex = 0;
        int lastindex = N - 1;
        int[] ans = new int[N];
        for (int i = N - 1; i >= 0; i--)
        {
            
            if (i % 2 != N%2)
            {
                ans[startindex] = a[i];
                startindex++;
            }
            else
            {
                ans[lastindex] = a[i];
                lastindex--;
            }
        }
        Console.WriteLine(string.Join(" ",ans));
    }

    public static void Main(string[] args)
    {
        new Program().Solve();
    }
}

class Scanner
{
    public Scanner()
    {
        _pos = 0;
        _line = new string[0];
    }

    const char Separator = ' ';
    private int _pos;
    private string[] _line;

    #region スペース区切りで取得

    public string Next()
    {
        if (_pos >= _line.Length)
        {
            _line = Console.ReadLine().Split(Separator);
            _pos = 0;
        }

        return _line[_pos++];
    }

    public int NextInt()
    {
        return int.Parse(Next());
    }

    public long NextLong()
    {
        return long.Parse(Next());
    }

    public double NextDouble()
    {
        return double.Parse(Next());
    }

    #endregion

    #region 型変換

    private int[] ToIntArray(string[] array)
    {
        var result = new int[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = int.Parse(array[i]);
        }

        return result;
    }

    private long[] ToLongArray(string[] array)
    {
        var result = new long[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = long.Parse(array[i]);
        }

        return result;
    }

    private double[] ToDoubleArray(string[] array)
    {
        var result = new double[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = double.Parse(array[i]);
        }

        return result;
    }

    #endregion

    #region 配列取得

    public string[] Array()
    {
        if (_pos >= _line.Length)
            _line = Console.ReadLine().Split(Separator);

        _pos = _line.Length;
        return _line;
    }

    public int[] IntArray()
    {
        return ToIntArray(Array());
    }

    public long[] LongArray()
    {
        return ToLongArray(Array());
    }

    public double[] DoubleArray()
    {
        return ToDoubleArray(Array());
    }

    #endregion
}

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

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

    bool flag = true;
    while(a > 0 && c > 0){
        if(flag){
            c -= b;
            flag = false;
        }
        else{
            a -= d;
            flag = true;
        }
    }

    cout << (a > 0 ? "Yes" : "No") << endl;
    return 0;
}

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

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

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


	map<int,int> count;

	int max = 0;
	for(auto an : a){
		count[an]++;
		max = std::max(max,an);
	}

	int out = 0;
	for(auto mp:count){
		if(mp.second > mp.first){
			out += mp.second - mp.first;
		}
		if(mp.second < mp.first){
			out += mp.second;
		}
	}

	cout << out << endl;

	return 0;
}


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

int main()
{
	int ar[3];
	int i;
	for(i=0;i<3;i++){
		cin>>ar[i];
	}
	sort(ar,ar+3);

	int ans=ar[0]+ar[1];
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define all(v) v.begin(),v.end()
#define inf (int)(3e18)
#define P pair<int,int>
#define mod (int)(1e9+7)
#define mod2 998244353

template<class T> inline void chmin(T &a, T b) {
	a = min(a, b);
}
template<class T> inline void chmax(T &a, T b) {
	a = max(a, b);
}


signed main(){
	int N,M;cin>>N>>M;
	int p=N%M;
	cout<<min(p,M-p)<<endl;
}


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

int main() {
    string s;
    std::cin >> s;
    ll n = s.size();
    ll ans = n;
    for (ll i = 0; i < n; i++) {
        if(s[i]=='1'){
            ans = min(ans,max(i,n-1-i));
        }
    }
    ll ans2 = n;
    for (ll i = 0; i < n; i++) {
        if(s[i]=='0'){
            ans2 = min(ans2,max(i,n-1-i));
        }
    }
    std::cout << max(ans,ans2) << std::endl;
}


Measured memory_bytes: 512
import java.util.*;
public class Main{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
  int N = sc.nextInt();
  int[] x = new int[N];
  int[] a = new int[N];
  for(int i = 0;i < N;i++){
    x[i] = sc.nextInt();
    a[i] = x[i];
  }
  Arrays.sort(a);
  int m1 = a[(N+1)/2];
  int m2 = a[(N-1)/2];
  double m = (m1+m2)/2;
  for(int i = 0;i < N;i++){
    System.out.println(x[i] <= m ? m1:m2);
  }
}}

Measured memory_bytes: 92284
#include<stdio.h>
 int main(){
 	int W,H,x,y,r;
 	scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
 	if(x+r<=W && x-r>=0 && y+r<=H && y-r>=0){
 		printf("Yes\n");
 		}else{
 			printf("No\n");
 			}
 		}

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

using namespace std;

#define FOR(i, x, y) for(int i = (x); i < (y); ++i)
#define REP(i, x, y) for(int i = (x); i <= (y); ++i)
#define PB push_back
#define MP make_pair
#define PH push
#define fst first
#define snd second
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair<int, int> pii;

const int maxn = 2e5 + 5;

int n;
int a[maxn], b[maxn];
vector<int> s, t;

int main(){
	scanf("%d", &n);
	FOR(i, 0, n)
		scanf("%d", a + i);
	FOR(i, 0, n)
		scanf("%d", b + i);
	reverse(b, b + n);
	
	int x = -1;
	FOR(i, 0, n) if(a[i] == b[i])
		s.PB(i), x = a[i]; 
	FOR(i, 0, n) if(a[i] != x && b[i] != x)
		t.PB(i);
	if(s.size() > t.size()){
		puts("No");
		return 0;
	}
		
	FOR(i, 0, s.size())
		swap(b[s[i]], b[t[i]]);
	puts("Yes");
	FOR(i, 0, n)
		printf("%d ", b[i]);
	puts("");
	return 0;
}


Measured memory_bytes: 6176
#include <iostream>
#include <limits>

using namespace std;

int main() {
    int n;
    cin >> n;
    int t, a;
    cin >> t >> a;
    size_t index = 0;
    double avg = numeric_limits<double>::max();
    for (size_t  i = 0; i <= n; ++i) {
        int h;
        cin >> h;
        double temp = static_cast<double>(t) - h * 0.006;
        double diff = static_cast<double>(a) - temp;
        if (diff < 0) diff = -diff;
        if (diff < avg) {
            avg = diff;
            index = i + 1;
        }
    }
    cout << index << endl;
    return EXIT_SUCCESS;
}

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


void solve(long long N, long long M, std::vector<long long> A){
    priority_queue <ll> q;
    rep(i,N)q.push(A[i]);
    rep(i,M){
        ll temp=q.top()/2;
        q.pop();
        q.push(temp);
    }
    ll a=0;
    rep(i,N){
        a+=q.top();
        q.pop();
    }

    cout<<a<<endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    long long M;
    scanf("%lld",&M);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    solve(N, M, std::move(A));
    return 0;
}


Measured memory_bytes: 2168
#ifdef __APPLE__
#include <iostream>
#include <vector>
#include <utility>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <random>
#else
#include <bits/stdc++.h>
#endif

using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define tc(t) for (int tc=1; tc<=t; tc++)
typedef vector<int> VI;
typedef vector<long long int> VLLI;
typedef vector<pair<int, int> > VPI;
typedef long long ll;
typedef pair<int,int> PII;
typedef pair<ll, ll> PLL;
mt19937 mrand(random_device{}()); 
const ll mod=1000000007;
int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
ll modInverse (ll a) {ll p = mod - 2; return powmod(a, p);}
// head

const ll MAX_BIT = 60;

int main() {
    ll n;
    cin >> n;
    vector<ll> arr(n);
    for (int i = 0; i < n; i++)
        cin >> arr[i];

    vector<ll> cnt(MAX_BIT);
    ll ans = 0;

    for (int i = n-1; i >= 0; i--) {
        // compute
        for (ll j = 0; j < MAX_BIT; j++) {
            if ((((ll)1<<j)&arr[i])) {
                ans += (((ll)1<<j)%mod)*((ll)(n-1-i-cnt[j]));
                ans %= mod;
            } else {
                ans += (((ll)1<<j)%mod)*cnt[j];
                ans %= mod;
            }
        }

        // add num
        for (ll j = 0; j < MAX_BIT; j++) {
            if ((((ll)1<<j)&arr[i]))
                cnt[j]++;
        }
        //cout << ans << "\n";
    }

    cout << ans << "\n";
}



Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(int)(a); (i)<(int)(b); ++(i))
#define rFor(i, a, b) for(int (i)=(int)(a)-1; (i)>=(int)(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
#define double long double
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
typedef pair<lint, lint> pll;
template<class T> bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T> bool chmin(T &a, const T &b){if(a>b){a=b; return true;} return false;}
template<class T> T div_floor(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>=0 ? a/b : (a+1)/b-1;
}
template<class T> T div_ceil(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>0 ? (a-1)/b+1 : a/b;
}

constexpr lint mod = 1e9+7;
constexpr lint INF = mod * mod;
constexpr int MAX = 200010;

int main(){
    string s, t;
    cin >> s >> t;
    puts(t.substr(0, s.size()) == s ? "Yes" : "No");
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rep3(i, l, n) for (int i = l; i < n; ++i)
#define chmax(a, b) a = (a >= b ? a : b)
#define chmin(a, b) a = (a <= b ? a : b)
#define out(a) cout << a << endl
#define outa(a, n) rep(_, n) cout << a[_] << " "; cout << endl
#define SZ(v) (int)v.size()
#define inf (int)(1e9+7)
#define abs(x) (x >= 0 ? x : -(x))
#define ceil(a, b) a / b + !!(a % b)
#define FIX(a) fixed << setprecision(a)

// https://kkishi.hatenadiary.org/entry/20090707/1246930309

int c;
int N;
vector<int> v;
map<char, int> mp;
vector<char> vv;
int zero[26];
int n;
void basen(int dep, int used, int num) {
    if (dep == n) {
        if (num == 0) c++;
        return;
    }
    rep3(i, zero[vv[dep] - 'A'] == 0 ? 0 : 1, 10) {
        if (used & (1 << i)) continue;
        basen(dep + 1, used | (1 << i), num + i * v[dep]);
    }
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    while (cin >> N && N) {
        fill_n(zero, 26, 0);
        mp.clear();
        rep(i, N - 1) {
            string str;
            cin >> str;
            for (int j = SZ(str) - 1; j >= 0; --j) {
                mp[str[j]] += pow(10, SZ(str) - 1 - j);
            }
            if (SZ(str) != 1) zero[str[0] - 'A'] = 1;
        }
        string str;
        cin >> str;
        for (int i = SZ(str) - 1; i >= 0; --i) {
            mp[str[i]] -= pow(10, SZ(str) - 1 - i);
        }
        if (SZ(str) != 1) zero[str[0] - 'A'] = 1;
        if (SZ(mp) > 10) { out(0); return 0; }
        // for (auto e : mp) cout << e.F << " " << e.S << endl;
        v.clear();
        vv.clear();
        for (auto e : mp) { v.eb(e.S); vv.eb(e.F); }
        n = SZ(v);
        // outa(zero, 26);
        c = 0;
        basen(0, 0, 0);
        out(c);
    }
}



Measured memory_bytes: 3368
#include <stdio.h>
int main(){
    int n,m,l,i,j,k,a[100][100],b[100][100];
    long long c[100][100]={0};
    scanf("%d %d %d",&n,&m,&l);
    for(i=0;i<n;i++){
        for(j=0;j<m;j++){
            scanf("%d",&a[i][j]);
        }
    }
    for(i=0;i<m;i++){
        for(j=0;j<l;j++){
            scanf("%d",&b[i][j]);
        }
    }
    for(i=0;i<n;i++){
        for(j=0;j<l;j++){
            for(k=0;k<m;k++){
                c[i][j]+=a[i][k]*b[k][j];
            }
            if(j!=0)
            {printf(" ");
            }
            printf("%ld",c[i][j]);
        }
        printf("\n");
    }
    return 0;
}



Measured memory_bytes: 2120
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
using namespace std;
int main(){
   string s;
   cin >> s;
   for(int i = 0; i < s.size()-1; i++){
       cout << 'x';
   }
   cout << 'x' << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, s, n) for (int i = s; i < n; i++)
#define ALL(a) a.begin(), a.end()
#define MOD 1000000007
using namespace std;
typedef long long ll;

int main() {
    int N, M; cin >> N >> M;
    set<int> divisors;
    for (int i = 1; i * i <= M; i++) {
        if (M % i != 0) continue;
        divisors.insert(i);
        divisors.insert(M / i);
    }

    int ans = 1;
    for (auto d : divisors) {
        if (M / d >= N) ans = d;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var a, b, c, x int
	fmt.Scan(&a, &b, &c)
	fmt.Scan(&x)

	ans := 0
	for i := 0; i <= a; i++ {
		for j := 0; j <= b; j++ {
			for k := 0; k <= c; k++ {
				if 500*i+100*j+50*k == x {
					ans++
				}
			}
		}
	}

	fmt.Println(ans)
}


Measured memory_bytes: 512
#!/usr/bin/env python
from collections import defaultdict
import logging
logging.basicConfig(level=logging.DEBUG)
logging.disable(logging.CRITICAL)

def main():
    N = int(input())
    
    my_dict = defaultdict(int)
    for _ in range(N):
        s = ''.join(sorted(input()))
        if s in my_dict:
            my_dict[s] += 1
        else:
            my_dict[s] = 0

    ans = 0
    for _, v in my_dict.items():
        logging.debug("{}".format(v))
        if v == 1:
            ans += 1
        else:
            ans += ((v + 1) * v / 2)

    return ans

if __name__ == '__main__':
    print(int(main()))

Measured memory_bytes: 66696
//g++ -std=c++11 -Wall -O2 -o main.exe main.cpp
//g++ -std=c++14 -Wall -O2 -o main.exe main.cpp

#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <functional>
#include <algorithm>
#include <complex>
#include <numeric>
#include <queue>
#include <stack>
#include <tuple>

using namespace std;

#define spc " "
#define com ", "

typedef long long ll;
typedef long double ld;
typedef pair<int, int> p_ii;

//------------------------------------------------------------------------------

int main(){
    int n;
    cin >> n;
    ll ans1 = 0, ans2 = 0;
    cin >> ans1 >> ans2;

    for(int i = 0; i < (n - 1); i++){
        ll a, b;
        cin >> a >> b;
        ll n = max((ans1 + (a - 1)) / a, (ans2 + (b - 1)) / b);
        
        ans1 = n * a; ans2 = n * b;
    }

    cout << (ans1 + ans2) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <fstream>
#include <string>
#include <math.h>
#include <cstdlib>
#include <istream>
#include <sstream>
#include <cctype>
#define fore(i,x,y) for(long long i=x;i<y;i++)
typedef long long ll;
using namespace std;
int main()
{
	int M;
	cin >> M;
	cout << 48-M << endl;
}

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

int main() {
    string str1,str2;cin>>str1>>str2;
    int ans=0;

    for(int i=0;i<3;++i){
        if(str1[i]==str2[i]) ans+=1;
    }

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

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

int main () {
    int N, K;
    cin >> N >> K;

    if(K==1) cout << 0 << endl;
    else cout << N-(K-1)-1 << endl;
    return 0;
}

Measured memory_bytes: 256
package main
 
import (
	"bufio"
	"fmt"
	"log"
	"os"
	"strconv"
	"sort"
)
 
type ByRune []rune

func (r ByRune) Len() int           { return len(r) }
func (r ByRune) Swap(i, j int)      { r[i], r[j] = r[j], r[i] }
func (r ByRune) Less(i, j int) bool { return r[i] < r[j] }

func run() {

	var N int64;
    N = nextInt();
    s := make([]string,N);
    for i := 0 ; i < int(N) ; i++ {
        s[i] = next();
    }
	solve(N, s);

}

func solve(N int64, s []string){	  
	for i, c := range s {
		s[i] = SortStringByCharacter(c)

	}
	
	m := map[string]int{}
	sum := 0

	for _, g := range s {
		v := m[g]
		m[g] = v+1
		sum += v
	}
	Println(sum)
	
}

func StringToRuneSlice(s string) []rune {
	var r []rune
	for _, runeValue := range s {
			r = append(r, runeValue)
	}
	return r
}

func SortStringByCharacter(s string) string {
	var r ByRune = StringToRuneSlice(s)
	sort.Sort(r)
	return string(r)
}
// --- template ---
// Thanks https://gist.github.com/halllllll/853ab587fd82ee3ffe6f7fb7fb499695
 
var sc = bufio.NewScanner(os.Stdin)
var out = bufio.NewWriter(os.Stdout)
 
// Caution: You will get unexpected result if a single token is larger than this size.
const BufferSize = 64 * 1024 * 1024
 
func Print(a ...interface{}) (n int, err error) {
	return fmt.Fprint(out, a...)
}
 
func Printf(format string, a ...interface{}) (n int, err error) {
	return fmt.Fprintf(out, format, a...)
}
 
func Println(a ...interface{}) (n int, err error) {
	return fmt.Fprintln(out, a...)
}
 
func next() string {
	sc.Scan()
	return sc.Text()
}
 
func nextInt() int64 {
	a, err := strconv.ParseInt(next(),10, 64)
	if err != nil {
		log.Fatal(err)
	}
	return a
}

func nextFloat() float64 {
	a, err := strconv.ParseFloat(next(), 64)
	if err != nil {
		log.Fatal(err)
	}
	return a
}

 
func main() {
	sc.Buffer(make([]byte, 0, BufferSize), BufferSize)
	sc.Split(bufio.ScanWords)
	run()
	out.Flush()
}


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

int main() {
  int n, s = 0;
  cin >> n;
  vector<int> l(2*n);
  for(int i = 0; i < 2*n; i++)
    cin >> l.at(i);
  sort(l.begin(), l.end());
  for(int i = 0; i < n; i++){
    int p = min(l.at(2*i), l.at(2*i+1));
    s += p;
  }
  cout << s << endl;
}


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

int main() {
  int a, b, c;
  string s;
  cin >> a >> b >>c;
  cin >> s;
  int pass = 0;
  int nb = 0;
  for(int i=0; i<a;i++){
    if(s[i] == 'c' ||pass >= b + c) cout << "No" << endl;
    else if(s[i] == 'a'){
        cout << "Yes" << endl;
        pass += 1;
    }else if(nb < c){
        cout << "Yes" << endl;
        pass += 1;
        nb += 1;
    }else{
        cout << "No" << endl;
    }
  }
}

Measured memory_bytes: 896
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv, std.math,
    std.functional, std.numeric, std.range, std.stdio, std.string, std.random,
    std.typecons, std.container, std.format;

// dfmt off
T lread(T = long)(){return readln.chomp.to!T();}
T[] lreads(T = long)(long n){return generate(()=>readln.chomp.to!T()).take(n).array();}
T[] aryread(T = long)(){return readln.split.to!(T[])();}
void scan(TList...)(ref TList Args){auto line = readln.split();
foreach (i, T; TList){T val = line[i].to!(T);Args[i] = val;}}
alias sread = () => readln.chomp();enum MOD = 10 ^^ 9 + 7;
alias PQueue(T, alias less = "a<b") = BinaryHeap!(Array!T, less);
// dfmt on

void main()
{
    immutable W = 30;
    long N = lread();
    auto A = aryread!uint();
    auto S = new long[][](N + 1, W);
    foreach (i; 0 .. N)
        foreach (j; 0 .. W)
        {
            S[i + 1][j] = S[i][j] + ((A[i] & (1 << j)) != 0);
        }
    long i;
    long j;
    long ans;
    while (i < N)
    {
        incj: while (true)
        {
            if (!(j <= N))
                break incj;
            auto tmp = new long[](W);
            tmp[] = S[j][] - S[i][];
            // writeln(tmp);
            if (tmp.all!(x => x <= 1)())
                j++;
            else
                break incj;
        }
        j--;
        long len = j - i;
        // writefln("%s %s %s", i, j, len);
        ans += len;
        i++;
        inci: while (true)
        {
            if (!(i < N) || !(i <= j))
                break inci;
            auto tmp = new long[](W);
            tmp[] = S[j][] - S[i][];
            // writeln("j", tmp);
            if (!(tmp.all!(x => x <= 1)()))
                i++;
            else
                break inci;
        }
    }
    writeln(ans);
}


Measured memory_bytes: 145372
const val MOD: Long = (1e9+7).toLong()

fun main(args: Array<String>) {
    val s = readLine()!!

    val x = s.map{
        (it == 'A') or (it == 'T') or (it == 'C') or (it == 'G')
    }

    var max = 0
    var stmax = -1
    var enmax = -1
    var a = 0
    var st = -1
    var en = -1
    for ((i, y) in x.withIndex()) {
        if (y) {
            if (a == 0) {
                st = i
            }
            a += 1
        } else {
            if (a > max) {
                max = a
                stmax = st
                enmax = i-1
            }
            a = 0
        }
    }
    if (a > max) {
        max = a
        stmax = st
        enmax = s.length-1
    }

    println(max)
}


Measured memory_bytes: 33472
import math
n=int(input())
digitSize=2
while math.floor(n/(10**digitSize))>0:
    digitSize+=1
# print('digitSize={}'.format(digitSize))

shime=[[],[],[],[357,375,537,573,735,753]]
def makeShime(nowDigitSize):
    shime.append([])
    for num in shime[nowDigitSize-1]:
        for i in range(nowDigitSize): # 挿入箇所
            for j in (3,5,7): # 挿入する値
                newNum=math.floor(num/(10**i))*10+j
                newNum=newNum*(10**i)+num%(10**i)
                shime[nowDigitSize].append(newNum)
    shime[nowDigitSize]=list(set(shime[nowDigitSize]))
    shime[nowDigitSize].sort()
    if nowDigitSize<digitSize:
        makeShime(nowDigitSize+1)
makeShime(4)
# print(shime)
# for i in range(digitSize+1):
#     print(len(shime[i]),end=',')

i=0
sh=shime[digitSize]
le=len(shime[digitSize])
while True:
    if i>=le:
        break
    if n<sh[i]:
        break
    i+=1

cnt=i
for i in range(digitSize):
    cnt+=len(shime[i])
print(cnt)


Measured memory_bytes: 10476
/* ---------- STL Libraries ---------- */
// IO library
#include <cstdio>
#include <fstream>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>
#include <cmath>
#include <numeric>
#include <random>
#include <cstring>

// container library
#include <array>
#include <bitset>
#include <deque>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>
#include <stack>

/* ---------- Namespace ---------- */
using namespace std;

/* ---------- Type ---------- */
using ll = long long;
#define int ll
#define P pair<ll, ll>

/* ---------- Constants  */
const double PI = 3.141592653589793238462643383279;
const ll MOD = 1e9 + 7;
const int INF = 1LL << 55;

/* v-v-v-v-v-v-v-v-v Main Part v-v-v-v-v-v-v-v-v */
signed main() {
    string str;
    cin >> str;
    int num = stoi(str);

    bool yymm = false;
    bool mmyy = false;

    if (num % 100 >= 1 && num % 100 <= 12) yymm = true;
    if (num / 100 >= 1 && num / 100 <= 12) mmyy = true;

    if (yymm && mmyy) cout << "AMBIGUOUS" << endl;
    else if (yymm) cout << "YYMM" << endl;
    else if (mmyy) cout << "MMYY" << endl;
    else cout << "NA" << endl;
    return 0;
}

Measured memory_bytes: 256
// ABC 160-E
// 2020.3.28 bal4u

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

typedef long long ll;

#define gc() getchar_unlocked()
int in() {   // 非負整数の入力
	int n = 0, c = gc();
	do n = 10 * n + (c & 0xf); while ((c = gc()) >= '0');
	return n;
}

unsigned a[300005]; int N;

void Usort(unsigned *a, int n) {
	int i, k;
#define B 8
#define BMSK 255 // (1<<8)-1
	int t1[1 << B], t2[1 << B];

	unsigned *tmp = malloc(n * sizeof(unsigned));
	for (k = 0; k < 4; ++k) {
		memset(t1, 0, sizeof(t1)), memset(t2, 0, sizeof(t2));
		for (i = 0; i < n; ++i)	t1[(a[i] >> k*B) & BMSK]++;
		for (i = 0; i < BMSK; ++i) t1[i+1] += t1[i];
		i = n; while (i--) tmp[--t1[(a[i] >> k*B) & BMSK]] = a[i];
		k++;
		for (i = 0; i < n; ++i) t2[(tmp[i] >> k*B) & BMSK]++;
		for (i = 0; i < BMSK; ++i) t2[i+1] += t2[i];
		i = n; while (i--) a[--t2[(tmp[i] >> k*B) & BMSK]] = tmp[i];
	}
	free(tmp);
#undef B
}

int main()
{
	int i, g, X, Y, A, B, C;
	ll ans;

	X = in(), Y = in();
	A = in(), B = in(), C = in(), N = A+B+C;
	i = 0;
	while (A--) a[i++] = (in() << 2) | 1;
	while (B--) a[i++] = (in() << 2) | 2;
	while (C--) a[i++] = (in() << 2);
	Usort(a, N);
	ans = 0, g = X + Y;
	for (i = N-1; g; --i) {
		int color = a[i] & 3;
		int v = (a[i] >> 2);
		if (color == 1) {
			if (X) X--, g--, ans += v;
		} else if (color == 2) {
			if (Y) Y--, g--, ans += v;
		} else g--, ans += v;
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 2560
using System;
using System.Linq;
class Program
{
    public static void Main()
    {
        int[] wab = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
        int ans = Math.Max(0, Math.Abs(wab[2] - wab[1]) - wab[0]);
        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 13396
//:Ditttoo
#include<bits/stdc++.h>
#define int long long int 
using namespace std;
int32_t main()
{
	int n;
	cin>>n;
	int h[n];
	for(int i=0;i<n;i++)cin>>h[i];

	int dp[n];

    dp[0] = 0 , dp[1] = abs(h[1]-h[0]);

    for(int i=2;i<n;i++){

    	dp[i] = min(dp[i-1] + abs(h[i] - h[i-1]) , dp[i-2] + abs(h[i]- h[i-2]));
    }

    cout<<dp[n-1];
    return 0;
}        

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

int main() {
  int N;
  int t[100100];
  int x[100100];
  int y[100100];
  cin >> N;
  x[0] = 0;
  x[0] = 0;
  t[0] = 0;

  for (int i=0; i < N; ++i) {
    cin >> t[i+1];
    cin >> x[i+1];
    cin >> y[i+1];
  }

  bool can = true;

  for (int i=0; i < N; ++i) {
    int abs_t = abs(t[i+1] - t[i]);
    int dist = abs(x[i+1] - x[i]) + abs(y[i+1] - y[i]);
    if (abs_t < dist) {
      can = false;
      break;
    } else if (abs_t % 2 != dist % 2) {
      can = false;
      break;
    }
  }

  if (can == true) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
const long double PI = acos(-1);
typedef long long ll;
typedef pair<int64_t,int64_t> pll;
int dx[]={1,-1,0,0,1,-1,1,-1};
int dy[]={0,0,1,-1,1,-1,-1,1};
#define INF (2147483647)
#define mod (1000000007)
#define limit (7368791)
#define rep(i,a,b) for (int64_t i = (a); i < (b); i++)
#define REP(i,n) rep(i,0,n)
#define ALL(a) begin(a),end(a)
#define sz(s) (s).size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second


void solve()
{
    ll n;cin>>n;
    if(n%2){cout<<0<<endl;return;}
    ll q,qq,ans=0;
    q=5;qq=2*q;
    while(n>=qq){
        ans+=n/qq;
        qq*=q;
    }
    cout<<ans<<endl;
}

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



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

int main() {
  int n, m;
  cin >> n >> m;
  
  vector<vector<int>> tonari(n);//隣接する部屋たち
  for(int i = 0; i < m; i++){
    int a, b;
    cin >> a >> b;
    a--; b--;//
    tonari.at(a).push_back(b);
    tonari.at(b).push_back(a);
  }
  
  
  //bfs
  queue<int> q;
  vector<string> color(n, "white");
  vector<int> mae(n, -1);//直前の頂点
  q.push(0);
  color.at(0) = "gray";
  
  while(!q.empty()){
    int u = q.front();
    q.pop();
    color.at(u) = "black";
    for(int v: tonari.at(u)){
      if(color.at(v) == "white"){
        mae.at(v) = u;
        q.push(v);
        color.at(v) = "gray";
      }
    }
  }
  
  
  cout << "Yes" << endl;
  for(int i = 1; i < n; i++){
    int ans = mae.at(i);
    ans++;//
    cout << ans << endl;
  }
}

Measured memory_bytes: 13380
X = int(input())

if X >= 400 and 599 >= X:
  print("8")
elif X >= 600 and 799 >= X:
  print("7")
elif X >= 800 and 999 >= X:
  print("6")
elif X >= 1000 and 1199 >= X:
  print("5")
elif X >= 1200 and 1399 >= X:
  print("4")
elif X >= 1400 and 1599 >= X:
  print("3")
elif X >= 1600 and 1799 >= X:
  print("2")
elif X >= 1800 and 1999 >= X:
  print("1")

Measured memory_bytes: 9028