akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h> 
#define rint register int
using namespace std;
set<pair<int,int> >st;
int a[222222],flag,n;
inline void pluss(int x,int now)
{
	pair<int,int>tmp;
	if(x<1) flag=-1;
	tmp=*st.lower_bound(make_pair(x,0));
	if(tmp.first!=x) st.insert(make_pair(x,0)),tmp=make_pair(x,0);
	else
	{
		st.erase(tmp);tmp.second++;
		if(tmp.second>=now) pluss(x-1,now);
		else st.insert(tmp);
	}
	while(1)
	{
		if(st.upper_bound(tmp)==st.end()) break;
		tmp=*st.upper_bound(tmp); st.erase(tmp);
	}
}
inline int check(int x)
{
	st.clear(); flag=0;
	for(rint i=1;i<=n;i++) if(a[i]<=a[i-1]) pluss(a[i],x-1);
	if(flag==-1)
		return 0;
	return 1;
}
inline int erf(int l,int r)
{
	while(l<=r)
	{
		int mid=l+r>>1;
		if(check(mid)) r=mid-1;
		else l=mid+1;
	}return l;
}
int main()
{
	cin>>n;int flag=1;
	for(rint i=1;i<=n;i++)
	{
		cin>>a[i];
		flag&=(a[i]>a[i-1]);
	}int ans;
	if(flag==1){cout<<1;return 0;}
	ans=erf(2,n);cout<<ans;
 	return 0;
}


Measured memory_bytes: 1024
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <vector>

#define rep(i,x,y) for (int i=x;i<=y;i++)
#define dep(i,y,x) for (int i=y;i>=x;i--)
#define sz(x) (int)(x.size())

using namespace std;

typedef long long LL; 
typedef unsigned long long uLL;

const int maxn=500+7;

int n,m;
char a[maxn][maxn],b[maxn][maxn],M[maxn][maxn];

int main()
{
 scanf("%d%d",&n,&m);
 rep(i,1,n)
 {
  scanf("%s",M[i]+1);
  rep(j,1,m) a[i][j]=M[i][j],b[i][j]=M[i][j];
 }
 
 rep(i,1,n) a[i][1]='#',b[i][m]='#';
 
 for (int i=1;i<=n;i+=2) rep(j,1,m-1) a[i][j]='#';
 for (int i=2;i<=n;i+=2) dep(j,m,2) b[i][j]='#';

 rep(i,1,n) printf("%s\n",a[i]+1);
 printf("\n");
 rep(i,1,n) printf("%s\n",b[i]+1);

 // system("pause");
 return 0;
}


Measured memory_bytes: 1536
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_map>
#define rep(i, a) for (int i = 0; i < (a); i++)
using namespace std;

int main(){
    long long int n, p;
    long long int ans;
    cin >> n >> p;

    if(n == 1){
        ans = p;
    }else if(p == 1){
        ans = 1;
    }else if(n >= 40){
        ans = 1;
    }else if(n >= 26){
        if(pow(2, n) <= p){
            if(p%(long long int)pow(2, n) == 0){
                ans = 2;
            }else{
                ans = 1;
            }
        }else{
            ans = 1;
        }
    }else{
        for(int i = 1; ; i++){
            if(pow(i, n) > p){
                break;
            }else{
                if(p%(long long int)pow(i, n) == 0){
                    ans = i;
                }
            }
        }
    }
    cout << ans << endl;
}


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

int main(){
  string w;
  cin >> w;
  int flag = 0;
  for(char c = 'a'; c <= 'z'; c++){
    int tmp = 0;
    for(auto ch:w){
      if(ch==c)tmp++;
    }
    if(tmp%2!=0)flag = 1;
  }
  if(flag)cout << "No" <<endl;
  else cout << "Yes" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define ss second
#define ff first
#define N 100005
#define inf 1000000009
#define ll long long
#define pii pair<int,int>
#define sz(a) int(a.size())
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}

ll n;
int ans,now,x;
vector <int> v;

int main(){
	scanf("%lld",&n);
	for(ll i = 2;i*i <= n;i++){
		now = 0;
		while(n % i == 0) now++,n/=i;
		if(now > 0) v.pb(now);
	}
	if(n > 1) ans++;
	for(auto i : v){
		now = 0,x = i;
		while(x - now > now) x-=now,now++;
		ans += now;
	}
	printf("%d",ans);
}


Measured memory_bytes: 3844
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
// #define main int main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
#define stlice(from, to) substr(from, (to) - (from) + 1)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vpii = vector<pii>;
using vvi = vector<vi>;
using vvb = vector<vb>;
using vvpii = vector<vpii>;
template<typename A> using fn = function<A>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
constexpr bool odd(const int &n) { return n & 1; }
constexpr bool even(const int &n) { return !odd(n); }
void solve();
main { solve(); return 0; }
// clang-format on

void solve() {
  string s;
  cin >> s;
  string t = "CODEFESTIVAL2016";
  int c    = 0;
  rep(i, s.size()) c += s[i] != t[i];
  cout << c << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long int n,a=0;
	cin>>n;
	long long int x[n];
	for(int i=0;i<n;i++)
	cin>>x[i];
	//sort(a,a+n);
	for(int i=1;i<n;i++)
	{
		if(x[i-1]<=x[i])
		continue;
		else
		{
			a+=x[i-1]-x[i];
			x[i]+=x[i-1]-x[i];
		}
	}
	cout<<a;
	return 0;
}

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

int N;
vint G[222222];
string S;
void dfs(int v,int p,int d,vint &dist){
    dist[v]=d;
    for(auto u:G[v]){
        if(u==p)continue;
        dfs(u,v,d+1,dist);
    }
}


    /*
    vint lim(N);
    rep(i,N)lim[i]=max(distS[i],distT[i])-1;
    rep(i,N)chmin(lim[i],R[i]+1);
*/


int ans;
int R[222222];
int dw[222222];


vint distS,distT;
void dfs2(int v,int p){
    R[v]=0;
    dw[v]=INT_MAX;
    for(auto u:G[v]){
        if(u==p)continue;
        dfs2(u,v);
        chmax(R[v],R[u]+1);
    }
    if(S[v]=='1')dw[v]=0;

    int lim=max(distS[v],distT[v])-1;
    chmin(lim,R[v]+1);
    ans+=max(0ll,lim-dw[v]+1);
    if(p!=-1)chmin(dw[p],max(dw[v]-1,R[v]+1));
}



