akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <algorithm>

struct Split{
public:
  int number;
  int reserve;
  Split():number(0),reserve(0){}
  Split(int num,int res):number(num),reserve(res){}
  bool operator<(const Split &hoge) {
    return number<hoge.number || (number==hoge.number && reserve<hoge.reserve);
  }
  Split operator+(const Split &hoge) {
    if (number<=0 || hoge.number<=0)
      return Split();
    else
      return Split(number+hoge.number,std::min(reserve,hoge.reserve));
  }
};

Split dp[50][50][50][50];
int demand[50][50];
int h,w,supply,total;

void init() {
  total = 0;
  for(int i=0; i<32; i++)
    for(int j=0; j<32; j++)
      for(int k=0; k<32; k++)
	for(int l=0; l<32; l++)
	  dp[i][j][k][l] = Split();
}

int main() {
  while(scanf("%d %d %d",&h,&w,&supply),h>0) {
    init();
    for (int y=0; y<h; y++)
      for (int x=0; x<w; x++) {
	scanf("%d",&demand[x][y]);
	total += demand[x][y];
      }

    for(int wd=1; wd<=w; wd++)
      for(int hg=1; hg<=h; hg++)
	for(int x=0; x+wd<=w; x++)
	  for(int y=0; y+hg<=h; y++) {
	    Split tmp,ans;
	    for(int sx=x+1; sx<x+wd; sx++) {
	      tmp = dp[x][sx][y][y+hg]+dp[sx][x+wd][y][y+hg];
	      ans = ans<tmp?tmp:ans;
	    }
	    for(int sy=y+1; sy<y+hg; sy++) {
	      tmp = dp[x][x+wd][y][sy]+dp[x][x+wd][sy][y+hg];
	      ans = ans<tmp?tmp:ans;
	    } 

	    int sum=0;
	    for(int x1=x; x1<x+wd; x1++)
	      for(int y1=y; y1<y+hg; y1++)
		sum += demand[x1][y1];
	    int reserve = supply-total+sum;
	    if(reserve>=0) {
	      tmp = Split(1,reserve);
	      ans = ans<tmp?tmp:ans;
	    }
	    dp[x][x+wd][y][y+hg] = ans;
	  }


    printf("%d %d\n",dp[0][w][0][h].number,dp[0][w][0][h].reserve);
  }
}

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

#define int long long 

int sol(int start,int end,vector<int> &v,vector<vector<int>> &dp)
{

    if(start>end) return numeric_limits<int>::min();

    if(start+1==end) return max(v[start],v[end]);
    if(start==end) return v[start];

    int &r=dp[start][end];
    if(r!=-1) return r;

    int res=0;
    res=v[start]+min(sol(start+2,end,v,dp),sol(start+1,end-1,v,dp));
    res=max(res,v[end]+min(sol(start+1,end-1,v,dp),sol(start,end-2,v,dp)));
    return r=res;
}

int32_t main()
{
    ios_base::sync_with_stdio(false),cin.tie(nullptr);
    int n=0;
    cin>>n;
    vector<int> v(n);
    for(int i=0;i<n;i++) cin>>v[i];

    int sum=0;
    for(auto u:v) sum+=u;

    vector<vector<int>> dp(n,vector<int> (n,-1));
    
    int ans=sol(0,n-1,v,dp)-(sum-sol(0,n-1,v,dp));
    cout<<ans<<"\n";
    return 0;
}

Measured memory_bytes: 71040
function Main(input) {
	var str = input;
	str = str.split("\n");
	var l = str[0].split(" "); 
	l.map( str => parseInt(str, 10) );
	l= l%10;
	if(l === 2|| l === 4|| l === 5|| l === 7|| l ===9){
		console.log("hon");
	}else if (l === 0||l === 1||l === 6||l ===8){
		console.log("pon");
	}else{
		console.log("bon");
	}
}
 //*おまじない
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 29624
#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 equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
//const ll mod = 1000000007;
const ll mod = 998244353;
const int inf = 1e9 + 10;
const ll INF = 1e18;
const ld EPS = 1e-10;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
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 (a>b) { a=b; return 1; } return 0; }



int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout << fixed << setprecision(25);

  ll n;
  string s;
  cin >> n >> s;

  ll ans = 1;
  ll v[3] = {}, d[3] = {};
  rep(i, 3 * n) {
    int j;
    if (s[i] == 'R') j = 0;
    if (s[i] == 'G') j = 1;
    if (s[i] == 'B') j = 2;
    int x = (j + 1) % 3;
    int y = (j + 2) % 3;
    if (d[j]) {
      ans = ans * d[j] % mod;
      d[j]--;
    }
    else if (v[x]) {
      ans = ans * v[x] % mod;
      d[y]++;
      v[x]--;
    }
    else if (v[y]) {
      ans = ans * v[y] % mod;
      d[x]++;
      v[y]--;
    }
    else {
      v[j]++;
    }
    //cout<<v[0]<<" "<<v[1]<<" "<<v[2]<<" "<<d[0]<<" "<<d[1]<<" "<<d[2]<<" "<<ans<<endl;
  }
  FOR(i, 1, n + 1) ans = ans * i % mod;
  cout << ans << '\n';




  




  
  return 0;
}

Measured memory_bytes: 3820
n, d = list(map(int, input().split()))
# A = list(map(int, input().split()))
#a = list(map(int, input().split()))
# data = [list(map(int, input().split())) for i in range(n)]
# q = int(input())
#a = list(map(int, input().split()))
# b = list(map(int, input().split()))
# ab_sorted = sorted(ab, key=lambda x: x[0])
x = [list(map(int, input().split())) for i in range(n)]
# print(min(15*n, 100*(n//10+1), 100*(n//10)+15*(n % 10)))
# for i in range(1, int(n**0.5)+1):

count = 0
for i in range(n):
    for j in range(i+1, n):
        a = 0
        for k in range(d):
            # print(k)
            a += pow(x[i][k]-x[j][k], 2)
        # print(a)
        a = a**0.5
        if a == a//1:
            count += 1

