akhauriyash/Code-Regression huggingface dataset:
import sys

def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline

def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    N = int(read_func().strip().split()[0])
    input_raw = read_func().strip().split()
    [D, X] = [int(input_raw[0]), int(input_raw[1])]
    s = 0
    for i in range(N):
        input_raw = read_func().strip().split()
        A = int(input_raw[0])
        s += (D - 1)/A + 1

    print s + X

if __name__ == '__main__':
    main()


Measured memory_bytes: 2568
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
typedef long long ll;
int main(){
	int n, sum=0;
	cin >> n;
	for (int i = 0; i < n; i++) {
		int a;
		cin >> a;
		sum += a;
	}
	cout << sum - n << endl;
    return 0;
}



Measured memory_bytes: 256
#include<iostream>
using namespace std;
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<cmath>
#define int long long int
#define inf 1000000000
#define pi acos(-1)
int32_t main()
{
	double a,b,h,m;
	cin>>a>>b>>h>>m;
	double angle1=(30*h+double(m)/2.0);
	double angle2=(6*m);
	double angle=abs(angle1-angle2);
	angle*=pi;
	angle/=180.0;
	double answer=sqrt(a*a+b*b-2*a*b*cos(angle));
	printf("%.10f\n",answer);
}


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

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

int main() {
  int n,ans=0;
  cin>>n;
  vector<int> a(n);
  rep(i,n) {
    cin>>a[i];
    if(a[i]!=i+1) ans++;
  }
  if(ans==2||ans==0) cout<<"YES";
  else cout<<"NO";
  return 0;
}

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

int main(){
  int N;
  ll ans = 0;
  cin >> N;
  for (int i = 0; i <= N; i++) {
    if (i%3 != 0 && i%5 != 0) ans += i;
  }
  cout << ans << "\n";
  
  return 0;
}

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

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = std::int64_t;
using P = std::tuple<int,int>;

int N;

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

  std::cin >> N;

  ll sum = 0;

  for(int i=1;i<=N;++i){
      if(i % 3 > 0 && i % 5 > 0){
          sum += i;
      }
  }

  std::cout << sum << std::endl;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
template <class T> int size(const T &x) { return x.size(); }
#define rep(i,a,b) for (__typeof(a) i=(a); i<(b); ++i)
#define iter(it,c) for (__typeof((c).begin()) \
  it = (c).begin(); it != (c).end(); ++it)
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef long long ll;
const int INF = ~(1<<31);

const double EPS = 1e-9;
const double pi = acos(-1);
typedef unsigned long long ull;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
template <class T> T smod(T a, T b) {
  return (a % b + b) % b; }

vector<ll> A;

ll f(ll mid)
{
    ll sm = 0;
    rep(i,0,size(A))
    {
        sm += abs(A[i]-(mid+i+1));
    }
    return sm;
}

int main()
{
    ios_base::sync_with_stdio(false);

    int n;
    cin >> n;
    A.resize(n);
    rep(i,0,n) cin >> A[i];

    ll lo = -1000000000, hi = 1000000000;
    while (hi - lo > 1)
    {
        ll mid = (hi + lo)>>1;
        if (f(mid) < f(mid + 1)) 
            hi = mid;
        else 
            lo = mid; 
    }

    cout << f(lo+1) << endl;

    
    return 0;
}


Measured memory_bytes: 1792
n = int(input())
p = list(map(int, input().split()))
cnt = 0
for i in range(1,n-1):
    if p[i-1]<=p[i]<p[i+1]:
        cnt += 1
    elif p[i-1]>p[i]>=p[i+1]:
        cnt += 1
print(cnt)



Measured memory_bytes: 3060
#include <bits/stdc++.h>
     
using namespace std;
     
#define FOR(i,a,b)		for(int i=(a),_b=(b);i<(_b);++i)
#define FORD(i,a,b)		for(int i=(a),_b=(b);i>(_b);--i)
#define pb			push_back
#define mp			make_pair
#define	all(c)			(c).begin(),(c).end()
#define	present(c,x)		((c).find(x) != (c).end())
#define	cpresent(c,x)		(find(all(c),x) != (c).end())
#define	endl			'\n'
     
typedef long long		ll;
typedef unsigned long long	ull;
typedef unsigned char	 	byte;
typedef vector<int>		vi;
typedef pair<int, int>		pii;
typedef pair<ll, ll>		pll;
typedef vector<pii>		vpii;
     
const int MX = 100005;

int memo[MX];

int play(int n, int K, vi &A)
{
	if (K == 0) return -1;
	if (memo[K] != 0) return memo[K];
	memo[K] = -1;
	FOR(i,0,n) {
		if (K >= A[i]) {
			int res = play(n,K-A[i],A);
			if (res == -1) return memo[K] = 1;
		}
	}
	return memo[K];
}

int main(int argc, char *argv[])
{
#ifdef	HTRINH_UNIT_TEST
	freopen(argv[1],"r",stdin);
	ifstream cin(argv[1]);
#endif
#if 0
	ofstream cout(argv[2]);
#endif
	ios :: sync_with_stdio(false);
	cin.tie(NULL);

	int n,k;
	cin >> n >> k;
	vi a(n);
	FOR(i,0,n) cin >> a[i];
	if (1 == play(n,k,a)) cout << "First" << endl;
	else cout << "Second" << endl;
    return 0;
}


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

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

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(int argc, char* argv[]) {
  string S;
  cin >> S;

  int n = 0, w = 0, s = 0, e = 0;
  for (int i = 0; i < S.length(); i++) {
    if (S[i] == 'N') n++;
    if (S[i] == 'W') w++;
    if (S[i] == 'S') s++;
    if (S[i] == 'E') e++; 
  }

  if ((n > 0 && s == 0) ||
      (s > 0 && n == 0)) {
    cout << "No" << endl;
  } else if ((w > 0 && e == 0) ||
	     (e > 0 && w == 0)) {
    cout << "No" << endl;
  } else {
    cout << "Yes" << endl;
  }
  
  return 0;
}


Measured memory_bytes: 256
// B.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

#include <iostream>
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <queue>
#include <functional>
#include <map>
#include <string>
#include <cstdlib>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <numeric>


using lolo=long long;
using namespace std;
using vec=vector<lolo>;
using vvec=vector<vec>;
using vecb=vector<bool>;
#define FOR(i,n) for (lolo i=0; i<n; ++i)
#define FORN(i,a,b) for (lolo i=a; i<b; ++i)
#define REV(i,a,b) for (lolo i=a; i>b; --i)
#define ALL(x) x.begin(), x.end()

