akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i
　　　　／　　　＼　 　  |　|
　　　 /　　 /￣￣￣￣/　　|
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿
　 　　　＼/＿＿＿＿/　（u　⊃
---------------------------------------------------------------------------------------------------*/







int N; string S; int Q;
//---------------------------------------------------------------------------------------------------
ll solve(int K) {
    ll ans = 0;
    int c = 0;
    int Mcnt = 0;
    int Ccnt = 0;
    ll tot = 0;
    rep(a, 0, N) {
        if (S[a] == 'D') {
            while (c < N and c - a < K) {
                if (S[c] == 'M') Mcnt++;
                else if (S[c] == 'C') {
                    Ccnt++;
                    tot += Mcnt;
                }
                c++;
            }
            ans += tot;
        }
        else if (S[a] == 'M') {
            Mcnt--;
            tot -= Ccnt;
        }
        else if (S[a] == 'C') {
            Ccnt--;
        }
    }
    return ans;
}
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> N >> S >> Q;
    rep(q, 0, Q) {
        int k; cin >> k;
        printf("%lld\n", solve(k));
    }
}


Measured memory_bytes: 1948
#include <iostream> 
    #include <vector>
     
    using namespace std;
     
    int main(int argc, char *argv[]) {
    	int N;
    	cin >> N;
     
    	vector<int> a(N);
    	for (int i = 0; i < N; i++) cin >> a[i];
     
    	long ans_pos = 0;
    	long sum = 0;
    	for (int i = 0; i < N; i++) {
    		sum += a[i];
    		if (i % 2 == 1 && sum >= 0) {
    			ans_pos += sum + 1;
    			sum = -1;
    		} else if (i % 2 == 0 && sum <= 0) {
    			ans_pos += -sum + 1;
    			sum = 1;
    		}
    	}
     
    	long ans_neg = 0;
    	sum = 0;
    	for (int i = 0; i < N; i++) {
    		sum += a[i];
    		if (i % 2 == 0 && sum >= 0) {
    			ans_neg += sum + 1;
    			sum = -1;
    		} else if (i % 2 == 1 && sum <= 0) {
    			ans_neg += -sum + 1;
    			sum = 1;
    		}
    	}
     
    	cout << min(ans_pos, ans_neg) << endl;
    	return 0;
    }

Measured memory_bytes: 640
N,M=map(int, input().split())
p=[]
S=[]
for i in range(M):
    P,s=input().split()
    p.append(int(P))
    S.append(s)
A=set()
W=[0 for i in range(0,N)]
w=0
for i in range(0, M):
    if S[i]=='AC' and p[i]-1 not in A:
        w+=W[p[i]-1]
        A.add(p[i]-1)
    elif S[i]=='WA':
        if p[i]-1 not in A:
            W[p[i]-1]+=1
print(len(A), w)

Measured memory_bytes: 23508
def main():
    import sys
    input = sys.stdin.readline
    a, b = map(int, input().rstrip('\n').split())
    s = input().rstrip('\n')
    ls = list("1234567890")
    for i in range(a + b + 1):
        if i < a:
            if s[i] not in ls:
                print("No")
                exit()
        elif i == a:
            if s[i] != "-":
                print("No")
                exit()
        elif b <= i:
            if s[i] not in ls:
                print("No")
                exit()
    print("Yes")


if __name__ == '__main__':
    main()


Measured memory_bytes: 38256
#include <iostream>

using namespace std;

int main()
{
    int f=0;
    while (1)
    {
	int a,b;
	cin >> a >> b;
	if (a==0)break;
	if (f==1)cout << endl;
	f=1;
	int f2=0;
	for (int i=a;i<=b;i++)
	{
	    if (i%400==0||(i%4==0&&i%100!=0))
	    {
		f2=1;
		cout << i << endl;
	    }
	}
	if (f2==0)cout << "NA" << endl;
    }
    return 0;
}

Measured memory_bytes: 0
#include<cstdio>
#include<algorithm>
#define fo(i,a,b) for(i=a;i<=b;i++)
#define fd(i,a,b) for(i=a;i>=b;i--)
using namespace std;
typedef long long ll;
const int maxn=300000+10;
const ll inf=1000000000000000000;
ll sum[maxn],f[maxn],g[maxn],h[maxn],L[maxn],R[maxn],ans[maxn];
int dl[maxn],xy[maxn];
int i,j,k,l,r,t,n,m,head,tail;
ll num;
void revsum(){
	fd(i,n,1) sum[i]-=sum[i-1];
	reverse(sum+1,sum+n+1);
	fo(i,1,n) sum[i]+=sum[i-1];
}
void revLR(){
	fo(i,0,n+1) swap(L[i],R[n+1-i]);
}
ll S(int x){
	return (ll)x*(x+1)/2;
}
int getxy(int x,int y){
	int l=y+1,r=n+1,mid;
	while (l<r){
		mid=(l+r)/2;
		if (f[x]-sum[x]+S(mid-x)>=f[y]-sum[y]+S(mid-y)) r=mid;else l=mid+1;
	}
	return l;
}
int getbest(int id){
	while (head<tail&&xy[tail-1]<=id) tail--;
	return dl[tail];
}
void put(int id){
	while (head<tail&&xy[tail-1]<=getxy(dl[tail],id)) tail--;
	dl[++tail]=id;
	if (head<tail) xy[tail-1]=getxy(dl[tail-1],id);
}
void dp(){
	f[0]=0;
	head=1;
	dl[tail=1]=0;
	fo(i,1,n){
		j=getbest(i);
		f[i]=f[j]+S(i-j)+sum[i]-sum[j];
		f[i]=max(f[i],f[i-1]);
		put(i);
	}
}
void solve(int l,int r,int c){
	if (l==r){
		g[l]=max(g[l],sum[l]-sum[l-1]+L[l-1]+R[l+1]+1);
		return;
	}
	int mid=(l+r+c)/2;
	int i,j,k;
	head=1;tail=0;
	fo(i,l-1,mid-1){
		f[i]=L[i];
		put(i);
	}
	fo(i,mid+1,r){
		j=getbest(i);
		h[i]=f[j]+S(i-j)+sum[i]-sum[j]+R[i+1];
	}
	fd(i,r-1,mid+1) h[i]=max(h[i],h[i+1]);
	fo(i,mid+1,r) g[i]=max(g[i],h[i]);
	solve(l,mid,c);solve(mid+1,r,c);
}
int main(){
	scanf("%d",&n);
	fo(i,1,n){
		scanf("%d",&t);
		t*=-1;
		sum[i]=sum[i-1]+(ll)t;
	}
	dp();
	fo(i,0,n) L[i]=f[i];
	revsum();
	dp();
	fo(i,0,n) R[n+1-i]=f[i];
	revsum();
	fo(i,1,n) g[i]=-inf;
	solve(1,n,0);
	fo(i,1,n) ans[i]=g[i];
	revsum();
	revLR();
	fo(i,1,n) g[i]=-inf;
	solve(1,n,-1);
	fo(i,1,n) ans[i]=max(ans[i],g[n-i+1]);
	revsum();
	revLR();
	fd(i,n,1) sum[i]-=sum[i-1];
	scanf("%d",&m);
	while (m--){
		scanf("%d%d",&j,&t);
		t*=-1;
		num=max(L[j-1]+R[j+1],ans[j]+t-sum[j]);
		printf("%lld\n",num);
	}
}

