akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<string.h>

#define N 1000000

#define INFINITY 2000000001

struct quick{
  char alpha;
  int value;
};
  

struct quick Q[N];
struct quick Merge[N];

struct quick R[N],L[N];

int partition (struct quick *, int ,int);

void quicksort (struct quick *, int ,int);

int merge(struct quick *, int ,int ,int);
void mergeSort (struct quick *,int ,int);

  
int main(){
  int num,i,j;
  int p,r;
  int right,left,mid;
  //printf("1\n");
  scanf("%d",&num);
  for(i=0;i<num;i++) {
    scanf(" %c%d",&Q[i].alpha,&Q[i].value);
    Merge[i] = Q[i];
  }
  //printf("2\n");
  p = 0;
  r = num-1;

  right = num;
  left = 0;
  //mid = (right + left) / 2;


  //printf("3\n");
  mergeSort(Merge,left,right);

  //printf("4\n");

  quicksort(Q,p,r);

  
  for(i=0;i<num;i++){
    if(Merge[i].alpha != Q[i].alpha) break;
  }
  if(i==num) printf("Stable\n");
  else printf("Not stable\n");
  for(i=0;i<num;i++){
    printf("%c %d",Q[i].alpha,Q[i].value);
    //printf("%c %d",Merge[i].alpha,Merge[i].value);
    
    printf("\n");
  }
  

  return 0;
}

int partition (struct quick *par,int p,int r){
  int x,i,j;
  struct quick temp;
  int n;

  x = par[r].value;
  i = p - 1;

  for(j = p;j<=r-1;j++){
    if(par[j].value <= x ){
      i = i+1;
      // A[i] と A[j] を交換
      temp = par[i];
      par[i] = par[j];
      par[j] = temp;
    }
  }
  //A[i+1] と A[r] を交換
  temp = par[i+1];
  par[i+1] = par[r];
  par[r] = temp;

  return i+1;
}


void quicksort (struct quick *A,int p,int r){
  if(p < r){
    int q;
    q = partition(A,p,r);
    quicksort(A,p,q-1);
    quicksort(A,q+1,r);
  }
}



int merge(struct quick *A,int left,int mid,int right){
  int i,j,k,n1,n2;
  //struct quick R[N],L[N];

  //printf("wa-i\n");
  
  n1 = mid - left;
  n2 = right - mid;
  //L[0...n1], R[0...n2] を生成
  for (i = 0;i<= n1-1;i++)
    L[i] = A[left + i];
  for (i = 0;i<= n2-1;i++)
    R[i] = A[mid + i];
  // printf("aaaa\n");
  L[n1].value = INFINITY;
  R[n2].value = INFINITY;
  i = 0;
  j = 0;
  for (k = left;k<=right-1;k++){
    if (L[i].value <= R[j].value){
      A[k] = L[i];
      i = i + 1;
    }
    else {
      A[k] = R[j];
      j = j + 1;
    }
    
  }
  return 0;
}

void mergeSort(struct quick *A,int left,int right){
  int mid;
  int i;
  //printf("%d  %d\n",left,right);
  if (left+1 < right){
    mid = (left + right)/2;
    mergeSort(A, left, mid);
    //printf("wa-iwa-i%d  %d\n",left,right);
    mergeSort(A, mid, right);
    //printf("wa-iwa-iwa-i\n");
    merge(A, left, mid, right);
  }
}





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

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	double l;cin>>l;
	cout<<setprecision(14)<<l*l*l/27<<endl;
	return 0;
}



Measured memory_bytes: 256
N, M = map(int, input().split())
K = []
S = []
for _ in range(M):
	tmp = list(map(int ,input().split()))
	K.append(tmp[0])
	tmp.pop(0)
	S.append(tmp)

P = list(map(int, input().split()))


ans = 0
for i in range(2**N):
	flg = [0 for _ in range(M)]
	for j in range(N):
		if i & (1 << j):
			for k in range(M):
				if j+1 in S[k]:
					flg[k] += 1

	cond = 1
	for l in range(M):
		if P[l] != (flg[l] % 2):
			cond = 0
			break

	if cond:
		ans += 1

print(ans)

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

int val(int x) {
  int res = 0;
  while(x>0){
    res += x%10;
    x /= 10;
  }
  return res;
}

int main(void) {
  int N;
  cin >> N;

  int m = numeric_limits<int>::max();
  for (int i = 1; i <= N-1; i++) {
    m = min(m, val(i)+val(N-i));
  }

  cout << m << endl;
  return 0;
}


Measured memory_bytes: 256
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

K = int(input())
count = 0
for a in range(1, K+1):
    for b in range(1, K+1):
        for c in range(1, K+1):
            d = gcd(a,b)
            count += gcd(c, d)
print(count)

Measured memory_bytes: 68780
import java.util.*;
public class Main{
	public static void main(String[] args){
		Scanner sc =  new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		String str1="";
		if(a<b){
			for(int i = 0;i<b;i++)
			str1+=""+a;
		}else{
			for(int i = 0;i<a;i++)
			str1 += ""+b;
		}
		System.out.println(str1);
		
	}
	
}

Measured memory_bytes: 23124
#include <iostream>

int main(void){
    int a, b, c, ans=0;
    std::cin >> a >> b >> c;

    if (a == b && b == c && a % 2 == 0) {
        ans = -1;
    } else {
        while (a % 2 == 0 && b % 2 == 0 && c % 2 == 0){
            int d, e, f;
            d = b / 2 + c / 2;
            e = c / 2 + a / 2;
            f = a / 2 + b / 2;
            a = d, b = e, c = f;
            ++ans;
        }
    }

    std::cout << ans << std::endl;

    return 0;
}


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

using namespace std;

