akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstring>
#include <fstream>
#include <functional>
#include <iostream>
#include <iomanip>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

#define ll long long int
#define FOR(i, a, b) for (int i = (a); i <= (b); ++i)
#define REP(i, n) for (int i = 0; i < n; ++i)
#define FOREACH(x, a) for (auto &(x) : (a))
#define ALL(a) (a).begin(), (a).end()
#define OUT(x) out << (x) << endl;
#define M0(x) memset(x, 0, sizeof(x))
#define MINF(x) memset(x, 0x3f, sizeof(x))
#define MMINUS(a) memset(a, 0xff, sizeof(a))
#define ten(n) ((int)1e##n)

const int INF = 0x3f3f3f3f;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;
const double EPS = 1.0 / LINF;
const char ENDL = '\n'; // for JetBrains IDE only supports yen

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;
}

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

using namespace std;

//===================================== template =========================================================

int main() {
    cin.tie(nullptr); ios_base::sync_with_stdio(false);
    int X; cin >> X;
    if (X == 7 || X == 5 || X == 3) {
        cout << "YES" << endl;
    } else cout << "NO" << endl;
}

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

int main(){
	int n,v[22];
	scanf("%d",&n);
	for(int i = 0;i < n;++i)
		scanf("%d",&v[i]);
	int resp = 0;
	for(int i = 1;i < n-1;++i){
		if(v[i] > v[i-1]){
			if(v[i] < v[i+1])
				++resp;
		}else if(v[i] > v[i+1]){
			++resp;
		}
	}
	printf("%d\n",resp);
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<string.h>
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
char a[10005],b[10005];
int cmp(char x,char y){
	return y<x;
} 
int main(){
	for(int i=0;i<=10000;i++)a[i]=b[i]='1';
   scanf("%s",a+1);
  // scanf("%c",b[0]);
   scanf("%s",b+1);
   int lena,lenb,panda=0;
   lena=strlen(a+1);lenb=strlen(b+1);
   sort(a+1,a+lena+1);sort(b+1,b+lenb+1,cmp);
   for(int i=1;i<=max(lena,lenb);i++){
   	  if(a[i]<b[i]){
   	  	panda=1;
   	  	break;
	  }
	  else if(a[i]>b[i]){
	  	panda=2;
	  	break;
	  }
   }
   if(panda==1)printf("Yes");
   else printf("No"); 
}

Measured memory_bytes: 256
<?php
fscanf(STDIN, '%d', $n);
$h = explode(' ', trim(fgets(STDIN)));
$ans = 1;
$max = 0;
for($i = 1; $i < count($h); $i++) {
    for($j = 0; $j < $i; $j++) {
        $max = ($h[$j] > $max) ? $h[$j] : $max;
    }
    $cond = ($h[$i] > $max) ? $h[$i] : $max;
    if($h[$i] >= $cond) {
        $ans++;
    }
}
echo $ans, PHP_EOL;

Measured memory_bytes: 4984
#include<bits/stdc++.h>
#define cl const long long&
#define C(x,y) (fac[x]*invf[y]%mod*invf[x-y]%mod)
using namespace std;
const long long mod=998244353;
long long n,a,b,u,v,g,K,p1,p2,t,ans,fac[300010],invf[300010];
long long POW(long long x,long long y){
	long long tot=1;
	while(y)y&1?tot=tot*x%mod:0,x=x*x%mod,y>>=1;
	return tot;
}
long long gcd(cl x,cl y){
	return y?gcd(y,x%y):x;
}
long long exgcd(cl p,cl q,cl val,long long&x,long long&y){
	if(!q){
		if(val%p)exit((puts("0"),0));
		return x=val/p,y=0;
	}
	long long tx,ty;
	exgcd(q,p%q,val,tx,ty),x=ty,y=tx-(p/q)*ty;
}
int main(){
	fac[0]=1;
	for(int i=1;i<=300000;++i)fac[i]=fac[i-1]*i%mod;
	invf[300000]=POW(fac[300000],mod-2);
	for(int i=299999;i>=0;--i)invf[i]=invf[i+1]*(i+1)%mod;
	scanf("%lld%lld%lld%lld",&n,&a,&b,&K);
	exgcd(a,b,K,u,v),g=gcd(a,b),p1=b/g,p2=a/g,p1<0?p1=-p1,p2=-p2:0;
	t=(u<0?((-u+p1-1)/p1):t=-u/p1),u+=t*p1,v-=t*p2;
	while(u<=n){
		if(0<=v&&v<=n)ans=(ans+C(n,u)*C(n,v))%mod;
		u+=p1,v-=p2;
	}
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 4992
import java.util.*;

public class Main{
	public static void main(String[] args){
		
		int i = 1;
		Scanner s = new Scanner (System.in);
		
		while (true) {
			int x = s.nextInt();
			
			if (x == 0){
				break;
			}
			System.out.println("Case "+ i + ": " + x);
			i++;
		}
	}
}

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

const int inf = 1000000007;
const int MOD = 1000000007;
const long long INF = 1000000000000000007;

int N;
int d[100];

int main()
{
    cin >> N;
    rep(i, N)
    {
        cin >> d[i];
    }

    ll ans = 0;
    rep(i, N - 1)
    {
        for (int j = i + 1; j < N; j++)
        {
            ans += d[i] * d[j];
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
# include <iostream>
# include <cstdio>
# include <cstring>
# include <vector>
# define A first
# define B second
# define lson l, m, id<<1
# define rson m+1, r, id<<1|1
using namespace std;
const int maxn = 2e5+30;
const int oo = 0x3f3f3f3f;
int imin[maxn<<2], cost[maxn], dp[maxn];
void build(int l, int r, int id)
{
    if(l == r)
    {
        imin[id] = oo;
        return;
    }
    int m = l+r>>1;
    build(lson);
    build(rson);
    imin[id] = min(imin[id<<1], imin[id<<1|1]);
}

int query(int L, int R, int l, int r, int id)
{
    if(L<=l && r<=R) return imin[id];
    int m = l+r>>1, res = oo;
    if(L <= m) res = min(res, query(L, R, lson));
    if(R > m) res = min(res, query(L, R, rson));
    return res;
}

void update(int pos, int val, int l, int r, int id)
{
    if(l == r)
    {
        imin[id] = min(imin[id], val);
        return;
    }
    int m = l+r>>1;
    if(pos <= m) update(pos, val, lson);
    else update(pos, val, rson);
    imin[id] = min(imin[id<<1], imin[id<<1|1]);
}
vector<int>v[maxn];
int main()
{
    int n, q, cnt=0;
    scanf("%d",&n);
    build(1, n, 1);
    for(int i=1, j; i<=n; ++i)
    {
        scanf("%d",&j);
        cnt += !j;
        cost[i] = j?1:-1;
    }
    scanf("%d",&q);
    for(int i=0, j, k; i<q; ++i)
    {
        scanf("%d%d",&j,&k);
        v[j].push_back(k);
    }
    memset(dp, oo, sizeof(dp));
    dp[0] = 0;
    for(int i=1; i<=n; ++i)
    {
        for(auto j : v[i])
        {
            int mi = dp[i-1];
            mi = min(mi, query(max(i-1,1), j, 1, n, 1));
            if(mi < dp[j])//chose
            {
                dp[j] = mi;
                update(j, mi, 1, n, 1);
            }
        }
        dp[i] = min(dp[i], dp[i-1]+cost[i]); //not chose
    }
    printf("%d\n",dp[n]+cnt);
    return 0;
}


Measured memory_bytes: 12544
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int x, n, y;
	scanf("%d", &n);
	if(n>=1 && n<=100){
			x=800*n;
		if(n>15){
			y=((n/15)*200);
			printf("%d", x-y);
		}
		else{
			printf("%d", x);
		}
	}
	else{
		printf("Error");
	}
	return 0;
}

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

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

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
const int INF_N = 1e+9;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
//typedef vector<vector<ll>> mat;
typedef vector<int> vec;

//繰り返し二乗法
ll mod_pow(ll a, ll n, ll m) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * a%m;
		a = a * a%m; n >>= 1;
	}
	return res;
}

struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n%mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint &a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint &a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint &a, modint b) { a.n = ((ll)a.n*b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a*a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

//逆元(Eucledean algorithm)
ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }

const int max_n = 1 << 18;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}
using mP = pair<modint, modint>;

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




void solve() {
    int N, T; cin >> N >> T;
    int res = 1001;
    rep(i, N){
        int c, t; cin >> c >> t;
        if(t <= T) res = min(res, c);
    }

    if(res == 1001){
        cout << "TLE" << endl;
    }else{
        cout << res << endl;
    }
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  //cout << fixed << setprecision(10);
  //init_f();
  //init();
  //int t; cin >> t; rep(i, t)solve();
  solve();
//   stop
    return 0;
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define LL long long
using namespace std;
template <typename T> void read(T &x){
	x = 0; int f = 1; char ch = getchar();
	while (!isdigit(ch)) {if (ch == '-') f = -1; ch = getchar();}
	while (isdigit(ch)) {x = x * 10 + ch - '0'; ch = getchar();}
	x *= f;
}
inline void write(int x){if (x > 9) write(x/10); putchar(x%10+'0'); }

const int P = 998244353,N = 1000050;
int fac[N],inv[N],nfac[N];
inline int C(int n,int m){ return (n<0||m<0||n<m)?0:(LL)fac[n] * nfac[m] %P * nfac[n-m] %P; } 
int main(){
	int i;
	fac[0] = inv[0] = nfac[0] = fac[1] = inv[1] = nfac[1] = 1;
	for (i = 2; i <= 1000000; ++i){
		fac[i] = (LL)fac[i-1] * i % P;
		inv[i] = (LL)(P-P/i) * inv[P%i] % P;
		nfac[i] = (LL)nfac[i-1] * inv[i] % P;
	}
	int n,k,ans = 0; cin>>n>>k;
	for (int i = n; i <= k; ++i){
		ans = (ans + C(k-1,i-1)) % P;
	}
	cout << ans << '\n';
	return 0;
}

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

// {U}{INT,LONG,LLONG}_{MAX,MIN}
#define INF         INT_MAX/3
#define LLINF       LLONG_MAX/3
#define MOD         (998244353LL)
#define MODA(a, b)  a=((a)+(b))%MOD
#define MODP(a, b)  a=((a)*(b))%MOD
#define inc(i, l, r)   for(int i=(l);i<(r);i++)
#define dec(i, l, r)   for(int i=(r)-1;i>=(l);i--)
#define pb          push_back
#define se          second
#define fi          first
#define mset(a, b)  memset(a, b, sizeof(a))

using LL  = long long;
using G   = vector<vector<int>>;

int di[] = {0, -1, 0, 1};
int dj[] = {1, 0, -1, 0};
// }}}

#define SIZE 300010

// べき乗
// verified AOJ NTL_1_B
LL mpow(LL a, LL b) {
    if(b == 0LL) return 1LL;
    LL aa = mpow(a, b/2LL);
    return aa*aa%MOD*(b%2LL == 1LL ? a : 1LL)%MOD;
}

// 階乗と階乗の逆元
// ARC077D
LL fact[SIZE] = {1LL, 1LL};
LL finv[SIZE] = {1LL, 1LL};

void initFact() {
    // fact
    for(LL i=2LL;i<SIZE;i++){
        fact[i] = fact[i-1LL]*i%MOD;
    }

    // finv
    finv[SIZE-1] = mpow(fact[SIZE-1], MOD-2LL);
    for(LL i=SIZE-1;i>=3;i--){
        finv[i-1] = finv[i]*i%MOD;
    }
}

// 組み合わせの数
// ARC077D
LL comb(LL n, LL r) {
    if(r > n) return 0LL;
    return fact[n]*(finv[r]*finv[n-r]%MOD)%MOD;
}

int main() {
    cin.tie(0);ios::sync_with_stdio(false);
    LL n, a, b, K;
    cin >> n >> a >> b >> K;
    LL ans = 0;
    initFact();
    //if(a != b){
        for(LL i=0;i<=n;i++){
            if((K-a*i) < 0) continue;
            if((K-a*i)%b != 0) continue;
            LL j = (K-a*i)/b;
            //cout << i << " " << j << endl;

            if(i > n || j > n) continue;

            MODA(ans, comb(n, i)*comb(n, j)%MOD);

            //for(LL k=0;k<=n;k++){
                //if(i-k < 0 || j-k < 0) break;
                //if((i-k)+(j-k)+k>n) continue;
                //LL l = n-(i-k)-(j-k)-k;
                //LL tmp = fact[n]*(finv[i-k]*finv[j-k]%MOD*finv[k]%MOD*finv[l]%MOD)%MOD;
                //MODA(ans, tmp);
            //}
            //cout << ans << endl;
        }
    //}else{
        //for(LL k=0;k<=n;k++){
            //if((K-(a+b)*k) < 0) continue;
            //if((K-(a+b)*k)%a != 0) continue;
            //LL m = (K-(a+b)*k)/a;
            //if(k+m>n) continue;
            ////cout << k << " " << m << " " << finv[k] << " " << finv[m] << endl;
            //LL tmp = fact[n]*(finv[k]*finv[m]%MOD*finv[n-k-m]%MOD)%MOD*mpow(2LL, m)%MOD;
            //MODA(ans, tmp);
            ////cout << k << " " << m << " " << tmp << " " << ans << endl;
        //}
    //}

    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 4992
#include <bits/stdc++.h>
#define rep(i,n) for(long long i=0; i<n; i++)
#define Rep(i,n) for(long long i=1; i<n; i++)
#define ll long long
#include <math.h>


using namespace std;
#define PI acos(-1)

int main(){
	int K;
	cin >> K;
	string S;
	cin>>S;
	if(S.size()<=K){
	    cout<<S<<endl;
	    return 0;
	}else{
	    rep(i,K){
	        cout<<S[i];
	      if(i==K-1){
	        cout<<"..."<<endl;
	      }
     	}
	 }
	
}



Measured memory_bytes: 3608
s=input()
s_list=s.split('/') 
s1=list(map(int,s_list))
st=[2019,4,30]
if s1[0]<st[0]:
    print('Heisei')
elif s1[0]==st[0] and s1[1]<=st[1]:
    print('Heisei')
else:
    print('TBD')

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

//#pragma gcc optimize("O3,unroll-loop")
//#pragma gcc target("sse,sse2,sse3,ssse3,sse4,avx,avx2,fma,abm,mmx,popcnt,tune=native")
#define int long long
//#define double long double

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

    int n;
    cin >> n;

    vector<int> v(n);
    map<int, int> mp;
    for (int i = 0; i < n; i++)
        cin >> v[i], v[i] -= i, mp[v[i]]++;

    int ans = 0;
    for (int i = 0; i < n; i++)
        ans += mp[i * -2 - v[i]];
    cout << ans << '\n';

    return 0;
}

//      *   *  *****  *   *  *   *
//     *   *  *      **  *  *   *
//    *****  *****  * * *  *   *
//   *   *      *  *  **  *   *
//  *   *  *****  *   *   ***

//      ***** ***** *   * *     ***** *   * ***** *****
//        *  *   * *   * *       *   **  *   *   *   *
//       *  *   * ***** *       *   * * *   *   *****
//   *  *  *   *   *   *       *   *  **   *   *
//  ****  *****   *   ***** ***** *   *   *   *


Measured memory_bytes: 27392
type ABC(stream:System.IO.TextReader) =
  member this.Scan1 f = stream.ReadLine() |> f
  member this.Scan2 f = stream.ReadLine().Split() |> Array.map f |> (fun a -> (a.[0], a.[1]))
  member this.Scan3 f = stream.ReadLine().Split() |> Array.map f |> (fun a -> (a.[0], a.[1], a.[2]))
  member this.Scan4 f = stream.ReadLine().Split() |> Array.map f |> (fun a -> (a.[0], a.[1], a.[2], a.[3]))
  member this.ScanVecH f = stream.ReadLine().Split() |> Array.map f
  member this.ScanVecV n f = [| for i in 1..n -> stream.ReadLine() |> f |]
  member this.ScanMatrix n f  = [ for i in 1..n do yield stream.ReadLine().Split() |> Array.map f ]
  member this.ScanCharMatrix n = [ for i in 1..n -> stream.ReadLine().ToCharArray() ]
  member this.Close () = stream.Close()

let util = ABC(stdin)

let S = util.Scan1 id

let check s = 0 < (int s) && (int s) <= 12

match check S.[0..1], check S.[2..3] with
| true, true -> "AMBIGUOUS"
| true, false -> "MMYY"
| false, true -> "YYMM"
| false, false -> "NA"
|> printfn "%s"

util.Close()


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

#define LOCAL 0

#define lli long long int
#define llu unsigned long long int
#define ld long double
#define all(v) v.begin(),v.end()
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define si(n) scanf("%d",&n)
#define slli(n) scanf("%lld",&n);
#define ss(n) scanf("%s",n);

const long double EPS = 1e-10;
const int MOD = 1000000007ll;
const int mod1 = 1000000009ll;
const int mod2 = 1100000009ll;
int INF = (int)1e9;
lli INFINF = (lli)1e18;
int debug = 0;
long double PI = acos(-1.0);

using namespace std;

int bit_count(lli _x){lli _ret=0;while(_x){if(_x%2==1)_ret++;_x/=2;}return _ret;}
int bit(lli _mask,int _i){return (_mask&(1ll<<_i))==0?0:1;}
int add(int a,int b,int m=MOD){int x=a+b;while(x>=m)x-=m;while(x<0)x+=m;return x;}
int sub(int a,int b,int m=MOD){int x=a-b;while(x<0)x+=m;while(x>=m)x-=m;return x;}
int mul(int a,int b,int m=MOD){lli x=a*1ll*b;x%=m;while(x<0)x+=m;return (int)x;}
int ldtoint(ld x){return (int)(x+0.5);}lli ldtolli(ld x){return (lli)(x+0.5);}
int powermod(lli _a,lli _b,int _m=MOD){lli _r=1;while(_b){if(_b%2==1)_r=mul(_r,_a,_m);_b>>=1;_a=mul(_a,_a,_m);}return _r;}

template<class T1,class T2>ostream&operator<<(ostream& os,const pair<T1,T2>&p){os<<"["<<p.first<<","<<p.second<<"]";return os;}
template<class T>ostream&operator<<(ostream& os,const vector<T>&v){os << "[";bool first=true;for (T it:v){if (!first)os<<", ";first = false;os<<it;}os<<"]";return os;}
template<class T>ostream&operator<<(ostream& os,set<T>&v){os<<"[";bool first=true;for (T it:v){if(!first)os<<", ";first=false;os<<it;}os<<"]";return os;}
template<class T1,class T2>ostream&operator<<(ostream& os,map<T1,T2>&v){os<<"[";bool first=true;for(pair<T1,T2> it:v){if(!first)os<<", ";first=false;os<<"("<<it.F<<","<<it.S<<")";}os<<"]";return os;}
template<class T>void parr(T a[],int s,int e){cout<<"[";for(int i=s;i<e;i++)cout<<a[i]<<", ";cout<<a[e]<<"]\n";}

int N;
int A[100010];

int main()
{
if(LOCAL){
    freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    debug = 1;
}
    srand (time(NULL));
    //ios::sync_with_stdio(0);cin.tie(0);

    si(N);
    for(int i=1;i<=N;i++)si(A[i]);

    int ans = 0;
    for(int i=1;i<=N;i++){
        int j1,j2;
        for(j1=i+1;j1<=N;j1++){
            if(A[j1] < A[j1-1])
                break;
        }
        j1--;
        for(j2=i+1;j2<=N;j2++){
            if(A[j2] > A[j2-1])
                break;
        }
        j2--;
        //cout<<i<<" "<<j<<"\n";
        ans ++;
        i = max(j1,j2);
    }
    cout<<ans;

    return 0;
}


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

#ifdef _WIN32
#define scanfll(x) scanf("%I64d", x)
#define printfll(x) printf("%I64d", x)
#else
#define scanfll(x) scanf("%lld", x)
#define printfll(x) printf("%lld", x)
#endif
#define rep(i,n) for(long long i = 0; i < (long long)(n); i++)
#define repi(i,a,b) for(long long i = (long long)(a); i < (long long)(b); i++)
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define fi first
#define se second
#define mt make_tuple
#define mp make_pair
template<class T1, class T2> bool chmin(T1 &a, T2 b) { return b < a && (a = b, true); }
template<class T1, class T2> bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }

using ll = long long; using vll = vector<ll>; using vvll = vector<vll>;
using ld = long double;  using vld = vector<ld>; 
using vi = vector<int>; using vvi = vector<vi>;
vll conv(vi& v) { vll r(v.size()); rep(i, v.size()) r[i] = v[i]; return r; }
using P = pair<ll, ll>;

template <typename T, typename U> ostream &operator<<(ostream &o, const pair<T, U> &v) {  o << "(" << v.first << ", " << v.second << ")"; return o; }
template<size_t...> struct seq{}; template<size_t N, size_t... Is> struct gen_seq : gen_seq<N-1, N-1, Is...>{}; template<size_t... Is> struct gen_seq<0, Is...> : seq<Is...>{};
template<class Ch, class Tr, class Tuple, size_t... Is>
void print_tuple(basic_ostream<Ch,Tr>& os, Tuple const& t, seq<Is...>){ using s = int[]; (void)s{0, (void(os << (Is == 0? "" : ", ") << get<Is>(t)), 0)...}; }
template<class Ch, class Tr, class... Args> 
auto operator<<(basic_ostream<Ch, Tr>& os, tuple<Args...> const& t) -> basic_ostream<Ch, Tr>& { os << "("; print_tuple(os, t, gen_seq<sizeof...(Args)>()); return os << ")"; }
ostream &operator<<(ostream &o, const vvll &v) { rep(i, v.size()) { rep(j, v[i].size()) o << v[i][j] << " "; cout << endl; } return o; }
template <typename T> ostream &operator<<(ostream &o, const vector<T> &v) { o << '['; rep(i, v.size()) o << v[i] << (i != v.size()-1 ? ", " : ""); o << "]";  return o; }
template <typename T>  ostream &operator<<(ostream &o, const set<T> &m) { o << '['; for (auto it = m.begin(); it != m.end(); it++) o << *it << (next(it) != m.end() ? ", " : ""); o << "]";  return o; }
template <typename T, typename U>  ostream &operator<<(ostream &o, const map<T, U> &m) { o << '['; for (auto it = m.begin(); it != m.end(); it++) o << *it << (next(it) != m.end() ? ", " : ""); o << "]";  return o; }
template <typename T, typename U>  ostream &operator<<(ostream &o, const unordered_map<T, U> &m) { o << '['; for (auto it = m.begin(); it != m.end(); it++) o << *it; o << "]";  return o; }
string bits_to_string(ll mask, ll n) { string s; rep(i, n) s += '0' + !!(mask & (1ll << i)); return s; }
#define ldout fixed << setprecision(40) 

static const double EPS = 1e-14;
static const long long INF = 1e18;
static const long long mo = 1e9+7;

int main(void) {
    cin.tie(0); ios::sync_with_stdio(false);
    string s; cin >> s;
    cout << s.substr(0, 4) << " " << s.substr(4) << endl;
    return 0;
}


Measured memory_bytes: 256
s=raw_input()
cntg=0
cntp=0
ans=0
for i in xrange(len(s)):
    if cntg>cntp:
        if s[i]=="g":
            cntp+=1
            ans+=1
        else:
            cntp+=1
    else:
        if s[i]=="g":
            cntg+=1
        else:
            cntg+=1
            ans-=1
print(ans)


Measured memory_bytes: 2692
#include <algorithm>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <set>
#include <stdio.h>
#include <string>
#include <vector>

using namespace std;

struct N {
  int i;
  double t;
};

bool operator<(const N &lhs, const N &rhs) { return lhs.t < rhs.t; }

double dist(pair<double, double> l, pair<double, double> r) {
  return sqrt((l.first - r.first) * (l.first - r.first) +
              (l.second - r.second) * (l.second - r.second));
}

int main() {
  double sx, sy, ex, ey;
  int n;
  cin >> sx >> sy >> ex >> ey >> n;
  vector<pair<double, double>> ps(n + 2);
  vector<double> r(n + 2);
  for (int i = 0; i < n; i++)
    cin >> ps[i].first >> ps[i].second >> r[i];
  ps[n] = make_pair(sx, sy);
  ps[n + 1] = make_pair(ex, ey);
  multiset<N> q;
  q.insert({n, 0});
  vector<bool> c(n + 2);
  while (q.size() > 0) {
    N now = *q.begin();
    q.erase(q.begin());
    if (now.i == n + 1) {
      printf("%.9lf\n", now.t);
      return 0;
    }
    if (c[now.i])
      continue;
    c[now.i] = true;
    for (int i = 0; i < n + 2; i++) {
      if (c[i])
        continue;
      q.insert({i, now.t + max(0.0, dist(ps[now.i], ps[i]) - r[now.i] - r[i])});
    }
  }
  return 0;
}


Measured memory_bytes: 31232
#include <iostream>
#include <string>

using namespace std;

int main()
{
	string s;
	cin >> s;
	int res = 0;
	for (char c : s)
	{
		res += c - '0';
		res %= 9;
	}
	if (res == 0)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}

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

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

    vector<int> a(n);
    for(int i=0; i<n; i++){
        cin >> a[i];
    }

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

Measured memory_bytes: 2944
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <list>
#include <numeric>
#include <map>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
//================================================

int a = 0, b = 0, c, d, n, k=0;
string s, t;


int main()
{
	cin >> s;
	bool app[26];
	rep(i, 26)
		app[i] = false;
	for (int i = 0; i<s.size(); ++i)
		app[s[i] - 'a'] = true;

	rep(i,26)
	{if(!app[i])
	{
		printf("%c\n", (char)(i + 'a'));
		return 0;
	}
	}
	puts("None");
	return 0;
}

Measured memory_bytes: 512
from collections import defaultdict
import sys
sys.setrecursionlimit(10 ** 6)
N, M = [int(s) for s in input().split()]
edges = defaultdict(list)
for _ in range(M):
    A, B = [int(s) for s in input().split()]
    edges[A].append(B)
    edges[B].append(A)

def dfs(node):
    for nn in edges[node]:
        if nn not in seen:
            # print(seen)
            # print(unseen)
            seen.add(nn)
            unseen.remove(nn)
            dfs(nn)

maxsize = 0
unseen = set(range(1, N + 1))
seen = set()
while unseen:
    sf = len(unseen)
    node = unseen.pop()
    seen.add(node)
    dfs(node)
    maxsize = max(maxsize, sf - len(unseen))

print(maxsize)

Measured memory_bytes: 241368
#include <iostream>

using namespace std;
int main(){
	string a,b;
	cin >>a>>b;
	int flag = 0;
	for(int i = 0; i < a.size(); i++){
		if(a == b){
			flag = 1;
			break;
		}
		a = a.back() + a.substr(0, a.size()-1);
	}
	if(flag){
		cout<<"Yes\n";
	}
	else
		cout<<"No\n";
return 0;
} 

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;cin>>n;
  int a[110];
  for(int i=0;i<n;i++)cin>>a[i];
  sort(a,a+n,greater<int>());
  int Alice=0;
  int Bob=0;
  for(int i=0;i<n;i++){
    if(i%2==0)Alice+=a[i];
    else Bob+=a[i];
  }
  cout<<Alice-Bob<<endl;
}

