akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define int long long
#define mod (int)(1e9+7)
#define inf (int)(3e18+7)
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(v) v.begin(),v.end()
#define mkp make_pair
#define mkt make_tuple
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define vecunique(vec) sort(vec.begin(), vec.end());decltype(vec)::iterator result = std::unique(vec.begin(), vec.end());vec.erase(result, vec.end())
using namespace std;

bool prime(int x) {
	for (int i = 2; i * i <= x; i++) {
		if (x % i == 0)return false;
	}
	return x > 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % mod;
		}
		x = x * x % mod;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2) % mod;
}
/*--------Library Zone!--------*/


signed main() {
	int n;
	cin >> n;
	vector<P>ans;
	multiset<int>st;
	rep(i, n) {
		int a; cin >> a; st.insert(a);
	}
	while (st.size() > 1) {
		int mi = *st.begin();
		auto it = st.end(); it--;
		int ma = *it;
		st.erase(st.begin()); st.erase(it);
		int memo = ma - mi;
		if (st.empty()) {
			ans.push_back({ ma, mi });
			st.insert(ma - mi);
			break;
		}
		it = st.end(); it--;
		if (memo - *st.begin() > * it + memo) {
			ans.push_back({ ma,mi });
			st.insert(ma - mi);
		}
		else {
			ans.push_back({ mi,ma });
			st.insert(mi - ma);
		}
	}
	cout << *st.begin() << endl;
	for (auto p : ans)cout << p.first << " " << p.second << endl;
}

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

int main() {
  int N;
  long long Sum=0;
  cin >> N;
  vector<int> A(N*3);
  rep(i, N*3) cin >> A.at(i);
  sort(A.begin(), A.end());
  reverse(A.begin(), A.end());
  for(int i=1; i<N*2; i=i+2) Sum+=A.at(i);
  cout << Sum << endl;
}

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

using namespace std;

long long r, D, x2000;
long long curX, prevX;
int main()
{
    while(cin >> r >> D >> x2000)
    {
        prevX = x2000;
        for(int i = 1; i <= 10; i++)
        {
            curX = r * prevX - D;
            cout << curX << endl;
            prevX = curX;
        }
    }

    return 0;
}


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

int adj[8][8];
int N, M;
int answer;

void search(int src, int visited[]) {
    // cout << "search(" << src << ", [";
    // for (int i = 1; i <= N; i++) {
    //     cout << visited[i] << ", ";
    // }
    // cout << "])" << endl;
    int newVisited[9];
    if (accumulate(visited, visited + 9, 0) == N) {
        // cout << "finish!" << endl;
        answer++;
    } else {
        for (int dst = 1; dst <= N; dst++) {
            if (adj[src][dst] && !visited[dst]) {
                memcpy(newVisited, visited, sizeof(int) * 9);
                newVisited[dst] = 1;
                search(dst, newVisited);
            }
        }
    }
}

int main() {
    memset(adj, 0, sizeof(adj));
    answer = 0;
    cin >> N >> M;
    for (int i = 0; i < M; i++) {
        int a, b;
        cin >> a >> b;
        adj[a][b] = 1;
        adj[b][a] = 1;
    }

    int visited[9] = {0, 1, 0, 0, 0, 0, 0, 0, 0};
    search(1, visited);

    cout << answer << endl;
}


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

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = (1<<30) - 1;
const ll LINF = (1LL<<60) - 1;

int main(){
    int a, b;
    cin >> a >> b;
    cout << ((b-1) + (a-2)) / (a-1) << endl;
}

Measured memory_bytes: 3600
#include<iostream>
#include<vector>

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

	int mul1=0;
	int mul2=0;
	int mul4=0;

	for(int i=0; i<n; i++){
		int tmp;
		std::cin>>tmp;

		if(tmp%4==0)
			mul4++;
		else if(tmp%2==0)
			mul2++;
		else
			mul1++;
	}

	if(mul2==0){
		if(mul1 <= mul4+1)
			std::cout<<"Yes"<<std::endl;
		else
			std::cout<<"No"<<std::endl;
	}else{
		if(mul2==1){
			if(mul1 <= mul4 && mul4>0)
				std::cout<<"Yes"<<std::endl;
			else
				std::cout<<"No"<<std::endl;

		}else{
			if(mul1 <= mul4)
				std::cout<<"Yes"<<std::endl;
			else
				std::cout<<"No"<<std::endl;
		}
	}

	return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define fo(i,s,e) for( i=s;i<e;i++)
#define rfo(i,s,e) for(i=s;i>e;i--)
#define LLI long long int
#define LI long int 
const LI MOD=1e9+7;
#define pb push_back
#define pob pop_back()
#define sp " "
#define ff first
#define ss second
//               When something is important enough, you do it even if the odds are not in your favor.
bool ref1[(LI) 1e6+4];
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    // code goes here
    int t=1;//cin>>t;
    while(t--){
      LI n,i;cin>>n;
      LI a[n];
      std::map<LI, LI> m;
      fo(i,0,n) {cin>>a[i];m[a[i]]++;}
      sort(a,a+n);
      LI ans=0;
      fo(i,0,n){
        if(ref1[a[i]]==0){
          if(m[a[i]]==1) ans++;
          LI j=1;
          while(j*a[i]<1e6+4){
            ref1[j*a[i]]=1;
            j++;
          }
        }
      }
      cout<<ans;
    }
    return 0;
}

Measured memory_bytes: 18620
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<algorithm>
#define LL long  long
using namespace std;
int X[100010],Y[100010],n,a[100010];
struct node{
	int x,y,c;
}b[200010];int len=0;
bool cmp1(int a,int b) {return X[a]<X[b];}
bool cmp2(int a,int b) {return Y[a]<Y[b];}
bool cmp(node a,node b) {return a.c<b.c;}
void ins(int x,int y,int c) {b[++len].x=x;b[len].y=y;b[len].c=c;}
int fa[100010];
int findfa(int x) {return fa[x]==x?x:fa[x]=findfa(fa[x]);}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d %d",&X[i],&Y[i]);
	for(int i=1;i<=n;i++) a[i]=i;sort(a+1,a+n+1,cmp1);
	for(int i=2;i<=n;i++) ins(a[i-1],a[i],min(abs(X[a[i]]-X[a[i-1]]),abs(Y[a[i]]-Y[a[i-1]])));
	for(int i=1;i<=n;i++) a[i]=i;sort(a+1,a+n+1,cmp2);
	for(int i=2;i<=n;i++) ins(a[i-1],a[i],min(abs(X[a[i]]-X[a[i-1]]),abs(Y[a[i]]-Y[a[i-1]])));
	sort(b+1,b+len+1,cmp);
	for(int i=1;i<=n;i++) fa[i]=i;
	LL ans=0;
	for(int i=1;i<=len;i++)
	{
		int x=findfa(b[i].x),y=findfa(b[i].y);
		if(x!=y) fa[x]=y,ans+=b[i].c;
	}
	printf("%lld",ans);
}

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

