akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;

namespace AtCoder.D
{
    public class Program
    {
        public static void Main() { var r = GetResult(); Debug.WriteLine(r); Console.Write(r); }

        private static object GetResult()
        {
            var (H, W) = Read2Longs();
            var N = ReadLong();
            var a = ReadLongs();

            var q = new Queue<long>();
            for (int n = 0; n < N; n++)
            {
                var count = a[n];
                for (int i = 0; i < count; i++)
                {
                    q.Enqueue(n + 1);
                }
            }

            var table = new long[H, W];
            for (int i = 0; i < W; i++)
            {
                if (i % 2 == 0)
                {
                    for (int j = 0; j < H; j++)
                    {
                        table[j, i] = q.Dequeue();
                    }
                }
                else
                {
                    for (int j = (int)H - 1; j >= 0; j--)
                    {
                        table[j, i] = q.Dequeue();
                    }
                }
            }

            var sb = new StringBuilder();
            for (int i = 0; i < H; i++)
            {
                var l = "";
                for (int j = 0; j < W; j++)
                {
                    if (string.IsNullOrEmpty(l))
                    {
                        l += table[i, j];
                    }
                    else
                    {
                        l += " " + table[i, j];
                    }
                }
                sb.AppendLine(l);
            }

            return sb.ToString().Trim();
        }

        #region Console.Read

        public static string ReadText() { return Console.ReadLine(); }
        public static List<string> ReadTexts() { return Console.ReadLine().Split(' ').ToList(); }
        public static long ReadLong() { return long.Parse(Console.ReadLine()); }
        public static (long, long) Read2Longs() { var ls = ReadLongs(); return (ls[0], ls[1]); }
        public static (long, long, long) Read3Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2]); }
        public static (long, long, long, long) Read4Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2], ls[3]); }
        public static (long, long, long, long, long) Read5Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2], ls[3], ls[4]); }
        public static List<long> ReadLongs() { return Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToList(); }

        #endregion
    }
}


Measured memory_bytes: 34688
#include <bits/stdc++.h>
#include <stdio.h>
#include <math.h>
using namespace std;
using vi = vector<int>;
using vll = vector<long long int>;
using vb = vector<bool>;
using vvi = vector<vector<int>>;
using vvll = vector<vector<long long int>>;
using ll = long long int;
 
 
int main(){
    ll N, M;
    cin >> N;
    cout << setprecision(10) << 2*N*3.1415926535;
}

Measured memory_bytes: 3788
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer tokenizer = new StringTokenizer(input.readLine());
        int number = Integer.parseInt(tokenizer.nextToken() + tokenizer.nextToken());
        double result = Math.sqrt(number);
        int round = (int) result;
        System.out.println(result == round ? "Yes" : "No");
    }
}


Measured memory_bytes: 20948
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  vector<long long> A(N);
  vector<bitset<20>> Abit(N);
  for (int i=0;i<N;i++){
    cin >> A[i];
    bitset<20> s(A[i]);
    Abit[i]=s;
  }
  long long ans=0,sum=A[0];
  bitset<20> xsum(A[0]);
  int s=0,t=0;
  for (;;){
    while(t<N&&sum==xsum.to_ullong()){
      t++;
      sum+=A[t];
      xsum^=Abit[t];
      ans+=t-s;
    }
    if (t==N){
      break;
    }
    sum-=A[s];
    xsum^=Abit[s];
    s++;
  }
  cout << ans << endl;
}

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

int main(){
	string s;
	cin>>s;
	int flag=0;
	for(int i=0;i<s.size();i++){
		int cnt=0;
		for(int j=0;j<s.size();j++){
			if(s[i]==s[j]) cnt++;
		}
		if(cnt>1) flag=1;
		if(flag==1) break;
	}
	if(flag==1) cout<<"no"<<endl;
	else cout<<"yes"<<endl;
	return 0;
}

Measured memory_bytes: 256
N, A, B, C = map(int, input().split())

path = []
inputs = [input() for _ in range(N)]

for i in range(N):
	target = inputs[i]
	if target == 'AB':
		if A > B:
			A -= 1
			B += 1
			path.append('B')
		elif A == 1 and B == 1:
			if i != N - 1 and inputs[i + 1] == 'AC':
				A += 1
				B -= 1
				path.append('A')
			else:
				A -= 1
				B += 1
				path.append('B')
		else:
			A += 1
			B -= 1
			path.append('A')
	if target == 'AC':
		if A > C:
			A -= 1
			C += 1
			path.append('C')
		elif A == 1 and C == 1:
			if i != N - 1 and inputs[i + 1] == 'AB':
				A += 1
				C -= 1
				path.append('A')
			else:
				A -= 1
				C += 1
				path.append('C')
		else:
			A += 1
			C -= 1
			path.append('A')
	if target == 'BC':
		if B > C:
			B -= 1
			C += 1
			path.append('C')
		elif B == 1 and C == 1:
			if i != N - 1 and inputs[i + 1] == 'AB':
				B += 1
				C -= 1
				path.append('B')
			else:
				B -= 1
				C += 1
				path.append('C')
		else:
			B += 1
			C -= 1
			path.append('B')
	if A < 0 or B < 0 or C < 0:
		print('No')
		exit(0)

print('Yes')
for i in path:
	print(i)


Measured memory_bytes: 17068
#include <bits/stdc++.h>
using namespace std;
int main()
  {int N, K; cin >> N >> K;
  int s = 0, m = 0;
  vector<int> ps(N); for (auto &p : ps) cin >> p;
  for (int i = 0; i < N; ++i)
    {s += ps[i];
    if (i >= K) s -= ps[i - K];
    m = max(m, s);}
  cout << fixed << setprecision(12) << 0.5 * (m + K) << endl;}

Measured memory_bytes: 1024
package main

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

func main() {
	Result := 9999999999
	S := ReadLine()

	for i := 0; i < len(S)-2; i++ {
		LS := S[i : i+3]
		LSInt, _ := strconv.Atoi(LS)
		Result = Min(Result, Abs(753-LSInt))
	}

	fmt.Println(Result)
}

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

