akhauriyash/Code-Regression huggingface dataset:
//#define __USE_MINGW_ANSI_STDIO 0
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define IN(a, b, x) (a<=x&&x<b)
#define MP make_pair
#define PB push_back
const int INF = (1LL<<30);
const ll LLINF = (1LL<<60);
const double PI = 3.14159265359;
const double EPS = 1e-12;
const int MOD = 1000000007;
//#define int ll

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

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

VI g[1010];

int dp[1010], dp2[1010][5010], x[1010];
void dfs(int num) {
  // 葉なら
  if(g[num].size() == 0) {
    dp[num] = 0;
    return;
  }
  for(int i: g[num]) dfs(i);
  // DPする
  memset(dp2, 0x3f, sizeof(dp2));
  dp2[0][0] = 0;
  REP(i, g[num].size()) REP(j, x[num]+1) {
    if(j>=x[g[num][i]])
      chmin(dp2[i+1][j], dp2[i][j-x[g[num][i]]] + dp[g[num][i]]);
    if(j>=dp[g[num][i]])
      chmin(dp2[i+1][j], dp2[i][j-dp[g[num][i]]] + x[g[num][i]]);
  }
  // cout << "num:" << num << endl;
  // REP(i, g[num].size()+1) {
  //   REP(j, x[num]+1) {
  //     cout << dp2[i][j] << " ";
  //   }
  //   cout << endl;
  // }
  int ret = 0x3f3f3f3f;
  REP(i, x[num]+1) chmin(ret, dp2[g[num].size()][i]);
  if(ret == 0x3f3f3f3f) {
    cout << "IMPOSSIBLE" << endl;
    exit(0);
  }
  // cout << "num:" << num << " " << ret << endl;
  dp[num] = ret;
}

signed main(void)
{
  int n;
  cin >> n;
  REP(i, n-1) {
    int p;
    cin >> p;
    p--;
    g[p].PB(i+1);
  }
  REP(i, n) cin >> x[i];

  dfs(0);
  // REP(i, n) cout << dp[i] << " "; cout << endl;
  cout << "POSSIBLE" << endl;

  return 0;
}


Measured memory_bytes: 20224
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define vi vector<int>
#define vvi vector< vector <int> > 
#define vb vector<bool>
#define si set<int>
#define mii map<int, int>
#define mci map<char, int>
#define md 1000000007
#define pb push_back
#define eb emplace_back
#define f(i,a,b) for(int i=(int)a;i<=(int)b;i++)
#define r(i,a,b) for(int i=(int)a;i>=(int)b;i--)
#define qw1(x) cerr<<#x<<": "<<x<<" "<<endl
#define qw2(x, y) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define qw3(x, y, z) cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define qw4(a, b, c, d) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl

void sieve(int n, vb &prime)
{
    prime[0]=false;     prime[1]=false;
    for(int i=2;i*i<=n;i++){
         if(prime[i]==true){
            for(int j=i*i;j<=n;j+=i)    prime[j]=false;
             }
    }
}
int32_t main ()
{
  //ios_base::sync_with_stdio (false); cin.tie (NULL);  cout.tie (NULL);
   int h,n; cin>>h>>n;
   vi v(n);
   f(i,0,n-1) cin>>v[i];
   int sum=0;
   f(i,0,n-1) sum+=v[i];
   if(sum>=h) cout<<"Yes";
   else cout<<"No";
 
}






Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int,int> Pii;

int main(){
    while(true){
        int n;
        cin>>n;
        if(n==0) return 0;
        vector<int> c(n);
        rep(i,n){
            char a;
            cin>> a;
            c[i]=(int)a-65;
        }
        vector<int> vec(26,0);
        Pii f(0,0),s(0,0);
        rep(i,n){
            vec[c[i]]++;
            if(f.second<vec[c[i]]){
                if(f.first!=c[i]&&f.first!=s.first) s=f;
                f=make_pair(c[i],vec[c[i]]);
            }
            else if(s.second<vec[c[i]]){
                s=make_pair(c[i],vec[c[i]]);
            }
        //    cout<<f.first<<" "<<f.second<<" "<<s.first<<" "<<s.second<<endl;
            if(f.second==s.second&&i!=n-1) continue;
            else if(f.second>s.second+n-i-1){
                cout<<(char)(f.first+65)<<" "<<i+1<<endl;
                break;
            }
            else if(i==n-1) cout<<"TIE"<<endl;
        }
    }
    return 0;
}


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

int main()
{
	int N;

	cin >> N;

	int ans = 0;

	for (int i = 0; i <= N; i++)
	{
		if (1 <= i && i <= 9)
		{
			ans++;
		}

		else if (100 <= i && i <= 999)
		{
			ans++;
		}

		else if (10000 <= i && i <= 99999)
		{
			ans++;
		}
	}

	cout << ans;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int sz=1e4;

char s[sz];

int main()
{
    ll i,j,n,d;
    scanf("%s", s);
    cin >> d;
    ll l=strlen(s);
    for(i=0; i<l; i+=d) {
        printf("%c", s[i]);
    }
    puts("");
}


Measured memory_bytes: 256
sa=list(input())
sb=list(input())
sc=list(input())

def f(a):
    if a=="a":
        if sa==[]:
            print("A")
        else:
            p=sa[0]
            del sa[0]
            f(p)
    if a=="b":
        if sb==[]:
            print("B")
        else:
            p=sb[0]
            del sb[0]
            f(p)
    if a=="c":
        if sc==[]:
            print("C")
        else:
            p=sc[0]
            del sc[0]
            f(p)

f("a")


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

long long int x, l[87];

long long int lucas(long long int n)
{
    if (n == 0)
        return 2;
    else if (n == 1)
        return 1;
    else
    {
        long long int sum = 0;
        if (!l[n - 1])
            sum = (l[n - 1] = lucas(n - 1));
        else
            sum = l[n - 1];
        if (!l[n - 2])
            sum += (l[n - 2] = lucas(n - 2));
        else
            sum += l[n - 2];
        return sum;
    }
}

int main()
{
    l[0] = 2;
    l[1] = 1;
    cin >> x;
    cout << lucas(x) << endl;
    return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
	"strconv"
)

func main() {
	var A, B int
	fmt.Scan(&A, &B)
	ans := 0
	for i := A; i <= B; i++ {
		is_kai := 0
		str_i := strconv.Itoa(i)
		len_i := len(str_i)
		for j := 0; j < len_i / 2; j++ {
			if str_i[j:j+1] != str_i[len_i - j - 1: len_i - j] {
				is_kai = 1
			}
		}
		if is_kai == 0 {
			ans += 1
		}
	}
	fmt.Println(ans)
}

Measured memory_bytes: 1024
S = list(map(int,input().split()))
N=S[0]
M=S[1]
N1=0
M1=0
count = 0

if 2*N<=M:
    count = N
    N1=0
    M1=M-2*N
    count+=M1//4
elif M<2*N:
    count += M//2
print(count)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i, a, b) for(ll i = ll(a); i < ll(b); i++)
#define rer(i, a, b) for(ll i = ll(a) - 1; i >= ll(b); i--)
#define sz(v) (int)(v).size()
#define pb push_back
#define sc second
#define fr first
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
using namespace std;
typedef long long int ll;
typedef pair <int, int> P;