int main() {
    int n;
    cin >> n;
    int ans=-1;
    for(int i=0;i<=n;i++){
        if(int(i*1.08)==n){
            ans=i;
        }
    }
    if(ans!=-1){
        cout << ans << endl;
    }
    else{
        cout << ":(" << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
    int n;
    cin >> n;
    int m1 = 0, m2 = 0, midx = -1;
    bool all = false;
    for (int i = 0; i < n; ++i) {
        int a;
        cin >> a;
        if (a >= m1) {
            midx = i;
            m2 = m1;
            m1 = a;
            all = m1 == m2;
        } else if (a > m2) {
            m2 = a;
        }
    }
    for (int i = 0; i < n; ++i) {
        if (all) {
            cout << m1 << endl;
        } else {
            cout << (i == midx ? m2 : m1) << endl;
        }
    }
}


Measured memory_bytes: 1664
//
//  main.cpp
//  ABC124
//
//  Created by hiroaki on 2019/05/07.
//  Copyright © 2019年 hiroaki. All rights reserved.
//

#include <iostream>
#include <vector>
#include <algorithm>


//pair sort firstに揃う

#define int long long
#define pb(n) push_back(n)
#define Rap(n,i) for(int (i)=0;(i)<(n);(i)++)
#define Pr(n) cout<<n<<endl;
#define F first
#define S second
#define vector2 vector<vector<int> >
#define index(v,x) find((v).begin(), (v).end(), (x))-(v).begin()
#define ctoi(c) (int)(c-'0')
#define incin(n) int (n); cin>>(n);
#define stcin(s) string (s); cin>>(s);
#define all(v) (v).begin() , (v).end()

using namespace std;

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

    incin(n);
    incin(k);
    stcin(s);
    s[k-1]=(char)(s[k-1]+32);
    Pr(s);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    long long int x, n3, n5, n15;
    cin>>x;
    n3 = x/3;
    n5 = x/5;
    n15 = x/15;
    long long int sum = (x*x + x)/2 - 3*(n3*(n3+1))/2 - 5*(n5*(n5 + 1))/2 + 15*(n15*(n15 + 1))/2;
    cout<<sum;
    return 0;
}

Measured memory_bytes: 3624
#include <stdio.h>
#include <math.h>
int main()
{
    int n,i,cnt=1,z;
    scanf("%d",&n);
    int t[n+1],x[n+1],y[n+1];
    t[0]=0;x[0]=0;y[0]=0;
    for(i=1;i<n+1;i++)
        scanf("%d%d%d",&t[i],&x[i],&y[i]);
    for(i=1;i<n+1;i++)
    {
        z=abs(x[i]-x[i-1])+abs(y[i]-y[i-1]);
        if(z>(t[i]-t[i-1]))
        {
            cnt=0;break;
        }
        else
        {
            if((t[i]-t[i-1])>z)
            {
                if((z%2!=(t[i]-t[i-1])%2))
                {
                    cnt=0;break;
                }
            }
        }
    }
    if(cnt)
        printf("Yes\n");
    else
        printf("No\n");
    return 0;
}


Measured memory_bytes: 1280
#include<bits/stdc++.h>
#define ll long long int
#define st string
#define con continue
#define br break
#define rt return 0
#define fr first
#define sec second
using namespace std;
int main(){
//ll tc; cin>>tc; while(tc--){
ll n,m,mn=INT_MAX,i,x,j,a=0,t,k,b=-1,mx=-1,cnt=0,c=0; 
 st s,str; char strn;
cin>>n; //a=n; n-=1; 
ll ara[n+1],bra[n+1],taj[n+1];
memset(ara,0,sizeof(ara));
//for(i=1;i<=n;i++) cin>>ara[i]; 
  for(i=1;i<=9;i++)
   {  
     for(j=1;j<=9;j++)
      {
        if(i*j==n)
           {
            cout<<"Yes";
               rt;
             }
        }
      
      
   }      
  
        
     cout<<"No"<<endl;
    
 
    rt;
}

Measured memory_bytes: 3632
#include<iostream>
#include<queue>
#include<algorithm>
#include<vector>

using namespace std;

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

vector<vector<ll>> work(100000 + 1);

