akhauriyash/Code-Regression huggingface dataset:
package main

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

type Scanner struct {
	lineScanner *bufio.Scanner
	wordScanner *bufio.Scanner
}

var Stdin *Scanner

func NewScanner() *Scanner {
	scanner := &Scanner{
		lineScanner: bufio.NewScanner(os.Stdin),
		wordScanner: bufio.NewScanner(os.Stdin),
	}
	scanner.lineScanner.Split(bufio.ScanLines)
	scanner.wordScanner.Split(bufio.ScanWords)
	return scanner
}

func (sc *Scanner) NextLine() string {
	Stdin.lineScanner.Scan()
	return Stdin.lineScanner.Text()
}

func (sc *Scanner) Next() string {
	Stdin.wordScanner.Scan()
	return Stdin.wordScanner.Text()
}

func (sc *Scanner) NextInt() int {
	Stdin.wordScanner.Scan()
	ret, err := strconv.Atoi(Stdin.wordScanner.Text())
	if err != nil {
		panic(err)
	}
	return ret
}

func (sc *Scanner) NextNInts(N int) []int {
	ints := make([]int, N)
	for i := 0; i < N; i++ {
		ints[i] = sc.NextInt()
	}
	return ints
}

func (sc *Scanner) NextInt64() int64 {
	Stdin.wordScanner.Scan()
	ret, err := strconv.ParseInt(Stdin.wordScanner.Text(), 10, 64)
	if err != nil {
		panic(err)
	}
	return ret
}

func (sc *Scanner) NextFloat() float64 {
	Stdin.wordScanner.Scan()
	ret, err := strconv.ParseFloat(Stdin.wordScanner.Text(), 64)
	if err != nil {
		panic(err)
	}
	return ret
}

type StringSlice []string

func (ss StringSlice) Contains(s string) bool {
	for _, element := range ss {
		if element == s {
			return true
		}
	}
	return false
}

func (ss StringSlice) CountIf(predicate func(string) bool) int {
	count := 0
	for _, s := range ss {
		if predicate(s) {
			count++
		}
	}
	return count
}

func (ss StringSlice) Filter(predicate func(string) bool) StringSlice {
	ret := make([]string, 0)
	for _, s := range ss {
		if predicate(s) {
			ret = append(ret, s)
		}
	}
	return ret
}

func (ss StringSlice) Map(mapper func(string) string) StringSlice {
	ret := make([]string, 0)
	for _, s := range ss {
		ret = append(ret, mapper(s))
	}
	return ret
}

type IntSlice []int

func (is IntSlice) CountIf(predicate func(int) bool) int {
	count := 0
	for _, i := range is {
		if predicate(i) {
			count++
		}
	}
	return count
}

func Pow(base int, power int) int {
	p := 1
	for i := 0; i < power; i++ {
		p *= base
	}
	return p
}

func init() {
	Stdin = NewScanner()
}

func main() {
	N := Stdin.NextInt()
	A := Stdin.NextNInts(N)

	evenCount := IntSlice(A).CountIf(func(element int) bool {
		return element%2 == 0
	})

	all := Pow(3, N)
	allOdds := Pow(2, evenCount)

	fmt.Println(all - allOdds)
}


Measured memory_bytes: 640
n,k=map(int,input().split())
l=list(map(int,input().split()))
dp=[0]*n
for i in range(1,n):    
    start=max(0,i-k)
    dp[i]=min(dp[j]+abs(l[i]-l[j]) for j in range(start,i))
print(dp[-1])

Measured memory_bytes: 20656
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

N,Q = map(int,input().split())
AB = [[int(i) for i in input().split()] for _ in range(N-1)]
PX = [[int(j) for j in input().split()] for _ in range(Q)]

graph = [[] for _ in range(N+1)]
for a,b in AB:
    graph[a].append(b)
    graph[b].append(a)
    
counters = [0] * (N+1)
for p,x in PX:
    counters[p] += x
    
def dfs(v,parent,add):
    counters[v] += add
    for x in graph[v]:
        if x == parent:
            continue
        dfs(x,v,counters[v])

dfs(1,0,0)

ans = ' '.join(map(str,counters[1:]))
print(ans)

Measured memory_bytes: 285868
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>
#include<utility>

using namespace std;

#define int long long
#define endl "\n"

constexpr long long INF = (long long)1e18;
constexpr long long MOD = 1'000'000'007; 

struct fast_io {
	fast_io(){
		std::cin.tie(nullptr);
		std::ios::sync_with_stdio(false);
	};
} ;
// } fio;

