akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <string.h>
#define M 1000003

typedef long long LL;
int n,k,dp[1010][1010][2],f[1010],g[1010],cp,cd,prime[30],e[30],div[1000];
void search(int i,int prod);
int phi(int x);
LL power(int n,int e);

int main(void)
{
    while(~scanf("%d%d",&n,&k))
    {
        if(!n) break;
        int i,j;
        for(i=n;i>=0;i--)
            for(j=0;j<=k;j++)
                if(i==n) dp[i][j][0]=dp[i][j][1]=1;
                else if(j==k)
                {
                    dp[i][j][0]=dp[i+1][1][1];
                    dp[i][j][1]=dp[i+1][1][0];
                }
                else
                {
                    dp[i][j][0]=(dp[i+1][j+1][0]+dp[i+1][1][1])%M;
                    dp[i][j][1]=(dp[i+1][j+1][1]+dp[i+1][1][0])%M;
                }
        for(i=0;i<=n;i++)
            f[i]=dp[n-i][0][0]-(i>k ? 0 : 2);
        for(i=n;i>=0;i--)
            for(j=0;j<=k;j++)
                if(i==n) dp[i][j][0]=0,dp[i][j][1]=1;
                else if(j==k)
                {
                    dp[i][j][0]=dp[i+1][1][1];
                    dp[i][j][1]=dp[i+1][1][0];
                }
                else
                {
                    dp[i][j][0]=(dp[i+1][j+1][0]+dp[i+1][1][1])%M;
                    dp[i][j][1]=(dp[i+1][j+1][1]+dp[i+1][1][0])%M;
                }
        for(i=1;i<=n;i++)
            g[i]=dp[n-i+1][1][1];
        memset(e,0,sizeof(e));
        LL t=n;
        for(cp=0,i=2;i*i<=n;i++)
            if(t%i==0)
            {
                prime[++cp]=i;
                while(t%i==0)
                {
                    t/=i;
                    e[cp]++;
                }
            }
        if(t>1)
        {
            prime[++cp]=t;
            e[cp]=1;
        }
        cd=0;
        search(1,1);
        int ans=0,d,sig;
        for(i=1;i<=cd;i++)
        {
            d=div[i];
            t=f[d];
            for(j=k+1;j<=k*2;j++)
                if(d>j) t=(t-g[d-j]*(k*2-j+1)%M*2%M+M)%M;
            ans=(ans+t*phi(n/d)%M)%M;
        }
        ans=((LL)ans+M)*power(n,M-2)%M;
        if(k>=n) ans=(ans+2)%M;
        printf("%d\n",ans);
    }
    return 0;
}

void search(int i,int prod)
{
    if(i>cp)
    {
        div[++cd]=prod;
        return;
    }
    search(i+1,prod);
    int j,t=prod;
    for(j=1;j<=e[i];j++)
    {
        t*=prime[i];
        search(i+1,t);
    }
}

int phi(int x)
{
    int i,ret=x;
    for(i=1;i<=cp;i++)
        if(x%prime[i]==0)
            ret=ret/prime[i]*(prime[i]-1);
    return ret;
}

LL power(int n,int e)
{
    if(!e) return 1;
    LL t=power(n,e/2);
    return (e%2 ? t*t*n : t*t)%M;
}

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

using namespace std;

const int N = 1e5 + 5 , MOD = 1e9 + 7;
vector<int> adj[N];
int n , k , ans;

int mul(int x) {
    ans = (ans * 1ll * x) % MOD;
}

void solve (int node , int par , int dep) {
    int rem = k - 1 - (dep >= 1);
    for (int i = 0 ;i < adj[node].size() ;i++) {
        int child = adj[node][i];
        if (child == par) continue;
        mul(rem--);
    }

    for (int c : adj[node])
        if (c != par)
            solve(c , node , dep + 1);
}

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

    cin >> n >> k;

    for (int i = 0 ;i < n - 1 ;i++) {
        int u , v;
        cin >> u >> v;
        adj[u].push_back(v);
        adj[v].push_back(u);
    }

    ans = k;
    solve(1 , -1 , 0);
    cout << ans;
}

Measured memory_bytes: 9216
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;

