akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <unordered_map>
#include <vector>

int main()
{
    std::string s, t;
    std::cin >> s >> t;

    std::unordered_map<char, std::vector<int>> char_pos;

    for (int i = 0; i < s.length(); i++) {
        char_pos[s[i]].push_back(i);
    }

    for (int i = 0; i < s.length(); i++) {
        char_pos[s[i]].push_back(i + s.length());
    }

    int ptr = 0;
    long long ans = 0;
    for (auto c : t) {
        if (char_pos[c].empty()) {
            std::cout << -1 << std::endl;
            return 0;
        }

        ptr = *lower_bound(char_pos[c].begin(), char_pos[c].end(), ptr) + 1;
        if (ptr >= s.length()) {
            ptr -= s.length();
            ans += s.length();
        }
    }

    ans += ptr;
    std::cout << ans << std::endl;
}


Measured memory_bytes: 1724
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <stdio.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;
 
const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll INF = 1ll << 60;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int main(){
  double R; scanf("%lf", &R);
  printf("%.10lf\n", 2 * R * PI);
  return 0;
}


Measured memory_bytes: 3788
export class Main {
  static main(input: string): string {
    const tmp: string[] = input.split("\n");
    const a = ("A").charCodeAt(0);
    const codeRange = ("Z").charCodeAt(0) - a + 1;
    const parse = code => (code - a) % codeRange + a;
    const [n]: number[] = tmp.shift().split(" ").map(int => parseInt(int));
    const [s]: string[] = tmp.shift().split(" ");
    let result = "";
    for (let i = 0, len = s.length; i < len; i++) {
      result += String.fromCharCode(parse(s.charCodeAt(i) + n));
    }
    return result;
  }
}
console.log(Main.main(require("fs").readFileSync("/dev/stdin", "utf8")));


Measured memory_bytes: 7500
#include<iostream>
#include<cstring>
#include<algorithm>
using namespace std;
int W,H;
int sum;
char array[101][101];
int place[4][2]={0,1,1,0,0,-1,-1,0};
void dfs(int x,int y,char t){
	array[x][y]='!';
	for(int i=0;i<4;i++){
		int tx=x+place[i][0];
		int ty=y+place[i][1];
		if(tx<0||tx>=H||ty<0||ty>=W||array[tx][ty]=='!')
			continue;
		if(array[tx][ty]==t){
			dfs(tx,ty,t);
		}
	}
}
int main(){
	cin>>H>>W;
	while(W!=0&&H!=0){
		sum=0;
		int a,b;
		for(int i=0;i<H;i++)
			for(int j=0;j<W;j++){
				cin>>array[i][j];
			}
		for(int i=0;i<H;i++)
			for(int j=0;j<W;j++)
				if(array[i][j]!='!'){
					dfs(i,j,array[i][j]);
					sum++;
				}
		cout<<sum<<endl;
		cin>>H>>W;
	}
	return 0;
}


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

using namespace std;
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
constexpr int MOD = 1000000007;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
constexpr int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
constexpr int dy[] = {0, -1, 0, 1, 1, -1, -1, 1};

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){os << "["; for (const auto &v : vec) {os << v << ","; } os << "]"; return os; }
template <typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &p) {os << "(" << p.first << ", " << p.second << ")"; return os;}

void solve() {
    int N;
    cin >> N;
    vector<ll> A(N);
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }
    sort(all(A));

    ll sum = A[0];
    ll ans_i = 0;
    for(int i = 1; i < N; i++) {
        if (sum * 2 < A[i]) {
            ans_i = i;
        }
        sum += A[i];
    }
    cout << N - ans_i << endl;
}

int main() {
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    solve();
    return 0;
}

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

int main() {
  int N, c=0,t=0;
  cin >>N;
  vector<string> vote(N), res(N, "*");
  vector<int> num(N,0);
  
  for (int i=0;i<N;i++){
      cin>>vote.at(i);
  }
  
  sort(vote.begin(), vote.end());
  
  for(int i=1;i<N;i++){
      if(vote.at(i)==vote.at(i-1)){
        c+=1;
        num.at(i)=c;
        t=max(t,c);
      }
      else{
        c=0;
      }
  }
//  for(int i=0;i<N;i++){
//    cout << vote.at(i)<<' '<< num.at(i)<<endl;
//  cout << t << endl;
  
  for(int i=0;i<N;i++){
      if(num.at(i)==t){
          res.at(i)=vote.at(i);

      }
  }
  sort(res.begin(), res.end());
  for(int i=0;i<N;i++){
      if(res.at(i)!="*"){
        cout << res.at(i) << endl;
      }
  }
}

Measured memory_bytes: 16640
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
from collections import deque

sys.setrecursionlimit(10**7)
inf = 10**20

DR = [1, -1, 0, 0]
DC = [0, 0, 1, -1]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
    
fac = [-1] * (10**7+1)
inv = [-1] * (10**7+1)
finv = [-1] * (10**7+1)

fac[0] = fac[1] = 1
inv[1] = 1
finv[0] = finv[1] = 1

def initNCMMod(limit):
    for i in range(2, limit):
        fac[i] = fac[i-1] * i

def NCM(n):
    return n * (n-1) // 2
def main():
    N = I()
    A = LI()
    vals = [0 for _ in range(N+1)]
    pick = [0 for _ in range(N+1)]
    for a in A:
        vals[a] += 1
    for i, val in enumerate(vals):
        pick[i] = NCM(val)
    picksum = sum(pick)
    for a in A:
        tmp_picksum = picksum - NCM(vals[a])
        tmp_picksum += NCM(vals[a]-1)
        print(tmp_picksum)


main()



