akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;

int main()
{

    double a0;
    string S;


    cin >> S;

      char c0 = S[0];
      char c1 = S[1];
      char c2 = S[2];
      char c3 = S[3];

   a0 = 0.0;
   if (c0 == c1) {
       if ((c2 == c3) && (c0 != c2)) {
           a0 = 1.0;
       }
   }

   if (c0 == c2) {
       if ((c1 == c3) && (c0 != c1)) {
           a0 = 1.0;
       }
   }

   if (c0 == c3) {
       if ((c1 == c2) && (c0 != c1)) {
           a0 = 1.0;
       }
   }


   if (a0 == 1) {
       cout << "Yes" << endl;
   }
   else {
       cout << "No" << endl;

   }

     return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
	while(1) {
		int n, m;
		cin >> n >> m;
		if((n == 0)&&(m == 0)) {
			break;
		} else {
			vector<long long int> arr_max(n, 0);
			vector<long long int> arr_min(n, 0);
			for(int i = 0; i < m; i++) {
				int s, k, c;
				cin >> s >> k;
				for(int j = 0; j < k; j++) {
					cin >> c;
					c--;
					arr_max[c] += s;
					if(k == 1) arr_min[c] += s;
				}
			}
			long long int ans = 0;
			for(int i = 0; i < n; i++) {
				for(int j = 0; j < n; j++) {
					if(i != j) {
						if(ans < arr_max[i] - arr_min[j]) ans = arr_max[i] - arr_min[j];
					}
				}
			}
			cout << ans + 1 << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 3212
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a
  
import collections
import fractions
a,b = map(int,input().split())
g = fractions.gcd(a,b)
c = collections.Counter(prime_factorize(g))
print(len(c)+1)

Measured memory_bytes: 5184
#include <iostream>
using namespace std;
int a[100001];
int main(){
  int n;cin>>n;
  for(int i=1;i<=n;i++){
    a[i]=a[i-1]+1;
    for(int j=6;j<=i;j*=6)
      a[i]=min(a[i],a[i-j]+1);
    for(int j=9;j<=i;j*=9)
      a[i]=min(a[i],a[i-j]+1);
  }
  cout<<a[n];
  return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define COUT(x) cout << #x << " = " << (x) << ", "
typedef long long ll;
using namespace std;
static const ll MOD = 1000000007;

int main(){
  string S;
  cin >> S;
  if(S[2] == S[3] && S[4] == S[5]){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define EPS (1e-10)
#define rep(i,n)for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;
typedef pair<int, int>P;

int main() {
	int h, w; cin >> h >> w;
	rep(i, h)rep(j, w) {
		string s; cin >> s;
		if (s == "snuke") {
			printf("%c%d\n", 'A' + j, i + 1); break;
		}
	}
}

Measured memory_bytes: 256
//                        Bismillahir Rahmanir Rahim
//ALGO:
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
#define pb push_back
#define F first
#define S second
#define all(v) v.begin(), v.end()
#define FILL(a, x) memset(a, x, sizeof(a))
#define ll long long
#define Fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define INF INT_MAX
/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define ordered_multiset tree<pair<int, int>, null_type,less<pair<int, int> >, rb_tree_tag,tree_order_statistics_node_update>
*/
const double Pi=acos(-1);
using namespace std;
int debug=01;
ll dp[110][100010], cost[110], value[110], n, mx;
ll solve(ll i, ll x){
    if(!x||i>n) return 0;
    if(~dp[i][x]) return dp[i][x];
    ll ret=solve(i+1, x);
    if(x>=cost[i]) ret=max(ret, solve(i+1, x-cost[i])+value[i]);
    return dp[i][x]=ret;
}
int main() {
    cin>>n>>mx;
    FILL(dp, -1);
    for(int i=0; i<n; i++)cin>>cost[i]>>value[i];
    cout<<solve(0, mx);
}



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

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int N; cin >> N;
	string ans = string("AB") + char('C' + (N / 1000));
	cout << ans << '\n';

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  int c = -1;
  int a;
  for(int i = 0; i < N; i++){
    cin >> a;
    int j = 0;
    while(a % 2==0){
      a /= 2;
      j++;
    }
    if(j < c || c == -1)
      c = j;
  }
  cout << c << endl;
}
      
          
      


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

int main(){
  string s; cin >> s; int f=0; int b=0;
  if((s[0] == '1' && (s[1] == '1' || s[1] == '2')) || (s[0] == '0' && s[1] != '0')) f=1;
  if((s[2] == '1' && (s[3] == '1' || s[3] == '2')) || (s[2] == '0' && s[3] != '0')) b=1;
  if(b==1 && f==1) cout << "AMBIGUOUS" << endl;
  if(b==1 && f==0) cout << "YYMM" << endl;
  if(b==0 && f==1) cout << "MMYY" << endl;
  if(b==0 && f==0) cout << "NA" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <stack>
#include <cmath>
#include <string>
using namespace std;

#define ll long long
int main()
{
	string s;
	cin >> s;

	int y = (s[0] - '0') * 10 + (s[1] - '0');
	int m = (s[2] - '0') * 10 + (s[3] - '0');

	if ((m < 1 || m > 12) && (y < 1 || y > 12))
	{
		cout << "NA" << endl;
	}
	else if ((m > 0 || m < 13) && (y < 1 || y > 12))
	{
		cout << "YYMM" << endl;
	}
	else if ((y > 0 || y < 13) && (m < 1 || m > 12))
	{
		cout << "MMYY" << endl;
	}
	else 
	{
		cout << "AMBIGUOUS" << endl;
	}

}





Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  vector<long long> A(N);
  for (int i = 0; i < N; i++){
    cin >> A[i];
  }
  vector<long long> X(N + 1, 0);
  for (int i = 0; i < N; i++){
    X[i + 1] = X[i] ^ A[i];
  }
  vector<long long> S(N + 1, 0);
  for (int i = 0; i < N; i++){
    S[i + 1] = S[i] + A[i];
  }
  long long ans = 0;
  for (int i = 0; i < N; i++){
    int tv = i;
    int fv = N + 1;
    while (fv - tv > 1){
      int mv = (tv + fv) / 2;
      if ((X[mv] ^ X[i]) == S[mv] - S[i]){
        tv = mv;
      } else {
        fv = mv;
      }
    }
    ans += tv - i;
  }
  cout << ans << endl;
}

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

int main(){

    int  a, b;

    scanf("%d %d", &a, &b);

    if((a * b) % 2 == 0){
        cout << "Even" << endl;
    }
    else{
        cout << "Odd" << endl;
    }
}

Measured memory_bytes: 3716
#include <bits/stdc++.h>
#define f first
#define s second
#define MOD 1000000007
#define PMOD 998244353
#define pb(x) push_back(x)
using namespace std;

typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> plii;
typedef pair<int, pii> piii;
const int INF = 1e9+10;
const ll LINF = 1LL*INF*INF;
const int MAXN = 2e5+10;
const int MAXM = 5e3+10;

priority_queue<int> pq;
vector<vector<int> > graph;
queue<int> que;

int A[MAXN];
ll tri[MAXN];
char S[MAXN];

int main()
{
    int n,m,k,a,b,x,y,q;
    int sum = 0;
    int cnt = 0;
    int mx = 0;
    int mn = INF;
    int cur = 0, idx = -1;
    int tc;

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    cin>>S;

    n = strlen(S);

    ll res = 0;
    ll bi = 1;

    tri[0] = 1;

    for(int i=1;i<n;i++)
        tri[i] = (tri[i-1]*3)%MOD;

    for(int i=0;i<n;i++){
        if(S[i]-'0'){
            res = (res+bi*tri[n-1-i])%MOD;
            bi = (bi*2)%MOD;
        }
    }
    res = (res+bi)%MOD;

    cout<<res<<"\n";

    return 0;
}


Measured memory_bytes: 1152
#include <cstdio>

using namespace std;

int main()
{
    long a, b, c, d;

    scanf("%ld %ld %ld %ld", &a, &b, &c, &d);

    long ab = a * b;
    long cd = c * d;

    if (ab < cd) printf("%ld\n", cd);
    else printf("%ld\n", ab);

    return 0;
}


Measured memory_bytes: 128
#!/usr/bin/env python3
import sys
INF = float("inf")


def solve(S: str):
    print(S.count("+")-S.count("-"))
    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  # type: str
    solve(S)


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include<iostream>
#include<algorithm>
#include<vector>
#include<numeric>
#include<string>
#include<cmath>
#include<set>
#include<queue>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cctype>
#include<map>
#include<cstring>
#include<bitset>
#include<cassert>

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,a,b) for (int (i)=a;(i)<(b);(i)++)
#define all(x) (x).begin(),(x).end()

using namespace std;
using ll = long long int;

const int inf = 1001001000;
const long long int Inf = 1001001001001001000;



void print(vector<vector<int>> a){
	for (int i = 0; i < a.size(); i++)
	{
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<vector<long long int>> a){
	for (int i=0;i<a.size();i++){
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<int> a){
    int n = a.size();
    for (int j=0;j<n;j++) {
        if (j != n-1) cout << a[j] << " ";
        else cout << a[j] << endl;
    }
}

void print(vector<long long int> a){
    int n = a.size();
    for (int j=0;j<n;j++) {
        if (j != n-1) cout << a[j] << " ";
        else cout << a[j] << endl;
    }
}

void print(set<int> a){
	for (auto x:a)
		cout << x << " ";
	cout << endl;
}




int main(){
	string s,t;
	cin >> s >> t;
	rep(i,s.size()){
		if(s[i] != t[i]){
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 3600
'use strict';

const main = arg => {

    const input = arg.split("\n");
    const n = parseInt(input[0]);

    let freq = new Map();
    for (let i = 0; i < n; i++) {
        const a = parseInt(input[i + 1].trim());
        if (freq.has(a)) {
            freq.set(a, freq.get(a) + 1);
        } else {
            freq.set(a, 1);
        }
    }

    let count = 0;
    for (const [key, value] of freq.entries()) {
        if (value % 2 == 1) {
            count++;
        }
    }
    console.log(count);
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 53920
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define loop(i,a,b) for(i=a;i<b;i++)
#define rloop(i,a,b) for(i=a;i>=b;i--)
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
const int inf=1000000001;
const ll INF=1e16;
#define MOD 1000000007
#define mod 1000000009
#define pi 3.14159265358979323846

int main(){
	int n,i,j;
	cin>>n;
	vs s(n);
	int m=inf,mi;
	loop(i,0,n){
		cin>>s[i];
		sort(s[i].begin(),s[i].end());
		m=min(m,(int)s[i].size());
		if(m==s[i].size()){
			mi=i;
		}
	}
	vector<char> ans;
	i=0;
	while(i<s[mi].size()){
		m=count(s[mi].begin(),s[mi].end(),s[mi][i]);
		i+=m;
		loop(j,0,s.size()){
			m=min(m,(int)count(s[j].begin(),s[j].end(),s[mi][i-m]));
		}
		loop(j,0,m){
			ans.push_back(s[mi][i-m]);
		}
	}
	loop(i,0,ans.size()){
		cout<<ans[i];
	}
	cout<<endl;
}

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

int main(void){
    int a1, a2, a3;
    scanf("%d %d %d", &a1, &a2, &a3);
    int max = a1, min = a1;
    if(max<a2) max = a2;
    if(max<a3) max = a3;
    if(min>a2) min = a2;
    if(min>a3) min = a3;
    printf("%d", max-min);
}


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

long long n;
long long cnt[1005] = {0}, ans = 1;

int main() {
  cin >> n;
  for(long long i = 2; i <= n; ++i) {
    long long now = i;
    for(long long j = 2; j <= now; ++j)
      while(now > 0 && now % j == 0) {
        ++cnt[j];
        now /= j;
      }
  }
  for(long long i = 0; i <= n; ++i)
    if(cnt[i] != 0) {
      ans *= cnt[i] + 1;
      ans %= 1000000007;
    }
  cout << ans << endl;
  return 0;
}

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

int main(void){
    long long int x, n, r, i, j, min, ans=0;
    scanf("%lld %lld", &n, &x);
    long long int l[n+1], d[n+1];
    for(i=0; i<n; i++) scanf("%lld", &l[i+1]);
    d[0] = 0;
    for(i=1; i<n+1; i++) d[i] = d[i-1] + l[i];
    for(i=0; i<n+1; i++){
        if(d[i]>x) break;
        ans++;
    }
//    for(i=0; i<n+1; i++) printf("%lld ", d[i]);
    printf("%lld", ans);
    
}

Measured memory_bytes: 128
s = input()
k = s[0]+s[1]
if (k == "SU"):
    print(7)
elif (k == "MO"):
    print(6)
elif (k == "TU"):
    print(5)
elif (k == "WE"):
    print(4)
elif (k == "TH"):
    print(3)
elif (k == "FR"):
    print(2)
else:
    print(1)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
//#pragma comment(linker, "/STACK: 2000000")

using namespace std;

const int N = 2e6 + 5;

long long n ,base = 313 ,mod = 1e9 +7;
long long pws[N];
string s;
void nor(long long &nr)
{
    nr%=mod;
    nr+=mod;
    nr%=mod;
}
int hhh[N];

bool check(int x)
{
    map<long long , int > hsh;

    long long now = 0;
    for(int i = 0;i<x;i++)
    {
        now+= (1LL * s[i] * pws[x-i-1])%mod;
        now%=mod;
    }
    hhh[0] = now;
    if(x==1)
        hsh[now]++;
    for(int i = 1;i<=n-x;i++)
    {
        now-= (1LL*s[i-1] * pws[x-1])%mod;nor(now);
        now =(now*base)%mod;
        now+= (1LL*s[i+x-1] )%mod;nor(now);
        hhh[i] = now;
        if(i>=x-1)
            hsh[now]++;
    }
    for(int i = 0;i<n-x;i++)
    {
        hsh[ hhh[i+x-1] ]--;
        if( hsh[ hhh[i] ] )
            return 1;
    }
    return 0;
}

int main() {
    cin>>n>>s;
    pws[0] = 1;
    for(int i = 1;i<N;i++)
        pws[i] = (1LL * pws[i-1] * base) %mod;
    int l= 1 , r = n , ans = 0;
    while(l<=r)
    {
        int mid = (l+r)/2;
        if(check(mid))
        {
            ans = mid;
            l = mid+1;
        }
        else r = mid-1;
    }
    cout<<ans;
    return 0;

}


Measured memory_bytes: 17920
from bisect import bisect_right

n, m, k = map(int, input().split())
a = list(map(int, input().split()))
csa = [0] * (n+1)
for i in range(n):
    csa[i+1] += csa[i] + a[i]
csb = [0] * (m+1)
b = list(map(int, input().split()))
for i in range(m):
    csb[i+1] += csb[i] + b[i]

ans = 0
for i in range(n+1):
    t = k - csa[i]
    if t < 0:
        break
    j = bisect_right(csb, t)
    ans = max(ans, i + j - 1)

print(ans)

Measured memory_bytes: 52304
fn getline() -> String {
    let mut __ret = String::new();
    std::io::stdin().read_line(&mut __ret).ok();
    return __ret;
}

fn main() {
    let s = getline();
    let n: i32 = s.trim().parse().unwrap();
    let x = 800 * n;
    let y = 200 * (n / 15);
    let ans = x - y;

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


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INFLL (1LL<<62) // 9223372036854775807
#define EPS 1e-9
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
template<class T>bool chmax(T &a, const T &b){ if(a<b){ a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b){ if(b<a){ a=b; return 1; } return 0; }
using namespace std;

int main(){
    Init();
    ll h, w, k;
    cin >> h >> w >> k;
    vi r(k), c(k), v(k);
    vvi item(h, vi(w, 0));
    rep(i, k){
        cin >> r[i] >> c[i] >> v[i];
        r[i]--, c[i]--;
        item[r[i]][c[i]] = v[i];
    }

    vector<vvi> dp(h+1, vvi(w+1, vi(4, 0)));
    for(ll i=0; i<h; i++){
        for(ll j=0; j<w; j++){
            // 右に遷移
            chmax(dp[i][j+1][0], dp[i][j][0]);
            chmax(dp[i][j+1][1], max(dp[i][j][0] + item[i][j], dp[i][j][1]));
            chmax(dp[i][j+1][2], max(dp[i][j][1] + item[i][j], dp[i][j][2]));
            chmax(dp[i][j+1][3], max(dp[i][j][2] + item[i][j], dp[i][j][3]));

            // 下に遷移
            chmax(dp[i+1][j][0], max(max(dp[i][j][0] + item[i][j], dp[i][j][1] + item[i][j]), max(dp[i][j][2] + item[i][j], dp[i][j][3])));
        }
    }
    cout << max(max(dp[h-1][w-1][0]+item[h-1][w-1], dp[h-1][w-1][1]+item[h-1][w-1]), max(dp[h-1][w-1][2]+item[h-1][w-1], dp[h-1][w-1][3])) << endl;
}

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

int main(){
    ll x, n;
    cin >> x >> n;
    set<ll> st;
    rep(i, 0, n){
        ll p;
        cin >> p;
        st.insert(p);
    }
    ll ans = 0, mn = 1e18;
    rep(i, -100, 200) {
        if(st.count(i)) continue;
        ll d = abs(x - i);
        if(d < mn) {
            mn = d;
            ans = i;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3584
/**
 *   author: malviyanshiv
 *   created: 09 January 2019  23:27:27
**/

#include <bits/stdc++.h>

using namespace std;

#define REP(i, a, b) for(int i = a; i < b; i++)
#define RREP(i, a, b) for(int i = a-1; i >= b; i--)
#define PB push_back
#define MP make_pair
#define MOD 1000000007
#define INF 0x7fffffff
#define MAX 100005

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

void fastscan(int &x){
    bool neg=false;
    register int c;
    x =0;
    c=getchar();
    if(c=='-'){
        neg = true;
        c=getchar();
    }
    for(;(c>47 && c<58);c=getchar())
        x = (x<<1) + (x<<3) +c -48;
    if(neg)
        x *=-1;
}

void optimizeIO(){
	ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
}

vector< vector<double> > dp(3000, vector<double>(3000, -1));
vector<double> ph(3000);

double cal(int n, int k ){
    if( n < k )
        return 0;
    if( k == 0 || n == 0)
        return 1;
    if( dp[n][k] >= 0 )
        return dp[n][k];
    else
        return dp[n][k] = cal(n-1, k-1)*ph[n] + cal(n-1, k)*(1-ph[n]);
}


int main(){
	optimizeIO();
    int n;
    cin >> n;
    REP(i, 1, n+1)
        cin >> ph[i];
    double v = ph[1];
    dp[1][1] = v;
    REP(i, 2, n+1){
        v = v * ph[i];
        dp[i][i] = v;
    }

    printf("%0.10f", cal(n, n/2+1));


	return 0;
}

Measured memory_bytes: 70912
#include <bits/stdc++.h>
//#define DEBUG

using namespace std;
int n, a[131100];
struct node {
    int id, point;
} node[1<<18];

void add(int id, int x)
{
    id=n-1+id;
    node[id].point+=x;

    while (id>0) {
        id=(id-1)/2;
        int c1=2*id+1, c2=2*id+2;
        if (node[c1].point>=node[c2].point)
            node[id]=node[c1];
        else
            node[id]=node[c2];
    }
}

void print()
{
#ifdef DEBUG
    int k=1;
    int x=0;
    while (true) {
        for(int i=0;i<k;++i) printf("(%d %d)", node[x+i].id, node[x+i].point);
        puts("");
        x+=k;
        k<<=1;
        if (x>=n) break;
    }
    puts("");
#endif
}

int main()
{
    int m, r, l;
    scanf("%d%d%d", &m, &r, &l);
    n=1;
    while (n<m) n<<=1;
    for(int i=0;i<m;++i) node[n-1+i].id=i;

    int pt=0;
    for(int i=0;i<r;++i) {
        int d, t, x;
        scanf("%d%d%d", &d, &t, &x);

        if (pt<t) {
            int id=node[0].id;
            a[id]+=t-pt;
        }
        add(d-1, x);
        print();
        pt=t;
    }
    print();
    a[node[0].id]+=l-pt;
#ifdef DEBUG
    for(int i=0;i<n;++i) printf("%d ", a[i]); puts("");
#endif
    printf("%d\n", 1+(max_element(a, a+n)-a));
}

Measured memory_bytes: 3168
import sys
def input(): return sys.stdin.readline().rstrip()

def main():
    MAX = 10 ** 5
    Q = int(input())

    ans = [0] * (MAX + 1)
    sum = 0
    prime = set()
    memo = [False] * 2 + [True] * (MAX - 1)
    for i in range(2, MAX + 1):
        if memo[i]:
            prime.add(i)
            for j in range(i * 2, MAX + 1, i):
                memo[j] = False
            if (i + 1) // 2 in prime:
                sum += 1
        ans[i] = sum
    
    for _ in range(Q):
        l, r = map(int, input().split())
        print(ans[r] - ans[l-1])

if __name__ == '__main__':
    main()


Measured memory_bytes: 6360
#include <cstdio>
#include <cassert>
using namespace std;

typedef long long ll;

const ll INF = ll(1E15);
const int MAXN = 100000;
const int dx[] = {0, 0, 1, -1};
const int dy[] = {1, -1, 0, 0};

bool nprm[MAXN + 5];
int prm[MAXN + 5], pcnt;
void init() {
	for(int i=2;i<=MAXN;i++) {
		if( !nprm[i] ) prm[++pcnt] = i;
		for(int j=1;i*prm[j]<=MAXN;j++) {
			nprm[i*prm[j]] = true;
			if( i % prm[j] == 0 ) break;
		}
	}
}

ll gcd(ll x, ll y) {
	return y == 0 ? x : gcd(y, x % y);
}

ll a[505][505], p[1005], q[1005];
int main() {
	init(); int N; scanf("%d", &N);
	if( N == 2 ) {
		printf("4 7\n23 10\n");
		return 0;
	}
	int cnt = 0;
	for(int i=1;i<=N;i+=2)
		p[i] = prm[++cnt], q[i] = prm[++cnt];
	for(int i=N-(N&1);i>=0;i-=2)
		p[i] = prm[++cnt], q[i] = prm[++cnt];
		
	
	for(int i=1;i<=N;i++)
		for(int j=1;j<=N;j++)
			if( (i + j) % 2 == 0 )
				a[i][j] = p[(i + j)/2] * q[(i + N - j + 1)/2];
	for(int i=1;i<=N;i++)
		for(int j=1;j<=N;j++) {
			if( (i + j) % 2 == 0 ) continue;
			a[i][j] = 1;
			for(int o=0;o<4;o++) {
				int x1 = i + dx[o], y1 = j + dy[o];
				if( x1 < 1 || x1 > N || y1 < 1 || y1 > N ) continue;
				a[i][j] = a[i][j] / gcd(a[i][j], a[x1][y1]) * a[x1][y1];
			}
			a[i][j]++, assert(a[i][j] <= INF);
		}
	
	for(int i=1;i<=N;i++)
		for(int j=1;j<=N;j++)
			printf("%lld%c", a[i][j], j == N ? '\n' : ' ');
}

Measured memory_bytes: 5120
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {
        n: usize
    }

    let mut ans = 0;
    for i in 1..=n {
        if i % 2 == 0 {
            continue;
        }

        let mut div_num = 0;
        for k in 1..=(i as f64).sqrt() as usize {
            if i % k == 0 {
                div_num += 1;
                if k != i / k {
                    div_num += 1;
                }
            }
        }
        if div_num == 8 {
            ans += 1;
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 2092
#include <cstdio>
#include <vector>
#include <string>
#include <iostream>
using namespace std;
typedef long long ll;

struct Node
{
	int id;
	int c;
	bool visited[2] = {0};
	bool processing[2] = {0};
	vector<Node*> ch;
	
	bool dfs(int k);
};

bool Node::dfs(int k)
{
	if(processing[k])
		return true;
	processing[k] = true;
	visited[k] = true;

	for(Node *v : ch) if((k == 0 && c == v->c) || (k == 1 && c != v->c)) {
		if(v->dfs((k+1)%2))
			return true;
	}
	
	processing[k] = false;
	
	return false;
}

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

	int n, m;
	cin >> n >> m;
	string s;
	cin >> s;
	vector<Node> nodes(n);
	for(int i=0; i<n; ++i) {
		nodes[i].c = s[i] - 'A';
		nodes[i].id = i+1;
	}
	for(int i=0; i<m; ++i)
	{
		int u, v;
		cin >> u >> v; --u, --v;
		nodes[u].ch.push_back(&nodes[v]);
		nodes[v].ch.push_back(&nodes[u]);
	}

	bool ans = 0;
	for(int i=0; !ans && i<n; ++i)
	{
		for(int j=0; !ans && j<2; ++j) {
			if(!nodes[i].visited[j])
				ans |= nodes[i].dfs(j);
		}
	}
	
	cout << (ans ? "Yes" : "No") << "\n";

	return 0;
}


Measured memory_bytes: 26192
#include <bits/stdc++.h>
using namespace std;
using i64 = int64_t;
using f80 = __float80;
constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
static const int dy[4] = {0,1,0,-1}, dx[4] = {1,0,-1,0};
#define _overload3(_1,_2,_3,name,...) name
#define repi(i,start,end) for(i64 i=(start);i<(end);++i)
#define _rep(i,n) repi(i,0,n)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(i,start,end) for(i64 i=(start);i>end;--i)
#define pb push_back
#define rng(a) a.begin(),a.end()
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define sz(x) (i64)(x).size()
#define bit(n) (1LL<<(n))
#define fi first
#define se second
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define v(T) vector<T>
#define vv(T) v(v(T))
typedef v(i64) vi;
typedef v(vi) vvi;
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;}

void Main()
{
  string s;
  cin >> s;
  if(s[2]==s[3] and s[4]==s[5]){
    cout << "Yes\n";
  }else
  {
    cout << "No\n";
  }
}

int main()
{
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  Main();
}



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

const int MAXN = 1e2 + 2, W = 1e5 + 5;
long long w[MAXN], v[MAXN], dp[MAXN][W];
int n, mxw;

void input();
void solve();

int main() {
	ios:: sync_with_stdio(0), cin.tie(0), cout.tie(0);
	input();
	solve();
	return 0;
}

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

void solve() {
	dp[0][w[0]] = v[0];
	long long ans = v[0];
	for (int i = 1; i < n; i++)
		for (int j = 0; j <= mxw; j++) {
			if (j > w[i])
				ans = max(ans, dp[i][j] = max(dp[i - 1][j], dp[i - 1][j - w[i]] + v[i]));
			else
				dp[i][j] = dp[i - 1][j];
			//if (i == 2)
			//	cout << dp[i][j] << " ";
		}
	cout << ans;
}


Measured memory_bytes: 77568
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
#include<deque>
using namespace std;

int main() {
    typedef pair<int, int> pair;
    int H, W; cin >> H >> W;
    vector<string> maze(H);
    vector< vector<int> > dist(H, vector<int>(W, -1));
    for (int i = 0; i < H; i++) cin >> maze[i]; 

    deque<pair> q;
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            if (maze[i][j] == '.') continue;
            q.push_back(make_pair(i, j));
            dist[i][j] = 0;
        }
    }

    while (!q.empty()) {
        auto curr = q.front();
        int h = curr.first;
        int w = curr.second;
        q.pop_front();
        if (h > 0 && dist[h - 1][w] == -1) {
            q.push_back(make_pair(h - 1, w));
            dist[h - 1][w] = dist[h][w] + 1;
        }
        if (h < H - 1 && dist[h + 1][w] == -1) {
            q.push_back(make_pair(h + 1, w));
            dist[h + 1][w] = dist[h][w] + 1;
        }
        if (w > 0 && dist[h][w - 1] == -1) {
            q.push_back(make_pair(h, w - 1));
            dist[h][w - 1] = dist[h][w] + 1;
        }
        if (w < W - 1 && dist[h][w + 1] == -1) {
            q.push_back(make_pair(h, w + 1));
            dist[h][w + 1] = dist[h][w] + 1;
        }
    }

    int ans = 0;
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            ans = max(dist[i][j], ans);
        }
    }
    cout << ans << endl;
}



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

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

  int N;
  cin >> N;
  vector<int> subordinate(N);
  for(int i = 0; i < N - 1; ++i) {
    int boss;
    cin >> boss;
    subordinate[boss - 1]++;
  }

  for(int i = 0; i < N; ++i) {
    cout << subordinate[i] << endl;;
  }

  return 0;
}


Measured memory_bytes: 3988
#include<stdio.h>
int dp[21][40001];
int main(void){
    int n,A[100],q,key;
    int i,j;
    scanf("%d",&n);
    A[i]=0;
    for(i=1;i<=n;i++) scanf("%d",&A[i]);
    
    dp[0][0]=1;
    for(i=0;i<n;i++){
	for(j=0;j<=40000;j++){
	    if(dp[i][j]==1){
		dp[i+1][j]=1;
		dp[i+1][j+A[i+1]]=1;
	    }
	}
    }

    scanf("%d",&q);
    for(i=0;i<q;i++){
	scanf("%d",&key);
	if(dp[n][key]==1) printf("yes\n");
	else printf("no\n");
    }

    return 0;
}

Measured memory_bytes: 684
import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, core.stdc.stdio;

immutable long MOD = 10^^9 + 7;

void main() {
    auto s = readln.split.map!(to!long);
    auto t1 = s[0];
    auto t2 = s[1];
    s = readln.split.map!(to!long);
    auto a = s[0];
    auto b = s[1];
    s = readln.split.map!(to!long);
    auto c = s[0];
    auto d = s[1];

    auto v = a * t1;
    auto w = b * t2;
    auto x = c * t1;
    auto y = d * t2;

    if (v > x && v + w > x + y) {
        writeln(0);
        return;
    }
    if (x > v && x + y > v + w) {
        writeln(0);
        return;
    }
    if (x + y == v + w) {
        writeln("infinity");
        return;
    }

    if (v > x) {
        swap(v, x);
        swap(w, y);
    }

    long diff1 = x - v;
    long diff2 = v + w - x - y;

    auto hi = BigInt(10)^^30;
    auto lo = BigInt(-1);

    while (hi - lo > 1) {
        auto mid = (hi + lo) / 2;
        auto p1 = (v + w) * mid;
        auto p2 = (x + y) * mid;
        if (p1 + v > p2 + x) {
            hi = mid;
        } else {
            lo = mid;
        }
    }

    auto ans = hi * 2 - 1;

    if (lo != 0 && lo * (v + w) + v == lo * (x + y) + x) {
        ans -= 1;
    }

    ans.writeln;
}

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

int main(){
  ll n,m;
  cin >> n >> m;
  vector<int> a(m);
  vector<int> b(m);
  rep(i,m) cin >> a[i] >> b[i];
  dsu d(n);
  rep(i,m) d.merge(a[i]-1, b[i]-1);
  int ans=0;
  rep(i,n){
    if(!d.same(0,i)){
      ans++;
      d.merge(0,i);
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 4276
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin >> n;
    double ans = 0;
    for(int i = 0; i < n; i++)
    {
        double a;
        string s;
        cin >> a >> s;
        if(s == "JPY")
        {
            ans += a;
        }
        else
        {
            ans += 380000.0 * a;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
struct Key{
	int cost;
	int locks;
};
int dp[1011][4999];
Key keys[1011];
const int inf = 1e9;
int main() {
	int n,m;
	cin>>n>>m;
	for(int i=1;i<=m;++i ) {
		Key key;
		cin>>key.cost;
		key.locks = 0;
		int t;
		cin>>t;
		for(int j=1;j<=t;++j) {
			int x;
			cin>>x;
			key.locks |= (1<<(x-1));
		}
		keys[i] = key;
	}
	
	int lim = 0;
	for(int i=0;i<n;++i) {
		lim |= (1<<i);
	}
	for(int i=0;i<=m;++i) {
		for(int j=0;j<=lim;++j) {
			dp[i][j] = inf;
		}
	}
	dp[0][0] = 0;
	for(int i=1;i<=m;++i) {
		for(int j=0;j<=lim;++j) {
			dp[i][j] = min(dp[i][j],dp[i-1][j]);
			dp[i][j|keys[i].locks] = min(dp[i][j|keys[i].locks],dp[i-1][j] + keys[i].cost);
		}
	}
	if(dp[m][lim] != inf) {
		cout<<dp[m][lim]<<endl;
	}else{
		cout<<-1<<endl;
	}
}

Measured memory_bytes: 19840
#include<stdio.h>

int main()
{
    int a,b,c,temp;

    scanf("%d %d %d", &a, &b, &c);

    temp = a;
    a = b;
    b = temp;

    temp = a;
    a = c;
    c = temp;

    printf("%d %d %d", a, b, c);

    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <bits/stdc++.h>
#include <math.h>

using namespace std;

int main(void){
    int n,m,c;
    cin>>n>>m>>c;
    vector<int> b(m);
    for(int i=0;i<m;i++) cin>>b.at(i);
    
    int ans=0;
    
    for(int i=0;i<n;i++){
        
        int sum=0;
        for(int j=0;j<m;j++){
            int hoge;
            cin>>hoge;
            sum+=hoge*b.at(j);
        }
        if(sum+c>0) ans++;
    }
    
    cout<<ans<<endl;
    
    return 0;
}

Measured memory_bytes: 256
A,B,K=(int(i) for i in input().split())
a=B-A+1
if K>=a:
  for i in range(A,B+1):
    print(i)
else:
  L1=list(range(A,A+K))
  L2=list(range(B-K+1,B+1))
  S=list(set(L1+L2))
  S.sort()
  for i in S:
    print(i)

Measured memory_bytes: 3064
/**
 * Author  : dhakad_123
 * Created : 15.08.2020
 **/

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

int total(int i , int d){

	int cnt = 0;
	int k = 1;

	while(k <= d){
		cnt++;
		k += i;
	}

	return  cnt;
}


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


	int N , D , X;
	cin >> N;

	cin >> D >> X;

	vector<int>A(N);

	int ans = 0;


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

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

		ans += total(A[i] ,D);
	}

	cout << ans + X << endl;

	return 0;
}



Measured memory_bytes: 3640
n, m = map(int, input().split())
AC = [0]*n
WA = [0]*n

for i in range(m):
    p, s = map(str, input().split())
    p = int(p)
    p -= 1
    if s == 'AC':
        AC[p] = 1
    else:
        if AC[p] != 1:
            WA[p] += 1

a = 0
w = 0
for i in range(n):
    if AC[i] == 1:
        a += 1
        w += WA[i]
print(a, w)


Measured memory_bytes: 76180
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define show(x) cout << x << '\n'
#define showh(x) cout << x << ' '
#define go(i, a, n) for (ll i = a; i < n; i++)
#define gor(i, a, n) for (ll i = n - 1; i >= a; i--)
#define pb push_back
#define mp make_pair
#define mod 1000000007
auto t1 = chrono::high_resolution_clock::now();
bool prime[1000001];
ll expo(ll a, ll b)
{
  a = a % mod;
  b = b % mod;
  if (b == 0)
    return 1;
  if (b % 2)
    return ((a % mod) * (expo((a * a) % mod, b / 2) % mod)) % mod;
  return expo((a * a) % mod, b >> 1) % mod;
}
ll mul(ll a, ll b)
{
  a = a % mod;
  b = b % mod;
  if (b == 0)
    return 0;
  if (b % 2)
    return ((a % mod) + (mul((a + a) % mod, b >> 1) % mod)) % mod;
  return mul((a + a) % mod, b >> 1) % mod;
}

bool ispoweroftwo(ll x)
{
  return x && !(x & (x - 1));
}
ll xorcal(ll n)
{
  if (n % 4 == 0)
    return n;
  if (n % 4 == 1)
    return 1;
  if (n % 4 == 2)
    return n + 1;
  if (n % 4 == 3)
    return 0;
}
void sieve(ll n)
{
  memset(prime, true, sizeof(prime));
  prime[0] = false;
  prime[1] = false;
  for (ll i = 2; i * i <= n; i++)
  {
    if (prime[i] == true)
    {
      for (ll j = i * i; j <= n; j += i)
        prime[j] = false;
    }
  }
}
bool isprime(ll n)
{
  if (n <= 1)
    return false;
  if (n <= 3)
    return true;

  if (n % 2 == 0 or n % 3 == 0)
    return false;

  for (ll i = 5; i * i <= n; i += 6)
  {
    if (n % i == 0 or n % (i + 2) == 0)
      return false;
  }
  return true;
}

ll modinverse(ll a, ll m)
{
  ll m0 = m;
  ll y = 0, x = 1;

  if (m == 1)
    return 0;

  while (a > 1)
  {
    ll q = a / m;
    ll t = m;

    m = a % m;
    a = t;
    t = y;

    y = x - q * y;
    x = t;
  }

  if (x < 0)
    x += m0;

  return x;
}

ll gcd(ll a, ll b)
{
  if (a == 0)
    return b;
  return (b % a, a);
}
bool ispalindrome(string s)
{
  string t = s;
  reverse(t.begin(), t.end());
  if (t == s)
    return true;
  return false;
}
void binary(ll a[], ll n)
{
  gor(i, 0, 64)
  {
    ll k = n >> i;
    a[i] = k & (ll)1;
  }
}
ll countBits(ll n)
{
  if (n == 0)
    return 0;
  return 1 + countBits(n & (n - 1));
}
bool sorted(vector<ll> &v, ll n)
{
  if (n == 0)
    return true;
  return v[n - 1] >= v[n - 2] and sorted(v, n - 1);
}
ll getsum(vector<ll> &v, ll n)
{
  ll sum = 0;
  go(i, 0, n) sum += v[i];
  if (sum != (n * (n + 1)) / 2)
    return 1;
  return 0;
}
int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  //cout << "Case #" << p << ": " << str << endl;
  ll n, m;
  cin >> n >> m;
  if (n % m == (ll)0)
  {
    show("0");
    exit(0);
  }
  if (n < m)
  {
    show(min(n, abs(n - m)));
    exit(0);
  }
  show((min(n % m, abs(m - (n % m)))));
  auto t2 = chrono::high_resolution_clock::now();
  auto duration = chrono::duration_cast<chrono::milliseconds>(t2 - t1).count();
  clog << "Time taken = " << duration * 1.0 / 1000 << " seconds" << endl;
  return 0;
}

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

#define endl '\n'

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

    long long n,resp=0;
    cin >> n;
    for (long long i=1; i<=n; i++){
        if (i%3 == 0 || i%5 == 0) continue;
        resp+=i;
    }
    cout << resp << endl;
}

Measured memory_bytes: 3656
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
using namespace std;

const int N=3005;
const int MOD=1000000007;

int n,m,f[N][N][2];

void updata(int &x,int y)
{
	x+=y;x-=x>=MOD?MOD:0;
}

int main()
{
	scanf("%d%d",&n,&m);
	f[0][0][1]=1;
	for (int i=1;i<=n;i++) f[0][i][0]=1;
	for (int i=0;i<m;i++)
		for (int j=0;j<=n;j++)
			for (int k=0;k<=1;k++)
			{
				if (j) updata(f[i+1][j-1][k|(j==1)],f[i][j][k]);
				if (j) updata(f[i+1][j][k|(j==1)],f[i][j][k]);
				if (n-j) updata(f[i+1][j+1][k],f[i][j][k]);
				if (n-j) updata(f[i+1][j][k],f[i][j][k]);
			}
	int ans=0;
	for (int i=0;i<=n;i++) updata(ans,f[m][i][1]);
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 70656
/* C - Sum of gcd of Tuples (Easy) */

#include <stdio.h>

int getgcd(int a, int b){
  int r;
  r = a % b;
  if(r == 0) return b;
  else return getgcd(b, r);
}

int gcd(int a, int b, int c){
  return getgcd(getgcd(a, b), c);
}

int main(void){
  int K, a, b, c, sum = 0;
  scanf("%d", &K);
  for(a = 1; a <= K; a++){
    for(b = 1; b <= K; b++){
      for(c = 1; c <= K; c++){
        sum += gcd(a, b, c);
      }
    }
  }
  printf("%d\n", sum);
  return 0;
}


Measured memory_bytes: 1648
from bisect import bisect_right, bisect_left
from itertools import groupby, permutations, combinations
from fractions import gcd
import numpy as np
from sys import stdin, stderr


def lcm(x, y):
    return (x * y) // gcd(x, y)


def main():
    a, b = [int(x) for x in input().split()]
    if a > b:
        a, b = b, a
    ret = str(a) * b
    return ret


if __name__ == "__main__":
    print(main())

Measured memory_bytes: 23080
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define pb push_back
#define mp make_pair
#define fast ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
#define ff first
#define ss second
#define INF (ll) (1e9)
#define mod (ll) (1e9 + 7)
#define endl "\n"
#define tt ll testcase; cin>>testcase; while(testcase--)
 
const int mxn = 1*(1e5) + 5;
ll n, m;
 
void solve(){
	cin >> n >> m;
	ll a[n];
	bool v[m+1] = {};
	for(int i=0; i<n; i++) {
		cin >> a[i];
		v[a[i]] = 1;
	}
	for(int i=0; i<=m; i++) {
		bool win = true;
		for(int j=n-1; j>=0; j--) {
			if((!v[i-a[j]]) && (i-a[j] >= 0)) {
				win = false;
				break;
			}
		}
		if(!win) {
			v[i] = 1;
		}
	}
	// for(int i=0; i<=m; i++) {
	// 	cout << v[i];
	// }
	if(v[m]) {
		cout << "First\n";
	} else {
		cout << "Second\n";
	}
}

int main(){
	fast;
	#ifndef ONLINE_JUDGE 
   freopen("input.txt", "r", stdin); 
   freopen("output.txt", "w", stdout); 
   #endif 
   
	// tt
		solve();
	return 0;
}

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

int main() {
  string s;
  cin >> s;
  int N = s.size();
  N = (N + 1) / 2;
  for(int i = 1;i < N + 1;i++){
    cout << s.at(i * 2 - 2);
  }
  cout << endl;
}

Measured memory_bytes: 512
#include <iostream>
#include<queue>
#include<stack>
#include<vector>
#include<set>
#include<map>
#include<algorithm>
#include<cstring>
#include<string>
#include<cassert>
#include<cmath>
#include<climits>
#include<iomanip>
#include<bitset>
#include<unordered_map>

using namespace std;

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define rep(i,j,n) for(ll (i)=(j);(i)<(n);(i)++)
#define FOR(i,c) for(decltype((c).begin())i=(c).begin();i!=(c).end();++i)
#define ll long long
#define ull unsigned long long
#define all(hoge) (hoge).begin(),(hoge).end()
typedef pair<ll, ll> P;
const long long INF = 1LL << 60;
const long long MOD = 1e9 + 7;
typedef vector<ll> Array;
typedef vector<Array> Matrix;


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

//グラフ関連
struct Edge {//グラフ
	ll to, cap, rev;
	Edge(ll _to, ll _cap, ll _rev) {
		to = _to; cap = _cap; rev = _rev;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

void add_edge(Graph& G, ll from, ll to, ll cap, bool revFlag, ll revCap) {
	G[from].push_back(Edge(to, cap, (ll)G[to].size()));
	if (revFlag)G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}


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

	ll n, t;
	cin >> n >> t;
	vector<P> ab(n);
	REP(i, n) cin >> ab[i].first >> ab[i].second;

	sort(all(ab));

	Matrix dp(n + 1, Array(t + 1, -1));

	dp[0][0] = 0;
	REP(i, n) {
		
		REP(j, t) {
			if (dp[i][j] != -1) {
				chmax(dp[i + 1][j],dp[i][j]);
				if (j + ab[i].first < t) {
					chmax(dp[i + 1][j + ab[i].first], dp[i][j] + ab[i].second);
				}
				else {
					chmax(dp[i + 1][t], dp[i][j] + ab[i].second);
				}
			}
		}

		if (dp[i][t] != -1) {
			chmax(dp[i + 1][t], dp[i][t]);
		}
	}

	ll ans = 0;
	REP(i, t + 1) {
		chmax(ans, dp[n][i]);
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 70784
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <string>
#include <cmath>
using namespace std;
#define MOD 1000000007
#define MAX 510000
#define INF 1<<30
#define LINF (ll)1<<62
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> P;
typedef vector<pair<ll, ll>> vpl;

int main(){
    ll a,b,c; cin >> a >> b >> c;
    if(a == max({a,b,c})){
        cout << a*10+b+c << endl;
    }else if(b == max({a,b,c})){
        cout << b*10+a+c << endl;
    }else{
        cout << c*10+b+a << endl;
    }
}

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

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

using namespace std;

int main() {

    cin.tie(0);
    ios::sync_with_stdio(false);

    map<string, int> score;

    int N;
    cin >> N;
    REP(_, N) {
        string s;
        cin >> s;
        ++score[s];
    }
    int M;
    cin >> M;
    REP(_, M) {
        string t;
        cin >> t;
        --score[t];
    }

    int max_score = 0;
    for (const auto &[_, v]: score) {
        max_score = max(max_score, v);
    }

    cout << max_score << endl;

    return 0;
}


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

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

  vector<int> sum(n);
  sum[0] = 0;
  for(int i=1; i<n; ++i){
    if(s.substr(i-1, 2) == "AC"s) sum[i] = sum[i-1] + 1;
    else sum[i] = sum[i-1];
  }

  while(q--){
    int l, r, ans = 0; cin >> l >> r;

    ans = sum[r-1] - sum[l-1];

    cout << ans << endl;
  }
}


Measured memory_bytes: 1408
#include <iostream>
#include <string>
#include <vector>
#include <queue>
using namespace std;
using ll = long long;

// 座標 corrdinate と深さを保持するための構造体
struct Corr {
    ll y;
    ll x;
    ll depth;
};

ll N, M;  // 迷路の縦，横
ll s_y, s_x, g_y, g_x;  // スタート，ゴールの座標
ll y, x, depth;  // キューから取り出した座標
vector<string> vec;  // 座標を受け取る配列
queue<Corr> q;

vector<ll> y_vec = {0, 0, -1, +1};  // 進む方向の簡便化，テクニックとして覚えておく．
vector<ll> x_vec = {-1, +1, 0, 0};  // ループで回すことで上下左右に移動できるようになっている

bool goal = false;

ll bfs() {
    while (!q.empty()) {
        Corr now = q.front(); q.pop();  // キューの先頭を取り出す
        y = now.y, x = now.x, depth = now.depth;  // 行，列が y, x になっているので注意

        // 停止条件：現在の座標がゴールなら深さを返す
        if (y == g_y && x == g_x) {
            goal = true;
            return depth;
        }

        // 上下左右 4 方向を探索．進むことができればキューに格納する．
        for (ll i = 0; i < 4; ++i) {
            Corr next = {y + y_vec[i], x + x_vec[i], depth + 1};
            if (0 <= next.y && next.y <= N-1 && 0 <= next.x && next.x <= M-1 && vec[next.y][next.x] == '.') {
                vec[next.y][next.x] = 'x';  // 同じ場所を探索しないようにする
                q.push(next);
            }
        }
    }
    return 0;
}

ll count () {
    ll num = 0;
    for ( int i = 0; i < N; ++i){
        for ( int j = 0; j < M; ++j){
            if ( vec[i][j] == '#' ) ++ num;
        }
    }
    return num;
}

int main() {
    // input
    cin >> N >> M;
    s_y = 0; s_x = 0; g_y = N-1; g_x = M-1;
    vec.resize(N); for (ll i = 0; i < N; ++i) cin >> vec[i];

    ll num = count();
    
    // calculation
    Corr start = {s_y, s_x, 0};  // 初期位置の深さ(depth)は 0
    q.emplace(start);  // 初期位置をキューに格納

    ll dis = bfs();
    ll ans = N * M - dis - num - 1;
    if ( goal ){
        cout << ans << endl;
    } else {
        cout << -1 << endl;
    }

    return 0;
}


Measured memory_bytes: 3584
#include<iostream>
#include<vector>
#include<queue>
#include<utility>
#include<climits>
#include<algorithm>
using namespace std;
typedef int Cost;
typedef int Node;

void dijkstra(int start,   vector<vector< pair<Node,Cost> > > m){
  vector<Cost> costs(m.size());
  bool visited[m.size()];

  fill(costs.begin(),costs.end(),INT_MAX);
  fill(visited,visited+m.size(),false);
  
  priority_queue<pair<Cost,Node> ,vector<pair<Cost,Node> >, greater<pair<Cost,Node> > > q;
  q.push(make_pair(0,start));
  while(!q.empty()){
    Cost c = q.top().first;
    Node n = q.top().second;
    q.pop();
    if(!visited[n]){
      costs[n] = c;
      for(auto &x:m[n]){
        int node = x.first;
        int cost = x.second;
        q.push(make_pair(cost+c,node));
      }
      visited[n] = true;
    }
  }
  for(int i = 0;i < costs.size();i++){
    cout << i << ' ' << costs[i] << endl;
  }
}

int main(){
  int n;
  cin >> n;
  vector<vector< pair<Node,Cost> > > m(n);
  
  for(int i = 0;i < n;i++){
    int u,k;
    cin >> u >> k;
    for(int j = 0;j < k;j++){
      int v,c;
      cin >> v >> c;
      m[u].push_back(make_pair(v,c));
    }
  }
  dijkstra(0,m);
}

Measured memory_bytes: 1392
#include "bits/stdc++.h"
#ifndef err
#define err(...)(void)0
#endif
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define CAT(a,b)a b
#define VASIZE(a,b,N,...)N
template<class T>auto size(T&&a)->decltype(a.size(), int()) { return a.size(); }
template<class T>typename make_signed<decltype(T() % 0)>::type size(T a) { return a; }
#define REP(t,a,N)for(decltype(size(N))t=size(a),_l##t=size(N);t<_l##t;t++)
#define RREP(t,a,N)for(decltype(size(N))t=size(N)-1,_l##t=size(a);t>=_l##t;t--)
#define rep(t,...)CAT(REP,VASIZE(__VA_ARGS__,(t,__VA_ARGS__),(t,0,__VA_ARGS__)))
#define rrep(t,...)CAT(RREP,VASIZE(__VA_ARGS__,(t,__VA_ARGS__),(t,0,__VA_ARGS__)))
#define all(a)begin(a),end(a)

void Calc();
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0); cin.exceptions(istream::failbit | istream::badbit);
  cout << fixed << setprecision(15); Calc(); cout.flush(); return 0;
}
template<class A>void amax(A&a, A b) { a = max(a, b); }
template<class A>void amin(A&a, A b) { a = min(a, b); }
struct Scanner {
  template<class A = string>A Next() { A a; cin >> a; return a; }
  template<class A = int>vector<A>Array(int n) { vector<A>a(n); for (A&i : a) cin >> i; return a; }
  string Line() { string s; getline(cin, s); return s; }
  template<class A>Scanner&operator,(A&a) { a = Next<A>(); return *this; }
  template<class A>operator A() { return Next<A>(); }
}in;

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

void Calc() {
  int n, k, x, y;
  in, n, k, x, y;
  ll ans = 0;
  rep(i, min(k, n))ans += x;
  rep(i, k, n)ans += y;
  cout << (ans) << endl;

}


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

int main(int argc, const char * argv[]) {
    int N;
    cin >> N;
    
    vector<int> A(N);
    for (int i = 0; i < N; i++) cin >> A[i];
    
    sort(A.begin(), A.end());
    cout << A[N - 1] - A[0] << endl;
    
    return 0;
}

Measured memory_bytes: 256
can=[0]
for i in range(1,151):
    can.append(pow(i,5))
    can.append(-pow(i,5))
can.sort()

x=int(input())

end=False
for i in range(len(can)):
    for q in range(len(can)):
        if can[i]-can[q]==x:
            
            print(i-150,q-150)
            end=True
            break
    if end:
        break
else:
    raise ValueError("xx")



Measured memory_bytes: 9200
while 1:
    try:
        number=[1,2,3,4,5,6,7,8,9,10]
        C1,C2,C3=map(int,input().split())
        number.remove(C1)
        number.remove(C2)
        number.remove(C3)
        my_sum=C1+C2
        count=0
        for i in number:
            if my_sum+i>20:
                count +=1
        if count/len(number)<0.5:print("YES")
        else:print("NO")
    except:break



Measured memory_bytes: 5608