akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <vector>
#include <stack>
#include <iostream>
#include <string>
#include <tuple>
#include <random>
#include <map>
#include <queue>
#include <set>
#include <complex>
#include <algorithm>
#include <cassert>
#include <iterator>
#include <numeric>
#include <cmath>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;

const double eps = 1e-8;

const ll INF = 1e15;

typedef ll Weight;
struct Edge {
	int src, dst;
	Weight weight;
	Edge(int src, int dst, Weight weight) :
		src(src), dst(dst), weight(weight) { }
};
bool operator < (const Edge &e, const Edge &f) {
	return e.weight != f.weight ? e.weight > f.weight : // !!INVERSE!!
	e.src != f.src ? e.src < f.src : e.dst < f.dst;
}
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

int main(){
	ll N, M;
	string s;
	cin >> N >> M >> s;
	vector<ll> alive(N);
	vector<ll> blive(N);
	Graph g(N);
	for (int i = 0;i < M;i++) {
		ll a, b;
		cin >> a >> b;
		a--;
		b--;
		g[a].push_back(Edge(a, b, 1));
		if (a != b)
			g[b].push_back(Edge(b, a, 1));
	}
	queue<ll> dead;
	vector<ll> isdead(N);
	ll num = N;
	for (int i = 0;i < N;i++) {
		for (int j = 0;j < g[i].size();j++) {
			ll to = g[i][j].dst;
			if (s[to] == 'A')
				alive[i]++;
			else
				blive[i]++;
		}
		if (alive[i] == 0 || blive[i] == 0) {
			dead.push(i);
			isdead[i] = true;
			num--;
		}
	}
	while (!dead.empty()) {
		ll now = dead.front();
		dead.pop();
		for (int i = 0;i < g[now].size();i++) {
			ll to = g[now][i].dst;
			if (!isdead[to]) {
				if (s[now] == 'A') {
					alive[to]--;
				}
				else {
					blive[to]--;
				}
				if (alive[to] == 0 || blive[to] == 0) {
					dead.push(to);
					isdead[to] = true;
					num--;
				}
			}
		}
	}
	if (num > 0)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
	return 0;
}


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

int main() {
    int n; cin >> n;
    vector<int> t(n); rep(i, n) cin >> t.at(i);
    int m; cin >> m;
    vector<int> p(m);
    vector<int> x(m);

    rep(i, m) {
        cin >> p.at(i) >> x.at(i);
    }

    rep(i, m) {
        int ans = 0;
        rep(j, n) {
            if (p.at(i) == j + 1) {
                ans += x.at(i);
            }
            else {
                ans += t.at(j);
            }
        }
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 256
N, Y = map(int, input().split())

max_10, _ = divmod(Y, 10000)
max_5, _ = divmod(Y, 5000)
max_1, _ = divmod(Y, 1000)

for i in range(min(max_10 + 1, N + 1)):
    for j in range(min(max_5 + 1, N + 1)):
        k = N - i - j
        if 10000 * i + 5000 * j + 1000 * k == Y and k >= 0 and k <= N:
            print(i, j, k)
            exit()
print(-1, -1, -1)

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

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

int a[200005], n;
ll k;
basic_string<int> e[200005];
int p[60][200005];
ll q[60][200005];

int inv[200005], b[200005], sol;

void dodaj(int x) {
	// cerr << "dodajem " << x << '\n';
	if (inv[x] == -1) {
		inv[x] = sol;
		b[sol++] = x;
	} else {
		while (inv[x] != -1) {
			inv[b[--sol]] = -1;			
		}
	}
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	cerr.tie(nullptr);

	memset(inv, 255, sizeof(inv));

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

	for (int i=1; i<=200000; i++) {
		if (e[i].size()) {
			for (int j=0; j<(int)e[i].size()-1; j++) {
				int x = (e[i][j+1] + 1) % n;
				int y = (e[i][j+1] + 1) / n;

				p[0][e[i][j]] = x;
				q[0][e[i][j]] = y;
			}

			{
				int x = (n + e[i][0] + 1) % n;
				int y = (n + e[i][0] + 1) / n;
				p[0][e[i].back()] = x;
				q[0][e[i].back()] = y;
			}
		}
	}

	for (int i=1; i<60; i++) {
		for (int j=0; j<n; j++) {
			int z = p[i-1][j];
			q[i][j] = q[i-1][j] + q[i-1][z];
			p[i][j] = p[i-1][z];
		}
	}

	ll mv = 0;
	int pos = 0;
	for (int i=59; i>=0; i--) {
		if (mv + q[i][pos] < k) {
			// cerr << "jmp " << i << '\n';
			mv += q[i][pos];
			pos = p[i][pos];
		}
	}

	// cerr << "stani " << mv << ' ' << pos << '\n';

	while (mv < k) {
		dodaj(a[pos]);
		if (++pos == n) {
			pos = 0;
			mv++;
		}
	}

	for (int i=0; i<sol; i++)
		cout << b[i] << " \n"[i == sol-1];
}

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


int main()
{
    ll n; cin>>n;
    ll x=0,y=0;

    for(int i=2;i<=sqrt(n);i++)
    {
        if(n%i==0)
        {
            x=i;
            y=n/i;
            //break;
        }
    }

    ll ans=(x-1)+(y-1);
    if(ans < 0) ans=n-1;
    cout<<ans;
}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {
    public static void main(String... args) {
        Scanner sc = new Scanner(System.in);
        List<Integer> l = new ArrayList<>();
        l.add(sc.nextInt());
        l.add(sc.nextInt());
        l.add(sc.nextInt());
        Collections.sort(l);
        System.out.print(l.get(0) + l.get(1));
    }
}


Measured memory_bytes: 21844
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {
            var s = cin.ReadInt;
          if(s == 000){
            Console.WriteLine(0);
          }else if(s == 001){
            Console.WriteLine(1);
          }else if(s == 010){
            Console.WriteLine(1);
          }else if(s == 100){
            Console.WriteLine(1);
          }else if(s == 011){
            Console.WriteLine(2);
          }else if(s == 101){
            Console.WriteLine(2);
          }else if(s == 110){
            Console.WriteLine(2);
          }else if(s == 111){
            Console.WriteLine(3);
          }
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); }}
        public int ReadInt { get { return int.Parse(Read); }}
        public long ReadLong { get { return long.Parse(Read); }}
        public double ReadDouble { get { return double.Parse(Read); }}
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret;}
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret;}
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret;}
    }
}