func fln(format string, elements ...interface{}) {
	fmt.Printf(format+"\n", elements...)
}

var BufReader = bufio.NewReaderSize(os.Stdin, 1e6)

func ReadLine() string {
	a, _, _ := BufReader.ReadLine()
	return string(a)
}

func ReadLineInt() (result []int) {
	in := strings.Split(ReadLine(), " ")
	result = make([]int, 0, 2)
	for _, v := range in {
		t, _ := strconv.Atoi(v)
		result = append(result, t)
	}
	return
}

func Min(a, b int) int {
	if a > b {
		return b
	}
	return a
}

func Abs(i int) int {
	if i >= 0 {
		return i
	}
	return i * -1
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll dp[114514][3];

int main() {
	ll n,k,r,s,p;
	string t;
	cin>>n>>k>>r>>s>>p>>t;
	for(int i=0;i<k;i++){
		if(t[i]=='s')dp[i][0]+=r;
		if(t[i]=='p')dp[i][1]+=s;
		if(t[i]=='r')dp[i][2]+=p;
	}
	ll ans=0;
	for(int i=0;i<k;i++){
		ll num=i+k;
		while(1){
			if(num>=n)break;
			dp[num][0]=max(dp[num-k][1],dp[num-k][2]);
			dp[num][1]=max(dp[num-k][2],dp[num-k][0]);
			dp[num][2]=max(dp[num-k][0],dp[num-k][1]);
			if(t[num]=='s')dp[num][0]+=r;
			if(t[num]=='p')dp[num][1]+=s;
			if(t[num]=='r')dp[num][2]+=p;
			num+=k;
		}
		num-=k;
		ans+=max({dp[num][0],dp[num][1],dp[num][2]});
		//cout<<ans<<endl;
	}
	//for(int i=0;i<n;i++)cout<<dp[i][0]<<' '<<dp[i][1]<<' '<<dp[i][2]<<endl;
	cout<<ans;
	return 0;
}


Measured memory_bytes: 2816
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>

using namespace std;
typedef long long ll;

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	if (a + b + c <= 21) {
		cout << "win" << endl;
	}
	else {
		cout << "bust" << endl;
	}

	return 0;
}

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


int main() {

   int n,p;
   cin>>n>>p;
   int min_index;int k = INT_MAX;
   for(int i=0;i<n;i++){
    int temp;
    cin>>temp;
    if(temp<k){
        k=temp;
        min_index=i;
    }
   }
  // cout<<min_index;
  int left =min_index;
  int right = n-min_index;
  cout<<(n-1+p-1-1)/(p-1);

 return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < (int)b; i++)
#define all(v) v.begin(), v.end()
const int MOD = 1e9 + 7;
const ll INF = 1e18;
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main() {
    int n, m;
    cin >> n >> m;
    vector<vector<pair<int, int>>> g(n);
    rep(i, 0, m) {
        int l, r, c;
        cin >> l >> r >> c;
        l--;
        r--;
        g[l].push_back(make_pair(c, r));
        g[r].push_back(make_pair(c, l));
    }
    rep(i, 1, n) {
        g[i].push_back(make_pair(0, i - 1));
    }

    vector<ll> dist(n, INF);
    priority_queue<pair<ll, int>> pq;
    pq.push(make_pair(0, 0));
    dist[0] = 0;
    while (!pq.empty()) {
        auto tmp = pq.top();
        pq.pop();
        int v = tmp.second;
        if (dist[v] < -tmp.second) continue;
        for (auto i : g[v]) {
            int nc = i.first;
            int nv = i.second;
            if (dist[v] + nc < dist[nv]) {
                dist[nv] = dist[v] + nc;
                pq.push(make_pair(-dist[nv], nv));
            }
        }
    }
    if (dist[n - 1] == INF) cout << -1 << endl;
    else cout << dist[n - 1] << endl;

    return 0;
}


Measured memory_bytes: 9848
n, k = map(int, input().split())
arr = [0] * int(1e5+10)

for i in range(n):
        a, b = map(int, input().split())
        arr[a-1] += b

for i in range(100001):
        k -= arr[i]
        if k<=0:
                print(i+1)
                break

Measured memory_bytes: 5744
#include <iostream>
#include <string>
#include <vector>
#include <cassert>
#include <algorithm>
#include <math.h> 
#include <set>
#include <map>

using namespace std;

#define ll long long int
#define rep(i, n) for(ll i = 0; i < n; i++)
#define repp(i, n) for(int i = 1; i <= n; i++)
#define sort(v) sort((v).begin(), (v).end())
#define riverse(v) reverse((v).begin(), (v).end())
using vi = vector<int>;
using vs = vector<string>;
using vll = vector<ll>;
using vvi = vector<vi>;
const ll MOD = 1e9 + 7;


int main() {
	int N, M;
	cin >> N >> M;
	ll ans;
	if (N == M) {
		ans = 2;
		for (int i = 1; i <= N; i++) {
			ans = ans * i;
			ans = ans % MOD;
			ans = ans * i;
			ans = ans % MOD;
		}
	}
	else if (N == M + 1) {
		ans = M + 1;
		for (int i = 1; i <= M; i++) {
			ans = ans * i;
			ans = ans % MOD;
			ans = ans * i;
			ans = ans % MOD;
		}
	}
	else if (M == N + 1) {
		ans = N + 1;
		for (int i = 1; i <= N; i++) {
			ans = ans * i;
			ans = ans % MOD;
			ans = ans * i;
			ans = ans % MOD;
		}
	}
	else ans = 0;
	cout << ans << endl;
}

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

int get_timestamp(string t)
{
  int h = stoi(t.substr(0, 2));
  int m = stoi(t.substr(3, 2));
  int s = stoi(t.substr(6, 2));
  return h * 60 * 60 + m * 60 + s;
}

