akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstring>
#include <algorithm>
#define inf 0x3f3f3f3f3f3f3f3fLL

using namespace std;

typedef long long ll;

ll d[5005];
int maxn[205][5005][20],ln[5005],m;

inline int query(int p[][20],int l,int r) {
  int k=ln[r-l+1];
  return max(p[l][k],p[r-(1<<k)+1][k]);
}

ll calc(int l,int r) {
  ll ans=d[l]-d[r];
  for(int i=1;i<=m;i++) ans+=query(maxn[i],l,r);
  return ans;
}

ll ans;

void solve(int l,int r,int lx,int rx) {
  if (l>r) return;
  int m=((l+r)>>1),id=0;
  ll now=-inf;
  for(int i=lx;i<=min(rx,m);i++) {
  	ll s=calc(i,m);
  	if (s>now) {
  		now=s;id=i;
	  }
  }
  ans=max(ans,now);
  solve(l,m-1,lx,id);
  solve(m+1,r,id,rx);
}

int main() {
  int n;
  scanf("%d%d",&n,&m);
  for(int i=2;i<=n;i++) {
  	int x;
  	scanf("%d",&x);
  	d[i]=d[i-1]+x;
  }
  for(int i=1;i<=n;i++)
    for(int j=1;j<=m;j++) scanf("%d",&maxn[j][i][0]);
  for(int i=1;i<=m;i++)
    for(int j=1;j<20;j++)
      for(int k=1;k<=n-(1<<j)+1;k++) maxn[i][k][j]=max(maxn[i][k][j-1],maxn[i][k+(1<<(j-1))][j-1]);
  for(int i=2;i<=n;i++) ln[i]=ln[i>>1]+1;
  ans=-inf;
  solve(1,n,1,n);
  printf("%lld\n",ans);
  return 0;
}

Measured memory_bytes: 79744
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  if(b<c||a>d){
    cout << 0 << endl;
  }
  else{
    cout << min(b,d)-max(a,c) << endl;
  }
}


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

int main()
{
	int n = 0, k = 0;
	string s = "";
	cin >> n >> s >> k;
	char nonchange = s[k - 1];
	for (int i = 0; i < n; i++)
	{
		if (s[i] != nonchange)
			s[i] = '*';
	}
	cout << s;
}

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

using namespace std;

int main(){
    int N;
    cin>>N;
    int ans=0;
    vector<int> v(N), c(N);
    for(int i=0; i<N; ++i){
        cin>>v[i];
    }
    for(int i=0; i<N; ++i){
        cin>>c[i];
    }
    for(int i=0; i<N; ++i){
        if(v[i]-c[i]>0){
            ans+=v[i]-c[i];
        }
    }
    cout<<ans<<endl;
    return 0;
}

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

using namespace std;

#define N 3001

typedef long long ll;

ll pg[N][N];


int main() {
	int n;

	cin >> n;

	int a[n];

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

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

		int I = 0;

		for (int j = i;j < n;j++) {
			ll p1 = pg[I][I] - pg[I + 1][j];
			ll p2 = pg[j][j] - pg[I][j - 1];

			if (p1 > p2) {
				pg[I][j] = p1;
			} else {
				pg[I][j] = p2;
			}	

			I++;
		}

	}

	cout << pg[0][n - 1];
}


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

int main() {
    int N ;
    cin >> N ;
    if(N%10 ==3)
        cout << "bon" << endl;
    else if (N%10 == 0 || N%10 ==1 || N%10 == 6 || N%10 == 8)
        cout << "pon" << endl;
    else 
        cout << "hon" << endl;
}



Measured memory_bytes: 3648
from bisect import bisect_left
N, K = map(int, input().split())
x = [int(s) for s in input().split()]

izero = bisect_left(x, 0)
zpos = x[izero:]
neg = [-v for v in reversed(x[:izero])]

ans = 1000000000
if len(neg) >= K and ans > neg[K - 1]:
    ans = neg[K - 1]
if len(zpos) >= K and ans > zpos[K - 1]:
    ans = zpos[K - 1]
for lenneg in range(max(1, K - len(zpos)), min(K - 1, len(neg)) + 1):
    cand = 2 * neg[lenneg - 1] + zpos[K - lenneg - 1]
    if ans > cand:
        ans = cand
    cand = neg[lenneg - 1] + 2 * zpos[K - lenneg - 1]
    if ans > cand:
        ans = cand
print(ans)


Measured memory_bytes: 14372
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout<< (x) << " "

int main(){
    int n;cin>>n;
    vector<int> v(n);rep(i,n)cin>>v[i];
    sort(v.begin(),v.end(), less<int>());
    co(abs(v[n/2]-v[n/2-1]));
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string a;
	long long n,o,i;
	bool flag=0;
	getline(cin,a);
	for(i=0;i<a.size();i++)
	{
		if(a[i]=='C')
		{
			flag=1;
		}
		if(a[i]=='F' && flag==1)
		{
			cout<<"Yes"<<endl;
			return 0; 
		}
	 } 
	 cout<<"No"<<endl;
	return 0;
}

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

#define MAX_SIZE (100000 + 10)
int DP[MAX_SIZE];
int A[MAX_SIZE];

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

  DP[0] = 0;
  DP[1] = std::abs(A[1] - A[0]);
  for (int i = 2; i < N; ++i)
  {
    DP[i] = std::min(DP[i - 1] + abs(A[i] - A[i - 1]), DP[i - 2] + abs(A[i] - A[i - 2]));
  }

  std::cout << DP[N - 1] << std::endl;

  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const int INF = 1001001001;
ll n;

