akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <iostream>
#include <math.h>
#include <cstdio>
#include <string.h>
#include <vector>
#include <functional>
#include <stack>
#include <queue>
#include <string>
#include <list>
using namespace std;
typedef long long ll;
/* prototype */
int EDSum(ll);//各桁の和
vector<int> SOE(int,int);//素数 (Min,Max)
int MinCM(int,int);//最小公倍数(num1,num2)
int MaxCD(int,int);//最大公約数(num1,num2)
vector<int> igets(int);//cin * N
ll nPr(ll,ll); //(n,r)
ll nE(ll); //(n)
ll nCr(ll,ll); //(n,r)

void solve(){
    //START
  	int i,j,k;
  	cin >> i >> j >> k;
    if(j-i == k-j)
  		cout << "YES" << endl;
  else cout << "NO" << endl;
}

int main(void){cin.tie(0);ios::sync_with_stdio(false);solve();}
/*FUNC*/
//各桁の和
int EDSum(ll number){
    int ans=0;
    while(1){
        ans += number % 10;
        number /= 10;
        if(number == 0) break;
    }
    return ans;
}

//エラトステネスのふるい(素数発見アルゴリズム)
vector<int> SOE(int min, int max)
{
    //0,1は含まれない
    if (min < 2) min = 2;
    //探索リスト作成
    vector<int> int_array;
    for (int i = min; i <= max; i++) int_array.push_back(i);
    //素数リスト
    vector<int> sosu;
    //√max
    double stop = sqrt(max);
    //計算
    while (true)
    {
        //素数リストに追加
        sosu.push_back(int_array.front());
        int_array.erase(int_array.begin());
        //停止
        if (stop < (double)(sosu.back())) break;
        //ふるい
        for (int i = 0; i < (int)int_array.size(); i++)
        {
            if (int_array[i] % sosu.back() == 0)
                int_array.erase(int_array.begin() + i);
        }
    }
    sosu.insert(sosu.end(), int_array.begin(), int_array.end());
    return sosu;
}

//最小公倍数
int MinCM(int a, int b)
{
    int c = a * b;
//入れ替え
    if (a < b)
        swap(a, b);
    int r = a % b;
    while (r != 0)
    {
        a = b;
        b = r;
        r = a % b;
    }
    return c / b;
}

//最大公約数
int MaxCD(int a, int b)
{
//入れ替え
    if (a < b)
        swap(a, b);
    int r = a % b;
    while (r != 0)
    {
        a = b;
        b = r;
        r = a % b;
    }
    return b;
}
//iget cin int 2 vector
vector<int> igets(int N){
    vector<int> A;
    int temp;
    for (int i = 0; i < N; ++i) {
        cin >> temp;
        A.push_back(temp);
    }
    return A;
}

ll nPr(ll n,ll r) {
    ll ans=1;
    r=n-r;
    while(n!=r) {
        ans*=n;
        --n;
    }
    return ans;
}

ll nE(ll n) {
    return nPr(n,n);
}

ll nCr(ll n,ll r) {
    if(r==0)return -1;
    else{
        if(0!=n-r&&n-r<r)r=n-r;
        return nPr(n,r)/nE(r);
    }
}

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

namespace Atcoder
{
    class Atcoderrrrrrr
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int X = int.Parse(input[0]);int t = int.Parse(input[1]);

            int ans = X-t;
            if(ans>0){
                Console.WriteLine(ans);
            }else{
                Console.WriteLine(0);
            }

        }
    }
}


Measured memory_bytes: 13140
N=int(input())
C=input()
R=[]
W=[]
for i in range(N):
  c=C[i]
  if c=="R":
    R.append(i)
  else:
    W.append(i)
ans=0
for i in range(N):
  if i>=len(R) or i>=len(W):
    break
  if W[i]>R[-i-1]:
    break
  ans+=1
print(ans)

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

using namespace std;

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

  string s;
  cin >> s;

  vector<char> nox;
  for (char c : s) {
    if (c != 'x') nox.push_back(c);
  }

  // for (char c : nox) cout << c; cout << endl;
  for (int i = 0; i < (int)nox.size() / 2; i++) {
    if (nox[i] != nox[nox.size() - i - 1]) {
      cout << "-1" << endl;
      return 0;
    }
  }

  int n = s.size();
  int half = (nox.size() + 1) / 2;
  map<int, int> before, after;
  int midLeft, midRight;
  for (int i = 0, j = 0; i < n; i++) {
    if (s[i] != 'x') j++;
    if (j == half) {
      midLeft = i;
      break;
    }
  }
  for (int i = n - 1, j = 0; i >= 0; i--) {
    if (s[i] != 'x') j++;
    if (j == half) {
      midRight = i;
      break;
    }
  }

  // cout << midLeft << " " << midRight << endl;

  for (int i = midLeft, j = 0; i >= 0; i--) {
    if (s[i] == 'x') {
      before[j]++;
    } else j++;
  }

  for (int i = midRight, j = 0; i < n; i++) {
    if (s[i] == 'x') {
      after[j]++;
    } else j++;
  }

  int result = 0;
  for (int i = 0; i <= half; i++) {
    int a = after[i];
    int b = before[i];
    result += abs(a - b);
  }
  cout << result << endl;
  return 0;
}


Measured memory_bytes: 5200
n = int(input())
ls = []
for _ in range(n):
    tmp = input()
    ls.append(tmp)

print(f"AC x {ls.count('AC')}")
print(f"WA x {ls.count('WA')}")
print(f"TLE x {ls.count('TLE')}")
print(f"RE x {ls.count('RE')}")


Measured memory_bytes: 16128
#include <iostream>
#include <vector>
using namespace std;
int main(){
    int n; cin >> n;
    vector<int> vec(n+1);
    for(int i = 1; i < n+1; ++i){
        for(int j = 1;;++j){
            if(n < i*j) break;
            vec[i*j]++;
        }
    }
    long long sum = 0;
    for(int i = 1; i < n+1; ++i) sum += (long long)i*vec[i];
    cout << sum << endl;
    return 0;
}
//Saw the solution video