const ll MOD=1000000007;
int n;
vector<ll> a;
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin>>n;
    a.resize(n);
    rep(i,0,n) cin>>a[i];
    if(n%2){
        ll res=0;
        rep(i,0,n) res^=a[i];
        cout <<(res?"No":"Yes")<<"\n";
    }
    else{
        ll res1=0, res2=0;
        rep(i,0,n){
            if(i%2) res1^=a[i];
            else res2^=a[i];
        }
        cout <<(res1||res2?"No":"Yes")<<"\n";
    }
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
 
using namespace std;
 
int main()
{
  int n;
  cin>>n;
  string temp = to_string(n);
  bool flag = false;
  for(char c:temp)
  {
    if(c=='7')
    {
      flag = true;
      break;
    }
  }
  if(flag)
  {cout<<"Yes"<<'\n';
  }
  else
  {
    cout<<"No"<<'\n';
  }
  
  return 0;
}

Measured memory_bytes: 3696
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb emplace_back
typedef long long ll;
typedef pair<ll,ll> pint;

int n;
const int INF=1000100010;
const int MAX_N=201;
struct edge{
    int to,cap,rev;
    edge(int to,int cap,int rev):
    to(to),cap(cap),rev(rev){}
    };

vector<edge> g[MAX_N];
int dist[MAX_N];
int used[MAX_N];
void add_edge(int src,int dst,int cap){
    g[src].pb(edge(dst,cap,g[dst].size()));
    g[dst].pb(edge(src,0,g[src].size()-1));
}
void bfs(int s){
    memset(dist,-1,sizeof(dist));
    queue<int> q;
    dist[s]=0;
    q.push(s);
    while(!q.empty()){
        int v=q.front();q.pop();
        rep(i,g[v].size()){
            edge &e=g[v][i];
            if(e.cap>0&&dist[e.to]<0){
                dist[e.to]=dist[v]+1;
                q.push(e.to);
            }
        }
    }
}
int dfs(int v,int t,int f){
    if(v==t) return f;
    used[v]=true;
    rep(i,g[v].size()){
        edge &e=g[v][i];
        if(e.cap>0&&dist[v]<dist[e.to]){
            int d=dfs(e.to,t,min(f,e.cap));
            if(d>0){
                e.cap-=d;
                g[e.to][e.rev].cap+=d;
                return d;
            }
        }
    }
    return 0;
}
int max_flow(int s,int t){
    int flow=0;
    while(1){
        bfs(s);
        if(dist[t]<0) return flow;
        memset(used,0,sizeof(used));
        int f;
        while((f=dfs(s,t,INF))>0){
            flow+=f;
        }
    }
}

int sr[2001],ds[2001],d[201][201],c[2001],dd[2001];
int warshall_floyd(){
    rep(k,n)rep(i,n)rep(j,n){
        if(d[i][k]==INF||d[k][j]==INF)continue;
        d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
    }
}
int main(){
    int m,s,t;
    cin>>n>>m>>s>>t;
    --s,--t;
    rep(i,n)rep(j,n) d[i][j]=INF;
    rep(i,n) d[i][i]=0;
    rep(i,m){
        cin>>sr[i]>>ds[i];
        --sr[i],--ds[i];
        cin>>d[sr[i]][ds[i]]>>c[i];
        dd[i]=d[sr[i]][ds[i]];
    }
    warshall_floyd();
    rep(i,m){
        if(d[s][sr[i]]+dd[i]+d[ds[i]][t]==d[s][t]){
            add_edge(sr[i],ds[i],c[i]);
        }
    }
    cout<<max_flow(s,t)<<endl;
    return 0;
}


Measured memory_bytes: 3276
#include <iostream>
#include <algorithm>
#include <vector>
using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;

int main(){
	int n;
	vector<int> v(1000,0);
        int dis,diss;
	while(1){
		cin >> n;
		if( n == 0 ){
			break;
		}

		for(int i = 0; i < n;i++){
			cin >> v[i];
		}

		diss = 0;

		for(int i = 0;i < n;i++){
			for(int j = i+1;j < n;j++){
				if(v[i]-v[j] < 0){
					dis = v[j] - v[i];
				}else{
					dis = v[i] - v[j];
				}


				if( dis < diss || (i == 0 && j == 1)){
					diss = dis;
				}
			}
		}

		cout << diss << endl;
	}
}

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

int main(){
    int n;
    int max = 0;
    int sum = 0;
    cin >> n ;
    int p[n];
    for (int i = 0; i < n; i++){
        cin >> p[i];
        sum += p[i];
        if (p[i] > max){
            max = p[i];
        }
    }
    sum -= max / 2;
    cout << sum << endl;
}

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

dic = {'AC':0, 'WA':0, 'TLE':0, 'RE':0}

for _ in range(N):
    w = input()
    dic[w] += 1

print('AC x', dic['AC'])
print('WA x', dic['WA'])
print('TLE x', dic['TLE'])
print('RE x', dic['RE'])


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

