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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

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

int H,W;
string S[222];

int dp[2][1<<16];
int pc[1<<16];
signed main(){
    cin.tie(0);ios_base::sync_with_stdio(0);

    for(int i=0;i<1<<16;i++)pc[i]=__builtin_popcount(i);
    cin>>H>>W;
    S[0]="";
    rep(i,H)cin>>S[i+1];

    fill_n(*dp,2*(1<<16),INT_MIN);
    dp[0][0]=0;
    int mask=(1<<W)-1;
    for(int t=0;t<H*W;t++){
            const int i=t/W,j=t%W,p=t&1,q=(t+1)&1;

            for(int k=0;k<(1<<W);k++){
                if(dp[p][k]==INT_MIN)continue;
                chmax(dp[q][(k<<1)&mask],dp[p][k]);

                int l=pc[k&((1<<j)-1)];
                if(l<S[i+1].size()){
                    int po=0;
                    if(j&&(k&1)&&S[i+1][l]==S[i+1][l-1])po++;
                    if(k>>(W-1)&1){
                        int m=S[i].size()-pc[k]+l;
                        if(S[i][m]==S[i+1][l])po++;
                    }
                    chmax(dp[q][((k<<1)&mask)+1],dp[p][k]+po*2);
                }
                dp[p][k]=INT_MIN;
            }

        if(j==W-1)for(int k=0;k<1<<W;k++)if(pc[k]!=S[i+1].size())dp[q][k]=INT_MIN;
    }

    int ans=INT_MIN;
    rep(i,1<<W)chmax(ans,dp[(H*W)&1][i]);
    cout<<ans<<endl;
    return 0;
}

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

using namespace std;

typedef long long int Int;

int main(void)
{
    string s;
    int a,b;
    cin>>s;

    for(int i = 0;i < s.size();i++)
    {
	if(s[i] == 'A')
	{
	    a = i;
	    break;
	}
    }

    for(int i = s.size()-1;i >= 0;i--)
    {
	if(s[i] == 'Z')
	{
	    b = i;
	    break;
	}
    }

    cout<<b-a+1<<endl;

    return 0;
}


Measured memory_bytes: 640
#include <stdio.h>
#include <vector>
#include <iostream>

using namespace std;

int main() {
    int n, i;
    cin >> n;
    long sum_mod = 0;

    for (i=1;i<n+1;i++){
        if (i == n)
            break;
        sum_mod +=  i;
    }
    cout << sum_mod << endl;
}



Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);

		int d = sc.nextInt();

		int count[] = new int[100];
		for(int i = 2; i <= d; i++){
			int n = i;
			int div = 2;

			while(n > 1){
				if(n%div == 0){
					n /= div;
					count[div]++;
				}
				else{
					div++;
				}
			}
		}

//		for(int i = 1; i <= 20; i++){
//			System.out.print(count[i] + " " );
//		}
//		System.out.println();
		int moreThan4 = 0;
		int moreThan2 = 0;
		int moreThan14 = 0;
		int moreThan24 = 0;

		for(int i = 0; i < count.length; i++){
			if(count[i] >= 4){
				moreThan4++;
			}
			if(count[i] >= 2){
				moreThan2++;
			}
			if(count[i] >= 14){
				moreThan14++;
			}
			if(count[i] >= 24){
				moreThan24++;
			}
		}

//		System.out.println(moreThan4 + " " + moreThan2);
		int result;
		if(moreThan4 >= 2 && moreThan2 >= 3){
			result = moreThan4*(moreThan4 - 1)/2 * (moreThan2 - 2);// - moreThan4*(moreThan4 - 1)*(moreThan4 - 2)/6;

			if(moreThan14 > 0){
				result += moreThan14*(moreThan4 - 1);// - moreThan14*(moreThan14 - 1)/2;
			}
			if(moreThan24 > 0){
				result += moreThan24*(moreThan2 - 1);// - moreThan24*(moreThan24 - 1)/2;
			}

			if(count[2] >= 74){
				result++;
			}
		}
		else {
			result = 0;
		}

		System.out.println(result);

	}

}


Measured memory_bytes: 23764
fun solve(s:String, t:String){
    val ls = s.length
    val lt = t.length
    var ans = lt
    for(i in 0..(ls-lt)){
        var tmp = lt
        for(j in 0 until lt){
            if(s[i+j] == t[j]){
                tmp -= 1
            }
        }
        ans = Math.min(ans,tmp)
    }

    println(ans)

}

fun main(){
    val s = readLine()!!
    val t = readLine()!!
    solve(s,t)
}

Measured memory_bytes: 35920
import sys
from collections import *
import heapq
import math
import bisect
from itertools import permutations,accumulate,combinations,product
from fractions import gcd
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
mod=pow(10,9)+7

