akhauriyash/Code-Regression huggingface dataset:
/**********WRITTEN BY ALMOREX***********/
/*
CodeChef:almorex
CodeForces:almorex011
*/
#include<bits/stdc++.h>
#define mod 1000000007
#define pb push_back
#define pop pop_back
#define test unsigned long long int test; cin >> test; while(test--)
#define show(x) cout<<(#x)<<"is"<<(x)<<"\n";
typedef unsigned long long int ull;
typedef long long int ll;
using namespace std;
int main(int argc, char const *argv[])
{
    ios_base :: sync_with_stdio(false);
    cin.tie(NULL);
    int s,w;
    cin >> s >> w;
    if (w>=s)
    {
        cout << "unsafe" << endl;
    }
    else
    {
        cout << "safe" << endl;
    }
    return 0;
}
/***********WRITTEN BY ALMOREX***********/

Measured memory_bytes: 3652
from collections import defaultdict, deque
import sys
#input = sys.stdin.readline
def inpl(): return list(map(int, input().split()))
N = int(input())
A = sorted(inpl())
if A[-1] < 0:
    print(A[-1] - sum(A[:-1]))
    for i in range(N-2, -1, -1):
        print(A[-1], A[i])
        A[-1] -= A[i]
else:
    print(sum(map(abs, A[1:])) - A[0])
    for i in range(N-2, 0, -1):
        a = A[i]
        if a > 0:
            print(A[0], a)
            A[0] -= a
        else:
            print(A[-1], a)
            A[-1] -= a
    print(A[-1], A[0])


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

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

  int c[10][10] = {};

  for (size_t i = 1; i <= N; i++) {
    string s = to_string(i);
    c[s[0] - '0'][s.back() - '0']++;
  }

  ll ret = 0;
  for (size_t i = 1; i < 10; i++) {
    for (size_t j = 1; j < 10; j++) {
      ret += c[i][j] * (ll)c[j][i];
    }
  }
  cout << ret << endl;
}

Measured memory_bytes: 256
/*Kadai4_3
  saitomo*/

#include<stdio.h>

int snow(int height_A,int height_B);
//プロトタイプ宣言
int main (void){
    int exs_tower_A,exs_tower_B;
    //晒されたタワーの高さを定義
    scanf("%d%d",&exs_tower_A,&exs_tower_B);
    printf("%d\n", snow(exs_tower_A,exs_tower_B));
    //関数を使い答えを出す
    return 0;
}




//関数を定義
int snow(int exs_tower_A,int exs_tower_B){
    int tower_dif , tower_A , snowfall;
    //塔の高さの差、Aの高さ、積雪量
    tower_dif=exs_tower_B-exs_tower_A;
    tower_A=(tower_dif-1)*tower_dif/2;
    //塔Aの高さは1から（（塔Aと塔Bとの高さの差）-1）までを足し合わせたものなので計算する
    snowfall=tower_A-exs_tower_A;
    //積雪量を出す
    return(snowfall);
}

Measured memory_bytes: 128
// 問題の URL を書いておく
// 

#include <algorithm>
#include <array>
#include <bitset>
#include <cmath>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>

using namespace std;

//#define ENABLE_PRINT

#if defined(ENABLE_PRINT)

#define Print(v) \
do {\
    cout << #v << ": " << v << endl; \
}while(0)

#define PrintVec(v) \
do {\
    for(int __i = 0; __i < v.size(); ++__i) \
    { \
        cout << #v << "[" << __i << "]: " << v[__i] << endl; \
    }\
}while(0)

#else

#define Print(v) ((void)0)
#define PrintVec(v) ((void)0)

#endif

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

using ll = int64_t;

int main(int, const char**)
{
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    
    rep(i, n)
    {
        cin >> a[i];
    }

    rep(i, n - k)
    {
        if(a[k + i] > a[i])
        {
            cout << "Yes" << endl;
        }
        else
        {
            cout << "No" << endl;
        }
    }
    return 0;
}


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

using namespace std;

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

    int M, D;
    cin >> M >> D;
    int res = 0;
    for (int d1 = 2; d1 <= 9; ++d1) {
        for (int d2 = 2; d2 <= 9; ++d2) {
            if (d1 + 10 * d2 <= D && d1 * d2 <= M) {
                ++res;
            }
        }
    }
    cout << res << "\n";
    
    return 0;
}

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

int main() {
	int n;
	string com;
	map<string, int> dic;
	cin >> n;
	string str;
	int cnt = 0;
	for (int i = 0; i < n; i++) {
		cin >> com >> str;
		if (com[0] == 'i') {
			dic.insert(pair<string,int>(str, cnt));
			cnt++;
		}
		else {
			int ret = dic.count(str);
			if (ret == 1)
				cout << "yes" << endl;
			else
				cout << "no" << endl;
		}
	}
	return 0;
}

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

using namespace std;

struct UnionFind {
    vector<int> par;
    vector<int> rank;
    
    UnionFind(int n) : par(n), rank(n, 0) {
        for (int i = 0; i < n; i++) par[i] = i;
    }

    int root(int x){
        if (par[x] == x) return x;
        else return par[x] = root(par[x]);
    }

    bool issame(int x, int y){
        return (root(x) == root(y));
    }


    void unite(int x, int y){
        int rx = root(x);
        int ry = root(y);
        if (rx == ry) return;
        if (rank[rx] < rank[ry]) par[rx] = ry;
        else {
            par[ry] = rx;
            if (rank[rx] == rank[ry]) rank[rx]++;
        }
    }
    /*
    void unite(int x, int y){
        x = root(x);
        y = root(y);
        if (x == y) return;
        par[x] = y;
    }*/
};