int main(){
  cin >> n;
  vector<ll> sosuu = {2,3,5,7,11,13,17,19,23,29,31};
  vector<ll> kosuu(1001,0); 
  ll count = 0;
  for(int i=2;i<=n;i++){
    int x = i;
    for(int j=0;j<11;j++){
      while(x%sosuu.at(j) == 0){
        x /= sosuu.at(j);
        kosuu.at(sosuu.at(j))++;
      }
    }  
    if(x!=1) kosuu.at(x)++;
  }
  ll ans = 1;
  for(int i=0;i<1001;i++){
    ans = ans * (1+kosuu.at(i)) % mod;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.*;
import java.util.stream.StreamSupport;

public class Main {

    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        int N = s.nextInt();
        int M = s.nextInt();
        PriorityQueue<Long> queue = new PriorityQueue<>(N, Comparator.comparing(Long::longValue).reversed());
        for (int i = 0; i < N; i++) {
            queue.add(s.nextLong());
        }

        int tmpM = M;
        while (queue.size() > 0 && tmpM > 0) {
            Long p = queue.poll();
            long newP = p / 2;
            if (newP > 0) queue.add(newP);
            tmpM--;
        }

        long totalPrice = StreamSupport.stream(queue.spliterator(), true).mapToLong(Long::longValue).sum();
        System.out.println(totalPrice);
     }
}

Measured memory_bytes: 96368
#include <bits/stdc++.h>
#include <stdio.h>
#include <ios>     
#include <iomanip> 

using namespace std;
#define inputInt(a) int a; cin >> a; 
#define inputInt2(a,b) int a; int b; cin >> a >> b; 
#define inputInt3(a,b,c) int a; int b; int c; cin >> a >> b >> c;
#define inputLong(a) long a;cin >> a; 
#define inputIntArray(a,N) int a[N];for(int i=0;i<N;i++){cin >> a[i];}
#define inputLongArray(a,N) long a[N];for(int i=0;i<N;i++){cin >> a[i];}
#define inputIntArray2(a,b,N) int a[N]; int b[N]; for(int i=0;i<N;i++){cin >> a[i] >> b[i];}
#define output(answer) cout << answer << endl;
#define fN(i,N)    for(int i=0; i<N; i++)
#define fSE(i,s,e) for(int i=s; i<=e; i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main()
{
  //input
  string s;
  cin >> s;

  //main
  
  // output
  int ans = 0;
  fN(i,4){
    if(s[i]=='+'){ans++;}
    else{ans--;}
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;
long long a[100005]={0,1,2,3,4,5,6,7,8,9};
int main()
{
	int k;
	cin >> k;
	int tot=9;
	int p1=0,p2=1;
	while(tot<=k){
		if(abs(a[p2]%10-a[p1])<=1)
		  a[++tot]=a[p2]*10+a[p1];
		p1++;
		if(p1==10) p2++,p1=0;
	}
	cout<<a[k];
	// system("pause");
	return 0;
}

Measured memory_bytes: 1024
/**
 * @author torith
 * @date 2018-11-01
 */

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const int md = (int) 1e9 + 7;

inline void add(int &a, int b){
    a += b;
    if (a >= md) a -= md;
}

inline void sub(int &a, int b){
    a -= b;
    if (a < 0) a += md;
}

inline int mul(int a, int b){
    return (int) ((ll) a * b % md);
}

inline int power(int a, long long b){
    int res = 1;
    while (b > 0) {
        if (b & 1) {
            res = mul(res, a);
        }
        a = mul(a, 1);
        b >>= a;
    }
    return res;
}

inline int dive(int a, int b){
    return mul(a, power(b, md - 2));
}

std::vector<int> trival_division(int N){
    int tmp = N;
    std::vector<int> rtnvec;
    if (tmp % 2 == 0) {
        while (tmp % 2 == 0){
            rtnvec.push_back(2);
            tmp /= 2;
        }
    }
    for (int i = 3; i < sqrt(tmp) + 2; ++i) {
        if (tmp % i == 0) {
            while (tmp % i == 0){
                rtnvec.push_back(i);
                tmp /= i;
            }
        }
    }
    if(tmp != 1) rtnvec.push_back(tmp);
    return rtnvec;
}



int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;

    int A[1001] = {};
    for (int i = 2; i <= N; ++i) {
        // 素因数分解する
        std::vector<int> a = trival_division(i);
        for (auto & e : a) {
            A[e]++;
        }
    }

    int ans = 1;
    for (int i = 1; i <= N; ++i) {
        ans = mul(ans, A[i]+1);
    }

    cout << ans << "\n";

    return 0;
}


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

using namespace std;

#define ff first
#define ss second
#define pb push_back

using ll = long long;
using ii = pair<int, int>;

const int oo = 1e9;
const int N = 1e3 + 5;

int p[N];
vector<ii> adj[N];
int r[N];

int fid(int x){
	return r[x] = x == r[x] ? x : fid(r[x]);
}

void joi(int a, int b){
	r[fid(a)] = fid(b);
}

bool bfs(int ini){
	queue<int> q;
	q.push(ini);
	p[ini] = -1;
	while(!q.empty()){
		int v = q.front();
		q.pop();
		bool ok = 1;
		for(ii i : adj[v]){
			if(i.ff != ini && p[i.ff] != 0){
				if(fid(v) == fid(i.ff)){
					ok = 0;
					break;
				}
			}
		}
		if(ok){
			for(ii i : adj[v]){
				if(i.ff == ini){
					vector<int> ans;
					while(v != -1){
						ans.pb(v);
						v = p[v];
					}
					printf("%d\n", ans.size());
					for(int j : ans){
						printf("%d\n", j);
					}
					return 1;
				}
				else if(!p[i.ff]){
					if(v != 1){
						joi(v, i.ff);
					}
					p[i.ff] = v;
					q.push(i.ff);
				}
			}
		}
	}
	return false;
}

int main(){
	int n, m;
	scanf("%d %d", &n, &m);
	for(int i = 0; i < m; i++){
		int a, b;
		scanf("%d %d", &a, &b);
		adj[a].pb({b, i});
	}
	for(int i = 1; i <= n; i++){
		memset(p, 0, sizeof(p));
		for(int j = 1; j <= n; j++){
			r[j] = j;
		}
		if(bfs(i)) return 0;
	}
	printf("-1\n");
	return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
  int A,B,C;
  cin >> A >> B >> C;
  if(A==7){
    if(B==5&&C==5){
      cout << "YES" << endl;
    }
    else{
    cout << "NO" << endl;
  }
  }
  else if(B==7){
    if(A==5&&C==5){
      cout << "YES" << endl;
    }
    else{
    cout << "NO" << endl;
  }
  }  
  else if(C==7){
    if(A==5&&B==5){
      cout << "YES" << endl;
    }
    else{
    cout << "NO" << endl;
  }
  }    
  else{
    cout << "NO" << endl;
  }
  
  
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <map>
#include <math.h>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <set>
#include <queue>
#include <sstream>
#include <stack>
#include <deque>
#include <memory.h>
#include <cassert>
#include <ctime>
#include <climits>
#include <list>
#include <time.h>
#include <unordered_map>
#include <bitset>
#include <exception>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned long long ull;
#define pb push_back
#define mp make_pair
#define FILE "file"
#define lc v << 1
#define rc (v << 1) + 1
#define inf 1e+9
#define linf ll(1e+18)
#define dinf 1e+14

typedef long long ll;
#define pb push_back
#define mp make_pair


void solve()
{
    int a, b;
    cin >> a >> b;
    string s;
    cin >> s;
    bool yes = true;
    
    for(int i = 0; i < a; i++)
    {
        if(!(s[i] >= '0' && s[i] <= '9'))
        {
            yes = false;
        }
    }
    
    if(s[a] != '-')
    {
        yes = false;
    }
    
    for(int i = a + 1; i < a + b + 1; i++)
    {
        if(!(s[i] >= '0' && s[i] <= '9'))
        {
            yes = false;
        }
    }
    
    
    if(yes)
    {
        cout << "Yes";
    }
    else
    {
        cout << "No";
    }
}

int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0), cout.tie(0);
    //freopen(FILE ".in", "r", stdin);freopen(FILE ".out", "w", stdout);
    //freopen("file.in", "r", stdin);freopen("file.out", "w", stdout);
    int t = 1;
    //cin >> t;
    
    while(t--)
    {
        solve();
    }
    
    return 0;
}


Measured memory_bytes: 256
use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

    println!("{}", answer);
}

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let n: usize = iterator.next().unwrap().parse().unwrap();
    let mut ans: usize = 0;
    for i in 1..=n {
        let keta = format!("{}", i).len();
        if keta % 2 == 1 {
            ans += 1;
        }
    }

    return ans.to_string();
}