Measured memory_bytes: 312180
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using vi=vector<int>;
using P = pair<int,int>;
using Graph = vector<vector<int>>;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n;
    cin >> n;
    vector<string> s(n);
    rep(i,n) cin >> s[i];
    vector<ll> a(5,0);
    rep(i,n){
        if(s[i][0]=='M') ++a[0];
        else if(s[i][0]=='A') ++a[1];
        else if(s[i][0]=='R') ++a[2];
        else if(s[i][0]=='C') ++a[3];
        else if(s[i][0]=='H') ++a[4];
    }
    ll ans=0;
    for(int i=0;i<3;++i){
        if(a[i]==0) continue;
        for(int j=i+1;j<4;++j){
            if(a[j]==0) continue;
            for(int k=j+1;k<5;++k){
                if(a[k]==0) continue;
                ans+=(a[i]*a[j]*a[k]);
            }
        }
    }
    cout << ans << "\n";
    return 0;
}   

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

        int can = a - b;
        if(c - can > 0){
            System.out.println(c - can);
        } else {
            System.out.println(0);
        }

        return;
    }
}

Measured memory_bytes: 23764
#include <stdio.h>

int main(void)
{
	long long int n,a,b,cost=0;
	scanf("%lld%lld%lld",&n,&a,&b);
	long long int x[n],i;

	for(i=0;i<n;i++){
		scanf("%lld",&x[i]);
		if(i>=1)
			if((x[i]-x[i-1])*a<b){
				cost+=a*(x[i]-x[i-1]);
			}else{
				cost+=b;
			}
	}

	printf("%lld\n",cost);
	return 0;
}

Measured memory_bytes: 896
#include <stdio.h>

int main(void){
  int n,a,b=1;
  long p=1;
  int i;
  scanf("%d",&n);
  for(i=0;i<9;i++){
    b*=10;
  }
  a=b+7;
  for(i=1;i<=n;i++){
    p=(p*i)%a;
  }
  printf("%ld\n",p);
  return(0);
}

Measured memory_bytes: 128
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        
        Scanner sc = new Scanner(System.in);
        
        int N = sc.nextInt();
        
        long S = 0;
        for(int i = 0; i < N; i++){
            S += i;
        }
        
        System.out.println(S);
    }
}



Measured memory_bytes: 21332
import java.util.*;  
public class Main {
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner input = new Scanner(System.in); 
       int s = input.nextInt();
      	int w = input.nextInt();
      if (s>w)
        System.out.println("safe");
      else 
        System.out.println("unsafe");
    }
}

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

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

  vector<int> a(n), b(n), sa(n), sb(n);
  rep(i,n){
    cin>>a[i];
    sa[i]=a[i];
  }
  rep(i,n){
    cin>>b[i];
    sb[i]=b[i];
  }

  vector<pair<int,int>> ba(n);
  rep(i,n){
    ba[i]=make_pair(b[i],a[i]);
  }
  sort(ba.begin(),ba.end());

  vector<pair<int,int>> asort(n);
  rep(i,n){
    asort[i]=make_pair(ba[i].second,i);
  }
  sort(asort.begin(),asort.end());


  rep(i,n){
    if(asort[i].first>ba[i].first){
      cout<<"No"<<endl;
      return 0;
    }
  }

  int p=0;
  rep(i,n-1){
    p=asort[p].second;
    if(p==0){
      cout<<"Yes"<<endl;
      return 0;
    }
  }

  rep(i,n-1){
    if(asort[i+1].first<=ba[i].first){
      cout<<"Yes"<<endl;
      return 0;
    }
  }

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


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

int main(){
    string s;
    cin >> s;
    for(int i = 1; i < s.size(); i++){
        if(s[i-1] == s[i]){
            cout << "Bad" << endl;
            return 0;
        }
    }
    cout << "Good" << endl;
    return 0;
}

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

using namespace std;
 
#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

typedef int64_t ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int MD = 1e9+7; typedef vector<ll> VL;
void dbg(){ cerr << "\n"; }  template <typename T,typename ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }

ll ba(int a) {return (ll)a*a;}
int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	int n, d;
	cin >>n >>d;
	vector<VI> dt(n, VI(d));
	rep(i, n) rep(j, d) cin >>dt[i][j];
	ll ans =0;
	rep(i, n) rep2(j, i+1, n){
		ll sm = 0;
		rep(k, d){
			sm += ba(dt[i][k] - dt[j][k]);
		}
		//dbg(i, j, sm);
		rep(i, 40000){
			if((ll)i*i == sm){
				ans++; break;
			}
			if((ll)i*i > sm) break;
		}
	}
	cout << ans <<"\n";
	return 0;
}


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

int main()
{
    int k;
    string s;
    cin >> k >> s;
    if(s.length()>k){
        cout << s.substr(0, k) + "...";
    }else{
        cout << s;
    }
    return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int A, B, C, k=1;
    cin >> A >> B >> C >> k;
    while(A >= B){
        B = B * 2;
        k--;
    }
    while(B >= C){
        C = C * 2;
        k--;
    }
    if(k >= 0) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 3632
#include <iostream>

using namespace std;

int main()
{
    string S;
    getline(cin,S);
    int count=0;

        if(S.find("R",0)<3)
    {
        int count=1;
        int n=S.length();
        for(int i=0; i<n; i++)
        {


                if( i<n)
                {

                    if(S[i]=='R' && S[i+1]=='R')
                    {
                        count++;
                    }
                }

        }
        cout<<count;

    }
    else
    {
        cout<<count;
    }


    return 0;
}


Measured memory_bytes: 3560
#include<iostream>
using namespace std;
int main(){
	int n;
	long long int p =1;
	
	cin>>n;
	
	for(int i=1;i<=n;i++){
		p = i*p%1000000007;
	}
	
	
	cout<<p<<endl;
	
	
	return 0;
}

Measured memory_bytes: 256
#pragma region template 1.0
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vi;
typedef pair<ll, ll> ii;
#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define REP1(i, n) for (ll i = 1; i <= (n); ++i)
#define OUT(x) cout << (x) << endl;
#define OUTA(a) \
    REP(i, (a).size()) { cout << (a[i]) << (i == (a).size() - 1 ? "\n" : " "); }
#define ALL(a) (a).begin(), (a).end()
#define SORT(a) sort(ALL(a))
#define RSORT(a) \
    SORT(a);     \
    reverse(ALL(a))

const ll INF = 1e18;
const ll MOD = 1e9 + 7;

int main()
{
    ll N;
    cin >> N;
    string S;
    cin >> S;

    ll ans = 0;
    REP1(k, N - 2)
    {
        set<char> c;
        REP(i, k)
        {
            for (ll j = k; j < N; ++j)
            {
                if (S[i] == S[j])
                {
                    c.insert(S[i]);
                }
            }
        }
        ans = max(ans, (ll)c.size());
    }
    OUT(ans);
}
#pragma endregion template

Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var n, cnt int
	var input_data []int
	done := false
	fmt.Scan(&n)
	
	for i := 0; i < n; i++ {
		var in int
		fmt.Scan(&in)
		input_data = append(input_data, in)
	}

	for {
		for i := 0; i < n; i++ {
			if v := input_data[i]; v == 0 || v % 2 != 0 {
				done = true
			}
		}
		if done {
			break
		}

		for i := 0; i < n; i++ {
			input_data[i] /= 2
		}

		cnt++
	}
	
	fmt.Println(cnt)
}

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