int main() {
	int N, M;
	cin >> N >> M;
	for (int i = 0; i < N; i++) {
		int a; ll b;
		cin >> a >> b;
		work[a].push_back(b);
	}
	ll ans = 0;
	priority_queue<ll> pq;
	for (int day = 1; day <= M; day++) {
		for (int i = 0; i < work[day].size(); i++)pq.push(work[day][i]);
		if (pq.size()) {
			ans += pq.top(); 
			pq.pop();
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 5632
n, x, m = list(map(int, input().split()))
a = [x]
start = -1
end = -1
check = [0]*m
path = -1
loop = 0

for i in range(1, n):
    ans = (a[i-1]**2) % m
    p = check[ans]
    if p != 0:
        if start == -1:
            start = i
            path = ans
        if p == 1:
            end = i
    if p >= 3:
        break
    check[ans] += 1
    a.append(ans)


if start == -1 or end == -1:
    print(sum(a))
else:
    lenght = end-start+1
    loop, mod = divmod(n-start, lenght)
    ans = sum(a[:start])+sum(a[start:end+1])*loop + sum(a[start:start+mod])
    print(ans)

Measured memory_bytes: 16024
#include<bits/stdc++.h>
using namespace std;
int main()
{
  string s;
  cin>>s;
  for(int i=0;i<s.length();i++)
  {
   if(s[i]=='1')s[i]='9';
    else if(s[i]=='9')
      s[i]='1';
  }
  cout<<s;
 return 0; 
}

Measured memory_bytes: 256
#include <stdio.h>

int N, M;
int A[1024];

int main(void) {
	int i;
	int answer = 0;
	int current = 0;
	if (scanf("%d%d", &N, &M) != 2) return 1;
	for (i = 0; i < N; i++) {
		if (scanf("%d", &A[i]) != 1) return 1;
	}
	for (;;) {
		int min = 0, max = 0;
		for (i = 0; i < M; i++) {
			if (i == 0) min = max = A[current];
			else {
				if (A[current] < min) min = A[current];
				if (A[current] > max) max = A[current];
			}
			current = (current + 1) % N;
		}
		answer += max - min;
		if (current == 0) break;
	}
	printf("%d\n", answer);
	return 0;
}



Measured memory_bytes: 2112
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>

//#include<bits/stdc++.h>

// #include "beginner_138/beginner_138.h"
// Still dunno how to put linker 

using namespace std; 

void b_ques(){
    int n,d;
    cin >> n >> d;

    int max = 2*d + 1; // max number of trees one inspector can check
    int ans;
    if(n%max!=0){
        ans = n / max +1;
    }
    else ans = n / max;

    cout << ans;
}

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

    b_ques();
    
    return 0;
}

Measured memory_bytes: 256
A = int(input())
B = int(input())
C = int(input())
X = int(input())
ans = 0
for i in range(X//500+1):
    #500円玉が足りなければ終了
    if A<i:
        break
    #500円玉をi枚使った残りの金額(X%(500*i)円)を、100円玉と50円玉に割り振る
    for j in range((X-500*i)//100+1):
        if B<j:
            break
        if C>=(X-(500*i)-(100*j))//50:
            ans+=1
print(ans)

Measured memory_bytes: 3064
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder
{
    public class Prog
    {
        public static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            new Prog().Solve(new ConsoleInput(Console.In, ' '));
            Console.Out.Flush();
        }

        public void Solve(ConsoleInput cin)
        {
            var n = cin.ReadInt;
            var w = cin.ReadIntArray(n);

            var ans = Int32.MaxValue;

            for (int i = 0; i < n; i++)
            {
                var g1 = 0;
                var g2 = 0;
                for (int j = 0; j < w.Length; j++)
                {
                    if (i >= j)
                    {
                        g1 += w[j];
                    }
                    else
                    {
                        g2 += w[j];
                    }
                }
                ans = Math.Min(ans, Math.Abs(g1 - g2));
            }

            Console.WriteLine(ans);
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
        public void ReadIntArrays(long N, out int[] A, out int[] B) { A = new int[N]; B = new int[N]; for (long i = 0; i < N; ++i) { A[i] = ReadInt; B[i] = ReadInt; } }
    }
}


Measured memory_bytes: 11220
#include <iostream>
using namespace std;
int main() {
    int n;
    cin >> n;
    int num[n];
    for (int i=0; i<n; i++) {
        cin >> num[i];
    }
    for (int j = n-1; j>=0; j--) {
        if (j != n-1) {
            cout << " ";
        }
        cout << num[j];
    }
    cout << endl;
}



Measured memory_bytes: 3080
#!/usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
bisect_left = bisect.bisect_left
bisect_right = bisect.bisect_right
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#A
def A():
    a, b = LI()
    if a + b >= 10:
        print("error")
    else:
        print(a + b)
    return

#B
def B():
    s = S()
    if len(s) == len(set(s)):
        print("yes")
    else:
        print("no")
    return

#C
def C():
    n = II()
    m = inf
    ans = 0
    for _ in range(n):
        s = II()
        ans += s
        if s % 10:
            m = min(m, s)
    if ans % 10:
        print(ans)
    else:
        if m != inf:
            print(ans - m)
        else:
            print(0)
    return

# D
# 解説AC
# 解を2分探索で求める
# T回のときB*T以上の体力を持つ者に対しては(h-(B*T))/A-Bで最低必要な回数
# が求められることに気づけない
def D():
    def f(t):
        lh = list(map(lambda x: max(0, (x - b * t - 1) // (a - b) + 1), h))
        if sum(lh) <= t:
            return True
        return False
    n, a, b = LI()
    h = IR(n)
    maxh = max(h)
    ok = (maxh - 1) // b + 1
    ng = 0
    while abs(ok - ng) > 1:
        mid = (ok + ng) // 2
        if f(mid):
            ok = mid
        else:
            ng = mid
    print(ok)
    return


#Solve
if __name__ == '__main__':
    D()


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

namespace AtCoder {
    class Program {
        static void Main(string[] args) {

            var n = int.Parse(Console.ReadLine());

            var list = new List<string>();
            list.Add(Console.ReadLine());

            var isFalse = false;

            for (int i = 0; i < n - 1; i++) {
                var word = Console.ReadLine();
                if (list.Any(w => w == word) || list.Last().Last() != word.First()) {
                    isFalse = true;
                }
                list.Add(word);
            }

            Console.WriteLine(isFalse ? "No" : "Yes");

        }
    }
}

Measured memory_bytes: 13268
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#define FOR(i,n,a) for(int i = a;i<n;i++)
#define rep(i,n) FOR(i,n,0)
#define UNFOR(i,n,a) for(int i = a;i>n;i--)
#define unrep(i,n) UNFOR(i,0.n)
typedef long long ll;
using namespace std;
string s;
int N,M,H,W;

int main() {
	int a, b, c,d;
	cin >> a >> b >> c>>d;
	if (abs(a - c) <= d) {
		cout << "Yes" << endl;
		return 0;
	}
	if (abs(a - b) <= d && abs(b - c) <= d) {
		cout << "Yes" << endl;
		return 0;
	}
	cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
/// TONI BO$$ was here
/// #MLC

using namespace std;
int v[200];
vector <int> vect;
char s[5];
int verif(int n,int i)
{
    int j;
    printf("? ");
    for(j=i-n+1; j<=i; j++)
        printf("%d ",j);
    printf("\n");
    fflush(stdout);
    scanf("%s",s);
    if(s[0]=='R')
        return 0;
    return 1;
}
int main()
{
    int n,i,j,k,rez,rez_prev,var,vari,pas;
    //freopen(".in","r",stdin);
    //freopen(".out","w",stdout);
    scanf("%d",&n);
    for(i=1; i<=2*n; i++)
        v[i]=-1;
    rez=verif(n,n);
    pas=1<<7;
    i=n;
    while(pas)
    {
        if(i+pas<=2*n && verif(n,i+pas)==rez)
            i+=pas;
        pas/=2;
    }
    i++;
    v[i]=1-rez;
    v[i-n]=rez;
    for(j=i+1; j<=2*n; j++)
    {
        printf("? ");
        for(k=i-n+1; k<i; k++)
            printf("%d ",k);
        printf("%d ",j);
        printf("\n");
        fflush(stdout);
        scanf("%s",s);
        if(s[0]=='R') v[j]=0;
        else v[j]=1;
    }
    for(j=1; j<i-n; j++)
    {
        printf("? ");
        printf("%d ",j);
        for(k=i-n+1; k<i; k++)
            printf("%d ",k);
        printf("\n");
        fflush(stdout);
        scanf("%s",s);
        if(s[0]=='R') v[j]=0;
        else v[j]=1;
    }
    int nrr=n/2,nrb=n/2;
    for(j=1; j<=2*n; j++)
    {
        if(v[j]==0 && nrr)
        {
            vect.push_back(j);
            nrr--;
        }
        if(v[j]==1 && nrb)
        {
            vect.push_back(j);
            nrb--;
        }
    }
    for(j=i-n+1; j<i; j++)
    {
        printf("? ");
        printf("%d ",j);
        for(auto it : vect)
            printf("%d ",it);
        printf("\n");
        fflush(stdout);
        scanf("%s",s);
        if(s[0]=='R') v[j]=0;
        else v[j]=1;
    }
    printf("! ");
    for(i=1; i<=2*n; i++)
        if(v[i]==0) printf("R");
        else printf("B");
    fflush(stdout);

    return 0;
}


Measured memory_bytes: 724
#include <bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(){
	int n,m;
	cin>>n>>m;
	int a[n]={0},b[m];
	r(i,m){cin>>b[i];}
	for(int i=m-1;i>=0;i--){
		if(!a[b[i]-1])cout<<b[i]<<endl;
		a[b[i]-1]++;
	}
	r(i,n)if(!a[i])cout<<i+1<<endl;
}

Measured memory_bytes: 4252
// https://atcoder.jp/contests/

#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#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) = (n); (i) >= (m); i--)
#define rep(...) _overload3(__VA_ARGS__, FOR, REP, )(__VA_ARGS__)
#define repr(...) _overload3(__VA_ARGS__, FORR, REPR, )(__VA_ARGS__)
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
#define INF 1e9
#define ALL(v) (v).begin(), (v).end()
#define pb push_back
#define mp make_pair
#define F first
#define S second
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;

auto c = [](pll l, pll r) { return l.second == r.second ? l.first < r.first : l.second < r.second; };
priority_queue<pll, vector<pll>, decltype(c)> tasks(c);
ll last;

bool work(pll task)
{
  last = min(last, task.second) - task.first;
  return 0 <= last;
}

int main()
{
  bool result = true;
  ll N, a, b;
  cin >> N;
  rep(i, N)
  {
    cin >> a >> b;
    tasks.push(mp(a, b));
  }
  last = tasks.top().second;

  while (result && !tasks.empty())
  {
    pll task = tasks.top();
    tasks.pop();
    result = work(task);
  }

  cout << (result ? "Yes" : "No") << '\n';

  return 0;
}


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

using namespace std;

#define ll long long
#define f first
#define s second
#define vi vector<int>
#define vll vector<ll>
#define pii pair<int,int>
#define vpii vector<pair<int,int>> 
#define pb push_back

void solve() {
	int x;
	cin>>x;
	if(x>=400&&x<=599) {
		cout<<8<<"\n";
	}
	else if(x>=600&&x<=799) {
		cout<<7<<"\n";
	}
	else if(x>=800&&x<=999) {
		cout<<6<<"\n";
	}
	else if(x>=1000&&x<=1199) {
		cout<<5<<"\n";
	}
	else if(x>=1200&&x<=1399) {
		cout<<4<<"\n";
	}
	else if(x>=1400&&x<=1599) {
		cout<<3<<"\n";
	}
	else if(x>=1600&&x<=1799) {
		cout<<2<<"\n";
	}
	else if(x>=1800&&x<=1999) {
		cout<<1<<"\n";
	}
}

int main() {
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	//freopen("ou.txt","w",stdout);
	#endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t=1;
    //cin>>t;
    while(t--) {
    	solve();
    }
    return 0;
}

Measured memory_bytes: 3648
/******************************************
* AUTHOR : RAJAGOPALAN *
* NICK : ARNO *
* INSTITUTION : VIT *
******************************************/
#include <bits/stdc++.h>
#include <ext/pb_ds/detail/standard_policies.hpp>
#define ll long long
#define ull unsigned long long
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define alli(a, n, k) (a+k),(a+n+k)
#define FP(i, a, b, k) for(__typeof(a) i = a;i < b;i += k)
#define FS(i, a, b, k) for(__typeof(a) i = a;i > b;i -= k)
#define IT(it, a) for(__typeof(a.begin()) it = a.begin();it != a.end(); ++it)
#define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
#define eps 1e-6
#define pi 3.141592653589793
using namespace std;
using namespace __gnu_pbds;

template<class T> inline T gcd(T x, T y) { if (!y) return x; return gcd(y, x%y);}
typedef vector<int> VII;
typedef vector<ll> VLL;
typedef pair<int, int> PII;
typedef vector< pair<int, int> > VPII;
typedef vector< pair<int, PII > > VPPI;
const int MOD = 1e9 + 7;
const int INF = 1e9;

inline ll modulo(ll a, ll m)
{
    return (a % m + m) % m;
}

inline ll modInverse(ll a, ll m)
{
    assert(__gcd(a, m) == 1);
    ll m0 = m;
    ll y = 0, x = 1;

    if (m == 1)
        return 0;

    while (a > 1)
    {
        ll q = a / m;
        ll t = m;

        m = a % m, a = t;
        t = y;

        y = x - q * y;
        x = t;
    }

    if (x < 0)
        x += m0;

    return x;
}

inline ll modPow(ll x, ll y, ll m)
{ //x^y % m
    if (y == 0)
        return 1LL;
    else if (y == 1)
        return x;
    else
    {
        ll ans = modPow(x, y / 2, m) % m;
        if (y & 1)
        {
            return (((ans * ans) % m) * x) % m;
        }
        else
        {
            return (ans * ans) % m;
        }
    }
}

int main(int argc, char* argv[])
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin>>n;
    map<string,bool> ch;
    string p="",c;
    cin>>c;
    n--;
    ch[c]=true;
    bool wn=true;
    while(n--)
    {
        p=c;
        cin>>c;
        if(ch[c])wn=false;
        if(p[p.size()-1]!=c[0])wn=false;
        ch[c]=true;
    }
    if(wn)cout<<"Yes";
    else cout<<"No";
    return 0;
}

Measured memory_bytes: 256
import math
import string
import collections
from collections import Counter


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


def nCr(n, r):
    return math.factorial(n)//(math.factorial(n-r)*math.factorial(r))


def has_duplicates2(seq):
    seen = []
    for item in seq:
        if not(item in seen):
            seen.append(item)
    return len(seq) != len(seen)


def divisor(n):
    divisor = []
    for i in range(1, n+1):
        if n % i == 0:
            divisor.append(i)
    return divisor


# coordinates
dx = [-1, -1, -1, 0, 0, 1, 1, 1]
dy = [-1, 0, 1, -1, 1, -1, 0, 1]
a, b, c, d = map(int, input())
#print(a, b, c, d)
if a+b+c+d == 7:
    print(str(a)+'+'+str(b)+'+'+str(c)+'+'+str(d)+'=7')
    exit()
if a+b-c+d == 7:
    print(str(a)+'+'+str(b)+'-'+str(c)+'+'+str(d)+'=7')
    exit()
if a+b+c-d == 7:
    print(str(a)+'+'+str(b)+'+'+str(c)+'-'+str(d)+'=7')
    exit()
if a+b-c-d == 7:
    print(str(a)+'+'+str(b)+'-'+str(c)+'-'+str(d)+'=7')
    exit()
if a-b+c+d == 7:
    print(str(a)+'-'+str(b)+'+'+str(c)+'+'+str(d)+'=7')
    exit()
if a-b-c+d == 7:
    print(str(a)+'-'+str(b)+'-'+str(c)+'+'+str(d)+'=7')
    exit()
if a-b+c-d == 7:
    print(str(a)+'-'+str(b)+'+'+str(c)+'-'+str(d)+'=7')
    exit()
if a-b-c-d == 7:
    print(str(a)+'-'+str(b)+'-'+str(c)+'-'+str(d)+'=7')
    exit()


Measured memory_bytes: 38512
object Main extends App {
  val input1 = readLine
  val input2 = readLine
  
  val K = input1.split(" ")(0).toInt
  val N = input1.split(" ")(1).toInt
    
  val arr1 = (input2.split(" "))
  val arr2 = arr1.map(x => x.toInt)
  
  var answer = arr2(0) + K-arr2(N-1)
  
  for(i <- 1 to N-1){
    if(arr2(i) - arr2(i-1) > answer){
      answer = arr2(i) - arr2(i-1)
    }
  }
  
  println(K-answer)
  
}

Measured memory_bytes: 50296
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Scanner;

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

		final int N = sc.nextInt();
		final int Q = sc.nextInt();
		
		int[] array = new int[N];
		for(int i = 0; i < N; i++){
			array[i] = sc.nextInt();
		}
		Arrays.sort(array);
		
		for(int i = 0; i < Q; i++){
			final int mod = sc.nextInt();
			
			int max = 0;
			for(int d = mod - 1; d <= 300000; d += mod){
				int pos = Arrays.binarySearch(array, d);
				
				if(pos < 0){
					pos = - (pos + 2);
					
					if(pos != -1){
						max = Math.max(max, array[pos] % mod);
					}else{
						continue;
					}
					
				}else{
					max = mod - 1;
					break;
				}
			}
			
			System.out.println(max);			
		}
		
		sc.close();
	}
}

Measured memory_bytes: 143928
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <queue>
#include <cmath>
using namespace std;

int main() {  
    int n, k, x, y;
    cin >> n >> k >> x >> y;
    cout << x * min(n, k) + y * max(0, n - k) << endl;
}




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

const int64_t MOD = 1000000007;
typedef int64_t ll;
typedef uint64_t ull;

#define FOR(i, start, end) for(uint64_t i=start; i<end; i++)
#define REP(i, n) FOR(i, 0, n)

// 最大公約数gcd
// 最小公倍数lcm=m*n/gcd
uint64_t gcd(uint64_t m, uint64_t n) {
  uint64_t temp;
  while (m % n != 0){
    temp = n;
    n = m % n;
    m = temp;
  }
  return n;
}

uint64_t lcm(uint64_t m, uint64_t n) {
  return (m*n)/gcd(m,n);
}

// vector<vector<uint64_t> > v(n+1, vector<uint64_t>(n+1, 0))
// v[n][k]に組み合わせ数が入る。
void comb(vector<vector <uint64_t> > &v){
  for(uint64_t i = 0;i <v.size(); i++){
    v[i][0]=1;
    v[i][i]=1;
  }
  for(uint64_t k = 1;k <v.size();k++){
    for(uint64_t j = 1;j<k;j++){
      v[k][j]=(v[k-1][j-1]+v[k-1][j]);
    }
  }
}

// 掛け算オーバーフロー判定
bool is_product_overflow(uint64_t a, uint64_t b) {

	uint64_t prod = a * b;
	
	return (prod / b != a);
}

//素因数分解
void primeFactorization(uint64_t a, list<uint64_t> &factors){ //素因数分解を出力するプログラム
  long i,sq;
  if(a%2==0){ //偶数の場合
    factors.push_back(2);
    primeFactorization(a/2,factors); //2で割った値で再帰
    return;
  }
  sq = sqrt(a);
  for(i=3;i<=sq;i+=2){ //3以上√a以下の奇数の場合
	if(a%i==0){
	  factors.push_back(i);
      primeFactorization(a/i,factors); //割れた値で再帰
      return;
	}
  }
  //偶数でも3以上√a以下の奇数の場合でも割り切れない場合
  if(a!=1){ //aが1でないなら、a自身は素数
    factors.push_back(a);
  }
}

// フェルマーの小定理
// mod. m での a の逆元 a^{-1} を計算する
// (a/b)%m = a*movinv(b,m)%m  
int64_t modinv(int64_t a, int64_t m) {
    int64_t b = m, u = 1, v = 0;
    while (b) {
        int64_t t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

/* 
  //エラトステネスのふるい
  int maxNum = 100000;
  char isNotPrime[maxNum+1] = {};
  isNotPrime[0]=isNotPrime[1]=1;
  for(int i=2;i<maxNum;i++){
    if(isNotPrime[i]==1) continue;
    int num = i+i;
    while(num<=maxNum){
      isNotPrime[num]=1;
      num += i;
    }
  }
*/
// 円周率
// M_PI

// #include <iomanip> // setprecisionを使用するのに必要
// cout << std::fixed << std::setprecision(15) << y << endl;

// 昇順
// priority_queue<int, vector<int>, greater<int> > queue;

// 降順ソート vector<int> v;
// sort(v.begin(),v.end(),greater<int>());

signed main() {
  int n;
  cin >> n;
  
  vector<int> a(n,0),b(n,0),c(n,0);
  
  for(int i=0;i<n;i++){
    cin >> a[i];
  }
  for(int i=0;i<n;i++){
    cin >> b[i];
  }
  for(int i=0;i<n;i++){
    cin >> c[i];
  }
  
  sort(a.begin(), a.end());
  sort(b.begin(), b.end());
  sort(c.begin(), c.end());

  int aB[n] = {};
  int bC[n] = {};
  for(int i=0;i<n;i++){
    aB[i] = distance(b.begin(),upper_bound(b.begin(),b.end(),a[i]));
    bC[i] = distance(c.begin(),upper_bound(c.begin(),c.end(),b[i]));
    //cout << aB[i] << ":" << bC[i] <<endl;
  }
  
  ll count = 0;
  ll currentCount = 0;
  for(int i=aB[n-1];i<n;i++){ // いちばん大きいのを先に
    currentCount += n-bC[i];
  }
  count += currentCount;
  for(int i=n-2;i>=0;i--){
    for(int j=aB[i];j<aB[i+1];j++){
      currentCount += n-bC[j];
    }
    count += currentCount;
  }
  cout << count << endl;
  
  //  1 2 3
  //  3 4 5
  //  4 5 6 
  
  return 0;
}



Measured memory_bytes: 5148
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,a,n) for(int i=(a); i<(n); i++)
#define all(v) v.begin(), v.end()
#define fi first
#define se second
#define sz(x) int(x.size())
using namespace std;
using ll = long long;
using P = pair<int ,int>;
const int INF = 1001001001;
const int MOD = 1000000007;
template<class T> inline bool chmax(T &a, T b) { if (a<b) {a=b; return 1;} return 0;}
template<class T> inline bool chmin(T &a, T b) { if (b<a) {a=b; return 1;} return 0;}

#ifdef _DEBUG
#include "debug.h"
#else
#define debug(...)
#define print(...)
#endif

int main() {
    int n, q; string s;
    cin >> n >> s >> q;
    vector<set<int>> a(26);
    rep(i, n) {
        char c = s[i];
        int num = c-'0'-49;
        a[num].insert(i);
    }
    rep(i, q) {
        int x; cin >> x;
        if (x==1) {
            int y; char z;
            cin >> y >> z; y--;
            char c = s[y];
            int num = c-'0'-49;
            int newnum = z-'0'-49;
            a[num].erase(y);
            a[newnum].insert(y);
            s[y] = z;
        } else {
            int cnt = 0;
            int l, r; cin >> l >> r;
            l--; r--;
            rep(j, 26) {
                auto itl = a[j].lower_bound(l); //l以上の最初の数字
                if (itl!=a[j].end() && *itl<=r) cnt++;
            }
            cout << cnt << endl;
        }
        debug(s);
    }
}

Measured memory_bytes: 24196
#include <iostream> 
#include <string> 
#include <vector> 
#include <cmath> 
#include <algorithm> 
#include <cstdlib> 
#include <ctime> 
#include <cstdio> 
#include <functional> 
#include <set> 
#include <sstream> 
#include <cctype>
#include <stack>
#include <queue>
#include <cstring>
#include <map>
 
using namespace std;

int main(){

	int h,w,n;
	cin>>h>>w>>n;

	vector<int> a(n);
	for(int i=0;i<n;i++) cin>>a[i];

	vector<vector<int> > res(h,vector<int>(w));
	int c=0;
	for(int i=0;i<h*w;i++){
		res[i/w][i%w]=c+1;
		a[c]--;
		if(a[c]==0) c++;
	}

	for(int i=1;i<h;i+=2){
		reverse(res[i].begin(),res[i].end());
	}

	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++) cout<<res[i][j]<<" ";
		cout<<endl;
	}

	return 0;
}


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

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;

#define INF (1LL << 60)
#define MOD 1000000007
#define PI 3.14159265358979323846

#define REP(i,m,n) for(ll (i)=(m),(i_len)=(n);(i)<(i_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define PR(x) cout << (x) << endl
#define PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define ASC(x) sort(ALL((x)))
#define DESC(x) sort(ALL((x)),greater<ll>())
#define pb push_back


vec fac(210000), finv(210000), inv(210000);

ll modpow(ll a, ll n, ll m)
{
    if(n == 0) return 1;
    ll t = modpow(a, n >> 1, m);
    t = t * t % m;
    if(n & 1) t = t * a % m;
    return t; 
}

void combinit()
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    REP(i,2,210000) {
        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 combmod(ll n, ll r)
{
    if (n < r) return 0;
    if (n < 0 || r < 0) return 0;
    ll c = 1;
    REP(i,0,r) c = c * (n-i) % MOD;
    c = c * finv[r] % MOD;
    return c;
}

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

//    vec inv(200010, 0);
//    inv[1] = 1;
//    REP(i,2,200010) inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;

    combinit();

    ll nCa = 1, nCb = 1, c, f = 1;
    REP(i,1,a+1) nCa = (nCa * (n-i+1) % MOD);
    REP(i,2,a+1) f = f * inv[i] % MOD; nCa = nCa * f % MOD;
    REP(i,1,b+1) nCb = (nCb * (n-i+1) % MOD);
    f = 1;
    REP(i,2,b+1) f = f * inv[i] % MOD; nCb = nCb * f % MOD;
    c = (modpow(2, n, MOD) - 1- nCa - nCb) % MOD;
    c = (c < 0) ? c + MOD : c;
    PR(c); 

    return 0;
}

/*

nC1 + ... + nCn - nCa - nCb
= 2^n - 1 - nCa - nCb

*/

Measured memory_bytes: 5120
from collections import deque

N,M,K = map(int,input().split())
friend = [list(map(int,input().split())) for _ in range(M)]
block = [list(map(int,input().split())) for _ in range(K)]

f = [set() for _ in range(N+1)]
b = [set() for _ in range(N+1)]

for i,j in friend:
    f[i].add(j)
    f[j].add(i)
for i,j in block:
    b[i].add(j)
    b[j].add(i)

stack=deque()
linkList = []
ans = [0] *(N+1)
visited = [0] * (N+1)

for i in range(1,N+1):
    if visited[i]:
        continue
    link = {i}
    visited[i] = 1 
    stack.append(i)
    while stack:
        n = stack.pop()
        for j in f[n]:
            if j in f[n] and visited[j]==0:
                stack.append(j)
                visited[j] = 1
                link.add(j)
    linkList.append(link)
    for i in link:
        ans[i] = len(link) - len(link & f[i]) - len(link & b[i]) - 1
print(*ans[1:])


Measured memory_bytes: 137984
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
class U {
	private:
		vi p,rk;
		int n,nc;
	public:
		U(int _n) {
			n = _n;
			nc = n;
			rk.assign(n,0);
			for(int i=0;i<n;i++) {
				p.push_back(i);
			}
		}
		int find(int a) {
			if(a == p[a]) return a;
			return p[a] = find(p[a]);
		}
		bool same(int a, int b) {
			return find(a) == find(b);
		}
		bool un(int a, int b) {
			if(same(a,b)) return false;
			nc--;
			int x = find(a),y = find(b);
			if(rk[x] > rk[y]) {
				p[y] = x;
				return true;
			}
			if(rk[x] == rk[y]) {rk[y]++;}
			p[x] = y;
			return true;
		}
		int con() {
			return nc;
		}
};
int main() {
	ios::sync_with_stdio(0);
	bool rec = false;
	ll n,m,q;
	cin >> n >> m >> q;
	U br(n);
	vii bs;
	for(int i=0;i<q;i++) {
		int a,b,c;
		cin >> a >> b >> c;
		if(c) {
			rec = true;
			bs.push_back({a,b});
		} else {
			br.un(a,b);
		}
	}
	bool po = true;
	for(int i=0;i<bs.size();i++) {
		int a = bs[i].first,b = bs[i].second;
		if(br.same(a,b)) {po = false;break;}
	}
	if(m == n-1) {
		cout << (rec?"No":"Yes") << '\n';
		return 0;
	}
	ll sz = br.con();
	//cout << sz << '\n';
	ll ma,mb;
	mb = n;
	ma = n-sz+(sz*(sz-1)/2);
	//cout << ma << " " << mb << '\n';
	if(!(m <= ma && m >= mb)) {
		po = false;
	}
	cout << (po?"Yes":"No") << '\n';
}

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

namespace ABC089A
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());

            int ans = N / 3;

            Console.WriteLine(ans);
            Console.ReadKey();

        }
    }
}


