akhauriyash/Code-Regression huggingface dataset:
// C++ includes used for precompiling -*- C++ -*-

// Copyright (C) 2003-2013 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library.  This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.

// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.

// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.

// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
// <http://www.gnu.org/licenses/>.

/** @file stdc++.h
 *  This is an implementation file for a precompiled header.
 */

// 17.4.1.2 Headers

// C
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

/*全てのライブラリをインクルード*/
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;

int main()
{
    string s;
    cin>>s;
    string s1="WB";
    string s2="BW";
    int count=0;
    int n;
    n=s.length();
    rep(i,n){
        if(s.compare(i,2,"BW")==0)count++;
        if(s.compare(i,2,"WB")==0)count++;
    }
    cout<<count<<endl;
    return 0;
}

Measured memory_bytes: 3696
/*2019/09/13 */
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#define MOD 1000000007
#define MIN 999999999
#define MAX -999999999
typedef long long int ll;
typedef unsigned long long int ull;
void llswap(ll *x,ll *y){ll temp;temp=*x;*x=*y;*y=temp;}
void swap(int *x,int *y){int tmp;tmp=*x;*x=*y;*y=tmp;}
int rmax(int x,int y){return x>y?x:y;}
int rmin(int x,int y){return x>y?y:x;}
ll llrmax(ll x,ll y){return x>y?x:y;}
ll llrmin(ll x,ll y){return x>y?y:x;}
int asc(const void *a,const void *b){return *(int*)a-*(int*)b;}
int desc(const void *a,const void *b){return *(int*)b-*(int*)a;}
int llasc(const void *a,const void *b){return *(ll*)a-*(ll*)b;}
int lldesc(const void *a,const void *b){return *(ll*)b-*(ll*)a;}
int gcd(int x,int y){if(y==0)return x;return gcd(y,x%y);}
/*
int asc_t(const void *a,const void *b){return ((struct_t*)a)->member - ((struct_t*)b)->member;}
int desc_t(const void *a,const void *b){return ((struct_t*)b)->member - ((struct_t*)a)->member;}
*/
int main(){
    int n,k,q;
    int a[200000];
    int score[200000]={};
    scanf("%d %d %d",&n,&k,&q);
    for(int i=0;i<n;i++){
        score[i]=k-q;
    }
    for(int i=0;i<q;i++){
        scanf("%d",&a[i]);
        score[a[i]-1]++;
    }
    
    for(int i=0;i<n;i++){
        //printf("i:%d %d\n",i,score[i]);
        if(score[i]<=0){
            printf("No\n");
        }else{
            printf("Yes\n");
        }
    }
    return 0;

}

Measured memory_bytes: 1664
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
    ll A, B, K;
    cin >> A >> B >> K;
    
    B += min(A - K, 0ll);
    A = max(A-K, 0ll);
    B = max(B, 0ll);
    cout << A << " " << B << "\n";
    return 0;
}


Measured memory_bytes: 256
import sys
n=int(input())
A=[int(i) for i in input().split()]

N=10**6
spf = [i for i in range(N+1)]

for i in range(2,N):
    if i**2>N:
        break
    if spf[i] == i:
        for j in range(i**2,N+1,i):
            if spf[j] == j:
                spf[j] = i

def get(n):
    ps = set()
    while n != 1:
        ps.add(spf[n])
        n //= spf[n]
    return ps

#f1=True
f2=True

n0 = list(get(A[0]))
K=set(n0)
J=set(n0)

for a in A[1:]:
    res = get(a)
    #print(K,J,res)
    
    if len(res) != 0:
        K &= res
        
    if len(J & res) !=0:
        f2 = False
        
    if len(res) != 0:
        J |= res
        
#print(K,J,res)        
        
if (1 in A) or len(K) == 0:
    f1 = True
else:
    f1 = False
    
if f1:
    if f2:
        print("pairwise coprime")
    else:
        print("setwise coprime")
else:
    print("not coprime")

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

int N;
long long int a[1005];

vector<int> rem;
vector<int> proc;

int main(void) {

	cin >> N;

	for (int i = 1; i <= N; i++) { cin >> a[i]; }

	long long int sum_even = 0;
	for (int i = 2; i <= N; i += 2) {
		if (a[i] >= 0) { sum_even += a[i]; }
	}

	long long int sum_odd = 0;
	for (int i = 1; i <= N; i += 2) {
		if (a[i] >= 0) { sum_odd += a[i]; }
	}

	long long int ans;

	//==========================================
	if (sum_even == 0 && sum_odd == 0) {
		int I; long long int M = -19999999999;
		for (int i = 1; i <= N; i++) {
			if (M < a[i]) { M = a[i]; I = i; }
		}
		for (int i = N; i > I; i--) {
			proc.push_back(i);
		}
		for (int i = 1; i < I; i++) {
			proc.push_back(1);
		}
		cout << M << endl;
		cout << proc.size() << endl;
		for (int i = 0; i < (int)proc.size(); i++) {
			cout << proc[i] << endl;
		}
		//system("pause");
		return 0;
	}
	//========================


	if (sum_even > sum_odd) {
		ans = sum_even;
		for (int i = 2; i <= N; i += 2) { if (a[i] >= 0) { rem.push_back(i); } }
	}
	else {
		ans = sum_odd;
		for (int i = 1; i <= N; i += 2) { if (a[i] >= 0) { rem.push_back(i); } }
	}

	//cout << ans << endl;

	int M = 0;

	sort(rem.rbegin(), rem.rend());

	int K = rem.size();

	for (int i = N; i > rem[0]; i--) {
		proc.push_back(i);
	}



	for (int i = 1; i <= K - 1; i++) {
		int Y = (rem[i - 1] - rem[i]) / 2 - 1;
		for (int j = 0; j < Y; j++) { proc.push_back(rem[i] + 2); }
		proc.push_back(rem[i]+1);
	}

	for (int i = 1; i < rem[K - 1]; i++) {
		proc.push_back(1);
	}
	

	cout << ans << endl;
	cout<< proc.size() << endl;
	for (int i = 0; i < (int)proc.size(); i++) {
		cout << proc[i] << endl;
	}

	//system("pause");
	return 0;
}