Measured memory_bytes: 764
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	var s, t string
	if sc.Scan() {
		s = sc.Text()
	}

	if sc.Scan() {
		t = sc.Text()
	}

	ten := strings.Split(t, " ")
	a, _:= strconv.Atoi(s)
	ans := 0

	for i := 1; i <= a; i++{
		e, _ := strconv.Atoi(ten[i - 1])
		if e != i{
			ans++
		}
	}

	if ans <= 2{
		fmt.Println("YES")
	}else{
		fmt.Println("NO")
	}
}

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

const int maxn = 1e5 + 5;
const int mod = 1e9 + 7;
typedef pair<int, int> pi;
int n;
pi a[maxn];
typedef long long ll;

ll dp[2005][2005];

int main(){
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    cin >> n;
    for(int i = 1;i <= n;i++){
        cin >> a[i].first;
        a[i].second = i;
    }
    sort(a + 1, a + 1 + n);
    for(int i = n;i >= 1;i--){
        int len = n - i;
        int pos = a[i].second;
        for(int l = 0;l <= len;l++){
            int r = n + 1 - (len - l);
            dp[l + 1][r] = max(dp[l + 1][r], dp[l][r] + 1LL * abs(l + 1 - pos) * a[i].first);
            dp[l][r - 1] = max(dp[l][r - 1], dp[l][r] + 1LL * abs(r - 1 - pos) * a[i].first);
        }
    }
    long long ans = 0;
    for(int l = 0;l < n;l++){
        ans = max(ans, dp[l][l + 1]);
    }
    cout << ans << endl;
    return 0;
}


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