Measured memory_bytes: 11220
#include "stdio.h"
#include "string"

using namespace std;

int N, A[200];

int main() {
	scanf("%d",&N);

	int d;
	int e = 0;
	int min = 5000;

	for (int i = 0; i < N; i++) {
		scanf("%d", &A[i]);
		d = A[i];
		while(d % 2 == 0) {
			d /= 2;
			e++;
		}
		if (min > e) min = e;
		e = 0;
	}

	printf("%d\n", min);

	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define ll long long
#define ld long double 
#define For(i, a, n) for(long long i = a; (a < n) ? (i < n) : (i > n); (a < n) ? (i++) : (i--))
#define ee 1000000007
#define pb push_back
#define fio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
 
using namespace std;

void solve() {
    ll x, k, d;
	cin >> x >> k >> d;
	x = abs(x);
	if(x / d < 1){
		d -= x;
		if(k % 2 == 0) cout << x;
		else cout << d;
		return;
	}
	if(x / d < k){
		if((x / d + k) % 2 == 0) cout << x % d;
		else cout << d - x % d;
		return;
	}
	cout << abs(x - k * d);
}

int main() {
    fio;
    ll t = 1;
    //cin >> t;
    while(t--) {
        solve();
    }
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  int q; cin >> q;
  while (q--) {
    lint a, b, c, d; cin >> a >> b >> c >> d, --c;
    lint k = (a + b) / (min(a, b) + 1);
    if (k == 1) {
      assert(abs(b - a) <= 1);
      if (a >= b) {
        for (int i = c; i < d; ++i) {
          cout << (i & 1 ? 'B' : 'A');
        }
      } else {
        for (int i = c; i < d; ++i) {
          cout << (i & 1 ? 'A' : 'B');
        }
      }
      cout << '\n';
      continue;
    }
    lint n = a + b;
    lint mid = ((k + 1) * a - n) / (k - 1);
    for (lint m = mid - 10; m <= mid + 10; ++m) if (0 <= m and m <= n) {
      if (m - m / (k + 1) + (n - m) / (k + 1) != a) continue;
      lint la = m % (k + 1);
      lint lb = m and !(m % (k + 1));
      lint ra = (n - m) and !((n - m) % (k + 1));
      lint rb = (n - m) % (k + 1);
      if (la + ra <= k and lb + rb <= k) {
        for (int i = c; i < min(d, m); ++i) {
          cout << (i % (k + 1) != k ? 'A' : 'B');
        }
        for (int i = max(c, m); i < d; ++i) {
          cout << ((n - 1 - i) % (k + 1) != k ? 'B' : 'A');
        }
        cout << '\n';
        break;
      }
    }
  }
}

Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <numeric>
using namespace std;
typedef long long int ll;

#define EPS (1e-7)
#define INF 1e18
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define PI (acos(-1))

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


int main() {

    int A, B;
    cin >> A >> B;
    int ans = 1 <= A && A <= 9 && 1 <= B && B <= 9 ? A * B : -1;

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
//A - Meal Delivery


#include <iostream>
using namespace std;

int main(){
  int x,a,b;
  int aran = 0,bran = 0;
  cin >> x >> a >> b ;
  if (a - x > 0){
    aran = a - x;
  }else{
    aran = x - a;
  }
  if (b - x > 0){
    bran = b - x;
  }else{
    bran = x - b;
  }

  if (bran > aran){
    cout << "A"<< endl;
  }else{
    cout <<"B"<< endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<n;i++)
#define Rep(i,a,b) for(ll i=a;i<b;i++)
#define pb emplace_back
#define allv v.begin(),v.end()
using namespace std;
typedef long long int ll;
typedef unsigned long long ull;
typedef vector<ll> vll;
#define FASTio ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define deb(x) cout<<(#x)<<" "<<x<<endl
ll mod=1e9+7;
template<typename t>
ll Max(ll a,ll b)
{
    return (a>b)?a:b;
    
}
ll Min(ll a,ll b)
{
    return (a>b)?b:a;
}
ll Power(ll a,ll b)
{
    ll p=1;
    a=a;
    b=b;
    while(b)
    {
        if(b&1)
        {
            p=((p)*(a));
        }
        a=((a)*(a));
        b=(b/2);
    }
    return p;
}
ll power(ll a,ll b)
{
    if(b==0)
    return 1;
    ll p=power(a,b/2)%mod;
    p=(p*p)%mod;
    if(b&1)
    p=(p*a)%mod;
    return p;
}
ll gcd(ll a,ll b)
{
    if(a==0)
    return b;
    return gcd(b%a,a);
}
/*void dfs(ll i)
{
    visited[i]=true;
   // provinces.pb(i);
    for(auto it:adj[i])
    {
        if(!visited[it] && choices[it])
        dfs(it);
    }
}*/
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    ll ans1=a*c;
    ans1=max(ans1,a*d);
    ans1=max(ans1,b*c);
    ans1=max(ans1,b*d);
    cout<<ans1<<endl;
    
    return 0;
}


Measured memory_bytes: 3648
//

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// const int INF = 2147483647;
// const ll INF = 9223372036854775807;
// const ll MOD = 1e9 + 7;

int A[200001];
int B[200001];

int main() {
	int N, K;
	cin >> N >> K;

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

	for (int i=0; i<K; i++) {
		for (int j=0; j<N; j++) {
			int l = max(0, j - A[j]);
			int r = min(N, j + A[j] + 1);
			B[l]++;
			B[r]--;
		}

		for (int k=1; k<N; k++) {
			B[k] = B[k-1] + B[k];
		}

		bool all_max = true;
		bool all_equal = true;
		for (int j=0; j<N; j++) {
			if (A[j] != B[j]) all_equal = false;
			A[j] = B[j];
			B[j] = 0;
			if (A[j] != N) all_max = false;
		}

		if (all_max) break;
	}

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

	return 0;
}

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

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

int main() {
	int N, W;
	cin >> N >> W;
	vector<int> v(N), w(N);
	rep(i, N) cin >> v[i] >> w[i];
	vector<int> dp(W + 1);
	for (int i = 0; i <= W; i++) {
		for (int j = 0; j < N; j++) {
			if (i >= w[j]) chmax(dp[i], dp[i - w[j]] + v[j]);
		}
	}
	cout << dp[W] << endl;
	return 0;
}


Measured memory_bytes: 3140
#include <iostream>

#define int long long

using namespace std;

const int N = 2e5 + 10;

int32_t main()
{
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);    
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    while (1)
    {
        c -= b;
        if (c <= 0) 
        {
            cout << "Yes";
            return 0;
        }
        a -= d;
        if (a <= 0)
        {
            cout << "No";
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 3648
#include <stdio.h>
#include <string.h>

char isSosuu[100001];
char is2017like[100001];//1-base
long long count2017like[100001];
//Eratostens

int main(){
        isSosuu[1] = 0;
        for(int n = 2; n <= 100000; n++) isSosuu[n] = 1;

        for(int n = 2; n <= 317 ; n++){
                for(int m = 2; n * m <= 100000; m++){
                        isSosuu[n*m] = 0;
                }
        }
        memset(is2017like,0,sizeof(is2017like));
        for(int n = 1; n <= 100000; n++){
                if( n % 2 == 1 && isSosuu[n] && isSosuu[(n+1)/2]){
                        is2017like[n] = 1;
                }
        }
        long long count = 0;
        for(long long i = 1; i <= 100000 ; i++){
                if(is2017like[i]) count++;
                count2017like[i] = count;

        }
        count2017like[0] = 0;

        long Q;
        scanf("%ld",&Q);
        long l, r;
        while(Q--){
                scanf("%ld %ld", &l, &r);
                printf("%lld\n",count2017like[r]-count2017like[l-1]);
        }
}

Measured memory_bytes: 1536
//BISMILLAHIR RAHMANIR RAHIM
//ALLAH HU AKABR
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    cin>>s;
    bool flag=false;
    for(int i=0;i<s.size();i++)
    {
        if(s[i]=='7')
        {
            flag=true;
            break;
        }
    }
    if(flag==true)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;

}


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

class unionfind{
public:
    vector<int> v;
    vector<int> rank;

    unionfind(int n){
        v = vector<int>(n);
        rank = vector<int>(n, 0);
        for(int i=0; i<n; i++) v[i]=i;
    }
    int find(int x){
        if(v[x] != x){
            v[x] = find(v[x]);
        }
        return v[x];
    }
    void marge(int a, int b){
        a = find(a);
        b = find(b);
        if(rank[a] < rank[b]){
            v[a] = b;
        }else{
            v[b] = a;
            if(rank[a] == rank[b]){
                rank[a]++;
            }
        }
    }
};

struct edge{
    int s,t;
    int cost;
    edge(int s, int t, int c):s(s), t(t), cost(c){}
    edge(){}
    bool operator < (const edge &a) const{
        return cost < a.cost;
    }
};

int main(){
    while(1){
        int n,m;
        cin >> n >> m;
        if(n==0) break;

        vector<edge> ve(m);
        for(int i=0; i<m; i++){
            int s,t,c;
            cin >> s >> t >> c;
            s--; t--;
            ve[i] = edge(s,t,c);
        }
        sort(ve.begin(), ve.end());

        unionfind uf(n);
        int count = 0;
        for(int i=0; i<m; i++){
            if(uf.find(ve[i].s) != uf.find(ve[i].t)){
                uf.marge(ve[i].s, ve[i].t);
                count++;
                if(count == n/2){
                    cout << ve[i].cost << endl;
                    break;
                }
            }
        }
    }
    return 0;
}


Measured memory_bytes: 3172
x=int(input())

if x<600:
  print(8)
elif x<800:
  print(7)
elif x<1000:print(6)
elif x<1200:print(5)
elif x<1400:print(4)
elif x<1600:print(3)
elif x<1800:print(2)
else:print(1)
  


Measured memory_bytes: 61936
#include <cstdio>
#include <cstring>
const int Maxn=1000;
const int Maxm=10000;
const int Inf=0x3f3f3f3f;
int a[Maxn+5],b[Maxn+5];
int n,h;
int f[Maxm<<1|5];
int mn(int a,int b){
	return a<b?a:b;
}
int main(){
	scanf("%d%d",&h,&n);
	for(int i=1;i<=n;i++){
		scanf("%d%d",&a[i],&b[i]);
	}
	memset(f,0x3f,sizeof f);
	f[0]=0;
	for(int i=1;i<=n;i++){
		for(int j=0;j<=h+Maxm-a[i];j++){
			f[j+a[i]]=mn(f[j+a[i]],f[j]+b[i]);
		}
	}
	int ans=Inf;
	for(int i=h;i<=h+Maxm;i++){
		ans=mn(ans,f[i]);
	}
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <string>

//std::ifstream f("input.in");
//std::ofstream g("output.out");

long long a,b;

long long gcd(long long a,long long b){
    if(b == 0)
        return a;
    return gcd(b,a % b);
}

int main(){
    
    std::cin >> a >> b;
    
    std::cout << (a * b) / gcd(a,b);
    
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <vector>
#include <queue>

#define rep(i, a, b) for ( int i = (a); i < (b); i++ )
#define per(i, a, b) for ( int i = (b)-1; i >= (a); i--)
#define pb push_back
#define bg begin()
#define en end()

using namespace std;

typedef long long ll;

ll ans;
int N;
int A[100005], B[100005], C[100005];
ll S[100005];

int main(void) {
    scanf("%d", &N);
    rep(i, 0, N) scanf("%d", &A[i]);
    rep(i, 0, N) scanf("%d", &B[i]);
    rep(i, 0, N) scanf("%d", &C[i]);

    sort(A, A+N);
    sort(C, C+N);

    rep(i, 0, N) {
      int lower = lower_bound(A, A+N, B[i]) - A;
      int upper = (C+N) - upper_bound(C, C+N, B[i]);
      ans += (ll)lower * (ll)upper;
    }


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


Measured memory_bytes: 1408
# coding: utf-8
#67
import itertools
K=[]
A=int()
while True:
    n,x = map(int,input().split())

    if n==0 and x==0:
        break

    #for i in range(n):
    K=[int(i) for i in range(1,n+1)]
    
    c=list(itertools.combinations(K,3))
    #print(c)
    for j in range(len(c)):
        a = c[j][0]+c[j][1]+c[j][2]
        
        if a==x:
            #print(c[j][0])
            A += 1
    print(A)
    A=0
    
            



Measured memory_bytes: 31436
#include<stdio.h>
 
int S[100000], n;
 
int binarySearch(int key){
  int left = 0;
  int right = n;
  int mid;
 
  while(left < right){
    mid = (left + right) / 2;
    if(key == S[mid]) return 1;
    if(key > S[mid]) left = mid+1;
    else if(key < S[mid]) right = mid;
  }
  return 0;
}
 
int main()
{
  int q, T[50000], C, i;
  C = 0;
  scanf("%d", &n);
  for(i = 0;i < n;i++) scanf("%d", &S[i]);
  scanf("%d", &q);
  for(i = 0;i < q;i++){
    scanf("%d", &T[i]);
    if(binarySearch(T[i])) C++;
  }
  printf("%d\n", C);
  return 0;
}

Measured memory_bytes: 2308
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N,K;
  cin >> N >> K;
  vector<int>list(N);
  for(int i=0; i<N; i++){
    cin >> list[i];   
  }
  int count = 0;
  for(int i=0; i<N; i++){
    if(list[i]>=K){
      count++;
    }
  }
  cout << count << endl;
  

}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n); i >= 0; i--)
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define ALL(obj) begin(obj), end(obj)
using namespace std;
using llong = long long;

const int INF = 100100100;
const int MOD = 1e9 + 7;

llong rec_plus(string str, int start, int end, llong sum) {

    if (str.size() > end) {
        llong sub;
        sub = stol(str.substr(start, end - start + 1));
        return rec_plus(str, end + 1, end + 1, sum + sub) +
               rec_plus(str, start, end + 1, sum);
    } else {
        if (str.size() == start) {
            return sum;
        }
        return 0;
    }
}

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

    string S;
    cin >> S;

    cout << rec_plus(S, 0, 0, 0) << "\n";

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <utility>
#include <tuple>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cmath>
#define rep(i, n) for(int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
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; }

typedef pair<int, int> P;

int main(){
  int H, W, N;
  cin >> H >> W >> N;
  vector<int> a(N);
  rep(i, N) cin >> a[i];
  vector<vector<int>> grid(H, vector<int>(W));
  int p = 0;
  rep(i, H) {
    if(i%2) {
      for(int j=W-1; j>=0; j--) {
        if(!a[p])
          p++;
        grid[i][j] = p+1;
        a[p]--;
      }
    } else {
      rep(j, W) {
        if(!a[p])
          p++;
        grid[i][j] = p+1;
        a[p]--;
      }
    }
  }
  rep(i, H) rep(j, W)
    printf("%d%c", grid[i][j], j<W-1?' ':'\n');
  return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define loop(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  loop(i,0,n)
#define all(c) c.begin(),c.end()
#define rall(c) c.rbegin(),c.rend()
#define vi vector<int>
#define vl vector<ll>
#define pll pair<ll,ll>
#define vpll vector<pll>

int main(){
    int n;
    cin>>n;
    string a,b;
    string c="";
    cin>>a>>b;
    rep(i,n){
      c+=a.substr(i,1)+b.substr(i,1);
    }
    cout<<c<<endl;
}

Measured memory_bytes: 256
import java.util.*;
import java.lang.*;

public class Main
{
	public static void main(String args[])
	{
		Scanner sc=new Scanner(System.in);
		int l=sc.nextInt();
		int r=sc.nextInt();
		int d=sc.nextInt();
		int a=0;
		for(int i=l;i<=r;i++)
		{
			if(i%d==0)
				a++;
		}
		System.out.println(a);
	}
}

Measured memory_bytes: 35636
#include <stdio.h>

int main() {
  int n;
  scanf("%d", &n);
  long long int arr[n], maks = 1e18, product = 1, flag = 0, zero = 0;
  
  for (int i = 0; i < n; i++) {
    scanf("%lld", &arr[i]);
    flag = (arr[i] > maks) ? 1 : flag;
    product *= arr[i];
    (arr[i]) ? maks /= arr[i] : zero = 1;
  }

  (zero) ? puts("0") : ((flag) ? puts("-1") : printf("%lld\n", product));
  return 0;
}


Measured memory_bytes: 4000
program main
    use iso_fortran_env
    implicit none
    integer(int64) :: n, i
    integer(int64), allocatable :: a(:)
    integer(int64) :: s, x, d, ans
    logical :: bx, bd

    read *, n
    allocate(a(n))
    read *, a(1:n)

    x = 0
    d = 0
    s = a(1) + a(2)
    ans = 0

    if ( n>2 ) then
        do i = 3, n
            x = ieor(x, a(i))
        enddo
    endif

    if ( trailz(s-x) >= 1 ) then
        d = (s - x) / 2
    else
        print *, "-1"
        stop
    endif

    if ( iand(x, d) /= 0) then
        print *, "-1"
        stop
    endif

    do i = 0, 63
        bd = btest(d, i)
        if (bd) then
            ans = ibset(ans, i)
        endif
    enddo

    do i = 63, 0, -1
        bx = btest(x, i)
        if (bx) then
            if ( ibset(ans, i) <= a(1) ) then
                ans = ibset(ans, i)
            endif
        endif
    enddo

    if ((ans == 0) .or. (ans > a(1))) then
        print *, "-1"
        stop
    endif

    print *, a(1) - ans
 
end program main


Measured memory_bytes: 2832
def N():
    return int(input())
def L():
    return list(map(int,input().split()))
def NL(n):
    return [list(map(int,input().split())) for i in range(n)]
mod = pow(10,9)+7
#import numpy

n = N()
d = NL(n)
cnt = 0
p = 1
ma = 0
for i in range(n):

    if d[i][0] == d[i][1] :
        if p == 1:
            cnt += 1
        else:
            cnt += 1
            p == 1
    else:
        cnt = 0
        p = 0
    ma = max(ma,cnt)
#print(ma)
if ma >= 3:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 62560
# D
from math import sqrt
def sieve(n:int)->list:
    """エラトステネスの篩"""
    if n<2:  return [False]*(n+1)
    is_prime = [True]*(n+1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(sqrt(n))+1):
        if is_prime[i]:
            for j in range(i*i, n+1, i):
                is_prime[j] = False
    
    return is_prime


N = int(1e5)
is_prime = sieve(N)
# like-2017
cnt = [0]*(N+1)
for i in range(1, N+1):
    cnt[i] += cnt[i-1]
    if is_prime[i] and is_prime[(i+1)//2]:
        cnt[i] += 1
    
import sys
Q = sys.stdin.readline()
for l,r in (map(int, line.split()) for line in sys.stdin.readlines()):
    print(cnt[r] - cnt[l-1])


Measured memory_bytes: 14792
s = input()
n = len(s)
head_n = int((n-1)/2)
head_s = s[:head_n]
# print(head_s)
foot_n = int((n + 3) / 2 -1)
foot_s = s[foot_n:]
# print(foot_s)

if s == s[::-1] and head_s == head_s[::-1] and foot_s == foot_s[::-1]:
  print("Yes")
else:
  print("No")

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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
#define debug(x) cerr << #x << ": " << x << endl
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

using P = pair<int, PII>;

/* -----  2017/09/20  Problem: ACPC2017_day3_e  / Link:   ----- */
/* ------??????------



-----?????????????????§----- */
/* -----?§£??¬???-----



----?§£??¬???????????§---- */

LL N;
struct BIT2D {
	int _H, _W;
	VVI data;
	BIT2D(int h, int w) {
		_H = h; _W = w;
		data = VVI(_W + 1, VI(_H + 1, 0));
	}
	void add(int a, int b, int val) {
		for (int x = a; x <= _W; x += x&-x) {
			for (int y = b; y <= _H; y += y&-y) {
				data[x][y] += val;
			}
		}
	}
	int _sum(int a, int b) {
		int ret = 0;
		for (int x = a; x > 0; x -= x & -x) {
			for (int y = b; y > 0; y -= y & -y) {
				ret += data[x][y];
			}
		}
		return ret;
	}
	int sum(int lx, int ly, int rx, int ry) {
		return _sum(rx, ry) - _sum(lx - 1, ry) - _sum(rx, ly - 1) + _sum(lx - 1, ly - 1);
	}
};

LL ans = 0LL;
int H, W, T, Q;

int main() {

	scanf("%d%d%d%d", &H, &W, &T, &Q);
	BIT2D yet(W,H);// 1index
	BIT2D done(W,H );// 1index


	queue<P> que;
	FOR(i, 0, Q) {
		int t, c, h1, w1, h2, w2;
		scanf("%d%d%d%d", &t, &c, &h1, &w1);

		while (!que.empty()) {
			P p = que.front();
			if (p.first + T <= t) {
				que.pop();
				int Y = p.second.first, X = p.second.second;
				yet.add(Y, X, -1);
				done.add(Y, X, 1);
			}
			else break;

		}

		if (c != 2) {
			if (c == 0) {
				if (yet.sum(h1, w1, h1, w1) == 0 && done.sum(h1, w1, h1, w1) == 0) {
					yet.add(h1, w1, 1);
					que.push({ t,PII(h1,w1) });
				}
			}
			else {//c ==1
				if (done.sum(h1, w1, h1, w1) == 1) {
					done.add(h1, w1, -1);
				}
			}
		}
		else {
			scanf("%d%d", &h2, &w2);
			printf("%d %d\n", done.sum(h1, w1, h2, w2), yet.sum(h1, w1, h2, w2));
		}

	}



	return 0;
}

Measured memory_bytes: 35476
#include <cstdio>
#include <cstring>
#include <iostream>
using namespace std;
int n,m,k;
int now;
int c[10010],v[110][110];
int main()
{
	scanf("%d%d%d",&n,&m,&k);
	int i,j;
	for(i=1;i<=k;i++)	scanf("%d",&c[i]);
	for(now=i=1;i<=n;i++)
	{
		if(i&1)	for(j=1;j<=m;j++)
		{
			v[i][j]=now,c[now]--;
			if(!c[now])	now++;
		}
		else	for(j=m;j>=1;j--)
		{
			v[i][j]=now,c[now]--;
			if(!c[now])	now++;
		}
	}
	for(i=1;i<=n;i++)
	{
		for(j=1;j<=m;j++)
		{
			printf("%d%c",v[i][j],j==m?'\n':' ');
		}
	}
	return 0;
}


Measured memory_bytes: 384
#include<stdio.h>
#include<string.h>
int main()
{ 
      int i,j,m,t,b,cd,o;
     char s[100];
     char a[100];
    scanf("%s",&s);
     j=0;
     m=0;
     for(i=0;i<strlen(s);i++)
     {
     	if(s[i]=='C')
     	j++;
     	if(s[i]=='F')
     	m++;	
     }
     cd=0;
     t=0;
     b=0;
	 for(i=0;i<strlen(s);i++)
	 {
	 	if(s[i]=='C')
	 	{
	 	
	 	t=i;
	 	for(o=i+1;o<strlen(s);o++)
	 	{
	 	
	    if(s[o]=='F')
	 	 b=o;
	    }
	 	if(t<b)
	 	break;
}
	 
	 } 
	if(t<b)
	printf("Yes");
	else
	printf("No");
	
	
	
	
	
}

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

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

	int price = 700 + (100 * count(S.begin(), S.end(), 'o'));
	cout << price << endl;

	return 0;
}

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



int main(void){
	double a,b,s;
	double S,L,h,c;

	scanf("%lf %lf %lf",&a,&b,&s);

	h = (b*sin((s*3.1415926535)/180.0));

	S = (0.5*a*h);

	c=sqrt((a*a)+(b*b)-(2*a*b*cos((s*3.1415926535)/180.0)));
	L = (a+b+c);

	printf("%f\n%f\n%f\n",S,L,h);
}


Measured memory_bytes: 2096
object Main {
  def main(args: Array[String]) {
    val sc = new java.util.Scanner(System.in)
    val a, b = sc.nextInt

    val ans = if (a % 3 == 0 || b % 3 == 0 || (a + b) % 3 == 0) {
      "Possible"
    } else {
      "Impossible"
    }

    println(ans)
  }
}


Measured memory_bytes: 27340
#include <stdio.h>
int main() {
	char s[4];
	scanf("%s", s);
	if (s[0] != s[1] && s[1] != s[2] && s[2] != s[0]) {
		printf("Yes\n");
	} else {
		printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 128
n,k=map(int,input().split())
a=list(map(int,input().split()))
s=set(a)
l=[0]*(n+1)
for i in range(n):
    l[a[i]]+=1
l=[i for i in l if i>0]
l.sort()
le=len(s)
c=0
for i in range(len(l)):
    if le<=k:
        break
    else:
        c+=l[i]
        le-=1
print(c)


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

namespace Palindrome_philia
{
    class Program
    {
        static void Main(string[] args)
        {
            String S = Console.ReadLine();
            char[] c = S.ToCharArray();
            var l = S.Length;

            int cnt = 0;

            for (int i = 1; i <= l / 2; i++)
            {
                //if (even)
                //{
                    if (c[i-1] != c[l-i])
                    {
                        c[l - i] = c[i-1];
                        cnt++;
                    }
                //}
                //else
                //{
                //    if (c[i - 1] != c[l - i])
                //    {
                //        c[l - i] = c[i - 1];
                //    }
                //}
            }
            Console.WriteLine(cnt);

        }
    }
}


Measured memory_bytes: 11092
// https://atcoder.jp/contests/abc136/tasks/abc136_e

#include <bits/stdc++.h>

using namespace std;

#define REP(i,n)   for(int i=0; i<(int)(n); i++)
#define FOR(i,b,e) for(int i=(b); i<=(int)(e); i++)
#define DUMP(a, n) REP(_i, n) printf("%d%c", a[_i], _i + 1 == n ? '\n' : ' ')
#define DUMP2D(a, n, m) REP(_i, n) REP(_j, m) printf("%d%c", a[_i][_j], _j + 1 == m ? '\n' : ' '); puts("")

//------------------------------------------------------------------------------
vector<int> divisor(int n) {
  vector<int> res;
  for (int i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      res.push_back(i);
      if (i != n / i) res.push_back(n / i);
    }
  }
  return res;
}

//------------------------------------------------------------------------------
const int N_MAX = 500;
const int A_I_MAX = 1e6;
const int K_MAX = 1e9;

int N, K;
int A[N_MAX];
int sum;
vector<int> ds;

bool check(int d) {
  vector<int> qs;
  int qsum = 0;
  REP(i, N) {
    int q = A[i] % d;
    if (q > 0) {
      qs.push_back(q);
      qsum += q;
    }
  }
  sort(qs.begin(), qs.end());
  int k = 0;
  for (int i = 0; i < qs.size() - qsum / d; i++) k += qs[i];
  return k <= K;
}

void solve() {
  sum = 0;
  REP(i, N) sum += A[i];
  ds = divisor(sum);
  sort(ds.begin(), ds.end(), greater<int>());
  for (int d: ds) {
    if (check(d)) {
      printf("%d\n", d);
      break;
    }
  }
}

void input() {
  scanf("%d%d", &N, &K);
  REP(i, N) scanf("%d", A + i);
}

int main() {
  input();
  solve();
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <array>
#include <vector>
#include <functional>
#include <unordered_map> 
#include <map> 
#include <numeric>
#include <limits>
#include <utility>
#include <queue>
#include <random>
#include <bitset>
#include <memory>
using namespace std;
typedef long long LL;

int main() {
    LL a, b;
    cin >> a >> b;
    cout << (a - 1)*(b - 1) << endl;
    return 0;
}

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

int n;
bool s[500], t[500], u[500], v[500];
int a[500][500];
ull ans[500][500];
void end(){
    cout << -1 << endl;
    exit(0);
}
void solve(){
    memset(a, 0xff, sizeof(a));
    vector<int> x(n), y(n);
    auto px = x.begin(), py = y.begin();
    for(int i = 0; i < n; i++) x[i] = y[i] = i;
    for(int i = 0; i < n; i++){
        if(s[i] ^ u[i]){
            for(int j = 0; j < n; j++) a[i][j] = u[i];
            px = x.erase(px);
        }
        else px++;
    }
    for(int j = 0; j < n; j++){
        if(t[j] ^ v[j]){
            for(int i = 0; i < n; i++){
                if(a[i][j] == (v[j] ^ 1)) end();
                a[i][j] = v[j];
            }
            py = y.erase(py);
        }
        else py++;
    }
    if(x.size() > 1 && y.size() > 1){
        bool b = 0;
        for(int i : x){
            bool c = b;
            for(int j : y){
                a[i][j] = c;
                c = !c;
            }
            b = !b;
        }
        return;
    }
    if(x.size() == 1){
        const int i = x[0];
        bool flag = 0;
        for(int j : y){
            a[i][j] = u[i];
            bool flag2 = 1;
            for(int i = 0; i < n; i++) if(a[i][j] == v[j]){
                flag2 = 0;
                break;
            }
            if(flag2) a[i][j] = v[j];
            else flag = 1;
        }
        if(flag) return;
    }
    if(y.size() == 1){
        const int j = y[0];
        bool flag = 0;
        for(int i : x){
            a[i][j] = v[j];
            bool flag2 = 1;
            for(int j = 0; j < n; j++) if(a[i][j] == u[i]){
                flag2 = 0;
                break;
            }
            if(flag2) a[i][j] = u[i];
            else flag = 1;
        }
        if(flag) return;
    }
    for(int i : x){
        bool flag = 1;
        for(int j = 0; j < n; j++) if(a[i][j] == u[i]){
            flag = 0;
            break;
        }
        if(flag) end();
    }
    for(int j : y){
        bool flag = 1;
        for(int i = 0; i < n; i++) if(a[i][j] == v[j]){
            flag = 0;
            break;
        }
        if(flag) end();
    }
}
int main(){
    cin >> n;
    vector<ull> u_(n), v_(n);
    for(int i = 0; i < n; i++) cin >> s[i];
    for(int i = 0; i < n; i++) cin >> t[i];
    for(auto& i : u_) cin >> i;
    for(auto& i : v_) cin >> i;
    for(int bit = 64; bit--; ){
        for(int i = 0; i < n; i++) u[i] = u_[i] >> bit & 1;
        for(int i = 0; i < n; i++) v[i] = v_[i] >> bit & 1;
        solve();
        for(int i = 0; i < n; i++) for(int j = 0; j < n; j++){
            ans[i][j] <<= 1;
            ans[i][j] |= a[i][j];
        }
    }
    for(int i = 0; i < n; i++){
        for(int j = 0; j < n; j++) cout << ans[i][j] << ' ';
        cout << '\n';
    }
}



Measured memory_bytes: 8464
#include<stdio.h>
int main(){
	int W;
	int H;
	int x;
	int y;
	int r;
	scanf("%d %d %d %d %d\n", &W, &H, &x, &y, &r);
	if(x-r<0 || y-r<0 || x+r>W || y+r>H){
		printf("No\n");
	}
	else{
		printf("Yes\n");
	}
	return 0;
}


Measured memory_bytes: 2104
import sys
import itertools
from itertools import accumulate
def main():
    input = sys.stdin.readline
    def inputs():return [int(x) for x in input().split()]
    H,W,D = inputs()
    w = [[None]*W for i in range(H)]
    A = []
    for i in  range(H):
        B = inputs()
        A.append(B)
    E={i:[] for i in range(1,H*W+1)}
    for i in range(H):
        for j in range(W):
            a = A[i][j]
            if a<=H*W:
                E[a].append((i+1,j+1))
    #print(E)
    dis = [0]*(H*W+1)
    for i in range(1,H*W+1):
        if i+D<=H*W:
            #print(i+D)
            x = E[i][0][0]
            y = E[i][0][1]
            a = E[i+D][0][0]
            b = E[i+D][0][1]
            dis[i+D] = dis[i]+abs(a-x)+abs(b-y)
    Q = int(input())
    for i in range(Q):
        r,l = inputs()
        print(dis[l]-dis[r])
main()

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

int main()
{
    int n,m;
    scanf("%d%d",&n,&m);
    int a=n-1;
    int b=m-1;
    int p = ((a*(a+1))/2)+((b*(b+1))/2);
    printf("%d\n",p);

    return 0;
}


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

struct Node {
  int key;
  Node *right, *left, *parent;
};

Node *root, *NIL;

Node * find(Node *u, int k) {
  while ( u != NIL && k != u->key) {
    if ( k < u->key ) u = u->left;
    else u = u->right;
  }
  return u;
}

void insert(int k) {
  Node *y = NIL;
  Node *x = root;
  Node *z;

  z = (Node *)malloc(sizeof(Node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while( x != NIL ) {
    y = x;
    if ( z->key < x->key) {
      x = x->left;
    } else {
      x = x->right;
    }
  }
  z->parent = y;
  if ( y == NIL) {
    root = z;
  } else {
    if ( z->key < y->key ) {
      y->left = z;
    } else {
      y->right = z;
    }
  }
}

void inorder(Node *u) {
  if ( u == NIL ) return;
  inorder(u->left);
  printf(" %d", u->key);
  inorder(u->right);
}

void preorder(Node *u) {
  if ( u == NIL ) return;
  printf(" %d", u->key);
  preorder(u->left);
  preorder(u->right);
}

int main() {
  int n, i ,x;
  string com;

  scanf("%d", &n);

  for (i = 0; i < n; i++) {
    cin >> com;
    if ( com[0] == 'f') {
      scanf("%d", &x);
      Node *t = find(root, x);
      if ( t != NIL) printf("yes\n");
      else printf("no\n");
    } else if (com == "insert") {
      scanf("%d", &x);
      insert(x);
    } else if ( com == "print") {
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }

  return 0;
}



Measured memory_bytes: 22020
// C
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#ifdef __GXX_EXPERIMENTAL_CXX0X__
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#ifdef __GXX_EXPERIMENTAL_CXX0X__
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif
//#include <bits/stdc++.h>

#define all(v) v.begin(), v.end()
typedef long long ll;
#define rep(i, z, n) for(ll i = z; i < n; i++)
//const int INF = 1<<29;
//const int MODINF = 1000000007;
using namespace std;

int main(){
    int X;
    cin >> X;
    if(X>=30) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 3648
public class Main {

	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????
		
		for (int i = 1; i < 10; i++) {
			for (int j = 1; j < 10; j++) {
				System.out.println(i + "x" + j + "=" + i * j);
			}
		}
		
	}

}

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

#ifdef LOCAL
#define debug(var) cerr << #var << " = " << var << endl;
#else
#define debug(var)
#endif

void init() {
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
}

const int N = 12343;

pair<int, int> p[N];
int n, w;

map<pair<int, long long>, long long> dp;

long long rek(int i, long long s) {
	if (i >= n) return 0;
	const auto pp = make_pair(i, s);
	if (dp.find(pp) != dp.end()) return dp[pp];
	if (p[i].first+s > w) return dp[pp] = rek(i+1, s);
	return dp[pp] = max(rek(i+1, s), rek(i+1, s+p[i].first)+p[i].second);
}

void solve() {
	scanf("%d%d", &n, &w);
	for (int i = 0; i < n; ++i) {
		int w, v; scanf("%d%d", &w, &v);
		p[i] = make_pair(w, v);
	}
	printf("%lld", rek(0, 0));
}

int main() {
	init();
	int t = 1; //scanf("%d", &t);
	while (t--) {
		solve();
	}
	return 0;
}


Measured memory_bytes: 6272
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(300000)


def solve(N: int, K: int, a: "List[int]", b: "List[int]"):
    p = []
    for i in range(N):
        p.append([a[i], b[i]])
    p.sort(key=lambda x:x[0])
    tmp = 0
    ret = 0
    for v, c in p:
        tmp += c
        if K <= tmp:
            ret = v
            break
    print(ret)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    a = [int()] * (N)  # type: "List[int]" 
    b = [int()] * (N)  # type: "List[int]" 
    for i in range(N):
        a[i] = int(next(tokens))
        b[i] = int(next(tokens))
    solve(N, K, a, b)

if __name__ == '__main__':
    main()


Measured memory_bytes: 22824
K = gets.chomp.to_i
x = 7.modulo(K)
mods = [x]
(1..K).each do |i|
    if x == 0 then
        puts i
        exit
    end
    x = (x * 10 + 7).modulo(K)
    # if mods.include?(x) then
    #     puts -1
    #     exit
    # else
    #     mods.push(x)
    # end
end
puts -1

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

int main() {
	char b;
	cin >> b;
	if (b == 'A') {
		cout << 'T' << endl;
	}
	if (b == 'C') {
		cout << 'G' << endl;
	}
	if (b == 'T') {
		cout << 'A' << endl;
	}
	if (b == 'G') {
		cout << 'C' << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#たこ焼きの個数を読み取る
N = int(input())

#たこ焼きの美味しさをリストにする
d = list(map(int, input().split(" ")))

result = 0

for i in range(N):
    for j in range(i+1,N):
        result += d[i] * d[j]
        j = j + 1
    i = i + 1

print(result)

Measured memory_bytes: 3060
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<unordered_map>
#include<stack>
#include<queue>
#include<iomanip>
#include<math.h>
#include<bitset>
#include<cassert>
#include<random>
#include<time.h>
#include<functional>
using namespace std;
using ll=long long;
using ld=long double;
using pint=pair<int,int>;
using pll=pair<ll,ll>;
#define MOD 1000000007LL
#define INF 1000000000LL
#define EPS 1e-10
#define FOR(i,n,m) for(ll i=n;i<(ll)m;i++)
#define REP(i,n) FOR(i,0,n)
#define DUMP(a) REP(d,a.size()){cout<<a[d];if(d!=a.size()-1)cout<<" ";else cout<<endl;}
#define ALL(v) v.begin(),v.end()
#define UNIQUE(v)  sort(ALL(v));v.erase(unique(ALL(v)),v.end());
#define pb push_back

vector<vector<ll>> g(101010);
vector<ll> dp(101010, -1);

ll dfs(ll pos) {
	if(dp[pos] != -1) return dp[pos];
	ll ret = 0;
	REP(i, g[pos].size()) {
		ret = max(ret, dfs(g[pos][i]) + 1);
	}
	return dp[pos] = ret;
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n, m;
	cin >> n >> m;
	REP(i, m) {
		ll x, y;
		cin >> x >> y;
		x--; y--;
		g[x].pb(y);
	}
	ll ans = 0;
	REP(i, n) ans = max(ans, dfs(i));
	cout << ans << endl;
	return 0;
}

/* --------------------------------------- */


Measured memory_bytes: 8576
/*
Sharif Hasan - CSE, PUST
Apr 24, 2020 02: 14 PM
*/
#include<bits/stdc++.h>
#include "string.h"
#define br cout<<"\n"
#define what(x) cout<<"in here var= "<<x<<"\n";

/*STL definations*/
#define pb push_back

#define FOR(i,n) for(int i=0;i<n;i++)
#define FROM(a,i,n) for(int i=a;i<n;i++)
using namespace std;
double clockAngle(double a,double b){
    double f=fabs(b*6-(a*30+b/2));
    if(f>180) f=360-f;
    return  f*acos(-1)/180.0;
}
int main(){
    long long a,b;string s;
        cin >> a >> s;
        b=(s[0]-'0')*100+(s[2]-'0')*10+s[3]-'0';
        cout<<long((a*b)/100)<<endl;
    return 0;
}

Measured memory_bytes: 3608
import java.util.*;

class Main{
  static Scanner sc = new Scanner(System.in);
  public static void main(String args[]){
    int n = sc.nextInt();
    PriorityQueue<Pair> pq = new PriorityQueue<>(n);
    for(int i=0;i<n;i++){
      Pair pi=new Pair(sc.nextInt(),sc.nextInt());
      pq.add(pi);
    }
    int time=0;
    while(!pq.isEmpty()){
      Pair p=pq.poll();
      if(time+p.a>p.b){
        System.out.println("No");
        return;
      }
      time+=p.a;
    }
    System.out.println("Yes");
  }
  public static class Pair implements Comparable<Pair>{
    int a;
    int b;
    Pair(int a,int b){
      this.a=a;
      this.b=b;
    }
    public int compareTo(Pair o){
      return Integer.compare(this.b,o.b);
    }
  }
}

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

int main(){
  int N,x;
  cin >>N >>x;
  vector<int> a(N);
  for(int i=0;i<N;i++)
    cin >>a.at(i);
  sort(a.begin(),a.end());
  int count=0;
  for(int i =0; i<N;i++){
    x -= a.at(i);
    if(x>=0 && i <N-1){
      count ++;
    }
    else if (i ==N-1 && x==0){
      count ++;
    }
    else{
      break;
    }
  }
  cout <<count <<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
int main(){
	ll a,b,c,d;
    cin>>a>>b>>c>>d;
    ll maxx=0;
    ll a1=a*c;
    ll b1=a*d;
    ll c1=b*c;
    ll d1=b*d;
    cout<<max(max(a1,b1),max(c1,d1))<<endl;

	return 0;
}

Measured memory_bytes: 3564