akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<stdlib.h>
#define swap(a,b) ((*a!=*b)&&(*a+=*b,*b=*a-*b,*a-=*b))
typedef long long LL;
const int IMIN=(1<<31);
const LL LINF=0x7fffffffffffffff;
#define rep(i,N) for(int i=0;i<(LL)N;i++)
#define array(N,t) (t*)calloc(N,sizeof(t))
inline LL IN(void)
{
  LL x=0;int f=0,c=getchar();while(c<48||c>57){f^=c==45,c=getchar();}
  while(c>47&&c<58){x=x*10+c-48,c=getchar();}return f?-x:x;
}
static inline void Sort(unsigned *from,unsigned *to,unsigned bit)
{
  if(!bit||to<from+1)return;
  unsigned *left=from,*right=to-1;
  for(;;)
  {
    while(left<right&&!(*left&bit))left++;
    while(left<right&&(*right&bit))right--;
    if(left>=right)break;
    swap(left,right);
  }
  if(!(bit&*left)&&left<to)left++;
  bit>>=1;
  Sort(from,left,bit);
  Sort(left,to,bit);
}
static inline void Radix(int *array,const int len)
{
  unsigned *x=(unsigned*)array;
  rep(i,len)x[i]^=IMIN;
  Sort(x,x+len,IMIN);
  rep(i,len)x[i]^=IMIN;
}
signed main(void)
{
  int N,m=0,p=0,z=0,NG,OK,BASE,minus,temp;
  LL K,L=-LINF/2,M,R=LINF/2,count;
  N=IN(),K=IN();
  int *A=array(N,int);
  rep(i,N){A[i]=IN();if(A[i]<0)m++;else if(A[i]>0)p++;else z++;}
  Radix(A,N);
  if(K>1ll*m*p&&K<1ll*m*p+1ll*z*(N-1)/2)return puts("0"),0;else temp=0;
  if(K<=1ll*m*p)R=1ll;else L=-1ll;
  while(R-L>1)
  {
    M=(L+R)/2,count=0;
    for(int i=temp;i<N;i++)
    {
      NG=i,OK=N,minus=A[i]<0;
      while(OK-NG>1)
      {
        BASE=(NG+OK)/2;
        if(1ll*A[i]*A[BASE]<=M){if(minus)OK=BASE;else NG=BASE;}
        else{if(minus)NG=BASE;else OK=BASE;}
      }
      count+=(minus)?N-OK:NG-i;
      if(!minus&&i==m*(m-1)-1){count+=m*(m-1);temp=N*(N-1)-p*(p-1)-1;}
    }
    if(count<K)L=M;else R=M;
  }
  return printf("%lld\n",R),0;
}

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

#define rep(i, n) for(int i=0; i<n; ++i)
#define repit(it, li) for(auto it=li.begin(); it!=li.end(); it++)
#define ll long long int

int main(){
    int x, y;
    cin>>x>>y;
    if(2*x<=y && y<=4*x && y%2==0)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 3580
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define PI 3.14159265359
#define INF 1000100100
#define MOD 1000000007
#define all(x) (x).begin(),(x).end()
typedef long long ll;
#define P pair<int, int>
#define PP pair<P,int>
#define T tuple<int,int,int> 
using namespace std;

int main(){
    string s,t; cin >> s >> t;
    int ans=0;
    rep(i,s.size()){
        if(s[i]!=t[i]) ans++;
    }
    cout << ans << endl;
return 0;
}


Measured memory_bytes: 3916
package main

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

var sc = bufio.NewScanner(os.Stdin)
var out = bufio.NewWriter(os.Stdout)

func main() {
	/*/TODO:!!!!!!!テスト用!!!!!!!!!
	sc = bufio.NewScanner(strings.NewReader(`

					`))
	//TODO:!!!!!!!テスト用!!!!!!!!!*/

	buf := make([]byte, 1024*1024)
	sc.Buffer(buf, bufio.MaxScanTokenSize)
	sc.Split(bufio.ScanWords)
	defer out.Flush() // !!!!caution!!!! you must use Fprint(out, ) not Print()
	/* --- code --- */

	//fmt.Fprintln(out, "[DEBUG]", time.Now())

	n := nextInt()
	ans := nextInt()
	for i := 1; i < n; i++ {
		a := nextInt()
		if ans != -1 {
			if log10(ans)+log10(a) <= 18 {
				ans *= a
				if ans > 1000000000000000000 {
					ans = -1
				}
			} else {
				ans = -1
			}
		}
		if a == 0 {
			ans = 0
			break
		}
	}

	//fmt.Fprintln(out, "[DEBUG]]", a)
	fmt.Fprintln(out, ans)
}

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

// -*-*-*-*-*-*-*-*-
// * I/O utilities *
// -*-*-*-*-*-*-*-*-

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}

func nextFloat64() float64 {
	a, _ := strconv.ParseFloat(next(), 64)
	return a
}

func nextInts(n int) []int {
	ret := make([]int, n)
	for i := 0; i < n; i++ {
		ret[i] = nextInt()
	}
	return ret
}
func nextFloats(n int) []float64 {
	ret := make([]float64, n)
	for i := 0; i < n; i++ {
		ret[i] = nextFloat64()
	}
	return ret
}
func nextStrings(n int) []string {
	ret := make([]string, n)
	for i := 0; i < n; i++ {
		ret[i] = next()
	}
	return ret
}

func chars(s string) []string {
	ret := make([]string, len([]rune(s)))
	for i, v := range []rune(s) {
		ret[i] = string(v)
	}
	return ret
}

func absInt(x int) int {
	return int(math.Abs(float64(x)))
}
func minInt(x, y int) int {
	if x < y {
		return x
	}
	return y
}
func maxInt(x, y int) int {
	if x > y {
		return x
	}
	return y
}
func log10(x int) float64 {
	return math.Log10(float64(x))
}


Measured memory_bytes: 5840
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

struct UnionFind {
  vector<int> par;
  vector<int> rank;
  vector<ll> Size;
  UnionFind(int n = 1) { init(n); }

  void init(int n = 1) {
    par.resize(n + 1);
    rank.resize(n + 1);
    Size.resize(n + 1);
    for (int i = 0; i <= n; ++i)
      par[i] = i, rank[i] = 0, Size[i] = 1;
  }

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

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