Measured memory_bytes: 42320
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::{Write, BufWriter};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};
    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, [graph1; $len:expr]) => {{
        let mut g = vec![vec![]; $len];
        let ab = read_value!($next, [(usize1, usize1)]);
        for (a, b) in ab {
            g[a].push(b);
            g[b].push(a);
        }
        g
    }};
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };
    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };
    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };
    ($next:expr, usize1) => (read_value!($next, usize) - 1);
    ($next:expr, [ $t:tt ]) => {{
        let len = read_value!($next, usize);
        read_value!($next, [$t; len])
    }};
    ($next:expr, $t:ty) => ($next().parse::<$t>().expect("Parse error"));
}

#[allow(unused)]
macro_rules! debug {
    ($($format:tt)*) => (write!(std::io::stderr(), $($format)*).unwrap());
}
#[allow(unused)]
macro_rules! debugln {
    ($($format:tt)*) => (writeln!(std::io::stderr(), $($format)*).unwrap());
}

fn solve() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (let _ = write!(out,$($format)*););
    }
    input! {
        n: i64, x: usize, m: usize,
    }
    const W: usize = 40;
    let mut dbl = vec![vec![0; m]; W];
    let mut sum = vec![vec![0; m]; W];
    for i in 0..m {
        dbl[0][i] = i * i % m;
        sum[0][i] = i;
    }
    for i in 0..W - 1 {
        for j in 0..m {
            let int = dbl[i][j];
            dbl[i + 1][j] = dbl[i][int];
            sum[i + 1][j] = sum[i][j] + sum[i][int];
        }
    }
    let mut cur = x;
    let mut ans = 0;
    for i in 0..W {
        if (n & 1 << i) != 0 {
            ans += sum[i][cur];
            cur = dbl[i][cur];
        }
    }
    puts!("{}\n", ans);
}

fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


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

const int MAX_N = 200005;
const int INF = 1001001001;

vector<int> a,ans;
vector<int> to[MAX_N];
int dp[MAX_N];

void dfs(int v,int p=-1){
  int i = lower_bound(dp,dp+MAX_N,a[v])-dp;
  int old = dp[i];
  dp[i] = a[v];
  ans[v] = i;
  if(p != -1)ans[v] = max(ans[v],ans[p]);
  for(int u:to[v]){
    if(u == p)continue;
    dfs(u,v);
  }
  dp[i] = old;
}

int main(){
  int n;
  cin >> n;
  a = ans = vector<int>(n);
  rep(i,n) cin >> a[i];
  rep(i,n-1){
    int u,v;
    cin >> u >> v;
    --u;--v;
    to[u].push_back(v);
    to[v].push_back(u);
  }
  rep(i,MAX_N)dp[i]=INF;
  dp[0]= -INF;
  dfs(0);
  rep(i,n)cout << ans[i] << endl;
  return 0;
}


Measured memory_bytes: 30780
#include <bits/stdc++.h>
using namespace std;
vector<int> empty;
vector<vector<int> > a;
vector<pair<int,int> > loc;
int calc(int l, int r, int d){
	int x, y;
	x = loc[l].first;
	y = loc[l].second;
	int res = 0;
	while(l != r){
		l += d;
		int x1 = loc[l].first;
		int y1 = loc[l].second;
		res += abs(x1 - x) + abs(y1 - y);
		x = x1;
		y = y1;
	}
	return res;
}
int main(){
	int h, w, d, l, r; 
	cin>>h>>w>>d;
	empty.resize(w);
	a.resize(h, empty);
	loc.resize(h * w + 1);
	for(int i = 0; i < h; ++i){
		for(int j = 0; j < w; ++j){
			cin>>a[i][j];
			a[i][j]--;
			loc[a[i][j]] = make_pair(i, j);
		}
	}
	vector<int> distance(h * w + 1, 0);
	for(int i = 0; i <= h * w; ++i){
		int r = i;
		int l = r - d;
		if(l < 0)continue;
		int x = calc(l, r, d);
		distance[i] = x;
	}
	int q;
	cin>>q;
	vector<int> total(h * w + 1, 0);
	for(int i = 0; i < d; i++){
		int x = i;
		while(x < h * w + 1){
			if(x < d)x+=d;
			else {
				total[x] = total[x - d] + distance[x];
				x+=d;
			}
		}
	}
	for(int i = 0; i < q; ++i){
		cin>>l>>r;
		l--, r--;
		cout<<total[r] - total[l]<<endl;
	}
	return 0;
}


Measured memory_bytes: 2944
#include<bits/stdc++.h>
using namespace std;
int main(){
   long long  int n;
    cin>>n;
   long long  int m;
    cin>>m;
   long long  int a[m];
   long long  int sum=0;
    for(long long int i=0;i<m;i++){
    	cin>>a[i];
    	sum+=a[i];
    }
    if(sum>n){
    	cout<<"-1";
    	return 0;
    }
    else{
    	cout<<n-sum<<endl;
    }

    





}


Measured memory_bytes: 3672
#include<cstdio>
#include<algorithm>
#include<cstring>
#define rep(i, s, t) for(i = s; i <= t; ++i)
#define dep(i, s, t) for(i = s; i >= t; --i)

using namespace std;

int A, B;
char mp[110][110];

int main() {
	int i, j;
	scanf("%d%d", &A, &B); --A; --B;
	puts("100 100");
	rep(i, 1, 50) rep(j, 1, 100) mp[i][j] = '#';
	rep(i, 51, 100) rep(j, 1, 100) mp[i][j] = '.';
	for(i = 1; A; ++i)
	if(i & 1)
		for(j = 1; A && j <= 100; ++j)
		if(j & 1) {--A; mp[i][j] = '.';}
	for(i = 51; B; ++i)
	if(!(i&1))
		for(j = 1; B && j <= 100; ++j)
		if(j & 1) {--B; mp[i][j] = '#';}
	rep(i, 1, 100) {
		rep(j, 1, 100) printf("%c", mp[i][j]);
		puts("");
	}
	return 0;
}

Measured memory_bytes: 128
#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>
#include <map>
#include <unordered_map>
#include <string.h>
#include<iomanip>
#include <iterator>
#include <locale>

#define all(a) a.begin(),a.end()
#define VV(T) vector<vector< T > >
#define rep(i,N) for(int i = 0; i <N; i++)
#define repsg(i,s,g) for(int i = s; i <g; i++)
#define name(x) #x
using namespace std;