Measured memory_bytes: 2108
#define DEB
#include<bits/stdc++.h>
#define REP(i,m) for(int i=0;i<(m);++i)
#define REPN(i,m,in) for(int i=(in);i<(m);++i)
#define ALL(t) (t).begin(),(t).end()
#define CLR(a) memset((a),0,sizeof(a))
#define pb push_back
#define mp make_pair
#define fr first
#define sc second

using namespace std;


#ifdef DEB
#define dump(x)  cerr << #x << " = " << (x) << endl
#define prl cerr<<"called:"<< __LINE__<<endl
#define dumpR(x) cerr<<"\x1b[31m"<<#x<<" = " <<(x)<<"\x1b[39m"<<endl
#define dumpY(x) cerr<<"\x1b[33m"<<#x<<" = " <<(x)<<"\x1b[39m"<<endl
#define dumpG(x) cerr<<"\x1b[32m"<<#x<<" = " <<(x)<<"\x1b[39m"<<endl
template<class T> void debug(T a,T b){ for(;a!=b;++a) cerr<<*a<<' ';cerr<<endl;}
#else
#define dump(x) ;
#define dumpR(x) ;
#define dumpY(x) ;
#define dumpG(x) ;
#define prl ;
template<class T> void debug(T a,T b){ ;}
#endif

template<class T> void chmin(T& a,const T& b) { if(a>b) a=b; }
template<class T> void chmax(T& a,const T& b) { if(a<b) a=b; }

typedef long long int lint;
typedef pair<int,int> pi;

namespace std{
  template<class S,class T>
  ostream &operator <<(ostream& out,const pair<S,T>& a){
    out<<'('<<a.fr<<','<<a.sc<<')';
    return out;
  }
}

const int INF=5e8;

char s[500005];
int q,n;

int jump[27][500005];

int blank[20][500005];
int main(){
  scanf("%s",s);
  n=strlen(s);

  REP(c,26) jump[c][n]=INF;
  jump[26][n]=n;
  for(int i=n-1;i>=0;--i){
    int c2=s[i]-'a';
    REPN(c,27,c2){
      if(s[i]=='a'+c) jump[c][i]=i+1;
      else{
        if(c==0 || jump[c-1][i]==INF) jump[c][i]=INF;
        else jump[c][i]=jump[c-1][jump[c-1][i]];
      }
    }
    REP(c,c2){
      if(jump[26][i]<INF) jump[c][i]=jump[c][jump[26][i]];
      else jump[c][i]=INF;
    }
  }
  REP(i,n) blank[0][i]=jump[26][i];
  REP(i,20) blank[i][n]=n;
  REP(i,19) REP(j,n){
    if(blank[i][j]<INF) blank[i+1][j]=blank[i][blank[i][j]];
    else blank[i+1][j]=INF;
  }

  cin>>q;
  while(q--){
    int l,r;scanf("%d%d",&l,&r);--l;
    for(int i=19;i>=0;--i) if(blank[i][l]<=r){
      l=blank[i][l];
    }
    if(l==r) puts("Yes");
    else puts("No");
  }
  return 0;
}