  bool merge(int x, int y) {
    x = root(x);
    y = root(y);
    if (x == y)
      return false;
    if (rank[x] < rank[y])
      swap(x, y);
    if (rank[x] == rank[y])
      ++rank[x];
    par[y] = x;
    Size[x] += Size[y];
    return true;
  }

  ll size(int x) { return Size[root(x)]; }
};

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

  int n, m;
  cin >> n >> m;
  vector<P> v(m);
  rep(i, 0, m) {
    int a, b;
    cin >> a >> b;
    v[i] = make_pair(a, b);
  }

  int ans = 0;
  rep(i, 0, m) {
    UnionFind uf;
    uf.init(n);
    rep(j, 0, m) {
      if (i == j)
        continue;
      uf.merge(v[j].first, v[j].second);
    }

    bool flg = true;
    rep(j, 1, n) {
      if (!uf.is_same(j, j + 1)) {
        flg = false;
        break;
      }
    }
    if (!flg)
      ans++;
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <cstdint>

using namespace std;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s;
	int a;
	cin >> a;
	cin >> s;
	if (a >= 3200)
		cout << s;
	else
		cout << "red";
}

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

const int MAXN = 2e5+5;
const int INF = 1e9+7;
#define ll long long
#define pb push_back
#define endl '\n'
#define fast_io ios_base::sync_with_stdio(false); cin.tie(NULL);
#define F first
#define S second

ll poww(ll a, ll b, ll md) {
    return (!b ? 1 : (b & 1 ? a * poww(a * a % md, b / 2, md) % md : poww(a * a % md, b / 2, md) % md));
}

ll MOD(ll a){
    return ((a%INF)+INF)%INF;
}

int a[MAXN],b[MAXN];

