akhauriyash/Code-Regression huggingface dataset:
#include<algorithm>
#include<iostream>
#include<vector>
#include<string>
#define rep(i, start, end) for (int i = (int)start; i < (int)end; ++i)
#define rrep(i, start, end) for (int i = (int)start - 1; i >= (int)end; --i)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
template<typename T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return 0;}
template<typename T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return 0;}

using P = pair<int, char>;

const int INF = 1 << 30;
const string dir = "ULDR";

void rotate(int N, vector<int>& X, vector<int>& Y, vector<char>& U) {
    int min_x = INF;
    rep(i, 0, N) {
        int tmp = X[i];
        X[i] = -Y[i];
        Y[i] = tmp;
        rep(j, 0, 4) {
            if (U[i] == dir[j]) {
                U[i] = dir[(j + 1) % 4];
                break;
            }
        }
        chmin(min_x, X[i]);
    }
    if (min_x < 0) {
        rep(i, 0, N) {
            X[i] -= min_x;
        }
    }
}

int calcMinSec(int N, const vector<int>& X, const vector<int>& Y, const vector<char>& U) {
    int res = INF;
    // 同じ向き
    vector<vector<P>> same_dirs(202020);
    rep(i, 0, N) {
        if (U[i] == 'U' || U[i] == 'D') {
            same_dirs[X[i]].emplace_back(Y[i], U[i]);
        }
    }
    rep(i, 0, 202020) {
        sort(all(same_dirs[i]));
        rep(j, 1, same_dirs[i].size()) {
            if (same_dirs[i][j - 1].second == 'U' && same_dirs[i][j].second == 'D') {
                chmin(res, (same_dirs[i][j].first - same_dirs[i][j - 1].first) * 5);
            }
        }
    }
    // 90度回転
    vector<vector<P>> rotate_dirs(404040);
    rep(i, 0, N) {
        if (U[i] == 'U' || U[i] == 'R') {
            rotate_dirs[X[i] + Y[i]].emplace_back(Y[i], U[i]);
        }
    }
    rep(i, 0, 404040) {
        sort(all(rotate_dirs[i]));
        rep(j, 1, rotate_dirs[i].size()) {
            if (rotate_dirs[i][j - 1].second == 'U' && rotate_dirs[i][j].second == 'R') {
                chmin(res, (rotate_dirs[i][j].first - rotate_dirs[i][j - 1].first) * 10);
            }
        }
    }
    return res;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<int> X(N), Y(N);
    vector<char> U(N);
    rep(i, 0, N) {
        cin >> X[i] >> Y[i] >> U[i];
    }
    int ans = INF;
    rep(i, 0, 4) {
        chmin(ans, calcMinSec(N, X, Y, U));
        rotate(N, X, Y, U);
    }
    if (ans == INF) {
        cout << "SAFE" << endl;
    } else {
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 31596
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

avail = []
need = 0
res = 0
sumA = 0
sumB = 0

for i in range(N):
	sumA += A[i]
	sumB += B[i]
	if A[i] > B[i]:
		avail.append(A[i] - B[i])
	if A[i] < B[i]:
		need += B[i] - A[i]
		res += 1

if sumA < sumB:
	print(-1)

else:
	avail.sort(reverse=True)
	avail.append(0)
	for i in avail:
		if need <= 0:
			print(res)
			break
		res += 1
		need -= i

Measured memory_bytes: 19068
import Data.Int (Int64)
import Data.List (foldl')

type VoteRatio a = (a, a)

divCeil :: Integral a => a -> a -> a
divCeil a b = flip div b $ a + b - 1

computeMinSum :: Integral a => [VoteRatio a] -> a
computeMinSum = uncurry (+) . foldl' f (1, 1)
    where f (x, y) (t, a) =
            let n = max (divCeil x t) (divCeil y a) in (n * t, n * a)

readInt64 :: String -> Int64
readInt64 = read

main :: IO ()
main = do
    _ <- getLine
    print . computeMinSum . fmap ((\[t, a] -> (t, a)) . fmap readInt64 . words) . lines =<< getContents


Measured memory_bytes: 1532
//AtCoder ABC061 C - Big Array
    #include <bits/stdc++.h>
    using namespace std;
    using ll=int64_t;

    int main() {
        ll N,K;
        cin>>N>>K;
        vector<pair<int,int>> arr(N);
        for(auto&& a:arr){
            cin>>a.first>>a.second;
        }
        sort(arr.begin(),arr.end());
        ll tmp=0;
        int ans=0;
        for(const auto& a:arr){
            tmp += a.second;
            if(tmp>=K){
                ans=a.first;
                break;
            }
        }
        cout<<ans<<endl;
        return 0;
    }

Measured memory_bytes: 1024
#include <iostream>
#include <bits/stdc++.h>
#define ll long long
#define inf 100000000
#define mod 1000000007
#define ld long double
#define point complex<double>
#define pi  acos(-1)
#define IO                    \
	ios_base::sync_with_stdio(false); \
	cin.tie(NULL);                    \
	cout.tie(NULL);
using namespace std;
vector<int>graph[200000+5];
ll val[200000+5]={};
bool viss[200000+5];
ll solve(int cur)
{
	ll tmp=val[cur]%mod;
	if(viss[cur])return 1;
	viss[cur]=1;
	for(auto v:graph[cur])
	{
		tmp*=solve(v)%mod;;
		tmp%=mod;
	}
	 tmp%=mod;
	 return tmp;

}
int main()
{
    IO
	int n,k;
	cin>>n>>k;
	int a,b;
	for(int i=0;i<n-1;i++)
	{
		cin>>a>>b;
		a--;
		b--;
		graph[a].push_back(b);
		graph[b].push_back(a);
	}
	queue<int>q;
	val[0]=k;
	bool vis[n]={};
	q.push(0);
	int cnt=1;
	
	while(q.size())
	{
		int cur=q.front();
		q.pop();
		if(vis[cur]==1)continue;
		vis[cur]=1;
		if(cur==0)cnt=1;
		else cnt=2;
		for(auto g:graph[cur])
		{
			if(vis[g]==0)
			{
				val[g]=k-cnt;
				cnt++;
				q.push(g);
				if(val[g]==0)
				{
					cout<<0<<endl;
					return 0;
				}
			}
		}
	}

	cout<<solve(0);


    return 0;
}


Measured memory_bytes: 12544
#include <bits/stdc++.h>
using  namespace std;
typedef long long ll;
bool check(ll n){
    bool flag = true;
    for(ll i=2;i*i<n;i++){
        if(n%i==0){
            flag = false;
            break;
        }
    }
    return flag;
}
int main(){
    ll ans;
    cin >> ans;
    while(!check(ans)){
        ans++;
    }
  	cout << ans << endl;
    return 0;
 
}


Measured memory_bytes: 256
//FA専用
#include <bits/stdc++.h>
using namespace std;
#define int long long
const long long LINF=1e18;
using ld=long double;
template<typename T>
void chmax(T &a,T b){
  if(a<b)a=b;
}
template<typename T>
void chmin(T &a,T b){
  if(a>b)a=b;
}
template<typename T>
void fin(T a){
  cout<<a<<endl;
  exit(0);
}

signed main(){
  int k,n;cin>>k>>n;
  vector<int> v(n);
  for(int i=0;i<n;i++)cin>>v[i];
  int mn=0;
  for(int i=0;i<n-1;i++)chmax(mn,v[i+1]-v[i]);
  chmax(mn,k-v[n-1]+v[0]);
  cout<<k-mn<<endl;
}


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

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

  int hyaku = a / 100;
  int zyuu = a % 100 / 10;
  int ichi = a % 10 / 1;

  if (hyaku == ichi) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=1e6+3;
int num[N];
int main(){
	int n,x;
	cin>>n;
	int z=0;
	for(int i=1;i<=n;i++){
		cin>>x;
		num[x]++;
		z=__gcd(z,x);
	}
	if(z!=1){
		cout<<"not coprime"<<endl;
		return 0;
	}
	
	for(int i=2;i<N;i++){
		int cnt=0;
		for(int j=i;j<N;j+=i){
			cnt+=num[j];
		}
		if(cnt>1) {
			cout<<"setwise coprime"<<endl;
			return 0;
		}
	}
	cout<<"pairwise coprime"<<endl;
	return 0;
}

Measured memory_bytes: 7564
# include<bits/stdc++.h>
using namespace std;
# define lowbit(x) ((x)&(-x))
# define pi acos(-1.0)
# define eps 1e-8
# define MOD 1000000007
# define INF 1000000000
# define mem(a,b) memset(a,b,sizeof(a))
# define FOR(i,a,n) for(register int i=a; i<=n; ++i)
# define FDR(i,a,n) for(register int i=a; i>=n; --i)
# define AU(i,x)    for(auto i=x.begin(); i!=x.end(); ++i)
# define ALL(A) A.begin(),A.end()
# define bug puts("H");
# define lch p<<1,l,mid
# define rch p<<1|1,mid+1,r
# define mp make_pair
# define pb push_back
typedef pair<int,int> PII;
typedef vector<int> VI;
# pragma comment(linker, "/STACK:1024000000,1024000000")
typedef long long LL;
inline char nc(){
    static char buf[1000000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,1000000,stdin),p1==p2)?EOF:*p1++;
}
inline int Scan(){
    char ch=nc();int sum=0, f=1;
    if (ch=='-') f=-1, ch=nc();
    while(!(ch>='0'&&ch<='9'))ch=nc();
    while(ch>='0'&&ch<='9')sum=sum*10+ch-48,ch=nc();
    return sum*f;
}
int ps4[4][2]={0,1,0,-1,1,0,-1,0};
int ps8[8][2]={0,1,0,-1,1,0,-1,0,1,1,1,-1,-1,-1,-1,1};
inline int min(int a,int b,int c) {return min(a,min(b,c));}
inline int max(int a,int b,int c) {return max(a,max(b,c));}
inline int min(int a,int b,int c,int d){return min(min(a,b,c),d);}
inline int max(int a,int b,int c,int d){return max(max(a,b,c),d);}
//struct Edge{int p, next, w;}edge[maxn];
//inline add_edge(int u, int v, int w){edge[cnt]=Edge{v,head[u],w}; head[u]=cnt++;}
const int N=100005;
///Code begin..................................................................


int main ()
{
    int a, b, c;
    scanf("%d%d%d",&a,&b,&c);
    printf("%d\n",(a-c)/(b+c));
}


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

int main() {
  char N[2];
  scanf("%s" ,&N) ;

  if ( N[0] == N[1] && N[1] == N[2]|| N[1] == N[2] && N[2] == N[3] ) {
    puts("Yes" );
  }
  
  else puts("No") ;
}


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

#define int long long int
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define lb lower_bound
#define ub upper_bound
#define srt(a) sort(a.begin(),a.end())
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;
typedef vector<pair<int,int>> vpii;
#define mxe(a) *max_element(a.begin(),a.end())
#define mne(a) *min_element(a.begin(),a.end())
#define endl '\n'
#define mod 1000000007
#define INF64 1e18

void solve(){
  int n ;cin>>n;
  vector<double> dp(n+1,0.0);
  dp[0]=1;
  for(int i=1;i<=n;i++){
    double p;cin>>p;
    for(int head=i;head>=1;head--)
      dp[head]=dp[head-1]*p+(1-p)*dp[head];
    dp[0]=(1-p)*dp[0];
  }
  double ans=0.0;
  for(int i=n/2+1;i<=n;i++)
    ans+=dp[i];
  cout<<fixed<<setprecision(10)<<ans;
}

int32_t main(){
  #ifndef ONLINE_JUDGE
   freopen("input.txt","r",stdin);
   freopen("output.txt","w",stdout);
  #endif
  
  ios_base::sync_with_stdio(false);
  cin.tie(0);cout.tie(0);

  int T=1;
  //cin>>T;
  for(int TT=1;TT<=T;TT++){
    solve();
  }
}

Measured memory_bytes: 3832
#include <iostream>
#include<vector>
#include<algorithm>
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = 1; i <= (n); i++)
#define drep(i,n) for(int i = (n)-1; i >= 0; i--)
#define srep(i,s,t) for (int i = s; i < t; i++)
#define rng(a) a.begin(),a.end()
using ll = long long;

using namespace std;



int main() {
    int n;
    cin>>n;
    vector<int>h(n);
    rep(i,n) cin>>h[i];
    vector<int>dp(n+1);
    int ans = 0;
    int cnt = 0;
    for(int i = n-2; i >= 0; i--) {
        if(h[i]>=h[i+1]) {
            cnt++;
            dp[i] = max(dp[i+1],cnt);
        } else {
            cnt = 0;
        }
        ans = max(ans,dp[i]);
    }
    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 3916
def is_prime(x):
    if x <= 1:
        return False
    for i in range(2, int(x**0.5) + 1):
        if x % i == 0:
            return False
    return True


n = int(input())
nums = [int(input()) for _ in range(n)]
ans = sum([1 for i in nums if is_prime(i)])
print(ans)



Measured memory_bytes: 5996
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
template< typename T >
struct BinaryIndexedTree {
  vector< T > data;

  BinaryIndexedTree(int sz) {
    data.assign(++sz, 0);
  }

  T sum(int k) {
    T ret = 0;
    for(++k; k > 0; k -= k & -k) ret += data[k];
    return (ret);
  }

  void add(int k, T x) {
    for(++k; k < data.size(); k += k & -k) data[k] += x;
  }
};

void _main()
{
    int N, K;
    cin >> N >> K;
    vector<int> a(N);
    rep(i, 0, N) cin >> a[i];
    vector<ll> sum(N + 1);
    sum[0] = 0;
    vector<ll> alt;
    alt.push_back(0);
    rep(i, 0, N)
    {
        sum[i + 1] = sum[i] + a[i] - K;
        alt.push_back(sum[i + 1]);
    }
    sort(alt.begin(), alt.end());

    BinaryIndexedTree<ll> bit(N + 1);

    ll ans = 0;
    rep(i, 0, N + 1)
    {
        const int x = lower_bound(alt.begin(), alt.end(), sum[i]) - alt.begin();
        ans += bit.sum(x);
        bit.add(x, 1);
    }
    cout << ans << endl;
}


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

in_list = []
x0, y0, h0 = 0, 0, 0
for i in range(N):
    xyh = list(map(int, input().split()))
    in_list.append(xyh)

for i in range(N):
    if in_list[i][2]:
        x0, y0, h0 = in_list[i]

for Cx in range(0, 101):
    for Cy in range(0, 101):
        for xyh in in_list:
            x, y, h = xyh[0], xyh[1], xyh[2]
            H = h0 + abs(x0-Cx) + abs(y0-Cy)
            if h != max(H-abs(x-Cx)-abs(y-Cy), 0):
                break
        else:
            print(Cx, Cy, H)



Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int n;
int a[200100];
bool check(int mid){
    if(a[n+1]<=mid&&a[n]<=mid||a[n]<=mid&&a[n-1]<=mid)
        return 1;
    if(a[n+1]> mid&&a[n]> mid||a[n]> mid&&a[n-1]> mid)
        return 0;
    for(int i=1;i<n-1;i++){
   		if(a[n+i+1]<=mid&&a[n+i]<=mid||a[n-i]<=mid&&a[n-i-1]<=mid)
     	   	return 1;
   		if(a[n+i+1]> mid&&a[n+i]> mid||a[n-i]> mid&&a[n-i-1]> mid)
     	   	return 0;
    }
    return a[1]<=mid;
}
int main(){
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cin>>n;
    for(int i=1;i<=2*n-1;i++)
        cin>>a[i];
    int le=0;
    int ri=2*n-1;
    while(le<ri){
        int mi=(le+ri)/2;
        if(check(mi))
            ri=mi;
        else
            le=mi+1;
    }
    cout<<le<<endl;
    return 0;
}


Measured memory_bytes: 1024
import java.util.*;

class activity{
    int a;
    int b;
    int c;
}

public class Main {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        ArrayList<activity> arr = new ArrayList<activity>(n+1);

        for(int i=0;i<n;i++){
            activity ac = new activity();
            ac.a = sc.nextInt();
            ac.b = sc.nextInt();
            ac.c = sc.nextInt();
            arr.add(ac);
        }

        int dp[][] = new int[n+1][3];
        dp[1][0] = arr.get(0).a;
        dp[1][1] = arr.get(0).b;
        dp[1][2] = arr.get(0).c;

        for(int i=2;i<=n;i++){
            dp[i][0] = arr.get(i-1).a + Math.max(dp[i-1][1],dp[i-1][2]);
            dp[i][1] = arr.get(i-1).b + Math.max(dp[i-1][0],dp[i-1][2]);
            dp[i][2] = arr.get(i-1).c + Math.max(dp[i-1][0],dp[i-1][1]);
        }

        System.out.print(Math.max(dp[n][0],Math.max(dp[n][1],dp[n][2])));

    }
}

Measured memory_bytes: 94176
#include "bits/stdc++.h"
using namespace std;
///////////////////////////////////////////
const long long int INF = 1LL<<60;
const long long int Mod = 1000000007;
using ll = long long int; using ci = const int;
using vi = vector<int>;  using Vi = vector<long long int>;
using P = pair<int, int>;  using PLL = pair<ll, ll>;
using matrix = vector<vector<ll>>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rep(i,N) for(ll i = 0; i < (ll)N; i++)
#define repi(i,a,b) for(ll i = ll(a); i < ll(b); ++i)
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
template<class T> inline void princ(T x){cout<<x<<" ";}; 
template<class T> inline void print(T x){cout<<x<<"\n";};
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
///////////////////////////////////////////////////////////////////////////////////

ll n,a,b;
Vi x;


int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(30);
    cin>>n>>a>>b;
    x.resize(n);
    rep(i,n){
        cin>>x[i];
    }
    ll ans = 0;
    rep(i,n-1){
        ll tmp = x[i+1]-x[i];
        ans += min(b,a*tmp);
    }
    print(ans);
    return 0;
}