int main()
{
	int n, s = 0;

	cin >> n;
	
	int m = n;

	while (m > 0) {
		s += m % 10;
		m = m / 10;
	}

	if (n % s == 0)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <stack>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define PF push_front
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double
#define pii pair<int,int>
#define pll pair<LL,LL>
#define vi vector<int>
#define vii vector<vi>

const double pi = 3.14159265358979323846264;
const int mod=1000000007;

int main(){
	 //cin.tie(0);
	//ios::sync_with_stdio(false);
	//std::cout << std::fixed;
	//std::cout << std::setprecision(12);
	//std::cout << std::defaultfloat;
	int n;
	cin>>n;
	cout<<1.*((n+1)/2)/n<<endl;

	return 0;
}


Measured memory_bytes: 256
n = int(input())
h = list(map(int, input().split()))

cnt = 0
result = 0
for i in range(n-1):
    if h[i] - h[i+1] >= 0:
        cnt += 1
    else:
        result = max(cnt, result)
        cnt = 0

result = max(cnt, result)

print(result)

Measured memory_bytes: 14252
#include <stdio.h>
int max(int a,int b){
if(a>b)return a;
return b;
}
int main(){
int dp[10010],w,n,m,v;
scanf("%d%d",&n,&w);
for(int i=0;i<=w;i++)dp[i]=0;
for(int i=0;i<n;i++){
scanf("%d%d",&v,&m);
for(int j=m;j<=w;j++)dp[j]=max(dp[j],dp[j-m]+v);
}
printf("%d\n",dp[w]);
}

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

// 小数点以下桁数
// fixed << setprecision(i)

int64_t gcd(int64_t a,int64_t b){return (a%b==0?b:gcd(b, a%b));}
int64_t lcm(int a,int b){return (int64_t)a*b/gcd(a, b);}
int factorial(int a){int b=1;while(a){b*=a--;}return b;} //13以下対応
bool is_prime(int a){if(a<=1)return false;for(int i=2;(int64_t)i*i<=a;i++){if(a%i==0)return false;}return true;}
int get_adp(double x, int n){return (int)round((x-(int)x)*pow(10,n))%10;} // 小数点以下の指定桁の値を取得
int64_t sigma(int64_t s, int64_t n){return n*(2*s+n-1)/2;}

//順列の全列挙
// vector<int> v(N);
// iota(v.begin(), v.end(), 1);       // v に 1, 2, ... N を設定
// do {
//   for(auto x : v) cout << x << " "; cout << "\n";    // v の要素を表示
// } while( next_permutation(v.begin(), v.end()) ); 

//bit全探索
// for (int tmp = 0; tmp < (1 << ビット数); tmp++) {
//   bitset<ビット数> s(tmp);
//   // (ビット列sに対する処理)
// }

int main()
{
  int n, q, l, r;
  string s;

  cin >> n >> q >> s;
  vector<int> count_arr(n);
  vector<int> ans(q);

  count_arr[n - 1] = 0;
  for (int i = n - 2; 0 <= i; i--)
      count_arr[i] = count_arr[i + 1] + (s[i] == 'A' && s[i + 1] == 'C');
  for (int i = 0; i < q; i++)
  {
    cin >> l >> r;
    ans[i] = count_arr[l - 1] - count_arr[r - 1];
  }
  for (int i = 0; i < q; i++)
    cout << ans[i] << endl;
}


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

int main() {
    int N,p=0,w=0,g=0,y=0,a=0;
    cin >> N;
    for(int i = 0; i < N; i++){
        string s;
        cin >> s;
        if(s == "Y"){
            a = 1;
        }
    }
    if(a == 0){
        cout << "Three" << endl;
    }else{
        cout << "Four" << endl;
    }
}


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

using namespace std;

typedef long long ll;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);
    int h, n;
    cin >> h >> n;
    ll sum = 0;
    for (int i = 0; i < n; ++i) {
        int x;
        cin >> x;
        sum += x;
    }
    if (sum >= h) {
        cout << "Yes\n";
    } else {
        cout << "No\n";
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <iomanip>

using namespace std;

void std_dev(int n, vector<int> s) {
	double sum = 0, mean, std_d;
	for (auto x : s) {
		sum += x;
	}
	mean = sum / n;
	sum = 0;
	for (auto x : s) {
		sum += pow(mean - x, 2);
	}
	std_d = sqrt(sum / n);
	cout << fixed << setprecision(6);
	cout << std_d << endl;
}
int main() {
	while (1) {
		int n;
		cin >> n;
		if (n == 0) {
			break;
		}
		vector<int> s(n);
		for (int i = 0; i < n; i++) {
			int tmp;
			cin >> tmp;
			s[i] = tmp;
		}
		std_dev(n, s);
	}
	return 0;
}




Measured memory_bytes: 3264
#include <math.h>
#include <iostream>
#include <algorithm>

using namespace std;

int main()
{
int H,W;
cin >> H >> W;
while (H!=0&&W!=0)
{
for (int i=0;i<H;i++)
{
for (int j=0;j<W;j++)
{
if(i!=0&&i!=H-1&&j!=0&&j!=W-1)cout << ".";
else cout << "#";
}
cout << endl;
}
cout << endl;
cin >> H >> W;
}
}


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

using namespace std;

#ifdef LOCAL

#include "debug.hpp"

#else
#define debug(...) 630
#endif

const int mod = 1e9+7;

struct Mint {
  long long x; Mint() : x(0) {}
  Mint(long long _x) : x ((_x%mod + mod)%mod) {}
  Mint& fix() { x = (x%mod + mod)%mod; return *this; }
  Mint& operator += (const Mint& other) { if ((x += other.x) >= mod) { x-= mod; } return *this;}
  Mint& operator -= (const Mint& other) { if ((x += mod-other.x) >= mod) { x -= mod; } return *this; }
  Mint& operator *= (const Mint& other) { (x*=other.x)%=mod; return *this; }
  Mint operator + (const Mint& other) const { return Mint(*this) += other; }
  Mint operator - (const Mint& other) const { return Mint(*this) -= other; }
  Mint operator * (const Mint& other) const { return Mint(*this) *= other; }
  Mint operator - () const { return Mint(0) - *this; }
  Mint operator ++ (int) { Mint result(*this); *this += 1; return result; }
  Mint operator -- (int) { Mint result(*this); *this -= 1; return result; }
  bool operator < (const Mint& other) const { return x < other.x; }
  bool operator == (const Mint& other) const { return x == other.x;}
};
ostream& operator << (ostream& out, const Mint& val) { return out << val.x; }
istream& operator >> (istream& in, Mint& val ) { in >> val.x; return in;}


const int N = 1e5+1;
Mint dp[N][2];
vector<vector<int>> adj(N);
bool vis[N];

void dfs (int v) {
	vis[v] = true;
	dp[v][1] = dp[v][0] = 1;
	for (auto u : adj[v]) {
		if (vis[u]) continue;
		dfs(u);
		dp[v][0] *= dp[u][0] + dp[u][1];
		dp[v][1] *= dp[u][0];
	} 
}
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin >> n;
	for (int i = 0; i < n - 1; i++) {
		int u, v;
		cin >> u >> v;
		u--; v--;
		adj[u].push_back(v);
		adj[v].push_back(u);
	} 
	dfs(0);
	cout << dp[0][1] + dp[0][0] << '\n';
	return 0;
}	



