akhauriyash/Code-Regression huggingface dataset:
#include <iostream>

template <typename T>
struct Vector
{
    T x , y;

    auto operator - (Vector v) -> Vector
    {
        return Vector <T> {x - v.x , y - v.y};
    }
    auto cross (Vector v) -> T
    {
        return x * v.y - y * v.x;
    }
};

auto main () -> int
{
    Vector <double> vecA , vecB , vecC , vecP;
    while (std::cin >> vecA.x >> vecA.y >> vecB.x >> vecB.y >> vecC.x >> vecC.y >> vecP.x >> vecP.y)
    {
        auto vecAB = vecB - vecA;
        auto vecBC = vecC - vecB;
        auto vecCA = vecA - vecC;

        auto vecAP = vecP - vecA;
        auto vecBP = vecP - vecB;
        auto vecCP = vecP - vecC;

        auto c1 = vecAB.cross (vecAP);
        auto c2 = vecBC.cross (vecBP);
        auto c3 = vecCA.cross (vecCP);

        if (c1 < 0 && c2 < 0 && c3 < 0 || c1 > 0 && c2 > 0 && c3 > 0)
        {
            std::cout << "YES" << std::endl;
        }
        else
        {
            std::cout << "NO" << std::endl;
        }
    }
}

Measured memory_bytes: 3148
import sys
fin = sys.stdin.readline
from math import ceil

N, K = [int(elem) for elem in fin().split()]
A_list = [int(elem) for elem in fin().split()]

pos_1 = A_list.index(1)
# num_left = pos_1
# num_right = N - pos_1 - 1

min_operations = float('inf')
for offset in range(K):
    left_edge = pos_1 - offset
    right_edge = pos_1 + K - 1 - offset
    if left_edge >= 0 and right_edge >= 0:
        min_operations = min(min_operations, \
            ceil(left_edge / (K - 1)) + ceil((N - right_edge - 1) / (K - 1)) + 1)

print(min_operations)


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

int main()
{
    unsigned long long int n,a,b,ans;
    cin>>n>>a>>b;
    ans=(n/(a+b))*a;
    n=n%(a+b);
    if(n<=a)
        ans+=n;
    else
        ans+=a;

    cout<<ans;
}



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

#define ed cout << "\n";
#define speed                         \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define ll long long
#define ffor(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(i, n) ffor(i, 0, n)
#define All(obj) (obj).begin(), (obj).end()
#define INF ((ll)1e9 + 7)
#define c(a) cout << a << "\n";
using namespace std;
const int N = 100005;

int main()
{
    speed;
    cout << fixed << setprecision(6);
    /*start*/
    string s;
    cin >> s;
    string f = s.substr(0, (s.size() - 1) / 2);
    string b = s.substr((s.size()) / 2 + 1, s.size());
    if(f==b){
        c("Yes");
    }else{
        c("No");
    }
}


Measured memory_bytes: 3664
#include <bits/stdc++.h>
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout << #x << " = " << (x) << endl
#define show2(x,y) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << endl
#define show3(x,y,z) cout << #x << " = " << (x) << ", " << #y << " = " << (y) <<  ", " << #z << " = " << (z) << endl
#define showv(v) rep(i,v.size()) printf("%d%c", v[i], i==v.size()-1?'\n':' ')
#define showv2(v) rep(j,v.size()) showv(v[j])
#define showt(t,n) rep(i,n) printf("%d%c", t[i], i==n-1?'\n':' ')
#define showt2(t,r,c) rep(j,r) showt(t[j],c)
#define showvp(p) rep(i,p.size()) printf("%d %d\n", p[i].first, p[i].second);
#define printv(v) rep(i,v.size()) printf("%d\n", v[i])
#define printt(t,n) rep(i,n) printf("%d\n", t[i])
#define incl(v,x) find(rng(v),x)!=v.end()
#define incls(s,c) s.find(c)!=string::npos
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define bit(n,k) ((n>>k)&1) // nのk bit目
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vs = vector<string>;
using P = pair<int, int>;
using T = tuple<int, int, int>;
using vp = vector<P>;
using vt = vector<T>;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = (1<<30)-1;
//const ll INF = (1LL<<62)-1;
#define dame { puts("No"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
//inline int in() { int x; scanf("%d",&x); return x;}
template<class T = int> inline T in() { T x; cin >> x; return (x);}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int a[3][3];

