akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;
#define rep(i, begin, n) for (int i = begin; i < n; i++)
#define repe(i, begin, n) for (int i = begin; i <= n; i++)
#define repr(i, begin, n) for (int i = begin; i > begin - n; i--)
#define repre(i, begin, end) for (int i = begin; i >= end; i--)

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

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

// -------------------------------------------------------
ll N;

int main() {
  cin >> N;
  ll ans = 1;
  repe(i, 1, N) {
    if (i * i <= N) {
      ans = i * i;
    } else {
      break;
    }
  }
  cout << ans;
}


Measured memory_bytes: 3644
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N, M, T; cin >> N >> M >> T;
  int a[N]; FOR(i,0,N) cin >> a[i];
  int go = a[0] - M;
  int ans = go;
  FOR(i,1,N) {
    // ?????????
    if(a[i-1] + 2 * M < a[i]) {
      int get = a[i - 1] + M;
      go = a[i] - M;
      ans += go - get;
    }
  }
  ans += max(T - a[N - 1] - M, 0);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3112
#include <bits/stdc++.h>
#define whlie while
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define rep(i,N) for(int i = 0; i < (N); i++)
#define repr(i,N) for(auto i = (N) - 1; i >= 0; i -= 1)
#define each(x,v) for(auto& x : v)
#define all(v) (v).begin(),(v).end()
#define sz(v) ((int)(v).size())
#define vrep(v,it) for(auto it = v.begin(); it != v.end(); it++)
#define vrepr(v,it) for(auto it = v.rbegin(); it != v.rend(); it++)
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) ll __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
#define rand mtrand
#ifdef NyaanDebug
  #include "NyaanDebug.h"
  #define trc(...) do { cout << #__VA_ARGS__ << " = "; dbg_out(__VA_ARGS__);} while(0)
  #define trca(v,...) do { cout << #v << " = "; array_out(v , ##__VA_ARGS__);cout << endl;} while(0)
#else
  #define trc(...)
  #define trca(...)
#endif
using namespace std;
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector< vector<int> >;
constexpr int inf = 1001001001;
constexpr ll infLL = 0x1FFFFFFFFFFFFFFFLL;
struct IoSetupNya {IoSetupNya() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); cerr << fixed << setprecision(15);} } iosetupnya;
template<typename T, typename U> inline bool amin(T &x, U y) { return (y < x) ? (x = y, true) : false; }
template<typename T, typename U> inline bool amax(T &x, U y) { return (x < y) ? (x = y, true) : false; }
template<typename T, typename U> ostream& operator <<(ostream& os, const pair<T, U> &p) { os << p.first << " " << p.second; return os; }
template<typename T, typename U> istream& operator >>(istream& is, pair<T, U> &p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator <<(ostream& os, const vector<T> &v) { int s = (int)v.size(); rep(i,s) os << (i ? " " : "") << v[i]; return os; }
template<typename T> istream& operator >>(istream& is, vector<T> &v) { for(auto &x : v) is >> x; return is; }
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << "\n";} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
template<typename T>void die(T x){out(x); exit(0);}

random_device seed_gen; mt19937_64 mtrand(seed_gen());
constexpr int MOD = 1000000007;
using P = pair<int,int>;
//////////////////////////////////////////

int main(){
  ins(S);
  string T = "keyence";
  int l = 0 , r = 0;
  rep(i,7){
    if(S[i] != T[i]) break;
    l++;
  }
  repr(i,7){
    if(S[i + sz(S) - 7] != T[i]) break;
    r++;
  }
  out(l+r >= 7 ? "YES" : "NO");
}

Measured memory_bytes: 256
N,M=map(int, input().split())
edge=[list(map(int,input().split())) for i in range(M)]
inf=10**13
f=lambda i,j,w: [i-1,j-1,-w]
edge=[f(i,j,w) for i,j,w in edge]
def bf(N,start):
    d=[inf]*N
    d[start]=0
    prev=[-1]*N
    for i in range(N-1):
        f=0
        for i,j,w in edge:
            if d[j]>d[i]+w:
                d[j]=d[i]+w
                prev[j]=i
                f=1
        if f==0:
            break
    while True:
        f=0
        for i,j,w in edge:
            if d[j]>d[i]+w and (d[j]!=-inf or d[i]!=-inf):
                d[i]=d[j]=-inf
                f=1
        if f==0:
            break
    return d
d=bf(N,0)
if d[N-1]==-inf:
    print('inf')
else:
    print(-d[N-1])


Measured memory_bytes: 3828
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

import numpy as np
MOD = 10**9 + 7

N,K = map(int,read().split())

def cumprod(arr,MOD):
    L = len(arr); Lsq = int(L**.5+1)
    arr = np.resize(arr,Lsq**2).reshape(Lsq,Lsq)
    for n in range(1,Lsq):
        arr[:,n] *= arr[:,n-1]; arr[:,n] %= MOD
    for n in range(1,Lsq):
        arr[n] *= arr[n-1,-1]; arr[n] %= MOD
    return arr.ravel()[:L]

def make_fact(U,MOD):
    x = np.arange(U,dtype=np.int64); x[0] = 1
    fact = cumprod(x,MOD)
    x = np.arange(U,0,-1,dtype=np.int64); x[0] = pow(int(fact[-1]),MOD-2,MOD)
    fact_inv = cumprod(x,MOD)[::-1]
    return fact,fact_inv

U = 10**4
fact, fact_inv = make_fact(U,MOD)

x = np.zeros(K,np.int64)
n = min(K,N-K+1)
x[:n] = fact[N-K+1] * fact_inv[1:n+1] % MOD * fact_inv[N-K::-1][:n] % MOD
y = fact[K-1] * fact_inv[:K] % MOD * fact_inv[:K][::-1] % MOD

answer = x*y%MOD
print('\n'.join(answer.astype(str)))

Measured memory_bytes: 13140
diceA = list(map(int, input().split()))

diceB = [[1,2,3,5,4,2],[2,1,4,6,3,1],[3,1,2,6,5,1],[4,1,5,6,2,1],[5,1,3,6,4,1],[6,2,4,5,3,2]]

q = int(input())

for i in range(q):
  quest = list(map(int, input().split()))
  ans = 0
  for j in range(6):
    if quest[0] == diceA[j]:
      for k in range(6):
        if quest[1] == diceA[k]:
          for l in range(1,5):
            if diceB[j][l] == k+1:
              ans = diceB[j][l+1]
  print(diceA[ans-1])


