akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double lld;
typedef struct p point;
ll MOD = (1e9)+7;
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
inline void fastIO(){
  ios_base::sync_with_stdio(0);cin.tie(0);
}
int main(){
	fastIO();
	int n,w,a,b;
	cin>>n>>w;
	ll dp[n+10][w+10],ans=0;
	vector<pair<int,int>>input;
	memset(dp,0,sizeof(dp));
	for(int i=0;i<n;i++){
		cin>>a>>b;
		input.push_back(make_pair(a,b));
	}
	sort(input.begin(),input.end());
	for(int i=input[0].first;i<=w;i++){
		dp[0][i]=input[0].second;
	}
	for(int i=1;i<n;i++){
		int weight=input[i].first;
		int value=input[i].second;
		for(int j=0;j<=w;j++){
			if(j-weight>=0){
				dp[i][j]=max(dp[i-1][j],dp[i-1][j-weight]+value);
			}else{
				dp[i][j]=dp[i-1][j];
			}
		}
	}
	for(int i=0;i<n;i++){
		for(int j=0;j<=w;j++){
			ans=max(ans,dp[i][j]);
		}
	}
	cout<<ans<<endl;
}
// - VERIFICAR LONG VS INT -


Measured memory_bytes: 86272
#include <stdio.h>

int main (void)
{
    int a,b;
    scanf("%d %d",&a,&b);

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

    return 0;
}

Measured memory_bytes: 580
#include <bits/stdc++.h>
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
#define _all(arg) begin(arg),end(arg)

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

using namespace std;


int main(void){
	string S;
	cin >> S;


	bool flag = true;
	for(int i = 0; i < S.size(); i++) {
		if(S[i] == 'N' && S.find('S') == string::npos) {
			flag = false;
		}
		if(S[i] == 'W' && S.find('E') == string::npos) {
			flag = false;
		}
		if(S[i] == 'S' && S.find('N') == string::npos) {
			flag = false;
		}
		if(S[i] == 'E' && S.find('W') == string::npos) {
			flag = false;
		}
	}

	cout << (flag?"Yes":"No") << endl;

        
	return 0;
}


Measured memory_bytes: 256
fun main(args: Array<String>) {
    fun max(vararg v: Long): Long = v.max()!!
    val digits = 41

    val (n, k) = readLine()!!.split(' ').map(String::toLong)
    val aList = readLine()!!.split(' ').map(String::toLong)

    val dp = Array(digits + 1) { Array(2) { -1L } }
    dp[digits][0] = 0L

    for (d in (digits - 1) downTo 0) {
        val mask = 1L shl d
        val count1 = aList.count { a -> (a and mask) != 0L }
        val x0score = count1 * mask
        val x1score = (n - count1) * mask

        if (dp[d + 1][1] >= 0)
            dp[d][1] = max(dp[d][1], dp[d + 1][1] + x0score, dp[d + 1][1] + x1score)

        if (dp[d + 1][0] >= 0)
            if (k and mask != 0L)
                dp[d][1] = max(dp[d][1], dp[d + 1][0] + x0score)

        if (dp[d + 1][0] >= 0)
            if (k and mask != 0L)
                dp[d][0] = max(dp[d][0], dp[d + 1][0] + x1score)
            else
                dp[d][0] = max(dp[d][0], dp[d + 1][0] + x0score)

    }
    println(max(dp[0][0], dp[0][1]))
}


Measured memory_bytes: 74660
#include <stdio.h>

int main(void) {

	int count=0;
	int ans;
	int sumN=0;
	int i;
	char n[200100];
	
	scanf("%s",n);
	
	for(i=0;i<200000;i++){
		if(n[i] == '\0'){
			//printf("%d\n",count);
			break;
		}
		sumN = sumN + ((int)n[i]-48);
		count++;
	}
	
	if(sumN%9 == 0){
		//printf("%d\n",sumN);
		printf("Yes\n");
	}
	else{
		//printf("%d\n",sumN);
		printf("No\n");
	}
	


}


Measured memory_bytes: 1764
import numpy as np

h, w = map(int, input().split())

grid = []
for i in range(h):
    grid.append(list(input()))
grid = (np.array(grid) == ".") * 1

L = np.zeros((h, w), dtype=int)
R = np.zeros((h, w), dtype=int)
U = np.zeros((h, w), dtype=int)
D = np.zeros((h, w), dtype=int)

for j in range(w):
    if j == 0:
        L[:, j] = grid[:, j]
    else:
        L[:, j] = (L[:, j - 1] + 1) * grid[:, j]


for j in range(w - 1, -1, -1):
    if j >= w - 1:
        R[:, j] = grid[:, j]
    else:
        R[:, j] = (R[:, j + 1] + 1) * grid[:, j]

for i in range(h):
    if i <= 0:
        U[i, :] = grid[i, :]
    else:
        U[i, :] = (U[i - 1, :] + 1) * grid[i, :]


for i in range(h - 1, -1, -1):
    if i >= h - 1:
        D[i, :] = grid[i, :]
    else:
        D[i, :] = (D[i + 1, :] + 1) * grid[i, :]

print(np.max(L + R + U + D - 3))


Measured memory_bytes: 266508
import sys
from sys import exit
from collections import deque
from copy import copy, deepcopy
from bisect import bisect_left, bisect_right, insort_left, insort_right
from heapq import heapify, heappop, heappush
from itertools import product, permutations, combinations, combinations_with_replacement
from functools import reduce
from math import gcd, sin, cos, tan, asin, acos, atan, degrees, radians

sys.setrecursionlimit(10**6)
INF = 10**20
eps = 1.0e-20
MOD = 10**9+7

def lcm(x,y):
    return x*y//gcd(x,y)
def lgcd(l):
    return reduce(gcd,l)
def llcm(l):
    return reduce(lcm,l)
def powmod(n,i,mod):
    return pow(n,mod-1+i,mod) if i<0 else pow(n,i,mod)
def div2(x):
    return x.bit_length()
def div10(x):
    return len(str(x))-(x==0)
def intput():
    return int(input())
def mint():
    return map(int,input().split())
def lint():
    return list(map(int,input().split()))
def ilint():
    return int(input()), list(map(int,input().split()))
def judge(x, l=['Yes', 'No']):
    print(l[0] if x else l[1])
def lprint(l, sep='\n'):
    for x in l:
        print(x, end=sep)
def ston(c, c0='a'):
    return ord(c)-ord(c0)
def ntos(x, c0='a'):
    return chr(x+ord(c0))
