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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REP1(i,n) for(int i=1, i##_len=(n); i<i##_len; ++i)
#define ll long long
static const int MAX = 10000;
static const ll INFTY = 1e12;

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

const ll MRINF = 5000000000000000;

int main() {

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

    int sum = a+b+c;
    int ans = max(a, max(b, c));
    REP(i, k){
        sum += ans;
        ans *= 2;
    }
    cout << sum << endl;
    

}
/*
                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         pass System Test!
*/

Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
#define rep(i,c) for(int i=0;i<c;++i)
int main(){
 string n,k;
 cin >> n >> k;
 if(n>k){
     cout<< ">" << endl;
 }else if(n<k){
     cout << "<" << endl;
 }else{
     cout << "=" << endl;
 }
  
return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = (a); i < (n); ++i)
#define all(x) x.begin(), x.end()
#define VI vector<int>
#define VS vector<string>
#define ll long long
#define INF 2e9
#define fir first
#define sec second
using namespace std;

void Main() {
    ll A, B, C, D;
    cin >> A >> B >> C >> D;
    ll ans = B - A + 1;
    ll div = 0;
    div += (B / C - (A - 1) / C);
    div += (B / D - (A - 1) / D);
    ll CD = C * D / __gcd(C, D);
    div -= (B / CD - (A - 1) / CD);
    cout << ans - div << endl;
}

int main() {
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15) << endl;
    Main();
    return 0;
}

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

#define sz(x) x.size()
#define all(x) x.begin(), x.end()

#define dbg(x) cout << #x << '=' << x << '\n'
#define dbg2(x, y) cout << #x << '=' << x << ' ' << #y << '=' << y << '\n' 

#define input() (*istream_iterator<int>(cin))
#define strin() (*istream_iterator<string>(cin))
#define output(x) cout << x << '\n' 

const double pi = M_PI;
int main(){
    ios::sync_with_stdio(false);
    int a, b, h, m;
    cin >> a >> b >> h >> m;
    double angle = 2*pi*((double) h/12.0 + (double) m/720.0 - (double) m/60.0);
    double len = a*a + b*b - (2*a*b*cos(angle));
    printf("%.10f", sqrt(len));
}

Measured memory_bytes: 4240
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<cstdio>
#include<cstdlib>
#include<queue>
#include<list>
#include<deque>
#include<unordered_map>
using namespace std;


using ll = long long int;

/// <summary>
/// GCDを計算します
/// </summary>
template <typename NumType>
NumType calcGCD(NumType a, NumType b) {
	if (a < b) {
		NumType tmp = a;
		a = b;
		b = tmp;
	}

	NumType r = a % b;
	while (r != 0) {
		a = b;
		b = r;
		r = a % b;
	}

	return b;
}

/// <summary>
/// 約数を数えます
/// </summary>
template <typename NumType>
NumType cntDivisor(const NumType& num) {
	NumType cnt = 0;
	for (NumType i = 1; i * i <= num; ++i) {
		if (num % i == 0) {
			cnt++;
			if (i * i != num) cnt++;
		}
	}

	return cnt;
}

/// <summary>
/// [beg, end)の範囲を，添え字indexでループするfor文に置換します
/// </summary>
#define rep(i,a) for(ll i=0; i<a; ++i)

const vector<ll> dx = { 0, 1, 0, -1 }, dy = { 1, 0, -1, 0 };

#define DEBUG(x)     std::cout << #x << " : " << x << "\n"


///////////////////////////////////////////////////////////////////////////

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

	string S;

	cin >> S;

	rep(i, 3) {
		if (S[i] == S[i + 1]) {
			cout << "Bad" << endl;
			return 0;
		}
	}

	cout << "Good" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <numeric>
#include <cmath>
#include <limits>
#include <stdio.h>
#include <iomanip>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
using ll = long long;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
ll Max(ll(a), ll(b), ll(c)) {
	return max(max(a, b), c);
}
ll Min(ll(a), ll(b), ll(c)) {
	return min(min(a, b), c);
}


ll mod = 1e9 + 7;

ll dp[1002][1002];
bool ma[1002][1002];
int main() {
	ll H, W;
	cin >> H >> W;
	rep(i, H) {
		string S;
		cin >> S;
		rep(j, W) {
			if (S.at(j) == '#')ma[i][j] = false;
			else ma[i][j] = true;
		}
	}
	dp[0][0] = 1;
	rep(i, H) {

		rep(j, W) {
			if (i == 0 && j == 0)continue;
			
			if (ma[i][j]) {
				if (i == 0) {
					dp[i][j] = dp[i][j-1];
				}
				else if (j == 0) {
					dp[i][j] = dp[i - 1][j];
				}
				else {
					dp[i][j] = dp[i - 1][j]+ dp[i][j-1];
				}
			}
			else {
				dp[i][j] = 0;
			}
			dp[i][j] %= mod;
		}
	}

	cout << dp[H - 1][W - 1] << endl;
}


Measured memory_bytes: 12392
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {

	public static void main(String[] args){
		Scanner s = new Scanner(System.in);
		String str=s.next();
		s.close();
		Map<String,String> map=new HashMap<String,String>();
		map.put("A", "T");
		map.put("T", "A");
		map.put("C", "G");
		map.put("G", "C");
		System.out.println(map.get(str));
	}

}

Measured memory_bytes: 20948
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <sstream>
#include <string>
#define _repargs(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _repargs(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define inf 2000000007
#define mp make_pair
#define pb push_back
typedef long long ll;
using namespace std;
template <typename T>
inline void output(T a, int p = 0) {
    if(p) cout << fixed << setprecision(p)  << a << "\n";
    else cout << a << "\n";
}
// end of template

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    // source code
    int X;
    cin >> X;
    int five_hundred = 1000 * (X / 500);
    int five = (X - X / 500 * 500) / 5 * 5;
    output(five_hundred + five);
    
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
 
using namespace std;
 
#define INF 1000000007
#define LINF 1000000000000000007
 
typedef long long ll;
typedef pair<ll,ll> P;


int n;
string s;

int main(){
	cin >> n >> s;
	
	int cnt = 0;
	for(int i = 0; i < n; i++){
		int c = 0;
		bool b[26] = {0}, d[26] = {0};
		for(int j = 0; j < n-i; j++){
			b[(int)(s[j]-'a')] = 1;
		}
		for(int j = n-i; j < n; j++){
			d[(int)(s[j]-'a')] = 1;
		}
		for(int j = 0; j < 26; j++){
			if(b[j]&&d[j]) c++;
		}
		cnt = max(cnt, c);
	}
	cout << cnt << endl;
	
	return 0;
}

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

