akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=(a),i##_end=(b);i<=i##_end;i++)
#define per(i,a,b) for(int i=(b),i##_st=(a);i>=i##_st;i--)
#define x first
#define y second
#define I inline
#define OP operator
#define pb push_back
#define mp make_pair
#define RT return *this
#define dbg(x) cerr<<#x" = "<<x<<endl
#define Es(x,i) for(Edge *i=G[x];i;i=i->nxt)
typedef long long ll;typedef pair<int,int> pii;
const int inf=~0u>>1,MOD=1e9+7;char *TT,*mo,but[(1<<15)+2];
#define getchar() ((TT==mo&&(mo=((TT=but)+fread(but,1,1<<15,stdin)),TT==mo))?-1:*TT++)
I bool IS(char x){return x==10||x==13||x==' ';}
struct Cg{I char OP()(){return getchar();}};struct Cp{I void OP()(char x){putchar(x);}};
#define RX char c,f=1;while(!isdigit(c=P()))f=c!='-';x=c-'0';while(isdigit(c=P()))x=x*10+c-'0';x=f?x:-x
#define TR *this,x;return x
struct Fr{Cg P;I Fr&OP,(int&x){RX;RT;}I OP int(){int x;TR;}I Fr&OP,(ll &x){RX;RT;}I OP ll(){ll x;TR;}
I Fr&OP,(char&x){while(IS(x=P()));RT;}I OP char(){char x;TR;}
I Fr&OP,(char*x){char t=P();for(;IS(t);t=P());if(~t){for(;!IS(t)&&~t;t=P())*x++=t;}*x++=0;RT;}}in;
#define WI if(x){if(x<0)P('-'),x=-x;char s[22],c=0;while(x)s[c++]=x%10+'0',x/=10;while(c--)P(s[c]);}else P('0')
struct Fw{Cp P;I Fw&OP,(int x){WI;RT;}I Fw&OP,(ll x){WI;RT;}I Fw&OP,(char x){P(x);RT;}
I Fw&OP,(const char *x){while(*x)P(*x++);RT;}}out;
I int pw(int n,int m){int r=1;for(;m;m>>=1,n=1LL*n*n%MOD)if(m&1)r=1LL*r*n%MOD;return r;}
const int N=2e5+11;
int a[N],b[N],c[N],w[N],cnt[N],n,X,Y;
int fac[N],fai[N];
void init(){
	const int M=2e5;
	fac[0]=1;
	rep(i,1,M)fac[i]=1LL*fac[i-1]*i%MOD;
	fai[M]=pw(fac[M],MOD-2);
	per(i,0,M-1)fai[i]=1LL*(i+1)*fai[i+1]%MOD;
}
int main(){
#ifdef flukehn	
	freopen("test.txt","r",stdin);
#endif
	init();
	in,n,X,Y;
	for (int i=0;i<=n;i++) a[i]=MOD;
	for (int i=1;i<=n;i++){
		in,c[i],w[i];
		if (w[i]<a[c[i]]) a[c[i]]=w[i],b[c[i]]=i;
	}
	int c1=0,c2=0;
	for (int i=1;i<=n;i++)
		if (a[i]<a[c1]) c2=c1,c1=i;
			else if (a[i]<a[c2]) c2=i;
	int m=0;
	for (int i=1;i<=n;i++)
		if ((c[i]!=c1 && w[i]+a[c1]<=Y)||(c[i]!=c2 && w[i]+a[c2]<=Y)||
			((i==b[c[i]] || w[i]+a[c[i]]<=X) && a[c[i]]+a[c1]<=Y)) cnt[c[i]]++,m++;
	int ans=fac[m];
//	out,fai[0],'\n';
	rep(i,1,n)ans=1LL*ans*fai[cnt[i]]%MOD;
//	out,m,'\n';
	out,ans,'\n';
//	out,129729600,'\n';
}

Measured memory_bytes: 5760
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf = 1e9 + 7;
const ll longinf = 1LL << 60;
const ll mod = 1e9 + 7;

int n;
double ans, a[102];

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

	rep(i, n){
		ans += 1 / a[i];
	}
	ans = 1 / ans;

	cout << ans << endl;

}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<cstdio>
#include<unordered_map>
using namespace std;
//---------------------------------------------------
//ライブラリゾーン！！！！
typedef long long ll;
typedef long double ld;
#define str string
#define rep(i,j) for(ll i=0;i<(long long)(j);i++)
const ll Mod = 1000000007;
const ll gosenchou = 5000000000000000;
short gh[2][4] = { { 0,0,-1,1 },{ -1,1,0,0 } };
struct P {
	ll pos, cost;
};
bool operator<(P a, P b) { return a.cost < b.cost; }
bool operator>(P a, P b) { return a.cost > b.cost; }
struct B {//隣接リスト表現
	ll to;
	ld cost;
};
struct E {//辺の情報を入れる変数
	ll from, to, cost;
};
bool operator<(E a, E b) {
	return a.cost < b.cost;
}
struct H {
	ll x, y, h;
};
bool operator<(H a, H b) {
	if (a.x != b.x) return a.x < b.x;
	return a.y < b.y;
}
bool operator>(H a, H b) {
	if (a.x != b.x) return a.x > b.x;
	return a.y > b.y;
}
bool operator==(H a, H b) {
	return a.x == b.x&&a.y == b.y;
}
bool operator!=(H a, H b) {
	return a.x != b.x || a.y != b.y;
}
ll gcm(ll i, ll j) {//最大公約数
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcm(j%i, i);
}
ld rad(H a, H b) {
	return sqrt(pow(a.x - b.x, 2.0) + pow(a.y - b.y, 2.0));
}//rad＝座標上の2点間の距離
ll ari(ll a, ll b, ll c) {
	return (a + b)*c / 2;
}//等差数列の和
bool suf(ld a, ld b, ld c, ld d) {
	if (b <= c || d <= a) return 0;
	return 1;
}//[a,b),[c,d)
ll fact(ll x, ll k) {//最大値、個数
	ll sum = 1;
	for (int i = 0; i < k; i++)
		sum *= (x--);
	return sum;
}//階乗(正）
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res*x%p;
		x = x*x%p;
		n >>= 1;
	}
	return res;
}
#define int long long
const long long inf = 4523372036854775807;
const int iinf = 1500000000;
//----------------------------------------------------
//++++++++++++++++++++++++++++++++++++++++++++++++++++
int a[100001];
signed main() {
	int n, sum = 0;
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
		if (a[i] < i&&a[a[i]] == i) {
			sum++;
		}
	}
	cout << sum << endl;
	getchar(); getchar();
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcount

#define INF INT_MAX/3

#define MAX_A 1e16+1000

bool check(vector<ll> a){
  rep(i,a.size()){
    if(a[i]<0||a[i]>MAX_A)return false;
  }
  return true;
}

ll k;

int main(){
	cin.sync_with_stdio(false);
  cin>>k;
  repl(n,2,51){
    vector<ll> a(n);
    ll st=n*(n-1),ed=n*(n-1)+k;
    ll add=k/n;
    ll rest=ed-(n-1+add)*n;
    rep(i,n){
      a[i]=n-1+add;
    }
    for(int i=0;i<n&&rest>0;i++){
      a[i]+=n;
      rep(j,n){
        if(j!=i)a[j]--;
      }
      rest--;
    }
    if(check(a)&&rest==0){
      printf("%lld\n", n);
      rep(i,n){
        printf("%lld%c", a[i],i==n-1?'\n':' ');
      }
      return 0;
    }
  }
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>

/*147 into x, 105 into y*/
#define MAX 10000000000
int gcd(int,int);
int main(){
  int x,y;
  int d,n;
  int tmp,ans;
  scanf("%d %d",&x,&y);
  /*if(x <= 0 || MAX < y){                                                      
    return 0;                                                                   
    }*/
  ans = gcd(x,y);
  printf("%d\n",ans);
  return 0;
}

int gcd(int x,int y){
 int tmp;
 int r;
  if(x == y){
    return x;
  }

 if(x <= y){
  tmp = x;
  x = y;
  y = tmp;
  }
 while(y > 0){
   if(x != y){
     r = x % y;
   }
   //r = x % y;                                                                 
    x = y;
    y = r;
    /*if(x == y){                                                               
      return x;                                                                 
    }                                                                           
    else if(x%y==0){                                                            
      return r;                                                                 
    }                                                                           
    */
if(x%y==0){ /*Debug*/
      return r;
    }

    //y = r;                                                                    
  }
}

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

using namespace std;

typedef unsigned long long ll;
typedef  long double ld;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    ll t=1;
    //cin >> t;
    while (t--)
    {

        ld b;
        ll a;
        cin>>a>>b;
        //BigUnsigned  num1 = stringToBigUnsigned ((string)a);
        cout<<(unsigned long long)(a*b)<<endl;
    }
    return 0;
}


Measured memory_bytes: 3740
main = readLn >>= putStrLn.format.answer

format (a,b) = show a ++ " " ++ show b

answer :: Integer -> (Integer,Integer)
answer x = head $ filter judge [(a,b) | a <- [-120..120], b <- [-120..120]] where
    judge (a,b) = x == a^5 - b^5

Measured memory_bytes: 4928
#include <stdio.h>

int main(void){
        int n,x,count,i,j,k;
        while(1){
                count=0;
                scanf("%d %d",&n,&x);
                if(n==0&&x==0)
                        break;
                for(i=1;i<=(n-2);i++){
                        if(i==(x/3))
                                break;
                        for(j=i+1;j<=(n-1);j++){
                                if((x-i-j)<=j)
                                        break;
                                for(k=j+1;k<=n;k++){
                                        if((i+j+k)==x)
                                                count++;
                                }
                        }
                }
                printf("%d\n",count);
        }
        return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include <vector>
#include <cmath>
#include <iomanip>
#include <algorithm>
#include <queue>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)

int main() {
    int n,a;
    cin>>n>>a;
   cout<<(n-1)/a+1;
	return 0;
}


Measured memory_bytes: 504
#include <atcoder/convolution>
#include <atcoder/dsu>
#include <atcoder/fenwicktree>
#include <atcoder/lazysegtree>
#include <atcoder/math>
#include <atcoder/maxflow>
#include <atcoder/mincostflow>
#include <atcoder/modint>
#include <atcoder/scc>
#include <atcoder/segtree>
#include <atcoder/string>
#include <atcoder/twosat>

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

int N,M;
vector<vector<int>> t(100005);

vector<int> d(100005,-1);
long ans=0;
bool flg=1;
void dfs(int i,int p, int dpth){
  for (auto u : t[i]) {
    if(u==p)  continue;
    if(d[u]==-1){
      d[u]=dpth+1;
      dfs(u,i,dpth+1);
    }
    else{

    }
  }
}

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

  for(int i=0;i<N;i++){
    flg=1;
    if(d[i]==-1&&d[i]!=123456789){
      d[i]=0;
      dfs(i,-1,0);
      ans+=flg;

    }
  }

  cout<<ans-1<<endl;
}


Measured memory_bytes: 10156
MOD = 10**9 + 7

H, W, K = map(int, input().split())
if W == 1:
    print(1)
    exit()
dp = [[0 for x in range(W)] for h in range(H+1)]
dp[0][0] = 1

# ループを回す
for h in range(H):
    X, Y, Z = 0, 0, 0

    # 0: 線あり、1: 線なし
    for i in range(2 ** (W-1)):
        # 連続した1がある→隣接する列に線が引かれている
        if bin(i).count('11') >= 1:
            continue
        perm = [k for k in range(W)]
        for j in range(W-1):
            if ((i >> j) & 1):
                perm[j], perm[j+1] = perm[j+1], perm[j]

        for j in range(W):
            dp[h+1][perm[j]] += dp[h][j]
            dp[h+1][perm[j]] %= MOD


# 答えを得て出力
print(dp[H][K-1])
# print(dp)


Measured memory_bytes: 3064
N = int(input())
XL = []
for i in range(N):
    XL.append(list(map(int,input().split())))
XL.sort(key=lambda x:x[0])
ans = 0
left = XL[0][0]-XL[0][1]
right = XL[0][0]+XL[0][1]
for i in range(1,N):
    new_left = XL[i][0]-XL[i][1]
    new_right = XL[i][0]+XL[i][1]
    #if no overlap
    if new_left >= right:
        left = new_left
        right = new_right
    else:
        ans += 1
        if new_right < right:
            left = new_left
            right = new_right
print(N-ans)

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

using namespace std;
typedef long long ll;
typedef long double lb;
#define rep(i,j,n) for (ll i = j; i < (n); i++)
#define repr(i,j,n) for(ll i = j; i >= (n); i--)
#define each(i,mp) for(auto& i:mp)
#define all(x) (x).begin(),(x).end()
#define CLR(mat,f) memset(mat, f, sizeof(mat))
#define IN(a, b, x) (a<=x&&x<b)
#define out(ans) cout << ans << endl
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; }
typedef pair<ll,ll>P;
const ll mod=1e9+7;
const ll INF = 1LL<<60;
const ll m=1LL<<32;

