akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>
#define pb push_back
using namespace std;
typedef long long int lli;
lli abs1(lli a,lli b){
  if(a>b) return a-b;
  else return b-a;

}

int main(void){
  int n,i;
  vector<lli> a;
  lli t,sum;
  cin>>n;
  sum=0;
  for(i=0;i<n;i++){
    cin>>t;
    a.pb(t);
    sum+=t;
  }
  lli b,res;
  b=a[0];
  res=abs1(b,sum-b);
  for(i=1;i<n-1;i++){
    b+=a[i];
    if(res>abs1(b,sum-b)) res=abs1(b,sum-b);
  }
  cout<<res<<endl;
  return 0;
}

Measured memory_bytes: 2420
s = ""
L = []
M = []
n = 0
h = 0
output = ""
while True:
    s=input()
    if s=="-":
        break
    elif s.isalpha():
        L = list(s)
        M = ["" for i in range(len(L))]
        n = int(input())
        for i in range(n):
            h = int(input())
            for j in range(len(L)-h):
                M[j]=L[j+h]
            for j in range(h):
                M[j+len(L)-h]=L[j]
            for j in range(len(L)):
                L[j] = M[j]
        output = ""
        for i in L:
            output += i
        print(output)


Measured memory_bytes: 5604
#define _USE_MATH_DEFINES
#define INF 0x3f3f3f3f

#include <iostream>
#include <cstdio>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>
#include <cctype>
#include <utility>
  
using namespace std;
  
typedef long long ll;
typedef pair <int,int> P;
typedef pair <int,P> PP;
  
static const double EPS = 1e-8;
  
static const int tx[] = {0,1,0,-1};
static const int ty[] = {-1,0,1,0};


int main(){
  int signal_num,code_num;
  while(~scanf("%d %d",&signal_num,&code_num)){
    if(signal_num == 0 && code_num == 0) break;

    int code[16];
    for(int i=0;i<code_num;i++){
      scanf("%d",code+i);
    }
    int input_signal[20000];
    for(int i=0;i<signal_num;i++){
      scanf("%d",input_signal+i);
    }

    int prev[256],next[256];
    memset(prev,0x3f,sizeof(prev));
    memset(next,0x3f,sizeof(next));

    prev[128] = 0;
    for(int step=0;step<signal_num;step++){
      for(int from = 0; from < 256;from++){
	for(int code_idx=0;code_idx<code_num;code_idx++){
	  int to = from + code[code_idx];
	  if(to < 0) to = 0;
	  if(to >= 256) to = 255;

	  next[to] = min(next[to],
			 prev[from] 
			 + (to - input_signal[step]) * (to - input_signal[step]));
	  
	}
      }
      memcpy(prev,next,sizeof(int)*256);
      memset(next,0x3f,sizeof(next));
    }

    int min_v = INF;
    for(int i=0;i<256;i++){
      min_v = min(min_v,prev[i]);
    }
    printf("%d\n",min_v);
  }
}

Measured memory_bytes: 1268
#b.py
n = int(input())
lis = [list(input().split())+[x] for x in range(n)]
lis = sorted(lis,key=lambda x:x[0])
now = lis[0][0]
ans_lis = []
sublis = []
for x in lis:
    if x[0] == now:
        sublis.append(x)
    else:
        now = x[0]
        sublis = sorted(sublis,key=lambda x:int(x[1]),reverse=True)
        ans_lis.append(sublis)
        sublis = []
        sublis.append(x)
sublis.sort(key=lambda x:int(x[1]),reverse=True)
ans_lis.append(sublis)
sublis = []
sublis.append(x)       
ans_lis = [item for sublist in ans_lis for item in sublist]
for x in ans_lis:
    print(x[2]+1)



Measured memory_bytes: 3064
#include<cstdio>

int main(void){
	int p,r;
	scanf("%d",&p);
	while(p!=-1){while(1){
if(p<=20){
r=1150;
if(p>=10)r+=(p-10)*125;
break;
}
if(p<=30){
r=2400;
r+=(p-20)*140;
break;
}
r=3800;
r+=(p-30)*160;
break;
}
	printf("%d\n",4280-r);
	scanf("%d",&p);
}
return 0;
}

Measured memory_bytes: 1028
import java.util.Scanner;

public class Main{

	public static void main(String[] args){
		new Main().solve();
	}
	
	void solve(){
		Scanner sc=new Scanner(System.in);
		int N=sc.nextInt();
		int[]a=new int[N+1];
		for(int i=0;i<N;i++){
			a[i+1]=sc.nextInt();
		}
		
		int count=0;
		int now=1;
		while(count<N && now!=2){
			now=a[now];
			count++;
		}
		
		if(now==2)System.out.println(count);
		else System.out.println(-1);
	}
	
}

Measured memory_bytes: 50988
#include <queue>
#include <algorithm>
#include <assert.h>
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <ctime>
#include <unordered_set>
#include <unordered_map>
#include <iomanip>
#include <chrono>
#include <random>

using namespace std;

using ll = long long;

const int N = 1002;
vector<int> g[N];
vector<int> used;
vector<int> mt;

bool dfs(int v) {
    if (used[v]) return false;
    used[v] = true;
    for (int to : g[v]) {
        if (mt[to] == -1 || dfs(mt[to])) {
            mt[to] = v;
            return true;
        }
    }
    return false;
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    int n;
    cin >> n;
    vector<pair<int, int>> a(n), b(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i].first >> a[i].second;
    }
    for (int i = 0; i < n; ++i) {
        cin >> b[i].first >> b[i].second;
    }
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < n; ++j) {
            if (a[i].first < b[j].first && a[i].second < b[j].second) {
                g[i].push_back(j);
            }
        }
    }
    mt.resize(n, -1);
    for (int i = 0; i < n; ++i) {
        used.assign(n, false);
        dfs(i);
    }
    int res = 0;
    for (int i = 0; i < n; ++i) {
        if (mt[i] != -1) ++res;
    }
    cout << res << '\n';
}





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

# N!を(10^9+7)で割った余りを求める
# N!そのものを求める必要はなく、
# x = i*x (mod 10^9+7) と更新していけばよい
M = 10**9 + 7
s = 1
for i in range(1, N+1):
  s *= i
  s %= M
  