signed main(){
    cin>>N;
    rep(i,N-1){
        int a,b;
        cin>>a>>b;
        a--;b--;G[a].pb(b);G[b].pb(a);
    }
    cin>>S;

    distS.resize(N);distT.resize(N);
    dfs(0,-1,0,distS);
    int s=0;
    rep(i,N)if(distS[i]>distS[s])s=i;
    dfs(s,-1,0,distS);
    int t=0;
    rep(i,N)if(distS[i]>distS[t])t=i;
    dfs(t,-1,0,distT);

    vint lis;
    rep(i,N){
        if(max(distS[i],distT[i])==(distS[t]+1)/2)lis.pb(i);
    }

    if(lis.size()==1){
        dfs2(lis[0],-1);
    }
    else{
        dfs2(lis[0],lis[1]);
        dfs2(lis[1],lis[0]);
    }
    cout<<ans+1<<endl;


    return 0;
}


Measured memory_bytes: 31108
#include<bits/stdc++.h>
using namespace std;
#define int long long
int f(int n){
    if(n%2==0)return n/2;
    else return 3*n+1;
}
int s,memo[200],ans=0;
signed main(){
    cin>>s;
    for(int i=1;;i++){
        if(i==1)memo[i]=s;
        else memo[i]=f(memo[i-1]);
        for(int j=1;j<i;j++){
            if(memo[i]==memo[j]){
                ans=i;
                break;
            }
        }
        if(ans!=0)break;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(){
  int n,h,w;
  cin>>n>>h>>w;
  
  int ans=0;
  for(int i=0;i<n;i++){
    int a,b;
    cin>>a>>b;
    if(a>=h&&b>=w)ans++;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 3504
import java.util.Scanner;

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

	String s1 = in.next();
	String s2 = in.next();
	String s3 = in.next();
	String s = s1.substring(0,1) + s2.substring(0,1) + s3.substring(0,1);

	in.close();

	System.out.println(s.toUpperCase());
	}
}

Measured memory_bytes: 21204
# -*- coding: utf-8 -*-
import sys
import copy
import collections
from bisect import bisect_left
from bisect import bisect_right
from collections import defaultdict
from heapq import heappop, heappush
import numpy as np
import statistics
from statistics import mean, median,variance,stdev
import math

def main():
	N = list(input())
	
	ans = 0
	for i in N:
		if i == "+":
			ans += 1
		else:
			ans -= 1
	
	print(ans)
	
	
if __name__ == "__main__":
	main()


Measured memory_bytes: 13316
import sys
## io ##
def IS(): return sys.stdin.readline().rstrip()
def II(): return int(IS())
def MII(): return list(map(int, IS().split()))
def MIIZ(): return list(map(lambda x: x-1, MII()))
## dp ##
def DD2(d1,d2,init=0): return [[init]*d2 for _ in range(d1)]
def DD3(d1,d2,d3,init=0): return [DD2(d2,d3,init) for _ in range(d1)]
## math ##
def to_bin(x: int) -> str: return format(x, 'b') # rev => int(res, 2)
def to_oct(x: int) -> str: return format(x, 'o') # rev => int(res, 8)
def to_hex(x: int) -> str: return format(x, 'x') # rev => int(res, 16)
MOD=10**9+7
def divc(x,y) -> int: return -(-x//y)
def divf(x,y) -> int: return x//y
def gcd(x,y):
    while y: x,y = y,x%y
    return x
def lcm(x,y): return x*y//gcd(x,y)
def enumerate_divs(n):
    """Return a tuple list of divisor of n"""
    return [(i,n//i) for i in range(1,int(n**0.5)+1) if n%i==0]
def get_primes(MAX_NUM=10**3):
    """Return a list of prime numbers n or less"""
    is_prime = [True]*(MAX_NUM+1)
    is_prime[0] = is_prime[1] = False
    for i in range(2, int(MAX_NUM**0.5)+1):
        if not is_prime[i]: continue
        for j in range(i*2, MAX_NUM+1, i): is_prime[j] = False
    return [i for i in range(MAX_NUM+1) if is_prime[i]]
def prime_factor(n):
    """Return a list of prime factorization numbers of n"""
    res = []
    for i in range(2,int(n**0.5)+1):
        while n%i==0: res.append(i); n //= i
    if n != 1: res.append(n)
    return res
## libs ##
from itertools import accumulate as acc, combinations as combi, product, combinations_with_replacement as combi_dup
from collections import deque, Counter
from heapq import heapify, heappop, heappush
from bisect import bisect_left
#======================================================#

def main():
    s = IS()
    t = IS()
    if s == t[::-1]: print('YES')
    else: print('NO')

if __name__ == '__main__':
    main()

Measured memory_bytes: 3316
#include<bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define pb push_back
#define powerof2 ()
#define mp make_pair
#define pi acos(-1)
using ll = long long;
const ll M = 1000000007;
const ll M1= 998244353;
using vl = vector<ll>;
using pll =  pair<ll,ll>;
ll power(ll x,ll y){
	if(y==0)
		return 1;
	ll res=power(x,y/2);
	res=(res*res);
	if(y&1)
		res=(res*x);
	return res;
}
 
ll powermod(ll x,ll y,ll mod){
	if(y==0)
		return 1;
	ll res=powermod(x,y/2,mod);
	res=(res*res)%mod;
	if(y&1)
		res=(res*x)%mod;
	return res;
}
/*ll binarysearch(ll va)
{
	ll n=1;
	ll l=va+1,u=n;
	ll st=num.order_of_key(va);
	while(l+1<u)
	{
		m=(l+u)/2;
		ll in=num.order_of_key(m);
		if(in-st==m-va)
		{
			l=m;
		}
		else
		{
            u=m;
		}
	}
	if(num1.find(l)==num1.end())
		return l;
	return u;
}*/
void solve(){
	int a,b;
	cin>>a>>b;
	if(a/10==0 && b/10==0) cout<<(a*b)<<"\n";
	else cout<<-1;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t=1;
    // cin>>t;
 
    for(int i=1;i<=t;i++)
    {//cout<<"Case #"<<i<<": ";
    solve();}
    return 0;
}

Measured memory_bytes: 3660
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
#define rep(i,n) for (ll i=0;i<(n);++i)
#define rep2(i,a,b) for (ll i=(a);i<(b);++i)
#define debug(x) cout << #x << '=' << x << endl
#define all(v) (v).begin(),(v).end()
const ll MOD=1e9+7;
//const ll MOD=998244353;
const ll INF=1e9;
const ll IINF=1e18;

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S; cin >> S;
    rep(i,S.size()){
        if (i&1){
            if (S[i]!='i'){
                cout << "No" << '\n';
                return 0;
            }
        } else {
            if (S[i]!='h'){
                cout << "No" << '\n';
                return 0;
            }
        }
    }
    cout << (S.size()%2==0?"Yes":"No") << '\n';
}

Measured memory_bytes: 256
/**
 *    Coded by : lucky_21
 *               --------Lokesh Singh
**/

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

#include<ext/pb_ds/tree_policy.hpp>
#include<ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
template<class T> using oset=tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;

#define     F           first
#define     S           second
#define     pb          push_back
#define     lb          lower_bound
#define     ub          upper_bound
#define     pii         pair<int,int>
#define     all(x)      x.begin(),x.end()
#define     fix         fixed<<setprecision(10)
#define     rep(i,a,b)  for(int i=int(a);i<=int(b);i++)
#define     repb(i,b,a) for(int i=int(b);i>=int(a);i--)
#define     FastIO      ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)

typedef double db;
typedef long long ll;

const int N=2e5+5;
const int mod=1e9+7;

signed main(){
    FastIO;
    string s;
    cin>>s;
    int sum=0;
    rep(i,0,s.size()-1){
        sum=sum*10+(s[i]-'0');
        sum%=9;
    }
    cout<<(sum?"No":"Yes");
    return 0;
}


Measured memory_bytes: 3776
N, Y = [int(s) for s in input().split(" ")]
Y = int(Y/1000)
# 10a + 5b + c = Y
# a + b + c = N
ans = []
for i in range(N + 1):
  for j in range(N + 1 - i):
    if N - i - j >= 0 and Y - 10 * i - 5 * j == N - i - j:
      ans += [str(i), str(j), str(N - i - j)]
      break
  else:
    continue
  break


if len(ans):
  print(" ".join(ans))
else:
  print("-1 -1 -1")

Measured memory_bytes: 9136
#include<bits/stdc++.h>
using namespace std;
const int N=1505;
int n,m,u,v,ans;
bool mp[N][N],dp[N][N];
int col[N],cnt[5];
void dfs(int x,int c){
    col[x]=c;
    cnt[c]++;
    for(int i=1;i<=n;++i){
        if(!mp[x][i]) continue;
        if(!col[i]) dfs(i,c^1);
        else if(col[i]==c){
            puts("-1");
            exit(0);
        }
    }
}

int main(){
    scanf("%d%d",&n,&m);
    for(int i=1;i<=m;++i){
        scanf("%d%d",&u,&v);
        mp[u][v]=mp[v][u]=1;
    }
    for (int i=1;i<=n;++i)
    	for (int j=1;j<=n;++j)
    		if (i!=j) mp[i][j]^=1;
    dp[0][0]=1;
    int tot1=0;
    for(int i=1;i<=n;++i){
        if(col[i]) continue;
        cnt[2]=cnt[3]=0;
        dfs(i,2);
        ++tot1;
        for(int j=0;j<=n;++j){
        	if (j>=cnt[2]) dp[tot1][j]|=dp[tot1-1][j-cnt[2]];
        	if (j>=cnt[3]) dp[tot1][j]|=dp[tot1-1][j-cnt[3]];
        }
    }
    ans=0x7fffffff;
    for(int i=0;i<=n;i++)
        if(dp[tot1][i])
            ans=min(ans,i*(i-1)/2+(n-i)*(n-i-1)/2);
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 5660
while 1:
    n,m = map(int,input().split())
    if n == 0 and m == 0:
        break
    a = list(map(int,input().split()))
    Max = -9999999999
    for i in range(n):
        for j in range(n):
            if i != j:
                if m >= (a[i] + a[j]):
                    Max = max(Max,(a[i] + a[j]))
    if Max < 0:
        print("NONE")
    else:
        print(Max)


Measured memory_bytes: 5624
import java.util.Scanner;

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

    while(n!=0){
      n = sc.nextInt();
      if(n==0) {
        break;
      }
      int [] s;
      s = new int [n];
      for(int i=0;i<n;i++){
        s[i] = sc.nextInt();
      }
      double var=0,ave=0;
       for(int i=0;i<n;i++){
         ave += s[i];
       }
       ave = (double)ave/n;

       for(int i=0;i<n;i++){
         var += ((double)s[i]-ave)*((double)s[i]-ave);
       }
       var = var/n;
       System.out.printf("%.8f\n",Math.sqrt(var));
    }
    sc.close();
  }
}



Measured memory_bytes: 31956
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <set>
#include <sstream>
#include <bitset>
#include <stack>
#include <cstdlib>

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

typedef long long ll;

using namespace std;

int main() {
    
    int n;
    cin >> n;
    
    vector<int> a(n);
    FOR(i, 0, n){
        cin >> a[i];
    }
    
    sort(a.begin(),a.end());
    
    int max = a[n-1];
    
    cout << max << endl;
    
    if(max%2 ==0){
        int mid = max/2;
        int i=0;
        while(a[i] < mid){
            i++;
        }
        
        if(mid - a[i-1] > a[i] - mid){
            cout << a[i] << endl;
        }else{
            cout << a[i-1] << endl;
        }
    }else{
        int mid1 = max/2;
        int mid2 = max/2+1;
        int i=0;
        while(a[i] <= mid1){
            i++;
        }
        if(mid1 - a[i-1] > a[i] - mid2){
            cout << a[i] << endl;
        }else{
            cout << a[i-1] << endl;
        }
    }
    
    
    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cstdio>
#include <cmath>
#include <cstring>

#define ll long long
#define scani(x) scanf("%i", &x)
#define scanll(x) scanf("%I64d", &x)
#define scanfl(x) scanf("%f", &x)
#define scanch(x) scanf("%c", &x)
#define scans(x) scanf("%s", x);
#define printi(x) printf("%i", x);
#define printll(x) printf("%I64d", x);
#define printfl(x) printf("%f", x);
#define printch(x) printf("%c", x);
#define prints(x) printf("%s", x);
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define INFI (1 << 29)
#define INFL (1LL << 62)
#define sz(x) int(x.size())
#define fi first
#define se second
#define forn(i, n) for(ll i = 0; i < n; i++)
#define for1(i, n) for(ll i = 1; i <= n; i++)
#define ford(i, n) for(ll i = (n - 1); i >= 0; i--)
#define fori(i, n) for(ll i = n; i >= 1; i--)
#define fore(i, l, r) for(ll i = l; i <= r; i++)

using namespace std;

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

    ll n;

    cin >> n;

    cout << (((n == 7) || (n == 5) || (n == 3)) ? "YES" : "NO") << "\n";

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
    int H, N;
    cin >> H >> N;
    int A[N], B[N];
    for (int i = 0; i < N; i++) {
        cin >> A[i] >> B[i];
    }
    int l = 30000;
    ll INF = 10000000000;
    ll d[l];
    fill(d, d + l, INF);
    d[0] = 0;
    
    for (int i = 0; i < H; i++) {
        if (d[i] == INF) continue;
        for (int j = 0; j < N; j++) {
            d[i + A[j]] = min(d[i + A[j]], d[i] + B[j]);
        }
    }
    ll ans = INF;
    for (int i = H; i < l; i++) {
        ans = min(ans, d[i]);
    }
    cout << ans << "\n";
    return 0;
}


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

#define rep(i, n) for(int i = 0; i < (n); i++)
using ll = long long;
constexpr ll INF = 1000000000;

using namespace std;

ll gcd(ll a, ll b) {
	if (b == 0)return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	return a * b / gcd(a, b);
}

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

	deque<int>de;

	rep(i, n) {
		int a;
		cin >> a;
		if (i % 2 == 0) {
			de.push_back(a);
		}
		else {
			de.push_front(a);
		}
	}

	if (n % 2 == 0) {
		rep(i, n) {
			cout << de[i] << ' ';
		}
	}
	else {
		reverse(de.begin(), de.end());
		rep(i, n) {
			cout << de[i] << ' ';
		}
	}
}


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

typedef long long int64;

int main()
{
    int64 n, m, h;
    cin >> n >> m;
    if (m - 2 * n > 0)
    {
        h = (m - 2 * n) / 4;
        n += h;
        m -= 2 * h;
    }
    if (m - 2 * n >= 0)
        cout << n << endl;
    else
        cout << m / 2 << endl;
}


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

int main() {
	char v[5];
	cin >> v ;

	for (int i=0;i<3;i++) {
		for (int j = i + 1;j < 3;j++) {
			if (v[i] == v[j]) {
				cout << "No\n";
				return 0;
			}
		}
	}
	
	cout << "Yes\n";
	
	return 0;
}



Measured memory_bytes: 256
import sys
X,N = map(int,input().split())
if N == 0:
	print(X)
	sys.exit()
P = list(map(int,input().split()))
i = 0
while True:
	if not X-i in P:
		print(X-i)
		break;
	if not X+i in P:
		print(X+i)
		break;
	i += 1



Measured memory_bytes: 9176
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;

int main(){
	int n,m;cin>>n >>m;
	if(n == m){
		cout << "Yes" << endl;
	}
	else{
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 768
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>
#include <stack>



#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = (int)(n-1); i >= 0; i--)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define all(x) (x).begin(),(x).end()

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

typedef long long ll;

using namespace std;


int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n,t;cin>>n>>t;
  struct di{
    ll a,b;
  };
  vector<di> ds(n);
  rep(i,n){
    cin>>ds[i].a>>ds[i].b;
  }
  sort(all(ds),[&](di a,di b){return a.a<b.a;});
  vector<ll>dp(t);
  ll res=0;
  rep(i,n){
    auto tdp=dp;
    rep(j,t){
      if(j+ds[i].a<t)chmax(tdp[j+ds[i].a],dp[j]+ds[i].b);
      else chmax(res,dp[j]+ds[i].b);

    }
    dp=tdp;
  }
  rep(i,t){
    chmax(res,dp[i]);
  }
  cout<<res<<endl;

  return 0;

}


Measured memory_bytes: 384
#include <iostream>
using namespace std;
int main() 
{
    long a, b, c, d, tmp;
    while (std::cin >> a >> b) {
    	d = a * b;
		if(a < b) {
            tmp = a;
            a = b;
            b = tmp;
        }
 
    c = a % b;
    while(c != 0) {
        a = b;
        b = c;
        c = a % b;
    }
    cout << b << " " << d / b << endl;
    }
       return 0;
}


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

typedef long long ll;
typedef long double Double;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

// chmax, chmin
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;
}

void solve(long long A, long long B, long long K) {
  vector<int> s;
  for(int i = 1 ; i <= 100000 ; i++){
    if( A % i == 0 && B % i == 0 ){
      s.push_back(i);
    }
  }
  reverse(s.begin(), s.end());
  cout << s[K-1] << endl;
}

int main() {
  long long A;
  scanf("%lld", &A);
  long long B;
  scanf("%lld", &B);
  long long K;
  scanf("%lld", &K);
  solve(A, B, K);
  return 0;
}


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

using namespace std;
typedef long long ll;
    
int main()
{
    int N, M;
    cin >> N >> M;
    vector<int> A;
    for (int i = 0; i < N; i++) {
        int tmp;
        cin >> tmp;
        A.push_back(tmp);
    }

    for (int i = 0; i < M; i++) {
        N -= A[i];
        if (N < 0) {
            cout << -1;
            return 0;
        }
    }
    cout << N;

    return 0;
}


Measured memory_bytes: 7460
N = int(input())
D = {i: [] for i in range(N)}
DD = {}
L = [list(map(int, input().split())) for _ in range(N-1)]
Q, K = map(int, input().split())
dist = [-1 for i in range(N)]
for i in range(N-1):
  D[L[i][0]-1].append(L[i][1]-1)
  D[L[i][1]-1].append(L[i][0]-1)
  DD[(L[i][0]-1)*N+L[i][1]-1], DD[(L[i][1]-1)*N+L[i][0]-1] = L[i][2], L[i][2]
dist[K-1] = 0
p = [K-1]
while p != []:
  n = len(p)
  for i in range(n):
    q = p[i]
    X = D[q][:]
    for j in X:
      if dist[j] < 0:
        dist[j] = dist[q] + DD[q*N+j]
        p.append(j)
  p = p[n:]
for i in range(Q):
  x, y = map(int, input().split())
  print(dist[x-1] + dist[y-1])

Measured memory_bytes: 77672
n = int(input())
s = input()
ans = s.count('R')*s.count('G')*s.count('B')

for i in range(n-2):
    for j in range(i+1, n-1):
        k = j + (j - i)
        if k > n-1:
            break
        if s[i] != s[j] and s[j] != s[k] and s[k] != s[i]:
            ans -= 1
print(ans)

Measured memory_bytes: 9176
K = int(input())
a = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(str(a[K-1]))

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

int m;
long long n,ans;
int p[105],q[105];
long long mu[105];

void exgcd(long long x,long long y,long long &a,long long &b){
	if(y==0){
		a=1;
		b=0;
	}else{
		exgcd(y,x%y,a,b);
		long long c=a;
		a=b;
		b=c-x/y*b;
	}
}

void dfs(int x,long long mul){
	if(x==m){
		if(mul!=1ll&&mul!=n){
			long long r1,r2;
			exgcd(mul,n/mul,r1,r2);
			ans=min(ans,-1ll*min(mul*r1,n/mul*r2));
		}
		return;
	}
	dfs(x+1,mul);
	dfs(x+1,mul*mu[x+1]);
}

int main(){
	scanf("%lld",&n);
	if(n==1ll){
		puts("1");
		return 0;
	}
	n*=2;
	ans=n;
	long long rn=n;
	for(long long i=2ll;i*i<=rn;i++) if(rn%i==0ll){
		p[++m]=i;
		mu[m]=1ll;
		while(rn%i==0ll){
			rn/=i;
			q[m]++;
			mu[m]*=i;
		}
	}
	if(rn!=0ll){
		p[++m]=rn;
		mu[m]=rn;
		q[m]=1;
	}
	dfs(0,1ll);
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 3844
#include<bits/stdc++.h>
//#include<atcoder/all>

using namespace std;
//using namespace atcoder;

int main(){
    int a,b,c;
    cin>>a>>b>>c;
    if((a<=c&&c<=b)||(b<=c&&c<=a)) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


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

int main(){
	int n,m;cin>>n>>m;
	pair<int,int> to[m];
	rep(i,m) cin>>to[i].first>>to[i].second;

	vector<int> ft,tt;
	rep(i,m){
		if(to[i].first==1) ft.push_back(to[i].second);
	}
	rep(i,m){
		if(to[i].second==n) tt.push_back(to[i].first);
	}
	int lft=ft.size(),ltt=tt.size();
	sort(ft.begin(),ft.end());
	sort(tt.begin(),tt.end());

	if(!tt.empty()){
		rep(i,lft){
			if(ft[i]==*lower_bound(tt.begin(),tt.end(),ft[i])){
				cout<<"POSSIBLE"<<"\n";
				return 0;
			}
		}
	}
	cout<<"IMPOSSIBLE"<<"\n";
}

Measured memory_bytes: 2936
n = gets.to_i

count = Hash.new(0)

(1..105).each do |x|
  (x..105).each do |y|
    (y..105).each do |z|
      tmp = x * x + y * y + z * z + x * y + y * z + z * x
      break if tmp > n
      count[tmp] += case
                    when x == y && y == z
                      1
                    when x == y || y == z || z == x
                      3
                    else
                      6
                    end
    end
  end
end

puts (1..n).map {count[_1]}

Measured memory_bytes: 14764
def N(n):
    return (n+1)*(n+2)*(n+3)/6

while True:
    try:
        n = int(raw_input())
        if n > 2000:
            n = 4000 - n
        if n < 1001:
            print N(n)
        else:
            m = n - 1000
            print N(n) - (N(2*m) - m - 1)/2
    except:
        break

Measured memory_bytes: 4212
#include "bits/stdc++.h"

using namespace std;

template <typename T>
struct BIT
{
	int N, K;
	vector<T> bit;

	BIT(int X)
	{
		bit = vector<T>(X + 1, 0);
		N = X + 1;
		K = pow(2, (int)(log(X) / log(2)));
	}

	void add(int idx, T w)
	{
		for (int x = idx; x <= N; x += x & -x)
		{
			bit[x] += w;
		}
	}

	T sum(int idx)
	{
		T res = 0;
		for (int x = idx; x > 0; x -= x & -x)
			res += bit[x];
		return res;
	}

	int lb(T w)
	{
		int k = K, idx = 0;

		while (k > 0)
		{
			if (idx + k <= N && w > bit[idx + k])
			{
				w -= bit[idx + k];
				idx += k;
			}
			k >>= 1;
		}

		return idx + 1;
	}
};

void solve(void)
{
	int q, x, a, b;
	cin >> q;
	vector<pair<int, pair<int, int>>> qs(q);
	set<int> s;
	for (int i = 0; i < q; i++)
	{
		cin >> x;
		if (x == 1)
		{
			cin >> a >> b;
			qs[i] = {x, {a, b}};
			s.insert(a);
		}
		else
		{
			qs[i] = {x, {0, 0}};
		}
	}
	int cnt = 0;
	map<int, int> mp, rev;
	for (int v : s)
	{
		mp[v] = ++cnt;
		rev[cnt] = v;
	}
	BIT<long> bitcnt(cnt+1), bitsum(cnt+1);

	long sumb = 0;
	int now = 0;
	for (auto &q : qs)
	{
		if (q.first == 1)
		{
			sumb += q.second.second;
			long z = q.second.first, v = mp[z];
			bitcnt.add(v, 1);
			bitsum.add(v, z);
			now++;
		}
		else
		{
			int idx = bitcnt.lb((now + 1) / 2);
			long res = sumb, rv = rev[idx];
			res += bitsum.sum(cnt) - 2 * bitsum.sum(idx) + (bitcnt.sum(idx)*2 - now) * rv;
			cout << rv << ' ' << res << endl;
		}
	}

}

int main()
{
	solve();
	//cout << "yui(*-v・)yui" << endl;
	return 0;
}


Measured memory_bytes: 20608
X, Y, A, B, C = list(map(int, input().split()))
P = sorted(list(map(int, input().split())), reverse=True)[:X]
Q = sorted(list(map(int, input().split())), reverse=True)[:Y]
R = sorted(list(map(int, input().split())), reverse=True)  # 降順=入れたい順

cands = sorted(P + Q)  # 昇順=消して欲しい順

c_ind = 0
r_ind = 0

while True:
    if c_ind >= len(cands) or r_ind >= len(R):
        break
    c = cands[c_ind]
    r = R[r_ind]
    if c >= r:
        break
    else:
        c_ind += 1
        r_ind += 1

print(sum(cands[c_ind:]) + sum(R[:r_ind]))


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

using namespace std;

const int N = 100;
const int INF = 100000000;
typedef pair<int, int> P;

class S{
public:
   int pos, cost, s;
   S(){}
   S(int pos, int cost, int s) : pos(pos), cost(cost), s(s) {}
   bool operator < (const S& t) const {
      if(cost == t.cost){
         return s > t.s;
      }
      return cost > t.cost;
   }
};

int n, m;
vector<P> G[N];
int dist[N][3];

void dijkstra(){
   priority_queue<S> que;
   fill(dist[0], dist[N], INF);
   dist[0][0] = 0;
   que.push(S(0, 0, 0));
   while(!que.empty()){
      S p = que.top(); que.pop();
      int v = p.pos;
      int v2 = p.s;
      if(dist[v][v2] < p.cost) continue;
      for(int i=0;i<G[v].size();i++){
         P e = G[v][i];
         if(v2 == 0){
            if(dist[e.first][1] > dist[v][v2]){
               dist[e.first][1] = dist[v][v2];
               que.push(S(e.first, dist[v][v2], 1));
            }
            if(dist[e.first][0] > dist[v][v2] + e.second){
               dist[e.first][0] = dist[v][v2] + e.second;
               que.push(S(e.first, dist[v][v2] + e.second, 0));
            }
         }
         if(v2 == 1){
            if(dist[e.first][2] > dist[v][v2]){
               dist[e.first][2] = dist[v][v2];
               que.push(S(e.first, dist[v][v2], 2));
            }
         }
         if(v2 == 2){
            if(dist[e.first][2] > dist[v][v2] + e.second){
               dist[e.first][2] = dist[v][v2] + e.second;
               que.push(S(e.first, dist[v][v2] + e.second, 2));
            }
         }
      }
   }
}

main(){
   while(cin >> n >> m && (n|m)){
      for(int i=0;i<n;i++) G[i].clear();
      for(int i=0;i<m;i++){
         int a, b, c;
         cin >> a >> b >> c;
         a--;
         b--;
         G[a].push_back(P(b, c));
         G[b].push_back(P(a, c));
      }
      dijkstra();
      cout << min(dist[n-1][0], dist[n-1][2]) << endl;
   }
}

Measured memory_bytes: 0
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scanln(&n)

	for {
		if n < 4 {
			fmt.Printf("No\n") // output for debug
			return
		}
		if n%4 == 0 {
			fmt.Printf("Yes\n") // output for debug
			return
		}
		if n%7 == 0 {
			fmt.Printf("Yes\n") // output for debug
			return
		}
		if n%2 != 0 {
			n -= 7
		} else {
			n -= 4
		}
	}

}


Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <stdlib.h>
#include <map>
#include <cmath>
#define MOD_P 1000000007
#define ll long long
using namespace std;

int main()
{
	int a, b;
	int ans = 0;
	cin >> a >> b;
	int now = 1;

	while (now < b) {
		now += a - 1;
		ans++;
	}

	printf("%d", ans);

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
  char c;
  int a,b;
  scanf("%d %d",&a,&b);
  if (a == 1) {
    if (b==1)
      printf("Draw\n");
    else
      printf("Alice\n");
  }else if (b==1) {
    if (a == 1)
      printf("Draw\n");
    else
      printf("Bob\n");
  }else{
    if (a > b && b)
      printf("Alice\n");
    else if (a<b)
      printf("Bob\n");
    else
      printf("Draw\n");
  }
  return 0;
}


Measured memory_bytes: 128
import java.util.Arrays;

public class Main {
  private static void solve() {
    long Q = nl();
    long H = nl();
    long S = nl();
    long D = nl();
    long N = nl();
    
    
    long[][] a = {{Q * 8, 1, Q * 4}, {H * 4, 1, H * 2}, {S * 2, 1, S}, {D, 2, D}};
    Arrays.sort(a, (o1, o2) -> Long.compare(o1[0], o2[0]));

    long cost = 0;
    for (int i = 0; i < 4; i ++) {
      long num = N / a[i][1];
      cost += num * a[i][2];
      N -= num * a[i][1];
    }
    System.out.println(cost);
  }

  public static void main(String[] args) {
    new Thread(null, new Runnable() {
      @Override
      public void run() {
        long start = System.currentTimeMillis();
        String debug = System.getProperty("debug");
        if (debug != null) {
          try {
            is = java.nio.file.Files.newInputStream(java.nio.file.Paths.get(debug));
          } catch (Exception e) {
            throw new RuntimeException(e);
          }
        }
        reader = new java.io.BufferedReader(new java.io.InputStreamReader(is), 32768);
        solve();
        out.flush();
        tr((System.currentTimeMillis() - start) + "ms");
      }
    }, "", 64000000).start();
  }

  private static java.io.InputStream is = System.in;
  private static java.io.PrintWriter out = new java.io.PrintWriter(System.out);
  private static java.util.StringTokenizer tokenizer = null;
  private static java.io.BufferedReader reader;

  public static String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }

  private static double nd() {
    return Double.parseDouble(next());
  }

  private static long nl() {
    return Long.parseLong(next());
  }

  private static int[] na(int n) {
    int[] a = new int[n];
    for (int i = 0; i < n; i++)
      a[i] = ni();
    return a;
  }

  private static char[] ns() {
    return next().toCharArray();
  }

  private static long[] nal(int n) {
    long[] a = new long[n];
    for (int i = 0; i < n; i++)
      a[i] = ni();
    return a;
  }

  private static int[][] ntable(int n, int m) {
    int[][] table = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[i][j] = ni();
      }
    }
    return table;
  }

  private static int[][] nlist(int n, int m) {
    int[][] table = new int[m][n];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[j][i] = ni();
      }
    }
    return table;
  }

  private static int ni() {
    return Integer.parseInt(next());
  }

  private static void tr(Object... o) {
    if (is != System.in)
      System.out.println(java.util.Arrays.deepToString(o));
  }
}