print(count)


Measured memory_bytes: 9392
#include<stdio.h>

int main(){
  int n, nDivisor=0, cnt=0;
  scanf("%d", &n);
  
  for(int i=1; i<=n; i=i+2){
    for(int j=1; j<=i; j=j+2){
      if(i%j==0){
        nDivisor++;
      }
    }
    if(nDivisor==8){
      cnt++;
    }
    nDivisor=0;
  }
  
  printf("%d",cnt);
  return 0;
}

Measured memory_bytes: 128
import math
n = input()
ans = 0
li=[]
global num_li
num_li = []
def create_num(n, length):
    global num_li
    if len(n) == length:
        num_li.append(n)
    else:
        create_num(n+"3", length)
        create_num(n+"5", length)
        create_num(n+"7", length)
for i in range(1, len(n)+1):
    if i == len(n):
        create_num("", i)
        for j in num_li:
            if "3" in j and "5" in j and "7" in j and int(j) <= int(n):
                ans+= 1       
    elif i > 2:
        ans += 3**i - (2**i -2) * 3 - 3 
print(ans)

Measured memory_bytes: 4340
#include<stdio.h>
#define abs(zz) (zz>=0) ? (zz) : (-(zz))

int main()
{
    int i,n,d=0;
	double t,a,temp,ans=1000000000;
	double h[1010]={0};
	scanf("%d",&n);
	scanf("%lf %lf",&t,&a);
	for(i=0;i<n;i++)
	{
		scanf("%lf",&(h[i]));
		temp=t-h[i]*6/1000;
		//printf("%lf\n",(abs(temp-a)));
		if(ans>(abs(temp-a)))
		{
			ans=(abs(temp-a));
			d=i;
		}
	}
	printf("%d",d+1);
}


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

#define rep(a,b) for(int a = 0;a < b;a++)
#define REP(i, x, n) for(int i = x; i < n; i++)
#define P(a) cout << a << endl
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define ssort(v) sort(v.begin(),v.end())
#define rev(v) reverse(v.begin(),v.end())
#define vP(v) for(int i = 0;i < v.size();i++){cout << v[i];if(i != v.size()-1)cout << endl;}
#define vcin(v,n) rep(i,n){int a;cin >> a;v.pb(a);}

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
int dx[] = { 1, -1 , 0 , 0 };
int dy[] = { 0,  0,  1, -1 };
ll MOD = 1000000007;

void solve(){
	string s,t;
	cin >> s >> t;
	ssort(s);
	ssort(t);
	rev(t);
	if(s < t){
		P("Yes");
	}else{
		P("No");
	}
}

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


Measured memory_bytes: 256
import heapq

N, M=map(int, input().split())
A=list(map(lambda x:x*(-1), map(int, input().split())))
heapq.heapify(A)
for i in range(M):
    a=heapq.heappop(A)
    a=((a*(-1))//2)*(-1)
    heapq.heappush(A, a)
print(-sum(A))

Measured memory_bytes: 14180
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int result = a + b;
    if (result < a * b)
      result = a * b;
    if (result < a - b)
      result = a - b;
    System.out.println(result);
  }
}

Measured memory_bytes: 21844
//----------------------------------------------------------------------
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
//----------------------------------------------------------------------

using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;

int main(void) {
    int n; cin >> n;
    vector<int> a(n+1);
    REP(i,n) cin >> a[i+1];

    vector<int> b(n+1);

    for(int i = n; i >=1; --i) {
        int sum = 0;
        for(int j = i + i; j <=n; j += i) {
            sum += b[j];
        }
        if(sum %2 == 0 && a[i] == 1){
            b[i] = 1;
        }
        if(sum %2 != 0 && a[i] == 1){
            b[i] = 0;
        }
        if(sum %2 != 0 && a[i] == 0){
            b[i] = 1;
        }
        if(sum %2 == 0 && a[i] == 0){
            b[i] = 0;
        }
    }
    vector<int> ans;

    for(int i = 1; i <= n; ++i) {
        if(b[i]) ans.push_back(i);
    }

    cout << ans.size() << endl;;
    for(auto v : ans) {
        cout << v << " ";
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <algorithm>
#include <random>
#include <string>
#include <cmath>
#include <sstream>
#include <istream>
#include <iomanip>
#include <typeinfo>
#include <stack>
#include <map> 
#include <queue>

using namespace std;
typedef long long ll;
ll N, M;

int main(){

    cin >> N;
    vector<ll > v;
    
    //マイナスの数
    vector<ll > minus;
    //合計
    ll sum = 0;
    ll m_sum = 0;

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

        ll temp = 0;
        cin >> temp;
        v.push_back(abs(temp));

        if(temp < 0){
            //マイナスの集合
            minus.push_back(temp);
            m_sum += temp;
        }
        sum += temp;
    }

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

    if(minus.size() % 2 == 0){
        sum += 2 * abs(m_sum);
    }else{
        sum += 2 * abs(m_sum) - 2 * v[0];
    }

    cout << sum << endl;


}

Measured memory_bytes: 2160
#define _USE_MATH_DEFINES

#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
using namespace std;

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


const int BIG_NUM = 1e8;
const ll INF = 1000000000000000000;

const int ALPHABET = 26;

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

	vector<int> r(4);
	for (int i = 0; i < n; i++) {
		string s;
		cin >> s;
		switch (s[0])
		{
		case 'A':
			r[0]++;
			break;
		case 'W':
			r[1]++;
			break;
		case 'T':
			r[2]++;
			break;
		case 'R':
			r[3]++;
			break;

		default:
			break;
		}
	}


	cout << "AC x " << r[0] << endl;
	cout << "WA x " << r[1] << endl;
	cout << "TLE x " << r[2] << endl;
	cout << "RE x " << r[3] << endl;

}

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

using namespace std;

// Header files, namespaces,
// macros as defined above
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>