int main () {
  rep(i,3)rep(j,3) cin >> a[i][j];
  int n;
  cin >> n;
  rep(bi,n) {
    int b;
    cin >> b;
    rep(i,3)rep(j,3) {
      if (a[i][j] == b) a[i][j] = -1;
    }
  }

  bool ok = false;
  rep(i,3) {
    bool f = true;
    rep(j,3) if (a[i][j] != -1) f = false;
    if (f) ok = true;
  }
  rep(j,3) {
    bool f = true;
    rep(i,3) if (a[i][j] != -1) f = false;
    if (f) ok = true;
  }
  bool f = true;
  rep(i,3) if (a[i][i] != -1) f = false;
  if (f) ok = true;
  f = true;
  rep(i,3) if (a[i][2-i] != -1) f = false;
  if (f) ok = true;
  
  if (ok) yn;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#define large 1050
// #define large 100
#define mod 1000000007

int main()
{
    int h,w;
    char a[large][large];

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

    int dp[large][large]={};
    for(int i=0;i<h;i++)
    {
        for(int j=0;j<w;j++)
        {
            if(i==0&&j==0) 
            {
                dp[i][j]+=1;
                continue;
            }
            if(a[i][j]=='#') continue;
            if(i!=0)
            {
                dp[i][j]+=dp[i-1][j];
                dp[i][j]%=mod;
            }
            if(j!=0)
            {
                dp[i][j]+=dp[i][j-1];
                dp[i][j]%=mod;
            }
        }
    }
    // for(int i=0;i<h;i++)
    // {
    //     for(int j=0;j<w;j++)
    //     {
    //         printf("%d ",dp[i][j]);
    //     }
    //     printf("\n");
    // }
    printf("%d\n",dp[h-1][w-1]);
}

Measured memory_bytes: 5504
#include <bits/stdc++.h>
#define rep(i,a,b) for(ll i=ll(a);i<ll(b);i++)
#define rep2(i,a,b) for(ll i=ll(a);i<ll(b);i+=2)
#define irep(i,a,b) for(ll i=ll(a);i>=ll(b);i--)
using ll = long long;
using namespace std;

int main(){
	ll n;
    cin>>n;
    ll v[n];
    ll x=100010;
    rep(i,0,n)cin>>v[i];
    ll ans1[x]={-1};
    ll ans2[x]={-1};
    ll a1=-1,a2=-1,a3=-1,a4=-1;
    ll s1=-1,s2=-1;
    rep2(i,0,n-1) ans1[v[i]]++;
    rep2(j,1,n) ans2[v[j]]++;
    rep(i,0,x){
        if(a1<=ans1[i]){a2=a1;a1=ans1[i];s1=i;}
        else if(a2<ans1[i])a2=ans1[i];
        }
    rep(j,0,x){
        if(a3<=ans2[j]){a4=a3;a3=ans2[j];s2=j;}
        else if(a4<ans2[j])a4=ans2[j];
        }
    if(s1!=s2)cout<<n-a1-a3;
    else cout<<n-max((a1+a4),(a2+a3))<<endl;
}

Measured memory_bytes: 2560
#include<stdio.h>

typedef long long ll;
ll md = 1000000007;

int main(){
  int N,A[100000];
  int i,j;
  ll x[3],tx;
  ll ans;
  scanf("%d",&N);
  for(i=0;i<N;i++){
    scanf("%d",A+i);
  }
  x[0] = x[1] = x[2] = 0;
  ans = 1;
  for(i=0;i<N;i++){
    tx = 0;
    for(j=0;j<3;j++){
      if(x[j] == A[i]){
        tx++;
      }
    }
    ans = (ans * tx) % md;
    for(j=0;j<3;j++){
      if(x[j] == A[i]){
        x[j]++;
        break;
      }
    }
  }
  printf("%lld",ans);
}

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

int main(int argc, char **argv)
{
	vector <ll> arr(3);
  for(ll i=0;i<3;i++) cin>>arr[i];
  ll count_5=0;
  ll count_7=0;
  for(ll i=0;i<3;i++){
    if (arr[i]==5) count_5++;
    if (arr[i]==7) count_7++;
  }
  if (count_5==2&&count_7==1) cout<<"YES"<<"\n";
  else cout<<"NO"<<"\n";
	return 0;
}


Measured memory_bytes: 3604
#include <stdio.h>
int main(void)
{
    int M, D, ans = 0;
    scanf("%d %d", &M, &D);
    for (int m = 1; m <= M; m++) {
        for (int d = 0; d <= D; d++) {
            if ((d / 10) * (d % 10) == m) {
                    ans++;
                    if (d / 10 < 2 || d % 10 < 2) {
                        ans--;
                    }
            }
        }
    }
    printf("%d", ans);
    return 0;
}

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

#define int long long

signed main(){
	int n;
	cin >> n;
	int x[1000];
	for(int i = 0;i < n;i++) cin >> x[i];

	int ans = LLONG_MAX;
	for(int i = -100;i <= 200;i++){
		int sum = 0;
		for(int j = 0;j < n;j++){
			sum += (x[j]-i) * (x[j]-i);
		}
		ans = min(ans, sum);
	}

	cout << ans << endl;

	return 0;
}


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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

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

using ll=long long;
using R=long double;
const R EPS=1e-9; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max<R>(x,0.0));}

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

// Problem Specific Parameter:

int main(void){
	int n,a,b;
	cin >> n >> a >> b;
	string s;
	cin >> s;
	
	int ca=0,cb=0;
	rep(i,n){
		bool ok=false;
		if(s[i]=='a' and ca+cb+1<=a+b) ok=true,ca++;
		if(s[i]=='b' and ca+cb+1<=a+b and cb+1<=b) ok=true,cb++;
		puts((ok?"Yes":"No"));
	}

	return 0;
}

Measured memory_bytes: 896
#include <functional>
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cassert>
#include <sstream>
#include <numeric>
#include <string>
#include <vector>
#include <cstdio>
#include <bitset>
#include <cmath>
#include <ctime>
#include <queue>
#include <stack>
#include <map>
#include <set>

using namespace std;

#define forit(it, s) for(__typeof(s.begin()) it = s.begin(); it != s.end(); it++)
#define np(v) next_permutation(v.begin(), v.end())
#define pll pair < long long, long long>
#define all(a) a.begin(), a.end()
#define ull unsigned long long
#define pii pair < int, int >
#define sz(a) (int)a.size()
#define sqr(x) ((x) * (x))
#define y1 stupid_cmath
#define vi vector <int>
#define pb push_back
#define mp make_pair
#define ll long long
#define f first
#define s second

const int inf = (int)3e6;
const int mod = inf + 7;
const double eps = 1e-9;
const double pi = acos(-1.0);

int n, a, b;

int get(int val){
    int cur = 0;
    while(val != 0){
        cur += val % 10;
        val /= 10;
    }
    return cur;
}