Measured memory_bytes: 5600
n = gets.to_i
ln = gets.split.map(&:to_i)

allen = 0
i = 0
ln.each {|len|
	allen += len
}

j = 0
g = 0
while j < n
	if ln[j] < (allen - ln[j])
		g += 1
	else
		g = g
	end
	j += 1
end

if g == n
	puts "Yes"
else
	puts "No"
end

Measured memory_bytes: 1788
#include<cstdio>
#include<algorithm>

int xx[3030], yy[3030];

int main(){
    int a[8];
    for(int i = 1; i <= 6; i ++)
        scanf("%d",&a[i]);
    xx[0] = 1;
    for(int i = 1; i*a[1] <= a[6]/100; i ++)
        xx[i*a[1]] = 1;
    
    for(int i = 0; i <= a[6] / 100; i ++){
        
        if(xx[i] == 0 || xx[i] == 2)
            continue;
        for(int j = 1; j*a[2] + i <= a[6]/100; j ++)
            xx[j*a[2]+i] = 2;
    }
    
    yy[0] = 1;
    
    for(int i = 1; i*a[3] <= a[6]; i ++)
        yy[ i * a[3] ] = 1;
    
    for(int i = 0; i <= a[6] ; i ++){
        if(yy[i] == 0 || yy[i] == 2)
            continue;
        for(int j = 1; j*a[4] + i <= a[6] ; j ++)
            yy[j*a[4]+i] = 2;
    }
    
    
    double x = a[5] + 100, y = a[5];
    double rem = y / x, ans = 0;
    int ansx = a[1]*100, ansy = 0;
    
    for(int i = a[1]; i <= a[6] / 100; i ++){
        if(xx[i] == 0)
            continue;
        for(int j = a[6]; j >= 1; j --){
            if(!yy[j])
                continue;
            if(j+i*100 > a[6])
                continue;
            double tx = j + i * 100, ty = j;
            if((ty/tx) > rem)
                continue;
            
            if(ans < (ty / tx)){
                ans = ty / tx;
                ansx = j + i*100;
                ansy = j;
            }
            
            break;
        }
    }
    
    printf("%d %d",ansx, ansy);
    return 0;
}

//1 2 10 20 100 109

Measured memory_bytes: 128
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		// 文字列の入力
		String s1 = sc.nextLine();

		String[] sr1 = s1.split(" ");
		
		int n = Integer.parseInt(sr1[0]);
		int m = Integer.parseInt(sr1[1]);
		int x = Integer.parseInt(sr1[2]);

		String s2 = sc.nextLine();

		String[] sr2 = s2.split(" ");

		int count1 = 0;
		for(int i = x; i<=n; i++) {
			for(int j = 0; j<m; j++) {
				if(i == Integer.parseInt(sr2[j])) count1++;
			}
		}

		int count2 = 0;
		for(int i = x; i>=0; i--) {
			for(int j = 0; j<m; j++) {
				if(i == Integer.parseInt(sr2[j])) count2++;
			}
		}

		if(count1 <= count2) {
			// 出力
			System.out.println(count1);
		} else {
			// 出力
			System.out.println(count2);
		}
	}
}

Measured memory_bytes: 22612
#include <bits/stdc++.h>
using namespace std;
inline int read() 
{
    register int x = 0 , ch = getchar(); 
    while( !isdigit( ch ) ) ch = getchar(); 
    while( isdigit( ch ) ) x = x * 10 + ch - '0' , ch = getchar();
    return x; 
}
inline long long ll_read() 
{
    register long long x = 0 , ch = getchar(); 
    while( !isdigit( ch ) ) ch = getchar(); 
    while( isdigit( ch ) ) x = x * 10 + ch - '0' , ch = getchar();
    return x; 
}
int gcd(int a,int b)
{
    return b?gcd(b,a%b):a;
}
int lcm(int a,int b)
{
    return a*b/gcd(a,b);
}
long long turtle_muti(long long ain,long long bin,long long modn)
{
    long long res=0;
    for(;bin;bin>>=1) 
    {
        if(bin&1)
            res=(res+ain)%modn;
        ain=(ain<<1)%modn;
    }
    return res;
}
long long quick_power(long long a,long long b,long long p)
{
    long long ans=1;
    while(b)
    {
        if(b%2)
        {
            ans=ans*a%p;        
        }
        a=a*a%p;
        b=(b>>1);
    } 
}
const int maxn=20;
const long long inf=5e18;
int n;
long long a[maxn],dp[maxn][maxn][maxn][maxn];
long long solve(int l,int r,int dl,int dr)
{
    if(l+1>=r)
        return 0;
    long long res=inf;
    for(int i=l+1;i<=r-1;i++)
        res=min(res,solve(l,i,dl,dr+dl)+solve(i,r,dl+dr,dr)+a[i]*(dl+dr));
    return res;
}

