akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <stack>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define PF push_front
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double
#define pii pair<int,int>
#define pll pair<LL,LL>
#define vi vector<int>
#define vl vector<LL>
#define vii vector<vi>
#define vll vector<vl>

const double pi = 3.14159265358979323846264;
const int mod=1000000007;

int main(){
	int n,m;
    cin>>n>>m;
    if(n==m){
        cout<<"Yes";
    }else{
        cout<<"No";
    }
}


Measured memory_bytes: 256
def rr(): return input().rstrip()
def rri(): return int(rr())
def rrl(): return list(map(int, rr().split()))
def rrt(): return tuple(map(int, rr().split()))
from collections import defaultdict
def mus(d=lambda: 0): return defaultdict(lambda: defaultdict(d))
def dd0(d=lambda: 0): return defaultdict(d)
def ms(x, y, d=0): return [[0]*y for i in range(x)]
def ar(x, d=0): return [d]*x
def ppm(m, n=0, x=0, y=0): print("\n".join(("\t".join((str(m[j][i]) for j in range(y or n))) for i in range(x or n))))
def ppa(a, n): print("\t".join(map(str, a[0:n])))
def ppl(a=0, x=[1]): x[0]=a or (x[0]+1); print("-"+"- -"*14+"-# "+str(x[0]-2)+" #-"+"- -"*14+"-")
def fltn(a): (i for sub in a for i in sub)
def yn(x): return "YES" if x else "NO"
from itertools import accumulate
from itertools import groupby
def grp(x): return ((i, sum(1 for _ in g)) for i, g in groupby(x))
import math
#def rnar(): return (*rrl(), rrl())
#def rn(): return (*rrl(),)
def dpp(a, b=""): print(")#| {} |#(o) ? {} ? (".format(a, b))

def read():
    n = rri()
    l = [rrt() for _ in range(n)]

    return n, l
    return (0,)

def solve(n, l):
    dp0 = ar(n)
    dp1 = ar(n)
    dp2 = ar(n)
    #dpp(l)

    dp0[0] = l[0][0]
    dp1[0] = l[0][1]
    dp2[0] = l[0][2]

    for i in range(1, n):
        dp0[i] = max(dp1[i-1], dp2[i-1]) + l[i][0]
        dp1[i] = max(dp0[i-1], dp2[i-1]) + l[i][1]
        dp2[i] = max(dp1[i-1], dp0[i-1]) + l[i][2]

    #dpp(dp0)
    #dpp(dp1)
    #dpp(dp2)

    ans = max(dp0[-1], dp1[-1], dp2[-1])
    return ans

if __name__ == "__main__":
    #test_count = rri()
    test_count = 1
    for _ in range(test_count):
        input_data = read()
        result = solve(*input_data)
        print(result)


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



int main()
{
	
ll n,L;
cin>>n>>L;
vector<ll>v(n),ans(n-1);
ll sum=0;
for(ll i=0;i<n;i++)
{
	cin>>v[i];
	sum+=v[i];
}

	for(ll f=0,l=n-1,j=0;j<n-1;j++)
	{
		if(v[f]+v[f+1]<v[l]+v[l-1])
		{
			if(sum>=L)
			sum-=v[f];
			else
			{
				cout<<"Impossible";
				return 0;
			}
			ans[j]=f+1;
			f++;
			
			
		}
		else
		{
			if(sum>=L)
			sum-=v[l];
			else
			{
				cout<<"Impossible";
				return 0;
			}
			ans[j]=l;
			l--;
		}
		
	}
	
	cout<<"Possible\n";
	for(auto x:ans)cout<<x<<"\n";
	



}

Measured memory_bytes: 4836
#include "bits/stdc++.h"

using namespace std;

void solve(void)
{
	int a, b;
	cin >> a >> b;
	if (a < 13)
	{
		b >>= 1;
	}
	if (a < 6)
	{
		b = 0;
	}
	cout << b << endl;
}

int main()
{
	solve();
	//cout << "yui(*-v・)yui" << endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();

        for (int i = 0; i < 10e4; i++) {
            int A2 = i * 8/100;
            int B2 = i * 10/100;
            if (A2==A && B2==B) {
                System.out.println(i);
                System.exit(0);
            }
        }

        System.out.println("-1");
    }
}


Measured memory_bytes: 23636
N,K = map(int,(input().split()))
flg=0
first_mod=0
while(flg==0):

  if(first_mod==0):
    N=N%K
    first_mod=1
    
  new_N=abs(N-K)

  if(new_N>N):
    flg=1
  else:
    N=new_N
print(N)

Measured memory_bytes: 9180
#include<iostream>
#include<iomanip>
#include<vector>
#include<map>
#include<set>
#include<algorithm>
#include<numeric>
#include<limits>
#include<bitset>
#include<functional>
#include<type_traits>
#include<queue>
#include<stack>
#include<array>
#include<random>
#include<utility>
#include<cstdlib>
#include<ctime>

using namespace std;

typedef  long long ll;
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;}

#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep2(i, begin_i, end_i) for (int i = (int)begin_i; i < (int)end_i; i++)