n=int(input())
print((n+1)//2)

Measured memory_bytes: 66028
#include <bits/stdc++.h>
#define pb push_back
#define ll long long
#define vi vector<int>
#define vll vector<ll>
#define pi pair<int, int>
#define F first
#define S second
#define mp make_pair
#define um unordered_map
#define all(x) (x).begin(), (x).end() 
#define reps(i, j, k) for(auto i = j; i < k; ++i)
#define rep(i, j) reps(i, 0, j)
#define decs(i, j, k) for(auto i = j; i >= k; --i)
#define dec(i, j) decs(i, j, 0)
using namespace std;
int main()
{
	int n; cin >> n;
	vector<string> s(n);
	rep(i, n) cin >> s[i];
	rep(i, n) sort(all(s[i]));
	sort(all(s));
	s.pb("x");
	ll ans = 0, l = 0;
	reps(i, 1, n + 1)
	{
		if(s[i] != s[i - 1])
		{
			ans += ((i == l + 1) ? 0 : (i - l) * (i - l - 1) * 0.5);
			l = i;
		}
	}
	
	cout << ans;
	return 0;
}

Measured memory_bytes: 8064
/*  ex9_1
    Rikuta  */
#include <stdio.h>
//スタックに格納するデータの最大数
#define SIZE 10
//スタックの定義
typedef struct stack
{
    int size;
    int count;
    char data[SIZE];
    char *top;
} stack;
//スタックの初期化
void initialize_stack(stack *string);
//データの追加
void push(stack *string, char elem);
//データの取り出し
void pop(stack *string);
//stackの出力
void print_stack(stack *string);

int main(void)
{   
    //スタックを宣言
    stack string;
    //スタックを初期化
    initialize_stack(&string);
    while (1)
    {   
        //受け取る変数の宣言
        char temp_char;
        //入力
        scanf("%c", &temp_char);
        //入力が終了なら終わり
        if (temp_char=='\n')
        {
            break;
        }
        //Bが入力されたらスタックをpop
        if (temp_char=='B')
        {
            pop(&string);
        }
        //0,1ならそれをスタックにpush
        if (temp_char=='0'||temp_char=='1')        
        {
            push(&string, temp_char);
        }
    }
    //スタックを出力
    print_stack(&string);

    return 0;
}

//スタックの初期化
void initialize_stack(stack *string)
{   
    //スタックの要素数と最大の大きさとtopを初期化
    string->count = 0;
    string->size = SIZE;
    string->top = &(string->data[SIZE]);
}

//データの追加
void push(stack *string, char elem)
{   
    //スタックの長さが最大を超えていたら標準エラー出力
    if (string->count >= string->size)
    {
        fprintf(stderr, "Error: stack overflow. (x=%c)\n", elem);
        exit(1);
    }
    else
    {   
        //スタックのtopは一個戻り，戻ったtopに要素が入る．要素数が1増える．
        string->top--;
        *(string->top) = elem;
        string->count++;
    }
}

//データの取り出し
void pop(stack *string)
{   
    //データに何も入っていなかったら
    if (string->count > 0)
    {   
        //スタックのトップを奥へ，要素数が1減る
        string->top++;
        string->count--;
    }
}

void print_stack(stack *string)
{   
    //ポインタの宣言
    char *pointer;
    //ポインタはスタックの一番古い要素を指す
    pointer = string->top+string->count-1;
    for (int i = 0; i < string->count; i++)
    {   
        //ポインタがさす要素を新しくしながら出力していく．
        printf("%c", *(pointer--));
    }
    //改行
    printf("\n");
}


Measured memory_bytes: 1596
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=1e4+7;
int main()
{
	int len,k;cin>>len>>k;
	string s;cin>>s;//vector<int> vv;
	queue< pair<int,int> > q;
	int ans=0;int left=0,right=0;
	for(int i=0;i<len;)
	{
		while(s[i]=='1') i++;
		right=i-1;ans=max(ans,right-left+1);
		int l=i;int r=0;
		while(s[i]=='0') i++;
		r=i-1;
		if(q.size()<k)
		{
			q.push(make_pair(l,r));
			ans=max(ans,right-left+1);
		}
		else
		{
			pair<int,int> x;
			x=q.front();q.pop();
			left=x.second+1;
			q.push(make_pair(l,r));
		}
	}
	while(!q.empty())
	{
		pair<int,int> x;
		x=q.front();q.pop();
		right=x.second;ans=max(ans,right-left+1);
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 640
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

N = int(input())
A = list(map(int, input().split()))

even = len(list(filter(lambda x: x % 2 == 0, A)))
even2 = len(list(filter(lambda x: x % 4 == 0, A)))
odd = N-even
ans = "No"
if even == N:
    ans = "Yes"
if even-even2 == 0:
    if odd <= even2+1:
        ans = "Yes"
else:
    if odd <= even2:
        ans = "Yes"
print(ans)


Measured memory_bytes: 14252
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define MOD 1000000007
#define INF (1<<30)
#define LINF (1LL<<60)
#define endl "\n"
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
typedef unsigned long long int ull;
typedef long long lint;
 
int main(void){
    int N;
    cin >> N;
    int A[N];
    rep(i,N) cin >> A[i];
    cout << *max_element(A,A+N)-*min_element(A,A+N) << endl;
}

Measured memory_bytes: 256
n,m=map(int,input().split())
num=[[] for i in range(n)]
p=[0]*m
y=[0]*m
for i in range(m):
  p[i],y[i]=map(int,input().split())
  num[p[i]-1].append((i,y[i]))
score=['']*m
for i in range(n):
  num[i].sort(key=lambda x:x[1])
  idx=1
  for s,t in num[i]:
    score[s]=str(i+1).zfill(6)+str(idx).zfill(6)
    idx+=1
print(*score,sep='\n')

Measured memory_bytes: 42268
import java.util.*;
public class Main {
    public static void main(final String[] args){
        final Scanner sc = new Scanner(System.in);
        
        final int n = sc.nextInt();
        int number[] = new int[n];
        for (int i = 0; i < n; i++) {
            number[i] = sc.nextInt();
        }
        Arrays.sort(number);
        for (int i = 0; i < n - 1; i++) {
            if(number[i] == number[i + 1]){
                System.out.println("NO");
                return;
            }

        }
        System.out.println("YES");
    }
}

Measured memory_bytes: 62960
a = input()

iseasy = "Yes"
odd_l = ["R","U","D"]
even_l = ["L","U","D"]
try:
	for i in range(0,int(len(a)/2+1)):
		if a[2*i] in odd_l: 
			pass
		else: 
			iseasy = "No"
			break
		if a[2*i+1] in even_l: 
			pass
		else:
			iseasy = "No"
			break
except IndexError as e:
	pass
print(iseasy)


Measured memory_bytes: 3060
# -*- coding: utf-8 -*-
import numpy as np
inputs = input().split()
A = int(inputs[0])
B = int(inputs[1])
K = int(inputs[2])


if A + K < B - K:
    candidates = np.concatenate([np.arange(A, A + K), np.arange(B - K + 1, B + 1)])
else:
    candidates = np.arange(A, B + 1)
    candidates = candidates[np.logical_or(candidates < A + K, candidates > B - K)]

for s in candidates:
    print(s)


Measured memory_bytes: 12408
#include <bits/stdc++.h>
#define int long long
#define pii pair<int,int>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(c) (c).begin(),(c).end()
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define FINF(a) memset(a,0x3f,sizeof(a))
#define POW(n) (1LL<<(n))
#define IN(i,a,b) (a <= i && i <= b)
using namespace std;
template <typename T> inline bool CHMIN(T& a,T b) { if(a>b) { a=b; return 1; } return 0; }
template <typename T> inline bool CHMAX(T& a,T b) { if(a<b) { a=b; return 1; } return 0; }
template <typename T> inline void SORT(T& a) { sort(ALL(a)); }
template <typename T> inline void REV(T& a) { reverse(ALL(a)); }
template <typename T> inline void UNI(T& a) { sort(ALL(a)); a.erase(unique(ALL(a)),a.end()); }
const int MOD = 1000000007;
const int INF = 0x3f3f3f3f3f3f3f3f;
const double EPS = 1e-10;
/* ---------------------------------------------------------------------------------------------------- */

int H,W;

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

  cin >> H >> W;
  int S = H*W;
  int ans = INF;
  for (int i = 1; i <= H; i++) {
    int A = i*W;
    int rem = S-A;
    int B = (H-i)*(W/2);
    int C = rem-B;
    CHMIN(ans,max({A,B,C})-min({A,B,C}));
  }
  for (int i = 1; i <= H; i++) {
    int A = i*W;
    int rem = S-A;
    int B = ((H-i)/2)*W;
    int C = rem-B;
    CHMIN(ans,max({A,B,C})-min({A,B,C}));
  }
  for (int i = 1; i <= W; i++) {
    int A = i*H;
    int rem = S-A;
    int B = (W-i)*(H/2);
    int C = rem-B;
    CHMIN(ans,max({A,B,C})-min({A,B,C}));
  }
  for (int i = 1; i <= W; i++) {
    int A = i*H;
    int rem = S-A;
    int B = ((W-i)/2)*H;
    int C = rem-B;
    CHMIN(ans,max({A,B,C})-min({A,B,C}));
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#pragma region Macros
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i, n) for(int i=(n); i>=0; --i)
#define FOR(i, n, m) for(int i=(m), i##_len=(n); i<i##_len; ++i)
#define EACH(i, v) for(const auto& i : v)
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<class Value>using vec = vector< Value >;
using ll = long long;
using P = pair< long long, long long >;
#define fi first
#define se second
#define el endl
#pragma endregion


void Main();

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

void Main(){
    ll N;
    cin >> N;
    priority_queue<int> a;
    REP(i, N){
        int a_i;
        cin >> a_i;
        a.push(a_i);
    }
    ll s1=0, s2=0;
    for(int i=0; !a.empty(); i++){
        if(i%2){
            s2+=a.top();a.pop();
        }else{
            s1+=a.top();a.pop();
        }
    }
    cout << s1-s2 << el;

}



Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
    int N; cin >> N;
    if(N < 105) cout << 0;
    else if(N < 135) cout << 1;
    else if(N < 165) cout << 2;
    else if(N < 189) cout << 3;
    else if(N < 195) cout << 4;
    else cout << 5 << endl;
}

Measured memory_bytes: 256
a,b=map(int,input().split())
s=input()
check=0
if s[a]!="-":
    check=1
if check==0:
    for i in range(a+b+1):
        if i==a:
            continue
        if s[i] not in "0123456789":
            check=1
            break
print("Yes" if check==0 else "No")

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pl;
typedef vector<pl> vp;
#define fore(i,a,b) for(ll i=(a);i<=(b);++i)
#define rep(i,n) fore(i,0,(n)-1)
#define rfore(i,a,b) for(ll i=(b);i>=(a);--i)
#define rrep(i,n) rfore(i,0,(n)-1)
#define all(x) (x).begin(),(x).end()
const ll INF=1001001001;
const ll LINF=1001001001001001001;
const ll D4[]={0,1,0,-1,0};
const ll D8[]={0,1,1,0,-1,-1,1,-1,0};
template<class T>
bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>
bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
template<class T>
ll sum(const T& a){return accumulate(all(a),0LL);}

void solve(){
    ll n,m,l;cin>>n>>m>>l;
    vvl a(n,vl(m));rep(i,n)rep(j,m)cin>>a[i][j];
    vvl b(m,vl(l));rep(i,m)rep(j,l)cin>>b[i][j];

    vvl c(n,vl(l));
    rep(i,n){
        rep(j,l){
            rep(k,m){
                c[i][j]+=a[i][k]*b[k][j];
            }
        }
    }
    rep(i,n){
        rep(j,l){
            if(j>0)cout<<" ";
            cout<<c[i][j];
        }
        cout<<endl;
    }
}

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



Measured memory_bytes: 3344
#include<iostream>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int main(){
    char c,k;
    int ans=0;
    scanf("%c",&c);
    printf("%c",c);
    while(scanf("%c",&c)!=-1){
        //记住cin输入失败返回0，scanf输入失败返回-1
        if(c==' '||c=='\n')break;
        ans++;
        k=c;
    }
    printf("%d%c",ans-1,k);
    return 0;
}

Measured memory_bytes: 256
from collections import deque

h,w = map(int,input().split())
S = [input() for i in range(h)]

queue = deque([[0,0]])
visited = [[-1 for i in range(w)]for j in range(h)]
visited[0][0] = 1
while queue:
    x,y = queue.popleft()
    if x!=0:
        if S[x-1][y] == '.' and visited[x-1][y] == -1:
            queue.append([x-1,y])
            visited[x-1][y] = visited[x][y] + 1
    if x!=h-1:
        if S[x+1][y] == '.' and visited[x+1][y] == -1:
            queue.append([x+1,y])
            visited[x+1][y] = visited[x][y] + 1
    if y!=0:
        if S[x][y-1] == '.' and visited[x][y-1] == -1:
            queue.append([x,y-1])
            visited[x][y-1] = visited[x][y] + 1
    if y!=w-1:
        if S[x][y+1] == '.' and visited[x][y+1] == -1:
            queue.append([x,y+1])
            visited[x][y+1] = visited[x][y] + 1

dots = 0
for i in range(h):
    for j in range(w):
        if S[i][j] == '.':
            dots += 1

if visited[h-1][w-1] != -1:
    print(dots-visited[h-1][w-1])
else:
    print(-1)

Measured memory_bytes: 3316
#include<bits/stdc++.h>
using namespace std;
string a[1005000];
long long int u,o,cou,alld,b[7];

int ccc(int n, int r)
{
    if (r == 0 || r == n)
        return (1);
    else if (r == 1)
        return (n);
    return (ccc(n - 1, r - 1) + ccc(n - 1, r));
}

int main(){
    cin>>o;
    for(int i=0;i<o;i++){
        cin>>a[i];
        if(a[i][0]=='M'){if(b[1]==0){cou++;}b[1]++;}
        if(a[i][0]=='A'){if(b[2]==0){cou++;}b[2]++;}
        if(a[i][0]=='R'){if(b[3]==0){cou++;}b[3]++;}
        if(a[i][0]=='C'){if(b[4]==0){cou++;}b[4]++;}
        if(a[i][0]=='H'){if(b[5]==0){cou++;}b[5]++;}
    }
    if(cou<3){cout<<"0"<<endl; return 0;}
    if(1)alld+=b[1]*b[2]*b[3];
    if(2)alld+=b[1]*b[2]*b[4];
    if(3)alld+=b[1]*b[2]*b[5];
    if(4)alld+=b[1]*b[3]*b[4];
    if(5)alld+=b[1]*b[3]*b[5];
    if(6)alld+=b[1]*b[4]*b[5];
    if(7)alld+=b[2]*b[3]*b[4];
    if(8)alld+=b[2]*b[3]*b[5];
    if(9)alld+=b[2]*b[4]*b[5];
    if(10)alld+=b[3]*b[4]*b[5];
    cout<<alld<<endl;

}


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

typedef long long ll;

string s;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> s;
    int r = s.length() - 1;
    int l = 0;
    while (s[l] != 'A')
        ++l;
    while (s[r] != 'Z')
        --r;
    cout << r - l + 1 << endl;

    return 0;
}