int main()
{
  while (1)
  {
    int n;
    cin >> n;
    if (!n)
      break;
    vector<int> t(MAX, 0);
    rep(i, n)
    {
      string s, e;
      cin >> s >> e;
      t.at(get_timestamp(s))++;
      t.at(get_timestamp(e))--;
    }
    rep(i, MAX - 1)
    {
      t.at(i + 1) += t.at(i);
    }
    int ans = 0;
    rep(i, MAX - 1)
    {
      ans = max(ans, t.at(i));
    }
    cout << ans << endl;
  }
}


Measured memory_bytes: 3492
#include<iostream>
#include<algorithm>
#include<set>
#include<math.h>
#include<vector>
#include<sstream>
#include<queue>
#include<functional>
#include<bitset>
#include<cstdio>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include <string.h>

using ll = long long;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, x) for(int i=1;i<=(int)(x);i++)
#define rrep(i, x) for(int i=((int)(x)-1);i>=0;i--)
#define rreps(i, x) for(int i=(int)(x);i>0;i--)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define vll vector<ll>
#define vi vector<int>
#define vpll vector<pair<ll,ll>>
#define vpi vector<pair<int,int>>
#define mod 1000000007
#define put2darr(arr, row, col) rep(i, row) { rep(j, col) { printf("%18d", arr[i][j]); } cout << endl; }

using namespace std;

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

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

/* 1..10
 * rep:   0 1 2 3 4 5 6 7 8 9
 * reps:  1 2 3 4 5 6 7 8 9 10
 * rrep:  9 8 7 6 5 4 3 2 1 0
 * rreps: 10 9 8 7 6 5 4 3 2 1
 */


int main() {
    int n;
    double x;
    string v;
    cin >>n;
    double ans = 0;
    rep(i, n){
        cin >> x >>v;
        if(v == "JPY"){
            ans += x;
        }else{
            ans += x *380000;
        }
    };
    cout << setprecision(20) << ans << endl;
}


Measured memory_bytes: 256
import Data.Char
main = do
  s <- getLine
  print $ foldl (+) 0 $ map eval $ sss' (s, 1) (length s)

ss'' :: (String, Int) -> [(String, Int)]
ss'' (xs, n) = [((take n xs)++"+"++(drop n xs), n+2), (xs, n+1)]

sss' :: (String, Int) -> Int -> [String]
sss' s n = 
  if n == 1
  then return $ fst s
  else do
    s' <- ss'' s
    sss' s' (n-1)

eval :: String -> Int
eval s = let xs = foldl e [0] s in
           if length xs == 1
           then head xs
           else head xs + last xs

e :: [Int] -> Char -> [Int]
e (n:(-1):m:xs) '+' = (-1):(n+m):xs
e xs '+' = (-1):xs
e ((-1):xs) n = (digitToInt n):(-1):xs
e (n:xs) m = (n*10 + (digitToInt m)):xs


Measured memory_bytes: 892
import numpy as np
def solve(n, x, y):
    x = np.asarray(x)
    y = np.asarray(y)
    z = x + y
    w = x - y
    return max(np.max(z) - np.min(z), np.max(w) - np.min(w))

n = int(input())
x, y = zip(*[map(int, input().split()) for i in range(n)])
print(solve(n, x, y))


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

#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define read()          freopen("in.txt","r",stdin)
#define write()         freopen("out.txt","w",stdout)
#define sf(n)           scanf("%d",&n)
#define sfd(n)          scanf("%lf",&n)
#define sl(x)           scanf("%I64d",&x)
#define sfl(n)          scanf("%lld", &n)
#define sfc(n)          scanf(" %c",&n)
#define sful(n)         scanf("%llu",&n)
#define ull             unsigned long long
#define endll           pf("\n")
#define pf              printf
#define PI              acos(-1.0)
#define eps             1e-12
#define mem(a,b)        memset(a,b,sizeof(a))
#define pb              push_back
#define xx              first
#define yy              second
#define pii             pair<int, int>
#define pll             pair<ll, ll>
#define MP make_pair
#define ll              long long
#define uniq(a)      a.erase(unique(a.begin(), a.end()), a.end())
#define cnd tree[idx]
#define lnd tree[idx<<1]
#define rnd tree[(idx<<1)+1]
#define lndp (idx<<1),(b),((b+e)>>1)
#define rndp ((idx<<1)+1),(((b+e)>>1)+1),(e)
#define inf 1999999999
#define MOD  1000000007
#define mod1 1000000009
#define var    int n,m,i,j,c=0,t,l,r,mid,z=0,k,x,y
#define aloc(n,t) ((t*)malloc((n)*sizeof(t)))

int dx[8]={0,0,1,1,-1,-1,1,-1};  //8 direction
int dy[8]={1,-1,1,-1,1,-1,0,0};
//int dx[4]={1,-1,0,0};  //4 direction
//int dy[4]={0,0,1,-1};

int n,m,a[200005];

