akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#define MAX 26
#define NIL -1

// bool isFirst;

struct Node{
    int parent, left, right;
};

struct Node T[MAX];

void prePerse(int u){
    if(u == NIL) return;
    // if(!isFirst) 
    printf(" ");
    // isFirst = false;
    printf("%d", u);
    prePerse(T[u].left);
    prePerse(T[u].right);
}

void inPerse(int u){
    if(u == NIL) return;
    inPerse(T[u].left);
    // if(!isFirst) 
    printf(" ");
    // isFirst = false;
    printf("%d", u);
    inPerse(T[u].right);
}

void postPerse(int u){
    if(u == NIL) return;
    postPerse(T[u].left);
    postPerse(T[u].right);
    // if(!isFirst) 
    printf(" ");
    // isFirst = false;
    printf("%d", u);
}

int main(void){
    int n, id, l, r, root;
    scanf("%d", &n);
    for(int i=0; i<n; i++){
        T[i].parent = T[i].left = T[i].right = NIL;
    }

    for(int i=0; i<n; i++){
        scanf("%d %d %d", &id, &l, &r);
        T[id].left = l;
        T[id].right = r;
        if(l != NIL) T[l].parent = id;
        if(r != NIL)T[r].parent = id;
    }

    for(int i=0; i<n; i++){
        if(T[i].parent == NIL) root = i;
    }

    // isFirst = true;
    printf("Preorder\n");
    prePerse(root);
    printf("\n");

    // isFirst = true;
    printf("Inorder\n");
    inPerse(root);
    printf("\n");

    // isFirst = true;
    printf("Postorder\n");
    postPerse(root);
    printf("\n");

    return 0;
}


Measured memory_bytes: 2704
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		
		int max = 1;
		int a[] = new int[n+1];
		
		for(int i=1;i<=n;i++){
			a[i] = sc.nextInt();
			if(Math.abs(a[i]) > Math.abs(a[max])){
				max = i;
			}
		}
		
		
		if(a[max] == 0){
			System.out.println(0);
		}
		else{
			int cnt = 0;
			int ans[][] = new int[2*n][2];
			
			for(int i=1;i<=n;i++){
				if(i!=max){
					ans[cnt][0] = max;
					ans[cnt][1] = i;
					a[i] += a[max];
					cnt++;
				}
			}
			
			if(a[max] > 0){
				for(int i=1;i<n;i++){
					if(a[i] > a[i+1]){
						ans[cnt][0] = i;
						ans[cnt][1] = i+1;
						a[i+1] += a[i];
						cnt++;
					}
				}
			}
			else{
				for(int i=n;i>1;i--){
					if(a[i-1] > a[i]){
						ans[cnt][0] = i;
						ans[cnt][1] = i-1;
						a[i-1] += a[i];
						cnt++;
					}
				}
			}
			
			System.out.println(cnt);
			for(int i=0;i<cnt;i++){
				System.out.println(ans[i][0] + " " +ans[i][1]);
			}
		}
	}

}


Measured memory_bytes: 22996
#include <iostream>
#include <utility>
#include <vector>

using namespace std;

void max_heapify(vector<int>& H, int i, int size)
{
    int left = i * 2;
    int right = i * 2 + 1;

    int max = i;
    if (left <= size && H[max] < H[left])
        max = left;
    if (right <= size && H[max] < H[right])
        max = right;

    if (max != i) {
        swap(H[max], H[i]);
        max_heapify(H, max, size);
    }
}

void build_max_heap(vector<int>& H, int size)
{
    for (int i = size / 2; i > 0; --i)
        max_heapify(H, i, size);
}

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

    vector<int> H(size+1);
    for (int i = 1; i <= size; ++i)
        cin >> H[i];

    build_max_heap(H, size);

    for (int i = 1; i <= size; ++i)
        cout << ' ' << H[i];
    cout << '\n';
}



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

int main () {
  int N;
  cin >> N;
  int cake = 4;
  int donut = 7;

  for (int i=0; i <= N / cake; ++i) {
    for (int j=0; j <= N / donut; ++j) {
      int total = cake * i + donut * j;
      if (total == N) {
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;
  return 0;
}


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

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var H = decimal.Parse(Console.ReadLine());

            decimal count = 1;
            decimal answer = 0;

            while (H > 0)
            {
                H = Math.Floor(H / 2);

                answer += count;
                count *= 2;
            }

            Console.WriteLine(answer.ToString());
        }
    }
}


Measured memory_bytes: 13396
#include <iostream>
#include <algorithm>
#include <vector>
#include <deque>
#include <queue>
#include <list>
#include <stack>
#include <string>
#include <functional>
#include <numeric>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <cstdlib>
#define INF 100000000
#define _INF -100000000
#define INFLL (long long)1e14
#define _INFLL (long long)-1e14
#define Loop(i, n) for(int i = 0; i < (int)n; i++)
#define Loop1(i, n) for(int i = 1; i <= (int)n; i++)
#define Loopr(i, n) for(int i = (int)n - 1; i >= 0; i--)
#define Loopr1(i, n) for(int i = (int)n; i >= 1; i--)
using namespace std;
typedef long long int ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef pair<int, int> P;