int main() {
  vector<vector<int>> c(3, vector<int>(3));
  for (int i = 0; i < 3; i++) {
    for (int j = 0; j < 3; j++) {
      cin >> c.at(i).at(j);
    }
  }
  int a_1_max = min(min(c.at(0).at(0), c.at(0).at(1)), c.at(0).at(2));
  for (int a_1 = 0; a_1 <= a_1_max; a_1++) {
    int b_1 = c.at(0).at(0) - a_1;
    int b_2 = c.at(0).at(1) - a_1;
    int b_3 = c.at(0).at(2) - a_1;
    int a_2 = c.at(1).at(0) - b_1;
    if (a_2 < 0) continue;
    if (a_2 != c.at(1).at(1) - b_2) continue;
    if (a_2 != c.at(1).at(2) - b_3) continue;
    int a_3 = c.at(2).at(0) - b_1;
    if (a_3 < 0) continue;
    if (a_3 != c.at(2).at(1) - b_2) continue;
    if (a_3 != c.at(2).at(2) - b_3) continue;
    cout << "Yes" << endl;
    return 0;
  }
  cout << "No" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define inf 0x7fffffff
#define RG register
#define maxn 100005
#define maxm 205
using namespace std;
typedef long long ll;
const ll mod = 1e9 + 7;
inline ll read(){
    ll x = 0, f = 1;
    char ch = getchar();
    while(ch > '9' || ch < '0') {if(ch == '-') f = -1;ch = getchar();}
    while(ch >= '0' && ch <= '9'){x = x *10 + ch -'0';ch = getchar();}
    return x * f;
}

int n, m, a[55], A, sum;
ll f[55][55][2505], ans;
int main(){
	int i, j, k;
	n = read(), A = read();
	for(i = 1;i <= n;i++) a[i] = read(), sum += a[i];
	f[0][0][0] = 1;
	for(i = 1;i <= n;i++){
		for(j = 0;j <= i;j++){
			for(k = 0; k <= sum;k++){
				if(i > j) f[i][j][k] = f[i - 1][j][k];
				if(k >= a[i] && j) f[i][j][k] += f[i - 1][j - 1][k - a[i]];
			}
		}
	}
	for(i = 1;i <= n;i++) ans += f[n][i][i * A];
	cout<<ans; 
	return 0;
}


Measured memory_bytes: 29732
#include <vector>
#include <iostream>
#include <cmath>
#include <map>
#include <algorithm>
#include <fstream>
#include <unistd.h>
#include <string>
#include <numeric>
#include <queue>
#include <deque>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
typedef vector<P> vp;
typedef vector<PL> vpl;
typedef vector<vector<P>> vvp;
const int INF = 1001001001;
const ll LINF = 1e18;
const string endstr = "\n";
#define FOR(i, a, b) for(ll i = (a); i < b; i++)
#define REP(i, n) for(ll i = 0; i < n; i++)

template <typename T>
T gcd(T a, T b) {
    return (a == 0) ? b : gcd(b%a, a);
}
template <typename T>
T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}

bool p_comp_fs(const P p1, const P p2){ return p1.first < p2.first;};
bool p_comp_fg(const P p1, const P p2){ return p1.first > p2.first;};
bool p_comp_ss(const P p1, const P p2){ return p1.second < p2.second;};
bool p_comp_sg(const P p1, const P p2){ return p1.second > p2.second;};
template <typename T>
vector<T> uniquen(vector<T> vec){
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
    return vec;
}


int main(){
    ll N, tot = 0; cin >> N;
    vl as(N, 0);
    REP(i, N){
        ll a; cin >> a; as[i] = a; tot += a;
    }
    
    if(tot % 10 != 0){
        cout << tot << endstr; return 0;
    }
    
    sort(as.begin(), as.end());
    ll ret = tot;
    bool no_remove = true;
    REP(i, N){
        if(as[i] % 10 != 0){
            ret -= as[i]; no_remove = false; break;
        }
    }
    cout << (no_remove ? 0 : ret) << endstr;
    return 0;
}


Measured memory_bytes: 256
s=input()
q=int(input())
cnt=0
front=[]
rear=[]
for qq in range(q):
  l=list(input().split())
  if l[0]=='1':
    cnt+=1
  else:
    if (cnt+int(l[1]))%2==1:
      front.append(l[2])
    else:
      rear.append(l[2])
front=''.join(front[::-1])
rear=''.join(rear)
s=front+s+rear
print(s if cnt%2==0 else s[::-1])

Measured memory_bytes: 12008
#include<iostream>
#include<string.h>
using namespace std;

int main(){
    int r, g, b,num;
    string s;
    cin >> r >> g >> b;
    s = to_string(r) + to_string(g) + to_string(b);
    if (atoi(s.c_str())%4==0)cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
	char str[100];
	int num,i;
	while(scanf("%s",str) != EOF){
		num = 0;
		for(i = 0;str[i] != 0;i++){
			switch(str[i]){
				case 'I':
				if(str[i + 1] == 'V' || str[i + 1] == 'X') num--;
				else num++;
				break;
				case 'V':
				num += 5;
				break;
				case 'X':
				if(str[i + 1] == 'L' || str[i + 1] == 'C') num -= 10;
				else num += 10;
				break;
				case 'L':
				num += 50;
				break;
				case 'C':
				if(str[i + 1] == 'D' || str[i + 1] == 'M') num -= 100;
				else num += 100;
				break;
				case 'D':
				num += 500;
				break;
				case 'M':
				num += 1000;
				break;
			}
		}
		printf("%d\n",num);
	}
	return 0;
}

Measured memory_bytes: 968
#include<bits/stdc++.h>
using namespace std;
const int maxn = 100009;

int first[maxn],col[maxn],cnt[3];
struct edg{int next,to;}e[maxn<<1];
int n,m,flag,e_sum;
long long ans;

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;
}
void add_edg(int x,int y)
{
	e_sum++;
	e[e_sum].next=first[x];
	first[x]=e_sum;
	e[e_sum].to=y;
}

void dfs(int x)
{
	cnt[col[x]]++;
	for(int i=first[x];i;i=e[i].next)
	{
		int w=e[i].to;
		if(!col[w]) col[w]=3-col[x],dfs(w);
		else if(col[w]==col[x]) flag=1;
	}
}

int main()
{
	n=read();m=read();
	for(int i=1;i<=m;i++)
	{
		int x=read(),y=read();
		add_edg(x,y);add_edg(y,x);
	}
	for(int i=1;i<=n;i++)
		if(!col[i])
		{
			cnt[1]=cnt[2]=0;
			col[i]=1;flag=0;
			dfs(i);
			if(flag) ans+=1ll*(cnt[1]+cnt[2])*(cnt[1]+cnt[2]-1)/2;
			else ans+=1ll*cnt[1]*cnt[2];
		}
	cout<<ans-m<<endl;
	return 0;
}


Measured memory_bytes: 3200
#include <iostream>
#include <string>
#include <sstream>

using namespace std;

string doCaesar ( string s, int n )
{
	for (int i = 0, I = s.size(); i < I; ++i) {
		if (s[i] < 'a' || 'z' < s[i]) { continue; }
		s[i] = (s[i] - 'a' + n) % 26 + 'a';
	}
	return s;
}