const int INF = INT_MAX;
const long long INFL =LONG_LONG_MAX;
const double PI = atan(1)*4;
const int MOD = pow(10,9)+7;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

typedef long long ll,LL;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
typedef pair<int,int> pii;
typedef pair<LL, LL> pLL;


// vector入力
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
    for(T& x: vec) is >> x;
    return is;
}
// vector出力
template<typename T>
ostream& operator << (ostream& os, vector<T>& vec){
    for(int i=0; i<vec.size(); i++){
        os << vec[i] << ( i+1 == vec.size() ? "" : " " );
    }
    return os;
}

ll gcb(ll a, ll b){/// ユークリッドの互除法: O(log)
    
    if(b == 0) return a;
    
    return gcb(b,a%b);
}


ll lcm(ll a, ll b){
    
    return  a/gcb(a,b) * b; ///gcbは約数
}


int main() {
    int n,k;cin>>n>>k;
    vector<ll> A(n);cin>>A;
    sort(all(A));
    
    vector<ll> B(A);
    repsg(i,1,n){B[i] = A[i]%A[0];};

    ll val= B[0];
    repsg(i,1,n) val = gcb(val,B[i]);
    
    for(auto i = lower_bound(all(A),k); i<A.end();i++){
        
        if((*i-k)%val==0) {cout<<"POSSIBLE"<<endl; return 0;}
        
    }
    
    cout<<"IMPOSSIBLE"<<endl;
    
    
    
    return 0;
}








Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Main m = new Main();
		m.run();
	}

	Scanner sc = new Scanner(System.in);

	void run() {

		int n = sc.nextInt();
		int[] a = new int[n];
		
		boolean isEven = true;
		for(int i = 0; i < n ; i++){
			a[i] = sc.nextInt();
			isEven = isEven && a[i] % 2==0;
		}
		
		System.out.println(isEven?"second":"first" );
		
	}
	
	
}


Measured memory_bytes: 50724
s=raw_input()
if s[0]=="A" and len(s)>=3 and s.count("C")==1 and s[-1]!="C" and s[1]!="C" and all(x not in s[1:] for x  in"ABDEFGHIJKLMNOPQRSTUVWXYZ"):print "AC"
else:print "WA"

Measured memory_bytes: 2572
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define INF (1LL<<50)
#define MOD 1000000007

int main(){
    int N,M,X;
    cin >> N >> M >> X;
    vector<int> C(N);
    vector<vector<int>> A(N,vector<int>(M));
    rep(i,N){
        cin >> C[i];
        rep(j,M) cin >> A[i][j];
    }
    ll ans = INF;
    for(int bit=0;bit<(1<<N);bit++){
        bool flg=true;
        vector<ll> Sum(M);
        ll tmp = 0;
        for(int i=0;i<N;i++){
            if(bit&(1<<i)){
                rep(j,M){
                    Sum[j]+=A[i][j];
                }
                tmp+=C[i];
            }
        }
        rep(j,M){
            if(Sum[j]<X){
                flg = false;
            }
        }
        if(flg){
            ans = min(ans,tmp);
        }
    }
    if(ans == INF){
        ans = -1;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
#define per(i,n) for(int i = n-1; i >= 0; i--)
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<ll> vll;

int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  int p = a/d;
  if(a%d!=0) p++;
  int q = c/b;
  if(c%b!=0) q++;
  if(q<=p) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

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

int r, c;
int **s;
int *flipR;
int res;

int getP()
{
	int i, j;
	int cRes = 0;
	for (j=0; j<c; j++) {
		int ccp = 0;
		for (i=0; i<r; i++)
			if ((!flipR[i] && s[i][j]) || (flipR[i] && !s[i][j]))
				ccp++;
		if (ccp < r - ccp)
			cRes += r - ccp; 
		else
			cRes += ccp;
	}
	return cRes;
}

void dfs(int i)
{
	if (i == r) {
		//evaluation
		int cRes = getP();
		res = (res < cRes) ? cRes : res;
		return;
	}
	
	flipR[i] = 0; 	
	dfs(i+1);

	flipR[i] = 1;
	dfs(i+1);

	return;
}

int main()
{
	int i, j;

	while (1) {

		scanf("%d%d ", &r, &c);
		if (!r && !c) break;

		flipR = (int *)calloc(r, sizeof(int));
		s = (int **)calloc(r, sizeof(int *));
		for (i=0; i<r; i++)
			s[i] = (int *)calloc(c, sizeof(int));
		
		for (i=0; i<r; i++)
			for (j=0; j<c; j++)
				scanf("%d ", &(s[i][j]));

		res = 0;
		dfs(0);
		printf("%d\n", res);
/*
		//check input
		printf("r = %d, c = %d\n", r, c);
		for (i=0; i<r; i++) {
			for (j=0; j<c; j++)
				printf("%d ", s[i][j]);
			puts("");
		}
*/		
		for (i=0; i<r; i++)
			free(s[i]);
		free(s);
		free(flipR);
	}

	return 0;
}

Measured memory_bytes: 744
n,m = map(int, input().split())
A=[list(map(int, input().split())) for i in range(n)]
B=[int(input()) for i in range(m)]
ans=0
for j in range(n):
    for i in range(m):
        ans+=A[j][i]*B[i]
    print(ans)
    ans=0



Measured memory_bytes: 6012
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <numeric> 
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;
const int INF = 1<<30; 
const int MOD = 1e9 + 7;
const int dx[] = {0, 1, 1, 1, 0, -1, -1, -1, 0};
const int dy[] = {1, 1, 0, -1, -1, -1, 0, 1, 1};
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    map<P, ll> mp;
    for(int i = 0; i < n; i++)
    {
        ll x, y, w;
        cin >> x >> y >> w;
        mp[make_pair(x, y)] = w;
    }
    ll ans = 0;
    for(auto itr = mp.begin(); itr != mp.end(); itr++)
    {
        ll cnt = itr->second;
        queue<ll> que;
        for(int i = 0; i < 9; i++)
        {
            ll nx = itr->first.first + dx[i];
            ll ny = itr->first.second + dy[i];
            P tmp = make_pair(nx, ny);
            if(mp.count(tmp) > 0) cnt += mp[tmp];
            if(mp.find(tmp) != mp.end()) que.push(mp[tmp]);
            else que.push(0);
            if(que.size() == 3) 
            {
                ans = max(cnt, ans);
                for(int j = 0; j < 2; j++)
                {
                    ll q = que.front(); que.pop();
                    cnt -= q;
                }
            }
        }
        ans = max(cnt, ans);
    }
    cout << ans << " / " << 1 << endl;
    return 0;
}


Measured memory_bytes: 9400
import java.util.Scanner;
class Main
{
   public static void main(String[] args)
  	{
  	Scanner sc1 = new Scanner(System.in);
        while(true){
        int H = sc1.nextInt();
        int W = sc1.nextInt();
        if(H==0&&W==0)break;
       
        for(int i = 0; i<H; i++){

        for(int j = 0; j<W; j++) System.out.print("#");
        System.out.println();
        
   
        }
        System.out.println();
}
}
}



Measured memory_bytes: 34736
#include <iostream>
#include <cstring>
#include<complex>
#include <algorithm>
#include<iomanip>
#include<map>
#include<vector>
using namespace std;
#define point complex<double> 
double dot(point a, point b)
{
	return (conj(a) * b).real();
}
double cross(point a, point b)
{
	return (conj(a) * b).imag();
}
#define mod 1000000007
    typedef long long ll;
        ll dp[2005][2005];
    int main()
    {
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
        int n, k;
        cin >> n >> k;
        dp[0][0] = 1; dp[1][1] = 1; dp[1][0] = 1;
        for (int i = 2; i <= n; i++)
        {
            dp[i][0] = 1; dp[i][i] = 1;
            for (int j = 1; j <= i; j++)
            {
                dp[i][j] = dp[i - 1][j]%mod + dp[i - 1][j - 1]%mod;
            }
        }
        int r = n - k;
        for (int i = 1; i <= k; i++)
        {
            cout << ((dp[k - 1][i - 1] % mod) * (dp[r + 1][i] % mod))%mod << '\n'; 
        }
        return 0;
    }


Measured memory_bytes: 30208
#include <stdio.h>

int main(void) {
	int t,a,b,i,j,y,n,l[16];
	scanf("%d",&t);
	for(i = 1;i <= t;i++){
		y = 1;
		a = 0;
		b = 0;
		for(j = 1;j <= 10;j++){
			scanf("%d",&l[j]);
		}
		for(j = 1;j <= 10;j++){
			n = l[j];
			if(a >= b){
				if(a < n) a = n;
				else if(b < n) b = n;
				else{
					y = 0;
					break;
				}
			}
			else{
				if(b < n) b = n;
				else if(a < n) a = n;
				else{
					y = 0;
					break;
				}
			}
		}
		if(y) printf("YES\n");
		else printf("NO\n");
	}
	return 0;
}

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

int main(){

	int n,k;
	int num;
	int ans=0;
	int a[200000]={};
	cin>>n>>k;
	
	for(int i=1;i<=n;i++){
		cin>>num;
		a[num]+=1;
	}
	sort(a,a+n+1);
	
	
	for(int i=1;i<=n;i++){
		if(a[i]!=0 && k<=n-i){
			ans+=a[i];
		}
	}
	cout<<ans<<endl;
}



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

const long double PI = acos(-1);

void solve() 
{
    double r;cin>>r;cout<<setprecision(20)<<2*PI*r<<endl;
}

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


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

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

	if (a<b && a+w<b){
		ans = b-a-w;
	}else if(b<a && b+w<a){
		ans = a-w-b;
	}else{
		ans = 0;
	}

	cout << ans << endl;



    return 0;
}