signed main(){
	cout<<fixed<<setprecision(10);
	
	int N;
	vector<int> A;
	
	cin>>N;
	
	A.resize(N);
	
	for(int i = 0; i < N; i++){
		cin>>A[i];
	}
	
	if(N%2 == 0) {
		vector<int> sum0(N/2+1), sum1(N/2+1);
		int ans = -INF;
		
		for(int i = 0; i < N/2; i++){
			sum0[i+1] += A[i * 2];
			sum1[i+1] += A[i * 2 + 1];
			sum0[i+1] += sum0[i];
			sum1[i+1] += sum1[i];
		}
		// cout<<sum1[N/2]<<endl;
		
		for(int i = 0; i <= N/2; i++){
			ans = max(sum0[i] - sum0[0] + sum1[N/2] - sum1[i], ans);
		}
		
		cout<<ans<<endl;
		
	} else {
		vector<vector<int>> dp(3, vector<int>(N/2+2, -INF));
		int ans = -INF;
		
		dp[0][0] = 0;
		dp[1][0] = 0;
		dp[2][0] = 0;
		
		// dp[0][0] = dp[1][0] = dp[2][0] = 0;
		
		for(int i = 0; i < N/2+1; i++){
			// cout<<"i = "<<i<<endl;
			if(i + 1 != N/2+1) {
				dp[0][i+1] = max(dp[0][i] + A[i*2], dp[0][i+1]);
			} else {
				dp[0][i+1] = dp[0][i];
			}
			if(i + 1 != N/2+1) {
				dp[1][i+1] = max(dp[1][i] + A[i*2+1], dp[0][i] + A[i*2+1]);
			} else {
				dp[1][i+1] = dp[1][i];
			}
			
			// if()dp[2][i+1] = max(dp[2][i] + A[i*2], dp[1][i] + A[i*2]);
			dp[2][i+1] = max(dp[2][i] + A[i*2], dp[2][i+1]);
			if(i >= 1) dp[2][i+1] = max(dp[2][i+1],max(dp[1][i-1] + A[i*2], dp[0][i-1] + A[i*2]));
			
			// cout<<"<> "<<dp[0][i+1] <<" "<<dp[1][i+1] <<" "<<dp[2][i+1] <<endl;
		}
		
		ans = max(dp[0][N/2+1], max(dp[2][N/2+1],dp[1][N/2+1]));
		
		cout<<ans<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 7940
//Home  » December Challenge 2017 » Chef and Universe » All Submissions » akathil [16446096]
//Solution: 16446096
//CodeChef submission 16446096 (C++14) plaintext list. Status: AC, problem CHEFUNI, contest DEC17. By akathil (akathil), 2017-12-04 17:25:12.
#include <bits/stdc++.h>
using namespace std;
#define all(v) v.begin(),v.end()
#define pii pair< int,int>
#define pb push_back
#define F first
#define S second
#define mp make_pair
#define ll long long int
#define mod 1000000007
#define mxn 2000002
#define sqr 320
ll arr[mxn]={0},ans[mxn]={0};
//vector<vector<int> > v(mxn);
ll dp[102][102][102]={0};
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n,k;
    cin>>n>>k;
    int i,tmp=0;
    for(i=0;i<n;i++)
    {
      cin>>arr[i];
      if(!ans[arr[i]])
        tmp++;
      ans[arr[i]]++;
    }
    if(tmp<=k)
    {
      cout<<0;
      return 0;
    }
    vector<int>v;
    for(i=1;i<=n;i++) if(ans[i]) v.pb(ans[i]);
      sort(all(v));
    int yu=0;
    for(i=0;i<tmp-k;i++)
      yu+=v[i];
    cout<<yu;

     return 0;
    }  

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

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

using namespace std;

int main(){
	int n,m,X,Y; cin>>n>>m>>X>>Y;
	int x[100],y[100];
	rep(i,n) cin>>x[i];
	rep(i,m) cin>>y[i];

	for(int z=X+1;z<=Y;z++){
		bool ok=true;
		rep(i,n) if(x[i]>=z) ok=false;
		rep(i,m) if(y[i]< z) ok=false;
		if(ok){ cout<<"No War"<<endl; return 0; }
	}
	cout<<"War"<<endl;

	return 0;
}


Measured memory_bytes: 384
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <bitset>    // bitset
#include <cctype>    // isupper, islower, isdigit, toupper, tolower
#include <cstdint>   // int64_t, int*_t
#include <cstdio>    // printf
#include <deque>     // deque
#include <iomanip>   // setprecision
#include <iostream>  // cout, endl, cin
#include <map>       // map
#include <queue>     // queue, priority_queue
#include <set>       // set
#include <stack>     // stack
#include <string>    // string, to_string, stoi
#include <tuple>     // tuple, make_tuple
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <utility>       // pair, make_pair
#include <vector>        // vector
using namespace std;

int gcd(long long a, long long b) { return b != 0 ? gcd(b, a % b) : a; }
// cout << fixed << setprecision(10);

int main() {
    int A, B, C;
    cin >> A >> B >> C;
    string ans = "No";
    if((A==B && B!=C) || (A==C && A!=B) || (B==C && A!=B)) {
        ans = "Yes";
    }
    cout << ans << endl;
}

Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF (INT_MAX / 4)
#define REP(i, n) for (ll i = 0, i##_len = (n); i < i##_len; ++i)
#define TIMER_S(start) chrono::system_clock::time_point start = chrono::system_clock::now();
#define TIMER_E(end) chrono::system_clock::time_point end = chrono::system_clock::now();
#define TIME(start, end) cout << static_cast<double>(chrono::duration_cast<chrono::microseconds>(end - start).count()) << "ms" \
                            << "\n";

int main()
{
    int a;
    cin >> a;
    if (a / 100 == 7 || (a - (a / 100) * 100) / 10 == 7 || (a - (a / 100) * 100) - ((a - (a / 100) * 100) / 10)*10==7){
        cout << "Yes" << "\n";
    }else{
        cout << "No" << "\n";
    }
        return 0;
}


Measured memory_bytes: 3568
#!/usr/bin/env python3

n = int(input())
s = [int(input()) for _ in range(n)]
s = sorted(s)

ans = sum(s)
if ans%10 != 0:
    print(ans)
    exit(0)
    
for i in s:
    if i%10 != 0:
        ans -= i
        print(ans)
        exit(0)

print(0)


Measured memory_bytes: 9172
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

n, a, b = map(int, readline().split())
x = list(map(int, readline().split()))
ans = 0
for bf, af in zip(x, x[1:]):
    ans += min((af - bf) * a, b)
print(ans)


Measured memory_bytes: 12496
#include<iostream>

using namespace std;

int main(){
	
	
	int n;
	cin>>n;
	int a[n];
	
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	
	
	int count = 0;
	bool flag = true;
	while(flag){
		flag = false;
		for(int i=n-1;i>0;i--){
			if(a[i-1] > a[i]){
				int temp = a[i];
				a[i] = a[i-1];
				a[i-1] = temp;
				count++;
				flag = true;
			}
		}
	}
	
	
	cout << a[0];
	for(int i=1;i<n;i++){
		cout<<' '<<a[i];
	}
	cout<<endl;
	cout<<count<<endl;
	
	return 0;

}

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

/*2進数配列+1*/
vector<int> twoadd(vector<int> v, int N){
    v[N-1]+=1;
    int ind = N-1;
    int j=N-1;
    for(j=N-1;j>=1;j--){
        if(v[j]>1){
            v[j-1]+=1;
            v[j]=0;
        }
    }
    return v;
}

/*フィボナッチ*/
long long fibonatti(long long d){
    long long count = 0;
    long long f1 = 1;
    long long f2 = 1;/*ここを変える*/
    long long temp;
    if(d == 1){
        count = f1;
    }else if(d == 2){
        count = f2;
    }else if(d==0){
        count = 1;
    }else{
        for(int i=0;i<d-2;i++){
            temp = f1+f2;
            f1 = f2;
            f2 = temp;
        }
        count = temp;
    }
    return count;
}

/*最大公約数*/
unsigned long long GCD(long long L,long long R){
    if(L>R){
        long long temp=R;
        R = L;
        L = temp;
    }
    unsigned long long pp=0,ppt=0;
    unsigned long long ans=0;
    if(R%L==0){
        ans = L;
    }else{
        while(true){
            ppt = pp;
            pp=R%L;
            if(pp == 0){
                ans = ppt;
                break;
            }
            R = L;
            L = pp;
        }
    }    
    return ans;    
}

/*最小公倍数*/
unsigned long long LCM(long long L,long long R){
    unsigned long long ans;
    unsigned long long gcd = GCD(L,R);
    ans = (L/gcd)*R;
    return ans;
}

/*Combination set*/
#define mod 1000000007
#define maxcomb 3000/*大きいものを求めるときはここを変える*/
vector<long long> fc(maxcomb+1);
vector<long long> ifc(maxcomb+1);
long long modpow(long long x,long long n){
    long long ans = 1;
    while(n > 0){
        if(n & 1) {
            ans = ans*x%mod;
        }
        x = x*x%mod;
        n >>= 1;
    }
    return ans;
}
void Conb(){
    fc[0]= 1;
    ifc[0]=1;
    for(long long i=0;i<maxcomb;i++){
        fc[i+1] = fc[i]*(i+1)%mod;//n!(mod)
        ifc[i+1] = ifc[i]*modpow(i+1,mod-2)%mod;//k!^{M-2} (mod)
    }
}
unsigned long long Combination(long long L,long long R){
    unsigned long long up=1,ans;
    Conb();
    if(L==0&&R==0){
        return 1;
    }else if(L<R||L<0){
        return 0;
    }else{
        long long t = ifc[L-R]*ifc[R]%mod;
        ans = t*fc[L]%mod;
    }
    return ans;
}
/*Combination set ここまで*/

/*ここから*/
int main() {
    int N;
    cin >> N;
    int ans;
    if(N==100000){
        ans = 9+900+90000;
    }else{
        if(N>=10000){
            ans = 9+900+N-10000+1;
        }else if(N>=1000){
            ans = 9+900;
        }else if(N>=100){
            ans = 9+N-100+1;
        }else if(N>=10){
            ans = 9;
        }else{
            ans = N;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3724
fun main(args: Array<String>) {
	val input1=readLine()!!.split(" ")
	var A:Long=input1[0].toLong()
	var B:Long=input1[1].toLong()
	var C:Long=input1[2].toLong()
	var K:Long=input1[3].toLong()
	if(K<=A){
		print(K)
	}
	else{
		if(A+B>=K){
			print(A)
		}
		else{
			print(A-(K-A-B))
		}
	}
	
	
}

Measured memory_bytes: 35732
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)
N = parse(readline())
X = parseMap(split(readline()))
sort!(X)

best_sum = 10000000000
for i in X[1]:X[N]
    sum = 0
    for x in X
        sum += (x - i) ^ 2
    end
    if sum < best_sum
        best_sum = sum
    end
end            
println(best_sum)

Measured memory_bytes: 124940
#ifndef ONLINE_JUDGE
    #include "debug.cpp"
#endif

#include <bits/stdc++.h>

using namespace std;

#define int long long
#define ar array

const int MOD = 1000000007;


/* Iterative Function to calculate (x^y)%MOD in O(log y) */
int power(int x, int y)  
{  
    int res = 1;     // Initialize result  
  
    x = x % MOD; // Update x if it is more than or  
                // equal to p 
   
    if (x == 0) return 0; // In case x is divisible by p; 
  
    while (y > 0)  
    {  
        // If y is odd, multiply x with result  
        if (y & 1)  
            res = (res*x) % MOD;  
  
        // y must be even now  
        y = y>>1; // y = y/2  
        x = (x*x) % MOD;  
    }  
    return res;  
}  


void solve(){
	int n;
	cin >> n;
	int ans = 0;
	ans += power(10,n);
	ans-=(2*power(9,n));
	ans+=power(8,n);
	cout << ((ans%MOD)+MOD)%MOD << "\n";
}

int32_t main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);

    int TC = 1;
//    cin>>TC;
    while(TC--)
        solve();

    return 0;
}



Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
int main()
{

    long long int n;
    cin>>n;
    unordered_map<string,int>m;
    for(int i=0;i<n;i++)
    {

        string s;
        cin>>s;
        m[s]++;
    }

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


}


Measured memory_bytes: 3632
from sys import stdout
printn = lambda x: stdout.write(str(x))
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
ins = lambda : input().strip()
DBG = True # and False
BIG = 999999999999
R = 10**9 + 7
import bisect

def ddprint(x):
  if DBG:
    print(x)

a,b,q = inm()
s = []
t = []
for i in range(a):
    s.append(inn())
for i in range(b):
    t.append(inn())
for qq in range(q):
    x = inn()
    mn = BIG

    i = bisect.bisect_left(s,x)
    j = bisect.bisect_left(t,x)
    #ddprint("i {} j {}".format(i,j))
    if i>0 and j>0:
        mn = min(mn, x-min(s[i-1],t[j-1]))
    if i>0 and j<b:
        mn = min(mn, min(x-s[i-1],t[j]-x)+t[j]-s[i-1])
    if i<a and j>0:
        mn = min(mn, min(x-t[j-1],s[i]-x)+s[i]-t[j-1])
    if i<a and j<b:
        mn = min(mn, max(s[i],t[j])-x)
    print(mn)


Measured memory_bytes: 12092
#include<iostream>
using namespace std;
int main(){
    int h,w;
    cin>>h>>w;
    int b[60][60];
    for(int i=0;i<h;i++)for(int j=0;j<w;j++){
        char x;
        cin>>x;
        if(i==0&&j==0);
        else if(i==0)b[i][j]=b[i][j-1]+x-48;
        else if(j==0)b[i][j]=b[i-1][j]+x-48;
        else b[i][j]=min(b[i][j-1],b[i-1][j])+x-48;
    }
    cout<<b[h-1][w-1]<<endl;
    return 0;
}

Measured memory_bytes: 1176
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
using P = pair<int,int>;
const ll INF = 1LL<<58;
int main()
{
    int a,b,q;
    cin >> a >> b >> q;
    vector<ll> s(a+2),t(b+2);
    rep(i,a)cin >> s[i+1];
    rep(i,b)cin >> t[i+1];
    s[0] = t[0] = -INF;
    s[a+1] = t[b+1] = INF;
    sort(s.begin(),s.end());
    sort(t.begin(),t.end());
    
    vector<ll> p(q);
    rep(i,q){
        ll x;
        cin >> x;
        ll ans = INF;
        ll al = lower_bound(s.begin(),s.end(),x)-s.begin();
        ll bl  = lower_bound(t.begin(),t.end(),x) -t.begin();
        ll af = upper_bound(s.begin(),s.end(),x) - s.begin()-1;
        ll bf = upper_bound(t.begin(),t.end(),x)- t.begin()-1;
        ans = min(ans,abs(s[af]-x)+abs(s[af]-t[bf]));
        ans = min(ans,abs(s[af]-x)+abs(s[af]-t[bl]));
        ans = min(ans,abs(s[al]-x)+abs(s[al]-t[bl]));
        ans = min(ans,abs(s[al]-x)+abs(s[al]-t[bf]));
        ans = min(ans,abs(t[bf]-x)+abs(s[af]-t[bf]));
        ans = min(ans,abs(t[bf]-x)+abs(s[al]-t[bf]));
        ans = min(ans,abs(t[bl]-x)+abs(s[af]-t[bl]));
        ans = min(ans,abs(t[bl]-x)+abs(s[al]-t[bl]));

       p[i] = ans;



    }
    rep(i,q)cout << p[i] << endl;

    return 0;
}

Measured memory_bytes: 3712
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Practice
{
    class Program
    {
        private static int ReadAndParseInt()
        {
            return int.Parse(Console.ReadLine());
        }
        private static int[] ReadAndParseIntArr()
        {
            return Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
        }
        private static long ReadAndParseLong()
        {
            return long.Parse(Console.ReadLine());
        }
        private static long[] ReadAndParseLongArr()
        {
            return Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse);
        }
        static void Main(string[] args)
        {
            SolveA(args);
            //SolveB(args);
            //SolveC(args);
            //SolveD(args);


        }
        static void SolveA(string[] args)
        {
            int n = ReadAndParseInt();
            int[] x = ReadAndParseIntArr();
            List<int> sorted = new List<int>(x);
            sorted.Sort();
            int mid = (n + 1) / 2 - 1;
            int midL = sorted[mid];
            int midR = sorted[mid + 1];

            for(int i=0;i<n;++i)
            {
                if(x[i] <= midL)
                {
                    Console.WriteLine(midR);
                }
                else
                {
                    Console.WriteLine(midL);
                }
            }
        }
        
    }
}


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