Measured memory_bytes: 1024
from collections import Counter
import sys
from functools import lru_cache
from functools import reduce
from operator import mul
input = sys.stdin.readline
# sys.setrecursionlimit(100000)


@lru_cache(None)
def cmb(n: int, r: int):
    if n < r:
        return 0
    r = min(n - r, r)
    if r == 0:
        return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1, r + 1))
    return over // under


def main():
    _ = int(input().strip())
    A = [int(i) for i in input().strip().split()]
    cnts = Counter(A)
    d = {}
    _sum = 0
    for k, v in cnts.items():
        d[k] = (cmb(v, 2), cmb(v - 1, 2))
        _sum += d[k][0]
    for a in A:
        dif = d[a][0] - d[a][1]
        print(_sum - dif)
    return


if __name__ == "__main__":
    main()


Measured memory_bytes: 111592
n=int(input())
x=input()
import sys
sys.setrecursionlimit(10**7)
if n==1:
  print(0 if x=='1' else 1)
  exit()
def pc(x):
  a=bin(x)[2:]
  return a.count('1')
def func(x):
  if x==0:
    return 0
  else:
    return func(x%pc(x))+1
pcx=x.count('1')
if pcx==0:
  for _ in range(n):
    print(1)
else:
  x0,x1=0,0
  for i in range(n):
    if x[i]=='1':
      if pcx!=1:
        x0+=pow(2,n-1-i,pcx-1)
        x0%=pcx-1
      x1+=pow(2,n-1-i,pcx+1)
      x1%=pcx+1
  for i in range(n):
    ans=0
    if x[i]=='1':
      if pcx==1:
        print(0)
      else:
        xx=x0-pow(2,n-1-i,pcx-1)
        xx%=pcx-1
        print(func(xx)+1)
    else:
      xx=x1+pow(2,n-1-i,pcx+1)
      xx%=pcx+1
      print(func(xx)+1)