Measured memory_bytes: 19328
#include<iostream>
#include<string>
#include<map>
#include<algorithm>
using namespace std;
typedef long long ll;
const int Max = 1e3 + 7;
int ls1[Max], ls2[Max];
int n;


int main()
{
	int a, b;
	cin >> a >> b;
	int t = b;
	int s = 0;
	while (t > 0)
	{
		a *= 10;
		t /= 10;
	}
	a += b;
	if ((int)sqrt(a) * (int)sqrt(a) == a) cout << "Yes";
	else cout << "No";

}

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

template<class T> void vin(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
    }
}

int main()
{
    int a[3];
    rep(i, 3) cin >> a[i];
    sort(a, a+3);
    cout << (a[0]==a[2] ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(){
	int n;
	scanf("%d",&n);
	int i=1;
	int j=1;
	int confira=0;
	for(i=1;i<=9;i++){
		for(j=1;j<=9;j++){
			if(n == i*j){
				confira=1;
				break;
			}
		}
	}
	if(confira==0)
		printf("No\n");
	else
		printf("Yes\n");
	return 0;
}

Measured memory_bytes: 128
# -*- coding: utf-8 -*-

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

def dijkstra(nodes: list, src: int) -> list:
    from heapq import heappush, heappop

    N = len(nodes)
    MAX = 50**2
    res = list2d(N, MAX+1, INF)
    que = [(0, src, min(S, MAX))]
    res[src][min(S, MAX)] = 0
    while que:
        dist, u, coin  = heappop(que)
        if res[u][coin] < dist:
            continue
        if dist + D[u] < res[u][min(coin+C[u], MAX)]:
            res[u][min(coin+C[u], MAX)] = dist + D[u]
            heappush(que, (dist+D[u], u, min(coin+C[u], MAX)))
        for v, a, b in nodes[u]:
            if coin - a >= 0 and dist + b < res[v][coin-a]:
                res[v][coin-a] = dist + b
                heappush(que, (dist+b, v, coin-a))
    return res

N, M, S = MAP()
nodes = [[] for i in range(N)]
for _ in range(M):
    u, v, a, b = MAP()
    u -= 1; v -= 1
    nodes[u].append((v, a, b))
    nodes[v].append((u, a, b))
C = [0] * N
D = [0] * N
for i in range(N):
    c, d = MAP()
    C[i] = c
    D[i] = d

res = dijkstra(nodes, 0)
for i in range(1, N):
    print(min(res[i]))


Measured memory_bytes: 92272
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line = "";

		while ((line = br.readLine()) != null) {

			int[] top = new int[10];
			for (int i = 0; i < 10; i++) {
				top[i] = line.charAt(i) - 48;
			}
			System.out.println(getBottommost(top));
		}
	}

	public static int getBottommost(int[] top) {

		if (top.length == 1) {
			return top[0];
		}

		int[] bottom = null;
		do {
			bottom = getBottom(top);
			top = bottom;
		} while (bottom.length > 1);

		return bottom[0];
	}

	public static int[] getBottom(int[] top) {

		if (top.length == 1) {
			return top;
		}

		int[] bottom = new int[top.length - 1];
		for (int i = 0; i < top.length - 1; i++) {
			bottom[i] = (top[i] + top[i + 1]) % 10;
		}
		return bottom;
	}
}

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

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

using ll = long long;
using namespace std;

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

    ll a1 = n % k;
    ll a2 = k - a1;

    cout << min(a1, a2) << endl;
}


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

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i=0; i<n; i++){
        cin >> a[i];
    }
    for(int i=0; i<n-1; i++){
        a[i+1] += a[i];
    }

    int ans = 0;
    for(;; ans++){
        bool ok = true;
        for(int i=0; i<n; i++){
            if(ans*(i+1) > a[i]){
                ok = false;
            }
        }
        if(!ok){
            ans--;
            break;
        }
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 3096
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

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

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

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<string> vs;
typedef pair<ll,ll> P;
typedef vector<P> vp;
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define REPR(i,n) for(int i=n-1;i>=0;i--)
#define FORR(i,n,m) for(int i=n-1;i>=m;i--)
#define all(in) in.begin(),in.end()
#define ALL(in,K) in,in+K
#define INF 1e18
#define MOD 100000007
#define SIZE 10005
#define PI 	3.14159265358979323846

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    cout << 48-n << endl;
}

Measured memory_bytes: 256
# nikkei2019-qualB - Touitsu
def main():
    N, *S = open(0).read().split()
    ans = 0
    for i in zip(*S):
        x = len(set(i))
        if x == 3:
            ans += 2
        elif x == 2:
            ans += 1
    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
#define itn int

int main(void){
    int n;
    cin >> n;
    int l[n];
    for(int i = 0;i < n;i++)cin >> l[i];
    
    long long sum = 0;
    for(int i = 0;i < n;i++){
        for(int j = i+1;j < n;j++){
            for(int k = j+1;k < n;k++){
                if(l[i] == l[j] || l[i] == l[k] || l[j] == l[k])continue;
                if(l[i]+l[j] <= l[k] || l[i]+l[k] <= l[j] || l[j]+l[k] <= l[i])continue;
                sum++;
            }
        }
    }
    cout << sum << endl;
  
}

