akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define str to_string
#define endl "\n"
#define PI 3.141592653589
using namespace std;
using lint = long long;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

int sum_digit(int a,int b){
    int sum=0;
    while(a>0){
        sum+=a%10;a/=10;
    }
    while(b>0){
        sum+=b%10;b/=10;
    }
    return sum;
}

int main(){
    int n,ans=10000;cin>>n;
    for(int i=1;i<(n/2+1);i++){
        int j=n-i;
        int s=sum_digit(i,j);
        if(s<ans)ans=s;
    }
    cout<<ans<<endl;
}


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

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

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

    int d = 0;
    int ans = 1;

    for(int i=0;i<n;i++){
        d += l[i];
        if(d<=x){
            ans +=1;
        }else{
            break;
        }
    }
    cout << ans << endl;
}

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

int main() {
	int n, k;
	cin >> n >> k;
	vector<int> x(n);
	rep(i, n) cin >> x[i];
	int ans = 0;
	rep(i, n) {
		ans += min(2*x[i], 2*(k-x[i]));
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;

public class Hello{
    public static void Main(){
        //string[]array=Console.ReadLine().Split(' ');
        string a = Console.ReadLine();
        var count=0;
        for(var i=0;i<a.Length-1;i++){
            if(a[i]==a[i+1]){
                count++;
            }
        }
        
        if(count>0)Console.WriteLine("Bad");
        else Console.WriteLine("Good");
    }
}


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

#define mp make_pair
#define pb push_back
#define xx first
#define yy second
#define i64 long long int
#define MEM(a,x) memset(a,x,sizeof(x))
#define INF 1000000000
#define mod 998244353

using namespace std ;

#define maxn 1000005

i64 p[maxn] ;
i64 a[maxn] , b[maxn] , st[maxn] , en[maxn] ;

int main()
{
    i64 i , j , k , l , m ,n ;

    scanf("%lld",&n) ;

    for(i=1 ; i<=n ; i++)
    {
        scanf("%lld",&p[i]) ;
    }

    for(i=1 ; i<=n ; i++)
    {
        j = p[i] ;
        a[j] += i ;
        b[j] += i ;
        if( j<n )
        {
            st[j+1] += (i+1) ;
            en[n] += (i+1) ;
        }
        if(  j>1)
        {
            st[1] += -(i+1) ;
            en[j-1] += -(i+1) ;
        }
    }

    i64 ret = 0LL , mn1 = 0 ,mn2 =0 ;

    for(i=1 ; i<=n ; i++)
    {
        ret += st[i] ;
        a[i] += ret ;
        b[i] += -ret ;
        mn1 = min(mn1,a[i]) ;
        mn2 = min(mn2,b[i]) ;
        ret -= en[i] ;
    }

    for(i=1 ; i<=n ; i++)
    {
        printf("%lld",a[i]-mn1+1) ;
        if( i<n ) printf(" ") ;
        else printf("\n") ;
    }
    for(i=1 ; i<=n ; i++)
    {
        printf("%lld",b[i]-mn2+1) ;
        if( i<n ) printf(" ") ;
        else printf("\n") ;
    }

    return 0 ;
}


Measured memory_bytes: 9088
# Problem A - Shik and Stone

# input
H, W = map(int, input().split())
board = [['']*W for i in range(H)]
for i in range(H):
    s = list(input())
    for j in range(W):
        board[i][j] = s[j]

# initialization
max_pos = 0
is_ok = True

# check
for i in range(H):
    tmp_min_pos = W
    tmp_max_pos = 0
    for j in range(W):
        if board[i][j]=='#':
            tmp_min_pos = min(tmp_min_pos, j)
            tmp_max_pos = max(tmp_max_pos, j)
    if not tmp_min_pos==max_pos:
        is_ok = False
    max_pos = tmp_max_pos

if is_ok:
    print("Possible")
else:
    print("Impossible")


Measured memory_bytes: 38384
#include<cstdio>
using namespace std;
char ch[105];
inline int read(){
	int ret=0,f=1;char ch=getchar();
	while (ch<'0'||ch>'9'){if (ch=='-') f=-1;ch=getchar();}
	while (ch>='0'&&ch<='9') ret=ret*10+ch-'0',ch=getchar();
	return ret*f;
}
int main(){
	scanf("%s",ch+1);
	if (ch[1]=='S') printf("Cloudy");
	if (ch[1]=='C') printf("Rainy");
	if (ch[1]=='R') printf("Sunny");
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <functional>
#include <utility>
#include <fstream>

using namespace std;

#define ll long long
#define INF 2000000000
#define LINF 9000000000000000000
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define du(x) cout<<#x<<'='<<x<<endl
#define du2(x,y) cout<<#x<<'='<<x<<' '<<#y<<'='<<y<<'\n'<<endl
#define du3(x,y,z) cout<<#x<<'='<<x<<' '<<#y<<'='<<y<<' '<<#z<<'='<<z<<'\n'<<endl
#define darr(arr,n) rep(i,(n-arr)){cout<<*(arr+i)<<' ';}cout<<endl
#define ddarr(arr,a,b) rep(i,a){rep(j,b){cout<<*(arr+i*b+j)<<' ';}cout<<endl;}
#define ddd ifstream in("Text.txt");cin.rdbuf(in.rdbuf());


int main() {
    int N;
    cin >> N;
    cout << (N % 2 == 0 ? N : N * 2) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b[3];
  cin>>a;
  for(int i=0;i<a;i++){
    cin>>b[0]>>b[1]>>b[2];
    sort(b,b+3,greater<int>());
    if(b[0]*b[0]==(b[1]*b[1])+(b[2]*b[2])) cout<<"YES\n";
    else cout<<"NO\n";
  }
}



Measured memory_bytes: 3072
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vb = vector<bool>;
using vl = vector<long>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvb = vector<vector<bool>>;
using vvc = vector<vector<char>>;
using pii = pair<int, int>;
using pll = pair<long, long>;
#define fix20 cout << fixed << setprecision(20);
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define MOD 1000000007
#define all(vec) vec.begin(), vec.end()

int main(){
    long h,n;
    cin >> h >> n;
    long sum = 0;
    rep(i,n){
        long a;
        cin >> a;
        h -= a;
    }
    if(h > 0) cout << "No" << endl;
    else cout << "Yes" << endl;
}


Measured memory_bytes: 256
a=input()
num=len(a)
mod_map={0:1}
moji_int=0
Sn=[0]*(num+1)
tens=[1]*(num+1)
for i in range(-1,-num-1,-1):
    tens[-i]=tens[-i-1]*10%2019
    tmp=int(a[i])*(tens[-i-1])%2019
    Sn[-i]=(Sn[-i-1]+tmp%2019)%2019
    mod=Sn[-i]
    if mod not in mod_map:
        mod_map[mod]=1
    else:
        mod_map[mod]+=1

res=0
for i in mod_map.values():
    res+=int(i*(i-1)/2)
print(res)


Measured memory_bytes: 23460
<?php
$stdin = trim(fgets(STDIN));

$words = preg_split("/[\s,\.]/", $stdin);
$compWords = array();
for ($i = 0; $i < count($words); $i++) {
  if (strlen($words[$i]) > 2 && strlen($words[$i]) < 7) {
    $compWords[] = $words[$i];
  }
}
print implode(' ', $compWords) . PHP_EOL;

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

int n, w;

int max(vector<int>& data) {
    int res = 0;
    for (int i = 0; i < data.size(); i++) 
        res = max(res, data[i]);
    return res;
}

int main() {
    while (cin >> n >> w, n || w) {
        vector<int> vs;
        for (int i = 0; i < n; i++) {
            int v; cin >> v;
            vs.push_back(v);
        }
        vector<int> data(max(vs)/w+1, 0);
        for (int i = 0; i < vs.size(); i++) 
            data[vs[i]/w]++;

        double ink = 0.01;
        double m = data.size()-1;
        double h = max(data);
        for (int i = 0; i < data.size(); i++) 
            ink += data[i] / h * (m - i) / m;
        printf("%.10lf\n", ink);
    }
    return 0;
}

Measured memory_bytes: 1236
package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	var n int
	fmt.Scan(&n)

	sc := bufio.NewScanner(os.Stdin)
	cnt := make([]int, 5)
	for i := 0; i < n; i++ {
		sc.Scan()
		s := sc.Text()
		switch s[0] {
		case 'M':
			cnt[0]++
		case 'A':
			cnt[1]++
		case 'R':
			cnt[2]++
		case 'C':
			cnt[3]++
		case 'H':
			cnt[4]++
		}
	}
	p := []int{0, 0, 0, 0, 0, 0, 1, 1, 1, 2}
	q := []int{1, 1, 1, 2, 2, 3, 2, 2, 3, 3}
	r := []int{2, 3, 4, 3, 4, 4, 3, 4, 4, 4}
	ans := 0
	for i := 0; i < 10; i++ {
		ans += cnt[p[i]] * cnt[q[i]] * cnt[r[i]]
	}
	fmt.Println(ans)
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 1000000000000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;



#define SIZE 200005
typedef pair<ll,ll> P;

ll N;
ll POW[SIZE];
map<P,P> MAP;

//最大公約数
ll gcd(ll x,ll y){

	x = abs(x);
	y = abs(y);

	if(x == 0)return y;
	if(y == 0)return x;

	if(x < y){
		swap(x,y);
	}
	if(y == 0){
		return x;
	}else{
		return gcd(y,x%y);
	}
}


int main(){

	POW[0] = 1;
	for(int i = 1; i < SIZE; i++){

		POW[i] = POW[i-1]*2;
		POW[i] %= MOD;
	}

	scanf("%lld",&N);

	ll num_zero = 0;

	ll x,y;

	for(int i = 0; i < N; i++){

		scanf("%lld %lld",&x,&y);
		if(x == 0 && y == 0){

			num_zero++;
			continue;
		}
		ll common = gcd(x,y);
		x /= common;
		y /= common;

		if(y < 0){
			x = -x;
			y = -y;
		}
		if(y == 0 && x < 0){
			x = -x;
		}
		bool FLG = (x <= 0);
		if(FLG){
			ll tmp = x;
			x = y;
			y = -tmp;
		}
		if(FLG){
			MAP[make_pair(x,y)].first++;
		}else{
			MAP[make_pair(x,y)].second++;
		}
	}

	ll ans = 1;

	for(auto at: MAP){

		ll s = at.second.first; //回転組
		ll t = at.second.second; //非回転

		ll work = 1; //何も選ばない
		work += (POW[s]-1+MOD)%MOD;	//少なくとも1つ選ぶ場合の数
		work %= MOD;
		work += (POW[t]-1+MOD)%MOD; //少なくとも1つ選ぶ場合の数
		work %= MOD;

		ans *= work;
		ans %= MOD;
	}

	ans = (ans-1+MOD)%MOD; //全て、何も選ばない場合を除く
	ans += num_zero;
	ans %= MOD;

	printf("%lld\n",ans);

	return 0;
}


Measured memory_bytes: 20772
#include <stdio.h>

int min(int a, int b){
  if( a > b)return b;
  return a;
}

int zero(int a){
  if( a < 0)return 0;
  return a;
}
int main(int argc, char const *argv[]) {
  int k,s;
  int x,y,z;
  int i,j,l;
  int count=0;
  scanf("%d %d", &k,&s);

  for(i = zero(s - 2*k);i<=k;i++){
    //if( s - i > 2*k)continue;
    if( i > s)break;
    for(j = zero(s - k - i);j<= min(k, s-i) ;j++){
      //if( s - i - j > k)continue;
      if( i + j > s)break;
      if( s - i - j <= k )count++;
      /*
      for(l = 0;l <= min(k, s - i -j);l++){
        if(s == i + j + l){
          count++;
          break;
        }
      }
      */
    }
  }
  printf("%d\n",count );
  return 0;
}


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

int main(){
  int N, M;
  cin >> N >> M;
  vector< pair<int,int> > V;
  for(int i = 0; i < M; ++i){
    int a, b;
    cin >> a >> b;
    V.emplace_back(b,a);
  }
  sort(V.begin(), V.end());
  int ans = 0, l = -1;
  for(int i = 0; i < M; ++i){
    if(V[i].second >= l){
      ++ans;
      l = V[i].first;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1400
n = int(input())
a=[]
a=list(map(int, input().split()))

m=[0]*n

for i in range(n):
  if i%2 == 0:
    m[0]+=a[i]
  else:
    m[0]-=a[i]
for i in range(1,n):
  m[i] =(a[i-1]-m[i-1]/2)*2
  
for i in range(n):
  print(int(m[i]),end=" ")
  

Measured memory_bytes: 14092
#include<stdio.h>

int main(void){

int a,b;

scanf("%d",&a);

scanf("%d",&b);

if(a < b){

printf("a < b\n");

}

if(a > b){

printf("a > b\n");

}

if(a == b){


printf("a == b\n");


}


return 0;

}

Measured memory_bytes: 580
program atcoder_contest_scheduling
  implicit none
  integer :: d, c(26) = 0, s(26, 365) = 0, t(365) = 0, u(365)
  integer :: mem(0:365) = 0, diff(26, 0:365) = 0
  integer :: m, n, x = 0, y, p, q, i
  real(8) :: t1, t2
  call cpu_time(t1)
  call random_seed_clock()
  read(*,*) d
  read(*,*) c
  read(*,*) (s(:, i), i = 1, d)
  t = [(maxloc(s(:, i), 1), i = 1, d)]
  do i = 1, d
    x = x + s(t(i), i)
  end do
  m = score(x, 1)
  u = t
  do
    p = next_int(365)
    q = next_int(26)
    t(p) = q
    y = x - s(u(p), p) + s(q, p)
    n = score(y, p)
    if (m < n) then
      x = y
      m = n
      u(p) = q
    else
      t(p) = u(p)
    end if
    call cpu_time(t2)
    if (t2 - t1 > 1.975d0) exit
  end do
  write(*,'(i0)') (u(i), i = 1, d)
contains
  integer function score(x, p) result(res)
    integer, intent(in) :: x, p
    integer :: i
    do i = p, d
      diff(:, i) = diff(:, i - 1) + c
      diff(t(i), i) = 0
      mem(i) = mem(i - 1) - sum(diff(:, i))
    end do
    res = x + mem(d)
  end
  subroutine random_seed_clock()
    integer :: nseed, clock
    integer, allocatable :: seed(:)
    call system_clock(clock)
    call random_seed(size = nseed)
    allocate(seed(nseed))
    seed = clock
    call random_seed(put = seed)
    deallocate(seed)
  end
  integer function next_int(m) result(res)
    integer, intent(in)  :: m
    real(8) :: r
    call random_number(r)
    res = int(m * r) + 1
  end
end program atcoder_contest_scheduling

Measured memory_bytes: 3064
#include <cstdio>
#include <cstring>
#include <iostream>
#include <cmath>
#include <set>
#include <algorithm>
#include <sstream>
#include <string>
#include <vector>
using namespace std;
#define mem(a,n) memset(a,n,sizeof(a))
#define pb(x) push_back(x)
#define rep(i,a,n) for(int i=a; i<n; i++)
typedef long long ll;
typedef unsigned long long ull;
const int mod=1e9+7;
const double eps=1e-6;
const int INF=0x3f3f3f3f;
const int N=1e5+5;
struct node
{
    int s,t,c;
} a[N];

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

pair<int,int> b[N];
int main()
{
    ios::sync_with_stdio(false);
    int n,c,ans=1;
    cin>>n>>c;
    for(int i=1; i<=n; i++) cin>>a[i].s>>a[i].t>>a[i].c;
    sort(a+1,a+n+1,cmp);
    b[1].first=a[1].t,b[1].second=a[1].c;
    for(int i=2; i<=n; i++)
    {
        bool flag=0;
        for(int j=1; j<=ans; j++)
            if((b[j].second==a[i].c&&a[i].s>=b[j].first)||(b[j].second!=a[i].c&&a[i].s>b[j].first))
            {
                b[j].first=a[i].t,b[j].second=a[i].c;
                flag=1;
                break;
            }
        if(!flag) ans++,b[ans].first=a[i].t,b[ans].second=a[i].c;
    }
    cout<<ans;
    return 0;
}


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

int main()
{
    int f,b,c,d;
    while(~scanf("%d %d %d %d",&f,&b,&c,&d))
    {
        if(f*b>c*d)
            printf("%d\n",f*b);
        else
            printf("%d\n",c*d);
    }
    return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<string>
using namespace std;
int main(){
  string str;
  int sum=0;
  cin>>str;
  for(int i=0;i<str.size();i++){
    sum+=str[i]-'0';
  }
  if(sum%9==0){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
  return(0);
}

Measured memory_bytes: 3752
n, t = map(int, input().split())
a = list(map(int, input().split()))
mins = set()
maxs = set()
ma = 0
mi = 10**9
for ind, i in enumerate(a):
    if i<mi:
        mi = i
        min_ind = [ind]
    elif i==mi:
        min_ind.append(ind)
    if i-mi>ma:
        ma = i-mi
        maxs = {ind}
        mins = set(min_ind)
    elif i-mi==ma:
        maxs.add(ind)
        for j in min_ind:
            mins.add(j)
print(min(len(maxs), len(mins)))

Measured memory_bytes: 15596
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,k,ans=1;
	cin>>n>>k; 
    for(int i=1;i<=n;i++)
      if(ans>k)
        ans+=k;
        else ans+=ans;
    cout<<ans;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <algorithm>

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

#define PRIME 1000003

ll Dictionary[PRIME];
bool result[1000000] = { false };

void initDict()
{
	rep(i, PRIME) Dictionary[i] = -1;
}

void insertDict(ll key)
{
	int index = 0;
	index = (int)(key % PRIME);
	while (Dictionary[index] != -1) index = (index + key % (PRIME - 1)) % PRIME;
	Dictionary[index] = key;
}

bool findDict(ll key)
{
	bool ret = false;
	int index = 0;
	index = (int)(key % PRIME);
	while (Dictionary[index] != -1) {
		if (Dictionary[index] == key) {
			ret = true;
			break;
		}
		else {
			index = (index + key % (PRIME - 1)) % PRIME;
		}
	}
	return ret;
}

ll word2value(string s)
{
	ll value = 0;
	ll digit = 0;

	rep(i, s.length()) {
		if (s[i] == 'A') digit = 1;
		else if (s[i] == 'C') digit = 2;
		else if (s[i] == 'G') digit = 3;
		else if (s[i] == 'T') digit = 4;

		value = value * 10 + digit;
	}
	return value;
}

int main()
{
	int n;
	int result_pos = 0;
	ll key;
	string direction;
	string word;

	initDict();

	cin >> n;

	rep(i, n) {
		cin >> direction >> word;
		key = word2value(word);

		if (direction == "insert") {
			insertDict(key);
		}
		else if (direction == "find") {
			result[result_pos] = findDict(key);
			result_pos++;
			
		}
		else cout << "Undefined Direction!" << endl;
	}

	rep(i, result_pos) {
		if (result[i]) cout << "yes" << endl;
		else cout << "no" << endl;
	}

	return 0;
}



Measured memory_bytes: 11420
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1000000007;
#define INF 1LL<<30
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()



int main() {
    ll s;
    cin>>s;
    const int v=1000000000;

    ll y2=(s+v-1)/v;
    ll y1=v*y2-s;
    cout<<"1000000000 "<<y1<<" 1 "<<y2<<" 0 0"<<endl;
}



Measured memory_bytes: 256
#include <iostream>
using namespace std;
long long n;
int nr;
int nrcif(int n)
{
    int contor = 0;
    do
    {
        contor++;
        n /= 10;
    }while(n);
    return contor;
}
int main()
{
    cin >> n;
    for(int i = 1; i <= n; ++i)
    {
        if(nrcif(i) % 2 == 1)
            nr++;
    }
    cout << nr;
    return 0;
}


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

int main(){
  int n, a[100];
  cin >> n;
  for(int i = 0; i < n; ++i) cin >> a[i];
  sort(a, a + n);
  cout << a[n - 1] - a[0] << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.*;

class Main {
	Scanner sc;
	int N;
	Set<Integer> s;
	
	private void calc() {
		sc = new Scanner(System.in);
		N = sc.nextInt();
		s = new HashSet<Integer>(200000);
		boolean contains = false;
		for (int i = 0; i < N; i++) {
			if (!s.add(sc.nextInt())) contains = true;
		}
		System.out.println(contains?"NO":"YES");
	}

	public static void main(String[] args) {
		new Main().calc();
	}
}


Measured memory_bytes: 103416
#include<bits/stdc++.h>
#define LL long long
using namespace std;
int main()
{
    int n,a[100005];
    bool vis[100005];
    while(scanf("%d",&n)!=EOF)
    {
        long long cnt=0;
        memset(vis,false,sizeof(vis));
        for(int i=0; i<n; i++)
        {
            scanf("%d",&a[i]);
            if(a[i])vis[i]=true;
            cnt+=a[i]/2;
            a[i]%=2;
        }
        for(int i=1; i<n; i++)
        {
            if(a[i]&&a[i-1])
            {
                a[i]=0;
                a[i-1]=0;
                cnt++;
            }
            else if(a[i]==0&&a[i-1])
                if(vis[i]) a[i]++,a[i-1]--;
        }
        printf("%lld\n",cnt);
    }
    return 0;
}


Measured memory_bytes: 768
N = int(input())
a = 0
w = 0
t = 0
r = 0

x = [0]*N
for i in range(N):
  x[i] = input()
  if x[i] == "AC":
    a += 1
  elif x[i] == "WA":
    w += 1
  elif x[i] == "TLE":
    t += 1
  else:
    r += 1

print("AC x " + str(a))
print("WA x " + str(w))
print("TLE x " + str(t))
print("RE x " + str(r))

Measured memory_bytes: 15976
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <limits.h>
#include <math.h>
using namespace std;

int main()
{
	long long int N, A, B, C, D, E;
	cin >> N >> A >> B >> C >> D >> E;

	B = min(A, B);
	C = min(B, C);
	D = min(C, D);
	E = min(D, E);

	long long int m = min(A, min(B, min(C, min(D, E))));

	long long int time = 0;
	long long int c1 = N, c2 = 0, c3 = 0, c4 = 0, c5 = 0, c6 = 0;

	if (m == 1)
	{
		cout << N / m + 4 << endl;
	}
	else
	{
		cout << N / m + 5 << endl;
	}

	return 0;
}

Measured memory_bytes: 256
//スネーク型でOK
#include <iostream>
using namespace std;

int h, w;
int n;
int a[10000];
int d[10000];
int ans[100][100];

signed main() {
	int i, j;
	
	cin >> h >> w;
	cin >> n;
	for (i = 0; i < n; i++) cin >> a[i];
	
	int cnt = 0;
	for (i = 0; i < n; i++) {
		for (j = 0; j < a[i]; j++) {
			d[cnt++] = i + 1;
		}
	}
	for (i = 0; i < h * w; i++) {
		ans[i / w][i % w] = d[i];
	}
	
	for (i = 1; i < h; i += 2) {
		int l = 0, r = w - 1;
		while (l < r) {
			swap(ans[i][l], ans[i][r]);
			l++;
			r--;
		}
	}
	
	for (i = 0; i < h; i++) {
		for (j = 0; j < w; j++) {
			cout << ans[i][j];
			if (j + 1 < w) cout << " ";
			else cout << endl;
		}
	}
	
	return 0;
}

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

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cerr<<*i<<" "; cerr<<endl; }
inline bool valid(int x, int y, int W, int H){ return (x >= 0 && y >= 0 && x < W && y < H); }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const int MAX_N = 5000000;
typedef pair<int, int> P;
int trans(int n){
  return 64 / n;
}
int trans(string s){
  int base = 0;
  REP(i, s.size()) if(isdigit(s[i])) base = base * 10 + s[i] - '0';
  int all = trans(base);
  int cur = all;
  REP(i, s.size()) if(s[i] == '.'){
    cur /= 2;
    all += cur;
  }
  return all;
}

int main(){
  int T;
  cin >> T;
  static int dp[MAX_N];
  int val[7] = {64, 32, 16, 8, 4, 2, 1};
  int len[7] = {2, 2, 2, 2, 3, 3, 3};
  string expr[7] = {"R1", "R2", "R4", "R8", "R16", "R32", "R64"};
  vector<P> tool;
  vector<string> tool_expr;
  REP(i, 7){
    int sum = 0;
    int length = 0;
    string expression = "";
    for(int j = i; j < 7; j++){
      expression += (j == i) ? expr[i] : ".";
      sum += val[j];
      length += (j == i) ? len[j] : 1;
      tool.push_back(make_pair(sum, length));
      tool_expr.push_back(expression);
    }
  }
  REP(i, MAX_N) dp[i] = INF;
  dp[0] = 0;
  REP(i, MAX_N){
    REP(j, tool.size()){
      int s = tool[j].first, l = tool[j].second;
      if(i + s < MAX_N) dp[i + s] = min(dp[i + s], dp[i] + l);
    }
  }
  while(T--){
    string s; cin >> s;
    REP(i, s.size()) if(s[i] == 'R') s[i] = ' ';
    stringstream ss(s);
    int seq = 0;
    int all = 0;
    while(ss >> s){
      all += trans(s);
    }
    int cur = all;
    string ans;
    while(cur > 0){
      string next = "ZZZZZZZZZ";
      int next_c = cur;
      REP(i, tool.size()){
        int s = tool[i].first, l = tool[i].second;
        if(cur - s >= 0 && dp[cur - s] + l == dp[cur] && next + "RRRRRRRRR" > tool_expr[i] + "RRRRRRRR"){
          next = tool_expr[i];
          next_c = cur - s;
        }
      }
      ans += next;
      cur = next_c;
    }
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 21108
#include <cstdio>

using namespace std;

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

typedef long long ll;

const ll MOD = 1000000007;
const int N_MAX = 100000;
const int M_MAX = 100000;

int n, m;
ll x[N_MAX];
ll y[M_MAX];

ll step_sum(int k, ll *v) {
  ll ans = 0;
  int i = 0, j = k - 1;
  int t = k - 1;
  while (t > 0 && i < j) {
    ans = (ans + (v[i++] + MOD) % MOD * t) % MOD;
    ans = (ans + (MOD - v[j--]) % MOD * t) % MOD;
    t -= 2;
  }
  return ans;
}

void solve() {
  ll ans = step_sum(n, x) * step_sum(m, y) % MOD;
  printf("%lld\n", ans);
}

void input() {
  scanf("%d%d", &n, &m);
  REP(i, n) scanf("%lld", x + i);
  REP(i, m) scanf("%lld", y + i);
}

int main() {
  input();
  solve();
  return 0;
}


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

const ll infll=9223372036854775806;
const int inf=2147483646;

int main()
{
	//freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
	ios_base::sync_with_stdio(false); cin.tie(0);
	int a,b,c;
	cin>>a>>b>>c;
	if (c<max(a,b)&&c>min(a,b)){
		cout<<"Yes";
	}
	else {
		cout<<"No";
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <algorithm>

using namespace std;
using ll = long long;
using ld = long double;

int main() {

    int R;
    cin >> R;
    if(R < 1200){
        cout << "ABC" << endl;
    } else if(R < 2800){
        cout << "ARC" << endl;
    } else{
        cout << "AGC" << endl;
    }
    return 0;
}

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

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;
using pll = pair<ll,ll>;

#define INF (1LL << 60)
#define MOD 1000000007
#define PI 3.14159265358979323846

#define REP(i,m,n) for(ll (i)=(m),(i_len)=(n);(i)<(i_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define PR(x) cout << (x) << endl
#define PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define ASC(x) sort(ALL((x)))
#define DESC(x) sort(ALL((x)),greater<ll>())
#define REV(x) reverse(ALL((x)))
#define pb push_back
#define eb emplace_back

int main()
{
    ll N;
    cin >> N;
    map<string,ll> S;
    REP(i,0,N) {
        string s;
        cin >> s;
        S[s]++;
    }

    cout << "AC x " << S["AC"] << endl;
    cout << "WA x " << S["WA"] << endl;
    cout << "TLE x " << S["TLE"] << endl;
    cout << "RE x " << S["RE"] << endl;

    return 0;
}

/*



*/

Measured memory_bytes: 3628
inf = 2**31

n = int(raw_input())
G = [[inf]*n for _ in range(n)]
ref = {}
inputs = [map(int,raw_input().split()) for _ in range(n)]
for i in range(n): ref[inputs[i][0]] = i
for i in range(n):
    for j in inputs[i][2:]:
        G[i][ref[j]] = 1
        
for k in range(n):
    for i in range(n):
        for j in range(n):
            G[i][j] = min(G[i][j],G[i][k]+G[k][j])
            
p = int(raw_input())
for loop in range(p):
    s,d,v = map(int,raw_input().split())
    dist = G[ref[s]][ref[d]]
    print dist+1 if dist+1 <= v else "NA"

Measured memory_bytes: 4360
#include <bits/stdc++.h> 
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define size_of_array(array) (sizeof(array)/sizeof(array[0]))
#define MAX 100005
#define NIL -1
using ll =long long;
using namespace std;
using Graph=vector<vector<int>>;
using Field=vector<vector<int>>;

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

const double PI=(acos(-1));

int main(){
    int x;
    cin>>x;
    if(x>=30){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
}

Measured memory_bytes: 3632
using System;
class test{
  static void Main(){
    var line = Console.ReadLine().Split(' ');
    int n = int.Parse(line[0]);
    int k = int.Parse(line[1]);
    int r = 1;
    int i = 0;
    while(n >= 1)
    {
      n = n/k;
      i++;
    }
    Console.WriteLine(i);
  }
}

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

int main() {
  int N, Q;
  cin >> N >> Q;
  map<int, int> from;
  for (int i = 0; i < N - 1; i++) {
    int a, b;
    cin >> a >> b;
    from[b] = a;
  }
  vector<int> counter(N + 1, 0);
  for (int j = 0; j < Q; j++) {
    int p, x;
    cin >> p >> x;
    counter[p] += x;
  }
  int memo[N + 1];
  memset(memo, -1, sizeof(memo));
  for (int i = 1; i <= N; i++) {
    int value = 0;
    int node = i;
    value += counter[node];
    while (node != 1) {
      node = from[node];
      if (memo[node] != -1) {
        value += memo[node];
        break;
      }
      value += counter[node];
    }
    memo[i] = value;
    cout << value;
    if (i != N) {
      cout << " ";
    }
  }
  cout << endl;
  return 0;
}

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

#define ll          long long
#define pb          push_back
#define pii         pair<ll int,ll int>
#define vpii        vector< pii >
#define vi          vector<ll int>
#define vs			vector< string >
#define vvi         vector< vector< ll > >
#define inf			1'010'000'000'000'000'017LL
#define all(it,a)   for(auto it=(a).begin();it!=(a).end();it++) 
#define sz(x)       (ll int)x.size()
#define rep(i,a,b)	for(ll int i=a;i<b;i++)
#define repr(i,a,b) for(ll int i=a;i>b;i--)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define mp          make_pair
#define whatis(x)   cout << #x << " is " << x << "\n";
#define graph(n)    adj(n,vector< ll > () )

using namespace std;

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


void Main()
{
	ll X, N;
	cin >> X >> N;
	vector<bool> P(110, false);
	rep(i, 0, N) {
		ll temp;
		cin >> temp;
		P[temp] = true;
	}
	ll ans = 0;
	ll diff = 1000;
	repr(i, 101, -1) {
		if (!P[i]) {
			if (abs(X - i) <= diff) {
				diff = abs(X - i);
				ans = i;
			}
		}
	}
	cout << ans << endl;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);

	Main();
	return 0;
}

Measured memory_bytes: 3664
#include <iostream>
#include <fstream>
#include <cassert>
#include <typeinfo>
#include <vector>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#include <random>
#include <complex>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<61;
const double pi=acos(-1);
const double eps=1e-7;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

typedef complex<double> vec;

// ??\???
void In(vec& p){
	double x,y;
	cin>>x>>y;
	p=vec(x,y);
}

// ??????
void Out(vec p){
	cout<<syosu(10)<<p.real()<<' '<<p.imag()<<endl;
}

// ??????
double IP(vec p,vec q){
	return p.real()*q.real()+p.imag()*q.imag();
}

// ?°???±
vec Proj(vec a,vec b,vec p){
	vec A=p-a,B=b-a;
	double l=abs(B);
	return B*IP(A,B)/(l*l)+a;
}

int n;
vec a,b;

int main(){
	In(a);In(b);
	cin>>n;
	for(int i=0;i<n;i++){
		vec p;
		In(p);
		Out(Proj(a,b,p));
	}
}

Measured memory_bytes: 3324
# -*- coding: utf-8 -*-
# !/usr/bin/env python
# vim: set fileencoding=utf-8 :

"""
#
# Author:   Noname
# URL:      https://github.com/pettan0818
# License:  MIT License
# Created: 土  6/23 21:04:04 2018

# Usage
#
"""
import sys

def get_std():
    target = sys.stdin.readline()
    return target

def parse(target):
    """
    >>> parse("-+--")
    -2
    >>> parse("-----")
    -5
    """
    res = 0
    for food in target:
        if food == "+":
            res += 1
        elif food == "-":
            res -= 1

    print(res)


if __name__ == '__main__':
    parse(get_std())


Measured memory_bytes: 3060
#include<stdio.h>
#include<cstdlib>

int linearSearch(int, int *);

int n,q;

int main(){
  int i, count = 0;
  int *S,*T;
  scanf("%d",&n);
  S = (int *)malloc(sizeof(int) * n + 1);
  for(i = 0; i < n; i++){
    scanf("%d",&S[i]);
  }
  scanf("%d",&q);
  T = (int *)malloc(sizeof(int) * n + 1);
  for(i = 0; i < q; i++){
    scanf("%d",&T[i]);
  }
  
#ifdef D
  printf("S : ");
  for(i = 0; i < n; i++){
    printf("%d ",S[i]);
  }
  printf("\n");
  printf("T : ");
  for(i = 0; i < q; i++){
    printf("%d ",T[i]);
  }
  printf("\n");
#endif

  for(i = 0; i < q; i++){
    if(linearSearch(T[i],S) == 1){
      count++;
    }
  }

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

  return 0;
}



int linearSearch(int key, int *A){
  int i = 0;
  A[n] = key; // 番兵
  while(A[i] != key){ // by using 番兵, faster than "for"  
    i++;
  }
  if(i == n){
      return 0;
  }
  return 1;
}



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

time = [0] * N

for i in range(N) :
    time[i] = list(map(int,input().split()))


# 締め切り順
time.sort(key=lambda A : A[1])

now = 0
for i in range(N) :
    now += time[i][0]
    if now > time[i][1] :
        print('No')
        break
else :
    print('Yes')

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, s, e) for (int i = (int)(s); i < (int)(e); i++)
#define _rep(i, n) for (int i = (int)(n - 1); i >= 0; i--)
#define _REP(i, e, s) for (int i = (int)(e - 1); i >= (int)(s); i--)

#define yes cout << "yes" << endl;
#define Yes cout << "Yes" << endl;
#define YES cout << "YES" << endl;

#define no cout << "no" << endl;
#define No cout << "No" << endl;
#define NO cout << "NO" << endl;

#define AC cout << "AC" << endl;
#define WA cout << "WA" << endl;

#define out(s) cout << s << endl;

#define ll long long
#define ull unsigned long long

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

unsigned GetDigit(ull num) {
    return log10(num);
}

void nextPernutationPrint(const vector<int>& v) {
    for_each(v.begin(), v.end(), [](int x) { cout << x << " "; });
    cout << endl;
}

int main() {
    int N;
    cin >> N;
    vector<int> T(N), P(N), Q(N);

    rep(i, N) {
        T[i] = i + 1;
    }
    rep(i, N) {
        cin >> P[i];
    }
    rep(i, N) {
        cin >> Q[i];
    }

    int cnt = 1, pValue = 0, qValue = 0;
    do {
        bool pFlag = true;
        for (int i = 0; i < N; i++) {
            if (T[i] != P[i]) {
                pFlag = false;
            }
        }
        if (pFlag) {
            pValue = cnt;
        }

        bool qFlag = true;
        for (int i = 0; i < N; i++) {
            if (T[i] != Q[i]) {
                qFlag = false;
            }
        }
        if (qFlag) {
            qValue = cnt;
        }

        cnt++;
    } while (next_permutation(T.begin(), T.end()));

    cout << abs(pValue - qValue) << endl;
}

Measured memory_bytes: 3724
//#define _GLIBCXX_DEBUG
#include <iostream>
#include <vector>
#include <stdio.h>
#include <bits/stdc++.h>


using namespace std;
#define ll long long
#define ld long double
#define  P pair<ll,ll>
#define FOR(i,n,m) for(ll i=n; i<(ll)m;i++)
#define FORa(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define FORr(i,m,n) for(ll i=n; i>=(ll)m; i--)
#define FORm(i,m) for(auto i=m.begin();i!=m.end();i++)
#define FORs(i,st) for(auto i : st)
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define ALL(c) (c).begin(), (c).end()
#define VEC2(x,a,b) vector<vector<ll>> x = vector<vector<ll>>(a,vector<ll>(b,0))
#define sortAl(v) sort(v.begin(),v.end())
#define sortAlr(v) sort(v.begin(),v.end()); reverse(v.begin(),v.end())
#define cinv(v,n,m) FOR(i,n,m) cin>>v.at(i)
#define coutv(v,n,m) FOR(i,n,m) cout<<v.at(i) <<" "; cout<<endl
#define cout(n) cout<<fixed<<setprecision(n)

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin>>n;
    map<ll,ll> mp_s;
    while(n--){
      ll in;
      cin>>in;
      mp_s[in] = 1;
    }
    ll q;
    cin>>q;
    ll ans=0;
    while(q--){
      ll in;
      cin>>in;
      ans += mp_s[in];
    }
    cout<<ans<<endl;
}



Measured memory_bytes: 12472
#include <bits/stdc++.h>
using namespace std;
#define MAX 1400

int dp[MAX][MAX], G[MAX][MAX];

int getLargestSquare(int H, int W) {
  int maxWidth = 0;
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      dp[i][j] = (G[i][j] + 1) % 2;
      maxWidth |= dp[i][j];
    }
  }

  for (int i = 1; i < H; i++) {
    for (int j = 1; j< W; j++) {
      if (G[i][j]) {
        dp[i][j] = 0;
      } else {
        dp[i][j] = min(dp[i - 1][j - 1], min(dp[i- 1][j], dp[i][j - 1])) + 1;
        maxWidth = max(maxWidth, dp[i][j]);
      }
    }
  }

  return maxWidth * maxWidth;
}

int main() {
  int H, W;
  scanf("%d %d", &H, &W);

  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      scanf("%d", &G[i][j]);
    }
  }

  cout << getLargestSquare(H, W) << endl;

  return 0;
}


Measured memory_bytes: 18524
# Define Item class
Item = Struct.new(:value, :weight)

def max(a, b)
  a > b ? a : b
end

# Make 2D array
def make_2d_array(n, m, init)
  n.times.map{[init] * m}
end


# Input values
_, W = gets.split(' ').map(&:to_i)
items = []
while line = gets
  v, w = line.split(' ').map(&:to_i)
  items.push(Item.new(v, w))
end


# Create DP table
dp_table = make_2d_array(items.size + 1, W + 1, nil)
# Initialize the first column
dp_table.size.times{|i|
  dp_table[i][0] = 0
}
# Initialize the first row
dp_table[0].size.times{|j|
  dp_table[0][j] = 0
}


# Fill DP table
(1..items.size).each{|i|
  item = items[i-1]
  (1..W).each{|j|
    if 0 <= j - item.weight
      dp_table[i][j] = max(dp_table[i-1][j], dp_table[i-1][j - item.weight] + item.value)
    else
      dp_table[i][j] = dp_table[i-1][j]
    end

  }
}

# Get max weight
max_weight = dp_table[-1][-1]
puts(max_weight)



Measured memory_bytes: 14780
import queue
N, M = map(int, input().split())
G = [[] for _ in range(N)]
dist = [-1] * N
pre = [-1] * N

for i in range(M):
    a, b = map(lambda n: int(n) - 1, input().split())
    G[a].append(b)
    G[b].append(a)

q = queue.Queue()
dist[0] = 0
q.put(0)

while not q.empty(): 
    v = q.get()
    for u in range(len(G[v])):
        if dist[G[v][u]] != -1:
            continue
        dist[G[v][u]] = dist[v] + 1
        pre[G[v][u]] = v
        q.put(G[v][u])
    
print('Yes')

for i in range(1, N):
    print(pre[i] + 1)

Measured memory_bytes: 35180
#include <iostream>
#include <cstdio>

using namespace std;

string disp(int a){
	string ans = "     ";
	if(a == 0){
		ans = "    0";
		return ans;
	}
	ans[0] = (a / 10000) + '0';
	ans[1] = (a / 1000) % 10 + '0';
	ans[2] = (a / 100) % 10 + '0';
	ans[3] = (a / 10) % 10 + '0';
	ans[4] = a % 10 + '0';
	
	for(int i = 0; i <= 4; i++){
		if(ans[i] == '0'){
			ans[i] = ' ';
		}else{
			break;
		}
	}
	
	return ans;
}

int main(){
	
	int n;
	
	int mat[20][20];
	
	cin >> n;
	
	while(n != 0){
		for(int i = 0; i < n; i++){
			for(int j = 0; j < n; j++){
				cin >> mat[i][j];
			}
		}
		
		int sum;
		
		for(int i = 0; i < n; i++){
			sum = 0;
			for(int j = 0; j < n; j++){
				sum += mat[i][j];
			}
			mat[i][n] = sum;
		}
		
		for(int j = 0; j <= n; j++){
			sum = 0;
			for(int i = 0; i < n; i++){
				sum += mat[i][j];
			}
			mat[n][j] = sum;
		}
		
		for(int i = 0; i <= n; i++){
			for(int j = 0; j <= n; j++){
				cout << disp(mat[i][j]);
			}
			cout << endl;
		}
		
		cin >> n;
	}
	return 0;
}

Measured memory_bytes: 1200
/*input
5 5
1 2
1 3
3 4
3 5
16 8 17 3 18
2 1
2 3
1 3 7
2 1
2 3


*/
 
/*
                                                    ______________
                                                          |       )
                                                          |   )   /
                                                          |______/
                                                    |     |      \
                                                    |     |   )   \
                                                    |_____|_______)
 
*/
 
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <iomanip>
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> PII;
typedef pair<ll , ll> PLL;
typedef long double ld;
 
#define pb push_back
#define all(c) c.begin(),c.end()
#define allr(c) c.rbegin(),c.rend()
int mod = 1000000007;
const int inf = 1034567891;
const ll LL_INF = 1234567890123456789ll;
#define PI 3.14159265
#define endl '\n'
#define F first
#define S second
#define debug(x) cout << #x << " = " << x << endl;
#define TRACE
 
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cout << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
 
#define out(container) for (auto it : container) cout << it << " "; cout << endl;
 
 
template < typename T > T GCD(T a, T b)            { ll t; while(a) { t = a; a = b % a; b = t; } return b; }
template < typename T > string toString(T a)       { return to_string(a); }
template < typename T > void toInt(string s, T &x) { stringstream str(s); str >> x;}
inline int add(int x, int y){ x += y; if(x >= mod) x -= mod; return x;}
inline int sub(int x, int y){ x -= y; if(x < 0) x += mod; return x;}
inline int mul(int x, int y){ return (x * 1ll * y) % mod;}
inline int powr(int a, ll b){
  int x = 1 % mod;
  while(b){
    if(b & 1) x = mul(x, a);
    a = mul(a, a);
    b >>= 1;
  }
  return x;
}
inline int inv(int a){ return powr(a, mod - 2);}

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

Measured memory_bytes: 892
#include<bits/stdc++.h>
const int MOD = 1E9+7;
const int N = 100000+5;
const int dx[] = {-1,1,0,0,-1,-1,1,1};
const int dy[] = {0,0,-1,1,-1,1,-1,1};
using namespace std;
vector<int> G[N];
int vis[N];
int main() {
	    int n;
    scanf("%d",&n);
    for(int i=1;i<=n-1;i++){
        int x,y;
        scanf("%d%d",&x,&y);
        G[x].push_back(y);
        G[y].push_back(x);
    }
 
    queue<int> Q;
    Q.push(1);
    Q.push(n);
    vis[1]=1;
    vis[n]=2;
 
    int fennec=0,snuke=0;
    while(!Q.empty()){
        int x=Q.front();
        Q.pop();
        for(int i=0;i<G[x].size();i++){
            int y=G[x][i];
            if(vis[y]==0){
                Q.push(y);
                vis[y]=vis[x];
                if(vis[y]==1)
                    fennec++;
                else if(vis[y]==2)
                    snuke++;
            }
        }
    }
    if(fennec>snuke)
        printf("Fennec\n");
    else
        printf("Snuke\n");
    return 0;
}

Measured memory_bytes: 6272
#include <iostream>
#include <stdio.h>
#include <vector>
#include <utility>
#include <algorithm>
#include <cmath>
using namespace std;

typedef vector<int> vi;

template<typename T>
static inline void p(T x) { cout << x << endl; }

int main()
{

	int n, cnt = 0;
	cin >> n;

	vi A(n), G;
	for (int &x: A)
		cin >> x;

	for (int i = 1, x = 1; x <= n; x = (pow(3, ++i) - 1) / 2)
		G.push_back(x);
	reverse(G.begin(), G.end());

	for (int g: G)
		for (int i = g; i < n; i++) {
			int v = A[i], j = i - g;
			for(; j >= 0 && A[j] > v; j -= g)
				A[j+g] = A[j], cnt++;
			A[j+g] = v;
		}

	p(G.size());
	for (int &x: G)
		cout << (&x == &G[0] ? "" : " ") << x;
	p("");
	p(cnt);
	for (int x: A)
		printf("%d\n", x);
}


Measured memory_bytes: 6792
function main(input) {
	const [o, d] = input.trim().split("\n");
  	let result = "";
  	for (let i = 0; i < o.length; i++) {
      	if (!d[i]) {
        	result = result + o[i];
          	continue;
        }
      	result = result + o[i] + d[i];
    }
  	console.log(result);
}
main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
S = list(input())
if(S[0] == S[1]) :
  if(S[2] == S[3] and S[0] != S[2]) :
    print("Yes")
  else :
    print("No")
elif(S[0] == S[2]) :
  if(S[1] == S[3] and S[0] != S[1]) :
    print("Yes")
  else :
    print("No")
elif(S[0] == S[3]) :
  if(S[1] == S[2] and S[0] != S[1]) :
    print("Yes")
  else :
    print("No")
else :
  print("No")

Measured memory_bytes: 3064
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#include<algorithm>//next_permutation
#define rep(i,n) for (int i = 0;i < (n);i++)
#define all(v) v.begin(),v.end()
#define dec(n) cout << fixed << setprecision(n);
#define large "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
#define small "abcdefghijklmnopqrstuvwxyz"
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vl>;

ll gcd(ll a,ll b){
  if(b == 0) return a;
  return gcd(b , a % b);
}

const ll MOD = 1000000007;
const ll MAX = 200001;

ll mod(ll a){
  return a % MOD;
}

ll lcm(ll a,ll b){
  return (a*b)/gcd(a,b);
}

ll fac[MAX], finv[MAX], inv[MAX];

void nCrprep() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        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 nCr(ll n, ll r){
    if (n < r) return 0;
    if (n < 0 || r < 0) return 0;
    return fac[n] * (finv[r] * finv[n - r] % MOD) % MOD;
}

ll nCrcheep(ll n,ll r){
  if(r == 0) return 1;
  else if(r == 1) return n;
  else return nCrcheep(n-1,r-1)*n/r;
}

int main(){
  ll n; cin >> n; ll allxor; cin >> allxor; vl num(n);
  num[0] = allxor;
  
  
  rep(i,n-1){
    ll x; cin >> x;  num[i+1] = x;
    allxor = (allxor ^ x);
  }
  
  rep(i,n){
    cout << (allxor ^ num[i]) << endl;
  }
  
}

Measured memory_bytes: 4792
#include <iostream>
#include <cstring>

constexpr int MaxAB = 16;
int dp[MaxAB][MaxAB];

bool isObstacle[MaxAB][MaxAB];

int main() {
	int a, b, n;
	while (std::cin >> a >> b, a + b) {
		std::cin >> n;

		for (int i = 0; i < n; ++i) {
			int x, y;
			std::cin >> x >> y;
			isObstacle[x - 1][y - 1] = true;
		}

		dp[0][0] = 1;
		for (int i = 0; i < a; ++i) {
			for (int j = 0; j < b; ++j) {
				if ((i == 0 && j == 0) || isObstacle[i][j])
					continue;

				dp[i][j] = (
					i == 0 ? dp[i][j - 1]
					: j == 0 ? dp[i - 1][j]
					: dp[i - 1][j] + dp[i][j - 1]
					);
			}
		}

		std::cout << dp[a - 1][b - 1] << std::endl;
        
        std::memset(dp, 0, sizeof(dp));
        std::memset(isObstacle, 0, sizeof(isObstacle));
	}
}

Measured memory_bytes: 3032
#include<cstdio>
#include<cstring>
#include<cctype>
#include<algorithm>
#define RG register

inline int read()
{
	int data = 0, w = 1; char ch = getchar();
	while(ch != '-' && (!isdigit(ch))) ch = getchar();
	if(ch == '-') w = -1, ch = getchar();
	while(isdigit(ch)) data = data * 10 + (ch ^ 48), ch = getchar();
	return data * w;
}

const char s[] = "RGBY";
int n, m, d;

int main()
{
	n = read(), m = read(), d = read();
	for(RG int i = 0; i < n; i++, putchar('\n'))
		for(RG int j = 0, x, y; j < m; j++)
			x = (m + i + j) / d % 2,
			y = (m + i - j) / d % 2,
			putchar(s[2 * x + y]);
	return 0;
}


Measured memory_bytes: 1536
using System;

namespace CSsample
{
    class Program
    {
        static void Main(string[] args)
        {
            string S = Console.ReadLine();
            int num = 0;
            for(int i = 0; i < S.Length; i++)
            {
                if(i%2 == 0)
                {
                    if(S[i] == '0')
                    {
                        num++;
                    }
                }
                else
                {
                    if(S[i] == '1')
                    {
                        num++;
                    }
                }
            }
            int answer = Math.Min(num, S.Length - num);
            Console.WriteLine(answer);
        }
    }
}



Measured memory_bytes: 13116