class counter(dict):
    def __init__(self, *args):
        super().__init__(args)
    def add(self,x,d=1):
        self.setdefault(x,0)
        self[x] += d
    def list(self):
        l = []
        for k in self:
            l.extend([k]*self[k])
        return l
class comb():
    def __init__(self, n, mod=None):
        self.l = [1]
        self.n = n
        self.mod = mod
    def get(self,k):
        l,n,mod = self.l, self.n, self.mod
        k = n-k if k>n//2 else k
        while len(l)<=k:
            i = len(l)
            l.append(l[i-1]*(n+1-i)//i if mod==None else (l[i-1]*(n+1-i)*powmod(i,-1,mod))%mod)
        return l[k]
def pf(x,mode='counter'):
    C = counter()
    p = 2
    while x>1:
        k = 0
        while x%p==0:
            x //= p
            k += 1
        if k>0:
            C.add(p,k)
        p = p+2-(p==2) if p*p<x else x
    if mode=='counter':
        return C
    S = set([1])
    for k in C:
        T = deepcopy(S)
        for x in T:
            for i in range(1,C[k]+1):
                S.add(x*(k**i))
    if mode=='set':
        return S
    if mode=='list':
        return sorted(list(S))

N,M=mint()
P=pf(M,mode='list')
i=bisect_right(P,M//N)
print(P[i-1])

Measured memory_bytes: 70820
#include<bits/stdc++.h>
using namespace std;
    int main(){
        int a, b, c, d, e, k, x; x = 0;
            cin >> a >> b >> c >> d >> e >> k;
                if(e - d > k || e - c > k || e - b > k || e - a > k){
                    cout << ":(" << endl;
                }else if(e - a <= k){
                    cout << "Yay!" << endl;
                }
/*                string A;
                A.at(0) = a;
                A.at(1) = b;
                A.at(2) = c;
                A.at(3) = d;
                A.at(4) = e;
                    for(int i = 0){
                        for(int j = 0){
                            if(A.at(i) == A.at(j)){
                                x += 1;
                            }
                        }
                    }
                        cout << x << endl;*/
    return 0;}

Measured memory_bytes: 256
import numpy as np
k, q = map(int, input().split())
d = np.array(list(map(int, input().split())))
for _ in range(q):
    n, x, m = map(int, input().split())
    dm = d % m
    a = (n - 1) % k
    ans = n - 1
    ans -= np.count_nonzero(dm[:a] == 0) * ((n - 1) // k + 1)
    ans -= np.count_nonzero(dm[a:] == 0) * ((n - 1) // k)
    ans -= (x % m + np.sum(dm[:a]) * ((n - 1) // k + 1) + np.sum(dm[a:]) * ((n - 1) // k)) // m
    print(ans)



Measured memory_bytes: 14592
#include<bits/stdc++.h>
using namespace std;
int main(){
int a[5];
for(int i=0;i<5;i++){
	cin >> a[i];
}
for(int i=0;i<5;i++){
	if(a[i]==0){
		cout << i+1 << endl;
		break;
	}
}
return 0;
}


Measured memory_bytes: 3556
import sys,collections as cl
import fractions
from functools import reduce
import copy
Max = sys.maxsize
def l():
	return list(map(int,input().split()))
def m():
	return map(int,input().split())
def s(x):
	a = []
	aa = x[i]
	su = 1
	for i in range(len(x)-1):
		if aa == x[i+1]:
			a.append([aa,su])
			aa = x[i+1]
			su = 1
		else:
			su += 1
	a.append([aa,su])
	return a

n = int(input())
su = 0

a = l()

co = 0
k = 0
a.sort()
f = 0
for i in range(n):
	if a[i] <= 0:
		co += 1
if co % 2 == 0:
	for i in range(n):
		su += abs(a[i])
	print(su)
else:
	for i in range(n):
		if a[i] == 0:
			break
		if a[i] > 0:
			kk = a[i-1]
		if a[i] > 0:
			if abs(a[i-1]) >= a[i]:
				k = a[i]*(-2)
			else:
				k = kk*2
			break
		elif i == n-1:
			k = a[i]*2
	for i in range(n):
		su += abs(a[i])
	su += k
	print(su)



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

using namespace std;

long long lcm(int a, int b)
{
  return a / __gcd(a, b) * b;
}

int main()
{
  int a, b, c;
  cin >> a >> b >> c;
  
  int ans = -1;
  for(int i = c; i < lcm(60, a+b); i += 60){ //Kai ha 60t + c & lcm de loop
    if(i % (a+b) <= a){ ans = i; break; } //a+b no amari ga a ika
  }
  cout << ans << endl;
  return 0;
}

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

int main(){
  int N, M, X, Y; cin >> N >> M >> X >> Y;
  vector<int> x(N), y(M);
  for(int i=0; i<N; i++) cin >> x[i];
  for(int i=0; i<M; i++) cin >> y[i];
  sort(x.begin(), x.end()); sort(y.begin(), y.end());
  
  if((x[N-1]<y[0])&&(x[N-1]<Y)&&(X<y[0])&&(X<Y))
    cout << "No War" << endl;
  else cout << "War" << endl;
}

Measured memory_bytes: 256
// 初項が正なら二項目は絶対値が初項より大きい負になるべき 逆も然り
// 1 -3 1 0 -> 1 -3 3 -2, -1 2 -2 2 最後にこの差を比較することにする
// 隣同士を比較したときにあとのほうを優先的に変えたらいけそう？

// 変換後の配列を最後に比較することにしたら単純化できた

package main
import "fmt"
func main(){
	var N int
	fmt.Scan(&N)
	A := make([]int, N)
	for i:=0; i<N; i++{
		fmt.Scan(&A[i])
	}
	ANS1, ANS2 := append([]int{}, A...), append([]int{}, A...)
	sum1, sum2 := 0, 0
	// 偶数番目までの和を正としたいときの場合
	for i:=0; i<N; i++{
		if i%2==0{
			if sum1+ANS1[i]>0{
				sum1+=ANS1[i]
			}else{
				x := abs(sum1+ANS1[i])+1
				sum1+=ANS1[i] + x
				ANS1[i] += x
			}
		}else{
			if sum1+ANS1[i]<0{
				sum1+=ANS1[i]
			}else{
				x := abs(sum1+ANS1[i])+1
				sum1+=ANS1[i]-x
				ANS1[i] += -x
			}
		}
	}
	// 偶数番目までの和を負としたいときの場合
	for i:=0; i<N; i++{
		if i%2==0{
			if sum2+ANS2[i] < 0{
				sum2+=ANS2[i]
			}else{
				x := abs(sum2+ANS2[i])+1
				sum2+=ANS2[i] - x
				ANS2[i] += -x
			}
		}else{
			if sum2+ANS2[i] > 0{
				sum2+=ANS2[i]
			}else{
				// 今の合計が -4, 加えるのが2としたとき、3足りない
				x := abs(sum2+ANS2[i]) + 1
				sum2+=ANS2[i]+x
				ANS2[i] += x
			}
		}
	}
	ans1, ans2 := 0, 0
	for i:=0; i<N; i++{
		ans1+=abs(A[i]-ANS1[i])
		ans2+=abs(A[i]-ANS2[i])
	}
	fmt.Println(min(ans1, ans2))
}

func min(a, b int) int {
	if a<b{
		return a
	}
	return b
}

func max(a, b int) int {
	if a<b{
		return b
	}
	return a
}

func abs(x int)int{
	if x < 0{
		x*=-1
	}
	return x
}

Measured memory_bytes: 7756
#include<iostream>
#include<climits>
#define MAX 500001
using namespace std;

int cnt = 0;

void merge(int *A, int left, int mid, int right) {
	int n1 = mid - left;
	int n2 = right - mid;
	int L[MAX], R[MAX];
		for (int i = 0; i < n1; i++) {
		L[i] = A[left + i];
			}
		for (int i = 0; i < n2; i++) {
		R[i] = A[mid + i];
			}
		L[n1] = INT_MAX;
	R[n2] = INT_MAX;
	int i = 0, j = 0;
	for (int k = left; k < right; k++) {
		cnt++;
		if (L[i] <= R[j]) {
			A[k] = L[i];
			i++;
		}
		else {
			A[k] = R[j];
			j++;
		}
	}
}


void mergeSort(int *A, int left, int right) {
	if (left + 1 < right) {
		int mid = (left + right) / 2;
		mergeSort(A, left, mid);
		mergeSort(A, mid, right);
		merge(A, left, mid, right);
	}
}

int main() {
	int n, A[MAX];
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> A[i];
	}
		mergeSort(A, 0, n);
	for (int i = 0; i < n; i++) {
		cout << A[i];
		if (i != n - 1) {
			cout << " ";
		}
		else {
			cout << endl;
		}
	}
	cout << cnt << endl;
}

Measured memory_bytes: 6920
#include<stdio.h>

int main(){
	
	int D, N;
	
	scanf("%d %d", &D, &N);
	
	int pengali = 1;
	for(int i = 0; i<D; i++){
		pengali *= 100;
	}
	if(N < 100){
		printf("%d", pengali * N);
	}
	else{
		printf("%d\n", pengali * 101);
	}
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <iomanip>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <string>
#include <stdio.h>
#include <set>
#include <map>
#include <algorithm>
#include <queue>
#include <vector>
#define ll long long
#define pb push_back
#define mp make_pair
#define f first
#define s second

using namespace std;

const int inf = 1e9 + 7;
const long long INF = 1e18 + 7;
const int maxn = 2e5 + 7;

int k, s, cnt;

int main(){
	ios_base::sync_with_stdio(NULL);
	cin.tie(0);
	cout.tie(0);
	cin >> k >> s;
	for (int i = 0; i <= k; i++){
		if (i > s)
			break;
		for (int j = 0; j <= k; j++){
			if (i + j <= s && s - (i + j) <= k)
				cnt++;
		}
	}
	cout << cnt;
	return 0;
} 

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

using namespace std;
using LL = long long;
using P = pair<int, int>;
using Tapris = tuple<int, int, int>;

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

#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

const int INF = (int)1e9;
const LL INFL = (LL)1e15;
const int MOD = 1e9 + 7;

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

/*************** using variables ***************/
int n;
int a[105][2];
int dp[105][2];
/**********************************************/

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

    cin >> n;
    REP(i, n) cin >> a[i][0];
    REP(i, n) cin >> a[i][1];

    dp[0][0] = 0;
    dp[0][1] = 0;

    REP(i, n){
        dp[i+1][0] = dp[i][0] + a[i][0];
        dp[i+1][1] = max(dp[i][1] + a[i][1], dp[i+1][0] + a[i][1]);
    }

    cout << dp[n][1] << endl;
}


Measured memory_bytes: 256
#入力
lst = input().split()

#整数値化
for i in range(len(lst)):
   lst[i] = int(lst[i])

#ソート
lst.sort()

#出力
if lst[0] == lst[2]:
   print(1)
elif lst[0] == lst[1] or lst[1] == lst[2]:
   print(2)
else:
   print(3)

Measured memory_bytes: 9088
M, D = gets.chomp.split.map(&:to_i)

# p M, D

r = 0

1.upto(M).each do |m|
  22.upto(D).each do |d|
    d1 = d % 10
    d2 = d / 10
    if d1 < 2
      next
    end
    if d2 < 2
      next
    end
    if (d2 * d1) == m
      r += 1
    end
  end
end

p r

Measured memory_bytes: 1788
n = int(input())
a_li = list(map(int,input().split()))

new_a = []
for i in range(n):
    new_a.append([i + 1, a_li[i]])

new_a.sort(key=lambda x:x[1])
for i in range(n):
    print(new_a[i][0], end="")
    if i != n - 1:
        print(" ", end="")


Measured memory_bytes: 22528
#include "bits/stdc++.h"
#define FI first.first
#define SE first.second
#define TH second
#define fi first
#define se second
#define th second

using namespace std;

class DebugStream {}LOG;
template <typename T>DebugStream &operator<<(DebugStream &s, const T&) { return s; }
#ifdef DEBUG
#define LOG clog
#endif

typedef long long ll;
typedef pair<ll, ll> ii;
typedef long double ld;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

const int maxN = 2e6 + 9, maxV = 1e6 + 9, MOD = 1e9 + 7, SQ = 335, lg = 20, bs = 29;

ll fac[maxN][2];
int r1, c1, r2, c2;

ll fastPow(ll a, ll b) {
	ll ret = 1;
	while(b) {
		if(b & 1) ret = ret * a % MOD;
		a = a * a % MOD, b >>= 1;
	}
	return ret;
}

ll ncr(int n, int k) {
	if(k > n) return 0;
	return fac[n][0] * fac[k][1] % MOD * fac[n - k][1] % MOD;
}

ll square(int x, int y) {
	auto ret= ncr(x + y + 2, x + 1) - 1;
	return ret;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	#ifdef DEBUG
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#endif

	fac[0][0] = fac[0][1] = 1;
	cin >> r1 >> c1 >> r2 >> c2;
	int bste = max(max(r1, r2), max(c1, c2));
	for(ll i = 1; i <= 2 * bste + 4; i++) {
		fac[i][0] = fac[i - 1][0] * i % MOD;
		fac[i][1] = fastPow(fac[i][0], MOD - 2);
	}

	ll ans = MOD * ll(2) + square(c2, r2) + square(c1 - 1, r1 - 1) - square(c1 - 1, r2) - square(c2, r1 - 1);
//	LOG << '\n';
	cout << ans % MOD << '\n';
}


Measured memory_bytes: 31488
#define _USE_MATH_DEFINES
#include  <iostream>
#include  <algorithm>
#include  <climits>
#include  <vector>
#include  <string>
#include  <cstring>
#include  <stack>
#include  <queue>
#include  <cmath>
#include  <iomanip>
#include  <set>
#include  <map>
#include  <new>
#include <cstdint>
#include <cctype>
#include  <cstdio>
#include  <sstream>
#include  <bitset>
using namespace std;
#define rep(i,n)  for(int i = 0; i < n; i++)
#define lrep(i,n,m)  for(int i = n; i < m; i++)

using ll = long long;
using ld = long double;
using Vii = vector<vector<int> >;
using Gjudge = vector<vector<bool>>;
using Vi = vector<int>;
using Vl = vector<ll>;
using Vd = vector<double>;
using Vld = vector<long double>;
using Vll = vector<vector<ll> >;
using Vldd = vector<vector<ld> >;
using Vs = vector<string>;
using Vb = vector<bool>;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using Pli = pair<ll, int>;
using VPi = vector<Pi>;
using VPl = vector<Pl>;
using VPli = vector<Pli>;
using Ti = tuple<int, int, int>;
using Tl = tuple<ll, ll, ll>;

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

const int Mod = static_cast<int>(1e9 + 7);
const int INF = INT_MAX;
const ll LINF = LLONG_MAX;
const int dx[4] = { 1,0,-1,0 };
const int dy[4] = { 0,1,0,-1 };



int main()
{
    string s, t;
    cin >> s;
    cin >> t;
    int ns = s.size();
    int nt = t.size();

    int cmin = 0;
    int ans = nt;

    for (int i = 0; i < ns - nt + 1; i++) {
        int tc = 0;
        for (int j = i; j < nt + i; j++) {
            if (s[j] == t[j - i]) tc++;
        }
        
        if (cmin < tc) {
            cmin = tc;
            ans = nt - tc;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std::literals::string_literals;
using i64 = std::int_fast64_t;
using std::cout;
using std::cerr;
using std::endl;
using std::cin;

template<typename T>
std::vector<T> make_v(size_t a){return std::vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return std::vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

int main() {
	int n; scanf("%d", &n); std::vector<int> a(n);
	for(auto& v: a) scanf("%d", &v);

	i64 ans = std::accumulate(begin(a), end(a), 0LL);
	std::vector<int> cnt((int)1e5 + 1);
	for(auto v: a) cnt[v]++;

	int q; scanf("%d", &q);
	while(q--) {
		int x, y; scanf("%d%d", &x, &y);

		ans += (i64)(y - x) * cnt[x];
		cnt[y] += cnt[x];
		cnt[x] = 0;

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


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

typedef long long ll;

template<typename T>
inline T Read(){
    T s = 0, f = 1; char ch = getchar();
    while(!isdigit(ch)) {if(ch == '-') f = -1; ch = getchar();}
    while(isdigit(ch)) {s = (s << 3) + (s << 1) + ch - '0'; ch = getchar();}
    return s * f;
}

#define read() Read<int>()
#define readl() Read<long long>()
const int N = 2010;
const int mod = 1e9 + 7;
int f[N];
void solve() {
	f[0] = f[1] = f[2] = 0;
	f[3] = f[4] = f[5] = 1;
	f[6] = 2;
	int n = read();
	for(int i = 7; i <= n; i++) {
		f[i] = 1;
		for(int j = 3; j <= i - 3; j++) f[i] += f[j], f[i] %= mod;
	}
	
	printf("%d\n", f[n]);
}

int main()
{
	int T = 1;
	//T = read();
	for(int i = 1; i <= T; ++i) {
		solve();
	}

	return 0;
}


Measured memory_bytes: 3748
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define RI(a) scanf("%d",&a)
#define RII(a,b) scanf("%d%d",&a,&b)
#define RIII(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define ALL(a) a.begin(),a.end()
#define F first
#define S second
#define REP(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#ifdef leowang
#define debug(...) do{\
	fprintf(stderr,"%s - %d : (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
	_DO(__VA_ARGS__);\
}while(0)
template<typename I> void _DO(I&&x){cerr<<x<<endl;}
template<typename I,typename...T> void _DO(I&&x,T&&...tail){cerr<<x<<", ";_DO(tail...);}
#else
#define debug(...)
#endif
//}}}
const ll maxn=100005;
const ll maxlg=__lg(maxn)+2;
const ll INF64=8000000000000000000LL;
const int INF=2000000000;

int n;
int a[305][305];
bool r[305][305];
ll sum=0;
bool check(){
	REP(i,305) REP(j,305) r[i][j]=(i==j);
	for(int i=0;i<n;i++) for(int j=i+1;j<n;j++){
		bool tmp=1;
		for(int k=0;k<n;k++){
			if(k==i||k==j) continue;
			
			if(a[i][k]+a[k][j]<=a[i][j]){
				tmp=0;
				break;
			}
		}
		r[i][j]=r[j][i]=tmp;
		if(tmp) sum+=a[i][j];
	}
	ll dis[305][305];
	REP(i,305) REP(j,305) dis[i][j]=(r[i][j])?a[i][j]:INF;
	
	REP(k,n) REP(i,n) REP(j,n){
		dis[i][j]=min(dis[i][j],dis[i][k]+dis[k][j]);
		dis[j][i]=dis[i][j];
	}
	
	//REP(i,n) REP(j,n) cout<<dis[i][j]<<" \n"[j==n-1];
	
	
	REP(i,n) REP(j,n) if(dis[i][j]!=a[i][j]) return false;
	return true;
}

int main()
{
	cin>>n;
	REP(i,n) REP(j,n) scanf("%d",&a[i][j]);
	if(check()){
		cout<<sum<<'\n';
	}
	else puts("-1");
	return 0;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;cin>>n;
    vector<int>v(n+1);
    for(int i=1 ; i<n+1 ; i++){cin>>v[i];}
    vector<int>dp(n+1);
    dp[1] = 0; dp[2]= abs(v[2]-v[1]);
    for(int i=3 ; i<=n ; i++)
    {
        dp[i]= min(dp[i-1]+abs(v[i]-v[i-1]) , dp[i-2]+abs(v[i]-v[i-2]));

    }
    cout<<dp[n]<<endl;
}

Measured memory_bytes: 1024
n = int(input())
a = list(map(int, input().split()))

if n == 0:
    if a[0] != 1:
        print(-1)
        exit()

node_d = [0 for i in range(n + 1)]

# 深さごとのノードの個数の最大値を求める
node_d[0] = 1
for i in range(n):
    node_d[i + 1] = 2 * (node_d[i] - a[i])
    if a[i + 1] > node_d[i + 1]:
        print(-1)
        exit()

node_d[n] = a[n]

for i in range(n - 1, 0, -1):
    # 1つ下のノードの個数+今回の葉の個数（最大値を超えないように）
    node_d[i] = min(node_d[i], node_d[i + 1] + a[i])

print(sum(node_d))

Measured memory_bytes: 674364
void main() {
    int[] tmp = readln.split.to!(int[]);
    int x = tmp[0], y = tmp[1] / 2;
    writeln(x + y);
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.container;
import std.typecons;

Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#define RI register int
using namespace std;
const int LIM=1e9;
long long s; int a,b,c,d;
int main()
{
	scanf("%lld",&s); a=d=(int)sqrt(s);
	while (1LL*a*d<s) if (a<d) ++a; else ++d;
	long long left=1LL*a*d-s; for (RI i=1;1LL*i*i<=left;++i)
	if (left%i==0&&i<=LIM&&left/i<=LIM) { b=i; c=left/i; break; }
	return printf("0 0 %d %d %d %d",a,b,c,d),0;
}

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

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


Measured memory_bytes: 256
def resolve():
    A, B, K = map(int, input().split())
    if K%2 == 0:
        for i in range(K//2):
            if A%2 == 1:
                A -= 1
            B += A//2
            A -= A//2
            if B%2 == 1:
                B -= 1
            A += B//2
            B -= B//2
    else:
        for i in range(K//2):
            if A%2 == 1:
                A -= 1
            B += A//2
            A -= A//2
            if B%2 == 1:
                B -= 1
            A += B//2
            B -= B//2
        if A % 2 == 1:
            A -= 1
        B += A // 2
        A -= A // 2
    print(A, B)
resolve()

Measured memory_bytes: 9216
#include<bits/stdc++.h>
#define int long long
using namespace std;
constexpr int mod=1e9+7;
signed main(){
    int n,x[100];
    cin>>n;
    for(int i=0;i<n;i++)
        cin>>x[i];
    int ans=mod;
    for(int p=1;p<=100;p++){
        int tmp=0;
        for(int i=0;i<n;i++)
            tmp+=(x[i]-p)*(x[i]-p);
        ans=min(ans,tmp);
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
bool isPrime(int x) {
  if (x < 2) return false;
  if (x <=3) return true;
  if ((x % 2) == 0 || (x % 3) == 0) return false;
  for(int k = 5; k * k <= x; k += 6) {
    if ((x % k) == 0 || (x % (k + 2)) == 0) return false;
  }
  return true;
}
int v[100000 + 10];
int d[100000 + 10];
int sum[100000 + 10];
int main () {
  ios::sync_with_stdio(false);
  for(int i = 0; i <= 100000; ++i) {
    if (isPrime(i)) v[i] = 1;
  }

  for(int i = 1; i <= 100000; i += 2) {
    if (v[i] && v[(i + 1) / 2]) d[i] = 1;
  }

  for(int i = 1; i <= 100000; ++i) {
    sum[i] = sum[i - 1] + d[i];
  }
  int Q;
  cin >> Q;
  for(int i = 0; i < Q; ++i) {
    int l, r;
    cin >> l >> r;
    cout << sum[r] - sum[l - 1] << '\n';
  }

}

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

struct Human {
    int no;
    int point;
};

int compareTo(const Human& h1, const Human& h2) {
    if(h1.point > h2.point) return(1);
    else if(h2.point > h1.point) return(0);
    
    if(h1.no < h2.no) return(1);
    else  return(0);
}

int main(void) {
    int n; scanf("%d", &n);
    Human player[n];
    for(int r = 0; r < n; r++) {
        scanf("%d %d", &player[r].no, &player[r].point);
    }
    sort(player, player+n, compareTo);
    printf("%d %d\n", player[0].no, player[0].point);
    return(0);
}

Measured memory_bytes: 1204
#include <bits/stdc++.h>
#include <algorithm>
#include <vector>
#include <iostream>
#include <string>
using namespace std;
 
int main() {
    //input
    int h,w;cin >> h >> w;
    vector<vector<char>> a(h, vector<char>(w));
    for(int i = 0;i < h; i++) {
        for(int j = 0; j < w ; j++){
            cin >> a[i][j];
        } 
    }

    //compute

    //output
    for(int i = 0; i < w + 2; i++) {
        cout << '#';
    }

    cout << endl;        

    for(int i = 0; i < h; i++) {
        cout << '#';
        for(int j = 0; j < w; j++) {
            cout << a[i][j];
            if(j == w -1){
                cout << '#' << endl;
            }
        }
    } 

    for(int i = 0; i < w + 2; i++) {
        cout << '#';
    }

    cout << endl;      
}

Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
vector<int>adj[100000];
vector<bool>visited(100000, false);
void dfs(int s)
{
  visited[s] = true;
  for(int u:adj[s])
    if(!visited[u])
      dfs(u);
}
int main()
{
  int i, n, m;
  cin>>n>>m;
  for(i=1;i<=m;i++)
  {
	int u, v;
    cin>>u>>v;
    adj[u].push_back(v);
    adj[v].push_back(u);
  }
  int ans = 0;
  for(i=1;i<=n;i++)
  {
    if(!visited[i])
    {
      ans++;
      dfs(i);
    }
  }
  ans--;
  cout<<ans;
  cout<<"\n";
  return 0;
}

Measured memory_bytes: 9572
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
using ll = long long;
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007;
// const int MOD = 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
const int dy8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dx8[] = {0, -1, -1, -1, 0, 1, 1, 1};
template <typename T, typename U> inline bool chmax(T &a, U b) { return a < b ? (a = b, true) : false; }
template <typename T, typename U> inline bool chmin(T &a, U b) { return a > b ? (a = b, true) : false; }
struct IOSetup {
  IOSetup() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
  }
} iosetup;

int main() {
  int n; cin >> n;
  vector<int> a(n), b(n); REP(i, n) cin >> a[i] >> b[i];
  vector<int> idx(n);
  iota(ALL(idx), 0);
  sort(ALL(idx), [&](int l, int r) { return a[l] - b[l] < a[r] - b[r]; });
  if (a[idx[0]] == b[idx[0]]) {
    cout << "0\n";
    return 0;
  }
  ll ans = accumulate(ALL(a), 0LL);
  int mn = INF;
  REP(i, n) {
    if (a[i] > b[i]) chmin(mn, b[i]);
  }
  cout << ans - mn << '\n';
  return 0;
}


Measured memory_bytes: 512
program ABC159B
    implicit none
    integer(8)::i,N,flg
    character(99)::S
    read*,S
    N=len_trim(S)
    flg=0

    do i=1,N/2
        if(S(i:i)/=S(N-i+1:N-i+1))flg=1
    end do

    do i=1,N/4
        if(S(i:i)/=S(N/2-i+1:N/2-i+1))flg=1
        if(S(N/2+1+i:N/2+1+i)/=S(N-i+1:N-i+1))flg=1
    end do
    if(flg==0)print'(A)',"Yes"
    if(flg==1)print'(A)',"No"
end program ABC159B

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
    //入力
    int N;
    vector<int> L;
    cin>>N;
    for(int i=0; i<N*2; i++)
    {
         int push;
         cin>>push;
         L.push_back(push);
    }
    
    //ソート
    sort(L.begin(), L.end());

    //隣の数と比較して短い方の値を足していく
    int NN=0;
    for(int i=0; i<N*2; i+=2)
    {
         if(L[i]>L[i+1]) NN+=L[i+1];
         else NN+=L[i];
    }

    //出力
    cout<<NN<<endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll ZERO = 0;
const ll INF = 1e14;
const ll MOD = 1000000007;
const double PI = 3.1415926535897;

int main() {
    ll N;
    cin >> N;
    vector<ll> A(N);
    for(ll i = 0;i < N;i++) {
        cin >> A.at(i);
    }
    vector<ll> B(N);
    for(ll i = 0;i < N;i++) {
        cin >> B.at(i);
    }
    ll a = 0;
    ll b = 0;
    for(ll i = 0;i < N;i++) {
        a += A.at(i);
        b += B.at(i);
    }
    if(a > b) {
        cout << "No" << endl;
    }
    else {
        a = b - a;
        b = a;
        for(ll i = 0;i < N;i++) {
            if(A.at(i) >= B.at(i)) {
                b -= A.at(i) - B.at(i);
            }
            else {
                ll c = B.at(i) - A.at(i);
                if(c % 2 == 0) {
                    a -= c / 2;
                }
                else {
                    a -= (c + 1) / 2;
                    b--;
                }
            }
        }
        if(b < 0 || a < 0) {
            cout << "No" << endl;
        }
        else if(b == a * 2) {
            cout << "Yes" << endl;
        }
        else {
            cout << "No" << endl;
        }
    }
}

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

typedef long long ll;

int main()
{
    int n;
    cin>>n;
    std::vector<int> B(n-1) ;
    for(int i=0;i<n-1;i++)
    {
        cin>>B[i];
    }
    
   // cout<<B[4]<<endl;
    ll sum=B[n-2];
    for(int i=n-3;i>=0;i--)
    {
        if(B[i+1]>=B[i]) sum+=B[i];
        else {sum+=B[i+1];
            
        }
    }
    
    cout<<sum+B[0]<<endl;
}

Measured memory_bytes: 256
n = int(input())
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())

now = [n,0,0,0,0,0]

from math import ceil

# i1 = ceil(n/a)
# now[0] = n - i1*a if n - i1*a >=0 else 0
# now[1] = a*(i1-1) - b*(i1-2) if a*(i1-1) - b*(i1-2) >=0 else 0
# now[2] = b*(i1-2) - c*(i1-3) if b*(i1-2) - c*(i1-3) >=0 else 0
# now[3] = c*(i1-3) - d*(i1-4) if c*(i1-3) - d*(i1-4) >=0 else 0
# now[4] = d*(i1-4) - e*(i1-5) if d*(i1-4) - e*(i1-5) >=0  else 0
# now[5] = e*(i1-5) if e*(i1-5) >=0 else 0

k = ceil(n/ min(a,b,c,d,e)) +4

print(k)

Measured memory_bytes: 3060
// C.

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

using namespace std;

int main(int argc, char *argv[]) {
	string s;
	cin >> s;
	int k;
	cin >> k;
	vector<string> v;
	int len = (int)s.length();
	for (int i = 0; i < len; ++i) {
		for (int j = 1; j <= 6; ++j) {
			if ((i + j) <= len) {
				string x = s.substr(i, j);
				v.push_back(x);
			}
		}
	}
	sort(v.begin(), v.end());
	int cnt = 0;
	string prev;
	for (string x : v) {
		if (x != prev) {
			prev = x;
			if (++cnt == k) {
				cout << x << endl;
				break;
			}
		}
	}
	return 0;
}


Measured memory_bytes: 1916
N,L = map(int,input().split())
plan = 0
for i in range(N):
        plan += L + i
diff = 10000000
ans = -1
for i in range(N):
        actual = 0
        for j in range(N):
                if i != j:
                        actual += L + j
        if abs(plan-actual) < diff:
                diff = abs(plan-actual)
                ans = actual
# print(plan, ans, diff)
print(ans)
        


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define lli long long int
# define mod 1000000007
using namespace std;
 
int main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    lli n,i,k;
    cin>>n>>k;
    lli a[n],aa[n];
    for(i=0;i<n;i++)
        cin>>a[i];
        aa[0]=0;
        for(i=1;i<=k && i<=n;i++)
        {
            aa[i]= abs(a[i]-a[0]);
        }
        for(i=k+1;i<n;i++)
        {   aa[i]= abs(a[i]-a[i-1])+aa[i-1];
            for(int j=i-1;j>= i-k;j--)
                aa[i]=min(aa[i],abs(a[i]-a[j])+aa[j]);
        }
        cout<<aa[n-1];
 
	return 0;
}

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

#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 ALL(obj) (obj).begin(), (obj).end()
#define INF 1e9
#define LINF 1e18
typedef long long ll;


int main() {
    int N,Ma, Mb; cin >> N >> Ma >> Mb;

    vector<pair<int,int>> med(N);
    REP(i,N){
        int a,b,c; cin >> a >> b >> c;
        med[i] = {Mb*a-Ma*b, c};
    }
    int geta = 5000;
    int ans = INF;
    REP(k,N){
        vector<vector<int>> dp(N+1,vector<int>(10000,INF));
        dp[0][geta] = 0;
        REP(i,N){
            REP(j,10000){
                if(0<=j+med[i].first && j+med[i].first<10000){
                    dp[i+1][j+med[i].first] = min(dp[i+1][j+med[i].first], dp[i][j]+med[i].second);
                }
                if(k!=i) dp[i+1][j] = min(dp[i+1][j], dp[i][j]);
            }
        }
        if(dp[N][geta] != INF) ans = min(ans, dp[N][geta]);
    }
    
    if(ans != INF) cout << ans << endl;
    else cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 4868
#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>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second

const int mx=1000010;
const ll mod=1e9+7;


int main(){
  int n;
  cin >> n;
  int ans = (n-2)*180;
  cout << ans << endl;
  return 0;
}

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

#define FOR(k,m,n) for(int (k)=(m);(k)<(n);(k)++)
#define rep(i,n) FOR((i),0,(n))

typedef long long ll;

const int INF=1e9+7;

const int MAX_N=305;

int data[MAX_N];

int take[MAX_N][MAX_N];
int dp[MAX_N][MAX_N];

int abs(int x){
	if(x>0)return x;
	else return -1*x;
}

int dfs(int i,int j){
	if(take[i][j]!=-1)return take[i][j];
	take[i][j]=0;
	if(i==j)return 0;
	else if(i+1==j){
		if(abs(data[i]-data[j])<=1)take[i][j]=1;
		else take[i][j]=0;
	}
	else{
		if(dfs(i+1,j-1)==1 && abs(data[i]-data[j])<=1)take[i][j]=1;
		for(int k=i;k<j;k++)if(dfs(i,k)==1 &&dfs(k+1,j)==1)take[i][j]=1;
	}
	return take[i][j];
}

int solve(int i,int j){
	if(dp[i][j]!=-1)return dp[i][j];
	dp[i][j]=0;
	if(dfs(i,j)==1){
		dp[i][j]=j-i+1;
	}
	for(int k=i;k<j;k++)dp[i][j]=max(dp[i][j],solve(i,k)+solve(k+1,j));
	return dp[i][j];
}

int main(){
	int n;
	while(cin>>n && n){
		rep(i,n+1){
			fill(dp[i],dp[i]+MAX_N,-1);
			fill(take[i],take[i]+MAX_N,-1);
		}
		rep(i,n)cin>>data[i+1];
		cout<<solve(1,n)<<endl;
	}
}

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

int main()
{
    string s, t;
    cin >> s >> t;
    ll ans = 0;
    rep(i, 3)
    {
        if (s[i] == t[i])
            ans++;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3580
#include <bits/stdc++.h>
using namespace std;
 
const int INF = 1145141919;
const long long INFL = 1LL<<60;
 
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;
}
 
double dp[3000][3000] = {};
vector<double> P;
int n;
 
double rec(int d, int x)
{
	if(dp[d][x])
	{
		return dp[d][x];
	}
	if(d == n)
	{
		if(n / 2 + n % 2 > x)
		{
			return 0;
		}
		else
		{
			return 1;
		}
	}
	double ret = 1;
	ret = rec(d+1, x+1) * P[d] + rec(d+1, x) * (1-P[d]);
	return dp[d][x] = ret;
}
 
int main()
{
	cin >> n;
	double in;
	for (int i = 0; i < n; ++i)
	{
		cin >> in;
		P.push_back(in);
	}
	for (int i = n / 2 + 1; i <= n; ++i)
	{
		dp[n][i] = 1;
	}
	for (int i = n; i > 0; --i)
	{
		for (int j = n; j > 0; --j)
		{
			dp[i-1][j-1] = dp[i][j] * P[i-1] + dp[i][j-1] * (1-P[i-1]);
		}
	}
	printf("%0.15lf\n", dp[0][0]);
}

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


int main(){
  int n;
  cin >> n;
  if(n % 10 == 3){
    cout << "bon" << endl;
}
  else if ((n % 10 == 0) || (n % 10 == 1) || (n % 10 == 6) || (n % 10 == 8)){
      cout << "pon" << endl;
  }else{
      cout << "hon" << endl;
  }
}


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

int N;
int A[210];

int main() {
    cin >> N;
    for (int i = 0; i < N; ++i) cin >> A[i];

    int counter = 0;

    while (true){
        bool exist_odd = false;  // A[i] がすべて偶数かどうかを判定するフラグ
        for (int i = 0; i < N; ++i) {
            if (A[i] % 2 != 0) exist_odd = true;  // 奇数があったらフラグを立てる
        }
        if (exist_odd) break;

        for (int i = 0; i < N; ++i) A[i] /= 2;

        counter += 1;
    }

    cout << counter << endl;

}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
  static int a, b, h;

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

    a = sc.nextInt(); b = sc.nextInt();
    h = sc.nextInt();

    int ans = (a + b) * h / 2;

    System.out.println(ans);
  }
}


Measured memory_bytes: 9936
#include<bits/stdc++.h>
using namespace std;
const int INF = 1e9 + 5;
int main(){
    int n;cin >> n;
    vector<int> h(n);
    for(int i=0;i<n;i++) cin >> h[i];
    vector<int> dp(n,INF);
    dp[0] = 0;
    for(int i=0;i<n;i++)
        for(int j:{i+1,i+2})
            if(j<n)
                dp[j] = min(dp[j],dp[i] + abs(h[i]-h[j]));

    cout << dp[n-1] << endl;
return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<functional>
#include<algorithm>
#include<cstdio>
#include<unordered_map>
using namespace std;
//---------------------------------------------------
//ライブラリゾーン！！！！
#define int long long
#define str string
#define rep(i,j) for(int i=0;i<(int)(j);i++)
typedef long long ll;
typedef long double ld;
const ll inf = 4523372036854775807;
const int inf2 = 1145141919;
const ld pi = 3.14159265358979323846264338327950288419716939937510582097494459230781640628620899;
struct P {
	ll pos, cost;
};
bool operator<(P a, P b) { return a.cost < b.cost; }
bool operator>(P a, P b) { return a.cost > b.cost; }
struct B {//隣接リスト表現
	ll to, cost;
};
struct S {//辺の情報を入れる変数
	int from, to, cost;
};
bool operator<(S a, S b) { return a.cost < b.cost; }
bool operator>(S a, S b) { return a.cost > b.cost; }
struct H {
	int x, y;
};
ll gcm(ll i, ll j) {//最大公約数
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcm(j%i, i);
}
ld rad(ld a, ld b, ld c, ld d) {
	return sqrt(pow(a - c, 2) + pow(b - d, 2));
}//rad＝座標上の2点間の距離
 //---------------------------------------------------
 //+++++++++++++++++++++++++++++++++++++++++++++++++++
signed main() {
	string a;
	cin >> a;
	if (a[0] == '9' || a[1] == '9')
		cout << "Yes\n";
	else
		cout << "No\n";
	getchar(); getchar();
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <queue>
#include <numeric>
#include <random>
#include <algorithm>
#include <functional>
#include <cassert>

using namespace std;
typedef long long ll;

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;
}

const int INF = (1 << 30) - 1;
const ll INFLL= (1LL << 61) - 1;
const int MOD = 1000000007;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

pair<int,int> operator+(const pair<int,int> &lhs, const pair<int,int> &rhs){
  pair<int,int> p = { lhs.first + rhs.first, lhs.second + rhs.second };
  return p;
}

int main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int H,W;
  cin>>H>>W;
  vector<string> S(H);
  REP(i,H)cin>>S[i];
  int ans=0;
  const pair<int,int> moves[] = {
    {-1,0}, {1,0}, {0,-1}, {0,1},
  };
  REP(i,H){
    REP(j,W){
      // スタートをi,jにする
      queue<pair<int,int>>q;
      vector<vector<int>> field(H,vector<int>(W,-1));
      if(S[i][j]=='#')continue;

      q.emplace(i,j);
      field[i][j]=0;
      while(!q.empty()){
        auto now=q.front();q.pop();
        for(auto e:moves){
          auto next=now+e;
          if(next.first<0 || next.first>=H || next.second<0 || next.second>=W || S[next.first][next.second]=='#' || field[next.first][next.second]!=-1)continue;

          q.push(next);
          field[next.first][next.second]=field[now.first][now.second]+1;
          chmax(ans,field[next.first][next.second]);
        }
      }
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long int  uint64;
////////////////////
int main() {
  uint64 X = 0, happy = 0;
  cin >> X;
  if(X == 0) {
    cout << 0;
  } else {
      happy = (X/500)*1000;
      if(X%500!=0){
      	X=X%500;
      	happy = X/5*5 + happy;
      }
      cout << happy;
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define MOD (1000000007)
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1}; // 移動方向

int n;
int h[100010];
int dp[100010];

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

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    input();
    dp[0] = 0;
    dp[1] = abs(h[1] - h[0]);
    for(int i=2;i<n;i++){
        dp[i] = min(dp[i-1] + abs(h[i] - h[i-1]), dp[i-2] + abs(h[i] - h[i-2]));
    }
    cout << dp[n-1] << endl;
    return 0;
}

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

int main() {
	int N = 0, max = 0, sum = 0, dmy;
	cin >> N;
	vector<int> L(N);
	for (int a = 0; a < N; a++) {
		cin >> L[a];
	}
	for (int a = 0; a < N; a++) {
		if (max < L[a]) {
			max = L[a];
		}
	}
	for(int a = 0; a < N; a++) {
		if (max == L[a]) {
			L[a] = 0;
            a = N + 1;
		}
	}
	for (int a = 0; a < N; a++) {
		sum += L[a];
	}
	if (max < sum) {
		cout << "Yes";
	}
	else
		cout << "No";
}


Measured memory_bytes: 256
N,K = map(int, input().split())
L = []
for i in range(N):
  L.append(0)
for i in range(K):
  d = int(input())
  A = list(map(int, input().split()))
  for j in range(d):
    L[A[j]-1] = 1
count = 0
for i in range(N):
  if L[i] == 0:
    count += 1
print(count)

Measured memory_bytes: 67668
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i) = 0; (i) < (n); ++(i))
#define rrep(i,n) for(int (i) = (n) - 1; (i) >= 0; --(i)) //Reversi rep
#define nfor(i,a,b) for(int (i) = (a); (i) < (b); ++(i)) //Natural for
#define rfor(i,a,b) for(int (i) = (b); (i) >= (a); --(i)) //Reversi for
#define ll long long
#define mod (1000000007)
#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;

int asc(const void *a, const void *b) {
    return *(int *)a - *(int *)b;
}

int desc(const void *a, const void *b) {
    return *(int *)b - *(int *)a;
}

int main()
{
    int n,k,x,ans = 0;
    cin >> n >> k;
    rep(i, n){
        cin >> x;
        if (x >= (k + 1)/2) {
            ans += abs(x - k) * 2;
        }else{
            ans += abs(x) * 2;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <bitset>
#include <complex>
#include <unistd.h>
#include <cassert>
#include <cctype>
#include <random>
#include <time.h>
#include <functional>
#define _USE_MATH_DEFINES
#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef pair<double, ll> pdlg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef tuple<ll, ll, ll, ll> tlglglglg;
typedef tuple<double, double, double> tddd;
typedef complex<double> xy_t;
typedef vector<ll> vll;
typedef vector< vector<ll> > matrix;
typedef unsigned int uint;
typedef unsigned long long ull;
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;
template <class T> using VVV = V<VV<T>>;
#define REP(i, x, y) for(ll i = (ll)x; i < (ll)y; i++)
#define DREP(i, x, y, d) for(ll i = (ll)x; i < (ll)y; i += (ll)d)
#define PER(i, x, y) for(ll i = (ll)x; i > (ll)y; i--)
#define DPER(i, x, y, d) for(ll i = (ll)x; i > (ll)y; i -= (ll)d)
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
double pi = 3.141592653589793;
ll mod = 1000000007;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;
int iinf = intmax / 8;
ll inf = llmax / 8;
double eps = 1e-12;
void yesno(bool ok, string yes = "Yes", string no = "No") {
    if (ok) {
        cout << yes << endl;
    } else {
        cout << no << endl;
    }
}

ll bo[10010];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    REP(i, 1, 101) {
        REP(j, 1, 101) {
            REP(k, 1, 101) {
                ll num = i * i + j * j + k * k + i * j + i * k + j * k;
                if (num <= 10001) {
                    bo[num]++;
                }
            }
        }
    }
    REP(i, 1, N + 1) {
        cout << bo[i] << endl;
    }
}


Measured memory_bytes: 3612