Measured memory_bytes: 3632
import kotlin.math.abs
import kotlin.math.cos
import kotlin.math.pow
import kotlin.math.sqrt

fun main(args: Array<String>) {
    val (a, b, h, m) = readLine()!!.split(" ").map { it.toDouble() }
    val angle = getAngle(h, m)
    print(sqrt(a.pow(2) + b.pow(2) - 2 * a * b * cos(Math.toRadians(angle))))
}

fun getAngle(h: Double, m: Double): Double {
    val angle = abs(h * 30 + 30 * m / 60 - m * 6)
    return if (angle > 180) 360 - angle else angle
}


Measured memory_bytes: 36652
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
using namespace std;
int main() {
	int a, b;
	cin >> a >> b;
	if (b > 0) {
		if (a + b >= a * b)
			cout << a + b << "\n";
		else
			cout << a * b << "\n";
	}
	else {
		if (a - b >= a * b)
			cout << a - b << "\n";
		else
			cout << a * b << "\n";
	}
}

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

template<Int MOD = 1000000007>
struct Mod{
  Int prev=0;
  vector<Int> fact,inv,finv;
  Mod(){}
  Mod(Int n){init(n);}
  
  Int pow(Int x,Int n){
    Int res=1;
    while(n){
      if(n&1) (res*=x)%=MOD;
      (x*=x)%=MOD;
      n>>=1;
    }
    return res;
  }
  
  Int inverse(Int a){
    return pow(a,MOD-2);
  }
  
  void init(Int n){
    if(prev>=n) return;
    prev=n;
    fact=inv=finv=vector<Int>(n);
    
    fact[0]=1;
    for(Int i=1;i<n;i++)
      fact[i]=(fact[i-1]*i)%MOD;
    
    inv[1]=1;
    for(Int i=2;i<n;i++)
      inv[i]=inv[MOD%i]*(MOD-MOD/i)%MOD;
    
    finv[0]=1;
    for(Int i=1;i<n;i++)
      finv[i]=finv[i-1]*inv[i]%MOD;
  }
  
  Int comb(Int n,Int k){
    Int res=1;
    for(Int i=0;i<k;i++){
      res*=(n-i)%MOD;
      res%=MOD;
      res*=inverse(i+1);
      res%=MOD;
    }
    return res;
  }
  
  //only for prime MOD
  Int C(Int n,Int k){
    if(k<0||k>n) return 0;
    return fact[n]*finv[k]%MOD*finv[n-k]%MOD;
  }

  Int H(Int n,Int k){
    return C(n+k-1,n);
  }

  Int S(Int n,Int k){
    Int res=0;
    for(Int i=1;i<=k;i++){
      Int tmp=C(k,i)*pow(i,n)%MOD;
      if((k-i)&1) res+=MOD-tmp;
      else res+=tmp;
      res%=MOD;
    }
    res=res*finv[k]%MOD;
    return res;
  }
  
  Int B(Int n,Int k){
    Int res=0;
    for(Int j=1;j<=k;j++){
      res+=S(n,j);
      res%=MOD;
    }
    return res;
  }
  
  Int montmort(Int n){
    Int res=0,rinv=1;
    for(Int k=2;k<=n;k++){
      rinv=rinv*inverse(k)%MOD;
      if(k%2) res+MOD-rinv;
      else res+=rinv;
      res%=MOD;
    }
    for(Int i=1;i<=n;i++) res=res*i%MOD;
    return res;
  }
  
  // calculate P(t) from given points in [0,N]
  Int LagrangePolynomial(vector<Int> &y,Int t){
    Int n=y.size()-1;
    init(n+1);
    Int num=1;
    for(Int i=0;i<=n;i++)
      num=num*((t-i)%MOD)%MOD;
    Int res=0;
    for(Int i=0;i<=n;i++){
      Int tmp=(y[i]*num%MOD)*inverse((t-i)%MOD)%MOD;
      tmp=tmp*finv[i]%MOD;
      tmp=tmp*finv[n-i]%MOD;
      if((n-i)&1) tmp=MOD-tmp;
      res=(res+tmp)%MOD;
    }
    return res;
  }
};

//INSERT ABOVE HERE
signed main(){
  const Int MOD = 1e9+7;
  Mod<MOD> mod(2e5);
  Int n,k;
  cin>>n>>k;
  cout<<(n<=k)<<endl;
  return 0;
}



Measured memory_bytes: 7468
#include <bits/stdc++.h>
using namespace std;
using str = string;
using ll = long long;
#define REP(i,n) for(int i=0; i<int(n); i++)
#define RREP(i,n) for(int i=int(n)-1; i>=0; i--)
#define FOR(i,f,t) for(int i=int(f); i<=int(t); i++)
#define RFOR(i,f,t) for(int i=int(f); i>=int(t); i--)
#define ALL(vec) (vec).begin(),(vec).end()
#define ASORT(vec) sort(ALL(vec))
#define DSORT(vec) sort(ALL(vec), greater<int>());
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define YES(ans) if(ans) cout<<"YES"<<endl; else cout<<"NO"<<endl;
#define Yes(ans) if(ans) cout<<"Yes"<<endl; else cout<<"No"<<endl;
#define yes(ans) if(ans) cout<<"yes"<<endl; else cout<<"no"<<endl;

int count(int n) {
    vector<int> data;
    for(int i=1; i*i<=n; i++) {
        if(n%i == 0) {
            data.push_back(i);
            if (n/i != i) data.push_back(n/i);
        }
    }
    return data.size();
}

int main() {
    int n, ans=0;
    cin >> n;
    vector<int> data(n);
    FOR(i, 1, n-1) data.at(i-1) = count(i);
    FOR(i, 1, n-1) ans += data.at(i-1);
    cout << ans << endl;
}


Measured memory_bytes: 7128
#include<bits/stdc++.h>
using namespace std;
int a,b;
int main(){
    cin>>a>>b;
    if(a>0) cout<<"Positive"<<endl;               
    else 
        if(b>=0) 
            cout<<"Zero";             
        else 
            if((a&1)^(b&1))
                cout<<"Positive"<<endl;  
            else 
                cout<<"Negative"<<endl;
    return 0;
}

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