int main(){
    int N ,M;
    cin >> N >> M;

    vector<int> a(M), b(M);

    for (int i = 0; i < M; i++){
        cin >> a[i] >> b[i];
        a[i]--;
        b[i]--;
    }

    int ans = 0;
    for (int i = 0; i < M; i++){
        UnionFind tree(N);

        for (int j = 0; j < M; j++){
            if (j == i) continue;
            tree.unite(a[j], b[j]);
        }
        if (!tree.issame(a[i], b[i])) ans++;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
string s,t;
int main(){
    cin >> s >> t;
    vector<string> vs;
    rep(i,s.size() -t.size()+1){
        string nows = s;
        int id = i;
        bool ok = 1;
        rep(j,t.size()){
            if(nows[id]!=t[j] && nows[id]!='?') ok = 0;
            else nows[id] = t[j];
            id++;
        }
        while(id<nows.size()){
            if(nows[id]=='?') nows[id]='a';
            id++;
        }
        rep(j,i) if(nows[j]=='?') nows[j] = 'a';
        if(ok) vs.push_back(nows);
    }
    sort(vs.begin(),vs.end());
    if(vs.size()==0) cout<<"UNRESTORABLE"<<endl;
    else cout << vs[0] << endl;
    return 0;
}

Measured memory_bytes: 256
package main
import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func newScanner() *bufio.Scanner {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	return scanner
}

func scanInt() int {
	sc.Scan()
	v, _ := strconv.Atoi(sc.Text())
	return v
}

func scanInts(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = scanInt()
	}
	return a
}

func scanString() string {
	if sc.Scan() {
		return sc.Text()
	}
	panic(sc.Err())
}

var sc = newScanner()

func main() {
	n := scanInt()
	a := scanInts(n)
	b := make([]int, n)
	m := make(map[int]int)
	for i := 0; i < n; i++ {
		b[i] = -a[i] + i + 1
		t := a[i] + i + 1
		m[t]++
	}

	var ans int
	for i := 0; i < n; i++ {
		ans += m[b[i]]
	}
	fmt.Println(ans)
}

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

int main() {
  string s;
  cin >> s;

  for(int i = 0; i < s.size()-1; i++) {
    if(s[i] == s[i+1]) {
      cout << "Bad" << endl;
      return 0;
    }
  }
  cout << "Good" << endl;


}



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

int main()
{
    int a, b;
    cin >> a >> b;
    string a1, b1;
    char aa, bb;
    aa = '0' + a;
    bb = '0' + b;

    rep(i, b)
    {
        a1.push_back(aa);
    }
    rep(i, a)
    {
        b1.push_back(bb);
    }

    if (a < b)
    {
        cout << a1 << endl;
    }
    else
    {
        cout << b1 << endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h> 
#define Pair pair<int, double>
#define MP(x, y) make_pair(x, y)
#define fi first
#define se second
//#define int long long 
#define LL long long 
#define Fin(x) {freopen(#x".in","r",stdin);}
#define Fout(x) {freopen(#x".out","w",stdout);}
using namespace std;
const int MAXN = 1e6 + 10, mod = 998244353, INF = 2e9 + 10;
const double eps = 1e-9;
inline int read() {
    char c = getchar(); int x = 0, f = 1;
    while(c < '0' || c > '9') {if(c == '-') f = -1; c = getchar();}
    while(c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
    return x * f;
}
int N, a[MAXN];
signed main() {
    N = read();
    for(int i = 1; i <= N; i++) a[i] = read();
    sort(a + 1, a + N + 1, greater<int>());
    for(int i = 1; i <= N; i++) {
        if(i + 1 > a[i + 1]) {
            if((a[i] - i) & 1) {puts("First"); return 0;}
            int j;
            for(j = i + 1; a[j] == i; j++); 
            if(!((j - i) & 1)) {puts("First"); return 0;}
            puts("Second"); return 0;
        }
    }
    return 0;
}

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

#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = (n)-1; i >= 0; i--)
#define rep1(i,n) for(int i = 1; i <= (n); i++)
#define rrep1(i,n) for(int i = (n); i > 0; i--)

#define ll long long
#define pi pair<int, int>
#define pll pair<ll, ll>

#define MOD 1000000007
#define INF 1000000000000000LL

using namespace std;

int main(){
  int n;cin>>n;
  n%=10;
  if(n==3)cout<<"bon"<<endl;
  else if(n==0 || n==1 || n==6 || n==8)cout<<"pon"<<endl;
  else cout<<"hon"<<endl;

  return 0;
}

Measured memory_bytes: 3636
#include <stdio.h>

int comp(char *in1, char *in2)
{
	int i, j, p;
	int max;
	int len;

	max = 0;
	j = 0;
	while (in1[j] != '\0'){
		len = 0;

		p = 0;
		while (in1[j + p] != '\0' && in2[p] != '\0'){
//printf("(%c %c)", in1[j + p], in2[p]);
			if (in1[j + p] == in2[p]){
				len++;
			}
			else {
				if (max < len){
//printf("%d", len);
					max = len;
				}
				len = 0;
			}
			p++;
		}
		if (max < len){
			max = len;
		}
		j++;
	}
	return (max);
}

int main(void)
{
	char in1[4001], in2[4001];
	int max1, max2;
	
	while (scanf("%s", in1) != EOF){
		scanf("%s", in2);
		
		max1 = comp(in1, in2);
		max2 = comp(in2, in1);

		if (max1 > max2){
			printf("%d\n", max1);
		}
		else {
			printf("%d\n", max2);
		}
	}
	return (0);
}

Measured memory_bytes: 548
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <functional>

using namespace std;
 
#define mod 1000000007
#define FOR(x,to) for(int x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define long long long
inline int rei(){int x;cin>>x;return x;}
inline long rel(){long x;cin>>x;return x;}
inline string res(){string x;cin>>x;return x;}
//------------------------------------------------------- 
void Calc(){
	int N = rei();
	int X = rei();
	int d = 0;
	int c = 1;
	for(int i=0;i<N;i++){
		int r = rei();
		d += r;
		if(d <= X){
			c++;
		}
	}
	cout << c << endl;
}
int main(int argc,char** argv){
	ios::sync_with_stdio(false), cin.tie(0);
	cout.tie(0); Calc(); return 0;
}

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

using namespace std;

int H, W, A, B;

int ans[1005][1005];

int main(){
    cin>>H>>W>>A>>B;

    for(int i=1;i<=H;++i){
        for(int j=1;j<=W;++j){
            if((i<=B&&j<=A)||(i>B&&j>A)){
                cout<<"1";
            }else{
                cout<<"0";
            }
        }
        cout<<endl;
    }

    return 0;
}


Measured memory_bytes: 3640
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;
#define rep(i, begin, n) for (int i = begin; i < n; i++)
#define repe(i, begin, n) for (int i = begin; i <= n; i++)
#define repr(i, begin, n) for (int i = begin; i > begin - n; i--)
#define repre(i, begin, end) for (int i = begin; i >= end; i--)

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

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

const int inf = INT_MAX;
const int MOD = 1000000007;
const long long INF = LLONG_MAX;

// -------------------------------------------------------

ll D;
ll c[30];
ll s[400][30];
ll t[400];
ll last[30];
ll score;

ll calc_score(ll day, ll ct) {
  ll res = 0;
  ll last_tmp[30];
  rep(i, 1, 26) { last_tmp[i] = last[i]; }

  res += s[day][ct];
  last_tmp[ct] = day;

  repe(i, 1, 26) { res -= c[i] * (day - last_tmp[i]); }

  return res;
}

int main() {
  cin >> D;
  repe(i, 1, 26) { cin >> c[i]; }
  repe(i, 1, D) {
    repe(j, 1, 26) { cin >> s[i][j]; }
  }

  repe(i, 1, D) {
    ll ct;
    ll gain = -INF;
    repe(j, 1, 26) {
      if (chmax(gain, calc_score(i, j))) {
        ct = j;
      }
    }

    score += gain;
    last[ct] = i;

    cout << ct << "\n";
  }
}


Measured memory_bytes: 3740
#include <bits/stdc++.h>
#define PB push_back
#define LL long long
const int mod = 924844033;
using namespace std;
LL p = 235743;
LL pwr[500005];
LL pref[500005];
LL mult(LL a , LL b)
{
	return (a * (LL)b) % mod;
}
LL add(LL a , LL b)
{
	return (a + b) % mod;
}
LL sub(LL a , LL b)
{
	return (a - b + mod) % mod;
}
LL hsh(int l , int r)
{
	return sub(pref[r] , (l ? pref[l - 1] : 0));
}
bool check(string s , int div)
{
	for(int i = div; i < s.size(); i += div)
	{
		if(mult(hsh(0 , div - 1) , pwr[i]) != hsh(i , i + div - 1))
		{
			return false;
		}
	}
	return true;
}
bool good(string s)
{
	bool res = true;
	for(int div = 1; div < s.size(); div++)
	{
		if(s.size() % div == 0)
		{
			res &= !check(s , div);
		}
	}
	return res;
}
int bad1[500005];
int bad2[500005];
int main()
{
	pwr[0] = 1;
	for(int i = 1; i <= 500000; i++)
	{
		pwr[i] = mult(p  ,pwr[i - 1]);
	}
	ios_base::sync_with_stdio(0);
	string s;
	cin >> s;
	for(int i = 0; i < s.size(); i++)
		pref[i] = add(mult(s[i] , pwr[i]) , (i ? pref[i - 1] : 0));
	
	bool allEq = true;
	for(auto x : s)
		allEq &= s[0] == x;
	if(allEq)
	{
		cout << s.size() << endl << 1 << endl;
		return 0;
	}
	if(good(s))
	{
		cout << 1 << endl << 1 << endl;
		return 0;
	}
	for(int len = 1; len <= s.size(); len++)
	{
		for(int i = len; i + len <= s.size(); i += len)
		{
			
			if(mult(hsh(0 , len - 1) , pwr[i]) == hsh(i , i + len - 1))
			{
				bad1[i + len] = 1;
			}
			else
				break;
		}
	}
	reverse(s.begin() , s.end());
	for(int i = 0; i < s.size(); i++)
		pref[i] = add(mult(s[i] , pwr[i]) , (i ? pref[i - 1] : 0));
	
	for(int len = 1; len <= s.size(); len++)
	{
		for(int i = len; i + len <= s.size(); i += len)
		{
			if(mult(hsh(0 , len - 1) , pwr[i]) == hsh(i , i + len - 1))
			{
				bad2[i + len] = 1;
			}
			else
				break;
		}
	}
	int ways = 0;
	for(int i = 1; i < s.size(); i++)	
	{
		ways += !bad1[i] && !bad2[s.size() - i];
	}
	cout << 2 << endl << ways << endl;
	return 0;
	
}


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

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using WGraph = vector<vector<pair<int, ll>>>;

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

constexpr int dx[4] = {-1, 0, 0, 1}, dy[4] = {0, -1, 1, 0};
constexpr int INF = 1e9;
constexpr int MOD = 1e9 + 7;
constexpr long long LINF = 1e18;
constexpr double EPS = 1e-10;
constexpr double PI = M_PI;

void solve() {
    int n;
    ll k;
    cin >> n >> k;
    vector<int> a(n);
    for (int i=0; i<n; ++i) {
        cin >> a.at(i);
        a.at(i)--;
    }

    int cur = 0;
    int cnt = 0;
    vector<int> visit(n, -1);
    visit.at(0) = 0;
    while (true) {
        cur = a.at(cur);
        ++cnt;
        if (cnt == k) {
            cout << cur + 1 << '\n';
            return;
        } else if (visit.at(cur) != -1) {
            ll loop = cnt - visit.at(cur);
            ll m = (k - cnt) % loop;
            for (int i=0; i<m; ++i) {
                cur = a.at(cur);
            }
            cout << cur + 1 << '\n';
            return;
        } else {
            visit.at(cur) = cnt;
        }
    }
}

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

    solve();

    return 0;
}


Measured memory_bytes: 4788
#include <iostream>
#include <vector>
using namespace std;
using ll = long long;
const ll MOD = 1e9 + 7;

const int N = 10;
pair<ll, ll> dp[N][N];

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

	for (int a = 0; a < N; ++a) {
		for (int b = 0; b < N; ++b) dp[a][b] = {-1, -1};
	}

	int n;
	cin >> n;

	ll res = -1; // Initial combine with tp
	int tp = 0;
	for (int i = 0; i < n; ++i) {
		int d;
		ll c;
		cin >> d >> c;
		
		--c;
		int cur = d;
		while(true) {
			// cerr << i << ' ' << tp << ' ' << cur << ": " << c << ' ' << res << '\n';
			if (dp[tp][cur].first != -1) {
				ll res_diff = res - dp[tp][cur].first;
				ll c_diff = dp[tp][cur].second - c;

				ll t = c / c_diff;
				c -= c_diff * t;
				res += res_diff * t;
			} else {
				dp[tp][cur] = {res, c};
			}

			++res;
			if (cur + tp >= 10) {
				cur = (cur + tp) % 10;
				tp = 1;
			} else {
				tp += cur;
				if (c == 0) break;

				cur = d;
				--c;
			}
		}
		for (int a = 0; a < N; ++a) {
			for (int b = 0; b < N; ++b) dp[a][b] = {-1, -1};
		}
	}
	cout << res << '\n';
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;
#define int long long
#define _CRT_SECURE_NO_WARNINGS
#define rep(i, n) for (int i = 0; i < n; i++)
#define _GLIBCXX_DEBUG
const int MOD = 1e9 + 7;
const int INF = 1e18 + 9;
constexpr long double pi = 3.141592653589793238462643383279; //円周率
/*---------------------便利な関数--------------------------------------*/
int fact(int i) {       //階乗
    if (i == 0) return 1;
    return (fact(i - 1)) * i;
}

int gcd(int a, int b) {        //最大公約数
    if (b == 0) return a;
    return gcd(b, a % b);
}

int lcm(int a, int b) {      //最小公倍数
    return a * b / gcd(a, b);
}

int keta(int n) {        //桁数を求める
    if (n == 0) return 1;
    int count = 0;
    while (n != 0) {
        n /= 10;
        count++;
    }
    return count;
}

int ketasum(int n) {    //各桁の和
    int sum = 0;
    while (n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
/*-------------ここまで---------------------------------------------*/

//C++(GCC9.2.1)

signed main() {
    //宣言
    string s;
    cin >> s;
    int n = s.size();
    string t = s;
    reverse(s.begin(), s.end());
    if (t != s)
        cout << "No";
    else
    {
        string s1 = s.substr(0, n / 2);
        string s2 = t.substr(0, n / 2);
        string t1 = s1, t2 = s2;
        reverse(s1.begin(), s1.end());
        reverse(s2.begin(), s2.end());
        if (t1 == s1 && t2 == s2)
            cout << "Yes";
        else
            cout << "No";
    }
    return 0;
}

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

# input
N = int(input())
D, X = map(int, input().split())
A = list()
for i in range(N):
    A.append(int(input()))

# solve
ans = [0] * D
for i in range(N):
    d = 1
    c = 1
    while d <= D:
        ans[d - 1] += 1
        d = c * A[i] + 1
        c += 1

# output
print(sum(ans) + X)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define MAX_N 100001
#define INF_INT 2147483647
#define INF_LL 9223372036854775807
#define REP(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> P;
void init(int n);
int find(int n);
void unite(int x,int y);
bool same(int x, int y);
ll bpow(ll,ll,ll);
typedef vector<int> vec;
typedef vector<vec> mat;
mat mul(mat &A,mat &B);
mat pow(mat A,ll n);
int dx[3] = {1,0,-1};
int dy[3] = {1,0,-1};
const int MOD = 1000000007;

bool cmp_P(const P &a,const P &b){
  return a.second < b.second;
}
int main()
{
  int N,K,cnt=1;
  cin >> N >> K;
  for(int i=0;i<N;i++){
    if(i == 0)
      cnt *= K;
    else
      cnt *= K-1;
  }
  cout << cnt << endl;
  return 0;  
}



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

int count(const vector<string> &a, int x, int y) {
  int count = 0;
  if (x-1 >= 0 and y-1 >= 0 and a[y-1][x-1] == '#')
    count += 1;
  if (y-1 >= 0 and a[y-1][x] == '#')
    count += 1;
  if (y-1 >= 0 and x+1 <= a[0].length()-1 and a[y-1][x+1] == '#')
    count += 1;
  if (x - 1 >= 0 and a[y][x-1] == '#')
    count += 1;
  if (x+1 <= a[0].length()-1 and a[y][x+1] == '#')
    count += 1;
  if (y+1 <= a.size()-1 and x - 1 >= 0 and a[y+1][x-1] == '#')
    count += 1;
  if (y+1 <= a.size()-1 and a[y+1][x] == '#')
    count += 1;
  if (y+1 <= a.size()-1 and x+1 <= a[0].length()-1 and a[y+1][x+1] == '#')
    count += 1;
  return count;
}

int main() {
  unsigned int H, W;
  cin >> H >> W;
  vector<string> a(H);
  for(int i = 0; i < H; ++i) {
    cin >> a[i];
  }

  for(int i = 0; i < H; ++i) {
      for(int j = 0; j < W; ++j) {
        if (a[i][j] == '.')
          cout << count(a, j, i);
        else
          cout << a[i][j];
      }
      cout << endl;
  }
}

Measured memory_bytes: 256
N, M = map(int, input().split())
a_list = [int(input()) for _ in range(M)]

mod = 10 ** 9 + 7

dp = [0 for _ in range(N+100)]
dp[0] = 1
a_set = set(a_list)

for i in range(N):
    if i in a_set:
        continue
    else:
        if 0 <= i <= N - 1:
            dp[i + 1] += dp[i]
            dp[i + 1] %= mod
        if 0 <= i <= N - 2:
            dp[i + 2] += dp[i]
            dp[i + 2] %= mod

print(dp[N] % mod)


Measured memory_bytes: 14100
n,x=map(int,input().split())
pati_kazu=[1]
atsusa=[1]
for i in range(n):
    pati_kazu.append(pati_kazu[i]*2+1)
    atsusa.append(atsusa[i]*2+3)

def dfs(level,z):
    if level==0:
        return 0 if z<=0 else 1
    elif z<=(1+atsusa[level-1]):
        return dfs(level-1,z-1)
    else:
        return 1+pati_kazu[level-1]+dfs(level-1,z-2-atsusa[level-1])

print(dfs(n,x))

Measured memory_bytes: 3064
N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

x = [0] * (N + 1)
y = [0] * (M + 1)
for i in range(N):
    x[i + 1] = x[i] + A[i]

for i in range(M):
    y[i + 1] = y[i] + B[i]

j = M
ans = 0
for i in range(N + 1):
    if x[i] > K:
        continue
    while j >= 0 and x[i] + y[j] > K:
        j -= 1
    ans = max(ans, i + j)
print(ans)


Measured memory_bytes: 118212
#include <stdio.h>
#include <string.h>
#define swap(type, x, y) {type tmp = x; x = y; y = tmp;}

int main(void) {
    char print[] = "print";
    char reverse[] = "reverse";
    char replace[] = "replace";
    char str[1001] = {'\0'};
    scanf("%s", str);
    int q, a, b, k;
    char p[1001] = {'\0'};
    char command[8]  = {'\0'};
    scanf("%d", &q);
    getchar();
    int BUF = 1100;
    char buff[BUF];

    while (fgets(buff, BUF, stdin) != NULL) {
        sscanf(buff, "%s %d %d %s", command, &a, &b, p);
        if (strcmp(command, print) == 0) {
            for (int j = a; j <= b; j++) {
                printf("%c", str[j]);
            }
            printf("\n");
        } else if (strcmp(command, reverse) == 0) {
            k = 0;
            int c = (a + b + 1) / 2;
            for (int j = b; j >= c; j--) {
                swap(char, str[j], str[a + k]);
                k++;
            }
        } else {
            for (int j = a; j <= b; j++) {
                str[j] = p[j - a];
            }
        }
    }
    return 0;
}


Measured memory_bytes: 2056
/* ＵＴＦ－８ */
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <array>
#include <queue>
#include <stack>
#include <algorithm>
#include <tuple>
#include <numeric>
#include <type_traits>
#include <limits>

#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <string.h>

#define USE_COLORED 1

#ifdef USE_COLORED
static const char stdout_pre[]  = "\033[1m"; // bold black
static const char stderr_pre[]  = "\033[31;1m"; // bold red
static const char stdxxx_post[] = "\033[m";

// 当然ながら GCC(g++)/libstdc++ 依存
#include <ext/stdio_filebuf.h>
using stdio_filebuf = __gnu_cxx::stdio_filebuf<char>;
class colored_stdio_filebuf : public stdio_filebuf {
private:
	const char* const pre_;
	const char* const post_;

public:
	colored_stdio_filebuf(FILE* fp, const char* pre, const char* post) : stdio_filebuf(fp, std::ios_base::out), pre_(pre), post_(post)
	{
	}

protected:
	std::streamsize xsputn(const char* s, std::streamsize count) override
	{
		stdio_filebuf::xsputn(pre_, strlen(pre_));
		auto ret = stdio_filebuf::xsputn(s, count);
		stdio_filebuf::xsputn(post_, strlen(post_));
		return ret;
	}
};
#endif

int main()
{
#ifdef USE_COLORED
	if (getenv("DEBUG")) {
		std::cout.rdbuf(new colored_stdio_filebuf(stdout, stdout_pre, stdxxx_post));
		std::cerr.rdbuf(new colored_stdio_filebuf(stderr, stderr_pre, stdxxx_post));
	} else
#endif
	{
		int fd = open("/dev/null", O_WRONLY);
		dup2(fd, 2);
		close(fd);
	}
	
	int N, K;
	std::cin >> N >> K;
	int result = K;
	for (int i = 1; i < N; ++i)
		result *= (K-1);
	std::cout << result << "\n";
}


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

typedef long long ll;

ll N, M;
vector<vector<pair<ll, ll>>> Conds;
// Dp[i][j][k]: coloring i boxes,
// the (1-indexed) j-th box is the leftest different color
// the (1-indexed) k-th box is the leftest yet different color
vector<vector<vector<ll>>> Dp;
const ll MOD = 1e9 + 7;
ll R;

int main() {
  cin >> N >> M;
  Conds.resize(N + 1);
  for (ll i = 0; i < M; ++i) {
    ll l, r, x;
    cin >> l >> r >> x;
    Conds[r].push_back(make_pair(l, x));
  }
  Dp.resize(N + 1);
  for (auto &dp : Dp) {
    dp.resize(N + 1);
    for (auto &dpx : dp) dpx.resize(N + 1);
  }
  Dp[1][0][0] = 3;
  for (ll i = 1; i <= N; ++i)
    for (ll j = 0; j <= max(i - 1, 0ll); ++j)
      for (ll k = 0; k <= max(j - 1, 0ll); ++k) {
        bool ok = true;
        for (auto cond : Conds[i]) {
          ll l, x;
          tie(l, x) = cond;
          ok = ok && (x == 1 ? j < l : x == 2 ? k < l && l <= j : l <= k);
        }
        if (!ok) Dp[i][j][k] = 0;
        if (i == N) continue;
        // same color
        (Dp[i + 1][j][k] += Dp[i][j][k]) %= MOD;
        // different color
        (Dp[i + 1][i][j] += Dp[i][j][k]) %= MOD;
        (Dp[i + 1][i][k] += Dp[i][j][k]) %= MOD;
      }
  ll R = 0;
  for (ll j = 0; j <= N - 1; ++j)
    for (ll k = 0; k <= max(j - 1, 0ll); ++k) {
      (R += Dp[N][j][k]) %= MOD;
    }
  cout << R << endl;
  return 0;
}


Measured memory_bytes: 216192
while True:
	m, f, r = map(int, input().split())
	if m == -1 and f == -1 and r == -1:
		break
	if m == -1 or f == -1:
		print("F")
	elif m + f >= 80:
		print("A")
	elif m + f >= 65:
		print("B");
	elif m + f >= 50:
		print("C")
	elif m + f >= 30:
		if r >= 50:
			print("C")
		else:
			print("D")
	else:
		print("F")


Measured memory_bytes: 5596
import java.util.*;
import static java.lang.Math.*;
import java.math.BigInteger;

public class Main {

	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		// 入力
		int d = sc.nextInt();

		// 計算
	    String result = "";
		if(d == 25) result = "Christmas";
		if(d == 24) result = "Christmas Eve";
		if(d == 23) result = "Christmas Eve Eve";
		if(d == 22) result = "Christmas Eve Eve Eve";
		
		// 出力
		System.out.println(result);
        
	}
}


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

int main() {
  int N;
  cin >> N;
  
  vector<int> topcodeer(N);
  
  for(int i = 0; i < N; i++){
    cin >> topcodeer.at(i);
  }
  
  sort(topcodeer.begin(), topcodeer.end());
  
  cout << topcodeer.back() - topcodeer.front() << endl;
}

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

int main(){
  int H, W;
  cin >> H >> W;
  vector<string>low(H);
  for(int i=0; i<H; i++){
    cin >> low.at(i);
  }
  for(int i=0; i<(W+2); i++){
    cout << '#';
  }
  cout << endl;
  for(int j=0; j<H; j++){
    cout << '#' << low.at(j) << '#' << endl;
  }
  cout << endl;
  for(int i=0; i<(W+2); i++){
    cout << '#';
  }
  cout << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 10000000000000000

pair<int,int> check(vector<long long> &A,long long X,long long C){
	int N = A.size();
	
	int R = N-C-1;
	int L = R-C+2;
	//cout<<C<<','<<L<<','<<R<<endl;
	pair<int,int> failed(-1,-1);
	if(L<0)return failed;

	
	if(abs(A[L]-X)>abs(A[R+1]-X))return failed;
	
	if(L!=0)L--;
	
	return make_pair(L,R);
}


int main(){
	
	int N,Q;
	cin>>N>>Q;
	
	vector<long long> A(N);
	for(int i=0;i<N;i++)cin>>A[i];
	
	vector<long long> S(N+1,0);
	for(int i=0;i<N;i++){
		S[i+1] = S[i] + A[i];
	}
	
	vector<long long> S2(N+1,0);
	
	for(int i=0;i<N;i++){
		S2[i+1] = A[i];
		if(i-1>=0)S2[i+1] += S2[i-1];
	}
	
	for(int i=0;i<Q;i++){
		long long X;
		cin>>X;
		
		long long ok = 1;
		long long ng = N+1;
		while(ng-ok>1){
			long long mid = (ok+ng)/2;
			auto ret = check(A,X,mid);
			if(ret.first==-1)ng = mid;
			else ok = mid;
		}
		//cout<<ok<<endl;
		long long ans = S.back() - S[N-ok];
		auto ret = check(A,X,ok);

		ans += S2[ret.first];
		cout<<ans<<endl;
	}
		
	
	return 0;
}

Measured memory_bytes: 4096
#include<iostream>
#include<vector>
int main(){
	while(1){
		int a,b;
		std::cin>>a>>b;
		if(a==0&&b==0)break;
		std::vector<int> vec(4);
		std::vector<int> vec2(4);
		int n=1000;
		for(int i=0;i<4;i++){
			int x=a/n;
			int y=b/n;
			vec[i]=x;
			vec2[i]=y;
			x*=n;
			y*=n;
			a-=x;
			b-=y;
			n/=10;
		}
			int c=0,d=0;
		for(int i=0;i<4;i++){
			for(int j=0;j<4;j++){
				if(vec[i]==vec2[j]){
					if(i==j)c++;
					else d++;
				}
			}
		}

		std::cout<<c<<" "<<d<<std::endl;
	}
	return 0;
}

Measured memory_bytes: 1192
#include <iostream>
#include <vector>
#include <cstdio>
#include <queue>
#include <algorithm>
#include <functional>
#include <string>
#include <queue>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <numeric>
#define ll long long
#define fr(i,k,N) for(ll i=k; i<N;i++)
#define rep(i,N) for(ll i=0; i<N;i++)
#define ALL(v) v.begin(),v.end()
#define mp make_pair
using namespace std;
template <class X> void pr(X test){cout<<test<<endl;}
template <class X> void prr(X test){for(auto it:test){cout<<it<<endl;}}
template <class X> void prrr(X test){int f=0;for(auto it:test){cout<<(f++!=0?" ":"")<<it;}cout<<endl;}
template<typename X>
istream&operator>>(istream&i,vector<X>&v){for(X&x:v)i>>x;return i;}

class UF { // union find from https://github.com/kartikkukreja/blog-codes (MIT)
    // [usage]
    // auto uf = new UF(n);
    // uf->merge(l, r); // 0 <= l, r <= n-1
    // ...
public:
    int *id; // inner id
    int cnt; // number of all vartices
    int *sz; // sz[i] means size of i's set
    UF(int N)   {
        cnt = N;
        id = new int[N];
        sz = new int[N];
        for(int i=0; i<N; i++) {
            id[i] = i;
            sz[i] = 1;
        }
    }
    ~UF() {
        delete [] id;
        delete [] sz;
    }
    int find(int p) {
        int root = p;
        while (root != id[root]) root = id[root];
        while (p != root) {
            int newp = id[p];
            id[p] = root;
            p = newp;
        }
        return root;
    }
    void merge(int x, int y) {
        int i = find(x);
        int j = find(y);
        if (i == j) return;
        
        if (sz[i] < sz[j]) {
            id[i] = j;
            sz[j] += sz[i];
        } else {
            id[j] = i;
            sz[i] += sz[j];
        }
        cnt--;
    }
    bool connected(int x, int y) {
        return find(x) == find(y);
    }
    int count() {
        return cnt;
    }
};

// return sorted 約数list 1 <= x <= n
vector<ll> divv(ll n) {
  vector<ll> v;
  for(ll i = 1; i*i <= n; i++) {
    if(n%i == 0) {
      v.push_back(i);
      if(i*i != n) v.push_back(n/i);
    }
  }
  sort(ALL(v));
  return v;
}

int main() {
    ll s;

    cin>>s;
    vector<ll> h(s);
    cin>>h;
    ll now = 0,last = 0, cnt = 0;
    rep(i, s){
        if(last >= h[i]) now+=1;
        else now =0;
        cnt = max(cnt, now);
        last = h[i];
    }
    pr(cnt);
    
}


Measured memory_bytes: 1024
#include<stdio.h>
#define N 100000
 
int A[N + 1];
 
int Partition(int p, int r){
  int x, i, j, arr;
  x = A[r];
  i = p - 1;
  for(j = p; j < r; j++){
    if(A[j] <= x){
      i++;
      arr = A[i];
      A[i] = A[j];
      A[j] = arr;
    }
  }
  arr = A[i + 1];
  A[i + 1] = A[r];
  A[r] = arr;
 
  return i + 1;
}
 
 
main(){
  int i, r, q, p = 0;
   
  scanf("%d", &r);
  for(i = 0; i < r; i++){
    scanf("%d", &A[i]);
  }
   
  q = Partition(p, r - 1);
  for(i = 0; i < r; i++){
    if(i == q){
      printf("[%d]", A[i]);
    } else {
      printf("%d", A[i]);
    }
 
    if(i != r - 1){
     printf(" ");
    }
  }
  printf("\n");
  return 0;
}

 
	   	
 

Measured memory_bytes: 992
#include <iostream> // cout, endl, cin
#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 <cmath>
using namespace std;

int main() {
    string s;
    cin >> s;
    int n = s.size();
    long mod = 1000000007;
    vector<vector<long>> dp(n+1,vector<long>(13));
    dp[0][0] = 1;
    for (int i = 0; i < n; i++) {
        int c;
        if (s[i] == '?') {
            c = -1;
        }
        else {
            c = s[i] - '0';
        }
        for (int j = 0; j < 10; j++) {
            if (c == -1 || c == j) {
                for (int k = 0; k < 13; k++) {
                    dp[i+1][(k * 10 + j) % 13] += dp[i][k];
                }
            }
        }
        for (int j = 0; j < 13; j++) {
            dp[i+1][j] %= mod;
        }
    }
    cout << dp[n][5] << endl;
}


Measured memory_bytes: 13696
N , L = (int(a) for a in input().split())
apple = []
for i in range (1,N+1) :
    apple.append(L + i - 1)

if L >= 0 :
    del apple[0]
elif N + L <= 1 :
    del apple[-1]
else : del apple[abs(L)]

print(sum(apple))


Measured memory_bytes: 3060
#include<stdio.h>
#include<string.h>
int main(void)
{
    int i=0,j=0,h=0;
    char s[101];
    scanf("%s",s);
    j=strlen(s)-1;
    while(s[i]!='\0'){
        if(s[i]!=s[j]){
            s[i]=s[j];
            h++;
        }
        i++;
        j--;
    }
    printf("%d\n",h);
    return 0;
}

Measured memory_bytes: 1732
#include <iostream>
#include <vector>
#include <algorithm>
#include <string.h>
#include <iomanip>
#include <math.h>

typedef long long int ll;

#define FOR(i,n,m) for(ll i=(ll)(m);i<(ll)(n);++i)
#define REP(i,n) FOR(i,n,0)
#define IREP(i,n) for(ll i=(ll)(n);i>=0;--i)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;

using namespace std;

int A[100005];
int B[100005];

int main()
{
	int N;
	cin >> N;
	REP(i, N)
	{
		cin >> A[i];
	}
	sort(A, A + N);
	REP(i, N)
	{
		B[A[i]]++;
	}
	int ans = 0;
	sort(B, B + 100005);
	REP(i, 100005)
	{
		if (B[i] == 0)continue;
		ans++;
		if (B[i] % 2 == 0)
		{
			if (i < 100004)
			{
				B[i + 1]--;
			}
			else
			{
				ans--;
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1024
def calc(s):
    if s == 'SUN':
        return 7
    elif s == 'MON':
        return 6
    elif s == 'TUE':
        return 5
    elif s == 'WED':
        return 4
    elif s == 'THU':
        return 3
    elif s == 'FRI':
        return 2
    else:
        return 1


s = input()
print(calc(s))

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

//data types
typedef long long ll;
typedef long li;
typedef int ii;
typedef float ff;
typedef double dd;
typedef long double pp;
typedef vector<int> vi;
typedef pair<int,int> pi;

//vector and pair components
#define f first
#define s second
#define push_back pb
#define make_pair mp

//loops
#define for1(i,v,m) for(i=v;i<=m;i++)
//#define rev(v,x,z) for(v=x;v>=z;v--)
//#define inf(m,j,k) for(m=j;m>=k;m++)

ii main()
{

    ii k,a,b,i;

    cin>>k;
    cin>>a>>b;

    for1(i,a,b)
    {

         if(i%k==0)
         {
             
             cout<<"OK"<<"\n";
             
             break;
             
         }




    }

    if(i==b+1)
    {
        
        
        cout<<"NG"<<"\n";
        
    }


}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
    using namespace std;
    typedef long long ll;
    #define FAST ios_base::sync_with_stdio(false);cin.tie(0);
    const double EPS = 1e-9;
    const double PI = acos(-1);
    const int knightDir[8][2] = {{-2,-1},{-2,1},{-1,2},{1,2},{2,-1},{2,1},{-1,-2},{1,-2}};
    //const int dx[]={0,0,0,1,1,1,-1,-1,-1};
    //const int dy[]={-1,0,1,-1,0,1,-1,0,1};
    const int dx[] = {0 , 1 , 0 , -1};
    const int dy[] = {1 , 0 , -1 , 0};
    //#define MOD         1000000007LL
    #define MAX         1000005
    const ll MOD = 1000000000 + 7;
    
    int main()
    {
        FAST
        int t;
        t = 1;

        while(t--)
        {
           int n;
           cin >> n;
           
           vector<int> arr(n);
           
           for(int i = 0 ; i < n ; i++)
           {
               cin >> arr[i];
           }
           
           sort(arr.begin() , arr.end() , greater<int>());
           
           ll sum = arr[0];
           int flag = 0 , k = 1;
           for(int i = 1 ; i < n - 1 ; i++)
           {
               sum += arr[k];
               flag++;
               if(flag == 2)
               {
                   flag = 0;
                   k++;
               }
           }
           
           cout << sum << endl;
        }
    }



Measured memory_bytes: 3928
from collections import deque
import bisect

INF = float("inf")

N,M = map(int,input().split())

xtic = {0,-INF,INF}
ytic = {0,-INF,INF}

hor = []
for _ in range(N):
  a,b,c = map(int,input().split())
  hor.append((c,a,b))
  xtic.add(a)
  xtic.add(b)
  ytic.add(c)
  
ver = []
for _ in range(M):
  d,e,f = map(int,input().split())
  ver.append((d,e,f))
  xtic.add(d)
  ytic.add(e)
  ytic.add(f)

xtic = list(xtic)
ytic = list(ytic)
xtic.sort()
ytic.sort()
xdic = {xtic[i]:i+1 for i in range(len(xtic))}
ydic = {ytic[i]:i+1 for i in range(len(ytic))}

gyaku_xdic = {xdic[k]:k for k in xdic}
gyaku_ydic = {ydic[k]:k for k in ydic}

hor.sort()
ver.sort()

hor_dic = {}
ver_dic = {}

now = None
for c,a,b in hor:
  c,a,b = ydic[c],xdic[a],xdic[b]
  if c != now:
    hor_dic[c] = (1<<b) - (1<<a)
  else:
    hor_dic[c] |= (1<<b) - (1<<a)
  now = c

now = None
for d,e,f in ver:
  d,e,f = xdic[d],ydic[e],ydic[f]
  if d != now:
    ver_dic[d] = (1<<f) - (1<<e)
  else:
    ver_dic[d] |= (1<<f) - (1<<e)
  now = d

def is_connected(x,y,dx,dy):
  if dx == 0:
    if dy > 0:
      if (hor_wall[y+1]>>x)&1:
        return False
      return True
    else:
      if (hor_wall[y]>>x)&1:
        return False
      return True
  else:
    if dx > 0:
      if (ver_wall[x+1]>>y)&1:
        return False
      return True
    else:
      if (ver_wall[x]>>y)&1:
        return False
      return True
      
def calc_area(x,y):
  X = gyaku_xdic[x+1] - gyaku_xdic[x]
  Y = gyaku_ydic[y+1] - gyaku_ydic[y]
  return X*Y

offset = [(1,0),(0,1),(-1,0),(0,-1)]
x0 = bisect.bisect(xtic,0)
y0 = bisect.bisect(ytic,0)
W,H = len(xtic)+1 ,len(ytic)+1

hor_wall = [0 for i in range(H)]
ver_wall = [0 for i in range(W)]

for k in hor_dic:
  hor_wall[k] = hor_dic[k]
for k in ver_dic:
  ver_wall[k] = ver_dic[k]
"""
for k in range(H):
  listb = list(map(int,list(bin(hor_wall[k])[2:])))
  hor_wall[k] = [0 for j in range(H-len(listb))] + listb

for k in range(W):
  listb = list(map(int,list(bin(ver_wall[k])[2:])))
  ver_wall[k] = [0 for j in range(W-len(listb))] + listb  
"""

d = [[0 for i in range(W)] for j in range(H)]
d[y0][x0] = 1
q = deque([(x0,y0)])

area = 0

while q:
  x,y = q.pop()
  area += calc_area(x,y)
  for dx,dy in offset:
    nx,ny = x+dx,y+dy
    if 0<=nx<W and 0<=ny<H:
      if is_connected(x,y,dx,dy):
        if nx == 0 or ny == 0 or nx == W-1 or ny == H-1:
          print("INF")
          exit()
        if d[ny][nx] == 0:
          d[ny][nx] = 1
          q.append((nx,ny))

print(area)


Measured memory_bytes: 260964
#include <queue>
#include <iostream>
#include <map>
#include <algorithm>
#include <string>
#include <cmath>
#include <vector>
#include <iomanip>
#include <cstdio>
#define rep(i, n) for(long long i = 0;(i) < (n);(i)++)
using namespace std;
using ll = long long;

int main()
{
	ll x;
	cin >> x;
	ll m = x % 100;
	ll q = x / 100;
	if (m <= q * 5) {
		cout << 1 << endl;
	}
	else
	{
		cout << 0 << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define MOD 1000000007
#define INF 1e18

using namespace std;

int main(void){
  ll a, b, t;
  cin >> a >> b >> t;
  
  cout << b * (t/a) << endl;
  

  return 0;
}


Measured memory_bytes: 256
/*
    coder:xxjAc 
    time:2017/11/18
*/
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
using namespace std;
int k,dist[100007];
deque<int> dq;
int main(){
	scanf("%d",&k);
	memset(dist,1000000007,sizeof(dist));
	dist[1]=1;
	dq.push_front(1);
	while (!dq.empty()){
		int x=dq.front();
		dq.pop_front();
		if (dist[(x*10)%k]>dist[x]){
			dist[(x*10)%k]=dist[x];
			dq.push_front((x*10)%k);
		}
		if (dist[(x+1)%k]>dist[x]){
			dist[(x+1)%k]=dist[x]+1;
			dq.push_back((x+1)%k);
		}
	}
	printf("%d\n",dist[0]);
	return 0;
}

Measured memory_bytes: 896
s = input()
f = int(s[:2])
l = int(s[2:])
if 1 <= f <= 12 and 1 <= l <= 12:
    print("AMBIGUOUS")
elif 1 <= f <= 12:
    print("MMYY")
elif 1 <= l <= 12:
    print("YYMM")
else:
    print("NA")


Measured memory_bytes: 2940
// Written By NewbieChd
#include <cstdio>
#include <algorithm>
using namespace std;

const int maxN = 2000003, mod = 998244353, inv2 = 499122177;
int fac[maxN], invFac[maxN];
inline int power(int x, int y) {
    int o = 1;
    while (y) {
        if (y & 1)
            o = 1ll * o * x % mod;
        x = 1ll * x * x % mod, y >>= 1;
    }
    return o;
}
inline int binom(int n, int m) { return 1ll * fac[n + m] * invFac[n] % mod * invFac[m] % mod; }

int main() {
    int n, m, lim, i, ans = 0;
    scanf("%d%d", &n, &m), lim = n + m;
    if (n < m)
        swap(n, m);
    
    fac[0] = 1;
    for (i = 1; i <= lim; ++i)
        fac[i] = 1ll * fac[i - 1] * i % mod;
    invFac[lim] = power(fac[lim], mod - 2);
    for (i = lim; i; --i)
        invFac[i - 1] = 1ll * invFac[i] * i % mod;
    
    for (i = 1; i <= m; ++i)
        ans = (1ll * binom(n - i, m - i) * binom(i, i) % mod + ans) % mod;
    ans = (1ll * inv2 * power(binom(n, m), mod - 2) % mod * ans + n) % mod;
    
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 10368
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string S;
  int N,K;
  cin >> N >> K >> S;
  
  if(S[K-1] == 'A'){S[K-1] = 'a';}
    if(S[K-1] == 'B'){S[K-1] = 'b';}
    if(S[K-1] == 'C'){S[K-1] = 'c';}
  
  cout << S << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
 
typedef pair<int,int> P;
struct edge{int to, id;};
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define mod 1000000007
 
using graph = vector<vector<ll>>;
 
int main(){
    int x;
    cin >> x;
    if(x >= 30){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 3588
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace AizuOnline
{
    internal class Program
    {
        private static void Main(string[] args)
        {
            var list = new List<string>();
            while (true)
            {
                var x = Console.ReadLine();

                if (x == "0")
                {
                    break;
                }
                list.Add(x);
            }

            foreach (var l in list)
            {
                var sum = 0;
                foreach (var c in l.ToCharArray())
                {
                    sum += int.Parse(c.ToString());
                }

                Console.WriteLine(sum);
            }

            Console.ReadLine();
        }
    }
}

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

int main(){
  int n, m=0, s=0;
  cin >> n;
  for(int i=0; i<n; i++){
    int p;
    cin >> p;
    s+=p;
    m=max(m, p);
  }
  cout << s-m/2;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const ll inf =1LL << 62;
const ll mod=1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b,const ll &mod) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b,const ll &mod) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b,const ll &mod) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b,const ll &mod) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
random_device rd;
mt19937 mt(rd());
uniform_int_distribution<int> dice(1,6);
uniform_real_distribution<double> score(0.0,10.0);

int h, w;
vector<string> f;

const int N = 21;
int memo[N][N][N][N];

int rec(int x1, int y1, int x2, int y2){
    int& cur = memo[y1][x1][y2][x2];
    if(cur != -1) return cur;

    if(x1 == x2 or y1 == y2){
        return cur = 0;
    }

    set<int> s;
    rep(y, y1, y2){
        rep(x, x1, x2){
            if(f[y][x] == 'X') continue;
            int g = 0;
            g ^= rec(x1, y1, x, y);
            g ^= rec(x1, y+1, x, y2);
            g ^= rec(x+1, y1, x2, y);
            g ^= rec(x+1, y+1, x2, y2);
            s.insert(g);
        }
    }
    cur = 0;
    for(auto& e : s){
        if(cur != e) break;
        cur++;
    }

    return cur;
}

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

    cin >> h >> w;
    f = vector<string>(h); for(auto& e : f) cin >> e;

    rep(y, h+1) rep(x, w+1) rep(yy, h+1) rep(xx, w+1) memo[y][x][yy][xx] = -1;

    cout << (rec(0, 0, w, h) == 0 ? "Second":"First") << endl;

    return 0;
}

Measured memory_bytes: 3956