int main()
{
	lolo r, d, x;
	cin >> r >> d >> x;
	FOR(i, 10) {
		x = r * x - d;
		cout << x << endl;
	}
}

// プログラムの実行: Ctrl + F5 または [デバッグ] > [デバッグなしで開始] メニュー
// プログラムのデバッグ: F5 または [デバッグ] > [デバッグの開始] メニュー

// 作業を開始するためのヒント: 
//    1. ソリューション エクスプローラー ウィンドウを使用してファイルを追加/管理します 
//   2. チーム エクスプローラー ウィンドウを使用してソース管理に接続します
//   3. 出力ウィンドウを使用して、ビルド出力とその他のメッセージを表示します
//   4. エラー一覧ウィンドウを使用してエラーを表示します
//   5. [プロジェクト] > [新しい項目の追加] と移動して新しいコード ファイルを作成するか、[プロジェクト] > [既存の項目の追加] と移動して既存のコード ファイルをプロジェクトに追加します
//   6. 後ほどこのプロジェクトを再び開く場合、[ファイル] > [開く] > [プロジェクト] と移動して .sln ファイルを選択します


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
//C++11
#if __cplusplus == 201103L
#include <tuple>
#endif

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)n; ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cout<<*i<<" "; cout<<endl; }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;
int S;
bool equation(string& s, int& p){
  if(s[p] == '-'){
    p++;
    bool v = equation(s, p);
    return !v;
  }else if(s[p] == '('){
    p++;
    bool v1 = equation(s, p);
    char ope = s[p++];
    if(ope == '-') assert(s[p++] == '>');
    bool v2 = equation(s, p);
    assert(s[p++] == ')');
    if(ope == '*'){
      return v1 && v2;
    }else if(ope == '+'){
      return v1 || v2;
    }else if(ope == '-'){
      return !v1 || v2;
    }
  }else if(s[p] == 'T'){
    p++;
    return true;
  }else if(s[p] == 'F'){
    p++;
    return false;
  }else if(s[p] >= 'a' && s[p] <= 'k'){
    bool res = (S & (1<<(s[p++]-'a')));
    return res;
  }else{
    fprintf(stderr, "%c is not expected\n", s[p]);
    exit(EXIT_FAILURE);
  }
}

int main(){
  string s1, s2, s;
  while(cin>>s){
    if(s == "#") break;
    REP(i, s.size()) if(s[i] == '=') s1 = s.substr(0, i), s2 = s.substr(i+1);
    bool ans = true;
    for(S = 0; S < 1<<11; S++){
      int p = 0;
      bool eq1 = equation(s1, p);
      p = 0;
      bool eq2 = equation(s2, p);
      if(eq1 != eq2) ans = false;
    }
    if(ans) cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
  }
  return 0;
}