int main(){

  ll n,m,k;cin>>n>>m>>k;
  bool e=false;
  rep(i,0,n+1){
    rep(j,0,m+1){
      if(m*i+n*j-2*i*j==k){
        e=true;
        // out(i<<":"<<j<<"="<<k);
      }
    }
  }

  if(e)out("Yes");
  else out("No");

  return 0;
}


Measured memory_bytes: 256
import sys
a,b,c = map(int,input().split(" "))
li = [[a,b,c]]
count=0

for i in range(10**2):
  if (a % 2)==1 or (b % 2)==1 or (c % 2)==1:
    break
  else:
    a2 = a/2
    b2 = b/2
    c2 = c/2
    a = b2+c2
    b = c2+a2
    c = a2+b2  
    count += 1
  if [a,b,c] in li:
    print(-1)
    sys.exit()
  else:
    li.append([a,b,c])
    
print(count)


Measured memory_bytes: 9192
import java.util.Scanner;

class Main {

	private static final String LIGHT_FLY = "light fly";
	private static final String FLY = "fly";
	private static final String BANTAM = "bantam";
	private static final String FEATHER = "feather";
	private static final String LIGHT = "light";
	private static final String LIGHT_WELTER = "light welter";
	private static final String WELTER = "welter";
	private static final String LIGHT_MIDDLE = "light middle";
	private static final String MIDDLE = "middle";
	private static final String LIGHT_HEAVY = "light heavy";
	private static final String HEAVY = "heavy";

	public static void main(String[] args) {
		Scanner scanner = null;
		try {
			scanner = new Scanner(System.in);
			while (scanner.hasNextDouble()) {
				double weight = scanner.nextDouble();
				System.out.println(getWeightClass(weight));
			}
		} finally {
			scanner.close();
		}
	}

	private static String getWeightClass(double weight) {
		String weghitClass = null;

		if (weight <= 48.00) {
			weghitClass = LIGHT_FLY;
		} else if (weight <= 51.00) {
			weghitClass = FLY;
		} else if (weight <= 54.00) {
			weghitClass = BANTAM;
		} else if (weight <= 57.00) {
			weghitClass = FEATHER;
		} else if (weight <= 60.00) {
			weghitClass = LIGHT;
		} else if (weight <= 64.00) {
			weghitClass = LIGHT_WELTER;
		} else if (weight <= 69.00) {
			weghitClass = WELTER;
		} else if (weight <= 75.00) {
			weghitClass = LIGHT_MIDDLE;
		} else if (weight <= 81.00) {
			weghitClass = MIDDLE;
		} else if (weight <= 91.00) {
			weghitClass = LIGHT_HEAVY;
		} else {
			weghitClass = HEAVY;
		}
		return weghitClass;
	}
}

Measured memory_bytes: 28052
#include<bits/stdc++.h>
#define start_routine cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(false); int begtime = clock();
#define end_routine int endtime = clock(); cerr << endl << "Time elapsed: " << (endtime - begtime)*1000/CLOCKS_PER_SEC << " ms"; return 0;
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define int long long
#define mp make_pair
#define fr(i,a,b) for(int i=a;i<b;i++)
#define mod 1000000007
#define FILEIO freopen("C:/Users/Aman/Desktop/kachda/input.txt", "r", stdin); freopen("C:/Users/Aman/Desktop/kachda/output.txt", "w", stdout);

using namespace std;

int n;
double p[3000], dp[3000][3000] = {0};

signed main()
{
	//FILEIO
 	start_routine
	cout<<setprecision(15);
	cin>>n;
	fr(i,1,n + 1) cin>>p[i];
	dp[0][0] = 1;
	
	fr(i,1,n + 1)
	{
		fr(j,0, i + 1)
		{
			dp[i][j] = p[i]*dp[i - 1][j - 1] + (1 - p[i])*dp[i - 1][j];
		}
	}

	double ans = 0;
	fr(i,n/2 + 1,n + 1) ans += dp[n][i];
	cout<<ans;

 	end_routine
}

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

string s;

int main() {
	cin >> s;
	int begin = -1, end = -1;
	for (int i = 0; i < s.length();i++) {
		if (s[i] == 'A' && begin == -1) {
			begin = i;
		}
		if (s[s.length() - 1 - i] == 'Z' && end == -1) {
			end = s.length() - 1 - i;
		}
	}

	cout << (end - begin + 1) << endl;
}

Measured memory_bytes: 640
import sys
sys.setrecursionlimit(10000000)
MOD = 10 ** 9 + 7
INF = 10 ** 15

def main():
    MAXS = 100005
    N = int(input())
    X = [set() for _ in range(MAXS)]
    Y = [set() for _ in range(MAXS)]
    for _ in range(N):
        x,y = map(int,input().split())
        X[x].add(y)
        Y[y].add(x)
    
    used_x = [0] * MAXS
    used_y = [0] * MAXS
    ans = -N
    for i in range(MAXS):
        if used_x[i]:
            continue
        used_x[i] = 1
        if not X[i]:
            continue
        max_height = set(X[i])
        max_width = {i}
        stack = [(i,0)]
        while stack:
            v,typ = stack.pop()
            if typ == 0:
                for y in X[v]:
                    if used_y[y]:
                        continue
                    used_y[y] = 1
                    if Y[y]:
                        max_width |= Y[y]
                        stack.append((y,1))
            else:
                for x in Y[v]:
                    if used_x[x]:
                        continue
                    used_x[x] = 1
                    if X[x]:
                        max_height |= X[x]
                        stack.append((x,0))
        ans += len(max_width) * len(max_height)
    print(ans)
if __name__ == '__main__':
    main()

Measured memory_bytes: 74712
#include <iostream>
using namespace std;
int main(void){
    int a;
    int b;
    
    cin >> a >> b;

    int no;
    for(int i = 1; i <= 1000000000; i++) {
        if (abs(a - i) == abs(b - i)) {
            no = i;
            break;
        } else {
            no = 0;
            if (a - i < 0 && b - i < 0) {
                break;
            }
        }
    }
    if (no != 0) {
        cout << no;   
    } else {
        cout << "IMPOSSIBLE";
    }
}

Measured memory_bytes: 888
#!python3

import sys
iim = lambda: map(int, sys.stdin.readline().rstrip().split())
from bisect import bisect

