akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner io = new Scanner(System.in);
		int N = io.nextInt();
		int M = io.nextInt();
		String[] a = new String[N];
		String[] b = new String[M];
		for(int i=0;i<N;i++){
			a[i] = io.next();
		}
		for (int j = 0; j < M; j++) {
			b[j] = io.next();
		}
		
		for(int i=0; i<N-M+1;i++){
			loop:for(int j=0;j<N-M+1;j++){
				for(int k=0;k<M;k++){
					for(int l=0;l<M;l++){
						if(a[i+k].charAt(j+l) !=
								b[k].charAt(l))
							continue loop;
					}
				}
				System.out.println("Yes");
				return;
			}
		}
		System.out.println("No");
	}
}	

Measured memory_bytes: 10112
n = int(input())
p = [0] * (n + 1)
m = [[0 for _ in range(100)] for _ in range(100)]

for i in range(n):
    p[i], p[i + 1] = map(int, input().split())

for l in range(2, n + 1):
    for i in range(1, n - l + 2):
        j = i + l - 1
        m[i][j] = float('inf')
        for k in range(i, j):
            m[i][j] = min(m[i][j], m[i][k] + m[k+1][j] + p[i-1] * p[k] * p[j])
print(m[1][n])

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

int main(){
  int N;
  cin >> N;
  vector<int> V(N);
  vector<int> C(N);
  for(int i=0; i<N; i++) cin >> V.at(i);
  for(int i=0; i<N; i++) cin >> C.at(i);
  int ans = 0;
  for(int i=0; i<N; i++){
    if(V.at(i)>C.at(i)) ans+= V.at(i)-C.at(i);
  }
  cout << ans << endl; 
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

long long F[50];

long long fib(int n) {
  if (F[n] != -1) {
    return F[n];
  }
  if (n == 0 || n == 1) {
    F[n] = 1;
    return 1;
  } else {
    F[n] = fib(n-1) + fib(n-2);
    return F[n];
  }
}

int main() {
  int n;
  cin >> n;
  for (int i = 0; i < 50; i++) {
    F[i] = -1;
  }
  cout << fib(n) << endl;
}



Measured memory_bytes: 3084
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<string>
#include<vector>
#include<map>
#include<stack>
#include<queue>

using namespace std;

int main(){
	int n;
	int num[101];
	long long dp[101][21]={0};
	
	scanf("%d",&n);
	for(int i=0;i<n;i++) scanf("%d",&num[i]);
	dp[0][num[0]]=1;
	for(int i=1;i<n-1;i++){
		for(int j=0;j<21;j++){
			if(j-num[i]>=0)
			dp[i][j]+=dp[i-1][j-num[i]];
			if(j+num[i]<=20)
			dp[i][j]+=dp[i-1][j+num[i]];
		}
	}
	printf("%lld\n",dp[n-2][num[n-1]]);
}


Measured memory_bytes: 3256
n = list(map(int, list(input())))

isFalse = False
for i in range(1, len(n)):
    if n[i] > n[0]:
        isFalse = True

if isFalse:
    res = str(n[0] + 1)
else:
    res = str(n[0])

for i in range(len(n)):
    print(res, end='')

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <string.h>
#include <ctype.h>
#include <algorithm>

using namespace std;

int main() {
  int x,a,b;
  cin >> x >> a >> b;
  x -= a;
  cout << (x%b) << endl;
}

Measured memory_bytes: 3572
///////////////////////////////////////////////////////////////////////////////

#include <iostream>
#include <vector>
#include <algorithm>
#include <set>

using namespace std;

///////////////////////////////////////////////////////////////////////////////

#define pb push_back

void longin(long &a)
{
        cin >> a;
}

void longinl1(auto &v, long count)
{
        for (long i = 0; i < count ; ++i) {
                long a;
                cin >> a;
                v.push_back(a);
        }
}

void longinl2(auto &v, long count)
{
        for (long i = 0; i < count ; ++i) {
                long a, b;
                cin >> a >> b;
                v.push_back({a, b});
        }
}

void longinl3(auto &v, long count)
{
        for (long i = 0; i < count ; ++i) {
                long a, b, c;
                cin >> a >> b >> c;
                v.push_back({a, b, c});
        }
}

void longina(auto &v, long count)
{
        longinl1(v, count);
}

long min(const vector<long> v)
{
        long ret = (long)numeric_limits<double>::infinity();
        for (auto i : v) ret = min(ret, i);
        return ret;
}

///////////////////////////////////////////////////////////////////////////////

int main()
{
        long n;
        longin(n);

        vector<long> tlist;
        longinl1(tlist, 5);

        long t = min(tlist);

        long count;
        if (n % t) count = n / t + 1;
        else count = n / t;

        cout << count + 4;

        return 0;
}

///////////////////////////////////////////////////////////////////////////////


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

using namespace std;

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

  int n;
  cin >> n;
  map<string, int> cnt;
  while (n--) {
    string s;
    cin >> s;
    ++cnt[s];
  }
  cout << "AC x " << cnt["AC"] << '\n';
  cout << "WA x " << cnt["WA"] << '\n';
  cout << "TLE x " << cnt["TLE"] << '\n';
  cout << "RE x " << cnt["RE"] << '\n';

  return 0;
}


Measured memory_bytes: 3616
#include<stdio.h>

long long mod;

void matpow(long long a[3][3],long long k){
  long long i,j,r[3][3],mem[3][3],t;
  for(i=0;i<3;i++){
    for(j=0;j<3;j++){
      if(i==j){r[i][j]=1;}
      else{r[i][j]=0;}
    }
  }
  while(k>0){
    if(k%2==1){
      for(i=0;i<3;i++){
        for(j=0;j<3;j++){
          mem[i][j]=0;
          for(t=0;t<3;t++){
            mem[i][j]+=r[i][t]*a[t][j];
            mem[i][j]%=mod;
          }
        }
      }
      for(i=0;i<3;i++){
        for(j=0;j<3;j++){
          r[i][j]=mem[i][j];
        }
      }
    }
    k/=2;
    for(i=0;i<3;i++){
      for(j=0;j<3;j++){
        mem[i][j]=0;
        for(t=0;t<3;t++){
          mem[i][j]+=a[i][t]*a[t][j];
          mem[i][j]%=mod;
        }
      }
    }
    for(i=0;i<3;i++){
      for(j=0;j<3;j++){
        a[i][j]=mem[i][j];
      }
    }
  }
  for(i=0;i<3;i++){
    for(j=0;j<3;j++){
      a[i][j]=r[i][j];
    }
  }
}

long long power(long long a, long long b){
	long long x = 1, y = a;
	while (b > 0){
		if(b%2){
			x = (x*y)%mod;
		}
		y = (y*y)%mod;
		b /= 2;
	}
	return x%mod;
}

