akhauriyash/Code-Regression huggingface dataset:
using AtCoderBeginnerContest122.Questions;
using AtCoderBeginnerContest122.Extensions;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;

namespace AtCoderBeginnerContest122.Questions
{
    public class QuestionA : AtCoderQuestionBase
    {
        public override IEnumerable<object> Solve(TextReader inputStream)
        {
            var b = inputStream.ReadLine()[0];

            switch (b)
            {
                case 'A':
                    yield return 'T';
                    break;
                case 'T':
                    yield return 'A';
                    break;
                case 'C':
                    yield return 'G';
                    break;
                case 'G':
                    yield return 'C';
                    break;
                default:
                    break;
            }
        }
    }
}


namespace AtCoderBeginnerContest122
{
    class Program
    {
        static void Main(string[] args)
        {
            IAtCoderQuestion question = new QuestionA();    // 問題に合わせて書き換え
            var answers = question.Solve(Console.In);
            foreach (var answer in answers)
            {
                Console.WriteLine(answer);
            }
        }
    }
}

#region Base Classes

namespace AtCoderBeginnerContest122.Questions
{

    public interface IAtCoderQuestion
    {
        IEnumerable<object> Solve(string input);
        IEnumerable<object> Solve(TextReader inputStream);
    }

    public abstract class AtCoderQuestionBase : IAtCoderQuestion
    {
        public IEnumerable<object> Solve(string input)
        {
            var stream = new MemoryStream(Encoding.Unicode.GetBytes(input));
            var reader = new StreamReader(stream, Encoding.Unicode);

            return Solve(reader);
        }

        public abstract IEnumerable<object> Solve(TextReader inputStream);
    }

}

#endregion

#region Extensions

namespace AtCoderBeginnerContest122.Extensions
{
    internal static class TextReaderExtensions
    {
        internal static int ReadInt(this TextReader reader) => int.Parse(ReadString(reader));
        internal static long ReadLong(this TextReader reader) => long.Parse(ReadString(reader));
        internal static double ReadDouble(this TextReader reader) => double.Parse(ReadString(reader));
        internal static string ReadString(this TextReader reader) => reader.ReadLine();

        internal static int[] ReadIntArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(int.Parse).ToArray();
        internal static long[] ReadLongArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(long.Parse).ToArray();
        internal static double[] ReadDoubleArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(double.Parse).ToArray();
        internal static string[] ReadStringArray(this TextReader reader, char separator = ' ') => reader.ReadLine().Split(separator);
    }
}

#endregion

Measured memory_bytes: 11092
#include<stdio.h>
int main(void){
	int a=0,n=0;
	scanf("%d",&n);
	if(n<10){
		a=n;
	}else if(n<100){
		a=9;
	}else if(n<1000){
		a=n-90;
	}else if(n<10000){
		a=909;
	}else if(n<100000){
		a=n-9090;
	}else{
		a=90909;
	}
	printf("%d",a);
	return 0;
} 

Measured memory_bytes: 1716
#include<iostream>
#include<string>
#include <vector>
#include<algorithm>
using namespace std;
using vi = vector<int>;
using vii = vector<vi>;
using pii = pair<int, int>;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define vsort(v) sort(v.begin(), v.end())
#define ll long long
const ll MOD = 1e9 + 7;

int main() {
	int n;
	cin >> n;
	vi a(n);
	rep(i, n) cin >> a[i];
	vsort(a);
	int k = a[n - 1] - a[0];
	cout << k << endl;
}

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

typedef long long ll;
typedef pair<int, int> pii;

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

	string s;
	cin >> s;

	cout << ((s[2] == s[3] && s[4] == s[5]) ? "Yes" : "No");

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <cmath>
#include <string>
#include <map>

#define pb push_back
#define mp make_pair

using namespace std;

typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef unsigned long long ull;
typedef long long ll;

int main() {
  ull n, a, b;
  cin >> n >> a >> b;

  cout << n/(a+b) * a + min(a, n%(a+b)) << endl;
  return 0;
}


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

using namespace std;

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

}

Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>

using namespace std;

const int N = 200100;

int n, m, a[N], c[N];

int main() {

	scanf("%d %d", &n, &m);

	for (int i = 0; i < n; i++) {
		scanf("%d", &a[i]);
	}

	for (int i = 1; i <= m; i++) {
		for (int j = 0; j <= n; j++) {
			c[j] = 0;
		}
		for (int j = 0; j < n; j++) {
			int u = max(0, j - a[j]);
			int v = min(n - 1, j + a[j]);
			c[u]++;
			c[v + 1]--;
		}
		for (int j = 1; j <= n; j++) {
			c[j] += c[j - 1];
		}
		bool change = false;
		for (int j = 0; j < n; j++) {
			change |= (a[j] != c[j]);
			a[j] = c[j];
		}
		if (!change) {
			break;
		}
	}

	for (int i = 0; i < n; i++) {
		printf("%d ", a[i]);
	}

	puts("");

	return 0;

}

Measured memory_bytes: 5388
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const ll mod = 1000000007;
//const ll mod = 998244353;
const int inf = 1e9 + 10;
const ll INF = 1e18;
const ld EPS = 1e-10;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }



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

  string s;
  cin >> s;

  vector<int> cnt(3, 0);
  rep(i, s.length()) {
    cnt[s[i] - 'a']++;
  }
  sort(cnt.begin(), cnt.end());
  cout << (cnt[2] - cnt[0] <= 1 ? "YES" : "NO") << '\n';


  
  return 0;
}

Measured memory_bytes: 512
// ABC 143-B
// 2019.10.19 bal4u

#include <stdio.h>

int d[105];

int main()
{
	int i, j, N, s;
	
	scanf("%d", &N);
	for (i = 0; i < N; ++i) scanf("%d", d+i);
	s = 0;
	for (i = 0; i < N; ++i) for (j = i+1; j < N; ++j)
		s += d[i] * d[j];
	printf("%d\n", s);
	return 0;
}