Measured memory_bytes: 256
N, M = map(int, input().split())
flag = [0]*N
WA = 0
WA_flag = [0]*N
AC = 0
for _ in range(M):
    p, S = input().split()
    p = int(p)
    if S == "AC":
        if flag[p-1] == 0:
            AC += 1
            flag[p-1] = 1
            WA += WA_flag[p-1]
    else:
        WA_flag[p-1] += 1

print("{} {}".format(AC , WA))

Measured memory_bytes: 4596
#include <bits/stdc++.h>
#define REP(i, N) for(int i=0, i##_len=(N); i<i##_len; i++)
#define RREP(i, N) for(int i=1, i##_len=(N); i<i##_len; i++)
#define REPP(i, N) for(int i=0, i##_len=(N); i<=i##_len; i++)
#define RREPP(i, N) for(int i=1, i##_len=(N); i<=i##_len; i++)
#define P(x) cout << (x)
using ll = long long;
using namespace std;

int n;
double v[55];

int main() {
    cin >> n;
    REP(i, n) cin >> v[i];
    sort(v, v+n);
    RREP(i, n) v[0] = (v[0] + v[i])/2;
    cout << v[0];
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iomanip>
#include <math.h>
#include <unistd.h>
#include <stdio.h>
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#define all(a) (a).begin(),(a).end()
#define vecin(a) rep(i,a.size())cin >> a[i]
#define vecout(a) rep(i,a.size()){cout << a[i];cout << (i == a.size() - 1 ? "\n":" ");}
#define rep(i,x) for(ll i = 0;i<x;i++)
#define REP(i,x) for(ll i = 1;i<=x;i++)
#define mp make_pair
#define debug(x) cerr << #x << ": " << x << "\n"
using ll = long long;
using ld = long double;
using namespace std;
using dou = double;
const ll inf = 2147483647;
const ll INF = 1LL << 60;
const dou pi = 3.14159265358;
const ll mod = 1000000007LL;
//const ll mod = 998244353LL;
typedef pair<ll,ll> P;
using graph = vector<vector<ll>>;
template<class T, class U> inline bool chmin(T& a, const U& b){ if(a > b){ a = b; return 1; } return 0; }
template<class T, class U> inline bool chmax(T& a, const U& b){ if(a < b){ a = b; return 1; } return 0; }
template<class T, class U> inline bool change(T& a,U& b){if(a > b){swap(a,b);return 1;}return 0;}
template<class T>
T gcd(T a,T b){
    if(a < b)swap(a,b);
    if(a % b == 0)return b;
    else return gcd(b,a%b);
}
template<class T>
T lcm(T a,T b){
    return a / gcd(a,b) * b;
}

//素数判定O(sqrt(N))
template<class T>
inline bool isp(T n){
    bool res = true;
    if(n == 1)return false;
    else{
        for(ll i = 2;i * i <= n;i++){
            if(n % i == 0){
                res = false;
                break;
            }
        }
        return res;
    }
}
const ll cmax = 1000000;
vector<ll> fac(cmax),finv(cmax),inv(cmax);

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < cmax; i++){
        fac[i] = fac[i - 1] * i % mod;
        inv[i] = mod - inv[mod%i] * (mod / i) % mod;
        finv[i] = finv[i - 1] * inv[i] % mod;
    }
}