def resolve():
    it = map(int, sys.stdin.read().split())
    D = next(it)
    C = [next(it) for i in range(26)]
    S = [[next(it) for i in range(26)] for i in range(D)]
    L = [[-1] for i in range(26)]
    T = [-1] * D

    score = 0
    for i in range(D):
        ti = next(it)-1
        score += S[i][ti]
        L[ti].append(i)
        T[i] = ti
        for ci, la in zip(C, L):
            score -= ci * (i-la[-1])

    N = next(it)
    for i in range(N):
        di, qi = next(it)-1, next(it)-1

        t0 = T[di]
        score += S[di][qi]-S[di][t0]
        T[di] = qi

        li = L[t0]
        ii = li.index(di)
        la = D if len(li)-1 == ii else li[ii+1]
        score -= C[t0] * (di-li[ii-1])*(la-di)
        li.remove(di)

        li = L[qi]
        ii = bisect(li, di)
        li.insert(ii, di)
        la = D if len(li)-1 == ii else li[ii+1]
        score += C[qi] * (di-li[ii-1])*(la-di)

        print(score)


if __name__ == "__main__":
    resolve()


Measured memory_bytes: 88028
n = int(input())
edges = [[] for _ in range(n)]

for _ in range(n-1):
    _from, to, dist = map(int, input().split())
    edges[_from-1].append([to-1, dist])
    edges[to-1].append([_from-1, dist])

q, k = map(int, input().split())
k -= 1

distance_from_k_to = [10**7] * n
distance_from_k_to[k] = 0

todo = []
while edges[k]:
    to, dist = edges[k].pop()
    todo.append([to, dist])

while todo:
    node, dist = todo.pop()
    if distance_from_k_to[node] != 10**7:  # if node has been seen
        continue

    distance_from_k_to[node] = dist
    while edges[node]:
        to, add_dist = edges[node].pop()
        todo.append([to, dist+add_dist])

for _ in range(q):
    start, goal = map(int, input().split())
    start, goal = start-1, goal-1
    ans = distance_from_k_to[start] + distance_from_k_to[goal]
    print(ans)


Measured memory_bytes: 52896
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
import java.util.StringTokenizer;

public class Main {
  private static class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;

    public FastScanner(InputStream in) {
      reader = new BufferedReader(new InputStreamReader(in));
      tokenizer = null;
    }

    public String next() {
      if (tokenizer == null || !tokenizer.hasMoreTokens()) {
        try {
          tokenizer = new StringTokenizer(reader.readLine());
        } catch (IOException e) {
          throw new RuntimeException(e);
        }
      }
      return tokenizer.nextToken();
    }

    public String nextLine() {
      if (tokenizer == null || !tokenizer.hasMoreTokens()) {
        try {
          return reader.readLine();
        } catch (IOException e) {
          throw new RuntimeException(e);
        }
      }

      return tokenizer.nextToken("\n");
    }

    public long nextLong() {
      return Long.parseLong(next());
    }

    public int nextInt() {
      return Integer.parseInt(next());
    }

    public double nextDouble() {
      return Double.parseDouble(next());
    }

    public int[] nextIntArray(int n) {
      int[] a = new int[n];
      for (int i = 0; i < n; i++)
        a[i] = nextInt();
      return a;
    }

    public long[] nextLongArray(int n) {
      long[] a = new long[n];
      for (int i = 0; i < n; i++)
        a[i] = nextLong();
      return a;
    }
  }

  public static void main(String[] args) {
    FastScanner sc = new FastScanner(System.in);
    int h = sc.nextInt();
    int w = sc.nextInt();
    int k = sc.nextInt();
    long mod = 1_000_000_007L;
    if (w == 1) {
      System.out.println(1);
      return;
    }
    long[][] dp = new long[h + 1][w];
    dp[0][0] = 1L;
    List<Integer> horizontalLine = new ArrayList<>();
    for (int i = 0; i < (1 << (w - 1)); i++) {
      int val = i;
      boolean pass = true;
      while (val > 0) {
        if ((val & 3) == 3) {
          pass = false;
          break;
        }
        val = val >> 1;
      }
      if (pass) horizontalLine.add(i);
    }
    for (int i = 1; i <= h; i++) {
      for (int j = 0; j < w; j++) {
        for (int hl : horizontalLine) {
          if (j < w - 1 && ((hl >> j) & 1) == 1) {
            dp[i][j] += dp[i - 1][j + 1];
          } else if (j - 1 >= 0 && ((hl >> (j - 1)) & 1) == 1) {
            dp[i][j] += dp[i - 1][j - 1];
          } else {
            dp[i][j] += dp[i - 1][j];
          }
          dp[i][j] %= mod;
        }
      }
    }
    System.out.println(dp[h][k - 1]);
  }
}

Measured memory_bytes: 21204
N=int(input())
info=[]
for i in range(N):
	name, p = input().split()
	p = int(p)
	info.append([i+1, name, p])

info = sorted(info, key=lambda x: x[2], reverse=True)
info = sorted(info, key=lambda x: x[1])
for r in info:
	print(r[0])


Measured memory_bytes: 3060
# coding: utf-8
# from time import time

N, K = map(int, input().split())
A = list(map(int, input().split()))

# start = time()

# C = [[A[i], i] for i in range(N)]
# C = []
# appeared = []
# for i in range(N):
#     if A[i] not in appeared:
#         C.append([A[i], i])
#         appeared.append(A[i])

C = [[A[i], i] for i in range(N)]

C = sorted(C, key=lambda x: x[0], reverse=False)
# print(C)

tento_dict = {C[0][1]: 0}  # i == 0
for i in range(1, N):
    if C[i][0] == C[i-1][0]:
        tento_dict[C[i][1]] = tento_dict[C[i-1][1]]
    else:
        tento_dict[C[i][1]] = i

# tento_dict = {C[i][1]: N-(i+1) for i in range(N)}
# print(tento_dict)