int main()
{
    string s;
    cin>>s;
    n = s.size();
    if(s[n-1] == 's')s+="es";
    else s+="s";

    cout<<s<<endl;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("O3,Ofast,no-stack-protector,unroll-loops,fast-math")
#define IOS ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
int main(){
    long long x,k;
    cin>>k>>x;
    if(k*500>=x){
	cout<<"Yes";
    }
    else{
	cout<<"No";
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <cmath>
#include <iomanip>
#include <functional>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) (int)(x).size()
using namespace std;
using ll = long long;
constexpr int inf = 1000000000;
constexpr ll INF = 1000000000000000000;
template <typename T> bool chmin(T &x, const T &y) {if (x < y) {x = y; return true;} return false;}
template <typename T> bool chmax(T &x, const T &y) {if (x > y) {x = y; return true;} return false;}

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    rep(i, N) cin >> A[i];
    
    map<int, int> cnt;
    rep(i, N) ++cnt[A[i]];
    int ans = 0;
    for (auto p : cnt) {
        if (p.second < p.first) ans += p.second;
        if (p.first < p.second) ans += (p.second - p.first);
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 8276
L, R = map(int, input().split())
if L == 0 or L // 2019  != R // 2019:
    print(0)
else:
    mod_min = 2019
    for i in range(L, R):
        for j in range(i+1, R+1):
            mod = (i * j) % 2019
            mod_min = min(mod_min, mod)
    print(mod_min)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>

#define INF 1000000021
#define MOD 1000000007
#define pb push_back
#define sqr(a) (a)*(a)
#define M(a, b) make_pair(a,b)
#define T(a, b, c) make_pair(a, make_pair(b, c))
#define F first
#define S second
#define all(x) (x.begin(), x.end())
#define deb(x) cerr << #x << " = " << x << '\n'
#define N 222222

using namespace std;
//using namespace __gnu_pbds;

typedef long double ld;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;

const ld pi = 2 * acos(0.0);
template<class T> bool umin(T& a, T b){if(a>b){a=b;return 1;}return 0;}
template<class T> bool umax(T& a, T b){if(a<b){a=b;return 1;}return 0;}
template<class T, class TT> bool pal(T a, TT n){int k=0;for(int i=0;i<=n/2;i++){if(a[i]!=a[n-i-1]){k=1;break;}}return k?0:1;}

//int month[] = {0,31,28,31,30,31,30,31,31,30,31,30,31};


int dp[N];
int main()
{
	int n;
	string s;
	cin >> n;
	cin >> s;
	int c = 0;
	for(int i = 0; i < n; i ++)
	{
		c += (s[i] == 'R');
		if(i)
			dp[i] = dp[i - 1];
		dp[i] += (s[i] == 'R');	
	}
	int ans = c;
	for(int i = 0; i < c; i ++)
	{
		int q = i + 1 - dp[i];
		int o = c - i-1;
		ans = min(ans, q + o);
	}
	cout << ans;





	





	getchar();
	getchar();
	return 0;
	//ios::sync_with_stdio(false);
	//cin.tie(0);
}

Measured memory_bytes: 4492
#include <bits/stdc++.h>
//#pragma GCC optimize(2)
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define rep(i,a,b) for(int i = (a);i <= (b);i++)
#define pii pair<int,int>
#define pll pair<long long, long long>
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll mod = 1e9 + 7;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const int inf = 0x3f3f3f3f;
const int maxn = 3e5 + 5;
const double eps = 1e-8;
const double pi = acos(-1.0);	
ll gcd(ll a,ll b){return !b?a:gcd(b,a%b);}
ll lcm(ll a,ll b){return a * b / gcd(a,b);}
ll qw(ll x,ll y){ll res = 1;while(y){if(y & 1) res *= x;x = x * x;y >>= 1;}return res;}
ll poww(ll x,ll y,ll p){ll ans = 1;while(y){if(y & 1) ans = ans * x % p;x = x * x % p;y >>= 1;}return ans % p;}
bool isp(ll x){if(x < 2) return 0; for(ll i = 2;i * i <= x;i++){if(x % i == 0) return 0;}return 1;}
int n;
void solve(){
	int x = n % 10;
	if(x == 2 || x == 4 || x == 5 || x == 7 || x == 9) cout << "hon" << endl;
	else if(x == 3) cout << "bon" << endl;
	else cout << "pon" << endl;
	return;
}
int main(){
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin >> n;
	solve();
	return 0;
}
//do smt instead of nothing! never give up!


Measured memory_bytes: 3616
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(10000)


def read_int():
    return int(input())


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


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(N, A):
    ans = 0
    for i in range(N-1):
        if A[i] % 2 == 0:
            ans += A[i] // 2
        elif A[i+1] > 0:
            ans += (A[i] + 1) // 2
            A[i+1] -= 1
        else:
            ans += A[i] // 2
    ans += A[-1] // 2
    return ans


def main():
    N = read_int()
    A = [read_int() for _ in range(N)]
    print(slv(N, A))


if __name__ == '__main__':
    main()


Measured memory_bytes: 9856
#include <iostream>
using namespace std;
int main(void){
  char ch;
  cin >> ch;
  
  if(ch == 'a' || ch == 'i' || ch == 'u' || ch == 'e' || ch == 'o')
    cout << "vowel" << endl;
  else
    cout << "consonant" << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);++i)
using namespace std;
using ll=long long;
int n,c=1,k=1000,x,m=1000,ans;
int main(){
  cin>>x>>n;
  vector<int> p(n);
  rep(i,n)cin>>p[i];
  for(int i=-110;i<110;++i){
    bool f=true;
    k=abs(x-i);
    // cout<<k<<endl;
    rep(j,n)if(i==p[j]){f=false;break;};
    if(f){
      if(m>k)m=k,ans=i;
    }
  }
  cout<<ans;
}

Measured memory_bytes: 3596
#include<stdio.h>

int data[10000];
int a;
int count = 0;

int main(void){
while(scanf("%d",&a) != EOF){
if (a == 0){
break;
}
data[count] = a;
count++;
}

for(int i = 0; i < count; i++){
printf("Case %d: %d\n",i+1,data[i]);
}
return 0;
}


Measured memory_bytes: 2056
def resolve():

    N=int(input())
    A=[0]+list(map(int,input().split()))+[0]
    val=0
    for i in range(N+1):
        val+=abs(A[i+1]-A[i])

    for i in range(N):
        ans=val
        ans=ans-abs(A[i+2]-A[i+1])-abs(A[i+1]-A[i])+abs(A[i+2]-A[i])
        print(ans)

resolve()

Measured memory_bytes: 65004
from collections import deque
import math

def Next(): return input()
def NextInt(): return int(Next())
def NextInts(): return map(int,input().split())
def Nexts(): return map(str,input().split())
def NextIntList(): return list(map(int,input().split()))
def RowInts(n): return [input() for i in range(n)]

a,b,c = NextInts()
k = NextInt()

cnt = 0
while b <= a:
    b *= 2
    cnt += 1
while c <= b:
    c *= 2
    cnt += 1
if cnt <= k:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 9400
#129_C
n,m=map(int,input().split())
a={int(input()) for _ in range(m)}
mod=10**9+7
dp=[0 for i in range(n+1)]
dp[0]=1
for i in range(1,n+1):
    if i in a:
        dp[i]=0
    else:
        dp[i]=(dp[i-1]+dp[i-2])%mod
        
print(dp[n])

Measured memory_bytes: 11884
open Printf
open Scanf

let read_int _ = scanf " %d " (fun x -> x)

let rec gcd a b = if b = 0 then a else gcd b (a mod b)

let () =
  let n = read_int () in
  let x::xs = Array.init n read_int |> Array.to_list in
  let res = List.fold_left (fun a v -> gcd a v) x xs in
  printf "%d\n" res


Measured memory_bytes: 6272
#include <cmath>
#include <cstdio>
#include <algorithm>
using namespace std;

int X, Y;
int N;
int place[1000][2];
int answer;

int main(){
	scanf("%d %d %d", &Y, &X, &N);
	for (int i = 0; i < N; ++i){
		scanf("%d %d", &(place[i][0]), &(place[i][1]));
	}
	for (int i = 1; i < N; ++i){
		int mar_x = place[i][0] - place[i - 1][0];
		int mar_y = place[i][1] - place[i - 1][1];
		if (mar_x * mar_y <= 0){
			answer += abs(mar_x) + abs(mar_y);
		}
		else{
			answer += max(abs(mar_x), abs(mar_y));
		}
	}

	printf("%d\n", answer);

	return 0;
}

Measured memory_bytes: 2728
if __name__ == '__main__':
    s_txt = input()
    p_txt = input()

    base_txt = s_txt * 2
    base_txt = base_txt[:-1]  # s_txt=='hoge', p_txt=='hogehoge' ??????????????´???????????£??????????????????????????????????????????????????????

    if p_txt in base_txt:
        print('Yes')
    else:
        print('No')

Measured memory_bytes: 7472
#include <iostream>
#include <string>
#include <cstdlib>
#include <cstdio>
#include <queue>
#include <stack>
#include <list>
#include <utility>
#include <vector>
#include <set>
#include <algorithm>
#include <cmath>
#include <climits>


#define REP(i,N) for(int i = 0; i <N; i++)
using namespace std;


const int MOD = pow(10,9)+7;
const int MAX = 2047483647;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

typedef long long ll;


int in(){
    int temp;
    scanf("%d",&temp);
    return temp;
}

ll lin(){
    ll temp;
    scanf("%lld",&temp);
    return temp;
}



int main() {
  
    ll N = lin();
    
    vector<ll> cumsumP;
    vector<ll> cumsumN;
    
    int maxdigit = 16;
    cumsumN.push_back(0);
    cumsumP.push_back(0);
    for(auto i = 0; i<maxdigit; i++){
        
        cumsumP.push_back(pow(4,i) + cumsumP.back());
        cumsumN.push_back(-pow(4,i)*2 + cumsumN.back());
        
    }
    
    string s;
    
//    maxdigit = log2(abs(N));
    
    int startflag = 0;
    
    for(auto j = maxdigit; j>0; j--){
//
//        cout << "N=" << N << endl;
//
//       cout << "2j+1" << endl;
//       cout << cumsumN[j] << " " <<-(1LL<<(2*j-1)) + cumsumP[j] << " " << endl;
        if(N >= cumsumN[j] && N <= -(1LL<<(2*j-1)) + cumsumP[j] ){
            s.push_back('1');
            N -=-(1LL<<(2*j-1));
            startflag = 1;
        }else if (startflag==1){
            s.push_back('0');
        }
//
//        cout << "2j" << endl;
////
//        cout << (1LL<<(2*j)) + cumsumN[j-1] << " " <<cumsumP[j]<< " " << endl;

        if (N <= cumsumP[j] && N >= (1LL<<(2*j-2)) + cumsumN[j-1]){
            s.push_back('1');
            N -=(1LL<<(2*j-2));
            startflag = 1;
        }else if (startflag==1){
            s.push_back('0');
        }
        
    }
    
    if (s.size() == 0){
        cout << 0 << endl;
        return 0;
    }
    
    cout << s << endl;

    return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
using namespace std;


int main() {
  double PI = 4.0*atan(1.0);
  double a, b, x;
  double water, bottle;
  cin >> a >> b >> x;

  water = x/a;
  bottle = a*b;
  cout << fixed;
  double l;
  if (water >= bottle/2.0){
    l = (bottle-water)*2.0/a;
    cout << atan(l/a)*180.0/PI << endl;
  }else{
    l = water*2.0/b;
    cout << atan(b/l)*180.0/PI << endl;
  }
}

Measured memory_bytes: 512
import java.util.*;

public class Main{
  public void battle(int n,int[] a) {
    int AP = 0;
    int BP = 0;
    int count = 0;
    
    for (int i = n-1;i >= 0;i--) {
      if (count%2== 0) AP += a[i];
      else BP += a[i];
      count++;
    }
    
    int SP = AP -BP;
    
    System.out.println(SP);
  }

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

    int N = scan.nextInt();
    
    int array[] = new int[N];
    
    for (int i = 0;i < N;i++) {
      array[i] = scan.nextInt();
    }
    
    Arrays.sort(array);
    
    Main main = new Main();
    
    main.battle(N,array);
  }
}

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


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

    int ar[n+10],ans[n+10];

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

    ans[0]=0;
    ans[1]=abs(ar[1]-ar[0]);

    for(int i=2;i<n;i++)
    {
       int r1,r2;

       r1=abs(ar[i]-ar[i-1])+ans[i-1];
       r2=abs(ar[i]-ar[i-2])+ans[i-2];

       ans[i]=min(r1,r2);

    }

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

    return 0;
}


Measured memory_bytes: 1024
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner sc =  new Scanner(System.in);
		int s = 1<<(sc.nextInt());
		int e = sc.nextInt();
		Condition[] cons = new Condition[e];
		
		for(int i=0;i<e;i++) {
			int n = sc.nextInt();
			int[] arr = new int[n];
			for(int j=0;j<n;j++) {
				arr[j] = sc.nextInt();
			}
			cons[i] = new Condition(arr);
		}
		
		for(int i=0;i<e;i++) 
			cons[i].OE = sc.nextInt();
		
		sc.close();
		int j;
		int count = 0;
		for(int i=0;i<s;i++) {
			for(j=0;j<e;j++) {
				if(!cons[j].meets(i))
					break;
			}
			if(j==e)
				count++;
		}
		System.out.println(count);
	}
}

