akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>

int main(){

int A,B,C,X,ans=0;
scanf("%d%d%d%d",&A,&B,&C,&X);

if (X>500 && A > X/500){A=X/500;};
if (X>100 && B > X/100){B=X/100;};
if (X>50 && C > X/50){C=X/50;};

for (int i = 0; i < A+1; i++){
  for (int j = 0; j < B+1; j++){
    for (int k = 0; k < C+1; k++){
      if (X==(500*i + 100*j + 50*k))
      {
        ans++;
      }
    }
  }
}
printf("%d",ans);

return 0;

}

Measured memory_bytes: 1732
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.UncheckedIOException;
import java.util.Arrays;
import java.util.List;
import java.util.StringTokenizer;


public class Main {
	public static void main(String[] args) {
		SC sc=new SC(System.in);
		String s=sc.next();
		long[] alp=new long[26];
		Arrays.fill(alp, 0);
		long len=(long)s.length();
		for(int i=0; i<len; i++) {
			alp[s.charAt(i)-97]++;
		}
		long[][] matrix=new long[26][26];
		for(int i=0; i<26; i++) {
			for(int j=0; j<26; j++) {
				if(i==j) {
					matrix[i][j]=0;
				}
				else {
					matrix[i][j]=alp[i]*alp[j];
				}
			}
		}
		long sum=0;
		for(int i=0; i<26; i++) {
			for(int j=0; j<26; j++) {
				if(i<j) {
					sum+=matrix[i][j];
				}
			}
		}
		pl(sum+1);
		//pl();
		for(int i=0; i<26; i++) {
			for(int j=0; j<26; j++) {
				if(i<j) {
					//p(matrix[i][j]+" ");
				}
			}
			//pl();
		}
	}
	static class SC {
		private BufferedReader reader = null;
		private StringTokenizer tokenizer = null;
		public SC(InputStream in) {
			reader = new BufferedReader(new InputStreamReader(in));
		}
		public String next() {
			if (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new UncheckedIOException(e);
				}
			}
			return tokenizer.nextToken();
		}
		public int nextInt() {
			return Integer.parseInt(next());
		}
		public long nextLong() {
			return Long.parseLong(next());
		}
		public double nextDouble() {
			return Double.parseDouble(next());
		}
		public String nextLine() {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new UncheckedIOException(e);
			}
		}
	}
	public static void pl(Object o) {
		System.out.println(o);
	}
	public static void pl() {
		System.out.println();
	}
	public static void p(Object o) {
		System.out.print(o);
	}
	public static void fra(int a,List<Integer> p) {//int型用
		for(int i=2; i*i<=a; i++) {
			if(a%i==0) {
				p.add(i);
				fra(a/i,p);
				return;
			}
		}
		if(a>1) {
			p.add(a);
		}
	}
}


Measured memory_bytes: 27660
import java.util.Scanner;

class Main {

  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    int N = scanner.nextInt();
    int[] X = new int[N];
    for (int i = 0; i < N; i++) {
      X[i] = scanner.nextInt();
    }
    int ans = 1;
    int max = X[0];
    for (int i = 1; i < N; i++) {
      if (max <= X[i]) {
        ans++;
        max = X[i];
      }
    }
    System.out.println(ans);
  }

}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

#define rep(i,s,n) for(ll i = (s); i < (n); i++)
#define rep0(i,n) rep(i,0,n)
#define rep1(i,n) rep(i,1,n+1)
#define repR(i,s,n) for(ll i = (n-1); i >= (s); i--)
#define repR0(i,n) repR(i,0,n)
#define repR1(i,n) repR(i,1,n+1)

#define BR "\n"
#define SP " "

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

  string ans = "No";
  rep0(i, s.size()) {
    bool check = true;
    rep0(j, p.size()) {
      if (s[(i + j) % s.size()] != p[j]) {
        check = false;
        break;
      }
    }
    if (check) {
      ans = "Yes";
      break;
    }
  }

  cout << ans << BR;
  return 0;
}


Measured memory_bytes: 3184
//Author : Nishit Patel
#include <bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef double db;
typedef long long ll;
#define pb push_back
#define FAST cin.sync_with_stdio(0); cin.tie(0);
#define rep(i, n)      for(int i = 0; i < (n); ++i)
#define arep(i, a, n)  for(int i = a; i <= (n); ++i)
#define drep(i, a, n)  for(int i = a; i >= (n); --i)
#define trav(a, x)     for(auto& a : x)
#define all(x) x.begin(), x.end()
typedef pair<int, int> pii;
typedef vector<ll> vl;
typedef map<ll, ll> ml;
typedef unordered_map<ll, ll> hash;
#define deb_1(A)                     {cerr << "[" << #A << "] : " << A << endl;}
#define deb_2(A,B)                   {cerr << "[" << #A << "] : " << A << endl<< "[" << #B << "] : " << B << endl;}
#define deb_3(A,B,C)                 {cerr << "[" << #A << "] : " << A << endl<< "[" << #B << "] : " << B << endl\
									   << "[" << #C << "] : " << C << endl;}
#define deb_4(A,B,C,D)               {cerr << "[" << #A << "] : " << A << endl<< "[" << #B << "] : " << B << endl\
									   << "[" << #C << "] : " << C << endl<< "[" << #D << "] : " << D << endl;}
#define deb_X(x,A,B,C,D,FUNC, ...)  FUNC  
#define deb(...)                    deb_X(,##__VA_ARGS__,\
                                          deb_4(__VA_ARGS__),\
                                          deb_3(__VA_ARGS__),\
                                          deb_2(__VA_ARGS__),\
                                          deb_1(__VA_ARGS__),\
                                         )
                                         
#define M 1000000007
ll h,w;
int main() {
	FAST
	cin>>h>>w;
	ll dp[h][w] = {0};
    char grid[h][w];  
	rep(i,h)
	{
		rep(j,w)
		{
			cin>>grid[i][j];
		}
	}
	dp[0][0] = 1;
	rep(i,h)
	{
		rep(j,w)
		{
			if(grid[i][j] == '#')
			{
				dp[i][j] = 0;
			}
			else{
				if(i>0 && j>0)dp[i][j] = (dp[i][j-1]%M + dp[i-1][j]%M)%M;
				else if(i==0 && j!=0)dp[i][j] = dp[i][j-1];
				else if(j==0 && i!=0)dp[i][j] = dp[i-1][j];
			}
			//deb(dp[i][j]);
		}
	}
	cout<<dp[h-1][w-1]<<endl;
	
	
}