# i == 0
ans = tento_dict[0] * (K * (K+1) // 2)
for i in range(1, N):
    ans += tento_dict[i] * (K * (K-1) // 2)
    for j in range(i+1, N):
        if A[i] > A[j]:
            ans += K

print(ans % (10**9 + 7))


Measured memory_bytes: 3572
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <string>
#include <queue>
#include <stack>
#include <math.h>
#include <tuple>

using namespace std;

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

#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define REPR(i, n) for (ll i = (n) - 1; i >= 0; --i)
#define FOR(i, n, m) for (ll i = (n); i < (m); ++i)
#define FORR(i, n, m) for (ll i = (m) - 1; i >= (n); --i) 
#define FORE(x, xs) for (auto &x: (xs))
#define ALL(v) v.begin(), v.end()
#define ZERO(a) memset(a,0,sizeof(a))
#define P(x, y) make_pair(x, y)

const ll INF = 1e17;
const int MOD = 1000000007;
const double EPS = 1e-14;
const double PI = acos(-1);

const int NMAX = 1e5; /// 最大頂点数
const int MMAX = 1e5; /// 最大辺

ll N, M; /// N:頂点数、M:辺の数

int a[MMAX], b[MMAX], c[MMAX];
ll dist[NMAX]; /// dist[j]は注目する頂点kからの最短距離、特にdist[k]=0


bool bellman_ford(int s) { /// 負の閉路があるときtrueを返す
  // fill_n(dist, N, INF);
  // dist[s] = 0;
  REP (loop, N-1) {
    REP (m, M) {
      if (dist[a[m]] == INF) continue; /// まだdist[a[i]]にたどり着いていないので考慮しない
      dist[b[m]] = min(dist[b[m]], dist[a[m]] + c[m]);
    }
  }

  REP (m, M) if (dist[b[m]] > dist[a[m]] + c[m]) return true;
  return false;
}

int main() {
  cin >> N >> M;
  REP (i, M) {
    cin >> a[i] >> b[i] >> c[i];
    a[i]--;
    b[i]--;
    c[i] *= -1;
  }

  fill_n(dist, N, INF);
  dist[0] = 0;
  bellman_ford(0);
  ll ans = dist[N-1];
  bellman_ford(0);

  if (ans != dist[N-1]) {
    cout << "inf" << endl;
  } else {
    cout << -dist[N-1] << endl;
  }

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define endl '\n'
using namespace std;
const ll mod = (ll)10e9+7;
const int INF = 0x3f3f3f3f;

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    string str;
    cin >> str;
    int seg=0, w=1;
    for(int i=0; i<str.length(); i++)
    {
        if(str[i]=='W'&&!w)
            w=1;
        else if(str[i]=='B'&&w)
        {
            seg+=2;
            w=0;
        }
    }
    if(str[0]=='B') seg--;
    if(str[str.length()-1]=='B') seg--;
    cout << seg;
}

//TODO: 47


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

int main(){
  int n;
  cin>>n;
  string str;
  cin>>str;
  int K;
  cin>>K;
  string ans = str;
  
  for(int i=0;i<n;i++){
    if(str[i] == '1' || K == 0) continue;
    ans[i] = '1';
    K--;
  }

  for(int i=0;i<n;i++){
    if(str[n-1-i] != ans[n-1-i] || K == 0)continue;
    ans[n-1-i] = '0';
    K--;
  }
  cout<<ans<<endl;

  return 0;
}

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


int main(){
  int N,M; cin >> N >> M;
  int count[M] = {0};
  for(int i=0;i<N;i++){
    int k; cin >> k;
    for(int j=0;j<k;j++){
      int temp; cin >> temp;
      count[temp-1]++;
    }
  }
  int r=0;
  for(int i=0;i<M;i++){
    if(count[i]==N) r++;
  }
  cout << r << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <list>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rep2(i, s, n) for(int i=s; i<(n); ++i)
#define sz(x) int(x.size())

typedef long long ll;

using namespace std;

/*******-c++14 don't include-*******/
template<typename T>
T gcd(T a, T b){if( b == 0)return a; return gcd(b, a%b); }
template<typename T>
T lcm(T a, T b){return a*b/gcd(a,b); }
void printArr(int *a, int len){for(int i=0; i<len; i++){if(i)cout << " ";cout << a[i];}cout << endl;}
/*******---------------------*******/

static const int INTINF = (2147483647);
static const ll LLINF = (1ll<<32);
static const int MAX = 100001;

int arr[MAX];

int main(int argc, const char * argv[]) {
    // input from txt
    /////////
    //write//
    /////////
    
    int a, b;
    cin >> a >> b;
    int res = a - b * 2;
    if(res < 0 )res = 0;
    cout << res << endl;
    
    
    return 0;
}


Measured memory_bytes: 768
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
typedef long double ld;
const ll MOD=1e9+7;
const ll N=2e5+5;
const ld pi=3.14159265359;
const ll INF=(1LL<<63);
#define REP(i,n) for(ll i=0;i<n;i++)
#define REP1(i,n) for(ll i=1;i<=n;i++)
#define pb push_back
#define mp make_pair
#define X first
#define Y second
#define setp setprecision
#define lwb lower_bound
#define SZ(a) (ll)a.size()

ll n,a[N],ans=1,id,cnt,j,c[3];

int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);
	cin>>n;
	REP1(i,n)cin>>a[i];
	REP1(i,n){
		for(id=-1,j=0,cnt=0;j<3;j++)if(a[i]==c[j])cnt++,id=j;
		if(id==-1){cout<<"0\n";return 0;}
		ans=ans*cnt%MOD;c[id]++;
	}
	cout<<ans<<"\n";
	return 0;
}




Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define RI(X) scanf("%d", &(X))
#define RII(X, Y) scanf("%d%d", &(X), &(Y))
#define RIII(X, Y, Z) scanf("%d%d%d", &(X), &(Y), &(Z))
#define DRI(X) int (X); scanf("%d", &X)
#define DRII(X, Y) int X, Y; scanf("%d%d", &X, &Y)
#define DRIII(X, Y, Z) int X, Y, Z; scanf("%d%d%d", &X, &Y, &Z)
#define RS(X) scanf("%s", (X))
#define CASET int ___T, case_n = 1; scanf("%d ", &___T); while (___T-- > 0)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define PII pair<int,int>
#define VI vector<int>
#define VL vector<long long>
#define VPII vector<pair<int,int> >
#define PLL pair<long long,long long>
#define VPLL vector<pair<long long,long long> >
#define F first
#define S second
typedef long long LL;
using namespace std;
const int MOD = 1e9+7;
const int SIZE = 1e6+10;
long double EPS=2e-16;
int main(){
    DRI(N);
    long double one=1;
    REPP(i,1,3501)REPP(j,1,i+1){
        LL k=(LL)(one/(one*4/N-one/i-one/j)+EPS);
        for(LL w=k-2;w<=k+2;w++){
            if(w>=1&&w<=3500){
                if(4LL*i*j*w==(LL)i*j*N+(LL)j*w*N+(LL)w*i*N){
                    printf("%d %d %lld\n",i,j,w);
                    return 0;
                }
            }
        }
    }
    return 0;
}


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

using namespace std ;

int n ;
const int N = 2e5 + 10 ;
struct Node {
  int v , nxt ;
} ;
Node e[N << 1] ;
int head[N] , cnt = 0 ;
void add(int u , int v) {
  e[++ cnt] = { v , head[u] } ;
  head[u] = cnt ;
}
int num = 0 ;
int cr[N] ;
void dfs(int u , int las , int fa) {
  int tot = 0 ;
  for(int i = head[u] ; i ; i = e[i].nxt) {
    int v = e[i].v ;
    if(v == fa) continue ;
    ++ tot ; if(tot == las) ++ tot ;
    cr[i] = tot ; num = max(num , tot) ;
    dfs(v , tot , u) ;
  }
}
signed main() {
  ios :: sync_with_stdio(false) ;
  cin.tie(nullptr);
  cout.tie(nullptr) ;
  cin >> n ;
  for(int i = 1 ; i < n ; i ++) {
    int u , v ;
    cin >> u >> v ;
    add(u , v) ;
    add(v , u) ;
  }
  dfs(1 , 0 , 0) ;
  cout << num << '\n' ;
  for(int i = 1 ; i < n ; i ++) {
    if(cr[(i - 1) << 1 | 1]) cout << cr[(i - 1) << 1 | 1] << '\n' ;
    else cout << cr[i << 1] << '\n' ;
  }
  return 0 ;
}

Measured memory_bytes: 6400
#include <cstdio>

#define maxn 100010
long long x[maxn], y[maxn];
const int mod = 1e9 + 7;
int main()
{
	int n, m, sm = 0, ans = 0; scanf("%d%d", &n, &m);
	for (int i = 1; i <= n; ++i) scanf("%lld", &x[i]);
	for (int i = 1; i <= m; ++i) scanf("%lld", &y[i]);
	for (int i = 1; i < m; ++i)
		sm = (sm + 1ll * i * (m - i) % mod * (y[i + 1] - y[i])) % mod;
	for (int i = 1; i < n; ++i)
		ans = (ans + 1ll * i * (n - i) % mod * (x[i + 1] - x[i]) % mod * sm) % mod;
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 1664
#include <iostream>
#include <map>
#include <set>
#include <string>
#define int long long
using namespace std;
map<string, int>m;
set<string>s;
signed main() {
	int q; cin >> q;
	for (int i = 0; i < q; i++) {
		int p; string k, l, r;
		cin >> p;
		if (p == 0) {
			cin >> k >> p;
			s.insert(k); m[k] = p;
		}
		else if (p == 1) {
			cin >> k;
			if (s.count(k))cout << m[k] << endl;
			else cout << 0 << endl;
		}
		else if (p == 2) {
			cin >> k;
			s.erase(k);
		}
		else {
			cin >> l >> r;
			for (auto i = s.lower_bound(l); i != s.upper_bound(r); i++)cout << *i << ' ' << m[*i] << endl;
		}
	}
}


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

#define MAX_L 3000

int dp[MAX_L + 1][MAX_L + 1];

int main() {
  std::string s, t;
  int ls, lt;

  std::cin >> s >> t;
  ls = (int) s.size();
  lt = (int) t.size();

  for(int i = 0; i < ls; ++i) {
    for(int j = 0; j < lt; ++j) {
      if(s[i] == t[j]) dp[i + 1][j + 1] = dp[i][j] + 1;
      else dp[i + 1][j + 1] = std::max(dp[i + 1][j], dp[i][j + 1]);
    }
  }

  std::string ans = "";
  int i = ls, j = lt;
  while(i > 0 && j > 0) {
    if(dp[i][j] == dp[i - 1][j]) --i;
    else if(dp[i][j] == dp[i][j - 1]) --j;
    else if(dp[i][j] == dp[i - 1][j - 1] + 1) {
      ans = s[i - 1] + ans;
      --i, --j;
    }
  }

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

Measured memory_bytes: 35456
#include <iostream>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <cstdio>
#include <math.h>
#include <map>
#include <queue>
#include <string>
using namespace std;

int c1,c2,c3;

int main(){
	while(cin>>c1>>c2>>c3){
		int n=0;
		for(int i=1;i<11;i++)if(i!=c1&&i!=c2&&i!=c3&&c1+c2+i<=20)n++;
		if(n>3)cout<<"YES"<<endl;
		else cout<<"NO"<<endl;
	}
}

Measured memory_bytes: 0
import java.util.*;
import java.io.*;
import java.math.BigInteger;
public class Main {

	private static final int mod =(int)1e9+7;
	public static void main(String[] args) throws Exception  {
	      Scanner  sc=new Scanner(System.in);
	      PrintWriter out=new PrintWriter(System.out);
long x=sc.nextLong();
long y=sc.nextLong();
if(Math.abs(x-y)<=1) {
  System.out.println("Brown");
}else {
  out.println("Alice");
}
out.flush();
	    }
	
	
	static boolean vis[]=new boolean[10001];
	      static int gcd(int a, int b) 
	      { 
	          if (a == 0) 
	              return b; 
	          return gcd(b % a, a); 
	      } 
	    
	      // Function to find gcd of array of 
	      // numbers 
	      static int f(int arr[], int n) 
	      { 
	          int result = n; 
	          int max=-1;
	          int ans=0;
	          for (int element: arr){ 
	                if(vis[element]==false)
	                     
	              result = gcd(n, element); 
	              if(result>max) {      
	                    max=result;
	                    ans=element;
	           
	              }
	           
	            
	          } 
	     
	               
	          return ans; 
	      } 
	     
	      
}

Measured memory_bytes: 35704
#include<bits/stdc++.h>
using namespace std;
#define ALL(obj) (obj).begin(), (obj).end()
#define REP(i, n) for(int i = 0;i < (n);++i)

#define endl '\n'
#define pb push_back
#define mkp make_pair
#define p_q priority_queue
#define INF 200000000
#define PI 3.1415926
#define coutdb cout << fixed << setprecision(10)

const int dx[]={1,0,-1,0}, dy[]={0,-1,0,1};
const int dx_8[]={1,1,0,-1,-1,-1,0,1}, dy_8[]={0,-1,-1,-1,0,1,1,1};
const long long MOD = 1e9+7;

// typedef long long ll;
#define int long long

template <typename T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template <typename T> inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template <typename T> inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template <typename T> inline T nHr(T a,T b){return nCr(a+b-1,b);}

typedef pair<int, int> P;

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

  int N, M, A, B; cin >> N >> M;
  vector<P> vec;
  REP(i, N){
    cin >> A >> B;
    vec.pb(P(A, B));
  }
  sort(ALL(vec));

  int num = 1, ans = 0;
  p_q<int> que;
  REP(i, N){
    cerr << "(" << vec[i].first << ", " << vec[i].second << ")" << endl;
    if(num > M) break;
    if(vec[i].first == num) que.push(vec[i].second);
    else {
      while(num != vec[i].first){
        if(num > M){
          cout << ans << endl;
          return 0;
        }
        if(!que.empty()){
          ans += que.top(); que.pop();
        }
        num++;
      }
      que.push(vec[i].second);
    }
  }
  while(num <= M){
    if(!que.empty()){
      ans += que.top(); que.pop();
    }
    num++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3568
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(n);i++)
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const int MAX = 1000000;
const int INF = 1e9;
const double pi=acos(-1);
long long 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;
    }
}

// 二項係数計算
long long COM(int n, int 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 x,y;
  cin >> x >> y;
  COMinit();
  if((x+y)%3!=0){
    cout << 0 << endl;
    return 0;
  }
  ll r=(2*y-x)/3;
  ll u=(2*x-y)/3;
  cout <<COM(r+u,r)<<endl;
  return 0;
}


Measured memory_bytes: 23680
#import sys
#def input():
#  return sys.stdin.readline()[:-1]

N, M=map(int, input().split())
NN=2**N

dp=[[0]+[-1]*(NN-1) for i in range(M+1)]
for i in range(1, M+1):
  a, b=map(int, input().split())
  c=list(map(int, input().split()))
  csum=sum([2**(c[s]-1) for s in range(b)])
  
  for j in range(NN):
    if dp[i-1][j]>-1:
      if dp[i][j]==-1 or dp[i][j]>dp[i-1][j]:
        dp[i][j]=dp[i-1][j]
      
      tmp=csum|j
      if dp[i][tmp]==-1 or dp[i][tmp]>dp[i][j]+a:
        dp[i][tmp]=dp[i][j]+a
        
print(dp[-1][-1])

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

int main(){
while(1){
	int n,m,h,k,r[1002],p[1002],e[1002],c,d,ans=0,ma=0;
	vector<int> a[1000],aa,bb;
	scanf("%d%d%d%d",&n,&m,&h,&k);
if(n==0&&m==0&&h==0&&k==0)break;
	for(int i=1;i<=n;i++){r[i]=i; scanf("%d",&p[i]);}
	for(int i=0;i<m;i++){
		scanf("%d%d",&c,&d);
		a[d].push_back(c);
	}
	for(int i=0;i<1000;i++){
		int s=a[i].size();
		for(int j=0;j<s;j++){
			aa.push_back(r[a[i][j]]);
			bb.push_back(r[a[i][j]+1]);
			int t=r[a[i][j]];
			r[a[i][j]]=r[a[i][j]+1];
			r[a[i][j]+1]=t;
		}
	}
	for(int i=1;i<=n;i++){
		e[r[i]]=i;
	}
	for(int i=1;i<=k;i++){
		ans+=p[e[i]];
	}
	for(int i=0;i<m;i++){
		if(aa[i]<=k&&bb[i]>k&&(p[e[aa[i]]]-p[e[bb[i]]])>ma)ma=p[e[aa[i]]]-p[e[bb[i]]];
		if(bb[i]<=k&&aa[i]>k&&(p[e[bb[i]]]-p[e[aa[i]]])>ma)ma=p[e[bb[i]]]-p[e[aa[i]]];
	}
	printf("%d\n",ans-ma);
}
}

Measured memory_bytes: 2756
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
using namespace std;
int main(){
	int n;
	while(cin >> n){
		if(n==-1)
			break;
		vector<int> ans(0);
		do{
			ans.insert(ans.begin(),n%4);
			n=n/4;
		}
		while(n!=0);
		for(int i=0;i<ans.size();i++)
			cout << ans[i];
		cout << endl;
	}
}

Measured memory_bytes: 3020
x,y = map(int,input().split())
x1 = abs(x)
y1 = abs(y)
count = 0
if x >= 0:
    if y >= 0:
        if y >= x:
            count = y - x
        else:
            count = x - y + 2
    else:
        count = abs(y1 - x) + 1
else:
    if y >= 0:
        count = abs(y - x1) + 1
    else:
        if x1 >= y1:
            count = x1 - y1
        else:
            count = y1 - x1 + 2
if y == 0:
    count = count - 1
print(count)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using P = pair<ll,ll>;
const ll mod = 1e9+7;
#define ALL(x) (x).begin(),(x).end()
#define pow(x,y) modpow(x,y)
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define REPS(i,n) for(ll (i)=1;(i)<=(n);(i)++)
#define RREP(i,n) for(ll (i)=(n-1);(i)>=0;(i)--)
#define RREPS(i,n) for(ll (i)=(n);(i)>0;(i)--)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());

template <class T = int>T in(){
    T x;
    cin >> x;
    return (x);
}

template<class T> inline void chmin(T& a, T b){
    if (a > b){
        a = b;
    }
}

template<class T> inline void chmax(T& a, T b){
    if (a < b){
        a = b;
    }
}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(10);
    int N = in();
    vector<int> H(N);
    REP(i,N)H[i] = in();
    int mini = H[0]-1;
    bool ok = 1;
    REP(i,N-1){
        if(H[i+1] > mini){
            H[i+1]--;
            chmax(mini,H[i+1]);
        }else if(H[i+1] == mini){
            continue;
        }else{
            ok = 0;
            break;
        }
    }
    cout << (ok ? "Yes" : "No") << "\n";
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define all(v) v.begin(),v.end()
#define P pair<int,int>
#define len(s) (int)s.size()
#define pb push_back

template<class T> inline bool chmin(T &a, T b){
	if(a>b){a=b;return true;}
	return false;
}
template<class T> inline bool chmax(T &a, T b){
	if(a<b){a=b;return true;}
	return false;
}
constexpr int mod = 1e9+7;
constexpr int inf = 3e18;

int N;
int A[100005];
signed main(){
	cin>>N;
	rep(i,N){
		cin>>A[i];
		if(A[i]==0){
			cout<<0<<endl;return 0;
		}
	}
	int now=1;
	rep(i,N){
		if(inf/now<A[i]){
			cout<<-1<<endl;return 0;
		}
		now*=A[i];
	}
	if(now>(int)1e18)cout<<-1<<endl;
	else cout<<now<<endl;
}


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

int main(){
	int N, L;
	cin >> N >> L;
	string S[N];
	rep(i,N) cin >> S[i];
	sort(S,S+N);
	string ans = "";
	rep(i,N) ans += S[i];
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3648
n = int(input())
ai = list(map(int,input().split()))

dp =[[0, -10**9]]
#print(dp[0][0])

for i in range(1,n+1):
	dp.append([max(dp[i-1][0]+ai[i-1], dp[i-1][1]-ai[i-1]), \
			max(dp[i-1][0]-ai[i-1], dp[i-1][1]+ai[i-1])])
	#print(dp)
    
print(dp[n][0])

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


void solve(long long N, long long X, long long T){
    if(N%X != 0) cout << T * (N/X + 1) << endl;
    else cout << T* (N/X) << endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    long long X;
    scanf("%lld",&X);
    long long T;
    scanf("%lld",&T);
    solve(N, X, T);
    return 0;
}


Measured memory_bytes: 3684
import sys
sys.setrecursionlimit(10**7)
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return sys.stdin.readline().strip()
INF = 10 ** 18
MOD = 10 ** 9 + 7

def main(): 
    S = II()

    import math

    if S <= 10**9:
        print(S, 0, 0, 1, 0, 0)
    else:
        ceil = math.ceil(math.sqrt(S))
        m = (ceil-1) * ceil - S
        n = ceil * ceil - S
        if m >= 0:  # S = (ceil-1) * ceil - m
            print(ceil, m, 1, ceil-1, 0, 0)
        else:  # S = ceil * ceil - n
            print(ceil, n, 1, ceil, 0, 0)

main()

Measured memory_bytes: 3188
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
//#include <regex>

/* g++ -g -std=c++0x */
/* g++ -g -std=c++11 */

using namespace std;

// std::ios::sync_with_stdio(false);

// freopen("input.txt", "rt", stdin);
// freopen("output.txt", "wt", stdout);

#define ALL(c)          (c).begin(), (c).end()
#define ALLR(c)         (c).rbegin(), (c).rend()
#define FOR(i,a,b)      for (int i=(a); i < (b); ++i)
#define FORR(i,a,b)     for (int i=(a); i > (b); --i)
#define FOR_ALL(i,c)    for (__typeof((c).begin()) i=(c).begin();   \
                             i != (c).end(); ++i)
#define FOR_ALLR(i,c)   for (__typeof((c).rbegin()) i=(c).rbegin(); \
                             i != (c).rend(); ++i)