class Condition{
	int[] nums;
	int OE;
	
	Condition(int[] nums){
		this.nums = nums;
	}
	
	
	boolean meets(int state) {
		int sum = 0;
		for(int i=0;i<nums.length;i++)
			sum += (state >> (nums[i]-1))&1;
		return OE == (sum&1);
	}
}

Measured memory_bytes: 21844
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
#include<iterator>
#include<list>

using namespace std;

#define INF LLONG_MAX / 5
#define int long long
#define rep(i, n) for (int i = 0; i < n; i++)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define enld endl

signed main() {
	int N, K;
	cin >> N >> K;
	if (K % 2 == 0) {
		int a = 0, b = 0;
		for (int i = 1; i <= N; i++) {
			if (i % K == 0) {
				a++;
			}
			else if (i % K == K / 2) {
				b++;
			}
		}
		cout << a * a * a + b * b * b << endl;
	}
	else {
		int a = 0, b = 0;
		for (int i = 1; i <= N; i++) {
			if (i % K == 0) {
				a++;
			}
		}
		cout << a * a * a << endl;
	}
}

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


public class Main{ 

	public static void main(String args[]){
	/*	Scanner scan = new Scanner(System.in);
		Dice d01 = new Dice(scan.nextLine());
		Dice d02 = new Dice(scan.nextLine());
		if(d01.equals(d02))
			System.out.println("Yes");
		else
			System.out.println("No");*/
		
		
		Scanner scan = new Scanner(System.in);
		int dnum = scan.nextInt();
		scan.nextLine();
		HashSet<Dice> dlist = new HashSet<Dice>();
		for(int i=0; i<dnum; i++)
			if(!dlist.add(new Dice(scan.nextLine()))){
				System.out.println("No");
				return;
			}
		System.out.println("Yes");
			
	}

}
class Dice{
	int top;
	int back;
	int right;
	int left;
	int front;
	int bottom;
	public Dice(String line){
		String[] face = line.split(" ");
		top = Integer.parseInt(face[0]);
		back = Integer.parseInt(face[1]);
		right = Integer.parseInt(face[2]);		
		left = Integer.parseInt(face[3]);
		front = Integer.parseInt(face[4]);
		bottom = Integer.parseInt(face[5]);
	}
	void rotate(){
		int tmp = front;
		front = right;
		right=back;
		back = left;
		left = tmp;
	}
	public void roll(char c){
		int tmp = top;
		switch(c){
			case 'N':
				top = back;
				back=bottom;
				bottom = front;
				front = tmp;
				break;
			case 'E':
				top = left;
				left = bottom;
				bottom = right;
				right = tmp;
				break;
			case 'S':
				top = front;
				front = bottom;
				bottom = back;
				back = tmp;
				break;
			case 'W':
				top = right;
				right = bottom;
				bottom = left;
				left = tmp;
				break;
		}
	}
	boolean equalFace(Dice d){
		if(this.top == d.top && 
		   this.bottom == d.bottom &&
		   this.right == d.right &&
		   this.left == d.left &&
		   this.front == d.front &&
		   this.back == d.back)
			return true;
		else
			return false;
	}
	@Override
	public int hashCode() {
		return 0;
		/*
	    final int prime = 31;
	    int result = 1;
	    result = prime * result + top;
	    result = prime * result + bottom;
	    result = prime * result + right;
	    result = prime * result + left;
	    result = prime * result + front;
	    result = prime * result + back;
	    return result;*/
    }
	@Override
	public boolean equals(Object obj) {
		Dice d = (Dice) obj;
		return rollAllPattern(d);
	}
	public boolean rotateCheck(Dice d){
		for(int j=0;j<4;j++){
			rotate();
			if(this.equalFace(d))
				return true;
		}
		return false;
	}
	public boolean rollAllPattern(Dice d){
		for(int i=0; i<4;i++){
			roll('N');
			if(rotateCheck(d))
				return true;
		}
		roll('W');
		if(rotateCheck(d))
			return true;		
		roll('E');
		roll('E');		
		if(rotateCheck(d))
			return true;	
		return false;			
	}
	
}	
	
	

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