#define f first
#define s second
#define db long double
#define pb push_back
#define sz(c) (c).size()
#define all(c) (c).begin(),(c).end()

typedef long long ll;
typedef pair <int , int> ii;
typedef pair <ii , int> iii;
typedef vector <int> vi;
typedef vector <ii> vii;
typedef vector <iii> viii;
typedef vector <vi> vvi;
typedef vector <vii> vvii;

const ll mod = 1e9+7;
const int MAX = (1<<22);
const db eps = 1e-13;

int memo[MAX];
int n;
vi v;
int dp( int pos , int mask ) {

    if( pos==n )
        return 1;

    int &res = memo[mask];
    if( memo[mask] != -1 )
        return res;

    res = 0;
    for( int i = 0 ; i < n ; i++ )
        if( !((1<<i)&mask) && ((1<<i)&v[pos]) )
            res = ( res + dp( pos+1, mask | (1<<i)) ) % mod;
    return res;
}


int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
    cout<<setprecision(11)<<fixed;
    memset( memo , -1 , sizeof memo );

    cin>>n;
    v = vi(n);
    for( int i = 0 ; i < n ; i++) {
        int msk = 0;
        for( int j = 0 ; j < n ; j++ ) {
            char c;
            cin>>c;
            if( c == '1' ) {
                msk |= (1<<j);
            }
        }
        v[i] = msk;
    }


    cout<<dp( 0 , 0 )<<"\n";
}
/*
1 1000
1
*/

Measured memory_bytes: 16768
import collections
n = int(input())
a = list(map(int,input().split()))
c = collections.Counter(a)
s = 0
for v in c.values():
    if v >= 2:
        s += v*(v-1)//2

for i in range(n):
    k = a[i]
    ans = s
    v = c[k]
    if v >= 3:
        ans -= v-1
    if v <= 2:
        ans -= v*(v-1)//2
    print(ans)

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

using namespace std;

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

    int n, k;
    cin >> n >> k;

    vector<int> a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    vector<bool> win(k + 1, false), lose(k + 1, true);

    for (int i = 1; i <= k; ++i) {
        for (int j : a) {
            if (j > i) continue;
            if (lose[i - j]) win[i] = true;
            if (!win[i - j]) lose[i] = false;
        }
    }

    cout << (win[k] ? "First" : "Second") << endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		String[] m = s.split("",0);
		int x = 0,y = 0;
	for(int i = 0; i < m.length;i++){
		if(m[i].equals("A")){
			x = i;
			break;
		}
	}
	for(int t = 0; t < m.length;t++){
		if(m[t].equals("Z")){
			y = t;
		}
	}
	System.out.print(""+(y-x+1));
	}
}


Measured memory_bytes: 53220
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, log
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
from decimal import Decimal
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10**9 + 7
from decimal import *
 
N = INT()
ab = [LIST() for _ in range(N-1)]
graph = [[] for _ in range(N)]

for a, b in ab:
	graph[a-1].append(b-1)
	graph[b-1].append(a-1)

length = [len(x) for x in graph]
ans = max(length)

color = defaultdict(int)

q = deque([])
cnt = 1
for x in graph[0]:
	q.append((x, 0, cnt))
	cnt += 1

while q:
	n, previous, col = q.pop()
	cnt = 1
	for x in graph[n]:
		if x == previous:
			color[(n, x)] = col
			color[(x, n)] = col
		else:
			if cnt == col:
				cnt += 1
			color[(n, x)] = cnt
			color[(x, n)] = cnt
			q.append((x, n, cnt))
			cnt += 1

print(ans)
for a, b in ab:
	print(color[(a-1, b-1)])


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

int main() {
  char s;
  cin >> s;
  if((s=='a') || (s=='i') || (s=='u') || (s=='e') || (s=='o')) cout << "vowel" << endl;
  else cout << "consonant" << endl;
  return 0;
}

Measured memory_bytes: 256
import java.math.*;
import java.io.*;
import java.util.*;

class Main{
    public static void main(String[] args) throws Exception{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int N = Integer.parseInt(br.readLine());
        
        String[] l1 = br.readLine().split(" ");

        int[] arr = new int[N];

        for(int i = 0; i < arr.length; i++){
            arr[i] = Integer.parseInt(l1[i]);
        }

        int[] dp = new int[N];
        Arrays.fill(dp, Integer.MAX_VALUE);
        dp[0] = 0;

        for(int i = 0; i < N; i++){
            for(int j = i + 1; j <= i + 2 && j < N; j++){
                dp[j] = Math.min(dp[j], dp[i] + Math.abs(arr[j] - arr[i]));
            }
        }
        
        System.out.println(dp[N - 1]);

    }
}

Measured memory_bytes: 34620
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring> 
#include <sstream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <memory.h>
#include <iomanip>
#include <bitset>
#include <list>
#include <stack>
 
using namespace std;
 
#define mod 1000000007

long long int StrToLLI(string s)
{
    long long int ans = 0;
    for(int i = 0; i < s.length(); i++){
        ans += (s[i] - '0') * (long long int)pow(10, s.length() - 1 - i);
    }
    // cout << s << " " << ans << endl;
    return ans;
}

int main()
{
    string s;
    cin >> s;
    long long int ans = 0;
    int l = s.length();
    for(int i = 0; i < (1 << (l - 1)); i++){
        string nownum = "";
        // cout << i << endl;
        for(int j = 0; j < l - 1; j++){
            nownum += s[j];
            if((i & (1 << j)) != 0){
                // cout << nownum << endl;
                ans += StrToLLI(nownum);
                nownum = "";
            }
        }
        nownum += s[l - 1];
        ans += StrToLLI(nownum);
    }
    cout << ans << endl;
    return 0;
}

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

void check(char ch)
{

	if (ch >= 'A' && ch <= 'Z')
		cout << "A";

	else if (ch >= 'a' && ch <= 'z')
		cout << "a";

}