Measured memory_bytes: 952
#include <bits/stdc++.h>
#include <numeric>
using namespace std;
#define ll long long
#define mod 100000007
#define rep(i, n) for (int i = 0; i < n; ++i)
using Graph = vector<vector<int>>;
ll lcm(ll a, ll b)
{
    return a * b / __gcd(a, b);
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    //cout << fixed << setprecision(15);
    int N;
    cin >> N;
    vector<string> S;
    string str;
    for (int i = 0; i < N; i++)
    {
        cin >> str;
        S.push_back(str);
    }
    ll ans = 1;
    sort(S.begin(), S.end());
    for (int i = 1; i < S.size(); i++)
    {
        if(S[i-1] != S[i]){
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 11576
#include<bits/stdc++.h>
#define mo 998244353
#define pi 3.1415926535898
#define eps 1e-9 
using namespace std;
long long read(){
    long long xx=0,flagg=1;
    char ch=getchar();
    while((ch<'0'||ch>'9')&&ch!='-')
        ch=getchar();
    if(ch=='-'){
        flagg=-1;
        ch=getchar();
    }
    while(ch>='0'&&ch<='9'){
        xx=xx*10+ch-'0';
        ch=getchar();
    }
    return xx*flagg;
}
void pus(long long xx,long long flagg){
    if(xx<0){
        putchar('-');
        xx=-xx;
    }
    if(xx>=10)
        pus(xx/10,0);
    putchar(xx%10+'0');
    if(flagg==1)
        putchar(' ');
    if(flagg==2)
        putchar('\n');
    return;
}
int n,m,nl,nr,ml,mr,i,j,k,l,x,y,f[55][105][55][105],sum1[105][105],sum2[105][105];
int ll,rr,p1,p2,p3,p4;
char s[105][105];
int maxx(int u,int v){
	return u>v?u:v;
}
int minn(int u,int v){
	return u<v?u:v;
}
int main(){
	scanf("%d%d",&n,&m);
	for(i=1;i<=n;i++)
		scanf("%s",s[i]+1);
	for(i=1;i<=n;i++)
		for(j=1;j<=m;j++)
			if(s[i][j]=='E'){
				x=i;
				y=j;
				break;
			}
	if(x>(n>>1)){
		x=n+1-x;
		for(i=1;i<=(n>>1);i++)
			for(j=1;j<=m;j++)
				swap(s[i][j],s[n-i+1][j]);
	}
	if(y>(m>>1)){
		y=m+1-y;
		for(i=1;i<=(m>>1);i++)
			for(j=1;j<=n;j++)
				swap(s[j][i],s[j][m+1-i]);
	}
	for(i=1;i<=n;i++)
		for(j=1;j<=m;j++){
			sum1[i][j]=sum1[i-1][j];
			sum2[i][j]=sum2[i][j-1];
			if(s[i][j]=='o'){
				sum1[i][j]++;
				sum2[i][j]++;
			}
		}
	nl=x-1;
	nr=n-x;
	ml=y-1;
	mr=m-y;
	for(i=0;i<=nl;i++)
		for(j=0;j<=nr;j++)
			for(k=0;k<=ml;k++)
				for(l=0;l<=mr;l++){
					p1=0;p2=0;p3=0;p4=0;
					
					ll=maxx(l,y-k-1);
					rr=minn(m-k,y+l);
					if(i!=0){
						if(x-i>j)
							p1=f[i-1][j][k][l]+sum2[x-i][rr]-sum2[x-i][ll];
						else
							p1=f[i-1][j][k][l];
					}
					if(j!=0){
						if(x+j<=n-i)
							p2=f[i][j-1][k][l]+sum2[x+j][rr]-sum2[x+j][ll];
						else
							p2=f[i][j-1][k][l];
					}

					ll=maxx(j,x-i-1);
					rr=minn(n-i,x+j);
					if(k!=0){
						if(y-k>l)
							p3=f[i][j][k-1][l]+sum1[rr][y-k]-sum1[ll][y-k];
						else
							p3=f[i][j][k-1][l];
					}
					if(l!=0){
						if(y+l<=m-k)
							p4=f[i][j][k][l-1]+sum1[rr][y+l]-sum1[ll][y+l];
						else
							p4=f[i][j][k][l-1];
					}
					
					f[i][j][k][l]=maxx(maxx(p1,p2),maxx(p3,p4));
				}
	pus(f[nl][nr][ml][mr],2);
	return 0;
}

Measured memory_bytes: 118272
//?????????????????????????????????????????????
using System;

namespace DefaultNamespace
{
	/// <summary>
	/// Description of Class1.
	/// </summary>
	public class Class1
	{
		public static void Main(String[] args)
		{				
			  new listArray();
		
			//listA.start();
			//listA.finish();
		}
	
	}

	public class listArray
	{
		private int first = 0;
		private int last = 0;
		private int[] list = new int[1000000];
		
		public  listArray()
		{
			int n = int.Parse(Console.ReadLine());
			for (int i = 0; i < n; i++) {
				string com = Console.ReadLine();
				string[] command = com.Split();
				switch (command[0]) {
					case "insert":
						list[first] = int.Parse(command[1]);//first?????¨????????????first-1????????????????????\??£?????????
						first++;
						break;
					case"deleteFirst":
						//deleteFirst();
						first--;
						while (list[first - 1] == -1) {
							first--;
						}
					
						break;
					case"deleteLast":
						//deleteLast();
						
						last++;
						while (list[last] == -1) {
							last++;
						}
						
						break;
					case "delete":
						//delete(int.Parse(command[1]));
						for (int j = first - 1; j >= last; j--) {
							if (list[j] == int.Parse(command[1])) {
								list[j] = -1;//?????????????????????-1???????????????
								while (list[first - 1] == -1) {
									first--;
								}
								while (list[last] == -1) {
									last++;
								}
								break;
							}
						}
						
						
						break;				
				}
			}
			finish();
		}
		/*
		public void insert(int val)
		{
			list[first]=val;//first?????¨????????????first-1????????????????????\??£?????????
			first++;
		}
		
		public void deleteFirst()
		{
			first--;
			while(list[first-1]==-1)
			{
				first--;
			}
		}
		
		public void deleteLast()//last???????????\??£????????????
		{
			last++;
			while(list[last]==-1)
			{
				last++;
			}
		}
		
		public void delete(int val)
		{
			for(int j=first-1;j>=last;j--)
			{
				if(list[j]==val)
				{
					list[j]=-1;//?????????????????????-1???????????????
					while(list[first-1]==-1)
					{
						first--;
					}
					while(list[last]==-1)
					{
						last++;
					}
					return;
				}
			}
			return;
		}
		*/
		private void finish()
		{
			for (int k = first - 1; k > last; k--) {
				if (list[k] != -1) {
					Console.Write(list[k] + " ");
				}				
			}			
			Console.WriteLine(list[last]);	
		}
	}
}

Measured memory_bytes: 16464
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <set>
#include <queue>

using namespace std;

typedef long long ll;

int N, x, A[100005];
int main() {
  scanf("%d %d", &N, &x);
  for (int i = 1; i <= N; i++) {
    scanf("%d", &A[i]);
  }
  ll res = 0;
  for (int i = 2; i <= N; i++) {
    int sum = A[i] + A[i - 1];
    if (sum > x) {
      int diff = sum - x;
      res += diff;
      A[i] -= min(A[i], diff);
    }
  }
  printf("%lld\n", res);
  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
int main() {
    string s; cin >> s;
    int x, y; cin >> x >> y;
    int nx=0, ny=0;
    int sz = s.size();
    if(s[sz-1]!='T') s += 'T', sz++;
    vector<int> Tstack;
    rep(i, sz) {
        if(s[i]=='T') Tstack.push_back(i);
    }
    if(s[0]=='F') {
        nx += Tstack[0];
    }
    vector<int> lr;
    vector<int> ud;
    for(int i=1;i<Tstack.size();i++) {
        if(i&1) {
            ud.push_back(Tstack[i]-Tstack[i-1]-1);
        }else{
            lr.push_back(Tstack[i]-Tstack[i-1]-1);
        }
    }
    map<int,int> LR[2]; LR[0][nx] = 1;
    map<int,int> UD[2]; UD[0][ny] = 1;
    rep(i, lr.size()) {
        LR[!(i%2)].clear();
        for(auto it=LR[i%2].begin();it!=LR[i%2].end();it++) {
            //printf("lr: %d %d\n",it->first+lr[i],it->first-lr[i]);
            LR[!(i%2)][it->first+lr[i]] = 1;
            LR[!(i%2)][it->first-lr[i]] = 1;
        }
    }
    rep(i, ud.size()) {
        UD[!(i%2)].clear();
        for(auto it=UD[i%2].begin();it!=UD[i%2].end();it++) {
            UD[!(i%2)][it->first+ud[i]] = 1;
            UD[!(i%2)][it->first-ud[i]] = 1;
        }
    }
    if((LR[(lr.size()&1)][x]&&UD[(ud.size()&1)][y])) cout << "Yes";
    else cout << "No";
}


Measured memory_bytes: 1024
import sys
read = sys.stdin.buffer.read
input = sys.stdin.buffer.readline
inputs= sys.stdin.buffer.readlines
#rstrip().decode('utf-8')

#import math
#import numpy as np
#import operator
#import bisect
#from heapq import heapify,heappop,heappush
#from math import gcd
#from fractions import gcd
from collections import deque
#from collections import defaultdict
#from collections import Counter
#from itertools import accumulate
#from itertools import groupby
#from itertools import permutations
#from itertools import combinations
#from scipy.sparse import csr_matrix
#from scipy.sparse.csgraph import floyd_warshall
#from scipy.sparse.csgraph import csgraph_from_dense
#from scipy.sparse.csgraph import dijkstra
#sys.setrecursionlimit(10**7)

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

def main():
	n,m=map(int,input().split())
	li=[[] for _ in range(n+1)]
	for i in range(m):
		l,r,d=map(int,input().split())
		li[l].append((r,d))
		li[r].append((l,-d))
	
	q=deque()
	a=[None]*(n+1)

	for i in range(1,n+1):
		if a[i]==None:
			q=[i]
			a[i]=0
			while q:
				now=q.pop()
				for r,d in li[now]:
					if a[r]==None:
						a[r] = a[now] + d
						q.append(r)
					else:
						if a[r]-a[now]!=d:
							print("No")
							exit(0)
						else:
							continue
					
	print("Yes")
	
	
if __name__ == '__main__':
	main()

Measured memory_bytes: 74528
a=[]
for i in range(5):
    a.append(int(input()))
b=set(map(lambda x: x%10,a))
if 0 in b:
    b.remove(0)
    if len(b) == 0:
        b.add(10)
print(sum(map(lambda x:(x/10+1)*10 if x%10 != 0 else (x/10)*10,a))+min(b)-10)


Measured memory_bytes: 2568
#A
#n = int(input())
#print(3*n**2)
#B
n, d = map(int, input().split())
canseerange = 2*d+1
if n % canseerange == 0:
    print(int(n/canseerange))
else:
    print(int(n/canseerange)+1)

Measured memory_bytes: 38256
#include<iostream>
#include<deque>

using namespace std;

int A[200005];

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

    int n,k;
    cin>>n>>k;

    for(int i=1; i<=n; i++)
        cin>>A[i];

    int desc=0;
    int rez=0;
    deque<int> Qmin,Qmax;
    bool ok_prev=false,ap=false;

    for(int i=1; i<k; i++)
    {
        if(A[i]<A[i-1])
            desc++;

        while(!Qmin.empty() && A[i]<A[Qmin.back()])
            Qmin.pop_back();
        while(!Qmax.empty() && A[i]>A[Qmax.back()])
            Qmax.pop_back();

        Qmin.push_back(i);
        Qmax.push_back(i);
    }

    for(int i=1; i<=n-k+1; i++)
    {
        if(A[i+k-1]<A[i+k-2])
            desc++;
        if(A[i]<A[i-1])
            desc--;

        while(!Qmin.empty() && A[i+k-1]<A[Qmin.back()])
            Qmin.pop_back();
        while(!Qmax.empty() && A[i+k-1]>A[Qmax.back()])
            Qmax.pop_back();

        Qmin.push_back(i+k-1);
        Qmax.push_back(i+k-1);

        if(desc==0)
        {
            ok_prev=false;
            ap=true;
        }
        else if(!(ok_prev && Qmin.front()==i-1 && Qmax.front()==i+k-1))
        {
            rez++;
            ok_prev=true;
        }

        if(!Qmin.empty() && Qmin.front()==i-1)
            Qmin.pop_front();
        if(!Qmax.empty() && Qmax.front()==i-1)
            Qmax.pop_front();
    }

    if(ap)
        rez++;
    cout<<rez<<"\n";
    return 0;
}


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

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;

//#include <boost/multiprecision/cpp_int.hpp>
//typedef boost::multiprecision::cpp_int bigint;

const int mod = (int)1e9 + 7;
void dbg(){ cerr << "\n"; } template <typename T,typename ...T2> void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }

struct Bitree {
	typedef int btT;
	vector<btT> bv;
	Bitree() : bv(505) {}
	btT sum(int i) {
		btT res=0; for(i++; i>0; i -= i & -i) res += bv[i]; return res;
	}
	btT sum(int a, int b) {return sum(b) - (a? sum(a-1): 0);}
	void add(int i, btT x){for(i++; i<(int)bv.size(); i += i & -i) bv[i] += x; }
	void updt(int i, btT x){ add(i, x - sum(i,i));} //replace, update
	//void dsp(){for(auto x:bv) cout<<x<<" ";puts("");}
};


int main()
{
	
	//cin.tie(0); ios_base::sync_with_stdio(false);
	int n,m,q;
	cin >>n >>m >>q;
	
	vector<pii> lr(m), st(q);
	
	rep(i,m) cin >>lr[i].first >> lr[i].second;
	rep(i,q) cin >>st[i].first >> st[i].second;
	
	vector<VI> dt(n+5, VI(n+5)), sk(n+6, VI(n+6));

	rep(i, m) dt[lr[i].first -1][lr[i].second -1]++;

	rep(i,n) rep(j,n){
		sk[i+1][j+1] = sk[i][j+1] + sk[i+1][j] - sk[i][j] + dt[i][j];
	}
			
	for(auto x: st){
		int y0,y1,x0,x1;
		y0=x0=x.first-1; y1=x1=x.second;
		int w = sk[y1][x1] - sk[y1][x0] - sk[y0][x1] + sk[y0][x0];
		cout << w <<"\n";
	}
	
	return 0;
}


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

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

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

    vector<int> ans(n + 1, 0);
    for (int i = n; i >= 1; i--)
    {
        int cnt = 0;
        for (int j = i; j <= n; j += i)
            cnt += ans[j];
        if (cnt % 2 != a[i])
            ans[i]++;
    }

    cout << accumulate(ans.begin(), ans.end(), 0) << endl;
    for (int i = 1; i <= n; i++)
        if (ans[i])
            cout << i << " ";
    cout << endl;

    return 0;
}

Measured memory_bytes: 4832
import java.util.Scanner;
import java.util.stream.IntStream;

/**
 * 解説どおりに実装したソースコード
 */
public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int n = scanner.nextInt();
			scanner.nextInt();
			int w = scanner.nextInt();

			int[] a = new int[n];
			IntStream.range(0, n).forEach(i -> a[i] = scanner.nextInt());

			if (1 == n) {
				System.out.println(Math.abs(a[n - 1] - w));
			} else {
				System.out.println(Math.max(Math.abs(a[n - 1] - w), Math.abs(a[n - 1] - a[n - 2])));
			}
		}
	}
}