// 二項係数計算
ll nCk(ll n, ll k){
    if(fac[0] == 0)COMinit();
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}
//nのm乗をMODで割ったあまりO(logm)
ll modpow(ll n,ll m,ll MOD){
    if(m == 0)return 1;
    if(m < 0)return -1;
    ll res = 1;
    while(m){
        if(m & 1)res = (res * n) % MOD;
        m >>= 1;
        n *= n;
        n %= MOD;
    }
    return res;
}
ll mypow(ll n,ll m){
    if(m == 0)return 1;
    if(m < 0)return -1;
    ll res = 1;
    while(m){
        if(m & 1)res = (res * n);
        m >>= 1;
        n *= n;
    }
    return res;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    string S;//AKIHABARA
    cin >> S;
    if(S == "KIHBR" || S == "AKIHBR" || S == "KIHABR" || S == "AKIHABR"
    || S == "KIHBAR" || S == "AKIHBAR" || S == "KIHABAR" || S == "AKIHABAR"
    || S == "KIHBRA" || S == "AKIHBRA" || S == "KIHABRA" || S == "AKIHABRA"
    || S == "KIHBARA" || S == "AKIHBARA" || S == "KIHABARA" || S == "AKIHABARA"){
        cout << "YES\n";
    }
    else cout << "NO\n";
}

Measured memory_bytes: 26476
#include<stdio.h>
#include<stdlib.h>
int main(void){
	int n;
	char *s;
	char *t;
	scanf("%d", &n);
	s = (char *)malloc(sizeof(char) * (n+1));
	t = (char *)malloc(sizeof(char) * (n+1));
	scanf("%s", s);
	scanf("%s", t);
	for(int i=0; i<n; i++){
		printf("%c", s[i]);
		printf("%c", t[i]);
	}
	printf("\n");
	return 0;
}


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


























int main() {
    long long N, X, M;
    cin >> N >> X >> M;
    long long ans = 0;
    for (int i = 0; i < 20; i++) {
        ans += X;
        X = (X * X) % M;
        N--;
        if (N == 0) break;
    }
    vector<long long> period;
    period.push_back(X);
    X = (X * X) % M;
    while(X != period[0]) {
        period.push_back(X);
        X = (X * X) % M;
    }
    long long q = N / period.size();
    long long sum = 0;
    for (long long i: period) {
        sum += i;
    }
    long long sum2 = 0;
    for (long long i = 0; i < (N % period.size()); i++) {
        sum2 += period[i];
    }
    ans += sum * q + sum2;

    cout << ans << endl;
}

Measured memory_bytes: 3780
/* It's a shot in the dark
 				But I will make it */
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int inf=1000000000;

bool cmp(pair<int,int> a, pair<int,int> b){
	return a.second<b.second;
}
const ll mod= 998244353;
const int N = 200005;

ll add(ll x, ll y){
	x+=y;
	while(x>= mod) x-=mod;
	while(x<0) x+=mod;
	return x;
} 
ll mul(ll x , ll y){
	return (x*y)%mod;
}
ll binpow(ll x , ll y){
	ll z=1;
	while(y){
		if(y&1) z = mul(z,x);
		x= mul(x,x);
		y>>=1;
	}
	return z;
}

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	ll n,k;
	cin >>n>>k;
	vector<pair<ll,ll> > v(k);
	for(ll i=0;i<k;i++){
		cin >>v[i].first>>v[i].second;
	}
	sort(v.begin(),v.end());
	vector<ll> dp(n+1,0),psum(n+1,0);
	dp[1]=1;
	
	psum[1]=1;
	for(int i=2;i<=n;i++){
		for(int j=0;j<k;j++){
		
			int l = max((ll)1,i-v[j].second);
			int r = max((ll)0,i-v[j].first);
			dp[i]=add(dp[i],add(psum[r],-psum[l-1]));
			
		}
		psum[i]=add(psum[i-1],dp[i]);
	}
	
	cout <<dp[n]<<"\n";

}


Measured memory_bytes: 6348
n,m=map(int,input().split())
st=[]
ch=[]
def mht(ax,ay,bx,by):
  return abs(ax-bx)+abs(ay-by)

for i in range(n):
  st.append(list(map(int,input().split())))
for i in range(m):
  ch.append(list(map(int,input().split())))
  
for i in st:
  ax=i[0]
  ay=i[1]
  mn=1000000000
  for (j,k) in zip(ch,range(len(ch))):
    bx=j[0]
    by=j[1]
    mh=mht(ax,ay,bx,by)
    if mh<mn:
      mn=mh
      nm=k
  print(nm+1)


Measured memory_bytes: 9220
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int k = sc.nextInt();
    String answer = sc.next();
    StringBuilder sb = new StringBuilder();
    sb.append(answer);
    char tmp = sb.charAt(k-1);
    if(tmp=='A'){
      sb.setCharAt(k-1,'a');
    }else if(tmp=='B'){
      sb.setCharAt(k-1,'b');
    }else{
      sb.setCharAt(k-1,'c');
    }
    answer = sb.toString();
 //   System.out.print()
//    if(answer[n-1]=="A"){
//      answer[n-1]="a";
//    }else if(answer[n-1]=="B"){
//      answer[n-1]="b";
//    }else{
//      answer[n-1]="c";
//    }
    System.out.println(answer);
  }
}

Measured memory_bytes: 21716
const fs = require('fs');