int w[2000][2000];
int b[2000][2000];
int w_acc[2001][2001];
int b_acc[2001][2001];

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

  int l = 2 * k;
  for (int i=0; i<l; i++) {
    for (int j=0; j<l; j++) {
      w[i][j] = 0;
      b[i][j] = 0;
    }
  }

  for (int i=0; i<n; i++) {
    int x, y;
    char c;
    cin>>x>>y>>c;
    if (c == 'B') {
      ++b[y % l][x % l];
    } else {
      ++w[y % l][x % l];
    }
  }

  for (int i=0; i<l+1; i++) {
    for (int j=0; j<l+1; j++) {
      w_acc[i][j] = 0;
      b_acc[i][j] = 0;
    }
  }
  for (int i=1; i<l+1; i++) {
    for (int j=1; j<l+1; j++) {
      w_acc[i][j] = w_acc[i-1][j] + w_acc[i][j-1] - w_acc[i-1][j-1] + w[i-1][j-1];
      b_acc[i][j] = b_acc[i-1][j] + b_acc[i][j-1] - b_acc[i-1][j-1] + b[i-1][j-1];
    }
  }
  int ans = 0;
  for (int i=0; i<l; i++) {
    for (int j=0; j<l; j++) {
      int score = 0;
      for (int y=-1; y<=2; y++) {
        for (int x=-1; x<=2; x++) {
          int rty = i + k * y;
          int rtx = j + k * x;
          int lby = i + k * y - k + 1;
          int lbx = j + k * x - k + 1;

          if (rty < 0 || rtx < 0) {
            continue;
          }
          if (lby > l || lbx > l) {
            continue;
          }
          rty = min(rty, l - 1);
          rtx = min(rtx, l - 1);
          lby = max(lby, 0);
          lbx = max(lbx, 0);
          if ((y + x + 2) % 2 == 0) {
            score += b_acc[rty+1][rtx+1] - b_acc[lby][rtx+1] - b_acc[rty+1][lbx] + b_acc[lby][lbx];
          } else {
            score += w_acc[rty+1][rtx+1] - w_acc[lby][rtx+1] - w_acc[rty+1][lbx] + w_acc[lby][lbx];
          }
        }
      }
      ans = max(score, ans);
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 62720
#include <bits/stdc++.h>
typedef long long ll; 
 
using namespace std;
 
int main() {
	int N, Z, W;
	cin >> N >> Z >> W;
	vector<int> a(N + 1);
	for (int i = 1; i <= N; i++) {
		cin >> a[i];
	}

	if (N == 1) {
		cout << abs(a[N] - W) << endl;
		return 0;
	}

	int res = max(abs(a[N] -  a[N - 1]), abs(a[N] - W));
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
#include<complex>
#include<numeric>
using namespace std;

typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef pair<int, int>P;
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
typedef vector<vector<ll>> mat;
typedef vector<int> vec;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
const ll mod = 1000000007;
const ll INF = mod * mod;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
//int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
ll qp(ll a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };

void solve() {
    string s;
    cin >> s;
    char temp = s[0];
    string ans = "No";

    rep(i,3){
        if(s[i] != temp) ans = "Yes";
    }

    cout << ans << endl;
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    //cout << fixed << setprecision(10);
    solve();
    // stopBBB
        return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast") 
#include<bits/stdc++.h>
#define l(i,a,b) for(auto i=a;i<b;i++)
#define lr(i,a,b) for(auto i=a;i>=b;i--)
#define ll long long
#define lli long long int
#define ld long double
#define vec vector<int>
#define mii map<ll,ll>
#define vl vector<long long>
#define se set <long long int>
#define pi pair<long long,long long>
#define pb push_back
#define mp make_pair
#define ft first
#define sd second
#define all(v) v.begin(), v.end()
#define in(x) cin>>x
#define o(x) cout<<x
#define SYNC ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define PI 3.14159265359
using namespace std;

ll max_rec(vl v, ll i, ll n)
{
    if(i>=n)
        return 0;
    else
        return max(max_rec(v,i+2,n) + v[i], max_rec(v,i+1,n));
}


int main()
{
    SYNC
    //clock_t tStart = clock();
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    ll d,t,s; in(d)>>t>>s;
    if(s*t>=d)
        o("Yes");
    else
        o("No");









    //printf("Time taken: %.2fs\n", (double)(clock() - tStart)/CLOCKS_PER_SEC);   
}


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

int main(void) {
	int i;
	int ans;
	char buf[200008] = "\0";
	char digit[2];

	fgets(buf, sizeof(buf), stdin);
	i = 0;
	ans = 0;
	digit[1] = '\0';
	while(buf[i] != '\0' && buf[i] != '\n') {
		digit[0] = buf[i];
		ans += atoi(digit);
		ans %= 9;
		i += 1;
	}

	if(ans == 0) {
		printf("Yes\n");
	} else {
		printf("No\n");
	}

	return 0;
}


Measured memory_bytes: 2156
#include<stdio.h>
int main(){
  char s[5];
  int ans = 0;
  scanf("%s",&s);
  for(int i = 0;i < 4;i++){
    if(s[i] == '+'){
      ans++;
    }else{
      ans--;
    }
  }
  printf("%d",ans);
  return 0;
}

Measured memory_bytes: 128
fun main() {
    var n = readLine()!!.toInt()
    var count = 0
    var ans = "No"
    while (n-- > 0) {
        val (a, b) = readStrings().map { it.toInt() }
        if (a == b) {
            count++
            if (count == 3) ans = "Yes"
        } else {
            count = 0
        }
    }
    println(ans)
}

private fun readLn() = readLine()!! // string line
private fun readInt() = readLn().toInt() // single int
private fun readLong() = readLn().toLong() // single long
private fun readDouble() = readLn().toDouble() // single double
private fun readStrings() = readLn().split(" ") // list of strings
private fun readInts() = readStrings().map { it.toInt() } // list of ints
private fun readIntArr() = readStrings().map { it.toInt() }.toIntArray() // list of ints
private fun readLongs() = readStrings().map { it.toLong() } // list of longs
private fun readDoubles() = readStrings().map { it.toDouble() } // list of doubles

Measured memory_bytes: 38056
#include<bits/stdc++.h>
#define ll long long
using namespace std;

const int m = 1e5, M = 1e9+7;
ll inverse[3*m], fact[3*m], invfact[3*m];

ll nCr(ll n, ll r){
    ll ans = fact[n]*invfact[r]%M;
    return (ans*invfact[n-r]%M); 
}

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

    //good luck kittu!
    inverse[1] = 1;
    for(ll i = 2; i<3*m; i++) inverse[i] = M - M/i * inverse[M%i]%M;
    fact[0] = invfact[0] = 1;
    for(ll i = 1; i<3*m; i++){
        fact[i] = fact[i-1]*i%M;
        invfact[i] = invfact[i-1]*inverse[i]%M;
    }

    int h, w, a, b; cin>>h>>w>>a>>b;
    ll ans = 0;
    for(int i = b; i<w; i++){
        ans += (nCr(i+h-a-1, h-a-1)*nCr(w-1-i+a-1,a-1))%M;
    }
    ans = ans%M;
    cout<<ans<<"\n";
    return 0;
}

Measured memory_bytes: 7296
n = int(input())
ans = n
for i in range(n+1):
    c = 0
    t = i
    while t>0:
        c+=t%6
        t //= 6
    t = n-i
    while t>0:
        c+=t%9
        t //= 9
    ans = min(ans,c)
print(ans)

Measured memory_bytes: 40940
#include<iostream>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
#define MAX 1004732

int calc(int n) { return n*(n + 1)*(n + 2) / 6; }
int p[200];
int p1[200];
//int dp[MAX] = { 0 };
//int dp1[MAX] = { 0 };

int func(int n, int P[], int DP[])
{
	if (n <= 0)return MAX;
	if (DP[n] != 0)return DP[n];
	else
	{
		int min_t = MAX;
		int i = 0;
		while (1)
		{
			if (P[i] <= n && n <= P[i + 1])break;
			if (P[i] == 1004731)
			{
				i--;
				break;
			}
			i++;
		}
		for (int t = i; t>0; t--)
		{
			int temp = func(n - P[t], P, DP);
			if (min_t > temp + 1)
			{
				min_t = temp + 1;
			}
		}
		DP[n] = min_t;
		return DP[n];
	}
}

int main()
{
	int *dp, *dp1;
	dp = new int[MAX];
	dp1 = new int[MAX];
	REP(i, MAX)
	{
		dp[i] = 0;
		dp1[i] = 0;
	}
	int index = 1;
	FOR(i, 1, 200)
	{
		int temp = calc(i);
		if (temp > 1004731)break;
		p[i] = temp;
		dp[p[i]] = 1;
		if (temp % 2 == 1)
		{
			p1[index] = temp;
			dp1[p1[index]] = 1;
			index++;
		}
	}
	while (1)
	{
		int N;
		cin >> N;
		if (N == 0)break;
		cout << func(N, p, dp) << " " << func(N, p1, dp1) << endl;
	}
	delete[] dp;
	delete[] dp1;
}

Measured memory_bytes: 10528
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		
		String s =String.valueOf(n);
		int sum = 0;
		for (int i = 0; i < s.length(); i++) {
			int a = Integer.parseInt(s.substring(i, i + 1));
			sum += a;
		}
		if (n % sum == 0) System.out.println("Yes");
		else System.out.println("No");
		
	}
}

Measured memory_bytes: 23636
#include<algorithm>
#include<cmath>
#include<deque>
#include<iomanip>
#include<iostream>
#include<list>
#include<map>
#include<numeric> //xとyの最大公約数は__gcd(x,y),xとyの最小公倍数は(x*y)/__gcd
#include<set>
#include<string>
#include<vector>

#include<bits/stdc++.h>
#include<cstdio>
#include<cstdlib>
#include<queue>
#include<stack>
#include<tuple>
#include<utility>
typedef long long ll;
#define rep(i,n) for(ll i=0; i<n; i++)
#define vll vector<ll>
#define vi vector<int>
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define mod 1000000007
using namespace std;

int main(){
  string s;   cin >> s;
  string a = {s[0],s[1]};
  string b = {s[2],s[3]};
  if(1 <= atoi(a.c_str()) and atoi(a.c_str()) <= 12){
    if(1 <= atoi(b.c_str()) and atoi(b.c_str()) <= 12){
      cout << "AMBIGUOUS";
    }else{
      cout << "MMYY";
    }
  }else{
    if(1 <= atoi(b.c_str()) and atoi(b.c_str()) <= 12){
      cout << "YYMM";
    }else{
      cout << "NA";
    }
  }
  return 0;
}


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

using namespace std;
using ll = long long;

template <typename T>
T power(T x, int n) {
  T ans{1};
  while (n) {
    if (n % 2) ans *= x;
    x *= x;
    n >>= 1;
  }
  return ans;
}

void solve(ll A, ll B, ll C, ll K) {
  ll ma = max({A,B,C});
  cout << A+B+C+(power(2,K)-1)*ma << endl;
}

int main() {
  ll A;
  cin >> A;
  ll B;
  cin >> B;
  ll C;
  cin >> C;
  ll K;
  cin >> K;
  solve(A, B, C, K);
  return 0;
}


Measured memory_bytes: 256
n=int(input())
l=list(map(int,input().split()))
l.sort()
ans=0

import bisect

for i in range(n):
  a=l[i]
  for j in range(i+1,n):
    b=l[j]
    
    ans+=bisect.bisect_left(l,a+b)-j-1
          
print(ans)

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

using namespace std;

#define FOE(i, s, t) for (int i = s; i <= t; i++)
#define FOR(i, s, t) for (int i = s; i < t; i++)
#define FOD(i, s, t) for (int i = s; i >= t; i--)
#define PI atan(1)*4

#define LL long long
#define mp make_pair
#define pb push_back

int x;

double cx = 100.00, cy = 0.00;
double eps = 1e-9;
double dx = 100.00, dy = 0.00;

int main() {
	cin >> x;
	int cnt = 1;
	cx = dx = 100.00;
	cy = dy = 0.00;
	
	while (abs(cx) > eps || abs(cy) > eps) {
		double deg = (double)x * 1.00 / 360.00 * (2 * PI);
		double nx = dx * cos(deg) - dy * sin(deg);
		double ny = dx * sin(deg) + dy * cos(deg);
		
		dx = nx;
		dy = ny;
		
		cx += dx;
		cy += dy;
		
		cnt++;
	}
	
	printf("%d\n", cnt);
}

Measured memory_bytes: 3896
n, a, b = map(int, input().split())
if a > b:
    print(0)
    exit(0)
if a == b:
    print(1)
    exit(0)
if n == 1:
    if a != b:
        print(0)
    else:
        print(1)
elif n == 2:
    print(1)
else:
    print(b * (n - 2) - a * (n - 2) + 1)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,a,n) for(ll i = a;i < n;i++)