Measured memory_bytes: 28628
#include<stdio.h>
#include<string.h>
#define maxH 2000001


void maxHeapify(int A[],int i,int H){
	int l=i*2;
	int r=l+1;
	int largest=i;
	
	if(l<=H && A[l]>A[i])largest=l;
	if(r<=H && A[r]>A[largest])largest=r;
	
	if(largest!=i){
		int temp=A[i];
		A[i]=A[largest];
		A[largest]=temp;
		maxHeapify(A,largest,H);
	}
}

void buildMaxHeap(int A[],int H){
	int i;
	for(i=H/2;i>0;i--)maxHeapify(A,i,H);
}

void insert(int A[],int key,int cnt){
	A[cnt]=key;
	int child=cnt;
	int parent=child/2;
	while(parent>0){
		if(A[parent]<A[child]){
			int temp=A[parent];
			A[parent]=A[child];
			A[child]=temp;
		}
		child=parent;
		parent=child/2;
	}

}

int main(void){
	int A[maxH];
	int cnt=0;
	int key;
	char cmd[10];
	
	while(1){
		scanf("%s",cmd);
		if(!strcmp(cmd,"insert")){
			scanf("%d",&key);
			insert(A,key,++cnt);
		}else if(!strcmp(cmd,"extract")){
			printf("%d\n",A[1]);
			A[1]=A[cnt--];
			maxHeapify(A,1,cnt);
		}else break;
	}
	return 0;
}

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