int main() {
  int n;
  cin >> n;
  vector<int> A(n);
  rep(i,n) {
    cin >> A.at(i);
  }
  
  int cnt = 0;
  while (true) {
    bool t = false;
    rep(i,n) {
      if (A.at(i)%2 != 0) {
        t = true;
      }
    }
    
    if(t) break;
    
    rep(i,n) {
      A.at(i) /= 2;
    }
    cnt++;
  }
  
  cout << cnt << endl;

}

Measured memory_bytes: 3564
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REP2(i, n) for (int i = 1; i <= (int)(n); i++)
#define FOR(i, m, n) for (int i = m; i n; i++)
#define SORT(x) sort(x.begin(), x.end())
#define REVE(x) reverse(x.begin(), x.end())
#define all(x) (x).begin(), (x).end()
struct initon
{
    initon()
    {
        cin.tie(0);
        ios::sync_with_stdio(false);
    };
};
int k=0,n=0, m=0, l=0,a=0, b=0, c=0, d=0,e=0,ans=0,ans2=0,x=0,y=0;
string s,t,S;
signed main() {
    cin >> a >> b >> c;
    cout << min(b/a, c);
}

Measured memory_bytes: 3560
#include <algorithm>
#include <cassert>
#include <cstring>
#include <iostream>
#include <vector>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define TRACE(x) cout << #x << " = " << x << endl
#define _ << " _ " <<

typedef long long llint;

int main(void) {
  ios_base::sync_with_stdio(false);
  int N, x;
  cin >> N >> x;

  vector<int> a(N);
  REP(i, N) cin >> a[i];

  sort(a.begin(), a.end());

  int i = 0, sum = 0;
  while (i < N && sum + a[i] <= x) sum += a[i++];

  if (i == N && sum != x) i--;
  cout << i << "\n";
  return 0;
}


Measured memory_bytes: 256
n, m = map(int,input().split())
ks = [list(map(int,input().split())) for i in range(m)]
p = list(map(int,input().split()))
cnt = 0

for i in range(2**n):
    flg = True
    for j in range(m):
        s = 0
        for k in range(1,len(ks[j])):
            if i & (1 << ks[j][k]-1):
                s += 1
        if s % 2 != p[j]:
            flg = False
            break
    if flg:
        cnt += 1
print(cnt)

Measured memory_bytes: 68356
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <iterator>
#include <map>

#define REP(i,k,n) for(int i=k;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)

using namespace std;

struct Time
{
	int t,cost;

	Time(int _t,int _cost)
	{
		t = _t;
		cost = _cost;
	}

	bool operator<(const Time &ti) const
	{
		return t < ti.t;
	}
};

int main()
{
	int n;
	while(cin >> n && n)
	{
		map<int,int> ma;

		rep(i,n)
		{
			int m,a,b;
			cin >> m >> a >> b;

			ma[a] += m;
			ma[b] -= m;
		}

		vector<Time> v;
		map<int,int>::iterator ite;
		for(ite = ma.begin();ite != ma.end();ite++)
		{
			v.push_back(Time(ite->first,ite->second));	
		}

		sort(v.begin(),v.end());
		vector<int> res;
		res.resize(v.size());
		
		int temp = 0;

		rep(i,v.size())
		{
			temp += v[i].cost;
			res[i] = temp;
		}

		bool flag = true;
		rep(i,res.size())
		{
			if(res[i] > 150) flag = false;
		}


		if(flag) cout << "OK" << endl;
		else cout << "NG" << endl;

	}

	return 0;
}

