akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main() {
  int N,O = 0; 
  string S;
  cin >> N;
  for (int i = 0; i < N; i++){
    cin >> S;
    if (S == "Y"){
      O = 1;
      break;
    }
  }
  if (O == 1){
    cout << "Four" << endl;
  }else{
    cout << "Three" << endl;
  }
}

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

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

  int ans = 0;
  for (int i = a; i <= b; i++) {
    if (i/10000 == i%10 && (i/1000)%10 == (i%100)/10) {
      ans += 1;
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
using System;

class lec01_B{
  public static void Main(){
    string[] str = Console.ReadLine().Split(' ');
    int x = int.Parse(str[0]);
    int y = int.Parse(str[1]);
    Console.WriteLine(Gcd(x,y));
  }
  public static int Gcd(int a,int b){
    if(a < b)
      return Gcd(b,a);
      while(b != 0){
        var remainder = a % b;
        a = b;
        b = remainder;
      }
      return a;
  }
}



Measured memory_bytes: 9136
//
//  main.cpp
//  B - Greedy Takahashi
//
//  Created by Hashizo on 2019/12/29.
//  Copyright © 2019 Hashizo. All rights reserved.
//

#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <regex>
#include <cmath>

using namespace std;
 
#undef LONG_MAX
#undef LONG_MIN
 
#define LONG_MAX    9223372036854775807
#define LONG_MIN    (-LONG_MAX  -1)
 
#define ll long long
 
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
 
#define SORT(c) sort((c).begin(), (c).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
int main(int argc, const char * argv[]) {

	ll a,b,k;
	cin >> a >> b >> k;

	if(a > k) {
		a -= k;
	}
	else {
		k -= a;
		a = 0;
		b -= k;
		if (b < 0) {
			b = 0;
		}
	}

	cout << a << " " << b << endl;
	return 0;
}


Measured memory_bytes: 256
n = int(input())
a_list = list(map(int, input().split()))
ai = max(a_list)

a_list.remove(ai)

new_a_list = [abs(ai / 2 - a) for a in a_list]
aj = a_list[new_a_list.index(min(new_a_list))]
    
print(ai, aj) 

Measured memory_bytes: 14428
n = int(input())
a = list(map(int, input().split()))
if n == 0:
    if a[0] == 1:
        print(1)
    else:
        print(-1)
    exit()

tmp = [[1,1]]
for i in range(n+1):
    l,r = tmp[-1]
    if r < a[i]:
        print(-1)
        exit()
    if i != n:
        nl = max(0, l-a[i])
        nr = 2*max(0, r-a[i])
        tmp.append([nl, nr])
ans = 0
node = 0
for i in reversed(range(n+1)):
    ans += a[i]
    l, r = tmp[i]
    r -= a[i]
    l -= a[i]
    l = max(l, 0)
    if node <= r:
        use = node
    else:
        use = r
    ans += use
    node = use + a[i]
print(ans)



Measured memory_bytes: 711600
#include <bits/stdc++.h>
using namespace std;
int n, m, a[200500], mx, flag, Ans;
int b[200500], c[200500], bo[200500], num;
set<int> ss;
int main(){
	scanf("%d%d", &n, &m);
	for(int i = 1; i <= n; i++)
		scanf("%d", &a[i]);
	for(int i = 2; i <= n; i++){
		b[i] = a[i] > a[i - 1] ? 1 : 0;
		c[i] = b[i] ? c[i - 1] + 1 : 0;
		if(c[i] >= m - 1){ 
			num++;
			bo[i] = 1;
		}
	}
	if(num) Ans = 1;

	for(int i = 1; i <= m; i++){
		if(a[i] < mx) flag = 1;
		else mx = a[i];
		ss.insert(a[i]);
	}
	
	if(flag) Ans++;

	for(int j = m + 1; j <= n; j++){
		if(a[j - m] == *(ss.begin()) && a[j] > *(--ss.end())){
			0;
		}
		else if(!bo[j]) Ans++;
		ss.erase(a[j - m]);
		ss.insert(a[j]);
	}
	printf("%d\n", Ans);
	return 0;
}

Measured memory_bytes: 12032
#include <bits/stdc++.h>
using namespace std;
const int SENTINEL = numeric_limits<int>::max();
void merge(vector<int> &A, int left, int mid, int right, long long &cnt) {
  int n1 = mid - left;
  int n2 = right - mid;
  vector<int> L(n1 + 1, 0);
  vector<int> R(n2 + 1, 0);
  for (int i = 0; i < n1; i++)
    L[i] = A[left + i];
  for (int i = 0; i < n2; i++)
    R[i] = A[mid + i];
  L[n1] = R[n2] = SENTINEL;
  int i = 0, j = 0;
  for (int k = left; k <= right - 1; k++) {

    if (L[i] <= R[j])
      A[k] = L[i++];
    else {
      A[k] = R[j++];
      cnt += n1 - i;
    }
  }
}
void merge_sort(vector<int> &A, int left, int right, long long &comp) {
  if (left + 1 < right) {
    int mid = (left + right) / 2;
    merge_sort(A, left, mid, comp);
    merge_sort(A, mid, right, comp);
    merge(A, left, mid, right, comp);
  }
}
int main(int argc, char const *argv[]) {
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<int> v(n);
  for (auto &e : v)
    cin >> e;
  long long cnt = 0;
  merge_sort(v, 0, v.size(), cnt);
  cout << cnt << endl;

  return 0;
}



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

using namespace std;

#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
#pragma GCC optimize("-ffloat-store")

#define fastio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long
#define endl "\n"

#define sz(a) ((int)(a).size())
#define all(v) (v).begin(), (v).end()
#define tr(c, it) for (auto(it) = (c).begin(); (it) != (c).end(); it++)
#define pres(c, val) ((c).find(val) != (c).end())      //
#define cpres(c, val) (find(all(c), val) != (c).end()) //

#define pb push_back
#define mp make_pair
#define F first
#define S second

#define forf(i, a, b) for (int i = (a); i < (b); i++)
#define forb(i, a, b) for (int i = (b); i >= (a); i--)
#define fo(i, n) forf(i, 0, n)
#define fob(i, n) forb(i, 0, n - 1)

typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pair<int, int>> vpii;

const int INF = 9e18;
// const int N = 1e9 + 7;
const int N = 998244353;

const auto start_time = std::chrono::high_resolution_clock::now();

void zark() {
  #ifdef ZARK
  auto end_time = std::chrono::high_resolution_clock::now();
  std::chrono::duration<double> diff = end_time - start_time;
  cerr << "Time Taken : " << diff.count() << "s\n";
  #endif
}

#ifdef ZARK
#include "/home/aranjan/Desktop/CP/header.h"
#else
#define dbg(args...)
#endif

/* ------------------ Actual Coding Starts ------------------ */

void solve() {
  int n,m;
  cin >> n >> m;
  vi h(n);
  fo(i ,n )cin >> h[i];
  vector<vi> g(n);
  fo(i, m) {
    int a, b;
    cin >> a >> b;
    a--,b--;
    if(h[a] <= h[b]) g[a].pb(b);
    if(h[b] <= h[a]) g[b].pb(a);
  }
  int ans = 0;
  fo(i, n) if(g[i].empty()) ans++;
  cout << ans << endl;
}

int32_t main() {
  fastio;
  #ifdef ZARK
  freopen("input.in", "r", stdin);
  #endif

  // freopen("txt.in", "r", stdin);
  // freopen("txt.out", "w", stdout);
  // cout << fixed << setprecision(35);

  solve();
  zark();
  return 0;
}


Measured memory_bytes: 8512
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector> 
#include<limits>
#include<numeric>
#include<type_traits>
#include<math.h>
using namespace std;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define in(x) cin >> x
#define out(str) cout << str << endl

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

int N,mini=1001,maxi=0;

int main(){
    cin>>N;
    int a[N];
    rep(i,N){
        cin>>a[i];
        mini=min(mini,a[i]);
        maxi=max(maxi,a[i]);
    }
    out(maxi-mini);
    return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10000000)
def input():
    return sys.stdin.readline()[:-1]
from bisect import *
from collections import *
from heapq import *
import itertools
import math
INF = 10**9
MOD = 10**9+7

a, b = map(int, input().split())
print(max(0, a-2*b))


Measured memory_bytes: 38256
#include <iostream>
#include <cmath>
#include <vector>
#include <bitset>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <climits>
#include <set>
#include <map>
#include <iomanip>
#include <cassert>
#include <functional>
#include <cstring>

using namespace std;

typedef pair<int, int> P;
#define FOR(i, a, b) for(int (i)=a;(i)<(b);++(i))
#define rep(i, n)  FOR(i,0,n)
#define rrep(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define vsort(v) sort((v).begin(), (v).end());
#define rvsort(v) sort(v.begin(), v.end(),greater<int>());
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define all(c) (c).begin(),(c).end()
#define ll long long
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define vs vector<string>
#define vc vector<char>
#define vvc vector<vector<char>>
#define Print(p) cout<<(p)<<endl
#define _1 first
#define _2 second
#define pb push_back
#define mod 1000000007LL
#define INF 105000000000

const int maxn = 1e5 + 10;



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

	int n;
	cin >> n;

	int a[maxn];
	int tmp;
	rep(i, n)
	{
		cin >> tmp;
		tmp--;
		a[i] = tmp;
	}

	int now=0;
	rep(i, n)
	{
		now = a[now];
		if (now == 1)
		{
			cout << i + 1 << endl;
			return 0;
		}
	}

	cout << -1 << endl;
	return 0;
	
}

Measured memory_bytes: 640
#include<iostream>
#include<bits/stdc++.h>
#define int long long
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
int32_t main()
{
	int l;
	cin>>l;
	double side=l/3.0;
	double res=side*side*side;
	cout.precision(15);
	cout<< fixed <<res;
	
}

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

bool solve(vector<int> &a, int m, int s) {
    if ( m==0 ) {
        return true;
    } else if (m < 0 || s < 0) {
        return false;
    } else {
        return solve(a, m-a[s], s-1) || solve(a, m, s-1);;
    }
}

int main() {
    int n, q;
    cin >> n;
    vector<int> a(n);
    for (int i=0; i<n; i++) cin >> a[i];
    cin >> q;
    vector<int> m(q);
    for (int i=0; i<q; i++) cin >> m[i];
    
    for (int i=0; i<q; i++) {
        if ( solve(a, m[i], n-1) ) {
            cout << "yes" << endl;
        } else {
            cout << "no" << endl;
        }
    } 
}

Measured memory_bytes: 1192
#include<iostream>
using namespace std;
int main(){
    int x,y;
    while(1)
    {
      cin >> x >> y;
      if(x == 0&&y == 0)break;
    
      if(x < y)cout << x << " " << y << endl;
      else cout << y << " " << x << endl;
    }
    return 0;
}


Measured memory_bytes: 3024
#include<bits/stdc++.h>
using namespace std;
#define crap ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
typedef long long int ll;
typedef unsigned long long ull;
typedef std::vector<int> vi;
typedef std::vector<ll> vll;
typedef std::vector<vi > vvi;
typedef std::vector<vll > vvll;
typedef std::pair<int,int> ii;
typedef std::pair< ll, ll > lp;
typedef std::vector<ii> vii;
typedef std::vector<vii > vvii;

#define pb emplace_back 
#define PB pop_back
#define pf push_front
#define PF pop_front
#define mp make_pair
#define ub(a,b) upper_bound(all(a),b)
#define lb(a,b) lower_bound(all(a),b)
#define bs(a,b) binary_search(all(a),b)
#define mem(a,b) memset(a,b,sizeof(a))
#define in(a,n) F(i,0,n-1)cin>>a[i]
#define in1(a,n) F(i,1,n)cin>>a[i]
#define out(a,n) F(i,0,n-1)cout<<a[i]<<"\n";cout<<endl
#define ff first
#define ss second
#define F(i,a,b) for (ll i=a;i<=b;i++)
#define RF(i,a,b) for(ll i=a;i>=b;i--)
#define rep(i,n) F(i,0,n-1)
#define clr(a) (a).clear()
#define rz resize
#define sqr(a) ((a) * (a))
#define sz(a) int((a).size())
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin() ,(a).rend()
#define endl '\n'

#define mod 1000000007

ll add(ll a, ll b){return (a%mod + b%mod)%mod;}
ll sub(ll a , ll b){return (a%mod - b%mod + mod)%mod;}
ll mul(ll a, ll b){return (a%mod * b%mod)%mod;}
ull poww(ull a,ull b){ull res=1;while(b){if(b&1){res*=a;}a=a*a;b>>=1;}return res;}
ll poww(ll a,ll b,ll MOD){ll res=1;while(b){if(b&1){res*=a;res%=MOD;}a=a*a;a%=MOD;b>>=1;}return res;}

#define dbg(x) cout<<#x<<" :: "<<x<<endl;
#define dbg2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<endl;
#define dbg3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<endl;
#define dbg4(x,y,z,w) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\t"<<#w<<" :: "<<w<<endl;

//end of template

const int N = 2e5 + 5;

ll fac[N];
ll ifac[N];

ll ncr(ll n, ll r){
	return mul(fac[n], mul(ifac[r], ifac[n-r]));
}

void pre(){
	ifac[0] = fac[0] = 1;
	F(i, 1, N-1){
		fac[i] = mul(fac[i-1], i);
		ifac[i] = mul(ifac[i-1], poww(i, mod-2, mod));
	}
}

int main(int argc, char const *argv[])
{
	crap;
	ll n, m , k;
	cin >> n >> m >> k; 
	pre();
	ll ans = ncr(n*m -2 , k-2);
	ll d1 = 0, d2 = 0, d = 0;
	vll x, y;
	F(i, 1, n){
		F(j, 1, m){
			x.pb(i);
			y.pb(j);
		}
	}
	sort(all(x));
	sort(all(y));
	ll prev = 0;
	rep(i, sz(x)){
		d1 = add(d1, sub(mul(i, x[i]), prev));
		prev += x[i];
	}
	prev = 0;
	rep(i, sz(y)){
		d2 = add(d2, sub(mul(i, y[i]), prev));
		prev += y[i];
	}
	d = add(d1, d2);
	ans = mul(ans, d);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 6756
#include <iostream>
using namespace std;
int main()
{
	int s;
	int h,m;
	 cin>>s;
      	m=s/60;
	    h=m/60;
	    s=s%60;
	    m=m%60;
	
     cout<<h<<":"<<m<<":"<<s<<endl;
    
    return 0;
}


Measured memory_bytes: 3100
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>
#include <time.h>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = (1LL << 31) - 1;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1
#define MAX_N 100100 * 3

int h, w;

string s[100];
bool used[100][100];
bool F[100][100][2];

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

void solve(int y, int x, int f) {
	used[y][x] = 1;
	F[y][x][f] = 1;
	REP(i, 4) {
		int ny = y + dy[i], nx = x + dx[i];
		if (used[ny][nx])continue;
		if (ny >= 0 && ny < h&&nx >= 0 && nx < w) {
			if (f == 0) {
				if (s[ny][nx] != 'B') {
					solve(ny, nx, f);
				}
			}
			else {
				if (s[ny][nx] != 'W') {
					solve(ny, nx, f);
				}
			}
		}
	}
}

int main() {
	while (cin >> w >> h&&h + w) {
		REP(i, 100)REP(j, 100) {
			used[i][j] = 0;
			REP(k, 2)F[i][j][k] = 0;
		}
		REP(i, h)cin >> s[i];
		REP(k, 2) {
			REP(i, 100)REP(j, 100) {
				used[i][j] = 0;
			}
			REP(i, h) {
				REP(j, w) {
					if (used[i][j])continue;
					if (k == 0 && s[i][j] == 'W') {
						solve(i, j, k);
					}
					else if (k == 1 && s[i][j] == 'B') {
						solve(i, j, k);
					}
				}
			}
		}
		//REP(I, h) {
		//	REP(J, w) {
		//		cout << F[I][J][0] << " ";
		//	}
		//	cout << endl;
		//}
		//cout << endl;
		//REP(I, h) {
		//	REP(J, w) {
		//		cout << F[I][J][2] << " ";
		//	}
		//	cout << endl;
		//}
		int ans[2] = {};
		REP(i, h) {
			REP(j, w) {
				if (s[i][j] != '.')continue;
				if (F[i][j][0] == 1 && F[i][j][1] == 0) {
					ans[0]++;
				}
				else if (F[i][j][0] == 0 && F[i][j][1] == 1) {
					ans[1]++;
				}
			}
		}
		cout << ans[1] << " " << ans[0] << endl;
	}
}

Measured memory_bytes: 3404
#include <fstream>
#include <vector>

using namespace std;

//ifstream cin("tema.in");
//ofstream cout("tema.out");

int main() {
    //freopen("tema.in", "r", stdin);
    //freopen("tema.out", "w", stdout);
    int x, y;
    scanf("%d%d", &x, &y);
    if (!x) {
        if (y > 0)
            printf("%d\n", y);
        else
            printf("%d\n", -y + 1);
        return 0;
    }
    if (!y) {
        if (x < 0)
            printf("%d\n", -x);
        else
            printf("%d\n", x + 1);
        return 0;
    }
    if (x < y)
        if (x > 0 || y < 0)
            printf("%d\n", y - x);
        else
            if (-x < y)
                printf("%d\n", y + x + 1);
            else
                printf("%d\n", -x - y + 1);
    else
        if (x < 0)
            printf("%d\n", -y + x + 2);
        else
            if (y > 0)
                printf("%d\n", x - y + 2);
            else
                if (x > -y)
                    printf("%d\n", x + y + 1);
                else
                    printf("%d\n", -y - x + 1);
    return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<climits>
#include<vector>
#include<list>
#include<functional>
#include<algorithm>
#include<string>
#include<cmath>
#include<complex>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
#define INF (int)1e9
#define INFL (ll)1e11
using namespace std;
typedef long long ll;
typedef pair<int, int> P;



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

	int A, B;
	cin >> A >> B;
	bool yes = false;
	if (A % 2 == 1 && B % 2 == 1) yes = true;
	if (yes) cout << "Yes\n";
	else cout << "No\n";

	return 0;
}

Measured memory_bytes: 256
N = int(input())
s = input()
tgt = []
res = 0
for i in range(0,1000):
    tgt = []
    if i <= 99:
        tgt.append('0')
    else:
        tgt.append(str(i//100))
    if i <= 9:
        tgt.append('0')
    else:
        tgt.append(str((i%100)//10))
    tgt.append(str(i%10))
    #print(tgt)
    now = 0
    if tgt[0] in s:
        t1 = s.index(tgt[0])
        if tgt[1] in s[t1+1:]:
            t2 = s[t1+1:].index(tgt[1])
            if tgt[2] in s[t1+t2+2:]:
                t3 = s[t1+t2+2:].index(tgt[2])
                res += 1
                #print(tgt)
print(res)


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

typedef struct node{
  int key;
  struct node *next, *pre;
} node;

node *primal;

node* search(int);
void init(void);
void insert(int);
void printlist(void);
void delnode(node *temp);
void delete_first(void);
void delete_last(void);
void delete_key(int);

int main(){
  int key, n ,i ,size = 0;
  char order[20];

  scanf("%d", &n);

  init();

  for(i = 0; i < n; i++){
    scanf("%s%d", order, &key);
    
    if(order[0] == 'i')
      insert(key);

    else if(order[0] == 'd'){
      if(strlen(order) > 6){
        if(order[6] == 'F')
          delete_first();
        else if(order[6] == 'L')
          delete_last();
      }
      else
        delete_key(key);
    }
  }

  printlist();
  
  return 0;
}

node* search(int key){
  node *temp;
  temp = primal -> next;

  while(temp != primal && temp -> key != key)
    temp = temp -> next;

  return temp;
}

void init(){
  primal = (node *)malloc(sizeof(node));
  primal -> next = primal;
  primal -> pre = primal;
}

void insert(int key){
  node *x;
  x = (node *)malloc(sizeof(node));
  x -> key = key;
  x -> next = primal -> next;
  x -> pre = primal;
  primal -> next -> pre = x;
  primal -> next = x;
  }
  
  void printlist(){
  node *temp = primal -> next;
  int i = 0;

  while(1){
    if(temp == primal)
      break;

    if(i != 0)
      printf(" ");

    printf("%d", temp -> key);
    temp = temp -> next;
    i++;
  }
  printf("\n");
}

void delnode(node *x){
  if(x == primal)
    return;

  x -> pre -> next = x -> next;
  x -> next -> pre = x -> pre;
  free(x);
}

void delete_first(){
  delnode(primal -> next);
}

void delete_last(){
  delnode(primal -> pre);
}

void delete_key(int key){
  delnode(search(key));
}


Measured memory_bytes: 32996
#include <iostream>
#include <cstdio>

using namespace std;

int main()
{
    int a,b,c;
    while(cin>>a>>b)
    {

        if(a%2==0||b%2==0)
            printf("No\n");
        else
        {
            int flag = 0;
            for(int i=1;i<=3;i++)
            {
                int tp = i*b*a;
                if(tp%2==1)
                {
                    printf("Yes\n");
                    flag = 1;
                    break;
                }
            }
            if(flag == 0)
                printf("No\n");
        }
    }
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef pair<int, int> pii;
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define vv(type, c, m, n, i) vector<vector<type>> c(m, vector<type>(n, i))
#define mat(type, c, m, n) vector<vector<type>> c(m, vector<type>(n));for(auto& r:c)for(auto& i:r)cin>>i;
#define rep(i,a,n) for(int i=(a), i##_len=(n); i<i##_len; ++i)
#define rrep(i,a,n) for(int i=(a), i##_len=(n); i>i##_len; --i)
#define each(x,y) for(auto &(x):(y))
#define var(type, ...)type __VA_ARGS__;Scan(__VA_ARGS__);
template<typename T> void Scan(T& t) { cin >> t; }
template<typename First, typename...Rest>void Scan(First& first, Rest&...rest) { cin >> first; Scan(rest...); }
#define vec(type, c, n) vector<type> c(n);for(auto& i:c) cin>>i;
#define len(x) ((int)(x).size())
#define mp make_pair
#define eb emplace_back
#define em emplace
#define pb pop_back
#define fi first
#define se second
#define get(a, i) get<i>(a)
#define bit_count __builtin_popcount
#define mt make_tuple
inline string zero(int a,string s,char c='0'){return string(a-len(s),c)+s;}
inline string zero(int a,int t,char c='0'){return zero(a, to_string(t), c);}
inline string zero(int a,ll t,char c='0'){return zero(a, to_string(t), c);}
#define mini min_element
#define maxi max_element
#define sum accumulate
#define chmax(a,b) if(a<b)a=b
#define chmin(a,b) if(a>b)a=b
template <class T> inline void print(T t){cout << t << '\n';}
template <class H, class... T> inline void print(H h, T... t){cout << h << " ";print(t...);}
#define MAX int(1e5+10)
int n, a[MAX], b[MAX], c[MAX];
void solve() {
	cin >> n;
	rep(i, 0, n) cin >> a[i] >> b[i] >> c[i];
	rep(i, 1, n) {
		a[i] += max(b[i - 1], c[i - 1]);
		b[i] += max(a[i - 1], c[i - 1]);
		c[i] += max(b[i - 1], a[i - 1]);
	}
	print(max({a[n - 1], b[n - 1], c[n - 1]}));
}
int main() {
	solve();
	return 0;
}


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

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  long long t1, t2;
  cin >> t1 >> t2;
  long long a1, a2;
  cin >> a1 >> a2;
  long long b1, b2;
  cin >> b1 >> b2;
  if (t1 * a1 + t2 * a2 == t1 * b1 + t2 * b2) {
    cout << "infinity\n";
    return 0;
  }
  if (t1 * a1 + t2 * a2 > t1 * b1 + t2 * b2) {
    swap(a1, b1);
    swap(a2, b2);
  }
  if (a1 < b1) {
    cout << "0\n";
    return 0;
  }
  long long d = (t1 * b1 + t2 * b2) - (t1 * a1 + t2 * a2);
  auto chk = [&](long long mid) {
    return d * mid + t1 * b1 <= t1 * a1;
  };
  long long ok = 0, ng = 1e18 / d;
  while (ng - ok > 1) {
    long long mid = (ok + ng) / 2;
    (chk(mid) ? ok : ng) = mid;
  }
  long long res = 2 * ok + 1;
  res -= d * ok + t1 * b1 == t1 * a1;
  cout << res << '\n';
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <stack>
#include <queue>
typedef long long ll;

using namespace std;

int main() {
    int n;
    cin >> n;
    
    vector<double> v(n);
    for(int i = 0; i < n; i++) {
        cin >> v[i];
    }
    
    double sum = 0.0;
    for(int i = 0; i < n; i++) {
        sum += 1.0 / v[i];
    }
    
    cout << setprecision(8) << 1.0 / sum << endl;
    
    return 0;
}



Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        if(s.equals("AAA") ||s.equals("BBB")){
            System.out.println("No");
        }else{
            System.out.println("Yes");
        }
    }
}

Measured memory_bytes: 35776
// ctuple.cpp
#include <bits/stdc++.h>
#define INF (1<<30)
#define MOD 1000000007
#define l_ength size
using ll = long long;
using namespace std;

int main(){
	int n, m; cin >> n >> m;
	vector<tuple<int, int, int>> vt(m);
	for( int i = 0; i < m; ++i ){
		int x, y; cin >> x >> y;
		get<0>(vt[i]) = y;
		get<1>(vt[i]) = x-1;
		get<2>(vt[i]) = i;
	}
	vector<int> stadt(n, 0);
	sort( vt.begin(), vt.end() );
	vector<tuple<int, int, int>> result(m);
	for( int i = 0; i < m; ++i ){
		get<0>(result[i]) = get<2>(vt[i]);
		get<1>(result[i]) = get<1>(vt[i]);
		get<2>(result[i]) = stadt.at(get<1>(vt[i]));
		++stadt[get<1>(vt[i])];
	}
	sort( result.begin(), result.end() );
	for( int i = 0; i < m; ++i ){
		printf("%06d", get<1>(result[i])+1);
		printf("%06d", get<2>(result[i])+1);
		printf("\n");
	}
	return 0;
}

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

namespace AtCoder
{

    static class Program
    {
        static void Main()
        {
            int A;int B;
            Multi(out A, out B);
            string S = GetStr();

            var ans = true;
            if (S[A] != '-') ans = false;
            if (S.Count(c => c == '-') != 1) ans = false;
            Console.WriteLine(ans.YesNo());
            Console.ReadKey();
        }

        static void Solve()
        {

        }


        static public string GetStr() { return Console.ReadLine().Trim(); }
        static public int GetInt() { return int.Parse(Console.ReadLine()); }
        static public long GetLong() { return long.Parse(Console.ReadLine()); }
        static public string[] GetStrArray() { return Console.ReadLine().Split(' '); }
        static public int[] GetIntArray() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
        static public long[] GetLongArray() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
        static public char[] GetCharArray() { return Console.ReadLine().Split(' ').Select(char.Parse).ToArray(); }
        static public List<double> GetDoubleList() { return Console.ReadLine().Split(' ').Select(double.Parse).ToList(); }
        static public void WriteObjects<T>(IEnumerable<T> values) { foreach (var o in values) { Console.Write(o + " "); } }
        static string yesno(this bool b) { return b ? "yes" : "no"; }
        static string YesNo(this bool b) { return b ? "Yes" : "No"; }
        static string YESNO(this bool b) { return b ? "YES" : "NO"; }

        static bool eq<T, U>() => typeof(T).Equals(typeof(U));
        static T ct<T, U>(U a) => (T)Convert.ChangeType(a, typeof(T));
        static T cv<T>(string s) => eq<T, int>() ? ct<T, int>(int.Parse(s))
                           : eq<T, long>() ? ct<T, long>(long.Parse(s))
                           : eq<T, double>() ? ct<T, double>(double.Parse(s))
                           : eq<T, char>() ? ct<T, char>(s[0])
                                             : ct<T, string>(s);
        static void Multi<T>(out T a) => a = cv<T>(GetStr());
        static void Multi<T, U>(out T a, out U b)
        {
            var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]);
        }
        static void Multi<T, U, V>(out T a, out U b, out V c)
        {
            var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]); c = cv<V>(ar[2]);
        }
        static void Multi<T, U, V>(out T a, out U b, out V c, out V d)
        {
            var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]); c = cv<V>(ar[2]); d = cv<V>(ar[3]);
        }
    }
}