using namespace std;

#define int long long
#define FOR(i, a, b) for(ll i = (a); i < (b); ++i)
#define FORR(i, a, b) for(ll i = (a); i > (b); --i)
#define REP(i, n) for(ll i = 0; i < (n); ++i)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOREACH(x, a) for(auto &(x) : (a))
#define VECCIN(x)                                                              \
    for(auto &youso_ : (x)) cin >> youso_
#define mp make_pair
#define bitcnt __builtin_popcount
#define SZ(x) ((ll)(x).size())
#define All(a) (a).begin(), (a).end()
template <typename T = long long> inline T IN() {
    T x;
    cin >> x;
    return (x);
}
inline void CIN() {}
template <class Head, class... Tail>
inline void CIN(Head &&head, Tail &&... tail) {
    cin >> head;
    CIN(move(tail)...);
}
#define CINT(...)                                                              \
    int __VA_ARGS__;                                                           \
    CIN(__VA_ARGS__)
#define LCIN(...)                                                              \
    ll __VA_ARGS__;                                                            \
    CIN(__VA_ARGS__)
#define SCIN(...)                                                              \
    string __VA_ARGS__;                                                        \
    CIN(__VA_ARGS__)
#define Yes(a) cout << (a ? "Yes" : "No") << "\n"
#define YES(a) cout << (a ? "YES" : "NO") << "\n"
#define Printv(v)                                                              \
    {                                                                          \
        FOREACH(x, v) { cout << x << " "; }                                    \
        cout << "\n";                                                          \
    }
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
    std::fill((T *)array, (T *)(array + N), val);
}

typedef long long ll;
typedef unsigned long long ul;
typedef vector<ll> VL;
typedef pair<ll, ll> PL;
typedef priority_queue<ll> PQ;
typedef priority_queue<ll, VL, greater<ll>> PQG;

const int INF = 1e9;
const int MOD = 1e9 + 7;
// const int MOD = 998244353;
const ll LINF = 1e18;
const ll dx[] = {1, -1, 0, 0};
const ll dy[] = {0, 0, 1, -1};

ll N;
ll A[300][300];
bool unuse[300][300];

signed main() {
    cin >> N;
    REP(i, N) REP(j, N) { cin >> A[i][j]; }
    REP(k, N) REP(i, N) REP(j, N) {
        if(A[i][j] > A[i][k] + A[k][j]) {
            cout << -1 << "\n";
            return 0;
        }
        if(A[i][j] == A[i][k] + A[k][j] && i != k && k != j) {
            unuse[i][j] = true;
        }
    }
    ll ans = 0;
    REP(i, N) FOR(j, i + 1, N) {
        if(!unuse[i][j]) {
            ans += A[i][j];
        }
    }
    cout << ans << "\n";
}

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

#define debug(var)  do{std::cout << __LINE__ << "> " << #var << ": ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }

using namespace std;
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

void Main() {
	int x, y; cin >> x >> y;
	ll res = 0;
	if (x == 1) {
		res += 300000;
	} else if (x == 2) {
		res += 200000;
	} else if (x == 3) {
		res += 100000;
	}
	if (y == 1) {
		res += 300000;
	} else if (y == 2) {
		res += 200000;
	} else if (y == 3) {
		res += 100000;
	}
	if (x == 1 && y == 1) {
		res += 400000;
	}
	cout << res << endl;
}

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


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

using namespace std;

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

    vector<int> r;

    if(n==0) cout << 0 << endl;
    for(long i=1; n != 0; i*=-2) {
        long t = abs((n % (i*(-2))) / i);
        r.push_back(t);
        n -= t * i;
    }
    while(!r.empty())
        cout << r.back(), r.pop_back();
    cout << endl;
}


Measured memory_bytes: 256
import itertools
import math
import string
import collections
from collections import Counter
from collections import deque
from operator import itemgetter
import sys
sys.setrecursionlimit(2*10**5)
INF = 2**60


def readints():
    return list(map(int, input().split()))


def nCr(n, r):
    return math.factorial(n)//(math.factorial(n-r)*math.factorial(r))


def has_duplicates2(seq):
    seen = []
    for item in seq:
        if not(item in seen):
            seen.append(item)
    return len(seq) != len(seen)


def divisor(n):
    divisor = []
    for i in range(1, n+1):
        if n % i == 0:
            divisor.append(i)
    return divisor


# coordinates
dx = [-1, -1, -1, 0, 0, 1, 1, 1]
dy = [-1, 0, 1, -1, 1, -1, 0, 1]
a, b, c = map(int, input().split())
if a > b:
    print(0)
    exit()
if a*c <= b:
    print(c)
else:
    print(math.floor(b/a))


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using pi = pair<int, int>;
const ll INF = 1LL << 60;

int main() {
	ll a, v, b, w, t;
	cin >> a >> v >> b >> w >> t;
	if (v <= w) {
		cout << "NO" << endl;
		return 0;
	}
	if (a < 0 || b < 0) {
		a += 1e9;
		b += 1e9;
	}
	long double dist = abs(a - b);
	long double run = v - w;
	if (ceil(dist/t) <= run) {
		cout << "YES" << endl;
		return 0;
	}
	else {
		cout << "NO" << endl;
		return 0;
	}
	return 0;
}



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

using namespace std;
const int INF = (int)1e9 + 7;
const double PI = acos(-1);

int main() {
    string s;
    cin >> s;
    long long n = s.size();
    long long ans = 0;
    map<char, int> cnt;
    for (int i = 0; i < n; ++i)
        cnt[s[i]]++;

    for (int i = 0; i < n; ++i) {
        ans -= cnt[s[i]];
        cnt[s[i]]--;
    }

    ans += (n * (n + 1)) / 2 + 1;
    cout << ans;

    return 0;
}

Measured memory_bytes: 640
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include<cmath>
#include<limits>
#define ll long long
#define ALL(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define int_INF 2147483647
#define pint_INF 2000000000
#define ll_INF 	9223372036854775807
#define MOD 1000000007
#define vi vector<int>
#define vvi vector<vector<int>>
#define vvll vector<vector<long long>>
#define vvc vector<vector<char>>
#define vll vector<long long>
#define pii pair<int,int>
#define vpii vector<pair<int,int>>
#define sysp system("PAUSE")
#define pno cout << "no" << endl
#define pyes cout << "yes" << endl
#define pYes cout << "Yes" << endl
#define pNo cout << "No" << endl
using namespace std;