signed main() {
  int N; cin >> N;
  vector<int> as(N);
  rep(i,N) cin >> as[i];
  double ans = 0.0;
  rep(i,N) {
    ans += 1.0 / as[i];
  }
  cout << fixed << setprecision(10);
  cout << (1.0 / ans) << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>


using namespace std;
typedef long long int ll;


int main() {
    int N, K;
    cin >> N >> K;
    
    vector<int> l(N);
    for(size_t i = 0; i < N; i++)
    {
        cin >> l[i];
    }
    
    sort(l.begin(), l.end(), std::greater<int>());
    ll L = 0;
    for (size_t i = 0; i < K; i++)
    {
        L += l[i];
    }

    cout << L << endl;
    return 0;
}

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

using namespace std;
using ll = long long;

int f_dir[2][4] = {{-1, 0, 0, 1}, {0, -1, 1, 0}};
int e_dir[2][8] = {{-1, -1, -1, 0, 0, 1, 1, 1}, {-1, 0, 1, -1, 1, -1, 0, 1}};
bool is_in_field(int y, int x, int h, int w){
  return (y >= 0 && y < h && x >= 0 && x < w);
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int ti = clock();
  // start-----------------------------------------------
  string s; cin >> s;
  if(s.length() % 2){
    cout << "No" << endl;
    return 0;
  }
  bool f = true;
  for(int i = 0; i < s.length(); i += 2){
    if(s[i] != 'h' || s[i+1] != 'i') f = false;
  }
  if(f) cout << "Yes" << endl;
  else cout << "No" << endl;

  // end-----------------------------------------------
  // cerr << 1.0 * (clock() - ti) / CLOCKS_PER_SEC << endl;
}


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

#define M_PI       3.14159265358979323846   // pi

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> VI;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> t3;
typedef tuple<ll, ll, ll, ll> t4;

#define rep(a,n) for(ll a = 0;a < n;a++)
#define repi(a,b,n) for(ll a = b;a < n;a++)

#include <bits/stdc++.h>
using namespace std;

template<typename T>
void cmpmax(T& reference, T value) {
	reference = max(reference, value);
}

template<typename T>
void cmpmin(T& reference, T value) {
	reference = min(reference, value);
}

const ll mod = 1000000007;

static const ll INF = 1e15;

ll mpow(ll x, ll n) {
	ll ans = 1; x %= mod;
	while (n != 0) {
		if (n & 1) ans = ans * x % mod;
		x = x * x % mod;
		n = n >> 1;
	}
	return ans;
}

ll gcd(ll a, ll b) { while (b) a %= b, swap(a, b); return abs(a); }

int main() {
	ll n;
	cin >> n;
	vector<ll> as(n), bs(n);
	map<P, ll> norm;
	ll wolf = 0;
	ll azero = 0;
	ll bzero = 0;
	rep(i, n) {
		cin >> as[i] >> bs[i];
		if (as[i] == 0 && bs[i] == 0) {
			wolf++;
			continue;
		}
		if (as[i] == 0) {
			azero++;
			continue;
		}
		if (bs[i] == 0) {
			bzero++;
			continue;
		}
		auto val = gcd(as[i], bs[i]);
		as[i] /= val;
		bs[i] /= val;
		if (as[i] < 0) {
			as[i] *= -1;
			bs[i] *= -1;
		}
		norm[make_pair(as[i], bs[i])]++;
	}
	set<P> visit;
	ll sum = 1;
	if (azero || bzero)
	{
		ll c = 0;
		if (azero) {
			c += mpow(2, azero) - 1;
		}
		if (bzero) {
			c += mpow(2, bzero) - 1;
		}
		c++;
		c %= mod;
		sum *= c;
		sum %= mod;
	}
	for (auto p : norm) {
		auto key = p.first;
		if (visit.count(key)) continue;
		visit.insert(key);
		auto f1 = key.first;
		auto f2 = key.second;
		if (f2 < 0) {
			f1 *= -1;
			f2 *= -1;
		}
		auto invKey = make_pair(f2, -f1);
		visit.insert(invKey);
		int n1 = p.second;
		int n2 = norm[invKey];

		auto c = mpow(2, n1) - 1;
		if (n2) {
			c += mpow(2, n2) - 1;
		}
		c++;
		c %= mod;
		sum *= c;
		sum %= mod;
	}
	sum += mod - 1;
	sum %= mod;
	sum += wolf;
	sum %= mod;
	cout << sum << endl;
	return 0;
}



Measured memory_bytes: 56108
n, m = map(int, input().split())
ks = [list(map(int, input().split())) for i in range(m)]
p = list(map(int, input().split()))
ans = 0

for i in range(2**n):
    judge = True
    switch = [('off') for _ in range(n)]
    for j in range(len(switch)):
        if (i >> j) & 1:
            switch[j] = 'on'
    for k in range(m):
        count = 0
        for l in range(ks[k][0]):
            if switch[ks[k][l+1]-1] == 'on':
                count += 1
        if count % 2 != p[k]:
            judge = False
            break
    if judge == True:
        ans += 1

print(ans)

Measured memory_bytes: 9232
N = int(input())
list1=[]
for i in range(N):
  a = input()
  list1.append(a)  
  
a = list1.count('AC')
b = list1.count('WA')
c = list1.count('TLE')
d = list1.count('RE')
list2 = [a,b,c,d]
print('AC x '+str(a))
print('WA x '+str(b))
print('TLE x '+str(c))
print('RE x '+str(d))


Measured memory_bytes: 16164
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <set>
#include <map>
#include <utility>
#include <string>
#include <sstream>
#include <algorithm>
#include <random>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <cassert>
#include <climits>

using namespace std;

static array<int, 25> kPrimes = { 2,3,5,7,11,13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97 };

uint64_t nCr(uint64_t n, uint64_t r) {
	if (n == 0) return 0;
	if (r > n) return 0;

	uint64_t ret = 1;
	for (uint64_t i = 0; i < r; i++) {
		ret = ret * (n - i) / (i + 1);
	}
	return ret;
}

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

	if (n <= 9) {
		cout << 0 << endl;
		return 0;
	}

	int i = 0;
	
	vector<int> ds(25);

	for (int i = 2; i <= n; i++) {
		for (int p = 0; p < 25; p++) {
			int val = i;
			while (val % kPrimes[p] == 0) {
				val /= kPrimes[p];
				ds[p]++;
			}
		}
	}

	int up74 = 0;
	for (int p = 0; p < 25; p++) {
		if (ds[p] >= 74) up74++;
	}
	int ret = up74;

	int up24 = 0;
	int up2  = 0;
	for (int p = 0; p < 25; p++) {
		if (ds[p] >= 24) up24++;
		else if (ds[p] >= 2) up2++;
	}
	ret += up24 * (up2 + up24 - 1);

	int up14 = 0;
	int up4 = 0;
	for (int p = 0; p < 25; p++) {
		if (ds[p] >= 14) up14++;
		else if (ds[p] >= 4) up4++;
	}

	ret += up14 * (up4 + up14 - 1);

	up4 = 0;
	up2 = 0;
	for (int p = 0; p < 25; p++) {
		if (ds[p] >= 4)      up4++;
		else if (ds[p] >= 2) up2++;
	}

	ret += nCr(up4, 2) * (up2 + up4 - 2);

	cout << ret << endl;

	return 0;
}

Measured memory_bytes: 256
s=input()
t=input()
ans=1000
if(len(s)==len(t)):
  tmp=0
  for i in range(len(s)):
    if(s[i]!=t[i]):
      tmp+=1
  ans=min(tmp,ans)
for i in range(len(s)-len(t)):
    tmp=0
    for j in range(len(t)):
        if(s[i+j]!=t[j]):
            tmp+=1
    ans=min(ans,tmp)
print(ans)

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int numero;
    long long cantidad_digitos = 0;
    int base;
    cin>>numero>>base;
    while(numero>0){
        numero/=base;
        cantidad_digitos++;
    }
    cout<<cantidad_digitos<<endl;
    
}

Measured memory_bytes: 256
#include <cmath>
#include <string>
#include <vector>
#include <iomanip>
#include <iostream>
#include <algorithm>
#include <functional>
#pragma warning(disable : 4996)
using namespace std;
int N, C, K, a[100009];
int main() {
	scanf("%d %d %d", &N, &C, &K);
	for (int i = 0; i < N; i++) scanf("%d", &a[i]);
	sort(a, a + N);
	int l = -1, ret = 0, cnt = 0;
	for (int i = 0; i < N; i++) {
		if (a[i] >= l || cnt == C) {
			ret++; cnt = 0;
			l = a[i] + K + 1;
		}
		cnt++;
	}
	printf("%d\n", ret);
	return 0;
}

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

using namespace std;

const int MOD = 1e9+7;

long long modpow(int a, int b){
	if(b == 0){
		return 1;
	}else if(b == 1){
		return a%MOD;
	}else if(b%2 == 0){
		long long x = modpow(a, b>>1);
		return x*x%MOD;
	}else{
		long long x = modpow(a, b>>1);
		return (x*x%MOD)*a%MOD;
	}
}

long long fact[200005];