Measured memory_bytes: 3756
#include "bits/stdc++.h"
#pragma GCC optimize "03"
using namespace std;
 
#define int long long int
#define ld long double
#define pi pair<int, int>
#define pb push_back
#define fi first
#define se second
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#ifndef LOCAL
#define endl '\n'
#endif
 
const int N = 1e5 + 5;
const int mod = 1e9 + 7;
const int inf = 1e9 + 9;

map<int, int> m;
 
int f(int x){
    if(m.find(x) != m.end())
        return m[x];
    if(x == 1)
        m[x] = 1;
    else 
        m[x] = 2*f(x/2) + 1;
    return m[x];
}

signed main() {
    IOS;
    int h;  cin >> h;
    cout << f(h) << endl;   
    return 0;
}

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

int main() {
  int A,B,K;
  int d;
  cin >> A >> B >> K;
  
  for (d=min(A,B); d >= 1; --d) {
    if (A % d == 0&& B % d == 0) --K;
    if (K == 0) break;
  }
  cout << d << endl;
}


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

int main(){
	int N; cin >> N;
	vector<int> A;
	A.resize(N);

	for(int i = 0; i < N; ++i) cin >> A[i];
	sort(A.begin(), A.end(), greater<int>());

	int a_size = A.size();
	for(;;){
		int a_size_i = a_size;
		for(int i = a_size_i-2; i >= 0; --i){
			A[i] = A[i] % A[a_size_i-1];
			if(A[i] == 0) a_size--;
			// cout << "i:" << i << ", A:" << A[i] << endl;
		}
		sort(A.begin(), A.end(), greater<int>());
		if(a_size <= 1) break;
	}

	cout << A[0] << endl;

	return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using ll = long long;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define all(v) v.begin(), v.end()
#define sz(v) v.size()
#define INF 100000000000000 //10^14
template <typename T>
bool chmax(T &a, const T& b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <typename T>
bool chmin(T &a, const T& b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

int op(int a, int b){
  return max(a, b);
}

int e(){
  return -1;
}

int v;

bool f(int x){
  return x < v;
}

int main()
{
    int N, Q;
    cin >> N >> Q;
    vector<int> A(N);
    rep(i, N) cin >> A.at(i);
    segtree<int, op, e> seg(A);
    rep(i, Q){
      ll T;
      cin >> T;
      if(T == 1){
        ll X, V;
        cin >> X >> V;
        X--;
        seg.set(X, V);
      }
      if(T == 2){
        ll L, R;
        cin >> L >> R;
        L--;
        R--;
        cout << seg.prod(L, R+1) << endl;
      }
      if(T == 3){
        ll X, V;
        cin >> X >> V;
        X--;
        v = V;
        cout << seg.max_right<f>(X)+1 << endl;
      }
    }
}

Measured memory_bytes: 6104
#include <iostream>
#include <iomanip> // << fixed << setprecision(xxx)
#include <algorithm> // do { } while ( next_permutation(A, A+xxx) ) ;
#include <vector>
#include <string> // to_string(nnn) // substr(m, n) // stoi(nnn)
#include <complex>
#include <tuple> // get<n>(xxx)
#include <queue>
#include <stack>
#include <map> // if (M.find(key) != M.end()) { }
#include <set> // S.insert(M);
// if (S.find(key) != S.end()) { }
// for (auto it=S.begin(); it != S.end(); it++) { }
// auto it = S.lower_bound(M);
#include <random> // random_device rd; mt19937 mt(rd());
#include <cctype>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib> // atoi(xxx)
using namespace std;

#define DEBUG 0 // change 0 -> 1 if we need debug.
// insert #if<tab> by my emacs. #if DEBUG == 1 ... #end

typedef long long ll;

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

// const int C = 1e6+10;
// const ll M = 1000000007;

int main () {
  int a[3];
  cin >> a[0] >> a[1] >> a[2];
  sort(a, a+3);
  cout << a[0] + a[1] << endl;
}


Measured memory_bytes: 256
// In the name of God

#include <bits/stdc++.h>

using namespace std;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int n, m;
	cin >> n >> m;
	priority_queue<int> pq;
	for(int i = 0; i < n; i++) {
		int x;
		cin >> x;
		pq.push(-x);
	}
	vector<pair<int,int>> v;
	for(int i = 0; i < m; i++) {
		int x, y;
		cin >> x >> y;
		v.push_back(make_pair(y, x));
	}
	sort(v.begin(), v.end());
	reverse(v.begin(), v.end());
	for(int i = 0; i < m; i++) {
		int x = v[i].second, y = v[i].first;
		while(-pq.top() < y && x) {
			x--;
			pq.pop();
			pq.push(-y);
		}
	}

	long long s = 0;
	while(pq.size()) {
		s += -pq.top();
		pq.pop();
	}

	cout << s;

	
		
	return 0;
}


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

int main()
{
  int a,x,y,r;

  scanf("%d%d",&x,&y);
  if(x<y){
    a=y;
    y=x;
    x=a;
  }
  
  while(y>0)
    {
      r=x%y;
      x=y;
      y=r;
    }

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

  return 0;
}


Measured memory_bytes: 2108
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define F first
#define S second
#define pb push_back
mt19937 rnd;


int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
#endif

    int k, a, b;
    cin >> k >> a >> b;
    if (b / k - (a - 1) / k > 0) {
        cout << "OK\n";
    }
    else {
        cout << "NG\n";
    }

#ifdef LOCAL
    cerr << "\nTime elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
    return 0;
}


Measured memory_bytes: 3656
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
const int MAX =1e5+6;
const long long inf=1e18;
int main(){
	string s;
	int n;
	cin>>n;
	cin>>s;
	if(n<3200)
		cout<<"red";
	else
		cout<<s;


}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <algorithm>
#include <numeric>
#include <math.h>
using namespace std;

#define N_MAX   (100000)
#define LL_MAX_NUM (1LL<<60)

typedef long long ll;
typedef long long int lli;

int main() {
    int K, res;
    cin >> K;
    
    for (int i = 2; i <= K; i+=2) {
        for (int j = 1; j <= K; j+=2) {
            res++;
        }
    }
    cout << res << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <iostream>
#include <bitset>
#include <cassert>
#include <queue>
#include <random>
#include <stack>
#include <iomanip>
#include <math.h>
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)n; i++)
#define repf(i, a, b) for (ll i = (ll)a; i < (ll)b; i++)
#define repr(i, a, b) for (ll i = (ll)a; i > (ll)b; i--)
#define repv(x, arr) for (auto &x : arr)
#define all(v) (v).begin(), (v).end()
#define vec(name, num) vector<ll> name((num), 0);
#define mp(a, b) make_pair(a, b)
#define F first
#define S second
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<int> vii;
typedef vector<vii> vvii;
const ll mod = 1e9 + 7;
const int infi = 2147483600;
const ll infl = 1e17;