Measured memory_bytes: 128
fun main(args: Array<String>) {
    val (N, K) = listOfInt()
    val k2 = K * 2
    val k4 = K * 4
    val B = Array(k2 + 1) { IntArray(k2 + 1) }
    repeat(N) {
        val xyc = listOfString()
        val c = xyc[0].toInt() % k2
        val r = xyc[1].toInt() % k2
        if (xyc[2] == "B") B[r][c] += 1 else B[r][(c + K) % k2] += 1
    }
    val S = Array(k4 + 1) { IntArray(k4 + 1) }
    for (r in 0 until k4) {
        for (c in 0 until k4) {
            S[r][c + 1] = S[r][c] + B[r % k2][c % k2]
        }
    }
    for (r in 1 .. k4) {
        for (c in 0 .. k4) {
            S[r][c] += S[r - 1][c]
        }
    }
    var ans = 0
    fun num(r: Int, c: Int) = S[r + K][c + K] - S[r][c + K] - S[r + K][c] + S[r][c]
    for (r in 0 .. k2) {
        for (c in 0 .. k2) {
            val b = num(r, c) + num(r + K, c + K)
            ans = Math.max(ans, b)
        }
    }
    println(ans)
}

fun next() = readLine()!!
fun nextInt() = Integer.parseInt(next())
fun nextInt(offset: Int = 0) = nextInt() + offset
fun nextLong() = java.lang.Long.parseLong(next())
fun nextLong(offset: Long = 0L) = nextLong() + offset
fun nextDouble() = next().toDouble()
fun listOfString() = next().split(" ")
fun listOfInt() = listOfString().map { Integer.parseInt(it) }



Measured memory_bytes: 135892
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<math.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()

using namespace std;
using ll = long long int;

int main(void) {
    int n; cin >> n;
    vector<vector<pair<int, bool>>> p(n);
    REP(i, n) {
        int a; cin >> a;
        REP(j, a) {
            int x; bool y;
            cin >> x >> y;
            p[i].push_back(make_pair(x - 1, y));
        }
    }
    int mx = 0;
    for (int bit = 0; bit < (1 << n); bit++) {
        int sum = 0;
        vector<bool> oou(n, false);
        for (int i = 0; i < n; i++) {
            if (bit & (1 << i)) {
                sum++;
                oou[i] = true;
            }
        }
        bool t = 1;
        for (int i = 0; i < n; i++) {
            if (oou[i] == true) {
                for (auto v : p[i]) {
                    if (oou[v.first] != v.second) {
                        t = false;
                        goto label;
                    }
                }
            } 
        }
        label:
        if (t) mx = max(mx, sum);
    }
    cout << mx << endl;
}

Measured memory_bytes: 256
import sys
import  math
import fractions
from collections import defaultdict
stdin = sys.stdin
     
ns = lambda: stdin.readline().rstrip()
ni = lambda: int(stdin.readline().rstrip())
nm = lambda: map(int, stdin.readline().split())
nl = lambda: list(map(int, stdin.readline().split()))

mod=998244353

N,S=nm()
A=nl()


dp=[[0]*3001  for _ in range(3001)]#i i番目 j和がj
dp[0][A[0]]=1
dp[0][0]=2
for i in range(1,N):
    for j in range(0,3001):
        if(0<=(j-A[i])):
            dp[i][j]=dp[i-1][j-A[i]]+2*dp[i-1][j]
        else:
            dp[i][j]=2*dp[i-1][j]
        dp[i][j]%=mod

ans=dp[N-1][S]
print(ans%mod)

Measured memory_bytes: 144412
import java.util.*;

public class Main {
	public static void main (String[] args) {
    	Scanner sc = new Scanner(System.in);
    	int h = sc.nextInt();
    	int w = sc.nextInt();
    	int m = sc.nextInt();
    	int[] harr = new int[h];
    	int[] warr = new int[w];
    	HashSet<Long> used = new HashSet<>();
    	for (int i = 0; i < m; i++) {
    	    int hh = sc.nextInt() - 1;
    	    int ww = sc.nextInt() - 1;
    	    harr[hh]++;
    	    warr[ww]++;
    	    used.add((long)w * hh + ww);
    	}
        int hmax = 0;
        ArrayList<Integer> hlist = new ArrayList<>();
        for (int i = 0; i < h; i++) {
            if (hmax <= harr[i]) {
                if (hmax < harr[i]) {
                    hlist.clear();
                    hmax = harr[i];
                }
                hlist.add(i);
            }
        }
        int wmax = 0;
        ArrayList<Integer> wlist = new ArrayList<>();
        for (int i = 0; i < w; i++) {
            if (wmax <= warr[i]) {
                if (wmax < warr[i]) {
                    wlist.clear();
                    wmax = warr[i];
                }
                wlist.add(i);
            }
        }
        for (int hh : hlist) {
            for (int ww : wlist) {
                if (!used.contains((long)w * hh + ww)) {
                    System.out.println(hmax + wmax);
                    return;
                }
            }
        }
        System.out.println(hmax + wmax - 1);
    }
    
    static class Path implements Comparable<Path> {
        int h;
        int w;
        int value;
        
        public Path(int h, int w, int value) {
            this.h = h;
            this.w = w;
            this.value = value;
        }
        
        public int compareTo(Path another) {
            return value - another.value;
        }
        
        public String toString() {
            return h + ":" + w + ":" + value;
        }
    }
}



Measured memory_bytes: 89132
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
typedef vector<llong> V;

#define _ cin.tie(0);ios::sync_with_stdio(false);
int n;
int main(){ _;
  cin>>n;
  V a(n);
  REP(i,n) cin>>a[i];
  int count=0;
  REP(i,n)
    if(a[i]%2==0)
      count++;
  if(n%2==0)
    if(count%2==0)
      cout<<"YES"<<endl;
    else
      cout<<"NO"<<endl;
  else
    if(count%2==0)
      cout<<"NO"<<endl;
    else
      cout<<"YES"<<endl;
	

  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
const double PI = acos(-1);
const double EPS = 1e-15;
long long INF=(long long)1E17;
#define i_7 (long long)(1E9+7)
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
using namespace std;
bool prime(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd(b,a%b);
  }
}
 