int main(){
    string S;
    cin >> S;
    if (S[0]=='R'){
        if (S[1]=='R'){
            if (S[2]=='R'){
                cout << 3;
            } else{
                cout << 2;
            }
        } else{
            cout << 1;
        }
    } else {
        if (S[1]=='R') {
            if (S[2]=='R') {
                cout << 2;
            } else{
                cout << 1;
            }
        } else{
            if (S[2]=='R'){
                cout << 1;
            } else{
                cout << 0;
            }
        }
    }
}

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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
using namespace std;

int main() {
    int n, m;
    cin >> n >> m;
    cout << (n == m ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
  char S[3];
  int i,N=0;
  int c0=0,c1=0,c2=0,c3=0;

  scanf("%d",&N);
  for(i=0; i<N; i++){
    scanf("%s",S);
      if(S[0] == 'A')
        c0++;
      else if(S[0] == 'W')
        c1++;
      else if(S[0] == 'T')
        c2++;
      else
        c3++;
  }

    printf("AC x %d\n", c0);
    printf("WA x %d\n", c1);
    printf("TLE x %d\n", c2);
    printf("RE x %d\n", c3);

    return 0;
}


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

lst = [1]
lst += [ 6**i for i in range(1, 10) if 6**i <= 100000]
lst += [ 9**i for i in range(1, 10) if 9**i <= 100000]
lst.sort()

dp = list(range(N+1))

for i in range(1, N+1):
    temp = []
    for j in lst:
        if j <= i:
            temp.append(dp[i-j] + 1) 
    dp[i] = min(temp)
print(dp[N])

Measured memory_bytes: 6900
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <stdbool.h>
#include <string.h>

main()
{
  int A,B;
  scanf("%d%d",&A,&B);
  if(A>8||B>8)
    printf(":(\n");
  else
    printf("Yay!\n");
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define ll long long
#define pb push_back

using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin>>n;
    vector<string>v(n);
    for(int i=0; i<n; ++i)
        cin>>v[i];
    sort(v.begin(), v.end());
    int ans = 1;
    int count = 1;
    for(int i=1; i<n; ++i) {
        if(v[i] == v[i-1]) {
            ++count;
        }
        else {
            ans = max(ans, count);
            count = 1;
        }
    }
    ans = max(ans, count);
    // cout<<ans<<endl;
    count = 1;
    for(int i=1; i<n; ++i) {
        if(v[i] == v[i-1]) {
            ++count;
        }
        else {
            if(count == ans)
                cout<<v[i-1]<<endl;
            count = 1;
        }
    }
    if(count == ans)
        cout<<v[n-1]<<endl;
}

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

signed main() {
    int A[3][3];
    rep(i, 3) {
        rep(j, 3) {
            cin >> A[i][j];
        }
    }
    int N;
    cin >> N;
    bool R[3][3] = {false};
    rep(k, N) {
        int b;
        cin >> b;
        rep(i, 3) {
            rep(j, 3) {
                if (A[i][j] == b) R[i][j] = true;
            }
        }
    }
/*
    cout << R[0][0] << R[0][1] << R[0][2] << endl;
    cout << R[1][0] << R[1][1] << R[1][2] << endl;
    cout << R[2][0] << R[2][1] << R[2][2] << endl;
*/
    bool res = false;
    if ((R[0][0]) && (R[0][1]) &&(R[0][2])) res = true;
    if ((R[1][0]) && (R[1][1]) &&(R[1][2])) res = true;
    if ((R[2][0]) && (R[2][1]) &&(R[2][2])) res = true;

    if ((R[0][0]) && (R[1][0]) &&(R[2][0])) res = true;
    if ((R[0][1]) && (R[1][1]) &&(R[2][1])) res = true;
    if ((R[0][2]) && (R[1][2]) &&(R[2][2])) res = true;

    if ((R[0][0]) && (R[1][1]) &&(R[2][2])) res = true;
    if ((R[0][2]) && (R[1][1]) &&(R[2][0])) res = true;

    if (res == true)  cout << "Yes" << endl;
    else              cout << "No" << endl;

}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <queue>
#define MOD (1000000007l)
#define rep(i, n) for(long i = 0; i < n; i++)

using namespace std;

void solve() {
  long H, W;
  cin >> H >> W;
  vector<string> data(H);
  rep (i, H) cin >> data[i];

  rep (h, H) rep (w, W) {
    if (data[h][w] == '#') continue;
    long num = 0;
    for (long dh = -1; dh <= 1; dh++) for (long dw = -1; dw <= 1; dw++) {
      if (dh == 0 and dw == 0) continue;
      if (h+dh < 0) continue;
      if (w+dw < 0) continue;
      if (h+dh >= H) continue;
      if (w+dw >= W) continue;
      if (data[h+dh][w+dw] == '#') num++;
    }
    data[h][w] = '0' + num;
  }

  rep (i, H) cout << data[i] << endl;
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout.precision(12);
  solve();
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){

  int a = 0;
  int b = 0;
  int c = 0;

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

  if (a < b && b < c){
      printf("Yes\n");
  }else{
      printf("No\n");
  }

  return 0;
}

Measured memory_bytes: 1008
#pragma comment (linker, "/STACK:526000000")
#define  _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"

using namespace std;
typedef string::const_iterator State;
#define eps 1e-11L
#define MAX_MOD 1000000007LL
#define GYAKU 500000004LL

#define MOD 998244353LL
#define seg_size 262144
#define pb push_back
#define mp make_pair
typedef long long ll;
#define REP(a,b) for(long long (a) = 0;(a) < (b);++(a))
#define ALL(x) (x).begin(),(x).end()
unsigned long xor128() {
    static unsigned long x = 123456789, y = 362436069, z = 521288629, w = 88675123;
    unsigned long t = (x^(x << 11));
    x = y; y = z; z = w;
    return (w = (w^(w >> 19))^(t^(t >> 8)));
}
void init() {
    iostream::sync_with_stdio(false);
    cout << fixed << setprecision(100);
}
#define int ll
void solve() {
    int n, k;
    cin >> n >> k;
    vector<int> inputs;
    REP(i, n) {
        int a;
        cin >> a;
        inputs.push_back(a);
    }
    sort(ALL(inputs));
    int ans = 0;
    for (int i = 0; i < n - k; ++i) {
        ans += inputs[i];
    }
    cout << ans << endl;
    return;
}
#undef int
int main() {
    init();
    solve();
}

Measured memory_bytes: 2420
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,n)  FOR(i,0,n)
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<P> Graph;

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

  int n,k;
  cin >> n >> k;
  
  cout << ceil((double)(n-1)/(k-1)) << endl;

  return 0;
}