signed main()
{
    n=read();
    for(int i=1;i<=n;++i)
        a[i]=ll_read();
    cout<<a[1]+a[n]+solve(1,n,1,1)<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<algorithm>
#include <cassert>
#include<string>
int main() {
	using namespace std;
	int a = 0, b = 0, c = 0, d = 0, e[10][10], f[10000], g[10000], h[10000], count = 0, x = 0, y = 0, z = 0;
	long long ab[100000], abc = 0;
	char rikka, toka[100000];
	string saya, homu, kyok, mami[100], mado[100];
	bool gg;
	cin >> a;
	for (int i = 0; i < a; i++) {
		cin >> mami[i];
	}
	
	cin >> b;
	for (int j = 0; j < b; j++) {
		cin >> mado[j];
	}
	for (int i = 0; i < a; i++) {
		for (int  j= 0; j < a; j++) {
			if (mami[i] == mami[j]) {
				count++;
			}
		}
		for (int j = 0; j < b; j++) {
			if (mami[i] == mado[j]) {
				count--;
			}
		}
		x = max(count, x);
		count = 0;
	}
	cout << x << endl;
	return 0;
}


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

const int N = 2e5 + 10;

long long s[N];

int main (void) {
	int n;
	scanf("%d", &n);
	;
	for (int i = 1; i <= n; i ++) 
		s[i] = i;
	for (int i = 1; i <= n; i ++) 
		s[i] += s[i - 1];
	for (int i = 1; i <= n; i ++) 
		s[i] += s[i - 1];
	long long ans = s[n];
	for (int i = 1, u, v; i < n; i ++) {
		scanf("%d%d", &u, &v);
		if (u > v) swap(u, v);
		ans -= 1ll * u * (n - v + 1);
	}
	printf("%lld\n", ans);
}

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

using namespace std;

int main(){
    int mod=1000000007;
    int o=0,p=0,w,h,n,x,y,a;
    scanf("%d %d %d",&w,&h,&n);
    for (int i=0;i<n;i++) {
        scanf("%d %d %d",&x,&y,&a);
        if (a==1) o=max(o,x);
        if (a==2) w=min(w,x);
        if (a==3) p=max(p,y);
        if (a==4) h=min(h,y);
    }
    printf("%d\n",max(w-o,0)*max(h-p,0));
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using uint = unsigned int;
using lint = long long int;
using ulint = unsigned long long int;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;
template<class T, class U> void assign(V<T>& v, int n, const U& a) { v.assign(n, a); }
template<class T, class... Args> void assign(V<T>& v, int n, const Args&... args) { v.resize(n); for (auto&& e : v) assign(e, args...); }


int main() {
  cin.tie(nullptr); ios_base::sync_with_stdio(false);
  int n; cin >> n;
  V<long double> p(n); for (int i = 0; i < n; ++i) cin >> p[i];
  VV<long double> dp; assign(dp, n + 1, n + 1, 0);
  dp[0][0] = 1;
  for (int k = 0; k < n; ++k) {
    for (int i = 0; i <= k; ++i) {
      int j = k - i;
      dp[i + 1][j] += dp[i][j] * p[k];
      dp[i][j + 1] += dp[i][j] * (1 - p[k]);
    }
  }
  long double res = 0;
  for (int i = 0; i <= n; ++i) {
    int j = n - i;
    if (i > j) {
      res += dp[i][j];
    }
  }
  cout << fixed << setprecision(15) << res << '\n';
}

Measured memory_bytes: 141056
#pragma GCC optimize("Ofast")
/*#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("fast-math")
#pragma GCC target("sse,sse2,sse3,ssse3,popcnt,abm,mmx,tune=native")*/
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <stdio.h>
#include <cstdio>
#include <math.h>
#include <cmath>
#include <string>
#include <cstring>
#include <queue>
#include <deque>
#include <random>
#include <iomanip>
#include <bitset>
                        
using namespace std;
                        
template<typename T> void uin(T &a, T b) {
    if (b < a) {
        a = b;
    }
}
                        
template<typename T> void uax(T &a, T b) {
    if (b > a) {
        a = b;
    }
}
  
#define int long long
#define ghost signed
#define left left228
#define right right228
#define prev prev228
#define list list228


ghost main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
	string s;
	cin >> s;
	int cnt[26];
	memset(cnt, 0, sizeof cnt);
	int res = 0;
	for (char c : s) {
		for (char p = 'a'; p <= 'z'; ++p) {
			if (p != c) {
				res += cnt[p - 'a'];
			}
		}
		++cnt[c - 'a'];
	}
	cout << res + 1 << '\n';
    return 0;
} // kek ;












Measured memory_bytes: 720
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <limits>
#include <cmath>
using namespace std;
using ll = long long;
const int INF = 1<<30;
const int MOD = (int)1e9 + 7;
const int MAX_N = (int)1e5 + 5;
#define debug(x) cout << #x << ": " << x << endl

signed main(void)
{
    int k, x; cin >> k >> x;
    if(500 * k >= x) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

/**
 * https://abc048.contest.atcoder.jp/tasks/arc064_a
 */
public class Main {

	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt(sc.next());
		int x = Integer.parseInt(sc.next());
		long[] a = new long[N];
		for(int i=0; i<N; i++){
			a[i] = Long.parseLong(sc.next());
		}
		sc.close();

		long ans = 0;
		for(int i=1; i<N; i++){
			if(a[i-1]+a[i]<=x) continue;
			long m = a[i-1]+a[i]-x;
			ans += m;
			a[i] = Math.max(0, a[i]-m);
		}
		System.out.println(ans);
	}

}


Measured memory_bytes: 48748
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <utility>
#include <queue>

using namespace std;

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

int n, m, k;
string s[1024];
int d[1024][1024];
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cin >> n >> m >> k;
    int x, y;
    for (int i = 0; i < n; ++i) {
        cin >> s[i];
        for (int j = 0; j < m; ++j) {
            if (s[i][j] == 'S') {
                s[i][j] = '.';
                x = i;
                y = j;
            }
            d[i][j] = INF;
        }
    }
    
    queue<pair<int, int> > Q;
    d[x][y] = 0;
    Q.push(make_pair(x, y));
    while (!Q.empty()) {
        pair<int, int> p = Q.front();
        Q.pop();
        int x = p.first;
        int y = p.second;
        for (int i = 0; i < 4; ++i) {
            int nx = x + dx[i];
            int ny = y + dy[i];
            if (nx < 0 || nx >= n || ny < 0 || ny >= m)
               continue;
            if (s[nx][ny] == '#')
               continue;
            if (d[nx][ny] > d[x][y] + 1) {
               d[nx][ny] = d[x][y] + 1;
               Q.push(make_pair(nx, ny));
            }
        }
    }
    
    int ans = 1000000000;
    for (int i = 0; i < n; ++i)
        for (int j = 0; j < m; ++j)
            if (d[i][j] <= k)
                ans = min(ans, 1 + (min(min(i, j), min(n-1-i, m-1-j)) + k - 1) / k);
    cout << ans << "\n";
    
    return 0;
}


Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ALL(v) v.begin(),v.end()
 
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

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

    ll n, m;
    cin >> n >> m;
    vll p(m), y(m);
    vvll a(n + 1);
    REP(i, m){
        cin >> p[i] >> y[i];
        a[p[i]].push_back(y[i]);
    }
    REP(i, n + 1) VSORT(a[i]);
    REP(i, m){
        ll s1 = p[i], s2 = lower_bound(ALL(a[p[i]]), y[i]) - a[p[i]].begin() + 1;
        ll tmp = s1, d1 = 0, d2 = 0;
        while(tmp){
            d1++;
            tmp /= 10;
        }
        tmp = s2;
        while(tmp){
            d2++;
            tmp /= 10;
        }
        REP(i, 6 - d1) cout << "0";
        cout << s1;
        REP(i, 6 - d2) cout << "0";
        cout << s2 << endl;
    }
    return 0;
}


Measured memory_bytes: 8576
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iomanip>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)

#define DEBUG