Measured memory_bytes: 9540
#include<bits/stdc++.h>
 
#define REP(i,s,N) for (int i=s;i<(N); ++i)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
using namespace std;


ll ans=0;

int main(){
	ll A,B;
	cin >> A >> B;
	ans = A-2*B;
	if(ans>0){
	cout << ans << endl;
	}else{
	cout << 0 << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back

using namespace std;
const long long MOD = (long long)1e9 + 7;

int n, cnt[30], k;
string s;
long long quickpow(long long b, int e)
{
	return e ? ((e & 1 ? b : 1)*quickpow((b*b) % MOD, e >> 1)) % MOD : 1;
}
int main()
{
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n >> s;
	for (int i = 0; i < (int)s.length(); i++) {
		if (cnt[s[i] - 'a'] == 0) k++;
		cnt[s[i] - 'a']++;
	}
	long long ans = 1;
		for (int i = 0; i < 30; i++) {
			if (cnt[i]) {
				ans = ans * (cnt[i] + 1);
				ans = ans % MOD;
			}
		}
	cout << ans - 1 << "\n";
	//system("pause");
	return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<vector>
using namespace std;
int main(){
  int k,t;
  cin>>k>>t;
  int MAX=0;
  for(int i=0;i<t;i++){
    int a;cin>>a;
    if(MAX<a) MAX=a;
  }
  int ans=2*MAX-k-1;
  if(ans<0) cout<<0<<endl;
  else cout<<ans<<endl;
}


Measured memory_bytes: 256
/*		Author : Kaustubh Gangwar
		||S||A||M||R||A||T||
*/
#include <bits/stdc++.h>
using namespace std;
#define modo 1000000007
#define ff first
#define ss second 
#define ld long double
#define pb push_back
#define gcd __gcd
#define vi vector<int>
#define vll vector<long long>
#define all(x) (x).begin(),(x).end()
#define f(i,a,b) for(int i=a;i<b;i++)
#define fe(i,a,b) for(int i=a;i<=b;i++)
#define nl '\n'
typedef long long  ll;
typedef pair<int,int> pii;

ll bpow(ll a, ll b) {
	a=a; ll res = 1;
    while(b){
        if (b & 1)
        res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}

int32_t main()
{	ios_base::sync_with_stdio(false);
	cin.tie(0),cout.tie(0);
	ll test=1;
	//cin>>test;
	while(test--)
	{
		ll n; cin>>n;
		n=2000-n;
		if(n%200==0)
		n--;
		ll ans=(n+200)/200;
		cout<<ans;
		
	}
return 0;
}


Measured memory_bytes: 3640
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
        new Main().run();
    }
	public void run(){
		Scanner scan = new Scanner(System.in);
		while(scan.hasNext()){
			int n = scan.nextInt();
			int t = scan.nextInt();
			int e = scan.nextInt();
			int count = 0;
			int[] x = new int[n];
			for(int i = 0;i < n;i++){
				x[i] = scan.nextInt();
			}
			for(int i = 0;i < n && count == 0;i++){
				for(int j = t-e;j <= t+e;j++){
					if(j%x[i] == 0){
						count = i+1;
						break;
					}
				}
			}
			System.out.println((count == 0)?-1:count);
		}
	}
}

Measured memory_bytes: 18348
#include<iostream>
#include<algorithm>

using namespace std;

int field[52][52];

void DFS(int x, int y){
    if(field[x][y]==1/*||field[x][y]==-1*/){
        field[x][y]=-1;
        DFS(x,y-1);
        DFS(x-1,y);
        DFS(x+1,y);
        DFS(x,y+1);
    }
}


int main(){
    int w,h;
    while(cin>>w>>h){
        if(w==0&&h==0)break;
        for(int i=0; i<50; i++){
            for(int j=0; j<50; j++){
                field[i][j]=0;
            }
        }
        
        int start_x;
        int start_y;
        for(int i=1; i<=h; i++){
            for(int j=1; j<=w; j++){
                char temp;
                cin>>temp;
                if(temp=='#')field[i][j]=0;
                else field[i][j]=1;
                
                if(temp=='@'){
                    start_x=i;
                    start_y=j;
                }
            }
        }
        
        DFS(start_x,start_y);
        
        int sum=0;
        for(int i=1; i<=h; i++){
            for(int j=1; j<=w; j++){
                if(field[i][j]==-1){
                    sum++;
                }
            }
        }
        cout<<sum<<endl;
    }
}

Measured memory_bytes: 1184
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	int ans = 0;
	for (int i=0;i<n;++i){
		int x;
		cin>>x;
		if (i%2 == 0 && x%2 == 1){
			++ans;
		}
	}
	cout << ans << endl;
}





Measured memory_bytes: 3632
#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
using namespace std;
struct nod{
int ma,mi,all;
}num[1100];
int n,i,l,j,now;
char s[1100];
bool cmp(nod a,nod b)
{
    if (a.mi!=b.mi) return a.mi>b.mi;
    return a.all>b.all;

}
bool cmp2(nod a,nod b)
{
    if (a.ma!=b.ma) return a.ma>b.ma;
    if (a.mi!=b.mi) return a.mi>b.mi;
    return a.all>b.all;
}
int main()
{
    scanf("%d\n",&n);
    for (i=1;i<=n;i++)
    {
        gets(s); l=strlen(s);
        num[i].mi=10000; num[i].ma=-10000;
        for (j=0;j<l;j++)
        {
            if (s[j]=='(') num[i].all++; else num[i].all--;
            num[i].mi=min(num[i].mi,num[i].all);
        }
        num[i].all=0;
        for (j=l-1;j>=0;j--)
        {
            if (s[j]=='(') num[i].all++; else num[i].all--;
            num[i].ma=max(num[i].ma,num[i].all);
        }
        now+=num[i].all;
    }
    if (now)
    {
        printf("No\n");
        return 0;
    }
    now=0;

    for (i=1;i<=n;i++) if (num[i].mi>=0) now+=num[i].all;

    sort(num+1,num+n+1,cmp);

    for (i=1;i<=n;i++)
    if (num[i].mi<0 && num[i].all>=0)
    {
        if (now+num[i].mi<0)
        {
            printf("No\n");
            return 0;
        }
        now+=num[i].all;
    }

    sort(num+1,num+n+1,cmp2);

    for (i=1;i<=n;i++)
    if (num[i].all<0)
    {
        if (now+num[i].mi<0)
        {
            printf("No\n");
            return 0;
        }
        now+=num[i].all;
    }
    printf("Yes\n");
}

Measured memory_bytes: 1188
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
using namespace std;

class Point
{
public:
    int y, x;
    Point(){
        y = x = 0;
    }
    Point(int y0, int x0){
        y = y0;
        x = x0;
    }
    Point operator+(const Point& p) const{
        return Point(y + p.y, x + p.x);
    }
    Point operator-(const Point& p) const{
        return Point(y - p.y, x - p.x);
    }
    Point operator*(int a) const{
        return Point(y * a, x * a);
    }
    bool operator==(const Point& p) const{
        return y == p.y && x == p.x;
    }
    bool operator<(const Point& p) const{
        return make_pair(y, x) < make_pair(p.y, p.x);
    }
};

const Point d[] = {Point(0, -1), Point(0, 1), Point(1, 0), Point(-1, 0)};

int main()
{
    int h, w;
    cin >> h >> w;

    vector<Point> init;
    Point goal;
    for(int y=0; y<h; ++y){
        for(int x=0; x<w; ++x){
            char c;
            cin >> c;
            if(c == 'o')
                init.push_back(Point(y, x));
            else if(c == '@')
                goal = Point(y, x);
        }
    }
    if(min(h, w) != 1 && init.size() > 2){
        cout << "yes" << endl;
        return 0;
    }

    set<vector<Point> > history;
    queue<vector<Point> > q;
    history.insert(init);
    q.push(init);
    while(!q.empty()){
        vector<Point> v = q.front();
        q.pop();
        for(unsigned i=0; i<v.size(); ++i){
            if(v[i] == goal){
                cout << "yes" << endl;
                return 0;
            }
        }

        for(unsigned i=0; i<v.size(); ++i){
            for(int j=0; j<4; ++j){
                vector<Point> v2 = v;
                for(;;){
                    Point p = v2[i] + d[j];
                    if(!(0 <= p.y && p.y < h && 0 <= p.x && p.x < w))
                        break;

                    for(unsigned k=0; k<v.size(); ++k){
                        if(v2[k] == p)
                            v2[k] = v2[k] - d[j];
                    }
                    v2[i] = p;
                }

                sort(v2.begin(), v2.end());
                if(history.find(v2) == history.end()){
                    history.insert(v2);
                    q.push(v2);
                }
            }
        }
    }

    cout << "no" << endl;
    return 0;
}

Measured memory_bytes: 3180
import sys
bbn=1000000007
	
#+++++

		
def main():
	n = int(input())
	t=[]
	l=[]
	for i in range(n):
		b , c =  input().split()
		c=int(c)
		l.append(c)
		t.append(b)
	
	x = input()
	ii=t.index(x)
	
	ret=sum(l[ii+1:])
	
	print(ret)
	
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)