Measured memory_bytes: 92928
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<functional>
#include<math.h>
using namespace std;
#define N (1000000000+7)
#define M (998244353)
#define INF 1e16
typedef long long ll;
typedef pair<ll,ll > P;
typedef pair<P,ll>Q;

int main(void){
    int n;
    cin>>n;
    vector<ll>a(n),b(n);
    ll sa = 0,sb = 0;
    for(int i=0;i<n;i++)cin>>a[i],sa+=a[i];
    for(int i=0;i<n;i++)cin>>b[i],sb+=b[i];
    ll s = sb - sa;
    ll pl = 0;
    ll mi = 0;
    for(int i=0;i<n;i++){
        if(a[i]-b[i]>0)pl += a[i]-b[i];
        else{
            if(a[i]-b[i]<0){
                mi += (b[i]-a[i])/2;
                if((b[i]-a[i])%2==1)mi++;
            }
        }
    }
    if(pl<=s && mi<=s)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 384
n, m, c = gets.chomp.split.map(&:to_i)
b = gets.chomp.split.map(&:to_i)
a = []
result = 0
for x in 1..n
  a << gets.chomp.split.map(&:to_i)
end
for y in 0..n - 1
  if b.zip(a[y]).reduce(0) { |s, e| s += e.reduce(:*) } + c > 0
    result = result + 1
  end
end
puts result


Measured memory_bytes: 1788
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;
using ll=long long;
using ld=long double;
//#define int long long
//#define _CRT_SECURE_NO_WARNINGS
#define rep(i, n) for (int i = 0; i < n; i++)
#define _GLIBCXX_DEBUG
const int MOD = 1e9 + 7;
const int INF = 1e18 + 9;
constexpr long double pi = 3.141592653589793238462643383279;
int fact(int i) {
    if (i == 0) return 1;
    return (fact(i - 1)) * i;
}
int gcd(int a, int b) {
    if (b == 0) return a;
    return gcd(b, a % b);
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
int keta(int n) {
    if (n == 0) return 1;
    int count = 0;
    while (n != 0) {
        n /= 10;
        count++;
    }
    return count;
}
int ketasum(int n) {
    int sum = 0;
    while (n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
int a, b;
int main(void) {
    cin >> a >> b;
    (a + b >= 10 ? cout << "error" << endl : cout << a + b << endl);
    return 0;
}

Measured memory_bytes: 3588
#include<iostream>
#include<string>

using namespace std;

int main(){

  string string;
  int sum,i,j=0;
  int sum_list[1000] = {0};

while(1){
  cin >> string;
    if(string == "0"){
      break;
    }
    sum = 0;
    for(i = 0; i < string.size() ;i++){
      sum += string[i] - '0';
    }
      sum_list[j++] = sum;
      string.clear();
  }

  for(i = 0;sum_list[i] != 0;i++){
    cout << sum_list[i] << endl;
  }
  return 0;
}

Measured memory_bytes: 3152
x, k, d = [int(_) for _ in input().split()]

if x <= 0:
    x = -x

if x-k*d >= 0:
    print(x-k*d)
else:
    n = x//d
    x -= n*d
    if (k-n) % 2 == 1:
        x = abs(x-d)
    # print(n)
    print(x)


Measured memory_bytes: 9172
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define EPS (1e-10)
#define equals(a, b) (fabs((a)-(b)) < EPS)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<double> vd;
typedef pair<double,double> PD;
typedef pair<int,P> ed;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
  
int main() {
  int N;
  cin >> N;
  map<char,int> mp;
  rep(i,N) {
    char c;
    cin >> c;
    mp[c]++;
  }
  if(sz(mp)==3) {
    cout << "Three" << endl;
  } else {
    cout << "Four" << endl;
  }
  return 0;
}

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

int main(){
    int N, Y;
    int x = -1, y = -1, z = -1;
    bool ans = false;
    scanf("%d %d\n", &N, &Y);
    for (int i = 0; i <= N; i++){
        for (int j = 0; j <= N - i; j++){
            if ((Y - i * 10000 - j * 5000) / 1000 == N - i - j){
                x = i;
                y = j;
                z = N - i - j;
                ans = true;
                break;
            }
        }
        if (ans) break;
    }
    printf("%d %d %d\n", x, y, z);
    return 0;
}


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

long long rec(int n,long long x){
    if(n==0)return 1;
    long long len=(1LL<<(n+1))-3;
    long long num=(1LL<<n)-1;
    if(x==1)return 0;
    else if(x<=len+1)return rec(n-1,x-1);
    else if(x<=len+2)return num+1;
    else if(x<=(len+1)*2)return num+1+rec(n-1,x-len-2);
    else return num*2+1;
}

int main(){
    int N; long long X;
    cin>>N>>X;
    cout<<rec(N,X)<<endl;
}

Measured memory_bytes: 256
# SPDX-License-Identifier: X11
# 2020-08-30
# Multiplication 2 (200pt)

const MAX = 1000000000000000000

function main()
  N = parse(Int, readline())
  Astr = readline()
  if occursin(r"^0 | 0 | 0$", Astr)
    println("0")
    return
  end
  Avec = split(Astr, " ")

  T = parse(Int, Avec[1])
  for i ∈ 2:N
    A = parse(Int, Avec[i])
    if big(T) * A > MAX
      println("-1")
      return
    else
      T *= A
    end
  end

  println(T)
end

main()


Measured memory_bytes: 182620
#include <iostream>
#include <algorithm>
#include<string>
#include<cmath>
#include<stack>
#include <vector>
#include<queue>
#include <random>
#include <cstdint>
#include <stdexcept>

using namespace std;

int main() {
	int n,count=0;
	cin >> n;
	if (n == 3) {
		cout << 2 << ' ' << 5 << ' ' << 63 << endl;
		return 0;
	}
	for (int i = 0; i < n / 4&&i<3750; i++) {
		if (i < 2500) {
			cout << 2 * (3 * i + 1) << ' ' << 2 * (3 * i + 2) << ' ' << 3 * (4 * i + 1) << ' ' << 3 * (4 * i + 3) << ' ';
		}
		else {
			cout << 15000 + 2 * (6 * (i - 2500) + 1) << ' ' << 15000 + 2 * (6 * (i - 2500) + 2) << ' ' << 15000 + 2 * (6 * (i - 2500) + 4) << ' ' << 15000 + 2 * (6 * (i - 2500) + 5) << ' ';
		}
		count += 4;
	}
	for (int i = 0; i < n - count;i++) {
		cout << 6 * (i + 1) << ' ';
	}
	
	return 0;
}



Measured memory_bytes: 384
#include <iostream>
using namespace std;
int main()
{
    int a,b;
    cin >> a >> b;
    if (a + b == 15)
    {
        cout << "+" << endl;
    }else if( a * b == 15)
    {
        cout << "*" << endl;
    }else{
        cout << "x" << endl;
    }

}

Measured memory_bytes: 888
#include<iostream>
using namespace std;
#define MAX 500000
#define SENTINEL 2000000000

int L[MAX/2+2],R[MAX/2+2];
int cnt;

void merge(int A[],int n,int left,int mid,int right){
  int n1 = mid - left;
  int n2 = right - mid;
  for(int i = 0;i<n1;i++) L[i] = A[left + i];
  for(int i = 0;i<n2;i++) R[i] = A[mid + i];
  L[n1] = R[n2] = SENTINEL;
  int i = 0,j=0;
  for(int k = left;k<right;k++){
    cnt++;
    if(L[i]<=R[j]){
      A[k] = L[i++];
    }else{
      A[k] = R[j++];
    }
  }
}

void mergeSort(int A[],int n,int left,int right){
  if(left+1<right){
    int mid = (left+right)/2;
    mergeSort(A,n,left,mid);
    mergeSort(A,n,mid,right);
    merge(A,n,left,mid,right);
  }
}

int main(){
  int A[MAX],n,i;
  cnt = 0;

  cin>>n;
  for(i = 0;i<n;i++) cin>>A[i];

  mergeSort(A,n,0,n);

  for(i=0;i<n;i++){
    if(i)cout<<" ";
    cout<<A[i];
  }
  cout<<endl;

  cout<<cnt<<endl;

  return 0;
}



Measured memory_bytes: 6980
package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getInts(N int) []int {
	ret := make([]int, N)
	for i := 0; i < N; i++ {
		ret[i] = getInt()
	}
	return ret
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

func abs(a int) int {
	if a >= 0 {
		return a
	}
	return -a
}

func lowerBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] >= x
	})
	return idx
}

func upperBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] > x
	})
	return idx
}