Measured memory_bytes: 12408
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long double ld;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int n,k;
	cin >> n >> k;
	vector<ll> h(n);
	REP(i,n) cin >> h[i];
	sort(ALL(h));
	ll ans = 0;
	REP(i,max(n-k,0)) ans += h[i];

	cout << ans << '\n';
	return 0;
}



Measured memory_bytes: 1792
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys
import numpy as np

mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000

N = int(input())
xy = [[] for i in range(N)]
for i in range(N):
    xy[i] = [int(i) for i in input().split()]

xy = np.array(xy)
count_dic = {}
for i in range(N):
    for j in range(i+1,N):
        diff = xy[i] - xy[j]
        p,q = diff
        if p == 0 and q == 0:
            pass
        else:
            k = (p,q)
            if k in count_dic:
                count_dic[k] += 1
            else:
                count_dic[k] = 1
            k = (-p,-q)
            if k in count_dic:
                count_dic[k] += 1
            else:
                count_dic[k] = 1


"""
            p = int(p)
            q = int(q)
            pq = str(p)+str(q)
            pq2 = str(-p)+str(-q)
            if pq in count_dic:
                count_dic[pq] += 1
            else:
                count_dic[pq] = 1
            if pq2 in count_dic:
                count_dic[pq2] += 1
            else:
                count_dic[pq2] = 1

"""
# print(count_dic)
ans = 1
for k,v in sorted(count_dic.items(), key = lambda x:-x[1]):
    ans = N - v
    break
print(max(1,ans))


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

int main() {
  int A, B, C, D, L, R;
  cin >> A >> B >> C >> D;
  L = A + B;
  R = C + D;
  
  if (L > R)
    cout << "Left" << endl;
  else if (L == R)
    cout << "Balanced" << endl;
  else
    cout << "Right" << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <algorithm>
#include <bitset>
#define range(i, r) for(int i=0;i<r;i++)
#define ranges(i, l, r) for(int i=l;i<r;i++)
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi std::vector<std::vector<int> >
#define vvl std::vector<std::vector<ll> >
#define MODs 1000000007;
typedef long long int ll;
using namespace std;
#define P 1000000007
#define N_MAX 2000000
ll fac[N_MAX+1];
ll inv[N_MAX+1];
ll finv[N_MAX+1];

ll comb(ll n, ll k){
    return (((fac[n]*finv[n-k])%P)*finv[k])%P;
}

void init(){
    fac[0] = finv[0] = fac[1] = finv[1] = inv[1] = 1;
    for(int i = 2; i <= N_MAX; i++){
        fac[i] = (fac[i-1]*i)%P;
        inv[i] = ((-(P/i)*inv[P%i])%P+P)%P;
        finv[i] = (finv[i-1]*inv[i])%P;
    }
}

int main(int argc, char const *argv[]) {
  ll N, M, K, Sij, ans=0, aBA, bD, cC, d;
  std::cin >>  N >> M >> K;
  init();
  for(int i=0;i<N;i++){
    for(int j=0;j<M;j++){
      aBA = ((i*j%1000000007)*(i+j+2))%1000000007;
      bD = ((M-j) * ((((i*(i+M-j-1))%1000000007)+i)%1000000007))%1000000007;
      cC = ((N-i) * ((((j*(N-i-1+j))%1000000007)+j)%1000000007))%1000000007;
      d = ((((N-i)*(M-j))%1000000007)*(N-i-1+M-j-1))%1000000007;
      Sij = (aBA + bD + cC + d)%1000000007;
      Sij = (Sij *inv[4])%1000000007;
      ans = (ans + (Sij * comb(N*M-2, K-2))%1000000007)%1000000007;
    }
  }
  std::cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 47232
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
#include <cstring>
using namespace std;

using ll = long long;
using P = pair<int, int>;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

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

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

    string s;
    cin >> s;
    if(s.back() == 's') s += "es";
    else    s += "s";
    cout << s << endl;
}

Measured memory_bytes: 3660
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;n>i;++i)
#define MOD 1000000007
using namespace std;
using ll=int64_t;
using pii=pair<int,int>;
using vi=vector<int>;
using VI=vector<ll>;
using vis=vector<string>;
using vvi=vector<vi>;
//最大公約数
int gcd(int a,int b){
    if(a%b==0)
    return b;
    return gcd(b,a%b);
}
//最小公倍数
int lcm(int a,int b){
   return a*b/gcd(a,b);
}
bool prime(int num){
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false;
    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2){
        if (num % i == 0)
        return false;
    }
    return true;
}
int main(){
    int a;
    cin>>a;
    cout<<a+a*a+a*a*a<<endl;
}

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

int num[110],ans[110],n;

inline int rd()
{
	int x=0;char ch=getchar();
	for (;ch<'0'||ch>'9';ch=getchar());
	for (;ch>='0'&&ch<='9';ch=getchar()) x=x*10+ch-'0';
	return x;
}

int main()
{
	n=rd();
	for (int i=1;i<=n;i++) num[i]=rd();
	for (int i=1;i<=n;i++)
	{
		int id=0;
		for (int j=1;j<=n-i+1;j++) if (num[j]==j) id=j;
		if (!id) { puts("-1");return 0; }
		ans[i]=id;
		for (int j=id;j<=n-i;j++) num[j]=num[j+1];
	}
	for (int i=n;i;i--) printf("%d\n",ans[i]);
	return 0;
}

Measured memory_bytes: 256
use std::cmp::*;
use std::collections::*;
use std::io::*;

use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}
fn main() {
    let n: usize = read();
    let m: usize = read();
    let mut a: Vec<i64> = (0..n).map(|_| read()).collect();
    let mut bc: Vec<(i64, i64)> = Vec::new();
    for i in 0..m {
        let b: i64 = read();
        let c: i64 = read();
        let t = (c, b);
        bc.push(t);
    }
    bc.sort();
    bc.reverse();
    let mut d: Vec<i64> = vec![0; n];
    let mut _id = 0;
    for _i in 0..bc.len() {
        if _id >= n {
            break;
        } else {
            for _j in 0..bc[_i].1 {
                if _id >= n {
                    break;
                }
                d[_id] = bc[_i].0;
                _id += 1;
            }
        }
    }
    a.sort();
    for i in 0..n {
        if d[i] < a[i] {
            break;
        } else {
            a[i] = d[i];
        }
    }
    let mut ans = 0;
    for i in a {
        ans += i;
    }
    println!("{}", ans);
}