Measured memory_bytes: 11520
N = int(input())
A = list(map(int, input().split()))
A.insert(0, 0)
A.append(0)
S = sum([abs(A[i] - A[i+1]) for i in range(0, N+1)])
for i in range(1, N+1):
    ans = S + abs(A[i-1] - A[i+1]) - (abs(A[i-1] - A[i]) + abs(A[i] - A[i+1]))
    print(ans)

Measured memory_bytes: 65132
#include<bits/stdc++.h>
using namespace std;
typedef  long long int ll;
typedef pair<ll, ll> pll;
#define pb push_back
typedef long double ld;
#define fi first
#define se second
#define PI 3.14159265358979323846264338327950288419716939937510
#define mp make_pair
ll inf = 1e18;
ll p = 1e9 + 7;
ll power(ll x, ll y, ll p)
{
    ll res = 1;
    x = x % p;
    while (y > 0)
    {
        if (y & 1)
            res = (res * x) % p;
        y = y >> 1;
        x = (x * x) % p;
    }
    return res;
}
ll pwr(ll x, ll y)
{
    ll res = 1;
    x = x ;
    while (y > 0)
    {
        if (y & 1)
            res = (res * x) ;
        y = y >> 1;
        x = (x * x) ;
    }
    return res;
}
ll modInverse(ll n, ll p)
{
    return power(n, p - 2, p);
}
int main()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll i, j, y, x,  z, w, g, key,  k, n, m, a, b;
    ll t2, t3, t4, t1, t5, t6;
    string s, t;

    cin >> s >> t;
    n = s.length();
    m = t.length();
    ll ans = inf;
    for (i = 0; i <= (n - m); i++)
    {
        t1 = 0;
        for (j = 0; j < m; j++)
        {
            if (t[j] != s[i + j])
                t1++;
        }
        ans = std::min(ans, t1);
    }
    cout << ans;

    return 0;
}