if __name__ == "__main__":
	if sys.platform =='ios':
		sys.stdin=open('inputFile.txt')
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

Measured memory_bytes: 38384
import java.util.HashMap;
import java.util.Scanner;

public class Main {
        public static void main(String[] args) {
                Scanner scan = new Scanner(System.in);

                int N = scan.nextInt();

                int[] A = new int[N];
                HashMap<Integer, Integer> aHash = new HashMap<Integer, Integer>();
                HashMap<Integer, Integer> aKaburiHash = new HashMap<Integer, Integer>();

                for (int i = 0; i < N; i++) {
                	int temp = scan.nextInt();

                	A[i] = temp;

                	if (aHash.containsKey(temp)) {
                		aKaburiHash.put(temp, 1);
                	}

                	aHash.put(temp, 1);

                }

                scan.close();

                int count = 0;

                aRoop: for (int a = 0; a < N; a++) {

                	int tempA = A[a];

                	if (aKaburiHash.containsKey(tempA)) {
                		continue aRoop;
                	}

                	aHash.remove(tempA);

	                int rootA = (int)Math.sqrt(tempA);

	                for (int i = 1; i <= rootA; i++) {

	                	if (tempA%i == 0 && (aHash.containsKey(i) || aHash.containsKey(tempA/i))) {
	                		continue aRoop;
	                	}

	                }

	                count++;

	                aHash.put(tempA, 1);

                }

                System.out.println(count);

        }
}