int main()
{
	int n, m, a, b;
	scanf("%d%d", &n, &m);
	scc_graph g(n);
	while (m--) {
		scanf("%d%d", &a, &b);
		g.add_edge(a, b);
	}
	auto scc = g.scc();
	printf("%d\n", scc.size());
	for (auto v : scc) {
		printf("%d", v.size());
		for (auto e : v) printf(" %d", e);
		puts("");
	}
}

Measured memory_bytes: 40092
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
ll MOD = 1e9+7;

#define vec     vector<int>
#define vecll   vector<ll>
#define vec2    vector<vector<int>>
#define vec2ll  vector<vector<ll>>
#define vpair   vector<pair<int, int>>
#define vpairll vector<pair<ll, ll>>

#define rep(i,n)         for(ll i=(ll)0; i<(ll)n; i++)
#define REP(i,m,n)       for(ll i=(ll)m; i<(ll)n; i++)
#define arr(var, n)      vec var(n); rep(i,n){cin >> var[i];}
#define arrll(var, n)    vecll var(n); rep(i,n){cin >> var[i];}
#define all(var)         (var).begin(), (var).end()
#define sortall(var)     sort(all(var))
#define mpair(v1, v2)    make_pair(v1, v2)
#define pb(var)          push_back(var)
#define prt(var)         cout << var << "\n"
#define scn(var)         cin >> var;
#define pYes()           prt("Yes")
#define pNo()            prt("No")
#define prtd(n, var)     cout << fixed << setprecision(n) << var << "\n"
#define prt2(v1, v2)     cout << v1 << " " << v2 << "\n"
#define prt3(v1, v2, v3) cout << v1 << " " << v2 << " " << v3 << "\n"
#define prtall(var)      rep(i,var.size()){cout << var[i] << " ";} cout << "\n"
//----------------------------------------------------------------

int main(void) {
  int n;
  cin >> n;
  arr(h,n);

  ll ans=0;
  int l=0;
  rep(i,100000){
    if(h[l]==0){
      l++;
    } else {
      REP(r,l,n){
        if(h[r]>0){
          h[r]--;
        } else {
          break;
        }
      }
      ans++;
    }
    if(l==n) break;
  }

  prt(ans);


}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
 
using namespace std;
 
int main(){
    int n;
    double students[1000] = {0},sum,m,div;
 
    while(true){
        scanf("%d",&n);
        if(n == 0) break;
        div = sum = 0;
        for(int i = 0; i < n; i++){
            scanf("%lf",&students[i]);
            sum += students[i];
        }
        m = sum/n;
        for(int i = 0; i < n;i++){
            div += (students[i] - m)*(students[i] - m);
            students[i] = 0;
        }
        printf("%.8lf\n",sqrt(div/n));
    }
}


Measured memory_bytes: 2744
from queue import deque
H, W = map(int, input().split())
matrix = []
count = 0
for i in range(H):
    matrix.append(list(input()))
    count += matrix[-1].count('.')
que = deque([(0, 0, 1)])

visited = set()

while que:
    row, col, depth = que.popleft()

    if not(0 <= row < H and 0 <= col < W) or matrix[row][col] == '#':
        continue
    
    if (row, col) in visited:
        continue

    visited.add((row, col))
    if (row, col) == (H-1, W-1):
        print(count - depth)
        exit()
    
    for ud, lr in ((-1, 0), (1, 0), (0, -1), (0, 1)):
        que.append((row+ud, col+lr, depth+1))
print(-1)