int main()
{
    fast_io;
    //cout << fixed << setprecision(15);

    int n;cin >> n;
    for(int i=0;i<n;++i){
        cin >> a[i];
    }
    int cnt=1;
    for(int i=0;i<n;++i){
        if(a[i] == cnt) ++cnt;
    }
    if(cnt == 1){
        cout << "-1";
        return 0;
    }
    cout << n-cnt+1;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define endl "\n"
#define sz(x) (int)(x).size()
#define _USE_MATH_DEFINES
using namespace std;
typedef long long int lli;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    
    ll x;
    cin >> x;
    ll sum = 0;
    for (ll i = 1; i <= x; i++) {
        sum += i;
        if (sum >= x) {
            cout << i;
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 256
n = int(input())
s = input()
a = []


for i in range(len(s)):
    if ord(s[i])+n > 90:
        a.append(chr(ord(s[i])+n-26))
    else:
        a.append(chr(ord(s[i])+n))

for j in range(len(s)):
    print(a[j], end="")

            
    



        


        


    







        



Measured memory_bytes: 4596
//84104971101048411497 - Can you guess what does this mean?
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef complex<double> point;
#define mapii map<int, int>
#define debug(a) cout << #a << ": " << a << endl
#define debuga1(a, l, r) fto(i, l, r) cout << a[i] << " "; cout << endl
#define fdto(i, r, l) for(int i = (r); i >= (l); --i)
#define fto(i, l, r) for(int i = (l); i <= (r); ++i)
#define forit(it, var) for(__typeof(var.begin()) it = var.begin(); it != var.end(); it++)
#define forrit(rit, var) for(__typeof(var.rbegin()) rit = var.rbegin(); rit != var.rend(); rit++)
#define ii pair<int, int>
#define iii pair<int, ii>
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define maxN 100005
#define oo 1000000007
#define sz(a) (int)a.size()

const double PI = acos(-1.0);

double fRand(double fMin, double fMax)
{
    double f = (double)rand() / RAND_MAX;
    return fMin + f * (fMax - fMin);
}

template <class T>
T min(T a, T b, T c) {
    return min(a, min(b, c));
}

template <class T>
T max(T a, T b, T c) {
    return max(a, max(b, c));
}

int n, m, k, a[maxN], minA[maxN];
vector<int> g[maxN];
multiset<int> s;
bool visited[maxN];
ll ans;

void DFS(int u) {
    visited[u] = true;
    minA[k] = min(minA[k], a[u]);
    s.insert(a[u]);
    for(int v: g[u]) {
        if (!visited[v]) DFS(v);
    }
}

int main () {
    scanf("%d%d", &n, &m);
    fto(i, 0, n-1) scanf("%d", &a[i]);
    fto(i, 1, m) {
        int u, v; scanf("%d%d", &u, &v);
        g[u].pb(v); g[v].pb(u);
    }

    fto(u, 0, n-1) {
        if (!visited[u]) {
            minA[k] = oo;
            DFS(u);
            ++k;
        }
    }

    if (k == 1) {
        puts("0");
        return 0;
    }
    if (2*(k-1) > n) {
        puts("Impossible");
        return 0;
    }

    fto(i, 0, k-1) {
        ans += minA[i];
        s.erase(s.find(minA[i]));
    }

    fto(i, 1, k-2) {
        ans += *s.begin();
        s.erase(s.begin());
    }

    cout << ans;

    return 0;
}


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

typedef long long ll;

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

    int k,n;
    cin >> k >> n;
    vector<int> a(n);
    for(int i=0;i<n;i++) cin >> a[i];
    int maxdist = 0;
    for(int i=0;i<n-1;i++){
        maxdist = max(maxdist,a[i+1]-a[i]);
    }
    maxdist = max(maxdist,min(a[n-1]-a[0],k-(a[n-1]-a[0])));
    cout << k - maxdist << endl;
    return 0;
}

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

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;
typedef vector<ld> vld;
typedef vector<pll> vpl;

#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 998244353;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

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

  ll n,s;
  cin>>n>>s;
  vll a(n);
  REP(i,n)cin>>a[i];

  ll ans=0;
  ll dp[n+2][3010];
  REP(i,n+2)REP(j,3010)dp[i][j]=0;

  REP(i,n){
    dp[i][0] += 1;
    dp[i][0] %= MOD;
    for(ll j=3010-1; j>=0; j--){
      dp[i+1][j]+=dp[i][j];
      dp[i+1][j]%=MOD;
      if(j-a[i]>=0)
        dp[i+1][j] += dp[i][j-a[i]];
      dp[i+1][j]%=MOD;
    }
    ans = (ans+dp[i+1][s])%MOD;
  }

  cout<<ans<<endl;
}



Measured memory_bytes: 70912
while True:
    n=int(input())
    if n==0:
        break    
    else:    
        s=list(map(int,input().split()))
        h=(sum(s))/n
        a=0
        for i in range(n):
            a+=(s[i]-h)**2
            b=(a/n)**(1/2)
        print('{:.8f}'.format(b))


Measured memory_bytes: 5684
//abc110_d2.cpp
//Sat Jun 27 17:14:16 2020

#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#include <set>
#define INTINF 2147483647
#define LLINF 9223372036854775807

using namespace std;
using ll=long long;
typedef pair<int,int> P;

//nCk を1000000007で割った余りの計算。
const ll MAX = 510000;
const ll MOD = 1000000007;
ll fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++){
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
ll COM(ll n, ll k){
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main(){
	ll n,m;
	cin >> n >> m;

	COMinit();

	ll x = m;
	ll num = 2;
	ll count = 0;
	ll ans = 1;
	while (num*num<=m){
		if (x%num==0){
			count++;
			x = x/num;
		}else if (count){
			ans = ans * COM(count+n-1,count) % MOD;
			count = 0;
			num++;
		}else {
			num++;
		}
	}
	if (x!=1){
		ans = ans * COM(n,1) % MOD;
	}

	cout << ans << endl;
//	printf("%.4f\n",ans);
}

Measured memory_bytes: 15636
#include<cstdio>
#include<cstdlib>
#include<iostream>
#include<cstring> 
#include<algorithm>
using namespace std;
typedef long long ll;
int tree[300000+10];
int a[100000+10];
int c[100000+10];
int n;
int lowbit(int x){
	return x&-x;
}
void update(int x){
	while(x<=200020){
		tree[x]++;
		x+=lowbit(x);
	}
}
ll query(int x){
	ll res=0;
	while(x>0){
		res+=tree[x];
		x-=lowbit(x);
	}
	return res;
}
bool check(int x){
	c[0]=0;
	for(int i=1;i<=n;i++) c[i]=c[i-1]+(a[i]>=x ? 1:-1);
	memset(tree,0,sizeof(tree));
	ll sum=0;
	for(int i=0;i<=n;i++){
		sum+=query(c[i]+100010);
		update(c[i]+100010);
	}
	return sum>=1ll*n*(n+1)/4;
}
int main(){
	while(~scanf("%d",&n)){
		int l=0,r=-1000000000;
		for(int i=1;i<=n;i++){
			scanf("%d",&a[i]);
			r=max(a[i],r);
		}
//		printf("%d %d\n",l,r);
		while(l<=r){
			int mid=(l+r)>>1;
			if(check(mid)) l=mid+1; else r=mid-1;
		}
		printf("%d\n",r);
	}
	return 0;
} 

Measured memory_bytes: 2176
#include <bits/stdc++.h>
#include <array>
#define FOR(i,a,b) for(int i=(a);i<=(b);++i) 
#define RFOR(i,a,b) for(int i=(a);i>=(b);--i) 
#define REP(i,n) for(int i=0;i<(n);++i)
#define RREP(i,n) for(int i=(n);i>0;--i)
#define CI cin>> 
#define CO cout<<
#define EN <<endl 
#define all(x) (x).begin(),(x).end() 
using namespace std;
template <typename T> istream & operator >> (istream & is, vector<T> & vec) { for (T& x : vec) is >> x; 	return is; }
using ll = long long;
using VI = vector<int>;

int main() {
	int a, b, c; char d, f;
	CI a >> d >> b >> f >> c;
	if (b > 4)CO "TBD" EN;
	else CO "Heisei" EN;

	return 0;
}


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

int main(){
    ll H;
    cin >> H;
    ll cnt = 0;
    while(1){
        if(H < pow(2,cnt)){
            cout << (ll)pow(2,cnt-1)*2-1 << endl;
            break;
        }
        cnt++;
    }
    /*
    7        8
    3 3      4 4
    1 1 1 1  2 2 2 2
             1 1 1 1 1 1 1 1
    6
    3 3
    1 1 1 1
     */
    return 0;
}

Measured memory_bytes: 256
#設定
import sys
input = sys.stdin.buffer.readline

#ライブラリインポート
from collections import defaultdict

con = 10 ** 9 + 7
#入力受け取り
def getlist():
	return list(map(int, input().split()))

#処理内容
def main():
	K, X = getlist()
	if 500 * K >= X:
		print("Yes")
	else:
		print("No")
	


if __name__ == '__main__':
	main()

Measured memory_bytes: 38640
import java.util.*;

public class Main {
    static ArrayList<Integer>[] graph = new ArrayList[110000];
    static int[] dp = new int[110000];
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int m = scanner.nextInt();
        Arrays.fill(dp,0,n, -1);
        for (int i = 0; i < m; ++i) {
            int x = scanner.nextInt() - 1;
            int y = scanner.nextInt() - 1;
            if (graph[x] == null)
                graph[x] = new ArrayList<>();
            graph[x].add(y);
        }
        int res = 0;
        for (int i = 0; i < n; ++i) {
            res = Math.max(res, solve(i));
        }
        System.out.println(res-1);
    }

    private static int solve(int a) {
        if (dp[a] != -1)
            return dp[a];
        int res = 0;
        if(graph[a]!= null) {
            for (int i = 0; i < graph[a].size(); ++i) {
                res = Math.max(res, solve(graph[a].get(i)) + 1);
            }
        }else {
            res = 1;
        }
        return dp[a] = res;
    }
}
/*
 *
 */

Measured memory_bytes: 73300
#include <bits/stdc++.h>
#define ALL(A) (A).begin(), (A).end()
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;
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; }

int dx[] = { 0, 1, -1, 0, 1, -1, 1, -1 };  // i<4:4way i<8:8way
int dy[] = { 1, 0, 0, -1, 1, -1, -1, 1 };