print(s)

Measured memory_bytes: 9132
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long n;
    cin>>n;long long mx=0;
    map<string,long long> mp;
    for(long i=0;i<n;i++)
    {
        string s;
        cin>>s;
        mp[s]+=1;
        if(mp[s]>mx)
        {
            mx=mp[s];
        }
    }
    vector<string> v;
    for(auto x:mp)
    {
        if(x.second>=mx)
        {
            v.push_back(x.first);
        }
    }
    sort(v.begin(),v.end());
    for(long i=0;i<v.size();i++)
    {
        cout<<v[i]<<"\n";
    }
}

Measured memory_bytes: 27228
#include<iostream>
#include<cmath>
#include<numeric>
#include<functional>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<iomanip>
#include<queue>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<n;i++)
#define ll long long
#define INF 2147483647
using namespace std;
using Graph=vector<vector<int>>;

int main(){
  int n,k,s; cin>>n>>k>>s;
  int ans[n];
  if(1){
    rep(i,n){
      if(1000000000%s!=0){
        ans[i]=1000000000;
      }else{
        ans[i]=999999999;
      }
    }
    rep(i,k){
      ans[i]=s;
    }
    rep(i,n){
      cout<<ans[i]<<" ";
    }
  }
}


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

typedef long long ll;
const ll MOD=1e9+7;
ll N;

ll powered(ll a, ll b){
	if(b==0)return 1;
	if(b==1)return a;
	if(b==2)return a*a;
	if(b%2==0){
		ll curr=powered(a,b/2);
		return curr*curr%MOD;
	}else{
		ll curr=powered(a,b/2);
		return (curr*curr%MOD)*a%MOD;
	}
}

ll sub(ll a, ll b){
	return (a+MOD-b)%MOD;
}

void Input(){
	cin>>N;
}

void Solve(){
	ll firsttype=(powered(9,N)%MOD)*2%MOD;
	ll secondtype=powered(8,N);
	cout<<sub(powered(10,N),sub(firsttype,secondtype))<<'\n';
}

int main(){
	Input();
	Solve();
}

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

const int N = 100010;
int cnt[N];

int main() {
  int n, a, ans = 0;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &a);
    if ( a >= N ) ans++;
    else cnt[a]++;
  }
  for (int i = 0; i < N; i++) {
    if ( cnt[i] >= i ) ans += cnt[i] - i;
    else ans += cnt[i];
  }
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<map>
#include<vector>
#include<queue>
#include<stack>
using namespace std;
typedef long long LL;
#define ms(a,b) memset(a,b,sizeof(a))
# define eps 1e-8
 