struct point{
    ll MAX, MIN;
};

int main()
{

    std::cout << std::fixed;
    int n;
    cin >> n;
    point pl, pr, pu, pd,px,py;
    pl.MAX = -infl;
    pl.MIN = infl;
    pr.MAX = -infl;
    pr.MIN = infl;
    pu.MAX = -infl;
    pu.MIN = infl;
    pd.MAX = -infl;
    pd.MIN = infl;
    px.MAX = -infl;
    px.MIN = infl;
    py.MAX = -infl;
    py.MIN = infl;
    rep(i, n)
    {
        ll x, y;
        char d;
        cin >> x >> y >> d;
        if (d =='R')
        {
            py.MAX = max(py.MAX, y);
            py.MIN = min(py.MIN, y);
            pr.MAX = max(pr.MAX, x);
            pr.MIN = min(pr.MIN, x);
        }
        if (d =='L')
        {
            py.MAX = max(py.MAX, y);
            py.MIN = min(py.MIN, y);
            pl.MAX = max(pl.MAX, x);
            pl.MIN = min(pl.MIN, x);
        }
        if (d =='U')
        {
            px.MAX = max(px.MAX, x);
            px.MIN = min(px.MIN, x);
            pu.MAX = max(pu.MAX, y);
            pu.MIN = min(pu.MIN, y);
        }
        if (d =='D')
        {
            px.MAX = max(px.MAX, x);
            px.MIN = min(px.MIN, x);
            pd.MAX = max(pd.MAX, y);
            pd.MIN = min(pd.MIN, y);
        }
    }
    ld ans = infl;
    rep(t,2e8+1){
        ld now = t / 2.0;
        ld xmax, xmin, ymax, ymin;
        xmax = max((ld)px.MAX, max(pl.MAX - now, pr.MAX + now));
        xmin = min((ld)px.MIN, min(pl.MIN - now, pr.MIN + now));
        ymax = max((ld)py.MAX, max(pu.MAX + now, pd.MAX - now));
        ymin = min((ld)py.MIN, min(pu.MIN + now, pd.MIN - now));
        ans = min(ans, (xmax - xmin) * (ymax - ymin));
    }

    cout << setprecision(10) << ans << endl;
}