int main ( void )
{
	string S[] = { "the", "the.", "this", "this.", "that", "that." };

	istringstream iss;
	string s;

	while (getline(cin, s)) {
		bool hit = false;
		for (int i = 0; i < 26 && !hit; ++i) {
			string t;
			iss.clear();
			iss.str(doCaesar(s, 26-i));
			while(iss >> t && !hit) {
				for (int w = 0, W = sizeof(S)/sizeof(string); w < W && !hit; ++w) {
					if (S[w] == t) {
						hit = true;
					}
				}
			}
			if (hit) {
				cout << doCaesar(s, 26-i) << endl;
			}
		}
	}

	return 0;
}

Measured memory_bytes: 1204
#include<stdio.h>


int main(void)


{


int i,n;


int number;


long long int sum=0;


int min=0;


int max=0;


scanf("%d",&n);


for(i=0;i<n;i++)


{


scanf("%d",&number);


if(i==0)


{


min=number;


max=number;


}


if(number<min)min=number;


if(number>max)max=number;


sum+=number;


}


printf("%d %d %lld\n",min,max,sum);


return 0;


}

Measured memory_bytes: 600
#include<iostream>
#include<set>
#include<string>
#include<sstream>
using namespace std;int main(){int m,n,i;set<int> p;set<int>::iterator q;string s;stringstream t;while(cin>>m>>n,m|n){p.clear();for(i=1;i<=m;i++)p.insert(i);q=p.begin();for(i=1;i<=n;i++){cin>>s;if(p.size()==1)continue;t.str("");if(i%3&&i%5){t<<i;}else{if(!(i%3))t<<"Fizz";if(!(i%5))t<<"Buzz";}if(s!=t.str())p.erase(q++);else q++;if(q==p.end())q=p.begin();}for(q=p.begin();q!=p.end();q++){if(q!=p.begin())cout<<" ";cout<<*q;}cout<<endl;}}

Measured memory_bytes: 976
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <queue>
#include <string>
#include <set>
#include <vector>

#define FOR(i, l, r) for (i = (l); i < r; i++ )

using namespace std;
typedef long long ll;

#define MAX_N (200010)
#define INF (0x7FFFFFFF)

int A[MAX_N];
int L[MAX_N>>1];
int R[MAX_N>>1];

ll merge(int A[], int l, int m, int r) {
    if ( r - l <= 1 ) return 0;
    int n1 = m - l;
    int n2 = r - m;
    
    for ( int i = 0; i < n1; i++ ) {
	L[i] = A[l+i];
    }

    for ( int i = 0; i < n2; i++ ) {
	R[i] = A[m+i];
    }

    L[n1] = INF;
    R[n2] = INF;

    int i_l = 0;
    int i_r = 0;
    ll ret = 0;

    for ( int k = l; k < r; k++ ) {
	if ( L[i_l] <= R[i_r] ) {
	    A[k] = L[i_l];
	    i_l++;
	}
	else {
	    A[k] = R[i_r];
	    i_r++;
	    ret += (n1 - i_l);
	}
    }

    return ret;
}

ll merge_sort(int A[], int l, int r) {
    ll ret = 0;
    if ( r - l > 1 ) {
	int m = ( r + l ) / 2;
	ret += merge_sort(A, l, m);
	ret += merge_sort(A, m, r);
	ret += merge(A, l, m, r);
    }

    return ret;
}

int main()
{
    int n;
    scanf("%d", &n);
    for ( int i = 0; i < n; i++ ) {
	scanf("%d", &A[i]);
    }
    
    ll ans = merge_sort(A, 0, n);
    printf("%lld\n", ans);
    
    return 0;
}

Measured memory_bytes: 4700
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

const long MOD = 1000000007;
typedef pair<int, int> P;
typedef long long ll;

int main(){
    int N, M;
    cin >> N >> M;
    
    int H[N];
    for(int i=0; i<N; i++){
        cin >> H[i];
    }

    vector<int> v[N];
    for(int i=0; i<M; i++){
        int a,b;
        cin >> a >> b;
        a--;b--;
        v[a].push_back(b);
        v[b].push_back(a);
    }

    int ans = 0;
    for(int i=0; i<N; i++){
        bool fl = true;
        for(auto t : v[i]){
            if(H[t] >= H[i]) fl = false;
        }
        if(fl) ans++;
    }

    cout << ans << endl;

    return 0;
}


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

void swap(int &x,int &y){
	int temp;
	temp=x;
	x=y;
	y=temp;
}

int main(){
	int x,y,z;
	cin>>x>>y>>z;
	swap(x,y);
	swap(x,z);
	printf("%d %d %d",x,y,z);

	return 0;
}


Measured memory_bytes: 256
n=int(input())
s=list(input())
cnt=0
right=0
left=0
for i in range(len(s)):
    if s[i] == '(':
        cnt+=1
    else:
        cnt-=1
    if cnt < 0:
        right+=1
        cnt=0
if cnt>0:
    left=cnt
for i in range(right):
    s.insert(0,'(')
for i in range(left):
    s.append(')')
print(''.join(s))

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

#define endl '\n'
#define fi first
#define se second
#define MOD(n,k) ( ( ((n) % (k)) + (k) ) % (k))
#define forn(i,n) for (int i = 0; i < n; i++)
#define forr(i,a,b) for (int i = a; i <= b; i++)
#define all(v) v.begin(), v.end()
#define pb(x) push_back(x)

using namespace std;

typedef long long ll;
typedef double ld;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ii> vii;

const int MX = 2005;
string s[3];
int p[] = {0, 1, 2}, res, sum, ini, to[3][3][MX];