int A[100005];
int B[100005];
int C[100005];
LL D[100005];
int main()
{
    int N;
    cin>>N;
    A[0]=B[0]=C[0]=D[N+1]=0;
    for(int i=1;i<=N;i++) cin>>A[i];
    for(int i=1;i<=N;i++) cin>>B[i];
    B[N+1]=B[N]+1;
    for(int i=1;i<=N;i++) cin>>C[i];
    C[N+1]=C[N]+1;
    sort(A+1,A+N+1);
    sort(B+1,B+N+1);
    sort(C+1,C+N+1);
    LL ans=0;
    for(int i=N;i>=1;i--){
            D[i]=N+1-(upper_bound(C,C+N+1,B[i])-C);
            if(i<N) D[i]+=D[i+1];
    }
 
    /*for(int i=1;i<=N;i++) cout<<D[i]<<" ";
    cout<<endl;
    for(int i=1;i<=N;i++) cout<<D[i]<<" ";
    cout<<endl;
*/
    for(int i=1;i<=N;i++){
            int j=(upper_bound(B,B+N+1,A[i])-B);
            ans+=D[j];
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 2176
dic={}
n=int(input())
for i in range(n):
  s=input()
  s=''.join(sorted(str(s)))
  if(s in dic):              
    dic[s]+=1
  else:
    dic[s]=1

ans=0
for x in dic.values():
  ans+=int(x*(x-1)/2)
print(ans)
# print(dic)

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

using namespace std;

int main(){

	int n,m;
	while(cin>>n>>m&&!(n==0&&m==0)){
		int scores[1001];
		vector<int> comb;
		for(int i = 0; i < n; i++){
			cin>>scores[i];
		}
		scores[n]=0;
		for(int i = 0; i < n+1; i++){
			for(int j = 0; j < n+1; j++){
				int sum=scores[i]+scores[j];
				if(sum<=m)
					comb.push_back(sum);
			}
		}
		sort(comb.begin(),comb.end());
		int maxNum=0;
		for(int i = 0; i < n; i++){
			for(int j = 0; j < n; j++){
				int left = (scores[i]+scores[j]);
				if(left<=m&&comb[0]+left<=m){
					vector<int>::iterator it = lower_bound(comb.begin(),comb.end(),m-left);
					if(it==comb.end()){
						maxNum=max(maxNum,comb[comb.size()-1]+left);
					}
					else{
						if(*it==(m-left)){
							maxNum=m;
						}
						else{
							it--;
							maxNum=max(maxNum,*it+left);
						}
					}
				}
			}
		}
		cout<<maxNum<<endl;
	}

	return 0;
}

Measured memory_bytes: 4956
N = int(input())
A = list(map(int, input().split()))

cnt = 0
zero = 0
for i in range(N):
        if A[i]<0:
            cnt+=1
        if A[i]==0:
            zero+=1

B = list(map(abs, A))
if (N-zero)%2==0:
    if cnt%2==0:
        print(sum(B))
    else:
        print(sum(B)-2*min(B))
else:
    if cnt%2==0:
        print(sum(B))
    else:
        print(sum(B)-2*min(B))

Measured memory_bytes: 14468
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<functional>
#include<map>
#include<cstdlib>
#include<complex>
#include<numeric>
#include<set>
#include<deque>
#include<queue>

using namespace std;
using Int = long long;
Int INF = 1LL << 60;
const Int MOD = 1000000000 + 7;

vector<Int> h;
Int N, A, B;

bool isOK(Int x) {//x回の攻撃
	
	Int cnt=0;//(A-B)ダメージの回数
	Int temp;
	for (Int i = 0; i < N; i++) {
		temp = max(0LL, h[i] - x * B);
		if (temp==0) {
			continue;
		}
		else {
			temp = (temp + (A - B - 1)) / (A - B);
		}
		//temp = (h[i] - x * B + (A - B + 1)) / (A - B);
		cnt += temp;
	}

	return x >= cnt;
}

// 汎用的な二分探索のテンプレ
Int binary_search() {
	Int ng = -1; //「index = 0」が条件を満たすこともあるので、初期値は -1
	Int ok = 1e9; // 「index = a.size()-1」が条件を満たさないこともあるので、初期値は a.size()

	/* ok と ng のどちらが大きいかわからないことを考慮 */
	while (abs(ok - ng) > 1) {
		Int mid = (ok + ng) / 2;

		if (isOK(mid)) ok = mid;
		else ng = mid;
	}
	return ok;
}

int main() {

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

	cin >> N >> A >> B;

	h.resize(N);
	for (Int i = 0; i < N; i++) {
		cin >> h[i];
	}

	Int ans = binary_search();

	cout << ans << "\n";

}


Measured memory_bytes: 1024
import bisect,collections,copy,itertools,math,string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())
def main():
    n = I()
    lst = [None for _ in range(n)]

    for i in range(n-1,-1,-1):
        a,b = LI()
        lst[i] = [a,b]
    cumsum = 0
    for a,b in lst:
        a += cumsum
        add = (b-(a%b))%b
        cumsum += add

    ans = cumsum
    print(ans)
main()            


Measured memory_bytes: 84680
import sys
sys.setrecursionlimit(10 ** 7)
mod = 10 ** 9 + 7
n = int(input())
edges = [[] for i in range(n)]
for i in range(n - 1):
    a, b = map(int, input().split())
    edges[a - 1].append((b - 1, i))
    edges[b - 1].append((a - 1, i))
l = [0 for i in range(n)]
def dfs(cur, x):
    res = 1
    for i in edges[cur]:
        if i[1] != x:
            res += dfs(i[0], i[1])
    l[x] = res
    return res
dfs(0, -1)
l2 = [1]
i2 = pow(2, mod - 2, mod)
for i in range(n):
    l2.append(l2[-1] * i2 % mod)
cnt = 0
for i in l:
    cnt += (1 - l2[i]) * (1 - l2[n - i])
print((-n * i2 - l2[-1] + cnt + 1) % mod)

Measured memory_bytes: 202228
import math
p = [2]
s = 3
max = 50000

while p[len(p)-1] <= max:
    m = int(math.sqrt(s))
    r = True
    for i in p:
        if i > m:
            break
        if s % i == 0:
            r = False
            break
    if r:
        p.append(s)
    s += 2

while True:
    try:
        n = int(raw_input())
    except EOFError as e:
        break
    i = 0
    while p[i] < n:
        i += 1
    print("%d %d" % (p[i-1], p[i+1] if p[i] == n else p[i]))

Measured memory_bytes: 4504
import java.util.Scanner;

/**
 * AOJのVolume0の0095を解くクラス
 * @author たっちゃん
 *
 */
public class Main {
	/**
	 * mainメソッド。
	 * @param args 使用せず
	 */
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int minA = Integer.MAX_VALUE, maxV = Integer.MIN_VALUE;
		for(int i = 0; i < n; i++) {
			int a = scan.nextInt();
			int v = scan.nextInt();
			if(maxV < v) {
				minA = a;
				maxV = v;
			} else if(maxV == v) {
				minA = Integer.min(minA, a);
			}
		}
		System.out.println(minA + " " + maxV);
		scan.close();
	}

}




Measured memory_bytes: 26300
puts "1x1=1"
puts "1x2=2"
puts "1x3=3"
puts "1x4=4"
puts "1x5=5"
puts "1x6=6"
puts "1x7=7"
puts "1x8=8"
puts "1x9=9"
puts "2x1=2"
puts "2x2=4"
puts "2x3=6"
puts "2x4=8"
puts "2x5=10"
puts "2x6=12"
puts "2x7=14"
puts "2x8=16"
puts "2x9=18"
puts "3x1=3"
puts "3x2=6"
puts "3x3=9"
puts "3x4=12"
puts "3x5=15"
puts "3x6=18"
puts "3x7=21"
puts "3x8=24"
puts "3x9=27"
puts "4x1=4"
puts "4x2=8"
puts "4x3=12"
puts "4x4=16"
puts "4x5=20"
puts "4x6=24"
puts "4x7=28"
puts "4x8=32"
puts "4x9=36"
puts "5x1=5"
puts "5x2=10"
puts "5x3=15"
puts "5x4=20"
puts "5x5=25"
puts "5x6=30"
puts "5x7=35"
puts "5x8=40"
puts "5x9=45"
puts "6x1=6"
puts "6x2=12"
puts "6x3=18"
puts "6x4=24"
puts "6x5=30"
puts "6x6=36"
puts "6x7=42"
puts "6x8=48"
puts "6x9=54"
puts "7x1=7"
puts "7x2=14"
puts "7x3=21"
puts "7x4=28"
puts "7x5=35"
puts "7x6=42"
puts "7x7=49"
puts "7x8=56"
puts "7x9=63"
puts "8x1=8"
puts "8x2=16"
puts "8x3=24"
puts "8x4=32"
puts "8x5=40"
puts "8x6=48"
puts "8x7=56"
puts "8x8=64"
puts "8x9=72"
puts "9x1=9"
puts "9x2=18"
puts "9x3=27"
puts "9x4=36"
puts "9x5=45"
puts "9x6=54"
puts "9x7=63"
puts "9x8=72"
puts "9x9=81"

Measured memory_bytes: 6112
#include <bits/stdc++.h>
#define max(xx,yy) (xx > yy ? xx : yy)
#define min(xx,yy) (xx > yy ? yy : xx)
#define all(x) x.begin(), x.end()
using namespace std;