Measured memory_bytes: 384
n = int(input())
l1 = list(map(int, input().split()))
l2 = list(map(int, input().split()))

max = 0
for i in range(1, n+1):
        max_rep = 0
        max_rep += sum(l1[0:i]) + sum(l2[i-1:])
        if max < max_rep: max = max_rep

print(max)

Measured memory_bytes: 3060
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i)
using namespace std;
typedef long long ll;
const int INF = 1001001001;

int main() {
    string S, T;
    int ans=0;

    cin >> S >> T;

    rep(i,3) {
        if(S[i]==T[i]) {
            ans++;
        }
    }

    cout << ans << endl;

    return 0;
    
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rep2(i,s,n) for (int i = s; i < n; ++i)
#define all(a) a.begin(),a.end()
#define tmax(a,b,c) max(a,max(b,c))
#define tmin(a,b,c) min(a,min(b,c))
#define pb push_back
using namespace std;
using ll = long long;
using P = pair<int,int>;
template<class T> inline bool chmin(T& a,T b) {if(a > b){a = b; return true;} return false;}
template<class T> inline bool chmax(T& a,T b) {if(a < b){a = b; return true;} return false;}
const int inf = 1001001001;

int main() {
    string s,t;
    cin >> s >> t;
    vector<vector<int>> dp(s.size()+1,vector<int>(t.size()+1,0));
    rep2(i,1,s.size()+1) rep2(j,1,t.size()+1) {
        dp[i][j] = max(dp[i-1][j],dp[i][j-1]);
        if(s[i-1] == t[j-1]) chmax(dp[i][j],dp[i-1][j-1]+1);
    }
    int n = dp[s.size()][t.size()];
    int i = s.size()-1;
    int j = t.size()-1;
    string ans;
    while(ans.size() < n) {
        if(s[i] == t[j]) {
            ans += s[i];
            i--; j--;
        }
        else {
            if(dp[i+1][j+1] == dp[i+1][j]) j--;
            else i--;
        }
    }
    reverse(all(ans));
    cout << ans << endl;
}

Measured memory_bytes: 35584
#include <bits/stdc++.h>
#define SORT(a) sort(a.begin(), a.end())
#define RSORT(a) sort(a.rbegin(), a.rend())
#define REP(i, n) for (long long i = 0; i < n; i++)
#define RREP(i, n) for (long long i = n - 1, 0 <= i; i--)
#define FOR(i, start, end) for (long long i = start; i < end; i++)
#define RFOR(i, start, end) for (long long i = start - 1; 0 <= i; i--)
#define ALL(a) a.begin(), a.end()
#define MOD(a) a %= 1'000'000'007
using ll = long long;
using namespace std;
const int INF32       = 1'050'000'000;
const long long INF64 = 4'000'000'000'000'000'000;
const int MOD7        = 1'000'000'007;
const int MOD9        = 1'000'000'009;
template <class T> inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
void print() { std::cout << '\n'; }
template <class H, class... T> void print(H &&head, T &&... args) {
    std::cout << head;
    sizeof...(args) == 0 ? std::cout << "" : std::cout << ' ';
    print(std::forward<T>(args)...);
}
template <class T> void print(std::vector<T> &v) {
    for (int i = 0; i < v.size(); i++) {
        std::cout << v[i];
        i == v.size() - 1 ? std::cout << '\n' : std::cout << ' ';
    }
}
template <class T> void print(std::vector<std::vector<T>> &v) {
    for (int i = 0; i < v.size(); i++) {
        for (int j = 0; j < v[i].size(); j++) {
            std::cout << v[i][j];
            j == v[i].size() - 1 ? std::cout << '\n' : std::cout << ' ';
        }
    }
}
// 配列を圧縮する。first に値、second に個数
template <class T> vector<pair<T, int>> run_length(vector<T> &v) {
    vector<pair<T, int>> ans;
    ans.emplace_back(v[0], 1);
    T now   = v[0];
    int cnt = 0;
    for (int i = 1; i < v.size(); i++) {
        if (v[i] == now) {
            ans[cnt].second++;
        } else {
            ans.emplace_back(v[i], 1);
            now = v[i];
            cnt++;
        }
    }
    return ans;
}
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);

    int N;
    cin >> N;
    vector<int> a, b;
    REP(i, N) {
        int x;
        cin >> x;
        if (i % 2 == 0)
            a.emplace_back(x);
        else
            b.emplace_back(x);
    }
    SORT(a);
    SORT(b);
    auto aa = run_length(a);
    auto bb = run_length(b);
    sort(ALL(aa), [](const pair<int, int> x, const pair<int, int> y) {
        return x.second > y.second;
    });
    sort(ALL(bb), [](const pair<int, int> x, const pair<int, int> y) {
        return x.second > y.second;
    });
    ll sum;
    if (aa[0].first == bb[0].first) {
        if (1 < aa.size() && 1 < bb.size())
            sum = max(aa[0].second + bb[1].second, aa[1].second + bb[0].second);
        else
            sum = max(aa[0].second, bb[0].second);
    } else {
        sum = aa[0].second + bb[0].second;
    }
    ll ans = N - sum;
    print(ans);

    return 0;
}