const ll mod = 1e9 + 7;
const ll INF = -1 * ((1LL << 63) + 1);
const int inf = -1 * ((1 << 31) + 1);

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    int m,d;
    cin >> m >> d;
    int ans = 0;
    for(int i=1;i<=m;i++){
        for(int j=1;j<=d;j++){
            int d1 = j%10;
            int d2 = j/10;
            if(d1*d2==i && d1>=2 && d2>=2)ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ll;
ll c,r;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>c>>r;
	ll sum=c*r;
	if(c==1 || r==1){
		cout<<1<<endl;
		return 0;
	} 
	if(sum&1)cout<<(sum/2)+1<<endl;
	else cout<<sum/2<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(x) ;
#else
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

template <typename T1, typename T2>
ostream &operator<<(ostream &out, const pair<T1, T2> &p) {
  out << "{" << p.first << ", " << p.second << "}";
  return out;
}

template <typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 510

int h, w;
char s[SIZE][SIZE];

int dx[8] = {0,0,1,-1,1,1,-1,-1};
int dy[8] = {1,-1,0,0,1,-1,1,-1};
char dirchar[] = "DURL"; // "SNWE"

pair<int,int> memo[SIZE][SIZE] = {};
ll ans[SIZE][SIZE] = {};

int check(int Y, int X) {

  if (s[Y][X] != '#') return 0;

  queue<pair<int,int> > que;
  que.push({Y,X});

  int res = 0;

  while(que.size()){
    auto p = que.front();
    que.pop();

    int y = p.first;
    int x = p.second;

    if(memo[y][x].first == Y && memo[y][x].second == X) continue;

    debug(memo[y][x]);
    if(memo[y][x].first != -1) {
      return ans[Y][X] = ans[memo[y][x].first][memo[y][x].second];
    }
    memo[y][x] = {Y, X};

    res += s[y][x] != '#';

    for(int i=0;i<4;i++){
      if(0 <= y+dy[i] && y+dy[i] < h && 0<= x+dx[i] && x+dx[i] < w &&
         s[y][x] != s[y+dy[i]][x+dx[i]]){
        que.push({y+dy[i], x+dx[i]});
      }
    }
  }

  ans[Y][X] = res;

  return res;
}

int main(){

  scanf("%d%d", &h, &w);

  for(int i=0;i<h;i++){
    scanf("%s", s[i]);
  }

  for(int i=0;i<h;i++)
    for(int j=0;j<w;j++)
      memo[i][j] = {-1, -1};

  ll ans = 0;

  for(int i=0;i<h;i++)
    for(int j=0;j<w;j++)
      ans += check(i, j);

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 4096
import sys

input = sys.stdin.readline

mod = 10**9 + 7
s = int(input())
dp = [0 for i in range(s+1)]
dp[0] = 1

for i in range(1,s+1):
    for j in range(0,(i-3)+1):
        dp[i] += dp[j]
        dp[i] %= mod

print(dp[s])

Measured memory_bytes: 9196
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
using ld = long double;
const int INF = 1 << 29;
const ll LINF = 1l << 61;
const ld PI = abs(acos(-1));
#define pq priotity_queue
#define mp make_pair
#define P pair
#define rep(i, a, b) for (ll i = a; i < b; i++)
#define rrep(i, a, b) for (ll i = a; i >= b; i--)
#define cbuf(buf, init) memset(buf, init, sizeof(buf))
#define modp(x, y) (((y) + (x) % (y)) % (y))
#define divd(x, y) (static_cast<double>(x) / static_cast<double>(y))

int main()
{
    //
    string S;
    cin >> S;
    for (ll i = S.size() - 2; i >= 2; i -= 2) {
        bool flag = true;
        for (ll j = 0; j < i / 2; j++) {
            if (S[j] != S[j + i / 2]) {
                flag = false;
                break;
            }
        }
        if (flag) {
            cout << i << endl;
            break;
        }
    }
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
const int INF = 1 << 28;
const ll MOD = 1'000'000'007;
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; }

int main() {
    int k, s;
    cin >> k >> s;
    ll ret = 0;
    for (int i = 0; i <= k; ++i) {
        for (int j = 0; j <= k; ++j) {
            if (i + j <= s && s - i - j <= k)
                ret++;
        }
    }
    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	static Scanner sc = new Scanner(System.in);
	static double v, t, y;
	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO ツ篠ゥツ督ョツ青カツ青ャツつウツづェツつスツδソツッツドツ・ツスツタツブ
		while(read()){
			slove();
		}
	}
	static boolean read(){
		if(!sc.hasNextDouble())
			return false;
		
		v = sc.nextDouble();
		return true;
	}
	static void slove(){
		/**
		 * v = 9.8*t
		 * y = 4.9*t^2
		 * ツづヲツづィ
		 */
		t = v/9.8;
		y = 4.9*t*t;
		//System.out.println(y);
		int N = 0;
		while(5*N-5 < y){
			N++;
		}
		System.out.println(N);
	}

}

Measured memory_bytes: 12000
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        // 入力
        int n = sc.nextInt();
        long k = sc.nextLong();

        int[] a = new int[n+1];
        for (int i = 1; i <= n; i++) {
            a[i] = sc.nextInt();
        }

        long zan = k;
        // 1 6 2 5 3 2 5 3 [2]...
        long[] check = new long[n+1];
        int t = 1;
        for (long j = 1; j <= k; j++) {
            if (check[t] == 2) {
                // ループし始めている
                break;
            }
            check[t]++;
            t = a[t];
            zan--;
        }

        if (zan > 0) {
            // 何回移動すれば同じ場所に戻るか
            long loopTerms = 0;
            for (int i = 1; i <= n; i++) {
                if (check[i] == 2) {
                    loopTerms++;
                }
            }

            long k2 = zan % loopTerms;
            for (long j = 1; j <= k2; j++) {
                t = a[t];
            }
        }

        // 出力
        System.out.println(t);
    }
}


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

int main() {
    int H, W;
    
    while(true){
        cin >> H >> W;
        
        if(H==0 && W==0) break;
        
        for(int i=1; i<=H; i++){
            for(int j=1; j<=W; j++){
            cout << "#";
            }
        cout << "\n";
        }
    cout << "\n";
    
    }
    return 0;
}

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

vector<vector<int>> par(100100,vector<int>(0));
vector<int> dp(100100,-1);

int f(int x){
  if(dp[x] != -1) return dp[x];
  int ans = 0;
  for(int p : par[x]){
    ans = max(ans, f(p)+1);
  }
  dp[x] = ans;
  return ans;
}

int main(){
  int n,m;
  cin >> n >> m;
  rep(i,m){
    int x,y;
    cin >> x >> y;
    par[y].push_back(x);
  }
  rep1(i,n) f(i);
  int ans = 0;
  rep1(i,n) ans = max(ans, dp[i]);
  cout << ans << endl;
}

Measured memory_bytes: 13312
n = gets.to_i
num = Array.new(n, 0)
pos = Hash.new(0)