int main(){
	int N, M, K;
	scanf("%d%d%d", &N, &M, &K);
	
	fact[0] = 1;
	for(int i = 1; i <= N*M; i ++){
		fact[i] = (fact[i-1] * i)%MOD;
	}
	long long mul1 = (fact[N*M-2] * modpow(fact[K-2], MOD-2) % MOD) * modpow(fact[N*M-2 - (K-2)], MOD-2) % MOD;
	//printf("%lld ", mul1);
	
	long long ans = 0;
	for(int d = 1; d < N; d ++){
		long long temp = d*(long long)(N-d);
		temp %= MOD;
		temp = (temp*M)%MOD;
		temp = (temp*M)%MOD;
		ans += temp;
	}
	
	for(int d = 1; d < M; d ++){
		long long temp = d*(long long)(M-d);
		temp %= MOD;
		temp = (temp*N)%MOD;
		temp = (temp*N)%MOD;
		ans += temp;
	}
	ans %= MOD;
	ans *= mul1;
	ans %= MOD;
	
	printf("%lld", ans);
	return 0;
}


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

using namespace std;

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

    int p = a+b;
    int m = a-b;
    int mu = a*b;

    int t = (p>m) ? p : m;
    t = (t>mu) ? t : mu;
    cout << t;
}

Measured memory_bytes: 256
s=list(input())
ans = "Yes"
for i in range(len(s)):
    if (i + 1) % 2 == 1 and s[i] != 'L':
        pass
    elif (i + 1) % 2 == 0 and s[i] != 'R':
        pass
    else:
        ans = "No"
        break
print(ans)

Measured memory_bytes: 3060
#include<stdio.h>