#ifdef LOCAL
	#define dbg(...) cout << "[ "  << #__VA_ARGS__ << " ] : "; debug(__VA_ARGS__); cout << endl;
#else
	#define dbg(...) (void)32 
#endif

template<typename... T> void debug(T... args){ ((cout << args << ", "), ...); };
template<class T> T input(){ T in; cin >> in; return in; }

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

	string s = input<string>();
	priority_queue<int> pq;
	
	int cur = 0;
	pq.push(0);
	for(char ch : s){
		if(ch == 'S'){
			pq.push(cur);
			cur = 0;
		} else {
			cur++;
		}
	}	
	pq.push(cur);
	cout << pq.top();
}


Measured memory_bytes: 3608
import itertools
 
n = int(input())
p = tuple(map(int,input().split()))
q = tuple(map(int,input().split()))
 
l = []
a, b,num = 0,0,0
 
for m in range(1,n+1):
	l.append(m)
 
for i in itertools.permutations(l):
	num += 1
	if i == p:
		a = num
	if i == q:
		b = num
print(abs(a-b))


Measured memory_bytes: 9188
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>
  
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
  
using namespace std;
  
typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;
  
const int INF=1<<29;
const double EPS=1e-9;
  
const int dx[]={1,0,-1,0,1,1,-1,-1},dy[]={0,-1,0,1,1,-1,-1,1};