int main() {
    int n,i;
    double sum;

    cin >> n;
    vector<int> a(n+10);
    sum = 0;

    for(i=0; i<n; i++){
        cin >> a.at(i);
        sum += (double) 1 / a.at(i);
    }

    cout <<  1 / sum << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <string>
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <bitset>

//#include <boost/multiprecision/cpp_dec_float.hpp>
//#include <boost/multiprecision/cpp_int.hpp>
//namespace mp = boost::multiprecision;
//// 任意長整数型
//using Bint = mp::cpp_int;
//// 仮数部が1024ビットの浮動小数点数型(TLEしたら小さくする)
//using Real = mp::number<mp::cpp_dec_float<1024>>;
//
typedef long long ll;
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
typedef pair<int,int> P;

const int MOD = 1000000007;


ll N,M,X;
vector<ll> C;
vector<vector<ll>> A;

ll sum = 100000000;
void dfs(vector<ll> D){
    if(D.size()>=N){
        vector<ll> cost(N);
        ll temp_sum = 0;
        for(ll i=0;i<N;i++){
            if(D[i]==1){
                temp_sum += C[i];
                for(ll j=0;j<M;j++){
                    cost[j]+=A[i][j];
                }
            }
        }
        
        for(ll i=0;i<M;i++){
            if(cost[i]<X){
                return;
            }
        }
        
        sum = min(sum, temp_sum);
        return;
    }
    
    D.push_back(1);
    dfs(D);
    D.pop_back();
    D.push_back(0);
    dfs(D);
    
    return;
}

int main(int argc, const char * argv[]) {
    cin>>N>>M>>X;
    C = vector<ll>(N);
    for(ll i=0;i<N;i++){
        cin >> C[i];
        vector<ll> A_temp(M);
        for(ll j=0;j<M;j++){
            cin >> A_temp[j];
        }
        A.push_back(A_temp);
    }
    
    for(ll i=0;i<M;i++){
        ll s = 0;
        for(ll j=0;j<N;j++){
            s += A[j][i];
        }
        if(s < X){
            cout << -1 << endl;
            return 0;
        }
    }
    dfs(vector<ll>());
    
    cout << sum << endl;
    
    return 0;
}



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

int main()
{
    int n;
    scanf("%d",&n);
    int x;
    int a,b,c;
    a=b=c=0;
    while(n--)
    {
        scanf("%d",&x);
        if(x%4==0)
            a++;
        else if(x%2==0)
            b++;
        else
            c++;
    }
    int cnt;
    if(b>0)
    {
        if(c<=a)
            cout<<"Yes"<<endl;
        else
            cout<<"No"<<endl;
    }
    else
    {
        if(a+1>=c)
            cout<<"Yes"<<endl;
        else
            cout<<"No"<<endl;
    }
    return 0;

}


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

typedef vector<int> vi;
typedef pair<int,int> ii;

// Union-Find Disjoint Sets Library written in OOP manner, using both path compression and union by rank heuristics
class UnionFind {                                              // OOP style
	private:
		vi p, rank, setSize;                       // remember: vi is vector<int>
		int numSets;
	public:
		UnionFind(int N) {
			setSize.assign(N, 1); numSets = N; rank.assign(N, 0);
			p.assign(N, 0); for (int i = 0; i < N; i++) p[i] = i; }
		int findSet(int i) { return (p[i] == i) ? i : (p[i] = findSet(p[i])); }
		bool isSameSet(int i, int j) { return findSet(i) == findSet(j); }
		void unionSet(int i, int j) { 
			if (!isSameSet(i, j)) { numSets--; 
				int x = findSet(i), y = findSet(j);
				// rank is used to keep the tree short
				if (rank[x] > rank[y]) { p[y] = x; setSize[x] += setSize[y]; }
				else                   { p[x] = y; setSize[y] += setSize[x];
					if (rank[x] == rank[y]) rank[y]++; } } }
		int numDisjointSets() { return numSets; }
		int sizeOfSet(int i) { return setSize[findSet(i)]; }
};

int main() {
	int N,K,L; cin>>N>>K>>L;
	UnionFind road(N+1), rail(N+1);
	for (int i=0; i<K; i++) {
		int p,q; cin>>p>>q; road.unionSet(p,q);
	}
	for (int i=0; i<L; i++) {
		int r,s; cin>>r>>s; rail.unionSet(r,s);
	}
	map<ii,int> ct;
	for (int i=1; i<=N; i++)
		ct[{road.findSet(i),rail.findSet(i)}]++;
	for (int i=1; i<=N; i++)
		cout<<ct[{road.findSet(i),rail.findSet(i)}]<<" ";
	cout<<"\n";
	return 0;
}

Measured memory_bytes: 16640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for (int i = (int)(s); i < (int)(n); i++)
const ll mod = ll(1e9) + 7;
const int INF = int(1e9);
int main()
{
    string s;
    cin >> s;
    ll ans = 0;
    ll tmp = 0;
    rep(i, s.size() - 2)
    {
        if (s[i] == 'A')
        {
            tmp++;
        }
        else
        {
            tmp = 0;
        }

        if (s[i] == 'A' && s[i + 1] == 'B' && s[i + 2] == 'C')
        {
            s[i + 2] = 'A';
            ans += tmp;
            tmp--;
            i += 1;
        }
    }
    //cout << s << endl;
    //break;

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


Measured memory_bytes: 640
// #include <stdio.h>
// #include <string.h>
//#include <iostream>
#include <utility>
#include <cstdio>
#include <stack>
#include <queue>
#include <algorithm>
#include <map>
#include <string>
#include <set>

using namespace std;
typedef pair<int, int> XY;// Pair型変数の宣言
    
int main()
{
    
  	int Nmax = 100000;
    char String[Nmax];
    int N;
    int i,j,k;
    int len;   // 文字列の長さ
    int flag=0;
    int t[Nmax];
    int x[Nmax];
    int y[Nmax];
/*    
    // int型スタック
    stack<int> stack;   
    stack.push(777);
    stack.push(778);
    stack.push(779);
  
	int tmpsl = stack.top();  // LAST要素の参照
 // 	int tpmsf = stack.back(); // FIRST要素の参照
 //	printf("%d %d \n",tmpsl,tmpsf);
    stack.pop();// LAST要素の削除（取出しではない）
 // 	if( stack.empty() == true) printf("empty stack\n");
     
    // int型キュー
    queue<int> que;
  	que.push(999);
  	que.push(998);   
  	que.push(997);    
  	int tmpqs = que.front(); // FIRST要素の参照
  	int tmpqe = que.back();  // LAST要素の参照
 //	printf("%d %d \n",tmpqs,tmpqe);
  	que.pop();  // FIRST要素の削除（取出しではない）
  //	if( que.empty() == true) printf("empty que\n");
    
    // ２次元座標を扱うキュー
    queue<XY> xyque; // ２次元座標型変数のキュー
  	XY p; 
  	xyque.pop();	// FIRST要素の削除。キューが空のときは削除が予約されて次のPOPが即削除される
  	xyque.push( XY(5,5) );
    xyque.push( XY(5,5) );
   	p = xyque.front();  // FIRST要素からのコピー
 // 	printf("%d %d\n", p.first, p.second);
  	
    
  que.back();
  //  sort(&(que.front()), &(que.back()));
     */   
    
      
    // 入力読込
    // 文字列
//    scanf("%s", String);   
    
    // 数列
    scanf("%d", &N);
//    for(i=1;i<=N;i++){
//        scanf("%d %d %d",&t[i],&x[i],&y[i]);
//    }
    
    // 文字列の長さをチェック
    // 文字列は配列の0からlen-1に格納されてる
//    len = strlen( String );
//  	printf("%d\n",len);
    
    // 奇数である確率
    if(N==1)
        printf("1.0");
    else if(N%2 ==1)
        printf("%f \n", (float)(N/2+1)/(float)N);
    else
         printf("%f \n", 0.5 );
    
    /*
    // 結果出力
    if(N%2 == 1)
        printf("NO \n");
    else
        printf("YES \n");
        
  */
    
  return 0;
   
}

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

template<typename T1,typename T2> void chmin(T1 &a,T2 b){if(a>b)a=b;};
template<typename T1,typename T2> void chmax(T1 &a,T2 b){if(a<b)a=b;};

const Int MAX = 1010;

double dp[2][MAX][MAX];
double dfs(Int k,Int i,Int j){
  double &res=dp[k][i][j];
  //cout<<k<<" "<<i<<" "<<j<<endl;
  assert(i>=0&&j>=0);
  if(res>=0) return res;  
  res=0;
  if(i==0||(k==0&&i<=j*2)) return res;
  if(!k){
    if(j) res+=dfs(0,i-2,j-1)*double(j)/double(i-j);
    res+=dfs(1,i,j+1)*double(i-2*j)/double(i-j);
  }else{
    assert(j>=1);
    res+=dfs(0,i-2,j-1)*double(1)/double(i-j);
    res+=(dfs(0,i-2,j-1)+1.0)*double(j-1)/double(i-j);
    res+=(dfs(0,i,j+1)+1.0)*double(i-j*2)/double(i-j);
  }
  return res;
}

signed main(){
  cin.tie(0);
  ios::sync_with_stdio(0);
  for(Int i=0;i<MAX;i++)
    for(Int j=0;j<MAX;j++)
      dp[0][i][j]=dp[1][i][j]=-1;
  Int n;
  while(cin>>n,n){
    cout<<fixed<<setprecision(12)<<dfs(0,n,0)<<endl;
  }
}




Measured memory_bytes: 19192
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#ifdef LOCAL
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;
#else
#define debug(x) ;
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200010


int main(){
  int n, h[SIZE];
  int dp[SIZE];

  scanf("%d", &n);

  for(int i=0;i<n;i++) scanf("%d", h+i);
  for(int i=0;i<=n;i++) dp[i] = INF;
  dp[0] = 0;

  for(int i=0;i<n-1;i++){
    for(int j=1;j<=2;j++)
      if(i+j < n) dp[i+j] = min(dp[i+j], dp[i] + abs(h[i] - h[i+j]));
  }

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

  return 0;
}


Measured memory_bytes: 1024
n,m = map(int,input().split())
h = list(map(int,input().split()))
l = [0]*n

for i in range(m):
    a,b = map(int,input().split())
    if h[a-1] < h[b-1]:
        l[a-1] = -1
    elif h[a-1] > h[b-1]:
        l[b-1] = -1
    elif h[a-1] == h[b-1]:
        l[a-1] = -1
        l[b-1] = -1
print(l.count(0))


Measured memory_bytes: 20128
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _155_A
{
    class Program
    {
        static void Main(string[] args)
        {
            var inputs = Console.ReadLine()
                .Split()
                .Select(int.Parse)
                .ToArray();
            Console.WriteLine(
                (inputs[0] != inputs[1] && inputs[1] != inputs[2] && inputs[2] != inputs[0])
                || (inputs[0] == inputs[1] && inputs[1] == inputs[2] && inputs[2] == inputs[0])
                ? "No" : "Yes");
        }
    }
}
//AC


Measured memory_bytes: 13268
/* 
	بسم الله الرحمن الرحیم

	(; طلا یک جهانی
*/

#include <bits/stdc++.h>
using namespace std;

#define int long long

const long long INF = 1e18;
const int MAX_N = 100 * 1000 + 5;
int n, e, t, a[MAX_N];
long long dp[MAX_N], seg[2][4 * MAX_N];

void read_input() {
	cin >> n >> e >> t;
	for (int i = 1; i <= n; i++)
		cin >> a[i];
}

void modify(int w, int p, long long x, int id = 1, int l = 0, int r = n + 1) {
	if (l == r - 1) {
		seg[w][id] = min(seg[w][id], x);
		return;
	}
	int mid = (l + r) / 2;
	if (p < mid)
		modify(w, p, x, id * 2, l, mid);
	else
		modify(w, p, x, id*2+1, mid, r);
	seg[w][id] = min(seg[w][id * 2], seg[w][id*2+1]);
}

long long get(int w, int x, int y, int id = 1, int l = 0, int r = n + 1) {
	if (x >= r || y <= l)
		return INF;
	if (x <= l && y >= r)
		return seg[w][id];
	int mid = (l + r) / 2;
	return min(get(w, x, y, id * 2, l, mid), get(w, x, y, id*2+1, mid, r));
}

void solve() {
	memset(seg, 63, sizeof seg);
	modify(0, 0, 0);
	modify(1, 0, -2 * a[1]);
	for (int i = 1; i <= n; i++) {
		int p = lower_bound(a, a + n + 1, a[i] - t / 2) - a - 1;
//		cerr << "* " << i << " : " << p << endl;
		dp[i] = min(get(0, p, n + 1) + a[i] + t, get(1, 0, p) + 3 * a[i]);
		modify(0, i, dp[i] - a[i]);
		modify(1, i, dp[i] - 2 * a[i + 1] - a[i]);
	}
}

void print_output() {
//	for (int i = 1; i <= n; i++)
//		cerr << i << " : " << dp[i] << endl;
	cout << dp[n] + e - a[n];
}

int32_t main() {
	ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	read_input();
	solve();
	print_output();
}


Measured memory_bytes: 8064
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;
 
public class Main {
	private static FastScanner sc = new FastScanner();
	
	public static void main(String[] args) {
		int N = sc.nextInt();
		int W = sc.nextInt();
		int[] v = new int[N];
		int[] w = new int[N];
		for(int i=0; i<N; i++) {
			v[i] = sc.nextInt();
			w[i] = sc.nextInt();
		}
		
		int[] dp = new int[10001];
		for(int i=1; i<dp.length; i++) {
			dp[i] = Integer.MAX_VALUE - 10000000;
		}
		for(int i=0; i<N; i++) {
			for(int j=dp.length-1; j>=0; j--) {
				if(j-v[i] >= 0 && dp[j-v[i]] + w[i] < dp[j]) {
					dp[j] = dp[j-v[i]] + w[i];
				}
			}
		}
		
		int max = 0;
		for(int i=0; i<dp.length; i++) {
			if(dp[i] <= W) {
				max = i;
			}
		}
		System.out.println(max);
	}
	
	static class FastScanner {
        private final InputStream in = System.in;
        private final byte[] buffer = new byte[1024];
        private int ptr = 0;
        private int buflen = 0;
        private boolean hasNextByte() {
            if(ptr < buflen) {
                return true;
            } else {
                ptr = 0;
                try {
                    buflen = in.read(buffer);
                } catch(IOException e) {
                    e.printStackTrace();
                }
                if(buflen <= 0) {
                    return false;
                }
            }
            return true;
        }
        private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
        private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
        private void skipUnprintable() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;}
        public boolean hasNext() { skipUnprintable(); return hasNextByte();}
        public String next() {
            if (!hasNext()) throw new NoSuchElementException();
            StringBuilder sb = new StringBuilder();
            int b = readByte();
            while(isPrintableChar(b)) {
                sb.appendCodePoint(b);
                b = readByte();
            }
            return sb.toString();
        }
        public long nextLong() {
            return Long.parseLong(next());
        }
        public int nextInt(){
            return Integer.parseInt(next());
        }
        public double nextDouble(){
            return Double.parseDouble(next());
        }
    }
}

Measured memory_bytes: 25292
#include<stdio.h>
int main(){
  int a,b,c,i;
  scanf("%d %d %d",&a,&b,&c);
  for(i=0;i<60;i++){
    if(a>=(i*60+c)%(a+b))break;
  }
  if(i==60)printf("-1\n");
  else     printf("%d\n",i*60+c);
  return 0;
}

Measured memory_bytes: 596
#define ll long long
#define mp make_pair
#define pb push_back
#define fi first
#define se second

#include<bits/stdc++.h>
using namespace std;

int n,k;

int main(){
    ios_base::sync_with_stdio(false);

    cin>>n>>k;
    if(n%k==0)cout<<0<<"\n";
    else cout<<1<<"\n";


}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define pll pair <ll, ll>
#define mp make_pair
#define pyshnapyshnakaa ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define x first
#define y second
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#define plll pair <ll, pair <ll, ll>>
#define pllll pair <pair <ll, ll>, pair <ll, ll> >
#define psl pair <string, ll>
#define all(a) a.begin(), a.end()

typedef long long ll;

typedef long double ld;

using namespace std;

const ll maxn = 1e6 + 100;
const ll maxm = 4e3;

ll n, m, k;

string s;

ll A[maxn];

bool is_st2(ll x) {
    while (x % 2 == 0) {
        x /= 2;
    }
    return x == 1;
}

ll cnt_2[maxn];

int main() {
    ll q, w, e, a, b, c, d;
    cin >> n;
    cin >> s;
    bool is1 = 0;
    for (q = 1; q <= n; q++) {
        if (q % 2 == 0) {
            cnt_2[q] = cnt_2[q / 2] + 1;
        }
    }
    for (q = 1; q < n; q++) {
        A[q - 1] = abs(s[q] - s[q - 1]);
        if (A[q - 1] == 1) {
            is1 = 1;
        }
    }
    if (is1) {
        // cout << "UH" << endl;
        // ll ans = A[0] % 2;
        ll ans = 0;
        ll cur = 0; 
        for (q = 0; q < n - 1; q++) {
            // cout << q << " " << cur << " CUR" << endl;
            if (cur == 0) {
                ans += A[q] % 2;
                ans %= 2;
            }
            // cout << q + 1 << " " << n - q - 1 << endl;
            cur += cnt_2[n - q - 2];
            cur -= cnt_2[q + 1];
        }
        cout << ans;
    }
    else {
        ll ans = 0;
        ll cur = 0; 
        for (q = 0; q < n - 1; q++) {
            if (cur == 0) {
                ans += A[q] / 2;
                ans %= 2;
            }
            cur += cnt_2[n - q - 2];
            cur -= cnt_2[q + 1];
        }
        cout << ans * 2;
    }
    return 0;
}


Measured memory_bytes: 17028
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 1000001;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

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

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

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

struct edge {
	ll ind;
	ll fr;
	ll to;
	ll d;
};


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


int main() {

	ll N, H;
	cin >> N >> H;

	vector<ll> a(N + 1), b(N + 1);
	repn(i, N) cin >> a[i] >> b[i];

	sort(++a.begin(), a.end(), greater<ll>());
	sort(++b.begin(), b.end(), greater<ll>());

	ll ans = (H - 1) / a[1] + 1;

	ll h = H;

	repn(i, N) {
		h -= b[i];

		ll at = i;
		if (h > 0) { at += (h - 1) / a[1] + 1; }
		ans = min(ans, at);
	}

	cout << ans;

	system("PAUSE");

	

}


Measured memory_bytes: 2040
#include<iostream>
using namespace std;
int a[105];
int main()
{
	int n,k,d,i,x;
	cin>>n>>k;
	for(i=0;i<k;i++)
	{
		cin>>d;
		while(d--)
		{
			cin>>x;
			a[x]++;
		}
	}
	int ans=0;
	for(i=1;i<=n;i++)
	{
		if(a[i]==0)
		ans++;
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 3604
#include <stdio.h>
//#include <stdlib.h>
//#include <string.h>
//#include <stdbool.h>
//#include <limits.h>
//#include <math.h>

int main() {
  int k, x;
  scanf("%d %d", &k, &x);
  if (500 * k >= x)
    printf("Yes\n");
  else
    printf("No\n");
  return 0;
}


Measured memory_bytes: 128
import java.io.*;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));

        String str = in.nextLine();
        int num0 = 0;
        int num1 = 0;
        for (int i=0; i<str.length(); i++) {
            char c = str.charAt(i);
            if (c == '0') {
                num0++;
            } else {
                num1++;
            }
        }
        out.println(Math.min(num0, num1) * 2);
        out.close();
    }

    static class Scanner {
        StringTokenizer st;
        BufferedReader br;

        public Scanner(InputStream s) {
            br = new BufferedReader(new InputStreamReader(s));
        }

        public Scanner(String s) {
            try {
                br = new BufferedReader(new FileReader(s));
            } catch (FileNotFoundException e) {
                e.printStackTrace();
            }
        }

        public String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public double nextDouble() {
            return Double.parseDouble(next());
        }

        public int[] nextIntArray(int n) {
            int[] arr = new int[n];
            for (int i = 0; i < n; i++) {
                arr[i] = nextInt();
            }
            return arr;
        }

        public double[] nextDoubleArray(int n) {
            double[] arr = new double[n];
            for (int i = 0; i < n; i++) {
                arr[i] = nextDouble();
            }
            return arr;
        }

        public long[] nextLongArray(int n) {
            long[] arr = new long[n];
            for (int i = 0; i < n; i++) {
                arr[i] = nextLong();
            }
            return arr;
        }

        public char[] nextCharArray(int n) {
            char[] arr = nextLine().trim().replaceAll("\\s", "").toCharArray();
            return arr;
        }

        public String[] nextStringArray(int n) {
            String[] arr = new String[n];
            for (int i = 0; i < n; i++) {
                arr[i] = next();
            }
            return arr;
        }
    }
}


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