Measured memory_bytes: 11220
#include<bits/stdc++.h>
#define sz(x) ((int)(x).size())
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
using namespace std;
 
typedef long long lld;
typedef vector<lld> vlld;
typedef pair<lld,lld> pi;
typedef tuple<lld,lld,lld> tup;
const lld mod=(lld)1e9+7;
 
lld solve(lld n,lld a[][3])
{
     for(lld i=1;i<n;i++)
     {
        a[i][0]+=max(a[i-1][1],a[i-1][2]);
        a[i][1]+=max(a[i-1][0],a[i-1][2]);
        a[i][2]+=max(a[i-1][1],a[i-1][0]);
     }

   return max(a[n-1][0],max(a[n-1][1],a[n-1][2]));

}	
 

int main() {

	lld n;
	cin>>n;
	lld a[n][3];
	forn(i,n)
	cin>>a[i][0]>>a[i][1]>>a[i][2];
	cout<<solve(n,a);
  
  return 0;
}

Measured memory_bytes: 5928
#include <iostream>
#include <string.h>
#include <stdlib.h>

using namespace std;

int main(void)
{
	char s[5];
	int a[5];
	int min = 255;
	int minnum;
	int minidx=0;
	int sum = 0;
	for (int i = 0; i < 5; i++)
	{
		cin >> a[i];
		sprintf(s, "%d", a[i]);
		if (a[i] % 10 != 0)
		{
			if (atoi(&s[strlen(s) - 1]) < min)
			{
				min = atoi(&s[strlen(s) - 1]);
				minnum = a[i];
				minidx = i;
			}
		}
		else
		{
			if (a[i] < minnum)
			{
				minnum = a[i];
				minidx = i;
			}

		}
		if(a[i]%10 != 0)a[i] += 10 - atoi(&s[strlen(s) - 1]);
		sum += a[i];
	}

	sum -= a[minidx];
	sum += minnum;

	cout << sum << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <string> 
#include <cmath>  
#include <cstdlib>
#include <ctime>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <bitset>
#include <functional>

using namespace std;
using ll = long long;
using ull = unsigned long long;

#define FOR(i, m, n) for(int i = (m);i < (n);i++)
#define REP(i,n) for(int i = 0; i < int(n); i++)
#define VI vector<int>
#define VVI vector<vector<int>>
#define VVVI vector<vector<vector<int>>>
#define VL vector<ll>
#define VVL vector<vector<ll>>
#define VB vector<bool>
#define VVB vector<vector<bool>>
#define PAIR pair<int,int>
#define MP make_pair
#define VP vector<pair<int,int>>
#define VS vector<string>
#define QUE queue<int>
#define DEQ deque<int>
#define PQUE priority_queue<int> //5,5,4,3,3,2,...
#define REPQUE priority_queue<int, vector<int>, greater<int>> //1,1,2,3,4,4,5,...
#define SUM(obj) accumulate((obj).begin(), (obj).end(), 0)
#define SORT(obj) sort((obj).begin(), (obj).end()) // 1,2,3,4,5...
#define RESORT(obj) sort((obj).begin(), (obj).end(), greater<int>()) // 5,4,3,2,1...
#define UB(obj,n) upper_bound((obj).begin(), (obj).end(), n) //itr > n
#define LB(obj,n) lower_bound((obj).begin(), (obj).end(), n) //itr>= n

const ll MOD = (ll)1e9 + 7;

int main() {
	int N;
	cin >> N;
	int a[100000] = {};
	REP(i, N) {
		int aa;
		cin >> aa;
		a[aa]++;	
	}
	int Xmax = 0;
	FOR(i, 2, 100000) Xmax = max(Xmax, a[i - 2] + a[i - 1] + a[i]);	
	cout << Xmax << endl;
	//cin >> N;
	return 0;
}


Measured memory_bytes: 640
import copy
N, x = map(int, input().split())
a = [int(i) for i in input().split()]
a2 = copy.copy(a)
s = 0
s2 = 0
for i in range(1, N):
    tmp = max(a[i-1]+a[i]-x, 0)
    a[i] = max(0, a[i]-tmp)
    s += tmp
a = a2
for i in range(N-2, -1, -1):
    tmp = max(a[i+1]+a[i]-x, 0)
    a[i] = max(0, a[i]-tmp)
    s2 += tmp
print(min(s, s2))


Measured memory_bytes: 64988
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int cityCnt = scanner.nextInt();
			int routeCnt = scanner.nextInt();

			Map<Integer, Integer> map = initMap(cityCnt);
			// input
			for (int i = 0; i < routeCnt; i++) {
				for (int j = 0; j < 2; j++) {
					int routeA = scanner.nextInt();
					if (map.containsKey(routeA)) {
						map.put(routeA, map.get(routeA) + 1);
					} else {
						map.put(routeA, 1);
					}
				}
			}
			// output
			for (Entry<Integer, Integer> entry : map.entrySet()) {
				System.out.println(entry.getValue());
			}
		}
	}

	private static Map<Integer, Integer> initMap(int cityCnt) {
		Map<Integer, Integer> map = new HashMap<Integer, Integer>();
		for (int i = 1; i <= cityCnt; i++) {
			map.put(i, 0);
		}
		return map;
	}
}