int main() {
  int W, H, N;
  cin >> W >> H >> N;
  int sx = 0, sy = 0, tx = W, ty = H;
  for(int i = 0; i < N; i++) {
    int x, y, a;
    cin >> x >> y >> a;
    if (a == 1) {
      sx = max(sx, x);
    } else if (a == 2) {
      tx = min(tx, x);
    } else if (a == 3) {
      sy = max(sy, y);
    } else {
      ty = min(ty, y);
    }
  }
  if (tx < sx || ty < sy) {
    cout << 0 << endl;
  } else {
    cout << (tx - sx) * (ty - sy) << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS

/* include ***********************/
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>

/* define *************************/
//for
#define REP(i,n) for(int i=0,i##_len=(int)(n);i<i##_len;i++)
#define REPS(i,n) for(int i=1,i##_len=(int)(n);i<=i##_len;i++)
#define RREP(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define RREPS(i,n) for(int i=(int)(n);i>0;i--)
#define FOR(i,s,n) for(int i=(int)(s),i##_len=(int)(n);i<i##_len;i++)
#define RFOR(i,s,n) for(int i=(int)(n)-1,i##_len=(int)(s);i>=i##_len;i--)

//printf
#define PRINTD(d) printf("%d\n",(d))
#define PRINTL(d) printf("%lld\n",(d))

//memset
#define m0(s) memset(s,0,sizeof(s))
#define ml(s) memset(s,63,sizeof(s))
#define fill(s,c) memset(s,c,sizeof(s))

#define INF 1e9
#define MOD 1000000007

typedef long long ll;
typedef unsigned long long ull;

int diff[4][2] = {
	{ 0, -1 },
	{ -1, 0 },
	{ 1, 0 },
	{ 0, 1 },
};
//今回の変数
int b[100000];
int l[100000];
int u[100000];
ll d[100000];
ll idx[100000];
ll sum;

int Min(int a, int b) {
	return (a)<(b) ? (a) : (b);
}
int Max(int  a, int  b) {
	return (a) > (b) ? (a) : (b);
}
ll Minl(ll a, ll b) {
	return (a)<(b) ? (a) : (b);
}
ll Maxl(ll a, ll b) {
	return (a)>(b) ? (a) : (b);
}

int main() {
	int n;
	scanf("%d", &n);
	
	int sum[100];
	REP(i, n) {
		scanf("%d", &sum[i]);
	}
	REPS(i, n - 1) {
		sum[i] += sum[i - 1];
	}

	int min = 1e9;
	REP(i, n - 1) {
		min = Min(min, abs(sum[i] - (sum[n - 1] - sum[i])));
	}
	PRINTD(min);
}


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

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

int a, b;

int main() {
  while (cin >> a >> b) {
    cout << (a + b) % 24 << endl;
  }
}


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

// int/long:            -2,147,483,648 - 2,147,483,647 (-2^31 <= int < 2^31)
// long/long long:      -9,223,372,036,854,775,808 - 9,223,372,036,854,775,807 (-2^63 <= long < 2^63)

#define INF (1<<30)
//1,073,741,824
//= 536,870,912 *2

#define MOD 1000000007

#define Rep0(i, n)      for (auto i=0; i<n; i++)
#define Rep1(i, n)      for (auto i=1; i<=n; i++)
#define Sort(P) sort(P.begin(), P.end())
#define Rev(P)  reverse(P.begin(), P.end())

int     main() {
        ll N;
        cin >>N;
        ll MA=0;
        ll ANS=0;
        Rep0(i, N) {
                ll A;
                cin >>A;
                if (MA>A)
                        ANS +=MA-A;
                else
                        MA=A;
        }
        cout <<ANS <<endl;
        return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define All(a) a.begin(),a.end()
#define INF 1000000007
const int MOD = 1000000007;
//accumulate(vec.begin(), vec.end(), 0)

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

int main(){
  int n,m;
  cin >> n >> m;
  if(n==m) cout<< "Yes" <<endl;
  else cout<< "No"<<endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <ctime>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;
using ll = long long;

#define REP(i, a) for (int i = 0; i < (a); ++i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define FORR(i, a, b) for (int i = (a)-1; i >= (b); --i)
#define ALL(obj) (obj).begin(), (obj).end()
#define SIZE(obj) (int)(obj).sizeT()
#define YESNO(cond, yes, no) \
    { cout << ((cond) ? (yes) : (no)) << endl; }
#define SORT(list) sort(ALL((list)));
#define RSORT(list) sort((list).rbegin(), (list).rend())
#define ASSERT(cond, mes) assert(cond&& mes)

constexpr int MOD = 1'000'000'007;
constexpr int INF = 1'050'000'000;

template <typename T>
T round_up(const T& a, const T& b) {
    return (a + (b - 1)) / b;
}

template <typename T1, typename T2>
istream& operator>>(istream& is, pair<T1, T2>& p) {
    is >> p.first >> p.second;
    return is;
}

template <typename T1, typename T2>
ostream& operator<<(ostream& os, pair<T1, T2>& p) {
    os << p.first << p.second;
    return os;
}

template <typename T>
istream& operator>>(istream& is, vector<T>& v) {
    REP(i, (int)v.size())
    is >> v[i];
    return is;
}

template <typename T>
T clamp(T& n, T a, T b) {
    if (n < a) n = a;
    if (n > b) n = b;
    return n;
}

template <typename T>
static T GCD(T u, T v) {
    T r;
    while (v != 0) {
        r = u % v;
        u = v;
        v = r;
    }
    return u;
}

template <typename T>
static T LCM(T u, T v) {
    return u / GCD(u, v) * v;
}

template <typename T>
std::vector<T> enum_div(T n) {
    std::vector<T> ret;
    for (T i = 1; i * i <= n; ++i) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i * i != n) { ret.push_back(n / i); }
        }
    }
    return ret;
}

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

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

struct ToUpper {
    char operator()(char c) {
        return toupper(c);
    }
};

struct ToLower {
    char operator()(char c) {
        return tolower(c);
    }
};

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

    string a, b;
    cin >> a >> b;
    string A, B;
    for (int i = 0; i < atoi(b.c_str()); i++) { A += a; }
    for (int i = 0; i < atoi(a.c_str()); i++) { B += b; }
    YESNO(A < B, A, B);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n); for(int i = 0;i < (n);i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef tuple<int,int,int> state;
long double pi = acos(-1);
const int INF = 1001001001;


// 最小公倍数を求める
int euqlid (int a, int b){
  int temp;
  temp = a % b;
  if(temp == 0)return b;
  return euqlid(b,temp);
}
ll conbination(ll a,ll b){
  ll u = 1;
  ll d = 1;
  while(b != 0){
    u *= a;
    d *= b;
    a--;
    b--;
  }
  return u / d;
}
int strtoint(char s){
  return (int(s-'0'));
}
char changeS(char alpha){
  if(0x41 <= alpha and alpha <= 0x5A)return (alpha + 0x20);
  else if(0x61 <= alpha and alpha <= 0x7A)return (alpha - 0x20);
  return alpha;
}
int fact(int n){
  if(n == 1)return 1;
  return n * fact(n-1);
  }
int ceil(int a,int b){
  // a/bの切り上げを考える
  return (a+b-1)/b;
}


int main(){ 
  int l, r, d;
  cin >> l >> r >> d;
  int cnt = 0;
  for(int i = l;i <= r;i++){
    if(i % d == 0)cnt++;
  }
  cout << cnt << endl;
}

Measured memory_bytes: 3620
//minamoto
#include<bits/stdc++.h>
#define R register
#define fp(i,a,b) for(R int i=(a),I=(b)+1;i<I;++i)
#define fd(i,a,b) for(R int i=(a),I=(b)-1;i>I;--i)
#define go(u) for(int i=head[u],v=e[i].v;i;i=e[i].nx,v=e[i].v)
template<class T>inline bool cmax(T&a,const T&b){return a<b?a=b,1:0;}
template<class T>inline bool cmin(T&a,const T&b){return a>b?a=b,1:0;}
using namespace std;
const int N=305;
char s[N];int f[N][N][N],n,k;
inline int max(R int x,R int y){return x>y?x:y;}
int dfs(int l,int r,int k){
	if(r<=l)return r-l+1;
	if(~f[l][r][k])return f[l][r][k];
	R int res=max(dfs(l+1,r,k),dfs(l,r-1,k));
	if(s[l]==s[r])cmax(res,dfs(l+1,r-1,k)+2);
	if(s[l]!=s[r]&&k)cmax(res,dfs(l+1,r-1,k-1)+2);
	return f[l][r][k]=res;
}
int main(){
	scanf("%s%d",s+1,&k),n=strlen(s+1);
	memset(f,-1,sizeof(f));
	printf("%d\n",dfs(1,n,k));
	return 0;
}

Measured memory_bytes: 111104
package main

import "fmt"

func main() {
	// Code for A - ι⊥l
	var a, b, c int
	fmt.Scanf("%d %d %d", &a, &b, &c)

	if b-a == c-b {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}


Measured memory_bytes: 1832
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
#define PRINT(v) for (auto x : (V)) cout <<x <<" " <<endl;
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
const ll MOD = 1000000007;
const ll INF = 10000000000000000;
vector<int> x4 = {0, 1, 0, -1}, x8 = {0, 1, 1, 1, 0, -1, -1, -1};
vector<int> y4 = {1, 0, -1, 0}, y8 = {1, 1, 0, -1, -1, -1, 0, 1};
template<class T> struct edge { int from, to; T cost;};
template<class T> inline bool chmin(T& a, T b){if (a>b){a = b; return true;}return false;}
template<class T> inline bool chmax(T& a, T b){if (a<b){a = b; return true;}return false;}
template<class T> inline T powerM(T a,T b){if (b==0) return 1;
T tmp = powerM(a,b/2); if (b%2==0) return tmp*tmp%MOD; else return tmp*tmp%MOD*a%MOD; }
template<class T> inline T power(T a,T b,T m){ if (b==0) return 1;
  T tmp = power(a,b/2,m); if (b%2==0) return tmp*tmp%m; else return tmp*tmp%m*a%m; }
template<class T> inline T gcd(T a, T b){if (b==0) return a; return gcd(b, a%b);}
template<class T> inline T lcm(T a, T b){return a / gcd(a,b) * b;}
// ax+by=gcd(a,b)を解く
template<class T> inline T extgcd(T a,T b,T &x,T &y){if (b==0){x=1; y=0; return a;} T d=extgcd(b,a%b,y,x); y -= a/b*x; return d;}
void hey(){ cout <<"hey" <<endl; }


int main() {
  int N; cin >>N;
  vector<int> res(N, 0);
  rep(i, N-1){
    int x; cin >>x; x--;
    res[x]++;
  }
  rep(i, N) cout <<res[i] <<endl;
}

Measured memory_bytes: 4008
#include<iostream>
#include<vector>
#include<algorithm>
#define int long long
using namespace std;
const int N=1e5+2;
int ar[N],ar1[N],pos[N][2];
vector<pair<int,pair<int,int> > > lis;
signed main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n,i,j,k,l,ans=0,sum=0;
	#define now k
	cin>>n;
	j=0;
	k=0;
	for(i=1;i<=n;i++){
		cin>>ar[i]>>ar1[i];
		j+=ar[i];
		k+=ar1[i];
		lis.push_back({ar[i],{i,0}});
		lis.push_back({ar1[i],{i,1}});
	}
	ans=min(j,k);
	sort(lis.begin(),lis.end());
	for(i=0;i<n;i++){
		sum+=lis[i].first;
	}
//	cout<<sum<<endl;
	for(i=0;i<lis.size();i++){
		pos[lis[i].second.first][lis[i].second.second]=i;
	}
	for(i=1;i<=n;i++){
		now=n-1;
		j=sum;
		bool cac=true,cac1=true;
		if(pos[i][0]>now&&cac){
			j+=lis[pos[i][0]].first;
			j-=lis[now].first;
			now--;
			cac=false;
		}
		if(cac1&&pos[i][1]>now){
			j+=lis[pos[i][1]].first;
			j-=lis[now].first;
			now--;
			cac1=false;
		}
		if(pos[i][0]>now&&cac){
			j+=lis[pos[i][0]].first;
			j-=lis[now].first;
			now--;
			cac=false;
		}
		if(cac1&&pos[i][1]>now){
			j+=lis[pos[i][1]].first;
			j-=lis[now].first;
			now--;
			cac1=false;
		}
		ans=min(ans,j);
	}
	cout<<ans;
}

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

using ll = long long;
using ld = long double;
using pii = pair<int, int>;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))