long long INF = 1LL<<60;
long long dp[100010];
int h[100010];
int n=0;
int main(){
    cin>>n;
    vector<int> c(n),s(n),f(n);
    rep(i,n)cin>>c.at(i)>>s.at(i)>>f.at(i);
    for(int i=0;i<n;i++){
        int t=0;
        for(int j=i;j<n-1;j++){
            if(t<s.at(j))t=s.at(j);
            else if(t%f.at(j)==0);
            else t=t+f.at(j)-t%f.at(j);
            t+=c.at(j);
        }
        printf("%d\n",t);
    }
    return 0;
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
string to_string(const string& s) {
	return '"' + s + '"';
}
string to_string(const bool b) {
	return (b ? "true" : "false");
}
string to_string(const char* s) {
	return to_string((string)s);
}
string to_string(const char c) {
	string s = "'";
	s += c;
	s += "'";
	return s;
}
template<class T, class U>
string to_string(const pair<T, U>& p) {
	string s = "(";
	s += to_string(p.first);
	s += ", ";
	s += to_string(p.second);
	s += ")";
	return s;
}
template<class T>
string to_string(const T& a) {
	bool first = true;
	string s = "{";
	for (const auto& x : a) {
		if(!first){
			s += ", ";
		}
		first = false;
		s += to_string(x);
	}
	s += "}";
	return s;
}
void debug_out() {cerr << '\n';}
template<class Head, class... Tail>
void debug_out(Head head, Tail... tail) {
	cerr << ' ' << to_string(head);
	debug_out(tail...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "] = ", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif
using ll = long long;
using ld = long double;
const int mod = 1e9 + 7;
const int inf = 1e9 + 100;
const ll inf64 = 7e18l;
void min_self(int& a, int b) {
	a = min(a, b);
}
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(20);
	string s;
	cin >> s;
	int sum = 0;
	for (char c : s) {
		sum += c - '0';
	}
	int n = s.size();
	int answer = 0;
	vector<vector<int>> dp(n, vector<int>(2, inf));
	dp[n - 1][0] = s[n - 1] - '0';
	dp[n - 1][1] = 10 - (s[n - 1] - '0');
	for (int i = n - 2; i >= 0; --i) {
		int cur = s[i] - '0';
		min_self(dp[i][1], dp[i + 1][1] + 9 - cur);
		min_self(dp[i][0], dp[i + 1][1] + cur + 1);
		min_self(dp[i][1], dp[i + 1][0] + 10 - cur);
		min_self(dp[i][0], dp[i + 1][0] + cur);
	}
	answer = min(dp[0][0], dp[0][1] + 1);
	cout << answer << '\n';
	
 	return 0;
}


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

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		
		int [] h = new int [n];
		
		for (int i=0; i<n; i++) 
			h[i] = sc.nextInt();
		
		int [] dp = new int [n];
		Arrays.fill(dp, Integer.MAX_VALUE);
		
		dp[0] = 0;
		
		for (int a=0; a<n; a++) {
			if (a+1<n)
				dp[a+1] = Math.min(dp[a+1], dp[a] + Math.abs(h[a+1]-h[a]));
			if (a+2<n)
				dp[a+2] = Math.min(dp[a+2], dp[a] + Math.abs(h[a+2]-h[a]));
		}
		
		System.out.println(dp[n-1]);
	}

}

Measured memory_bytes: 50852
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define debug(a) cerr << #a << ": " << a << endl
#define sz(a) int(a.size())
#define rep(i,n) for(int i=0;i<n;i++)
#define forr(i, st, en) for(int i = st; i <= en; i++)
#define all(v) (v).begin(),(v).end()
#define X first
#define Y second
#define fast cin.tie(0); ios::sync_with_stdio(false)
#define vi vector<int>
#define vii vector<vector<int>>

int32_t main(){ fast;
	vector<int> a(5);
	rep(i, 5){
		cin>>a[i];
	}
	sort(all(a));
	rep(i, 6){
		if(a[i] != i){
			cout<<i;
			return 0;
		}
	}
}


Measured memory_bytes: 3616
H, W = map(int, input().split())
ctr = [0] * 26
for _ in range(H):
    s = str(input())
    for a in s:
        ctr[ord(a) - 97] += 1

# print(ctr)

def count(ctr):
    odd = 0
    two = 0
    four = 0
    for n in ctr:
        if n == 0: continue
        if n % 2 == 1: odd += 1
        elif n % 4 == 0: four += 1
        elif n % 2 == 0: 
            two += 1
            if n >= 4:
                four += 1
    return odd, two, four  

def f():
    odd, two, four = count(ctr)
    # print(odd, two, four)
    if (H * W) % 2 == 1:
        if odd > 1: return False
        if two > (H - 1) // 2 + (W - 1) // 2: return False
        return True
    if H % 2 == 0 and W % 2 == 0:
        if odd > 0 or two > 0: return False
        return True
    else:
        if odd > 0: return False
        if H % 2 == 1:
            tmp = W
        else:
            tmp = H
        if two > tmp // 2: return False
        return True

if f():
    print("Yes")
else:
    print("No")

Measured memory_bytes: 38640
#ifndef BZ
#pragma GCC optimize "-O3"
#endif
#include <bits/stdc++.h>

#define FASTIO
#define ALL(v) (v).begin(), (v).end()
#define rep(i, l, r) for (int i = (l); i < (r); ++i)

#ifdef FASTIO
#define scanf abacaba
#define printf abacaba
#endif

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

using namespace std;


/*
ll pw(ll a, ll b) {
	ll ans = 1; while (b) {
		while (!(b & 1)) b >>= 1, a = (a * a) % MOD;
		ans = (ans * a) % MOD, --b;
	} return ans;
}
*/

int dd[12][12];

vector<tuple<int, int, int> > vv;

int en[12][12];

int main() {
#ifdef FASTIO
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
#endif
	int a, b;
	cin >> a >> b;
	for (int i = 1; i <= a; ++i)
		for (int j = 1; j <= b; ++j)
			cin >> dd[i][j];
	for (int k = 0; k <= 100; ++k)
		for (int x = 0; x + k <= 100; ++x)
			for (int y = 0; x + y + k <= 100; ++y) {
				int fl = 0;
				for (int i = 1; i <= a; ++i)
					for (int j = 1; j <= b; ++j) {
						if (i * x + j * y + k < dd[i][j])
							fl = 1;
					}
				if (fl)
					continue;
				for (int i = 1; i <= a; ++i)
					for (int j = 1; j <= b; ++j) {
						if (!en[i][j] && i * x + j * y + k == dd[i][j])
							en[i][j] = 1, fl = 1;
					}
				if (fl)
					vv.emplace_back(k, x, y);
			}
	for (int i = 1; i <= a; ++i)
		for (int j = 1; j <= b; ++j) {
			if (!en[i][j]) {
				cout << "Impossible\n";
				return 0;
			}
		}
	cout << "Possible\n";
	int n = 202;
	vector<tuple<int, int, string>> ed;
	for (int i = 1; i <= 100; ++i)
		ed.emplace_back(i, i + 1, "X");
	for (int i = 102; i < 202; ++i)
		ed.emplace_back(i, i + 1, "Y");
	for (auto e: vv) {
		int k, x, y;
		tie(k, x, y) = e;
		ed.emplace_back(1 + x, 202 - y, to_string(k));
	}
	cout << n << " " << ed.size() << "\n";
	for (auto e: ed) {
		cout << get<0>(e) << " " << get<1>(e) << " " << get<2>(e) << "\n";
	}
	cout << 1 << " " << 202 << "\n";
	return 0;
}




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