#define rrep(i,a,n) for(ll i = n; i >= a;i--)
#define index_check(i,n) if(i > n-1 || i < 0) continue; 
#define LINF 1e18
#define INF 1e9
using namespace std;

#define fs first
#define sc second

using P = pair<ll,ll>;
using PQ = priority_queue<P,vector<P>,greater<P>>;

signed main(){
    ll n,cnt = 0,memo = 1;
    cin >> n;
    ll a[n]={};
    rep(i,0,n){
        cin >> a[i];
        if(memo != a[i]) cnt++;
        else memo++;
    }

    
    cout << ((cnt==n)?-1:cnt) << endl;
    return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int>P;
priority_queue<P,vector<P>,greater<P> >p;
priority_queue<P,vector<P>,greater<P> >pq;

int main(){
  int n,q;
  int t[200009],x[200009];
  cin>>n>>q;
  for(int i=0;i<n;i++){
    int s;
    cin>>s>>t[i]>>x[i];
    t[i]-=x[i];
    p.push(P(s-x[i],i));
  }
  for(int i=0;i<q;i++){
    int d;
    cin>>d;
    while(!p.empty()){
      P now=p.top();
      int s=now.first;
      int idx=now.second;
      if(s>d)break;
      pq.push(P(x[idx],idx));
      p.pop();
    }
    while(!pq.empty()){
      P now=pq.top();
      int idx=now.second;
      if(t[idx]>d){
	cout<<x[idx]<<endl;
	break;
      }
      pq.pop();
    }
    if(pq.empty())cout<<-1<<endl;
  }
  return(0);
}


Measured memory_bytes: 6384
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define VV 55555
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int N;
int listP[VV + 1][4];
int counter[4];
int main() {
  cin >> N;
  // cout << N << endl;
  vector< bool > flg(VV + 1);
  FOR(i, 2, VV + 1) {
    if (!flg[i]) {
      for (int j = 2 * i; j <= VV; j += i) {
        flg[j] = true;
      }
    }
  }
  FOR(i, 2, VV + 1) {
    if (!flg[i]) {
      int modulo = i % 5 - 1;
      if (modulo == -1)
        continue;
      else {
        listP[modulo][counter[modulo]] = i;
        counter[modulo]++;
      }
      // printf("%d\n", i);
    }
  }
  // REP(i, 4) { cout << counter[i] << endl; }
  REP(i, N) { printf("%d ", listP[0][i]); }
}

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

using namespace std;

typedef long long ll;
typedef vector<int> pi;
typedef pair<int,int> vi;

#define F first
#define S second
#define PB push_back
#define MK make_pair
#define REP(i, a, b) for (int i=a; i < b; i++)


bool sort_by(vi c, vi d){
	return c.S < d.S;
}

int main() {
	ll N, K, Q, j;
	cin >> N >> K >> Q;
	ll b[N];
	REP(i, 0, N) b[i] = K-Q;
	REP(i, 0, Q){
		cin >> j;
		++b[j-1];
	}
	REP(i, 0, N){
		if(b[i] > 0) cout << "Yes\n";
		else cout << "No\n";
	}
	

}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll,ll> P;
typedef vector<P> vp;
typedef vector<string> vs;
typedef vector<bool> vb;

const ll mod=1e9+7;
const ll inf=1e16;

#define rep(i,m,n) for(ll i=m;i<n;i++)
#define repr(i,m,n) for(ll i=m-1;i>=n;i--)
#define fi first
#define se second
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
#define eb(x) emplace_back(x)
#define all(x) x.begin(),x.end()
#define allr(x) x.rbegin(),x.rend()
#define sum(x) accumulate(all(x),0)
#define pc(x) __builtin_popcount(x)
#define gll greater<ll>()

void solve(){
 ll a,b,c,k;
  cin >> a >> b >> c >> k;
  rep(i,0,k+1){
   if(a<b*(1<<i)&&b*(1<<i)<c*(1<<(k-i))) {
     cout << "Yes" << endl;
     return; 
   }
    
  }
 cout << "No" << endl;
    
}
int main(){
   cin.tie(nullptr);
  ios::sync_with_stdio(false);
  solve();
}

Measured memory_bytes: 3612
// in case of multiple test cases and N=1e5 don't intialize arrays as global except for graph vector-array
// always check whether or not you are doing mod of a negative number
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <bits/stdc++.h>
 
using namespace __gnu_pbds;
using namespace std;

#define double      	long double
#define int         	long long
#define pb          	push_back
#define pii         	pair<int,int>
#define vi          	vector<int>
#define vii         	vector<pii>
#define mi          	map<int,int>
#define mii         	map<pii,int>
#define all(a)      	(a).begin(),(a).end()
#define sz(x)       	(int)x.size()
#define endl        	"\n"
#define repp(i,a,b) 	for(int i=a;i<b;i++)
#define rep(i,a,b) 		for(int i=a;i<=b;i++)
#define brep(i,a,b)     for(int i=a;i>=b;i--)
#define deb1(x)      	cout << #x << "=" << x << endl
#define deb2(x, y)  	cout << #x << "=" << x << "," << #y << "=" << y << endl
#define deb3(x, y, z)  	cout << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z << endl
#define trace(v) 		for(auto it=v.begin();it!=v.end();it++)cout<<*it<<" ";cout<<endl;
#define tracearr(a,l,r) for(int iii=l;iii<=r;iii++)cout << a[iii] << " ";cout << endl;
#define PI          	3.1415926535897932384626
#define F 				first
#define S 				second
#define clr(x,y) 		memset(x, y, sizeof(x))
#define IOS         	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);


typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
// *s.find_by_order(1) - gives the 2nd samllest element in set
// s.order_of_key(x)   - gives the number of elements in the set which are strictly smaller than x


const int N=1e5 + 5;
const int MOD=1e9 + 7;

int32_t main()
{
	IOS;
	int T=1;
	//cin >> T;
	// int numOfSetBits = __builtin_popcountll(n);
	std::cout << std::fixed << std::setprecision(12);
	while(T--)
	{
		int x;
		cin >> x;
		if(x>=30)
			cout << "Yes";
		else
			cout << "No";
	}
}

Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<int,int> P;
const LL mod=1000000007;
const LL LINF=1LL<<60;
const int INF=1<<30;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
 

const int M_N=200001;

struct UnionFind{
    int par[M_N];
    int rank[M_N];
    LL number[M_N];
 
    void init(int n){
        for(int i=0;i<n;i++){
            par[i]=i;
            rank[i]=0;
            number[i]=1;
        }
    }
 
    int find(int x){
        if(par[x]==x){
            return x;
        }
        else{
            return par[x]=find(par[x]);
        }
    }
 
    void unite(int x,int y){
        x=find(x);
        y=find(y);
        if(x==y) return;
        if(rank[x]<rank[y]){
            par[x]=y;
            number[y]+=number[x];
        }
        else{
            par[y]=x;
            if(rank[x]==rank[y]) rank[x]++;
            number[x]+=number[y];
        }
    }
 
    bool same(int x,int y){
        return find(x)==find(y);
    }
 
    int get(int x){
        return number[find(x)];
    }
 
};

vector<int> v[100001],u[100001];

int main(){
    int n;cin >> n;
    UnionFind uf;
    uf.init(100001);
    for (int i = 0; i < n; i++) {
        int x,y;cin >> x >> y;
        v[x].pb(y);
        u[y].pb(x);
    }
    for (int i = 1; i <= 100000; i++) {
        for (int j = 1; j < u[i].size(); j++) {
            uf.unite(u[i][j],u[i][j-1]);
        }
    }
    LL ans = 0;
    vector<bool> used(100001,false);
    for (int i = 1; i <= 100000; i++) {
        if(used[uf.find(i)]) continue;
        if(uf.get(i)==1){
            ans += (LL)v[i].size();
            continue;
        }
        LL t = 1;
        set<int> st;
        for (int j = 0; j < v[i].size(); j++) {
            st.insert(v[i][j]);
        }
        for (int j = i+1; j <= 100000; j++) {
            if(!uf.same(i,j)) continue;
            t++;
            for (int k = 0; k < v[j].size(); k++) {
                st.insert(v[j][k]);
            }
        }
        used[uf.find(i)]=true;
        ans += st.size()*t;
    }
    cout << ans-n << endl;
    return 0;
}


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

int top, S[1000];

void push(int x) {
	S[++top] = x;
}
int pop() {
	top--;
	return S[top + 1];
}

int main() {
	int a, b;
	top = 0;
	char s[100];

	while ((scanf("%s", s) != EOF)) {
		if (s[0] == '+') {
			a = pop();
			b = pop();
			push(a + b);
		}
		else if (s[0] == '-') {
			b = pop();
			a = pop();
			push(a - b);
		}
		else if (s[0] == '*') {
			a = pop();
			b = pop();
			push(a * b);
		}
		else {
			push(atoi(s));
		}
	}
	printf("%d\n", pop());

	return 0;
}


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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); 