function main(input) {
  var arr = input.split('\n')
  var N = parseInt(arr[0], 10);
  var a = arr[1].split(' ')
  a = a.map(n => parseInt(n, 10));
  a.sort((a, b) => (a < b ? 1 : -1));

  var sa = 0;
  var sb = 0;
  a.forEach((v, i) => {
    (i & 1) ? sb += v : sa += v;
  });
  var ans = sa - sb;
  console.log(ans);
}

var input = fs.readFileSync('/dev/stdin', 'utf8');
main(input);

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

using namespace std;

int main()
{
	long long int a,b,c;
	cin >> a >> b >> c; 
	long long int ar[3];
	ar[0] = a * b;
	ar[1] = a * c;
	ar[2] = c * b;
	sort(ar , ar + 3);
	if ((a * b * c) % 2 == 0)
	{
		cout << 0 << endl;
	}
	else
	{
		cout << ar[0];
	}
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<queue>
#include<algorithm>
#include<map>
#include<set>
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;



int main() {
	int n;
	cin >> n;
	set<ll> s;
	rep(i, n) {
		ll k;
		cin >> k;
		if (s.count(k)) s.erase(k);
		else s.insert(k);
	}
	cout << s.size() << endl;
}

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

int main(){
	int a,b;
	cin >> a >> b;
	bool ans=false;
	for(int c=1;c<4;c++){
		if((a*b*c)%2!=0) ans=true;
	}
	if(ans) cout << "Yes" << endl;
	else cout << "No" << endl;
}


Measured memory_bytes: 256
from collections import deque

n,m = map(int,input().split())
remains = set(range(1,n+1))
edges = [[] for _ in range(n+1) ]

for i in range(m):
    x,y,z = map(int, input().split())
    edges[x].append(y)
    edges[y].append(x)

ans = 0
while(len(remains) > 0):
    ans += 1

    d = deque()
    d.append(remains.pop())
    while(len(d) > 0):
        tmp = d.pop()
        for i in edges[tmp]:
            if( i in remains):
                d.append(i)
                remains.remove(i)

print(ans)

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

using namespace std;

#define M 256
#define EPS 1e-9

int main()
{
  int N;
  while(cin >> N, N){
    int I[256];
    for(int i = 0; i < N; i++) cin >> I[i];
    
    double H = 1000000.0;
    int S, A, C;
    for(int s = 0; s <= 15; s++){
      for(int a = 0; a <= 15; a++){
	for(int c = 0; c <= 15; c++){
	  int R[256]; R[0] = s;
	  int x[256] = {0};
	  for(int i = 0; i < N; i++){
	    R[i+1] = (a*R[i] + c) % M;
	    x[(I[i] + R[i+1])%M]++;
	  }
	  double h = 0.0;
	  for(int i = 0; i < 256; i++){
	    if(x[i] == 0) continue;
	    h -= (double)x[i] / N * log((double)x[i] / N);
	  }
	  if(h + EPS < H) H = h, S = s, A = a, C = c;
	}
      }
    }
    cout << S << " " << A << " " << C << endl;
  }
  return 0;
}

Measured memory_bytes: 1204
# coding: utf-8
# Your code here!

import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline

#from itertools import permutations

from math import atan2, pi
from bisect import *

n = int(input())
#a,b = [int(i) for i in readline().split()]
ans = 0
txy = []
for _ in range(n):
    x,y = [int(i) for i in readline().split()]
    ans = max(ans,x*x+y*y)
    txy.append((atan2(y,x),x,y))
    txy.append((atan2(y,x)+2*pi,x,y))

txy.sort()
#print(txy)

N= 100000
a = 2*pi/N

id1 = id2 = 0
for i in range(N):
    r = i*a
    
    nid1 = bisect(txy,(r,0,0))
    nid2 = bisect(txy,(r+pi,0,0))

    if id1 == nid1 and id2 == nid2: continue
    id1,id2 = nid1,nid2
    
    rx = ry = 0
    for t,x,y in txy[id1:id2]:
        rx += x
        ry += y
    
    ans = max(ans,rx*rx+ry*ry)




print(ans**0.5)




    

Measured memory_bytes: 44936
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
#include<stdio.h>
#include <cstdint>
#include <stdlib.h> 
#include <time.h>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define drep(i,n,m) for(int i = n;i >= m;i--)
#define rrep(i,n) REP(i,1,n+1)
#define all(a) a.begin(), a.end()
#define fi first
#define se second
#define RNG(x, a, n) &((x)[a]), &((x)[n])
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }
typedef long long ll;
typedef pair<ll, ll> Pll;
typedef pair<int, int> PII;
typedef vector<ll> Vl;
typedef vector<int> VI;
typedef tuple<int, int, int> TT;
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define rall(v) v.rbegin(), v.rend()
#define dmp(x,y) make_pair(x,y)
#define dmt(x, y, z) make_tuple(x, y, z)
#define pb(x) push_back(x)
#define pf(x) push_front(x)
const int MAX = 500000;
const int inf = 1000000007;
const ll mod = 1000000007;
const long double PI = (acos(-1));
const long double EPS = 0.0000000001;

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


int n, ans;
int k;
int a[1000];

int main() {

	cin >> n >> k;

	rep(i, k) {
		int d;
		cin >> d;
		rep(i, d) {
			int cnt;
			cin >> cnt;
			a[cnt]++;
		}
	}

	rrep(i, n) {
		if (a[i] == 0)ans++;
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i = 0; i < (N); i++)
#define repo(i,N) for(int i = 1; i < (N); i++)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
//#define num 1000000007
#define pi acos(-1.0)
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//#define int long long


int main() {
  string s;
  cin >> s;

  cout << s.substr(0,5) << " " << s.substr(6,7) << " " << s.substr(14,5) << endl;
      
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define _overload3(_1,_2,_3,name,...)name
#define _rep(i,n)repi(i,0,n)
#define repi(i,a,b)for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define MSVC_UNKO(x)x
#define rep(...)MSVC_UNKO(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define all(c)c.begin(),c.end()
#define write(x)cout<<(x)<<'\n'
using namespace std; typedef long long ll; template<class T>using vv = vector<vector<T>>;
template<class T>auto vvec(int n, int m, T v) { return vv<T>(n, vector<T>(m, v)); }
constexpr int INF = 1 << 29, MOD = int(1e9) + 7; constexpr ll LINF = 1LL << 60;
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10); }; }aaaa;