int main() {

// #ifndef ONLINE_JUDGE
// 	freopen("input.txt", "r", stdin);
// 	freopen("output3.txt", "w", stdout);
// #endif

	ios::sync_with_stdio(false);
	cin.tie(0);

	char a;
	cin >> a;
	check(a);
	return 0;
}

Measured memory_bytes: 3608
using System;
using System.Linq;

namespace A
{
    class Program
    {
        static void Main(string[] args)
        {
            var HW =Console.ReadLine().Split().Select(int.Parse).ToArray();
            var hw =Console.ReadLine().Split().Select(int.Parse).ToArray();

            Console.WriteLine(HW[0]*HW[1] - HW[1]*hw[0] - HW[0]*hw[1] + hw[0]*hw[1]);
        }
    }
}


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

typedef long long ll;
const int mod = 1e9 + 7;
typedef pair<ll, ll> P;

ll X, Y, Z, K;
vector<ll> A, B, C;

int main() {
    cin >> X >> Y >> Z >> K;
    A.resize(X);
    B.resize(Y);
    C.resize(Z);
    rep(i, X) cin >> A[i];
    rep(i, Y) cin >> B[i];
    rep(i, Z) cin >> C[i];

    vector<ll> bc;
    rep(i, Y) {
        rep(j, Z) {
            bc.push_back(B[i] + C[j]);
        }
    }
    sort(bc.rbegin(), bc.rend());

    vector<ll> bc2;
    rep(i, bc.size()) {
        if (i == 3000) break;
        bc2.push_back(bc[i]);
    }
    sort(A.rbegin(), A.rend());

    vector<ll> ans;
    for (ll i = 0; i < X; i++) {
        for (ll j = 0; j < bc2.size(); j++) {
            ans.push_back(A[i] + bc2[j]);
        }
    }

    sort(ans.rbegin(), ans.rend());
    for (ll i = 0; i < ans.size(); i++) {
        if (i == K) break;
        cout << ans[i] << endl;
    }
}

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

using namespace std;
using ll =long long;
#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//Write From this Line

int main()
{
	//x=10Bとしたときにそれが満たすかどうか？
	double a , b ;
	cin >> a >> b ;
	double x = 10 * b ;
	rep(i,10){
		if((int)(x*0.08) == a){
			cout << x << endl;
			return 0; 
		} 
		x++;
	}
	puts("-1");
}


Measured memory_bytes: 256
#include <stdio.h>
#define NIL -1
#define MAX 252

/*
   void swap(int *x, int *y) {
   int temp;
   temp = *x;
 *x = *y;
 *y = temp;
 } */

int parent(int i) {
    return i/2;
}

int left(int i) {
    return 2*i;
}

int right(int i) {
    return 2*i + 1;
}

int main() {
    int n;
    int T[MAX];
    int i = 1;
    int r, l, p;

    while(i < MAX+1) {
        T[i] = NIL;
        i++;
    }

    scanf("%d", &n);
    for(i = 1; i < n+1; i++) {
        scanf("%d", &T[i]);
    }
    for(i = 1; i < n+1; i++) {
        l = left(i);
        r = right(i);
        p = parent(i);

        printf("node %d: key = %d, ", i, T[i]);
        if(i != 1) printf("parent key = %d, ", T[p]);
       /* if(T[l] != NIL) printf("left key = %d, ", T[l]);
        if(T[r] != NIL) printf("right key = %d, ", T[r]); */
        if(2*i <= n) printf("left key = %d, ", T[l]);
        if((2*i + 1) <= n) printf("right key = %d, ", T[r]);
        printf("\n");
    }
    return 0;
}

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

#define lp(i,n) for(int i=0;i<n;i++)
#define lpin(a,i,n) for(int i=0;i<n;i++){cin>>a[i];}
using namespace std;
int main(){
  list<int> l;
  list<int>::iterator it;
  it = l.end();
  int n;
  cin>>n;
  lp(i,n){
    int a,b;
    cin>>a;
    if(a==0){
      cin>>b;
      it=l.insert(it, b);
    }
    if(a==1){
      cin>>b;
      if(b>=0){
	lp(j,b){
	  it++;
	}
      }
      else{
	lp(j,-b){
	  it--;
	}
      }
    }
    if(a==2){
      it=l.erase(it);
    }
  }
  it=l.begin();
  while(it!=l.end()){
    cout<<*it<<endl;
    it++;
  }
  return 0;
}


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

int main(){
    int i,res = 0;
    string s;

    cin >> s;

    for( i = 0; i < 4; i++){
        if( s[i] == '+' ){
            res++;
        }
        else{
            res--;
        }
    }
    cout << res << "\n";
}

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

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;
long long mod=1e9+7;
int main() {
    ios::sync_with_stdio(0);
     cin.tie(0);
    cout.tie(0);
     long long t,a[200010],tem=0,ans=0;
    cin>>t;
    for(int i=1;i<=t;i++){
        cin>>a[i];
        tem+=a[i];
    }
    for(int i=1;i<t;i++){
            tem-=a[i];
        ans=(ans+(a[i]*(tem%mod))%mod)%mod;
    }
    cout<<ans<<endl;
    return 0;
}




Measured memory_bytes: 5208
#include<bits/stdc++.h>
#define mes(a, b)  memset(a, b, sizeof a)
#define pb push_back
typedef unsigned long long int ull;
typedef long long int ll;
const int    maxn = 1e6 + 20;
const int    maxm = 1e5 + 10;
const ll     mod  = 1e9 + 7;
const ll     INF  = 1e18 + 100;
const int    inf  = 0x3f3f3f3f;
const double pi   = acos(-1.0);
const double eps  = 1e-8;
using namespace std;
struct node{
    ll val,id;
    bool operator<(const node &a)const{
        return val > a.val;
    } 
}a[maxn];
int main(){
    int x,y,n,m,k;scanf("%d %d %d %d %d",&x,&y,&n,&m,&k);
    int tot = 0;
    for(int i = 1;i <= n;i++) scanf("%lld",&a[++tot].val),a[tot].id = 1;
    for(int i = 1;i <= m;i++) scanf("%lld",&a[++tot].val),a[tot].id = 2;
    for(int i = 1;i <= k;i++) scanf("%lld",&a[++tot].val),a[tot].id = 3;
    sort(a + 1,a + 1 + tot);
    int sum = x + y;ll ans = 0;
    for(int i = 1;i <= tot;i++){
        if(sum == 0) break;
        if(a[i].id == 3) ans += a[i].val,sum--;
        else if(a[i].id == 2 && y) y--,sum--,ans += a[i].val;
        else if(a[i].id == 1 && x) x--,sum--,ans += a[i].val;
    }
    cout << ans << "\n";
}