n.times{|i|
    x = gets.to_i
    num[i] = x
    pos[x] = i % 2
}

count = 0
num = num.sort
num.each_with_index{|x, i|
    count += 1 if i % 2 != pos[x]
}
puts count / 2


Measured memory_bytes: 10872
#include <cctype>
#include <stdio.h>

using namespace std;

int main(){

        char word;

        while(true){
                scanf("%c",&word);
                if(islower(word)) printf("%c",toupper(word));
                else printf("%c",tolower(word));

                if(word == '\n') break;
        }       

        return 0;
}

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

int main()
{

	//str.replace(開始位置, 長さ, 文字列);
	
	string s;
	
	cin >> s;

	s.replace(5, 1, " ");
	s.replace(13, 1, " ");

	cout << s;






}

Measured memory_bytes: 256
import itertools
A, B, C = map(int,input().split())

lst = []
for i in range(1,100):
    lst.append(A * i)


for i in range(1,3):
    for v in itertools.combinations(lst,i):
        if sum(v) % B == C:
            print('YES')
            exit()
print('NO')

Measured memory_bytes: 9024
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <bits/stdc++.h>
using namespace std;
char _;
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define io() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#ifdef _getchar_nolock
#define getchar _getchar_nolock
#endif
#ifdef _putchar_nolock
#define putchar _putchar_nolock
#endif
#ifdef getchar_unlocked
#define getchar getchar_unlocked
#endif
#ifdef putchar_unlocked
#define putchar putchar_unlocked
#endif
typedef __gnu_pbds::tree<int, __gnu_pbds::null_type, less<int>, __gnu_pbds::rb_tree_tag,__gnu_pbds::tree_order_statistics_node_update> ordered_set;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
typedef pair<ll,int> pli;
typedef pair<int,ll> pil;
template <typename t> void scan (t& x) {do{while((x=getchar())<'0'); for(x-='0'; '0'<=(_=getchar()); x=(x<<3)+(x<<1)+_-'0');}while(0);}
void scan(pii &x) {scan(x.first); scan(x.second);}
template <typename t, typename ...r> void scan (t& x, r&... xs) {scan(x); scan(xs...);}
const int MN = 1e5+2, MM = 1e6+2, MOD = 1e8, BASE = 131;
int fpow (int base, int ex) {int res = 1;while (ex) {if (ex&1) res = res*1LL*base%MOD;base = base*1LL*base%MOD;ex>>=1;}return res;}
ll lcm (ll a, ll b) {return a*b/__gcd(a,b);}
int moddiv (int a, int b) {return a*1LL*fpow(b,MOD-2)%MOD;}
int a[MN], b[MN], c[MN];
int main () {
    int n,ans=0;
    scan(n);
    for (int i = 1; i <= n; i++) scan(a[i]);
    for (int i = 1; i <= n; i++) scan(b[i]);
    for (int i = 1; i < n; i++) scan(c[i]);
    for (int i = 1; i <= n; i++) {
        ans += b[i];
        if (i>1&&a[i]-a[i-1]==1) ans += c[a[i-1]];
    }
    printf ("%d\n",ans);
    return 0;
}

Measured memory_bytes: 256
n=int(input())
l=[]

def prime(N):
  for i in range(2,int(N**0.5)+1):
    if N%i==0:
      return False
      break
  return True

for i in range(2,55555):
  if prime(i) is True and i%5==1:
    l.append(i)
  if len(l)>=n:
    break
print(" ".join(map(str,l)))

Measured memory_bytes: 3060
///not today

#include<bits/stdc++.h>
using namespace std;

#define SZ(x) (int)(x).size()
#define pb push_back
#define ll long long
#define xmax(x, y) (x) = max((x), (y))
#define xmin(x, y) (x) = min((x), (y))
#define F first
#define S second
#define pii pair<int, int>
#define pll pair<long long, long long>
#define int long long
#define pipii pair<int, pair<int, int> >

const int maxn = 2000* 100 + 5;
string s = "", c = "", d = "";
int n, q;

string f(int x){
    int pt_s = x, pt_q = 0;
    while(pt_q < q and pt_s < n and pt_s >= 0){
        if(s[pt_s] == c[pt_q]){
            if(d[pt_q] == 'R')
                pt_s ++;
            else
                pt_s --;
        }
        pt_q ++;
    }
    if(pt_s >= n)
        return "right";
    else if(pt_s < 0)
        return "left";
    else
        return "alive";
}

int32_t main(){
    ios_base::sync_with_stdio;
    cin >>n >>q >>s;
    for(int i = 0; i < q; i ++){
        char cc, dd;
        cin >>cc >>dd;
        c += cc;
        d += dd;
    }
    int l = -1, r = n + 1;
    while(r - l > 1){
        int mid = (r + l)/ 2;
        if(f(mid) == "right")
            r = mid;
        else
            l = mid;
    }
    int ans_r = r;
    l = -1, r = n + 1;
    while(r - l > 1){
        int mid = (r + l)/ 2;
        if(f(mid) == "left")
            l = mid;
        else
            r = mid;
    }
    cout << n - (n - 1 - ans_r + 1) - (l + 1) <<endl;
    return false;
}


Measured memory_bytes: 1024
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
    int a,b;
    cin>>a>>b;
    int cnt = 0;
    if(b==1)
    {
        cout<<"0\n";
        return 0;
    }
    if(b<=a)
    {
        cout<<"1\n";
        return 0;
    }
    b-=a;
    cnt=1+ceil((double)b/(a-1));
    cout<<cnt<<endl;
    return 0;
}


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

#define ll long long 
#define MOD 1000000007
#define pb push_back
#define mp make_pair
#define mt make_tuple

int main(){
	ios::sync_with_stdio(0); cin.tie(0);
	string s; cin >> s;
	if(s[2] == s[3] && s[4] == s[5]) cout << "Yes";
	else cout << "No";
	return 0; 	
}


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

ans = 0
for num_a in range(min(N,K) + 1):
    for num_b in range(min(N-num_a,K-num_a) + 1):
        if num_b >= 1:
            temp_v = V[:num_a] + V[-num_b:]
        else:
            temp_v = V[:num_a]
        t = K - num_a - num_b
        s = 0
        for vv in sorted(temp_v):
            if vv < 0 and t > 0:
                s += -vv
                t -= 1
        ans = max(ans, sum(temp_v) + s)
        
print(ans)