Measured memory_bytes: 5384
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int n,L,T;
struct evol{long long x,w;}a[101010];
bool cmp(evol u,evol v){return u.x<v.x;}
int main()
{
	scanf("%d%d%d",&n,&L,&T);
	for(int i=1,x,y;i<=n;i++)
	scanf("%lld%lld",&a[i].x,&a[i].w);
	long long rk=0;	
	for(int i=1;i<=n;i++)
	{
		if(a[i].w==1) a[i].x+=T;
		else a[i].x-=T;
		rk+=a[i].x/L;
		if(a[i].x%L<0) rk--;
		a[i].x=(a[i].x%L+L)%L;
	}
	sort(a+1,a+n+1,cmp);
	rk=(rk%n+n)%n;
	for(int i=rk+1;i<=n;i++)
	printf("%lld\n",a[i].x);
	for(int i=1;i<=rk;i++)
	printf("%lld\n",a[i].x);
	return 0;
}

Measured memory_bytes: 2816
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(ll i=0;i<n;i++)
const ll INF=1e15;
const ll MOD=1000000007;

int main(){
    int H,W,K;cin>>H>>W>>K;;
    char cake[H][W];
    rep(i,H)rep(j,W)cin>>cake[i][j];
    int ans[H][W];
    int count[H],countsum[H];
    rep(i,H){
        int now=0;
        rep(j,W){
            if(cake[i][j]=='#')now++;
        }
        count[i]=now;
        if(i==0)countsum[i]=count[i];
        else countsum[i]=countsum[i-1]+count[i];
    }
    int number=1,check=0;
    int now=0,line,nowcount=0;
    set<ll> draw;
    rep(i,H){
        if(nowcount==0 or (nowcount==1 and count[i]==0)){
            if(count[i]>0){
                line=i;
                nowcount++;
            }
            draw.insert(i);
            if(i!=H-1)continue;
        }
        nowcount=1;
        now=0;
        rep(j,W){
            if(cake[line][j]=='#')now++;
            if(now==2){
                number++;
                nowcount=1;
                now=1;
            }
            for(auto p:draw)ans[p][j]=number;
            if(j==W-1)number++;
        }
        draw.clear();
        draw.insert(i);
        line=i;
    }
    now=0;
    if(count[H-1] and H!=1 and count[H-1]!=K){
        rep(j,W){
            if(cake[line][j]=='#')now++;
            if(now==2){
                number++;
                nowcount=1;
                now=1;
            }
            for(auto p:draw)ans[p][j]=number;
        }
    }
    rep(i,H){
        rep(j,W){
            if(j)cout<<" ";
            cout<<ans[i][j];
        }cout<<endl;
    }
    return 0;
}

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

vector<int> forintinput(int n) {
	vector<int> x;
	for(int i = 0;i < n;i++){
		int ia;
		cin >> ia;
		x.push_back(ia);
	}
	return x;
}
int main(){
	int n;
	cin >> n;
	vector<unsigned long long> a(n);
	for(int i = 0;i < n;i++){
		cin >> a[i];
	}
	unsigned long long cnt = 1;
	sort(a.begin(), a.end());
	if(a[0] <= 0){
		cout << 0 << endl;
	}else{
		for(int i = 0;i < n;i++){
			if(a[i] <= 1000000000000000000/cnt){
				cnt = cnt * a[i];
			}else{
				cout << -1 << endl;
				goto owari;
			}
		}
		cout << cnt << endl;
	}
	owari:
	return 0;
}

Measured memory_bytes: 4024
#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 (int i = 0; i < (n); i++)
#define repb(i, n) for (int i = (n-1); i >= 0; i--)
#define rea(i, a, b) for (int i = (a); i < (b); i++)
#define reab(i, a, b) for (int i = (a)-1; i >= (b); i--)
#define ALL(a) (a).begin(),(a).end()
#define SZ(x) ((int)(x).size())
#define PRINT(V) for (auto v:(V)) {cerr << v << " ";} cerr << endl
#define dump(x) cerr << #x << " : " << (x) << endl
#define dump2(x, y) cerr << "(" << #x << ", " << #y << ") = (" << x << ", " << y << ")" << endl
inline ll GCD(ll a, ll b){return b ? GCD(b, a % b) : a;}
const int MOD = 1000000007;
/* END OF TEMPLATE */