Measured memory_bytes: 6400
console.log(function(args){
  let N = BigInt(args.trim());
  let name = [];
  while( N >= 26n ) {
    let p = ((N-1n) % 26n)+1n;
    name.unshift( Number(p) );
    N = (N-p) / 26n;
  }
  if ( N  ) name.unshift( Number(N) );
  return name.map(v=>String.fromCharCode(v+96)).join('');
}(require('fs').readFileSync('/dev/stdin', 'utf8')));

Measured memory_bytes: 29640
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <random>
#include <iomanip>
#include <functional>
#include <cassert>
#include <bitset>

using namespace std;

typedef long long ll;
typedef long double ld;

const int N = 2000 * 2000;

using bs = bitset <N>;

int main() {
  ios_base::sync_with_stdio(false); cin.tie(0);
#ifdef LOCAL
  freopen("input.txt", "r", stdin);
#endif
  int n;
  cin >> n;
  vector <int> a(n);
  int sum = 0;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    sum += a[i];
  }
  bs bp;
  bp[0] = 1;
  for (int i = 0; i < n; ++i) {
    bp |= (bp << a[i]);
  }
  for (int i = 0; i < N; ++i) {
    if (bp[i] && 2 * i >= sum) {
      cout << i << '\n';
      return 0;
    }
  }
}



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

int main()
{
    ll n, a, b, c, d, e;
    cin >> n >> a >> b >> c >> d >> e;

    ld res = n / ld(min({a, b, c, d, e}));

    cout << (ll (ceil(res) + 4)) << "\n"; 

    return 0;
} 


Measured memory_bytes: 3640
//============================================================================
// Name        : AOL.cpp
// Author      : Akari Fujii
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <cctype>
#include <string>
#include<algorithm>

using namespace std;



int main(){

	long long n;
	long long a;
	long long e;
	cin>>n;

	for(long long i=1; i<100000; i++){
		a=i*i;
		if( a <= n ){
			e=a;
		}

	}
	cout<<e<<endl;
}


Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func rcvInt() (n int) {
	sc.Scan()
	for _, v := range sc.Bytes() {
		n = n*10 + int(v-48)
	}
	return
}

func cumSum(a []int) []int {
	res := make([]int, len(a))
	var sum = 0
	for i := 0; i <= len(res)-1; i++ {
		sum += a[i]
		res[i] = sum
	}
	return res
}

func cumSumReverse(a []int) []int {
	res := make([]int, len(a))
	var sum = 0
	for i := len(res) - 1; i >= 0; i-- {
		sum += a[i]
		res[i] = sum
	}
	return res
}

func main() {
	sc.Split(bufio.ScanWords)
	n := rcvInt()

	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = rcvInt()
	}
	b := make([]int, n)
	for i := 0; i < n; i++ {
		b[i] = rcvInt()
	}

	aa := cumSum(a)        // cumulative sum
	bb := cumSumReverse(b) // cumulative sum (reverse)

	var max = 0
	for i := 0; i < n; i++ {
		var sum = 0

		sum += aa[i]
		sum += bb[i]

		if sum > max {
			max = sum
		}
	}
	fmt.Println(max)
}


Measured memory_bytes: 640
#include <cstdio>

#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++)

int main() {
  int n;
  while(scanf("%d",&n) != EOF) {
    int t = 0;
    REP(i,10) {
      if(i > n) break;
      REP(j,10) {
	if(i+j > n) break;
	REP(k,10) {
	  if(i+j+k > n) break;
	  REP(l,10) {
	    if(i+j+k+l > n) break;
	    else if(i+j+k+l == n) t += 1;
	  }
	}
      }
    }
    printf("%d\n", t);
  }

  return 0;
}

Measured memory_bytes: 2720
def gcd(a, b):
    if a < b:
        a, b = b, a
    while b != 0:
        a, b = b, a % b
    return a

a, b, c, d = map(int, input().split())

lcm = c * d // gcd(c, d)

count = b // c - a // c
if a % c == 0:
    count += 1

count += b // d - a // d
if a % d == 0:
    count += 1