Measured memory_bytes: 3064
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i=(a); i<(int)(b); i++)
#define pb push_back
#define ALL(x) (x).begin(), (x).end()
#define st first
#define nd second
using namespace std;
 
const int maxN = 1 << 19;

void solve()
{
	int a,b, c;
	scanf ("%d%d%d", &a, &b, &c);
	printf("%s\n", a+b+c>=22 ? "bust"  : "win");
}
 
int main()
{
	int t;
	t=1;//scanf ("%d", &t);
	while (t--)
		solve();
	return 0;
}


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

#define ll long long 
#define sz(x) (int)x.size()

using namespace std;

int f(ll n){
	int res=0;
	while(n){
		res+=n%10;
		n/=10;
	}
	return res;
}

int main(){
	ll n;
	cin>>n;
	cout<<(n%f(n)?"No":"Yes");
	
	
}

Measured memory_bytes: 3640
def calc(i,x):
    if i ==0:
        return int((x % 4 == 1) or (x % 4 == 2))
    else:
        return int((x % (2**(i+1)) >= 2**i) and (x % 2 == 0))

def main():
    A,B = map(int, input().split())
    
    #2^10 > 10^3⇒ 2^10^4 > 10^3^4
    ans = 0
    for i in range(41):
        ans += 2**i*(calc(i,A-1)^calc(i,B))# ^ calc(i,B)))
    print(ans)
    
main()

Measured memory_bytes: 3060
A,B,C = map(int,input().split())
K = int(input())
card = [[] for _ in range(7)]
card[0].append([A,B,C])

for i in range(K):
  if A >= B:
    B *= 2
  else:
    if B >= C:
      C*=2
if A < B and B < C:
  print('Yes')
else:
  print('No')



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

#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define EPS (1e-8)
#define equals(a,b) (fabs((a)-(b))<EPS)

using namespace std;

bool LTE(double a,double b) { return equals(a,b) || a < b; }
bool LT(double a,double b) { return !equals(a,b) && a < b; }

int n,m,K[201],S[201][21],H[201][21];
double cost[210][210];
double dp[210];

void compute() {
  rep(i,n) {
    rep(j,m+1) {
      int remain = j;
      rep(k,K[i]) {
        if( remain == 0 ) break;
        if( 0 < S[i][k] * H[i][k] && S[i][k] * H[i][k] <= remain ) {
          cost[i][j] += H[i][k];
          remain -= S[i][k] * H[i][k];
        } else {
          cost[i][j] += (double)remain/(double)S[i][k];
          remain = 0;
        }
      }
    }
  }
  rep(i,n) {
    for(int j=m;j>=0;--j) {
      rep(k,m+1) {
        if( j+k <= m && LT(dp[j+k],dp[j] + cost[i][k]) ) {
          dp[j+k] = dp[j] + cost[i][k];
        }
      }
    }
  }
  printf("%.10f\n",dp[m]);
}

int main() {
  cin >> n >> m;
  rep(i,n) {
    cin >> K[i];
    rep(j,K[i]) cin >> S[i][j] >> H[i][j];
  }
  compute();
  return 0;
}

Measured memory_bytes: 3536
#include<bits/stdc++.h>
using namespace std;
const long long maxn=1e5+5;
const long long inf=0x3f3f3f3f;
long long a[maxn],b[maxn],ans,sum1,sum2,sum,minu;
priority_queue<long long> q;
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	long long n;
	cin>>n;
	for(long long i=1;i<=n;i++)
	{
		cin>>a[i];
		sum1+=a[i];
	}
	for(long long i=1;i<=n;i++)
	{
		cin>>b[i];
		sum2+=b[i];
	}
	if(sum1<sum2)
	{
		cout<<"-1"<<endl;
		return 0;
	}
	for(long long i=1;i<=n;i++)
	{
		if(a[i]>b[i])
		{
			minu+=a[i]-b[i];
			q.push(a[i]-b[i]);
		}
		if(a[i]<b[i])
		{
			sum+=b[i]-a[i];
			ans++;
		}
	}
	if(sum==0)
	{
		cout<<"0"<<endl;
		return 0;
	}
	while(!q.empty())
	{
		long long x=q.top();
		q.pop();
		sum-=x;
		ans++;
		if(sum<=0)
			break;
	}
	cout<<ans<<endl;
	return 0;
}




Measured memory_bytes: 2428
#include<iostream>
#include<vector>
#include<cmath>
using namespace std;
int main()
{
	int n;
	cin>>n;
	vector<int> a(n);
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
	}
	vector<int> dp(n,0);
	dp[0]=0;
	dp[1]=abs(a[1]-a[0]);
	for(int i=2;i<n;i++)
	{
		dp[i]=min(dp[i-1]+abs(a[i]-a[i-1]),dp[i-2]+abs(a[i]-a[i-2]));
	}
	cout<<dp[n-1];
	cout<<endl;
}


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

int main() {
    int d;
    string ans;

    cin >> d;

    if (d == 25) {
        ans = "Christmas";
    } else if (d == 24) {
        ans = "Christmas Eve";
    } else if (d == 23) {
        ans = "Christmas Eve Eve";
    } else {
        ans = "Christmas Eve Eve Eve";
    }

    cout << ans << endl;
}

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

int main(){
  int N,Q;
  cin >> N >> Q;
  string S;
  cin >> S;
  map<int,int> m;
  int n=0;
  m[-1]=0;
  for(int i=0;i<N-1;i++){
    if((S.at(i)=='A')&&(S.at(i+1)=='C')){
      n++;
    }
    m[i]=n;
  }
  vector<int> l(Q),r(Q),ans(Q,0);
  for(int i=0;i<Q;i++){
    cin >> l.at(i) >> r.at(i);
    l.at(i)--;
    r.at(i)--;
    ans.at(i)=m.at(r.at(i)-1)-m.at(l.at(i)-1);
    cout << ans.at(i) << endl;
  }
  return 0;
}


Measured memory_bytes: 6784
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        A solver = new A();
        solver.solve(1, in, out);
        out.close();
    }

    static class A {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 入力
            String S = in.next();

            // 出力
            S = S.replace("1", "@");
            S = S.replace("9", "$");
            S = S.replace("@", "9");
            S = S.replace("$", "1");
            out.println(S);

        }

    }
}



Measured memory_bytes: 21460
N, M = map(int, input().split())
ds = [-1]*N
for i in range(M):
  s, c = map(int, input().split())
  s = s-1
  if ds[s] < 0:
    ds[s] = c
  elif ds[s] != c:
    print(-1)
    exit()