Measured memory_bytes: 80608
import java.util.Scanner;

public class Main{
    public static Scanner scan  = new Scanner(System.in);
    public static void main(String[]args){
        int n,k,sum;

        n=nextInt();
        k=nextInt();
        sum=0;

        int[] arr = new int[n];
        for(int i=0;i<n;i++){
            arr[i]=nextInt();
        }
        for(int a:arr){
            if(a>=k){
                sum+=1;
            }
        }
        print(sum);
    }



    public static int nextInt(){
        return Integer.parseInt(scan.next());
    }
    public static long nextLong(){
        return Long.parseLong(scan.next());
    }
    public static String next(){
        return scan.next();
    }
    public static double nextDouble(){
        return Double.parseDouble(scan.next());
    }
    public static float nextFloat(){
        return Float.parseFloat(scan.next());
    }

    //Yes or No
    public static void yesNo(boolean flag){
        if(flag) System.out.println("Yes");
        else System.out.println("No");
    }
    public static void print(Object a){
        System.out.println(a);
    }
}

Measured memory_bytes: 45976
#include <stdio.h>

#define N 8
#define free -1
#define notfree 1

int row[N], col[N], dpos[2*N -1],dneg[2*N-1];

int X[N][N];

void printBoard() {
  int i,j;
  for(i=0;i<N;i++){
    for(j=0;j<N;j++){
      if(X[i][j]){
        if(row[i] != j)return;
      }
    }
  }
  for(i = 0;i<N;i++){
    for(j = 0;j<N;j++){
      if(row[i] == j)printf("Q");
      else printf(".");
    }
    printf("\n");
  }
}