Measured memory_bytes: 3656
#include<stdio.h>
int n,a[100]={99999999},b[100],i,r=0;
int main(){
    scanf("%d",&n);
    for(i=0;i<n-1;i++){
        scanf("%d",&b[i]);
        a[i]=a[i]<b[i]?a[i]:b[i];
        a[i+1]=b[i];
    }
    for(i=0;i<n;)r+=a[i++];
    printf("%d",r);
    return 0;
}

Measured memory_bytes: 128
#include <iomanip>
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <algorithm>
#include <bitset>
#include <queue>
#include <deque>
#include <stack>
#include <unordered_map>
#include <cmath>

using namespace std;

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

typedef long long ll;
typedef unsigned int uint;
typedef long double ld;

const int INT_INF=1e9;
const ll LONG_INF=1e18;
const double pi = acos(-1);
const int MAXN = 1e6;
const int MAXM = 1e6;

void solve() {
    ll d, t, s;
    cin >> d >> t >> s;
    if (d <= t * s) {
        cout << "Yes\n";
    } else {
        cout << "No\n";
    }
}

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    cout << fixed << setprecision(9);
#ifdef LOCAL
    freopen("input.in", "r", stdin);
    //freopen("output.out", "w", stdout);
#endif
    solve();

#ifdef LOCAL
    cout << "Time:\n";
    cout << static_cast<double>(clock()) / CLOCKS_PER_SEC << '\n';