Measured memory_bytes: 23764
#include <cstdio>
#include <cstring>

#include <algorithm>
#include <iostream>
#include <string>

bool CanChange(std::string const &line, std::string const &target) {
  if (line == target) {
    return true;
  }

  int m = (int)target.length();
  int n = (int)line.length();
  if (n <= m) {
    return false;
  }
  int d = n - m;
  for (int i = 0; i + d <= n; ++i) {
    // [0, i) [i, i+d) [i+d, n)
    std::string tmp = line.substr(0, i) + line.substr(i + d, n - (i + d));
    if (tmp == target) {
      return true;
    }
  }
  return false;
}

int main() {
  std::string target = "keyence";
  std::string line;

  std::cin >> line;

  puts(CanChange(line, target) ? "YES" : "NO");
  return 0;
}

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

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

int N;

int main() {
	cin >> N;

	unsigned a;
	cin >> a;

	unsigned int Max = a;
	unsigned int Min = a;

	for (int i = 1; i < N; i++) {
		cin >> a;

		Max = max(Max, a);
		Min = min(Min, a);

	}

	cout << Max - Min << endl;

	return 0;
}

Measured memory_bytes: 256
import Control.Applicative ((<$>), (<*>))
import Control.Monad
import Data.List

main :: IO ()
main = do
  solve <$> replicateM 5 (getl toInt) >>= print