using namespace std;
#define DBG(x)                         \
    (void)(cout << "L" << __LINE__     \
                << ": " << #x << " = " \
                << (x) << '\n')
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
typedef long long ll;
using pii = pair<int, int>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const long double PI = (acos(-1));
const long double EPS = 0.0000000001;
const int INF = 0x3f3f3f3f;
const int maxn = 1100000;
int x[6];
void run_case()
{
    int ans = 0;
    for (int i = 1; i <= 5; i++)
    {
        cin >> x[i];
        if (x[i] == 0)
        {
            ans = i;
        }
        //cout << ans << "\n";
    }
    cout << ans << "\n";
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setiosflags(ios::fixed) << setprecision(12);
    run_case();
    cout.flush();
    return 0;
}

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

 
int main() {

    int x,n;
    cin >> x >> n;
    if(n == 0) {
        cout<<x<<endl;
        return 0;
    }
    vector<int> p(n);
    rep(i,n)    cin >> p[i];

    int i = 0;
    while(1) {
        rep(j,n) {
            if(x-i == p[j]) break;
            else if(j == n-1) {
                cout<<x-i<<endl;
                return 0;
            }
        }
        rep(j,n) {
            if(x+i == p[j]) break;
            else if(j == n-1) {
                cout<<x+i<<endl;
                return 0;
            }
        }
        i++;
    }

    
 return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, start, n) for (int i = (int)(start); i < (int)(n); ++i)