void solve (string &a, string &b, string &c) {
	for (int i = 0; i < a.size(); i++) {
		to[0][1][i] = 1;
		for (int j = 0; j < b.size() && i + j < a.size(); j++)
			if (a[i + j] != '?' && b[j] != '?' && a[i + j] != b[j])
				to[0][1][i] = 0;
	}

	for (int i = 0; i < a.size(); i++) {
		to[0][2][i] = 1;
		for (int j = 0; j < c.size() && i + j < a.size(); j++)
			if (a[i + j] != '?' && c[j] != '?' && a[i + j] != c[j])
				to[0][2][i] = 0;
	}

	for (int i = 0; i < b.size(); i++) {
		to[1][0][i] = 1;
		for (int j = 0; j < a.size() && i + j < b.size(); j++)
			if (b[i + j] != '?' && a[j] != '?' && b[i + j] != a[j])
				to[1][0][i] = 0;
	}

	for (int i = 0; i < b.size(); i++) {
		to[1][2][i] = 1;
		for (int j = 0; j < c.size() && i + j < b.size(); j++)
			if (b[i + j] != '?' && c[j] != '?' && b[i + j] != c[j])
				to[1][2][i] = 0;
	}

	for (int i = 0; i < c.size(); i++) {
		to[2][0][i] = 1;
		for (int j = 0; j < a.size() && i + j < c.size(); j++)
			if (c[i + j] != '?' && a[j] != '?' && c[i + j] != a[j])
				to[2][0][i] = 0;
	}

	for (int i = 0; i < c.size(); i++) {
		to[2][1][i] = 1;
		for (int j = 0; j < b.size() && i + j < c.size(); j++)
			if (c[i + j] != '?' && b[j] != '?' && c[i + j] != b[j])
				to[2][1][i] = 0;
	}

	for (int i = 0; i <= a.size(); i++) {
		if (i < a.size() && !to[0][1][i])
			continue;

		for (int j = i; j <= max(a.size(), i + b.size()); j++) {
			if (j < a.size() && !to[0][2][j]) continue;
			if (j <= i && i < j + c.size() && !to[2][1][i - j]) continue;
			if (i <= j && j < i + b.size() && !to[1][2][j - i]) continue;

			res = min(res, (int)max({a.size(), i + b.size(), j + c.size()}));
		}
	}
}

int main () {
	ios_base::sync_with_stdio(0); cin.tie(0);
	
	cin >> s[0] >> s[1] >> s[2];
	res = sum = s[0].size() + s[1].size() + s[2].size();

	ini = s[0].size();
	ini = max(ini, int(s[1].size()));
	ini = max(ini, int(s[2].size()));

	do solve(s[p[0]], s[p[1]], s[p[2]]);
	while (next_permutation(p, p + 3));

	cout << res << endl;

	return 0;
}


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

int main(){
string a,b;
cin >> a >> b;
sort(a.begin(),a.end());
sort(b.begin(),b.end());
reverse(b.begin(),b.end());
if(a<b)cout<<"Yes"<<endl;
else cout << "No"<< endl;
}

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

using namespace std;

typedef long double ld;
typedef long long ll;

#define sz(x) (int)(x).size()
#define pb push_back
#define mp make_pair
#define f first
#define s second

template<typename T, typename U> bool ckmin(T &a, U b){ return b < a ? a = b, true : false; }
template<typename T, typename U> bool ckmax(T &a, U b){ return b > a ? a = b, true : false; }

int a, b, c, k;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> a >> b >> c >> k;
    while(k && b <= a){
        b *= 2, k--;
    }
    while(k && c <= b){
        c *= 2, k--;
    }
    if(c > b && b > a) cout << "Yes";
    else cout << "No";
    return 0;
}

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