class LargeNumber {
private:
	bool is_prime[300000 + 13];// Up to 3e5 + 1
	vector<long long> Prime_table;
public:
	vector<long long> Eratosthenes(const long long N = 300007) { // return primes up to N
		for (int i = 0; i <= N; i++)
		{
			is_prime[i] = true;
		}
		for (int i = 2; i <= N; i++)
		{
			if (is_prime[i])
			{
				for (int j = 2 * i; j <= N; j += i)
				{
					is_prime[j] = false;
				}
				Prime_table.emplace_back(i);
			}
		}
		return Prime_table;
	}

	template<typename T>
	map<T, T> mFactorization(T N) const {
		map<T, T> mp;
		if (N == 1) {
			return mp;
		}

		for (int i = 0; i < Prime_table.size(); i++) {
			while (N % Prime_table[i] == 0) {
				mp[Prime_table[i]]++;
				N /= Prime_table[i];
			}
		}

		if (N > 1) mp[N]++;

		return mp;
	}

	bool isPrime(long long x) {
		if (x == 0 || x == 1) {
			return false;
		}
		return is_prime[x];
	}

	template<typename T>
	map<T, T> solve(T N, map<int, int>& mp) {
		if (N == 1) {
			return mp;
		}

		for (int i = 0; i < Prime_table.size(); i++) {
			while (N % Prime_table[i] == 0) {
				mp[Prime_table[i]]++;
				N /= Prime_table[i];
			}
		}

		if (N > 1) mp[N]++;

		return mp;
	}
};

template<typename T>
T modpow(T x, T n) {
	T res = 1;
	for (int i = 0; i < n; i++) {
		res *= x;
		res %= MOD;
	}
	return res;
}
int main() {
	LargeNumber Lg;
	const int M = 1005;
	Lg.Eratosthenes(M);
	map<int, int> mp_master;
	int N; cin >> N;
	for (int i = 1; i <= N; i++) {
		Lg.solve(i,mp_master);
	}
	ll ans = 1;
	for (auto iter = mp_master.begin(); iter != mp_master.end(); iter++) {
		ans *= (iter->second + 1);
		ans %= MOD;
	}

	cout << ans << endl;
}

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

int N, K;