int main(){
	int a,b;
	cin >> a >> b;
	cout << (a-1)  * (b -1) << endl;
	return 0;
}




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

int main() {
    int n, m; cin >> n >> m;
    int G[n][n] = {};
    for (int i = 0; i < m; i++) {
        int a, b; cin >> a >> b;
        a--, b--;
        G[a][b] = 1;
        G[b][a] = 1;
    }
    int perm[n + 1];
    for (int i = 0; i < n; i++) perm[i] = i;
    int ans = 0;
    do {
        int flag = 1;
        for (int i = 0; i < n - 1; i++) {
            if (G[perm[i]][perm[i + 1]] == 0) flag = 0;
        }
        if (flag) ans++;

    } while (next_permutation(perm, perm + n) && perm[0] == 0);
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    int n, a[102] = {}, b = 0;
    cin >> n;
    for (int i = 0; i < n; i++) cin >> a[i], b += a[i];
    if (b % 10) cout << b;
    else {
        sort(a, a + n);
        for (int i = 0; i < n; i++) if (a[i] % 10) {
            cout << b - a[i];
            return 0;
        }
        cout << 0;
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>
#include <numeric>
#include <set>

using namespace std;
struct aaa{aaa(){cin.tie(nullptr); ios::sync_with_stdio(false); cout<<fixed<<setprecision(20);};}aaa;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v){o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
#define debug(v) {cerr<<"\033[1;36m[debug]\033[m "<<#v<<" : "<<v<<endl;}

using int64 = long long;
using P = pair<int,string>;

int main() {
    int n;
    cin >> n;
    vector<string> s(n);
    for (int i=0; i<n; i++) cin >> s[i];
    sort(s.begin(), s.end());

    vector<P> c;
    c.emplace_back(0,s[0]);
    for (int i=0; i<n; i++) {
        if (c.back().second == s[i]) c.back().first++;
        else c.emplace_back(1,s[i]);
    }

    sort(c.begin(), c.end());

    int pri = c.back().first;
    for (auto p : c ) {
        if (p.first != pri) continue;
        cout << p.second << endl;
    }
}

Measured memory_bytes: 15212
import java.io.IOException;
import java.util.Arrays;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {

		new Main().run();
	}

	private void run() throws IOException {
		Scanner scanner = new Scanner(System.in);
		n = scanner.nextInt();
		int q = scanner.nextInt();
		int[] st = new int[n];
		for (int i = 0; i < n; i++)
			st[i] = scanner.nextInt();
		int[] s = Arrays.copyOf(st, n);
		Arrays.sort(s);
		PriorityQueue<Integer> list = new PriorityQueue<Integer>();
		while (q-- > 0) {
			char query = scanner.next().charAt(0);
			int x = scanner.nextInt();
			if (query == 'A') {
				list.add(st[x - 1]);
			} else if (query == 'R') {
				list.remove(st[x - 1]);
			} else {
				int r = INF;
				int l = 0;
				while (r != l) {
					int mid = (r + l) / 2;
					int pre = 0;
					int BAN = 0;
					Integer[] tmp =list.toArray(new Integer[list.size()]) ;
					Arrays.sort(tmp);
					for (int i : tmp) {
						int p = lower(s, i - mid);
						BAN += Math.max(p - pre, 0);
						pre = upper(s, i);
					}
					BAN += n - pre;
					if (BAN <= x)
						r = mid;
					else
						l = mid + 1;
				}
				System.out.println(l != INF ? l : "NA");
			}
		}
	}

	private int lower(int[] s, int i) {
		int p = Arrays.binarySearch(s, i);
		if (p < 0) {
			p = p * -1 - 1;
		} else {
			for (int j = p - 1; j >= 0; j--) {
				if (s[j] != i)
					break;
				p--;
			}
		}
		return p;
	}

	private int upper(int[] s, int i) {
		int pre = Arrays.binarySearch(s, i);
		for (int j = pre + 1; j < n; j++) {
			if (s[j] != i)
				break;
			pre++;
		}

		return pre + 1;
	}

	int INF = 1000000001;
	int n;
}

Measured memory_bytes: 305804
#include <bits/stdc++.h>
 
#if DEBUG
    #include "debug.h"
#else
    #define debug(args...)
#endif    

using namespace std;

#define int long long

typedef vector<int> vi;
typedef pair<int,int> ii;


#define M 1000000 
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define sz(x) (int)x.size()
#define fill(a,x) memset(a,x,sizeof(a))
#define F first
#define S second
#define FOR(i,a,b) for(int i = a; i<=b; ++i)
#define NFOR(i,a,b) for(int i = a; i>=b; --i)
#define fast ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
const int INF = 1e18;
const int mod = 1e9+7;
const int N = 2e5 + 10;
inline int add(int x,int y){
  x += y;
  if(x >= mod) x -= mod;
  return x;
}
inline int mul(int x,int y){
  x = (1LL * x * y) % mod;
  return x;
}
// mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());



int32_t main(){
  fast;

  int n;
  cin >> n;
  vector<int>b(n-1);
  FOR(i,0,n-2) {
    cin >> b[i];
  }
  int ans = 0;
  FOR(i,0,n-1) {
    if(i == 0)ans += b[i];
    else if(i == n-1)
      ans += b[i-1];
    else
      ans += min(b[i],b[i-1]);
  }
  cout << ans;
  

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
using namespace std;

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

const int INF = 101010101;

int main(){
    int n, m, x;
    cin >> n >> m >> x;
    int c[n];
    int a[n][m];
    rep(i, n){
        cin >> c[i];
        rep(j, m) cin >> a[i][j];
    }
    int ans = INF; //すべての買い方の中での、条件を満たす場合の値段の最小値
    rep(s, 1<<n){ //sに、バイナリビット列を入れていく（0~10^nの2進数の値まで）
        int cost = 0; //買い終えた後の値段の合計
        int d[m] = {0}; //各アルゴリズムの理解度
        rep(i, n){
            if(s>>i&1){ //i個目の本を買うかどうか調べる（sの本の番号と一致する値を、最下位ビットに移動している
                cost += c[i];
                rep(j, m) d[j] += a[i][j];
            }
        }
        bool is = true;
        rep(j, m) if(d[j] < x) is = false; //すべてのアルゴリズムの理解度がx以上であるかの確認
        if(is) ans = min(ans, cost); //上の条件を満たすなら、ans(最小の値段)を更新
    }
    if(ans == INF) cout << -1 << endl; //すべてのアルゴリズムの理解度がx以上となるような買い方が無かった場合
    else cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3624
using System;
using System.Linq;
using System.Collections.Generic;

class Program
{
    static void Main()
    {
        var lr = Console.ReadLine().Split(' ').Select(x => Int64.Parse(x)).ToArray();
        var L = lr[0];
        var R = lr[1];

        const long mod = 2019;
        var modL = L % mod;
        var modR = R % mod;

        var ans = long.MaxValue;

        var sa = R - L;
        if (mod - 1 <= sa) ans=0;
        else if (modR < modL) ans=0;
        else
        {
            var modArray = new long[R - L + 1];
            var index = 0;
            for (var i = L; i <= R; ++i)
            {
                var num = i;
                while (mod <= num)
                {
                    num %= mod;
                }
                modArray[index] = num;
                index++;
            }
            for (int i=0;i<modArray.Length;++i)
            {
                for (int j=i+1;j<modArray.Length;++j)
                {
                    var num = modArray[i] * modArray[j];
                    while (mod <= num)
                    {
                        num %= mod;
                    }
                    if (num < ans) ans = num;
                }
            }
        }
        Console.WriteLine(ans);
    }
}


Measured memory_bytes: 13268
# -*- coding: utf-8 -*-

import sys
import os


def chessboard(w, h):
    even_row = ('#.' * 150)[:w]
    odd_row = ('.#' * 150)[:w]
    for i in range(h):
        if i % 2 == 0:
            print(even_row)
        else:
            print(odd_row)

for s in sys.stdin:
    H, W = list(map(int, s.split()))
    if W == H == 0:
        break
    else:
        chessboard(W, H)
        print()

Measured memory_bytes: 7752
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
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; }
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll INF = 1LL<<60;
const ll MOD = 1e9 + 7;

// 入力
int N;
long long a[100010][3]; // a[i], b[i], c[i] をそれぞれまとめて a[i][0], a[i][1], a[i][2] にしてしまう

// DP テーブル
long long dp[100010][3];

int main() {
    int N; cin >> N;
    for (int i = 0; i < N; ++i) for (int j = 0; j < 3; ++j) cin >> a[i][j];

    // 初期化は既に 0 に初期化される
    // 初期条件も既に 0 で OK

    // ループ
    for (int i = 0; i < N; ++i) {    //i日目
        for (int j = 0; j < 3; ++j) {       //i+1日目の行動を選ぶ
            for (int k = 0; k < 3; ++k) {   //i日目の行動
                if (j == k) continue;   //i日目とi+1日目の行動は異なる
                chmax(dp[i + 1][k], dp[i][j] + a[i][k]);  //行動kのi日目から行動jのi+1日目までの遷移
            }
        }
    }

    ll ans = max(dp[N][0],dp[N][1]); //dp[i] はi日目なので注意,
    ans = max(ans,dp[N][2]);         //N日目はN-1でなく、dp[N]なので注意
    cout << ans << endl;
}

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

int main(void) {
    int cant;
    cin >> cant;
    int diar = 0;
    for (int i = 0; i < cant && diar < 3; i++) {
        int A, B;
        cin >> A;
        cin >> B;
        diar = (A == B) ? diar + 1 : 0;
    }
    if (diar >= 3) {
        cout << "Yes";
    } else {
        cout << "No";
    }
}

Measured memory_bytes: 3632
n = int(input())
A = list(map(int, input().split(" ")))

memo = [[0, 0] for _ in range(n)]

memo[0][0] = A[0]
memo[0][1] = -A[0]

for i in range(1, n - 1):
    memo[i][0] = max(
        memo[i - 1][0] + A[i],
        memo[i - 1][1] - A[i],
    )
    memo[i][1] = max(
        memo[i - 1][0] - A[i],
        memo[i - 1][1] + A[i],
    )

memo[n - 1][0] = memo[n - 2][0] + A[n - 1]
memo[n - 1][1] = memo[n - 2][1] - A[n - 1]

print(max(memo[-1]))

Measured memory_bytes: 25604
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner in = new Scanner(System.in);

        int a = in.nextInt();
        String op = in.next();
        int b = in.nextInt();

        while (op != null && !op.equals("?")) {
            switch (op) {
                case "+":
                    System.out.println(a + b);
                    break;
                case "-":
                    System.out.println(a - b);
                    break;
                case "*":
                    System.out.println(a * b);
                    break;
                default:
                    System.out.println(a / b);
                    break;
            }

            a = in.nextInt();
            op = in.next();
            b = in.nextInt();
        }

        System.exit(0);
    }
}