int main(){
    ios_base::sync_with_stdio(0), cin.tie(0);
    cin >> n >> a >> b;
    ll ans = 0;
    for(int i = 1; i <= n; ++i){
        int cur = get(i);
        if(a <= cur && cur <= b){
            ans += i;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
#include<string.h>
#include<string>
#include<math.h>
#include<stdlib.h>
#include<time.h>
#include<map>
#include<queue>
#include<set>
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,a,b) for(int i=a;i>=b;i--)
using namespace std;
char s1[5],s2[5];
int main(){
	scanf("%s%s",s1,s2);
	fo(i,0,2) if (s1[i]!=s2[2-i]){
		printf("NO\n");
		return 0;
	}
	printf("YES\n");
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
const int INF=1145141919,MOD=1e9+7;
const int64_t LINF=8931145141919364364,LMOD=998244353;
// const int dy[]={0,-1,0,1,1,-1,-1,1};
// const int dx[]={1,0,-1,0,1,1,-1,-1};

int main() {
	int n; cin >> n;
	vector<int> l(n); rep(i,n) cin>>l[i];
	sort(all(l));
	int ans = 0;
	for(int i = 0; i < n; ++i) {
		for(int j = i + 1; j < n; ++j) {
			int k = lower_bound(all(l), l[i] + l[j]) - l.begin();
			ans += (k - j - 1);
			// cerr << k << " " << (k - j - 1) << endl;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <functional>
#include <cmath>
#define SIZE 305

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

ll MOD;
ll C[SIZE][SIZE];
ll dp[SIZE][SIZE];
ll rdp[SIZE];//dp の sum
ll dp2[SIZE][SIZE];

void make()
{
	for(int i=0;i<SIZE;i++)
	{
		C[i][i]=C[i][0]=1;
		for(int j=1;j<i;j++)
		{
			C[i][j]=C[i-1][j-1]+C[i-1][j];
			if(C[i][j]>=MOD) C[i][j]-=MOD;
		}
	}
}
int main()
{
	int N,K;
	scanf("%d %d %lld",&N,&K,&MOD);
	make();
	for(int i=K;i>=1;i--)
	{
		for(int j=0;j<N;j++)
		{
			if(j==0) dp[i][j]=1;
			else
			{
				if(i==K) dp[i][j]=0;
				else
				{
					dp[i][j]=0;
					for(int l=0;l<j;l++)
					{
						// i の直接左に l 個置く
						dp[i][j]+=dp[i][l]*rdp[j-l-1]%MOD*C[j-1][l]%MOD;
						if(dp[i][j]>=MOD) dp[i][j]-=MOD;
					}
				}
			}
		}
		for(int j=0;j<N;j++)
		{
			rdp[j]+=dp[i][j];
			if(rdp[j]>=MOD) rdp[j]-=MOD;
		}
	}
	dp2[0][0]=1;
	for(int i=0;i<N;i++)
	{
		ll sum=0;
		for(int j=i;j>=0;j--)
		{
			sum+=dp2[i][j];
			if(sum>=MOD) sum-=MOD;
			for(int k=1;i+k<=N;k++)
			{
				dp2[i+k][j+k-1]+=sum*rdp[k-1]%MOD*C[j+k-1][k-1]%MOD;
				if(dp2[i+k][j+k-1]>=MOD) dp2[i+k][j+k-1]-=MOD;
			}
		}
	}
	ll ret=0;
	for(int i=0;i<=N;i++)
	{
		ret+=dp2[N][i];
		if(ret>=MOD) ret-=MOD;
	}
	printf("%lld\n",ret);
	return 0;
}


Measured memory_bytes: 2304
#include <stdio.h>

int main(void)
{
	int a[10]={0};
	int n,i,j,k,l,x;
	
	for(j=0;j<20;j++)
	{
		//printf("?????°???");
		for(l=0;l<10;l++)
		a[l]=0;
		scanf("%d",&n);
		if(n==0)
		break;
		
		else
		{
			for(i=0;i<n;i++)
			{
				scanf("%d",&x);
				a[x]=a[x]+1;
			}
		}
	for(k=0;k<10;k++)
	{
		if(a[k])
		{
			for(l=0;l<a[k];l++)
			{
				printf("*");
			}
			printf("\n");
		}
		else printf("-\n");
	}
	}
	return 0;
}

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

int descending_compare(const void *a, const void *b){
    if (*(int*)a > *(int*)b){
        return -1;
    }else if (*(int*)a == *(int*)b){
        return 0;
    }else{
        return 1;
    }
}

int ascending_compare(const void *a, const void *b){
    if (*(int*)a < *(int*)b){
        return -1;
    }else if (*(int*)a == *(int*)b){
        return 0;
    }else{
        return 1;
    }
}


int lower_bound(int *a, int n, int key){
    int left, mid, right;
    left = 0, right = n;
    mid = (left + right)/2;
    while ((left+1 != mid || mid+1 != right) && mid != left){
        if (key > a[mid]){
            left = mid;
        }else{
            right = mid+1;
        }
        mid = (left + right)/2;
    }
    if (a[left] >= key)return left;
    if (a[mid] >= key)return mid;
    if (a[right] >= key)return right;
    return n;
}

//greatest common divisor
unsigned long  gcd(unsigned long x, unsigned long y){
    if (y == 0){ 
        return x;
    }else if (x > y){
        return gcd(y, x % y);
    }else{
        return gcd(x, y % x);
    }
}



long long factorial(int x){
    long long rtn = 1;
    int i;
    for (i = x; i > 1; i--){
        rtn = (rtn*i);
    }
    return rtn;
}
int soinsu[1001] = {0};

int main(void){
    int n;
    int tmp;
    int mod = 1000000007;
    long long ans = 1;
    scanf("%d", &n);
    for (int i = 2; i <= n; i++){
        tmp = i;
        for (int j = 2; j <= tmp; j++){
            while (tmp % j == 0){
                soinsu[j]++;
                tmp /= j;
            }
        }
    }

    for (int i = 2; i <= n; i++){
        ans *= (long long)soinsu[i]+1;
        ans %= mod;
    }

    printf("%lld\n", ans);



    return 0;
}


Measured memory_bytes: 128
import java.util.*;

public class Main {
    public static void main(String[] args) {
        int N;
        int K;
        int MOD_VAL = 1_000_000_007;

        try (Scanner sc = new Scanner(System.in)) {
            N = sc.nextInt();
            K = sc.nextInt();
        }
        long[] mae = new long[N+1];
        long[] ushi = new long[N+1];

        mae[0] = 0;
        for (int i = 1; i < N+1; i++) {
            mae[i] = (mae[i -1]% MOD_VAL + i% MOD_VAL) % MOD_VAL;
        }

        ushi[N] = N;
        for (int i = N-1; i >= 0; i--) {
            ushi[i] = (ushi[i+1]% MOD_VAL + i% MOD_VAL) % MOD_VAL;

        }
        //System.out.println(Arrays.toString(mae));
        //System.out.println(Arrays.toString(ushi));
        long result = 0;
        for (int i = K; i <= N + 1; i++) {
            long temp = ushi[(N+1) -i]% MOD_VAL - (long)(mae[i -1]% MOD_VAL -1);
            if(temp < 0){
                temp = (MOD_VAL + temp) % MOD_VAL;
            }
            temp = temp% MOD_VAL;
            //System.out.println(temp);
            result += temp;
            result = result % MOD_VAL;
        }
        System.out.println(result);
    }

}


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

int v,e;
int memo[16][100000];
vector<vector<pair<int,int> > > graph;

int dp(int n,int c,int bit){

  if(bit == (pow(2,v)-1)){
    for(int i = 0;i < graph[n].size();i++){
      if(graph[n][i].first == 0){
        return graph[n][i].second;
      }
    }
    return 1000000;
  }

  if(memo[n][bit] != 0){
    return memo[n][bit];
  }

  int a = 1000000;

  for(int i = 0;i < graph[n].size();i++){
    if((bit & (1 << graph[n][i].first)) == 0){
      a = min(a,dp(graph[n][i].first,c+1,bit | (1 << graph[n][i].first))+graph[n][i].second);
    }
  }

  return memo[n][bit] = a;
}



int main(){
  cin >> v >> e;
  graph.resize(v);
  for(int i = 0;i < e;i++){
    int s,t,d;
    cin >> s >> t >> d;
    pair<int,int> p = make_pair(t,d);
    graph[s].push_back(p);
  }

  int ans = dp(0,0,1);

  if(ans >= 20000){
    cout << -1 << endl;
  }else{
    cout << ans << endl;
  }

  return 0;
}



Measured memory_bytes: 4856
let () =
  let n = read_int () in
  let a = Array.make_matrix n n 0 in
  let rec read i =
    if i < n then begin
      let (id, k) = Scanf.scanf "%d %d " (fun id k -> (id, k)) in
      let rec g j =
        if j < k then (a.(id-1).(Scanf.scanf "%d " (fun i -> i) - 1) <- 1; g (j + 1))
      in g 0;
      read (i + 1)
    end in
  read 0;
  let rec print = function
    | (i, _) when i = n -> ()
    | (i, j) when j = n -> print_newline (); print (i + 1, 0)
    | (i, j) ->
      Printf.printf (if j = 0 then "%d" else " %d") a.(i).(j);
      print (i, j + 1)
  in print (0, 0)

Measured memory_bytes: 4304
import numpy as np

a=int(raw_input())

com = raw_input()

#print a
coma = list(com)

num =[]
s=0
num.append(0)
for i in coma:
    if i == "I":
        s=s+1
        num.append(s)
    else:
        s=s-1
        num.append(s)

#print num
#print s
print max(num)


Measured memory_bytes: 13336
def warshall_floyd(dist_matrix)
	dist = dist_matrix
	n = dist.size
	raise "dist_matrix is not square" if dist.any?{|row| row.size != n}

	(0..n-1).each{|k|
		next_dist = (1..n).map{ Array.new(n) }	
		(0..n-1).each{|i|
			(0..n-1).each{|j|
				x = dist[i][j]
				y = dist[i][k] + dist[k][j]
				next_dist[i][j] = (x < y ? x : y)
			}
		}
		dist = next_dist
	}
	dist
end

loop {
	n, m = gets.split.map &:to_i
	break if n == 0

	land_dist = (1..n).map { [Float::INFINITY] * n }
	sea_dist = (1..n).map { [Float::INFINITY] * n }
	(0..n-1).each{|i| land_dist[i][i] = sea_dist[i][i] = 0}

	m.times {
		i, j, d, t = gets.chomp.split
		i = i.to_i-1
		j = j.to_i-1
		d = d.to_i
		if t == ?L
			land_dist[i][j] = d
			land_dist[j][i] = d
		else
			sea_dist[i][j] = d
			sea_dist[j][i] = d
		end
	}
	land_dist = warshall_floyd(land_dist)
	sea_dist = warshall_floyd(sea_dist).map{|a| a.map.with_index{|x, i| [i, x] }.sort_by(&:last)}

	gets
	reqs = gets.split.map(&:to_i).map{|x| x - 1}
	table = (0..1).map{ [Float::INFINITY] * n }
	table[0][reqs[0]] = 0
	(1..reqs.size-1).each{|i|
		(0..n-1).each{|next_boat_pos|
			min = table[0][next_boat_pos] + land_dist[reqs[i-1]][reqs[i]]
			base = land_dist[next_boat_pos][reqs[i]]
			sea_dist[next_boat_pos].each{|prev_boat_pos, x|
				break if x + base >= min
				d = table[0][prev_boat_pos] + 
				    land_dist[reqs[i-1]][prev_boat_pos] + 
				    x + base
				min = d if d < min
			}
			table[1][next_boat_pos] = min
		}
		table << table.shift
	}
	p table[0].min
}

Measured memory_bytes: 72940
def solve(N,d):
  if N % 2 == 1:
    return 0
  else:
    arc = d[N//2:]
    abc = d[:N//2]
    return arc[0] - abc[-1]

N = int(input())
d = list(sorted(map(int,input().split())))

print(solve(N,d))

Measured memory_bytes: 14396
s = input()
t = input()

dp = [[0]*(len(s)+1) for _ in range(len(t)+1)]

for i in range(len(t)):
  for j in range(len(s)):
    if t[i] == s[j]:
      dp[i+1][j+1] = dp[i][j] + 1
    else:
      dp[i+1][j+1] = max(dp[i+1][j], dp[i][j+1])

i = len(t)
j = len(s)
ans = ''
while i >= 0 and j >= 0:
  if dp[i][j] == dp[i-1][j]:
    i -= 1
  elif dp[i][j] == dp[i][j-1]:
    j -= 1
  else:
    i -= 1
    j -= 1
    ans = ans + t[i]
print(ans[::-1])

Measured memory_bytes: 112444
import Data.List

main = do
    n <- readLn :: IO Int
    let ns = [1 .. n]
    let maxPow = maximum $ filter (\x -> elem x ns) $ map (2 ^) [0 .. floor $ logBase 2.0 (fromIntegral n :: Float)]
    let (Just i) = elemIndex maxPow ns
    print $ ns !! i

Measured memory_bytes: 508
def d_even_relation(N, Nodes):
    from collections import deque
    graph = [{} for _ in range(N)]
    for u, v, w in Nodes:
        graph[u - 1][v - 1] = w
        graph[v - 1][u - 1] = w

    ans = [0] * N
    queue = deque([(-1, -1, 0)])
    while queue:
        previous, parent, child = queue.pop()
        if parent == -1:
            ans[child] = 0
        elif previous != child:
            length = graph[parent][child]
            if length % 2 == 0:
                ans[child] = ans[parent]
            else:
                ans[child] = 1 if ans[parent] == 0 else 0
        for k in graph[child].keys():
            if parent != k:
                queue.appendleft((parent, child, k))
    return '\n'.join(map(str, ans))

N = int(input())
Nodes = [[int(i) for i in input().split()] for j in range(N - 1)]
print(d_even_relation(N, Nodes))

Measured memory_bytes: 69420
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); i++)
typedef long long int ll;
typedef pair<int, int> P;
const ll MOD = 1e9+7, INF = 1e9;

int main()
{
  int n, a = 0, b = 0, c = 0;
  cin >> n;
  rep(i, n){
    ll t;
    cin >> t;
    if(t % 2 != 0) a++;
    else{
      if(t % 4 != 0) b++;
      else c++;
    }
  }
  if(b == 0){
    if(a <= c+1){
      cout << "Yes" << endl;
    }
    else{
      cout << "No" << endl;
    }
  }
  else{
    if(a <= c){
      cout << "Yes" << endl;
    }
    else cout << "No" << endl;
  }
  system("pause");
}


Measured memory_bytes: 504
#include <bits/stdc++.h>
#ifdef HIRO
#define d(f_, ...) printf((f_), ##__VA_ARGS__)
#else
#define d(f_, ...)
#endif

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector< pair<int, int> > vii;
typedef vector< pair<long long, long long> > vllll;
typedef map<int, int> mii;
typedef map<long long, long long> mllll;
typedef queue<int> qi;
typedef queue< pair<int, int> > qp;
#define mp make_pair
#define pi 3.14159265358979323846
#define MAX max_element
#define MIN min_element
#define all(v) v.begin(), v.end()
#define gt(T) greater<T>()
#define sum(v) accumulate(v.begin(), v.end(), 0ll)
#define uni(v) do{ \
  sort(v.begin(), v.end()); \
  decltype(v)::iterator result = unique(v.begin(), v.end()); \
  v.erase(result, v.end()); \
}while(0)
#define fi(init, n) for(int i = init; i < n; ++i)
#define fj(init, n) for(int j = init; j < n; ++j)
#define fk(init, n) for(int k = init; k < n; ++k)
#define zero(x) memset(x, 0, sizeof(x))
#define negative(x) memset(x, ~0, sizeof(x))
#define bitsum(x) __builtin_popcount(x)
const ll MOD = 1e9 + 7;
const int INF = 1e9;
const int di[] = { 0, 1, 0, -1 };
const int dj[] = { 1, 0, -1, 0 };

template<typename T>
T gcd(T a, T b) {
	return b ? gcd(b, a % b) : a;
}
template<typename T>
T lcm(T a, T b) {
	return a / gcd(a, b) * b;
}
template<typename T>
int finder(vector<T> vec, T number) {
	auto itr = find(vec.begin(), vec.end(), number);
	size_t index = distance(vec.begin(), itr);
	if (index != vec.size()) return 1;
	else return 0;
}
ll frac(ll n){
	if (n == 0) return 1;
	return (n * frac(n - 1)) % MOD;
}
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 main(int argc, char** argv) {
#ifdef HIRO
  string quiz(argv[1]);
  string id(argv[2]);
  string filename("input/" + quiz + "/" + id + ".txt");
  ifstream fin(filename);
  if (fin.peek() == ifstream::traits_type::eof()) {
    cout << "No input.";
    return 0;
  }
  ifstream cin(filename);
  std::cin.rdbuf(cin.rdbuf());
#endif
  string ans;
  ll n;
  cin >> n;
  // ll n, m;
  // cin >> n >> m;
  // ll n, m, k;
  // cin >> n >> m >> k;
  int min[26];
  fi(0, 26)
    min[i] = INF;
  fi(0, n) {
    int cnt[26] = { 0 };
    string s;
    cin >> s;
    for(char c: s) {
      cnt[c - 'a']++;
    }
    fj(0, 26) {
      chmin(min[j], cnt[j]);
    }
  }
  fi(0, 26) {
    string s(min[i], (char)(i + 'a'));
    // cout << min[i] << "," << (char)(i + 'a') << endl;
    ans += s;
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 256
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		double A = sc.nextDouble();
		double B = sc.nextDouble();
		double C = sc.nextDouble();
		double D = sc.nextDouble();
		System.out.println(Math.ceil(A/D)>=Math.ceil(C/B)?"Yes":"No");
	}

}


Measured memory_bytes: 37396
void main() {
    int n = readln.chomp.to!int;
    int[] d = new int[n];
    foreach (i; 0 .. n) {
        d[i] = readln.chomp.to!int;
    }
    writeln(d.sort!"a < b".uniq.array.length);
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.container;
import std.typecons;
import std.ascii;
import std.uni;

Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#pragma GCC optimize("Ofast")
//*********************************************DO IT NOW****************************************************************
#include<bits/stdc++.h> 
#include<random>
#define int long long   
#define pp pair<int,int> 
#define ss second 
#define ff first 
#define pb push_back
#define mod 1000000007
#define pi 3.14159265359
#define mk(arr,n,type)  type *arr=new type[n];
#define sl s1.length();
#define yes cout<< "YES"<<endl
#define no  cout<< "NO"<<endl
#define all(v) (v).begin(),(v).end()
#define s(v)   sort(v,v+n)
#define  mt mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define read(a,n) for(int i=0;i<n;i++)cin>>a[i]
#define print(a,n) for(int i=0;i<n;i++)cout<<a[i]<<" "
using namespace std;
//**********************************************DO IT NOW***************************************************************
void fastio()
{  
  #ifndef ONLINE_JUDGE
  freopen("INPUT.txt","r",stdin);
  freopen("OUTPUT.txt","w",stdout); 
  #endif
  ios_base :: sync_with_stdio(false); 
  cin.tie(NULL) ; 
  cout.tie(NULL);
}
int dp[101][1001],ans1=1e9,dp1[1000001];
int num[10];
int a[1000000];
signed main()
{   
    fastio();
    int t=1;
   // cin>>t;
    while(t--)
    {
        int n,m,sum=0;
        cin>>n>>m;
        for(int i=n-1;i>=1;i--)
        sum+=i;
        for(int i=m-1;i>=1;i--)
        sum+=i;
        cout<<sum;
    }
}
// 🍪 🍪 🍪


Measured memory_bytes: 3560
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define f(i, x, n) for (int i = x; i < (int)(n); ++i)
const int N = 1e7, M = 7 + 1e9;
int n, t;
ll dp[21][2097152];// (1 << 21)-1 the maximum number for the mask
vector<int> v[21];
map<int, bool> sorryIhaveaboyfriend;
ll cal(int i, int taken){
	if( i == n )
		return 1;
	ll &ret = dp[i][taken];
	if(~ret)
		return ret;
	ret = 0;
	f(j, 0, v[i].size()){
		if( !sorryIhaveaboyfriend[v[i][j]] ){
			sorryIhaveaboyfriend[v[i][j]] = 1;
			ret += cal(i+1, taken | (1<<v[i][j]));
			ret %= M;
			sorryIhaveaboyfriend[v[i][j]] = 0;
		}
	}
	return ret;
}
int main()
{
	memset(dp, -1, sizeof dp);
	cin >> n;
	f(i, 0, n){
		f(j, 0, n){
			cin >> t;
			if(t)
				v[i].push_back(j);
		}
	}
	cout << cal(0, 0);
}

Measured memory_bytes: 344448
#include <stdio.h>

int main(){
	int a,b,c;
	scanf("%d %d %d",&a,&b,&c);
	
	int count=0;
	if( a==b ) count++;
	if( b==c ) count++;
	if( c==a ) count++;
	
	if( count==1 ) printf("Yes");
	else printf("No");
	
	return 0;
}

Measured memory_bytes: 128
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
s = 0
for i in range(n):   
    if i > 0 and a[i] - a[i-1] ==  1:
        s = s + b[a[i]-1] +c[a[i-1]-1]
    else:  
        s = s + b[a[i]-1] 
print(s)


Measured memory_bytes: 3064
/*
Author : Xinyuan
*/
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < n; i++)
#define all(x) (x).begin(), (x).end()
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<PII> VII;
typedef vector<VI> VVI;
typedef long long int ll;
const int INF = 1e9 + 7;
const int mod = 1e9 + 7;
ll powmod(ll a, ll b) {
    ll res = 1;
    a %= mod;
    assert(b >= 0);
    for (; b; b >>= 1) {
        if (b & 1) res = res * a % mod;
        a = a * a % mod;
    }
    return res;
}
int nxt() {
    int x;
    scanf("%d", &x);
    return x;
}

const int nax = 2e5 + 5;
int fac[nax], inv_fac[nax];

int mul(int a, int b) {
    return (ll)a * b % mod;
}

int my_inv(int a) {
    return powmod(a, mod - 2);
}

int binomial(int a, int b) {
    if (a < 0 || b < 0 || b > a) return 0;
    return mul(fac[a], mul(inv_fac[b], inv_fac[a - b]));
}

int f(int a, int b) {
    return binomial(a + b, b);
}

int sub(int a, int b) {
    return (a - b + mod) % mod;
}

int main() {
    fac[0] = inv_fac[0] = 1;
    for (int i = 1; i < nax; i++) {
        fac[i] = mul(fac[i - 1], i);
        inv_fac[i] = my_inv(fac[i]);
    }
    int h = nxt(), w = nxt(), n = nxt();
    VII in(n);
    REP(i, n) {
        cin >> in[i].first >> in[i].second;
    }
    sort(all(in));
    in.emplace_back(h, w);
    vector<int> dp(n + 1);
    for (int i = 0; i <= n; i++) {
        int tmp = f(in[i].first - 1, in[i].second - 1);
        for (int j = 0; j < i; j++) {
            if (in[j].first <= in[i].first && in[j].second <= in[i].second) {
                tmp = sub(tmp, mul(dp[j], f(in[i].first - in[j].first, in[i].second - in[j].second)));
            }
        }
        // printf("%d %d\n", i, tmp);
        dp[i] = tmp;
    }
    printf("%d\n", dp[n]);
    return 0;
}


Measured memory_bytes: 5396
N = int(input())
B = list(map(int, input().split()))
A = []
i = len(B) - 1
flag = True

while B != []:
    if i < 0:
        flag = False
        break

    if i + 1 == B[i]:
        A.append(B.pop(i))
        i = len(B) - 1
    else:
        i -= 1


if flag:
    print(*A[::-1], sep="\n")
else:
    print(-1)

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

int main(){
    int A,B,K; cin>>A>>B>>K;

    for(int i=A;i<=min(B,A+K-1);i++) cout<<i<<endl;
    for(int i=max(B-K+1,A+K);i<=B;i++) cout<<i<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <climits>
#include <set>
#include <algorithm>
#include <unordered_map>
#include <queue>
#include <iomanip>
#include <map>
#include <utility>
#include <numeric>
#include <chrono>
#include <ctime>
#include <bitset>
#include <iterator>

#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define P pair<long long, long long>
#define debug(x) cerr << #x << ": " << x << ", "
#define debugln(x) cerr << #x << ": " << x << '\n'

using namespace std;
using ll = long long;
const ll mod = 1e9 + 7;

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

  int n; cin >> n;
  vector<ll> a(n);
  rep(i, n) {
    cin >> a[i];
  }

  if (n==1) {
    cout << a[0] << endl;
    return 0;
  }

  ll dp[n+1][n+1];
  for(int i=1; i<n; i++) {
    dp[i][i+1] = abs(a[i] - a[i-1]);
    //cerr << i << ' ' << i+1 << ' ' << dp[i][i+1] << endl;
  }

  for(int i=2; i<n; i++) {
    for(int j=1; j+i<=n; j++) {
      if (i%2 == 0) {
        dp[j][j+i] = min(-a[j-1] + dp[j+1][j+i], dp[j][j+i-1] - a[j+i-1]);
      } else {
        dp[j][j+i] = max(a[j-1] + dp[j+1][j+i], dp[j][j+i-1] + a[j+i-1]);
      }
      //cerr << j << ' ' << j+i << ' ' << dp[j][j+i] << endl;
    }
  }

  ll ans;
  if (n%2 == 0) {
    ans = dp[1][n];
  } else {
    ans = -dp[1][n];
  }

  cout << ans << endl;
}

Measured memory_bytes: 70528
#include <bits/stdc++.h>
#include <stdlib.h>
#include <time.h> 
 
using namespace std;
long long mod = 1e9 + 7;
long long INF = 1e7;
double EPS = 1e-12;
typedef long long int lld;
long double tick(){static clock_t oldt; clock_t newt=clock();
    long double diff=1.0L*(newt-oldt)/CLOCKS_PER_SEC; oldt = newt; return diff; }
#define rep(i,a,n) for(long long int i = (a); i <= (n); ++i)
#define repI(i,a,n) for(int i = (a); i <= (n); ++i)
#define repD(i,a,n) for(long long int i = (a); i >= (n); --i)
#define repDI(i,a,n) for(int i = (a); i >= (n); --i)
inline lld sc() { lld a; scanf("%lld", &a); return a; }
inline int scd() { int a; scanf("%d", &a); return a; }
inline double scf() { double a; scanf("%lf",&a); return a; }
#define prL(a) printf("%lld\n",a)
#define prS(a) printf("%lld ",a)
#define prdL(a) printf("%d\n",a)
#define prdS(a) printf("%d ",a)
#define all(c) (c).begin(), (c).end()
#define sz(a) ((int)a.size())
#define Error(x...) { cout << "(" << #x << ")" << " = ( "; printIt(x); }
template <typename T1> void printIt(T1 t1) { cout << t1 << " )" << endl; }
template <typename T1, typename... T2>
void printIt(T1 t1, T2... t2) { cout << t1 << " , "; printIt(t2...); }
#define errorpair(a) cout<<#a<<" = ( "<<((a).first)<<" , "<<((a).second)<<" )\n";
#define mset(a, v) memset(a, v, sizeof(a))
#define popcount __builtin_popcountll

typedef pair<lld,lld> PA;

lld powP(lld x, lld y) {
    lld ans = 1, po = x % mod;
    while(y > 0) {
        if(y & 1) ans = ans * po % mod;
        y >>= 1; po = po * po % mod;
    }
    return ans;
}
 
bool bitSet(lld n, lld bit){
    if((n & (1LL << bit)) != 0) return true;
    else return false;
}
 
lld findGcd(lld a, lld b){
    while(a != 0) { lld temp = b % a; b = a; a = temp; }
    return b;
}

#define lim 300010
#define lim2 200010
#define qqqqqq 210
// Ab :)
// inline lld sqr(lld x) { return x * x; }
// unordered_map<lld,lld>::iterator it;
// std::ios::sync_with_stdio(false);
// priority_queue<PA> Q;
// lld dp[1<<18];

// vector<lld> G[lim];
// string S[lim];
lld A[lim], C[lim];

int main(){
    lld n = sc(), k = sc();
    rep(i,1,n) A[i] = sc();
    lld turn = 1, vertex = 1;
    while(k--) {
        if(C[vertex] != 0) {
            lld loopSize = turn - C[vertex];
            vertex = A[vertex];
            k = k % loopSize;
            while(k--) {
                vertex = A[vertex];
            }
            prL(vertex);
            return 0;
        }
        // Error(turn, vertex);
        C[vertex] = turn;
        vertex = A[vertex];
        turn++;
    }
    prL(vertex);
    return 0;
}


Measured memory_bytes: 6864
//Moh_K_Imar .......
//22/08/2020  ... 12,42 .
//Ya Rab....
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
int main(){
    ll a,b;
    cin>>a>>b;
    if(a>=10)cout<<b<<endl;
    else if(a<10){
        cout<<b+(100*(10-a));
    }


    return 0;
}



Measured memory_bytes: 3564
#include<stdio.h>
#include<string.h>
#include<math.h>
#define N 100001
int min(int x , int y)
{
	return (x < y) ? x : y;
}
int main()
{
	int dp[N];
	int h[N];
	int n;
	while (scanf("%d", &n) != EOF)
	{
		for (int i = 1; i <= n; i++)
			scanf("%d", &h[i]);
		memset(dp, 0, sizeof(dp));
		dp[2] = fabs(h[2] - h[1]);
		for (int i = 3; i <= n; i++)
			dp[i] = min(dp[i - 2] + fabs(h[i] - h[i - 2]), dp[i - 1] + fabs(h[i] - h[i - 1]));
		printf("%d\n", dp[n]);
	}
	return 0;
}

Measured memory_bytes: 896
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <deque>
#include <numeric>
#include <cmath>
#include <map>
#include <set>
#define ull unsigned long long
#define ll long long
using namespace std;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> a_1;
    int a;
    for(int i=0;i<n;i++){
        cin >> a;
        a_1.emplace_back(a);
    }

    deque<int> ans;
    for(int i=0;i<n;i++){
        if(i%2!=n%2){
            ans.emplace_front(a_1[i]);
        }
        else {
            ans.emplace_back(a_1[i]);
        }
    }

    for(int i=0;i<n;i++){
        if(i==n-1){
            cout << ans[i] << endl;
        }
        else cout << ans[i] << " ";
    }


    return 0;
}

Measured memory_bytes: 3956
#include <iostream>
#include <climits>
#include <algorithm>
#define rep(i, n) for (int i = 0; (i) < (int)(n); i++)
using namespace std;
int main() {
	int X, Y, Z;
	cin >> X >> Y >> Z;
	cout << Z << " " << X << " " << Y << endl;
	return 0;
}


Measured memory_bytes: 256
/* ***********************************************
Author        :devil
Created Time  :2016/6/23 15:27:25
************************************************ */
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <stdlib.h>
using namespace std;
typedef long long LL;
const int N  = 5e5+5;
const LL mod = 1e9+7;
int a[105],n;
int main(){
  scanf("%d",&n);
  n<<=1;
  for(int i=1;i<=n;++i)scanf("%d",&a[i]);
  sort(a+1,a+1+n);
  int ret=0;
  for(int i=1;i<=n;i+=2)ret+=a[i];
  printf("%d\n",ret);
  return 0;
}

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

int main()
{
    int n,m;
    cin >> n >> m;
    int min_close=n,max_open=0;
    for(int i = 0 ; i < m ; i++)
    {
        int a,b;
        cin >> a >> b;
        min_close=min(min_close,b);
        max_open=max(max_open,a);
    }
    if(min_close<max_open)
        cout << 0 << endl;
    else
        cout << min_close-max_open+1 << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
	int m,n,i;
	while(1){
		scanf("%d %d",&m,&n);
		if(m==0)break;
		for(i=1;i<=m-1;i++){
			if(i==2)n+=29;
			else if(i==4||i==6||i==9||i==11)n+=30;
			else n+=31;}
		if((n-1)%7==0)printf("Thursday\n");
		if((n-1)%7==1)printf("Friday\n");
		if((n-1)%7==2)printf("Saturday\n");
		if((n-1)%7==3)printf("Sunday\n");
		if((n-1)%7==4)printf("Monday\n");
		if((n-1)%7==5)printf("Tuesday\n");
		if((n-1)%7==6)printf("Wednesday\n");}	
	return 0;
}

Measured memory_bytes: 0
// -*- coding:utf-8-unix -*-

use proconio::input;
use proconio::marker::Chars;

fn main() {
    input! {
        h: usize,
        w: usize,
        a: [Chars; h],
    }

    let mut head = std::u32::MAX;
    let mut tail = 0;
    let mut dot_after_sharp = false;
    for i in 0..w {
        if a[0][i] == '#' {
            if dot_after_sharp {
                // like "##.#"
                println!("Impossible");
                return;
            }

            head = head.min(i as u32);
            tail = tail.max(i as u32);
        } else {
            if head != std::u32::MAX {
                dot_after_sharp = true;
            }
        }
    }

    for i in 1..h {
        let mut current_head = std::u32::MAX;
        let mut current_tail = 0;
        dot_after_sharp = false;
        for j in 0..w {
            if a[i][j] == '#' {
                if (j as u32) < tail || dot_after_sharp {
                    println!("Impossible");
                    return;
                }

                current_head = current_head.min(j as u32);
                current_tail = current_tail.max(j as u32);
            } else {
                if current_head != std::u32::MAX {
                    dot_after_sharp = true;
                }
            }
        }
        tail = current_tail;
    }
    println!("Possible");
}


Measured memory_bytes: 2136
#include<bits/stdc++.h>
using namespace std;
typedef long long int llint;
typedef long int lint;
typedef vector<int> vint;
typedef vector<vector<int>> vvint;
int main(){
  int n;
  lint i,j,m,Q;
  cin>>n>>m>>Q;
  vint l(m);vint r(m);vint p(Q);vint q(Q);
  vvint mapp(n,vint(n,0));
  for(i=0;i<m;i++){
    cin>>l[i]>>r[i];
    l[i]--;r[i]--;mapp[l[i]][r[i]]++;
  }
  for(i=0;i<Q;i++){
    cin>>p[i]>>q[i];
    p[i]--;q[i]--;
  }
  for(i=0;i<n;i++){
    for(j=i-1;j>=0;j--){
     mapp[j][i]+=mapp[j+1][i];
    }
  }
  for(j=0;j<n;j++){
    for(i=j+1;i<n;i++){
      mapp[j][i]+=mapp[j][i-1];
    }
  }
  for(i=0;i<Q;i++){
    cout<<mapp[p[i]][q[i]]<<endl; 
  }
  

}

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

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;A++)
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

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


ll N,Np, S[303030];
priority_queue<ll> aaq;
stack<ll> aas;
vector<ll> av;
ll i, j, k,ans;

int main(){
    scanf("%lld",&N);
    Np = 1 << N;
    fornum(i,0,Np){
        scanf("%lld", &S[i]);
        aaq.push(S[i]);
    }

    av.push_back(aaq.top());
    aaq.pop();
    fornum(i,0,N){
        //printf("%d\n", aaq.size());
        sort(av.begin(), av.end(),greater<ll>());
        fornum(j,0,(1<<i)){
            if(aaq.empty()){
                break;
            }
            ll a = aaq.top();
            aaq.pop();
            if(av[j]>a){
                av.push_back(a);
                
            }else{
                aas.push(a);
                j--;
            }
        }
        if(j<(1<<i)){
            break;
        }
        while(aas.size()){
            aaq.push(aas.top());
            aas.pop();
        }
    }
    printf("%s", i == N ? "Yes" : "No");

    return 0;
}

Measured memory_bytes: 9328
from fractions import gcd

def divisor(n):
    divisors = []
    i = 1
    while i * i < n:
        if n % i == 0:
            divisors.append(i)
            divisors.append(n // i)
        i += 1
    if i * i == n:
        divisors.append(i)
    divisors.sort()
    return divisors

N = int(input())
ans = len(divisor(N-1)) - 1
divisors = divisor(N)
for K in divisors[1:]:
    n = N
    while n % K == 0:
        n //= K
    if (n - 1) % K == 0:
        ans += 1
print(ans)

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

#define rep(i, a, b) for(int i = (a); i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define endl '\n'

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;

const ll mod = 1000000007;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
// head
const int nax = 2e5+2;
vector<ll> t(4*nax);

void update(int v, int tl, int tr, int p, ll val) {
    if(tl == tr) {
        t[v] = val;
    } else {
        int tm = (tl + tr) / 2;
        if(p <= tm)
            update(2*v, tl, tm, p, val);
        else update(2*v+1, tm + 1, tr, p, val);
        t[v] = max(t[v*2], t[v*2+1]);
    }
}
ll maxi(int v, int tl, int tr, int l, int r) {
    if(l > r) return 0;
    if(l == tl && r == tr) {
        return t[v];
    } else {
        int tm = (tl + tr) / 2;
        return max(maxi(v*2, tl, tm, l, min(r, tm)), maxi(v*2+1, tm + 1, tr, max(l, tm + 1), r));
    }
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);

    int n;
    cin >> n;
    vi h(n);
    vll a(n);
    rep(i,0,n) cin >> h[i];
    rep(i,0,n) cin >> a[i];

    vll dp(n + 1);
    rep(i,0,n) {
        // find the max value of dp[i] from [0, h[i] - 1]
        ll val = maxi(1,0,n,0,h[i]-1);
        //ll val = maxi(1,0,n,0,h[i]-1);
        if(val + a[i] > dp[h[i]]) {
            dp[h[i]] = val + a[i];
            update(1,0,n,h[i],val + a[i]);
        }
        //dp[h[i]] = max(val + a[i], dp[h[i]]);
        //dp[h[i]] = val + a[i];
        /*rep(j,0,h[i]) {
            dp[h[i]] = max(dp[h[i]], dp[j] + a[i]);
        }*/
    }
    cout << t[1] << endl;
    return 0;
}


Measured memory_bytes: 10368
#include<iostream>
#include<cstring>
using namespace std;
int dp[11][1<<10][331];
int dpset(int n, int data, int sum);
int main(){
	int n,m;
	memset(dp,-1,sizeof(dp));
	while(cin>>n>>m){
		if(m>330 || n>10){cout<<"0"<<endl;}
		else{cout<<dpset(n,0,m)<<endl;}
	}
	return 0;
}
int dpset(int n, int data, int sum){
	int ans = 0;
	if(dp[n][data][sum]>=0){return dp[n][data][sum];}
	if(sum<0){return 0;}
	if(n == 1){
		if(sum<10 && !(data&(1<<sum))){ans = 1;}
	}
	else{
		for(int i=0; i<10; i++){
			if(!(data&(1<<i))){
				ans+=dpset(n-1,data|(1<<i),sum-i*n);
			}
		}
	}
	dp[n][data][sum] = ans;
	return ans;
}

Measured memory_bytes: 15000
# 解けなかった...orz

N = int(input())
A = [int(i) for i in input().split()]

def gcd(i, j):
    if i <= 0:
        return j
    elif j <= 0:
        return i

    while i != j:
        if i < j:
            j %= i
            if j == 0: return i
        else:
            i %= j
            if i == 0: return j
    return i

# M = [0] * N
L = [0] * (N+1)
R = [0] * (N+1)
# L[0] = 0
# R[N] = 0

for i in range(N):
    L[i+1] = gcd(L[i], A[i])
    R[N-i-1] = gcd(R[N-i], A[N-i-1])

res = max(gcd(L[i], R[i+1]) for i in range(N))
print(res)

Measured memory_bytes: 14052
from collections import deque

n = int(input())
q = deque(range(1, 10))
for _ in range(n - 1):
    x = q.popleft()
    r = x % 10
    y = 10 * x
    if r == 0:
        q.extend([y, y+1])
    elif r == 9:
        q.extend([y+8, y+9])
    else:
        q.extend([y+r-1, y+r, y+r+1])
print(q.popleft())

Measured memory_bytes: 18436
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
b = b[::-1]
s = 0
e = 0
for i in range(n):
    if s == 0 and a[i] == b[i]:
        s = i+1
    if s > 0 and a[i] != b[i]:
        e = i+1
        break
if s == 0:
    print("Yes")
    print(*b)
    quit()
cl = a[s-1]
k = e-s
j = 0
for i in range(n):
    if s-1 <= i < e-1:
        continue
    if cl != b[i] and cl != a[i]:
        b[s-1+j] = b[i]
        b[i] = cl
        j += 1
    if j == k:
        break
for i in range(n):
    if a[i] == b[i]:
        print("No")
        quit()
print("Yes")
print(*b)

Measured memory_bytes: 106224
n = int(input())
k = [input() for i in range(n)]
ac = 0
wa = 0
tle = 0
re = 0

for j in range(n):
  if k[j] == 'AC':
    ac += 1
  elif k[j] == 'WA':
    wa += 1
  elif k[j] == 'TLE':
    tle += 1
  elif k[j] == 'RE':
    re += 1
    
print("AC x",ac)
print("WA x",wa)
print("TLE x",tle)
print("RE x",re)

Measured memory_bytes: 16192