void recursive(int i){
  int j;
  if(i == N){
    printBoard();
    return;
  }
  for(j=0;j<N;j++){
    if(notfree == col[j] || notfree == dpos[i + j] || notfree ==dneg[i-j+N-1])continue;
    row[i] = j;
    col[j] = dpos[i + j] = dneg[i-j+N-1]= notfree;
    recursive(i+1);
    row[i] = col[j] = dpos[i + j] = dneg[i - j + N -1] = free;
  }
}

int main(){
  int i;
  for(i = 0;i<N;i++){
    row[i] = free;
    col[i] = free;
  }
  for(i = 0;i<2*N-1;i++){
    dpos[i] = free;
    dneg[i] = free;
  }
  int j;
  for(i=0;i<N;i++){
    for(j=0;j<N;j++){
      X[i][j] = 0;
    }
  }
  int k;
  scanf("%d",&k);
  int r,c;
  for(i = 0;i<k;i++){
    scanf("%d %d",&r,&c);
    X[r][c] = 1;
  }
  recursive(0);
  return 0;
}

Measured memory_bytes: 2652
x=i=0
while(c=gets.to_i)>0
m=(1..gets.to_i).inject([0]*1e4){|s|v,w=gets.split(?,).map &:to_i;(0..c).map{|j|x=[s[j],w>j ?0:s[j-w]+v].max}}
puts "Case #{i+=1}:",x,m.index(x)
end

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

#define rep(i, N) for (int i = 0; i < (int)N; i++)
using namespace std;
typedef long long ll;
const ll LLINF = 9223372036854775807;
const int INF = pow(2,29);
const int MOD = 1000000007;

int main() {
  int N; cin >> N;
  int W[N]; rep(i,N) cin >> W[i];
  int result = 0; rep(i,N) result+= W[i];

  int tmp = result;
  rep(i,N) {
    tmp -= 2 * W[i];
    result = min(result, abs(tmp));
  }
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
	int A,B,K,i,x;
	scanf("%d %d %d",&K,&A,&B);
	x=0;
	for(i=A;i<=B;i++){
		if(i%K==0){
			x=1;
		}
	}
	if(x==1){
		printf("OK\n");
	}
	if(x==0){
		printf("NG\n");
	}
	return 0;
}

Measured memory_bytes: 1656
#include <bits/stdc++.h>
using namespace std;
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define in(x,y,h,w) x >= 0 && x < h && y >= 0 && y < w

#define int long long
//using ll = long long;
using P = pair<int,int>;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
 
const int INF=1e+18;
const double EPS=1e-9;
const int MOD=1000000007;

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

bool ask(vector<int> &vec){
	cout << "?";
	for(int v : vec) cout << " " << v + 1;
	cout << endl;
	string s;
	cin >> s;
	return s == "Red";
}

signed main(){
	int n;
	cin >> n;
	string ans;
	for(int i = 0;i < n * 2;i++) ans += '?';
	vector<int> q;
	for(int i = 0;i < n;i++) q.push_back(i);
	bool isR = ask(q);
	int r = 0,b = n;
	if(!isR) swap(r,b);
	while(abs(r - b) > 1){
		int mid = (r + b) / 2;
		for(int i = 0;i < n;i++) q[i] = mid + i;
		if(ask(q)) r = mid;
		else b = mid;
	}
	if(r < b){
		ans[r] = 'R';
		ans[r + n] = 'B';
	}else{
		ans[b] = 'B';
		ans[b + n] = 'R';
	}
	int ma = max(b,r);
	for(int i = 0;i < n * 2;i++){
		q.clear();
		if(ma <= i && i < ma + n - 1){
			for(int j = -1;j < n;j++){
				if(ma + j != i) q.push_back(ma + j);
			}
			ans[i] = (ask(q) ? 'B' : 'R');
		}else{
			for(int j = 0;j < n - 1;j++){
				q.push_back(ma + j);
			}
			q.push_back(i);
			ans[i] = (ask(q) ? 'R' : 'B');
		}
	}
	cout << "! " << ans << endl;
}


Measured memory_bytes: 724
#include<bits/stdc++.h>
using namespace std;
#define el '\n'

int main()
{
    string a,b;
    int k=0;
    cin>>a>>b;
    for(int i=0;i<a.size();i++)
        if(a[i]==b[i])
            k++;
    cout<<k<<el;


    return 0;
}


Measured memory_bytes: 256
#include <bitset>
#include <cmath>
#include <iostream>
using ull = unsigned long long;