if N > 1 and ds[0] == 0:
  print(-1)
  exit()
if N > 1 and ds[0] < 0:
  ds[0] = 1
if N == 1 and ds[0] < 0:
  ds[0] = 0
for i in range(1, N):
  if ds[i] < 0:
    ds[i] = 0
r = "".join(map(str, ds))
print(r)


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
  ll n;
  cin>>n;
  ll a[n+1],b[n+1];
  ll i;
  ll ans=0;
  for(i=0;i<n+1;i++) cin>>a[i];
  for(i=1;i<=n;i++) cin>>b[i];
  
  for(i=1;i<=n;i++)
  {
    if(a[i-1]>=b[i]) {ans+=b[i];}
    else if(a[i-1]<b[i])
    {
      ans+=a[i-1];
      b[i]-=a[i-1];
      if(a[i]<=b[i]) {ans+=a[i];a[i]=0;}
      else {ans+=b[i];a[i]-=b[i];}
    }
  }
  cout<<ans<<" ";
  return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <climits>
#include <vector>
#include <iomanip>
#include <string>
#include <queue>
#include <numeric>
#include <functional>
#include <array>
#include <map>
#include <set>

using namespace std;
using P = pair<int, int>;
using T = tuple<long, long, long>;

long long MOD = 1000000007;
long long dp[100005][4];

int A[300][300];

int main() {
	int H,W,D;
	cin >> H >> W >> D;
	map<int, P> mp;
	for (int i = 0; i < H; ++i) {
		for (int j = 0; j < W; ++j) {
			int a;
			cin >> a;
			mp[a] = make_pair(i+1,j+1);
		}
	}
	int Q;
	cin >> Q;
	vector<P>LR(Q);
	for (int i = 0; i < Q; ++i)cin >> LR[i].first >> LR[i].second;
	
	vector<int>distance(H*W+1);
	for (int j = H * W; 0 < j;--j) {
		if (j + D <= H * W) {
			distance[j] = distance[j + D] + abs(mp[j+D].first-mp[j].first)+ abs(mp[j + D].second - mp[j].second);
		}
		else {
			distance[j] = 0;
		}
	}

	for (int i = 0; i < Q;++i) {
		cout << distance[LR[i].first] - distance[LR[i].second] << endl;
	}
}


Measured memory_bytes: 7936
import java.util.*;
public class Main {
    public static void main(String[] args){
    
    Scanner sc = new Scanner(System.in);
        int X = sc.nextInt();
        int Y = sc.nextInt();
        int Z = sc.nextInt();
        
            System.out.println((X-Z)/(Y+Z));    
    }         
}


Measured memory_bytes: 35720
#include<iostream>
#include<vector>
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
int main()
{
	int M,N;
	cin>>N>>M;
	if( M==N )
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
// C++ implementation of the above approach 
#include<bits/stdc++.h> 
using namespace std; 
  
void CountTriangles(vector <int> A){  
  
    int n=A.size(); 
  
    sort(A.begin(), A.end());  
  
    int count = 0; 
      
    for( int i = n-1; i >= 1; i--){ 
        int l = 0, r = i-1; 
        while( l < r){ 
            if( A[l] + A[r] > A[i]){ 
  
                // If it is possible with a[l], a[r] 
                // and a[i] then it is also possible 
                // with a[l+1]..a[r-1],a[r] and a[i] 
                count += r - l ;  
  
                //checking for more possible solutions 
                r--;   
            } 
            else 
  
                // if not possible check for  
                // higher values of arr[l] 
                l++;   
        } 
    } 
    cout<<count<<endl; 
} 
int main(){ 
    int N; cin >> N;
    vector<int> A(N);
    for(int i = 0; i< N; i++) cin >> A[i];  
  
    CountTriangles(A); 
    
}     

Measured memory_bytes: 256
#include<stdio.h>
#define MAX 500000

int i,j,k,count;
void Merge(int A[],int l,int m,int r);
void Merge_S(int A[],int l,int r);

int main(){
  int A[MAX],n;
  scanf("%d",&n);
  for(i=0;i<n;i++) scanf("%d",&A[i]);
  Merge_S(A,0,n);
  for(i=0;i<n-1;i++) printf("%d ",A[i]);
  printf("%d\n",A[n-1]);
  printf("%d\n",count);
  return 0;
}

void Merge(int A[],int l,int m,int r){
  int n1=m-l,n2=r-m,L[n1], R[n2];
  for(i=0;i<n1;i++) L[i]=A[l+i];
  for(i=0;i<n2;i++) R[i]=A[m+i];
  L[n1]=1000000000;
  R[n2]=1000000000;
  int i=0,j=0;
  for(k=l;k<r;k++){
    if(L[i]<=R[j]){
      A[k]=L[i];
      i++;
      count++;
    }
    else {
      A[k]=R[j];
      j++;
      count++;
    }
  }
}

void Merge_S(int A[],int l,int r){
  int m;
  if(l+1<r){
    m=(l+r)/2;
    Merge_S(A,l,m);
    Merge_S(A,m,r);
    Merge(A,l,m,r);
  }
}

Measured memory_bytes: 4504
def main():

    N, A, B = map(int, input().split())
    X = list(map(int, input().split()))
    v = 0
    for i in range(N-1):
        v += min((X[i+1] - X[i]) * A, B)
    return v

if __name__ == '__main__':
    print(main())

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

using namespace std;

int main(){

    while(1){
        int m, mi, ma;
        cin>> m>> mi>> ma;
        if(!(m||mi||ma)) break;
        int P[m];
        for(int i=0; i<m; i++) cin>> P[i];

        sort(P, P+m);
        reverse(P, P+m);
        int ans=0, magap=0;
        for(int n=mi; n<=ma; n++){
            if(magap<=P[n-1]-P[n]){
                ans=n;
            }
            magap=max(magap, P[n-1]-P[n]);
        }

        cout<< ans<< endl;
    }

    return 0;
}

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

#define Omar45 ios_base::sync_with_stdio(false); cin.tie(NULL);
#define ll long long
#define pb push_back
#define endl '\n'
#define mod 1000000007

bool vis[1000000] = {};
vector <ll> v;
ll inv[1000000],fact[10000000];

ll modPow (ll a, ll b)
{
    if(b == 0)
        return 1;
    ll ret = modPow(a, b / 2);
    ret = ((ret % mod) * (ret %mod))%mod;
    if(b % 2)
        ret = (ret * (a % mod))%mod;
    return ret;
}

void calcFacAndInv(ll n)
{
	fact[0] = inv[0] = 1;
	for (ll i = 1; i <= n; i++)
	{
		fact[i] = (i * fact[i - 1]) % mod;
		inv[i] = modPow(fact[i], mod - 2);
	}
}

ll nCr(ll n, ll r)
{
	return ((fact[n] * inv[r]) % mod * inv[n - r]) % mod;
}

int main() {
	Omar45
	ll n, k; cin >> n >> k;
	calcFacAndInv(n+5);
    v.resize(n);
    for (int i=0; i<n; i++)
        cin >> v[i];
    sort(v.begin(), v.end());
    ll _min, _max, res=0;
    for (int i=0; i<n; i++){
        if (i >= k - 1)
            _max = nCr(i, k-1);
        else
            _max = 0;
        if (i <= n - k)
            _min = nCr(n-i-1, k-1);
        else
            _min = 0;
        res += (((_max - _min) % mod) * (v[i] % mod)) % mod;
        res = res % mod;
    }
    cout << res;
}


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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template < typename T >
void vprint(T &v){
	REP(i, v.size()){
		cout << v[i] << " ";
	}
	cout << endl;
}

int main(){
	ll N, A, B;
	cin >> N >> A >> B;
	cout << min(A, B) << " " << max(A+B-N, 0ll) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define vi vector<int>
#define ll long long
#define pb push_back
#define ii pair<int, int>
#define qi queue<int>
#define si stack<int>
#define mii map<int, int>
#define msi map<string, int>
#define fr first
#define sc second
#define all(x) x.begin(), x.end()
using namespace std;

const int MAX = 1e5+5;
const int mod = 1e9+7;

int k, s, ctr = 0;

int main(int argc, char** argv) {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

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

	cin >> k >> s;

	for (int x = 0; x <= k; x++) {
		for (int y = 0; y <= k; y++) {
			int z = s-(x+y);
			if (z >= 0 && z <= k) {
				//cout << x << ' ' << y << ' ' << z << endl;
				ctr++;
			}
		}
	}

	cout << ctr << endl;
	

	return 0;
}


Measured memory_bytes: 256
s = input()
a = int(s[:2])
b = int(s[2:])

if 0<a<=12 and 0<b<=12:
    print('AMBIGUOUS')
elif 0<a<=12:
    print('MMYY')
elif 0<b<=12:
    print('YYMM')
else:
    print('NA')

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

using namespace std;

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)

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

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

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

    ll X, Y;
    std::cin >> X >> Y;

    if(abs(X - Y) <= 1){
        std::cout << "Brown" << std::endl;
    }else{
        std::cout << "Alice" << std::endl;
    }
}