const inf = 1001001001001001

func main() {
	sc.Split(bufio.ScanWords)
	N, M := getInt(), getInt()
	a := make([]int, M)
	c := make([]int, M)
	for i := 0; i < M; i++ {
		a[i] = getInt()
		b := getInt()
		for j := 0; j < b; j++ {
			n := getInt() - 1
			c[i] |= (1 << n)
		}
	}

	dp := make([][]int, M+1)
	for i := 0; i < M+1; i++ {
		dp[i] = make([]int, 1<<N)
		for j := 0; j < 1<<N; j++ {
			dp[i][j] = inf
		}
	}
	dp[0][0] = 0
	for i := 0; i < M; i++ {
		for j := 0; j < 1<<N; j++ {
			if dp[i][j] == -1 {
				continue
			}
			dp[i+1][j] = min(dp[i+1][j], dp[i][j])
			dp[i+1][j|c[i]] = min(dp[i+1][j|c[i]], dp[i][j]+a[i])
		}
	}
	ans := dp[M][1<<N-1]
	if ans == inf {
		out(-1)
		return
	}
	out(ans)
}


Measured memory_bytes: 35232
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i <= (n); i++)
#define zep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,m,n) for(ll i = (m); i <= n; i++){cout << (x[i]) << " ";} cout<<endl;

int main(){
	cin.tie(0); ios::sync_with_stdio(false);
	
	ll k, x;
	cin >> k >> x;
	if(k*500 >= x){
		print("Yes")
	}
	else{
		print("No")
	}
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner((System.in));
		int N = sc.nextInt();
		int[] a = new int[N + 1];
		long b = 0, c = 0;
		
		for (int i = 0; i < N; i++) {
            a[i] = sc.nextInt();
            if (a[i] > c) {
                c = a[i];
            }
		}
    
        for (int i = 0; i < N; i++) {
            int n = a[i];
            b = 0;
            while (n % 2 == 0 && n > 0) {
                n = n / 2;
                b++;
            }
            if (b < c) {
                c = b;
            }
        }
		
		System.out.println(c);

		sc.close();
	}
}


Measured memory_bytes: 23892
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#include <list>

using namespace std;

typedef long long ll;
typedef long double ld;

#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define rep1(i,n) for(int i=1; i<=(int)(n); i++)
#define all(c) c.begin(),c.end()
#define psb push_back
#define ppb pop_back

const int I_INF = 1001001001;
const ll LL_INF = 1001001001001001001;
const ld EPS = 0.001;

int main() {
    ll A, B, V, W, T;
    cin >> A >> V >> B >> W >> T;

    ll ad = 0;
    ll bd = 0;
    string ans = "";
    if (B > A) {
        ad = V*T+A;
        bd = W*T+B;
        ans = ad >= bd ? "YES" : "NO";
    } else if (B < A) {
        ad = A-V*T;
        bd = B-W*T;
        ans = ad <= bd ? "YES" : "NO";
    }

    cout << ans << endl;
}