#ifdef DEBUG
#define var_dump(...) fprintf(stdout, __VA_ARGS__)
#define dump(a) cout << a << "\n";
#else
#define var_dump(...) 42
#define dump(a) 42
#endif

// https://beta.atcoder.jp/contests/abc056/tasks/abc056_b

int main() {

    int W, a, b;
    cin >> W >> a >> b;

    if ((b >= a && b <= a+W) || (b+W >= a && b+W <= a+W)) {
        cout << 0 << "\n";
        return 0;
    }

    if (b < a) {
        cout << a-(b+W) << "\n";
    }
    else {
        cout << b-(a+W) << "\n";
    }

    return 0;
}


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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  if(N == 1) {
    cout << "Hello World" << endl;
  } else {
    int a, b;
    cin >> a >> b;
    cout << a + b << endl;
  }
  return 0;
}

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

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

    int maxLoop = X/100;

    int loopCount = 0;
    int test = X%100;
    int isSuccess = 0;
    while (loopCount < maxLoop){
        loopCount++;

        test -= min(5,test);
        if (test == 0) {
            isSuccess = 1;
            break;
        }
    }

    cout << isSuccess << endl;
    return 0;
}



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

int main(){
    string s;
    cin >> s;
    bool cflag=false, fflag=false;
    int cpos=0, fpos=0;
    rep(i,s.length()){
        if(s[i]=='C'){
            cflag=true;
            cpos=i;
        }else if(s[i]=='F'){
            fflag=true;
            fpos=i;
        }
    }
    if(cflag==true&&fflag==true&&cpos<fpos){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <cmath>
#include <queue>
#include <deque>
#include <set>
#include <iomanip>
#include <utility>
using namespace std;
#define ll long long

int main() {
	int N; cin >> N;
	vector<ll> a(N);
	ll ans=0;
	for(int i=0; i<N; ++i){
	    cin >> a[i];
	    ans += abs(a[i]);
	}
	sort(a.begin(), a.end());
	int neg=-1;
	if(a[0]>0){
	    ans -= 2*a[0];
	    neg=1;
	}
	if(a[N-1]<=0){
	    ans += 2*a[N-1];
	    neg=N-1;
	}
	cout << ans << endl;
	if(neg<0){
	    neg=0;
	    while(a[neg]<=0) ++neg;
	}
	int le=0, ri=N-1;
	if(neg*2<=N){
	    ll now=a[0];
	    for(int i=0; i<N-neg*2; ++i){
	        cout << now << ' ' << a[ri] << endl;
	        now -= a[ri];
	        --ri;
	    }
	    ++le;
	    for(int i=0; i+1<neg*2; ++i){
	        if(i%2==0){
	            cout << a[ri] << ' ' << now << endl;
	            now=a[ri]-now;
	            --ri;
	        }
	        else{
	            cout << a[le] << ' ' << now << endl;
	            now=a[le]-now;
	            ++le;
	        }
	    }
	}
	else{
	    ll now=a[N-1];
	    for(int i=0; i<neg*2-N+1; ++i){
	        cout << now << ' ' << a[le] << endl;
	        now -= a[le];
	        ++le;
	    }
	    --ri;
	    for(int i=0; i+2<(N-neg)*2; ++i){
	        if(i%2==1){
	            cout << a[ri] << ' ' << now << endl;
	            now=a[ri]-now;
	            --ri;
	        }
	        else{
	            cout << a[le] << ' ' << now << endl;
	            now=a[le]-now;
	            ++le;
	        }
	    }
	}
	return 0;
}


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

int main(){
  int n;
  cin>>n;
  vector<int> place(n);
  for(int i=0;i<n;i++){
    cin>>place.at(i);
  }
  
    sort(place.begin(),place.end());
  
  cout<<place.at(n-1)-place.at(0)<<endl;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys, math, itertools, heapq, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
sys.setrecursionlimit(10**8)
inf = float('inf')
ans = count = 0

n=int(input())
Y=list(map(int,input().split()))
X=sorted(Y)
X0=X[n//2-1]
X1=X[n//2]
for i in  range(n):
    if Y[i]<=X0:
        print(X1)
    else:
        print(X0)



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

int main() {

 int N;
 cin >> N;

 vector<int> A(N),num(100005);
 for(int i = 0;i < N; i++) {
   cin >> A.at(i);
   num.at(A.at(i))++;
 }

 int maxi = 0;
 for(int i = 0;i < 100003;i++) {
   int sum = num.at(i) + num.at(i + 1) + num.at(i + 2);
   maxi = max(maxi,sum);
 }

cout << maxi << endl;

 

}

Measured memory_bytes: 1024
from collections import Counter

N = int(input())

A = []
for _ in range(N):
    A.append(input().strip())

dic = Counter(A)

B = []
for a, c in dic.items():
    B.append((a,c))

B.sort(key=lambda x:x[0])
B.sort(key=lambda x:x[1],reverse=True)

r = B[0][1]
for b in B:
    p, q = b
    if q < r:
        exit()
    print(p)

Measured memory_bytes: 150464
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef vector<vector<int> > vvi;
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<string, int> psi;
typedef pair<int, int> pii;
#define rep(i,s,n) for(int i = (s); i < (n); i++)
#define loop(i) for(int i = 0;true; i++)
#define all(x) (x).begin(), (x).end()
#define yn(f) (f?"yes":"no")
#define YN(f) (f?"YES":"NO")
#define Yn(f) (f?"Yes":"No")
#define mn 1000000007
#define INT32_MAX 2147483647

int main() {
	int N;
	cin >> N;
	vvi A(N,vi(N));
	for (int i = 0; i < N; i++)
	{
		for (int j = 0; j < N; j++)
		{
			cin >> A[i][j];
			if (A[i][j] == -1)A[i][j] = INT32_MAX;
		}
	}
	vi used(N, 0);
	vi mincost(N,INT32_MAX);
	int total = 0;
	mincost[0] = 0;
	while (true) {
		int minIndex = -1;
		for (int u = 0; u < N; u++) {
			if (used[u]==0 && (minIndex == -1 || mincost[u] < mincost[minIndex])) minIndex = u;
		}
		if (minIndex == -1) break;
		used[minIndex] = 1;
		total += mincost[minIndex];
		for (int u = 0; u < N; u++)
		{
			mincost[u] = min(mincost[u], A[minIndex][u]);
		}
	}
	cout << total << endl;
};



Measured memory_bytes: 3160
#include <iostream>
#include <iomanip>
#include <cstring>
#include <algorithm> 
#include <math.h>
#include <queue>
#include <functional>
#include <map>
#include <vector>
#include <string>
#include <set> 
using namespace std;

typedef long long ll;
typedef pair<ll, int> P;
typedef pair<pair<int, int>, int> PP;

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

const ll INF = 1e15;
const ll MAX = 510000;
const ll MOD = 1000000007;


int main(void) {
    string S,T;cin>>S>>T;
    int ans =0;
    if(S[0]==T[0]) ans++;
    if(S[1]==T[1]) ans++;
    if(S[2]==T[2]) ans++;
    cout<<ans<<endl;
}


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

main(){
	int a,b;
	do{
		cin >>a >>b;
		if(a<=b && b!=0){
			cout << a << " " << b << "\n";
		}
		else if(b<a){
			cout << b << " " << a << "\n";
		}		
	}while(a!=0||b!=0);
}

Measured memory_bytes: 1164
h, w = gets.split.map(&:to_i)
ss = h.times.map { gets.chomp.chars }

ans = Array.new(h) { Array.new(w, 0) }

h.times do |i|
  w.times do |j|
    if ss[i][j] == "#"
      ans[i][j] = ss[i][j]
      next
    end

    l = j - 1 < 0 ? j : j - 1
    r = j + 1 > w ? j : j + 1
    count = 0

    if i - 1 >= 0
      count += ss[i - 1][l..r].count("#")
    end

    count += ss[i][l..r].count("#")

    if i + 1 <= h - 1
      count += ss[i + 1][l..r].count("#")
    end

    ans[i][j] = count
  end
end

ans.each { |a| puts a.join }


Measured memory_bytes: 2172
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <complex>
#include <vector>
#include<limits>
#include<iomanip>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;

const long double pi = 3.141592653589793;

#define debug(x) cout << #x << " = " << (x) << endl;
#define rep(i, n) for(int i = 0;i < n;i++)
#define repi(i, j, n) for(int i = j;i < n;i++)
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define F first
#define S second

// #define COMMENT

/*

const int NN = 200090;
ll fact[NN];
ll finv[NN];
ll inv[NN];

void inverse_modulao() {
  fact[0] = fact[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;

  for(int i = 2;i < NN;i++) {
    fact[i] = fact[i-1]*i%mod;
    inv[i] = mod-mod/i*inv[mod%i]%mod;
    finv[i] = finv[i-1]*inv[i]%mod;
  }
}

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

*/

int h1,m1,h2,m2,k;

int main() {

  //freopen("input.in","r",stdin);
 // freopen("output.out","w",stdout);

  cin>>h1>>m1>>h2>>m2>>k;
  cout<<(h2*60+m2)-(h1*60+m1)-k;

  return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define f first
#define s second
#define pb push_back
#define mk make_pair
#define MOD 1000000007
#define fo(i,a,b) for(i=a;i<b;i++)
#define foe(i,a,b) for(i=a;i<=b;i++)
#define boost ios::sync_with_stdio(false); cin.tie(0)
using namespace std;
int v[105], w[105];
ll dp[105][100005];
int main()
{
	boost;
	int n, W, i, j;
	cin >> n >> W;
	foe(i, 1, n)
	cin >> w[i] >> v[i];
	
	foe(i, 0, n)
	{
		foe(j, 0, W)
		dp[i][j] = 0;
	}
	
	foe(i, 1, n)
	{
		foe(j, 1, W)
		dp[i][j] = max(dp[i - 1][j], (j >= w[i] ? dp[i - 1][j - w[i]] + v[i] : 0));
	}
	cout << dp[n][W];
}

Measured memory_bytes: 80128
import sys
N = input()
p_t, p_x, p_y = 0, 0, 0
for _ in range(N):
    c_t, c_x, c_y = map(int, raw_input().split())
    if not c_t - p_t >= abs(c_x - p_x) + abs(c_y - p_y) or \
        not (c_t - p_t) % 2 == (abs(c_x - p_x) + abs(c_y - p_y)) % 2:
        print "No"
        sys.exit()
    p_t, p_x, p_y = c_t, c_x, c_y
print "Yes"


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

int main() {
    int N, M;
    cin >> N >> M;
    vector<int> cnt(N + 1);
    for (int i = 0; i < M; i++) {
        int a, b;
        cin >> a >> b;
        cnt[a]++; cnt[b]++;
    }

    for (int i = 1; i <= N; i++) {
        if (cnt[i] % 2) {
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define IFOR(i, m, n) for (ll i = n - 1; i >= m; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define FOREACH(x, a) for (auto&(x) : (a))
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

int main() {
  int n;
  cin >> n;
  vector<ll> a(n);
  REP(i, n) { cin >> a[i]; }
  sort(ALL(a));
  ll sum = 0;
  REP(i, n - 1) { sum += a[i]; }

  cout << (sum > a[n - 1] ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define endl "\n"
const int maxx = 2e5 + 5;
//int a[101];
 
/*bool cmp(pair<int , int>p ,pair<int , int >q ){
	if(p.second == q.second){
		return p.first > q.first;
	}
	else{
		return p.second > q.second;
	}
} 
*/
 
 
int main(){
	#ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output.txt", "w", stdout);
#endif 
       ios_base::sync_with_stdio(false);  
       cin.tie(0);
ll n,d, x, y, cnt = 0;
cin>>n>>d;  
for (int i = 0; i < n; ++i)     
{
	 cin>>x>>y;
	 double s = sqrt((x)*(x) + (y)*(y));
	 if(s <= d){
	 	cnt++;  
	 }
}   
cout<<cnt<<endl;
}

Measured memory_bytes: 3692
import java.util.Scanner;

public class Main {
	public static void main(String arg[]) {

		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		int L = sc.nextInt();

		int a[] = new int[N];
		int sum = 0;

		for (int i = 0; i < N; i++) {
			a[i] = L + i;
			sum += a[i];
		}

		if (a[0] > 0) {
			System.out.print(sum - a[0]);
		} else if (a[N - 1] < 0) {
			System.out.print(sum - a[N - 1]);
		} else {
			System.out.print(sum);
		}

	}
}


Measured memory_bytes: 23124
#include <bits/stdc++.h>
#include <stdio.h>
#include<iostream>
#include<cstdio>
#include<bitset>
#include<algorithm>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<string>
#include<string.h>
#include<cmath>
#include<utility>
#include<functional>
#include<map>
#include<set>
#include<cctype>
#include<fstream>
#include <numeric>
#include <iomanip>
#include <cstring> 
using namespace std;
using ll=long long;

#define FOR(i, a, b) for( int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for( int i=(a);i>=(b);i--)
#define LFOR(i, a, b) for( long long int i=(a);i<=(b);i++)
#define LRFOR(i, a, b) for(long long int i=(a);i>=(b);i--)
#define MOD 1000000007
#define LLONG_MAXs 9223372036854775800

#define ALL(a) (a).begin(),(a).end()

#include <iostream>
#include <cmath>
using namespace std;
 

 
bool isPrimeNum( ll x ){ // 素数である場合 true を返す
  if( x <= 1 ){ // 1以下である場合は素数でないことがすぐにわかる
    return false;
  }
  // sqrt( double型 ) は引数の平方根を double型で返すので、int型でキャスト
  int n = (int)sqrt( (double)x );
  for( int i = 2; i <= n; i++ ){
    if( x % i == 0 ){ // 割り切る整数がある場合、即判定終了
      return false;
    }
  }
  return true; // 割り切る整数がない場合、素数である
}

ll myPow(ll x, ll n, ll m){
  if(n == 0)
    return 1;
  if(n % 2 == 0)
    return myPow(x * x % m, n / 2, m);
  else
    return x * myPow(x, n - 1, m) % m;
}

constexpr ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
constexpr ll lcm(ll a,ll b){return a*b/gcd(a,b);}
constexpr ll abs(ll a,ll b){
if(a>=b)return a-b;
if(a<b)return b-a;
}
constexpr ll min(ll a,ll b){
if(a>=b)return b;
if(a<b)return a;
}

constexpr ll max(ll a,ll b){
if(a>=b)return a;
if(a<b)return b;
}

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

class UnionFind {
public:
	//親の番号を格納する。親だった場合は-(その集合のサイズ)
	vector<int> Parent;
 
	//作るときはParentの値を全て-1にする
	//こうすると全てバラバラになる
	UnionFind(int N) {
		Parent = vector<int>(N, -1);
	}
 
	//Aがどのグループに属しているか調べる
	int root(int A) {
		if (Parent[A] < 0) return A;
		return Parent[A] = root(Parent[A]);
	}
 
	//自分のいるグループの頂点数を調べる
	int size(int A) {
		return -Parent[root(A)];//親をとってきたい]
	}
 
	//AとBをくっ付ける
	bool connect(int A, int B) {
		//AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
		A = root(A);
		B = root(B);
		if (A == B) {
			//すでにくっついてるからくっ付けない
			return false;
		}
 
		//大きい方(A)に小さいほう(B)をくっ付けたい
		//大小が逆だったらひっくり返しちゃう。
		if (size(A) < size(B)) swap(A, B);
 
		//Aのサイズを更新する
		Parent[A] += Parent[B];
		//Bの親をAに変更する
		Parent[B] = A;
 
		return true;
	}
};




long long fac[510000], finv[510000], inv[510000];

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

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


int main() {
  // 前処理
  COMinit();

  ll R,G,B,N;
  cin>>R>>G>>B>>N;
  ll ans=0;

  FOR(i,0,3000){
    FOR(j,0,3000){
      ll nokori = N-i*R-j*G;

      if(nokori>=0 && nokori%B==0)ans++;

    }
  }


  cout<<ans<<endl;

  return 0;
 
}


Measured memory_bytes: 12160
n, k = map(int, input().split())

MOD = 10**9+7
n += 1
ans = 0
for i in range(k, n+1):
    p = i*(2*n - (i-1)) // 2
    m = i*(2 + i-1) // 2
    ans += p - m + 1
print(ans % MOD)

Measured memory_bytes: 63396
#include<bits/stdc++.h>
#define int long long
using namespace std;
signed main(){
  int N,K;
  cin>>N>>K;
  vector<int> P(N),C(N);
  for(int &i:P){
    cin>>i;
    i--;
  }
  for(int &i:C)cin>>i;
  int ans=-1000000000;
  for(int i=0;i<N;i++){
    vector<bool> B(N,true);
    int cnt=0,s=0;
    for(int j=i;B[j];j=P[j],cnt++)B[j]=false,s+=C[j];
    if(s>0){
      int n=0,mx=0;
      int j=P[i],m=0;
      for(;m<K%cnt;j=P[j],m++)n+=C[j],mx=max(mx,n+K/cnt*s);
      for(;m<cnt;j=P[j],m++)n+=C[j],mx=max(mx,n+(K/cnt-1)*s);
      ans=max(ans,mx);
    }else{
      for(int n=0,j=P[i],m=0;n<K && n<cnt;j=P[j],n++)m+=C[j],ans=max(ans,m);
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3708
#include <iostream>
#include <cmath>
#include <stdint.h>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
using namespace std;
 
#define int long long
#define INF (1e18)+1
 
int nChoosek( int n, int k )
{
    if (k > n) return 0;
    if (k * 2 > n) k = n-k;
    if (k == 0) return 1;

    int result = n;
    for( int i = 2; i <= k; ++i ) {
        result *= (n-i+1);
        result /= i; 
    }
    return result;
}

int choose2(int n){
	
	return n*(n-1)/2;
}


double expectedValue(int value){
	double sum = 0;
	double div = 1.0 / value;
	for(int i=1; i<=value; i++){	
		sum = sum + (i*div);
	}
	return sum;
}
 int arr[200001];
int32_t main() {
 
   int N,K;
   
   cin >> N >>K ;
   
   for(int i=0; i<N; i++){
   	
   		cin >> arr[i];
   	
   }
   
    int maxi = 0;
    int index = 0;
   for(int i=0; i<N; i++){
   		int sum = 0;
   		if(i+K > N){
   			break;
		}
   		for(int j=0; j<K; j++){
   			
		   	sum+= arr[i+j];
   			
		}
   		if(sum > maxi){
   			maxi = sum;
   			index = i;
		}
   } 
  // cout << index << endl;
    double ans = 0;
 	for(int i = 0; i < K; i++){
 		
 		ans += expectedValue(arr[i+index]);
 		
	 }
 	cout << fixed << setprecision(12) <<  ans << endl;
}

Measured memory_bytes: 4772
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
int main() {
	int n, k;
	cin >> n >> k;
	vector<int> l(n);
	for (int i = 0; i<n; i++) {
		cin >> l[i];
	}
	sort(l.begin(), l.end());
	int s = 0;
	for (int i = 0; i<k; i++) {
		s+= l[n - 1 - i];
	}
	cout << s << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    string N;
  cin >> N;
  int c = 0;
  if(N[0] == '7'){c++ ;};
  if(N[1] == '7'){c++ ;};
  if(N[2] == '7'){c++ ;};
  if(c == 0){
  cout << "No" << endl;
  }else{
  cout << "Yes" << endl;};
}

Measured memory_bytes: 3624
import time
import random

def calc(D, C, S, T):
    s = 0
    l = [-1] * len(C)
    for d, t in enumerate(T):
        s += S[d][t]
        s -= C[t] * (d - l[t]) * (d - l[t] - 1) // 2
        l[t] = d
    s -= sum(c * (d - l[i]) * (d - l[i] + 1) // 2 for i, c in enumerate(C))
    return s

def main():
    start = time.time()
    D = int(input())
    C = list(map(int, input().split()))
    S = [list(map(int, input().split())) for _ in range(D)]
    
    M = [0] * 26

    P = []
    
    for d in range(D):
        for i in range(26):
            M[i] += C[i]
        T = [m + s for m, s in zip(M, S[d])]
        i = T.index(max(T))
        M[i] = 0
        P.append(i)

    Sc = calc(D, C, S, P)
    while time.time() - start <= 1.8:
        d = random.randrange(D)
        q = random.randrange(26)
        if P[d] == q:
            continue
        old = P[d]
        P[d] = q
        Sn = calc(D, C, S, P)
        if Sn <= Sc:
            P[d] = old
        else:
            Sc = Sn
    return P

p = main()
print('\n'.join(str(i + 1) for i in p))


Measured memory_bytes: 81228
#include <iostream>
#include <string> 
#include <vector> 
#include <algorithm> 
#include <utility> 
#include <tuple> 
#include <cstdint> 
#include <cstdio> 
#include <map> 
#include <queue> 
#include <set> 
#include <stack> 
#include <deque> 
#include <unordered_map> 
#include <unordered_set> 
#include <bitset> 
#include <cctype> 
#include<math.h>
using namespace std;

#define int long long
#define endl "\n"
#define fir first
#define sec second
#define fro front
#define m_p make_pair
#define mod 1000000007
#define all(v)  v.begin(),v.end()
#define rep(i,n)  for(int i=0; i<(int) (n); i++)
#define all(v)  v.begin(),v.end()
#define vecin(v) for(int i=0; i<(int)v.size(); i++)cin>>v[i];
using namespace std;

const int MAX = 510000;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];
int jousu(int x00, int y00) {
	int z00 = 1;
	for (int i = 0; i < y00; i++) {
		z00 *= x00;
	}
	return z00;
}
int keta(int x00) {
	int z00 = x00;
	int w00 = 0;
	while (z00 != 0) {
		z00 /= 10;
		w00++;
	}
	return w00;
}

int modinv(int a, int m) {
	int b = m, u = 1, v = 0;
	while (b) {
		int t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
int modpow(int a, int n) {
	int res = 1;
	while (n > 0) {
		if (n & 1) res* a% mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}
int gcd(int xx, int yy) {
	int p = xx;
	int q = yy;
	if (q > p)swap(p, q);
	while (p % q != 0) {
		p %= q;
		swap(p, q);
	}
	return q;
}
int lcm(int xx, int yy) {
	return xx * yy / gcd(xx, yy);
}
bool prime(int xx) {
	int a = xx;
	for (int i = 2; i * i <= xx; i++) {
		if (xx % i == 0) {
			return 0;
		}
	}
	return 1;
}
int com(int xx, int yy) {
	int zz = 1;
	for (int i = xx; i > xx - yy; i--) {
		zz *= i;
		zz %= mod;
	}
	for (int i = 1; i <= yy; i++) {
		zz *= modinv(i, mod);
		zz %= mod;
	}
	return zz;
}



signed main() {
	int n, a, ans=1;
	map<int, int>m;
	m[-1] = 3;
	cin >> n;
	rep(i, n) {
		cin >> a;
		ans *= (m[a - 1] - m[a]);
		if (!m.count(a)) {
			m[a] = 1;
		}
		else m[a]++;
		ans %= mod;
	}
	cout << ans;
}


Measured memory_bytes: 6528
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <cmath>
#include <string>
using namespace std;
typedef vector<int> vint;
typedef vector<long long> vll;
typedef pair<int,int> pint;
typedef long long ll;
#define range(i,a,b) for(int i=a;i<b;++i)
#define rep(i,n) range(i,0,n)
#define INF 10000000000 //10^10
#define PI 3.141592

int main(){
    int N;
    string S;
    cin >> N >> S;
    int cnt=0;
    int r=0;
    range(i,1,N) if(S[i]=='E') ++cnt;
    int minn=cnt;
    range(i,1,N){
        if(S[i-1]=='W') ++cnt;
        if(S[i]=='E') --cnt;
        minn=min(minn,cnt);
    }
    cout << minn << endl;
}


Measured memory_bytes: 888
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<string>
#include<queue>
#include<cmath>

using namespace std;
int m[110],n,x,ans;

int main()
{
	scanf("%d%d",&n,&x);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&m[i]);
	}
	sort(m+1,m+1+n);
	for(int i=1;i<=n;i++)
	{
		if(x>=m[i])
		{
			x-=m[i];
			ans++;
		}
		else break;
	}
	ans+=x/m[1];
	printf("%d",ans);
	return 0;
}

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

using namespace std;

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

	vector<int> a(n);
	int r = -1, g = -1, b = -1;
	long long ans = 1;
	int t = 0;
	int s = 0;

	for (int i = 0; i < n; i++) {
		t = 0;
		s = 0;

		cin >> a[i];

		if (a[i] - 1 == r) {
			t += 1;
			s++;
		}
		if (a[i] - 1 == g) {
			t += 2;
			s++;
		}
		if (a[i] - 1 == b) {
			t += 4;
			s++;
		}

		ans *= s;
		ans %= 1000000007;
		
		if ((t & 1) == 1) {
			r++;
		}
		else if ((t & 2) == 2) {
			g++;
		}
		else if((t & 4) == 4){
			b++;
		}
	}
		
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
// __builtin_ctz : no of trailing zeros
#define ll long long
#define pp pair<ll,ll>
#define mod 1000000007
#define trace(x) cerr<<#x<<": "<<x<<" "<<endl
#define trace2(x, y) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z) cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define sa(a,n) for(int i =0 ; i<n ; i++) cin>>a[i]
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define scan() int n; cin>>n ; int 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;
ll max(ll x, ll y)
{
    return x>y ? x : y;
}
ll min(ll x, ll y)
{
    return x<y ? x : y;
}
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n;cin >> n;ll a[n];set<ll> s;
    for (int i = 0; i < n; ++i)
    {
    	cin >> a[i];s.insert(a[i]);
    }
    if(s.size()==n)cout << "YES";
    else cout <<"NO";
    }

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

int main(){
    string s;
    cin>>s;
    if(s[2]!=s[3]){
        cout<<"No"<<endl;
        return 0;
    }
    if(s[4]!=s[5]){
        cout<<"No"<<endl;
        return 0;
    }
    cout<<"Yes"<<endl;
    return 0;
}

Measured memory_bytes: 256
//#define LOCAL
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<string>
#include<math.h>
#include<map>
#include<random>
using namespace std;
using lld = long long int;
using llu = unsigned long long int;
using pii = pair<int, int>;
using pli = pair<lld, int>;
using pil = pair<int, lld>;
using pll = pair<lld, lld>;
using piii = pair<pii, pii>;
using pdii = pair<int, pii>;
int n, m, q;
int a[109];
piii b[109];
int res = 0;
vector<pdii> v[109];
void dfs(int dep, int si, int score)
{
	if (dep == n + 1) {
		if (res >= score)return;
		res = score;
		return;
	}
	for (int i = si; i <= m; i++) {
		a[dep] = i;
		int sum = 0;
		for (int j = 0; j < v[dep].size(); j++) {
			if (a[dep] - a[v[dep][j].first] == v[dep][j].second.first) {
				sum += v[dep][j].second.second;
			}
		}
		dfs(dep + 1, i, score + sum);
	}
}
int main() {
	int i, j, k, l;
	int t = 1, tv = 0;
	while (t--) {
		scanf("%d %d %d", &n, &m, &q);
		for (i = 0; i < q; i++) {
			scanf("%d %d %d %d", &b[i].first.first, &b[i].first.second, &b[i].second.first, &b[i].second.second);
			v[b[i].first.second].push_back(pdii(b[i].first.first, b[i].second));
		}
		res = 0;
		dfs(1, 1, 0);
		printf("%d\n", res);
	}
}

Measured memory_bytes: 3264
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int k,n,i;
	cin>>k>>n;
	int a[n+2];
	a[n+1]=k;
	a[0]=0;
	for(i=1;i<n+1;i++)
	cin>>a[i];
	int mx=0;
	mx=a[1]-a[0]+a[n+1]-a[n];
	for(i=1;i<n;i++)
	{
		
		mx=max(mx,a[i+1]-a[i]);
	}
cout<<(k-mx);
}


Measured memory_bytes: 4356
#coding:utf-8
#余りが0になった時点で以降の処理をやめる
import math
l, r = map(int, input().split())
ans = 2018

for i in range(l, r+1):
    for j in range(i+1, r+1):
        mod = (i * j) % 2019
        if mod < ans:
            ans = mod
        if mod == 0:
            ans = 0
            break
    else:
    #最小値が入れ替わらない、もしくは0が出なかった場合は次の数と比較
        continue
    break

print(ans)

Measured memory_bytes: 3060
#include<iostream>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<queue>
#include<cstring>
#include<cmath>
#include<cstdio>
#include<cstdlib>
using namespace std;
#define REP(i,a,n) for(int i = a ; i < n ; i++)
#define rep(i,n) REP(i,0,n)

typedef long long ll;

int dp[100000][11];

int main(){
  char s[100000];

  while(scanf("%s",s),s[0]!='0'){
    int n = strlen(s);
    memset(dp,0,sizeof(dp));
    rep(i,n) if(s[i] != '0') dp[i][s[i]-'0'] = 1;

    rep(i,n-1){
      rep(j,11){
        if(dp[i][j] == 0) continue;
        int idx = ((s[i+1] - '0') + j * 10) % 11;
        dp[i+1][idx] += dp[i][j];
      }
    }

    int ans = 0;
    rep(i,n) ans += dp[i][0];
    cout<<ans<<endl;
  }
}

Measured memory_bytes: 5268
#define _DEBUG 1

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

using ll = long long;

const long long MOD = 2;

#ifdef _DEBUG
#define dump(x) cerr << #x << "=" << x << endl
#define dump2(x, y) cerr << #x << "=" << x << "," << #y << "=" << y << endl
#define dump3(x, y, z)                                                         \
  cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z     \
       << endl
#define check(s) cerr << s << endl
#else
#define dump(x)
#define dump2(x, y)
#define dump3(x, y, z)
#define check(s)
#endif

#define rep(i, n) for (ll i = 0; i < (int)(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());

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

void solve(ll N, ll M, vector<ll> k, vector<vector<ll>> s, vector<ll> p) {
  ll result = 0;
  ll upper = pow(2, N);
  for (int tmp = 0; tmp < (1 << 10); tmp++) {
    bitset<10> bs(tmp);
    if (bs.to_ullong() >= upper)
      break;

    bool patternExist = true;
    rep(i, M) {
      ll onCount = 0;
      rep(j, k.at(i)) {
        ll n = s.at(i).at(j) - 1;
        if (bs.test(n))
          onCount++;
      }
      patternExist = patternExist && onCount % 2 == p.at(i);
      if (!patternExist)
        break;
    }

    if (patternExist)
      result++;
  }

  cout << result << endl;
}

int main() {
  ll N, M;
  cin >> N >> M;
  vector<ll> k(M);
  vector<vector<ll>> s(M, vector<ll>(N));
  vector<ll> p(M);

  rep(i, M) {
    cin >> k.at(i);
    rep(j, k.at(i)) { cin >> s.at(i).at(j); }
  }
  rep(i, M) { cin >> p.at(i); }

  solve(N, M, move(k), move(s), move(p));

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define m_p make_pair
#define p_b push_back
#define e_b emplace_back
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
using namespace std;
using ll = long long;
using ld = long double;
template<class T> bool chmax(T &a,T b){if(a<b){a=b;return true;}return false;}
template<class T> bool chmin(T &a,T b){if(a>b){a=b;return true;}return false;}

int main(){
  ios_base::sync_with_stdio(false);cin.tie(0);
  int N;
  cin >> N;

  if(N%1000==0) cout << 0 << endl;
  else  cout << 1000-N%1000 << endl;

  return 0;
}


Measured memory_bytes: 3612