int dx4[4] = {1,0,-1,0}, dy4[4] = {0,1,0,-1};


int main()
{
    int n,k;
    cin>>n>>k;
    long ans =k;
    
    for(int i = 0; i < n-1; i++)
    {
        ans*=k-1;
    }
    cout << ans << endl;
 
    return 0;
}

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

enum occupant
{
build, floor, room, number
}

class Program
 {



    static void Main(string[] args)
    {
        string nyuryoku;
        char[] data;


        nyuryoku = Console.ReadLine();
        data = new char[nyuryoku.Length];
        for (int i = 0; i < nyuryoku.Length; i++)
        {
            if(Char.IsUpper(nyuryoku[i]))
                data[i] = Char.ToLower(nyuryoku[i]);
            else if(Char.IsLower(nyuryoku[i]))
                data[i] = Char.ToUpper(nyuryoku[i]);
            else
                data[i] = nyuryoku[i];
        }
        string result = new string(data);
        Console.WriteLine(result);
  





    }

 }



Measured memory_bytes: 15892
import java.util.*;
import java.io.*;

class Main
{
    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

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

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

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

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

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

    public static void main(String[] args)
    {
        FastReader s = new FastReader();
        int val = s.nextInt();
        String line = val+"";
        char one =  line.charAt(0);
        char two  = line.charAt(1);

        int onecount =0 ;
        for (int i =0;i<line.length();i++)
        {
            if(one == line.charAt(i))
                onecount++;
            else
                break;
        }

        int twocount = 0;
        for (int i = 1;i<line.length();i++)
        {
            if(two == line.charAt(i))
                twocount++;
            else
                break;
        }

         if (onecount >= 3 || twocount >=3)
             System.out.println("Yes");
        else
            System.out.println("No");


    }
}

Measured memory_bytes: 22612
#include<stdio.h>
int main()
{
  int n, y, i, j, b, r, t, num;
  double ans, max;

  while(1){

    max = 0.0;
    
    scanf("%d", &n);
    if(n == 0) break;

    scanf("%d", &y);

    
    for(i=0; i<n; i++){
      scanf("%d%d%d", &b, &r, &t);

      if(t == 1){
	ans = (1 + y * (double)r / 100);
    
      }
  
      else{
	ans = 1.0;
	for(j=0; j<y; j++){
	ans *= (1 + (double)r / 100);
	}
	
      }

      if(max < ans){
      num = b;
      max = ans;
      }

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

  }

  return 0;

}

Measured memory_bytes: 596
#include<iostream>
#include <math.h>

using namespace std;

struct Vector2D{
    double x;
    double y;
};
//???????????????(??????????????¨??????)
#define Vertex2D Vector2D

//?????????????????????(a-b)
Vector2D sub_vector(const Vector2D& a, const Vector2D& b)
{
    Vector2D ret;
    ret.x = a.x - b.x;
    ret.y = a.y - b.y;
    return ret;
}

// ????§???¢??¨?????????????????????(2D?????´???)
// ?????????    0:????§???¢????????´???????????????    1:????§???¢????????´???????????????
int hittest_point_polygon_2d(Vertex2D A, Vertex2D B, Vertex2D C, Vertex2D P) {

    //??????????????¨??????????????????
    //ABC???????§???¢????????????????????§??????????????\...

    Vector2D AB = sub_vector(B, A);
    Vector2D BP = sub_vector(P, B);

    Vector2D BC = sub_vector(C, B);
    Vector2D CP = sub_vector(P, C);

    Vector2D CA = sub_vector(A, C);
    Vector2D AP = sub_vector(P, A);

    //??????    Z?????????????¨????????????°????????§???
    double c1 = AB.x * BP.y - AB.y * BP.x;
    double c2 = BC.x * CP.y - BC.y * CP.x;
    double c3 = CA.x * AP.y - CA.y * AP.x;

    if ((c1 > 0 && c2 > 0 && c3 > 0) || (c1 < 0 && c2 < 0 && c3 < 0)) {
        //????§???¢????????´???????????????
        return 0;
    }

    //????§???¢????????´???????????????
    return 1;

}

int main(){
    Vector2D A;
    Vector2D B;
    Vector2D C;
    Vector2D P;

    while (cin >> A.x >> A.y >> B.x >> B.y >> C.x >> C.y >> P.x >> P.y)
    {
        if (hittest_point_polygon_2d(A, B, C, P) == 0){
            cout << "YES" << endl;
        }
        else
        {
            cout << "NO" << endl;
        }
    }

    return 0;
}

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

using namespace std;

const int N=1e5+10;
char  a[N];

int main()
{
    int l=0,b,i;
    scanf("%s",a);
    b=strlen(a);
    for(i=1;i<b;i++)
    {
        if(a[i]!=a[i-1]) l++;
    }
    printf("%d",l);
    return 0;
}

Measured memory_bytes: 384
A, B, M = input().split(" ")
A, B, M = int(A), int(B), int(M)
a = input().split(" ")
b = input().split(" ")
a = list(map(int, a))
b = list(map(int, b))
amin = min(a)
bmin = min(b)
min_price = amin + bmin

for i in range(M):
    x, y, c = input().split(" ")
    x, y, c = int(x), int(y), int(c)
    if (min_price > a[x - 1] + b[y - 1] - c):
        min_price = a[x - 1] + b[y - 1] - c

print(min_price)

Measured memory_bytes: 21104
#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<int,int>;


int main(){
	LL N, K;
	cin >> N >> K;
	LL ans = min(N % K, K - (N % K));
	cout << ans << endl;

}














Measured memory_bytes: 3548
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("unroll-loops") 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
#define int long long
#define fr(i,a,b) for(int i = a ; i <= b ; ++i)
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) begin(x), end(x)
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()
#define pb push_back
#define fst first
#define snd second
using namespace __gnu_pbds;
using ordered_set =
 tree<int, null_type,less<int>,
 rb_tree_tag,tree_order_statistics_node_update>;