Measured memory_bytes: 384
#include <iostream>
#include <map>
#include <vector>
#include <utility>
#include <cstdio>
using namespace std;

int main() {
  int n, m;
  cin >> n >> m;
  vector<pair<int, int> > v(m);
  map<int, int> a, b;
  for (int i = 0; i < m; i++) {
    int p, y;
    cin >> p >> y;
    v[i].first = p;
    v[i].second = y;
    a[y] = p;
  }
  for (auto i = a.begin(); i != a.end(); i++) {
    int tmp = i->first;
    int cnt = i->second;
    a[tmp] = b[cnt]++ + 1;
  }
  for (int i = 0; i < m; i++) {
    int ans1 = v[i].first, ans2 = a[v[i].second];
    printf("%06d%06d\n", ans1, ans2);
  }
  return 0;
}

Measured memory_bytes: 11648
#include <vector>
#include <iostream>
#include <set>
#include <algorithm>
#include <map>
#include <string>
#include <cmath>
#include <tuple>
#include <queue>

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P; 
typedef tuple<ll,ll,ll> T;

int main(){
	ll n,d,x;
	cin >> n >> d >> x;
	vector<vector<ll>> p(d,vector<ll>(n));
	for(int i=0;i<d;i++){
		for(int j=0;j<n;j++)
			cin >> p[i][j];
	}
	ll ans=x;
	for(int t=0;t<d-1;t++){
		vector<ll> dp(ans+1); //dp[before]=after
		for(int i=0;i<n;i++){
			for(int now=0;now+p[t][i]<=ans;now++){
				dp[now+p[t][i]] = max(dp[now] + p[t+1][i] , dp[now+p[t][i]]);
			}
		}
		ll next=0;
		for(int i=0;i<=ans;i++){
			next=max(dp[i]+ans-i, next);
		}
		ans=next;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3192
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 

using namespace __gnu_pbds; 
using namespace std;
using   ll=long long;
using   ld=long double;

#define fast        	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ordered_set 	tree<pll, null_type,less<pll>, rb_tree_tag,tree_order_statistics_node_update>

#define endl        	"\n"
#define pb          	push_back
#define mp          	make_pair
#define F           	first
#define S           	second
#define int             long long int

#define ALL(v)      	v.begin(),v.end()
#define ALLR(v)     	v.rbegin(),v.rend()
#define pii         	3.14159265358979323
#define inf     		LLONG_MAX
#define ones(x)     	__builtin_popcount(x)
#define fill(a,b)   	memset(a,b,sizeof(a))
#define mod 			998244353

ll mod_pow(ll a,ll b) 
{
    ll res = 1;
    while(b)	
    {
        if(b&1) 	
        {
        	res=(res*a)%mod;
        }
        a=(a*a)%mod;
        b>>=1;
    }
    return res;
}

ll mod_inverse(ll a) 
{
	return mod_pow(a , mod-2);
}

void solve()
{
	int n;
	
	cin >> n;
	
	vector< int > vec;
	
	map<int , char> m;
	
	for(int i = 0; i < 26; ++i) {
		m[(i+1)%26] = (i+'a');
	}
	
	while(n > 0) {
		vec.pb(n%26);
		
		if(n % 26 == 0) {
			n/=26;
			n--;
		}
		else {
			n /= 26;
		}
	}
	
	reverse(ALL(vec));
	
	for(auto u : vec) {
		cout << m[u];
	}
}

signed main() {
    fast;
    
    int t = 1;
    
    //cin >> t;
    
    while(t--) {
        solve();
    }
 
    return 0;
}


Measured memory_bytes: 3652