Measured memory_bytes: 11348
n=int(input())
inp = list(map(int,input().split()))
inp.sort(reverse=True)
ans=inp[0]
x=len(inp)-1
flag=0
i=1
while x>1:
    if flag==0 or flag==1:
        ans+=inp[i]
        flag+=1
    if flag==2:
        flag=0
        i+=1
    x-=1
print (ans)

Measured memory_bytes: 31720
int main(void){
	int a[10],b[2],n,i,max,index;

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

		max = a[0];

		for(i=0; i<10; i++){

			if(a[i] > max){
				max = a[i];
				index = i;
			}
		}
		a[index] = 0;
		b[n] = max;
	}

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

	return 0;

}

Measured memory_bytes: 600
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
void _main()
{
    int A, B;
    cin >> A >> B;
    cout << (A + B) % 24 << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <type_traits>

using namespace std;

int gcd(int a, int b){
  return b ? gcd(b, a%b) : a;
}
int main(int argc, const char * argv[]) {
  int n;
  cin >> n;
  vector<int> a(n);
  vector<int> left(n+1, 0), right(n+1,0);
  for(int i = 0; i < n; i++){
    cin >> a[i];
  }
  for(int i = 0; i < n; i++){
    left[i+1] = gcd(left[i], a[i]);
  }
  for(int i = n-1; i >= 0; i--){
    right[i] = gcd(right[i+1], a[i]);
  }
  
  int res = 0;
  for(int i = 0; i < n; i++){
    int l = left[i];
    int r = right[i+1];
    res = max(res, gcd(l,r));
  }
  cout << res << endl;
  return 0;
}


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

int main() {
  int n;
  cin>>n;
  long long int ans=0;
  vector<int> count(n+1);
  for(int i=1;i<=n;i++){
  count[i]=i;
  }
  for(int i=1;i<=n;i++){
  if(count[i]%3==0){
    count[i]=0;
  }else if(count[i]%5==0){
  count[i]=0;
  }
  

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


Measured memory_bytes: 7060
#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int Q;
ll X[303];
ll ma;
int P[7]={2,3,5,7,11,13,17};
int R[7]={8,5,3,2,2,2,2};
int V[7]={0,0,0,0,0,0,0};

void hoge(ll m) {
	ll tot=0;
	int i,j,k;
	ll cnt[303]={};
	
	for(i=1;i<=300;i++) {
		int x=i;
		int ng=0;
		FOR(j,7) {
			FOR(k,V[j]) if(x%P[j]==0) x/=P[j];
			if(x%P[j]==0) ng=1;
		}
		if(ng==0) {
			if(x==1) tot+=X[i];
			else cnt[x]+=X[i];
		}
	}
	
	for(i=1;i<=300;i++) tot+=max(0LL,cnt[i]);
	ma=max(ma,tot);
}

void dfs(int cur,ll mul) {
	
	if(cur==7) {
		hoge(mul);
		return;
	}
	
	dfs(cur+1,mul);
	if(R[cur]) {
		R[cur]--;
		V[cur]++;
		dfs(cur,mul*P[cur]);
		V[cur]--;
		R[cur]++;
	}
	
}

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>Q;
	FOR(i,Q) {
		cin>>x>>y;
		X[x]+=y;
	}
	
	dfs(0,1);
	cout<<ma<<endl;
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 384
#include <stdio.h>

int main(void){

  char s[100000+1];
  scanf("%s", s);
  for (int i = 0; i < 100000+1; i += 2) {
    if (s[i] < 'a' || s[i] > 'z') {
      break;
    }
    printf("%c", s[i]);
  }
  printf("\n");

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int H,W;
int S[1405][1405];

int mini(int a,int b,int c){
    if(a<=b){
        if(a<=c) return a;
        else{
            return c;
        }
    }

    else{
        if(b>=c) return c;
        else return b;
    }
}

int main(){
    scanf("%d %d",&H,&W);
    int value, maxSpace = 0;
    for(int i=0;i<H;++i){
        for(int j=0;j<W;++j){
            scanf("%d",&value);
            if(value==0){
                S[i][j] = 1;
                maxSpace = 1;
            }
            else S[i][j] = 0;
        }
    }
    for(int i=1;i<H;++i){
        for(int j=1;j<W;++j){
            if(S[i][j]!=0){
                S[i][j] = mini(S[i-1][j-1],S[i-1][j],S[i][j-1])+1;
                if(S[i][j]>maxSpace) maxSpace = S[i][j];
            }
        }
    }

    printf("%d\n",maxSpace*maxSpace);
}



Measured memory_bytes: 10812
#include <iostream>
#include <cstdio>

using namespace std;

bool onPaper(int x, int y) {
  return (0 <= x && x <= 9 &&
          0 <= y && y <= 9);
}

void smallDrop(int x, int y, int p[][10]) {
  if (onPaper(x-1, y))
    p[x-1][y]++;
  if (onPaper(x+1, y))
    p[x+1][y]++;
  if (onPaper(x, y-1))
    p[x][y-1]++;
  if (onPaper(x, y+1))
    p[x][y+1]++;
}

void middleDrop(int x, int y, int p[][10]) {
  smallDrop(x, y, p);
  if (onPaper(x-1, y-1))
    p[x-1][y-1]++;
  if (onPaper(x-1, y+1))
    p[x-1][y+1]++;
  if (onPaper(x+1, y-1))
    p[x+1][y-1]++;
  if (onPaper(x+1, y+1))
    p[x+1][y+1]++;
}

void bigDrop(int x, int y, int p[][10]) {
  middleDrop(x, y, p);
  if (onPaper(x-2, y))
    p[x-2][y]++;
  if (onPaper(x+2, y))
    p[x+2][y]++;
  if (onPaper(x, y-2))
    p[x][y-2]++;
  if (onPaper(x, y+2))
    p[x][y+2]++;
}

int main(int argc, char *argv[]) {
  int paper[10][10] = {0};
  int x, y, size;

  while (scanf("%d,%d,%d", &x, &y, &size) != -1) {
    paper[x][y]++;
    if (size == 1)
      smallDrop(x, y, paper);
    else if (size == 2)
      middleDrop(x, y, paper);
    else
      bigDrop(x, y, paper);
  }

  int white, black;
  white = black = 0;
  for (int i = 0; i < 10; i++)
    for (int j = 0; j < 10; j++)
      if (paper[i][j] == 0)
        white++;
      else if (black < paper[i][j])
        black = paper[i][j];

  cout << white << endl;
  cout << black << endl;
  return 0;
}

Measured memory_bytes: 1208
# -*- coding: utf-8 -*-
import sys
import numpy as np

def get_num():
    return int(input())


def get_nums(n):
    res = [0 for _ in range(n)]
    for i in range(n):
        res[i] = int(input())
    return res


def get_numbers():
    return map(int, input().split())


n = get_num()
costs = get_nums(5)

max_time = 0
for cost in costs:
    max_time = max(max_time, int(np.ceil(n / cost)))

print(max_time + 4)

Measured memory_bytes: 22304
N, W = map(int, input().split())

M = 100000
dp = [-1] * (M + 1)
dp[0] = W
for _ in range(N):
    w, v = map(int, input().split())
    for i in range(M, -1, -1):
        if dp[i] == -1:
            continue
        if dp[i + v] < dp[i] - w:
            dp[i + v] = dp[i] - w

for i in range(M, -1, -1):
    if dp[i] != -1:
        print(i)
        break


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

using namespace std;

bool prep(string s1,string s2,int n1){
    for(int i=0;i<n1;i++){
        if(s1[i]!=s2[i]){
            return false;
        }
    }
    return true;
}

int main(){
    string s1,s2;
    cin>>s1>>s2;
    int n1=s1.length();
    int n2=s2.length();
    if(n2==n1+1&&prep(s1,s2,n1)){
        cout<<"Yes";
    }else{
        cout<<"No";
    }
    return 0;
}




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

const int N = 200010;
int n, a[26];
long long z;
char s[N];

int main()
{
	scanf("%s", s);
	n = strlen(s);
	for (int i = 0; i < n; i++) a[s[i] - 'a']++;
	for (int i = 0; i < 26; i++)
		for (int j = i + 1; j < 26; j++) z += (long long) a[i] * a[j];
	printf("%lld", z + 1);
	return 0;
}

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

using namespace std;
#define K 400001

int a[K], n, l;

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

	int ok = -1;
	
	for (int i = 1; i < n; i++) {
		int z = a[i] + a[i + 1];
		
		if (z >= l) {
			ok = i;	
		}
	}
	
	if (ok == -1) {
		puts("Impossible");
		return 0;	
	}
	
	puts("Possible");
	for (int i = 1; i < ok; i++) printf("%d\n", i);
	
	for (int i = n - 1; i > ok; i--) printf("%d\n", i);
	
	printf("%d\n", ok);
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef long long ll;
typedef double db;
typedef pair<int,int> PII;
typedef vector<int> VI;

int main() {
	ll n,k;
	scanf("%lld%lld",&n,&k);
	n%=k;
	printf("%lld\n",min(n,abs(n-k)));
	return 0;
}

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

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

Measured memory_bytes: 3636
n=int(input())
l=[[int(i) for i in input().split()] for _ in range(n)]

a,b,c=0,0,0
for x in range(n):
    pa,pb,pc=l[x]
    a,b,c=pa+max(b,c),pb+max(a,c),pc+max(b,a)

print(max(a,b,c))

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

const int INF = 1000000000;
int D;
long long int G;
vector<int> p(10), c(10);
vector<long long int> x(10);
int C =INF;

void que(int, int, vector<bool>);

int main() {
    cin >> D >> G;
    for(int i=0; i<D; ++i) {
        cin >> p[i] >> c[i];
        x[i] = p[i]*100*(i+1) + c[i];
    }
    vector<bool> checked(D, false);
    que(0, 0, checked);
    cout << C << endl;
}

void que(int sum, int i, vector<bool> checked) {
    int k;
    for(int j=0; j<D; ++j) {
        if(!checked[D-1-j]) {
            k = D-1-j;
            break;
        }
    }
    int r;
    if(G>sum) r = ((G-sum) + 100*(1+k) -1 )/(100*(1+k));
    else r=0;
    if(r < p[k]) {
        int l=0;
        for(int g = 0; g<D; ++g) {
            if(checked[g]) {
                l += p[g];
            }
        }
        l += r;
        if(C>l) {
            C=l;
        }
    }
    if(i==D){
        return;
    }
    
    que(sum, i+1, checked);
    sum += x[i];
    checked[i] = true;
    que(sum, i+1, checked);
    return;
}

Measured memory_bytes: 256
///...................SUBHASHIS MOLLICK...................///
///.....DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING....///
///.............ISLAMIC UNIVERSITY,BANGLADESH.............///
///....................SESSION-(14-15)....................///
#include<bits/stdc++.h>
using namespace std;
#define sf(a) scanf("%d",&a)
#define sf2(a,b) scanf("%d %d",&a,&b)
#define sf3(a,b,c) scanf("%d %d %d",&a,&b,&c)
#define pf(a) printf("%d",a)
#define pf2(a,b) printf("%d %d",a,b)
#define pf3(a,b,c) printf("%d %d %d",a,b,c)
#define sfl(a) scanf("%lld",&a)
#define sfl2(a,b) scanf("%lld %lld",&a,&b)
#define sfl3(a,b,c) scanf("%lld %lld %lld",&a,&b,&c)
#define pfl(a) printf("%lld",a)
#define pfl2(a,b) printf("%lld %lld",a,b)
#define pfl3(a,b,c) printf("%lld %lld %lld",a,b,c)
#define nl printf("\n")
#define   timesave              ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll long long
#define pb push_back
#define MPI map<int,int>mp;
#define fr(i,n) for(i=0;i<n;i++)
#define fr1(i,n) for(i=1;i<=n;i++)
#define frl(i,a,b) for(i=a;i<=b;i++)
#define tz 100000
#define clr0(a) memset(a,0,sizeof(a))
#define clr1(a) memset(a,-1,sizeof(a))
/*primes in range 1 - n
1 - 100(1e2) -> 25 pimes
1 - 1000(1e3) -> 168 primes
1 - 10000(1e4) -> 1229 primes
1 - 100000(1e5) -> 9592 primes
1 - 1000000(1e6) -> 78498 primes
1 - 10000000(1e7) -> 664579 primes
large primes ->
104729 1299709 15485863 179424673 2147483647 32416190071 112272535095293 48112959837082048697
*/
//freopen("Input.txt","r",stdin);
//freopen("Output.txt","w",stdout);
//const int fx[]={+1,-1,+0,+0};
//const int fy[]={+0,+0,+1,-1};
//const int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};   // Kings Move
//const int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};  // Kings Move
//const int fx[]={-2, -2, -1, -1,  1,  1,  2,  2};  // Knights Move
//const int fy[]={-1,  1, -2,  2, -2,  2, -1,  1}; // Knights Move
main()
{
    timesave;
    int n,m,mp[500]={0},diff,diff1,a,mn=10000;
    cin>>n>>m;
    for(int i=1;i<=m;i++)
    {
       cin>>a;
       mp[a]=1;
    }
    for(int i=0;i<=200;i++)
    {
        if(mp[i]==1)
            continue;
        else
        {
            diff=abs(i-n);
            if(diff<mn)
            {
                mn=diff;
                diff1=i;
            }
        }
    }
    cout<<diff1<<endl;
}




Measured memory_bytes: 3644
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(n);i++)
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
const ll INF=1e18;
const int MOD=1e9+7;
const double pi=acos(-1);


int main(){
  int n,m;
  cin >> n;
  map<string,int>blue;
  map<string,int>red;
  rep(i,n){
    string s;
    cin >> s;
    blue[s]++;
  }
  cin >> m;
  rep(i,m){
    string t;
    cin >> t;
    red[t]++;
  }
  int ans=0;
  for(auto b:blue){
    ans=max(ans,b.second-red[b.first]);
  }
  cout << ans << endl;
    
}


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

#define pb push_back
#define pob pop_back
#define mp make_pair
#define f first
#define s second

typedef long long ll;
const ll INF = 1e18;
const ll mod = 1e9 + 7;

ll lcm(ll c,ll d){
	return (c*d)/__gcd(c,d);
}

void solve(){
	ll a,b,c,d;
	cin>>a>>b>>c>>d;
	ll ans=0;
	if(c != 1 && d !=1 ){
		ans= (b - b/c - b/d + b/lcm(c,d));
		if(a != 1) ans -= ((a-1) - (a-1)/c - (a-1)/d + (a-1)/lcm(c,d));
	}
	cout<<ans<<"\n";
}

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define isYES(x) printf("%s\n",(x) ? "YES" : "NO")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define isYes(x) printf("%s\n",(x) ? "Yes" : "No")
#define isIn(x,y,h,w) (x >= 0 && x < h && y >= 0 && y < w)

#define int long long
//using ll = long long;
using P = pair<int,int>;

ostream &operator<<(ostream &os,const P &p){ return os << "(" << p.first << "," << p.second << ")"; }
template<class T>
ostream &operator<<(ostream &os,const vector<T> &v){
	for(int i = 0;i < v.size();i++) os << (i ? "," : "[") << v[i];
	os << "]";
	return os;
}

template<class T> T &chmin(T &a,const T &b){ return a = min(a,b); }
template<class T> T &chmax(T &a,const T &b){ return a = max(a,b); }

const int INF=1e+18;
const double EPS=1e-9;
const int MOD=998244353;

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

signed main(){
	using P = pair<int,int>;
	int n;
	cin >> n;
	vector<P> vecUp,vecDown;
	for(int i = 0;i < n;i++){
		string s;
		cin >> s;
		int cnt = 0,mi = 0;
		for(int j = 0;j < s.length();j++){
			if(s[j] == '(') cnt++;
			else cnt--;
			mi = min(mi,cnt);
		}
		if(cnt >= 0) vecUp.emplace_back(-mi,cnt - mi);
		else vecDown.emplace_back(-mi,cnt - mi);
	}
	sort(vecUp.begin(),vecUp.end());
	sort(vecDown.begin(),vecDown.end(),[](const P &p1,const P &p2){
		return p1.second > p2.second;
	});
	int cnt = 0,mi = 0;
	for(P p : vecUp){
		cnt -= p.first;
		mi = min(mi,cnt);
		cnt += p.second;
	}
	for(P p : vecDown){
		cnt -= p.first;
		mi = min(mi,cnt);
		cnt += p.second;
	}
	isYes(!cnt && mi >= 0);
}

Measured memory_bytes: 19040
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;

int main(){
  ll n,a,b;
  cin>>n>>a>>b;
  
  ll diff = b-a;
  if(diff%2==0)
  {
    cout<<diff/2ll<<endl;
  }
  else{
        
        ll ans1 = (a)+diff/2ll;
        ll ans2 = (n-b+1)+diff/2ll;
        cout<<min(ans1,ans2)<<endl;
  }

}


Measured memory_bytes: 256
S = input()
ans = 0
for i in range(2**(len(S)-1)):
    s = S
    for j in range(len(S)-1):
        if (i>>j) & 1:
            s = s[:j-len(S)+1]+'+'+s[j-len(S)+1:]
    ans += eval(s)
print(ans)


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

#define EQ(a,b) (abs((a)-(b)) < EPS)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define fs first
#define sc second
#define pb push_back
#define sz size()
#define all(a) (a).begin(),(a).end()

using namespace std;
typedef double D;
typedef complex<D> P;
typedef pair<P,P> Line;
typedef vector<P> Poly;

const D EPS = 1e-8;
const D PI = acos(-1);
const D sq2 = 1.0/sqrt(2.0);

inline D dot(P x, P y){return real(conj(x)*y);}
inline D cross(P x, P y){return imag(conj(x)*y);}

int ccw(P a,P b,P c){
  b -= a;c -= a;
  if (cross(b,c)>EPS) return 1;   //counter clockwise
  if (cross(b,c)<-EPS) return -1; //clockwise
  if (dot(b, c)<-EPS) return 2;   //c--a--b on line
  if (abs(b)+EPS<abs(c)) return -2;   //a--b--c on line
  return 0;                       //on segment
}

inline bool is_cp(Line a,Line b){
  if(ccw(a.fs,a.sc,b.fs)*ccw(a.fs,a.sc,b.sc)<=0)
    if(ccw(b.fs,b.sc,a.fs)*ccw(b.fs,b.sc,a.sc)<=0)return true;
  return false;
}

int main(){
  D Time,R;
  int L,M,N;
  P pm[55], vm[55], pg[55], vg[55];
  D tm[55], tg[55];
  Poly obj[55];

  cin.tie(0);
  std::ios::sync_with_stdio(false);
  while(cin >> Time >> R){
    if(EQ(Time,0) && EQ(R,0))break;

    cin >> L;
    rep(i,L){
      D x,y;
      cin >> x >> y >> tm[i];
      pm[i] = P(x,y);
    }
    rep(i,L-1)vm[i] = (pm[i+1] - pm[i]) / (tm[i+1] - tm[i]);

    cin >> M;
    rep(i,M){
      D x,y;
      cin >> x >> y >> tg[i];
      pg[i] = P(x,y);
    }
    rep(i,M-1)vg[i] = (pg[i+1] - pg[i]) / (tg[i+1] - tg[i]);

    cin >> N;
    rep(i,N){
      D xl, yb, xr, yt;
      cin >> xl >> yb >> xr >> yt;
      if(xl > xr)swap(xl,xr);
      if(yb > yt)swap(yb,yt);

      obj[i].clear();
      obj[i].pb(P(xl,yb)); obj[i].pb(P(xr,yb));
      obj[i].pb(P(xr,yt)); obj[i].pb(P(xl,yt));
    }

    vector<D> event;

    int sm=0, sg=0;
    D hoge = 0;
    while(hoge<=Time+EPS){
      event.pb(hoge);
      hoge += 0.00005;
    }

    D ans = 0;
    sm = 0; sg = 0;
    rep(t,event.sz-1){
      D T = (event[t] + event[t+1])/2;
      if(sm<L && EQ(tm[sm+1], event[t]))sm++;
      if(sg<M && EQ(tg[sg+1], event[t]))sg++;

      //check
      bool f = true;
      P curM = P(vm[sm].real() * (T-tm[sm]) + pm[sm].real(),
		 vm[sm].imag() * (T-tm[sm]) + pm[sm].imag() );
      P curG = P(vg[sg].real() * (T-tg[sg]) + pg[sg].real(),
		 vg[sg].imag() * (T-tg[sg]) + pg[sg].imag() );

      if(abs(curM-curG) > R+EPS)f = false;
      else{
	P A = pg[sg+1]-curG, B = curM-curG;
	if(dot(A,B)/abs(A)/abs(B) +EPS < sq2)f = false;
	else{
	  Line eye = Line(curM, curG);
	  rep(i,N){
	    rep(j,obj[i].sz){
	      Line wall = Line( obj[i][j], obj[i][(j+1)%obj[i].sz] );
	      if(is_cp(eye, wall)){
		f = false; break;
	      }
	      if(!f)break;
	    }
	  }
	}
      }

      if(f)ans += event[t+1]-event[t];
    }

    cout << fixed << setprecision(12) << ans << endl;
  }
}

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

int main(){
  int a,b,c,x,y;
  cin>>a>>b>>c>>x>>y;
  int d,e,f;
  d=a*x+b*y;
  e=c*2*max(x,y);
  if(x>y){
    f=2*c*y+a*(x-y);
  }
  else{
    f=2*c*x+b*(y-x);
  }
  cout<<min(d,min(e,f))<<endl;
  
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iostream>
#include<ostream>
#include<cstdio>
using namespace std;
int a[100001];
int find(int i){
	if(a[i]!=i)
		return a[i]=find(a[i]);
	return i;
}
int main(){
	int n,m;
	cin>>n>>m;
	for(int i=1;i<=n;++i)
		a[i]=i;
	int ans=0;
	for(int i=1;i<=m;++i){
		int x,y,z;
		cin>>x>>y>>z;
		int u=find(x),v=find(y);
		a[u]=v;
	}
	for(int i=1;i<=n;++i)
		if(a[i]==i)
			ans++;
	cout<<ans<<endl;
	return 0;
}

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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N, M;
  cin >> N >> M;
  int a = 1, b = M + 2;
  for (int i = M; i > 0; i--) {
    cout << a << ' ' << a + i << '\n';
    a++;
    swap(a, b);
  }
  return 0;
}


Measured memory_bytes: 3652