int N, K;
void func()
{
    cin >> K >> N;
    int A[N], ans(0);
    rep(i, 0, N) cin >> A[i];
    int max(0);
    rep(i, 0, N - 1)
    {
        if (A[i + 1] - A[i] > max)
            max = A[i + 1] - A[i];
    }
    ans = (K - max < A[N - 1] - A[0]) ? K - max : A[N - 1] - A[0];
    cout << ans << endl;
}
int main()
{
    func();
}

Measured memory_bytes: 1024
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define Sort(Array) sort(Array.begin(), Array.end())
#define Reverse(a) reverse(a.begin(), a.end())
#define out(ans) cout << ans << endl;
const int MOD = 1000000007;
const int INF = 2147483647;

//------------↓------------- M -------------- E ---------------- M --------------- O ---------------↓--------------//
// コンパイル 
// g++ -std=c++1z
//
// -------型変換--------
// int を string に変換
// string s = to_string(n);
// string を int に変換
// int n = stoi(s);
//
// -------二分探索---------
// k以上の値が最初に現れる時のイテレータ O(logN)
// lower_bound(data.begin(), data.end(), k)
// kより大きい値が最初の現れる時のイテレータ O(logN)
// upper_bound(data.begin(), data.end(), k)
// kがdataに存在するかをtrue or falseで返す O(logN)
// binary_search(data.begin(), data.end(), k)
// 
//
//
//
//
//
// 
//------------↑------------- M -------------- E ---------------- M --------------- O ---------------↑--------------//