Measured memory_bytes: 26528
#include<bits/stdc++.h>
#define fi first
#define sd second

using namespace std;

const int maxn = 100010;
const int inf = 10000000000;

int X,Y,Z,a[maxn],b[maxn],c[maxn];
long long ans=0;
set<pair <int,int> > choose_A, choose_B, not_choose_A, not_choose_B;

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
   // freopen("in.txt","r",stdin);
    cin>>X>>Y>>Z;
    for (int i=1;i<=X+Y+Z;i++) {
        cin>>a[i]>>b[i]>>c[i];
        ans-=c[i];
        a[i]=c[i]-a[i];
        b[i]=c[i]-b[i];
    }
    for (int i=1;i<=X+Y+Z;i++) {
        choose_A.insert(make_pair(a[i],i));
        choose_B.insert(make_pair(b[i],i));
    }
    int nX=X, nY=Y;
    for (int i=1;i<=X+Y;i++) {
        int ca = (*choose_A.begin()).fi;
        int cb = (*choose_B.begin()).fi;
        int cab = (*choose_B.begin()).fi + (*not_choose_A.begin()).fi;
        int cba = (*choose_A.begin()).fi + (*not_choose_B.begin()).fi;
        if (nX==0) {
            ca=inf; cab=inf;
        }
        if (nY==0) {
            cb=inf; cba=inf;
        }
        if (nX==0&&nY==0) break;
        int ma = min(min(ca,cab),min(cb,cba));
        //cout<<"LOL "<<ma<<endl;
        ans+=ma;
        if (ca==ma) {
            int id = (*choose_A.begin()).sd;
            //cout<<"1 "<<id<<endl;
            choose_A.erase(make_pair(a[id],id));
            choose_B.erase(make_pair(b[id],id));
            not_choose_B.insert(make_pair(b[id]-a[id],id));
            nX--;
        }
        else if (cb==ma) {
            int id = (*choose_B.begin()).sd;
            // cout<<"2 "<<id<<endl;
            choose_A.erase(make_pair(a[id],id));
            choose_B.erase(make_pair(b[id],id));
            not_choose_A.insert(make_pair(a[id]-b[id],id));
            nY--;
        }
        else if (cab==ma) {
            int id;
            id = (*choose_B.begin()).sd;
           //  cout<<"3 1 "<<id<<" ";
            choose_A.erase(make_pair(a[id],id));
            choose_B.erase(make_pair(b[id],id));
            not_choose_A.insert(make_pair(a[id]-b[id],id));
            id = (*not_choose_A.begin()).sd;
            //cout<<id<<" "<<endl;
            not_choose_A.erase(not_choose_A.begin());
            not_choose_B.insert(make_pair(b[id]-a[id],id));
            nX--;
        }
        else if (cba==ma) {
            int id;
            id = (*choose_A.begin()).sd;
            // cout<<"4 1 "<<id<<" ";
            choose_A.erase(make_pair(a[id],id));
            choose_B.erase(make_pair(b[id],id));
            not_choose_B.insert(make_pair(b[id]-a[id],id));
            id = (*not_choose_B.begin()).sd;
           // cout<<id<<" "<<endl;
            not_choose_B.erase(not_choose_B.begin());
            not_choose_A.insert(make_pair(a[id]-b[id],id));
            nY--;
        }
        //cout<<"lmao"<<nX<<" "<<nY<<endl;
    }
    cout<<-ans;
}