int main(){
  int n;
  cin >> n;
  int d = 0;
  if(1 <= n && n <= 9){
    cout << "Yes" << endl;
    d++;
  }
  else{
    for(int i=1; i<10; i++){
      if(!(n%i)){
        if(1 <= n/i && n/i <= 9){
          cout << "Yes" << endl;
          d++;
          break;
        }
      }
    }
  }
  if(!d){
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
from collections import deque
N = int(input())
ans = 0
A = "357"
Q = deque(["3","5","7"])
while Q:
    q = Q.pop()
    x = int(q)
    if x>N:continue
    if len(set(q))==3:ans+=1
    for a in A:
        Q.append(q+a)
print(ans)

Measured memory_bytes: 3436
#include<bits/stdc++.h>
using namespace std;
const int maxn=5e5+10;
char laz[maxn];
int pi[16*maxn];
bool prefix_function(const string &s,const string &t) {
    ///search t on s
    int m=(int)t.length();
    string ss=t+'#'+s;
    int n = (int)ss.length();
    pi[0]=0;
    for (int i = 1; i < n; i++) {
        int j = pi[i-1];
        while (j > 0 && ss[i] != ss[j])
            j = pi[j-1];
        if (ss[i] == ss[j])
            j++;
        pi[i] = j;
        if(pi[i]==m&&i>m){
            return true;
        }
    }
    return false;
}
string s,t,a,ss,tt;
/**
There exists a non-negative integer j
such that the concatenation of i copies of t
is a substring of the concatenation of j copies of s.
*/


int main(){
    scanf("%s",laz);
    ss=string(laz);
    scanf("%s",laz);
    t=string(laz);
    s=ss;
    while((int)s.length()<=(int)t.length()+(int)ss.length()){
        s+=ss;
    }
    s+=ss;
    int l=1,r=((int)s.length())/((int)t.length()),mid,c=-1;
    while(l<=r){
        mid=(l+r)>>1;
        a=t;
        for(int i=1;i<mid;i++){
            a+=t;
        }
        if(prefix_function(s,a)){
            c=mid;
            l=mid+1;
        }
        else{
            r=mid-1;
        }
    }
    if(c==-1){
       return !printf("0");
    }
    s+=s;
    l=1,r=((int)s.length())/((int)t.length());
    int cc=-1;
    while(l<=r){
        mid=(l+r)>>1;
        a=t;
        for(int i=1;i<mid;i++){
            a+=t;
        }
        if(prefix_function(s,a)){
            cc=mid;
            l=mid+1;
        }
        else{
            r=mid-1;
        }
    }
    if(cc==c){
        return !printf("%d\n",cc);
    }
    else{
        return !printf("-1");
    }
}
/*
    Good Luck
        -Lci70121
*/


Measured memory_bytes: 55484
/*
--> WHEN IT'S OBVIOUS THAT THE GOAL CANNOT BE REACHED,
	DON'T ADJUST THE GOALS,
	ADJUST THE ACTION STEPS.

--> THE WAY YOU CONQUER SELF-DOUBT IS BY DOING THINGS THAT MAKE YOU UNCOMFORTABLE.

--> IT IS DURING OUR DARKEST MOMENTS WE MUST FOCUS TO SEE LIGHT.
*/

#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <cstring>
#include <climits>
using namespace std;
#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define sortAll(x) sort(all(x))
#define sz(x) (int)x.size()
#define clr(x) memset(x, 0, sizeof(x))
#define PI 3.1415926535897932384626
#define FAST ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
typedef long long ll;
typedef pair< int, int >	pii;
typedef pair< ll, ll >		pl;
typedef vector< int >		vi;
typedef vector< ll >		vl;
typedef vector< pii >		vpii;
typedef vector< pl >		vpl;
typedef vector< vi >		vvi;
typedef vector< vl >		vvl;

const int MOD = 1e9 + 7;

ll power(ll a, ll b)
{
	ll ans = 1;

	while (b > 0)
	{
		if (b & 1)
			ans *= a;
		a = a * a;
		b >>= 1;
	}
	return ans;
}

ll powm(ll a, ll b)
{
	a %= MOD;
	ll ans = 1;

	while (b > 0)
	{
		if (b & 1)
			ans = (ans * a) % MOD;
		a = (a * a) % MOD;
		b >>= 1;
	}
	return ans;
}

//================================

int main()
{
	FAST;

	int n, x, y;
	cin >> n >> x >> y;

	int A[n + 1], vis[n + 1][n + 1] = {0};
	clr(A);
	for (int i = 1; i <= n; i++)
	{
		for (int j = 1; j <= n; j++)
		{
			if (vis[i][j] || vis[j][i])
				continue;

			vis[i][j] = 1;
			int mn = min(abs(j - i), min(abs(x - i) + abs(y - j) + 1, abs(y - i) + abs(x - j) + 1));
			// cout << mn << " ";
			A[mn]++;
		}
	}

	for (int i = 1; i < n; i++)
		cout << A[i] << "\n";
	return 0;
}

Measured memory_bytes: 15872
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const ll mod = 1e9 + 7;
const int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};

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

  rep(i,s.size()) {
    if (s[i] == '?') {
      if (i-1 >= 0 && i+1 < s.size()) {
        if (s[i-1] == 'P') s.replace(i,1,"D");
        else if (s[i+1] == 'D' || s[i+1] == '?') s.replace(i,1,"P");
        else s.replace(i,1,"D");
      } else if (i-1 < 0) {
        if (s[i+1] == 'D') s.replace(i,1,"P");
        else s.replace(i,1,"D");
      } else {
        s.replace(i,1,"D");
      }
    }
  }

  cout << s << endl;

  return 0;
}


Measured memory_bytes: 3756
#include <iostream>
#include <cstdio>
#include <vector>
using namespace std;

const int maxn = int(1e5)+5;

int cnt[maxn];