Measured memory_bytes: 256
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <iterator>

using namespace std;

#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(v) reverse((v).begin(),(v).end())
#define ANS(ans) cout<<(ans)<<endl;
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
typedef vector<int> VI;

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

struct MyStruct {
	int idx, a, b, pl;
};

bool comp(const MyStruct& s, const MyStruct& t) {
	if (s.pl != t.pl)
		return s.pl > t.pl; // 高い順
	return s.idx < t.idx;
}

int main() {

	int n;
	cin >> n;

	long long taka = 0, aoki = 0;

	vector<MyStruct> vec(n);
	REP(i, n) {
		cin >> vec[i].a >> vec[i].b;
		vec[i].pl = vec[i].a + vec[i].b;
	}
	sort(vec.begin(), vec.end(), comp);

	REP(i, n) {
		if (i % 2 == 0) {
			taka += vec[i].a;
		}
		else {
			aoki += vec[i].b;
		}
	}
	ANS(taka - aoki);

	return 0;
}


Measured memory_bytes: 1792
import java.util.*;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int W = sc.nextInt();
		long[] w = new long[N];
		int[] v = new int[N];
		int V = 0;
		for(int i=0; i<N; i++){
			w[i] = sc.nextLong();
			v[i] = sc.nextInt();
			V += v[i];
		}
		long[][] dp = new long[N+1][V+1];
		for(int i=0; i<N+1; i++){
			for(int j=1; j<V+1; j++){
				if(i == 0 && j != 0){
					dp[i][j] = 1000000010;
				}
				else if(j < v[i-1]){
					dp[i][j] = dp[i-1][j];
				}
				else{
					dp[i][j] = Math.min(dp[i-1][j], dp[i-1][j-v[i-1]] + w[i-1]);
				}
			}
		}
		for(int i=V; i>=0; i--){
			if(dp[N][i] <= W){
				System.out.println(i);
				break;
			}
		}
	}
}