int main() {
	int x, y; cin >> x >> y;
	vll p(x), q(y), sump(x + 1, 0);
	ll ans = 0;
	Loop(i, x) {
		cin >> p[i];
		ans += p[i];
	}
	Loop(j, y) {
		cin >> q[j];
		ans += q[j];
	}
	sort(p.begin(), p.end());
	sort(q.begin(), q.end());
	Loop(i, x) sump[i + 1] = sump[i] + p[i];
	Loop(j, y) {
		int itr = upper_bound(p.begin(), p.end(), q[j]) - p.begin();
		ans += sump[itr] + (x - itr)*q[j];
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
//#define DEBUG
#define REP(i, nn ) for(int i = 0 ; i < (int) nn; i++)
#define deb(x) std::cout << #x << " " << x << endl;

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;

template<typename... T>
void read(T& ... a){
    ((cin >> a),...);
}
template<typename... T>
void write(T... a){
    ((cout << a << "\n"),...);
}
template<typename... T>
void write_space(T... a){
    ((cout << a << " "),...);
}
constexpr int mxN = 100;
int a[2][mxN];
int max_candies = 0;
int n;

void dfs(int i, int j, int current_candices){
    if( i == 1 && j == n-1){
        current_candices += a[i][j];
        if( max_candies < current_candices) max_candies = current_candices;
        return;
    }
    if( i == 0){
       int updated_candices = current_candices + a[i][j];
       dfs(i+1, j, updated_candices);
       if ( j + 1 < n - 1)
        dfs(i, j+1, updated_candices);
    }else{
        int updated_candices = current_candices + a[i][j];
        dfs(i, j+1, updated_candices);
    }

}

void solve(){
    read(n);
    REP(i,n) cin >> a[0][i];
    REP(i,n) cin >> a[1][i];
    dfs(0,0,0);
    cout << max_candies << "\n";
} 

int main()
{
    //making data IO Fast
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(NULL);
    /****************************/

    #ifdef DEBUG
    int TEST_CASES = 2;
    while(TEST_CASES--){
    #endif // DEBBUG

    solve();

    #ifdef DEBUG
    }
    #endif // DEBUG
    
    return 0;
}

//Thanks to CSES problemset
// I am trained with this kind of problem

Measured memory_bytes: 3624
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;
const ll INF = 1e18;
const ll MOD = 1e9 + 7;
#define all(v) v.begin(), v.end()
#define repi(i, n, init) for (ll i = init; i < (n); i++)
#define repd(i, n, init) for (ll i = (n); i >= init; i--)
#define repm(i, m) for (auto i = m.begin(); i != m.end(); i++)
#define repb(bit, n, init) for (ll bit = init; bit < (1 << n); ++bit)

int gcd(int a, int b)
{
    int x, y;
    x = max(a, b);
    y = min(a, b);
    if (x % y == 0)
    {
        return y;
    }
    gcd(y,x%y);
}

int main()
{
    int x, y;
    cin >> x >> y;
    cout << gcd(x, y) << endl;
    return 0;
}


Measured memory_bytes: 3104
#include "bits/stdc++.h"
using namespace std;
#define repi(i,a,b) for(int i=(a), i##_len=(b); i<i##_len; ++i)
#define rep(i,n) repi(i,0,n)
#define all(x) (x).begin(),(x).end()
#define tsort(v) sort((v).begin(), (v).end())
#define trev(v) tsort(v);reverse(all(v))
#define siz(v) ((int)(v).size())
#define ers(v, n) (v).erase((v).begin() + n)
#define vmin(v) *min_element(v.begin(), v.end())
#define vmax(v) *max_element(v.begin(), v.end())
#define cnt(v,a) count(all(v),a)
#define el "\n"
#define co(x) cout<<(x)<<el
#define coc(c, a, b) if(c)co((a));else co((b))
#define YES(c) coc(c,"YES", "NO")
#define Yes(c) coc(c,"Yes", "No")
#define yes(c) coc(c,"yes", "no")
#ifdef tqktmp_2
#define gc() getchar(); getchar()
#else
#define gc() 1
#endif
typedef long long lint;

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

template<class T>bool maxi(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool mini(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }

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

    lint n, in, b;
    vector<lint> a;
    cin>>n;
    rep(i,n){
        cin>>in;
        a.push_back(in);
    }
    trev(a);
    lint i=0, l;
    while(i<n){
        l=1;
        while(a[i+l]==a[i])l++;
        if(l>=4){
            co(a[i]*a[i]);
            return 0;
        }
        if(l>=2){
            b=a[i];
            i+=l;
            break;
        }
        i++;
    }
    while(i<n){
        l=1;
        while(a[i+l]==a[i])l++;
        if(l>=2){
            co(b*a[i]);
            return 0;
        }
        i++;
    }
    co("0");
}

Measured memory_bytes: 1400
H,W=map(int,input().split())
N=int(input())
a=list(map(int,input().split()))

ans=[[0 for _ in range(W)] for _ in range(H)]
if H%2==1:
    END=[H-1,W-1]
else:
    END=[H-1,0]
h=0
w=0
col=1
cnt=0

while h<H:
    ans[h][w]=col
    cnt+=1
    if cnt>=a[col-1]:
        cnt=0
        col+=1
    if (h%2==1 and w==0) or (h%2==0 and w==W-1):
        h+=1
    else:
        w+=(-1)**h

if W>1:
    for A in ans:
        for B in A:
            print(B,end=" ")
        print()
else:
    for A in ans:
        print(A[0])

Measured memory_bytes: 3908
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
typedef long long int lint;
using namespace std;

//ただの辺
struct edge {
    using lint = long long int;
    int to;
    lint cost;
    //引数一つの時は距離1
    edge(int t, lint c = 1) : to(t), cost(c) {
    }
    edge() {
    }
};

// path[start]を計算して格納する
void dfs(int start, vector<vector<edge>> &g, vector<int> &path,
         vector<bool> &calced) {
    if (calced[start]) {
        return;
    }
    if (g[start].size() == 0) {
        path[start] = 0;
    } else {
        int temp = 0;
        for (int i = 0; i < g[start].size(); i++) {
            dfs(g[start][i].to, g, path, calced);
            temp = max(temp, path[g[start][i].to]);
        }
        path[start] = temp + 1;
    }
    calced[start] = true;
}

int main() {
    int n, m;
    cin >> n >> m;
    vector<vector<edge>> g(n);
    for (int i = 0; i < m; i++) {
        int x, y;
        cin >> x >> y;
        x--, y--;
        g[x].push_back(y);
    }
    // path[i]:iスタートのパスで最長なものの長さ
    vector<int> path(n);
    vector<bool> calced(n, false);
    int ans = 0;
    for (int i = 0; i < n; i++) {
        dfs(i, g, path, calced);
        ans = max(ans, path[i]);
    }
    cout << ans << endl;
}

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

using namespace std;

int verifica(int a,int b){

    if((a*b)%2!=0){
        return 1;
    }else if((a*b*2)%2!=0){
        return 1;
    }else if((a*b*3)%2!=0){
        return 1;
    }

    return 0;
}

int main(){
    int a,b;
    bool c;

    cin>>a>>b;
    
    c = verifica(a,b);

    if(c==1){
        cout<<"Yes";
    }else{
        cout<<"No";
    }

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<numeric>
#include<vector>
#include<set>
#include<map>
#include<math.h>
#include <string>
#define cinf(n,x) for(int i=0;i<(n);i++) cin >> x[i];
typedef long long int ll;
using namespace std;
int main(){
 	int n; cin >>n;
 	if(n%2==0){
 		int cnt=0;
 		for(int i=n-1;i>=1;i--){
 			cnt+=i;
 		}
 		cout << cnt-n/2 << endl;
 		for(int i=1;i<=n;i++){
 			for(int j=i+1;j<=n;j++){
 				if(i+j==n+1) continue;
 				else cout << i << " " << j << endl;
 			}
 		}
 	}
 	else{
 		int cnt=0;
 		for(int i=n-1;i>=1;i--){
 			cnt+=i;
 		}
 		cout << cnt-(n-1)/2 << endl;
 		for(int i=1;i<=n;i++){
 			for(int j=i+1;j<=n;j++){
 				if(i+j==n) continue;
 				else cout << i << " " << j << endl;
 			}
 		}
 	}
 }

Measured memory_bytes: 256
def bubble_sort(cards, n):
#2   for i = 0 to N-1
#3     for j = N-1 downto i+1
#4       if C[j].value < C[j-1].value
#5         C[j] と C[j-1] を交換
    for i in range(0, n):
        for j in range(n-1, i, -1):
            if int(cards[j][1]) <  int(cards[j-1][1]):
                cards[j], cards[j-1] = cards[j-1], cards[j]
    
    return cards

def selection_sort(cards, n):

#8   for i = 0 to N-1
#9     minj = i
#10    for j = i to N-1
#11      if C[j].value < C[minj].value
#12        minj = j
#13    C[i] と C[minj] を交換
    for i in range(0, n-1):
        minj = i
        for j in range(i, n):
            if int(cards[j][1]) <  int(cards[minj][1]):
                minj = j
        cards[i], cards[minj] = cards[minj], cards[i]
    
    return cards


n = int(input())
cards = input().split()
list_buble = bubble_sort(cards[:], n)
list_selection = selection_sort(cards[:], n)
print(*list_buble)
print("Stable")
print(*list_selection)
print("Stable" if list_buble == list_selection else "Not stable")



Measured memory_bytes: 5616
import sys
n=int(input())
s=list(input())
for i in range(n):
    if s[i]=="o":
        s[i]=0
    else:
        s[i]=1
s.append(s[0])
#"1"は羊、"0"は狼
data=["11","10","01","00"]
anser=""
for ans in data:
    qqq=ans
        
    for i in range(1,n+1):
        if ans[i]=="1":
            ans+=str((int(ans[i-1])+s[i])%2)
        else:
            ans+=str((int(ans[i-1])+s[i]+1)%2)
    if ans[n:]==qqq:
        anser=ans[:n]
        break
else:
    print(-1)
    sys.exit()
anser=list(anser)
for i in range(n):
    if anser[i]=="1":
        anser[i]="S"
    else:
        anser[i]="W"
print("".join(anser))

Measured memory_bytes: 5032
#include <stdio.h>
#include <string.h>
int main(){
  int i,first,last,len;
  char s[200000],tmp[2000000];
  
  scanf("%s",s);
  len=strlen(s);
  
  for(i=0;i<len;i++){
    if(s[i]=='A'){
      first=i;
      break;
    }
  }
  
  for(i=len-1;0<=i;i--){
    if(s[i]=='Z'){
      last=i;
      break;
    }
  }
  
  for(i=0;i<=(last-first);i++){
    tmp[i]=s[first+i];
  }
  
  printf("%d",strlen(tmp));
}

Measured memory_bytes: 2120
def main():
    # 下、右、上、左
    dy = [1, 0, -1, 0]
    dx = [0, 1, 0, -1]
    H, W = map(int, input().split())
    s = ["." * (W + 2)]
    s += ["." + input() + "." for i in range(H)]
    s.append("." * (W + 2))
    for y in range(1, H + 1):
        for x in range(1, W + 1):
            if s[y][x] == ".":
                continue
            elif "." == s[y + dy[0]][x + dx[0]]\
                    == s[y + dy[1]][x + dx[1]]\
                    == s[y + dy[2]][x + dx[2]]\
                    == s[y + dy[3]][x + dx[3]]:
                print("No")
                return
    print("Yes")
    return


main()


Measured memory_bytes: 3064
#include<stdio.h>
int main(void){
	int n,m,i,a,f=-1;
	scanf("%d%d",&n,&m);
	for(i=0;i<m;i++){
		scanf("%d",&a);
		n-=a;
	}
	printf("%d",0<=n?n:f);
	return 0;
}


Measured memory_bytes: 1648
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Linq;
using System.Text;

class Program
{

    static void Main(string[] args)
	{
        string s = Console.ReadLine();

        int sum = 0;

        for (int i = 0; i < s.Length; i++)
        {
            sum += (int)Char.GetNumericValue(s[i]);

        }


        if (sum % 9 == 0)
        {
            Console.WriteLine("Yes");
        }
        else
        {
            Console.WriteLine("No");
        }

    }
}

Measured memory_bytes: 17676
#include <iostream>
using namespace std;
int main() {
int a,b,c;
cin >> a >> b >> c;
if ( a > b){
int temp = a ;
a = b;
b = temp;
}
if ( b> c){
int temp = b;;
b = c;
c = temp;
}
if ( a > b){
int temp = a ;
a = b;
b = temp;
}
cout << a << " " <<   b  << " " << c << endl;
return 0;
}


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

N, M = MAP()

node = []
for _ in range(M):
	a, b = MAP()
	node.append(a-1)
	node.append(b-1)

for x in Counter(node).values():
	if x%2:
		print("NO")
		break
else:
	print("YES")


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

class Point{
public:
  double x, y;
  Point(double x = 0, double y = 0):x(x), y(y){}
  Point operator +(Point p) { return Point(x + p.x, y + p.y); }
  Point operator -(Point p) { return Point(x - p.x, y - p.y); }
  Point operator *(double a) { return Point(x * a, y * a); }
};
typedef Point Vector;

double dot(Vector a, Vector b) {
  return a.x*b.x + a.y*b.y;
}

double cross(Vector a, Vector b) {
  return a.x*b.y - a.y*b.x;
}

bool isParallel(Vector a, Vector b) {
  return cross(a, b) == 0.0;
}

int main() {
  while(1) {
    double D;
    Point P;
    Vector V;
    cin >> D;
    if(D == 0) break;
    cin >> P.x >> P.y >> V.x >> V.y;

    double d = -1.0;
    Vector PO = P * (-1);
    if(isParallel(PO, V)) {
      if(dot(PO, V) > 0) {
	d = sqrt(pow(PO.x, 2) + pow(PO.y, 2));
      } else {
	d = 2.0 - sqrt(pow(PO.x, 2) + pow(PO.y, 2));
      }
    }
    if(d == -1 || d > D) cout << "impossible" << endl;
    else                 printf("%.8f\n", d);
  }
  return 0;
}

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

using namespace std;

string s;
int sum = 0,vic;
int main() {
    cin.tie(0), ios::sync_with_stdio(0);
    cin >> s;
    for(int i = 0; i < s.length(); i++){
        if(s[i] == 'p' && sum > 0){
            sum--;
            continue;
        }
        else if(s[i] == 'p'){
            vic--;
            sum++;
            continue;
        }
        if(s[i] == 'g' && sum > 0){
            sum--;
            vic++;
        }
        else if(s[i] == 'g')
            sum++;
        //cout << sum << " " << vic << "\n";
    }
    cout << vic << "\n";
}

Measured memory_bytes: 512
#define _CRT_SECURE_NO_WARNINGS 
#include <stdio.h>


int main(void)
{
	int a, b, d, r;
	double f;

	scanf("%d %d", &a, &b);

	d = a / b;
	r = a % b;
	f = (double)a / b;

	printf("%d %d %f\n", d, r, f);

	return 0;
}

Measured memory_bytes: 1064
#include <iostream> 
#include <cstdio> 
#include <cstdlib> 
#include <cstring> 
#include <cmath> 
#include <algorithm> 
using namespace std; 
const int Mod = 1e9 + 7; 
const int MAX_N = 1e6 + 5; 
int fpow(int x, int y) { 
	int res = 1; 
	while (y) { 
		if (y & 1) res = 1ll * res * x % Mod; 
		x = 1ll * x * x % Mod; 
		y >>= 1; 
	} 
	return res; 
} 
int N = 1e6, M, K; 
int fac[MAX_N], ifc[MAX_N]; 
int C(int n, int m) { 
	if (n < m || n < 0 || m < 0) return 0; 
	else return 1ll * fac[n] * ifc[m] % Mod * ifc[n - m] % Mod; 
} 
int main () { 
	fac[0] = 1; for (int i = 1; i <= N; i++) fac[i] = 1ll * fac[i - 1] * i % Mod; 
	ifc[N] = fpow(fac[N], Mod - 2); 
	for (int i = N - 1; ~i; i--) ifc[i] = 1ll * (i + 1) * ifc[i + 1] % Mod; 
	cin >> N >> M >> K; 
	int ans = 0, sum = 1; 
	int pw = fpow(3, M + K), inv3 = fpow(3, Mod - 2); 
	ans = pw; 
	for (int i = 1; i <= M + K; i++) { 
		pw = 1ll * pw * inv3 % Mod; 
		sum = (sum + sum) % Mod; 
		if (i > M) sum = (sum - C(i - 1, i - M - 1) + Mod) % Mod; 
		if (i > K) sum = (sum - C(i - 1, K) + Mod) % Mod; 
		ans = (ans + 1ll * pw * C(N - 1 + i, N - 1) % Mod * sum) % Mod; 
	} 
	printf("%d\n", ans); 
    return 0; 
} 


Measured memory_bytes: 8064
#include<bits/stdc++.h>
using namespace std;
int a[110],n,ans1,ans2;
int main() {
    cin>>n;
    for(int i=1;i<=n;i++) cin>>a[i];
    sort(a+1,a+n+1,greater<int>());
    for(int i=1;i<=n;i++) {
        if(i%2!=0) ans1+=a[i];
        if(i%2==0) ans2+=a[i];
    }
    cout<<ans1-ans2<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep2(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep_inv(i, n, m) for(int i = (int)(n); i > (int)(m); i--)
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vc = vector<char>;
using vvl = vector<vl>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using vpii = vector<pll>;

int main(){
  ll N, L;
  cin >> N >> L;

  vector<string> S(N);
  rep(i, N){
    cin >> S[i];
  }

  stable_sort(S.begin(), S.end());

  rep(i, N){
    cout << S[i];
  }

  cout << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <array>
#include <algorithm>

int main(void) {
    std::array<int, 3> a;
    std::cin >> a[0] >> a[1] >> a[2];

    std::sort(a.begin(), a.end());

    std::cout << a[0] + a[1] << std::endl;
    return 0;
}


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

using ll = long long int;
using vi = vector<int>;
using vll = vector<long long int>;
using vii = vector<vi>;
using pii = pair<int, int>;

#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)
#define FOR(i, a, b) for(int (i) = a; (i) < (b);(i)++)
#define MAX(a, b) ((a > b) ? a : b)
#define MIN(a, b) ((a > b) ? b : a)

int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

const int QUA = 1e9 + 7;

int main(){
  ll n, a, b;
  scanf("%lld%lld%lld", &n, &a, &b);
  ll P, Q, ans = 0;
  scanf("%lld", &P);
  REP(i, n - 1){
    scanf("%d", &Q);
    ans += MIN(a * (Q - P), b);
    P = Q;
  }
  printf("%lld\n", ans);
  return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
	public static void main(String args[])  throws Exception{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int x = 0;
		int y = 0;
		boolean end = false;

		while (!end) {
			String temp = br.readLine();
			String[] numbers = temp.split(" ");
			x = Integer.parseInt(numbers[0]);
			y = Integer.parseInt(numbers[1]);

			if (x == 0 && y == 0) {
				end = true;
			} else if (x >= y) {
				System.out.println(y + " " + x);
			} else if (x < y) {
				System.out.println(x + " " + y);
			} else {
				// ???????????????????????????????????\???????????????
			}
		}
	}
}

Measured memory_bytes: 26920
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int X;
    cin >>X;
    int ans=1;
    for(int b=2;b<=X;b++){
        int power=b*b;
        for(int p=2;;p++){
            if(power>X){
                break;
            }
            ans=max(ans,power);
            power*=b;
        }
    }
    cout <<ans<<endl;
}

Measured memory_bytes: 3504
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define all(v) v.begin(), v.end()
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define Rep(n) for (ll _ = 0; _ < (ll)(n); _++) 
#define fs first
#define sc second
#define _GLIBCXX_DEBUG

template<class S>S sum(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
ll min(int a,ll b){return min((ll)a,b);} ll min(ll a,int b){return min(a,(ll)b);}

template <class S>
void print(vector<S> &v){for(ll i=0; i<(ll)v.size(); i++){
		cerr << v[i] << ' ';
	}
	cerr << endl;
}
template <class S>
void print(vector<vector<S>> &v) {
  	for (ll i = 0; i < (ll)v.size(); i++) {
    	for (ll j = 0; j < (ll)v[i].size(); j++) {
      		cerr << v[i][j] << ' ';
    	}
    	cerr << endl;
  	}
}

int main(void){
	ll a,b,n,x; cin >> a >> b >> n;
	if(n >= b) x=b-1;
	else x=n;
	cout << a * x / b << endl;
}

Measured memory_bytes: 3592
import sys
import itertools
# import numpy as np
import time
import math
import heapq
from collections import defaultdict
sys.setrecursionlimit(10 ** 7)
 
INF = 10 ** 9 + 7
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

# map(int, input().split())

N, K = map(int, input().split())
P = list(map(lambda x: int(x) - 1, input().split()))
C = list(map(int, input().split()))


ans = -INF
for i in range(N):
    nx = i
    total = 0
    L = [] 
    while True:
        nx = P[nx]
        total += C[nx]
        L.append(C[nx])
        if nx == i:
            break
    l = len(L)
    tmp = 0
    for j in range(l):
        if j + 1 > K:
            break
        tmp += L[j]
        now = tmp
        if total > 0:
            e = (K - j - 1) // l
            now += total * e
        ans = max(ans, now)
    # if total > 0:
    #     now = total * (K // l)
    #     ans = max(ans, now)
    #     r = K % l
    #     for j in range(r):
    #         now += L[j]
    #         ans = max(ans, now)
print(ans)




Measured memory_bytes: 81440
s = input()
n = len(s) - 1
ans = 0

for i in range(2**n):
    num = []
    bi = format(i, '0'+str(n)+'b')
    for j in range(n):
        num.append(s[j])
        if bi[j] == '1':
            num.append('+')
    num.append(s[-1])
    calc = ''.join(num)
    ans += eval(calc)

print(ans)

Measured memory_bytes: 3064
# coding:utf-8

import sys
import math
import time
#import numpy as np
import collections
from collections import deque
from collections import Counter
import queue
import copy
import bisect
import heapq
import itertools



sys.setrecursionlimit(10**7)
#N, Q = map(int, input().split())
#G = [list(input()) for i in range(H)]
#INF = V * 10001
#A = [int(i) for i in input().split()]
#AB = [list(map(int, input().split())) for _ in range(K)]

#A, B = map(int,input().split())
n = str(input())
N = int(n[-1])
ans = 0

if(N==3):
    print("bon")
elif(N==0 or N==1 or N==6 or N==8):
    print("pon")
else:
    print("hon")


Measured memory_bytes: 68680
#include<iostream>
using namespace std;
int main()
{
  unsigned long int n,i,j,num=0;
  cin>>n;
  unsigned long int a[n+1],b[n];
  for(i=0;i<n+1;i++)
    cin>>a[i];
  for(i=0;i<n;i++)
    cin>>b[i];
  for(i=0;i<n;i++)
  {
    j=i;
    while(j<i+2)
    {
    if(b[i]<=a[j])
    {
      num+=b[i];
      a[j]-=b[i];
      b[i]=0;
    }
    else
    {
      num+=a[j];
      b[i]-=a[j];
      a[j]=0;
    }
    j++;
    }
  }
  cout<<num;
  return 0;
}

Measured memory_bytes: 1792
package main

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

var scanner = bufio.NewScanner(os.Stdin)

func nextString() string {
	scanner.Scan()
	return scanner.Text()
}

func nextInt() int {
	n, err := strconv.Atoi(nextString())
	if err != nil {
		fmt.Printf("strconv.Atoi failed: %v\n", err)
	}
	return n
}

func nextFloat64() (float64, error) {
	return strconv.ParseFloat(nextString(), 64)
}

func norm2(x, y float64) float64 {
	return x*x + y*y
}

func crossProd(x1, y1, x2, y2 float64) float64 {
	return x1*y2 - x2*y1
}

func lte(x1, y1, x2, y2 float64) bool {
	if x1 == x2 {
		return y1 <= y2
	}
	return x1 <= x2
}

func main() {
	scanner.Split(bufio.ScanWords)

	p0x, _ := nextFloat64()
	p0y, _ := nextFloat64()
	p1x, _ := nextFloat64()
	p1y, _ := nextFloat64()

	p1x -= p0x
	p1y -= p0y

	nQueries := nextInt()
	for i := 0; i < nQueries; i++ {
		p2x, _ := nextFloat64()
		p2y, _ := nextFloat64()
		p2x -= p0x
		p2y -= p0y

		cross := crossProd(p1x, p1y, p2x, p2y)
		// fmt.Println(cross)
		if cross > 0 {
			fmt.Println("COUNTER_CLOCKWISE")
		} else if cross < 0 {
			fmt.Println("CLOCKWISE")
		} else {
			if (lte(0, 0, p2x, p2y) && lte(p2x, p2y, p1x, p1y)) || (lte(p1x, p1y, p2x, p2y) && lte(p2x, p2y, 0, 0)) {
				fmt.Println("ON_SEGMENT")
			} else if (lte(0, 0, p1x, p1y) && lte(p1x, p1y, p2x, p2y)) || (lte(p2x, p2y, p1x, p1y) && lte(p1x, p1y, 0, 0)) {
				fmt.Println("ONLINE_FRONT")
			} else if (lte(p2x, p2y, 0, 0) && lte(0, 0, p1x, p1y)) || (lte(p1x, p1y, 0, 0) && lte(0, 0, p2x, p2y)) {
				fmt.Println("ONLINE_BACK")
			}
		}
	}
}



Measured memory_bytes: 1148
#include<bits/stdc++.h>
#define int long long int
const int mod=1e9+7;
#define fastinout     ios_base::sync_with_stdio(false); cin.tie(NULL);

using namespace std;
int power(int x, int y, int p)
{
    int res = 1;
    x = x % p;
    while (y > 0)
    {
        if (y & 1)
            res = (res * x) % p;
        y = y >> 1;
        x = (x * x) % p;
    }
    return res;
}
int imod(int a, int m)
{
    return power(a, m - 2, m);
}

void myfun()
{
	int n,i;
	string s;
	cin>>s;
	n=s.size();
	if(s[n-1]=='s')
	cout<<s<<"es"<<"\n";
	else
	cout<<s<<"s"<<"\n";
}

signed main()
{
	 fastinout;
	int t=1;
	//cin>>t;
	while(t--)
	myfun();
	return 0;
}

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

int main(){
  int64_t A,B;
  int K;
  cin >> A >> B >> K;
  while(K>0){
    A/=2;
    B+=A;
    K--;
    if(K==0){
      break;
    }
    B/=2;
    A+=B;
    K--;
  }
  cout << A << " " << B << endl;
  return 0;
}


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

typedef long long ll;

int n,h,w;
int H,W;
int main()
{
    ll n,p;
    cin>>n>>p;

    ll ans=1;
    for(ll i=2,sq=sqrt(p+0.5);i<=sq;i++)if(p%i==0)
    {
        int cnt=0;
        while(p%i==0)p/=i,cnt++;
        for(int j=cnt/n;j>=1;j--)ans*=i;
    }
    if(p>1)for(int j=1/n;j>=1;j--)ans*=p;
    cout<<ans<<endl;
}


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

int main(){
  int N;
  int W[111];
  cin >> N;
  int i;
  for(i=0;i<=N-1;i++)
    cin >> W[i];
  int T;
  int sum = 0;
  for(i=0;i<=N-1;i++)
    sum += W[i];
  int sa[111];
  for(T=0;T<=N-1;T++){
    sa[T] = sum;
    for(i=0;i<=T-1;i++)
      sa[T] -= 2 * W[i];
      }
  for(i=0;i<=N-1;i++)
    if(sa[i] < 0) sa[i] *= (-1);
  int min  = sa[0];
  for(i=0;i<=N-1;i++)
    if(min > sa[i])
      min = sa[i];
  cout << min << endl;
}

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

long long gcd(long long, long long);

int main() {
	long long a, b;
	cin >> a >> b;

	long long g = gcd(a, b);

	long long count = 1;
	long long p = 2;
	while (g >= p * p) {
		if (g % p == 0) {
			++count;
		}

		while (g % p == 0) {
			g /= p;
		}

		++p;
	}

	if (g != 1) {
		++count;
	}

	cout << count;
}

long long gcd(long long a, long long b) {
	return a == 0 ? b : gcd(b % a, a);
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <clocale>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i, s, n) for(int i = (s), i##_len=(n); i < i##_len; ++i)
#define FORS(i, s, n) for(int i = (s), i##_len=(n); i <= i##_len; ++i)
#define VFOR(i, s, n) for(int i = (s); i < (n); ++i)
#define VFORS(i, s, n) for(int i = (s); i <= (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) FORS(i, 0, n)
#define VREP(i, n) VFOR(i, 0, n)
#define VREPS(i, n) VFORS(i, 0, n)
#define RFOR(i, s, n) for(int i = (s), i##_len=(n); i >= i##_len; --i)
#define RFORS(i, s, n) for(int i = (s), i##_len=(n); i > i##_len; --i)
#define RREP(i, n) RFOR(i, n, 0)
#define RREPS(i, n) RFORS(i, n, 0)
#define ALL(v) (v).begin(), (v).end()
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v), greater<decltype(v[0])>())
#define SZ(x) ((int)(x).size())
#define REV(x) reverse(ALL(x))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define MT make_tuple
#define BIT(n) (1LL<<(n))
#define UNIQUE(v) v.erase(unique(ALL(v)), v.end())

using ld = long double;
using ll = long long;
using ui = unsigned int;
using ull = unsigned long long;
using Pi_i = pair<int, int>;
using Pll_ll = pair<ll, ll>;
using VB = vector<bool>;
using VC = vector<char>;
using VD = vector<double>;
using VI = vector<int>;
using VLL = vector<ll>;
using VS = vector<string>;
using VSH = vector<short>;
using VULL = vector<ull>;

const int MOD = 1000000007;
const int INF = 1000000000;
const int NIL = -1;
const double EPS = 1E-10;

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


int main(){
    int N; cin >> N;
    int a(N);
    REP(i, N){
        if(i * (i+1) / 2 >= N){
            a = i;
            break;
        }
    }
    int d = a * (a+1) / 2 - N;
    FORS(i, 1, a){
        if(i != d) cout << i << "\n";
    }
    return 0;
}


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

#define pb push_back
#define mp make_pair
#define pf push_front
#define ff first
#define ss second
#define vll vector < ll >
#define vvll vector < vll >
#define vld vector < ld >
#define pll pair < ll,ll > 
#define pld pair < ld,ld > 
#define vpll vector < pll >
#define vpld vector < pld >
#define all(X) X.begin(),X.end()
#define endl "\n"
#define sz(x) ((ll)((x).size()))
vll emptyVector;
const ll MAX = 1e5 + 5;
const ll INF = 1e18;
const ll MOD = 1e9 + 7;
const ld pi = 3.141592653589793238462643383279502884197169399375105;

ll binaryExpo(ll x, ll n)
{
	if(n == 0)
		return 1;
	if(n % 2 == 0)
		return binaryExpo((x*x) % MOD, n/2);
	return (x*binaryExpo((x*x) % MOD, n/2)) % MOD;
}

ll gcd(ll a, ll b)
{
	if(b == 0)
		return a;
	return gcd(b, a % b);
}
/*-------------------------------------------		CODE STARTS FROM HERE		------------------------------------------*/

ll ans = -1, dis[MAX];
vll adj[MAX], ADJ[MAX], v;
bool vis[MAX];

void dfs(int x)
{
	vis[x] = true;
	for(int i = 0; i < adj[x].size(); i++)
	{
		if(!vis[adj[x][i]])
			dfs(adj[x][i]);
	}
	v.pb(x);
}

void dfs2(int x)
{
	vis[x] = true;
	for(int i = 0; i < ADJ[x].size(); i++)
	{
		if(!vis[ADJ[x][i]])
			dfs2(ADJ[x][i]);
		dis[x] = max(dis[x], 1 + dis[ADJ[x][i]]);
	}
	ans = max(ans, dis[x]);
}


void solve(void)
{
	int n, m;
	cin >> n >> m;

	for(int i = 1; i <= n; i++)
	{
		vis[i] = false;
		dis[i] = 1;
	}

	for(int i = 0; i < m; i++)
	{
		int x, y;
		cin >> x >> y;
		adj[x].pb(y);
		ADJ[y].pb(x);
	}

	for(int i = 1; i <= n; i++)
	{
		if(!vis[i])
			dfs(i);
	}

	for(int i = 1; i <= n; i++)
		vis[i] = false;

	for(int i = 0; i < sz(v); i++)
	{
		if(!vis[v[i]])
			dfs2(v[i]);
	}

	cout << ans - 1 << endl;


	

}


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

	// int t;
	// cin >> t;
	// while(t--)
	{	
		solve();
	}




	return 0;
}

Measured memory_bytes: 17656
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define mp make_pair
 
const int N = 303;
int n;
ll a[N][N];
ll ans = 0;
 
int main()
{
	scanf("%d", &n);
	for (int i = 0; i < n; i++)
		for (int j = 0; j < n; j++) {
			scanf("%lld", &a[i][j]);
		}
	
	for (int i = 0; i < n; i++)
		for (int j = 0; j < i; j++) {
			ll w = a[i][j] + 1;
			for (int k = 0; k < n; k++) {
				if (i == k || j == k) continue;
				w = min(w, a[i][k] + a[k][j]);
			}
			if (w < a[i][j]) {
				printf("-1\n");
				return 0;
			}
			if (w > a[i][j]) ans += a[i][j];
		}
	printf("%lld\n", ans);
 
	return 0;
}

Measured memory_bytes: 896
N, A, B, C = map(int, input().split())
L = [int(input()) for _ in range(N)]

INF = 10**9

def dfs(n, a, b, c): # n本目を使用するかしないか
  if n == N: # 全ての竹を選び終わったら、延長魔法と短縮魔法を使ってA,B,Cの長さにする
    if min(a, b, c) > 0: # 最低でも1本のみ使用する
      return abs(A-a)+abs(B-b)+abs(C-c)-30 # 1本使用の場合は合成しないため-30
    else:
      return INF
  ret0 = dfs(n + 1, a, b, c) # 使わない
  ret1 = dfs(n + 1, a + L[n], b, c) + 10 # Aに使う
  ret2 = dfs(n + 1, a, b + L[n], c) + 10 # Bに使う
  ret3 = dfs(n + 1, a, b, c + L[n]) + 10 # Cに使う
  return min(ret0, ret1, ret2, ret3)

print(dfs(0,0,0,0))

Measured memory_bytes: 3064
ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))

n,k = mi()
alis = li()
for i in range(n):
    alis[i] -= 1

dp = [0]*(n+1)
dp2 = [0]*(n+1)

ima = 0
for i in range(n):
    ima = alis[ima]
    if dp[ima] == 0:
        dp[ima] = i+1
    else:
        ragu = i+1
        dp2[ima] = i+1
        break
for i in range(1,n+1):
    ima = alis[ima]
    if dp2[ima] == 0:
        dp2[ima] = i + ragu
    else:
        ragu2 = ragu + i
        break

if k < ragu:
    for i in range(0,n):
        if dp[i] == k:
            print(i+1)
            exit()

else:
    delta = ragu2 - ragu
    for i in range(n):
        if dp2[i] == 0:
            continue
        else:
            tmp = k - dp2[i]
            if tmp % delta == 0:
                print(i+1)
                exit()





Measured memory_bytes: 32408
<?php
$n=trim(fgets(STDIN));
$X=explode(' ',trim(fgets(STDIN)),$n);
$Y=explode(' ',trim(fgets(STDIN)),$n);

$A=$B=$C=$D=0.0;
for($i=0;$i<$n;$i++){
  $a=($X[$i]<$Y[$i])?$Y[$i]-$X[$i]:$X[$i]-$Y[$i];
  $b=$a*$a;
  $A+=$a;
  $B+=$b;
  $C+=$b*$a;
  if($D<$a){$D=$a;}
}
echo $A
,PHP_EOL
,sqrt($B)
,PHP_EOL
,pow($C,1/3)
,PHP_EOL
,$D;
?>

Measured memory_bytes: 15620
using System;
using System.Collections.Generic;
using System.Text;

namespace codeTester.contest190707
{
    class ProblemA
    {
        static List<long> values = new List<long>();
        static long answer = 0;

        public static void Main(string[] args)
        {
            Input();
            Logic();
            Output();
        }

        static void Input()
        {
            values = ReadSpaceSeparatedValues();
        }

        public static List<long> ReadSpaceSeparatedValues()
        {
            List<long> values = new List<long>();
            string[] inputs = Console.ReadLine().Split(' ');
            foreach (string input in inputs)
            {
                values.Add(long.Parse(input));
            }

            return values;
        }

        static void Logic()
        {
            long n = values[0];
            long a = values[1];
            long b = values[2];

            answer = Math.Min(n * a, b);
        }

        static void Output()
        {
            Console.WriteLine(answer.ToString());
        }
    }
}


Measured memory_bytes: 11220
#include<iostream>
#include<string>
using namespace std;
int main(){
  string str;
  while(cin>>str){
    string tate[8];
    tate[0]="";tate[0]+=str[0];tate[0]+=str[3];tate[0]+=str[6];
    tate[1]="";tate[1]+=str[1];tate[1]+=str[4];tate[1]+=str[7];
    tate[2]="";tate[2]+=str[2];tate[2]+=str[5];tate[2]+=str[8];
    tate[3]="";tate[3]+=str[0];tate[3]+=str[1];tate[3]+=str[2];
    tate[4]="";tate[4]+=str[3];tate[4]+=str[4];tate[4]+=str[5];
    tate[5]="";tate[5]+=str[6];tate[5]+=str[7];tate[5]+=str[8];
    tate[6]="";tate[6]+=str[0];tate[6]+=str[4];tate[6]+=str[8];
    tate[7]="";tate[7]+=str[2];tate[7]+=str[4];tate[7]+=str[6];
    int flag=1;
    for(int i=0;i<8;i++){
      if(tate[i].compare("ooo")==0){
	flag=0;
	cout<<"o"<<endl;
	break;
      }else if(tate[i].compare("xxx")==0){
	flag=0;
	cout<<"x"<<endl;
	break;
      }
    }
    if(flag)
      cout<<"d"<<endl;
  }
  return 0;
}

Measured memory_bytes: 3104
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define rep2(i,n) for(int i = 1; i <= (n); ++i)
#define rrep2(i,n) for(int i = (n); i > 0; --i)
#define srep(i,s,n) for(int i = s; i < (n); ++i)
#define rsrep(i,s,n) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<(x)<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { int n = (__VA_ARGS__).size(); rep(i, n) printf("%d%s", (__VA_ARGS__)[i], i != n-1 ? " " : "\n"); }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;


int main() {
    int n, x, t;
    cin >> n >> x >> t;

    int ans = (n + (x - 1)) / x * t;

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

Measured memory_bytes: 3644
#include <iostream>
#include <string>
#include <math.h>
#include <iomanip>
#include <stdio.h>
#include <algorithm>
#include <ctime>
#include <vector>
#include <set>
#include <queue>
using namespace std;
typedef long long ll;

#define PI 3.14159265358979323846264338327950L

int res=0;

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

    int N,K;
    cin >> N >> K;
    vector<int> sunuke(N,0);
    for(int i = 0; i < K; i++ )
    {
        int D;
        cin >> D;
        for (int j = 0; j < D; j++)
        {
            int tmp;
            cin >> tmp;
            sunuke[tmp - 1]++;
        }
    }
    for(int i = 0; i < N; i++ )
    {
        if(sunuke[i]==0){
            res++;
        }
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 3652
#include<iostream>
#include<cstdlib>
#include<cmath>
using namespace std;

int main(){
    int n;
    cin >> n;
    int t, a;
    cin >> t >> a;

    int ans;
    double min = 100000.0;
    for(int i = 0; i < n; i++){
        int h;
        cin >> h;
        double tmp = t - (h * 0.006);
        double sa = abs(tmp - a);
        if(sa < min){
            min = sa;
            ans = i + 1;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define LL long long
#define INF 0x3f3f3f3f
#define Inf 1000000000000000000LL
#define F first
#define S second
using namespace std;
typedef pair<int,int>pii;
int n,m;
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>n>>m;
	vector<vector<int> >a(n,vector<int>(n,0));
	LL total=0;
	for(int i=0;i<m;i++){
		int x,y,z;
		cin>>x>>y>>z;
		x--,y--;
		a[x][y]=a[y][x]=z;
		total+=z;
	}
	const int inf=(int)1e9;
	vector<int>inside(1<<n);
	for(int t=0;t<(1<<n);t++)
		for(int i=0;i<n;i++)if(t&(1<<i))
			for(int j=i+1;j<n;j++)if(t&(1<<j))
				inside[t]+=a[i][j];
	vector<vector<int> >dp(1<<n,vector<int>(n,-1));
	for(int t=0;t<(1<<n);t++)if(t&1)dp[t][0]=inside[t];
	for(int t=0;t<(1<<n);t++)
		for(int ii=0;ii<n;ii++){
			if(dp[t][ii]==-1)continue;
			int u=(1<<n)-1-t;
			while(u>0){
				for(int j=0;j<n;j++)
					if(u&(1<<j))if(a[ii][j]>0)
							dp[t|u][j]=max(dp[t|u][j],dp[t][ii]+inside[u]+a[ii][j]);
				u=(u-1)&((1<<n)-1-t);
			}
		}
	cout<<total-dp[(1<<n)-1][n-1]<<endl;
	return 0;
}


Measured memory_bytes: 3712
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,a,n) for(int i=a;i<n;i++)
#define been(ix) (ix).begin(),(ix).end()
using namespace std;
typedef long long ll; 
typedef vector<int> vi;
typedef vector<long long> vl;
const ll INFL = 1e18;
const int INF = 1001001001; 
typedef pair<int,int> P;
#define foreach(ix,i) for(auto& (ix) : (i))
typedef long double ld;
const int mod =1000000007;

int main(){
   int n;cin>>n;
   ll a[n];
   

   rep(i,n)cin>>a[i];
   ll sum =0;

   rep(i,n)sum+=a[i];

   ll x =sum;
   rep (i,n){
       //if(i==0)continue;
       if(i%2==1)x-=2*a[i];
   }
   //cout<<1<<endl;
   vl ans;
   ans.push_back(x);
   rep(i,n-1){
       //if(i==0)continue;
       ans.push_back((a[i]-(ans[i]/2))*2);
   }
   rep(i,n-1){
       cout<<ans[i]<<' ';
   }
   cout<<ans[n-1]<<endl;
}


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

int main(){
	int a,b,sum,keta;
	while(cin>>a>>b){
		sum=a+b;
		for(keta=1;;keta++){
			sum=sum/10;
			if(sum==0)break;
		}
		cout<<keta<<endl;
	}
	return 0;
}

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

struct Dice {
 public:
  vector<int> num = vector<int>(6);
  vector<int> tmp = vector<int>(6);

  void Roll(char ch) {
    tmp = num;
    if (ch == 'S') {
      num.at(0) = tmp.at(4);
      num.at(1) = tmp.at(0);
      num.at(2) = tmp.at(2);
      num.at(3) = tmp.at(3);
      num.at(4) = tmp.at(5);
      num.at(5) = tmp.at(1);
    } else if (ch == 'W') {
      num.at(0) = tmp.at(2);
      num.at(1) = tmp.at(1);
      num.at(2) = tmp.at(5);
      num.at(3) = tmp.at(0);
      num.at(4) = tmp.at(4);
      num.at(5) = tmp.at(3);

    } else if (ch == 'N') {
      num.at(0) = tmp.at(1);
      num.at(1) = tmp.at(5);
      num.at(2) = tmp.at(2);
      num.at(3) = tmp.at(3);
      num.at(4) = tmp.at(0);
      num.at(5) = tmp.at(4);

    } else if (ch == 'E') {
      num.at(0) = tmp.at(3);
      num.at(1) = tmp.at(1);
      num.at(2) = tmp.at(0);
      num.at(3) = tmp.at(5);
      num.at(4) = tmp.at(4);
      num.at(5) = tmp.at(2);
    } else if (ch == 'C') {
      num.at(0) = tmp.at(0);
      num.at(1) = tmp.at(2);
      num.at(2) = tmp.at(4);
      num.at(3) = tmp.at(1);
      num.at(4) = tmp.at(3);
      num.at(5) = tmp.at(5);
    }
  }
  void Print(int n) { cout << num.at(n) << endl; }
  int Check(int a) { return num.at(a); }
};

bool same(Dice a, Dice b) {
  bool flag = false;

  for (int i = 0; i < 4; i++) {
    for (int j = 0; j < 4; j++) {
      bool compd = a.num.at(0) == b.num.at(0) && a.num.at(1) == b.num.at(1) &&
                   a.num.at(2) == b.num.at(2) && a.num.at(3) == b.num.at(3) &&
                   a.num.at(4) == b.num.at(4) && a.num.at(5) == b.num.at(5);
      if (compd) {
        flag = true;
        break;
      }
      a.Roll('C');
    }
    if (flag) break;
    a.Roll('N');
  }
  a.Roll('E');
  for (int i = 0; i < 4; i++) {
    for (int j = 0; j < 4; j++) {
      bool compd = a.num.at(0) == b.num.at(0) && a.num.at(1) == b.num.at(1) &&
                   a.num.at(2) == b.num.at(2) && a.num.at(3) == b.num.at(3) &&
                   a.num.at(4) == b.num.at(4) && a.num.at(5) == b.num.at(5);
      if (compd) {
        flag = true;
        break;
      }
      a.Roll('C');
    }
    if (flag) break;
    a.Roll('N');
  }
  return flag;
}

int main() {
  int n;
  cin >> n;
  vector<Dice> dice_vec(n);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 6; j++) {
      cin >> dice_vec.at(i).num.at(j);
    }
  }
  bool ans;
  for (int i = 0; i < n - 1; i++) {
    for (int j = i + 1; j < n; j++) {
      ans = same(dice_vec.at(i), dice_vec.at(j));
      if (ans) break;
    }
    if (ans) break;
  }

  if (!ans)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 3156