int main(void)
{
	int n, c;
	scanf("%d", &n);
	for(int i = 0;i < n;i++)
	{
		scanf("%d", &c);
		cnt[c+1]++;
	}

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

Measured memory_bytes: 640
#include <stdio.h>

int main() {
    int i, j, N, mod = 1000000007;
    long long int ans, sum;
    sum = ans = 0;
    
    scanf("%d", &N);
    long long int A[N];

    for(i=0; i < N; i++) {
        scanf("%lld", &A[i]);
        sum+= A[i];
        sum%= mod;
    }

    for(i=0; i < N; i++) {
        sum -= A[i];
        if(sum < 0) sum+= mod;
        ans += A[i] * sum;
        ans %= mod;
    }

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

Measured memory_bytes: 3204
/*
 *Author : zsenshi
 DP 
 */
#include <bits/stdc++.h> //Only for gcc compilers
#define mt make_tuple
#define eb emplace_back
#define pb push_back
#define dg(x) cout << #x << ":"<<x<<endl
#define dg2(x,y) cout<<#x<<':'<<x<<' '<<#y<<':'<<y<<endl
#define dg3(x,y,z) cout<<#x<<':'<<x<<' '<<#y<<':'<<y<<' '<<#z<<':'<<z<<endl
#define dg4(x,y,z,zz) cout<<#x<<':'<<x<<' '<<#y<<':'<<y<<' '<<#z<<':'<<z<<' '<<#zz<<':'<<zz<<endl
#define rep(i,begin,end) for(__typeof(end) i = (begin)-((begin) > (end)); i != (end) - ((begin) > (end)); i += 1-2*((begin) > (end)))
using namespace std;
typedef long long ll;
typedef vector<vector<int>> vvi;
typedef pair<int,int> pii;
typedef vector<pii> vii;
typedef vector<int> vi;
typedef vector<vector<pii>> vvpi;

int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  cin >> n;
  ll W;
  cin >> W;
  vector<vector<ll>> dp(W+1,vector<ll>(n+1,0));
  vector<pair<ll,ll>> item(n);
  for(int i = 0; i < n; ++i){
    cin >> item[i].first >> item[i].second;
  }
  for(int i = 0; i <= W; ++i){
    for(int j = 0; j <= n; ++j){
      ll w = item[j].first, v = item[j].second;
      if(j + 1 <= n){
        if(i + w <= W){
            dp[i+w][j+1] = max(dp[i+w][j+1],dp[i][j] + v);
          }
          dp[i][j+1] = max(dp[i][j+1],dp[i][j]); 
        }
      }
    }
  cout << dp[W][n];
}


Measured memory_bytes: 82304
import sys
sys.setrecursionlimit(200000)


N = int(input())
S = input()
S = list(S)


indices_black = list()
for i, c in enumerate(S):
    if c == '#':
        indices_black.append(i)

count_white = dict()
count = 0
for i, c in enumerate(S[::-1]):
    if c == '.':
        count += 1
    count_white[N - i - 1] = count


def get_answer(S):
    # most left
    if len(indices_black) == 0:
        return 0

    idx = indices_black.pop(0)
    if count_white[idx] == 0:
        return 0
    # count white: turn all white -> black
    ans_w = count_white[idx]

    # turn most left black -> white
    S[idx] = '.'
    ans_b = get_answer(S) + 1
    return min(ans_w, ans_b)


print(get_answer(S))

Measured memory_bytes: 112740
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,x,t;
    cin>>n>>x>>t;
    int p=n/x;
    int l=n%x;
    if(l==0)
    {
        cout<<t*p;
    }
    else{
        cout<<t*(p+1);
    }
}


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

int main(){
  int64_t a,b,ans1,ans2;
  cin >> a >> b;
 
  rep(i,1001){
    ans1 = i*8/100;
    ans2 = i/10;
  if((ans1 == a)&&(ans2 == b)){
    cout << i;
    return 0;
  }
  }
  cout << -1;
}


Measured memory_bytes: 256
// ＡＢＣのＡ過去問を解くだけだよ

// フォント:Electroharmonix
// x:小文字(ｘ)    X:大文字(Ｘ)
// +:プラス(＋)    &:アンド(＆)

#include <bits/stdc++.h>

using namespace std;

void Main()
{
    int K;
    cin >> K;

    int odd = K % 2 == 0 ? K / 2 : K / 2 + 1;
    int even = K / 2;

    //cout << "odd :" << odd << endl;
    //cout << "even:" << even << endl;

    int ret = odd * even;

    cout << ret;
}

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

    //std::cout << std::fixed << std::setprecision(10);

#ifdef DEBUG_BUILD
    while (true)
    {
        Main();
        cout << std::endl;
    }
#endif

    Main();
    cout << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int64_t MOD = 1000000007;

int main()
{
  int64_t N, ans = 0;
  cin >> N;
  vector<int64_t> A(N), S(N + 1, 0); // S.at(r) - S.at(l); [l, r)
  for (int i = 0; i < N; i++)
  {
    cin >> A.at(i);
    S.at(i + 1) = (S.at(i) + A.at(i)) % MOD;
  }
  for (int i = 0; i < N; i++)
  {
    ans += (A.at(i) * ((S.at(N) - S.at(i + 1) + MOD) % MOD)) % MOD;
    ans %= MOD;
  }
  cout << ans << endl;
}

Measured memory_bytes: 6420
#include <bits/stdc++.h>
 
using namespace std;
 
string s[10001], smin[10001], smax[10001], target;
int strict, pos, n;
 
int main(){
    cin>>n;
    for(int i=0; i<n; i++){
        cin>>s[i];
        smin[i]=s[i];
        smax[i]=s[i];
        for(int j=0; j<s[i].size(); j++){
            if(s[i][j]=='?')smin[i][j]='a';
            if(s[i][j]=='?')smax[i][j]='z';
        }
    }
    cin>>target;
    for(int i=0; i<n; i++){
        if(smin[i]<=target && target<=smax[i]){
            pos++;
        }
        if(smax[i]<target){
            strict++;
        }
    }
    for(int i=0; i<=pos; i++){
        cout<<strict+i+1;
if(i<pos) cout<<' ';
    }
    cout << endl;
}

Measured memory_bytes: 1920
#include <bits/stdc++.h>
using namespace std;
int N, E, W, S;
char s[1000 + 100];
int main()
{
#ifdef hk_cnyali
	freopen("A.in", "r", stdin);
	freopen("A.out", "w", stdout);
#endif
	scanf("%s", s);
	for (int i = 0; i < strlen(s); ++i)
	{
		if (s[i] == 'N') N = 1;
		if (s[i] == 'E') E = 1;
		if (s[i] == 'W') W = 1;
		if (s[i] == 'S') S = 1;
	}
	if ((N && !S) || (!N && S) || (E && !W) || (!E && W)) cout<<"No"<<endl;
	else cout<<"Yes"<<endl;
	return 0;
}

Measured memory_bytes: 256
from collections import Counter
n = int(input())
a = list(map(int, input().split()))