int main()
{
	char a[5];
	int b = 0;
	scanf("%s",a);
	for (int i = 0; i < 4; i++)
	{
		if (a[i] == '+') b++;
		else if (a[i] == '-') b--;
	}

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

Measured memory_bytes: 128
var Main = input => {
    var args = input.split("\n");
    // var num_count = args[0];
    var num_list = args[1].split(" ");
    var input_sum = num_list.reduce((acc, cur) => Number(acc) + Number(cur));
    var half = Math.ceil(input_sum / 2.0);
    var sum = 0;
    var i = 0;
    for (; i < num_list.length; i++) {
        sum += Number(num_list[i]);
        if (sum >= half) {
            break;
        }
    }
    var ans = Math.min(Math.abs(input_sum - sum * 2), Math.abs(input_sum - (sum - Number(num_list[i])) * 2));
    console.log(ans);

}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7500
#include <stdio.h>
 
int main() {
 
    long x;
    char cr;
    scanf("%ld", &x);

    long name[14];
    for (long i = 0; i < 14; i++) {
        name[i] = -1;
    }

    name[0] = x-1;
    for (long i = 1; i < 14; i++) {
        name[i] += name[i-1]/26;
        name[i-1] %= 26;
    }
    
    for (long i = 13; i >= 0; i--) {
        if (name[i] == -1) {
            continue;
        }
        cr = 'a'+name[i];
        printf("%c", cr);
    }

    printf("\n");
 
  return 0;
}

Measured memory_bytes: 1660
#include<bits/stdc++.h>
using namespace std;
// 多倍長テンプレ
/* ---------------------- ここから ---------------------- */
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
namespace mp = boost::multiprecision;
// 任意長整数型
using Bint = mp::cpp_int;
// 仮数部が1024ビットの浮動小数点数型(TLEしたら小さくする)
using Real = mp::number<mp::cpp_dec_float<1024>>;
/* ---------------------- ここまで ---------------------- */
int main() {
  int n;
  cin >> n;
  Bint res = 1;
  vector<Bint> a(n);
  for(int i = 0; i < n; i++) {
    cin >> a[i];
    if(a[i]==0) {cout << 0 << endl; return 0;}
  }
  for(int i = 0; i < n; i++) {
    res *= a[i];
    if(res>1000000000000000000) {cout << -1 << endl; return 0;}
  }
  cout << res << endl;
}

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

int main() {
  int N, K;
  string S;
  
  cin >> N >> S >> K;
  
  char c = S.at(K - 1);
  
  for (int i = 0; i < S.size(); i++){
    if (S.at(i) != c){
      S.at(i) = '*';
    }
  }
  
  cout << S << endl;  
  
}

Measured memory_bytes: 256
# frozen_string_literal: true

cards = {}

cards['a'] = gets.chomp!.split('')
cards['b'] = gets.chomp!.split('')
cards['c'] = gets.chomp!.split('')

next_user = 'a'
winner = 'x'

loop do
  next_user = cards[next_user].shift
  if cards[next_user].empty?
    winner = next_user
    break
  end
end

puts winner.upcase


Measured memory_bytes: 1788
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    H,W,h,w = LI()
    if W%w != 0:
        s = [0]+[100000]*(w-1)
        for i in range(W-w+1):
            s.append(s[-w]-1)
        a = [s[i]-s[i-1] for i in range(1,W+1)]
        print("Yes")
        for i in range(H):
            print(*a)
    elif H%h != 0:
        H,W,h,w = W,H,w,h
        s = [0]+[100000]*(w-1)
        for i in range(W-w+1):
            s.append(s[-w]-1)
        a = [s[i]-s[i-1] for i in range(1,W+1)]
        print("Yes")
        ans = [[a[i]]*H for i in range(W)]
        for i in range(W):
            print(*ans[i])
    else:
        print("No")
    return

#Solve
if __name__ == "__main__":
    solve()


Measured memory_bytes: 48476
#include<stdio.h>
int main(){
	unsigned long a,b[300000],c;
	int i,d;
	c=0;
	scanf("%d",&d);
	scanf("%lu",&a);
	for(i=0;i<d;i++){
		scanf("%lu",&b[i]);
	}
	for(i=1;i<d;i++){
		if((b[i]-b[i-1])>a){
			c=c+a;
		}
		else{c=c+(b[i]-b[i-1]);}
	}
	printf("%lu",c+a);
	return 0;
}
		
	

Measured memory_bytes: 1792
using System;

public class Hello
{
    public static void Main()
    {
        var nn = int.Parse(Console.ReadLine().Trim());
        for (int i = 0; i < nn; i++)
        {
            var a = int.Parse(Console.ReadLine().Trim());
            var c = int.Parse(Console.ReadLine().Trim());
            var q = int.Parse(Console.ReadLine().Trim());
            var ret = 0;
            for (int j = 0; j < q; j++)
            {
                string[] line = Console.ReadLine().Trim().Split(' ');
                var zo = int.Parse(line[0]);
                var b = decimal.Parse(line[1]);
                var fee = int.Parse(line[2]);
                var t = 0;
               if (zo == 0) t = Tanri(a, b, c, fee);
                else t = Fukuri(a, b, c, fee);
                ret = Math.Max(ret, t);
            }
            Console.WriteLine(ret);
        }
    }
    public static int Tanri (int a , decimal b , int c, int fee)
    {
        var g = a;  var rishi = 0;
        for (int i = 0; i < c; i++)
        {
            var gd = (decimal)g;
            rishi += (int)(gd * b);
            gd -= fee;
            g = (int)gd;
        }
        return g + rishi;
    }
    public static int Fukuri (int a, decimal b , int c, int fee)
    {
        var g = a;
        for (int i = 0; i < c; i++)
        {
            var gd = (decimal)g;
            gd = gd * (1m + b) - fee;
            g = (int)gd;
        }
        return g;
    }
}


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

int main()
{
	int n, m;
	scanf("%d%d", &n, &m);
	int s = n*m, t = n*m+1;
	char grid[n+5][m+5];
	mf_graph<int> graph(n*m+2);
	for (int i = 0; i < n; ++i) scanf("%s", grid[i]);
	for (int i = 0, v = 0; i < n; ++i) {
		for (int j = 0; j < m; ++j, ++v) {
			if (grid[i][j] != '#') {
				if ((i+j)&1) graph.add_edge(v, t, 1);
				else {
					graph.add_edge(s, v, 1);
					if (i && grid[i-1][j] == '.') graph.add_edge(v, v-m, 1);
					if (i+1<n && grid[i+1][j] == '.') graph.add_edge(v, v+m, 1);
					if (j && grid[i][j-1] == '.') graph.add_edge(v, v-1, 1);
					if (j+1<m && grid[i][j+1] == '.') graph.add_edge(v, v+1, 1);
				}
			}
		}
	}
	printf("%d\n", graph.flow(s, t));
	auto edges = graph.edges();
	for (auto e : edges) {
		if (e.from != s && e.to != t && e.flow) {
			int i = e.from/m, j = e.from%m, i1 = e.to/m, j1 = e.to%m;
			if (i+1 == i1) {
				grid[i][j] = 'v';
				grid[i1][j1] = '^';
			}
			else if (i-1 == i1) {
				grid[i][j] = '^';
				grid[i1][j1] = 'v';
			}
			else if (j+1 == j1) {
				grid[i][j] = '>';
				grid[i1][j1] = '<';
			}
			else {
				grid[i][j] = '<';
				grid[i1][j1] = '>';
			}
		}
	}
	for (int i = 0; i < n; ++i) printf("%s\n", grid[i]);
}

Measured memory_bytes: 5680
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;

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

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

// Self settings
// clang-format off
#define MAX_N 100000
#define REP(i, N) for (int i = 0; i < (int)(N); ++i)
#define SLN(i,N) (i == N-1 ? "\n" : " ")
ll fact(ll n) { ll res = 1; for(ll i=2;i<=n;++i) res = res * i; return res;}
ll nCr(ll n, ll r) {return (fact(n)/fact(n-r)*fact(r)) ;}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
const ll MOD = 1e9+7;
const ll INF = 1LL << 60;
const int inf = 1 << 31;
// clang-format on

int a, b;

int main(void)
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> a >> b;

  int tmp = b;
  int keta = 0;
  while (tmp > 0) {
    tmp /= 10;
    keta++;
  }
  int sum = a * (int)pow(10, keta) + b;

  for (int i = 1; i * i <= sum; i++) {
    if (i * i == sum) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 256
<?php
fscanf(STDIN, "%d", $n);
$s = str_split(trim(fgets(STDIN)));
$ans = array();
$E_num[0] = 0;
for($i=1;$i<$n+1;$i++){
    if($s[$i-1] == "E"){
    $E_num[$i] = $E_num[$i-1] + 1;
    }else{
    $E_num[$i] = $E_num[$i-1];
    }
}

for($i=1;$i<$n+1;$i++){
    $num = 0;
    $num += $i-1 -($E_num[$i-1] - $E_num[0]); //リーダーより←にいてWを向いている人の数
    $num += $E_num[$n] - $E_num[$i]; //リーダーより→にいてEを向いている人の数
    $ans[] = $num;
}

sort($ans);
echo $ans[0];

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


int main() {
    string s;
    cin >> s;
    bool even = false, palin = false;

    if (s.size() % 2 == 0) even = true;
    if (s[0] == s[s.size()-1]) palin = true;

    if (palin && even) cout << "First" << endl;
    if (palin && !even) cout << "Second" << endl;
    if (!palin && !even) cout << "First" << endl;
    if (!palin && even) cout << "Second" << endl;

}

Measured memory_bytes: 512
import * as fs from 'fs';

//in
// 11 2
//out
// 4
const main = (inp: string) => {
    const [n, k]: number[] = inp.split(' ').map(Number);
    let tmp: number = n;
    let ans: number = 0;
    while (Math.floor(tmp) > 0) {
        tmp = tmp / k;
        ans++;
    }
    console.log(ans);

}
main(fs.readFileSync('/dev/stdin', 'utf8').trim());


Measured memory_bytes: 9420
#include <bits/stdc++.h>
#define rep(i,n) for(i=1; i<=n; ++i)
using namespace std;
int main(void){
  int N;
  cin >> N;
  int i,score,n,x,y,z,max;
  rep(i,N){
    max = N;
    score = 0;
    for(x=1; x<=max; ++x)for(y=1; y<=max; ++y)for(z=1; z<=max; ++z){
          n = (x*x+y*y+z*z+x*y+y*z+z*x);
          if(n==i){
            ++score;
            if(max==N)
              max = z;
            break;
          }
          else if(n>i){
            if(max==N)
              max = z;
            break;
          }
    }
    cout << score << endl;
  }

  return 0;
}


Measured memory_bytes: 3588
N,M = map(int,input().split())
 
#AC,WA
P = [0]*N
Penalty = 0
Accepted = 0
 
for i in range(M) :
    p,S = input().split()
    p = int(p)
    
    if S == "AC" and P[p-1] != -1:
        Penalty += P[p-1]
        Accepted += 1
        P[p-1] = -1
    elif S == "WA" and P[p-1] != -1:
        P[p-1] += 1

print(Accepted,Penalty)

Measured memory_bytes: 9456
#include<cstdio>
#include<iostream>
using namespace std;
#define P 1000000007
int main(){
    long long n,k;
    long long b;
    long long sum=0;
    cin >> n >> k;
    for(long long i=k;i<=n+1;i++){
        b=i*(n+1-i)+1;
        sum=sum+b;
        //printf("%d\n",i*(n+1-i)+1);
    }
    cout << sum%P <<endl;
	return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define MP make_pair
#define PII pair<int, int>
#define PLL pair<ll, ll>
#define PLI pair<ll, int>
#define PIL pair<int, ll>
#define STR string
#define Fst first
#define Snd second
#define SHN 1e9
#define LSHN 1e18
using namespace std;
int a[3];
int main()
{
	cin >>a[0]>>a[1]>>a[2];
	sort(a,a+3);
	if ((a[0]==a[1] && a[0]!=a[2]) || (a[2]==a[1] && a[0]!=a[2]))
		cout <<"Yes";
	else cout <<"No";
	return 0;
} 

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

int main()
{
    string s;
    cin >> s;
    int k;
    cin >> k;

    int num = 1;
    rep(i, k)
    {
        num = (int)s.at(i) - '0';
        if (num != 1)
        {
            break;
        }
    }

    cout << num << endl;
}

Measured memory_bytes: 384
//============================================================================
// Name        : LongestCommonSeq.cpp
// Author      : Ken
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <vector>
using namespace std;

class DPMatrix{
public:
	vector<vector<int> > matrix;
	string seq1;
	string seq2;

	DPMatrix(const string sequence1, const string sequence2):matrix(),seq1(sequence1), seq2(sequence2){
		for(int i=0; i<sequence1.size()+1; i++){
			vector<int> vec(sequence2.size()+1);
			matrix.push_back(vec);
		}
	}

	void update(int i, int j){
		if(i<1 or j<1){
			cout << "caution! i: " << i << ", j: " << j << "\n";
		}

		if(seq1.at(i-1) == seq2.at(j-1)){
			matrix.at(i).at(j) = max(matrix.at(i).at(j-1), max(matrix.at(i-1).at(j), matrix.at(i-1).at(j-1)+1));
		}else{
			matrix.at(i).at(j) = max(matrix.at(i).at(j-1), max(matrix.at(i-1).at(j), matrix.at(i-1).at(j-1)));
		}
	}

	int fillMatrix(){
		for(int i=1; i<seq1.size()+1; i++){
			for(int j=1; j<seq2.size()+1; j++){
				update(i, j);
			}
		}

		return matrix.at(seq1.size()).at(seq2.size());
	}
};

int main() {
	int n;
	string sequence1, sequence2;
	cin >> n;

	for(int i=0; i<n; i++){
		cin >> sequence1;
		cin >> sequence2;

		DPMatrix dpmat(sequence1, sequence2);
		int score = dpmat.fillMatrix();

		cout << score << "\n";
	}

	return 0;
}



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

L1 = [0]
for i in range(N):
    L1.append(L1[i] + A[i])

L2 = [0]
for i in range(N):
    L2.append(L2[i] + A[-i-1])

x = 100000000000
for i in range(N):
    y = abs(L1[i] - L2[-i-1])
    x = min(x, y)

print(x)

Measured memory_bytes: 30888
import java.io.*;
import java.util.*;
public class Main{
	public static void main(String args[]) throws Exception{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String str = br.readLine();
		String[] buf = str.split(" ");
		int N= Integer.parseInt(buf[0]);
		int W= Integer.parseInt(buf[1]);
		int[] DP= new int[W+1];
		int v,w;
		
		int j;
		for(j=1;j<W+1;j++){
			DP[j]= -1;
		}
		int i;
		for(i=0;i<N;i++){
			str = br.readLine();
			buf = str.split(" ");
			v= Integer.parseInt(buf[0]);
			w= Integer.parseInt(buf[1]);
			for(j=0;j<W-w+1;j++){
				if( DP[j]>=0 && DP[j]+v>DP[j+w] ){
					DP[j+w]= DP[j]+v;
				}
			}
		}
		
		int v_max=0;
		for(j=W;j>0;j--){
			if( v_max<DP[j] ){
				v_max= DP[j];
			}
		}
		System.out.println(v_max);
	}
}

Measured memory_bytes: 19624
#include <iostream>
#include <vector>
#include <list>
#include <algorithm>
#include <string>
#include <sstream>
#include <stack>
#include <iomanip>
#include <numeric>
#include <queue>
#include <climits>
#include <set>
#include <complex>
#include <cmath>
#include <cstring>
#include <map>
using namespace std;
using ll = long long;
#define MOD 1000000007
#define INF 1LL << 59
using ld = long double;

const int MAX = 510000;

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

    ll K;
    cin >> K;

    vector<ll> res;

    ll b = 1;

    for (int i = 0; i < 15; ++i)
    {
        for (int j = 1; j < 150; ++j)
        {
            res.push_back(b * (j + 1) - 1);
        }
        b *= 10;
    }

    sort(res.begin(), res.end());
    res.erase(unique(res.begin(), res.end()), res.end());

    for (int i = 0; i < res.size(); ++i)
    {
        for (int j = i + 1; j < res.size(); ++j)
        {
            ll sum1 = 0, sum2 = 0;
            ll t1 = res[i], t2 = res[j];
            while (t1)
            {
                sum1 += t1 % 10;
                t1 /= 10;
            }

            while (t2)
            {
                sum2 += t2 % 10;
                t2 /= 10;
            }

            if ((double)res[i] / sum1 > (double)res[j] / sum2)
            {
                res.erase(res.begin() + i--);
                break;
            }
        }
    }
    for (int i = 0; i < K; ++i)
    {
        cout << res[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 384
#include "bits/stdc++.h"

#define REP(i,n) for(ll i=0;i<ll(n);++i)
#define RREP(i,n) for(ll i=ll(n)-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<ll(n);++i)
#define RFOR(i,m,n) for(ll i=ll(n)-1;i>=ll(m);--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;



int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s;
	cin >> s;
	int ans = 100000000;
	REP(i, s.size() - 2) {
		string t = s.substr(i, 3);
		int a = stoi(t);
		ans = min(ans, abs(a - 753));
	}
	cout << ans << endl;
}


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

int main() {
    int n, k;
    cin >> n >> k;
    vector<int> l(n);
    for (int i=0; i<n; i++) {
        cin >> l.at(i);
    }

    sort(l.begin(), l.end(), greater<int>());

    int ans = 0;
    for (int i=0; i<k; i++) {
        ans += l.at(i);
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main() {

    int i;
    int n, m;
    int a[100] = {0};
    double all = 0;
    double k;
    int ans = 0;
//読み込む
    scanf("%d %d", &n, &m);
    for(i = 0; i < n; i++) {
        scanf("%d", &a[i]);
    }
//総投票数の計算
    for(i = 0; i < n; i++) {
        all = all + a[i];
    }
//基準値の計算
    k = all / (4 * m);
//人気商品として選べる数
    for(i = 0; i < n; i++) {
        if(a[i] >= k) {
            ans++;
        }
    }
//回答
    if(ans >= m) {
        printf("Yes\n");
    }
    else {
        printf("No\n");
    }

    return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int h = sc.nextInt(),w = sc.nextInt();
		StringBuilder sb = new StringBuilder();
		sb.append(rep("#",w+2));
		sb.append("\n");
		for (int i = 0; i < h; i++) {
			sb.append("#");
			sb.append(sc.next());
			sb.append("#\n");
		}
		sb.append(rep("#",w+2));
		sb.append("\n");
		System.out.println(new String(sb));
		sc.close();
	}

	public static String rep(String s,int n) {
		StringBuilder sb = new StringBuilder();
		for (int i = 0; i < n; i++) {
			sb.append(s);
		}
		return new String(sb);
	}
}

Measured memory_bytes: 22736
mod=10**9+7
n,k=map(int,input().split())
arr=list(map(int,input().split()))
dp=[[0]*(k+1) for _ in range(n+1)]
dp[0][0]=1
acum=[1]*(k+2)
acum[0]=0
for i in range(n):
  tmp=[0]
  for j in range(k+1):
    dp[i+1][j]=acum[j+1]-acum[max(0,j-arr[i])]
    dp[i+1][j]%=mod
    tmp.append((tmp[-1]+dp[i+1][j])%mod)
  acum=tmp
print(dp[-1][k]%mod)

Measured memory_bytes: 220284
#include <iostream>
#include <vector>
#include <cstdio>
#include <queue>
#include <algorithm>
#include <functional>
#include <string>
#include <queue>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <random>
#include <unordered_map>
#include <unordered_set>
#define ll long long
#define fr(i,k,N) for(ll i=k; i<N;i++)
#define rep(i,N) for(ll i=0; i<N;i++)
#define alll(v) v.begin(),v.end()
using namespace std;
template <class X> void pr(X test){cout<<test<<endl;}
template <class X> void prr(X test){for(auto it:test){cout<<it<<endl;}cout<<endl;}

int main() {
    ll n,m;
    cin>>n>>m;
    if(m % n == 0){
        pr(n+m);
    }
    else pr(m-n);
    
}



Measured memory_bytes: 256
N, M, C = map(int, input().split())
A = []
B = list(map(int, input().split()))
for i in range(N):
  A.append(list(map(int, input().split())))
count = 0
for i in range(N):
  hantei = 0
  for j in range(M):
    hantei += A[i][j]*B[j]
  if hantei + C > 0:
    count += 1
print(count)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long int LL;
LL n,m,x,ans;
LL gcd(LL a,LL b){return b==0?a:gcd(b,a%b);}
int main()
{
    int i,j,k,l;
    scanf("%lld%lld",&n,&x);
    ans=3LL*(n-gcd(n,x));
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define lower(s) transform(s.begin(), s.end(), s.begin(), ::tolower)
using namespace std;
using ll = long long;
int INF = 1001001001;

int main()
{
  int h, w, k;
  cin >> h >> w >> k;
  vector<vector<int>> m(h);
  int ans = 0;
  rep(i, h)
  {
    vector<int> wt(w);
    rep(j, w)
    {
      char c;
      cin >> c;
      if (c == '#')
        wt[j] = 1;
    }
    m[i] = wt;
  }

  int temp = 0;
  rep(i, 1 << h)
  {
    vector<vector<int>> mp(h);
    mp = m;
    rep(j, h)
    {
      if (i >> j & 1)
      {
        rep(k, w) mp[j][k] = 2;
      }
    }
    rep(j, 1 << w)
    {
      vector<vector<int>> mp2(h);
      mp2 = mp;
      rep(k, w)
      {
        if (j >> k & 1)
        {
          rep(l, h) mp2[l][k] = 2;
        }
      }

      int black = 0;
      rep(j, h)
      {
        rep(k, w)
        {
          if (mp2[j][k] == 1)
            black++;
        }
      }

      if (black == k) {
        ans++;
      }
    }
  }

  cout << ans << endl;

  return 0;
}

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

bool compare(tuple<string,int,int> a, tuple<string,int,int> b){
	if(get<0>(a) != get<0>(b)){
		return get<0>(a) < get<0>(b);
	}
	else
	{
		return get<1>(a) > get<1>(b);
	}
}

int main()
{
	int n;
	cin >> n;
	vector<tuple<string, int, int>> res;
	for (int i = 0; i < n; i++)
	{
		string s;
		int p;
		cin >> s >> p;
		res.emplace_back(s, p, i + 1);
	}
	sort(res.begin(), res.end(), compare);
	for (auto x:res)
	{
		cout << get<2>(x) << endl;
	}
}


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

using Pair = System.Collections.Generic.KeyValuePair<int, int>;

class Program
{
	public Program() { }

	static void Main(string[] args)
	{
		new Program().prog();
	}
	Scanner cin;
	const int MOD = 1000000007;
	const int INF = int.MaxValue - 10;
	const long INFL = long.MaxValue - 10;
	const double EPS = 1e-7;
	const double PI = 3.1415926536;

	void prog()
	{
		cin = new Scanner();
		int[,] dir8 = new int[8, 2] { { -1, -1 }, { -1, 0 }, { -1, 1 }, { 0, -1 }, { 0, 1 }, { 1, -1 }, { 1, 0 }, { 1, 1 } };
		int[,] dir4 = new int[4, 2] { { -1, 0 }, { 0, -1 }, { 0, 1 }, { 1, 0 } };

		int N = cin.nextInt();
		int x = cin.nextInt();

		if (N == 1)
		{
			Console.WriteLine("Yes");
			Console.WriteLine(1);
			return;
		}

		if (x == 1 || x == 2 * N - 1)
		{
			Console.WriteLine("No");
			return;
		}
		Console.WriteLine("Yes");
		int[] ans = new int[2 * N - 1];
		ans[N - 2] = 1;
		ans[N - 1] = x;
		ans[N] = 2 * N - 1;
		if (N >= 3)
		{
			if (x != 2 * N - 2)
			{
				ans[N - 3] = 2 * N - 2;
			}
			if (x != 2)
			{
				ans[N + 1] = 2;
			}
		}
		int num = x != 2 ? 3 : 2;
		for (int i = 0; i < 2 * N - 1; i++)
		{
			if (ans[i] != 0) continue;
			if (num == x) num++;
			ans[i] = num;
			num++;
		}
		//*
		for (int i = 0; i < 2 * N - 1; i++)
		{
			Console.WriteLine(ans[i].ToString());
		}
		//*/ Console.WriteLine("end");
	}
}

class Scanner
{
	string[] s;
	int i;

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

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

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

	public int nextInt()
	{
		return int.Parse(next());
	}

	public long nextLong()
	{
		return long.Parse(next());
	}

	public double nextDouble()
	{
		return double.Parse(next());
	}
}

Measured memory_bytes: 8776
n, m = gets.split.map &:to_i
g = Array.new(n) {[]} #隣接リストのグラフを配列の配列で作る
m.times do
  u, v = gets.split.map(&:to_i).map(&:pred) #デクリメントして辺をプッシュ
  g[u].push(v)
end
s, t = gets.split.map(&:to_i).map(&:pred)

dist = Array.new(n) {Array.new(3)} # nilで初期化
dist[s][0] = 0
q = [[s, 0]] #BFS用のキュー
#BFSで探索
while q.size > 0
  u, v = q.shift
  nl = (v + 1) % 3
  g[u].each do |e|
    unless dist[e][nl]
      dist[e][nl] = dist[u][v] + 1
      q.push([e, nl])
    end
  end
end
ans = dist[t][0] || -3
puts ans / 3 #けんけんぱの回数を求める



Measured memory_bytes: 15996
D = int(input())
c = list(map(int,input().split()))
s = []
for i in range(D):
    s.append(list(map(int,input().split())))
last = [0]*26
    
ans = 0
md = [0]*26

for day in range(D):
    for j in range(26):
        last[j] += 1
    
    for k in range(26):
        #k番目を選ぶことによる
        merit = s[day][k]
        merit += last[k] * c[k]
        demerit = 0
        for j in range(26):
            if j != k:
                demerit += c[j] * last[j]
        md[k] = merit - demerit

    #日程の確定
    t = md.index(max(md))
    last[t] = 0
    print(t+1)

Measured memory_bytes: 9304
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll mod=1e9+7;
#define w(x) int x;cin>>x;while(x--)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define vi vector<int>
#define vll vector<ll>
#define ppi pair<Sint,int>
#define ppl pair<ll,ll>
#define F first
#define S second 
#define LB lower_bound
#define UB upper_bound
#define mset multiset
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
ll binpow(ll x, ll y, ll p){  ll res = 1;x = x % p;if (x == 0)return 0;while (y > 0)  { if (y & 1) res = (res*x) % p; y = y>>1;x = (x*x) % p;}return res;}  
ll gcd(ll a, ll b){ if (b == 0) return a; return gcd(b, a % b); } 
bool parity(ll x,ll y){ bool f = ((x ^ y) < 0);return !f;}

ll a[5001][5001];

int main()
{
    IOS

    int n;
    cin>>n;
    vi v(n);
    for(int i=0;i<n;i++)
        cin>>v[i];

    vi dp(n,0);
    dp[1]=abs(v[1]-v[0]);
    for(int i=2;i<n;i++)
    {
        dp[i]=min(dp[i-1]+abs(v[i]-v[i-1]),dp[i-2]+abs(v[i]-v[i-2]));
    }    
    cout<<dp[n-1];
    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main(){
    long long a,b,c,x,kari=0,count=0;
 long long ans=0;
    int N=10,S=10, E=10, W=10;
    string ST_Array;
    //char Ans_Array[200005];


    cin>>ST_Array;

    kari=ST_Array.size();

    for(int i=0;ST_Array[i];i++){
        if(ST_Array[i]=='S'){
            a++;
        }else if(a>0)a--;
        else ans++;
    }


    //kari=strlen(ST_Array);

        cout<<ans*2<<endl;

}



Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cassert>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define rep(i,n) FOR(i,0,n)
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define vint vector<int>
#define vdouble vector<double>
#define vstring vector<string>
using namespace std;

#include<map>
#include<set>
#include<queue>

typedef long long ll;
typedef unsigned long long ull;

// const int MAX_N = 1000000;
const int INFTY = (1 << 21); // 2097152
// const ll INFTY = (1LL << 60);
const ll MD = 1000000007LL;
// fprintf(stderr, "%d %lld \n", x, xll);

// segtree
// memeory error??
const int MAX_N = 200000; // 1 << 20; // > 10^6

class SegTree{

public:

	int n;
	int dat[2 * MAX_N - 1];
	int dummy = 2147483647; // (1 << 31) - 1;

	SegTree(int _n){
		init(_n);
	}

	void init(int n_){
		n = 1;
		while(n < n_) n *=2;
		// initialize
		rep(i, 2 * n - 1) dat[i] = dummy;
	}

	void update(int k, int a){
		// update from bottom
		k += n-1;
		dat[k] = a;
		while(k > 0){
			k = (k - 1) / 2;
			dat[k] = min(dat[k*2+1], dat[k*2+2]);
		}
	}

	// min of [a, b)
	int query(int a, int b){
		return _query(a, b, 0, 0, n);
	}

	// min of [a, b)
	// node k, corresponding [l, r)
	int _query(int a, int b, int k, int l, int r){
		if(r <= a || b <= l) return dummy;
		if(a <= l && r <= b) return dat[k];
		else{
			int vl = _query(a, b, k*2+1, l, (l+r)/2);
			int vr = _query(a, b, k*2+2, (l+r)/2, r);
			return min(vl, vr);
		}
	}
};


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

	SegTree ST(N);

	rep(q, Q){
		int c, x, y;
		cin >> c >> x >> y;

		if(c == 0){
			// update
			ST.update(x, y);
		}
		else{
			// find
			cout << ST.query(x, y+1) << endl;
		}
	}
}

Measured memory_bytes: 4128
function Main(input) {
	var S = parseInt(input);
	var A = 0;
	
	for (var i = 1; i <= S; i++) {
		if (i % 2 != 0) {
			A++;
		}
	}
	
	console.log(A / S);

}

//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
n=int(input())
A=list(map(int, input().split()))

def bubblesort(A,n):
    count=0
    flag=1
    while flag:
        flag=0
        for j in reversed(range(1,len(A))):
            if A[j]<A[j-1]:
                tmp=A[j-1]
                A[j-1]=A[j]
                A[j]=tmp
                flag=1
                count+=1
    return(A,count)

result,count=bubblesort(A,n)
print(" ".join([str(i) for i in result]))
print(count)



Measured memory_bytes: 5608
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		int k = scan.nextInt();

		long[][]a = new long[k + 1][k + 1];

		int i,j,l;
		for(i = 1;i <= k; i++) {
			for(j = 1; j <= k; j++) {
				a[i][j] = gcd(i, j);
			}
		}

		long sum = 0;
		for(i = 1; i <= k; i++) {
			for(j = 1; j <= k; j++) {
				for(l = 1; l <= k; l++) {
					sum += gcd(a[i][j], l);
				}
			}
		}
		System.out.println(sum);
	}
	public static long gcd(long a, long b) {
		if(b == 0)
			return a;

		return gcd(b, a % b);
	}
}


Measured memory_bytes: 36096
n = int(input())
v = list(map(int, input().split()))
v = [[i for e,i in enumerate(v) if e%2 == 0],[i for e,i in enumerate(v) if e%2 == 1]]
dic = [{},{}]
for i in range(2):
    for j in range(n//2):
        k = v[i][j]
        if k in dic[i].keys():
            dic[i][k] += 1
        else:
            dic[i][k] = 1
m1 = max(list(dic[0].values()))
m2 = max(list(dic[1].values()))
i1 = list(dic[0].keys())[list(dic[0].values()).index(m1)]
i2 = list(dic[1].keys())[list(dic[1].values()).index(m2)]
if i1 == i2:
    dic[0][i1] = 0
    dic[1][i2] = 0
    m3 = max(list(dic[0].values()))
    m4 = max(list(dic[1].values()))
    if m2+m3 >= m1+m4:
        print(n-m2-m3)
    elif m2+m3 < m1+m4:
        print(n-m1-m4)
else:
    print(n-m1-m2)

Measured memory_bytes: 17812
import sys
input = sys.stdin.readline
import sys
sys.setrecursionlimit(10**7)
def main(n,ab,px):
  g=[[]for _ in range(n)]
  for a,b in ab:
    g[a-1].append(b-1)
    g[b-1].append(a-1)
  ans=[0 for _ in range(n)]
  for p,x in px:
    ans[p-1]+=x  
  def dfs(seen,i):
    seen[i]=1
    for li in g[i]:
      if seen[li]==0:
        ans[li]+=ans[i]
        dfs(seen,li)
  seen=[0 for _ in range(n)]
  dfs(seen,0)
  print(' '.join(list(map(str,ans))))

if __name__=='__main__':
  n,q=map(int,input().split())
  ab=[list(map(int,input().split())) for _ in range(n-1)]
  px=[list(map(int,input().split())) for _ in range(q)]
  main(n,ab,px)
  

Measured memory_bytes: 352976
#include <iostream>
#include <math.h>
#include <cstdio>
#include <utility>
#include <queue>
#include <vector>
#include <algorithm>

using namespace std;

int nm[100][100],m1[100];

int main() {
  
  int n,m;
  
  cin>>n>>m;
  
  for(int i=0; i<n; i++){
    for(int j=0; j<m; j++){
      cin>>nm[i][j];
      }
    }
    
   for(int j=0; j<m; j++){
      cin>>m1[j];
      }
      
  for(int i=0; i<n; i++){
    int c=0;
    for(int j=0; j<m; j++){
      c+=nm[i][j]*m1[j];
      }
      cout<<c<<endl;
    }
    
}

Measured memory_bytes: 1200
import java.math.BigDecimal;
import java.util.Scanner;

public class Main {
	private static Scanner sc;
	
	public static void main(String[] args) {
		sc =  new Scanner(System.in);
		//N:学期の総数を表す
		int n = Integer.parseInt(sc.next());
		//K:学期目を表す
		int k = Integer.parseInt(sc.next());
		//各学期のテスト結果
		long[] longArr = new long[n];
		for (int i=0; i<n; i++) {
			longArr[i] = Long.parseLong(sc.next());
		}
		
		for(int i=k; i<n; i++) {
			if(longArr[i-k] < longArr[i]) {
				System.out.println("Yes");
			} else {
				System.out.println("No");
			}
		}
		
	}
}


Measured memory_bytes: 61860
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int n,k;
  cin >> n >> k;
  vector<int>p(n);
  for(int i=0;i<n;i++){
    cin >> p.at(i);
  }
  sort(p.begin(),p.end());
  int ans=0;
  for(int i=0;i<k;i++){
    ans+=p.at(i);
  }
  cout << ans << endl;
}

Measured memory_bytes: 3628
while True:
    five_num = 0
    expo = 1
    n = int(input())
    if n == 0:
        break
    elif n < 10:
        print(0)
    else:
        while n >= 5 ** expo:
            five_num += int((n/(5 ** expo)))
            expo += 1
        print(five_num)

Measured memory_bytes: 7468
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int m = Integer.parseInt(sc.next());
        int[] ary = new int[2];
        ary[0] = 1;
        ary[1] = n;
        for (int i = 0; i < m; i++) {
            int l = Integer.parseInt(sc.next());
            int r = Integer.parseInt(sc.next());
            if (ary[1] < l || ary[0] > r) {
                System.out.println(0);
                return;
            }
            if (ary[0] < l) {
                ary[0] = l;
            }
            if (ary[1] > r) {
                ary[1] = r;
            }
        }
        System.out.println(ary[1] - ary[0] + 1);
    }
}

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

// Shrotening
#define fst first
#define snd second
#define pb push_back

// Loop
#define FOR(i,a,b) for(auto i=(a);i<(b);++i)
#define RFOR(i,a,b) for(auto i=(a);i>=(b);--i)

#define REP(i,a) for(long i=0;i<(a);++i)
#define RREP(i,a) for(long i=(a);i>=0;--i)

#define EACH(i,a) for(auto (i)=(a).begin(),_END=(a).end();i!=_END;++i)
#define REACH(i,a) for(auto (i)=(a).rbegin(),_END=(a).rend();i!=_END;++i)

//Algorithm
#define ALL(a) (a).begin(), a.end()
#define RALL(a) (a).rbegin(), a.rend()
#define EXIST(a,x) ((a).find(x)!=(a).end())
#define SORT(a) std::sort((a).begin(), (a).end())
#define UNIQUE(a) std::sort((a).begin(), a.end()), a.erase(std::unique((a).begin(), a.end()), a.end());
#define SUM(a) std::accumulate((a).begin(), (a).end(), 0);

//Setting
#define OPT std::cin.tie(0);std::ios::sync_with_stdio(false);

//debug message
bool debug = true;
#define MSG(s)   if(debug){std::cout << s << std::endl;}
#define DEBUG(x) if(debug){std::cout << "debug(" << #x << "): " << x << std::endl;}

//alias
typedef long long LL;
typedef std::vector<char> VC;
typedef std::vector<int>  VI;
typedef std::vector<long> VL;
typedef std::vector<long long> VLL;

typedef std::vector< VC > VC2;
typedef std::vector< VI > VI2;
typedef std::vector< VL > VL2;
typedef std::vector< VLL > VLL2;

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

int a, b, c, d;
int main() {
    std::cin >> a >> b >> c >> d;
    if(std::abs(a-c) <= d) {
        std::cout << "Yes" << std::endl;
    }  else if(std::abs(a-b) <= d && std::abs(b-c) <= d) {
        std::cout << "Yes" << std::endl;
    } else {
        std::cout << "No" << std::endl;
    }
}

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

int main(void) {
  int N;
  std::cin >> N;

  std::vector<int> A(N);
  int odd = 0;
  int even = 0;
  for (int i = 0; i < N; i++) {
    std::cin >> A[i];
    if (A[i] %2 == 0) {
      even++;
    } else {
      odd++;
    }
  }

  if (odd %2== 0) {
    std::cout << "YES" << std::endl;
  } else {
    std::cout << "NO" << std::endl;
  }

  return 0;
}


Measured memory_bytes: 640