Measured memory_bytes: 10752
from sys import stdin


def main():
    readline = stdin.readline
    read = stdin.read
    N, Q = map(int, readline().split())
    S = readline().strip()
    * LR, = map(lambda x: int(x) - 1, read().split())
    AC = []
    pre = None
    cnt = 0
    for c in S:
        if c == "A":
            pre = "A"
        elif pre == "A" and c == "C":
            cnt += 1
            pre = None
        elif pre == "A":
            pre = None
        AC.append(cnt)
    for l, r in zip(*[iter(LR)] * 2):
        print(AC[r] - AC[l])
    return


main()


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

#ifdef LOCAL
#define debug(var) cerr << (#var) << " = " << (var) << endl;
#else
#define debug(var)
#endif

void init() {
  ios_base::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
}

void solve() {
  long long s; scanf("%lld", &s);
  const long long b = 1e9;
  printf("0 0 1000000000 1 %lld %lld", (b-s%b)%b, (s+(b-s%b)%b)/b);
}

int main() {
  int t = 1; //scanf("%d", &t);
  while (t--) {
    solve();
  }
  return 0;
}


Measured memory_bytes: 3824
#include <iostream>
using namespace std;
typedef long long llong;

llong gcd(llong a, llong b) {
    llong x = a * b;
    if (a < b) {
        llong temp = a;
        a = b;
        b = temp;
    }
    llong r = a % b;
    while(r!=0){
        a = b;
        b = r;
        r = a % b;
    }
    return b;
}

llong lcm(llong a, llong b){
    llong nume = a * b;
    llong deno = gcd(a, b);
    return nume / deno;
}