int main(){
    ll N, X;
    cin >> N >> X;
    vll x(N), y(N);
    rep(i, N){
        cin >> x[i];
        y[i] = abs(x[i] - X);
    }
    ll ans = y[0];
    rea(i, 1, N){
        ans = GCD(ans, y[i]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 1792
N = int(input())
S = []
for i in range(N):
    S.append(input())
S = sorted(S)
CNT = [1]
dummy = 1
for i in range(1, N):
    if(S[i] == S[i - 1]):
        dummy += 1
    else:
        dummy = 1
    CNT.append(dummy)
#print(S)
#print(CNT)        
MAX = max(CNT)
for i in range(N):
    if(CNT[i] == MAX):
        print(S[i])

Measured memory_bytes: 26096
#include<bits/stdc++.h>
using ll = int_fast64_t;

int main(){
        ll n, t, d, x;
        scanf("%ld", &n);

        std::deque<ll> deq;
        for(ll i=0; i<n; i++){
                scanf("%ld %ld", &t, &d);
                if(t==0){
                        scanf("%ld", &x);
                        if(d) deq.push_back(x);
                        else deq.push_front(x);
                }else if(t==1){
                        printf("%ld\n", deq[d]);
                }else{
                        if(d) deq.pop_back();
                        else deq.pop_front();
                }
        }
        return 0;
}


Measured memory_bytes: 6284
#include<bits/stdc++.h>
using namespace std;
const int N=110;
int n;
char s[N];

char key[10]={'k','e','y','e','n','c','e'};
bool  check(int s1,int t1,int s2,int t2) {
	if (t1-s1+1+t2-s2+1!=7) return 0;
	int now=0;
	for (int i=1;i<=n;i++)
		if (s1<=i && i<=t1 || s2<=i && i<=t2) {
			if (s[i]!=key[now]) return 0;
			now++;
		}
	return 1;
}

int main()
{
	scanf("%s",s+1);
	n=strlen(s+1);
	for (int i=1;i<=n;i++)
		for (int j=i-1;j<=n;j++) {
			if (check(1,i-1,j+1,n)) {
				puts("YES");
				return 0;
			}
		}
	puts("NO");	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;

#define rep(i, n) for (int i = 0; i < n; ++i)
#pragma region Debug
template <typename T>
void view(const std::vector<T> &v)
{
    for (const auto &e : v)
    {
        std::cout << e << " ";
    }
    std::cout << std::endl;
}
template <typename T>
void view(const std::vector<std::vector<T>> &vv)
{
    for (const auto &v : vv)
    {
        view(v);
    }
}
#pragma endregion

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

    ll ans = LLONG_MAX;
    rep(i, 1 << n)
    {
        ll now = 0;
        int m = 0;
        int ok = 0;
        rep(j, n)
        {
            if ((1 << j) & i)
            {
                now += max(0, m - a[j] + 1);
                m = max(m + 1, a[j]);
                ok++;
            }
            else
            {
                if (m < a[j])
                {
                    ok++;
                }
                m = max(m, a[j]);
            }
        }
        if (ok >= k)
        {
            ans = min(now, ans);
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
#define VL vector<ll>
#define VS vector<string>
#define VB vector<bool>
#define VP vector<pair<ll,ll>>
#define VVL vector<vector<ll>>
#define VVP vector<vector<pair<ll,ll>>>
#define PL pair<ll,ll>
#define ALL(v) (v).begin(), (v).end()
ll d1[4] = {1, -1, 0, 0};
ll d2[4] = {0, 0, 1, -1};

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

    ll itr = 0;
    bool exi = true;
    while(itr < k && exi){
        bool f = false;
        vector<ll> imos(n+1, 0);
        rep(i, 0, n){
            if(a[i] != n) f = true;
            imos[max(0LL, i - a[i])]++;
            imos[min(n, i + a[i] + 1)]--;
        }
        ll acc = 0;
        rep(i, 0, n){
            acc += imos[i];
            a[i] = acc;
        }
        exi = f;
        itr++;
    }

    rep(i, 0, n-1) cout << a[i] << " ";
    cout << a[n-1] << endl;
    return 0;
}


Measured memory_bytes: 6392
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=2e5;
queue<int>q;
int du[maxn+10][2];
int n,m;
string s;
vector<int>ve[maxn+10];
bool vis[maxn+10];
int cnt;
int main()
{
    while(cin>>n>>m)
    {
        cnt=0;
        cin>>s;
        for(int i=1; i<=n; i++)
            du[i][1]=0,du[i][0]=0,ve[i].clear(),vis[i]=false;
        for(int i=0; i<m; i++)
        {
            int u,v;
            cin>>u>>v;
            du[u][s[v-1]=='B']++;
            du[v][s[u-1]=='B']++;
            ve[u].push_back(v);
            ve[v].push_back(u);
        }
        for(int i=1; i<=n; i++)
            if(du[i][0]==0||du[i][1]==0)
                if(!vis[i])
                    q.push(i),vis[i]=true,cnt++;
        while(!q.empty())
        {
            int u=q.front();
            q.pop();
            for(int i=0; i<ve[u].size(); i++)
            {
                int v=ve[u][i];
                if(!vis[v])
                    if(--du[v][s[u-1]=='B']==0)
                        q.push(v),vis[v]=true,cnt++;
            }
        }
        if(cnt==n)
            puts("No");
        else
            puts("Yes");
    }
    return 0;
}


Measured memory_bytes: 12548
N,M,Q=map(int,input().split())

from itertools import combinations_with_replacement
A=[0]*N
conditions = []

for i in range(Q):
    con =list(map(int,input().split()))
    conditions.append(con)

c = combinations_with_replacement(range(1,M+1),N)

total =0
for seq in c:
    total_tmp=0
    for q in conditions:
        if seq[q[1]-1] - seq[q[0]-1] == q[2]:
            total_tmp += q[3]

    total = max(total,total_tmp )

print(total)



Measured memory_bytes: 9148
/*{{{*/
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstring>
#include <unordered_map>
#include <unordered_set>
#include <cassert>
using namespace std;
typedef pair<int, int> PP;
typedef long long LL;
#define pb push_back
#define fr first
#define sc second
#define bitcnt __builtin_popcount
#define all(x) x.begin(), x.end()
inline LL ri() {LL x; scanf("%lld", &x); return x;}
#define rep2(i, n, ...) for (int i = 0; i < (n); i ++) 
#define rep3(i, a, b, ...) for (int i = (a); i < (b); i ++)
#define GET_MACRO(_1, _2, _3, NAME, ...) NAME
#define rep(...) GET_MACRO(__VA_ARGS__, rep3, rep2)(__VA_ARGS__)
#define drep2(i, n, ...) for (int i = (n) - 1; i >= 0; i --)
#define drep3(i, a, b) for (int i = (a) - 1; i >= (b); i --)
#define drep(...) GET_MACRO(__VA_ARGS__, drep3, drep2)(__VA_ARGS__)
template<typename T>inline bool smax(T&a, T b){if(a<b){a=b;return true;}return false;} 
template<typename T>inline bool smin(T&a, T b){if(a>b){a=b;return true;}return false;} 
/*}}}*/

const int maxn = 1000;

vector<int> v;

int p[maxn], vis[maxn];
int main() {
  int n;
  cin >> n;
  rep(i, n) {
    int x; 
    cin >> x;
    v.pb(x);
  }

  vector<int> res;
  rep(i, n) {
    drep(j, v.size()) {
      if (v[j] - 1 - j == 0) {
        res.pb(v[j]);
        v.erase(v.begin() + j);   
        break;
      }
    }
    
    if (res.size() != i + 1) {
      cout << -1 << endl;
      return 0;
    }
  }

  //rep(i, n) {
    //p[i] = v[i] - 1 - i;
    //if (p[i] <= 0) {
      //cout << i << endl;
      //cout << -1 << endl;
      //return 0;
    //}
  //}

  //vector<int> res;

  //rep(i, n) {
    //bool found = false;
    //rep(j, n) if (!vis[j]) {
      //bool ok = true;
      //rep(k, n) if (!vis[k] && k != j) {
        //if (p[k] - (v[k] < v[j]) < 0) {
          //ok = false;
          //break;
        //}
      //}
      //if (ok) {
        //res.pb(v[j]);
        //vis[j] = 1;
        //rep(k, n) if (!vis[k] && k != j) {
          //p[k] -= (v[k] < v[j]);
        //}
        //found = true;
        //break;
      //}
    //}
    //if (!found) {
      //cout << -1 << endl;
      //return 0;
    //}
  //}

  rep(i, n) cout << res[n - 1 - i] << ' ';

  


  return 0;
}


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

#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <deque>

#include <algorithm>

using namespace std;

int main(int argc, char *argv[]) {
	int a, p;
	cin >> a >> p;
	cout << (a * 3 + p) / 2 << endl;

}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "debug.h"
#else
#define dump(...)
#endif
#define endl '\n'
#define ll long long
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define REP(i, x) for (int i = 0; i < (int)(x); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define RREP(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (int i = ((int)(x)); i > 0; i--)
#define INF 2147483647
#define LLINF 9223372036854775807LL
#define vi vector<int>
#define vvi vector<vector<int>>
#define pi pair<int, int>
#define ALL(a) (a).begin(), (a).end()
#define BIT(n) (1LL << (n))
#define TOUPPER(s) transform(s.begin(), s.end(), s.begin(), ::toupper)
#define TOLOWER(s) transform(s.begin(), s.end(), s.begin(), ::tolower)
#define FILLZERO(s, n)                      \
    do {                                    \
        ostringstream os;                   \
        os << setw(n) << setfill('0') << s; \
        s = os.str();                       \
    } while (0);
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end()) //sortしてからつかうこと
#define INIT                               \
    std::cin.tie(nullptr);                 \
    std::ios_base::sync_with_stdio(false); \
    cout << std::fixed << std::setprecision(10);

template <typename T>
vector<T> make_vec(size_t a, T n) { return vector<T>(a, n); }
template <typename T, typename... Ts>
auto make_vec(size_t a, Ts... ts) { return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...)); }
template <class T>
inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
    for (T &x : vec)
        is >> x;
    return is;
}

constexpr ll MOD = 1e9 + 7;
int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};
ll A, B, C, D, E, F, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S, T;
ll ans = 0;

signed main() {
    INIT;
    cin >> N >> K >> X >> Y;
    if (N > K) {
        cout << X * K + Y * (N - K) << endl;
    } else
        cout << X * N << endl;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define LLI long long int
#define FOR(v, a, b) for(LLI v = (a); v < (b); ++v)
#define FORE(v, a, b) for(LLI v = (a); v <= (b); ++v)
#define REP(v, n) FOR(v, 0, n)
#define REPE(v, n) FORE(v, 0, n)
#define REV(v, a, b) for(LLI v = (a); v >= (b); --v)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define ITR(it, c) for(auto it = (c).begin(); it != (c).end(); ++it)
#define RITR(it, c) for(auto it = (c).rbegin(); it != (c).rend(); ++it)
#define EXIST(c,x) ((c).find(x) != (c).end())
#define fst first
#define snd second
#define popcount __builtin_popcount
#define UNIQ(v) (v).erase(unique(ALL(v)), (v).end())
#define bit(i) (1LL<<(i))

#ifdef DEBUG
#include <misc/C++/Debug.cpp>
#else
#define dump(...) ((void)0)
#endif

#define gcd __gcd

using namespace std;
template <class T> constexpr T lcm(T m, T n){return m/gcd(m,n)*n;}

template <typename I> void join(ostream &ost, I s, I t, string d=" "){for(auto i=s; i!=t; ++i){if(i!=s)ost<<d; ost<<*i;}ost<<endl;}
template <typename T> istream& operator>>(istream &is, vector<T> &v){for(auto &a : v) is >> a; return is;}

template <typename T, typename U> bool chmin(T &a, const U &b){return (a>b ? a=b, true : false);}
template <typename T, typename U> bool chmax(T &a, const U &b){return (a<b ? a=b, true : false);}
template <typename T, size_t N, typename U> void fill_array(T (&a)[N], const U &v){fill((U*)a, (U*)(a+N), v);}

struct Init{
  Init(){
    cin.tie(0);
    ios::sync_with_stdio(false);
  }
}init;


int main(){
  int N;
  while(cin >> N){
    vector<int> A(N), B(N), C(N-1); cin >> A >> B >> C;
    REP(i,N) --A[i];

    int ans = 0;
    //dump(A);

    REP(i,N){
      ans += B[A[i]];
      
      if(i < N-1 and A[i] + 1 == A[i+1]) ans += C[A[i]];
    }
    


    cout << ans << endl;
  }


  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define EPS 1e-9
#define rank asadf
using namespace std;

const int MAXN = 3e5 + 111;
const int MOD = 998244353;

int n;

int tx[4 * MAXN], ty[4 * MAXN];

void build(int v, int l, int r) {
    if (l == r - 1) {
        tx[v] = ty[v] = n - 1;
        return;
    }
    int mid = (l + r) / 2;
    build(2 * v + 1, l, mid);
    build(2 * v + 2, mid, r);
    tx[v] = min(tx[2 * v + 1], tx[2 * v + 2]);
    ty[v] = min(ty[2 * v + 1], ty[2 * v + 2]); 
}

void updatex(int v, int l, int r, int pos, int d) {
    if (pos < l || r <= pos)
        return;
    if (l == r - 1) {
        tx[v] = min(tx[v], d);
        return;
    }
    int mid = (l + r) / 2;
    updatex(2 * v + 1, l, mid, pos, d);
    updatex(2 * v + 2, mid, r, pos, d);
    tx[v] = min(tx[2 * v + 1], tx[2 * v + 2]);
}

void updatey(int v, int l, int r, int pos, int d) {
    if (pos < l || r <= pos)
        return;
    if (l == r - 1) {
        ty[v] = min(ty[v], d);
        return;
    }
    int mid = (l + r) / 2;
    updatey(2 * v + 1, l, mid, pos, d);
    updatey(2 * v + 2, mid, r, pos, d);
    ty[v] = min(ty[2 * v + 1], ty[2 * v + 2]);
}

int queryx(int v, int l, int r, int ql, int qr) {
    if (ql <= l && r <= qr)
        return tx[v];
    if (r <= ql || qr <= l)
        return n;
    int mid = (l + r) / 2;
    int left = queryx(2 * v + 1, l, mid, ql, qr);
    int right = queryx(2 * v + 2, mid, r, ql, qr);
    return min(left, right);
}

int queryy(int v, int l, int r, int ql, int qr) {
    if (ql <= l && r <= qr)
        return ty[v];
    if (r <= ql || qr <= l)
        return n;
    int mid = (l + r) / 2;
    int left = queryy(2 * v + 1, l, mid, ql, qr);
    int right = queryy(2 * v + 2, mid, r, ql, qr);
    return min(left, right);
}


int main() {
#ifdef LOCAL
    freopen("xxx.in", "r", stdin);
    freopen("xxx.out", "w", stdout);
#endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    
    cin >> n;
    build(0, 0, n);
    
    int q;
    cin >> q;
    
    ll ans = (n - 2) * 1LL * (n - 2);
    for (int i = 0; i < q; ++i) {
        int t, x;
        cin >> t >> x;
        --x;
        if (t == 1) {
            int pos = queryx(0, 0, n, x, n);
            ans -= pos - 1;
            updatey(0, 0, n, pos, x);
        } else {
            int pos = queryy(0, 0, n, x, n);
            ans -= pos - 1;
            updatex(0, 0, n, pos, x);
        }
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 7772
#include <stdio.h>
#include <string.h>
#define LEN 100005
 
typedef struct pp {
  char name[100];
  int t;
} P;
 
P Q[LEN];
int head, tail, n;
 
void enqueue(P x) {
  Q[tail] = x;
  tail = (tail + 1) % LEN;
}
 
P dequeue() {
  P x = Q[head];
  head = (head + 1) % LEN;
  return x;
}
 
int min(int a,int b) {
  return a < b ? a : b; 
}
 
int main() {
  int elaps = 0, c;
  int i, q;
  P u;
  char str[64];
  
  scanf("%d %d",&n ,&q);
  for(i=1; i<=n; i++) {
    scanf("%s", Q[i].name);
    scanf("%d", &Q[i].t);
  }
  head = 1; tail = n + 1;
 
  while(head != tail) {
    u = dequeue();
    c = min(q, u.t);
    u.t -= c;
    elaps += c;
    if(u.t > 0) enqueue(u);
    else {
      printf("%s %d\n",u.name,elaps);
    }
  }
  return 0;
}


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

int main() {
  // input
  int N, M, C;  cin >> N >> M >> C;
  vector<int> B(M);
  for (int i = 0; i < M; i++) {
    cin >> B.at(i);
  }
  
  // judge
  int A, sum, ans = 0;
  for (int i = 0; i < N; i++) {
    sum = C;
    for (int j = 0; j < M; j++) {
      cin >> A;
      sum += A * B.at(j);
    }
    if (sum > 0) ans++;
  }
  
  // output
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python

from collections import deque
import itertools as it
import sys
import math

sys.setrecursionlimit(10000000)

while True:
    n, p, q = map(int, raw_input().split())
    if n == p == q == 0:
        break
    T = [0 for i in range(2401)]
    for loop in range(n):
        k = input()
        ts = map(int, raw_input().split())
        for i in range(k):
            T[ts[i * 2]] += 1
            T[ts[i * 2 + 1]] -= 1
    cnt = 0
    S = 0
    ans = 0
    for i in range(24):
        for j in range(60):
            t = i * 100 + j
            if p <= t < q:
                cnt += T[t]
                if cnt < n:
                    S += 1
                else:
                    ans = max(ans, S)
                    S = 0
    ans = max(ans, S)
    print ans


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

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;
using pll = pair<ll,ll>;

#define INF (1LL << 60)
#define MOD 1000000007
#define PI 3.14159265358979323846

#define REP(i,m,n) for(ll (i)=(m),(i_len)=(n);(i)<(i_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define PR(x) cout << (x) << endl
#define PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define REV(x) reverse(ALL((x)))
#define ASC(x) sort(ALL((x)))
#define DESC(x) ASC((x)); REV((x))
#define pb push_back
#define eb emplace_back

int main()
{
    ll N;
    cin >> N;
    vec X(N+1, 0), Y(N+1, 0);
    REP(i,1,N+1) {
        cin >> X[i];
        Y[i] = X[i];
    }

    ASC(Y);
    REP(i,1,N+1) {
        if(X[i] <= Y[N/2]) PR(Y[N/2+1]);
        else PR(Y[N/2]);
    }


    return 0;
}

/*

1 2 3 4 5 6 7 8

1 2 4 5 6 7 8
1 3 4 5 6 7 8
1 2 3 4 5 7 8
2 3 4 5 6 7 8
1 2 3 4 5 6 7
*/

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

int gcd(int a, int b) 
{ 
    if (a == 0) 
        return b; 
    return gcd(b % a, a); 
} 

int findGCD(int a, int b, int c)
{
    return gcd(a, gcd(b, c));
}

int main(){

 int k;
 cin>>k;
 int sum = 0;

 for(int a = 1; a <= k ; a++)
 {
 for(int b = 1; b <= k ; b++)
 {
 for(int c = 1; c <= k ; c++)
 { 
     sum += findGCD(a,b,c);

 }
 }
 
 }
 
 cout<<sum;

}

Measured memory_bytes: 3596
N=int(input())

if N == 3:
	print(61)

else:
	chars = "ACGT"
	invalid = [c+"AGC" for c in chars] + [c+"GAC" for c in chars] + [c+"ACG" for c in chars] + ["A"+c+"GC" for c in chars] + ["AG"+c+"C" for c in chars] + ["AGC"+c for c in chars] + ["GAC"+c for c in chars] + ["ACG"+c for c in chars]

	now={}
	for w in chars:
		for x in chars:
			for y in chars:
				for z in chars:
					s=w+x+y+z
					if s not in invalid:
						now[s] = 1

	for _ in range(N-4):
		new={}
		for s in now.keys():
			for c in chars:
				ns=s[1:]+c
				if ns not in invalid:
					if ns not in new:
						new[ns] = 0
					new[ns] += now[s]
					new[ns] %= 10**9+7
		now=new

	print(sum(now.values()) % (10**9+7))


Measured memory_bytes: 43372
#include <iostream>
#include <string>
#include <stack>
#include <queue>
#include <set>
#include <cstring>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <map>
#include <numeric>
#define bogo_sort std::sort
#define bozo_sort std::stable_sort
#define alles(obj) obj.begin(), obj.end()
#define elif else if
#define unless(flg) if(!(flg))
#define elless(flg) else if(!(flg))
#define echo std::cout <<
#define read std::cin >>
#define endl std::endl
#define fin << '\n'
#define bash push_back
#define makePair std::make_pair
#define _ << ' ' <<
// type-define
#define Stack std::stack
#define Queue std::queue
#define Set std::set
#define PQueue std::priority_queue
#define Vector std::vector
#define Pair std::pair
#define Map std::map
#define Greater std::greater
using String = std::string;
using llong = long long;
using boolean = bool;
using Pii = Pair<int, int>;
using Vi = Vector<int>;
using Vii = Vector<Pii>;
// utils
constexpr int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
constexpr int dy[] = {0, 1, 0, -1, 1, -1, 1, -1};
constexpr int INF = 0x3f3f3f3f;
constexpr llong LINF = 0x3f3f3f3f3f3f3f3fLL;

namespace {
    llong power ( llong x, llong n, llong mod ) {
        llong ans = 1;
        while ( n > 0 ) {
            if ( n & 1 ) ans = ( ans * x ) % mod;
            x = ( x * x ) % mod;
            n >>= 1;
        }
        return ans;
    }
    llong power ( llong x, llong n ) { return power( x, n, 1000000007 ); }
    llong gcd ( llong x, llong y ) { return x % y ? gcd( y, x % y ) : y; }
    llong lcm ( llong x, llong y ) { return ( x / gcd(x, y) * y ); }
    boolean isMovable ( int x, int y, int w, int h ) { 
        return ( x >= 0 && y >= 0 && x < w && y < h ); }
    llong abs ( llong n ) { return n < 0 ? -n : n; }
}

#define int long long

namespace Rlyeh {

    int dp[4][100100];
    int a[4][100100];
    int n;

    int dfs ( int prev, int day ) {
        if ( ~dp[prev][day] ) return dp[prev][day];
        if ( n == day ) return 0;
        int rec = 0;
        for ( int i = 0; i < 3; i++ ) {
            if ( i == prev ) continue;
            rec = std::max ( rec, dfs ( i, day+1 ) + a[i][day] );
        }
        return dp[prev][day] = rec;
    }

    signed call_of_Cthulhu( signed datum ) {
        memset ( dp, -1, sizeof(dp));
        read n;
        for ( int i = 0; i < n; i++ ) {
            for ( int j = 0; j < 3; j++ ) {
                read a[j][i];
            }
        }
        int rec = 0;
        for ( int i = 0; i < 3; i++ ) {
            rec = std::max ( rec, dfs ( i, 1 ) + a[i][0] );
        }

        echo rec fin;

        return 0;
    }
}

signed main(){std::cin.tie(0); std::ios::sync_with_stdio(false); int main_result = Rlyeh::call_of_Cthulhu(114514); return 0;}


Measured memory_bytes: 12800
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N=1000005;
struct Gragh{
	int cnt,y[N],z[N],nxt[N],fst[N];
	void clear(){
		cnt=0;
		memset(fst,0,sizeof fst);
	}
	void add(int a,int b,int c){
		y[++cnt]=b,z[cnt]=c,nxt[cnt]=fst[a],fst[a]=cnt;
	}
}g;
int n,m;
int q[N],head,tail;
LL dis[N],Max[N];
LL INF=10000000000000000LL;
bool SPFA(int S){
	for (int i=1;i<=n*2;i++)
		dis[i]=INF;
	head=tail=0;
	q[++tail]=S;
	dis[S]=0;
	while (head!=tail){
		int x=q[++head],y;
		for (int i=g.fst[x];i;i=g.nxt[i]){
			int y=g.y[i];
			if (dis[y]!=dis[x]+g.z[i]){
				if (dis[y]!=INF)
					return 0;
				dis[y]=dis[x]+g.z[i];
				q[++tail]=y;
			}
		}
	}
	return 1;
}
int TS=0;
int main(){
	scanf("%d%d",&n,&m);
	g.clear();
	for (int i=1;i<=n;i++)
		Max[i]=INF;
	for (int i=1;i<=m;i++){
		int a,b,c;
		scanf("%d%d%d",&a,&b,&c);
		g.add(a,b+n,-c);
		g.add(b+n,a,c);
		g.add(b,a+n,-c);
		g.add(a+n,b,c);
		Max[a]=min(Max[a],1LL*c);
		Max[b]=min(Max[b],1LL*c);
	}
	if (!SPFA(1)){
		puts("0");
		return 0;
	}
	LL v=INF;
	for (int i=1;i<=n;i++)
		if (dis[i]!=INF&&dis[i+n]!=INF){
			LL A=dis[i],B=dis[i+n];
			// x+A=-(x+B) => x=-(A+B)/2;
			if ((A+B)%2LL){
				puts("0");
				return 0;
			}
			LL x=-(A+B)/2LL;
			if (x!=v)
				if (v==INF)
					v=x;
				else {
					puts("0");
					return 0;
				}
		}
	if (v!=INF){
		int f=1;
		for (int i=1;i<=n;i++){
			if (dis[i]!=INF)
				if (v+dis[i]<=0)
					f=0;
			if (dis[i+n]!=INF)
				if (v+dis[i+n]>=0)
					f=0;
		}
		printf("%d",f);
		return 0;
	}
	LL MIN=1,MAX=INF;
	for (int i=1;i<=n;i++)
		if (dis[i]!=INF){
			// 0 < x+dis[i] < Max[i]
			MAX=min(MAX,Max[i]-dis[i]-1);
			MIN=max(MIN,-dis[i]+1);
		}
		else {
			// 0 < -(x+dis[i]) < Max[i]
			MAX=min(MAX,-dis[i+n]-1);
			MIN=max(MIN,-Max[i]-dis[i+n]+1);
		}
	printf("%lld",max(MAX-MIN+1,0LL));
	return 0;
}

Measured memory_bytes: 25984
import bisect,collections,copy,heapq,itertools,math,string
import sys
def S(): return sys.stdin.readline().rstrip()
def M(): return map(int,sys.stdin.readline().rstrip().split())
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())
n, h, w = M()
ans = 0
for _ in range(n):
    a, b = M()
    if a >= h and b >= w:
        ans += 1
print(ans)

Measured memory_bytes: 68384
n = input()
def dfs(A):
    #print(A)
    global cnt
    if len(A) > len(n):
        return
    if len(A) >= 3 and int(A) <= int(n):
        if A.count('7') >= 1 and A.count('5') >= 1 and A.count('3') >= 1:
            cnt += 1
            #print('?')
    for num in "357":
        A += num
        dfs(A)
        A = A[:-1]

cnt = 0
dfs("")
print(cnt)


Measured memory_bytes: 3060
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
#include <iomanip>

#define int long long int
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )

using namespace std;

typedef pair<int, int> P;

const int INF = 1e15;
const int MOD = 1e9+7;

template <typename T>
using vector2 = vector<vector<T>>;
template <typename T>
vector2<T> initVec2(size_t n0, size_t n1, T e = T()){
    return vector2<T>(n0, vector<T>(n1, e));
}

template <typename T>
using vector3 = vector<vector<vector<T>>>;
template <typename T>
vector3<T> initVec3(size_t n0, size_t n1, size_t n2, T e = T()){
    return vector3<T>(n0, vector2<T>(n1, vector<T>(n2, e)));
}

//Mat[0] : 第0行ベクトル
typedef vector<int> Vec;
typedef vector<Vec> Mat;

//転置B : A(B) -> C
Vec trans(Vec a, Vec b){
    Vec c(b.size());
    for(int i = 0; i < (int)a.size(); i++){
        c[i] = b[a[i]];
    }
    return c;
}

Vec powTrans(Vec a, int n){
    Vec b(a.size());;
    for(int i = 0; i < (int)a.size(); i++){
        b[i] = i;
    }

    while(n != 0){
        if(n % 2 == 1){
            b = trans(a, b);
        }

        n /= 2;
        a = trans(a, a);
    }
    return b;
}

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

    int n;
    cin >> n;
    vector<int> x(n);
    rep(i, n) cin >> x[i];
    int m, k;
    cin >> m >> k;
    vector<int> a(m);
    rep(i, m){
        cin >> a[i];
        a[i]--;
    }

    vector<int> y(n - 1);
    rep(i, n - 1){
        y[i] = x[i+1] - x[i];
    }

    vector<int> z(n - 1);
    rep(i, n - 1) z[i] = i;
    rep(i, m){
        swap(z[a[i]-1], z[a[i]]);
    }

    Vec yy = trans(powTrans(z, k), y);
    vector<int> ans(n);
    ans[0] = x[0];
    rep(i, n - 1){
        ans[i+1] = ans[i] + yy[i];
    }

    rep(i, n){
        cout << ans[i] << endl;
    }

    return 0;
}


Measured memory_bytes: 7504
#include<iostream>

using namespace std;

main(){
  int i=0;
  double a,b;
  double sum;
  while(cin >> a >> b){
    
    sum = a+b;
    
    while(sum>=1){
	i++;
	//cout << i << endl;
	sum/=10;
    }
      cout << i << endl;
      i=0;
  }
  return 0;
  
}

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

int main(){
  int r,g,b,n,sum,ans=0;
  cin>>r>>g>>b>>n;
  for(int i=0;i<=n/r;i++){
    for(int j=0;j<=n/g;j++){
        sum=r*i+g*j;
        if(sum>n)break;
        if((n-sum)%b==0){
          ans++;
        }
      }
  }
  cout<<ans<<endl;
  return 0;
}



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

const int N = (1e5) + 5;
int a[N];
int ind[N];

bool cmp(int i, int j) {
  return a[i] < a[j];
}

int main() { // claudio van
  int n; cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    ind[i] = i;
  }
  sort(ind, ind + n, cmp);
  for (int i = 0; i < n; ++i) {
    if (i != 0) cout << " ";
    cout << ind[i] + 1;
  }
  cout << endl;
  return 0;
}

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

int main()
{
long long int x,n,i;

cin>>n;

for(i=1;i<=n;i++)
{


    if ( i % 3 == 0 )
            cout << " " << i;
else
{
    x=i;
    while(x)
    {

    if( x % 10 == 3 ){
    cout << " " << i;
    break;
    }
    x=x/10;
    }

}


}
 cout << endl;



}



Measured memory_bytes: 3092
import java.util.*;

public class Main {
    static boolean[] bits;
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n=sc.nextInt();
        int k=sc.nextInt();
        Queue<Integer> queue=new PriorityQueue<>();
        int[] nums=new int[n];
        for(int i=0;i<n;i++){
            nums[i]=sc.nextInt();
        }
        int ans=Integer.MIN_VALUE;
        int tmp;
        for(int i=-1;i<n;i++){
            for(int j=i+1;j<n+1;j++){
                if(n-(j-i-1)>k)continue;
                tmp=0;
                for(int l=0;l<=i&&l>-1;l++){
                    tmp+=nums[l];
                    queue.add(nums[l]);
                }
                for(int l=j;l<n&&l>-1;l++){
                    tmp+=nums[l];
                    queue.add(nums[l]);
                }
                for(int l=0;l<k-n+(j-i-1)&&queue.size()>0&&queue.peek()<0;l++){
                    tmp-=queue.poll();
                }
                ans=Math.max(ans,tmp);
                queue=new PriorityQueue<>();
            }
        }
        System.out.println(ans);
    }
    
}


Measured memory_bytes: 24020
/* ex 5_3
   offNaria */

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



int main(void){
    //10文字以下なので最大の要素数は\0を含めて11
    char sequence[11],*ptr;
    int flag=0,maxLength=0,tempLength=0;
    scanf("%s", sequence);
    ptr=sequence;
    //終了位置まで動かす
    while (*ptr)
    {
        if (flag==0) //ACGT部分文字列の途中でないときの処理
        {
            if ((*ptr=='A')||(*ptr=='C')||(*ptr=='G')||(*ptr=='T')) //ACGT文字列が開始したらフラグを上げtempLengthをインクリメントしていく
            {
                flag=1;
                tempLength++;
            }
        }
        else //ACGT部分文字列の先頭でないときの処理
        {
            if ((*ptr=='A')||(*ptr=='C')||(*ptr=='G')||(*ptr=='T')) //ACGT文字列中ならばtempLengthをインクリメントしていく
            {
                tempLength++;
            }
            else //ACGT文字列が終了していたならばフラグを下げtempLengthとmaxLengthの大きいほうをmaxLengthとしtempLengthをリセットする
            {
                flag=0;
                if (tempLength>maxLength)
                {
                    maxLength=tempLength;
                }
                tempLength=0;
            }
        }
        ptr++;
    }
    if ((flag=1)&&(tempLength>maxLength)) //末尾もACGT文字列中であったときの処理
    {
        maxLength=tempLength;
    }
    printf("%d\n",maxLength); //maxLengthを出力する
    return 0;
}

Measured memory_bytes: 1728