//find_by_order(k):returns iterator to kth element starting from 0
//order_of_key(k):returns count of elements strictly smaller than k
typedef long long ll;typedef pair<int, int> pii;
typedef vector<int> vi;typedef long double ld;
template<class T>
using min_heap = priority_queue<T,vector<T>,greater<T>>; 
template<typename T> T gcd(T a, T b){return(b?__gcd(a,b):a);}
template<typename T> T lcm(T a, T b){return(a*(b/gcd(a,b)));}
template<class T> void re(T& x) { cin >> x; }
template<typename T> 
void remdup(vector<T>& v) {
	sort(all(v)); v.erase(unique(all(v)), v.end());
}
template<typename T> void re(vector<T> &v) {trav(i,v) cin >> i;}
template<class H, class... T> void re(H& h, T&... t) { re(h); re(t...); }
void unsyncIO() { ios_base::sync_with_stdio(0); cin.tie(0); }
#ifdef np
#include "/home/o_o/MyCodes/pr.h"
#else
#define trace(...)
#endif

#define MOD 1000000007  


const int N = 3e5+5;
int r[N+1] , c[N+1];
void solve(){
	int h ,w , m ; 
	re(h,w,m);
	int x = 0, y = 0 ;
	vector<pii> brd;
	rep(i,0,m){
		int a, b;
		re(a,b);
		r[a]++;
		c[b]++;
		x = max(x,r[a]);
		y = max(y,c[b]);
		brd.emplace_back(a,b);
	}
	int cnt = 0 ;
	for(auto[X ,Y] : brd){
		if(r[X] == x and c[Y] == y) cnt++;
	}
	int rc = 0 , cc = 0 ;
	fr(i,1,h){if(r[i] == x) rc++;}
	fr(i,1,w){if(c[i] == y) cc++;}
	int ans = x+y-(cnt == rc*cc);
	cout << ans << endl;
}


signed main() {
	unsyncIO();
	int tt =1 ;
	// cin >> tt;
	rep(i,0,tt) solve();













#ifdef np
	cout <<endl<<endl<< "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}


Measured memory_bytes: 16244
#include <iostream>
#include <cstdlib>
#include <vector>
#include <string>

using namespace std;

int main()
{
    int n, max_profit, profit, c, l;
    vector<vector<vector<int>>> f;
    vector<vector<int>> p;
    cin >> n;
    f.resize(n);
    p.resize(n);
    max_profit = -2000000000;
    for(int i=0; i<n; ++i){
        f[i].resize(5);
        for(int j=0; j<5; ++j){
            f[i][j].resize(2);
            for(int k=0; k<2; ++k){
                cin >> f[i][j][k];
            }
        }
    }
    for(int i=0; i<n; ++i){
        p[i].resize(11);
        for(int j=0; j<=10; ++j){
            cin >> p[i][j];
        }
    }
    bitset<10> b;
    for(unsigned int m=1; m<1024; ++m){
        b = static_cast<bitset<10>>(m);
        profit = 0;
        for(int i=0; i<n; ++i){
            c = 0;
            for (int j=0; j<5; ++j){
                for(int k=0; k<2; ++k){
                    l = k + 2 * j;
                    if(f[i][j][k] == 1 && b[l] == 1){
                        c++;
                    }
                }
            }
            profit += p[i][c];
        }
        max_profit = max(profit, max_profit);
    }
    cout << max_profit << endl;
}


Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	n := nextInt()

	if n % 2 == 0 {
		fmt.Printf("%d", n / 2 - 1)
	} else {
		fmt.Printf("%d", n / 2)
	}
}


Measured memory_bytes: 640
#include <algorithm>
#include <cstdio>
#include <cstdlib>

using namespace std;

static int paper[10][10];

void drop_ink(int x, int y, int size) {
  switch (size) {
    case 3:
      if (y > 1) { ++paper[y-2][x]; }
      if (x > 1) { ++paper[y][x-2]; }
      if (x < 8) { ++paper[y][x+2]; }
      if (y < 8) { ++paper[y+2][x]; }
      // Fall through.
    case 2:
      if (y > 0 && x > 0) { ++paper[y-1][x-1]; }
      if (y > 0 && x < 9) { ++paper[y-1][x+1]; }
      if (y < 9 && x > 0) { ++paper[y+1][x-1]; }
      if (y < 9 && x < 9) { ++paper[y+1][x+1]; }
      // Fall through.
    case 1:
      if (y > 0) { ++paper[y-1][x]; }
      if (x > 0) { ++paper[y][x-1]; }
      ++paper[y][x];
      if (x < 9) { ++paper[y][x+1]; }
      if (y < 9) { ++paper[y+1][x]; }
      break;
  }
}