int main() {
    cout << fixed << setprecision(10);

    cin >> N >> K;
    vector<double> Ep(N);

    for (int i = 0; i < N; i++) {
        double pi;
        cin >> pi;
        Ep[i] = (pi+1)/2;
    }

    vector<double> sum_Ep(N+1);
    sum_Ep[0] = 0;
    for (int i = 0; i < N; i++) {
        sum_Ep[i+1] = sum_Ep[i] + Ep[i];
    }

    double ans = -1;
    for (int i = 0; i+K < N+1; i++) {
        ans = max(ans, sum_Ep[i+K] - sum_Ep[i]);
    }

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

Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
const ll MOD = 1000000007;
const ll nmax = 8;
const ll INF = 1e9;
bool graph[nmax][nmax];
vector<vector<ll>> dist = vector<vector<ll>>(nmax, vector<ll>(nmax, INF));
void warshall_floyd(ll n)
{
    for (size_t i = 0; i < n; i++)
    {
        for (size_t j = 0; j < n; j++)
        {
            for (size_t k = 0; k < n; k++)
            {
                dist[j][k] = min(dist[j][k], dist[j][i] + dist[i][k]);
            }
        }
    }
}

class UnionFind
{
public:
    vector<ll> Parent;

    UnionFind(ll N)
    {
        Parent = vector<ll>(N, -1);
    }
    ll find(ll A)
    {
        if (Parent[A] < 0)
            return A;
        return Parent[A] = find(Parent[A]);
    }

    ll size(ll A)
    {
        return -Parent[find(A)];
    }

    bool Union(ll A, ll B)
    {
        A = find(A);
        B = find(B);
        if (A == B)
        {
            return false;
        }
        if (size(A) < size(B))
            swap(A, B);

        Parent[A] += Parent[B];
        Parent[B] = A;

        return true;
    }
};

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

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

ll mulMod(ll a, ll b)
{
    return (((a % MOD) * (b % MOD)) % MOD);
}

ll powMod(ll a, ll p)
{
    if (p == 0)
    {
        return 1;
    }
    else if (p % 2 == 0)
    {
        ll half = powMod(a, p / 2);
        return mulMod(half, half);
    }
    else
    {
        return mulMod(powMod(a, p - 1), a);
    }
}
std::vector<ll> enum_div(ll n) //nの約数を列挙
{
    std::vector<ll> ret;
    for (ll i = 1; i * i <= n; ++i)
    {
        if (n % i == 0)
        {
            ret.push_back(i);
            if (i != 1 && i * i != n)
            {
                ret.push_back(n / i);
            }
        }
    }
    return ret;
}
void solve(long long N)
{
    vector<ll> enum_d = enum_div(N);
    ll ans = 0;
    for (auto &&i : enum_d)
    {
        if (((N - i) % i) == 0)
        {
            if (((N - i) / i) > i)
            {
                ans += ((N - i) / i);
            }
        }
    }
    cout << ans << endl;
}

// Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main()
{
    long long N;
    scanf("%lld", &N);
    solve(N);
    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <stdlib.h>
#include <string.h>
#include <math.h>
int downint(const void *a, const void *b) { return *(int *)a < *(int *)b ? 1 : *(int *)a > *(int *)b ? -1 : 0; }

int main() {

    long long int N,K,C;
    scanf("%lld %lld %lld",&N,&K,&C);
    long long int saisou[K];
    char S[N];

    long long int saioso[K];
    saisou[0] = 0;
    saioso[0] = 0;

    scanf("%s",S);

    long long int sub = 0;
    for(int i = 0; i < N; ++i){
        if(S[i] == 'o'){
            saisou[sub] = i;
            sub ++;
            i += C;
        }
        if(sub == K) {
            break;
        }
    }
    sub = K-1;

    for(int i = N-1; i >= 0; --i){
        if(S[i] == 'o'){
            saioso[sub] = i;
            sub --;
            i -= C;
        }
        if(sub == -1)break;
    }


    for(int i = 0; i <= K-1; ++i){
        if(saisou[i] == saioso[i]) {
            printf("%lld\n", saisou[i]+1);
        }
    }
    return 0;

}

int A(){
    int A,B,C;
    scanf("%d %d %d",&A,&B,&C);
    printf("%d %d %d",C,A,B);
    return 0;
}

int B(){
    int M, N;
    scanf("%d %d", &N, &M);
    int A[N];
    int SUM = 0;
    for (int i = 0; i < N; ++i) {
        scanf("%d", &A[i]);
        SUM += A[i];
    }
    qsort(A, sizeof(A) / sizeof(A[0]), sizeof(int), downint);

    if (A[M-1] >= 1.0*SUM / (4 * M)) {
        printf("Yes");
        return 0;
    } else {
        printf("No");
        return 0;
    }
}

int C(){
    long long int N,K;
    scanf("%lld %lld",&N,&K);
    if(N%K >= K-N%K){
        printf("%lld",K-N%K);
    }
    else{
        printf("%lld",N%K);
    }
    return 0;
}

int D(){
    long long int K;
    scanf("%lld",&K);
    long long int A[400000];
    for(long long int i = 0; i <= 9; ++i){
        A[i] = i;
    }
    long long int s = 10;


    for(long long int i = 1;i <= K; ++i){
        if(A[i] % 10 != 0) {
            A[s] = A[i] * 10 + (A[i] % 10) - 1;
            s++;
        }
        A[s] = A[i] * 10 + (A[i]%10);
        s++;
        if(A[i] % 10 != 9){
            A[s] = A[i] * 10 + (A[i]%10) + 1;
            s++;
        }
    }
    printf("%lld",A[K]);
    return 0;
}

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

void selectsort(int a[], int n)
{
    int i,j;
    int k=n+1;
    int min;
    for(i=0;i<n;++i)
    {
      min=a[i];//暫定最小値
      k=i;
      for(j=i+1; j<n;++j)
      {
        if(a[j]<min)//最小値走査
        {
          min=a[j];
          k=j;
        }
      }
      if(a[i]>min)//2つの要素を交換
      {
        min = a[k];
        a[k]=a[i];
        a[i]=min;
      }
    }
}

int main()
{
  int N,i;
  int *c;
  scanf("%d",&N);
  if ((c=(int *)malloc((N)*sizeof(int))) != NULL){
    for(i=0; i<N; ++i){
      scanf("%d",&c[i]);
    }
  }
  selectsort(c,N);

  int a=0; int b=0;
  for(i=N-1; i>0; i-=2){
    a+=c[i];  b+=c[i-1];
  }
  if(i==0)  a+=c[i];
  printf("%d\n",a-b);
  return 0;
}

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

int main(void) {
	long long H;
	scanf("%lld", &H);
	long long ans = 0;
	long long monsterNum = 1;
	while (H > 0) {
		if (H == 1) {
			ans += monsterNum;
			H = 0;
		} else {
			ans += monsterNum;
			H /= 2;
			monsterNum *= 2;
		}
	}
	printf("%lld\n", ans);

	return 0;
}


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

#define loop(n, i) for(int i=0;i<n;i++)
#define all(v) v.begin(),v.end()
#define HERE cout << "HERE: " << __LINE__ << endl;
#define INSP(v) cout << v << " at " << __LINE__ << endl;

using namespace std;
typedef long long ll;


int main()
{
    int M, T, P, R;
    while (cin >> M >> T >> P >> R, M) {
        vector<vector<int>> result(T, vector<int>(3+P,0));
        loop(T,i) result[i][0] = i+1;
        loop(R,i) {
             int m, t, p, j;
             cin >> m >> t >> p >> j;
             if (j) {
                 if (result[t-1][p+2] != -1) result[t-1][p+2]++;
             } else {
                 if (result[t-1][p+2] != -1) {
                     result[t-1][1]++;
                     result[t-1][2] += result[t-1][p+2]*20 + m;
                     result[t-1][p+2] = -1;
                 }
             }
        }
        
        sort(all(result),
                [](vector<int> a, vector<int> b) {
                    if(a[1] != b[1]) return a[1] > b[1];
                    if(a[2] != b[2]) return a[2] < b[2];
                    return a[0] > b[0];
                });
            
        loop(T,i) {
            cout << result[i][0];
            if (i==T-1) {
                cout << endl;
            } else if (result[i][1] == result[i+1][1]
                    && result[i][2] == result[i+1][2])
                cout << '=';
            else cout << ',';
        }
    }
}

Measured memory_bytes: 3148
#include<iostream>
#include<vector>
using namespace std;
typedef long long ll;
 /// first: primo   second: exponente
 vector<pair<ll,ll> >Canon;
 int Gau[50];
void Prec(){
 int i;
 for(i=1;i<50;i++){
  Gau[i]=Gau[i-1]+i;
 }
 return;
}
int main(){
 ll N,Aux;
 cin>>N;
 ll i,j;
 Aux=N;
 if(Aux%2==0){
  Aux/=2;
  Canon.push_back({2,1});
   while(Aux%2==0){
    Aux/=2;
    Canon[Canon.size()-1].second+=1;
   }
 }
 if(Aux%3==0){
  Aux/=3;
  Canon.push_back({3,1});
   while(Aux%3==0){
    Aux/=3;
    Canon[Canon.size()-1].second+=1;
   }
 }
 if(Aux%5==0){
  Aux/=5;
  Canon.push_back({5,1});
   while(Aux%5==0){
    Aux/=5;
    Canon[Canon.size()-1].second+=1;
   }
 }
 for(i=6;i*i<=Aux;i+=6){
  if(Aux%(i+1)==0){
   Aux/=(i+1);
   Canon.push_back({i+1,1});
     while(Aux%(i+1)==0){
      Aux/=(i+1);
      Canon[Canon.size()-1].second+=1;
     }
  }
  if(Aux%(i+5)==0){
    Aux/=(i+5);
    Canon.push_back({i+5,1});
      while(Aux%(i+5)==0){
       Aux/=(i+5);
       Canon[Canon.size()-1].second+=1;
      }
  }
 }
 if(Aux>1)Canon.push_back({Aux,1});
 Prec();
 int Ans=0;
 for(i=0;i<Canon.size();i++){
  j=1;
   while(Canon[i].second>=Gau[j])j+=1;
   Ans+=j-1;
 }
 cout<<Ans;
}


Measured memory_bytes: 3192
#include <iostream>
#include <utility>
#include <vector>
#include <algorithm>
using namespace std;
int N,P;
int ans[10000];
int prime[1000000];
int prime_set[101];
void calc_prime(){
    prime[0] = 1;
    prime[1] = 1;
    for(int i=2;i<1000;i++){
        if(prime[i] == 0){
            for (int j=i*i;j<1000000;j+=i){
                prime[j] = 1;
            }

        }
    }

}


int main(){

    calc_prime();
    
    while(1){
        cin >>N >>P;

        if (N==-1&&P==-1)break;
        int cnt = 0;
        int i=N+1;
        while(cnt < P){
            if(prime[i] == 0){
                prime_set[cnt] = i;
                cnt++;

            }
            i++;
        }
        
        cnt=0;
        for(int i=0;i<P;i++){
            for(int j=i;j<P;j++){
                ans[cnt]=prime_set[i]+prime_set[j];
                cnt++;
            }
        }


        
        sort(ans,ans+cnt);
        //cout << prime_set[100] <<endl;
        cout << ans[P-1] <<endl;
    }
}


Measured memory_bytes: 6980
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
using namespace std;
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const int MOD2 = 998244353;


int main(){
    string s;
    cin >> s;
    bool flag = false;
    int n = s.size();
    rep(i, n - 1){
        for (int j = i; j < n; j++){
            string tmp = s.substr(0, i) + s.substr(j,n - j);
            if (tmp == "keyence") flag = true;
        }
    }
    if (flag) cout << "YES" << endl;
    else cout << "NO" << endl;

    return 0;
}


Measured memory_bytes: 256
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv, std.math,
    std.functional, std.numeric, std.range, std.stdio, std.string, std.random,
    std.typecons, std.container, std.format;

// dfmt off
T lread(T = long)(){return readln.chomp.to!T();}
T[] lreads(T = long)(long n){return generate(()=>readln.chomp.to!T()).take(n).array();}
T[] aryread(T = long)(){return readln.split.to!(T[])();}
void scan(TList...)(ref TList Args){auto line = readln.split();
foreach (i, T; TList){T val = line[i].to!(T);Args[i] = val;}}
alias sread = () => readln.chomp();enum MOD = 10 ^^ 9 + 7;
alias PQueue(T, alias less = "a<b") = BinaryHeap!(Array!T, less);
// dfmt on

void main()
{
    long N = lread();
    auto A = aryread();
    auto sum = new long[](N + 1);
    foreach (i; 0 .. N)
    {
        sum[i + 1] = sum[i] + A[i];
    }
    long ans = long.max;
    foreach (i; 1 .. N)
    {
        long tmp = abs(sum[i] - (sum[$ - 1] - sum[i]));
        ans = ans.min(tmp);
    }
    writeln(ans);
}


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

long long int GR[8200][21];

int main() {

  for ( long long int i = 0; i < 21; i++ ) {
    GR[1][i] = 0;
  }

  long long int n, S, input;

  while( true ) {

    cin >> n;

    if ( n == 0 ) break;

    cin >> S;

    vector< long long int > m;

    for ( long long int i = 0; i < n * 2; i++ ) {

      cin >> input;

      m.push_back( input );

    }

    for ( long long int i = 2; i <= S; i++ ) {

      for ( long long int j = 0; j < n * 2; j++ ) {

	bool flag[17] = {};

	for ( long long int k = max( 1LL, i - m[j] ); k < i; k++ ) {

	  flag[ GR[k][(j+1)%(n*2)] ] = true;

	}

	int cnt = 0;
	while( flag[cnt] ) {cnt++;}
	GR[i][j] = cnt;

      }

    }

    cout << ( GR[S][0] == 0 ? "0" : "1" ) << endl;

  }

  return 0;

}

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

struct TIME {
	int time;
	int start;
	bool operator<(const TIME &t) const{
		if( time == t.time ){
			return start<t.start;
		}
		return time<t.time;
	}
};

int main() {
	while(true){
		
		vector<TIME> times;
		
		int n;
		cin >> n;
		if(n==0)break;
		
		for(int i=0;i<n;i++){
			int h,m,s;
			char c;
			cin >> h >> c >> m >> c >> s;
//			cout << h <<":"<<m<<":"<<s <<endl; 
			TIME t0={h*60*60+m*60+s,1};
			times.push_back(t0);

			cin >> h >> c >> m >> c >> s;
//			cout << h <<":"<<m<<":"<<s<<endl; 
			TIME t1={h*60*60+m*60+s,0};
			times.push_back(t1);
		}

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

		int count=0;
		int ans=0;
		for(TIME &t : times){
//			cout << t.start << " " << t.time << endl;;
			if(t.start==1){
				count++;
				ans=max(count,ans);
			}else{
				count--;
			}
		}
		cout << ans << endl;
	}
	
	
	return 0;
}

Measured memory_bytes: 1596
#include <iostream>
using namespace std;
 
int main() {
    int N , Y;
    cin >> N >> Y;
  	int ans = -1;
  	int ans2 = -1;
  	int ans3 = -1;
    for (int i = 0; i <= N; ++i){
      for(int j = 0; i + j <= N; ++j){
        int k = N - i - j;
          if(i + j + k == N && 10000 * i + 5000 * j + 1000 * k == Y){
            ans = i;
            ans2 = j;
            ans3 = k;
          }
      }
    }
 
    cout << ans << " " <<  ans2 << " " << ans3 << endl;
}

Measured memory_bytes: 256
/******tech_knight18_@11******/
/*I'm_not_the_only_traveller*/
/*who_has_not_repaid_his_debt*/
/*Take_me_back_to_The_Night_We_Met*/
#include<bits/stdc++.h>
using namespace std;
#define lld               long long int
#define ld                long double
#define pb                push_back
#define ppb               pop_back
#define mp                make_pair
#define F                 first
#define S                 second
#define nl                '\n'
#define all(c)            (c).begin(),(c).end()
#define rall(c)           (c).rbegin(),(c).rend()
#define sz(c)             (c).size()
#define tr(x,a)           for(auto &a : x)
#define psnt(x,a)         (x).find(a)!=(x).end()
#define vpsnt(x,a)        find(all(x),a)!=(x).end()
#define lexichar(x,y)     lexicographical_compare(x,x+strlen(x),y,y+strlen(y)) //modify the ranges
#define lexistr(x,y)      lexicographical_compare(x.begin(),x.end(),y.begin(),y.end()) 
#define MOD               1000000007
#define pi                3.1415926536
#define tod               1
#define itr(i,a,b)        for(lld i=a;i<=b;i++)
#define itrn(i,a,b)       for(lld i=a;i>=b;i--)
#define iot(n)            for(lld i=0;i<n;i++)
#define pls(n,arr)        lld arr[n]; iot(n)  cin>>arr[i];
#define bye               fflush(stdout)

typedef pair<lld,lld>     pii;
typedef pair<string,lld>  psi;
template <typename T>
bool mycomp(T x,T y){ 
   return (x==y);  //give your condition here
}
bool paircomp(const pair<lld,lld> &x,const pair<lld,lld> &y){ 
return x.second<y.second;
}

int main(){
       ios_base::sync_with_stdio(false);
             cin.tie(0);
            cout.tie(0);
      lld t=1; //cin>>t;  
      while(t--){
          lld n; cin>>n;
          pls(n,a);
          lld cnt=0;
          for(lld i=0;i<=n-1;i+=2) if(a[i]%2)  cnt++;
          cout<<cnt<<nl;
      }
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using ull = long long unsigned;
using P = pair<int,int>;
const int INF=1001001;
int main(){
  ull h,w;
  cin>>h>>w;
  ull ans;
  if (h==1 or w==1){
    cout<<1;
    return 0;
  }
  if (h%2==0){
    ans=(h/2)*w;
  }
  else{
    
    if (w%2==0){
      ans=(w/2)*h;
    }
    else {
      ans=h*(w-1)/2+(h+1)/2;
    }
  }
  cout<<ans;
}


Measured memory_bytes: 256
n, q = map(int, input().split())
names = []
times = []
now = 0
count = 1

for i in range(n):
    name, time = input().split()
    names.append(name)
    times.append(int(time))

idx = 0
while True:
#    print('\n# count: ' + str(count))
    if (len(names) == 0):
        break

    if q < times[idx]:
        times[idx] = times[idx] - q
        now += q
        idx += 1
    else:
        now += times[idx]
        print(names[idx] + ' ' + str(now))
        del names[idx]
        del times[idx]
#        continue
    if idx == len(names):
        idx = 0

    count += 1




Measured memory_bytes: 9304
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define rrep(i, n) for (int i = (int)n-1; i >= 0; --i)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;

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

__attribute__ ((constructor))
void fastio() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(10);
}

int main(){
    int n, m;
    cin >> n >> m;
    vector<vector<int>> dis(n, vector<int>(n, inf));
    vector<int> to[n];
    map<pair<int, int>, int> mii;
    rep(i,m){
        int a,b,c;
        cin >> a >> b >> c;
        a--;
        b--;
        mii[{a, b}] = c;
        mii[{b, a}] = c;
        dis[b][a] = c;
        dis[a][b] = c;
    }
    rep(k,n){
        rep(i,n){
            rep(j,n){
                chmin(dis[i][j],dis[i][k]+dis[k][j]);
                if(i == j)
                    dis[i][j] = 0;
            }
        }
    }
    int cnt = 0;
    for(auto u : mii){
        bool ok = 0;
        rep(i,n){
            rep(j,n){
                if(dis[i][j] == dis[i][u.first.first] + u.second + dis[u.first.second][j] ){
                    // cout << "use" << endl;
                    ok = 1;
                }
            }
        }
        // cout << ok << endl;
        if(!ok)
            cnt++;
    }
    cout << cnt/2 << endl;
    return 0;
}

Measured memory_bytes: 3748
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int H,W;
  cin >> H >> W;
  vector<string> S(110),T(110);
  for(int i=0;i<H;i++)cin >> S[i];
  for(int i=0;i<H;i++)T[i]="";
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      if(S[i][j]=='#'){T[i]+='#';}
      else{
        int cnt=0;
        if(i>0 && S[i-1][j]=='#')cnt++;
        if(i<H-1 && S[i+1][j]=='#')cnt++;
        if(j>0 && S[i][j-1]=='#')cnt++;
        if(j<W-1 && S[i][j+1]=='#')cnt++;
        if(i>0 && j>0 && S[i-1][j-1]=='#')cnt++;
        if(i>0 && j<W-1 && S[i-1][j+1]=='#')cnt++;
        if(i<H-1 && j>0 && S[i+1][j-1]=='#')cnt++;
        if(i<H-1 && j<W-1 && S[i+1][j+1]=='#')cnt++;
        string count=to_string(cnt);
        T[i]+=count;
      }
    }
  }
  for(int i=0;i<H;i++)cout << T[i] << endl;
}

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


int main() {
  int n,i,j,k,ac=0,wa=0,tle=0,re=0;
  cin >> n;
  rep(i,n){
    string s;
    cin >> s;
    switch(s.at(0)){
      case 'A':
        ac++;break;
        case 'W':
        wa++;break;
        case 'T':
        tle++;break;
        case 'R':
        re++;break;
    }
  }
  cout << "AC x " << ac << endl;
  cout << "WA x " << wa << endl;
  cout << "TLE x " << tle << endl;
  cout << "RE x " << re << endl;
}


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

int main() {
    int in[3];
    int cost[3] = {0};
    int min;
    scanf("%d %d %d", &in[0], &in[1], &in[2]);

    cost[0] = abs(in[0] - in[1]) + abs(in[1] - in[2]);
    cost[1] = abs(in[0] - in[2]) + abs(in[2] - in[1]);
    cost[2] = abs(in[2] - in[0]) + abs(in[0] - in[1]);

    min = cost[0];

    for(int i = 1; i < 3; i++) {
        if(min > cost[i]) min = cost[i];
    }

    printf("%d\n", min);
}

Measured memory_bytes: 128