c = dict(Counter(a))
dp_on = {}
dp_off = {}
for k, v in c.items():
    if v == 1:
        dp_on[k] = 0
        dp_off[k] = 0
    elif v == 2:
        dp_on[k] = 1
        dp_off[k] = 0
    else:
        dp_on[k] = int(v*(v-1)/2)
        dp_off[k] = int((v-1)*(v-2)/2)
comb_sum = sum([v for v in dp_on.values()])
for i in range(n):
    print(comb_sum - dp_on[a[i]] + dp_off[a[i]])


Measured memory_bytes: 40112
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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; }

void _main() {
  int N;
  cin >> N;

  int digit_num = N % 10;
  N /= 10;
  rep(i, 0, 2) {
    digit_num  = (N%10 < digit_num) ? N%10 + 1 : N%10;
    N /= 10;
  }
  int ans = digit_num*100 + digit_num*10 + digit_num;
  cout << ans << "\n";
}

Measured memory_bytes: 256
# input
N, M = map(int, input().split())
Cake = [list(map(int, input().split())) for i in range(N)]

Cake_sum = [0 for i in range(N)]

# sum(x_i), sum(y_i), sum(z_i)の正負で8通りに場合分け
# x_i >= 0, y_i >= 0, z_i >= 0
ans1 =  0
for i in range(N):
    Cake_sum[i] = Cake[i][0] + Cake[i][1] + Cake[i][2]

Cake_sum_sorted = sorted(Cake_sum, reverse = True) 

for j in range(M):
    ans1 += Cake_sum_sorted[j]

ans2 = 0
# x_i < 0, y_i >= 0, z_i >= 0
for i in range(N):
    Cake_sum[i] = -Cake[i][0] + Cake[i][1] + Cake[i][2]

Cake_sum_sorted = sorted(Cake_sum, reverse = True) 

for j in range(M):
    ans2 += Cake_sum_sorted[j]

ans3 = 0
# x_i >= 0, y_i < 0, z_i >= 0
for i in range(N):
    Cake_sum[i] = Cake[i][0] - Cake[i][1] + Cake[i][2]

Cake_sum_sorted = sorted(Cake_sum, reverse = True) 

for j in range(M):
    ans3 += Cake_sum_sorted[j]

ans4 = 0
# x_i >= 0, y_i >= 0, z_i < 0
for i in range(N):
    Cake_sum[i] = Cake[i][0] + Cake[i][1] - Cake[i][2]

Cake_sum_sorted = sorted(Cake_sum, reverse = True) 

for j in range(M):
    ans4 += Cake_sum_sorted[j]

ans5 = 0
# x_i < 0, y_i < 0, z_i >= 0
for i in range(N):
    Cake_sum[i] = -Cake[i][0] - Cake[i][1] + Cake[i][2]

Cake_sum_sorted = sorted(Cake_sum, reverse = True) 

for j in range(M):
    ans5 += Cake_sum_sorted[j]

ans6 = 0
# x_i >= 0, y_i < 0, z_i < 0
for i in range(N):
    Cake_sum[i] = Cake[i][0] - Cake[i][1] - Cake[i][2]

Cake_sum_sorted = sorted(Cake_sum, reverse = True) 

for j in range(M):
    ans6 += Cake_sum_sorted[j]

ans7 = 0
# x_i < 0, y_i >= 0, z_i < 0
for i in range(N):
    Cake_sum[i] = -Cake[i][0] + Cake[i][1] - Cake[i][2]

Cake_sum_sorted = sorted(Cake_sum, reverse = True) 

for j in range(M):
    ans7 += Cake_sum_sorted[j]

ans8 = 0
# x_i < 0, y_i < 0, z_i < 0
for i in range(N):
    Cake_sum[i] = -Cake[i][0] - Cake[i][1] - Cake[i][2]

Cake_sum_sorted = sorted(Cake_sum, reverse = True) 

for j in range(M):
    ans8 += Cake_sum_sorted[j]

ans = max(ans1, ans2, ans3, ans4, ans5, ans6, ans7, ans8)

print(ans)

Measured memory_bytes: 3316
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <map>
#include <iomanip>
#include <limits>
#include <utility>
#include <bitset>
#include <sstream>
#define ll long long
#define lint long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
#define INF 1e9