#define SZ(array)       (sizeof(array)/sizeof(array[0]))
#define lc(x)           (x<<1)     /* 2*x */
#define rc(x)           (x<<1 | 1) /* 2*x+1 */
#define lowbit(x)       (x & (-x)) /* 0b10100 -> 0b100 */

typedef long long       LL;
typedef map<int,int>    MII;
typedef pair<int,int>   PII;
typedef set<int>        SI;
typedef vector<bool>    VB;
typedef vector<double>  VD;
typedef vector<int>     VI;
typedef vector<string>  VS;

/* check if a key is in container C */
template <class C>
inline bool in_(const typename C::key_type& k, const C& A)
{ return A.find(k) != A.end(); }
inline bool in_(const string& s, const string& S)
{ return S.find(s) != string::npos; }

const int maxn = 1e5+5;
int A[maxn];

int main()
{
/* #ifndef ONLINE_JUDGE */
/*     freopen("foo", "rt", stdin); */
/* #endif */
    int N;
    while (cin >> N) {
        FOR(i,1,N+1) {
            int a; cin >> a;
            A[i] = i == a;
        }
        int ans = 0;
        FOR(i,1,N) {
            if (A[i] == 1 && A[i+1] == 1) {
                A[i] = A[i+1] = 0;
                ans++;
            }
        }
        FOR(i,1,N+1) {
            if (A[i] == 1) {
                A[i] = 0;
                ans++;
            }
        }
        cout << ans << endl;
    }
    return 0;
}


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