Measured memory_bytes: 27092
// #define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <locale>
#include <cctype>
#include <sstream>	// istringstream
using namespace std;

void Output(vector<pair<int, double> > ans){
	for (int i = 0; i < ans.size(); i++){
		printf("%d %.2lf\n", ans[i].first, ans[i].second);
	}
}

int main(){
	// 注意：it = hogehoge.erase(it) 使用時はC++11でコンパイル.

	int number = 0, count = 0;
	double time = 0.0;
	map<double, int>	time_number;
	vector<pair<int, double> > ans;
	map<double, int>	plus2;

	while (cin >> number >> time){
		count++;
		time_number.insert(pair<double, int>(time, number));

		if (count == 8){
			map<double, int>::iterator it = time_number.begin();
			// 上位2人をansに格納
			for (int i = 0; i < 2; i++){
				ans.push_back(make_pair((*it).second, (*it).first));
				it = time_number.erase(it);
			}
			// それ以外はplus2に格納
			for (map<double, int>::iterator it = time_number.begin(); it != time_number.end(); it++){
				double first = (*it).first;
				int second = (*it).second;
				plus2.insert(pair<double, int>(first, second));
			}
			count = 0;
			time_number.clear();
		}
	}
	// ここまでで6人決まった

	// plus2の上位2人をansに格納
	map<double, int>::iterator it = plus2.begin();
	for (int i = 0; i < 2; i++){
		ans.push_back(make_pair((*it).second, (*it).first));
		it = plus2.erase(it);
	}

	Output(ans);
	return 0;
}