Measured memory_bytes: 1200
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
int main(){
  int n; cin>>n;
  vector<ll> num(n);
  for(int i=0;i<n;i++){
    cin>>num[i];
  }
  ll ans=0,rest=0;
  for(int i=0;i<n;i++){
    if(num[i]==0){
      rest=0;
    }else{
      num[i]+=rest;
      rest=0;
      if(num[i]%2==1) rest++;
      ans+=num[i]/2;
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 1024
#include<stdio.h>

int main(void) {
	int N, K, X, Y;
	scanf(" %d %d %d %d", &N, &K, &X, &Y);
	if (N <= K) {
		printf("%d\n", N*X);
	}
	else {
		printf("%d\n", K*X + (N - K) * Y);
	}
	return 0;
}

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

int main(int argc, char *argv[]) {
  ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);

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

  cout<<max(a-k, 0ll)<<' ';
  cout<<max(b - max(k - a, 0ll), 0ll)<<endl;

  return 0;
}


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

int main() {
    int d, g, ans = INT_MAX;
    cin >> d >> g;
    vector<pair<int, int>> question(d);
    rep(i, d) cin >> question.at(i).first >> question.at(i).second;
    rep(i, 1 << d) {
        int temp = 0, cnt = 0, maximum = 0;
        rep(j, d) {
            if(1 & (i >> j)) {
                temp += 100 * (j + 1) * question.at(j).first;
                temp += question.at(j).second;
                cnt += question.at(j).first;
            } else {
                maximum = j;
            }
            if(temp >= g) break;
        }
        rep(j, question.at(maximum).first) {
            if(temp + 100 * (maximum + 1) * j >= g) {
                temp += 100 * (maximum + 1) * j;
                cnt += j;
                break;
            }
        }
        if(temp >= g) ans = min(ans, cnt);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<string>
using namespace std;
int main()
{
  //入力
  int h,w;
  cin>>h>>w;
  char s[h+2][w+2];
  for(int i=1;i<=h;i++) for(int j=1;j<=w;j++) cin>>s[i][j];

  for(int i=0;i<=w+1;i++) { s[0][i]='.'; s[h+1][i]='.'; }
  for(int i=0;i<=h+1;i++) { s[i][0]='.'; s[i][w+1]='.'; }

  bool flag=true;
  for(int i=1;i<=h;i++)
  {
    for(int j=1;j<=w;j++)
    {
      if(s[i][j]=='#')
      {
        if((s[i-1][j]=='#' || s[i+1][j]=='#') || s[i][j-1]=='#' || s[i][j+1]=='#');
        else flag=false;
      }
    }
  }

  if(flag) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define space ' '
typedef long long ll;
typedef long double ld;
const long double PI = 3.14159265358979323846;

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

    string w;
    cin >> w;
    int n = w.size();
    unordered_map<char, int> occurs;
    for (int i = 0 ; i < n; ++i) {
        occurs[w[i]] += 1;
    }
    for (auto x : occurs) {
        if (x.second % 2) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;

    return 0;
}


Measured memory_bytes: 256
Max=1000000
Sqrt=1000
def prime_number():
    count=[]
    prime=[True for i in range(Max)]
    for i in range(4,Max,2):
        prime[i]=False
    for i in range(3,Sqrt,2):
        if prime[i]==True:
            for j in range(i*2,Max,i):
                prime[j]=False       
    for k in range(2,Max):
        if prime[k]==True:
            count.append(k)
    return count
box=prime_number()
while 1:
    try:
        ans=0
        N=int(input())
        if N==0:break
        for i in range(N):
            ans +=box[i]
        print(ans)
    except:break



Measured memory_bytes: 16320
from sys import stdin
import sys

n,m,k = [int(x) for x in stdin.readline().rstrip().split()]
A = [int(x) for x in stdin.readline().rstrip().split()]
B = [int(x) for x in stdin.readline().rstrip().split()]

cc = []
count = 0
sumA = 0

for i in range(n):
    sumA_ = sumA + A[i]
    if sumA_ > k: break

    sumA = sumA_
    count = count + 1

maxA = count

sumB = 0
j = 0

for i in range(maxA+1):
    if i != 0:
        count = count - 1
        sumA = sumA - A[maxA-i]

    while True:
        sumB_ = sumB + B[j]

        if sumA + sumB_ > k:
            cc.append(count)
            break

        sumB = sumB_
        count = count + 1
        j = j + 1

        if j == m:
            cc.append(count)
            break

    if j == m:
        break


if cc == []:
    print (0)
else:
    print (max(cc))






Measured memory_bytes: 41016
s = gets.chomp.split("")
bw = Array.new(2, 0)
i = 0
s.each do |c|
  if i % 2 == 0
    if c == "0"
      bw[1] += 1
    else
      bw[0] += 1
    end
  else
    if c == "0"
      bw[0] += 1
    else
      bw[1] += 1
    end
  end
  i += 1
end
bw.sort!
puts bw[0]


Measured memory_bytes: 9468
def main():
    A, B, C, D, E, F = map(int, input().split())
    ans = -1
    sugar = 0
    sugar_water = 0
    for a in range(F // (A * 100) + 1):
        for b in range((F - 100 * A * a) // (B * 100) + 1):
            for c in range((F - 100 * A * a - 100 * B * b) // C + 1):
                for d in range((F - 100 * A * a - 100 * B * b - C * c) // D + 1):
                    x = a * A + b * B
                    y = c * C + d * D
                    if x == 0:
                        continue
                    if x * E >= y and ans < (100 * y)/(x*100+y):
                        ans = (100 * y)/(x*100+y)
                        sugar = y
                        sugar_water = 100 * x + y
    print(sugar_water,sugar)

if __name__ == "__main__":
    main()

Measured memory_bytes: 73612
#pragma GCC optimize(3,"Ofast","inline")
#include<bits/stdc++.h>

#define int long long
#define pb push_back
#define pf push_front
#define st first
#define nd second
#define sz(x) ((int)x.size())
#define ins insert
#define fastio ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define lowbit(x) ((x)&(-x))
#define pi acos(-1.0)
using namespace std;

const int maxn=2e5+10;
const int maxe=1e6+10;
const int mod=1e9+7;
const int inf=0x3f3f3f3f;

inline int read(){
    int x=0; bool flag=1; char ch=getchar();
    while(ch<'0'||ch>'9') {if(ch=='-') flag=0; ch=getchar();}
    while(ch>='0'&&ch<='9') {x=(x<<1)+(x<<3)+ch-'0'; ch=getchar();}
    if(flag) return x;
    return ~(x-1);
}
inline void write(int x){
    if(x<0) {x=~(x-1); putchar('-');}
    if(x>9) write(x/10);
    putchar(x%10+'0');
}

int a[maxn];
int sum[maxn]={};
main(){
    fastio;
    int n=read();
    for(int i=1;i<=n;++i)a[i]=read();
    for(int i=n;i>=1;--i)sum[i]=(sum[i+1]+a[i])%mod;
    int ans=0;
    for(int i=1;i<=n;++i){
        ans=(ans+(a[i]*sum[i+1])%mod)%mod;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 6780
use std::io::{BufRead, Write, stdin, stdout};

fn solve<R: BufRead, W: Write>(mut input: R, mut output: W) {
    let mut s = String::new();
    input.read_line(&mut s).unwrap();
    let x = s.trim().parse::<i64>().unwrap();
    let mut result = ((x * 2) as f64).sqrt().floor() as i64;
    if result * (result + 1) / 2 < x {
        result += 1;
    }
    writeln!(output, "{}", result).unwrap();
}

fn main() {
    let stdin = stdin();
    let stdout = stdout();
    solve(stdin.lock(), stdout.lock());
}

#[cfg(test)]
mod tests {
    fn test(input: &str, output: &str) {
        let mut v = Vec::<u8>::new();
        ::solve(input.as_bytes(), &mut v);
        assert_eq!(String::from_utf8(v).unwrap(), output);
    }
    #[test]
    fn case1() {
        test("6\n", "3\n");
    }
    #[test]
    fn case2() {
        test("2\n", "2\n");
    }
    #[test]
    fn case3() {
        test("11\n", "5\n");
    }
}


Measured memory_bytes: 4352
#include <algorithm>
#include <cassert>
#include <functional>
#include <iostream>
#include <vector>

typedef long long ll;

using namespace std;

int main() {
  std::ios_base::sync_with_stdio(false);
  int n; cin >> n;
  vector<int> a(n);
  int div2 = 0, div4 = 0;
  for (int& x : a) {
    cin >> x;
    div2 += x % 2 == 0;
    div4 += x % 4 == 0;
  }
  bool ok = div4 * 2 + 1 >= n || 2 * div4 + (div2 - div4) >= n;
  cout << (ok ? "Yes\n" : "No\n");
  return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <sstream>
#include <cstdio>
#include <stdlib.h>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
int n,array[101],m[101][101];
void matrixchainorder(){
  int i,j,l,k;
  for(i=0;i<n+1;i++)
    for(j=0;j<n+1;j++)
      m[i][j]=2000000000;
  for(i=0;i<n+1;i++)m[i][i]=0;
  for(l=2;l<=n;l++){
    for(i=1;i<=n-l+1;i++){
      j=i+l-1;
      for(k=i;k<=j-1;k++){
	m[i][j]=min(m[i][j],m[i][k]+m[k+1][j]+array[i-1]*array[k]*array[j]);
      }
    }
  }
}
int main(){
  cin>>n;
  for(int i=0;i<n;i++)cin>>array[i]>>array[i+1];
  matrixchainorder();
  cout<<m[1][n]<<endl;

  return 0;
}



Measured memory_bytes: 3152
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)

int vs[10];
int main(void) {
  REP(i, 3) {
    scanf("%d", &vs[i]);
  }

  sort(vs, vs + 3);
  puts(vs[0] == 5 && vs[1] == 5 && vs[2] == 7 ? "YES" : "NO");
  return 0;
}


Measured memory_bytes: 128
#include<stdio.h>
int main(){
  int n,m,x,i,k,d[2][200020],r[2],w[2][200020]={};
  char s[2][200020]={};
  scanf("%d %d %d %s",&n,&m,&x,s[0]);
  for(k=0;k<2;k++){
    for(i=r[k]=0;i<n;i++){
      if(d[k][i]==0){
	if(s[k][i]=='o'){
	  w[k][r[k]++]=i;
	  d[k][i+1]=x;
	}
      }
      else d[k][i+1]=d[k][i]-1;
    }
    for(i=0;i<n;i++)s[1][i]=s[0][n-i-1];
    //printf("%s\n",s[1]);
  }
  //for(i=0;i<r[0];i++)printf("%d ",  w[0][i    ]  );printf("\n");
  //for(i=0;i<r[1];i++)printf("%d ",n-w[1][m-i-1]-1);printf("\n");
  //printf("%d %d %d\n",
  if(r[0]==r[1]&&r[0]==m){
    for(i=0;i<m;i++){
      if(w[0][i]==n-w[1][m-i-1]-1)printf("%d\n",w[0][i]+1);
    }
  }
  return 0;
}


Measured memory_bytes: 4864
#include <algorithm>
#include <array>
#include <climits> // INT_MAX, LONG_MAX, LLONG_MAX, UINT_MAX, ULONG_MAX, ULLONG_MAX
#include <cmath>
#include <cstdint>
#include <cstring> // memset
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <vector>

#define ALL(x) (x).begin(), (x).end()
#define INF 1e9
#define LOG(x) cout << #x << " = " << (x) << endl
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)

using namespace std;

int main() {
    ios::sync_with_stdio(false);

    long long a, b;
    string op;
    cin >> a >> op >> b;
    cout << (op == "+" ? a + b : a - b) << endl;
    
    return 0;
}


Measured memory_bytes: 256
a = int(input())
b = int(input())
c = int(input())
x = int(input())

count = 0
for i in range(a+1):
  for j in range(b+1):
    for k in range(c+1):
      num = x - 500 * i - 100 * j - 50 * k
      if num == 0:
        count += 1
print(count)
    

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

using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cout.precision(12);
    cout << fixed;
    cin.tie(0);

    int L;
    cin >> L;

    int MUL = 32;
    vector<pair<int, int> > edges;
    int n = 1;
    int done = 1;
    while(true) {
        if (2 * done > L) {
            break;
        }
        n++;
        done *= 2;
    }

    int q = done / 2;
    for (int i = 1; i < n; i++) {
        edges.push_back({i*MUL+i+1, q});
        edges.push_back({i*MUL+i+1, 0});
        q /= 2;
    }
    int rest = L - done;

    while(rest > 0) {
        int add = 1;
        int to = n;
        while(true) {
            if (2 * add > rest) {
                break;
            }
            add *= 2;
            to--;
        }
        edges.push_back({1*MUL+to, done});
        rest -= add;
        done += add;
    }

    cout << n << " " << edges.size() << endl;
    for (auto e : edges) {
        cout << e.first / MUL << " " << e.first % MUL << " " << e.second << endl;
    }

    return 0;
}


Measured memory_bytes: 256
from collections import deque
h, w = map(int, input().split())
S = [list(input()) for _ in range(h)]
INF = 10010001001
way = [[0, 1], [0, -1], [1, 0], [-1, 0]]

ans = 0
for sy in range(h):
    for sx in range(w):
        dist = [[INF] * w for _ in range(h)]
        dist[sy][sx] = 0
        if S[sy][sx] == '#':
            continue
        q = deque()
        q.append((sy, sx))
        while len(q):
            y, x = q.popleft()
            for dy, dx in way:
                ny, nx = y + dy, x + dx
                if not (0 <= ny <= h - 1 and 0 <= nx <= w - 1):
                    continue
                if S[ny][nx] == '#' or dist[ny][nx] != INF:
                    continue
                dist[ny][nx] = dist[y][x] + 1
                q.append((ny, nx))
        for yy in range(h):
            for xx in range(w):
                if dist[yy][xx] == INF:
                    continue
                else:
                    ans = max(ans, dist[yy][xx])
print(ans)

Measured memory_bytes: 47580
let content = '';
process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', buf => {
  content += buf;
});
process.stdin.on('end', () => {
  const nums = content
    .trim()
    .split('\n')
    .map(line =>
      line
        .split(' ')
        .map(n => parseInt(n, 10))
        .sort((a, b) => a - b)
    )
    .filter(([fst, snd]) => fst !== 0 || snd !== 0);
  nums.forEach(pair => console.log(pair.join(' ')));
});


Measured memory_bytes: 20588
#include<stdio.h>
#include<iostream>
#include<string>
#include<vector>
#include<stdlib.h>
#include<set>
#include<math.h>
#include<iomanip>

using namespace std;


int main(void)
{
    int n;
    cin>>n;
    
    int h[n];
    
    for(int i=0;i<n;i++){
        cin>>h[i];
    }
    
    int flag=0;
    h[0]--;
    
    for(int i=1;i<n;i++){
        if(h[i]-h[i-1]<0){
            flag=1;
            break;
        }
        
        else if(h[i]-h[i-1]>0){
            h[i]--;
        }
    }
    
    if(flag==1){
        cout<<"No"<<endl;
    }
    else{
        cout<<"Yes"<<endl;
    }
    
}


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

list< int > del(list< int > input, int value) {
  for (list< int >::iterator iter = input.begin(); iter != input.end(); iter++) {
    if (*iter == value) {
      input.erase(iter);
      return input;
    }
  }
  return input;
}

int main(int argc, char **argv) {
  ios_base::sync_with_stdio(false);
  int n;
  cin >> n;
  list< int > my_list;
  for (int i = 0; i < n; i++) {
    string holder;
    cin >> holder;
    if (holder == "insert") {
      int value;
      cin >> value;
      my_list.push_front(value);
    } else if (holder == "delete") {
      int value;
      cin >> value;
      my_list = del(my_list, value);
    } else if (holder == "deleteFirst") {
      my_list.pop_front();
    } else {
      my_list.pop_back();
    }
  }
  list< int >::iterator iter = my_list.begin();
  while (iter != my_list.end()) {
    cout << *iter;
    if (++iter == my_list.end())
      cout << endl;
    else
      cout << ' ';
  }
  return 0;
}



Measured memory_bytes: 54628
#include<bits/stdc++.h>
using namespace std;
#define ll long long int

int main(){
 ll A,B,K;
  cin>>A>>B>>K;
  if(K<=A)
    cout<<A-K<<" "<<B<<endl;
  else if(K<=A+B)
  {
    cout<<0<<" "<<B-(K-A)<<endl;
  }
  else
  {
    cout<<0<<" "<<0<<endl;
  }
  return 0;
}

Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let r: i64 = read();
    let d: i64 = read();
    let mut x: i64 = read();

    for _ in 0..10 {
        x = x * r - d;
        println!("{}", x);
    }
}


Measured memory_bytes: 2128
// AOJ 0590
// @kankichi573
#include <stdio.h>
#include <string.h>

char prime_flag[65536];

int prime256[]={2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,
67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,
157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,
241,251};

make_furui()
{
        int i,j,num;
        memset(prime_flag,-1,65536);
        
        prime_flag[0]=prime_flag[1]=0;

        for(i=0;prime256[i];i++)
                for(j=2;(num=prime256[i]*j)<65536;j++)
                {
                        prime_flag[num]=0;
                }
}


main()
{
        int N,i;

        make_furui();

        while(scanf("%d",&N) && N)
	  {
	    if((N % 2)==0)
	      N--;
	    for(i=N;i>=3;i-=2)
	      if(prime_flag[i] && prime_flag[i-2])
		{
		  printf("%d %d\n",i-2,i);
		  break;
		}
	  }
        return(0);
}

Measured memory_bytes: 672
//In the name of ALLAH
#include <bits/stdc++.h>
#define pb push_back
#define X first
#define Y second
const bool DEBUG = false;
#define cerr if(DEBUG)cerr
using namespace std;

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

const long long maxn = 2e5 + 5;
const long long INF = 1e18 + 1;
const long long M = 1e9 + 7;
const int lg = 21;

int n, m, ans, p[maxn];
vector<int> g[maxn];
vector<int> pos;
bool mark[maxn];
set<int> s;

void dfs(int v){
	pos.pb(v);
	s.insert(p[v]);
	mark[v] = 1;
	for(auto u : g[v]){
		if(!mark[u])
			dfs(u);
	}
}

int main(){
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	cin >> n >> m;
	for(int i = 0; i < n; i++)
		cin >> p[i], p[i]--;
	for(int i = 0; i < m; i++){
		int x, y;
		cin >> x >> y, x--, y--;
		g[x].pb(y);
		g[y].pb(x);		
	}
	for(int i = 0; i < n; i++){
		if(!mark[i]){
			s.clear();
			pos.clear();
			dfs(i);
			for(auto u : pos)
				if(s.find(u) != s.end())
				ans++;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 16632
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i)
using namespace std;
using ll=long long;
int main(){
    int n;
    cin>>n;
    int ans=0;
    for(int i=1; i<=n; ++i){
        string s=to_string(i);
        if(s.length()%2==1){
            ans++;
        }
    }
    cout<<ans<<endl;
}

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

const int n_MAX = 100010;

int main() {
  int n;
  int a[n_MAX];
  int b[n_MAX];

  cin >> n;
  for (int i = 1; i <= n; ++i) cin >> a[i];

  for (int i = 1; i <= n; ++i) {
    b[a[i]] = i;
  }

  for (int i = 1; i < n; ++i) {
    printf("%d ", b[i]);
  }

  printf("%d\n", b[n]);
  return 0;
}


Measured memory_bytes: 1536
#include <iostream>
#include <time.h>
#include <algorithm>
#include <math.h>
#include <set>
#include <vector>
#define ll  int
#define mod 998244353
#define mp make_pair
using namespace std;
int main() {
	double x;
	cin >> x;
	double start_amount = 100;
	ll count = 0;
	while (start_amount <= x) {
		if (start_amount == x)
			break;
		start_amount = start_amount * 1.01;
		start_amount = floor(start_amount);
//		cout << start_amount << endl;
		++count;
	}
	cout << count;
}

Measured memory_bytes: 3736
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const long long LINF = 1e18;
const long long MOD = 1e9 + 7;

bool use1[10];
bool use2[10][10];
bool use3[10][10][10];

signed main(){
    int n;
    string s;
    cin >> n;
    cin >> s;
    for(int i = 0; i < n; i++){
        int num = s[i] - '0';
        for(int j = 0; j < 10; j++){
            for(int k = 0; k < 10; k++){
                if(use2[j][k]) use3[j][k][num] = true;
            }
        }
        for(int j = 0; j < 10; j++){
            if(use1[j]) use2[j][num] = true;
        }
        use1[num] = true;
    }
    int ans = 0;
    REP(i,10){
        REP(j,10){
            REP(k,10){
                if(use3[i][j][k]) ans++;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main
{

public static void main(String[] args) {
	    Scanner in=new Scanner(System.in);
	   long x=in.nextLong();
	   long y=in.nextLong();
      long p=gcd(x,y);
      long  lcm= x*y/p;
      int ok=1;
long ans=-1;
for(long i=x;i<lcm;i+=x)
{
if(i%y==0)
{
ok=0;
break;
}
else {ans=i;break;}
}
      if(ok==0)
      System.out.println(-1);
      else
    	  System.out.println(ans);
	    }
	static long gcd (long a,long b) {
		return b==0?a:gcd(b,a%b);
	}
}

Measured memory_bytes: 21844
object Main extends App {
	override def main(args: Array[String]) = {
		val sc = new java.util.Scanner(System.in)
		
		val n : Int = sc.nextInt
		
		var min : Int = 1000000
		var max : Int = -1000000 
		var sum : Long = 0
		for(_ <- 1 to n){
			val x:Int = sc.nextInt
			min = Math.min(x,min)
			max = Math.max(x,max)
			sum = x + sum
		}
		println(f"$min%d $max%d $sum%d")
	}
}

Measured memory_bytes: 60888
#include <bits/stdc++.h>
#include <climits>
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define srep(i, begin, end) for (__typeof(end) i = begin; i != end; i++)
#define si(x) int x = scanInt();
#define sll(x) LL x = scanLong();
#define sci(x) int x; scanf("%d", &x);
#define scll(x) LL x; scanf("%lld", &x);
#define pi(x) printf("%d ", x)
#define pll(x) printf("%lld ", x)
#define nl printf("\n")
#define clr(a) memset(a, 0, sizeof(a))
#define PB push_back
#define MP make_pair
using namespace std;
typedef unsigned int UI; // 32 bit integer
typedef long int LI; // 32 bit integer
typedef unsigned long int ULI; // 32 bit unsigned integer
typedef long long int LL; // 64 bit integer
typedef unsigned long long int ULL; // 64 bit unsigned integer
typedef long double LD;
typedef vector<int> VI;
typedef vector<LL> VLL;
typedef deque<int> DI;
typedef deque<LL> DLL;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
const LL MOD = 1e9+7;

/* Fast I/O */
inline int scanInt() {
	int n = 0;
	char ch = getchar();
	int sign = 1;
	while(ch < '0' || ch > '9') {
		if(ch == '-')	sign = -1;
		ch = getchar();
	}
	while(ch >= '0' && ch <= '9') {
		n = (n<<1)+(n<<3)+(int)(ch-'0');
		ch = getchar();
	}
	return n*sign;
}

inline LL scanLong() {
	LL n = 0;
	char ch = getchar();
	LL sign = 1;
	while(ch < '0' || ch > '9') {
		if(ch == '-')	sign = -1;
		ch = getchar();
	}
	while(ch >= '0' && ch <= '9') {
		n = (n<<1)+(n<<3)+(LL)(ch-'0');
		ch = getchar();
	}
	return n*sign;
}

bool check(string str, LL start, LL end) {
	while(start != end) {
		if(end - start == 1)	return true;
		if(str[start+1] == '.')	start++;
		else if(str[start+2] == '.')	start += 2;
		else	return false;
	}
	return true;
}

bool checkTriple(string str, LL start, LL end) {
	rep(i, start, end+1) {
		if(str[i] == '.' && str[i+1] == '.' && str[i-1] == '.')
			return true;
	}
	return false;
}

int main() {
	sll(n); sll(a); sll(b); sll(c); sll(d);
	a--; b--; c--; d--;
	string str; cin >> str;
	if(check(str, a, c) && check(str, b, d)) {
		if(c < d)	puts("Yes");
		else if(c > d && checkTriple(str, b, d))	puts("Yes");
		else	puts("No");
	}
	else	puts("No");
}


Measured memory_bytes: 900
import java.io.PrintWriter;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;

class Main implements Runnable {
	public static void main(String[] args) {
		new Thread(null, new Main(), "", Runtime.getRuntime().maxMemory()).start();
	}

	class State {
		int i;
		int parent;
		int j;// in next step,go into g[i][j]

		public State(int i_, int parent_, int j_) {
			i = i_;
			parent = parent_;
			j = j_;
		}
	}

	int strongly_connected_componets(ArrayList<Integer>[] g, int[] col) {
		int n = g.length;
		Arrays.fill(col, -1);
		int cols = 0;
		int[] low = new int[n];
		int[] ord = new int[n];
		boolean[] marked = new boolean[n];
		Arrays.fill(low, -1);
		Arrays.fill(ord, -1);
		int order = 0;
		ArrayDeque<State> stk = new ArrayDeque<>();
		ArrayDeque<Integer> pnd = new ArrayDeque<>();
		for (int ii = 0; ii < n; ++ii) {
			if (ord[ii] == -1) {
				stk.add(new State(ii, -1, 0));
			}
			while (!stk.isEmpty()) {
				State s = stk.pollFirst();
				if (ord[s.i] == -1) {
					low[s.i] = (ord[s.i] = order++);
					pnd.addFirst(s.i);
				}
				if (s.j > 0 && s.parent != g[s.i].get(s.j - 1) && !marked[g[s.i].get(s.j - 1)]) {
					if (low[g[s.i].get(s.j - 1)] == -1) {
						throw new AssertionError();
					}
					low[s.i] = Math.min(low[s.i], low[g[s.i].get(s.j - 1)]);
				}
				if (s.j == g[s.i].size() && low[s.i] == ord[s.i]) {
					while (true) {
						int v = pnd.pollFirst();
						col[v] = cols;
						marked[v] = true;
						if (v == s.i)
							break;
					}
					++cols;
					continue;
				}
				if (s.j == g[s.i].size())
					continue;
				int v = g[s.i].get(s.j);
				stk.addFirst(new State(s.i, s.parent, s.j + 1));
				if (ord[v] == -1) {
					stk.addFirst(new State(v, s.i, 0));
				} else if (!marked[v]) {
					low[s.i] = Math.min(low[s.i], low[v]);
				}
			}
		}
		return cols;
	}

	@SuppressWarnings("unchecked")
	public void run() {
		Scanner sc = new Scanner(System.in);
		PrintWriter pw = new PrintWriter(System.out);
		int V = sc.nextInt();
		int E = sc.nextInt();
		ArrayList<Integer>[] g = new ArrayList[V];
		for (int i = 0; i < V; ++i) {
			g[i] = new ArrayList<>();
		}
		for (int i = 0; i < E; ++i) {
			int s = sc.nextInt();
			int t = sc.nextInt();
			g[s].add(t);
		}
		int[] col = new int[V];
		strongly_connected_componets(g, col);
		int q = sc.nextInt();
		while (q-- > 0) {
			int u = sc.nextInt();
			int v = sc.nextInt();
			System.out.println(col[u] == col[v] ? "1" : "0");
		}
	}

	static void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}

}

Measured memory_bytes: 100348
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define pii pair <int, int>
#define fi first
#define sc second
#define ALL(x) x.begin(), x.end()
#define RALL(X) x.begin(), x.end()
#define FOR(i, n, k) for(i=0; i<n; i+=k)
#define FO(i, n, k) for(i=1; i<=n; i+=k)
#define CLEAR(a, b) memset(a, b, sizeof(a))
#define N 100005
#define mid ((l+r)/2)
#define dbg(x) (cerr << #x << " : " << x << endl)
#define endl "\n"
#define MOD 100000009

using namespace std;

typedef long long int lli;

lli odd_solve(lli x){
	return ((x+1) / 2) % 2;
}

lli solve(lli x){
	if(x % 2) return odd_solve(x);
	return odd_solve(x-1) ^ x;
}

int main(){
	ios_base::sync_with_stdio(false);
	lli a, b;
	cin >> a >> b;
	cout << (solve(b) ^ solve(a-1));	
	return 0;
}

Measured memory_bytes: 256
a,b,c,d,e,f=[int(i) for i in input().split(' ')]
a=a*100
b=b*100
am = f//a
bm = f//b
cm = int((f/((100+e)/e))//c)
dm = int((f/((100+e)/e))//d)

yl=0
yn=0
ys=0
for i_a in range(am+1):
  la=i_a*a
  for i_b in range(bm+1):
    lb=i_b*b
    if 0<la+lb<=f:
      for i_c in range(cm+1):
        lc=i_c*c
        if 0<la+lb+lc<=f:
          for i_d in range(dm+1):
            ld=i_d*d
            if 0<la+lb+lc+ld<=f:
              if (lc+ld)/(la+lb+lc+ld) <= e/(100+e):
                n=(lc+ld)/(la+lb+lc+ld)
                if n >= yn:
                  yn=n
                  yl=la+lb+lc+ld
                  ys=lc+ld
print(yl,ys)

Measured memory_bytes: 3064
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.text.DecimalFormat;
import java.text.NumberFormat;
import java.util.StringTokenizer;

public class Main {
  private static class InputReader {
    public BufferedReader reader;
    public StringTokenizer tokenizer;

    public InputReader(final InputStream stream) {
      reader = new BufferedReader(new InputStreamReader(stream), 32768);
      tokenizer = null;
    }

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

    public int nextInt() {
      return Integer.parseInt(next());
    }

    public long nextLong() {
      return Long.parseLong(next());
    }

    public double nextDouble() {
      return Double.parseDouble(next());
    }
  }

  private static class OutputWriter extends PrintWriter {
    public OutputWriter(final OutputStream outputStream) {
      super(outputStream);
    }

    @Override
    public void println() {
      super.println();
      super.flush();
    }
  }

  private static boolean isLocal() {
    return new File("../in.txt").exists();
  }

  public static void main(final String[] args) throws IOException {
    final InputStream inputStream = isLocal() ? new FileInputStream("../in.txt") : System.in;
    final OutputStream outputStream = System.out;
    final InputReader in = new InputReader(inputStream);
    final OutputWriter out = new OutputWriter(outputStream);
    final Task solver = new Task();
    int testcase = 1;
    while (testcase-- > 0) {
      solver.solve(in, out);
    }
    out.close();
  }

  private static class Task {
    public void solve(final InputReader in, final PrintWriter out) {
      int S = in.nextInt();
      int W = in.nextInt();
      if (W >= S) {
        out.println("unsafe");
      } else {
        out.println("safe");
      }
    }
  }
}


Measured memory_bytes: 32684
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <time.h>
#include <iostream>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <assert.h>
#include <fstream>

using namespace std;

const int MAXN = 100005;

int n,ans;

pair<int,int> a[MAXN];

int main()
{
	ios::sync_with_stdio(false);
	cin >> n;
	for (int i = 1;i <= n;i++)
	{
		cin >> a[i].first;
		a[i].second = i;
	}
	sort(a + 1,a + n + 1);
	for (int i = 1;i <= n;i += 2)
		ans += (~a[i].second & 1);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>

int main(void){

  char s1,s2,s3;
  scanf("%c%c%c", &s1, &s2, &s3);
  int answer = 0;
  if (s1 == '1') {
    answer++;
  }
  if (s2 == '1') {
    answer++;
  }
  if (s3 == '1') {
    answer++;
  }
  printf("%d\n", answer);

  return 0;
}

Measured memory_bytes: 128