count -= (b // lcm - a // lcm)
if a % lcm == 0:
    count -= 1

print((b - a) + 1 - count)


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


int main(){
  while(true){
    double n,m,ans=100000000;
    cin>>n>>m;
    if(n+m==0)break;
    rep(i,n){
      double a=abs(sqrt(i*i+(n-i)*(n-i))-m);
      ans=min(ans,a);
    }
    cout<<ans<<endl;
  }
}



Measured memory_bytes: 3208
import java.util.*;

public class Main{
	private static final Scanner scan = new Scanner(System.in);

	public static void main(String[] args){
		int n = scan.nextInt();
		long mon = 100_000;
		for(int i = 0; i < n; i++){
			mon = (long) Math.ceil(mon * 1.05 / 1000.0) * 1000;
		}
		System.out.printf("%d\n", mon);
	}
}

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

#define rep(i,s,n) for (int i = (int)s; i < (int)n; i++)
#define ll long long
#define pb push_back
#define eb emplace_back
#define All(x) x.begin(), x.end()
#define Range(x, i, j) x.begin() + i, x.begin() + j
#define lbidx(x, y) lower_bound(x.begin(), x.end(), y) - x.begin()
#define ubidx(x, y) upper_bound(x.begin(), x.end(), y) - x.begin()
#define llbidx(x, y, z) lower_bound(x.begin(), x.end(), z) - lower_bound(x.begin(), x.end(), y) // 二要素間の距離
#define deg2rad(deg) ((((double)deg)/((double)360)*2*M_PI))
#define rad2deg(rad) ((((double)rad)/(double)2/M_PI)*(double)360)
#define Find(set, element) set.find(element) != set.end()

typedef pair<int, int> PI;
typedef pair<ll, ll> PLL;

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

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

int main() {
  int A, B;
  cin >> A >> B;
  int ans = -1;
  rep(i, 1, 100005) {
    if ((i * 8) / 100 == A && (i * 10) / 100 == B) {
      ans = i;
      break;
    }
  }

  cout << ans << endl;
};


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

int main()
{
    ll n;
    cin>>n;
    if(n==25)
    {
        cout<<"Christmas";
    }
    else if(n==24)
    {
         cout<<"Christmas Eve";
    }
    else if(n==23)
    {
        cout<<"Christmas Eve Eve";
    }
    else if(n==22)
    {
         cout<<"Christmas Eve Eve Eve";
    }
    return 0;
}

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

int main()
{
  int N,K ;
  cin>>N>>K ;
  vector<int>A(N) ;
  for(int i=0;i<N;i++) cin>>A.at(i) ;
  sort(A.begin(),A.end()) ;
  
  int pre_value=A.at(0) ;
  int num=1 ;
  vector<int>Num ;
  for(int i=0;i<N-1;i++){
    if(A.at(i)==A.at(i+1)) num++ ;
    else{
      Num.push_back(num) ;
      num=1 ;
    }
    if(i==N-2) Num.push_back(num) ;
  }
  sort(Num.begin(),Num.end()) ;

  if(Num.size()<=K) cout<<0<<endl ;
  else{
    int ans=0 ;
    for(int i=0;i<Num.size()-K;i++) ans+=Num.at(i) ;
    cout<<ans<<endl ;
  }
  
  return 0 ;
}

Measured memory_bytes: 2168
#include<cstring>
#include<iostream>
#include<algorithm>
#include<cstdlib>
#include<cstdio>
#include<cmath>
#include<set>
#define rep(i,l,r) for (int i=l;i<=r;i++)
#define down(i,l,r) for (int i=l;i>=r;i--)
#define clr(x,y) memset(x,y,sizeof(x))
#define maxn 100050
#define ll long long
#define low(x) (x&(-x))
#define inf 1000000000
using namespace std;
int read(){
    int x=0,f=1; char ch=getchar();
    while (!isdigit(ch)) {if (ch=='-') f=-1; ch=getchar();}
    while (isdigit(ch)) {x=x*10+ch-'0'; ch=getchar();}
    return x*f;
}
int a[100500],ans,n;
int main(){
//	freopen("in.txt","r",stdin);
	n=read();
	rep(i,1,n) a[i]=read();
	rep(i,1,n-1) {
		if (a[i]==i) swap(a[i],a[i+1]),ans++;
	}
	if (a[n]==n) ans++;
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int,int> pint;
typedef vector<pint> vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=n-1;i>=(0);i--)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define all(v) (v).begin(),(v).end()
#define eall(v) unique(all(v), v.end())
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
const int MOD = 1e9 + 7;
const int INF = 1e9;
const ll INFF = 1e18;

int main(void) {
	int n, m; cin >> n >> m;
	n--, m--;
	printf("%d\n", n * m);
	return 0;
}

Measured memory_bytes: 256
class Heap
	@@LOWER_LIMIT = -2_000_000_001
	@@UPPER_LIMIT =  2_000_000_001

	def self.build_max_heap(array)
		(array.size / 2).downto(1) { |i| max_heapify(array, i - 1) }
		Heap.new(array)
	end

	def to_s
		" #{@heap.join(" ")}"
	end
	private
	def initialize(array)
		@heap = array
	end

	def self.max_heapify(heap, index)
		left  = left_child_index(index)
		right = right_child_index(index)

		max = [index, left, right].max_by { |i| heap[i] || @@LOWER_LIMIT }
		if max != index
			heap[index], heap[max] = heap[max], heap[index]
			max_heapify(heap, max)
		end
	end

	def self.left_child_index(index)
		index * 2 + 1
	end

	def self.right_child_index(index)
		index * 2 + 2
	end

end

n = STDIN.gets.to_i
array = STDIN.gets.split[0...n].map(&:to_i)
puts Heap.build_max_heap(array)

Measured memory_bytes: 166024
// 基本テンプレート
 
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
using namespace std;
 
#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define int long long int
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
typedef pair<int, int> pii;
typedef long long ll;
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1001001001001001LL;
const ll MOD = 1000000007LL;
 
signed main() {
    int N; cin >> N;
    map<int, int> mp;
    rep(i,0,N) {
        int p; cin >> p;
        mp[p]++;
    }

    int ans = 0;
    for(auto x : mp) {
        int val = x.first, cnt = x.second;
        if(val <= cnt) ans += cnt - val;
        else ans += cnt;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 6272
n,m = map(int,input().split(" "))
ar = [int(i) - 1 for i in input().split(" ")]
if n >= m:
    a = 0
    for i in range(m):
        a = ar[a] 
    print(a + 1)
    exit()
a = 0
br = [-1] * n
br[0] = 0
for i in range(1,n):
    a = ar[a]
    if br[a] != -1:
        break
    br[a] = i
b = i - br[a]
m -= i
m %= b
for i in range(m):
    a = ar[a]
print(a+1)

Measured memory_bytes: 32304
//Don't have to see. start------------------------------------------
var read = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});
var obj; var inLine = [];
read.on('line', function(input){inLine.push(input);});
read.on('close', function(){
  obj = init(inLine);
  console.error("\n");
  var start = Date.now();
  Main();
  var end = Date.now() - start;
  myerr("time : " + end + "ms");
  myerr("memory : " + Math.round(process.memoryUsage().heapTotal / 1024) + "KB");
});
function makeClone(obj){return JSON.parse(JSON.stringify(obj));}
function nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}
function nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}
function next(){return obj.next();} function hasNext(){return obj.hasNext();}
function init(input){  
  var returnObj = {
    list : input, index : 0, max : input.length,
    hasNext : function(){return (this.index < this.max);},
    next : function(){if(!this.hasNext()){throw "ArrayIndexOutOfBoundsException ‚There is no more input";}else{var returnInput = this.list[this.index++];return returnInput;}}
  };
  return returnObj;
}
function myout(s){console.log(s);}
function myerr(s){console.error("debug:" + require("util").inspect(s,false,null));}
//param "no" is
//unknown or outlier : return i. 1: parseInt.
//2: split space. 4: split space and parseInt.
//6: split 1 character. 7: split 1 character and parseInt.
//8: join space. 9: join nextline. 0: join no character.
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 4:return i.split(" ").map(Number);case 6:return i.split("");case 7:return i.split("").map(Number);case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}catch(e){return i;}}