Measured memory_bytes: 1240
unittest
{
	assert( [ "5", "3 2 4 1 2" ].solve == 2 );
	assert( [ "10", "10 71 84 33 6 47 23 25 52 64" ].solve == 36 );
	assert( [ "7", "1 2 3 1000000000 4 5 6" ].solve == 999999994 );
}



import std.algorithm;
import std.conv;
import std.math;
import std.range;
import std.stdio;

void main()
{
	stdin.byLineCopy.solve.writeln;
}

auto solve( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto n = input.front.to!( long );
	input.popFront;
	auto as = input.front.split.to!( long[] );
	
	// 累積和表を作成
	auto ts = new long[ 1 + as.length ];
	foreach( i, a; as )
	{
		ts[ i + 1 ] = ts[ i ] + a;
	}
	
	// pとrの区切りを全探索する
	auto ans = long.max;
	auto bs = [ 0L, 1L, 2L, 3L, ts.length.signed - 1 ];
	for( ; bs[ 2 ] < ts.length.signed - 2; bs[ 2 ]++ )
	{
		if( bs[ 3 ] <= bs[ 2 ] ) bs[ 3 ] = bs[ 2 ] + 1;
		
		// しゃくとり法でpとqの差を最小にする
		auto p = ts[ bs[ 1 ] ] - ts[ bs[ 0 ] ];
		auto q = ts[ bs[ 2 ] ] - ts[ bs[ 1 ] ];
		auto pq = abs( p - q );
		for( ; bs[ 1 ] + 1 < bs[ 2 ]; bs[ 1 ]++ )
		{
			auto pp = ts[ bs[ 1 ] + 1 ] - ts[ bs[ 0 ] ];
			auto qq = ts[ bs[ 2 ] ] - ts[ bs[ 1 ] + 1 ];
			auto ppqq = abs( pp - qq );
			if( pq <= ppqq ) break;
			p = pp;
			q = qq;
			pq = ppqq;
		}
		
		// しゃくとり法でrとsの差を最小にする
		auto r = ts[ bs[ 3 ] ] - ts[ bs[ 2 ] ];
		auto s = ts[ bs[ 4 ] ] - ts[ bs[ 3 ] ];
		auto rs = abs( r - s );
		for( ; bs[ 3 ] + 1 < bs[ 4 ]; bs[ 3 ]++ )
		{
			auto rr = ts[ bs[ 3 ] + 1 ] - ts[ bs[ 2 ] ];
			auto ss = ts[ bs[ 4 ] ] - ts[ bs[ 3 ] + 1 ];
			auto rrss = abs( rr - ss );
			if( rs <= rrss ) break;
			r = rr;
			s = ss;
			rs = rrss;
		}
		
		// 総和の最大と最小の差を計算
		ans = min( ans, max( p, q, r, s ) - min( p, q, r, s ) );
	}
	return ans;
}