#endif

}


Measured memory_bytes: 3648
import fractions
a, b, c, d = map(int, input().split())
lcm = c // fractions.gcd(c,d)*d
ans = (b-a+1) - ((b//c)-((a-1)//c)) - ((b//d)-((a-1)//d)) + ((b//lcm)-((a-1)//lcm)) 
print(ans)


Measured memory_bytes: 5048
package main

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

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)

	n := scanInt(sc)
	t := float64(scanInt(sc))
	a := float64(scanInt(sc))

	idx := -1
	diff := math.MaxFloat64
	for i := 0; i < n; i++ {
		h := scanInt(sc)
		b := t - float64(h)*0.006
		if math.Abs(a-b) < diff {
			idx = i
			diff = math.Abs(a - b)
		}
	}

	fmt.Println(idx + 1)
}

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


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    ll n,k;
    cin>>n>>k;
    ll m=ll(sqrt(n));
    vector<pair<ll,ll> > v;
    for(ll i=1;i<=m;i++){
    	ll num=n/i;
    	v.push_back({i,num});
    	if(num!=i)v.push_back({num,i});
    }
    v.push_back({0,mod});
    sort(be(v));



    map<ll,ll> mp,mp2;
    ll niko=v.size();
    vector<ll> mp1(niko+1);
    vector<vector<ll> > dp(k,vector<ll> (niko,0LL));
    for(int i=1;i<niko;i++){
    	dp[0][i]=v[i].first;
    	mp[v[i].first]=i;
    	mp2[i]=v[i].first-v[i-1].first;
    }
    for(int i=1;i<niko;i++){
    	mp1[mp[v[i].first]]=mp[v[i].second];
    	mp1[mp[v[i].second]]=mp[v[i].first];
    }
    for(int i=1;i<k;i++){
    	for(int j=1;j<niko;j++){
    		dp[i][j]=dp[i-1][mp1[j]];
    		(dp[i][j]*=mp2[j])%=mod;
    	}
    	for(int j=1;j<niko;j++){
    		(dp[i][j]+=dp[i][j-1])%=mod;
    	}
    }
    cout << dp[k-1][niko-1] << endl;
    return 0;
}