//Don't have to see. end------------------------------------------
function Main(){
  var one = nextIntArray();
  var N = one[0];
  var K = one[1];
  var maxK = (N - 1) * (N - 2) / 2;
  if(maxK < K){
    myout(-1);
    return;
  }
  var output = [N - 1];
  for(var i = 2; i <= N; i++){
    output.push("1 " + i);
  }
  var addK = maxK - K;
  var under = 2;
  while(addK > 0){
    for(var i = under + 1; i <= N; i++){
      output.push(under + " " + i);
      output[0]++;
      addK--;
      if(addK == 0){
        break;
      }
    }
    under++;
  }
  
  myout(myconv(output, 9));
  
}


Measured memory_bytes: 31072
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using V = vector<int>;
using VV = vector<V>;
using VVV = vector<VV>;
using VL = vector<ll>;
using VVL = vector<VL>;
using VVVL = vector<VVL>;
template<class T> using VE = vector<T>;
template<class T> using P = pair<T, T>;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define REP(i,k,n) for(int i=(k);i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define output(x,y) cout << fixed << setprecision(y) << x << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
ll upper = MOD + MOD;
ll under = -upper;
ll UPPER = MOD * MOD;
ll UNDER = -UPPER;
const long double pi = 3.141592653589793;
int main() {
	ll n;
	cin >> n;
	rep1(i, 3500) rep1(j, 3500) {
		ll a = n * i * j;
		ll b = 4 * i * j - n * i - n * j;
		if (a > 0 && b > 0 && a % b == 0) {
			printf("%d %d %lld\n", i, j, a / b);
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 3816
from collections import deque
import sys
sys.setrecursionlimit(10**7)
input = sys.stdin.readline
inf = pow(10, 10)

n, m = map(int, input().split())
a = [inf] * n

edge = [[] for i in range(n)]

for i in range(m):
    l, r, d = map(int, input().split())
    l-=1;r-=1
    edge[l].append((r, d))
    edge[r].append((l, -d))

"""
# BFS解放
flag = True
dist = [inf] * n
for i in range(n):
    if not flag: break
    if dist[i] == inf: # 偽の場合、連結で既に訪れている
        dist[i] = 0
        dq = deque([i])
        while dq:
            now = dq.popleft()
            for e in edge[now]:
                nnode, d = e
                if dist[nnode] == inf:
                    dist[nnode] = dist[now] + d
                    dq.append(nnode)
                else:
                    if dist[nnode] != dist[now] + d:
                        flag = False
                        break
if flag:
    print('Yes')
else:
    print('No')
"""

# DFS解法
dist = [inf]*n
def dfs(i, totald = 0):
    if dist[i] < inf:
        if dist[i] == totald:
            return True
        else:
            return False
    dist[i] = totald
    for e in edge[i]:
        nnode, d = e
        if not dfs(nnode, totald+d):
            return False
    return True


f = True
for i in range(n):
    if dist[i] == inf:
        if not dfs(i, 0):
            f = False
            break
if f:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 159168
#include<bits/stdc++.h>
using namespace std;
#define INF (1LL<<30)
#define DEKAI 1000000007
#define lp(i,n) for(int i=0;i<n;i++)
/*
using ll long long;
#define ALL(n) n.begin(),n.end()
*/
#define int long long


signed main(){
	int n;
	cin>>n;
	int p[4],t[4];

	lp(i,4){
		cin>>p[i];
	}
	lp(i,4)cin>>t[i];
	int ans=INF;
	for(int i=0;i<=100;i++){
		for(int j=0;j<=100;j++){
			for(int k=0;k<=100;k++){
				int sumt=t[0]*i+t[1]*j+t[2]*k;
				int l=0;
				if(sumt<n){
					l=(n-sumt)/t[3];
					if((n-sumt)%t[3]!=0)l++;
				}
				int v=i*p[0]+j*p[1]+k*p[2]+l*p[3];
				ans=min(ans,v);
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 3104
#include <bits/stdc++.h>
using namespace std;
int main()
{
    // 文字列の入力
    string s;
    cin >> s;

    int res = 0;
    if (s == "SUN") res = 7;
    if (s == "MON") res = 6;
    if (s == "TUE") res = 5;
    if (s == "WED") res = 4;
    if (s == "THU") res = 3;
    if (s == "FRI") res = 2;
    if (s == "SAT") res = 1;

    cout << res <<endl;
    return 0;
}

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

#define MAX_N 10000

int n, m;
string S[MAX_N], T, U; long long cost[MAX_N];
long long a, b;
vector<int>x[MAX_N];
int used[MAX_N];

queue<int>Q;

long long bfs(int st) {
	memset(used, 0, sizeof(used));
	Q.push(st);
	used[st] = 1;
	while (!Q.empty()) {
		for (int i = 0; i < x[Q.front()].size(); i++) {
			if (used[x[Q.front()][i]] == false) {
				used[x[Q.front()][i]] = true;
				Q.push(x[Q.front()][i]);
			}
		}
		Q.pop();
	}
	long long minx = (1LL << 60);
	for (int i = 0; i < n; i++) {
		if (used[i] == 1) {
			minx = min(minx, cost[i]);
		}
	}
	return minx;
}

int main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> S[i] >> cost[i];
	}
	cin >> m;
	for (int i = 0; i < m; i++) {
		cin >> T >> U;
		for (int j = 0; j < n; j++) {
			if (T == S[j]) {
				a = j;
			}
			if (U == S[j]) {
				b = j;
			}
		}
		x[a].push_back(b);
		x[b].push_back(a);
	}
	long long sum = 0;
	for (int i = 0; i < n; i++) {
		sum += bfs(i);
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 1928
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1000003 ;

int main(){
  int n;
  cin >> n;
  ll a[3*n];
  rep(i,3*n)cin >> a[i];
  sort(a,a+3*n,greater<ll>());
  ll sum=0;
  rep(i,3*n){
    if(i%2==1 && i<2*n)sum+=a[i];
  }
  cout << sum << endl;
return 0;}

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

using namespace std;

int main() {
 
    long long X;
    cin >> X;
 
    double i = 100;
 
    int ans = 0;
 
    while(i < X) {
        i = floor(i * 1.01);
        ans++;
    }
 
    cout << ans << endl;
 
    return 0;
}

Measured memory_bytes: 3636
#include <cassert>
#include <algorithm>
#include <vector>
#include <map>
#include <iostream>
using namespace std;
int main() {
    int n; cin >> n;
    int v[n+1], w[n+1];
    for (int i = 1; i <= n; i++) cin >> v[i] >> w[i];

    const int S = 512;
    vector<pair<int, int> > mp[S];
    mp[1].push_back({0, 0});
    mp[1].push_back({w[1], v[1]});
    for (int i = 2; i <= min(n, S-1); i++) {
        mp[i] = mp[i/2];
        for (auto it = mp[i/2].rbegin(); it != mp[i/2].rend(); it++) {
            int j = it->first + w[i];
            if (j <= 1e5) {
                mp[i].push_back({j, it->second + v[i]});
            }
        }
        sort(mp[i].begin(), mp[i].end(),
             [](pair<int, int> &lhs, pair<int, int> &rhs) {
                 return lhs.first < rhs.first || (lhs.first == rhs.first && lhs.second > rhs.second);
             });
    }
    // for (int i = 1; i <= min(n, S-1); i++) {
    //     cerr << "i = " << i << " size = " << mp[i].size() << endl;
    //     for (auto x : mp[i]) cerr << x.first << " " << x.second << endl;
    // }

    int q; cin >> q;
    while (q--) {
        int i, l; cin >> i >> l;
        vector<pair<int, int> > temp;
        temp.push_back({0, 0});
        while (i >= S) {
            for (int k = temp.size()-1; k >= 0; k--) {
                int j = temp[k].first + w[i];
                if (j <= l)
                    temp.push_back({j, temp[k].second + v[i]});
            }
            i /= 2;
        }
        sort(temp.begin(), temp.end());

        int vmax = 0;
        for (auto &x : temp) {
            vmax = max(vmax, x.second);
            x.second = vmax;
        }

        // cerr << "q = " << i << " " << "size = " << temp.size() << endl;
        // for (auto x : temp) cerr << x.first << " " << x.second << endl;
        int ans = 0;
        auto it1 = mp[i].begin();
        auto it2 = temp.rbegin();
        while (it1 != mp[i].end() && it2 != temp.rend()) {
            while (it2 != temp.rend() && it1->first + it2->first > l) it2++;
            if (it2 != temp.rend()) {
                ans = max(ans, it1->second + it2->second);
            }
            it1++;
        }
        cout << ans << endl;
    }
}


Measured memory_bytes: 7052
#include <bits/stdc++.h>
#define ull unsigned long long
#define MOD 1000000007 
using namespace std;

bool bad[100005];
ull cnt[100005];

int main() {
    int N, M;
    cin >> N >> M;
    for(int i = 0; i < M; i++) {
        int a;
        cin >> a;

        bad[a] = true;
    }

    cnt[0] = 1;
    for(int i = 0; i <= N; i++) {
        if(!bad[i+1]) {
            cnt[i+1] += cnt[i];
            cnt[i+1] %= MOD;
        }
        if(!bad[i+2]) {
            cnt[i+2] += cnt[i];
            cnt[i+2] %= MOD;
        }
    }

    cout << cnt[N] % MOD << endl;
}

Measured memory_bytes: 1152
#include<iomanip>
#include <string>
#include<iostream>
#include<vector>
#include <bits/stdc++.h>
#include <stdio.h>
#include <numeric>
#include<math.h>
#include <ctype.h>
#include <algorithm> // sort
#include <map> // pair
using namespace std;
#define nin(n) int n; cin >> n;
#define kin(k) int k; cin >> k;
const int INF = 1001001001;
int main(){
  int n,k;
  cin >> n;
  cout << n*n*n;
}

Measured memory_bytes: 256
<?php

while(fscanf(STDIN, "%d%d", $h, $w)){
    if($h == 0 && $w == 0){
        return 1;
    }

$count = 1;

for($j = 1; $j <= $h; $j++){

    if($count % 2 == 1){

//#.#.#.
    for($i = 1; $i <= $w; $i++){
        if($i % 2 == 1){
            echo "#";
        }else{
            echo ".";
        }
    }
    echo PHP_EOL;
    $count++;
    }else{

//.#.#.#
    for($i = 1; $i <= $w; $i++){
        if($i % 2 == 1){
            echo ".";
        }else{
            echo "#";
        }
    }
    echo PHP_EOL;
    $count++;
    } // if count()
    
} // for($j =)
echo PHP_EOL;

} //while

?>

Measured memory_bytes: 15004