#define ll long long
#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define mp make_pair
#define pu push
#define pp pop_back
#define in insert
#define ld long double
#define endl '\n'
#define forn(low,high,i) for(i=low;i<high;i++)
#define forrev(high,low,i) for(i = high; i>= low;i--)
#define trace(x) cerr << #x << ": " << x << " " << endl;
#define all(v) v.begin(),v.end()
#define sz(v) (int)v.size()
#define line cout << __LINE__;
#define prv(a) for(auto x : a) cout << x << ' ';cout << '\n';
#define decimal_digits cout << fixed << setprecision(15);
#define sp cout << " ";
#define dbg2(a,b) cerr << #a << " = " << a << " " << #b << " = " << b << '\n';        
#define debug(x) cerr << __LINE__ << ' ' << #x << " = " << x << '\n';

typedef unordered_map<int,int> umi;
typedef unordered_map<ll,ll> uml;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;


clock_t time_p = clock();

void ktj(){
  time_p = clock() - time_p;
  cerr << "Time elapsed : " << (float)(time_p)/CLOCKS_PER_SEC << "\n";
}

int main(){
  fastio

  ll n,l,i,j;
  cin >> n >> l;
  vl a;
  bool zero = 0;
  ll sum = 0;
  forn(1,n + 1,i){
    if(l + i == 1)zero = 1;
    a.pb(l + i - 1);
    sum += (l + i - 1);
  }
  sort(all(a));
  if(zero){ 
    cout << sum << '\n';
  }else{

    ll ans = -1e18;
    ll diff = 1e18;
    ll sgn = 0;
    forn(0,n,i){
      diff = min(diff, abs(a[i]));
      if(diff == abs(a[i])){
        sgn = a[i] / abs(a[i]);
      }
    }

    cout << sum - sgn * diff << '\n';

  }
  ktj();
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1e9+7,MAX = 1e5;

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

	if(d==0)
	{
		if(n==100)
		{
			cout<<101<<endl;
		}
		else
		{
			cout<<n<<endl;
		}
	}
	else if(d==1)
	{
		if(n==100)
		{
			cout<<10100<<endl;
		}
		else
		{
			cout<<n*100<<endl;
		}
	}
	else
	{
		if(n==100)
		{
			cout<<1010000<<endl;
		}
		else
		{
			cout<<n*10000<<endl;
		}
		
	}
	
	
	return 0;
}