Measured memory_bytes: 75348
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
using P=pair<ll,ll>;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
//const ll mod=998244353;
const ll mod=1000000007;
ll GCD(ll a,ll b) {return b ? GCD(b,a%b):a;}
ll LCM(ll c,ll d){return c/GCD(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
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 (a>b) { a=b; return 1; } return 0; }
int main(){
    int n,k,c;
    cin>>n>>k>>c;
    string s;
    cin>>s;
    V<ll> a(n,-1),b(n,-1);
    int cnt=1;
    for(int i=0;i<n;i++){
        if(s[i]=='o'){
            a[i]=cnt++;
            if(cnt>k)break;
            i+=c;
        }
    }
    cnt=k;
    for(int i=n-1;i>=0;i--){
        if(s[i]=='o'){
            b[i]=cnt--;
            if(cnt<=0)break;
            i-=c;
        }
    }
    for(int i=0;i<n;i++){
        if(0<a[i]&&a[i]==b[i])cout<<i+1<<"\n";
    }
}

Measured memory_bytes: 6780
#include <bits/stdc++.h>
#include <numeric>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rep1(i,n) for (int i = 1; i <= n; ++i)
template<typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> inline T intceil(T a, T b) { return (a + (b - 1)) / b; }
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
const long long MOD = 1e9+7;
#define precout() cout << std::fixed << std::setprecision(20);
const string alphabet = "abcdefghijklmnopqrstuvwxyz";
const int dy[4] = { 0, 1, 0, -1 };
const int dx[4] = { 1, 0, -1, 0 };
typedef complex<double> cd;
static const double pi = 3.141592653589793;

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

  ll k,a,b; cin >> k >> a >> b;

  if(k <= a || b - a <= 2) {
    cout << (k + 1) << endl;
    return 0;
  }

  ll ans = 0;

  k -= a + 1;
  ans += b;

  ans += (k / (ll)2) * (b - a);
  ans += k % 2;

  cout << ans << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef pair<int, P> P1;

#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define rep(i, x) for (int i = 0; i < x; i++)
#define rep1(i, x) for (int i = 1; i <= x; i++)
#define rrep(i, x) for (int i = x - 1; i >= 0; i--)
#define rrep1(i, x) for (int i = x; i > 0; i--)
#define sor(v) sort(v.begin(), v.end())
#define rev(s) reverse(s.begin(), s.end())
#define lb(vec, a) lower_bound(vec.begin(), vec.end(), a)
#define ub(vec, a) upper_bound(vec.begin(), vec.end(), a)
#define uniq(vec) vec.erase(unique(vec.begin(), vec.end()), vec.end())
#define mp1(a, b, c) P1(a, P(b, c))

const int INF = 1000000000;
const ll M = 1000000000;
const int dir_4[4][2] = {{1, 0}, {0, 1}, {-1, 0}, {0, -1}};
const int dir_8[8][2] = {{1, 0},  {1, 1},   {0, 1},  {-1, 1},
                         {-1, 0}, {-1, -1}, {0, -1}, {1, -1}};

/*----------------------------------------------/
/- char         : %c  | char *       : %s  | short        : %hd
/- int          : %d  | long         : %ld | long long    : %lld
/- unsigned short:%hu | unsigned int : %u  | unsigned long: %lu
/- u_long long  : %llu| (octal)      : %o  | (hexadecimal): %x
/- float        : %f  | double       : %lf |
/----------------------------------------------*/

/*----------------------------------------------/
/- INT_MAX, LONG_MAX   : 1<<15 = 2.1*pow(10, 9)       (= 2147483647)
/- UINT_MAX, ULONG_MAX : 1<<16 = 4.2*pow(10, 9)       (= 4294967295)
/- LLONG_MAX           : 1<<63 = 9.2*pow(10, 18)      (= 9223372036854775807)
/- ULLONG_MAX          : 1<<64 = 1.8*pow(10, 19)      (= 18446744073709551615)
/----------------------------------------------*/

int main() {
    int n, h[105];
    scanf("%d", &n);
    rep1(i, n) scanf("%d", &h[i]);
    /* ====================================== */
    int ph = 0;
    int ans = 0;
    h[n + 1] = 0;
    rep1(i, n + 1) {
        if (h[i] < ph) {
            ans += ph - h[i];
        }
        ph = h[i];
    }

    cout << ans;
    /* ====================================== */
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
M = list(int(input()) for _ in range(5))
Ms = list(map(str, M))
M1 = []
lastM = 0
time = 0
for i in Ms:
    if i[-1] != "0":
        M1.append(i[-1])
    elif i[-1] == "0":
        M1.append("9")
lastM = M1.index(str(min(map(int, M1))))
last = M.pop(lastM)
for i in M:
    if i % 10 == 0:
        time += i
    else:
        time += (i // 10) * 10 + 10
print(time + last)



Measured memory_bytes: 3064
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace practice1
{
    class Program
    {
        static void Main(string[] args)
        {
            long[] a = new long[3];
            long b, c;
            string[] input = MyScanfSplit();
            b = long.Parse(input[0]);
            c = long.Parse(input[1]);
            a[0] = b + c;
            a[1] = b - c;
            a[2] = b * c;
            MyLongSort(a);
            Println("" + a[2]);

        }

        public static void Println(string str)
        {
            Console.WriteLine(str);
        }

        public static void Print(string str)
        {
            Console.Write(str);
        }

        public static string MyScanf()
        {
            return Console.ReadLine();
        }

        public static string[] MyScanfSplit()
        {
            return MyScanf().Split();
        }

        public static void MyDoubleSort(double[] boo)
        {
            if (boo.Length < 2) return;

            long i, count;
            double a;

            while (true)
            {
                count = 0;

                for (i = 0; i < boo.Length - 1; i++)
                {
                    if (boo[i] > boo[i + 1])
                    {
                        a = boo[i];
                        boo[i] = boo[i + 1];
                        boo[i + 1] = a;
                        count++;
                    }
                }

                if (count == 0) break;
            }
        }

        public static void MyLongSort(long[] boo)
        {
            if (boo.Length < 2) return;

            long i, count;
            long a;

            while (true)
            {
                count = 0;

                for (i = 0; i < boo.Length - 1; i++)
                {
                    if (boo[i] > boo[i + 1])
                    {
                        a = boo[i];
                        boo[i] = boo[i + 1];
                        boo[i + 1] = a;
                        count++;
                    }
                }

                if (count == 0) break;
            }
        }
    }
}


Measured memory_bytes: 13140
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	private static final long DEV_NUM = 1000000000 + 7;
	private static final int MAX_COLOR_NUM = 2 * 100000;
	
	int[] jumpIndex = null;
	long[] patterns = null;
	int N = 0;

	public void solve() {
		Scanner in = new Scanner(System.in);
		N = in.nextInt();
		int[] color = new int[N];
		for (int i=0; i<N; i++) {
			color[i] = in.nextInt();
		}
		in.close();

		patterns = new long[N];
		Arrays.fill(patterns, -1);
		jumpIndex = new int[N];
		Arrays.fill(jumpIndex, -1);
		int[] beforeIndex = new int[MAX_COLOR_NUM+1];
		Arrays.fill(beforeIndex, -1);
		for (int i=0; i<N; i++) {
			int c = color[i];
			if (beforeIndex[c] == -1) {
				beforeIndex[c] = i;
			} else if (beforeIndex[c] == i-1) {
				beforeIndex[c] = i;
			} else {
				jumpIndex[beforeIndex[c]] = i;
				beforeIndex[c] = i;
			}
		}

		for (int i=N-1; i>=0; i--) {
			patterns[i] = getPatterns(i);
		}
		
		System.out.println(patterns[0]);
	}
	
	private long getPatterns(int index) {
		if (index >= N-2) {
			return 1;
		}
		long unjumpPatterns = patterns[index+1];
		long jumpPatterns = 0;
		if (jumpIndex[index] != -1) {
			jumpPatterns = patterns[jumpIndex[index]];
		}
		
		return (unjumpPatterns + jumpPatterns) % DEV_NUM;
	}
	
	public static void main(String[] args) {
		Main main = new Main();
		main.solve();
	}
}


Measured memory_bytes: 86908
#include<algorithm>
#include<climits>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<list>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<utility>
#include<vector>

using namespace std;

#define lint long long
#define REP(i, x, n) for(int i = x ; i < n ; i++)
#define rep(i, n) REP(i, 0, n)
#define repr(i, n) for(int i = n - 1 ; i >= 0 ; i--)
#define SORT(c) sort((c).begin(), (c).end())
#define SORT_INV(c) sort((c).begin(), (c).end(), greater<int>())
#define IINF (int)(1e9+10)
#define LLINF (lint)(1e18+10)

struct unionFind{

    vector<int> par, rank;

    void init(int n){
        par.resize(n);
        rank.resize(n, 0);
        rep(i, n){
            par[i] = i;
        }
        return;
    }

    int root(int x){
        if(par[x] == x){
            return x;
        }else{
            par[x] = root(par[x]);
            return par[x];
        }
    }

    void unite(int x, int y){
        int rx = root(x);
        int ry = root(y);
        if(rx == ry){
            return;
        }
        if(rank[rx] < rank[ry]){
            par[rx] = ry;
        }else if(rank[rx] == rank[ry]){
            par[rx] = ry;
            rank[ry]++;
        }else{
            par[ry] = rx;
        }
        return;
    }

    bool same(int x, int y){
        return root(x) == root(y);
    }

};

int main(){
    int n;
    cin >> n;
    vector<int> x(n);
    map<string, int> mp;
    rep(i, n){
        string a;
        cin >> a;
        mp[a] = i;
        cin >> x[i];
    }
    int m;
    cin >> m;
    unionFind uf;
    uf.init(n);
    rep(i, m){
        string s, t;
        cin >> s >> t;
        uf.unite(mp[s], mp[t]);
    }
    rep(i, n){
        rep(j, n){
            if(uf.same(i, j)){
                x[i] = min(x[i], x[j]);
            }
        }
    }
    int ans = 0;
    rep(i, n){
        ans += x[i];
    }
    cout << ans << endl;
    return 0;
}


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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;
typedef pair<ll, ll> PL;
typedef pair<P, ll> PPL;

#define INF INT_MAX/3

#define MAX_N 1000

int n,m,k;
int cnt[11111111];

void dfs(int sum,int num){
	if(num==n){
		cnt[sum]++;
		return;
	}
	repl(i,1,m+1){
		dfs(sum+i,num+1);
	}
}

int main(){
	cin.sync_with_stdio(false);
	while(1){
		cin>>n>>m>>k;
		if(n==0)break;
		memset(cnt,0,sizeof(cnt));
		dfs(0,0);
		double res=0;
		repl(i,n,n*m+1){
			if(i>k){
				res+=(double)((i-k)*cnt[i])/pow(m,n);
			}else{
				res+=(double)(1.0*cnt[i])/pow(m,n);
			}
		}
		printf("%.10f\n", res);
	}
	return 0;
}

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

int main(){
  int W,H,x,y,r;
  cin >> W >> H >> x >> y >> r;
  if(x-r<0||y-r<0||x+r>W||y+r>H){
    cout << "No" <<endl;
  }else{
    cout << "Yes" <<endl;
  }
	return 0;
}


Measured memory_bytes: 3100
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

var (
	in  = bufio.NewReader(os.Stdin)
	out = bufio.NewWriter(os.Stdout)
)

func main() {
	var a, b, t int
	_, _ = fmt.Scanf("%d %d %d", &a, &b, &t)
	fmt.Println(t / a * b)
}

func readInt64Slice() []int64 {
	line := readStringSlice()
	slice := make([]int64, 0, len(line))
	for _, tmp := range line {
		val, err := strconv.ParseInt(tmp, 10, 64)
		if err != nil {
			fmt.Println(err)
			os.Exit(1)
		}
		slice = append(slice, val)
	}
	return slice
}
func readFloat64Slice() []float64 {
	line := readStringSlice()
	slice := make([]float64, 0, len(line))
	for _, tmp := range line {
		val, err := strconv.ParseFloat(tmp, 64)
		if err != nil {
			fmt.Println(err)
			os.Exit(1)
		}
		slice = append(slice, val)

	}
	return slice
}
func readString() string {
	s, _, _ := in.ReadLine()
	return string(s)
}
func readStringSlice() []string {
	line := readString()
	s := strings.Split(line, " ")
	return s
}
func dump(value ...interface{}) {
	for _, v := range value {
		fmt.Printf("%#v\n", v)
	}
}


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

int main(){
    int N;
    cin >> N;
    int A[N];
    for(int i=0; i<N; i++){
        cin >> A[i];
    }

    int B[N];
    for(int i=0; i<N; i++){
        int r =0;
        int counter = 0;
        while(true){
            r = A[i] % 2;
            if(r==1){
                break;
            }
            A[i] = A[i]/2;
            counter += 1;
        }
        B[i] = counter;
    }

    int ans = *min_element(B, B+N);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3628
fun main(arr:Array<String>) {
    val (n,m,q) = readLine()!!.split(" ").map { it.toInt() }
    val req = (1..q).map { readLine()!!.split(" ").map { it.toInt() }.let { Require(it) } }
    val solve = Solve(m, req)
    var ans = 0
    for(i in (1..m)) {
        val arr = (1..n).map { 1 }.toTypedArray()
        arr[0] = i
        ans = Math.max(ans, solve.getAns(1, arr))
    }
    println(ans)
}

class Require(num:List<Int>) {
    val index1 = num[0] - 1
    val index2 = num[1] - 1
    val diff = num[2]
    val score = num[3]
}
class Solve(val maxNum:Int, val requireList:List<Require>) {
    fun getAns(index:Int, arr:Array<Int>):Int {
        if(index >= arr.size) {
            return getScore(arr)
        }

        var ans = 0
        for(i in (arr[index-1]..maxNum)) {
            arr[index] = i
            ans = Math.max(ans, getAns(index+1, arr))
        }
        return ans
    }

    fun getScore(arr:Array<Int>):Int {
        var score = 0
        for(req in requireList) {
            if(arr[req.index2] - arr[req.index1] == req.diff) {
                score+=req.score
            }
        }
        return score
    }
}


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

int n;
int a[10005]={0};
int b[10005]={0};

int main(){
  int i,sum=0;
  cin >> n;
  for(i=0;i<n;i++){
    cin >> a[i];
    while(a[i]%2==0){
      sum++;
      a[i]/=2;
    }
  }
  cout << sum <<endl;
  return 0;
}


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

int main(void){
	char **pp;
	int i, j, k;
	int x[3000];
	int y[3000];
	int tempo;
	
	pp = (char **)malloc(sizeof(char *) * 3000);
	
	for (i = 0; i < 3000; i++){
		pp[i] = (char *)malloc(sizeof(char *) * 13);
	}
	
	for (j = 0; j < 3000; j++){
		fgets(pp[j], sizeof(char) * 13, stdin);
		x[j] = atoi(strtok(pp[j], " "));
		y[j] = atoi(strtok(NULL, " "));
		if (x[j] == y[j] && x[j] == 0){
			break;
		}
	}
	
	for (k = 0; k < j; k++){
		if (x[k] > y[k]){
			tempo = x[k];
			x[k] = y[k];
			y[k] = tempo;
		}
		printf("%d %d\n", x[k], y[k]);
	}
	
	return 0;
}

Measured memory_bytes: 928
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace MINPRO2019C
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split().Select(long.Parse).ToArray();
            long K = input[0];
            long A = input[1];
            long B = input[2];

            long ans;
            if (A >= B - 1) ans = K +1;
            else if (A >= K + 1) ans = K +1;
            else
            {
                long increase = (K - A + 1) / 2;
                long amari = (K - A + 1) % 2;

                ans = A + increase * (B - A) + amari;
            }

            Console.WriteLine(ans);
            Console.ReadKey();
        }
    }
}