Measured memory_bytes: 13156
l=[int(input()) for i in range(5)]
k=int(input())
A=True
for i in range(4):
  for j in range(i+1,5):
    a=l[j]-l[i]
    if a>k:
      A=False
      break
if A:
  print('Yay!')
else:
  print(':(')
    


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

using namespace std;

const int mod = 1e9 + 7;
int n;
int c[200005];
int f[200005];
int s[200005];

int main(void) {
    ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
    cin >> n;
    for (int i = 1; i <= n; ++i) cin >> c[i];
    f[0] = 1;
    for (int i = 1; i <= n; ++i) {
        if (c[i] == c[i-1]) {
            f[i] = f[i-1];
            continue;
        }
        f[i] = (f[i-1] + s[c[i]]) % mod;
        s[c[i]] = (s[c[i]] + f[i-1]) % mod;
    }
    cout << f[n] << endl;
    return 0;
}


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

int main(void){
    int A, B;
    cin >> A >> B;
    int count = 0;
    int check;
    string s;
    
    while(A <= B){
        check = 0;
        s = to_string(A);
        for(int i = 0; i < 5; i++){
            if(s[i] == s[4-i])
                check++;
        }
        if(check == 5)
            count++;
        A++;
    }

    cout << count << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=2e5+5;
int n,ans,now,cnt,b[N],vi[N];
map<__int128,__int128>ma,pos;
__int128 a[N<<1];
int main(){
	scanf("%d",&n);
	for(int i=2;i<N;i++){
		if(!vi[i])	b[++now]=i;
		for(int j=1;j<=now&&b[j]*i<N;j++){
			vi[i*b[j]]=1;
			if(i%b[j]==0)	break;
		}
	}
	for(int i=1;i<=n;i++){
		__int128 x,val=1,res=1;
		long long h;

		scanf("%lld",&h),x=h;
		int k=pow(x+0.5,1.0/3);
		for(int i=1;i<=now;i++)
			if(b[i]>k)	break;
			else{
				int d=0;
				while(x%b[i]==0)
					x/=b[i],++d;
				d%=3;
				if(!d)	continue;
				if(d==1)	val*=b[i],res*=b[i]*b[i];
				else	val*=b[i]*b[i],res*=b[i];
			}
		k=sqrt(x),val*=x;
		if(1LL*k*k==x)	res*=k;
		else	res*=x*x;
		pos[val]=res,pos[res]=val,++ma[val],a[++cnt]=res,a[++cnt]=val;
	}
	sort(a+1,a+cnt+1);
	n=unique(a+1,a+cnt+1)-a-1;
	for(int i=1;i<=n;i++){
		if(pos[a[i]]>a[i])	ans+=max(ma[a[i]],ma[pos[a[i]]]);
		else	if(pos[a[i]]==a[i])	++ans;
	}
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 36608
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**5)

N = int(input())
ab = [[int(i) for i in input().split()] for _ in range(N - 1)]

v = [[] for _ in range(N)]
for i, (a, b) in enumerate(ab) :
    v[a-1].append((b-1, i))
    v[b-1].append((a-1, i))

ret = [0] * (N - 1)

def dfs(pre, cur, color) :
    i = 1
    for nex, j in v[cur] :
        if nex != pre :
            if i == color :
                i += 1
            ret[j] = i
            dfs(cur, nex, i)
            i += 1

dfs(-1, 0, 0)

print(max(ret))
for r in ret :
    print(r)


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

int main() {
  int N;
cin>>N;
vector<int> v(N);
  for(int i=0;i<N;i++){
   cin>>v.at(i); 
  }
  int n=0;
   for(int i=0;i<N;i++){
  if(v.at(i)%2==0){
  if(v.at(i)%3!=0&&v.at(i)%5!=0){
    n++;
  }
  }
   }
  if(n==0){
    cout<<"APPROVED"<<endl;
  }
  else{
    cout<<"DENIED"<<endl;
  }
}


Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <cassert>
using namespace std;
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define EACH(t,i,c) for(t::iterator i=(c).begin(); i!=(c).end(); ++i)
const double EPS = 1e-10;
const double PI  = acos(-1.0);

int main(){
	int n,m;
	while(cin>>n,n){
		vvi field(21,vi(21));
		for (int i = 0; i < n; i++)
		{
			int x,y;
			cin>>x>>y;
			field[x][y]=1;
		}
		cin>>m;
		int cx=10,cy=10;
		int cnt=0;
				if(field[cx][cy]){
					cnt++;
					field[cx][cy]=0;
				}
		for (int i = 0; i < m; i++)
		{
			char d;
			int l;
			cin>>d>>l;
			for (int j = 0; j < l; j++)
			{
				switch(d){
				case 'N':
					cy++;break;
				case 'S':
					cy--;break;
				case 'E':
					cx++;break;
				case 'W':
					cx--;break;
				default:
					assert(0);
				}
				if(field[cx][cy]){
					cnt++;
					field[cx][cy]=0;
				}
			}
		}
		cout<<(cnt==n?"Yes":"No")<<endl;
	}

}

Measured memory_bytes: 1212
if __name__ == '__main__':
    n, k = map(int, input().split())
    snuke = [0] * n
    for i in range(k):
        d = int(input())
        a = list(map(int, input().split()))
        for j in a:
            snuke[j - 1] += 1
    print(snuke.count(0))


Measured memory_bytes: 9124
#include<iostream>
#include<iomanip>
#include<stdio.h>
#include<vector>
#include<list>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<string>
#include<algorithm>
#include<functional>
#include<math.h>
#include<unordered_set>

using namespace std;

int main() {
	int ans = 700;
	for (int i = 0; i < 3; i++) {
		char ch;
		cin >> ch;
		if (ch == 'o')ans += 100;
	}

	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
function main(arg) {
	var s = arg.trim().split("\n")[0].split("")
	var od0 = 0
	var od1 = 0
	var ev0 = 0
	var ev1 = 0
	for (var i = 0; i < s.length; i++) {
		if (i % 2 === 0) {
			if (s[i] === '0') {
				od0++
			} else {
				od1++
			}
		} else {
			if (s[i] === '0') {
				ev0++
			} else {
				ev1++
			}
		}
	}
	var a = od0 + ev1
	var b = od1 + ev0
	console.log(Math.min(a, b))
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 9292
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fi first
#define sec second
#define opr iterator
typedef long long ll;
using namespace std;
int main()
{
	int a,b;
	cin>>a>>b;
	if(a>=13)
	{
		cout<<b<<endl;
	}
	else if(a<=12&&a>=6)
	{
		cout<<b/2<<endl;
	}
	else
	{
		cout<<0<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
def c():
    n, k = map(int, input().split())
    U = []
    for i in range(n):
        U.append(tuple(map(int, input().split())))
    U = sorted(U, key=lambda i: i[0])
    # print(U)
    for i in U:
        k -= i[1]
        if k <= 0:
            print(i[0])
            break

c()


Measured memory_bytes: 18960
#include <stdio.h>
#include <iostream>
using namespace std;

int main(){
	int r,c;
	cin>>r>>c;
	int N[r][c];
	int M[r+1][c+1];
	
	for(int i=0;i<r+1;i++){
		for(int j=0;j<c+1;j++){
			M[i][j] = 0;
		}
	}
	
	for(int i=0;i<r;i++){
		for(int j=0;j<c;j++){
			cin>>N[i][j];
			M[i][j] = N[i][j];
		}
	}
	
	for(int i=0;i<r;i++)
		for(int j=0;j<c;j++)
			M[i][c]+=M[i][j];
		
	for(int i=0;i<c+1;i++)
		for(int j=0;j<r;j++)
			M[r][i]+=M[j][i];
	
//	for(int i=0;i<r+1;i++){
//		for(int j=0;j<c+1;j++)
//			printf("%d ", M[i][j]);
//		cout<<endl;
//	}
	for(int i = 0; i < r+1; i++){
        for(int j = 0; j < c; j++){
            printf("%d ",M[i][j]);
        }
        printf("%d\n",M[i][c]);
    }
    
    
	return 0;
}


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

signed main(){

    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int n; cin >> n;
    int mn = 3 * 100000;
    int p;
    int cnt = 0;
    rep(i,n){
        cin >> p;
        mn = min(mn,p);
        if (p == mn) cnt++;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define SZ(x) ((int)x.size())
#define ALL(x) x.begin(),x.end()
#define L(i,u) for (register int i=head[u]; i; i=nxt[i])
#define rep(i,a,b) for (register int i=(a); i<=(b); i++)
#define per(i,a,b) for (register int i=(a); i>=(b); i--)
using namespace std;
typedef long double ld;
typedef long long ll;
typedef unsigned int ui;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
typedef vector<int> Vi;
template<class T> inline void read(T &x){
	x=0; char c=getchar(); int f=1;
	while (!isdigit(c)) {if (c=='-') f=-1; c=getchar();}
	while (isdigit(c)) {x=x*10+c-'0'; c=getchar();} x*=f;
}
template<class T> T gcd(T a, T b){return !b?a:gcd(b,a%b);}
template<class T> inline void umin(T &x, T y){x=x<y?x:y;}
template<class T> inline void umax(T &x, T y){x=x>y?x:y;}
mt19937 R(chrono::system_clock().now().time_since_epoch().count());


int main() {
	string s;cin>>s;
	for(auto&x:s)if(x=='?')x='D';
	cout<<s;
	return 0;
}


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

#define int long long
#define debug(x) cout<<#x<<" "<<x<<endl;

const int N=1e6+5;
const double eps=1e-9;
const int INF=1e18;

signed main()
{
    //freopen("a.in","r",stdin);
    //freopen("a.out","w",stdout);
    int h,a;
    cin>>h>>a; 
    int ans=0;
    while(1){
        if(h<=0) break;
        h-=a;ans++;
    }
    cout<<ans<<endl;
    return 0;
}

//Created Time  :2020/1/26 20:09:32


Measured memory_bytes: 256