Measured memory_bytes: 256
N, X = map(int, input().split())

def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)

Xi = list(map(int, input().split()))
Xi.sort()
Di = []
for i in range(N):
    Di.append(abs(X - Xi[i]))
DLen = len(Di)
g = Di[0]
for i in range(1, DLen):
    if Di[i] != 0:
        g = gcd(g, Di[i])
print(g)


Measured memory_bytes: 14252
#include <bits/stdc++.h>
#define LL long long
#define PII pair<int,int>
using namespace std;
const int MAXN = 200005;
const int INF = (LL)1e9 + 5;

int dp[30];
char best[MAXN];
string s, ans;

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
	cin >> s;
	int len = 1;
	best[s.size()] = 'a';
	for (int i = 0; i < 26; i++) dp[i] = 1;
	
	for (int i = s.size() - 1; i >= 0; i--) {
		for (int j = 0; j < 26; j++) {
			dp[j] = s[i] - 'a' == j ? len + 1 : dp[j];
		}
		
		best[i] = min_element(dp, dp + 26) - dp + 'a';
		len = dp[best[i] - 'a'];
	}
	
	int i = 0;
	while (i <= s.size()) {
		ans.push_back(best[i]);
		while (i < s.size() && s[i] != ans.back()) i++;
		i++;
	}
	
	cout << ans << "\n";
	
	return 0;
	
	/**** Note MAXN ****/
}