int main() {

    int n, x;
    n = x = 1;
    while (1) {
        cin >> n >> x;
        if (n == 0 && x == 0) break;
        int ans = 0;
        for (int i = 1; i <= n; ++i) {
            for (int j = i + 1; j <= n; ++j) {
                int k = x - i - j;
                if (k != i && k != j && j + 1 <= k && k <= n) ++ans;
            }
        }
        out(ans);
    }

    return 0;
}











Measured memory_bytes: 3076
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <math.h>
using namespace std;

long long int GCD(long long int x, long long int y) {
    return x ? GCD(y % x, x) : y;
}

vector<long long int > divisor(long long int  n) {
    vector<long long int  > ret;
    for(long long int i = 1; i * i <= n; i++) {
        if(n % i == 0) {
            ret.push_back(i);
            if(i * i != n) ret.push_back(n / i);
        }
    }
    sort(begin(ret), end(ret));
    return (ret);
}

int main()
{
    long long int A;
    long long int B;
    
    cin >> A;
    cin >> B;
    
    long long int P;
    P = GCD(A,B);

//    cout << GCD(A,B) << endl;
    
    // 割る数の初期値
    long long int count = 1;
    long long int a = 2;
    
//    long long int p;
//    p = P;
    // √n ≧ a ( n ≧ a * a ) の間ループ処理
    
    long long int p;
    p = P;
    bool flag = false;
    while (P >= a * a) {
        
        if (p % a == 0) {
            if (flag == false){
//                cout << a << endl;
                count++;
                flag = true;
            }
            p /= a;
        } else {
            flag=false;
            a++;
        }
    }
    if(p != 1) count++;
    
    cout << count << endl;
    
    return 0;
}


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