int main(){
  int a,b,c,d,e,z,aa,bb,cc,dd,ee;
  cin >> a>> b>> c>> d>> e;
  aa = (a-1) % 10;
  //cout << aa << endl;
  //aa = z;
  //int bb;
  bb = (b-1) % 10-1;
 // cout << bb << endl;
  //bb = z;
  //int cc;
  cc = (c-1) % 10;
 // cout << cc << endl;
  //cc = z;
  //int dd;
  dd = (d-1) % 10;
 // cout << dd << endl;
  //dd = z;
  //int ee;
  ee = (e-1) % 10;
  //cout << ee << endl;
  if(aa<bb && aa<cc && aa<dd && aa<ee)
  {
    cout << ((e+9)/10+(b+9)/10+(c+9)/10+(d+9)/10)*10+a << endl;
  }
  /*
  else if(aa%5>bb%5||aa%5>cc%5||aa%5>dd%5||aa%5>ee%5)
  {
    cout << ((e+9)/10+(b+9)/10+(c+9)/10+(d+9)/10)*10+a << endl;
  }
  */
  else if(bb<cc && bb<dd && bb<ee)
  {
    cout << ((a+9)/10+(e+9)/10+(c+9)/10+(d+9)/10)*10+b << endl;
  }
  /*
  else if(aa%5>bb%5||aa%5>cc%5||aa%5>dd%5||aa%5>ee%5)
  {
    cout << ((a+9)/10+(e+9)/10+(c+9)/10+(d+9)/10)*10+b << endl;
  }
  */
  else if(cc<dd && cc<ee)
  {
    cout << ((a+9)/10+(b+9)/10+(e+9)/10+(d+9)/10)*10+c << endl;
  }
  /*
  else if(cc%5>bb%5||cc%5>aa%5||cc%5>dd%5||cc%5>ee%5)
  {
    cout << ((a+9)/10+(b+9)/10+(e+9)/10+(d+9)/10)*10+c << endl;
  }
  */
  else if(dd<ee)
  {
    cout << ((a+9)/10+(b+9)/10+(c+9)/10+(e+9)/10)*10+d << endl;
  }
  /*
  else if(dd%5>bb%5||dd%5>cc%5||dd%5>aa%5||dd%5>ee%5)
  {
    cout << ((a+9)/10+(b+9)/10+(c+9)/10+(e+9)/10)*10+d << endl;
  }
  */
  else
  {
    cout << ((a+9)/10+(b+9)/10+(c+9)/10+(d+9)/10)*10+e << endl;
  }
  //ee = z;
  /*
  a/10=a;
  b/10=b;
  c/10=c;
  d/10=d;
  e/10=e;
  */
  //cout << (a/10+b/10+c/10+d/10+e/10)*10 << endl;
  /*
  if(t<10)
  {
  t=10;
  }
  else if(t<20)
  {
  t=20;
  }
  else if(t<30)
  {
  t=30;
  }
  else if(t<40)
  {
  cout << ":(" << endl;
  }
  else if(c-b>k)
  {
  cout << ":(" << endl;
  }
  else if(d-b>k)
  {
  cout << ":(" << endl;
  }
  else if(e-b>k)
  {
  cout << ":(" << endl;
  }
  else if(d-c>k)
  {
  cout << ":(" << endl;
  }
  else if(e-c>k)
  {
  cout << ":(" << endl;
  }
  else if(e-d>k)
  {
  cout << ":(" << endl;
  }
   else
  {
  cout << "Yay!" << endl;
  }
  */
  //cout << ((a+9)/10+(b+9)/10+(c+9)/10+(d+9)/10+(e+9)/10)*10 << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<queue>
#include<map>
#include<cmath>
#include<set>
 
using namespace std;
 
const int MAX_H = 20;
const int MAX_W = 20;
const int INF = (1 << 30);
int H,W;
int memo[MAX_H][MAX_W][MAX_H][MAX_W];
 
typedef pair<int,int>P;
typedef pair<int,P>PP;
 
vector<string> input(){
  vector<string>ret;
  cin >> H >> W;
  for(int i = 0 ; i < H ; i++){
    string str;
    cin >> str;
    ret.push_back(str);
  }
  return ret;
}
 
bool check(P pos, vector<string> field){
  if(!(0 <= pos.first && pos.first < H && 0 <= pos.second && pos.second < W))return false;
  if(field[pos.first][pos.second] == '#')return false;
  return true;
}
 
int bfs(P start, vector<string> field){
  const static int dy[4] = {0, 1, 0, -1};
  const static int dx[4] = {1, 0, -1, 0};
 
  set<P>visited;
  int ret = -1;
 
  queue<PP>  que = queue<PP>();
  que.push(PP(0,start));
  while(que.size()){
    PP state = que.front();
    que.pop();
 
    if(visited.count(state.second))continue;
    visited.insert(state.second);
    ret = max(ret, state.first);
 
    for(int i = 0 ; i < 4 ; i++){
      PP next_state = PP(state.first + 1, P(state.second.first + dy[i], state.second.second + dx[i]));
      if(check(next_state.second, field)){
        que.push(next_state);
      }
    }
  }
  return ret;
}
 
int solve(vector<string>field){
  int res = -1;
  for(int sy = 0 ; sy < H ; sy++){
    for(int sx = 0 ; sx < W ; sx++){
      if(field[sy][sx] == '#')continue;
      res = max(res, bfs(P(sy,sx), field));
    }
  }
  return res;
}
 
void init(){
  for(int i = 0 ; i < MAX_H ; i++){
    for(int j = 0 ; j < MAX_W ; j++){
      for(int k = 0 ; k < MAX_H ; k++){
        for(int l = 0 ; l < MAX_W ; l++){
          memo[i][j][k][l] = INF;
        }
      }
    }
  }
}

int main(){
  init();
  cout << solve(input()) << endl;
  return 0;
}


Measured memory_bytes: 896
#include<iostream>
#include<cstdio>
#include<cmath>
#include<vector>
#include<queue>
#include<map>
#include<algorithm>
#include<set>
#include<complex>
#include<string>
#include<cstring>
using namespace std;
#define rep2(x,from,to) for(int x=(from);(x)<(to);(x)++)
#define rep(x,to) rep2(x,0,to)
#define INF 100000000
#define debug(x) cout<<#x<<": "<<x<<endl

#define all(x) x.begin(),x.end()
typedef pair<int,int> P;
typedef pair<int,P> PP;
string s;
int main()
{
	cin>>s;
	rep(i,s.size())
	{
		if(s[i]=='A')
		{
			cout<<'T';
		}
		if(s[i]=='T')
		{
			cout<<'A';
		}
		if(s[i]=='C')
		{
			cout<<'G';
		}
		if(s[i]=='G')
		{
			cout<<'C';
		}
	}
	cout<<endl;
	return 0;
}

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

vector<ll> arr;
vector<vector<ll>> dp;

bool recurse(bool who, ll k, ll n) {
    if (k == 0) {
        return !who;
    }

    if (dp[who][k] != -1) {
        return (bool)dp[who][k];
    }

    bool found = false;
    for (auto a: arr) {
        if (a > k) {
            continue;
        }

        if (recurse(!who, k-a, n) == who) {
            found = true;
            break;
        }
    }
    if (found) {
        return dp[who][k] = who;
    } else {
        return dp[who][k] = !who;
    }

}

int main(void) {
    // ios_base::sync_with_stdio(false);
    // cin.tie(NULL);
    // cout.tie(NULL);
    ll n, k;
    cin >> n >> k;

    arr.resize(n);
    for (ll i = 0; i < n; i++) {
        cin >> arr[i];
    }
    dp.resize(2);
    dp[0].resize(k+1);
    dp[1].resize(k+1);
    fill(dp[0].begin(), dp[0].end(), -1);
    fill(dp[1].begin(), dp[1].end(), -1);

    bool ans = recurse(TARO, k, n);
    cout << (ans ? "First" : "Second") << endl;



    
    return 0;
}

Measured memory_bytes: 11136
using System;
using System.Linq;

namespace C___Prison
{
    class Program
    {
        static void Main(string[] args)
        {
            var NM = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int N = NM[0], M = NM[1];
            var LiRi = new int[M].Select(_ => Console.ReadLine().Split().Select(int.Parse).ToArray()).ToArray();

            var L = LiRi.Max(x => x[0]);
            var R = LiRi.Min(x => x[1]);

            Console.WriteLine(Math.Max(R - L + 1, 0));
        }
    }
}


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


int main(void){
  int n,i,vn,v[2][100005]={},t,ans;
  
  cin >> n;
  for (i=0;i<n;i++){
    cin >> vn;
    v[i%2][vn]++;
  }
  
  int r[2][2]={},l[2][2]={};
  for (t=0;t<2;t++){
    for (i=0;i<100005;i++){
      if (r[t][0]<v[t][i]){
        r[t][1]=r[t][0];
        r[t][0]=v[t][i];
        l[t][1]=l[t][0];
        l[t][0]=i;
      }else if (r[t][1]<v[t][i]){
        r[t][1]=v[t][i];
        l[t][1]=i;
      }
    }
  }
  
  if (l[0][0]==l[1][0]){
    ans=n-max(r[0][0]+r[1][1],r[0][1]+r[1][0]);
  }else{
    ans=n-r[0][0]-r[1][0];
  }
  
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }
#define dump(x) cerr<<#x<<": "<<x<<endl;
#define bit(k) (1LL<<(k))
typedef long long ll;
typedef pair<int, int> i_i;
typedef pair<ll, ll> l_l;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;
template< typename T1, typename T2 >
ostream &operator<<(ostream &os, const pair< T1, T2 >& p) {
  os << "{" <<p.first << ", " << p.second << "}";
  return os;
}
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; }