int main(void) {
    short n;
    std::cin >> n;

    for (int i = 0; i < pow(2, n); ++i) {
        std::cout << i << ':';
        const std::bitset<20> i_bitset(i);
        const std::string i_bitset_string = i_bitset.to_string();

        for (int j = i_bitset_string.size() - 1; j >= 0; --j)
            if (i_bitset_string[j] == '1')
                std::cout << ' ' << i_bitset_string.size() - j - 1;

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


Measured memory_bytes: 3316
import sys
input = lambda: sys.stdin.readline().rstrip()

def par(a):
    L = []
    while P[a] >= 0:
        L.append(a)
        a = P[a]
    for l in L:
        P[l] = a
    return a
def unite(a, b):
    if par(a) != par(b):
        if P[par(b)] >= P[par(a)]:
            if P[par(b)] == P[par(a)]: P[par(a)] -= 1
            P[par(b)] = par(a)
        else:
            P[par(a)] = par(b)

N, Q = map(int, input().split())
P = [-1 for i in range(N)]
for _ in range(Q):
    t, u, v = map(int, input().split())
    if t == 0:
        unite(u, v)
    else:
        print(1 if par(u) == par(v) else 0)


Measured memory_bytes: 80320
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <queue>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using namespace std;

template<class T>
constexpr T INF = ::numeric_limits<T>::max() / 32 * 15 + 208;

int main() {
    int n, a, b;
    while(cin >> n >> a >> b, n|a|b){
        vector<int> v(n);
        for (auto &&i : v) scanf("%d", &i);
        int ans = 0, M = -1;
        for (int i = a; i <= b; ++i) {
            if(M <= v[i-1]-v[i]) {
                ans = i;
                M = v[i-1]-v[i];
            }
        }
        cout << ans << "\n";
    }
    return 0;
}



Measured memory_bytes: 3140
#include <cstdio>
#include <iostream>
#include <utility>
using namespace std;
 
typedef struct{
    char c;
    int v;
}cards;
 
int main(){
    int n;
    cards x[36], y[36], z[36];
    int count=0;
     
    scanf(" %d", &n);
    for(int i=0; i<n; ++i){
        scanf(" %c %d", &x[i].c, &x[i].v);
        y[i]=x[i];
        z[i]=x[i];
    }
     
    //bubble sort   
    bool flag=true;
    while(flag){
        flag=false;
        for(int i=n-1; i>0; --i){
            if(y[i].v<y[i-1].v){
                swap(y[i], y[i-1]);
                flag=true;
            }   
        }
    }
     
    //selection sort    
    for(int i=0; i<n; ++i){
        int minj=i;
        for(int j=i; j<n; ++j){
            if(z[j].v<z[minj].v) minj=j;     
        }   

         
        if(i!=minj) swap(z[i], z[minj]);
    }
 
     
    for(int i=0; i<n; ++i){
        if(i>0) printf(" ");
        printf("%c%d", y[i].c, y[i].v);
    }
    printf("\n");
     
    printf("Stable\n");
     
    for(int i=0; i<n; ++i){
        if(i>0) printf(" ");
        printf("%c%d", z[i].c, z[i].v);
    }
        printf("\n");
     
    bool f2=true;
    for(int i=0; i<n; ++i) if(y[i].c!= z[i].c) f2=false;
     
    if(f2) printf("Stable\n");
    else printf("Not stable\n");
}


Measured memory_bytes: 3216
n = int(input()) 
a = list(map(int, input().split()))
aa = sum(a)/2
sum_ = 0
b = []

for i in range(n):
    if i%2 ==1:
        sum_ = sum_ + a[i]

b.append(aa-sum_)

for i in range(n-1):
    b.append(a[i]-b[i])

for i in range(len(b)):
    b[i] = int(2*b[i])

for i in range(len(b)):            
    print(b[i],end=" ")

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

using namespace std;

int main(){

    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
 
    int x;
    cin>>x;
    int y = x / 500;
    int z = (x%500)/5;
    cout << y*1000 + z*5 << endl;
}

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

int main () { 
	int N, M;
	cin >> N >> M;
	int max = 1;
	for (int i=1; i<=M/N && i*i<=M; i++)
		if (M%i==0) {
			max = i;
			if (M/i <= M/N) {
				max = M/i;
				break;
			}
		}
	cout << max << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long N,i,L,R,total=0;
	cin>>N;
	for(i=0;i<N;i++)
	{
		cin>>L>>R;
		total+=(R-L)+1;
	}
	cout<<total<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
using namespace std;

int n;
int arr[1000111];

int cntOdd[1000111];
int cntEven[1000111];

vector< pair<int,int> > evens;
vector< pair<int,int> > odds;

int MAX(int a,int b)
{
    if (a > b)
        return a;
    else
        return b;
}

int main()
{
    int i;
    int ans;

    scanf("%d",&n);

    ans = 0;

    for (i=1;i<=n;i++)
    {
        scanf("%d",&arr[i]);

        if (i%2 == 1)
        {
            cntOdd[ arr[i] ]++;
        }
        else
        {
            cntEven[ arr[i] ]++;
        }
    }

    for (i=0;i<=1000000;i++)
    {
        if (cntOdd[i] > 0)
        {
            odds.push_back(make_pair(cntOdd[i], i));
        }
        if (cntEven[i] > 0)
        {
            evens.push_back(make_pair(cntEven[i], i));
        }
    }

    odds.push_back(make_pair(0, 0));
    evens.push_back(make_pair(0, 0));

    sort(odds.begin(),odds.end());
    reverse(odds.begin(),odds.end());

    sort(evens.begin(),evens.end());
    reverse(evens.begin(),evens.end());

    if (odds[0].second != evens[0].second)
        ans = odds[0].first + evens[0].first;
    else
        ans = MAX(odds[0].first+evens[1].first, odds[1].first+evens[0].first);

    printf("%d\n",n-ans);

    return 0;
}


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

#define int long long

int sum(int n) {
    string s = to_string(n);
    int res = 0;
    for(int i=0; i<s.size(); ++i) {
        res += s[i]-'0';
    }
    return res;
}

signed main() {
    int n, a, b;
    cin >> n >> a >> b;
    int ans = 0;
    int t = 1;
    while(t<=n) {
        int u = sum(t);
        if(a<=u&&u<=b) ans+=t;
        t++;
    }
    cout << ans << endl;
    return 0;
}



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

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int A, B, C;
    cin >> A >> B >> C;
    if(A == 5 and B == 5 and C == 7) cout << "YES" << endl;
    else if(A == 5 and B == 7 and C == 5) cout << "YES" << endl;
    else if(A == 7 and B == 5 and C == 5) cout << "YES" << endl;
    else cout << "NO" << endl;
}

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

int main(){

	int x, y;
	while(cin){
		cin >> x >> y;
		if(x == 0 && y == 0) break;
		if(x < y){
			cout << x << " " << y << endl;
		}else{
			cout << y << " " << x << endl;
		}
	}

return 0;
}

Measured memory_bytes: 1160
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
	string S; cin >> S;
	int cnt[26] = {};
	rep(i, S.length()) cnt[S[i] - 'a']++;
	rep(i, 26) {
		if (cnt[i] == 0) {
			cout << (char)(i + 'a') << endl;
			return 0;
		}
	}
	cout << "None" << endl;

    return 0;
}


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

using namespace std;

template <typename T>std::string NumberToString ( T Number ){std::ostringstream ss; ss << Number;return ss.str(); } // Usages NumberToString(3)
template <typename T>T StringToNumber ( const string &Text ){istringstream ss(Text);T result;return ss >> result ? result : 0;} // StringToNumber<int>("3")

int main(){

   ios::sync_with_stdio(0);
   cin.tie(0);

  // freopen ("input.txt", "r", stdin);

    int r;
    double pi = 3.141592653589793238;
    cin >> r;

    cout << 2 * pi * r << endl;

    return 0;
}

Measured memory_bytes: 3764
#include<iostream>
using namespace std;
int main(){
	int H, W, i, j, k,l;
	while (true){
		cin >> H >> W;
		if (H == 0 && W == 0){ break; }
		for (i = 0; i < W; i++){
			cout << "#";
		}
		cout << endl;
		for (j = 0; j < H - 2; j++){
			cout << "#";
			for (k = 0; k < W - 2; k++){
				cout << ".";
			}
			cout << "#" << endl;
		}
		for (l = 0; l < W; l++){
			cout << "#";
		}
		cout << endl << endl;
	}
return 0;
}

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

int main() {
	int N;
	cin >> N;
	map<string, int> m;
	for (int i = 0; i < N; i++) {
		string t;
		cin >> t;
		m[t]++;
	}
	vector<pair<string, int>> v;
	for (auto i = m.begin(); i != m.end(); i++) {
		v.push_back(make_pair(i->first, i->second));
	}
	sort(v.begin(), v.end(), [](pair<string, int> &p1, pair<string, int> &p2) {
		if (p1.second > p2.second) {
			return true;
		} else if (p1.second < p2.second) {
			return false;
		} else {
			if (p1.first < p2.first) {
				return true;
			} else {
				return false;
			}
		}
	});
	int tmp = v[0].second;
	for (auto i = v.begin(); i != v.end(); i++) {
		if (tmp != i->second)
			break;
		cout << i->first << endl;
	}

}


Measured memory_bytes: 29424
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <deque>
using namespace std;




int main() {

  int H,W,h,w;
  cin >> H >> W >> h >> w;
  int ans;

  ans = H*W - h*W - w*H +h*w;
  cout << ans << endl;

}


Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <map>
using namespace std;

using cat = long long;

cat A, B, C, D, ans;
constexpr int MX = 2000000;
vector<cat> ans_sm(MX+1);
map<cat, cat> ans_cache;

void prec(cat N) {
	ans_sm[N] = D*N;
	if(N <= 1) return;
	cat d3 = N%3, d5 = N%5, n3 = N/3, n5 = N/5;
	if(d3 == 2) d3 = 1, n3++;
	if(d5 == 3) d5 = 2, n5++;
	if(d5 == 4) d5 = 1, n5++;
	ans_sm[N] = min(ans_sm[N], d5*D+C+ans_sm[n5]);
	ans_sm[N] = min(ans_sm[N], d3*D+B+ans_sm[n3]);
	cat d2 = N%2, n2 = N/2;
	ans_sm[N] = min(ans_sm[N], d2*D+A+ans_sm[n2]);
	if(d2) ans_sm[N] = min(ans_sm[N], d2*D+A+ans_sm[n2+1]);
}

int main() {
	cin.sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int T;
	cin >> T;
	while(T--) {
		cat N;
		cin >> N >> A >> B >> C >> D;
		for(int i = 0; i <= MX; i++) prec(i);
		ans = 1000*(A+D);
		ans_cache.clear();
		ans_cache[N] = 0;
		auto it = begin(ans_cache);
		while(true) {
			cat cur = it->first, cur_ans = it->second;
			if(cur <= MX) ans = min(ans, cur_ans + ans_sm[cur]);
			else if(cur_ans < ans) {
				if(cur <= ans/D) ans = min(ans, cur_ans+D*cur);
				cat d3 = cur%3, d5 = cur%5, n3 = cur/3, n5 = cur/5;
				if(d3 == 2) d3 = 1, n3++;
				if(d5 == 3) d5 = 2, n5++;
				if(d5 == 4) d5 = 1, n5++;
				cat d2 = cur%2, n2 = cur/2;
				auto jt = ans_cache.find(n5);
				if(jt == end(ans_cache)) ans_cache[n5] = cur_ans+d5*D+C;
				else jt->second = min(jt->second, cur_ans+d5*D+C);
				jt = ans_cache.find(n3);
				if(jt == end(ans_cache)) ans_cache[n3] = cur_ans+d3*D+B;
				else jt->second = min(jt->second, cur_ans+d3*D+B);
				jt = ans_cache.find(n2);
				if(jt == end(ans_cache)) ans_cache[n2] = cur_ans+d2*D+A;
				else jt->second = min(jt->second, cur_ans+d2*D+A);
				if(d2) {
					jt = ans_cache.find(n2+1);
					if(jt == end(ans_cache)) ans_cache[n2+1] = cur_ans+d2*D+A;
					else jt->second = min(jt->second, cur_ans+d2*D+A);
				}
			}
			if(it == begin(ans_cache)) break;
			it--;
		}
		cout << ans << endl;
	}
}


Measured memory_bytes: 19196
#include<bits/stdc++.h>
using namespace std;
long long int a[105];
#define mod 1000000007

int main(){
      int n, k;
      cin>>n>>k;
      for(int i=0; i<n; i++)
            cin>>a[i+1];
      vector<int>prefix(k+1, 1);
      int dp[n+1][k+1];
      for(int i=0; i<=n; i++)
            for(int j=0; j<=k; j++)
                  dp[i][j]=0;
      dp[0][0]=1;

      for(int i=1; i<=n; i++){
            /*vector<int>pre(k+1);

            for(int p=0; p<=k; p++){
                  if(p-a[i]-1<0)
                        dp[i][p]=prefix[p];
                  else {
                        dp[i][p]=(prefix[p]-prefix[p-a[i]-1]+mod)%mod;
                  }
                  //cout<<i<<' '<<p<<' '<<dp[i][p]<<'\n';

                  if(p>0)pre[p]=dp[i][p]+pre[p-1];
                  else pre[p]=1;
            }
            prefix=pre;*/
            int sums[k+1];
        sums[0]=dp[i-1][0];
        for(int j=1;j<=k;j++)
        {
            sums[j]=(sums[j-1]+dp[i-1][j])%mod;  ///Calculate the prefix sums for i-1
        }
        for(int j=0;j<=k;j++)
        {
            int tr=sums[j];  ///Sum of dp[i-1][0...j]
            int unreachable=j-a[i]-1;  ///We need to subtract the sum of the first "unreachable" elements (dp[i-1][0...unreachable])
            if(unreachable>=0)
            {
                tr=(tr-sums[unreachable]+mod)%mod;  ///Add mod to make sure that "tr-sums[unreachable]" is not negative.
            }
            dp[i][j]=tr;
        }
      }
      cout<<dp[n][k];
}

Measured memory_bytes: 43460
import collections


def go_next(digits):
    if all(x==9 for x in digits):
        return [0]*len(digits) + [1]

    digits[0] += 1

    maxInc = -1
    # print(digits)
    for i in range(1, len(digits)):
        if digits[i-1] >= 10 or abs(digits[i]-digits[i-1]) >= 2:
            digits[i] += 1
            maxInc = i
        else:
            break
    # print(digits)
    if maxInc > 0:
        for i in range(maxInc, 0, -1):
            digits[i-1] = max(0, digits[i]-1)
    return digits


# go_next([9,8])


def main():
    K = int(input())

    digits = [0]
    for _ in range(K):
        digits = go_next(digits)

    print("".join(map(str, reversed(digits))))


if __name__ == '__main__':
    main()

Measured memory_bytes: 3444