Measured memory_bytes: 3628
#include <iostream>
#include<math.h>
#include<vector>
#include<string>
#include<algorithm>

using namespace std;

#define vi vector<int>
#define vvi vector<vi>
#define rpt(i,x) for (int i = 0; i < x; i++)
#define fti(i,f,t) for (int i = f; i <= t; i++)
#define fte(i,f,t) for (int i = f; i < t; i++)
#define rptws(i,x,s) for (int i = 0; i < x; i += s)
#define llrpt(i,x) for (long long i = 0; i < x; i++)
#define llfti(i,f,t) for (long long i = f; i <= t; i++)
#define llfte(i,f,t) for (long long i = f; i < t; i++)


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

    int arr[n];
    int cnt = 0;
    rpt(i, n) {
        cin>>arr[i];
        if (arr[i] % 2 != 0 && (i+1) % 2 != 0) cnt++;
    }

    cout<<cnt;
    return 0;
}

Measured memory_bytes: 3624
/*
   ЗАПУСКАЕМ СТЕНУ ИЗ КРЕМА
   💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩
   💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩
   💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩
   💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩
   💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩
   💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩
   💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩
   💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩
   💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩
   💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩
   💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩
   💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩
   💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩
   💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩
   💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩
   💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩
   💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩
   💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩
   💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩
   💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩
   💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩
   💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩
   💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩
*/

#include <cmath>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <map>
#include <list>
#include <time.h>
#include <math.h>
#include <random>
#include <deque>
#include <queue>
#include <cassert>
#include <unordered_map>
#include <iomanip>

using namespace std;

typedef long long ll;

mt19937 rnd(228);

const int inf = 1e9 + 7;

int main()
{
#ifdef ONPC
    freopen("a.in", "r", stdin);
#endif
    vector <int> a(9, inf);
    vector <int> dp(9, inf);
    dp[0] = 0;
    cin >> a[1] >> a[2] >> a[4] >> a[8];
    for (int i = 1; i <= 8; i++)
    {
        for (int j = 0; j + i <= 8; j++)
        {
            dp[j + i] = min(dp[j + i], dp[j] + a[i]);
        }
    }
    ll n;
    cin >> n;
    n *= 4;
    ll ans = 0;
    ans += dp[8] * (n / 8);
    ans += dp[n % 8];
    cout << ans << endl;
}


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



int main() {

  int A, B;
  cin >> A >> B;
  
  if (A>B) {
    cout << A + A - 1 << endl;
  } else if (B>A){
    cout << B + B - 1 << endl;
  } else {
    cout << A + B << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ll mod = 1e9 + 7;
//const ll mod = 998244353;
#define REP(i,n) for(int i=0;i<(int)n;++i)
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
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; }
template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}
string num2bit(ll num, ll len){
    string bit = "";
    REP(i, len){
    bit += char('0'+(num>>i & 1));
    }
    return bit;
}

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

    ll N;
    vector<ll> A(3);
    cin >> N >> A[0] >> A[1] >> A[2];
    map<ll, char> mp;
    mp[0] = 'A';
    mp[1] = 'B';
    mp[2] = 'C';

    ll T = 0;
    REP(i, 3) T += A[i];

    vector<string> S(N);
    REP(i, N) cin >> S[i];
    vector<char> res;

    REP(i, N){

        //cerr << A << endl;
        ll x = -1;
        ll y = -1;
        if(S[i]=="AB"){
            x = 0;
            y = 1;
        }
        if(S[i]=="BC"){
            x = 1;
            y = 2;
        }
        if(S[i]=="AC"){
            x = 2;
            y = 0;
        }

        //dump(x)
        //dump(y)

        if(A[x]==0 and A[y]==0){
            cout << "No" << endl;
            return 0;
        }else{
            if(T==2 and A[x]==1 and A[y]==1 and i != N-1 and S[i] != S[i+1]){
                if(S[i]=="AB" and S[i+1]=="BC") A[0]--, A[1]++, res.push_back('B');
                if(S[i]=="AB" and S[i+1]=="AC") A[0]++, A[1]--, res.push_back('A');
                if(S[i]=="BC" and S[i+1]=="AB") A[1]++, A[2]--, res.push_back('B');
                if(S[i]=="BC" and S[i+1]=="AC") A[1]--, A[2]++, res.push_back('C');
                if(S[i]=="AC" and S[i+1]=="AB") A[0]++, A[2]--, res.push_back('A');
                if(S[i]=="AC" and S[i+1]=="BC") A[0]--, A[2]++, res.push_back('C');
            }else{
                if(A[x]>=A[y]){
                    A[x]--;
                    A[y]++;
                    res.push_back(mp[y]);
                }else{
                    res.push_back(mp[x]);
                    A[x]++;
                    A[y]--;
                }   
            }
        }
    }

    cout << "Yes" << endl;
    REP(i, N){
        cout << res[i] << endl;
    }

    return 0;
}

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

const int N = 100010;
const long long INF = 1e18;
int n, m;
vector<pair<int, int>> G[N];

vector<long long> Dist(N);
vector<bool> seen(N);

bool f = true;

void dfs(int now){
    if(!f) return;
    seen[now] = true;
    for(int i = 0; i < G[now].size(); i++){
        pair<int, int> p = G[now][i];
        int to = p.first;
        int cost = p.second;
    
        if(!seen[to]){
            Dist[to] = cost + Dist[now];
            dfs(to);
        }else{
            if(Dist[to] != cost + Dist[now]) {
                f = false;
                break;
            }
        }
    }
}

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

    cin >> n >> m;
    Dist.resize(n);
    for(int i = 0; i < n; i++){
        Dist[i] = INF;
    }

    for(int i = 0; i < m; i++){
        int l, r;
        long long d;
        cin >> l >> r >> d;
        l--; r--;
        G[l].push_back({r, d});
        G[r].push_back({l, -d});
    }

    for(int i = 0; i < n; i++){
        if(Dist[i] == INF) Dist[i] = 0;
        else continue;
        dfs(i);
    }

    cout << (f ? "Yes" : "No") << endl;

    return 0;
}

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