Measured memory_bytes: 788
#include<stdio.h>
#include<iostream>
#include<string>
#include<vector>
#include<math.h>
#include<algorithm>
using namespace std;
using ll = long long;
#define max(a,b) ((a)>(b) ? (a):(b))
#define min(a,b) ((a)<=(b) ? (a):(b))
#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++)

int main(){
  ll N;
  cin >> N;
  ll X,L,i;
  vector<pair<ll,ll>> x(N);
  rep(i,N){
    cin >> X;
    cin >> L;
    x[i].first = X+L;
    x[i].second = X-L;
  }
  sort(x.begin(), x.end());
  ll cnt = 1;
  ll right = x[i].first;
  rep(i,N-1){
    if(right <= x[i+1].second){
      cnt += 1;
      right = x[i+1].first;
    }
  }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 1792
/**
 * Created by hiramekun at 20:44 on 2019-12-08.
 */
#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using vl = vector<ll>;
using vvl = vector<vl>;
using vb = vector<bool>;
using P = pair<ll, ll>;
template<typename T> using pq = priority_queue<T>;
template<typename T> using minpq = priority_queue<T, vector<T>, greater<T>>;
template<typename T, typename K> using ump = unordered_map<T, K>;
const ll dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll e5 = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = ll(n - 1); i >= 0; i--)
#define each(i, mp) for(auto& i:mp)
#define eb emplace_back
#define F first
#define S second
#define all(obj) (obj).begin(), (obj).end()

template<class T>
ostream &operator<<(ostream &out, const vector<T> &list) {
    ll n = list.size();
    rep(i, n) out << list[i] << ' ';
    return out;
}

template<class T>
istream &operator>>(istream &in, vector<T> &list) {
    ll n = list.size();
    rep(i, n) in >> list[i];
    return in;
}

template<class T>
ostream &operator<<(ostream &out, const vector<vector<T>> &list) {
    ll n = list.size();
    rep(i, n) out << list[i] << '\n';
    return out;
}

/* ------------- ANSWER ------------- */
/* ---------------------------------- */

void solve() {
    ll h, w;
    cin >> h >> w;
    int a[h][w], b[h][w];
    rep(i, h) rep(j, w) cin >> a[i][j];
    rep(i, h) rep(j, w) cin >> b[i][j];

    ll max_diff = 2 * 80 * 160;
    bool dp[h][w][max_diff];
    rep(i, h) rep(j, w) rep(l, max_diff) dp[i][j][l] = false;

    ll mid = max_diff / 2;
    dp[0][0][b[0][0] - a[0][0] + mid] = true;
    dp[0][0][-b[0][0] + a[0][0] + mid] = true;

    rep(i, h) {
        rep(j, w) {
            rep(l, max_diff) {
                bool now = dp[i][j][l];
                if (i + 1 <= h - 1) {
                    dp[i + 1][j][l + b[i + 1][j] - a[i + 1][j]] |= now;
                    dp[i + 1][j][l - b[i + 1][j] + a[i + 1][j]] |= now;
                }
                if (j + 1 <= w - 1) {
                    dp[i][j + 1][l + b[i][j + 1] - a[i][j + 1]] |= now;
                    dp[i][j + 1][l - b[i][j + 1] + a[i][j + 1]] |= now;
                }
            }
        }
    }
    ll ans = ll_inf;
    rep(i, max_diff) {
        if (dp[h - 1][w - 1][i]) ans = min(ans, abs(i - mid));
    }
    cout << ans << '\n';
}

int main() {
#ifdef MY_DEBUG
    while (true) {
#endif
        solve();
#ifdef MY_DEBUG
    }
#endif
    return 0;
}

Measured memory_bytes: 160256
n = int(input())
l = []
for i in range((n+1)%2, n, 2):
  l += [i, i] if i>0 else [i]