int main()
{
    int A, B;
    cin >> A >> B;

    llong ans = lcm(A, B);
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
typedef long long int ll;

int main()
{

	ios_base:: sync_with_stdio(false); cin.tie(0);
	string s,t; cin>>s>>t;
	int cnt=0;
	for(int i=0; i<3; i++) {
		cnt+=(s[i]==t[i]);
	}
	cout<<cnt<<endl;


	return 0;
}


Measured memory_bytes: 256
package main

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

var sc *bufio.Scanner

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func divCeil(x, d int) int {
	if x%d == 0 {
		return x / d
	}
	return (x / d) + 1
}

func main() {
	sc = bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	n := nextInt()

	aArray, bArray := make([]int, n), make([]int, n)
	for i := 0; i < n; i++ {
		aArray[i], bArray[i] = nextInt(), nextInt()
	}

	ans := 0
	for i := n - 1; i >= 0; i-- {
		aArray[i] += ans
		nextA := divCeil(aArray[i], bArray[i]) * bArray[i]
		ans += (nextA - aArray[i])
	}
	fmt.Println(ans)
}


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

/* abc064 c */
int  main()
{
	int n;
	cin >> n;
	vector<int> a(n);
	set<int> color;
	int free = 0;
	rep(i, n)
	{
		cin >> a[i];
		if (a[i] < 400)
			color.insert(1);
		else if (a[i] < 800)
			color.insert(2);
		else if (a[i] < 1200)
			color.insert(3);
		else if (a[i] < 1600)
			color.insert(4);
		else if (a[i] < 2000)
			color.insert(5);
		else if (a[i] < 2400)
			color.insert(6);
		else if (a[i] < 2800)
			color.insert(7);
		else if (a[i] < 3200)
			color.insert(8);
		else
			free++;
	}
	if (!color.size() && free)
		cout << 1 << " " << free << endl;
	else
		cout << color.size() << " " << color.size() + free << endl;
	return (0);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <numeric>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rep1(i,n) for (int i = 1; i <= n; ++i)
template<typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> inline T intceil(T a, T b) { return (a + (b - 1)) / b; }
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
const long long MOD = 1e9+7;
#define precout(val) cout << std::fixed << std::setprecision(20) << val;
const string alphabet = "abcdefghijklmnopqrstuvwxyz";
const int dy[4] = { 0, 1, 0, -1 };
const int dx[4] = { 1, 0, -1, 0 };
static const double pi = 3.141592653589793;
// if(nextH >= 0 && nextH < H && nextW >= 0 && nextW < W)

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

  int n; cin >> n;
  bool first = 0;
  rep(i, n) {
    int a; cin >> a;
    if(a % 2 == 1) {
      first = 1;
    }
  }
  if(first) {
    cout << "first" << endl;
  } else {
    cout << "second" << endl;
  }
  return 0;
}


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

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

const int INF = 1e9 + 7;

using namespace std;

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

	string s, t;
	cin >> s >> t;

	int s_ele[26] = {};
	int t_ele[26] = {};
	rep (i, 0, (int)s.size()) {
		s_ele[s[i] - 'a']++;
	}
	rep (i, 0, (int)t.size()) {
		t_ele[t[i] - 'a']++;
	}

	string s_new, t_new;
	rep (i, 0, 26) {
		if (s_ele[i] > 0) {
			s_new += string(s_ele[i], 'a' + i);
		}
	}
	for (int i = 25; i >= 0; i--) {
		if (t_ele[i] > 0) {
			t_new += string(t_ele[i], 'a' + i);
		}
	}

	if (s_new < t_new)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for (int i=(a); i<=(b); i++)
#define per(i,a,b) for (int i=(a); i>=(b); i--)
using namespace std;
typedef long long LL;

inline int read() {
    int x=0,f=1; char ch=getchar();
    while (!(ch>='0'&&ch<='9')) {if (ch=='-')f=-1;ch=getchar();}
    while (ch>='0'&&ch<='9') {x=x*10+(ch-'0'); ch=getchar();}
    return x*f;
}

int a,b;

int main() {

	#ifndef ONLINE_JUDGE
	//	freopen("data.in","r",stdin);
	//	freopen("data.out","w",stdout);
	#endif

	a=read(),b=read();
	cout<<(a-1)*(b-1)<<endl;

	return 0;
}



Measured memory_bytes: 256
MOD = 10**9+7

MAX = 1000010
fac = [0] * MAX 
finv = [0] * MAX
inv = [0] * MAX
def COMinit():
    fac[0] = fac[1] = 1
    finv[0] = finv[1] = 1
    inv[1] = 1
    for i in range(2, MAX):
        fac[i] = fac[i-1] * i % MOD
        inv[i] = MOD - inv[MOD%i] * (MOD//i) % MOD
        finv[i] = finv[i-1] * inv[i] % MOD

def COM(n, k):
    res = 1
    for i in range(k):
        res = res * (n-i) % MOD
    return res * finv[k] % MOD


s = int(input())
x = s//3

COMinit()
ans = 0

for i in range(x):
    ans = (ans + COM(s-2*(i+1)-1, i)) % MOD
    #print(COM(s-2*(i+1)-1, i))
print(ans)

Measured memory_bytes: 127604
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <regex>
#include <algorithm>
#include <typeinfo>
#include <cstdlib>

int main()
{
  /* declaration */
  std::string input;
  std::regex sep(" ");
  std::vector<std::string> svec;
  std::vector<int> ivec;
  int sum=0;

  /* input */
  std::getline(std::cin >> std::ws, input);
  auto ite = std::sregex_token_iterator(input.begin(), input.end(), sep, -1);
  auto end = std::sregex_token_iterator();

  /* separate string and convert to integer */
  while(ite != end)
    svec.push_back(*ite++);
  for(int i=0; i<svec.size(); i++)
    ivec.push_back(std::stoi(svec[i]));

  /* sort reverse */
  std::sort(ivec.rbegin(), ivec.rend());
  // std::sort(ivec.begin(), ivec.end(), std::greater<Type>());

  /* calculate problem */
  for(int i=0; i<ivec.size()-1; i++){
    sum += ivec[i] - ivec[i+1];
  }

  /* print */
  std::cout << sum << std::endl;

  return(0);
}


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

using namespace std;

typedef long long ll;

int main(){
  ll N,M,i;
  ll p[222222];
  ll WA[222222]; //WAの回数
  ll AC[222222]; //ACしてたら1,してなかったら0
  string S[222222];
  cin >> N >> M;
  for(i=0;i<=M-1;i++){
    cin >> p[i] >> S[i];
    if(S[i]=="AC" && AC[p[i]]==0) AC[p[i]]=1;
    if(S[i]=="WA" && AC[p[i]]==0) WA[p[i]]++;
  }
  ll A = 0;
  ll W = 0;
  for(i=1;i<=N;i++){
    A += AC[i];
    if(AC[i]==1) W += WA[i];
    }
  cout << A << " " << W << endl;
} 

Measured memory_bytes: 12700
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
    ll x;
    cin>>x;
    ll s[x*3];

    for(ll i=0;i<3*x;i++)
    {
        cin>>s[i];
    }

    sort(s,s+3*x);

    ll c=0;

    for(int i=x;i<3*x;i=i+2)
    {
        c+=s[i];
    }
     cout<<c;


}

Measured memory_bytes: 5944
#include <iostream>
#include <array>
#include <algorithm>
#include <vector>
#include <set>
#include <unordered_set>
#include <cmath>
#include <complex>
#include <deque>
#include <iterator>
#include <numeric>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
#define ALL(v) v.begin(),v.end()
template<class T> inline bool chmax(T& a, T b) {if (a<b) {a=b; return true;} return false;}
template<class T> inline bool chmin(T& a, T b) {if (a>b) {a=b; return true;} return false;}
#define DEBUG_VLL(vec) REP(i, vec.size()) cerr<<vec[i]<<(i==vec.size()-1?'\n':' ');

const ll MOD = 1000000007;
const ll HIGHINF = (ll)1e18;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string k;
    ll d;
    cin >> k >> d;
    V<vvll> dp(k.size()+1, vvll(2, vll(d, 0)));  // i桁目でk=0:ぴったり k=1:以下 のDの倍数
    dp[0][0][0] = 1;
    rep(i, 1, k.size()+1) {
        REP(j, d) {
            dp[i][0][(j+k[i-1]-'0')%d] += dp[i-1][0][j];
            if (dp[i][0][(j+k[i-1]-'0')%d]>=MOD) dp[i][0][(j+k[i-1]-'0')%d]-=MOD;
            REP(dig, 10) {
                if (dig < k[i-1]-'0') {
                    dp[i][1][(j+dig)%d] += dp[i-1][0][j];
                    if (dp[i][1][(j+dig)%d]>=MOD) dp[i][1][(j+dig)%d]-=MOD;
                }
                dp[i][1][(j+dig)%d] += dp[i-1][1][j];
                if (dp[i][1][(j+dig)%d]>=MOD) dp[i][1][(j+dig)%d]-=MOD;
            }
        }
    }
    ll ans = dp[k.size()][0][0] + dp[k.size()][1][0] - 1;
    if (ans < 0) ans += MOD;
    if (ans >= MOD) ans -= MOD;
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 17024
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define all(a) (a).begin(), (a).end()

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; }

using ll = long long;

std::string S;
ll cnt;

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

  ll p = 0;
  char ch = S[0];

  while( p < S.size() )
  {
    while( p < S.size() && S[p] == ch )
      ++p;

    if( p < S.size() )
      ch = S[p], ++cnt;
  }

  std::cout << cnt << std::endl;

  return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <string>

using namespace std;

int main()
{
int K;
int A,B;
cin>>K;
cin>>A>>B;

int P=B/K;
int R=P*K;
if(A<=R)
{
    cout<<"OK";
}
else
{
    cout<<"NG";
}
return 0;
}


Measured memory_bytes: 3620