int main(){
  int n, c;
  cin >> n >> c;
  vector<int> v;
  for (int i = 0; i < n; i++){
    int d;
    cin >> d;
    if (d < c) v.push_back(d);
  }
  sort(v.begin(), v.end());
  int prev = 0;
  int count = 0;
  for (int i = 0; i < v.size(); i++) {
    if (prev == v[i]) count++;
    else {
      prev = v[i];
      vector<bool> b(c+1, false);
      bool flag = false;
      b[0] = true;
      for (int j = i + 1; j < v.size(); j++){
        for (int k = c-v[j]; k >= 0; k--) {
          if (b[k]) {
            int w = k+v[j];
            b[w] = true;
            //cout << k  << "\t" << w << endl;
            if (w >= c - v[i] && w < c) {
              flag = true;
              break;
            }
          }
        }
      }
      if (flag) break;
      else count++;
    }
  }
  cout << count << endl;
  return 0;
}


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

int main(){
	int N, Z, W;
	cin >> N >> Z >> W;
	int a[N];
	for(int i=0; i<N; i++){
		cin >> a[i];
	}	
	if(N == 1){
		cout << abs(a[0] - W) << endl;
		return 0;
	}

//dp[i][0]・・・a[i]～a[N-1]で，先手最大，後手最小，先手は全部取らない
//dp[i][1]・・・a[i]～a[N-1]で，先手最小，後手最大，先手は全部取らない

	int dp[N][2];
	dp[N-1][0] = abs(a[N-2] - a[N-1]);
	dp[N-1][1] = abs(a[N-2] - a[N-1]);
	dp[N-2][0] = abs(a[N-2] - a[N-1]);
	dp[N-2][1] = abs(a[N-2] - a[N-1]);
	for(int i=N-3; i>=0; i--){
		int Min, Max;
		Max = min(dp[i+1][1], abs(a[i] - a[N-1]));
		Min = max(dp[i+1][0], abs(a[i] - a[N-1]));
		for(int j=i; j<N-1; j++){
			if(Max < min(dp[j+1][1], abs(a[j] - a[N-1]))){
				Max = min(dp[j+1][1], abs(a[j] - a[N-1]));
			}
			if(Min > max(dp[j+1][0], abs(a[j] - a[N-1]))){
				Min = max(dp[j+1][0], abs(a[j] - a[N-1]));
			}
		}
		
		dp[i][0] = Max;
		dp[i][1] = Min;
	}
	cout << max(dp[0][0], abs(a[N-1] - W)) << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;


public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        
        int n= sc.nextInt();
        int ans=0;
        
        if(n<105){
            System.out.println(0);
            return;
        }
        
        for(int i=105; i<=n; i++){
            //System.out.println(ans);
            int count=0;
            for(int j=2; j<i; j++){
                //System.out.println(j);
                if(i%j==0){
                    //System.out.println(j);
                    count++;
                }
            }
            if(count==6){
                ans++;
            }
            i++;
        }

        System.out.println(ans);
        
	}
}

Measured memory_bytes: 35676
def culculate(a,b)
  ans=Float::INFINITY
  (1..a-1).each do |i|
    s1=i*b
    s2=(a-i)*(b/2)
    s3=(a-i)*(b-b/2)
    s22=((a-i)/2)*b
    s32=((a-i)-(a-i)/2)*b
    sort1=[s1,s2,s3].sort
    sort2=[s1,s22,s32].sort
    ans=[sort1[2]-sort1[0],sort2[2]-sort2[0],ans].min
  end
  return ans
end

h,w=gets.split.map(&:to_i)
if h%3==0 || w%3==0
  puts 0
  exit
end
puts [culculate(h,w),culculate(w,h)].min


Measured memory_bytes: 3836