a = sorted(list(map(int, input().split())))
if a == l:
  print((2 ** (n//2)) % (10**9 + 7))
else:
  print(0)

Measured memory_bytes: 16248
#include <iostream>

using namespace std;

int N, a, cnt4, cnt2, cnt1;

int main() {
    cin >> N;
    for (int i = 0; i != N; ++i) {
        cin >> a;
        if (a >> 2 << 2 == a) ++cnt4;
        else if (a >> 1 << 1 == a) ++cnt2;
        else ++cnt1;
    }
    cout << ((cnt1 < cnt4 || (cnt1 == cnt4 + 1 && cnt2 == 0) || (cnt1 == cnt4 && (cnt4 != 0 || (cnt4 == 0 && cnt2 > 1)))) ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <string>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <cassert>
#include <numeric>
#include <functional>
#pragma warning(disable:4996) 

typedef long long ll;
typedef unsigned long long ull;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF  9223300000000000000
#define LINF2 1223300000000000000
#define LINF3 1000000000000
#define INF 2140000000
//const long long MOD = 1000000007;
const long long MOD = 998244353;

using namespace std;



void solve()
{
    ll n;
    scanf("%lld", &n);

    vector<ll> a;
    int i;
    ll curr = 1;
    for (i = 1; i <= 12; i++) {
        curr *= 26;
        a.push_back(curr);
    }
    vector<ll> sa(13);
    for (i = 0; i < 12; i++) {
        sa[i + 1] = sa[i] + a[i];
    }
    int k=lower_bound(sa.begin(), sa.end(), n)-sa.begin();
    k--;
    assert(k >= 0);

    ll m = n - 1 - sa[k];
    vector<char> ans;
    for (i = 0; i < k + 1; i++) {
        int tmp = m % 26;
        ans.push_back('a' + tmp);
        m /= 26;
    }
    reverse(ans.begin(), ans.end());
    ans.push_back('\0');
    printf("%s", &ans[0]);
    return;
}


int main(int argc, char* argv[])
{
#if 1
    solve();
#else
    int T;
    scanf("%d", &T);
    int t;
    for(t=0; t<T; t++) {
        //printf("Case #%d: ", t+1);
        solve();
    }
#endif
    return 0;
}


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

int main(int argc, const char * argv[]) {
    // insert code here...
    string N;
    cin >> N;
    
    if (N[0] == '9' || N[1] == '9') cout << "Yes" << endl;
    else cout << "No" << endl;
    
    return 0;
}


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

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

 vector<long long> p(n+1);
 for(int i = 1;i <= n;i++) {
   cin >> p.at(i-1) >> p.at(i);
 }

 vector<vector<long long> > dp(n+1,vector<long long>(n+1,0));

 for(int l = 2;l <= n;l++) {
   for(int i = 1;i <= n-l+1;i++) {
     int j = i + l - 1;
     dp[i][j] = (1<<21);
     for(int k = i;k <= j-1;k++) {
       dp[i][j] = min(dp[i][j],dp[i][k]+dp[k+1][j]+p[i-1] * p[k] * p[j]);
     }
   }
 }

 cout << dp[1][n] << endl;
 
 
  
}





Measured memory_bytes: 3216
#include<bits/stdc++.h>
using namespace std;
int main(){
  int long long A,B,C;cin>>A>>B>>C;
  if(A%2==0 or B%2==0 or C%2==0)cout<<0<<endl;
  
  else{
    vector<int long long>a(3);
    a.at(0)=A;a.at(1)=B;a.at(2)=C;
    sort(a.begin(),a.end());
    cout<<a.at(0)*a.at(1)<<endl;
  }
}

Measured memory_bytes: 256
#include<stdio.h>

#define MAX 100000



int EACH_AREA_Decision(int snd_stk[], int each_area[], int s_idx)//各水溜まりの面積を求めた時点で、それ以前にその水溜まりより高い水溜まりがないかを確認する。
{
	int share_count = 0,
		number = 0,
		pool_number = 0,
		pool_count = 0,
		f_cnt = 0;

	while (1) {
		pool_number++;
		if (each_area[pool_number] == 0) {
			pool_number--;
			break;
		}
	}

	share_count = 1;
	s_idx -= 1;

	while ((pool_number - share_count) != -1) { 

		if (snd_stk[s_idx] < snd_stk[s_idx - share_count]) {//判定した水溜まりとそれ以前の水溜まりが同じ以下の高さであれば（※数値上では高ければ）その間にある水溜まりを結合する。
			each_area[pool_number - share_count] += each_area[pool_number - pool_count];//判定されたほうに入れていく
			snd_stk[s_idx - share_count] = 0;
			each_area[pool_number - pool_count] = 0;//初期化
			
			pool_count++;
		}
		else if (snd_stk[s_idx] >= snd_stk[s_idx - share_count]) {//
			break;
		}

		share_count++;//判定したところから結合する部分まで
		
	}
	share_count -= 1;
	snd_stk[s_idx - share_count] = snd_stk[s_idx];

	return share_count;
}


int main(void)
{

	int fst_stk[MAX] = { 0 }, f_idx = 0,
		snd_stk[MAX] = { 0 }, s_idx = 0,
		each_area[MAX] = { 0 }, e_idx = 0,
		ALL_area = 0;

	int i_idx = 0,
		d_count = 0,
		f_cnt = 0,
		distance = 0,
		TOP = 0;


	char input[MAX];

	fgets(input, MAX, stdin);


	while (input[i_idx] != '\n') {

		switch (input[i_idx]) {
		case '\\':
			

			d_count++;
			fst_stk[f_idx] = d_count;
			f_idx++;
			i_idx++;
			break;


		case '/':
			if (d_count == 0) {
				snd_stk[s_idx] = 1;
				s_idx++;
				i_idx++;
				break;
			}

			

			fst_stk[f_idx] = d_count;

			for (f_cnt = f_idx - 1; f_cnt >= 0; f_cnt--) {//Ｘ軸の面積を求める
				distance++;
				if (fst_stk[f_idx] == fst_stk[f_cnt]) {
					each_area[e_idx] = distance;
					e_idx++;
					snd_stk[s_idx] = d_count;//水溜まりの深さを一時的に格納
					s_idx++;
					distance = 0;//次に使うために初期化

					f_cnt = EACH_AREA_Decision(snd_stk, each_area, s_idx);//水溜まりを結合していた場合、帳尻を合わせる
					
					e_idx -= f_cnt;//結合した分の帳尻を合わせる
					s_idx -= f_cnt;
					break;
				}
			}

			d_count--;
			f_idx++;
			i_idx++;

			break;


		case '_':
			if (d_count == 0) {
				i_idx++;
				break;
			}
			fst_stk[f_idx] = -1;
			f_idx++;
			i_idx++;
			break;

		}
	}

	for (f_cnt = 0; f_cnt < e_idx; f_cnt++) {
		ALL_area += each_area[f_cnt];
	}

	printf("%d\n", ALL_area);
	printf("%d", e_idx);

	for (f_cnt = 0; f_cnt < e_idx; f_cnt++) {
		printf(" %d", each_area[f_cnt]);
	}
	putchar('\n');

	return 0;

}


Measured memory_bytes: 3052
# -*- coding: utf-8 -*-
"""
Created on Sun May 10 20:59:16 2020

@author: shinba
"""
a,b,c,k = map(int,input().split())

if a >= k:
    print(k)
elif a+b >= k :
    print(a)
else:
    print(2*a+b-k)

    



Measured memory_bytes: 9152
H, W = [int(_) for _ in input().split()]

def solve(H, W):
    if H % 3 == 0:
        return 0
    result = H * W
    H1 = H // 2
    H2 = H - H1
    for x in range(W + 1):
        a = H * x
        b = (W - x) * H1
        c = (W - x) * H2
        r = max(a, c) - min(a, b)
        result = min(result, r)
        W1 = (W - x) // 2
        W2 = W - x - W1
        b = H * W1
        c = H * W2
        r = max(a, c) - min(a, b)
        result = min(result, r)
    return result

# print(H, W)

result = min(solve(H, W), solve(W, H))

print(result)

Measured memory_bytes: 3064
// ナップザック問題
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<stack>
#include<algorithm>
#include<iostream>
#include<cmath>
#include<cassert>

#include<vector>
#include<queue>
#include<set>

using namespace std;

const int INF = -1;
const int MAX_N = 100;
const int MAX_W = 10000;

// 品物の価値 (1を開始とする配列)
int gV[MAX_N + 1];
// 品物の重さ (1を開始とする配列)
int gW[MAX_N + 1];
// 品物の数, ナップザックの容量
int N, W;

// 品物の価値を保存する配列
// ( 第1要素：品物の数, 第2要素：重量 )
int Value[MAX_N + 1][MAX_W + 1];

int KnapsackProblem();

int main(void)
{
	int vi, wi, ret;

	// 配列の初期化
	for( int i = 0; i < MAX_N + 1; i++)
	{
		for(int j = 0; j < MAX_W; j++)
		{
			if( i == 0 || j == 0 )
			{
				// 品物を選んでいない, もしくは, 重量がゼロ
				Value[i][j] = 0;
			}
			else
			{
				Value[i][j] = INF;
			}
		}

	}

	cin >> N >> W;

	gV[0] = gW[0] = 0;

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

		gV[i] = vi;
		gW[i] = wi;
	}

	ret = KnapsackProblem();

	printf("%d\n", ret);

	return 0;

}

// ナップザック問題を解く関数
int KnapsackProblem()
{

	for(int i = 1; i <= N; i++)
	{
		for(int j = 1; j <= W; j++)
		{
			int weight = j - gW[i];

			if( weight >= 0 )
			{
				// i番目の品物を使う時
				Value[i][j] = Value[i - 1][weight] + gV[i];
			}
			else
			{
				// i番目の品物を使わない時
				Value[i][j] = Value[i - 1][j];
			}

			// 価値がより大きくなるように選択する
			Value[i][j] = max(Value[i - 1][j], Value[i][j]);
		}
	}

	return Value[N][W];
}



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

string s, r;

inline int cast(char c) {
	return (int)(c - '0');
}

int main(){
	bool fg;
	int a, b;
	while (cin >> s) {
		fg = false;
		r = "";
		if (s.size() % 2 != 0) {
			cout << "NA" << endl;
			continue;
		}
		for (int i = 0; i < s.size(); i += 2) {
			a = cast(s[i]), b = cast(s[i + 1]);
			if (a > 6 || b > 5 || a < 1 || b < 1) {
				fg = true;
				break;
			}
			if (a < 6) {
				r += ('a' + ((a - 1) * 5 + (b - 1)));
			}
			else {
				switch (b) {
				case 1:r += 'z';
					break;
				case 2:r += '.';
					break;
				case 3:r += '?';
					break;
				case 4:r += '!';
					break;
				case 5:r += ' ';
					break;
				default:break;
				}
			}
		}
		if (fg) {
			cout << "NA" << endl;
		}
		else {
			cout << r << endl;
		}
	}

	return 0;
}

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

class Program
{
    static void Main(string[] args)
    {
        var count = int.Parse(Console.ReadLine());
        var nums = Console.ReadLine().Split(' ');

        var n = 1;
        var result = 0;

        for(var i = 0; i < count; i++)
        {
            if (int.Parse(nums[i]) == n)
            {
                n += 1;
            }
            else
            {
                result++;
            }
        }
        if(result == count)
        {
            result = -1;
        }

        Console.WriteLine(result);
        Console.ReadLine();
    }
}

Measured memory_bytes: 29020
object Main extends App {
  val n = scala.io.StdIn.readLine.toInt
  val ans = {
    //println(n / 1.08)
    val tmp = (n / 1.08).toInt
    if ((tmp * 1.08).toInt == n) {
      tmp.toString
    } else {
      if (((tmp - 1) * 1.08).toInt == n) {
        (tmp - 1).toString
      } else if (((tmp + 1) * 1.08).toInt == n) {
        (tmp + 1).toString
      }
      else {
        ":("
      }
    }
  }

  println(ans)
}


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

struct Pos {
	int y, x;
	Pos() {}
	Pos(int y, int x) { this->y = y; this->x = x; }
	bool operator<(const Pos &r) const { return (y != r.y) ? y < r.y : x < r.x; }
};

int n, m;
Pos arm[100000];
int dp[2][100000];

//?§??????????(dir=0:???, dir=1:???), (?????£????????£???)??¢???????????????id, ??????????????????????????´???(0-indexed)?????????
int dfs(int dir, int id) {
	int nextId;

	if (dp[dir][id] != -1) {
		return dp[dir][id];
	}
	
	if (dir == 0) {
		nextId = upper_bound(arm, arm + m, Pos(arm[id].y - 1, arm[id].x)) - 1 - arm;
		if (nextId < 0 || arm[nextId].y != arm[id].y - 1) return arm[id].y;
		return dp[dir][id] = dfs(dir, nextId);
	}
	
	nextId = upper_bound(arm, arm + m, Pos(arm[id].y + 1, arm[id].x)) - 1 - arm;
	if (nextId < 0 || arm[nextId].y != arm[id].y + 1) return arm[id].y + 1;
	return dp[dir][id] = dfs(dir, nextId);
}

int main() {
	int i, j;
	
	cin >> n >> m;
	for (i = 0; i < m; i++) { cin >> arm[i].x >> arm[i].y; arm[i].y--; }
	sort(arm, arm + m);
	
	for (i = 0; i < 2; i++) for (j = 0; j < m; j++) dp[i][j] = -1;
	
	int id;
	for (i = 0; i < n; i++) {
		id = lower_bound(arm, arm + m, Pos(i, -1)) - 1 - arm;
		int low  = ((id < 0 || arm[id].y != i - 1) ? i : dfs(0, id));
		id = lower_bound(arm, arm + m, Pos(i + 1, -1)) - 1 - arm;
		int high = ((id < 0 || arm[id].y != i) ? i : dfs(1, id));
		cout << high - low + 1;
		if (i + 1 < n) cout << " ";
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 7776
#include <iostream>
#include <string>
#include <math.h>
#include <vector>
using namespace std;
int main()
{
    int ans, A, B, K, itr;
    int count = 0;
    vector<int> N;

    cin >> A >> B >> K;

    for (int i = 1; i <= min(A, B); i++)
    {
        if (A % i == 0 && B % i == 0)
        {
            N.push_back(i);
        }
    }
ans=N.at( N.size() - K);
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3584
#include <cmath>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <functional>
#include <queue>
#include <iostream>
#include <string.h>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <cstdint>
#include <climits>
#include <unordered_set>
#include <sstream>
#include <stack>

using namespace std;

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

using namespace std;

void solve()
{
    int n;
    cin >> n;
    while(n > 0)
    {
        if(n % 10 == 9)
        {
            cout << "Yes" << endl;
            return;
        }
        n /= 10;
    }
    cout << "No" << endl;
    return;
}

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

Measured memory_bytes: 256
N, K = map(int, input().split())

A_list = [[0, j] for j in range(N)]
B_list = [0] * N

for i in range(N):
    A_list[i][0], B_list[i] = map(int, input().split())

A_list.sort()
sort_key = [j[1] for j in A_list]
B_list_sort = [B_list[j] for j in sort_key]

for i in range(10 ** 5):
    K -= B_list_sort[i]
    if K <= 0:
        print(A_list[i][0])
        break


Measured memory_bytes: 25444