long long lcm(long long x, long long y){
  return (x/gcd(x,y))*y;
}
 
class UnionFind {
    public:
    //各頂点の親の番号を格納する。その頂点自身が親だった場合は-(その集合のサイズ)を入れる。
    vector<int> Parent;
    
    //クラスを作るときは、Parentの値を全て-1にする。
    //以下のようにすると全てバラバラの頂点として解釈できる。
    UnionFind(int N) {
        Parent = vector<int>(N, -1);
    }
    
    //Aがどのグループに属しているか調べる
    int root(int A) {
        if (Parent[A] < 0) return A;
        return Parent[A] = root(Parent[A]);
    }
    
    //自分のいるグループの頂点数を調べる
    int size(int A) {
        return -Parent[root(A)];//先祖をrootで取っておきたい。
    }
    
    //AとBをくっ付ける
    bool connect(int A, int B) {
        //AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
        A = root(A);
        B = root(B);
        if (A == B) {
            //すでにくっついてるからくっ付けない
            return false;
        }
        
        //大きい方(A)に小さいほう(B)をくっ付けたい
        //大小が逆だったらAとBをひっくり返す。
        if (size(A) < size(B)) swap(A, B);
        
        //Aのサイズを更新する
        Parent[A] += Parent[B];
        //Bの親をAに変更する
        Parent[B] = A;
        
        return true;
    }
};

//typedef pair<long long,long long> P;