Measured memory_bytes: 126804
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,o,n) for(long long i = o;i<n;i++)
#define oneforall ios::sync_with_stdio(false);cin.tie(0);
#define all(v) (v).begin(),(v).end()
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) long long __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << "\n";} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
typedef vector<int> vi;
typedef vector<long long> vl;
typedef long long ll;
typedef vector<pair<long,long>> vpll;
typedef vector<pair<int,int>> vpii;
int main() {
	oneforall
	ins(a);
	FOR(i,0,a.size()){a[i] = 'x';}
	out(a);return 0;}

Measured memory_bytes: 256
w,h,x,y,r = input().split()
w = int(w)
h = int(h)
x = int(x)
y = int(y)
r = int(r)
if x - r >= 0 and y - r >= 0 and x + r <= w and y + r <= h:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 5596
#include <iostream>
#include <vector>
#include <queue>

using namespace std;

vector <int> sortaret(int n, vector <int> &grad, vector <vector <int> > &v) {
    queue <int> Q;
    vector <int> d;

    for (int i = 1; i < n + 1; i++) {
        if (grad[i] == 0)
            Q.push(i);
    }

    while (!Q.empty()) {
        int curent = Q.front();
        Q.pop();

        d.push_back(curent);
        for (auto vecin : v[curent]) {
            grad[vecin]--;
            if (grad[vecin] == 0)
                Q.push(vecin);
        }
    }

    return d;
}

int main() {
    int n, m;
    cin >> n >> m;
    vector <vector <int> > v(n + 1);
    vector <int> grad(n + 1, 0);
    
    int x, y;
    for (int i = 0; i < m; i++) {
        cin >> x >> y;
        v[x].push_back(y);
        grad[y]++;
    }

    vector <int> sorted_dag = sortaret(n, grad, v);

    int max = -1, nr;
    vector <int> dp(n + 1, 0);
    for (auto &&idx: sorted_dag) {
        for (auto &&son: v[idx]) {
            nr = dp[idx] + 1;
            if (nr > dp[son])
                dp[son] = nr;
        }
    }

    for (auto &&el: dp) {
        if (max < el)
            max = el;
    }

    cout << max << '\n';
    return 0;
}

Measured memory_bytes: 7032
#include <iostream> // cin, cout, cerr
#include <algorithm> // minmax, sort, swap
#include <numeric> // iota
#include <cstdio> // printf, scanf
#include <string> // string, stoi, to_string
#include <vector> // vector
#include <queue> // queue, priority_queue
#include <deque> // deque
#include <map> // key-value pairs sorted by keys
#include <set> // set
#include <iomanip> // cout<<setprecision(n)
#include <functional> // function<void(int)>
#include <cmath>
#include <cassert>
#include <bitset>

#ifdef DEBUG
#include "debug.hpp"
#else
#define debug(...)
#endif

#define int long long // at least int64 > 9*10^18
#define EL '\n'
#define rep(i,n) for(int i = 0; i < (n); i++)
#define print(i) std::cout << (i) << '\n'
#define all(v) (v).begin(), (v).end()
/* libraries */

signed main() {
	int n;
	std::cin >> n;
	int min = 64;
	rep(i,n) {
		int x;
		std::cin >> x;
		int y = 0;
		while(x%2==0) x/=2,++y;
		min=std::min(min,y);
	}
	print(min);
	return 0;
}


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

namespace _20180319_AOJ
{
    class ALDS1_11C
    {
        static int[,] graph;
        static int[] outArr;
        static Queue<KeyValuePair<int, int>> q;
        static void Main(string[] args)
        {
            for (;;)
            {
                string line = Console.ReadLine();
                if (string.IsNullOrEmpty(line))
                {
                    break;
                }

                int n = int.Parse(line);
                graph = new int[n + 1, n + 1];
                q = new Queue<KeyValuePair<int, int>>();
                outArr = new int[n + 1];
                for (int i = 0; i < n; i++)
                {
                    int[] vertex = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
                    int u = vertex[0];
                    for (int k = 0; k < vertex[1]; k++)
                    {
                        graph[u, vertex[k + 2]] = 1;
                    }
                }

                for (int i = 0; i < outArr.Length; i++)
                {
                    outArr[i] = -1;
                }

                BreadthFirstSearch(1, 0);

                for(int i=1;i<outArr.Length;i++)
                {
                    Console.WriteLine("{0} {1}", i, outArr[i]);
                }
            }
        }

        static void BreadthFirstSearch(int id, int depth)
        {
            if (outArr[id] < 0)
            {
                outArr[id] = depth;
                for (int i = 1; i < graph.GetLength(1); i++)
                {
                    if (graph[id, i] > 0)
                    {
                        q.Enqueue(new KeyValuePair<int, int>(i, depth + 1));
                    }
                }

                while(q.Count>0)
                {
                    KeyValuePair<int, int> kvp = q.Dequeue();
                    BreadthFirstSearch(kvp.Key, kvp.Value);
                }
            }
        }
    }
}



Measured memory_bytes: 10608