int main() {
    int n,k;
    cin >> n >> k;
    int m=n;
    for (int i=0; i<m; i++)
    {
        int d;
        cin >> d;
        if (d<k) 
            n--;
    }
    cout << n;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define f(i,a,b) for( ll i = a; i < (ll) b ; i++ ) 
#define af(i,a,b) for( ll i = a; i >= (ll) b ; i--)
#define rep(i,a,b,k) for(ll i = a; i < (ll) b ; i+= k )
#define arep(i,a,b,k) for( ll i = a; i >= (ll) b ; i-= k)
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define sz(a) (ll) a.size()
#define all(a) a.begin(), a.end()
#define sor(a) sort( a.begin(), a.end() )
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL)
#define inter ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nuintptr)
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> ii ;
typedef vector<ll>  vi ;
typedef vector<ii> vii ;
 
const ll MAX= 3e3+6;
const ll inf =1e9;

int main(){
	ll n,m;
	string s,t;
	cin>>s>>t;
	bool go=true;
	f(i,0,s.size()) if(s[i]!=t[i]) go=false;
	if(go) cout<<"Yes\n";
	else cout<<"No\n";
}

Measured memory_bytes: 3596
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.NoSuchElementException;

public class Main {
	static FastScanner sc = new FastScanner();
	static PrintWriter out = new PrintWriter(System.out);

	static void solve() {
		int N = sc.nextInt();
		int[][] num = new int[N][3];
		for (int i = 0; i < N; i++) {
			for (int j = 0; j < 3; j++) {
				num[i][j] = sc.nextInt();
			}
		}
		int[] score = new int[N];
		for (int j = 0; j < 3; j++) {
			for (int i = 0; i < N; i++) {
				boolean frag = true;
				for (int k = 0; k < N; k++) {
					if (i == k) {
						continue;
					} else if (num[i][j] == num[k][j]) {
						frag = false;
						break;
					}
				}
				if (frag) {
					score[i] += num[i][j];
				}
			}
		}

		for (int i = 0; i < N; i++) {
			out.println(score[i]);
		}
		out.flush();
	}

	public static void main(String[] args) {
		solve();
	}

	static int max(int a, int b) {
		return a < b ? b : a;
	}

	static int min(int a, int b) {
		return a < b ? a : b;
	}
}

class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}

	private int readByte() {
		if (hasNextByte()) {
			return buffer[ptr++];
		} else {
			return -1;
		}
	}

	private static boolean isPrintableChar(int c) {
		return '!' <= c && c <= '~';
	}

	private void skipUnprintable() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr])) {
			ptr++;
		}
	}

	public boolean hasNext() {
		skipUnprintable();
		return hasNextByte();
	}

	public int nextInt() {
		if (!hasNext()) {
			throw new NoSuchElementException();
		}
		int n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}
}

Measured memory_bytes: 24276
#include <iostream>
using namespace std;
int main(){

  int n,m,result=0,i;

  cin>>n;
  for(i=0;i<n;i++){
    cin>>m;
    if(m%2==0 && m>2) continue;
    for(int j=2;j*j<=m;j++) if(m%j==0){
	result--;
	break;
      }
    result++;
  }

  cout<<result<<endl;
  return 0;

}



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

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

int main(){

	int x[5];
	rep(i,5)cin>>x[i];
	rep(i,5){
		if(x[i]==0){
			cout<<i+1<<endl;
			break;
		}
	}

	return 0;
}


Measured memory_bytes: 3592
#include <iostream>
#include <vector>
#include <stack>

using namespace std;

vector<int> G[100000];
int color[100000];
int n;

void dfs(int idx, int c)
{
	stack<int> s;
	s.push(idx);
	color[idx] = c;

	while (!s.empty())
	{
		int u = s.top(); s.pop();
		for (int i = 0; i < G[u].size(); ++i)
		{
			int v = G[u][i];
			if (color[v] == -1)
			{
				color[v] = c;
				s.push(v);
			}
		}
	}
}

void AssignColor()
{
	int id = 1;
	for (int i = 0; i < n; ++i) color[i] = -1;
	for (int u = 0; u < n; ++u)
	{
		if (color[u] == -1) dfs(u, id++);
	}
}

int main()
{
	int s, t, m, q;
	cin >> n >> m;

	for (int i = 0; i < m; ++i)
	{
		cin >> s >> t;
		G[s].push_back(t);
		G[t].push_back(s);
	}

	AssignColor();

	cin >> q;
	for (int i = 0; i < q; ++i)
	{
		cin >> s >> t;
		if (color[s] == color[t])
		{
			cout << "yes" << endl;
		}
		else
			cout << "no" << endl;
	}

	return 0;
}

Measured memory_bytes: 8944
#include <stdlib.h>
#include <math.h>
#include <stdio.h>

int main(){
int x,y,z,m;
scanf("%d",&x);
scanf("%d",&y);
if(x<y){
z=x;
x=y;
y=z;
}
while(y>0){
m=x%y;
x=y;
y=m;
}
printf("%d\n",x);
return 0;
}

Measured memory_bytes: 2700
while True:
    try:
        a=0
        b=0
        e1 =list(map(int,input().split()))
        e2 =list(map(int,input().split()))
        for i in range(4):
            if e1[i]==e2[i]:
                a+=1
            for j in range(4):
                if e1[i]==e2[j]:
                   b+=1
        b = b-a
        print(a,b)
    except:
        break


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