solve :: [Int] -> Int
solve = flip div 5 . sum . map f
  where
    f x
      | x < 40 = 40
      | otherwise = x

toInt :: String -> Int
toInt = read

getl :: (String -> a) -> IO a
getl f = f <$> getLine

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

int a, b;
int X;

void search(int A, int B) {
    if(pow(A,5) > X ) {
        A = B;
        search(A,B-1);
        return;
    }
    if(pow(A,5)-pow(B,5) == X) {
        a = A;
        b = B;
        return;
    }
    search(A+1, B);
}

int main() {
    cin >> X;
    search(-100, 100);
    cout << a << " " << b << endl;

    return 0;
}

Measured memory_bytes: 4052
import math
import bisect
import collections
import itertools
def gcd(a,b):return math.gcd #最大公約数
def lcm(a,b):return (a*b) // math.gcd(a,b) #最小公倍数
def iin(): return int(input()) #整数読み込み
def imn(): return map(int, input().split()) #整数map取得
def iln(): return list(map(int, input().split())) #整数リスト取得
def iln_s(): return sorted(iln()) # 昇順の整数リスト取得
def iln_r(): return sorted(iln(), reverse=True) # 降順の整数リスト取得
def join(l, s=''): return s.join(l) #リストを文字列に変換
def perm(l, n): return itertools.permutations(l, n) # 順列取得
def comb(l, n): return itertools.combinations(l, n) # 組み合わせ取得
def divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i: divisors.append(n//i)
    return divisors
def is_prime(n):
    if n == 1: return False
    for i in range(2, int(n**0.5) + 1):
        if n % i == 0: return False 
    return True

N = iin()
if N % 2 == 1: 
    print(0)
    exit()
cnt = 0
div = 10
while True:
    cnt += N//div
    div *= 5
    if div > N:break

print(cnt)


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

int main(){

    ll n, k;
    cin >> n >> k;

    ll x = n;
    if (x > k + k/2) {
        x = (x % k) + k;
    }
    while (x > k/2) {
        x = abs(x-k);
    }

    cout << x << endl;
    return 0;
}


Measured memory_bytes: 256