int main() {
  char *line = NULL;
  size_t buffer_size = 0;
  while (getline(&line, &buffer_size, stdin) > 0) {
    int x, y, size;
    sscanf(line, "%d,%d,%d", &x, &y, &size);
    drop_ink(x, y, size);
  }
  free(line);

  int num_white_cells = 0;
  int deepest_cell = 0;
  for (int i = 0; i < 10; ++i) {
    for (int j = 0; j < 10; ++j) {
      if (paper[i][j] == 0) { ++num_white_cells; }
      else { deepest_cell = max(deepest_cell, paper[i][j]); }
    }
  }
  printf("%d\n%d\n", num_white_cells, deepest_cell);

  return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <sstream>
#include <utility>
#define ll long long int
#define rep(i,x,y) for(int i=x;i<y;i++)
#define rel(i,x,y) for(int i=x-1;i>=y;i--)
#define all(x) x.begin(),x.end()

using namespace std;

int main(){
	int n,m;
	cin >> n >> m;
	int l,r;
	int add[n] = {};
	int cnt=0;
	rep(i,0,m){
		cin >> l >> r;
		add[l-1]++;
		if(r<n){
			add[r]--;
		}
	}
	rep(i,0,n-1){
		add[i+1] += add[i];
		if(add[i] == m){
			cnt++;
		}
	}
	if(add[n-1] == m){
		cnt++;
	}
	cout << cnt << endl;

}


Measured memory_bytes: 640
#include <stdio.h>
#define REP(a) for(i = 0; i < a; i++)

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

int main(void) {
    int n,k,i,sum = 0;
    scanf("%d%d",&n,&k);
    int a[n];
    REP(n) {
        scanf("%d",&a[i]);
    }
    qsort(a, n, sizeof(int), compare);
    REP(k) {
        sum += a[i];
    }
    printf("%d\n",sum);
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
using ll = long long;

const int D = 60;
const int MAX_N = 200005; //頂点番号
int to[D][MAX_N];

int main(int argc, char const *argv[]) {
  //入力
  int n;
  ll k;
  cin >> n >> k;
  rep(i, n) {
    cin >> to[0][i];
    to[0][i]--;
  }

  rep(i, D - 1) rep(j, n) to[i + 1][j] = to[i][to[i][j]]; //表の作成

  int v = 0;
  for (int i = D - 1; i >= 0; i--) {
    ll l = 1ll << i; // llはオーバーフロー対策。つけないとintで計算される。
    if (l <= k) {
      v = to[i][v];
      k -= l;
    }
  }
  cout << v + 1 << endl;
  return 0;
}


Measured memory_bytes: 50524
import bisect
n=int(input())
l=[]
e=[]
for i in range(n//2):
    j=int(input())
    e.append(j)
    l.append(j)
    j=int(input())
    l.append(j)
if n%2==1:
    j=int(input())
    e.append(j)
    l.append(j)
l.sort()
e.sort()
res=0
for i in range(0,n,2):
    if e[min(len(e)-1,bisect.bisect_left(e,l[i]))]!=l[i]:
        res+=1
print(res)

Measured memory_bytes: 7868
import java.util.Scanner;

public class Main {

        public static void main(String[] args) {
            Scanner sc = new Scanner(System.in);
            int S = sc.nextInt();
            int h = S / 3600;
            int m = S % 3600 / 60;
            int s = S % 60;
            System.out.println(h + ":" + m + ":" + s);
            sc.close();
        }
    }



Measured memory_bytes: 26296
/**
 *      ABC 58 C
 *      author  : kyomukyomupurin
 *      created : 2018-09-29 17:26:25
**/

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n; cin >> n;
    string S[n] = {};
    for (auto i = 0; i < n; ++i) {
        cin >> S[i];
    }
    int countC[30] = {};

    for  (char c = 'a'; c <= 'z'; ++c){
        int min = 30;
        for (auto i = 0; i < n; ++i) {
            //int min = 30;
            int x = count(S[i].begin(), S[i].end(), c);
            if (x < min) min = x;
        }
        countC[c - 'a'] = min;
    }
    string answer = {};

    for (auto c = 'a'; c <= 'z'; ++c) {
        if (countC[c - 'a'] > 0){
            for (auto i = 0; i < countC[c - 'a']; ++i) {
                answer.push_back(c);
            }
        }
    }
    cout << answer << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    list<int> a;
    
    char s[21];
    int n,x;
    scanf("%d",&n);
    for (int i=0; i<n; i++){
    	scanf("%s",s);
    	if (s[0]=='i'){
    		scanf("%d",&x);
    		a.push_front(x);
		}
		else{
			if (s[6]=='F'){
				a.pop_front();
			}
			else{
				if (s[6]=='L'){
					a.pop_back();
				}
				else if (s[0]=='d'){
					scanf("%d",&x);
					for (list<int>::iterator it=a.begin(); it!=a.end(); it++){
						if (*it==x){
							a.erase(it);
							break;
						}
					}
				}
				
			}
		}
	}
	int i=0;
	for (list<int>::iterator it=a.begin(); it!=a.end(); it++){
		if (i++) printf(" ");
		printf("%d",*it);
	}
	printf("\n");
    return 0;
} 


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

using namespace std;

#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define DEBUG_MAT(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}


typedef long long ll;

#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1000000007;
//const ll MOD = 998244353;
const double pi = 3.14159265358979323846;
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx[4] = { -1,0, 1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
// #define mp make_pair
//#define endl '\n'

int main() {
  ll n;
  cin >> n;
  ll ans = (n - 1) * n / 2;
  cout << ans << endl;
}


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

using namespace std;

void solve() {
    int h1, m1, h2, m2, k;
    cin >> h1 >> m1 >> h2 >> m2 >> k;
    int from = h1*60 + m1;
    int to = h2*60 + m2;
    int ans = to - from - k;
    cout << ans << endl;
}

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    solve();
}



Measured memory_bytes: 3664