Measured memory_bytes: 1784
object Main extends App {
  val Array(n, k) = io.StdIn.readLine().split(' ').map(_.toInt)
  val k2 = k*2  
  // 0 ≦ x,y ≦ 2K に圧縮
  val squares = Array.fill(k2)(Array.fill(k2)(0))
  for (i <- 1 to n) {
    val Array(x, y, color) = io.StdIn.readLine().split(' ')
    // 'W'はY方向にKずらした'B'と同値
    squares(x.toInt % k2)((y.toInt + (if (color == "B") 0 else k)) % k2) += 1
  }
  // 計算量削減のために累積和を事前算出
  for {
    i <- 0 until k2
    j <- 1 until k2
  } squares(i)(j) += squares(i)(j-1)
  for {
    j <- 0 until k2
    i <- 1 until k2
  } squares(i)(j) += squares(i-1)(j)
  var max = 0
  val end = k2-1
  for {
    i <- 0 until k
    j <- 0 until k
  } {
    // ex) k = 2
    //      ■ □ □ ■ 
    //  j+k □ ■ ■ □
    //      □ ■ ■ □
    //    j ■ □ □ ■
    //      i   i+k
    val cnt =
      (squares(i)(j)) +
      (squares(end)(j) - squares(i+k)(j)) +
      (squares(i+k)(j+k) - squares(i+k)(j) - squares(i)(j+k) + squares(i)(j)) +
      (squares(i)(end) - squares(i)(j+k)) +
      (squares(end)(end) - squares(end)(j+k) - squares(i+k)(end) + squares(i+k)(j+k))
    max = Math.max(Math.max(cnt, n - cnt), max)
  }
  print(max)
}


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

int main() {
  int N,K;
  cin >> N >> K;;
  string S;
  cin >> S;
  K--;
  if(S.at(K) == 'A'){
    S.at(K)='a';
  }
  else if( S.at(K)=='B'){
    S.at(K)='b';
  }
  else if(S.at(K)=='C'){
    S.at(K)='c';
  }
  cout << S <<endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <queue>
#include <stack>
#include <utility>
#include <vector>
using std::cin;
using std::cout;
using std::endl;

struct Shop {
  int64_t amount;
  int64_t cost;
  Shop(int a, int b) {
    cost = a, amount = b;
  }
  bool operator<(const Shop &another) const {
    return cost < another.cost;
  }
  bool operator>(const Shop &another) const {
    return cost > another.cost;
  }
};

int main(void) {
  cout << std::fixed << std::setprecision(10);
  cin.tie(0);
  std::ios::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  std::vector<Shop> shop;
  for (int i = 0; i < n; i++) {
    int m1, m2;
    cin >> m1 >> m2;
    shop.push_back(Shop(m1, m2));
  }
  std::sort(shop.begin(), shop.end());
  int64_t result = 0;
  for (auto x : shop) {
    if (m - x.amount >= 0) {
      result += x.amount * x.cost;
      m -= x.amount;
    } else {
      result += m * x.cost;
      m = 0;
    }
  }
  cout << result << endl;
  return 0;
}


Measured memory_bytes: 2420
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
#include <random>

using namespace std;

#define int long long

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

int inp(int x) {
	int ans = 0;
	while (x % 2 == 0) {
		x /= 2;
		ans++;
	}
	return ans;
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);

	int n, m;
	cin >> n >> m;
	m *= 2;
	vector<int> a(n);
	set<int> in;
	for (auto &t : a) {
		cin >> t;
		in.insert(inp(t));
	}    
	if (in.size() > 1) {
		cout << 0 << endl;
		exit(0);
	}
	int l = 1;
	for (auto t : a) {
		l = lcm(l, t);
		if (l > m) {
			cout << 0 << endl;
			exit(0);
		}
	}
	int res = (m / l);
	// cerr << res << endl;
	res -= res / 2;
	cout << res << endl;
}   