int main(){
  long long l,a,b,k=10,r=0;
  long long st,fi,te;
  long long mat[3][3];
  scanf("%lld%lld%lld%lld",&l,&a,&b,&mod);
  while(l>0){
    if(a>=k){k*=10;continue;}
    st=0;fi=l-1;
    while(st<=fi){
      te=(st+fi)/2;
      if((a+b*te)>=k){fi=te-1;}
      else{st=te+1;}
    }
    if(fi==-1){k*=10;continue;}
    mat[0][0]=k%mod;
    mat[0][1]=(mod-(k%mod))%mod;
    mat[0][2]=0;
    mat[1][0]=0;mat[1][1]=k%mod;mat[1][2]=0;
    mat[2][0]=1;mat[2][1]=0;mat[2][2]=1;
    matpow(mat,fi+1);
    r*=power(k%mod,fi+1);r%=mod;
    r+=(mat[2][0]*((a+fi*b)%mod));r%=mod;
    r+=(mat[2][1]*(b%mod));r%=mod;
    l-=(fi+1);
    a=a+b*st;
    k*=10;
  }
  printf("%lld\n",r);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep2(i, a, n) for(ll i = a; i < (ll)(n); i++)
#define memi cout << endl
#define kono(n) cout << fixed << setprecision(n)
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define hina cout << ' '
#define in(n) cin >> n
#define in2(n, m) cin >> n >> m
#define in3(n, m, l) cin >> n >> m >> l
#define out(n) cout << n
const ll mei = (ll)1e9 + 7;

int main(){
  string s, t;
  ll n, m, a;
  in2(s, t);
  n = s.size();
  m = t.size();
  bool h;
  rep(i, n - m + 1){
    h = true;
    rep(j, m){
      if(s[n - m - i + j] != t[j] && s[n - m - i + j] != '?')
        h = false;
    }
    if(h){
      rep(j, m)
        s[n - m - i + j] = t[j];
      rep(j, n){
        if(s[j] == '?')
          s[j] = 'a';
      }
      out(s);
      memi;
      return 0;
    }
  }
  out("UNRESTORABLE");
  memi;
}

Measured memory_bytes: 256
#include <iostream>
#define llint long long
#define mod 1000000007

using namespace std;

llint fact[300005], fact_inv[300005];

llint pow(llint a, llint n)
{
	if(n == 0) return 1;
	if(n % 2){
		return ((a%mod) * (pow(a, n-1)%mod)) % mod;
	}
	else{
		return pow((a*a)%mod, n/2) % mod;
	}
}

void make_fact()
{
	llint val = 1;
	fact[0] = 1;
	for(int i = 1; i < 300005; i++){
		val *= i;
		val %= mod;
		fact[i] = val;
	}
	for(int i = 0; i < 300005; i++){
		fact_inv[i] = pow(fact[i], mod-2);
	}
}

llint comb(llint n, llint k)
{
	llint ret = 1;
	ret *= fact[n];
	ret *= fact_inv[k], ret %= mod;
	ret *= fact_inv[n-k], ret %= mod;
	return ret;
}

llint N, M, K;

int main(void)
{
	make_fact();
	cin >> N >> M >> K;
	
	llint ans = 0;
	for(int i = 0; i <= K; i++){
		llint tmp = comb(N+M+2*K, N+2*i);
		tmp *= (comb(N+2*i, i) - comb(N+2*i, i-1) + mod) % mod;
		tmp %= mod;
		tmp *= (comb(M+2*(K-i), K-i) - comb(M+2*(K-i), (K-i)-1) + mod) % mod;
		tmp %= mod;
		ans += tmp;
		ans %= mod;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 7804
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <limits>
#include <random>
#include <complex>
#include <cmath>
#include <cstdio>
#include <cstdlib>
using namespace std;

#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define RREP(i,n) for(int (i)=(int)(n)-1;i>=0;i--)
#define REMOVE(Itr,n) (Itr).erase(remove((Itr).begin(),(Itr).end(),n),(Itr).end())
typedef long long ll;

int main() {

    int n; cin >> n;
    vector < int > a(n);
    REP(i,n) cin >> a[i];

    sort(a.begin(), a.end());

    int ans = -1;
    int diff = 1e9;

    REP(i,n - 1) {
        if (abs(a[i] - a.back() / 2) <= diff) {
            diff = abs(a[i] - a.back() / 2);
            ans = a[i];
        }
    }

    cout << a.back() << " " << ans << endl;

    return 0;
}

Measured memory_bytes: 640
using System;
using System.Collections.Generic;

namespace abc148_e
{
  class Program
  {
    static void Main(string[] args)
    {
      var n = CIn.ReadLong();

      if (n % 2 == 1)
      {
        Console.WriteLine(0);
        return;
      }

      var ans = 0L;
      var log = (int)Math.Log(n / 2, 5);
      var div = 2L;

      for (var i = 1; i <= log; i++)
      {
        div *= 5;
        ans += n / div;
      }

      Console.WriteLine(ans);
    }
  }

  class CIn
  {
    private static readonly Queue<string> fieldBuffer = new Queue<string>();

    public static string Read()
    {
      if (fieldBuffer.Count == 0)
      {
        foreach (var field in Console.ReadLine().Split())
        {
          fieldBuffer.Enqueue(field);
        }
      }
      return fieldBuffer.Dequeue();
    }

    public static int ReadInt() => int.Parse(Read());
    public static long ReadLong() => long.Parse(Read());
    public static double ReadDouble() => double.Parse(Read());

    public static string[] ReadStringArray(long n)
    {
      var array = new string[n];
      for (var i = 0; i < n; i++)
      {
        array[i] = Read();
      }
      return array;
    }

    public static int[] ReadIntArray(long n)
    {
      var array = new int[n];
      for (var i = 0; i < n; i++)
      {
        array[i] = ReadInt();
      }
      return array;
    }

    public static long[] ReadLongArray(long n)
    {
      var array = new long[n];
      for (var i = 0; i < n; i++)
      {
        array[i] = ReadLong();
      }
      return array;
    }

    public static double[] ReadDoubleArray(long n)
    {
      var array = new double[n];
      for (var i = 0; i < n; i++)
      {
        array[i] = ReadDouble();
      }
      return array;
    }
  }
}

Measured memory_bytes: 11220
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int64_t N;
  cin >> N;
  vector<pair<int, int>> table;
  
  //cout << N << endl;
  for (int64_t i = 2; i*i <= N; i++ ) {
    int x = 0;
    while (N % i == 0) {
      N /= i;
      x++;
      // cout << N << endl;
    }
    if (x != 0) {
    table.emplace_back(i,x);
    }
  }
  
  if (N != 1) {
    table.emplace_back(N, 1);
  }
  
  // ここで各素因数のチェック
  /*for (int i = 0; i < table.size(); i++) {
   	cout << table.at(i).first << " " << table.at(i).second <<endl;
  }*/
  
  int ans = 0;
  
  // 長さチェック
  //cout << table.size() << endl;
  
  
  for (int j = 0; j < table.size(); j++) {
    int y = table.at(j).second;
    int b = 1;
    while (y >= b ) {
      ans++ ;
      y -= b; 
      b++ ;
    }
  }
  
   cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 3632
#include <stdio.h>
#include <stack>

using namespace std;

int n;

//array[base_loc]???base_value????????§?????????????????????
int setArray(int array[100],int base_loc,int base_value){
	int sum = 0,index = base_loc+1;
	array[base_loc] = base_value;

	for(int i=0; i <= base_loc; i++){
		sum += array[i];
	}

	while(sum < n){
		array[index] = (base_value <= (n-sum))?base_value:(n-sum);
		sum += array[index];
		index++;
	}
	return index;
}

//index??????????????????????????????2??\????????°????????´????????????
void func(int array[100],int size,int index){

	int new_size;

	for(int i=0;i<size;i++){
		if(i == size-1)printf("%d\n",array[i]);
		else{
			printf("%d ",array[i]);
		}
	}
	if(array[index] > 1){	//??????????±??????´????????°??????1????????§????????´???
		new_size = setArray(array,index,array[index]-1);	//????????????????´??????????????????????
		for(index = 0; index < new_size && array[index] > 1;index++);
		func(array,new_size,index-1);

	}else{ //array[index] == 1  //???????????´????????????????????´???????????????
		while(index > 0){
			if(array[index-1] > 1){ //???????´????????????????????´???????????§????????????????????????????????????????!!!
				new_size = setArray(array,index-1,array[index-1]-1);	//?????????array[index-1]-1????????§????£????????????????
				for(index = 0; index < new_size && array[index] > 1; index++);
				func(array,new_size,index-1);
				break;
			}
			index--;
		}
	}
}

int main(){
	int array[100];

	while(true){
		scanf("%d",&n);
		if(n == 0)break;

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

		if(n > 1){
			array[0] = n-1;
			array[1] = 1;
			func(array,2,0);
		}

		for(int i=0; i < 100; i++)array[i] = 0;

	}
    return 0;
}

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

int main(){
    int size,count,i;
    string str1,str2,str3;
    cin >> size;
    cin >> str1;
    cin >> str2;
    cin >> str3;
    count = 0;
    i = 0;

    while(i <= size){
        if(str1[i] == str2[i] && str2[i] != str3[i]){
            count = count + 1;
            i++;
        }else if(str2[i] == str3[i] && str2[i] != str1[i]){
            count = count + 1;
            i++;
        }else if(str3[i] == str1[i] && str1[i] != str2[i]){
            count = count + 1;
            i++;
        }else if(str1[i] == str2[i] && str2[i] == str3[i]){
            i++;
        }else{
            count = count + 2;
            i++;
        }
    }
    cout << count << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
 
int main(void)
{
 
    int i_inputBingoNum[9];
    int i_repeatNum;
    char c_bingoCheckFlag = 0;
    int i_checkNumFlag[] = {0, 0, 0, 0, 0, 0, 0, 0, 0};
 
    for (int index = 0; index < 9; index++)
    {
        scanf("%d", &i_inputBingoNum[index]);
    }
 
    scanf("%d", &i_repeatNum);
 
    int i_inputJudgeNum[i_repeatNum];
 
    for (int index = 0; index < i_repeatNum; index++)
    {
        scanf("%d", &i_inputJudgeNum[index]);
    }
 
    for (int index = 0; index < i_repeatNum; index++)
    {
        for (int index2 = 0; index2 < 9; index2++)
        {
            if (i_inputJudgeNum[index] == i_inputBingoNum[index2])
            {
                i_checkNumFlag[index2] = 1;
            }
        }
    }
 
    if ((i_checkNumFlag[0] == 1 && i_checkNumFlag[1] == 1 && i_checkNumFlag[2] == 1) ||
        (i_checkNumFlag[0] == 1 && i_checkNumFlag[3] == 1 && i_checkNumFlag[6] == 1) ||
        (i_checkNumFlag[0] == 1 && i_checkNumFlag[4] == 1 && i_checkNumFlag[8] == 1) ||
        (i_checkNumFlag[1] == 1 && i_checkNumFlag[4] == 1 && i_checkNumFlag[7] == 1) ||
        (i_checkNumFlag[2] == 1 && i_checkNumFlag[4] == 1 && i_checkNumFlag[6] == 1) ||
        (i_checkNumFlag[2] == 1 && i_checkNumFlag[5] == 1 && i_checkNumFlag[8] == 1) ||
        (i_checkNumFlag[3] == 1 && i_checkNumFlag[4] == 1 && i_checkNumFlag[5] == 1) ||
        (i_checkNumFlag[6] == 1 && i_checkNumFlag[7] == 1 && i_checkNumFlag[8] == 1))
    {
        printf("Yes");
    }
    else
    {
        printf("No");
    }
 
}

Measured memory_bytes: 128
#include<stdio.h>
int main()
{
int n,x;

double r,y;
x=100000;
r=1.05;
scanf("%d",&n);
for(int i=0;i<n;i++){
x=r*x;
if(x%1000>0)x=x+1000-(x%1000);
}
printf("%d\n",x);
return 0;
}

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

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

	for (int i = 1; i <= n; ++i) {
		int total = 0;
		int x = 1;
		while (true) {	
			int y = 1;
			while (true) {
				
				int z = 1;
				while (true) {
					
					int buff = x * x + y * y + z * z + x * y + y * z + z * x;
					if (buff == i) {
						++total;
					}
					else if (buff > i) {
						break;
					}
					++z;
				}
				if ((x * x + y * y + 1 + x * y + y + x) > i) {
					break;
				}
				++y;
			}
			if ((x * x + 2 + x + 1 + x) > i) {
				break;
			}
			++x;
		}
		cout << total << endl;
	}
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define ALL(x) (x).begin(), (x).end()
#define REP(i ,n) for(int i = 0; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
typedef vector<int>vint;
typedef vector<ll>vll;
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename A,typename B>inline bool chmin(A &a,const B &b){if(a>b){a=b;return true;}else{return false;}}
template<typename A,typename B>inline bool chmax(A &a,const B &b){if(a<b){a=b;return true;}else{return false;}}

const ll mod = 1e9+7;

int main()
{
    int N,P;
    cin >> N >> P;
    int cnt=0;
    REP(i,N){
        int a;
        cin >> a;
        if(0 != a%2)cnt++;
    }
    ll ans=0;
    if(0 == cnt){
        ans = 1LL << N;
    }else{
        ans = 1LL << (N-1);
    }
    if(P){
        ans = (1LL << N) - ans;
    }
    cout << ans << endl;
}

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

N = int(input())
A = [int(i) for i in input().split()]

answer = 0
right = 0
lrsum = 0
for left in range(N):
    while right < N and (lrsum ^ A[right]) == (lrsum + A[right]):
        lrsum += A[right]
        right += 1
    answer += right - left
    if left == right:
        right += 1
    else:
        lrsum -= A[left]

print(answer)

Measured memory_bytes: 23508
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <algorithm>
#include <random>
#include <chrono>
#include <iomanip>
#define lint long long int
#define FOR(x, to) for(int x=0; x<(int)(to); x++) // for簡略表記
#define DUMP(ar) for(int loop=0; loop<(int)ar.size(); loop++) cout << "[" << loop << "]:" << ar[loop] << endl // 配列一覧表示
#define DUMPL(ar) for(int loop=0; loop<(int)ar.size(); loop++) { cout << ar[loop]; if(loop<(int)ar.size()-1) cout << ' '; } cout << endl; // 配列一行一覧表示
#define COUT(x) cout << x << endl // 単要素出力
#define ALL(ar) ar.begin(), ar.end() // コンテナの全要素
#define LOOPD(i) cout << "ループ[" << i << "]回目---------------" << endl // ループ回数デバグ
using namespace std;
// cout << fixed << setprecision(4) で小数点以下4桁の桁そろえ
// cout << setw(5) << ... で表示形式を5桁に設定 5桁未満なら頭に空白がつく 5桁越なら先頭から5桁まで
// cout << setw(5) << setfill('0') << ... で空白部分の埋め文字に5を使う
// getline(cin, [変数]); で空白などを含む入力の受け取り(行ごとの受け取り)
// cin >> ws; でそこまでにストリームに残されたホワイトスペースを取り除く(=以降のgetlineの有効化)

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

    int a, b, c;
    cin >> a >> b >> c;

    if(a + b + c >= 22){
        COUT("bust");
    }else{
        COUT("win");
    }

    return 0;
}

Measured memory_bytes: 256
N, A, B = map(int, input().split())
C = abs(A-B)
X = max(A-1,B-1)
Y = max(N-A,N-B)
if C % 2 == 0:
  print(min(C//2,X,Y))
else:
  if B > A:
    A, B = B, A
  P = (2*N - B - A + 1)//2
  Q = (A + B - 1)//2
  print(min(P,Q,X,Y))

Measured memory_bytes: 3064
A,B,C,X,Y = map(int,input().split())
a = min(X,Y)
b = max(X,Y)
if A+B>=2*C:
    ans = a*2*C
    if X>=Y:
        ans += (X-Y)*min(A,2*C)
    else:
        ans += (Y-X)*min(B,2*C)
else:
    ans = A*X+B*Y
print(ans)

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

int main() {
  int D,N,x;
  N=0;
  x=0;
  cin >> D;
  vector<int> c(26);
  vector<int> last(26);
  for (int i=0;i<26;i++) {
    cin >> c.at(i);
  }
  vector<vector<int>> s(D,vector<int>(26));
  for (int i=0;i<D;i++) {
    for (int j=0;j<26;j++) {
      cin >> s.at(i).at(j);
    }
  }
  for (int i=0;i<D;i++) {
    cout << 13 << endl;
  }
}

Measured memory_bytes: 3688
#include<iostream>

using namespace std;

int s(long long x){
	int res = 0;
	while(x > 0){
		res += x % 10;
		x /= 10;
	}
	return res;
}

long long next_sunuke(long long x){
	if(x < 10){
		return x;
	}
	long long t = x, k = 10;
	double sunuke1, sunuke2;
	sunuke1 = 1.0 * x / s(x);
	while(k <= x){
		t = t - (t % k) + (k - 1);
		sunuke2 = 1.0 * t / s(t);
		if(sunuke1 > sunuke2){
			x = t;
			sunuke1 = sunuke2;
		}else{
			break;
		}
		k *= 10;
	}
	return x;
}

int main(){
	int k, ans = 0;
	cin >> k;
	long long t = 1;
	for(int i = 1; i <= k; i++){
		cout << t << endl;
		t = next_sunuke(t + 1);
	}
	return 0;
}

Measured memory_bytes: 256
a, b, c, x, y = map(int, input().split())
if (a + b) / 2 < c:
    print(a*x + b*y)
else:
    ans = c * min(x, y) * 2
    if x > y:
        if a < c * 2:
            ans += a * (x - y)
        else:
            ans += c * 2 * (x - y)
    else:
        if b < c * 2:
            ans += b * (y - x)
        else:
            ans += c * 2 * (y - x)
    print(ans)

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

int ctoi(char c) {
    int n = c - '0';
    return n;
}

int pow_int(int x, int n) {
    if (n == 0) {
        return 1;
    }else {
        int y = x;
        for (int i = 0; i < n-1; i++) {
            x *= y;
        }
        return x;
    }
}


int main() {
    int a, b;
    cin >> a >> b;
    cout << a * b << endl;
}


Measured memory_bytes: 3584
import sys

sys.setrecursionlimit(1000000)

import bisect
import math
import collections
import heapq


def solve(H, W, K, field):
    # print(H, ",", W, ",", K, ",", field)
    N = 2 ** (H + W)
    F = "{:0" + str(H + W) + "b}"
    ans = 0
    for n in range(N):
        HM = F.format(n)[:H]
        WM = F.format(n)[H:]
        c = 0
        for h in range(H):
            for w in range(W):
                if HM[h] == "1":
                    continue
                if WM[w] == "1":
                    continue
                if field[h][w] == "#":
                    c += 1
        if c == K:
            ans += 1

    return ans


# print(solve(2, 3, 2, ['..#', '###']))

if __name__ == "__main__":
    H, W, K = tuple(map(int, input().split(" ")))
    field = [input() for _ in range(H)]
    print(solve(H, W, K, field))


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

int main() {
    int n;
    cin >> n;
    vector<vector<ll>> v(n, vector<ll>(3));
    for(int i = 0; i < n; ++i)
        for(int j = 0; j < 3; ++j)
            cin >> v[i][j];
    vector<vector<ll>> dp(n, vector<ll>(3));
    dp[0][0] = v[0][0];
    dp[0][1] = v[0][1];
    dp[0][2] = v[0][2];
    for(int i = 1; i < n; ++i) {
        dp[i][0] = v[i][0] + max(dp[i-1][1], dp[i-1][2]);
        dp[i][1] = v[i][1] + max(dp[i-1][0], dp[i-1][2]);
        dp[i][2] = v[i][2] + max(dp[i-1][0], dp[i-1][1]);
    }
    // for(int i = 0; i < n; ++i) {
    //     cout << *max_element(dp[i].begin(), dp[i].end());
    // }
    cout << max({dp[n-1][0], dp[n-1][1], dp[n-1][2]});
}

Measured memory_bytes: 11136
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <utility>
#include <set>
using namespace std;
const int inf = 1e9;
int dx[7] = {0, 1, 1, 0, -1, -1, 0};
int dy[2][7] = {{1, 0, -1, -1, -1, 0, 0}, {1, 1, 0, -1, 0, 1, 0}};

struct info{
    int x,y,t,c;
    info(int x, int y, int t, int c):x(x),y(y),t(t),c(c){}
    info(){}
    bool operator < (const info &a) const{
        return c > a.c;
    }
};

int main(){
    int sx,sy,gx,gy;
    cin >> sx >> sy >> gx >> gy;
    int n;
    cin >> n;
    set<pair<int,int> > noentry;
    for(int i=0; i<n; i++){
        int x,y;
        cin >> x >> y;
        noentry.insert(make_pair(x,y));
    }
    int lx, ly;
    cin >> lx >> ly;

    priority_queue<info> wait;
    wait.push(info(sx, sy, 0, 0));
    vector<vector<vector<int> > > mincost(201, vector<vector<int> >(201, vector<int>(6, inf)));
    mincost[sx+100][sy+100][0] = 0;
    int ans = -1;
    while(!wait.empty()){
        int x = wait.top().x;
        int y = wait.top().y;
        int t = wait.top().t;
        int c = wait.top().c;
        wait.pop();
        if(c > mincost[x+100][y+100][t]) continue;
        if(x==gx && y==gy){
            ans = c;
            break;
        }
        for(int i=0; i<7; i++){
            int nc = (i==(abs(x*y*t))%6)? c : c+1;
            int nx = x + dx[i];
            int ny = y + dy[(x+100)%2][i];
            int nt = (t+1)%6;
            if(abs(nx)>lx || abs(ny)>ly) continue;
            if(noentry.find(make_pair(nx,ny)) != noentry.end()) continue;
            if(nc < mincost[nx+100][ny+100][nt]){
                mincost[nx+100][ny+100][nt] = nc;
                wait.push(info(nx, ny, nt, nc));
            }
        }
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 5516
use strict;
use warnings;

chomp(my $nab = <>);

my ($n, $a, $b) = split(/ /, $nab);
my $blue;

$blue = int($n/($a+$b))*$a;

if($n%($a+$b) < $a){
  $blue += $n%($a+$b);
} else{
  $blue += $a;
}

print "$blue\n";


Measured memory_bytes: 640
# -*- coding: utf-8 -*-
"""
Created on Sat Apr 20 20:47:47 2019

@author: Owner
"""

# -*- coding: utf-8 -*-
"""
Created on Sat Apr 13 09:53:12 2019

@author: Owner
"""
import numpy as np
import sys
import collections
import scipy.misc
import math
from operator import itemgetter
import itertools
import copy
import bisect

#素因数を並べる
def prime_decomposition(n):
  i = 2
  table = []
  while i * i <= n:
    while n % i == 0:
      n /= i
      table.append(int(i))
    i += 1
  if n > 1:
    table.append(int(n))
  return table   
# 桁数を吐く
def digit(i):
    if i > 0:
        return digit(i//10) + [i%10]
    else:
        return []
    
def getNearestValueIndex(list, num):
    """
    概要: リストからある値に最も近い値のインデックスを取得する関数
    @param list: データ配列
    @param num: 対象値
    @return 対象値に最も近い値
    """

    # リスト要素と対象値の差分を計算し最小値のインデックスを取得
    idx = np.abs(np.asarray(list) - num).argmin()
    return idx

def find_index(l, x, default=False):
    if x in l:
        return l.index(x)
    else:
        return default


"""
N, X = map(int, input().split())

x = list(map(int, input().split()))

P = [0]*N
Y = [0]*N
for n in range(N):
    P[n], Y[n] = map(int, input().split())

# 多次元配列の宣言（あとでintにすること。）（タプルにすること。）
dp = np.zeros((N+1, 4,4,4))
    
all(nstr.count(c) for c in '753')

# 複数配列を並び替え
ABT = zip(A, B, totAB)
result = 0
# itemgetterには何番目の配列をキーにしたいか渡します
sorted(ABT,key=itemgetter(2))
A, B, totAB = zip(*ABT)
A.sort(reverse=True)

# 2進数のbit判定
(x >> i) & 1

# dp最小化問題
dp = [np.inf]*N
for n in range(N):
    if n == 0:
        dp[n] = 0
    else:
        for k in range(1,K+1):
            if n-k >= 0:
                dp[n] = min(dp[n], dp[n-k] + abs(h[n]-h[n-k]))
            else:
                break
# 累積和
add = 1 # 問題によって決まる
res = 0
sums = [0]*(len(nums)+1)
for i in range(len(nums)):
    sums[i+1] = sums[i] + nums[i]
for i in range(0, len(nums), 2):
    left = i
    right = min(i+add, len(nums))
    tmp = sums[right] - sums[left]
    res = max(tmp, res)

#２分探索
li, ri = bisect.bisect_left(p_ac, l[i]-1), bisect.bisect_right(p_ac, r[i]-1)    

#ソート関数
org_list = [3, 1, 4, 5, 2]
new_list = sorted(org_list)
print(org_list)
print(new_list)
# [3, 1, 4, 5, 2]
# [1, 2, 3, 4, 5]

#Distance Transformation
    for h in range(0,H):
        for w in range(0,W):
            if h == 0 and w == 0:
                pass
            elif h == 0:
                D[H-h-1][W-w-1]= min(D[H-h-1][W-w-1], D[H-h-1][W-w]+1)
            elif w == 0:   
                D[H-h-1][W-w-1]= min(D[H-h-1][W-w-1], D[H-h][W-w-1]+1)
            else:
                D[H-h-1][W-w-1]= min(D[H-h-1][W-w-1], D[H-h][W-w-1]+1, D[H-h-1][W-w]+1, D[H-h][W-w]+2)
            d_max = max(D[H-h-1][W-w-1], d_max)

"""
N, K = list(map(int, input().split()))
def main():
    p = 0.
    if K <= N:
        p += float(N-K+1)/float(N)
    if K<=N:
        r = K
    else:
        r = N+1
    for n in range(1,r):
        i = 1         
        while n*2**i<K:
            i+=1
        p += 1./float(N)*(1./2.)**(float(i)) 
            
    print(p)
                
                
                
            
            
                

    
if __name__ == '__main__':
    main()


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

int main(void){
    int R;
    cin >> R;
    
    if(R < 1200)
        cout << "ABC" << endl;
    if(1200 <= R && R < 2800)
        cout << "ARC" << endl;
    if(2800 <= R && R <= 4208)
        cout << "AGC" << endl;

    return 0;
}

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

int main(){
	int num[9],per[9],ans = 0;
	for(int i = 0;i < 9;i++) {
		cin >> num[i];
		per[i] = i + 1;
	}
	do{
		bool flag = true;
		for(int i = 0;i < 9;i++){
			if(num[i] != -1 && per[i] != num[i]) flag = false;
		}
		if((per[0] + per[2] + per[5]) % 10 != per[8]) flag = false;
		if(((per[0] + per[2] + per[5]) / 10 + per[1] + per[4]) % 10 != per[7]) flag = false;
		if(((per[0] + per[2] + per[5]) / 10 + per[1] + per[4]) / 10 + per[3] != per[6]) flag = false;
		if(flag) ans++;
	}while(next_permutation(per,per + 9));
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3092
#include <string>
#include <iostream>
#include <cctype>
using namespace std;
int main(){

  int i,match=0;
  string W,T;

  cin>>W;

  while(1){

    cin>>T;
    if(T=="END_OF_TEXT")break;
  
  for(i=0; i<T.size(); i++)if(isupper(T[i]))T[i]=tolower(T[i]);
  if(W==T)match++;

  }

  cout<<match<<"\n";

}

Measured memory_bytes: 1192
#include <stdio.h>//%cと%sはchar型,sortは並び換え
 int main(){
   int a,b,i,v,j,A[1000],N,k; 
   scanf("%d",&N);
   for(i=0;i<N;i++)
	 scanf("%d",&A[i]);

   for(k=0;k<N;k++){
	 
	 if(k != N-1){
	   printf("%d ",A[k]);
	 }else{
	   printf("%d\n",A[k]);
	 }
   }
   for(i=1;i<=N-1;i++){//iは0からn-1まで
	 v = A[i];//同じ数字がでるから別のところに格納しておく。
	 j = i - 1;//iから一個手前にjがいるから
	 while(j >= 0 && A[j] > v){
	   A[j + 1] = A[j];
	   j--;//次で一個手前に格納するから
	 }  
	 A[j + 1] = v;
	 for(k=0;k<N;k++){
	   if(k != N-1){
		 printf("%d ",A[k]);
	   }else{
		 printf("%d\n",A[k]);
	   }
	 }
   }
   return 0;
 }
  



Measured memory_bytes: 2056
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll dp[110][100100];
ll p[110],c[110];
int main(){
	int n;
	ll w;
	scanf("%d %lld",&n,&w);
	for(int i = 1; i <= n; i++)
		scanf("%lld %lld",&p[i],&c[i]);
	for(int i = 1; i <= n; i++)
		for(int j = 1; j <= w; j++)
			dp[i][j] = max(dp[i-1][j], (j - p[i] >= 0)?dp[i-1][j-p[i]] + c[i]:0);
	printf("%lld\n", dp[n][w]);
	return 0;
}

Measured memory_bytes: 81920
#include <iostream>
#include <algorithm>
#include <string>
#include <sstream>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstring>
#include <cmath>
#include <cstdio>

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

typedef long long ll;

int main(){
    int n;cin>>n;
    int a;cin>>a;
    int b;cin>>b;
    int c = a;
    if(n==3)cin>>c;
    int d = min(c,min(a,b));
    vector<int> v,u;
    for(int j=1;j*j<=d;j++){
        if(a%j==0 && b%j==0 && c%j==0){
            v.push_back(j);
        }
        if(j*j!=d && b%(d/j)==0 && c%(d/j)==0){
            u.push_back(d/j);
        }
    }
    vector<int>::iterator it = v.begin();
    while(it != v.end()){
        cout << *it << endl;
        it++;
    }
    reverse(u.begin(),u.end());
    it = u.begin();
    while(it != u.end()){
        cout << *it << endl;
        it++;
    }
    return 0;
}

Measured memory_bytes: 1220
#include<iostream>
#include<vector>
#include<set>
#include<algorithm>

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

int main(){

    int n;
    cin >> n;
    cout << n/2 + n%2 << endl;

     return 0;
}

Measured memory_bytes: 256
N = int(input())

from collections import deque
tmp = []
tmp = deque(tmp)
num = [0]*(10**4*7)
for i in range(1,10**2+1):
    tmp.append(i**2)

for x in tmp:
    xx = int(x**0.5)
    for y in tmp:
        yy = int(y**0.5)
        for z in tmp:
            zz = int(z**0.5)
            ans = x + y + z + xx*yy + yy*zz + zz*xx
            num[ans] += 1
            
for i in range(1,N+1):
    print(num[i])

Measured memory_bytes: 10176
using System;
using System.Collections.Generic;

class Program
{
    static void Main(string[] args)
    {
        string input = Console.ReadLine();
        int s, e;

        for(int i=0; ;i++)
        {
            if (input[i] == 'A')
            {
                s = i;
                break;
            }
        }
        for (int i = input.Length - 1; ; i--)
        {
            if (input[i] == 'Z')
            {
                e = i;
                break;
            }
        }
            Console.WriteLine(e-s+1);
    }
}

Measured memory_bytes: 3416
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

bool judge(string s)
{
	for(int i = 0; i < s.size() / 2; i++)
	{
		if(s[i] != s[i + (s.size() / 2)])
		{
			return false;
		}
	}
	return true;
}

int main()
{
	string s;
	cin >> s;
	
	while(1)
	{
		s.pop_back();
		s.pop_back();
		
		if(judge(s) == true)
		{
			cout << s.size() << endl;
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 256
n = int(input())
x = list(map(float,input().split()))
y = list(map(float,input().split()))

tmp = [abs(x[i] - y[i]) for i in range(n)]

for p in range(1, 4):
    ans = 0
    for d in tmp:
        ans += d ** p
    print("{:.6f}".format(ans ** (1 / p)))

print("{:.6f}".format(max(tmp)))


Measured memory_bytes: 5676
import sys
import math
import itertools
import bisect
from copy import copy,deepcopy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(map(int,input().split()))
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
INF = 10**9
mod = 10**9+7

N = i()
C = l()
B = l()
A = l()
B.sort()
C.sort()
l = []
for i in range(N):
    l.append(bisect.bisect_left(C,B[i]))
ruiseki = [0]+list(itertools.accumulate(l))
ans = 0
for i in range(N):
    num = bisect.bisect_left(B,A[i])
    ans += ruiseki[num]
print(ans)

Measured memory_bytes: 110328
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define ll long long
#define f first 
#define s second
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);
#define MAX 1000005
#define pb push_back
int flag[1000006];
ll gcd(ll a, ll b)
{
  if(a == 0)
    return b;
  return gcd(b%a,a);
}
bool cmp(pair<ll,ll>&a,pair<ll,ll>&b)
{
  if(a.f!=b.f)
    return a.f > b.f;
  return a.s > b.s;
}
int main(){
  FIO;
  int n,m;
  cin >> n >> m;
  ll a[n+1],b,c;
  for (int i = 0; i < n; ++i)
  {
    cin >> a[i];
  }
  vector<pair<ll,ll>>v;
  for (int i = 0; i < m; ++i)
  {
    cin >> b >> c;
    v.pb(make_pair(c,b));
  }
  sort(a,a+n);
  sort(v.begin(), v.end(),cmp);

  ll i = 0, j = 0,count = 0;
  for (int i = 0; i < n; ++i)
  {
    count++;
    a[i] = max(a[i],v[j].f);
    // cout << a[i] << " ";
    if(count == v[j].s)
    {
      j++;
      count = 0;
    }
    if(j == v.size())
      break;
  }
  ll sum = 0;
  for (int i = 0; i < n; ++i)
  {
    sum += a[i];
    // cout << a[i] << " ";
  }
  cout << sum << " ";
  return 0;
}

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i ,n) for(int i = 0 ; i < (n) ; i ++ )
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
using namespace std;
using ll = long long;
using vin=vector<int>;
using P = pair<int, int>;
const int inf=1e9+7;
const ll INF=1e18;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }


int main() {
 int n,m;
  cin>>n>>m;
  set<int> a;
  rep(i,m) {
   int df  ;
    cin>>df;
    a.insert(df);
  }
  ///////
  ll dp[100010];
  rep(i,100010) dp[i]=0;
  dp[0]=1;
  
  
  for(int i=1;i<=n;i++){
    if(a.count(i)){
    }
    else{
     if(i==1){
      dp[i]=1;
     }
      else{
       dp[i]=dp[i-1]+dp[i-2];
       dp[i]%=inf;
      }
    }
  }
  cout<<dp[n]<<endl;
}

Measured memory_bytes: 5760
fun main(args: Array<String>) {
    val (a, b) = readLine()?.split(" ")?.map { it.toInt() } ?: listOf(0, 0)
    when {
        a == b -> {
            println("a == b")
        }
        a < b -> {
            println("a < b")
        }
        else -> {
            println("a > b")
        }
    }
}


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

int compare_int(const void *a, const void *b)
{
    return *(int *)a - *(int *)b;
}
int main(void)
{
    int N, K;
    int p[1000];
    scanf("%i %i", &N, &K);
    for (size_t i = 0; i < N; i++)
    {
        scanf("%i", &p[i]);
    }
    qsort(p, N, sizeof(int), compare_int);

    int sum = 0;
    for (size_t i = 0; i < K; i++)
    {
        sum += p[i];
    }
    printf("%i\n", sum);
}


Measured memory_bytes: 1744
#include<iostream>
#include<vector>
#include<queue>
using namespace std;

vector<vector<int>> to;
int N, M;

const int INF = 1001001001;

vector<int> bfs(int s) {
    vector<int> dist(N, INF);
    vector<int> prev(N, -1);
    queue<int> q;
    dist[s] = 0;
    q.push(s);
    while(!q.empty()) {
        int v = q.front(); q.pop();
        for (int w : to[v]) {
            if (dist[w] != INF) continue;
            prev[w] = v;
            dist[w] = dist[v] + 1;
            q.push(w);
        }
    }

    pair<int, int> best(INF, -1);
    for (int v = 0; v < N; ++v) {
        if (v == s) continue;
        for (int w : to[v]) {
            if (w == s) {
                best = min(best, make_pair(dist[v], v));
            }
        }
    }

    if (best.first == INF) return vector<int>(N+1);
    int v = best.second;
    vector<int> res;
    while(v != -1) {
        res.push_back(v);
        v = prev[v];
    }
    return res;


}


int main() {
    cin >> N >> M;
    to.resize(N);
    for (int i = 0; i < M; ++i) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        to[a].push_back(b);
    }

    vector<int> ans(N+1);
    for (int s = 0; s < N; ++s) {
        vector<int> temp = bfs(s);
        if (temp.size() < ans.size()) ans = temp;
    }
    if (ans.size() == N+1) {
        cout << -1 << endl;
        return 0;
    }
    cout << ans.size() << endl;
    for(int v : ans) {
        cout << v+1 << endl;
    }
    return 0;
}

Measured memory_bytes: 384
N=int(input())
text=input()
ls=[0 for i in range(N)]
if text[0]=="W":
  ls[0]=0
else:
  ls[0]=1
for i in range(1,N):
  if text[i]=="W":
    ls[i]=ls[i-1]
  else:
    ls[i]=ls[i-1]+1
ans=min([ls[N-1]-ls[0],N-1-ls[N-2]])
for i in range(1,N-1):
  x=0
  x+=i-ls[i-1]
  x+=ls[N-1]-ls[i]
  if x<ans:
    ans=x
print(ans)
  
  


Measured memory_bytes: 15392
#include<stdio.h>
#include<math.h>

int main(void){
        int i;

        scanf("%d",&i);
        if(i%10==3){
        printf("bon\n");
}
        else if(i%10==0|i%10==1|i%10==6|i%10==8){
        printf("pon\n");
}
        else{
        printf("hon\n");
}


        return 0;
}

Measured memory_bytes: 1656
#include <cstdio>
#include <algorithm>
#include <vector>
#include <map>
using namespace std;

#define ll long long

int main() {
	ll n, h; scanf("%lld%lld", &n, &h);
	
	vector<pair<ll, bool>> a;
	for (int i = 0; i < n; i++) {
		ll p, q; scanf("%lld%lld", &p, &q); 
		a.push_back(make_pair(p, true));
		a.push_back(make_pair(q, false));
	}
	
	sort(a.begin(), a.end()); reverse(a.begin(), a.end());
	ll k = 0, ans = 0;

	while (true) {
		if (!a[k].second) {
			h -= a[k].first;
			k++; ans++;
		}
		else {
			ans += ((h + a[k].first - 1)/ a[k].first);
			break;
		}
		if (h <= 0) {
			break;
		}
	}

	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 6512
import java.util.Scanner;
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int m = sc.nextInt();
    int[] town = new int[n];
    for(int i = 0; i < m; i++) {
      int a = sc.nextInt();
      town[a-1] += 1;
      a = sc.nextInt();
      town[a-1] += 1;
    }
    for(int i = 0; i<n; i++) {
      System.out.println(town[i]);
    }
  }
}


Measured memory_bytes: 21844
/*
	*	Created By: 'Present_Sir'
	*	Created On: Friday 21 August 2020 11:51:12 AM IST
*/

#include<bits/stdc++.h>
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL)
#define int long long
using namespace std;
const int N = 1e5+5;
vector < int > gr[N];
int vis[N];

void dfs(int cur){
    //cout<<cur<<endl;
    vis[cur] = true;
    for(auto x: gr[cur]){
        if(!vis[x]){
            dfs(x);
        }
    }
}

void solve(){
    int n,m;
    cin>>n>>m;
    
    memset(vis,0,sizeof(vis));

    for(int i=0; i<m; ++i){
        int x,y;
        cin>>x>>y;
        //cout<<x<<" "<<y<<endl;
        gr[x].push_back(y);
        gr[y].push_back(x);
    }
    
    dfs(1);

    for(int i=1; i<=n; ++i){
        if(!vis[i]){
            //cout<<i<<endl;
            cout<<"No"<<endl;
            return;
        }
        vis[i]=0;
    }

    queue<int> q;
    q.push(1);
    
    vector < int >  ans(n+1);
    while(!q.empty()){
        int top = q.front();
        q.pop();

        for(auto x: gr[top]){
            //db(x);
            if(!vis[x]){
                ans[x] = top;
                vis[x] = true;
                q.push(x);
            }
        }
        
    }
    cout<<"Yes"<<endl;
    for(int i=2; i<=n; ++i){
        cout<<ans[i]<<endl;
    }
}

int32_t main(){
    IOS;
    //int t; cin>>t; while(t--)
    {
        solve();
    }
    return 0;
}



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

typedef long long ll;

#define INF 10e17 // 4倍しても(4回足しても)long longを溢れない
#define rep(i,n) for(int i=0; i<n; i++)
#define rep_r(i,n,m) for(int i=m; i<n; i++)
#define END cout << endl
#define MOD 1000000007
#define pb push_back
#define sorti(x) sort(x.begin(), x.end())
#define sortd(x) sort(x.begin(), x.end(), std::greater<int>())
#define debug(x) std::cerr << (x) << std::endl;
#define roll(x) for (auto itr : x) { debug(itr); }

template <class T> inline void chmax(T &ans, T t) { if (t > ans) ans = t;}
template <class T> inline void chmin(T &ans, T t) { if (t < ans) ans = t;}

template <class Thead>
constexpr auto make_vector(Thead head)
{
  return std::vector<Thead>();
}

template <class THead, class ...Args>
constexpr auto make_vector(THead head, Args... tail) 
{
  return std::vector<decltype(make_vector(tail...))>();
}

int N,C,X;
int D[30][39];
int t[3][30];

int main() {
  cin >> N >> C;
  rep(i, C)rep(j, C) cin >> D[i][j];
  rep(i, N)rep(j, N) {
    cin >> X;
    t[(i + j)% 3][X - 1] += 1;
  }
  int ans = 1 << 30;
  rep(i, C)rep(j, C) if (i != j) rep(k, C) if (i != k and j != k)
  {
    int tt = 0;
    rep(l, C) tt += D[l][i] * t[0][l];
    rep(l, C) tt += D[l][j] * t[1][l];
    rep(l, C) tt += D[l][k] * t[2][l];
    chmin(ans, tt);
  }

  cout << ans << endl;
}



Measured memory_bytes: 256
n = int(input())
a = 0
b = 0
for i in range(n):
    c = input().split()
    if c[0] == c[1]:
        a += 1
        b += 1
    elif c[0] == sorted(c)[0]:
        b += 3
    else:
        a += 3
print(a,b)


Measured memory_bytes: 5596
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using pii = pair<int,int>;
const long long INF = 1LL << 60;

int x,a,b;

int main()
{
  cin >> x >> a >> b;
  cout << (x-a)-(x-a)/b*b << endl;
}

Measured memory_bytes: 3636
#include<stdio.h>
int main()
{
	int H,W,h,w,ans;
	scanf("%d",&H);
	scanf("%d",&W);
	scanf("%d",&h);
	scanf("%d",&w);
	ans=H*W-h*W-w*H+h*w;
	printf("%d",ans);
	return 0;
	
	
	
 } 

Measured memory_bytes: 128
#include<iostream>
#include<cstdlib>
#include<string>
#include<vector>
#include<map>
#include<unordered_map>
#include<queue>
#include<algorithm>
#include<iomanip>
using namespace std;
using ll = long long int;
const int mod = 1e9 + 7;
#define rep(i, a, b) for(int i = a;i < b; i++)

int main() {

	int n;
	cin >> n;

	vector<int> a(n + 1), b(n);
	rep(i, 0, n + 1) cin >> a[i];
	rep(i, 0, n) cin >> b[i];

	ll asum = 0, count = 0;

	rep(i, 0, n) {
		asum = a[i] + a[i + 1];
		if (asum >= b[i]) {
			count += b[i];
			b[i] -= a[i];
			if(b[i] > 0) a[i + 1] -= b[i];
		}
		else {
			count += asum;
			a[i] = 0;
			a[i + 1] = 0;
		}
		asum = 0;
	}

	cout << count << endl;

	return 0;
}


Measured memory_bytes: 1024
# -*- coding:utf-8 -*-
if __name__ == "__main__":
    n, x = map(int, input().split())
    m = [ int(input()) for _ in range(n) ]
    ans = len(m)
    singleWeight = sum(m)
    surplus = x - singleWeight
    if surplus > 0:
        ans += surplus//min(m)
        surplus -= min(m)*(surplus//min(m))
    else:
        pass
    print(ans)

Measured memory_bytes: 3064
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static System.Math;
public static class P
{
    public static void Main()
    {
        var abx = Console.ReadLine().Split().Select(int.Parse).ToArray();
        double a = abx[0];
        double b = abx[1];
        double x = abx[2];
        var triangle = x / a;
        double res;
        if (triangle < a * b / 2)
        {
            var width = triangle * 2 / b;
            res = Acos(width / Sqrt(b * b + width * width)) / PI * 180;
        }
        else
        {
            var height = (a * b - triangle) * 2 / a;
            res = Asin(height / Sqrt(height * height + a * a)) / PI * 180;
        }
        Console.WriteLine(res);
    }
}

Measured memory_bytes: 13268
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define all(V) V.begin(),V.end()
#define MOD 1000000007

vector<int> G[200010], T[200010];
ll P[200010], W[200010], F[200010], pt[200010], inv[200010], ptp[200010], N;

ll modpow(ll x, ll y) {
	ll ans = 1;
	while (y) {
		if (y & 1)
			ans *= x;
		ans %= MOD;
		x *= x;
		x %= MOD;
		y /= 2;
	}
	return ans;
}

void make_tree(int c, int p) {
	T[p].push_back(c);
	P[c] = p;
	for (int i : G[c]) {
		if (i == p)continue;
		make_tree(i, c);
	}
}

ll nCk(ll n, ll k) {
	return F[n] * inv[k] % MOD * inv[n - k] % MOD;
}

void eval(int k) {
	ll w = 0, p = 1;
	for (int i : T[k]) {
		eval(i);
		w += W[i];
		p *= pt[i];
		p %= MOD;
	}
	W[k] = w + 1;
	for (int i : T[k]) {
		p *= nCk(w, W[i]);
		p %= MOD;
		w -= W[i];
	}
	pt[k] = p;
}

void eval_rev(int c, int p) {
	if (c == 1) {
		ptp[c] = pt[c];
	}
	else {
		ll pp = ptp[p] * modpow(nCk(N - 1, W[c]) * pt[c] % MOD, MOD - 2) % MOD;
		ptp[c] = nCk(N - 1, N - W[c]) * pp % MOD * pt[c] % MOD;
	}
	for (int i : T[c]) {
		eval_rev(i, c);
	}
}

int main() {
	F[0] = 1;
	inv[0] = 1;
	for (ll i = 1;i < 200010;i++) {
		F[i] = F[i - 1] * i % MOD;
		inv[i] = modpow(F[i], MOD - 2);
	}
	int a, b;
	cin >> N;
	for (int i = 1;i < N;i++) {
		cin >> a >> b;
		G[a].push_back(b);
		G[b].push_back(a);
	}
	make_tree(1, 0);
	eval(1);

	eval_rev(1, 0);

	for (int i = 1;i <= N;i++) {
		cout << ptp[i] << "\n";
	}
}

Measured memory_bytes: 31360
#include<cstdio>
#include<cstring>
using namespace std;
int n;
bool flag=1;
char s[105];
int main()
{
	scanf("%s",s+1);
	n=strlen(s+1);
	for(int i=1;i<=n&&flag;i++)
		if(i&1&&s[i]=='L')flag=0;
		else if(!(i&1)&&s[i]=='R')flag=0;
	if(flag)puts("Yes");
	else puts("No");
	return 0;
}

Measured memory_bytes: 128