int main() {
    int N;
    cin >> N;
    write((N + 1) / 2);
}

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

int main() {
	int k, n;
	cin >> k >> n;
	int a[n];
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	int max = a[0] - a[n - 1] + k;
	for (int i = 0; i < n - 1; i++) {
		if (a[i + 1] - a[i] > max)
			max = a[i + 1] - a[i];
	}
	cout << k - max << endl;

}


Measured memory_bytes: 1024
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define rep2(i, l, r) for (int i = (l); i < (r); i++)
#define ALL(x) (x).begin(), (x).end()     //昇順
#define RALL(x) (x).rbegin(), (x).rend()  // 降順
#define FOR(i, c) \
  \ for (__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
const long long mod = 1e9 + 7;
typedef long long ll;  // ll とdoubleは違う
typedef priority_queue<int> PQ;
typedef vector<long long> VL;
typedef vector<bool> VB;
typedef vector<int> VI;  // VI a(n);
typedef vector<double> VD;
typedef vector<string> VS;
typedef vector<char> VC;
typedef vector<VS> VSS;
typedef vector<VC> VCC;
typedef vector<VI> VII;  // VII a(n,vector<int>(m)) n * m
typedef vector<VL> VLL;
typedef vector<VB> VBB;
typedef pair<int, int> PII;
typedef map<int, int> MP;  // MP a;
typedef vector<pair<ll, ll>> PS;

template <class T, class U>  // chmax(max, a);
bool chmax(T &a, U b) {
  if (a <= b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T, class U>  // chmin(min,a)
bool chmin(T &a, U b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename T>  // operator << (cout,a);
ostream &operator<<(ostream &os, vector<T> &v) {
  os << "{";
  rep(i, (int)v.size()) { os << v[i] << (i < v.size() - 1 ? ", " : ""); }
  os << "}";
  return os;
}

// g++ -std=c++11 prac.cpp

// Union Find
struct UnionFind {
    vector<ll> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2
    vector<ll> siz;
    
    //最初は全てが根であるとして初期化
    UnionFind(ll N) : par(N), siz(N, 1LL) { 
        for(ll i = 0; i < N; i++) par[i] = i;
    }

    //初期化
    void init(ll N) {   
        par.resize(N);
        siz.assign(N, 1LL);  // resize だとなぜか初期化されなかった
        for (ll i = 0; i < N; i++) par[i] = i; // 初期では親は自分自身
    }

    // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
    ll root(ll x) { 
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    // 素集合のサイズ
    ll size(ll x){ 
      return siz[root(x)];
    }

    // xとyの木を併合
    bool unite(ll x, ll y) {
        ll rx = root(x); //xの根をrx
        ll ry = root(y); //yの根をry
        if (rx == ry) return false; //xとyの根が同じ(=同じ木にある)時はそのまま

        if (siz[rx] < siz[ry]) swap(rx, ry);
        siz[rx] += siz[ry];
        par[ry] = rx;     //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
        return true;
    }

    // 2つのデータx, yが属する木が同じならtrueを返す
    bool same(ll x, ll y) { 
        ll rx = root(x);
        ll ry = root(y);
        return rx == ry;
    }
};

int main() {
  ll x=0,y=0,k,n,m,h,w,ans=0,sum=0,Max=1,Min=1e9+1;
  string s,t;
  bool ok = false;
  cin >> n >> m >> k;
  VII a(n);
  UnionFind u(n);

  rep(i,m){
    cin >> x >> y;
    x--;y--;
    a[x].emplace_back(y);
    a[y].emplace_back(x);
    u.unite(x,y);
  }
  rep(i,k){
    cin >> x >> y;
    x--;y--;
    if(!u.same(x,y)) 
      continue;
    a[x].emplace_back(y);
    a[y].emplace_back(x);
  }
  rep(i,n){
    ans = u.size(i)-1;
    ans -= a[i].size();
    cout << ans << " ";
  }
  return 0;
}

Measured memory_bytes: 9088
#include<bits/stdc++.h>
using namespace std;
int main(){
	int t=1;
	//cin >> t;
	while(t--){
		int i=0,n=0,x=0,y=0,j=0,z=0;
      	cin >> x >> n;
      	int arr[210];
      	memset(arr,0,sizeof(arr));
      	for(i=0;i<n;i++){
        	cin >>z;
          	arr[z+100]++;
        }
      	if(arr[x+100]==0){cout << x <<endl;}
      	else{
          	i=x;j=x;
        	while(arr[i+100]!=0){i--;}
          	while(arr[j+100]!=0){j++;}
            //cout << i << j << endl;
          	if(abs(j-x)>=abs(x-i)){cout << i << endl;}
          	else cout << j<< endl;
        }
	}
}

Measured memory_bytes: 3636
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>
#include <algorithm>
using namespace std;
int main()
{
	int n, i;
	int a[105];
	int sum = 0 ,sum1 = 0 , sum2 = 0;
	scanf("%d", &n);
	for(i = 1; i <= n ; i++)
	{
		scanf("%d", &a[i]);
		sum = sum + a[i];
	}
	sort(a + 1 , a + 1 + n);
	if(n % 2 == 0)
	{
		for(i = 2 ; i <= n ; i = i + 2)
		{
			sum1 = sum1 + a[i];
		}
		printf("%d\n",2 * sum1 - sum);
	}
	else
	{
		for(i = 1; i <= n ; i = i + 2)
		{
			sum1 = sum1 + a[i];
		}
		printf("%d\n", 2 * sum1 - sum);
	}
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pint;

int main(){
    int x,t;
    cin>>x>>t;
    cout<<max(x-t,0)<<endl;
    return 0;
}

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

int main(){
  string X;cin>>X;
  stack<char> st;
  for(int i=0;i<X.size();i++){
    if(st.empty())st.push(X[i]);
    else if(X[i]=='S')st.push(X[i]);
    else if(st.top()=='S')st.pop();
    else st.push(X[i]);
  }
  cout<<st.size()<<endl;
}


Measured memory_bytes: 644
#include<iostream>
#include<vector>
#include<string>

using namespace std;

int main(){
  int N; cin >> N;
  vector<string> W(N);
  for(int i = 0; i < N; i++){
    cin >> W[i]; }
  bool flag = true;
  for(int j = 0; j < N - 1; j++){
    if(W[j].back() != W[j+1].front()){ flag = false; break;}}
  
  for(int j = 0; j < N - 1; j++){
    for(int k = j + 1; k < N; k++){
      if(W[k] == W[j]){ flag = false; break;}}}
  
  if(flag){cout << "Yes" << endl;}
  else{cout << "No" << endl;}
  
  return 0;
}
    

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

int main(void){
    int n,x;
    cin>>n>>x;
    vector<int> l(n);
    for(int i=0;i<n;i++){
        cin>>l[i];
    }
    l.push_back(0);
    int d=0;
    int count=0;
    for(int i=0;d<=x&&i<=n;i++){
        count++;
        d+=l[i];
    }
    cout<<count<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	int n,a[100];
	cin>>n;
	for(int i=0;i<n;i++){cin>>a[i];}
	for(int j=n-1;j>=1;j--){
	cout<<a[j]<<" ";}
	cout<<a[0]<<endl;
	return 0;
}


Measured memory_bytes: 3096
#include <algorithm>
#include <iostream>

using namespace std;

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

    int res = 100;
    for (long long i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            int d1 = 0;
            for (long long j = i; j > 0; j /= 10) {
                d1++;
            }

            int d2 = 0;
            for (long long j = n / i; j > 0; j /= 10) {
                d2++;
            }

            res = min(res, max(d1, d2));
        }
    }

    cout << res << endl;
}


Measured memory_bytes: 256
a = input()
b = input()

dicta = dict()
dictb = dict()

for i in a:
	if i not in dicta:
		dicta[i] = 1
	else:
		dicta[i] += 1
	
for i in b:
	if i not in dictb:
		dictb[i] = 1
	else:
		dictb[i] += 1
		
		
if sorted(dicta.values()) == sorted(dictb.values()):
	print ('Yes')
else:
	print ('No')

Measured memory_bytes: 3632
#include <iostream>
#include <stdio.h>
#include<algorithm>
#include <math.h>
#include <string.h>
#include <map>
#define eps 1e-9
typedef long long int ll;
#define p1 3.1415926535898
using namespace std;
int main()
{
    int n,m;
    cin>>n>>m;
    if(n>=10)
    {
        cout<<m<<endl;
    }
    else
    {
        cout<<m+(100*(10-n))<<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 <complex>

#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

#include <stdexcept>

using namespace std;

// type alias
using ll = long long;
using ull = unsigned long long;
using comp = complex<double>;

const ll MOD = 1000000007LL;
const double PI = 3.14159265358979323846;

//conversion
//------------------------------------------
inline int toint(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class t> inline string tostring(t x) { ostringstream sout; sout << x; return sout.str(); }

//debug
#define DUMP(x)  cerr << #x << " = " << (x) << endl
#define DEBUG(x) cerr << #x << " = " << (x) << " (l" << __line__ << ")" << " " << __file__ << endl

ll get_wd(ll i, ll C, string S, vector<ll>& wds) {
	if (i < 0) {
		return 0LL;
	}
	if (wds[i] != -1) {
		return wds[i];
	}

	if (S[i] == 'o') {
		wds[i] = get_wd(i - C - 1LL, C, S, wds) + 1LL;
	}
	else if (S[i] == 'x') {
		wds[i] = get_wd(i - 1LL, C, S, wds);
	}

	return wds[i];
}

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

	ll N, K, C;
	string S;
	cin >> N >> K >> C >> S;

	vector<ll> wds(N);
	vector<vector<ll>> k_to_idx(K + 2);
	for (ll i = 0; i < N; ++i) {
		if (S[i] == 'o') {
			wds[i] = 1LL;
			if (i - C - 1LL >= 0) {
				wds[i] += wds[i - C - 1LL];
			}
			if (wds[i] < K + 1LL) {
				k_to_idx[wds[i]].emplace_back(i);
			}
			else {
				k_to_idx[K + 1LL].emplace_back(i);
			}
		}
		else if (S[i] == 'x') {
			if (i - 1LL >= 0) {
				wds[i] += wds[i - 1LL];
			}
		}
	}

	if (k_to_idx[K + 1].size() > 0LL) {
		cout << endl;
		return 0;
	}

	stack<ll> res;
	ll val = N;
	for (ll i = K; i > 0; --i) {
		auto iter = upper_bound(k_to_idx[i].begin(), k_to_idx[i].end(), val);
		auto dist = distance(k_to_idx[i].begin(), --iter);
		val = (*iter) - C - 1LL;
		if (dist == 0LL) {
			res.push(*iter + 1);
		}
	}
	while (!res.empty()) {
		cout << res.top() << endl;
		res.pop();
	}

	return 0;
}


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

int main(){
    int n; string s;
    cin >> n >> s;
    int c = 'A';
    for(int i = 0; i < s.size(); i++){
        int num = (s[i] - c + n)%26;
        s[i] = (char)(c+num);
    }
    cout << s << endl;
    return 0;
}

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

using namespace std;

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define pf push_front
#define mp make_pair
#define mt make_tuple
#define popb pop_back
#define popf pop_front
#define int long long int
#define vi         vector<int>
#define vll        vector<ll>
#define vpii       vector<pair<int,int>>
#define vpll       vector<pair<ll,ll>>
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define sz(container) int((container).size())
#define rep(i,a,b) for(i=a;i<b;i++)
#define tr(container,it)   for(typeof(container.begin()) it = container.begin(); it != container.end(); it++)
#define present(container, element) (container.find(element) != container.end())      //set,map etc.
#define cpresent(container, element) (find(all(container),element) != container.end())    //vector
#define hell 1000000007
#define PI 3.14159265
#define mod 998244353
#define fs first
#define sc second
#define TIME        cerr << "\nTime elapsed: " << setprecision(5) <<1000.0 * clock() / CLOCKS_PER_SEC << "ms\n";
void solve()
{
  int a,b;
  cin>>a>>b;
  cout<<6-a-b;
}
signed main()
{
  fastio
  //freopen("input.txt", "r", stdin);
  //freopen("output.txt", "w", stdout);
  int t;
  t=1;
  //cin>>t;
  while(t--)
  solve();
  //TIME
  return 0;
}

Measured memory_bytes: 256