#define VIC ios::sync_with_stdio(0);cin.tie(0);ios_base::sync_with_stdio(0);
#define wtf(s) freopen((s), "w", stdout)
#define rff(s) freopen((s), "r", stdin)
#define pi (2 * acos(0))
typedef long double ld;
typedef long long ll;
#define endl '\n'
#define matrix vector<vector<ll>>
ll fact[4009] , inv[4009]  , mod=998244353 , n,  k;
ll fp(ll x , ll exp)
{
    if(exp == 0)
        return 1;
    if(exp % 2 == 0)
        return fp((x * x) % mod, exp / 2) % mod;
    return ((fp((x * x) % mod, exp / 2) % mod) * x) % mod;
}
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] = fp(fact[i], mod - 2);
    }
}
ll ncr(ll n, ll r)
{
    return ((fact[n] * inv[r]) % mod * inv[n - r]) % mod;
}

ll npr(ll n, ll r)
{
    return (fact[n] * inv[n - r]) % mod;
}
int main()
{
    VIC
    cin>>k>>n;
    calcFacAndInv(4000);
    for(ll i=2;i<=2*k;i++)
    {
        ll p=0, ans = ncr(n+k-1,k-1);
        for(int j=1;j<=i/2;j++)
            if(j <= k && i-j<=k)
                p++;
            for(int j=1;j<=p;j++)
            {
              //  cout<<j<<" "<<p<<endl;
              if(2*j>n)break;
                ll cur=ncr(p,j) * ncr(n-2*j+k-1,k-1);
                if(j%2==0)
                    ans+=cur;
                else
                    ans-=cur;
                ans=(ans+mod * mod)%mod;
            }
        cout<<ans<<"\n";
    }
    return 0;
}


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

int main() {
    int K,X;
    cin>>K>>X;
    for(int i=X-K+1;i<=(X+K-1);i++){
        if(i>=-1000000 && i<=1000000)
            cout<<i<<" ";
    }
	return 0;
}

Measured memory_bytes: 256
# A
N = int(input())
A = list(map(int, input().split()))

res = 1
status = 0
a = A[0]
for i in range(1, N):
    if A[i] > a:
        if status == 1:
            a = A[i]
        elif status == 0:
            a = A[i]
            status = 1
        elif status == -1:
            res += 1
            status = 0
            a = A[i]
    elif A[i] < a:
        if status == 1:
            res += 1
            status = 0
            a = A[i]
        elif status == 0:
            a = A[i]
            status = -1
        elif status == -1:
            a = A[i]
    else:
        pass
    
print(res)

Measured memory_bytes: 14436