Measured memory_bytes: 1024
#pragma warning (disable:4996)
#include"bits/stdc++.h"
#include<cassert>
#define int long long
#define MRE assert(0);
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
const long long mod = 998244353;
const long long inf = 1ll<<61;
typedef pair<int, int> P;
typedef pair<int, P > PP;
signed main() {
	int a, b; cin >> a >> b;
	rep(i, 1000000) {
		int A = i*108/100, B = i*11/10;
		if (A - i == a&&B - i == b) {
			cout << i << endl; return 0;
		}
	}cout << -1 << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <array>
#include <cstdint>
#include <functional>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <stdlib.h>
#include <string>
#include <time.h>
#include <utility>
#include <vector>

#define INF 1000000000
#define MOD 1000000007
#define rep(i,a,b) for(uint32 i = (a); i < (b); ++i)
#define bitget(a,b) (((a) >> (b)) & 1)
#define ALL(x) (x).begin(),(x).end()
#define C(x) std::cout << #x << " : " << x << std::endl
#define scanf scanf_s

using int32 = std::int_fast32_t;
using int64 = std::int_fast64_t;
using uint32 = std::uint_fast32_t;
using uint64 = std::uint_fast64_t;

template<typename T=uint32>
T gcd(T m, T n)
{
	T temp = m;
	temp %= n;
	while (temp) {
		m = n;
		n = temp;
		temp = m%n;
	}
	return n;
}

int main(void) {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	uint32 n,k;
	std::cin >> n >> k;
	std::vector<uint32> a(n);
	rep(i, 0, n)
		std::cin >> a[i];
	uint32 g, max = a[0];
	g = a[0];
	rep(i, 1, n) {
		g = gcd(g, a[i]);
		max = std::max(max, a[i]);
	}
	if (k > max || (k%g) != 0) {
		std::cout << "IMPOSSIBLE\n";
	}
	else {
		std::cout << "POSSIBLE\n";
	}
	return 0;
}

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

using namespace std;
typedef long long ll;

int main()
{
    ios_base::sync_with_stdio(0);
    int x, y, z;
    cin >> x >> y >> z;
    if (x == y && y == z)
        cout << "No\n";
    else if (x == y || x == z || y == z)
        cout << "Yes\n";
    else
        cout << "No\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pl;
typedef vector<ll> vl;
int main (void) {
    ios::sync_with_stdio(false);cin.tie(0);
    ll n,k; cin >> n >> k;
    if (n%k == 0) cout << 0 << '\n';
    else {
        ll d = n%k;
        cout << min(d,k-d) << '\n';
    }
    return 0;
}



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

int main()
{
    int a,b,c,x,t=0;
    cin>>a>>b>>c>>x;
    for(int i=0;i<=a;i++){
        for(int j=0;j<=b;j++){
            for(int k=0;k<=c;k++){
                if((i*500+j*100+k*50)==x)
                    t++;
            }
        }
    }
    cout<<t;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    int N;cin>>N;
    bool dp[200];
    for(int i=0;i<200;i++) {
        dp[i]=false;
    }
    dp[0]=true;
    for(int i=0;i<=N;i++){
        if(dp[i]) dp[i+4]=dp[i+7]=true;
    }
    if(dp[N]) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}


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

int main() {
  string S;
  cin >> S;
  if (S.back() == '2') return cout << "hon" << "\n", 0;
  if (S.back() == '4') return cout << "hon" << "\n", 0;
  if (S.back() == '5') return cout << "hon" << "\n", 0;
  if (S.back() == '7') return cout << "hon" << "\n", 0;
  if (S.back() == '9') return cout << "hon" << "\n", 0;
  if (S.back() == '0') return cout << "pon" << "\n", 0;
  if (S.back() == '1') return cout << "pon" << "\n", 0;
  if (S.back() == '6') return cout << "pon" << "\n", 0;
  if (S.back() == '8') return cout << "pon" << "\n", 0;
  if (S.back() == '3') return cout << "bon" << "\n", 0;
}

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

int main(){
  ll n,m,c;
  cin>>n>>m>>c;
  ll b[m],a[n][m];
  for(ll i=0;i<m;i++){
     cin>>b[i];
  }
  for(ll i=0;i<n;i++){
     for(ll j=0;j<m;j++){
        cin>>a[i][j];
     }
  }
  ll sum=0,coun=0;
  for(ll i=0;i<n;i++){
     for(ll j=0;j<m;j++){
        sum+=a[i][j]*b[j];
     }
     if((sum+c)>0)
        coun++;

     sum=0;
  }

  cout<<coun<<endl;
  return 0;
}


Measured memory_bytes: 256
H,W,N = map(int, input().split())

field = {}
for i in range(N):
    a,b = map(int, input().split())
    a,b = a-1,b-1
    for j in range(a-1, a+2):
        for k in range(b-1, b+2):
            if not field.get(j):
                field[j] = {}
            if not field[j].get(k):
                field[j][k] = 0
            field[j][k] += 1

ans = [0] * 10
for kh in field.keys():
    for kw in field[kh].keys():
        if 1 <= kh <= H-2 and 1 <= kw <= W-2:
            ans[field[kh][kw]] += 1

tmp = (H-2)*(W-2)
for i in range(1,10):
    tmp -= ans[i]

ans[0] = tmp
for i in range(10):
    print(ans[i])



Measured memory_bytes: 155204
#include<vector>
#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include <iostream>
#include <algorithm>
#include <map>
#include <cmath>
#include<queue>
#include <sstream>
#include <set>

const long long INF = 1000000007;
using namespace std;
typedef long long llong;

//int isalpha(char ch): ch がアルファベットなら true を返す
//int isdigit(char ch): ch が数字なら true を返す
//int islower(char ch): ch が小文字なら true を返す
//int isupper(char ch): ch が大文字なら true を返す
//int tolower(char ch): ch の小文字を返す
//int toupper(char ch): ch の大文字を返す

//string型
//size()	文字数を返す
//Insert()	（指定した場所に）文字・文字列を挿入する
//erase()	（指定した場所の）文字・文字列を削除する
//clear()	すべての文字を削除する
//substr()	文字列の（指定した）部分文字列を返す
//replace()	（指定した）部分文字列を新しい文字列に置換する
//c_str()変換
//文字列の比較は、<=や==などを使え
//replace関数を使い、簡単に文字列を置換
//リバース関数：reverse(str.begin(), str.end());
//map<type, type> dict;で宣言
//グラフ理論用変数
//vector<vector<llong> > graph(N);

//ソート
//降順sort(v.begin(), v.end(), std::greater<Type>());

//大文字から小文字へんかん
//w[i] = w[i]-'A'+'a';

//vector
//assignメソッド　引数：サイズ、値
//与えられたサイズと値でvectorを初期化する

//queueクラス
//find()次に取り出す値の表示をする。
//pop()値を取り出す。戻り値はなし
//push()キューに値をプッシュする

//priority_queueクラス

//切り上げ
//ceil
//floor

int main(){
    llong N,X;
    cin >> N >> X;
    vector<llong> A(N,0);
    llong minv  = INF;
    llong total = 0;
    for(int i=0; i<A.size(); i++){
        cin >> A[i];
        minv = min(minv, A[i]);
        total = total + A[i];
    }
    if((X-total)<=0){
        cout << N << endl;
    }else{
        cout << N+(X-total)/minv << endl;
    }
    return 0;
}


Measured memory_bytes: 3140
def main():
    n, k = map(int, input().split())

    # ダブリング
    d = 60
    to = [[0 for _ in range(n)]
          for _ in range(d)]  # to[i][j] : 町jから2**i回ワープした町
    to[0] = list(map(int, input().split()))

    for i in range(1, d):
        for j in range(n):
            to[i][j] = to[i - 1][to[i - 1][j] - 1]

    v = 1
    for i in range(d, -1, -1):
        l = 2 ** i  # 2**i回ワープする

        if l <= k:
            v = to[i][v - 1]
            k -= l

        if k == 0:
            break

    print(v)


if __name__ == "__main__":
    main()


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

#define REP(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define REPS(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define RREP(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define RREPS(i, n) for (int i = ((int)(n)); i > 0; i--)
#define IREP(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define IREPS(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RVISORT(v) sort(v.begin(), v.end(), greater<int>());
#define ALL(v) v.begin(), v.end()
#define MP(n, m) make_pair(n, m);
#define COUT(d) cout<<std::setprecision(10)<<d<<endl;
#define CIN(n) getline(cin,n);

using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using ll = long long;
using ul = unsigned long;

typedef long long ll;

template<class T, class C> void chmax(T& a, C b){ a>b?:a=b; }
template<class T, class C> void chmin(T& a, C b){ a<b?:a=b; }

const int mod=1e9+7;

struct mint {
  ll x;
  mint(ll x=0):x(x%mod){}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
};

mint c[4005][4005];
void init() {
  c[0][0] = 1;
  for (int i = 0; i <= 4000; i++) {
    for (int j = 0; j <= i; j++) {
      c[i+1][j] += c[i][j];
      c[i+1][j+1] += c[i][j];
    }
  }
}
mint comb(int n, int k) {
  return c[n][k];
}

bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false;

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

    return true;
}

map<ll, ll> primeFact(ll n) {
  map<ll, ll> res;
  for (ll i = 2; i * i <= n; i++) {
    while (n % i == 0) {
      res[i]++;
      n /= i;
    }
  }
  if (n != 1) res[n]++;
  return res;
}

void printv(VI& v){
  REP(i,v.size()) cout << v[i] << " ";
  cout << endl;
}

int vtotal(VI& v){
  int total=0;
  REP(i,v.size()) total+=v[i];
  return total;
}

int main()
{
  cin.tie( 0 );
  ios::sync_with_stdio( false );
	
  //init(); // mint初期化
  int a,b,c,d,e,k;
  cin>>a>>b>>c>>d>>e>>k;
  string ans="Yay!";
  if(e-a>k)ans=":(";
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 125568
#include <bits/stdc++.h>
using namespace std;
main(){
  // ここにプログラムを追記
  int A,B,C;
  cin>> A >>B>>C;
  int X=100*A+10*B+C;
  if (X %4 ==0) {cout <<"YES"<<endl;
               }

else{ cout<<"NO"<<endl;
}
}


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

class Program
{
    const string Yes = "Yes";
    const string No = "No";
    const char White = '.';
    const char Black = '#';
    const long Mod = 1000000007;

    static void Main(string[] args) {
#if DEBUG
        MyDebugger.Test(process, "../TextFile1.txt");
#else
        object ret = process(new StreamReader(Console.OpenStandardInput()));
        Console.WriteLine(ret);
#endif
    }

    static object process(TextReader input) {
        var s = input.ReadLine();

        var hash = new HashSet<char>();
        foreach(var c in s) {
            if(hash.Contains(c)) return "no";
            hash.Add(c);
        }

        return "yes";
    }

    static int[] ToIntArray(string strs, int n) {
        var ret = new int[n];
        var spl = strs.Split(' ');
        for (int i = 0; i < n; i++)
            ret[i] = int.Parse(spl[i]);
        return ret;
    }

}


Measured memory_bytes: 26092
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using static System.Console;

class Program
{
    static void Main(string[] args)
    {
        var NK = ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
        var (N, K) = (NK[0], NK[1]);
        var S = ReadLine();

        var rle = RunLengthEncoding.Encode(S).ToList();

        if(rle[0].element == '0')
            rle.Insert(0, ('1', 0));
        if (rle[^1].element == '0')
            rle.Add(('1', 0));

        if ((rle.Count - 1) / 2 < K)
            K = (rle.Count - 1) / 2;

        var sum = rle.Take(K * 2 + 1).Sum(x => x.length);
        var max = sum;

        for (int i = 0; i < (rle.Count - 1) / 2 - K; i++)
        {
            sum -= rle[i * 2].length;
            sum -= rle[i * 2 + 1].length;
            sum += rle[K * 2 + 1 + i * 2].length;
            sum += rle[K * 2 + 1 + i * 2 + 1].length;

            if (max < sum)
                max = sum;
        }

        WriteLine(max);
    }
}
static class RunLengthEncoding
{
    public static IEnumerable<(T element, int length)> Encode<T>(IEnumerable<T> collection)
    {
        var isFirst = true;
        var prevElement = default(T);
        var length = 0;

        foreach (var element in collection)
        {
            if (!isFirst && !EqualityComparer<T>.Default.Equals(prevElement, element))
            {
                yield return (prevElement, length);
                length = 0;
            }
            else
                isFirst = false;

            length++;
            prevElement = element;
        }
        if (!isFirst)
            yield return (prevElement, length);
    }

    public static IEnumerable<T> Decode<T>(IEnumerable<(T element, int length)> rle) => rle.SelectMany(t => Enumerable.Repeat(t.element, t.length));
}


Measured memory_bytes: 30380