const int INF = (ll)1e9;
const ll INFLL = (ll)1e18+1;
const ll MOD = (ll)1e9+7;
const double PI = acos(-1.0);
/*
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const string dir = "DRUL";
*/

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

    ll N;
    cin >> N;
    vec<l_l> v;
    rep(i,N){
        ll X, L;
        cin >> X >> L;
        v.emplace_back(X+L,X-L);
    }
    //終端ソート
    sort(all(v));
    //print(v);
    ll ans = 0;
    ll r = -INFLL;
    for(int i = 0; i < N; i++){
        ll nr = v[i].first;
        ll nl = v[i].second;
        if(r <= nl){
            r = nr;
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 2420
#include<bits/stdc++.h>
    #define ll long long
    #define rep(i,a,b) for(i=a;i<b;i++)
    #define pb push_back
    #define all(v) v.begin(),v.end()
    #define F first
    #define S second
    #define vi vector < ll  int >
    #define CLR(a) memset((a),0,sizeof(a))
    #define mp make_pair
    #define hell 1000000007
    using namespace std;

    #define MAXN 1000005
    int spf[MAXN];
    void sieve()
    {
        spf[1] = 1;
        for (int i=2; i<MAXN; i++)
            spf[i] = i;
        for (int i=4; i<MAXN; i+=2)
            spf[i] = 2;

        for (int i=3; i*i<MAXN; i++)
        {
            if (spf[i] == i)
            {
                for (int j=i*i; j<MAXN; j+=i)

                    if (spf[j]==j)
                        spf[j] = i;
            }
        }
    }


    vector<int> gf(int x)
    {
        vector<int> ret;
        while (x != 1)
        {
            ret.push_back(spf[x]);
            x = x / spf[x];
        }
        return ret;
    }
    int BIT[100050];
    void upd(int x) { ++x;  while(x<=MAXN)  {  BIT[x]++;  x+=(x&-x);  } }
    int cal(int x) {  ++x;  int res=0;  while(x>0)  {  res+=BIT[x];  x-=(x&-x);  } return res; }

    ll mod=hell;
    ll pr( ll x , ll y)
    {
        ll ans=1;
        if(y==0) return ans;
        while(y>1)
        {
            if(y&1) ans*=x;
            x*=x;
            y/=2;
            x%=mod;
            ans%=mod;
        }
        ans*=x;
        ans%=mod;
        return ans;
    }
    ll inv(ll n)
    {
        return pr(n,mod-2);
    }
    ll stoi(string s)
    {
        int n=s.size();
        ll k=0; int i;
        rep(i,0,n)
        {
            k+=s[i]-'0';
            k*=10;
        }
        return k/10;
    }
    string to_string(ll n)
    {  if(!n) return "0";
        string s=""; int a,b;
        while(n>0)
        {
            b=n%10;
            s+=(b+'0');
            n/=10;
        }
        reverse(all(s));
        return s;
    }
  ll invvf[1000500],fact[1000500];
  void pre()
  {
      ll i,j,n=1000050;
      fact[0]=1; fact[1]=1;
      rep(i,2,n) {fact[i]=fact[i-1]*i; fact[i]%=hell;}
      invvf[1]=1; invvf[0]=1;
      rep(i,2,n)
      {
          invvf[i]=inv(fact[i]);
      }

  }
 ll ncr(ll n , ll r)
 {
     ll y=fact[n];
     y*=invvf[r];
     y%=hell;
     y*=invvf[n-r];
     y%=hell;
     return y;
 }


int phi(int n) {
    int result = n;
    for (int i = 2; i * i <= n; i++) {
        if (n % i == 0) {
            while (n % i == 0)
                n /= i;
            result -= result / i;
        }
    }
    if (n > 1)
        result -= result / n;
    return result;
}

void solve()
{
    ll i,j,k,n,m,y=0,c=0,a,b;
    cin>>n>>m;
    if(m>=n) cout<<"unsafe";
    else cout<<"safe";
}
signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t=1;
    //cin>>t;
    while(t--)
        solve();
}


Measured memory_bytes: 3644
#include <stdio.h>
#include<stdio.h>
int main()
{
  char a[10];
  scanf("%s", a);
  a[0] = '2';
  a[1] = '0';
  a[2] = '1';
  a[3] = '8';
  printf("%s", a);
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

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

    ll ans = 0;
    for(int b=k+1; b<=n; ++b){
        for(int a=0; a<=n; a+=b){
            int s = min(n, a+k-1);
            int e = min(n, a+b-1);
            ans += e-s;
        }
        if(k==0) --ans;
    }

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
#include<stdio.h>
#include<string.h>
#include <bitset>

using namespace std;
#define int long long

#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(), (x).end()

template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return; std::cout << e <<" ";}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){std::cout<< e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class... Ts> void DEBUG(T d, Ts... e){if(DEBUG_OUT == false)return;DEBUG(d);DEBUG(e...);}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; abort();}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
//SOLVE

template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

void add(long long &a, long long b) {
    a += b;
    if (a >= MOD) a -= MOD;
}



void solve(void)
{
  int N; cin>>N;
  auto DP =  make_vec<int> (N+1,5,5,5);
  DP[0][0][0][0] = 1;
  for (int n = 0; n < N; n++)
  {
    for (int i = 0; i < 5; i++)
    {
      for (int j = 0; j < 5; j++)
      {
        for (int k = 0; k <  5; k++)
        {
          for (int l = 1; l < 5; l++)
          {
            if(i == 1 && j == 2 && l == 3)continue;
            if(i == 1 && k == 2 && l == 3)continue;
            if(j == 1 && k == 2 && l == 3)continue;
            if(j == 2 && k == 1 && l == 3)continue;
            if(j == 1 && k == 3 && l == 2)continue;
            add(DP[n+1][j][k][l],DP[n][i][j][k]);
          }
          
        }
        
      }
      
    }
    
  }
  int res = 0;
  for (int i = 1; i < 5; i++)
  {
    for (int j = 1; j < 5; j++)
    {
      for (int k = 1; k < 5; k++)
      {
        add(res,DP[N][i][j][k]);
      }
      
    }
    
  }
  cout<<res<<endl;

  
  


  return;
}
int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();

  return 0;
}


Measured memory_bytes: 512
/**
 *  author:   TakeruOkuyama
 *  created:  
**/
#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>;

const int MOD = 1000000007;