int main(){
  long long n,a,b;
  cin>>n>>a>>b;
  if(a>b){
    cout<<0<<endl;
    return 0;
  }
  if(a==b){
    cout<<1<<endl;
    return 0;
  }
  if(n<=2){
    if(n==1){
      cout<<0<<endl;
    }else{
      cout<<1<<endl;
    }
    return 0;
  }
  //以下はnが3以上でa<bの時
  cout<<(b-a)*(n-2)+1<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define lp(n) for(int i = 0; i < n; i++)
#define LP(i, a, n) for(int i = a; i < n; i++)
#define lpp(i, n) for(int i = 0; i < n; i++)
using namespace std;
int N;
int check(int a[], int n, int s, int q) {
  if(s == q) return 1;
  else if(n == N) return 0;
  else if(check(a, n+1, s + a[n], q)||check(a, n+1, s, q)) return 1;
  return 0;
}
int main() {
  int q, b, c=0;
  int a[20];
  cin >> N;
  lp(N) cin >> a[i];
  cin >> q;
  lp(q) {
    cin >> b;
    cout << (check(a,0,0,b)?"yes":"no") << endl;
  }
  return 0;
}




Measured memory_bytes: 3096
n = int(input())
h = list(map(int, input().split()))

dp = [0, abs(h[1]-h[0])]
if n >2:
    for i in range(2,n):
        dp.append(min(abs(h[i]-h[i-2])+dp[-2], abs(h[i]-h[i-1])+dp[-1]))
else:
    print(dp[-1])
    exit()

print(dp[-1])


Measured memory_bytes: 13980
n=int(input())
p=[list(map(int,input().split())) for _ in range(n)]
import math
sum=0
for i in range(n):
    for j in range(i+1,n):
        sum+=math.sqrt((p[i][0]-p[j][0])**2+(p[i][1]-p[j][1])**2)
print(sum*2/n)

Measured memory_bytes: 8996
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
using namespace std;
//#define B
#define C

#ifdef A
int main(void)
{
	int a, b;
	cin >> a >> b;
	cout << a / b << " " << a %b << " ";
	printf("%f\n", static_cast<double>(a) / b);
	return 0;
}


#endif // A

#ifdef B
#define PI 3.141592653589f
int main(void)
{
	double r;
	cin >> r;
	printf("%.6f %.6f\n",r * 2 * PI, PI * r * r);
	return 0;
}
#endif // B


#ifdef C
#define _MAX 2000

void add(std::pair<int, int> &a) { cout << a.first + a.second << endl; }
void sub(std::pair<int, int> &a) { cout << a.first - a.second << endl; }
void mul(std::pair<int, int> &a) { cout << a.first * a.second << endl; }
void les(std::pair<int, int> &a) { cout << a.first / a.second << endl; }

int main(void)
{
	char op;
	pair<int, int> dis;
	vector<pair<int, int> > arr_num(_MAX);
	vector<char> arr_c(_MAX);

	op = 0;
	//arr_c[0] =0 ;


	for (size_t i = 0; i < _MAX && op != '?'; i++)
	{
		cin >> dis.first >> op >> dis.second;

		arr_num[i] = dis;
		arr_c[i] = op;
	}

	for (size_t i = 0; i < _MAX && arr_c[i] != '?'; ++i)
	{
		switch (arr_c[i])
		{
		case '+':
			add(arr_num[i]);
			break;

		case '-':
			sub(arr_num[i]);
			break;
		case '/':
			les(arr_num[i]);
			break;
		case '*':
			mul(arr_num[i]);
			break;
		}

	}



	return 0;
}
#endif // C

#ifdef D
int main(void)
{
	return 0;
}

#endif // D

Measured memory_bytes: 3080
def main():
    import sys
    import math
    import collections
    
    A=[list(map(int,input().split())) for _ in range(3)]
    N=int(input())
    C=[]
    D=[]
    for _ in range(N):
        b=int(input())
        for i in range(3):
            for j in range(3):
                if A[i][j]==b:
                    C.append(i)
                    D.append(j)
                    A[i][j]=0
    c=collections.Counter(C)
    d=collections.Counter(D)
    if 3 in c.values():
        print("Yes")
    elif 3 in d.values():
        print("Yes")
    elif A[0][0]==A[1][1] and A[1][1]==A[2][2]:
        print("Yes")
    elif A[0][2]==A[1][1] and A[1][1]==A[2][0]:
        print("Yes")
    else:
        print("No")

    
if __name__ == '__main__':
    main()



Measured memory_bytes: 38256
a, b, k = list(map(int, input().split(" ")))

c = a - k
if c < 0:
  d = b + c
else:
  d = b
  
if c < 0:
  c = 0
if d < 0:
  d = 0
  
print(str(c) + " " + str(d))


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

using namespace std;
int main()
{
	int a, b, c;
	cin >> a >> b;
	if (a > b)
		c = a + a - 1;
	else if (b > a)
		c = b + b - 1;
	else
		c = a * 2;
	cout << c << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  long long a, b;
  cin >> a >> b;
  long long ans = 0;
  vector<long long> vec(a);
  for (long long i = 0; i < a; i++) cin >> vec.at(i);
  sort(vec.begin(), vec.end());
  for (long long i = 0; i < a; i++) {
    b -= vec[i];
    if (b < 0) break;
    ans++;
  }
  if (b > 0) cout << ans - 1 << endl;
  else cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#include<string.h>
ll ar1[1000000];
ll ar2[1000000];
char s1[100009][5];
int main()
{
    ll  a,b,c,d,e,j,k,l,test;
    cin>>a>>b;
    ll ac=0,wa=0;
    ll i;
    for(i=0; i<b; i++)
    {
        cin>>ar1[i];
        cin>>s1[i];
        if(s1[i][0]=='A')ar2[ar1[i]]=1;
    }
    for(i=0; i<b; i++)
    {
        if(ar2[ar1[i]]==1)
        {
            if(s1[i][0]=='A')
            {
                ac++;
                ar2[ar1[i]]=0;
            }
            else wa++;
        }
    }
    cout<<ac<<" "<<wa<<endl;
    return 0;
}


Measured memory_bytes: 3584
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    a, b, c, d = LI()

    if abs(a - b) <= d and abs(c - b) <= d or abs(c - a) <= d:
        print('Yes')
    else:
        print('No')

if __name__ == '__main__':
    resolve()


Measured memory_bytes: 10048
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>
#include <random>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
//#define int long long

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

constexpr double EPS = 1e-10;
//constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;
constexpr int MOD = 1'000'000'007;
//inline void modAdd(LL &l, LL &r) {l = (l + r) % MOD;}

template<class T> inline T sqr(T x) {return x*x;}

void solve() {
    int n;
    cin >> n;
    cout << (n + 1) / 2 << endl;
 }

signed main() {
    solve();
    
    return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARINGS
#define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#include<iostream>
#include<algorithm>
#include<string>
#include<map>
#include<vector>
#include<set>
#include<cmath>
#include<bitset>
#include<iterator>
#include<queue>
using namespace std;
int main()
{
	fast; 
	int n;
	cin >> n;
	vector<int>v(n);
	for (int i = 0; i < n; i++)  {
		cin >> v[i];
	}
	int sum = 0, mn = 0;
	sort(v.begin(), v.end());

	for (int i =0; i <v.size(); i++) {
		if (v[i] > mn) {
			sum++;
			mn = v[i];
		}
	}
	cout << sum << endl;
	return 0;
}


Measured memory_bytes: 256
function Main(input) {
    input = input.split("\n");
    var line = input[0].split(" ");
    var max = parseInt(line[0]);
    var sum = parseInt(line[1]);
    var count = 0;
    for(var x = 0; x<=max; x++){
        for(var y = 0; y<=max; y++){
            var z = sum - (x+y);
            if(z>=0 && z<=max){
                count++;
            }
        }
    }
    
    console.log(count);

}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
#include <iostream>
#include <math.h>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()

typedef long long lint;

using namespace std;

int main(){
  int N;
  cin>>N;
  int C[N],S[N],F[N];
  REP(i,N-1)cin>>C[i]>>S[i]>>F[i];
  REP(i,N-1){
    int ans=S[i]+C[i];
    FOR(j,i+1,N-1){
      // cout<<" "<<ans<<endl;
      ans=max(S[j],((ans-1)/F[j]+1)*F[j])+C[j];
    }
    cout<<ans<<endl;
  }
  cout<<0<<endl;
  return 0;
}


Measured memory_bytes: 256
N,x =map(int,input().split())
a=[int(i) for i in input().split()]
ans=0
if a[0] >x:
  ans += (a[0]-x) 
  a[0] -= (a[0]-x) 
  

for i in range(N-1):
  if a[i]+a[i+1] >x:
    ans += ((a[i]+a[i+1])-x)
    a[i+1] -= ((a[i]+a[i+1])-x)
    
  else: continue
    
print(ans)

Measured memory_bytes: 14252
#include <bits/stdc++.h>
using namespace std;
struct Fast {
    Fast() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} fast;

long long mod = 1000000007;

long long div(long long a, long long b, long long c) { return b / c - (a - 1) / c; }

void print_binary(long long a) {
    for (int i = 31; i >= 0; i--) {
        cout << (a >> i & 1);
    }
    cout << endl;
}
long long modpow(long long m, long long n) {
    if (n == 0) return 1;
    if (n % 2 == 0) {
        long long t = modpow(m, n / 2);
        return t * t;
    } else {
        return modpow(m, n - 1) * m;
    }
}
void yes() {
    cout << "Yes" << endl;
    exit(0);
}
void no() {
    cout << "No" << endl;
    exit(0);
}

int main() {
    int r, g, b, n;
    cin >> r >> g >> b >> n;
    int ans = 0;
    for (int i = 0; i <= 3000; i++) {
        for (int j = 0; j <= 3000; j++) {
            if (i * r + j * g <= n) {
                // cout << i << " " << j << endl;
                if ((n - i * r - j * g) % b == 0) {
                    // cout << i << " " << j << n - i * r + j * g << endl;
                    ans++;
                }
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <functional>
#include <map>
#include <queue>
#include <list>
#include <set>
#define FOR(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RFOR(i,a,b) for(int i=(int)b-1;i>=(int)a;--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
using namespace std;
using ll = long long;
const int INF = 1e9 + 1;
ll MOD = 1e9+7;


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

    int N, M;
    cin >> N >> M;
    vector<int> X(M,0);
    vector<int> Xd(M-1,0);
    
    REP(i, M){
        cin >> X[i];
    }
    
    sort(X.begin(), X.end());
    
    REP(i, M-1){
        Xd[i] = X[i+1] - X[i];
    }
    
    sort(Xd.begin(), Xd.end());
    
    ll ans = 0;
    REP(i, M-N){
//        cout << Xd[i] << endl;
        ans += Xd[i];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1024
ref = {"1":".,!? ",
	   "2":"abc",
	   "3":"def",
	   "4":"ghi",
	   "5":"jkl",
	   "6":"mno",
	   "7":"pqrs",
	   "8":"tuv",
	   "9":"wxyz"}
for _ in range(input()):
	inputs = map(str,raw_input().split("0"))
	ans = ""
	for input in inputs:
		if len(input) > 0:
			k = input[0]
			ans += ref[k][(len(input)-1)%len(ref[k])]
	print ans

Measured memory_bytes: 4228
#include<stdio.h>

#define N 8
#define free -1
#define notfree 1
#define FALSE 2
#define TRUE 3

int row[N],col[N],dpos[2*N-1],dneg[2*N-1];
int X[N][N];

void initialize(void);
void printboard(void);
void recursive(int);

int main(){
  int i,j,k,r,c;

  initialize();

  for(i=0;i<N;i++)
    for(j=0;j<N;j++)
      X[i][j] = FALSE;

  scanf("%d",&k);
  for(i=0;i<k;i++){
    scanf("%d %d",&r,&c);
    X[r][c] = TRUE;
  }

  recursive(0);

  return 0;
}

void initialize(){
  int i;

  for(i=0;i<N;i++){
    row[i] = free;
    col[i] = free;
  }

  for(i=0;i<2*N-1;i++){
    dpos[i] = free;
    dneg[i] = free;
  }
}

void printboard(){
  int i,j;

  for(i=0;i<N;i++)
    for(j=0;j<N;j++)
      if(X[i][j] == TRUE){
	if(row[i] != j)return;
      }

  for(i=0;i<N;i++){
    for(j=0;j<N;j++){
      if(row[i] == j)printf("Q");
      else printf(".");
    }
    printf("\n");
  }
}

void recursive(int i){
  int j;

  if(i == N){
    printboard();
    return;
  }

  for(j=0;j<N;j++){
    if(notfree == col[j] || notfree == dpos[i+j] || notfree == dneg[i-j+N-1])continue;
    row[i] =j;
    col[j] = dpos[i+j] = dneg[i-j+N-1] = notfree;
    recursive(i+1);
    row[i] = col[j] = dpos[i+j] = dneg[i-j+N-1] = free;
  }
}

Measured memory_bytes: 572
#include <cstdio>
#include <bitset>
#include <cmath>
#include <complex>

#define EPS 1e-6
using namespace std;

double cross(complex<double> a, complex<double> b)
{
  return a.real() * b.imag() - a.imag() * b.real();
}

double dot(complex<double> a, complex<double> b)
{
  return a.real() * b.real() + a.imag() * b.imag();
}

int main()
{
  complex<double> coor[3];
  int N;
  scanf(" %d ", &N);
  for (int i = 0; i < N; i++) {
    for (int i = 0; i < 3; i++) {
      double x, y;
      scanf(" %lf %lf ", &x, &y);
      coor[i] = complex<double>(x, y);
      //printf("coor[%d](%.3lf, %.3lf)\n", i ,coor[i].real(), coor[i].imag());
    }
    complex<double> h[2], d[2];
    for (int j = 0; j < 2; j++) {
      h[j] = complex<double>((coor[j].real() + coor[j + 1].real()) / 2, (coor[j].imag() + coor[j + 1].imag()) / 2);
      d[j] = complex<double>(coor[j].real() - coor[j + 1].real(), coor[j].imag() - coor[j + 1].imag());
    }
    double D = cross(d[0], d[1]);
    complex<double>o(cross( complex<double>( dot( d[0], h[0] ) , dot( d[1], h[1] ) ), complex<double>( d[0].imag(), d[1].imag() ) ) / D,
					cross( complex<double>( d[0].real(), d[1].real() ), complex<double>( dot( d[0], h[0] ) , dot( d[1], h[1] ) ) ) / D);
    //printf("h1(x, y) = (%.3lf, %.3lf), h2(x, y) = (%.3lf, %.3lf), d1(x, y) = (%.3lf, %.3lf), d2(x, y) = (%.3lf, %.3lf), o(x, y) = ( %.3lf, %.3lf)\n", h[0].real(), h[0].imag(), h[1].real(), h[1].imag(), d[0].real(), d[0].imag(), d[1].real(), d[1].imag(), o.real(), o.imag());
    complex<double> t = o - coor[0];
    double r = abs(t);
    printf("%.3lf %.3lf %.3lf\n", o.real(), o.imag(), r);    
  }
  return 0;
}

Measured memory_bytes: 0
use std::io::{stdin, Read, StdinLock};
use std::str::FromStr;
use std::iter::FromIterator;
use std::cmp::max;

fn main() {
    let cin = stdin();
    let mut scan = Scanner::new(cin.lock());
    let n = scan.read::<usize>();
    let k = scan.read::<i64>();
    let mut a = vec![];
    let mut b = vec![];
    for _ in 0..n {
        a.push(scan.read::<i64>());
        b.push(scan.read::<i64>());
    }
    let mut masks = vec![k];
    for i in 0..31 {
        if (k >> i) & 1 == 1 {
            masks.push((k ^ (1 << i)) | ((1 << i) - 1));
        }
    }
    let mut ret = 0;
    for mask in masks {
        let mut sum = 0;
        for i in 0..n {
            if a[i] & mask == a[i] {
                sum += b[i];
            }
        }
        ret = max(ret, sum);
    }
    println!("{}", ret);
}

// region template
#[allow(dead_code)]
fn iu(i: i64) -> usize { i as usize }

#[allow(dead_code)]
fn ui(i: usize) -> i64 { i as i64 }

#[allow(dead_code, deprecated)]
fn join<T: std::fmt::Display>(slice: &[T], sep: &str) -> String {
    let strings = slice.iter().map(|t| format!("{}", t)).collect::<Vec<_>>();
    strings.connect(sep)
}

#[allow(dead_code)]
fn arr<'a, S, T>(n: usize, mut f: S) -> Vec<T> where S: FnMut(usize) -> T + 'a {
    (0..n).map(|i| f(i)).collect::<Vec<T>>()
}

#[allow(dead_code)]
fn alt<S, T>(v: Vec<S>) -> T where T: FromIterator<S> {
    v.into_iter().collect::<T>()
}

#[allow(dead_code)]
fn dup<S, T>(v: &[S]) -> T where T: FromIterator<S>, S: Clone {
    v.iter().cloned().collect::<T>()
}

struct Scanner<'a> {
    cin: StdinLock<'a>,
}

#[allow(dead_code)]
impl<'a> Scanner<'a> {
    fn new(cin: StdinLock<'a>) -> Scanner<'a> {
        Scanner { cin: cin }
    }

    fn read1<T: FromStr>(&mut self) -> Option<T> {
        let token = self.cin.by_ref().bytes().map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        token.parse::<T>().ok()
    }

    fn read<T: FromStr>(&mut self) -> T {
        self.read1().unwrap()
    }

    fn readn<T: FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read::<T>()).collect()
    }

    fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}
// endregion

Measured memory_bytes: 8444
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt(), rt;

		for (int i = n; i >= 1; i--) {
			rt = (int)Math.sqrt(i);
			if (rt * rt == i) {
				System.out.println(i);
				break;
			}
		}
	}

}

Measured memory_bytes: 23252
#! ruby -Ku

class Fibonatchi
	@@memo = []

	def initialize()
		@@memo[87] = nil
	end

	def fib(n)
		return @@memo[n] if @@memo[n] != nil
		return 2 if n == 0
		return 1 if n == 1
		return @@memo[n] = fib(n-1) + fib(n-2)
	end
end

num = gets.to_i

cls = Fibonatchi.new()
puts cls.fib(num)

Measured memory_bytes: 1788
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <bitset>
#include <numeric>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <cstring>

using namespace std;

#define rep(i,n) for(int i = 0; i<n ; i++)
#define FOR(i,a,n) for(int i=a; i<n; i++)
#define REPSTR(i,s) for(int i=0; (s)[i]; i++)
#define REPITR(i,s) for(auto i=(s)begin(); i!=(s).end();i++)

#define RANGE(a,i,b) ((a)<=(i)&&(i)<=(b))

#define pb push_back
#define mp make_pair

#define ALL(a) (a).begin(), (a).end()

#define EXIST(s,x) ((s).find(x)!=(s).end())

#define SET(a,c) memset(a,c,sizeof(a))
#define CLR(a) memset(a,0,sizeof(a))

#ifdef _DEBUG
#define DEBUG(x) cerr<<#x<<":"<<x<<endl
#else
#define DEBUG(x)
#endif

#define PRINTJOIN(x,n) rep(i,n){if(i)cout<<" ";cout<<x[i];}cout<<endl 

#define INF 1001001001
#define LLINF 1001001001001001001LL

typedef long long ll;
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef stringstream SS;

#define PQ priority_queue

#define FST first
#define SEC second

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

//------------------HEAD---------------------

int main(void) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	ll res = 1;
	rep(i, n) {
		res = (res * (i+1)) %(1000000000+7);
	}
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
// clang-format off
using i64 = int64_t;
using i32 = int32_t;
#define all(x) x.begin(), x.end()
#define int i64
template <class T, typename U> constexpr inline bool exist(const T &s, const U &e) { return s.find(e) != s.end(); }
template <class T> constexpr inline i32 SZ(const T &x) { return x.size(); }
template <class T> constexpr inline bool rmn(T &a, T b) { return a > b ? (a = b, true) : false; }
template <class T> constexpr inline bool rmx(T &a, T b) { return a < b ? (a = b, true) : false; }
const char el = '\n'; const i32 MOD = 1e9 + 7, INF = 0x3f3f3f3f; const i64 INFLL = ((i64)INF << 32) | INF;

#ifdef LOCAL // debugging swiss knife
template <typename Ostream, typename Cont> enable_if_t<is_same<Ostream, ostream>::value, Ostream &> operator<<(Ostream &os, const Cont &v) { os << "{"; for (const auto &x : v) os << x << ", "; return os << "}"; }
template <typename Ostream, typename... Ts> Ostream &operator<<(Ostream &os, const pair<Ts...> &p) { return os << "(" << p.first << ", " << p.second << ")"; }
template <class... Args> void dbg_out(Args... args) { ((std::cerr << "\033[32m" << args << "\033[37m, "), ...); }
#define dbg(...) cerr << "\033[1;31m" << __LINE__ << ": [" << #__VA_ARGS__ << "]\033[37m  = ", dbg_out(__VA_ARGS__), cerr << "\033[0m" << endl;
#else
#define dbg(...) ;
#endif
// clang-format on
////////////////////////////////// TEMPLATE ENDS /////////////////////////////////
vector<vector<i32>> adj;
vector<i32> vis, color;

int32_t main() {
    ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
    cout << fixed << setprecision(13), cerr << fixed << setprecision(3);

    int a, b, c, d;
    cin >> a >> b >> c >> d;
    cout << max({a * c, a * d, b * c, b * d}) << el;

    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define mod 1000000007

//read question carefully!

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t = 1;
    // cin >> t;
    while (t--)
    {
        int n;
        cin >> n;
        string s;
        cin >> s;
        string giv = s;
        sort(s.begin(), s.end());
        int ans = 0;
        //cout << giv << " " << s << "\n";
        for (int i = 0; i < n; ++i)
        {
            if (s[i] == 'R')
            {
                if (s[i] != giv[i])
                    ans++;
            }
        }
        cout << ans << "\n";
    }
}

Measured memory_bytes: 3872
S = gets.chomp.split('')
# s = S.dup

ans = 0
(1 << (S.size - 1)).times do |i|
  op = Array.new(S.size - 1, '')
  (S.size - 1).times do |j|
    if i >> j & 1 == 1
      op[j] = "+"
    end
  end
  s = S.dup
  s.each_with_index do |x, i|
    s[i] += op[i] unless i == s.size - 1
  end
  ans += eval(s.join)
end
puts ans

Measured memory_bytes: 1916
import java.util.Scanner;

public class Main{

     public static void main(String []args){
        Scanner input = new Scanner(System.in);
        String s = input.nextLine();
        if (s.equals("abc") || s.equals("acb") || s.equals("bac") || s.equals("bca") || s.equals("cba") || s.equals("cab")){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
     }
}

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

int main()
{
    string str, comm, sa, sb, sinj;
    cin >> str;

    int n, a, b;
    cin >> n;
    cin.ignore();

    for (int i = 0; i < n; i++)
    {
        getline(cin, comm, ' ');
        if (comm.substr(0, 5) == "print") {
            getline(cin, sa, ' ');
            getline(cin, sb, '\n');
            // cout << "sa = " << sa << " sb = " << sb << endl;
            a = stoi(sa);
            b = stoi(sb);
            // cout << "a = " << a << " b = " << b << endl;
            cout << str.substr(a, b - a + 1) << endl;
        }
        else if (comm.substr(0, 7) == "reverse") {
            getline(cin, sa, ' ');
            getline(cin, sb, '\n');

            a = stoi(sa);
            b = stoi(sb);

            string revstr = str.substr(a, b - a + 1);
            reverse(revstr.begin(), revstr.end());
            str = str.substr(0, a) + revstr + str.substr(b + 1, str.length() - b - 1);

            // cout << str << endl;
        } else {
            getline(cin, sa, ' ');
            getline(cin, sb, ' ');
            getline(cin, sinj, '\n');

            a = stoi(sa);
            b = stoi(sb);

            str = str.substr(0, a) + sinj + str.substr(b + 1, str.length() - b - 1);

            // cout << str << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3180
#include<iostream>

int main() {
    int S, a, b, c, h, m, s, d;
    std::cin >> S;
    a = S / 60;
    s = S % 60;
    h = a / 60;
    m = a % 60;

    std::cout << h << ":" << m << ":" << s << "\n";

}


Measured memory_bytes: 3092
N = int(input())
D = [[int(s) for s in input().split()] for _ in range(N)]

result = 'No'
for d1, d2, d3 in zip(D, D[1:], D[2:]):
    if d1[0] == d1[1] and d2[0] == d2[1] and d3[0] == d3[1]:
        result = 'Yes'

print(result)

Measured memory_bytes: 62324
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ll n,i,j,k,l,a,b,c,d,m,f,p,y;
    string s1,s2;
    vector< pair<ll,ll> >vc;
    map<ll,ll>mp;
    map<pair<ll,ll>,ll >mp1;
    map< pair<ll,ll> ,pair<ll,ll> >mp2;
    map<pair<ll,ll>,ll >::iterator it;

    cin>>n>>m;
    for(i=0;i<m;i++)
    {
        cin>>p>>y;
        vc.push_back({p,y});
        mp1[{y,p}]=1;
    }
    for(it=mp1.begin();it!=mp1.end();it++)
    {
        k=it->first.first;
        l=it->first.second;
        a=mp[l]+1;
        mp[l]++;
        mp2[{l,k}]={l,a};
    }
    for(i=0;i<vc.size();i++)
    {
        k=mp2[{vc[i].first,vc[i].second}].first;
        l=mp2[{vc[i].first,vc[i].second}].second;
        stringstream ss;
        ss<<k;
        ss>>s1;
        stringstream sf;
        sf<<l;
        sf>>s2;
        reverse(s1.begin(),s1.end());
        reverse(s2.begin(),s2.end());
        for(j=s1.size();j<6;j++){s1.push_back('0');}
        for(j=s2.size();j<6;j++){s2.push_back('0');}
        reverse(s1.begin(),s1.end());
        reverse(s2.begin(),s2.end());
        s1+=s2;
        cout<<s1<<endl;
    }
    return 0;
}


Measured memory_bytes: 23408
#include <stdio.h>

int	main(void)
{
  	int	n;
  	int	m;
  	int	a[10001];
  	int	i;
  	int	t;
  
  	scanf("%d %d\n", &n ,&m);
  	t = n;
  	for(i=0; i<m; i++)
    {
      	scanf("%d", &a[i]);
      	t = t - a[i];
    }
  
  	if(t < 0)
    {
      	printf("-1");
    }
  	else
    {
      	printf("%d", t);
    }
  	return (0);
}

Measured memory_bytes: 1772
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

#define ll long long int
#define MOD ((int)(1e9) + 7)

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  cin >> n;
  vector<int> st;
  for(int i=0; i<n; i++) {
    int tp; cin >> tp;
    st.push_back(tp);
  }
  sort(st.begin(), st.end());
  reverse(st.begin(), st.end());
  int b = 0, a = 0;
  for(int i=0; i<n; i++) {
    if(i&1) b+= st[i];
    else a += st[i];
  }
  cout << a - b << '\n';
  return 0;
}


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

using namespace std;

#define all(v)				((v).begin()), ((v).end())
#define allr(v)				((v).rbegin()), ((v).rend())
#define sz(v)				((int)((v).size()))
#define rep(i, v)		for(int i=0;i<sz(v);++i)
#define lp(i, n)		for(int i=0;i<(int)(n);++i)
#define lpi(i, j, n)	for(int i=(j);i<(int)(n);++i)
#define lpd(i, j, n)	for(int i=(j);i>=(int)(n);--i)
#define ll long long
#define pb					push_back
#define fIO ios_base::sync_with_stdio(0);cin.tie(0);

const ll oo = 1e8;
const double pi = 3.1415926535897;


const double EPS = (1e-7);
int dcmp(double x, double y) {	return fabs(x-y) <= EPS ? 0 : x < y ? -1 : 1;	}


typedef vector<int>                vi;
typedef vector<pair<int,int>>      vii;
typedef vector<ll>                 vll;
typedef vector<double>             vd;
typedef vector< vi >               vvi;
typedef vector< vd >               vvd;
typedef vector<string>             vs;
typedef pair<int, int>             pii;

/**
    * PLEASEEE READDD PROBLEEEM CARFULLY ****
    * Always check for OVERFLOW ll vs int
    * Always check for array bounds
    * Check for function return
    * READ OUTPUT SECTION AGAIN!!!
**/

struct edge{
    int from, to, w;

    edge(){}
    edge(int x, int y, int we): from(x), to(y), w(we){}

    bool operator < (const edge &rhs) const{
        return w > rhs.w;
    }

};

int main(){
    fIO

    int a, b, c;
    cin >> a >> b >> c;

    set<int> st = {a, b, c};

    if(sz(st) == 2) cout << "Yes\n";
    else cout << "No\n";

}








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

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

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


void solve(long long A, long long B){
  float l=min(A/0.08,B/0.1);
  float r=max(A/0.08,B/0.1);
  //cout<<l<<" "<<r<<endl;
  ll x=floor(l);
  //cout<<x<<endl;
  while(l-1<=x and x<=r+1){
    if(floor(x*0.08)==A and floor(x*0.1)==B){
      cout<<x<<endl;
      return;
    }
    x++;
  }
  cout<<-1<<endl;
}

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
  int n;
  cin >> n;

  vector<int> v;
  for (int i = 0; i < n; i++)
  {
    int a;
    cin >> a;
    v.push_back(a);
  }

  ll base = 0;
  for (int i = 0; i < n; i++)
  {
    base += v[i] * pow(-1, i);
  }

  cout << base << " ";
  for (int i = 1; i < n; i++)
  {
    base *= -1;
    base += v[i - 1] * 2;

    cout << base << " ";
  }

  cout << "\n";
}

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

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

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

    if(a+b < 2*c){
        cout << a*x + b*y;
    }else{
        long long cc = min(x,y);
        cout << cc * 2 * c + max(x-cc,(long long)0) * min(a,2*c) + max(y-cc,(long long)0) * min(b,2*c);
    }

    return 0;
}

Measured memory_bytes: 256
/*@shutoshsuman99*/
#include<bits/stdc++.h>
using namespace std;
#include<cstdio>
#define pi 3.141592653589
#define pb push_back
#define ld long double
#define rem 1000000007
#define rem1 998244353
#define inf 1e18+1e17
#define F first
#define S second
#define pii pair<long long,long long>
#define p_q priority_queue <ll, vector<ll>, greater<ll> >
#define m_sp multiset <pair <ll,ll> > 
#define el "\n"
#define sp " "
typedef long long ll;
ll Pow(ll x,ll y,ll m) 
{ if (y == 0) return 1; ll p = Pow(x, y/2, m) % m; 
p = (p * p) % m;return (y%2 == 0)? p : (x * p) % m; } 
main()
{ 
	// fast io
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL);ll i; 
	ll n;
	cin>>n;
	vector < pair<string,ll> > v;
	map <ll,ll> m;
	for(i=0;i<n;i++)
	{
		string s;
		ll x;
		cin>>s>>x;
		m[x]=i+1;
		v.push_back(make_pair(s,-x));
	}
	sort(v.begin(),v.end());
	for(i=0;i<n;i++)
	cout<<m[-v[i].second]<<el;
}

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

int N;
const int MAX=101;
unsigned int A[MAX];


void  bubblesort(unsigned int A[]){
	int count=0;
	int k=N;
	while(k>=1){
		int j=N-1;
		while(j>=N-k+1)
		{
			if(A[j]<A[j-1])
			{
				swap(A[j],A[j-1]);
				count++;
			}
			j--;
		}
		k--;
	}
	
	for(int k=0;k<N;k++)
	{
		if(k==0)cout<<A[k];
		else
			cout<<" "<<A[k];
	}
	cout<<endl;
	cout<<count<<endl;
}

int main()
{
	cin>>N;
	for(int i=0;i<N;i++)
		cin>>A[i];
	bubblesort(A);
	return 0;

}

Measured memory_bytes: 3096
import sys
# sys.setrecursionlimit(100000)


def input():
    return sys.stdin.readline().strip()


def input_int():
    return int(input())


def input_int_list():
    return [int(i) for i in input().split()]


def main():
    from collections import Counter
    n = input_int()
    cnts = Counter(input_int_list())
    MOD = 10**9 + 7
    # nが奇数/偶数の場合で分ける
    if n % 2 == 1:
        # 0 が１人つ残りは、2,4,6... が2人ずついるはず
        if cnts[0] != 1:
            print(0)
            return
        for i in range(2, n - 1, 2):
            if cnts[i] != 2:
                print(0)
                return
    else:
        #  1,3,5... が2人ずついるはず
        for i in range(1, n, 2):
            if cnts[i] != 2:
                print(0)
                return
    print(pow(2, n // 2, MOD))
    return


if __name__ == "__main__":
    main()


Measured memory_bytes: 84972