Measured memory_bytes: 13396
#include<stdio.h>
#include<string.h>
int main()
{
	char a[111];
	while(scanf("%s",a)!=EOF){
		int i,j,max;
		for(i=0;i<strlen(a)-1;i++){
			if(a[i]=='C')
			break;
		}
		for(j=0;j<=strlen(a)-1;j++){
			if(a[j]=='F')
			max=j;
		}
		if(i<max) printf("Yes\n");
		else printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n; cin >> n;
    vector<int> l(n);
    for(int i=0; i<n; ++i){cin >> l[i];}
    sort(l.begin(), l.end());
  	
    int res = 0; int cnt = 0;
    for(int i=0; i<n-2; ++i){
        int a = l[i];
        for(int j=i+1; j<n-1; ++j){
            int b = l[j]; 
            for(int k=j+1; k<n; ++k){
              	
                if(l[k]>(a+b)){break;}
              	if(l[k]==(a+b)){continue;}
                int c = l[k]; 
                if(a<(b+c) && b<c+a){res++;}
            }
        }
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 3576
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define pll pair<ll,ll>
#define vi vector < int >
#define pii pair<int,int>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define all(a) (a).begin(),(a).end()
#define s(x) scanf("%d",&x)
#define sll(x) scanf("%lld",&x)
#define pf(x) printf("%d\n",x)
#define pfl(x) printf("%lld\n",x)
#define flash ios_base::sync_with_stdio(false);cin.tie(0)
#define goog(x) cout << "Case #" << x << ": "
#define MAX5 200005
#define MAX6 2000005
#define MLOG 18
#define limit 1e18
#define mod 1000000000   
void __print(int x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif


int power(int x, int y, int p){
    int res = 1;
    x = x % p;
    while (y > 0){
        if (y & 1)
            res = (res*x) % p;
        y = y>>1;
        x = (x*x) % p;
    }
    return res;
}


void solve(){
    int n;
    cin >> n;
    vi v(n);
    for(int i = 0; i < n-1; i++) cin >> v[i];
    vi dp(n+1, 0);
    for(int i = 0; i < n; i++){
        dp[v[i]]++;
    }
    for(int i = 1; i <= n; i++){
        cout << dp[i] << endl;
    }
}

signed main(){  
//  freopen("ii.txt", "w", stdin);
    // flash;
    int t = 1;
    // cin >> t;  
    for(int tc = 1; tc <= t; tc++){
    // goog(tc);
        solve();
    }
}

Measured memory_bytes: 6352
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
using namespace std;

int main(){
	int n;
	cin>>n;
	for(int i=1;i<=9;i++){
		if(n<=i*9&&n%i==0){
			cout<<"Yes"<<endl;
			return 0;
		}
	}
	cout<<"No"<<endl;
	return 0;
}


Measured memory_bytes: 256
//#include <boost/multiprecision/cpp_dec_float.hpp>
//#include <boost/multiprecision/cpp_int.hpp>
#include <stdio.h>
#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <math.h>
#include <algorithm>
#include <bitset>
#include <iomanip>
using namespace std;
//namespace mp = boost::multiprecision;
//using llll = mp::cpp_int;
// 仮数部が1024ビットの浮動小数点数型(TLEしたら小さくする)
//using Real = mp::number<mp::cpp_dec_float<1024>>;
using ll = long long;
const double EPS = 1e-10;
const ll MOD = 7+(1e+9);

int main(){
  //cout<<fixed<<setprecision(10);
  ll n,ans=0;
  vector<string>s;
  vector<ll>t;
  string ss;
  ll tt;
  cin>>n;
  for(ll i=0;i<n;i++){
    cin>>ss>>tt;
    s.push_back(ss);
    t.push_back(tt);
  }
  string x;
  cin>>x;
  ll i;
  for(i=0;i<n;i++){
    if(s[i]==x)break;
  }
  i++;
  for(ll j=i;j<n;j++){
    ans+=t[j];
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define FOR(i, a, b) for(int i = (int)a; i <= (int)b; i++)
#define DEC(i, a, b) for(int i = (int)a; i >= (int)b; i--)
typedef pair<int, int> pi;
typedef pair<int, pi> pii;
typedef pair<pi, pi> pipi;
#define f first
#define s second
typedef vector<int> vi;
typedef vector<pi> vpi;
typedef vector<pii> vpii;
#define pb push_back
#define pf push_front
#define all(v) v.begin(), v.end()
#define disc(v) sort(all(v)); v.resize(unique(all(v)) - v.begin());
#define INF (int) 1e9 + 100
#define LLINF (ll) 1e18
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());    //can be used by calling rng() or shuffle(A, A+n, rng)
inline ll rand(ll x, ll y) { ++y; return (rng() % (y-x)) + x; } //inclusivesss

ll n, arr[200005], k, ans = 1, mod = 1e9+7;

void fail(ll x) {
	cout << x;
	exit(0);
}

ll f(ll a, ll b) {
	ll res = a * b;
	if (res < 0) res += (-res/mod + 1) * mod;
	return res % mod;
}

int main() {
	fastio; cin >> n >> k;
	FOR(i, 1, n) cin >> arr[i];
	sort(arr+1, arr+n+1);
	if (arr[n] == 0 and k % 2 == 1) fail(0);
	if (arr[n] <= 0 and k % 2 == 1) {
		DEC(i, n, n-k+1) ans = f(ans, arr[i]);
		fail(ans);
	}
	ll l = 1, r = n;
	if (k % 2 == 1) {
		ans = f(1, arr[r--]);
		k--;
	}
	FOR(i, 1, k/2) {
		ll a = arr[l] * arr[l+1], b = arr[r] * arr[r-1];
		if (a > b) l += 2;
		else r -= 2;
		ans = f(ans, max(a, b) % mod);
	}
	cout << ans;
}


Measured memory_bytes: 5156
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,1,n+1)
#define RFOR(i,l,r) for(long long i=(l);i>=(r);--i)
#define RREP(i,n) RFOR(i,N-1,0)
#define RREPS(i,n) RFOR(i,N,1)
#define int long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define SZ(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
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;
}
const int INF=1e18;
const int MOD=1e9+7;

signed main(){
    int N;cin>>N;
    vector<int>A(N);
    map<int,int>memo;
    REP(i,N){
        int a;cin>>a;
        if(i%2==1)memo[a]++;
        A[i]=a;
    }
    sort(all(A));
    int ans=0;
    REP(i,N){
        if(i%2==0&&memo[A[i]]!=0)ans++;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 7296
#include <iostream>
using namespace std;
int main(void) {
	long long q, h, s, d, n;
	cin >> q >> h >> s >> d >> n;
	h = min(h, 2 * q);
	s = min(s, 2 * h);
	long long ans = 0;
	if (s * 2 <= d) ans = s * n;
	else {
		ans = (n / 2) * d;
		if (n % 2 == 1) ans += s;
	}
	cout << ans << endl;
	return 0;
}

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

S = gets.chomp
T = gets.chomp

N = S.length - T.length + 1

max = 0

N.times do |i|
  matches = 0

  T.length.times do |j|
    matches += 1 if S[i + j] == T[j]
  end

  max = matches if max < matches
end

puts T.length - max


Measured memory_bytes: 14336
A, B = map(int, input().split())
S = list(str(input()))

ans = 'Yes'

for i in range(A):
  if not str.isdecimal(S[i]):
    ans = 'No'

if S[A] != '-':
  ans = 'No'
  
for i in range(B):
  if not str.isdecimal(S[-1*i-1]):
    ans = 'No'
print(ans)

Measured memory_bytes: 3064
N = int(input())
A = [int(i) for i in input().split()]

ap = [(v, k) for k, v in enumerate(A)]
ap.sort(reverse=True)

dp = [[-float('inf')] * (N + 1) for _ in range(N + 1)]
dp[0][0] = 0

for i, (a, p) in enumerate(ap) :
  for l in range(i + 1) :
    r = i - l
    if l + 1 <= N :
      dp[l + 1][r] = max(dp[l + 1][r], dp[l][r] + a * (p - l))
    if r + 1 <= N :
      dp[l][r + 1] = max(dp[l][r + 1], dp[l][r] + a * (N - 1 - r - p))
  
print(max(dp[i][N - i] for i in range(N + 1)))

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

using namespace std;

typedef long long lli;

const int N = 100 + 10;

int num[N];
lli f[N][4][2];

int main()
{
	int n, k, i, j;
	string s;
	cin>>s;
	cin>>k;
	n = s.size();
	for (i=1; i<=n; i++) num[i] = s[i-1] - '0';
	f[0][0][1] = 1;
	for (i=1; i<=n; i++)
	{
		if (num[i] == 0) 
		{
			f[i][0][0] = f[i-1][0][0];
			f[i][0][1] = f[i-1][0][1];
		}
		else
		{
			f[i][0][0] = f[i-1][0][0] + f[i-1][0][1];
			f[i][0][1] = 0;
		}
		for (j=1; j<=k; j++) 
		{
			f[i][j][0] = f[i-1][j-1][0] * 9 + (num[i] == 0 ? 0 : f[i-1][j-1][1] * (num[i] - 1)) + f[i-1][j][0] + (num[i] == 0 ? 0 : f[i-1][j][1]);
			if (num[i] == 0) f[i][j][1] = f[i-1][j][1]; else f[i][j][1] = f[i-1][j-1][1];
		}
//		cout<<f[i][0][0]<<" "<<f[i][0][1]<<" "<<f[i][1][0]<<" "<<f[i][1][1]<<endl;
	}
	cout<<f[n][k][0] + f[n][k][1]<<endl;
	return 0;
}

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

using namespace std;

#define rep(i , l , r) for(int i = (l) , ___ = (r) ; i <= ___ ; ++i)
#define per(i , r , l) for(int i = (r) , ___ = (l) ; i >= ___ ; --i)

#define DEBUG(...) fprintf(stderr , __VA_ARGS__)

template<typename T>inline int chkmin(T &x , const T &y){ return x > y ? x = y , 1 : 0; }
template<typename T>inline int chkmax(T &x , const T &y){ return x < y ? x = y , 1 : 0; }

template<typename T>inline T read(T &f)
{
	f = 0 ; int x = 1 ; char c = getchar();
	while(!isdigit(c)) x = c == '-' ? -1 : 1 , c = getchar();
	while(isdigit(c)) (f *= 10) += c & 15 , c = getchar();
	return f *= x;
}

using int64 = long long;
using uint64 = unsigned long long;

const int KCZ = 1e9 + 7;

int64 L , R;

inline int inc(const int &val)
{
	return val >= KCZ ? val - KCZ : val;
}

inline int dec(const int &val)
{
	return val < 0 ? val + KCZ : val;
}

inline void add(int &x , const int &y)
{
	x = inc(x + y);
}

inline void sub(int &x , const int &y)
{
	x = dec(x - y);
}

int f[100 + 5][2][2][2];

int cL[100 + 5] , cR[100 + 5];

int dfs(int pos , int limL , int limR , int zero)
{
	if(pos == -1) return zero;
	int &ret = f[pos][limL][limR][zero];
	if(ret != 0) return ret;
	int dL = limL ? cL[pos] : 0;
	int dR = limR ? cR[pos] : 1;
	// cerr << pos << ' ' << dL << ' ' << dR << endl;
	rep(vx , dL , 1)
	rep(vy , vx , dR)
	{
		if(zero == 0 && vy == 1)
		{
			if(vx == 0) continue;
			add(ret , dfs(pos - 1 , limL & (vx == cL[pos]) , limR & (vy == cR[pos]) , 1));
		}
		else
		{
			add(ret , dfs(pos - 1 , limL & (vx == cL[pos]) , limR & (vy == cR[pos]) , zero));
		}
	}
	return ret;
}

int main()
{
	read(L) , read(R);
	per(i , 63 , 0)
	{
		if((1ll << i) & L) cL[i] = 1;
		if((1ll << i) & R) cR[i] = 1;
	}
	cout << dfs(63 , 1 , 1 , 0) << endl;
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main()
{
    char s1[12],s2[12];
    int i,flag=0;
    scanf("%s",&s1);
    scanf("%s",&s2);
    int l=strlen(s1);
   // printf("%d\n",l);
    for(i=0; i<strlen(s2)-1; i++)
    {
        if(s1[i]==s2[i])
            flag++;
    }
    //printf("%d\n",flag);
    if(flag==l)
        printf("Yes\n");
    else
        printf("No\n");
    return 0;
}


Measured memory_bytes: 1648
/**
 *    author:   K.R.Surrya  
 *    created:  02/05/2020 17:30:21
**/
#include<bits/stdc++.h>
#define vi vector<int>
#define vii vector<vector<int> >
#define vpi vector<pair<int,int> >
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define pb push_back
using namespace std; 

#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it)  { return ;}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a,Args... args)
{
    cerr << *it << " = " << a <<endl;
    err(++it,args...);   //args is going to end.
}

void solve() {
    int n;
    cin >> n;
    int a,b;
    cin >> a >> b;
    int ok=0;
    for(int i=a;i<=b;++i) { 
        if(i%n==0) { 
            ok=1;
            break;
        }
    }
    if(ok)   cout << "OK" << '\n';
    else     cout << "NG" << '\n';
}
int main()
{   
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

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

     auto start = chrono::high_resolution_clock::now();
     solve();
     auto end = chrono::high_resolution_clock::now();

     cerr << " Execution time : " << chrono::duration_cast<chrono::milliseconds>(end-start).count()<<"ms"<<endl;

   
    return 0;
}


Measured memory_bytes: 3660
#include <bits/stdc++.h>
using namespace std;
#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 ll = long long;
using VL = vector<ll>;
using VVL = vector<vector<ll>>;
using P = pair<ll, ll>;

// chmin, chmax関数
template<typename T, typename U, typename Comp=less<>>
bool chmax(T& xmax, const U& x, Comp comp={}) {
    if(comp(xmax, x)) {
        xmax = x;
        return true;
    }
    return false;
}
template<typename T, typename U, typename Comp=less<>>
bool chmin(T& xmin, const U& x, Comp comp={}) {
    if(comp(x, xmin)) {
        xmin = x;
        return true;
    }
    return false;
}

// Yes-Noを出力する問題で楽をする
void Ans(bool f){
    if(f) cout << "Yes" << endl;
    else cout << "No" << endl;
}

//---------------------------

int main(){
    int a,b,c; cin >> a >> b >> c;
    cout << a+b+c-max(max(a,b),c) << endl;
    return 0;
}

Measured memory_bytes: 256
// J'aime
// Chemise Blanche

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

#define int long long

#define ii pair<int,int>
#define fi first
#define sc second

#define all(x) (x).begin(),(x).end()
#define dbg(x) cerr << __LINE__ << " > " << #x << " = " << (x) << endl

void MAIN() {
  int n; cin >> n;
  cout << n / 3 << '\n';
}

signed main() {
#ifdef _DEBUG
  // freopen("in" , "r", stdin );
  // freopen("out", "w", stdout);
#endif
  ios::sync_with_stdio(0); cin.tie(0);
  int T = 1;
  // cin >> T;
  while (T--) MAIN();
}


Measured memory_bytes: 3656
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
using namespace std;

int main(){
    int n;
    for(int _ = 0; cin >> n,n; _++){
        pair<int,string> p[21];
        if(_) cout << endl;
        rep(i,n){
            string name;
            int a,b,c;
            cin >> name >> a >> b >> c;
            p[i] = make_pair(a * 3 + c, name);
        }
        sort(p, p + n,
                [](pair<int, string> x, pair<int, string> y) -> bool {
                return ( x.first > y.first );
                } );
        for(auto it:p){
            if(it.second.empty()) break;
            cout << it.second <<',' << it.first << endl;
        }
    }
}

Measured memory_bytes: 3156
a = gets.to_i
b = gets.to_i
c = gets.to_i
x = gets.to_i
ans = 0
for l in 0..a do
    for m in 0..b do
        for n in 0..c do
            if l * 500 + m * 100 + n * 50 == x
                ans += 1
            end
        end
    end
end
puts ans

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

using namespace std;

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

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

ll A[2005];

int main() {
    ll N, K, Q;
    cin >> N >> K >> Q;
    REP(i, N) {
        cin >> A[i];
    }

    ll ans = INF;
    REP(i, N) {
        ll a = A[i];
        //! a未満の数字は入らないようにする
        priority_queue<ll, vector<ll>, greater<ll>> q0, q1;
        REP(j, N) {
            if (A[j] < a) {
                while (!q0.empty())
                    q0.pop();
                continue;
            }
            q0.push(A[j]);
            if (q0.size() == K) {
                ll t = q0.top();
                q0.pop();
                q1.push(t);
            }
        }

        if (q1.size() < Q)
            continue;
        ll min = INF, max = -INF;
        REP(j, Q) {
            ll m = q1.top();
            q1.pop();
            min = std::min(min, m);
            max = std::max(max, m);
        }
        ans = std::min(ans, max - min);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
N=int(input())
L=list(map(int,input().split()))
M=[]
for i in L:
  if i%2==0:
    M.append(i)
A='APPROVED'
for k in M:
  if k%3!=0 and k%5!=0:
    A='DENIED'
    break
print(A)
 

Measured memory_bytes: 3060