int main()
{

    int P,Q,R;
    cin >> P>>Q>>R;

    vector<int> a(3);
    a[0] = P;
    a[1] = Q;
    a[2] = R;

    
    int ans = 0;

    int m = -INF;
    rep(i,3){
        
        ans += a[i];
        m = max(m,a[i]);
    }

    ans -= m;


    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;
using msi = map<string, int>;
using mii = map<int, int>;
using psi = pair<string, int>;
using pii = pair<int, int>;
using vlai = valarray<int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF 1E9
#define EPS 1E-9
#define MOD (ll)(1E9+7)
#define PI 3.1415926535897932384

template <class T>ostream &operator<<(std::ostream &o, const vector<T> &v)
{
	rep(i, v.size()) {
		o << (i > 0 ? " " : "") << v[i];
	}
	return o;
}

int main() {
	int h, w;
	int dx[8] = {-1,0,1,-1,1,-1,0,1};
	int dy[8] = {-1,-1,-1,0,0,1,1,1};
	cin >> h >> w;
	vector<string> map(h+2);
	string kabe = "****************************************************";
	map[0] = kabe.substr(0, w + 2);
	map[h+1] = kabe.substr(0, w + 2);
	for (int i = 1; i <= h; i++) {
		cin >> map[i];
		map[i] = '*' + map[i] + '*';
	}
	for (int i = 1; i <= h; i++) {
		for (int j = 1; j <= w; j++) {
			int count = 0;
			if (map[i][j] == '#') {
				cout << map[i][j];
				continue;
			} 
			for (int k = 0; k < 8; k++) {
				if (map[i + dx[k]][j + dy[k]]=='#') {
					count++;
				}
			}
			map[i][j] = count+'0';
			cout << map[i][j];
		}
		cout << endl;
	}
	
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
using namespace std;
int main(int argc, const char * argv[]) {
    int a,b,c,d;
    double e;
    cin >> a >> b;
    c = a/b;
    d =a%b;
    e= 1.0*a/b;
    //printf("%d " "%d,%.5lf\n",c,d,e);
    // insert code here...
   // cout << c <<" " << d << " " ;
    printf("%d",c);
    printf(" ");
    printf("%d",d);
    printf(" ");
    printf("%.8lf\n",e);
    return 0;
}

Measured memory_bytes: 1200
#include <bits/stdc++.h>
#define rep(i,a) for(int i=0;i<int(a);++i)
#define REP(i,a,b) for(int i=int(a);i<int(b);++i)
#define pb push_back
#define mp make_pair
#define F first
#define S second
using ll = long long;
using itn = int;
using namespace std;
using Graph = vector<vector<int>>;
static const long double GRATIO=(long double)(1+sqrt(5))/2;
ll GCD(ll a, ll b){
    return b ? GCD(b, a%b) : a;
}
ll LCM(ll a, ll b){
    return a/GCD(a,b)*b;
}
int main(){
    int N;
    cin>>N;
    vector<int> A(N);
    rep(i,N) cin>>A[i];
    pair<int,int> B[N];
    rep(i,N) B[i]=make_pair(A[i],i+1);
    sort(B,B+N);
    rep(i,N) cout<<B[i].S<<" ";
}

Measured memory_bytes: 2048
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int H, W;
  cin >> H >> W;
  string a;
  for (int i = 0; i < W + 2; i++){
    cout << "#";
  }
  
  cout << endl;
  
  for (int i = 0; i < H; i++){
    cin >> a;
    cout << "#" << a << "#" << endl;
  }
  
  for (int i = 0; i < W + 2; i++){
    cout << "#";
  }
  cout << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define MOD 1000000007
#define INF 1e18

using namespace std;



int main(void){
  ll n, p;
  cin >> n >> p;
  
  ll hoge[2] = {};
  for (int i = 0; i < n; i++){
    ll a;
    cin >> a;
    
    hoge[a % 2]++;
  }

  if (p == 1){
    cout << (1LL << hoge[0]) * (1LL << (hoge[1] - 1)) << endl;
  }
  else {
    if (hoge[1] == 0){
      cout << (1LL << hoge[0]) << endl;
    }
    else {
      cout << (1LL << hoge[0]) * (1LL << (hoge[1] - 1)) << endl;
    }
  }

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i = (a);i < (b);++i)
#define FORR(i, b, a) for (int i = (b) - 1;i >= 0;--i)
#define REP(i, n) for(int i = 0;i < (n);++i)
#define REPR(i, n) for(int i = (n) - 1;i >= 0;--i)
#define ITER(itr, v) for(auto itr = v.begin();itr != v.end();++itr)
#define SORT(v) sort(v.begin(), v.end())
#define REV(v) reverse(v.begin(), v.end())
#define SIZE(v) int(v.size())
using namespace std;
typedef long long ll;
typedef pair<int, int> P;



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

	int N;
	cin >> N;
	vector<int> a(N + 1);
	REP(i, N) {
		cin >> a[i + 1];
	}
	vector<int> res;
	for (int i = N;i > 0;--i) {
		int mod = 0;
		for (int j = i; j <= N; j += i) {
			mod = (mod + a[j]) % 2;
		}
		if (a[i] != mod) a[i] = !a[i];
		if (a[i]) res.push_back(i);
	}
	
	cout << SIZE(res) << endl;
	for (auto &i : res) cout << i << " ";

	return 0;
}

Measured memory_bytes: 2424
#include<bits/stdc++.h>
#define MAXN 100005
#define INF 1000000000
#define MOD 1000000007
#define F first
#define S second
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int a,b,c;
int find_ans(int x,int y)
{
	if(x>=y) return x-y;
	if((y-x)&1) return 2+(y-x)/2;
	return (y-x)/2;
}
int main()
{
	scanf("%d%d%d",&a,&b,&c);
	int lb=min(min(a,b),c);
	int rb=max(max(a,b),c);
	int ans=INF;
	for(int i=lb;i<=rb;i++)
		ans=min(ans,find_ans(a,i)+find_ans(b,i)+find_ans(c,i));
	printf("%d\n",ans);
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <sstream>
#include <random>
#include <utility>
#include <map>
#include <vector>
#define REP(i,x) for(int i=0; i<(x); i++)

using namespace std;

int main(int argc, const char * argv[]) {
    int n,m;
    cin >> n >> m;
    int x=0,y=0,z=0;
    
    x = m/10000;
    m = m%10000;
    y = m/5000;
    m = m%5000;
    z = m/1000;
    
    while (true) {
        if ((x+y+z) == n) {
            cout << x << " " << y << " " << z << endl;
            return 0;
        } else if ((x+y+z)>n){
            cout << "-1 -1 -1" << endl;
            return 0;
        } else {
            if ((n-(x+y+z)) >=9 ) {
                if (x>0) {
                    x--;
                    z+=10;
                } else if(y>0){
                    y--;
                    z+=5;
                } else {
                    cout << "-1 -1 -1" << endl;
                    return 0;
                }
            } else if ((n-(x+y+z))>=4){
                if (y>0) {
                    y--;
                    z+=5;
                } else if(x>0){
                    x--;
                    y+=2;
                } else {
                    cout << "-1 -1 -1" << endl;
                    return 0;
                }
            } else if((n-(x+y+z))>=1){
                if (x>0) {
                    x--;
                    y+= 2;
                } else {
                    cout << "-1 -1 -1" << endl;
                    return 0;
                }
            }
                
        }
    }
    
    
    
    return 0;
}


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

string alphabet = "abcdefghijklmnopqrstuvwxyz";
int main(){
	char a;
	cin >> a;
	bool flag = true;
	rep(i,alphabet.size()){
		if(alphabet[i] == a) flag = false;
	}
	if(flag){
		cout << "A" << endl;
	}else{
		cout << "a" << endl;
	}
	
    return 0;
}



Measured memory_bytes: 3636
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.util.InputMismatchException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

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

    static class TaskC {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int m = in.nextInt();

            long ans = 1900 * m + 100 * (n - m);
            for (int i = 0; i < m; i++) {
                ans *= 2;
            }

            out.println(ans);
        }

    }

    static class InputReader {
        BufferedReader in;
        StringTokenizer tok;

        public String nextString() {
            while (!tok.hasMoreTokens()) {
                try {
                    tok = new StringTokenizer(in.readLine(), " ");
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
            }
            return tok.nextToken();
        }

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

        public InputReader(InputStream inputStream) {
            in = new BufferedReader(new InputStreamReader(inputStream));
            tok = new StringTokenizer("");
        }

    }
}



Measured memory_bytes: 21460
#include <iostream>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cassert>
#include <ctime>
#include <sstream>
#include <algorithm>
#include <functional>
#include <numeric>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
using namespace std;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define popb pop_back()
#define sz size()
#define int long long
#define y1 dfsdsfsdfsd
#define next fdsfsdfjkl
#define endl "\n"
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long long ll;
typedef unsigned long long ull;
double pi = acos(-1.0);
int mod = 1e9+7;
const double eps = (double)1e-9;
const ll INF = 1e18+7;
/////////////////////////////////////////

int a,b;
vector<int> find_dividers(int x) {
    vector<int> dividers;

    for (int i = 1; i <= sqrt(x); i++) {
        if (x % i == 0) {
            dividers.push_back(i);

            //для корня из x не существует парного делителя
            if (i * i != x) {
                dividers.push_back(x / i);
            }
        }
    }

    return dividers;
}

bool is_prime(int x) {
    for (int i = 2; i <= sqrt(x); i++) {
        if (x % i == 0) {
            return false;
        }
    }

    return true;
}
map<int,int>used;
signed main(){speed;
    cin>>a>>b;

    vector<int> A = find_dividers(a);
    vector<int> B = find_dividers(b);

    int cnt = 0;

    for(int i=0;i<A.size();i++) {
        if(is_prime(A[i]) && used[A[i]]==0 && a%A[i]==0 && b%A[i]==0) {
            used[A[i]] = 1;
            cnt++;
            //cout<<A[i]<<" ";
        }
    }

    for(int i=0;i <B.size();i++) {
        if(is_prime(B[i]) && used[B[i]]==0 && b%B[i]==0 && a%B[i]==0) {
            used[B[i]] = 1;
            cnt++;
            //cout<<B[i]<<" ";
        }
    }

    cout<<cnt<<endl;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main(){
        const long long c = 2019;
        long long l, r;
        cin >> l >> r;
        if(r-l>2019) r = l+2020;
        long long ans = 2000000001;
        for(long long i=l; i<r; i++){
                for(long long j=i+1; j<=r; j++){
                        ans = min(ans, i*j%c);
                }
        }
        cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#define N 250

int parent(int n){
  return n / 2;
}

int left(int n){
  return 2 * n; 
}

int right(int n){
  return 2 * n + 1;
}

main(){
  int i,n,a[N],b;

  scanf("%d",&b);
  for(i=1;i<=b;i++){
    scanf("%d",&a[i]);
  }
  for(i=1;i<=b;i++){
    printf("node %d: key = %d, ",i,a[i]);
    if(parent(i)>=1){
      printf("parent key = %d, ",a[parent(i)]);
    }
    if(left(i)<=b){
      printf("left key = %d, ",a[left(i)]);
    }
    if(right(i)<=b)
      printf("right key = %d, ",a[right(i)]);
    printf("\n");
  }
  return 0;
}

Measured memory_bytes: 600
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    stack<int> stk;
    rep(i,s.size()){
        if(s[i] == '0') stk.push(0);
        else if(s[i] == '1') stk.push(1);
        else{
            if(!stk.empty()) stk.pop();
        }
    }
    vector<int> ans;
    while(!stk.empty()){
        int t = stk.top();
        stk.pop();
        ans.push_back(t);
    }
    for(int i = ans.size()-1; i >= 0; i--){
        cout << ans[i];
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int,input().split()))
ans = a[0]
for i in range(1,n):
    while a[i] % ans:
        a[i] = a[i] %ans
        if a[i] < ans:
            tmp = a[i]
            a[i] = ans
            ans = tmp
print(ans)

Measured memory_bytes: 62704
/*input
6
1 53
13 91
37 55
19 51
73 91
13 49
*/
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define F first
#define S second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define pb push_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#ifdef leowang
#define debug(...) do{\
	fprintf(stderr,"%s - %d : (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
	_DO(__VA_ARGS__);\
}while(0)
template<typename I> void _DO(I&&x){cerr<<x<<endl;}
template<typename I,typename...T> void _DO(I&&x,T&&...tail){cerr<<x<<", ";_DO(tail...);}
#else
#define debug(...)
#endif
template<typename T1,typename T2>
ostream& operator<<(ostream& out,pair<T1,T2> P){
	out<<'('<<P.F<<','<<P.S<<')';
	return out;
}
//}}}
const ll maxn=500005;
const ll maxlg=__lg(maxn)+2;
const ll INF64=8000000000000000000LL;
const int INF=0x3f3f3f3f;
const ll MOD=ll(1e9+7);
const double PI=acos(-1);
//const ll p=880301;
//const ll P=31;

ll mypow(ll a,ll b){
	ll res=1LL;
	while(b){
		if(b&1) res=res*a%MOD;
		a=a*a%MOD;
		
		b>>=1;
	}
	return res;
}

bool isp[maxn];
vector<int> p;
vector<int> v;
int main()
{
	IOS;
	for(int i=2;i<maxn;i++){
		if(!isp[i]) p.pb(i);
		for(int j=0;i*p[j]<maxn;j++){
			isp[i*p[j]]=1;
			if(i%p[j]==0) break;
		}
	}
	for(int i:p) if(i>2){
		if(isp[(i+1)/2]==0) v.pb(i);
	}

	int q;
	cin>>q;
	while(q--){
		int l,r;
		cin>>l>>r;
		cout<<upper_bound(ALL(v),r)-lower_bound(ALL(v),l)<<'\n';
	}
}



Measured memory_bytes: 1404
n = gets.chomp.to_i
n.times do |i|
	a = gets
	break if a == nil
	b = a.split(" ")
	b.map! {|item| item.to_i}
	b.sort!
	if (b[2] ** 2) == (b[1] ** 2) + (b[0] ** 2) then
		puts "YES"
	else
		puts "NO"
	end
end	

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

using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int INF = 100000000;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
int main(){
  int a,b,c,d;
  cin >> a >> b >> c >>d;
  if(a+b>c+d){
    cout << "Left" << endl;
  }else if(a+b==c+d){
    cout << "Balanced" << endl;
  }else{
    cout << "Right"<< endl;
  }
}

Measured memory_bytes: 256
from collections import deque

n, q = map(int, input().split())
queue = deque()
for _ in range(n):
    name, t = input().split()
    t = int(t)
    queue.append((name, t))

time = 0
while len(queue) != 0:
    name, t = queue.popleft()
    if t > q:
        queue.append((name, t - q))
        time += q
    elif t <= q:
        time += t
        print(name, time)



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

const ll MOD = 1000000007;

ll modpow(ll x, ll n){
    ll res = 1;
    ll mul = x;
    while(n){
        if(n % 2) res = res * mul % MOD;
        mul = mul * mul % MOD;
        n /= 2;
    }
    return res;
}

struct Combination
{
    int maxn;
    vector<ll> fmemo;
    vector<ll> imemo;
    vector<ll> ifmemo;
    
    Combination(int maxn) : maxn(maxn){
        fmemo.resize(maxn + 1);
        imemo.resize(maxn + 1);
        ifmemo.resize(maxn + 1);
        for(ll i = 1; i <= maxn; i++){
            imemo[i] = modpow(i, MOD - 2);
        }
    }

    ll fact(ll n){
        if(n == 0) return 1;
        if(fmemo[n]) return fmemo[n];
        return fmemo[n] = n * fact(n - 1) % MOD;
    }

    ll ifact(ll n){
        if(n == 0) return 1;
        if(ifmemo[n]) return ifmemo[n];
        return ifmemo[n] = imemo[n] * ifact(n - 1) % MOD;
    }

    ll com(ll n, ll k){
        if(k > n) return 0;
        if(k == n || k == 0) return 1;
        return (fact(n) * ifact(k) % MOD) * ifact(n - k) % MOD;
    }
};

vector<int> enum_prime(int n){   // containing n
    vector<int> res;
    if (n <= 1) return res;
    vector<bool> p(n + 1);
    fill(p.begin() + 2, p.end(), true);
    for(int i = 2; i <= n; i++){
        if(p[i]){
            res.push_back(i);
            for(int j = i * 2; j <= n; j += i) p[j] = false;
        }
    }
    return res;
}

int main()
{
    int n, m;
    cin >> n >> m;
    vector<int> prime = enum_prime(100000);
    Combination com(150000);
    ll ans = 1;
    for(int p : prime){
        int k = 0;
        while(m % p == 0){
            m /= p;
            k++;
        }
        ans = ans * com.com(n + k - 1, k) % MOD;
    }
    if(m > 1) ans = ans * n % MOD;
    cout << ans << endl;
}


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

#define V             vector
#define PQ            priority_queue

#define pb            push_back
#define mp            make_pair
#define ins           insert
#define endl          '\n'
#define all(x)        x.begin(),x.end()
#define debug(X)      { cerr<<endl<<(#X)<<" = "<<(X)<<endl; }
//#define cerr if(0)cerr

typedef long long ll;
typedef unsigned long long ull;


ll freq[2000010]={0};  // freq of balls

inline ll c(ll n) {
    return (n*(n-1)/2);
}

int main() {
    ios_base::sync_with_stdio(0);cin.tie(0);
    ll n,a;
    vector<ll> balls(1,-1);  // actaul seq
    unordered_set<ll> val;  // values involved

    cin>>n;
    ll _=n;
    while (_--) {
        cin>>a;
        ++freq[a];
        balls.pb(a);
        val.insert(a);
    }

    ll res=0;
/*
    int B=0,res=0;
    for (int k=1; k<=n; ++k) {
        B=balls[k];
        res=0;
        --freq[B];
        for (auto& e:val) {
            res += c(freq[e]);
        }
        ++freq[B];
        cout<<res<<endl;
    }
*/
    for (auto &e: val)
        res += c(freq[e]);

    ll u_res=res;  //backup
    for (int k=1; k<=n; ++k) {
        res=u_res;
        res-=freq[balls[k]]-1;
        cout<<res<<endl;
    }
}



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

main(){
    string str, maxs;
    int maxl = 0;
    map<string, int> M;
    while( cin >> str ){
	if ( maxl < str.size()){
	    maxl = str.size(); maxs = str;
	}
	M[str]++;
    }
    int m = 0;
    string fs;
    for ( map<string, int>::iterator it = M.begin(); it != M.end(); it++ ){
	if ( m < (*it).second ){
	    fs = (*it).first;
	    m = (*it).second;
	}
    }
    cout << fs << " " << maxs << endl;
}

Measured memory_bytes: 0
use std::str::FromStr;
use std::cmp::Ordering;

fn cmp(e1: &(usize, bool), e2: &(usize, bool)) -> std::cmp::Ordering {
    if e1.0 < e2.0 {
        Ordering::Less
    } else if e1.0 > e2.0 {
        Ordering::Greater
    } else if e1.1 && !e2.1 {
        Ordering::Greater
    } else if !e1.1 && e2.1 {
        Ordering::Less
    } else {
        Ordering::Equal
    }
}
fn main() {
    let n: usize = {
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).unwrap();
        s.trim().parse::<usize>().unwrap()
    };
    let mut a: Vec<usize> = {
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).unwrap();
        s.trim().split_whitespace().map(|c| usize::from_str(c).unwrap()).collect()
    };
    a.push(0);
    
    let mut ends: Vec<(usize, bool)> = Vec::new();
    let mut top: usize = 0;
    let mut up: bool = true;
    for i in 0..n+1 {
        if !up && (i == n || a[i+1] > a[i]) {
            ends.push((a[i], true));
            ends.push((top, false));
            up = true;
        } else if i != n && up && a[i+1] < a[i] {
            top = a[i];
            up = false;
        }
    }
    
    ends.sort_by(cmp);
    
    let mut max_overlaps = 0;
    let mut overlaps = 0;
    for end in ends {
        if end.1 {
            overlaps += 1;
            if overlaps > max_overlaps {
                max_overlaps = overlaps;
            }
        }
        else {
            overlaps -= 1;
        }
    }
    println!("{}", max_overlaps);
}


Measured memory_bytes: 11064
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int a,v,b,w,t;
    cin>>a>>v>>b>>w>>t;
    if(v<w)
        cout<<"NO"<<endl;
    else if((v-w)*t>=abs(a-b))
        cout<<"YES"<<endl;
    else
        cout<<"NO"<<endl;
}


Measured memory_bytes: 3636
n, k, q, *a = map(int, open(0).read().split())

p = k - q
ans = [p]*n

for i in range (0,q):
  ans[a[i]-1] = ans[a[i]-1] + 1

for i in range (0,n):
  if ans[i] > 0:
    print("Yes")
  else:
    print("No")

Measured memory_bytes: 13988