Measured memory_bytes: 59124
#include <iostream>
#include <vector>
#define m 1000000007LL
using namespace std;
typedef long long ll;
int n;
string x[1001];
vector <int> G[1001];
ll SUM,*R;

void saiki2(int ima,ll sum){
  for(int i=ima-1;i>=0;i--) saiki2(i,sum*R[i]);
  SUM+=sum;
}

ll saiki(int ima){
  ll S=G[ima].size(),res=1,r[11];
  char C=x[ima][0];
  for(int i=0;i<S;i++)r[i]=saiki(G[ima][i]);
  
  if(C=='E')
    for(int i=0;i<S;i++) res*=r[i];
  
  if(C=='A'){
    res=0;
    for(int i=0;i<S;i++) res+=r[i];
  }
  if(C=='R'){
    SUM=0,R=r;
    saiki2(S,1);
    res=SUM-1;
  }
  return (res+x[ima].size()-1)%m;
}

int main(){
  cin >>n;
  for(int i=1;i<=n;i++)cin>>x[i];
  for(int i=1;i<n;i++){
    int a,b;
    cin >>a>>b;
    G[a].push_back(b);
  }
  cout <<saiki(1)<<endl;
  return 0;
}

Measured memory_bytes: 1444
m, d = map(int, input().split())
count = 0
for i in range(m):
    for j in range(d):
        day = j + 1
        if day <= 21:
            continue
        lst = []
        while day > 0:
            lst.append(day%10)
            day //= 10
        lst.reverse()
        if (lst[0] < 2) or (lst[1] < 2):
            continue
        if lst[0] * lst[1] == i + 1:
            count += 1
print(count)

Measured memory_bytes: 3064
#include <iostream>
#include <vector>

using namespace std;

int main(){
    int n, m;
    cin >> n >> m;
    vector<vector<int>> edge(n);
    for(int i = 0; i < m; i++){
        int a, b;
        cin >> a >> b;
        edge[a - 1].push_back(b - 1);
        edge[b - 1].push_back(a - 1);
    }
    for(auto&& i : edge[0]){
        for(auto&& j : edge[i]){
            if(j == n - 1){
                cout << "POSSIBLE\n";
                return 0;
            }
        }
    }
    cout << "IMPOSSIBLE\n";
}

Measured memory_bytes: 12016
from sys import stdin

def main():
    from collections import deque
    import copy
    input = stdin.readline

    h, w = map(int, input().split())
    cm = [[0] * (w + 2) for _ in range(h + 2)]
    que = deque([])
    a = deque([])
    for i in range(1, h + 1):
        s = input()
        for j in range(1, w + 2):
            if s[j - 1] == ".":
                cm[i][j] = -1
                a.append([i, j])
    ans = 0
    for y, x in a:
        dm = copy.deepcopy(cm)
        que.append([y, x, 0])
        dm[y][x] = 0
        while len(que) > 0:
            y, x, r = que.popleft()
            if ans < r + 1:
                ans = r + 1
            if dm[y + 1][x] == -1:
                dm[y + 1][x] = r + 1
                que.append([y + 1, x, r + 1])
            if dm[y - 1][x] == -1:
                dm[y - 1][x] = r + 1
                que.append([y - 1, x, r + 1])
            if dm[y][x + 1] == -1:
                dm[y][x + 1] = r + 1
                que.append([y, x + 1, r + 1])
            if dm[y][x - 1] == -1:
                dm[y][x - 1] = r + 1
                que.append([y, x - 1, r + 1])
    print(ans - 1)