int main(){
    string S;
    cin >> S;
    bool N = false, W = false, SS = false, E = false;
    rep(i, S.size()){
        if(S[i] == 'N'){
            N = true;
        }else if(S[i] == 'W'){
            W = true;
        }else if(S[i] == 'S'){
            SS = true;
        }else if(S[i] == 'E'){
            E = true;
        }
    }
    if(N == SS && W == E){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
return 0;}

/**
 * g++ code.cpp
 * ./a.out
 * shift + ctrl + i
**/ 

Measured memory_bytes: 256
n = int(input())
pmax = 0
pmin = 0
mmax = 0
mmin = 0
for i in range(n):
    x, y = map(int, input().split())
    if(i ==0 or pmax < x + y):
        pmax = x+y
    if(i == 0 or pmin > x+y):
        pmin = x+y
    if(i == 0 or mmax < x-y):
        mmax = x-y
    if(i == 0 or mmin > x-y):
        mmin = x-y
print(max(pmax - pmin, mmax - mmin))

Measured memory_bytes: 69780
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<numeric>

#define rep(i,a,n) for(int (i)=(a);(i)<(n);(i)++)
#define rrep(i,a,n) for(int (i)=(a);(i)>=(n);(i)--)

#define INF 1000000000
#define MOD 1000000007

typedef  long long ll;

using namespace std;

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

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

double euclid_distance(double a,double b){
    return sqrt(a*a+b*b);
}

ll gcd(ll  a,ll b){
    ll r;
    if(a < b){
        ll tmp;
        tmp = a;
        a = b;
        b = tmp;
    }
    while(r = a % b){
        a = b;
        b = r;
    }
    return b;
}

void Integer_factorization(long long int b,long long int n){
    long long int a = 2;
    long long int count = 0;
    long long int ans = 1;
    long long int ndash = n;
    if(b == 1) cout << n << endl;
    else{
    while(ndash >= a*a){
        if(n % a  == 0){
            count++;
            n/=a;

        if(count % b == 0){
            ans *= a;
        }
        }else{a++;count = 0;}
    }

    cout<<  ans << endl;
    }
}

ll r_fuct[2000];
ll fuct[2000];

//MOD逆元
void conb(ll n,ll k){
    fuct[0] = 1;
    for(int i = 1;i < k+1;i++){
        fuct[i] *= fuct[i-1]%MOD;
        
        ll b = MOD, u = 1, v = 0;
        ll value = fuct[i];
        while (b) {
            ll t = value / b;
            value -= t * b;
            swap(value, b);
            u -= t * v;
            swap(u, v);
        }
        u %= MOD;
        if (u < 0) u += MOD;
        r_fuct[i] = u;
    }
}

void solve() {
    ll n,k;
    cin >> n;
    vector<ll> a;
    ll ans = 0;
    bool flag = false;
    ll count = 0;
    bool mflag = false;

    for(int i = 0;i<n;i++){
       ll t;
       cin >> t;
       if(t == 0)flag = true;
       if(t < 0) count++;
       a.push_back(t);
    }
    if(count%2 == 1){
        mflag = true;
    }
     
    ll m = MOD;
    for(int i = 0;i < n;i++){
        if(llabs(a[i]) < llabs(m)){
            m = a[i];
            if(a[i] > 0) m*=-1;
        }
    }

    for(int i = 0;i < n;i++){
        ans+=llabs(a[i]);
    }
    if(mflag & !flag) ans+=2*m;
    cout << ans << endl;
   
}

int main() {

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


Measured memory_bytes: 1400
#include<stdio.h>

int num[1000][3];
int score[1000];
int n;

int samenum(int a,int b){
  int i;

  for(i=0;i<n;i++){
    if(i!=a){
      if(num[i][b]==num[a][b]){
	return 1;
      }
    }
  }

  return 0;
}

void input(){
  int i,j;

  scanf("%d",&n);

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

void judge(){
  int i,j;

  for(i=0;i<n;i++){
    for(j=0;j<3;j++){
      if(samenum(i,j)==0)
	score[i]=score[i]+num[i][j];
    }
  }
}

int main(){
  int i;

  for(i=0;i<1000;i++){
    score[i]=0;
  }

  input();
  judge();

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

  return 0;
}

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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> pll;


const ll LongINF=1e13+7;
const int INF=1e9+7;
const int dx[]={0,1,0,-1};
const int dy[]={1,0,-1,0};

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template <class T, class Y>T GCD(T a, Y b){if(a<b){int c=a;a=b;b=c;}if (a % b == 0){return b;}return GCD(b, a % b);}
void clear(queue<pair<int, int>> &q){queue<pair<int, int>> empty;swap(q, empty);} //queueの中身の型は適時変更を忘れない

#define REP(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define rv reverse
#define ALL(a) (a).begin(),(a).end()


int main(){
    ll N,M;
    cin>>N>>M;
    vector<bool>Q(N+2,false);
    vector<int> sum(N+2,0);

    ll WS=0,AS=0;

    rep(i,M){
        ll p;
        string A;
        cin>>p>>A;
        if(A=="AC"&&!Q[p]){
            Q[p]=true;
            AS++;
            WS+=sum[p];
        }
        if(!Q[p]){
            sum[p]++;
        }
    }

    cout<<AS<<endl<<WS<<endl;

    return 0;
}

//a=97,z=122

Measured memory_bytes: 768
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <list>
#include <algorithm>
#include <cmath>
#include <map>

using namespace std;

#define N 2001
#define INFTY (1<<21)

int d[N];
int ans[N];
int n;
int x, y;

void bfs(int s)
{
    queue<int> q;
    q.push(s);
    for (int i = 1; i <= n; i++) d[i] = INFTY;
    d[s] = 0;
    int u;
    while (!q.empty()) {
        u = q.front(); q.pop();
        if (u != n && d[u+1] == INFTY) {
            d[u+1] = d[u] + 1;
            ans[d[u+1]]++;
            q.push(u+1);
        }
        if (u != 1 && d[u-1] == INFTY) {
            d[u-1] = d[u] + 1;
            ans[d[u-1]]++;
            q.push(u-1);
        }
        if (u == x) {
            if (d[y] == INFTY) {
                d[y] = d[u] + 1;
                ans[d[y]]++;
                q.push(y);
            }
        }
        if (u == y) {
            if (d[x] == INFTY) {
                d[x] = d[u] + 1;
                ans[d[x]]++;
                q.push(x);
            }
        }
    }
}

int main()
{
    int i;

    cin >> n >> x >> y;

    for (i = 1; i <= n; i++) {
        bfs(i);
    }

    for (i = 1; i < n; i++) {
        cout << ans[i] / 2 << endl;
    }

    return 0;
}


Measured memory_bytes: 256
N=int(input())
S=str(input())
X=[0]*1000
cnt=0
for i in range(10):
  a=S.find(str(i))
  if a==-1:
    continue
  else:
    for j in range(10):
      b=S[a+1:].find(str(j))
      if b==-1:
        continue
      else:
        for k in range(10):
          c=S[a+b+2:].find(str(k))
          if c==-1:
            continue
          else:
            cnt+=1
print(cnt)

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

int x;
int main() {
	scanf("%d", &x);

	int n = 1;
	while((n + 1) * n / 2 < x) {
		n++;
	}
	printf("%d\n", n);
	return 0;
}


Measured memory_bytes: 128
N = int(input())
h = list(map(int,input().split()))
dp = [0] * (N+1)
dp[2] = abs(h[1]-h[0])
for i in range(3, N+1):
    dp[i] = min(dp[i-1]+abs(h[i-1]-h[i-2]), dp[i-2]+abs(h[i-1]-h[i-3]))
print(dp[N])


Measured memory_bytes: 13928
#include <iostream>
#include <string>
#include <cmath>
#include <ctime>
#include <vector>
#include <algorithm>
#include <cstdlib>
using namespace std;

int main(){
    int N, L;
    cin >> N >> L;
    string S[N];
    for(int i = 0; i < N; i++){
        cin >> S[i];
    
    }

    sort(S, S+N);

    string s;
    for(int i = 0; i < N; i++){
        s += S[i];
    
    }

    cout << s << endl;


}

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

int main() {
  int a, counter = 0;
  cin >> a;
  rep(i, 3) {
    if (a % 10 == 1) {
      counter++;
    };
    a = a / 10;
  };
  cout << counter << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;
int main(){
	string S, T;
	cin >> S >> T;
	vector<char> trans(26, '0');
	vector<int> use(26, 0);
	string::iterator itrs = S.begin();
	string::iterator itrt = T.begin();
	int check = 1;
	for(int i=0;i<(int)S.size();i++){
		if(trans[*(itrs + i) - 'a'] == '0') {
			trans[*(itrs + i) - 'a'] = *(itrt + i);
			if(use[*(itrt + i) - 'a'] == 1) check = 0;
			use[*(itrt + i) - 'a'] = 1;
		}
		else if(trans[*(itrs + i) - 'a'] != *(itrt + i)) {
			check = 0;
		}
	}
	if(check) cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 776
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using P = pair<int, int>;
using vec = vector<int>;
using mat = vector<vector<int>>;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define endl "\n"

constexpr int MOD = 1000000007;
const int INF = 1 << 30;

int main() {
    int n;
    cin >> n;
    vec a(n);
    rep(i, n) cin >> a[i];

    lint res = 0;

    rep(i, n) {
        while (a[i] % 2 == 0) {
            a[i] /= 2;
            res++;
        }
    }

    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
/*
*         ****FOX****
*/
#include <iostream>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <set>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <limits>
//freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#include <utility>
#include <list>
#include <cstdio>
#include<forward_list>
#include<algorithm>
#include<string>
#define Omar_Hafez ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pi 3.1415926536
#define ll long long
#define ull unsigned long long
#define lli long long int
using namespace std;
int main()
{
    Omar_Hafez
   int n; cin >> n;
    vector<int> v(n,0); 
    for (int i = 1; i <(double) n/2; i++)
    {
        for (int j = 1; j <(double) n/2; j++)
        {
            for (int z = 1; z <(double) n/2; z++)
            {
                int res = (i * i) + (j * j) + (z * z) + (i * j) + (j * z) + (i * z);  
                if (res <= n)  v[--res]++;
                else break;
            }
        }
    }
    for (int i = 0; i< v.size(); i++) cout << v[i] << "\n";
    return 0;
}



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

int f(int p, int x){
  return p * (100 + x) / 100;
}

int main(){
  int x, y, s;

  while(cin >> x >> y >> s, x || y || s){
    int res = 0;

    for(int i = 1; i < s; i++){
      for(int j = 1; j < s; j++){
        int sum = f(i, x) + f(j, x);
        if(sum != s) continue;
        res = max(res, f(i, y) + f(j, y));
      }
    }
    cout << res << endl;
  }
}

Measured memory_bytes: 1160
#include "bits/stdc++.h"
#include <chrono>
#include <random>
#include <cstdio>
#define ll long long int
#define endl '\n'
#define pb push_back
#define mp make_pair
#define mod 998244353LL
#define rep(i,n) for(ll i=0;i<n;i++)
#define vi vector <int>
#define vs vector <string>
#define vc vector <char>
#define vl vector <ll>
#define pll pair<ll, ll>
#define pint pair<int, int>
#define S second
#define F first
#define all(c) (c).begin(),(c).end()
using namespace std;
ll power(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll modInverse(ll a){return power(a,mod-2);}
const int N=500001;
ll gcd(ll a, ll b) { if (a == 0) return b; return gcd(b % a, a); } 
ll lcm(ll a, ll b){return a*b/gcd(a, b);}
#define pi 3.14159265358979323846264338
using namespace std; 
ll max(ll a, ll b){ if(a>b)return a;return b;}
ll min(ll a, ll b){ if(a < b) return a;return b;}
ll inf = 100000000000000000;

void solve() 
{
    int n, z, w;
    cin>>n>>z>>w;

    vi a(n);
    rep(i, n) cin>>a[i];
    if(n == 1)
    {
        cout<<abs(w - a[n-1])<<endl;
        return;
    }

    cout<<max(abs(a[n-1] - w), abs(a[n-2] - a[n-1]))<<endl;

}

int main()
{   

    #ifndef ONLINE_JUDGE
        // for getting input from input.txt
        freopen("input.txt", "r", stdin);
        // for writing output to output.txt
        freopen("output.txt", "w", stdout);
    #endif

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int T=1;
    // cin>>T;
    int t=0;
    while(t++<T)
    {
        // cout<<"Case #"<<t<<":"<<' ';
        solve();
        // cout<<'\n';
    }
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}


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

using namespace std;

int main()
{
    int A, B, C;
    cin >> A >> B >> C;
    
    for( int i = A; i < A*B+C; i += A ){
        if( i % B == C ){
            cout << "YES" << endl;
            return 0;
        }
    }
    cout << "NO" << endl;
    
    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++)

int main(){
    string s;
    cin >> s;
    int N = (int)s.size();
    //区間の数を求める
    int cnt = 0;
    char word = s[0];
    for(int i = 0; i < N;){
        if(word == s[i]){
            while(i < N && word == s[i]){
                i++;
            }
            word = s[i];
            cnt++;
        }else{
            i++;
        }
    }
    cout << cnt-1 << endl;
    return 0;
}

Measured memory_bytes: 3708