using namespace std;

int main()
{
	int n;

	scanf("%d", &n);

	int cnt[200001] = { 0, };

	for (int i = 0; i < n - 1; i++)
	{
		int input;

		scanf("%d", &input);

		cnt[input]++;
	}

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

	return 0;
}

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

int main() {
    string S, T; cin >> S >> T;
    int ls = S.size(), lt = T.size(), min = lt, count = 0;
    for (int i=0 ;i < lt; i++) { //i:Tの添字i文字目から探索
        for (int j = i; j <= ls - lt + i ; j++) { //Sの添字jから添字iの文字の一致を検索
            if (T.at(i) == S.at(j)){ //どっかで一致したらその後をずっと検索
                count = 1;
                for (int k = j + 1; k <= j + lt - 1 - i; k++) {
                    if (S.at(k) == T.at(i + k - j)) count++;
                }
                if (lt - count < min ) min = lt - count; //不一致がminより小さかったら更新
            }
        }
    }
    cout << min << endl;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
using bint = boost::multiprecision::cpp_int;
using ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repSE(i,s,n) for (int i = (s); i < (n); i++)
#define ssort(v) sort(v.begin(), v.end())
#define gsort(v) sort(v.rbegin(), v.rend())
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &vec){ os << "["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const deque<T> &vec){ os << "deq["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &pa){ os << "(" << pa.first << "," << pa.second << ")"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const unordered_map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }
template<typename T> bool chmax(T &m, const T q) { if (m < q) {m = q; return true;} else return false; }
template<typename T> bool chmin(T &m, const T q) { if (q < m) {m = q; return true;} else return false; }

int main()
{
    int N, K;
    cin >> N >> K;
    vector<ll> h(N);
    rep(i,N) cin >> h[i];
    ssort(h);
    ll ans = 0;
    rep(i,N-K) {
        ans += h[i];
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 4788
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.IOException;
import java.util.NoSuchElementException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FasterScanner in = new FasterScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, FasterScanner in, PrintWriter out) {
            int n = in.nextInt();
            if (n == 3 || n == 5 || n == 7) out.println("YES");
            else out.println("NO");
        }

    }

    static class FasterScanner {
        private InputStream in;
        private byte[] buffer;
        private int bufPointer;
        private int bufLength;

        public FasterScanner(InputStream in) {
            this.in = in;
            buffer = new byte[1024];
        }

        private boolean hasNextByte() {
            if (bufPointer < bufLength) return true;
            bufPointer = 0;
            try {
                bufLength = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            return (bufLength > 0);
        }

        private int readByte() {
            if (hasNextByte()) return buffer[bufPointer++];
            return -1;
        }

        private static boolean isPrintableChar(int c) {
            return (c >= 33 && c <= 126);
        }

        public boolean hasNext() {
            while (hasNextByte() && !isPrintableChar(buffer[bufPointer])) bufPointer++;
            return hasNextByte();
        }

        public int nextInt() {
            long nl = nextLong();
            if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
            return (int) nl;
        }

        public long nextLong() {
            if (!hasNext()) throw new NoSuchElementException();
            long n = 0;
            boolean minus = false;
            int b = readByte();
            if (b == '-') {
                minus = true;
                b = readByte();
            }
            if (b < '0' || b > '9') throw new NumberFormatException();

            while (true) {
                if (b >= '0' && b <= '9') {
                    n *= 10;
                    n += b - '0';
                } else if (b == -1 || !isPrintableChar(b)) {
                    return minus ? -n : n;
                } else {
                    throw new NumberFormatException();
                }
                b = readByte();
            }
        }

    }
}



Measured memory_bytes: 22864
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main() {

  vector<int> w,k;

  int temp;


  for(int i=0;i<10;i++) {

    cin >> temp;

    w.push_back(temp);

  }

  for(int i=0;i<10;i++) {

    cin >> temp;

    k.push_back(temp);

  }

  sort(w.begin(),w.end(),greater<int>());

  sort(k.begin(),k.end(),greater<int>());

  cout << w[0]+w[1]+w[2] << " " << k[0]+k[1]+k[2] << endl;

  return 0;

}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned ll
#define uint unsigned
#define pii pair<int,int>
#define pll pair<ll,ll>
#define PB push_back
#define fi first
#define se second
#define For(i,j,k) for (int i=(int)(j);i<=(int)(k);i++)
#define Rep(i,j,k) for (int i=(int)(j);i>=(int)(k);i--)
#define CLR(a,v) memset(a,v,sizeof(a));
#define CPY(a,b) memcpy(a,b,sizeof(a));
using namespace std;
const int N=200005;
int n,vis[N];
pii a[N*2];
ll ans1,ans2,ans3;
int main(){
	scanf("%d",&n);
	For(i,1,n){
		int x,y;
		scanf("%d%d",&x,&y);
		a[i]=pii(x,i);
		a[i+n]=pii(y,-i);
		ans1+=x; ans2+=y;
	}
	sort(a+1,a+2*n+1);
	bool ok=0;
	For(i,1,n){
		ans3+=a[i].fi;
		if (vis[abs(a[i].se)]) ok=1;
		vis[abs(a[i].se)]=1;
	}
	if (!ok){
		int dif=1<<30;
		For(i,n+1,n*2)
			dif=min(dif,a[i].fi-a[a[i].se+a[n].se?n:n-1].fi);
		ans3+=dif;
	}
	printf("%lld",min(min(ans1,ans2),ans3));
}

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

int main() {
  int n, ans = 0;
  vector<int> d;

  scanf("%d", &n);

  for (int k = 0; k < n; k++) {
    int t;
    scanf("%d", &t);
    if (find(d.begin(), d.end(), t) == d.end()) {
      d.push_back(t);
      ans++;
    }
  }

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

Measured memory_bytes: 256