main()

Measured memory_bytes: 3444
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}
ll gcd(ll a, ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a, ll b){return a/gcd(a,b)*b;}



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

  string S; cin >> S;

  ll ans = 0;
  rep(i,S.size()){
    if(i == 0) continue;
    if(S[i] != S[i-1]) ans ++;
  }
  cout << ans << endl;
  
  //cout << fixed << setprecision(16) << ans << endl;
  return 0;
}


Measured memory_bytes: 512
def main(): 
  N, M = list(map(int, input().split()))
  Data = []
  for i in range(M):
    Data.append(list(map(lambda x: int(x) - 1, input().split())))
  Data.sort()
  
  S = [i for i in range(N)]
  Lo = {}
  G = [0 for i in range(N)]
  for i in Data:
    Lo.setdefault(i[0], []).append(i[1])
    G[i[1]] += 1
    S[i[1]] = -1

  S = list(set(S))
  S.sort()
  S.remove(-1)
  
  L = []  
  while S != []:
    t = S.pop(-1)
    L.append(t)
    if t in Lo:
      for i in Lo[t]:
        G[i] -= 1
        if G[i] == 0:
          S.append(i)

  DP = [0 for i in range(N)]
  
  for i in range(N):
    t = L[i]
    if t in Lo:
      for j in Lo[t]:
        DP[j] = max(DP[j], DP[t] + 1)
        
  print(max(DP))
main()


Measured memory_bytes: 90200
s = gets.chomp.split('').map(&:to_i)
s.reverse!

ans = 0
['+', '-'].repeated_permutation(s.size - 1) do |a|
  count = 0 # 10の何乗をかけるか
  s.each_with_index do |t, index|
    ans += t * (10 ** count)
    break if index == s.size - 1
    if a[index] == '+'
      count += 1
    else
      count = 0
    end
  end
end
p ans


Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define MOD 1000000007  
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;   
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
//find_by_order(k) - k is the kth element of the multiset
//order_of_key(k) - Number of elements striclty samller than k
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll a,b;
    cin>>a>>b;
    if(a==b)
    {
        cout<<((a%2019)*(a%2019))%2019;
        return 0;
    }
    ll x,y;
    if((b-a)>=2019)
    {
        cout<<"0"<<endl;
        return 0;   
    }
    x=a%2019;
    y=b%2019;
    ll ans=1e18;
    if(x>y)
    {
        cout<<"0"<<endl;
        return 0;
    }
    for(int i=x;i<=y-1;i++)
    {
        for(int j=i+1;j<=y;j++)
        {
            ans=min(ans,(i*j)%(ll)2019);
            if(ans==0)
            {
                //cout<<i<<endl;
                break;
            }
        }
        if(ans==0)
            break;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define repr(i, a, b) for(ll i = (a); i < (b); i++)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((ll)(x).size())
const ll MOD = 1000000007;
const ll INF = 100000000000000000LL;
inline ll GCD(ll a, ll b){ return b?GCD(b, a % b):a; }
inline ll LCM(ll a, ll b){ return a/GCD(a, b)*b; }
inline ll powint(ll x, ll y){ ll r=1; while(y){ if(y&1) r*=x; x*=x; y>>=1; } return r; }
inline ll powmod(ll x, ll y, ll m = MOD){ ll r=1; while(y){ if(y&1) r*=x; x*=x; r%=m; x%=m; y>>=1; } return r; }
template<class T>bool chmax(T &a, const T &b){ if(a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b){ if(b<a) { a=b; return 1; } return 0; }
#ifdef OJ_LOCAL
#include "dump.hpp"
#else
#define dump(...) ((void)0)
#endif

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    ll r;
    cin >> r;
    cout << 3*r*r << endl;
    return 0;
}

Measured memory_bytes: 892
/**
*   Bismillahir Rahmanir Rahim.
*   Imtiaz_rafi
*   PCIU, CHITTAGONG
**/
#include<bits/stdc++.h>
using namespace std;
#define speed() ios::sync_with_stdio(0);cin.tie(0);
#define file() freopen ("input.txt", "r", stdin);freopen ("output.txt", "w", stdout);
#define rep(i,a) for(ll i=0;i<a;i++)
#define rep1(i,begin,end) for(ll i=begin;i<=end;i++)
#define trace(x) cerr << #x << " = " << x << endl
#define mem(dp,i) memset(dp,i,sizeof(dp))
#define all(v)   v.begin(),v.end()
#define rall(v)   v.rbegin(),v.rend()
#define sl(a)   scanf("%lld",&a)
#define pb push_back
#define pf push_front
#define mp make_pair
#define F first
#define S second
#define pi acos(-1)
#define en '\n'
// bitshift (1LL<<(3)) *2^3
typedef long long int ll;
typedef vector<ll>vi;
typedef map<ll,ll>mi;
typedef pair<ll,ll>pll;
typedef vector<pll> vll;
typedef set<ll>st;
typedef set<char>sc;
ll dx[] = {-1,+1,0,0,+1,-1,+1,-1};
ll dy[] = {0,0,-1,+1,+1,+1,-1,-1};
const ll mx = 1e6+123;
const ll MOD = 1e9+7;
const ll INF = LLONG_MAX;

template <class T> T power(T a,T b){a%=MOD;if(!a) return 0;T p=1;while(b>0){if(b&1){p*=a;p%=MOD;}a*=a;a%=MOD;b=b>>1;}return p;}
template <class T> void print(vector<T> &v){for(T u:v){cout<<u<<" ";}cout<<endl;}
template <class T> T gcd(T a, T b){return (b!=0?gcd<T>(b,a%b):a);}
template <class T> T lcm(T a, T b){return (a/gcd<T>(a,b)*b);}

int main()
{
    speed();
    ll a,i,x,j,k,ans=0;
    cin>>a;
    for(i=1;i<a;i++)
    {
        ans+=((a-1)/i);
        /*for(j=1;j<a;j++)
        {
            for(k=1;k<a;k++)
            {
                if(i*j+k==a)
                {
                    cout<<i<<" "<<j<<" "<<k<<endl;
                    ans++;
                }
            }
        }*/
    }
    cout<<ans<<endl;




return 0;
}


Measured memory_bytes: 3648