Measured memory_bytes: 256
use std::io;
 
fn main () {
    let mut input = String::new();
    io::stdin().read_line(&mut input).unwrap();
    let sum: i32 = input.split_whitespace().map(|x| x.parse::<i32>().unwrap()).product();
    if sum % 2 == 1 {
        println!("Odd");
    } else {
        println!("Even");
    }
}

Measured memory_bytes: 4352
def main():

    K = int(input())
    S = input()

    mod = pow(10, 9) + 7
    N = len(S)

    g1 = [1, 1]
    g2 = [1, 1]
    inv = [0, 1]

    for i in range(2, K+N+1):
        g1.append((g1[-1] * i) % mod)
        inv.append( ( -inv[mod % i] * (mod//i)) % mod )
        g2.append((g2[-1] * inv[-1]) % mod)

    def combi(n, r):
      r = min(r, n-r)
      return g1[n]*g2[r]*g2[n-r]%mod

    pow25 = [1]
    pow26 = [1]
    for i in range(K):
        pow25.append(pow25[-1] * 25 % mod)
        pow26.append(pow26[-1] * 26 % mod)

    ans = 0
    for i in range(N-1, N+K):
        ans += combi(i, N-1) * pow25[i-N+1] % mod * pow26[K-i+N-1] % mod
        ans %= mod
    return ans

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

Measured memory_bytes: 226512
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import sys
import re
import math
import collections
import itertools
import functools

DEBUG = True
DEBUG = False

def dbg(*args):
    if DEBUG:
        print("DBG: ", file=sys.stderr, end="")
        print(*args, file=sys.stderr)



def main():
    N = int(input())

    k = math.floor(math.log(N, 2))
    print(2**k)

if __name__ == "__main__": main()


Measured memory_bytes: 4084
#include <iostream>
#include <algorithm>
using namespace std;
const int MAX = 2005;
int L[MAX][MAX], R[MAX][MAX], U[MAX][MAX], D[MAX][MAX], H[MAX][MAX], G[MAX][MAX], ans;
int main()
{
	ios_base::sync_with_stdio(false); cin.tie(0);
	int h, w; cin >> h >> w;
	for (int i = 0; i < h; i++)
	{
		for (int j = 0; j < w; j++) 
		{
			char ch; cin >> ch;
			if (ch == '#') G[i][j] = 0;
			else if (ch == '.') G[i][j] = 1;
		}
	}
	//cout << "left";
	for (int i = 0; i < h; i++)
	{
		for (int j = 1; j < w; j++)
		{
			if (j == 1)
			{
				L[i][j] = G[i][j-1];
			}
			else L[i][j] = L[i][j-1] + 1;
			if (G[i][j] == 0 || G[i][j-1] == 0) L[i][j] = 0;
		}
	}
	//cout << "right";
	for (int i = 0; i < h; i++)
	{
		for (int j = w-2; j >= 0; j--)
		{
			if (j == w-2)
			{
				R[i][j] = G[i][j+1];
			}
			else R[i][j] = R[i][j+1] + 1;
			if (G[i][j] == 0 || G[i][j+1] == 0) R[i][j] = 0;
		}
	}
	//cout << "up";
	for (int i = 1; i < h; i++)
	{
		for (int j = 0; j < w; j++)
		{
			if (i == 1)
			{
				U[i][j] = G[i-1][j];
			}
			else U[i][j] = U[i-1][j] + 1;
			if (G[i][j] == 0 || G[i-1][j] == 0) U[i][j] = 0;
		}
	}
	//cout << "down";
	for (int i = h-2; i >= 0; i--)
	{
		for (int j = 0; j < w; j++)
		{
			if (i == h-2)
			{
				D[i][j] = G[i+1][j];
			}
			else D[i][j] = D[i+1][j] + 1;
			if (G[i][j] == 0 || G[i+1][j] == 0) D[i][j] = 0;
		}
	}
	//cout << "main";
	for (int i = 0; i < h; i++)
	{
		for (int j = 0; j < w; j++)
		{
			H[i][j] = 1 + L[i][j] + R[i][j] + U[i][j] + D[i][j];
			ans = max(ans, H[i][j]);
		}
	}
	cout << ans;
	return 0;
}

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

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

int main(void) {
    int N;
    cin >> N;
    vector<long long> L(N);
    rep(i, N) cin >> L[i];
    sort(L.begin(), L.end());

    long long ans = 0;
    for (int i = 0; i < N; i++) {
        for (int j = i + 1; j < N; j++) {
            for (int k = j + 1; k < N; k++) {
                if (L[k] < L[i] + L[j]) {
                    ans += 1;
                }
            }
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

N = int(input())

ans = 0
s = factorization(N)

if s[0][0] != 1:
    for i in range(len(s)):
        cnt = 1
        rest = s[i][1]
        while True:
            if cnt <= rest:
                N = N//(s[i][0]**cnt)
                rest -= cnt
                cnt += 1
                ans += 1
            else:
                break
    print(ans)
else:
    print(0)


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

t = 0
a = 0
for _ in range(N):
  rt,ra = map(int,input().split())
  c = max((t-1)//rt+1, (a-1)//ra+1)
  t = rt*c
  a = ra*c
  if a+t == 0:
    t += rt
    a += ra

    
answer = t+a
print(answer)

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

#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORR(i, m, n) for (int i = m; i >= n; i--)
#define ALL(x) (x).begin(), (x).end()

using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 1e15;
const ll MOD = 1e9 + 7;

int main() {
  ll n, k;
  cin >> n >> k;
  string s;
  cin >> s;

  vector<ll> nums;
  ll now = 1;
  ll cnt = 0;
  REP(i, s.size()) {
    if (s[i] == (char)('0' + now))
      ++cnt;
    else {
      nums.push_back(cnt);
      now = 1 - now;
      cnt = 1;
    }
  }
  if (cnt != 0) nums.push_back(cnt);
  if (nums.back() == '0') nums.push_back(0);

  vector<ll> sum((ll)nums.size() + 1, 0);
  REP(i, nums.size()) sum[i + 1] = sum[i] + nums[i];

  ll ans = 0;
  for (ll left = 0; left < sum.size(); left += 2) {
    ll right = min(left + 2 * k + 1, (ll)sum.size() - 1);
    ans = max(ans, sum[right] - sum[left]);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 2164
#include<stdio.h>
#include<math.h>
int main(void){
        int a[10][10],n,d,i,j,k,l=0,p=0;
        double s[50];
        scanf("%d%d",&n,&d);
        for(i=0;i<n;i++){
            for(j=0;j<d;j++){
                scanf("%d",&a[i][j]);
            }
        }
       for(i=0;i<n-1;i++){
            for(k=i+1;k<n;k++){
                for(j=0;j<d;j++){
                    s[p]=s[p]+(pow((a[i][j]-a[k][j]),2));
                }
                p++;
            }
       }
       for(i=0;i<p;i++){
            s[i]=sqrt(s[i]);
            if(round(s[i])-(s[i])==0){
                l++;
            }
       }
       printf("%d",l);
       return 0;
}


Measured memory_bytes: 2132
import java.util.Scanner;

public class Main {

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

        int N = scanner.nextInt();

        long sum = 0;
        for (int i = 1 ; i <= N ; i++) {
            if ( i % 3 != 0 && i % 5 != 0) {
                sum+= i;
            }
        }

        System.out.println(sum);
    }
}


Measured memory_bytes: 35664
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
#define fi first
#define se second
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define siz(v) (ll)(v).size()
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repi(i, x, n) for (ll i = x; i < (ll)(n); i++)
typedef pair<ll, ll> P;
typedef pair<ll, ll> PL;
const ll mod = 1000000007;
const ll INF = 1000000099;
vector<ll> dx = {-1, 1, 0, 0}, dy = {0, 0, -1, 1};
//cin.tie(0);
//ios::sync_with_stdio(false);

signed main()
{
    string s;
    cin >> s;
    ll k = 1, ans = 1;
    int mae=1;

    for (ll i = 1; i < siz(s); i++)
    {
        //cout<<i<<endl;
        if(s[i]==s[i-1] && mae==1){
            i++;
            mae=2;
            if(i==siz(s)){
                k--;
                //cout<<"D"<<endl;
            }
        }else{
            mae=1;
        }
        k++;
        //cout<<i<<":"<<k<<endl;
    }
    ans = k;
    reverse(all(s));

    k = 1;
    mae=1;

    for (ll i = 1; i < siz(s); i++)
    {
        //cout<<i<<endl;
        if(s[i]==s[i-1] && mae==1){
            i++;
            mae=2;
            if(i==siz(s)){
                k--;
                //cout<<"D"<<endl;
            }
        }else{
            mae=1;
        }
        k++;
        //cout<<i<<":"<<k<<endl;
    }
    
    ans = max(ans, k);
    cout << ans << endl;
}

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

int count_C(vector<int>*C){
  int count = 0;
  for(int i=0;i<C->size();i++){
    if(C->at(i)==0)count++;
  }
  return count;
}
int Get_ind(vector<int>*C){
  for(int i=0;i<C->size();i++){
    if(C->at(i)==0)return i;
  }
  return -1;
}
double Distance(int A,int B,vector<int>*X,vector<int>*Y){
  double dist;
  dist = pow((X->at(A) - X->at(B)),2) + pow((Y->at(A) - Y->at(B)),2);
  dist = sqrt(dist);
  return dist;
}
int Kaijo(int n){
  int ans =1;
  if(n==0)return 1;
  else{
    for(int i=1;i<n+1;i++){
      ans*=i;
    }
    return ans;
  }
}
double Print_all_patterns(vector<int>C,int Now,vector<int>*X,vector<int>*Y){
  int N = count_C(&C);
  double dist = 0;
  if(N==1){
    return Distance(Get_ind(&C),Now,X,Y);
  }else{
    vector<int> Indlist;
    for(int i=0;i<C.size();i++){
      if(C.at(i)==0)Indlist.push_back(i);
    }
    for(int i=0;i<Indlist.size();i++){
      C.at(Indlist.at(i))=1;
      dist+= Kaijo(N-1)*Distance(Indlist.at(i),Now,X,Y)+Print_all_patterns(C,Indlist.at(i),X,Y);
      C.at(Indlist.at(i))=0;
    }
  }
  return dist;
}

int main(){
  int N;
  cin>>N;
  vector<int>X(N);
  vector<int>Y(N);
  vector<int>C(N,0);
  for(int i=0;i<N;i++){
    cin>>X.at(i)>>Y.at(i);
  }
  double ans=0;
  int n = 1;
  for(int i=0;i<N;i++){
    C.at(i)=1;
    ans+=Print_all_patterns(C,i,&X,&Y);
    C.at(i)=0;
    }
  ans /= Kaijo(N);
  cout<<setprecision(10)<<ans<<endl;
}


Measured memory_bytes: 256
#include <cstdio>

int digit_sum(int n)
{
    int sum = 0;

    while(n)
    {
        sum += n%10;
        n /= 10;
    }

    return sum;
}

int main()
{
    int n;
    scanf("%d", &n);
    printf("%s\n", n%digit_sum(n) == 0 ? "Yes" : "No");;
    return 0;
}


Measured memory_bytes: 128
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using System.Globalization;
using System.Diagnostics;



class Myon
{
    public Myon() { }
    public static int Main()
    {
        new Myon().calc();
        return 0;
    }


    Scanner cin;

    void calc()
    {
        cin = new Scanner();
        int N = cin.nextInt();
        string S = cin.next();
        bool[] type = new bool[N];
        for (int i = 0; i < 2; i++)
        {
            for (int j = 0; j < 2; j++)
            {
                type[0] = i == 0;
                type[1] = j == 0;
                for (int k = 2; k < N; k++)
                {
                    type[k] = (type[k - 1]) ^ (S[k - 1] == 'o') ^ (type[k - 2]);
                }

                if (type[0] != (type[N - 1]) ^ (S[N - 1] == 'o') ^ (type[N - 2])) continue;
                if (type[1] != (type[0]) ^ (S[0] == 'o') ^ (type[N - 1])) continue;
                for (int k = 0; k < N; k++)
                {
                    if (type[k]) Console.Write("S");
                    else Console.Write("W");
                }
                Console.WriteLine();
                return;
            }
        }
        Console.WriteLine(-1);
    }

}



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);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

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

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

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


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}


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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int H, W;
  cin >> H >> W;
  vector<string> A(H);
  vector<vector<int>> B(H, vector<int>(W));
  REP(i, H) cin >> A[i];
  int dx[4] = {0, 1, 0, -1};
  int dy[4] = {-1, 0, 1, 0};
  int ans = -1;
  int INF = 1e9;
  for(int i = 0; i < H; i++) {
    for(int j = 0; j < W; j++) {
      if(A[i][j] == '.') { B[i][j] = INF; }
      if(A[i][j] == '#') { B[i][j] = 0; }
    }
  }
  // mazu hidari kara migi
  for(int i = 0; i < H; i++) {
    for(int j = 1; j < W; j++) {
      if(B[i][j - 1] == INF) continue;
      B[i][j] = min(B[i][j], B[i][j - 1] + 1);
    }
  }
  // migi kara hidari
  for(int i = 0; i < H; i++) {
    for(int j = W - 2; j >= 0; j--) {
      B[i][j] = min(B[i][j], B[i][j + 1] + 1);
    }
  }
  // ue kara sita
  for(int j = 0; j < W; j++) {
    for(int i = 1; i < H; i++) {
      B[i][j] = min(B[i][j], B[i - 1][j] + 1);
    }
  }
  // sita kara ue
  for(int j = 0; j < W; j++) {
    for(int i = H - 2; i >= 0; i--) {
      B[i][j] = min(B[i][j], B[i + 1][j] + 1);
    }
  }
  for(int i = 0; i < H; i++) {
    for(int j = 0; j < W; j++) {
      ans = max(ans, B[i][j]);
    }
  }

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

Measured memory_bytes: 5376
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll mxn= 5e5+5;
// check for forloop
// intialize variable
// overflow
// go for easy solution
#define mod 1000000007
ll INF = 1000000000000000005LL;
#define endl '\n'
void rishabh(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}
int main(){
    rishabh();
    int n;
    cin>>n;
    int arr[n];
    for(int i=0;i<n;i++){
        cin>>arr[i];
    }
    for(int i=n-1;i>=0;i-=2){
        cout<<arr[i]<<' ';
    }
    for(int i=(n%2==0)?0:1;i<n;i+=2){
        cout<<arr[i]<<' ';
    }
}


Measured memory_bytes: 4436
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
#define MAXN 100
#define MAXA 1000
int main(int argc,char const* argv[])
{
  int n,i,ans=0,a,min=0,max=0;
  vector<int> buckets(MAXA+1,0);
  cin >> n;
  for(i=0;i<n;i++)
    {
      cin >> a;
      if(buckets[a]==0) buckets[a]+=1;
    }
  for(i=0;i<=MAXA;i++)
    {
      if(buckets[i] !=0)
	{
	  min=i;
	  break;
	}
    }
  for(i=MAXA;i>=0;i--)
    {
      if(buckets[i] !=0)
	{
	  max=i;
	  break;
	}
    }
  ans=max-min;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define P pair<int,int>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000
#define MOD 1000000007
#define all(v) v.begin(),v.end()
#define pb push_back
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int kaijo[200010];
struct edge{int to,cost;};
int gcd(int a,int b){
	if(b==0)return a;
	return gcd(b,a%b);
}
int lcm(int a,int b){
	return a/gcd(a,b)*b;
}
bool prime(int a){
	if(a==1)return false;
	for(int i=2;i*i<=a;i++){
		if(a%i==0)return false;
	}
	return true;
}
bool kosa(double ax,double ay,double bx,double by,double cx,double cy,double dx,double dy){//線分の交差判定
	double ta=(cx-dx)*(ay-cy)+(cy-dy)*(cx-ax);
	double tb=(cx-dx)*(by-cy)+(cy-dy)*(cx-bx);
	double tc=(ax-bx)*(cy-ay)+(ay-by)*(ax-cx);
	double td=(ax-bx)*(dy-ay)+(ay-by)*(ax-dx);
	return tc*td<0&&ta*tb<0;
}
void init_fact(int n){
	kaijo[0]=1;
	for(int i=1;i<=n;i++){
		kaijo[i]=kaijo[i-1]*i;
		kaijo[i]%=MOD;
	}
}
int modpow(int a,int b){
	if(b==0)return 1;
	if(b%2)return modpow(a,b-1)*a%MOD;
	int memo=modpow(a,b/2);
	return memo*memo%MOD;
}
int comb(int a,int b){
	if(b>a)return 0;
	if(a==b)return 1;
	return kaijo[a]*modpow(kaijo[a-b],MOD-2)%MOD*modpow(kaijo[b],MOD-2)%MOD;
}
int g(int x){
	x=modpow(x,MOD-2);
	return x;
}
int n,a[1010][1010],day=0;
bool b[1010][1010];
P now[1010];
//次の相手、最終の試合の日
signed main(){
	cin>>n;
	rep(i,n){
		rep(j,n-1){
			cin>>a[i][j];
			a[i][j]--;
		}
	}
	rep(i,n)now[i]={0,-1};
	queue<int>q;
	while(1){
		bool flag=false;
		rep(i,n){
			if(now[i].fi==n-1)continue;
			int aite=a[i][now[i].fi];
			if(now[aite].fi==n-1)continue;
			if(a[aite][now[aite].fi]==i){
				if(b[i][aite])continue;
				if(now[i].se==day||now[aite].se==day)continue;
				b[i][aite]=b[aite][i]=true;
				
				now[i].fi++,now[i].se=day;
				now[aite].fi++,now[aite].se=day;
				flag=true;
			}
		}
		if(!flag)break;
		day++;
	}
	rep(i,n){
		rep(j,n){
			if(i!=j){
				if(!b[i][j]){
					puts("-1");
					return 0;
				}
			}
		}
	}
	cout<<day<<endl;
	return 0;
}


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

using namespace std;

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

int N = 1000;
bool is_prime[100000];

void set_prime() {
    memset(is_prime, true, N);
    is_prime[0] = is_prime[1] = false;
    REP(i, 2, sqrt(N)) {
        if(is_prime[i]) {
            for(int j=0; i*(j+2)<N; j++) {
                is_prime[i*(j+2)] = false;
            }
        }
    }
}

map<int, int> pfact(int n) {
    map<int, int> ret;
    REP(p, 2, n+1) {
        if(!is_prime[p]) continue;
        int m = n, i = 0;
        for(; m%p==0; i++) if(m%p==0) m /= p;
        if(i) ret[p] = i;
    }
    return ret;
}

int main() {
    set_prime();
    int n;
	cin >> n;
    map<int, int> m;
    REP(i, 1, n+1) {
        for(auto p : pfact(i)) {
            m[p.first] += p.second;
        }
    }
    
    int ans = 0;
    int x, y;

    // 3x5x5
    x = 0, y = 0;
    for(auto p : m)
        if(p.second>=4) x+=1;
        else if(p.second>=2) y+=1;
    ans += x*(x-1)/2*(x+y-2);

    // 3x25
    x = 0, y = 0;
    for(auto p : m)
        if(p.second>=24) x+=1;
        else if(p.second>=2) y+=1;
    ans += x * (x+y-1);

    // 5x15
    x = 0, y = 0;
    for(auto p : m)
        if(p.second>=14) x+=1;
        else if(p.second>=4) y+=1;
    ans += x * (x+y-1);

    // 75
    x = 0;
    for(auto p : m)
        if(p.second>=74) x+=1;
    ans += x;

    cout << ans << endl;
}


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

using namespace std;

int main(){
    string a,b;
    cin >> a >> b;
    for(int i = 0;i < a.size();i++){
        if(a[i] != b[i]){
            cout << "No";
            return 0;
        }
    }
    cout << "Yes";
}

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

void PrintVector(vector<int> A, int N)
{
    for (int i = 0; i < N; i++)
    {
        if (i != N - 1)
        {
            cout << A[i] << ' ';
        }
        else
        {
            cout << A[i] << endl;
        }
    }
}

int InsertionSort(vector<int> &A, int N, int g)
{
    int cnt = 0;
    for (int i = g; i < N; i++)
    {
        int pivot = A[i];
        int j = i - g;
        while ((j >= 0) && (A[j] > pivot))
        {
            A[j + g] = A[j];
            j -= g;
            cnt++;
        }
        A[j + g] = pivot;
    }
    return cnt;
}

int main()
{
    int N;
    cin >> N;
    vector<int> A(N, 0);
    for (int i = 0; i < N; i++)
    {
        cin >> A[i];
    }
    int m = 0, cnt = 0;
    vector<int> M = {1};
    for (int i = 0; M[i] * 2 <= N; i++)
    {
        M.push_back(M[i] * 2);
    }
    reverse(M.begin(), M.end());
    m = M.size();
    cout << m << endl;
    PrintVector(M, m);
    for (int i = 0; i < m; i++)
    {
        cnt += InsertionSort(A, N, M[i]);
    }
    cout << cnt << endl;
    for (int i = 0; i < N; i++)
    {
        cout << A[i] << endl;
    }

    return 0;
}


Measured memory_bytes: 6668
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>
#include <set>
#include <functional>
#include <iomanip>

using namespace std;

#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ;
#endif

#define equals(a,b) (fabs((a)-(b)) < EPS)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back

//#define int long long

typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

template <typename T>
void print_array(const T &ary, int size){
    REP(i,size){
        cout << ary[i] << " ";
    }
    cout << endl;
}

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;
const double EPS = (1e-10);

signed main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(12);

    int A,B; cin >> A >> B;
    FOR(i,1,10000){
        int a = i * 1.08;
        int b = i * 1.1;
        if(a-i == A && b-i == B){
            cout << i << endl;
            return 0;
        }
    }
    cout << -1 << endl;

}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
#include <utility>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <set>

#define INF_LL 9000000000000000000
#define INF 2000000000

#define REP(i, n) for(int i = 0;i < (n);i++)
#define FOR(i, a, b) for(int i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()

using namespace std;

typedef long long ll;
typedef pair<int, int> PII;
typedef pair<int, PII> PPII;
typedef pair<int, PPII> PPPII;

class Union_find{
private:
	vector<int> par;
	vector<int> rank;
	int n;

public:
	Union_find(int a){
		n = a;
		for(int i = 0;i < n;i++){
			par.push_back(i);
			rank.push_back(0);
		}
	}

	int find(int x){
		if(par[x] == x){
			return x;
		}else{
			return par[x] = find(par[x]);
		}
	}

	void unite(int x, int y){
		x = find(x);
		y = find(y);
		if(x == y) return;

		if(rank[x] < rank[y]){
			par[x] = y;
		}else{
			par[y] = x;
			if(rank[x] == rank[y]) rank[x]++;
		}
	}

	bool same(int x, int y){
		return find(x) == find(y);
	}
};

int main(void){
	int D, n, m;
	while(cin >> D && D){
	ll res = 0;
	ll d[100010] = {};
	cin >> n >> m;
	d[0] = 0;
	REP(i, n-1){
		cin >> d[i+1];
	}
	d[n] = D;
	sort(d, d+n);
	REP(i, m){
		ll k;
		cin >> k;
		ll *s = upper_bound(d, d+n+1, k);
		res += min(abs(*s-k), abs(*(s-1)-k));
	}
	cout << res << endl;
	}
}

Measured memory_bytes: 3796
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <time.h>
#include <math.h>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
#include <iterator>
#include <sstream>
#include <string>
#include <bitset>
using namespace std;
#define FOR(I,F,N) for(int I = F; I < (int)(N); I++)
#define rep(i, n) FOR(i, 0, n)
#define FIN(V) cout<<V<<endl
#define pb push_back
#define int long long
#define INF (1 << 30)
typedef pair<int, int> P;
typedef long long ll;
typedef priority_queue<int> pq;
int StrToInt(string);
string IntToStr(int);
int dx[4] = {1, -1, 0, 0};
int dy[4] = {0, 0, 1, -1};

signed main(void){
	int N;
	while(cin >> N, N){
		int sum = 0;
		rep(i, N){
			int a; 
			cin >> a;
			sum += a;
		}
		int maxi=sum*N;
		vector<int> v;
		rep(i, N-1){
			int aa;
			cin >> aa;
			v.push_back(aa);
		}
		sort(v.begin(), v.end(), greater<int>());
		rep(i,v.size()){
			sum += v[i];
			maxi = max(maxi, sum*(N-i-1));
		}

		cout << maxi << endl;
	}
	return 0;
}



int StrToInt(string s){
	stringstream ss;
	ss << s;
	int val;
	ss >> val;
	return val;
}
string IntToStr(int i){
	stringstream ss;
	ss << i;
	return ss.str();
}

Measured memory_bytes: 2128
#include <bits/stdc++.h>
#define SORT(x) sort((x).begin(), (x).end())
#define ALL(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < n; i++)
#define reps(i, m, n) for (ll i = m; i < n; i++)
#define repr(i, m, n) for (ll i = m; i >= n; i--)
template <class T> bool maxi(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> bool mini(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
#define dame {cout<< "-1" <<"\n"; return;}
#define INF2 1000000000000000037
#define INF  1000000007
#define MOD  1000000007
#define PI (acos(-1))
using namespace std;
using ll = long long;
using ld = long double;
using P  = pair<ll,ll>;
//--GLOBAL---------------------------------
const ll MAX = 200010;
ll fac[MAX], finv[MAX], inv[MAX];
void cinit() { // O(nlogn)
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    reps(i, 2, MAX){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
ll c(int n, int k){ // 二項係数計算
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
ll modpow(ll a, ll n, ll mod=MOD){ // a^n % MOD の計算
    ll res = 1;
    while (n > 0){
        if(n & 1) res = res * a % mod;
        a = a * a  % mod;
        n >>= 1;
    }
    return res;
}
//--MAIN-----------------------------------
void Main() {
    ll N,A,B,C; cin>>N>>A>>B>>C;
    ll ans=0;
    cinit();
    reps(M,N,N*2){
        ll invs=modpow(A+B,MOD-2);
        ll X=( ( c(M-1,N-1) * ((modpow(A,N)*modpow(B,M-N)+modpow(A,M-N)*modpow(B,N))%MOD) )%MOD)*modpow(invs,M);
        X%=MOD;
        ll Y=M*100*modpow(100-C,MOD-2)%MOD;
        ans+=X*Y;
        ans%=MOD;
    }
    cout<< ans <<"\n";
}
//--START----------------------------------
int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
}
//-----------------------------------------


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

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n, k, ans = 0;
    cin >> n >> k;
    for (int i = 0; i < n; i++) {
        int temp;
        cin >> temp;
        if (temp >= k) {
            ans++;
        }
    }
    cout << ans << '\n';
    return 0;
}


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 sum = 0;
    for (int i = 0; i < k;i++){
        sum += l.at(i);
    }
    cout << sum;
}

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

int main() {
  string S;
  cin>>S;
  int n = S.size();
  
  int ans=0;
  
  for(int i=0; i<(n/2); i++){
    if(S.at(i)!=S.at(n-1-i)){
      ans++;
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3624
//#pragma GCC optimize ("O3")
//#pragma GCC target ("avx")
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please


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


	int N;
	cin >> N;
	int kotae[200000] = {};

	rep(i, N - 1) {
		int a;
		cin >> a;
		a--;
		kotae[a]++;
	}
	rep(i, N) co(kotae[i]);

	Would you please return 0;
}

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

int stack[1000];
int main(void) {
	int top = 0, val;
	char buf[100], *ptr;
	while (scanf("%s", buf) != EOF) {
		val = strtol(buf, &ptr, 10);
		if (buf == ptr) {
			switch (*buf) {
				case '+': val = stack[top - 2] + stack[top - 1]; break;
				case '-': val = stack[top - 2] - stack[top - 1]; break;
				case '*': val = stack[top - 2] * stack[top - 1]; break;
			}
			stack[top - 2] = val;
			top--;
		} else {
			stack[top++] = val;
		}
	}
	printf("%d\n", *stack);
}

Measured memory_bytes: 1848
import java.util.*;

public class Main{
   public static void main(String args[]) {
     Scanner sc = new Scanner(System.in);
     int n = sc.nextInt();
     
     if(n == 1) {
        System.out.println("Hello World");
     } else {
        int a = sc.nextInt();
        int b = sc.nextInt();
        System.out.println(a + b);
     }

   }
}

Measured memory_bytes: 21460
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define CK(N, A, B) (A <= N && N < B)
#define REP(i, a, b) for (int i = a; i < b; i++)
#define RREP(i, a, b) for (int i = (b - 1); a <= i; i--)
#define F first
#define S second
#define ll long long

const int INF = 1e9;
const long long LLINF = 1e18;

using namespace std;

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

/*==================================================*/
/*variable*/

/*==================================================*/
/*function*/


/*==================================================*/

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

    ll a = 0, b = 0;
    REP(i,0,s.size()){
        a = 10*a + (s[i]-'0');
        b = b + (s[i]-'0');
    }
    
    if( a % b == 0){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }

    return 0;
}


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

int main(int argc, char const *argv[])
{
	int a, b;
	cin >> a >> b;

	if (a > b)
	{
		printf("a > b\n");
	} else if (a == b){
		printf("a == b\n");
	}else{
		printf("a < b\n");
	}

	return 0;
}

Measured memory_bytes: 1116
#include<bits/stdc++.h>
using namespace std;
#define MOD ((int)(1e9+7))
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long
#define float long double

int32_t main()
{
	int n;cin>>n;
	vector<int>A(n+2);
	for(int i=1;i<=n;i++)cin>>A[i];
	int diff=0;
	for(int i=0;i<=n;i++)
	{
		diff+=abs(A[i]-A[i+1]);
	}
	cout<<diff/2<<endl;
	
	
}
	
			
	
	
	
	
	

	

	

	
		


Measured memory_bytes: 256
K = input()
A,B = input().split()

k = int(K)
a = int(A)
b = int(B)

x = a // k
z = b // k

# print(x,z)
for i in range(z-x + 1):
#   print("fof---", k*(x+i))
  if a <= k*(x+i) and k*(x+i) <= b:
        print("OK")
        exit()
print("NG")

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

using namespace std;
#define int long long

int32_t main()
{
    int a, b, k; cin >> a >> b >> k;
    if (a >= k) cout << a - k << " " << b << "\n";
    else cout << 0 << " " << max(0ll, b - (k - a)) << "\n";
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <math.h>
#include <stdlib.h>
#include <string.h>
#include <sstream>
#include <string>
#include <map>
#include <vector>
#include <stack>
#include <time.h>
#include <set>
#include <queue>
#define scan(a) scanf("%d",&a)
#define scann(n,m) scanf("%d%d",&n,&m)
#define scannn(n,m,w) scanf("%d%d%d",&n,&m,&w)
#define print(a) printf("%d\n",a)
#define dg(x) cout<<#x<<"="<<x<<endl
#define mem(a,n) memset(a,n,sizeof(a))
using namespace std;
const int maxn=2e5+10;
const int inf=0x3f3f3f3f;
const int mod=1e9+7;
const double eps=1e-8;
typedef pair<int,int> PP;
typedef long long ll;
typedef unsigned long long ull;
ll powmod(ll a,ll x,ll mod){ll t=1ll;while(x){if(x&1)t=t*a%mod;a=a*a%mod;x>>=1;}return t;}
ll gcd(ll a,ll b){return b==0?a:gcd(b,a%b);}
//==============================================================================================
int n,m;
int dp[maxn],f[maxn];
struct node{
    int x,y;
}p[maxn];

bool cmp(node a,node b){
    return a.x<b.x;
}

int main()
{
    //freopen("F://Duipai//in.txt","r",stdin);
    //freopen("F://Duipai//out.txt","w",stdout);

    while(~scann(n,m)){
        for(int i=0;i<m;i++)
            scann(p[i].x,p[i].y);
        sort(p,p+m,cmp);
        for(int i=1;i<=n;i++) dp[i]=1,f[i]=1;

        for(int i=0;i<m;i++){
            int yy=p[i].y;
            dp[yy+1]=dp[yy]+1;
        }

        for(int i=0;i<m;i++){
            int yy=p[i].y;
            f[yy]=f[yy+1]+1;
        }

        for(int i=1;i<=n;i++)
            printf("%d%c",dp[i]+f[i]-1,i==n?'\n':' ');
    }
    return 0;
}

Measured memory_bytes: 5560
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define Yes() std::cout << "Yes" << std::endl
#define No() std::cout << "No" << std::endl
#define Say(s) std::cout << s << std::endl
const ll MOD = 1000000007;
const ll INF = 1061109567;

int main()
{
    ll n;
    std::cin >> n;
    ll temp_10 = 10;
    ll temp_9 = 9;
    ll temp_8 = 8;
    rep(i, n - 1)
    {
        temp_10 *= 10;
        temp_10 %= MOD;
        temp_9 *= 9;
        temp_9 %= MOD;
        temp_8 *= 8;
        temp_8 %= MOD;
    }
    ll ans;
    ans = temp_10 - 2 * temp_9 + temp_8;
    ans %= MOD;
    while (ans < 0) {
        ans += MOD;
    }
    Say(ans);
    return 0;
}

Measured memory_bytes: 3628
import java.util.*;
import java.text.*;

public class Main {
    static long MOD = (long)1e9+7;
    public static void main(String args[]) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        boolean[][] g = new boolean[n][n];
        for(int i = 0; i< n; i++)
            for(int j = 0; j< n; j++)
                g[i][j] = in.nextInt() == 1;
        long[] ways = new long[1<<n];
        Arrays.fill(ways, -1);
        ways[0] = 1;
        System.out.println(calc(ways, g, n-1, (1<<n)-1));
    }
    static long calc(long[] ways, boolean[][] g, int cur,  int mask){
        if(cur == -1)return 1;
        if(ways[mask] != -1)return ways[mask];
        ways[mask] = 0;
        for(int i = 0; i < g.length; i++){
            if(((mask>>i)&1) == 1 && g[cur][i]){
                ways[mask] += calc(ways, g, cur-1, mask^(1<<i));
                if(ways[mask] >= MOD)ways[mask] -= MOD;
            }
        }
        return ways[mask];
    }
    static int bit(int x){
        return x == 0?0:(1+bit(x&(x-1)));
    }
}

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

#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef complex<double> point;
#define xx real()
#define yy imag()

#define REP(i, a, b) for(int i = (a); i < (int)(b); i++)
#define REPN(i, a, b) for(int i = (a); i <= (int)(b); i++)
#define FA(it, x) for(__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define SZ(x) (int)(x).size()
#define BE(x) (x).begin(), (x).end()
#define SORT(x) sort(BE(x))
#define _1 first
#define _2 second

#define x1 gray_cat_x1
#define y1 gray_cat_y1

template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }

#define file "I1"

const double EPS = 1e-9;
const double PI = acos(-1.);
const int INF = 1e9;
const ll MOD = 1e9 + 7;

const int MAXN = 1e5 + 5;

void solve(){
	int n, sum = 0, mn = INF, a;
	scanf("%d", &n);
	REP(i, 0, n) {
		scanf("%d", &a);
		sum += a;
		if (a % 10) {
			mn = min(mn, a);
		}
	}
	mn = min(mn, sum);
	if (sum % 10 == 0) {
		sum -= mn;
	}
	printf("%d\n", sum);
}   

int main(){

    //freopen(file".in", "r", stdin); freopen(file".out", "w", stdout);
    int t = 1;
    //cin >> t;
    while(t--){
        solve();    
    }
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 100;

/* typedef */

/* global variables */

int n, m, p;
int xis[MAX_N];

/* subroutines */

/* main */

int main() {
  for (;;) {
    cin >> n >> m >> p;
    if (n == 0) break;
    m--;

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

    int d = (xis[m] == 0) ? 0 : (double)(sum * (100 - p)) / xis[m];
    cout << d << endl;
  }
  
  return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#define rep(i , x , y) for(register int i = (x) , _## i = ((y) + 1) ; i < _## i ; i ++)
#define Rep(i , x , y) for(register int i = (x) , _## i = ((y) - 1) ; i > _## i ; i --)
using namespace std ;
#define int long long
using ll = long long ;
using pii = pair < int , int > ;
const static int _ = 1 << 20 ;
char fin[_] , * p1 = fin , * p2 = fin ;
inline char gc() { return (p1 == p2) && (p2 = (p1 = fin) + fread(fin , 1 , _ , stdin) , p1 == p2) ? EOF : * p1 ++ ; }
inline int read() {
	bool sign = 1 ; char c = 0 ; while(c < 48) ((c = gc()) == 45) && (sign = 0) ;
	int x = (c & 15) ; while((c = gc()) > 47) x = (x << 1) + (x << 3) + (c & 15) ;
	return sign ? x : -x ;
}
template < class T > void print(T x , char c = '\n') {
	(x == 0) && (putchar(48)) , (x < 0) && (putchar(45) , x = -x) ;
	static char _st[100] ; int _stp = 0 ;
	while(x) _st[++ _stp] = x % 10 ^ 48 , x /= 10 ;
	while(_stp) putchar(_st[_stp --]) ; putchar(c) ;
}
template < class T > void cmax(T & x , T y) { (x < y) && (x = y) ; }
template < class T > void cmin(T & x , T y) { (x > y) && (x = y) ; }
signed main() {
#ifdef _WIN64
	freopen("testdata.in" , "r" , stdin) ;
#endif
	int a = read() , b = read() ;
	print(a * b / __gcd(a , b)) ; 
	return 0 ;
}


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

const int K = 18, N = 1<<K, M = 1e9+7;
int prod[K][N];
int a[N];

vector<pair<int, int>> vp[N];

void add(int x, int z, int mul) {
    if (vp[x].empty() || vp[x].back().first < z)      vp[x].push_back({z, mul});
    else {
        vp[x].back().second += mul;
        if (vp[x].back().second >= M) vp[x].back().second -= M;
    }
}

int rgt[N];

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

    int k;
    cin>>k;

    int L = 1<<(k-1);

    for (int i=L; i<2*L; i++) {
        prod[0][i] = i;
        for (int j=1; j<k; j++) {
            prod[j][i] = (1LL*prod[j-1][i]*(i>>j))%M;
        }
    }

    for (int i=L; i<2*L; i++) {
        int x;
        cin>>x;
        a[i] = x+L-1;
    }

     for (int k1=k-1; k1>=0; k1--) {
        for (int k2=k-1; k2>=0; k2--) {
            for (int i=L; i<2*L; i++) {
                int x = a[i];
                int pr = (1LL*prod[k1][i]*prod[k2][x])%M;
                int a1 = (i>>k1), a2 = (x>>k2);
                add(a2, a1, pr);
            }
        }
    }

    long long ans = 0;
    for (int i=1; i<=L; i++) {
        int ll = 2*i, rr = 2*i+1;

        for (auto pr: vp[rr])       rgt[pr.first] = pr.second;

        for (auto pr: vp[ll]) {
            int x = pr.first;
            if (x == 1) continue;
            unsigned long long con = (1LL*pr.second*rgt[x^1])%M;
            con = (con*i*(x>>1))%M;
            ans += con;
        }

        for (auto pr: vp[rr])       rgt[pr.first] = 0;
    }
    cout<<ans%M<<endl;
}


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


Measured memory_bytes: 2756
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
 
int main(void)
{
    int a,b,x=0,y=0,z=0;
    cin >> a >> b;

    for(int i=0;i <= a;i++){
            for(int j=0;j <= a;j++){
                if((a-i-j)>=0 && b == 1000*j+5000*i+10000*(a-i-j)){
                    cout << a-i-j << " " << i << " " << j << endl;
                    return 0;
                }
        }
    }

    cout << "-1 -1 -1" << endl;

}

Measured memory_bytes: 256