akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;
#define endl "\n"
#define MOD 1000000007
typedef long long ll;
typedef pair<int,int> pii;
const int N = 5e3 + 5;
int p[N], n;
ll k, c[N], ans = -1e18, maxV[N];
vector<vector<int> > res;
bool vis[N];

int main()
{
//    freopen("D.INP", "r", stdin);
    ios_base::sync_with_stdio(false); cin.tie(0);
    cin >> n >> k;
    for (int i = 1; i <= n; ++i) cin >> p[i];
    for (int i = 1; i <= n; ++i) cin >> c[i];
    for (int i = 1 ; i <= n; ++i)
    {
        if (vis[i]) continue;
        int temp = i;
        res.push_back({});
        while (!vis[temp])
        {
            vis[temp] = true;
            res.back().push_back(temp);
            temp = p[temp];
        }
    }
    for (int i = 0; i < res.size(); ++i) {
        if (i == 2)
            int z = 1;
        int m = res[i].size();
        for (int j = 0; j < m; ++j)
            res[i].push_back(res[i][j]);// double

        ll sum = 0;
        for (int j = 0; j < m; ++j)
            sum += c[res[i][j]];

        ll temp;
        maxV[0] = -1e18;
        for (int limit = 1; limit <= m; ++limit)
        {
            maxV[limit] = maxV[limit - 1];
            temp = 0;
            for (int j = 0;j < m * 2; ++j)
            {
                temp += c[res[i][j]];
                if (j >= limit - 1)
                {
                    maxV[limit] = max(maxV[limit], temp);
                    temp -= c[res[i][j - (limit - 1)]];
                }
            }
        }
        ans = max(ans, sum * (k / m) + maxV[k % m]);
        if (k / m > 0)
        {
            ans = max(ans, maxV[m]);
            ans = max(ans, sum * (k / m - 1) + maxV[m]);
        }
    }
    cout << ans;
    return 0;
}


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

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


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

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

Node *root, *NIL;

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

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

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

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

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

void inorder(Node *u) {
	if (u == NIL)return;
	inorder(u->left);
	cout << " " << u->key;
	inorder(u->right);
}
void preorder(Node *u) {
	if (u == NIL)return;
	cout << " " << u->key;
	preorder(u->left);
	preorder(u->right);
}

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

	cin >> n;
	for (i = 0; i < n; i++) {
		cin >> com;
		if (com == "find") {
			cin >> x;
			Node *t = find(root, x);
			if (t != NIL) cout << "yes" << endl;
			else cout << "no" << endl;
		}else if (com == "insert") {
			cin >> x;
			insert(x);
		}else if(com=="print"){
			inorder(root);
			printf("\n");
			preorder(root);
			printf("\n");
		}
	}
    return 0;
}

Measured memory_bytes: 21904
#include <iostream>

void include3(int n);

int main(int argc, char const *argv[])
{
    int n;

    std::cin >> n;

    for (int i = 1; i <= n; i++)
    {
        if (i % 3 == 0)
        {
            std::cout << " " << i;
        }
        else
        {
            include3(i);
        }
    }
    std::cout << std::endl;

    return 0;
}

void include3(int n)
{
    int x = n;
    while (n != 0)
    {
        if (n % 10 == 3)
        {
            std::cout << " " << x;
            return;
        }
        n /= 10;
    }
    return;
}


Measured memory_bytes: 3092
#include <iostream>
#include <string>
#define REP(i,n) for(int i=0;i<(n);++i)
#define MOD 1000000007
using namespace std;
typedef long long LL;

int main(){
  int N;
  cin >> N;
  int A = 0, B = 0, C = 0;
  LL r = 1;
  REP(i, N) {
    int X;
    cin >> X;
    if(X == A) {
      if(A == C) {
        C++;
        r *= 3;
      } else if(A == B) {
        B++;
        r *= 2;
      } else {
        A++;
      }
    } else if(X == B) {
      if(B == C) {
        C++;
        r *= 2;
      } else {
        B++;
      }
    } else if(X == C) {
      C++;
    } else {
      r = 0;
    }
    r %= MOD;
  }
  cout << r << endl;
}

Measured memory_bytes: 256
n,m,*a=map(int,open(0).read().split())
d=[]
for i,j in((7,3),(9,6),(8,7),(6,6),(5,5),(4,4),(3,5),(1,2),(2,5)):
    if i in a:
        d.append((i,j))
dp=[0]*-~n
for i in range(1,n+1):
    for j,k in d:
        if i-k<0 or i-k!=0 and not dp[i-k]:continue
        dp[i]=max(dp[i],dp[i-k]*10+j)
print(dp[n])

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

int main() {
  string S;
  cin >> S;
  
  int n;
  cin >> n;
  
  string ans;
  int tmp;
  
  if(S.size() % n == 0) {
    tmp = S.size() / n;
  } else {
    tmp = (S.size() / n) + 1;
  }
    
  for(int i = 0; i < tmp; i++) {
    ans += S.at(i * n);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cmath>
#include <set>
#include <utility>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <iomanip>
#include <cstdio>
#include <cstring>

using namespace std;

constexpr long long mod = 1000000007;
constexpr double eps = 0.0000000001;

typedef long long ll;
typedef long long unsigned ull;

int main() {
    int n;
    string s;
    map<string,int> c;
    cin >> n;
    for(int i = 0;i < n;i++) {
        cin >> s;
        c[s]++;
    }
    vector<pair<int,string>> d;
    for(auto& e: c) {
        d.emplace_back(-e.second,e.first);
    }
    sort(d.begin(),d.end());
    for(auto& e:d) {
        if(e.first == d[0].first) cout << e.second << endl;
    }
}

Measured memory_bytes: 29556
import itertools
N,M,Q = map(int,input().split())
pair = [list(map(int,input().split())) for i in range(Q)]

ans = 0

for A in itertools.combinations_with_replacement(range(1,M + 1),N):
  temp = 0
  for p in pair:
    if A[p[1]-1] - A[p[0]-1] == p[2]:
      temp += p[3]
      ans = max(ans,temp)
    
print(ans)

Measured memory_bytes: 9068
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cmath>
#include <iostream>
#include <queue>
#include <list>
#include <stack>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <vector>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;

int main(){
  ios::sync_with_stdio(false);
  int K, T;
  cin >> K >> T;
  priority_queue<int> que;
  rep(i,T){
    int a;
    cin >> a;
    que.push(a);
  }
  int ret = 0;
  while(!que.empty()){
    int a = que.top(); que.pop();
    if(que.empty()){
      ret = a-1;
      break;
    }
    int b = que.top(); que.pop();
    a--;
    b--;
    if(a>0) que.push(a);
    if(b>0) que.push(b);
  }

  cout << ret << endl;
  
  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)
#define rrep(i,n) for(int i=n-1;0<=i;--i)
#define rRep(i,n) for(int i=n;0<i;--i)
#define range(i,a,b) for(int i=(a);i<(b);++i)
#define mp make_pair
#define pb push_back
#define all(x) x.begin(), x.end()
#define EPS 1e-8
#define INF 1e8

typedef double Real;
typedef int Int;
typedef vector<Int> vi;
typedef vector<vector<Int> > vvi;
typedef pair<Int,Int> pii;

inline Real sr(Real a) {return sqrt(max(a, (Real)0));}
const vi dy = {-1, 0, 1, 0}, dx = {0, -1, 0, 1};

template <typename K, typename V> ostream& operator<< (ostream& out, const pair<K, V>& p) {
  out << '(' << p.first << ", " << p.second << ')';
  return out;
}

template <typename T> ostream& operator<< (ostream& out, const vector<T>& v) {
  out << '[';
  rep(i, v.size()) out << v[i] << ",";
  out << "\b], " << v.size();
  return out;
}

void solve(){
  Int M, T, P, R, m, t, p, j;
for(;;){
  cin >> M >> T >> P >> R;
  if(M == 0) return;

  vvi penalty(T, vi(P, 0));
  map<Int, pii> scores; // <teamnum, <correctprobrems, time>>
  rep(i, T) scores[i] = make_pair(0, 0);

  rep(i, R){
    cin >> m >> t >> p >> j;
    --t; --p;

    if(j){
      penalty[t][p]++;
      continue;
    }

    pii &ct = scores[t];
    ct.first++;
    ct.second += m + 20 * penalty[t][p];
  }

  vector<pair<Int, pii> > v(all(scores));
  sort(all(v), [&](pair<Int, pii> a, pair<Int, pii> b) {
    if(a.second.first != b.second.first) return a.second.first > b.second.first;
    if(a.second.second != b.second.second) return a.second.second < b.second.second;
    return a.first > b.first;
  });

//  cout << v << endl;

  Int lastnums = v[0].second.first, lasttime = v[0].second.second;
  cout << v[0].first + 1;
  for (int i = 1; i < T; ++i)
  {
    cout << (v[i].second.first == lastnums ? (v[i].second.second == lasttime ? '=' : ',') : ',') << v[i].first + 1;
    lastnums = v[i].second.first;
    lasttime = v[i].second.second;
  }
  cout << endl;
}
}

signed main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(9);

  solve();

  return 0;
}

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

#define rep(i,n) for (int i = 0; i< (n); ++i)
#define vvec(m,n) vector<vector<int>> (int(m), vector<int>(n))
#define ALL(a) (a).begin(), (a).end()

using ll = long long;

int main(){
    int N,A,B;
    cin >> N >> A >> B;
    cout << min(N*A,B) << endl;
}

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

#define pb push_back
#define ff first
#define ss second
#define all(x) (x).begin(), (x).end()
#define ll long long
#define ii pair<int,int>
#define vi vector<int>
#define vll vector<ll>
#define vii vector<ii>

using namespace std;

int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int n; 
	cin>>n;
	vi vs(n);
	ll ans=1e9+10;
	for(int &x:vs) cin >> x;
	for(int p=1;p<=1000;++p){
		ll s=0;
		for(int i=0;i<n;++i){
			ll x=(vs[i]-p)*(vs[i]-p);
			s+=x;
		}
		ans=min(ans,s);
	}
	cout<<ans<<endl;
	return 0;
}

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

using namespace std;

//Shortcut
#define long long long
#define pb push_back
#define pf push_front
#define mp make_pair
#define X first
#define Y second
#define sz size
#define ft(i , a , b) for (long i = (long)a ; i <= (long)b ; i++)
#define fd(i , a , b) for (long i = (long)a ; i >= (long)b ; i--)
#define lt(i , a , b , c) for (long i = (long)a ; i <= (long)b ; i += (long)c)
#define ld(i , a , b , c) for (long i = (long)a ; i >= (long)b ; i -= (long)c)
#define pll pair <long , long>
#define pls pair <long , string>
#define vtl vector <long>
#define vts vector <string>
#define vtp vector <pll>
#define dql deque <long>
#define mll map <long , long>
#define prio priority_queue<pll , vector<pll > , greater<pll> >
#define pushpq(a , b) push({(long) a , (long) b})

//Variable
const long mxN = 1e3 + 5;
const long base = 311;
const long oo = 1e15;
const long MOD = 1e9 + 7;
const long d4i[4] = {-1 , 0 , 1 , 0} , d4j[4] = {0 , 1 , 0 , -1};
const long d8i[8] = {-1 , -1 , 0 , 1 , 1 , 1 , 0 , -1} , d8j[8] = {0 , 1 , 1 , 1 , 0 , -1 , -1 , -1};

int TestCase;
int n , m , answer; 
int dp[mxN][mxN];
bool mark[mxN][mxN];
char a[mxN][mxN];

void Solve() {
    cin >> n >> m;
    ft(i , 1 , n) ft(j , 1 , m) cin >> a[i][j];
    dp[1][1] = 1;
    ft(i , 1 , n) {
        ft(j , 1 , m) {
            if (a[i][j] == '#') continue;
            if (i == 1 && j == 1) continue;
            dp[i][j] = (dp[i - 1][j] % MOD + dp[i][j - 1] % MOD) % MOD;
        }
    }
    cout << dp[n][m];
}

int main() {
    ios_base::sync_with_stdio(NULL);
    cin.tie(NULL);
    cout.tie(NULL);
    //freopen(".inp", "r", stdin);
    //freopen(".out", "w", stdout);
    //cin >> TestCase;
    TestCase = 1;
    while(TestCase--)
        Solve();
    return 0;
}

Measured memory_bytes: 8516
def main():
    s = input()
    x, y = map(int, input().split())
    d = {}
    d[True] = {0}
    d[False] = {0}
    xf = True
    t = 0
    first = True
    for i in s:
        if i == 'F':
            t += 1
        else:
            if first:
                d[xf] = set()
                d[xf].add(t)
                first = False
            else:
                tmp = set()
                for j in d[xf]:
                    tmp.add(j-t)
                    tmp.add(j+t)
                d[xf] = tmp
            xf = not xf
            t = 0
    if t == len(s):
        d[True] = {t}
        d[False] = {0}
    elif t > 0:
        tmp = set()
        for j in d[xf]:
            tmp.add(j-t)
            tmp.add(j+t)
        d[xf] = tmp
    if x in d[True] and y in d[False]:
        return True
    return False
if main():
    print('Yes')
else:
    print('No')


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

void yes(int n){
	for(int i=1;i<=n;i++)printf("Yes\n");
}

int main() {
	
	int n,k,q;  cin>>n>>k>>q;
	if(k>q) {yes(n); return 0;}
	
	int *score=new int[n];
	for(int i=0;i<n;i++) score[i]=k;
	int *ans=new int[q];
	for(int i=0;i<q;i++){cin>>ans[i];  score[ans[i]-1]++; }
	for(int i=0;i<n;i++){
		score[i]-=q;
		cout<<((score[i]>0)?"Yes\n":"No\n"); 
	}
	
	return 0;
}

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

int main(){
	int a,b;
	cin>>a>>b;
	if((a+b)%2==0){
		cout<<(a+b)/2<<endl;
	}else{
		cout<<"IMPOSSIBLE"<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <queue>
using ll = long long;
using graph = std::vector<std::vector<ll>>;

using namespace std;

int main() {
    string S;
    cin >> S;
    ll a = 0;
    ll b = 0;
    ll c = 0;
    for(int i = 0; i <S.size(); i++){
        if(S[i] == 'a'){
            a++;
        }
        if(S[i] == 'b'){
            b++;
        }
        if(S[i] == 'c'){
            c++;
        }
    }
    ll m = min(min(a,b),c);
    ll M = max(max(a,b),c);
    if(M - m >= 2){
        cout << "NO" << endl;
    }else{
        cout <<"YES" << endl;
    }
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define int long long

signed main(){
    int n; cin >> n;
    int ans = 0;
    rep(i,n){
        int a; cin >> a;
        while(a % 2 == 0){
            a /= 2;
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; i++)
#define PI 3.1415926535897932384626433832795028
#define INF (1<<29)
#define LINF (1LL<<60)
using namespace std;
using INT = long long;
using P = pair<int,int> ;

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



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

using namespace std;

int main(){
  int a, b;
  cin >> a >> b;
  cin.ignore();

  int k_2;
  k_2 = a + b;
  if(k_2 % 2 != 0){
    cout << "IMPOSSIBLE" << endl;
    return 0;
    
  }
  int k;
  k = k_2 / 2;
  if((a <= k) && (b >= k)){
    cout << k << endl;
    return 0;
  } else if((a >= k) && (b <= k)){
    cout << k << endl;
    return 0;
    
  } else {
    cout << "IMPOSSIBLE" << endl;
    return 0;
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int main(){
    int n,sum=0;
    cin >> n;
    vector<int> vec(n);
    rep(i,n)cin >> vec.at(i);
    sort(vec.begin(),vec.end());
    reverse(vec.begin(),vec.end());
    rep(i,n/2){
        sum+=vec.at(2*i)-vec.at(2*i+1);
    }
    if(n%2)sum+=vec.at(n-1);
    cout << sum << endl;
}
    


Measured memory_bytes: 256
module.exports=function(e){var t={};function r(n){if(t[n])return t[n].exports;var i=t[n]={i:n,l:!1,exports:{}};return e[n].call(i.exports,i,i.exports,r),i.l=!0,i.exports}return r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var i in e)r.d(n,i,function(t){return e[t]}.bind(null,i));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=0)}([function(e,t,r){"use strict";var n=r(1);r(2)(n.readFileSync("/dev/stdin","utf8"))},function(e,t){e.exports=require("fs")},function(e,t,r){"use strict";var n=r(3),i=r(5);e.exports=function(e){var t=new n(e);i(t)}},function(e,t,r){"use strict";var n=r(4);e.exports=class{constructor(e){var t=e.trim().split(/\s+/g);this.inp=new n(t)}inr(){return this.inp.deq()}in(){return parseInt(this.inp.deq(),10)}fin(){this.inp.clear()}}},function(e,t,r){"use strict";e.exports=class{constructor(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];this.size=e.length,this.items=e,this.ind=0}enq(e){this.size+=1,this.items.push(e)}deq(){var e=this.items[this.ind];return this.size-=1,this.ind+=1,e}clear(){this.items=[],this.size=0,this.ind=0}}},function(e,t,r){"use strict";e.exports=function(e){for(var t=e.in(),r=new Array(t),n=!1,i=0;i<t;i++)r[i]=e.in(),0!=r[i]&&(n=!0);if(n)if(t%3==0){for(var o=[-1,-1,-1],s=[0,0,0],u=0,l=0;l<t;l++){for(var c=!1,f=0;f<3;f++){if(o[f]==r[l]){c=!0,s[f]++;break}if(-1==o[f]){u++,c=!0,o[f]=r[l],s[f]++;break}}if(!c)return void console.log("No")}if(s[0]!=t/3||s[1]!=t/3||s[2]!=t/3||0!=(o[0]^o[1]^o[2])){if(2==u)if(0==o[0]){if(s[0]==t/3&&s[1]==2*t/3)return void console.log("Yes")}else if(0==o[1]&&s[1]==t/3&&s[0]==2*t/3)return void console.log("Yes");console.log("No")}else console.log("Yes")}else console.log("No");else console.log("Yes")}}]);

Measured memory_bytes: 17856
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int a, b, k;

		a = sc.nextInt();
		b = sc.nextInt();
		k = sc.nextInt();

		for (int i = 0; i < k; ++i) {
			if (i % 2 == 0) {
				if (a % 2 != 0)
					--a;
				b += a / 2;
				a = a - (a / 2);
			} else {
				if (b % 2 != 0)
					--b;
				a += b / 2;
				b = b - (b / 2);
			}
		}

		System.out.println(a + " " + b);

		sc.close();
	}

}


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

int main() {
  int N;
  cin >> N;
  vector<int> order(N);
  for(int i = 0; i < N; i++){
  cin >> order.at(i);
  }
  sort(order.begin(), order.end());
  int M;
  M = order.at(N-1) - order.at(0);
  cout << M << endl;
  }

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

using namespace std;

void solve()
{
    int n, xr = 0;
    cin >> n;
    vector <int> a(n);
    for (int i = 0; i < n; i++)
    {
        cin >> a[i]; 
        xr ^= a[i];
    }
    for (int i = 0; i < n; i++)
    {
        cout << (xr ^ a[i]) << " ";
    }
}

int main() 
{
    int tt = 1;
    //cin >> tt;
    while (tt--) solve();
}


Measured memory_bytes: 3960
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
using ll = long long;
using vpii = vector<pair<int, int>>;
using vpll = vector<pair<ll, ll>>;
// ceil() 切り上げ, floor() 切り捨て
// next_permutation(all(x))

int		main(void)
{
	int K, A, B;
	cin >> K >> A >> B;
	
	bool ans = false;
	for (int i = A; i <= B; i++)
	{
		if (i % K == 0)
			ans = true;	
	}
	cout << (ans ? "OK" : "NG") << endl;
}



Measured memory_bytes: 3636
import sys
sys.setrecursionlimit(10**6)
N = int(input())
A=list(map(int,input().split()))
Q = int(input())
BC = [map(int, input().split()) for _ in range(Q)]
B, C = [list(i) for i in zip(*BC)]
sum=0
D=[0]*(10**5+1)
for i in range(N):
    sum+=A[i]
    D[A[i]]+=1
for i in range(Q):
    D[C[i]]+=D[B[i]]
    sum+=D[B[i]]*(C[i]-B[i])
    D[B[i]]=0
    print(sum)


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

void solve(long long N, std::vector<long long> A, std::vector<long long> B){
    ll ans = 0;
    for (int i = 0; i < (int)N; ++i) {
        int left = min(A[i], B[i]);
        ans += left;
        A[i] -= left;
        B[i] -= left;

        int right = min(A[i+1], B[i]);
        ans += right;
        A[i+1] -= right;
        B[i] -= right;
    }
    cout << ans << endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> A(N+1);
    for(int i = 0 ; i < N+1 ; i++){
        scanf("%lld",&A[i]);
    }
    std::vector<long long> B(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&B[i]);
    }
    solve(N, std::move(A), std::move(B));
    return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <algorithm>
#define ll long long
using namespace std;
int main(){
    int a,b,c,d,e,k;
    cin>>a>>b>>c>>d>>e>>k;
    if(e-a<=k){
        cout<<"Yay!"<<endl;
    }else{
        cout<<":("<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
fn main() {
	let mut buf = String::new();
	std::io::stdin().read_line(&mut buf).expect("");
	let mut iter = buf.split_whitespace();
	let x = iter.next().unwrap();
	let y = iter.next().unwrap();
	if x<y {
		println!("<");
	}else if x > y {
		println!(">");
	}else{
		println!("=");
	}
}

Measured memory_bytes: 4352
#include <iostream>
#include <string>
#include <vector>
#include <algorithm> 
#include <utility> 
#include <tuple> 
#include <cstdint> 
#include <cstdio> 
#include <map> 
#include <queue> 
#include <set> 
#include <stack> 
#include <deque> 
#include <unordered_map> 
#include <unordered_set> 
#include <bitset> 
#include <cctype> 
#include <cmath>
#include <iomanip>
#include <ctype.h>
#include <numeric>

using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi >;
using vl = vector<ll>;
using vvl = vector<vl >;
using pairi = pair<int, int>;
using pairl = pair<ll, ll>;

#define TR ","
#define TS " "
#define rep(i,N) for(ll i=0;i<(ll)N;++i)
#define rpt(i,a,b) for(ll i=a;i<(ll)b;++i)
#define all(v) v.begin(), v.end()
#define IO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)

ll gcd(ll a, ll b) {
    if (a < b) swap(a, b);
    if (b == 0) return a;
    return gcd(b, a % b);
}

ll lcm(ll x, ll y) {
    return x / gcd(x, y) * y;
}

ll waz = 76543217;

void printVector(const vector<int>& vec) {
    for (int value : vec) {
        cout << value << " ";
    }
    cout << endl;
}

int main()
{
    IO;

    ll N; cin >> N;

    vl a(N), b(N);

    rep(i, N) {
        cin >> a[i];
        b[i] = a[i];
    }

    sort(all(a));

    ll p = a[N / 2], q = a[N / 2 - 1];

    rep(i, N) {
        if (b[i] >= p) {
            cout << q << endl;
        }
        else {
            cout << p << endl;
        }
    }

}

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

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

	int X[N];
	for(i=0;i<N;i++){
	scanf("%d",&X[i]);
	}

	int sum1=0;
	int sum2=0;
	int sum;
	float PP;
	int P;

	for(i=0;i<N;i++){
		sum1+=X[i]*X[i];
		sum2+=X[i];
	}

	NN = N;
	sum = sum2;

	PP = sum/NN;

	// printf("%f\n",PP);

	P = PP + 0.5;

	// printf("%d\n",P);


	printf("%d\n",sum1- 2*P*sum2 + N*P*P);
	
	return 0;
}

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

int main() {
  int N, L;
  cin >> N >> L;
  vector<string> S(N);
  for (string &e : S) {
    cin >> e;
  }
  sort(S.begin(), S.end());
  for (string e : S) {
    cout << e;
  }
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

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

using namespace std;
typedef long long int ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PI;
const ll mod = 1e9 + 7;



int main(void){
  string str;
cin>>str;
int n,w,e,s;
n=w=e=s=0;
REP(i,0,str.length()){
switch(str[i]){
case 'N': n++;break;
case 'S': s++;break;
case 'E': e++;break;
case 'W': w++;break;
}}
n=n?1:0;
w=w?1:0;
s=s?1:0;
e=e?1:0;
cout << ((n ^ s) || (e ^ w) ? "No" : "Yes") << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()		//sort(all(vi S)) sort(all(string S))
#define rall(a) (a).rbegin(), (a).rend()
typedef long long ll;
typedef vector<int> vi;
typedef set<int> seti;
typedef vector<string> vs;

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

int main() {
	int N,x;
	cin>>N>>x;
	vector<int> a(N);
	int ans = 0,suma = 0;
	rep(i,N){
		cin>>a[i];
		suma+=a[i];
	}
	sort(all(a));
	rep(i,N){
		//cout<<x-a[i]<<endl;
		if(x-a[i]>0&&i==N-1)break;
		else if(x-a[i]<0)break;
		else if(x-a[i]>=0){
			x-=a[i];
			ans++;
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

class B
{
	static int[] Read() => Console.ReadLine().Split().Select(int.Parse).ToArray();
	static void Main()
	{
		var r = new List<long>();
		var h = Read();
		var n = h[0];
		var a = Read();

		var st = new ST_Subsum(n);
		for (int i = 0; i < n; i++)
			st.Add(i, a[i]);

		for (int i = 0; i < h[1]; i++)
		{
			var q = Read();
			if (q[0] == 0)
				st.Add(q[1], q[2]);
			else
				r.Add(st.Subsum(q[1], q[2]));
		}
		Console.WriteLine(string.Join("\n", r));
	}
}

class ST
{
	public struct Node
	{
		public int k, i;
		public Node(int _k, int _i) { k = _k; i = _i; }
	}

	int kMax;
	List<long[]> vs = new List<long[]> { new long[1] };

	public ST(int n)
	{
		for (int c = 1; c < n; vs.Add(new long[c <<= 1])) ;
		kMax = vs.Count - 1;
	}

	public long this[int i] => vs[kMax][i];
	public long this[Node n]
	{
		get { return vs[n.k][n.i]; }
		set { vs[n.k][n.i] = value; }
	}

	public void ForLevels(int i, Action<Node> action)
	{
		for (int k = kMax; k >= 0; --k, i >>= 1) action(new Node(k, i));
	}

	public void ForRange(int minIn, int maxEx, Action<Node> action)
	{
		for (int k = kMax, f = 1; k >= 0 && minIn < maxEx; --k, f <<= 1)
		{
			if ((minIn & f) != 0) action(new Node(k, (minIn += f) / f - 1));
			if ((maxEx & f) != 0) action(new Node(k, (maxEx -= f) / f));
		}
	}
}

class ST_Subsum : ST
{
	public ST_Subsum(int n) : base(n) { }

	public void Set(int i, long v) => Add(i, v - this[i]);
	public void Add(int i, long v) => ForLevels(i, n => this[n] += v);

	public long Subsum(int minIn, int maxEx)
	{
		var r = 0L;
		ForRange(minIn, maxEx, n => r += this[n]);
		return r;
	}
}


Measured memory_bytes: 92644
#include <vector>
#include <set>
#include <algorithm>
#include <cstdio>
using namespace std;

int main(){
	int n,r=0;
	scanf("%d",&n);
	vector<int>v(n);
	for(int i=0;i<n;i++)scanf("%d",&v[i]);
	sort(v.begin(),v.end());
	set<int>se;
	for(int i=1;i*i<=v[n-1];i++)if(v[n-1]%i==0)se.insert(i),se.insert(v[n-1]/i);
	for(auto &e:v)r+=*se.lower_bound(e)-e;
	printf("%d\n",r);
}

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

int main() {
  int n, m;
  cin >> n >> m;
  priority_queue<int> q;
  rep(i, n) {
    int num;
    cin >> num;
    q.push(num);
  }
  rep(i, m) {
    int num = q.top()/2;
    q.pop();
    q.push(num);
  }

  ll ans = 0;
  while(!q.empty()) {
    ans += q.top();
    q.pop();
  }

  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 892
using System;
class WA
{
  static void Main()
  {
    var NT=Console.ReadLine();
    var R=NT.Split();
    var a = int.Parse(R[0]);
    var b = int.Parse(R[1]);
    if(a>=13)
      Console.Write(b);
    else if(a>=6)
      Console.Write(b/2);
    else
      Console.Write(0);
  }
}

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

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)n; ++i)
#define FOR(i, a, b) for(int i = a; i < (int)b; ++i)

typedef long long ll;

const int Inf = 1e9;
const double EPS = 1e-9;

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

int lcm(int a, int b) {
    return a * b / gcd(a, b);
}

int bitCount(long bits) {
    bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
    bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
    bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
    bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
    return (bits & 0x0000ffff) + (bits >>16 & 0x0000ffff);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int q;
    cin >> q;
    map<int, int> mp;
    for (int i = 3; i <= 1e6; i += 2) {
        bool isPrime = true;
        FOR (j, 2, sqrt(i) + 1) {
            if (i % j == 0) {
                isPrime = false;
                break;
            }
        }
        int t = (i + 1) / 2;
        FOR (j, 2, sqrt(t) + 1) {
            if (t % j == 0) {
                isPrime = false;
                break;
            }
        }
        if (isPrime) mp[i] = 1;
    }
    vector<int> v(1e6);
    FOR (i, 1, 1e6) {
        v[i] = v[i - 1] + mp[i];
    }
    rep (i, q) {
        int l, r;
        cin >> l >> r;
        cout << v[r + 1] - v[l - 1] << endl;
    }
    
    return 0;
}



Measured memory_bytes: 51456
#include <bits/stdc++.h>
#include <atcoder/dsu>
using namespace std;
using namespace atcoder;
using ll = long long;

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

    int N, Q;
    cin >> N >> Q;
    dsu uf(N);
    for (int i = 0; i < Q; i++) {
        int t, u, v;
        cin >> t >> u >> v;
        if (t == 0) uf.merge(u, v);
        else cout << uf.same(u, v) << "\n";
    }
}

Measured memory_bytes: 4008
import java.util.*;

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

        int num1 = sc.nextInt();
        int num2 = sc.nextInt();
        int num3 = sc.nextInt();
        int num4 = sc.nextInt();

        int ans;
        ans = num1 * num2 - num3 * num2 - num4 * num1 + num3 * num4;

        System.out.println(ans);
    }
}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
    ll x1,x2,x3,x4,x5;
    cin>>x1>>x2>>x3>>x4>>x5;
    if(x1==0)cout<<1<<endl;
      if(x2==0)cout<<2<<endl;
        if(x3==0)cout<<3<<endl;
          if(x4==0)cout<<4<<endl;
            if(x5==0)cout<<5<<endl;




}


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

int main(){
    string s, t;
    cin >> s ;
    cin >> t ;
    ll num = 0;
    rep(i, t.size()){
        if (t[i] != s[i]){
            num++ ;
        }
    }
    cout << num << endl;
}

Measured memory_bytes: 3912
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v).begin(), (v).end()
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define DEBUG
#define int long long
#define INF 1e9
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; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }
template<class T>void show(vector<T>v){for (int i = 0; i < v.size(); i++){cerr<<v[i]<<" ";}cerr<<"\n";}
typedef long long ll;
double a[110];
signed main(){

    int n;
    cin>>n;
    REP(i,n) cin>>a[i];

    double sum=0;
    for (int i = 0; i < n; i++)
    {
        sum+=1/a[i];
    }
    printf("%.10f\n",1/sum);
    
    return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
from heapq import merge
from bisect import bisect
def inpl(): return list(map(int, input().split()))

X, Y, Z, K = inpl()
A = sorted(inpl())
B = sorted(inpl())
C = sorted(inpl(), reverse=True)

AB = [-1] * K
for a in A[::-1]:
    if AB[0] >= B[-1] + a:
        break
    tmp = [a + b for b in B[bisect(B, AB[0]-a):]][-K:]
    AB = list(merge(tmp, AB))[-K:]

ans = [-1] * K

for c in C:
    if ans[0] >= AB[-1] + c:
        break
    tmp = [ab + c for ab in AB[bisect(AB, ans[0]-c):]][-K:]
    ans = list(merge(ans, tmp))[-K:]

print(*ans[::-1], sep="\n")

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

int main()
{
    long n, k;
    long ans;
    // scanf("%d", &x);
    cin >> n >> k;
    // printf("%d\n", x * x * x);
    n -= (n / k) * k;
    if (n < k - n)
    {
        ans = n;
    }
    else
    {
        ans = k - n;
    }
    cout << ans << endl;
}

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

int main()
{
  std::string w;
  int alphabet[26];
  int i;
  
  std::cin >> w;

  for (i = 0; i < 26; i++) {
    alphabet[i] = 0;
  }
  
  for (i = 0; i < w.size(); i++) {
    char ch = w[i];
    alphabet[ch - 97]++;
  }
  
  for (i = 0; i < 26; i++) {
    if (alphabet[i] % 2 != 0){
      std::cout << "No";
      return 0;
    }
  }

  std::cout << "Yes";
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <string>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <functional>
#include <queue>
#include <stack>
#include <cmath>
#include <iomanip>
#include <list>
#include <tuple>
#include <bitset>
#include <ciso646>
#include <cassert>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;
typedef vector<ll> vec;

inline bool check(ll x, ll y, ll xMax, ll yMax) { return x >= 0 && y >= 0 && xMax > x && yMax > y; }
inline int toint(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string tostring(T x) { ostringstream sout; sout << x; return sout.str(); }
template<class T> inline T sqr(T x) { return x*x; }
template<class T> inline T mypow(T x, ll n) { T res = 1; while (n > 0) { if (n & 1)res = res * x;	x = x * x;	n >>= 1; }return res; }
inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

#define For(i,a,b)	for(ll (i) = (a);i < (b);(i)++)
#define rep(i,n)	For(i,0,n)
#define rFor(i,a,b)	for(ll (i) = (a-1);i >= (b);(i)--)
#define rrep(i,n)	rFor(i,n,0)
#define each(i,n)	for(auto &i : n)
#define clr(a)		memset((a), 0 ,sizeof(a))
#define mclr(a)		memset((a), -1 ,sizeof(a))
#define all(a)		(a).begin(),(a).end()
#define sz(a)		(sizeof(a))
#define tostr(a)	tostring(a)
#define dump(val) 	cerr << #val " = " << val << endl;
#define Fill(a,v)	fill((int*)a,(int*)(a+(sz(a)/sz(*(a)))),v)

const ll dx[8] = { 1, 0, -1, 0, 1, 1, -1, -1 }, dy[8] = { 0, 1, 0, -1, -1, 1, -1, 1 };

const ll mod = 1e9 + 7;
const ll INF = 1e17 + 9;

#define int ll
#define double ld

signed main() {

	int n, k;
	cin >> n >> k;
	set<int> d;
	for (int i = 0; i < k; i++) {
		int t;
		cin >> t;
		d.insert(t);
	}

	for (int t = n;; t++) {
		auto s = tostr(t);
		bool ok = true;
		each(c, s) {
			if (d.count(c - '0')) {
				ok = false; break;
			}
		}
		if (ok) {
			cout << t << endl; return 0;
		}
	}


	return 0;
}

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


/*priority_queue<int,vector<int>,greater<int>>pq;   //ascending order;

 ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
*/
//Ascending
int k;
bool cmp(int &a,int &b){
	if(abs(a-k)<abs(b-k)) return true;
	return false;
}
int n;
int a[40][40];
long long int total ;
long long int dp[2097158][22];

long long int count_plz(long long int mask,int wm)
{
    if(mask == total) return 1;

    if(wm > n) return 0;

    if(dp[mask][wm]!=(-1)) return dp[mask][wm];

    long long int ans = 0;
    for(int i=0;i<n;i++)
    {
        if(a[wm][i] == 1 && (mask &(1<<i))==0)
            ans = (ans + count_plz((mask |(1<<i)),wm+1))%mod;
    }

    dp[mask][wm] = ans;
    return ans;
}
int main(){
	
    cin>>n;
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<n;j++)
            cin>>a[i][j];
    }



    total = (1<<n)-1;

    for(long long int i=0;i<total;i++)
    {
        for(long long int j=0;j<n;j++)
            dp[i][j] = (-1);
    }
    cout<<count_plz(0,0)<<endl;
}


/*////////////////////////////////////custom priority queue;

priority_queue<Person, vector<Person>, CompareHeight> Q; 

struct CompareHeight { 
    bool operator()(Person const& p1, Person const& p2)  //descending order
    { 
        // return "true" if "p1" is ordered  
        // before "p2", for example: 
        return p1.height < p2.height; 
    } 
}; 



upper_bound(a+i, a+n, a[i] + mid) - (a+i+1))
Here upper_bound is a variant of binary search which returns a pointer to the first element from a[i] to a[n-1] which is greater than a[i] + mid. 
*/


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

int n;

int main()
{
	cin >> n;
	int t, x, y, ans = 1;
	while (n--)
	{
		cin >> t >> x >> y;
		if (t < x + y || t % 2 != (x + y) % 2) ans = 0;
	}	
	
	if (ans) cout << "Yes" << '\n';
	else cout << "No" << '\n';
	
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<utility>
#include<algorithm>
#include<map>
#include<cmath>
#include<bitset>
typedef long long ll;
#define PB	push_back
#define FOR(n)			for(int i = 0; i < n; ++i)
#define RFOR(n)			for(int i = n; i >= 0; --i)
#define FORR(start,end) for(int i = start; i < end; ++i)
#define COUT(n)			cout << n << " " << flush
#define vi(v)			vector<int> v
#define vii(v)			vector<pair<int,int>> v
#define pii(p)			pair<int,int> p
#define mii(m)			map<int, int> m
#define msi(m)			map<string, int, less<>> m
#define mmsi(m)			multimap<string, int, less<>> m
#define mkp(a,b)		make_pair(a,b)
#define ALL(obj)		obj.begin(), obj.end()
#define PI 3.141592
#define MOD 1e9+7
using namespace std;

void solve() {
	char c;
	cin >> c;
	cout << (char)(c+1) << endl;
}

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

Measured memory_bytes: 256
import numpy as np

if __name__ == "__main__":
	w,h,n = map(int, raw_input().split())
	fi = np.zeros([h,w])

	for i in range(n):
		x,y,a = map(int, raw_input().split())
		if(a == 1):
			for j in range(h):
				for k in range(x):
					fi[j][k] = 1
		elif(a == 2):
			for j in range(h):
				for k in range(x, w):
					fi[j][k] = 1
		elif(a == 3):
			for j in range(h-y,h):
				for k in range(w):
					fi[j][k] = 1
		elif(a == 4):
			for j in range(h-y):
				for k in range(w):
					fi[j][k] = 1


	ans = 0
	for i in range(h):
		for j in range(w):
			if(fi[i][j] == 0):
				ans += 1
	print ans


Measured memory_bytes: 19172
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>

using namespace std;

#define FOR(i,n) for(int i = 0; i < n; i++)
#define FORa(i,a,b) for(int i = a; i < b; i++)
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a, b)
#define F first
#define S second
#define SORT(a,n) sort(begin(a), begin(a) + n)
#define VSORT(v) sort(v.begin(), v.end())
#define MAX 1000000
#define ll long long
#define LOW(s) transform(s.begin(),s.end(),s.begin(),::tolower)
#define UP(s) transform(s.begin(),s.end(),s.begin(),::toupper)

//-------------------------------------------------------//

int main() {
	int n;
	cin >> n;
	
	unordered_map<string, int> m;
	
	FOR(i, n) {
		string temp;
		cin >> temp;
		m[temp]++;
	}
	
	cout << m.size() << endl;
  
	return 0;
}

Measured memory_bytes: 17676
#include <algorithm>
#include <cstring>
#include <iostream>
#include <vector>

using namespace std;


int main() {
  int n;
  cin>>n;
  vector<pair<int,int> >  task;
  int a,b;
  for(int i = 0;i<n;i++){
    cin>>a>>b;
    task.push_back(make_pair(b,a));
  }
  sort(task.begin(),task.end());
  long long time = 0;
  for(int i = 0;i<n;i++){
    time += task[i].second;
    if( task[i].first < time){
      cout<<"No"<<endl;
      return 0;
    }
  }
  
  cout<<"Yes"<<endl;
  return 0;
}

Measured memory_bytes: 2420
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(ll i=a;i<=b;i++)
const ll max_n = 2e5+5;

int main() {
    // your code goes here
    ll n, k, h[max_n], sum = 0;
    cin >> n >> k;
    rep(i,0,n-1) cin >> h[i];
    sort(h, h + n);
    rep(i,0,n-k-1) sum += h[i];
    cout << sum << endl;
    return 0;
}

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

#define LL long long
#define DD long double

#define M 1000000007
#define INF 1e18

void setIO(string s = "") { 
  cin.sync_with_stdio(0); cin.tie(0);
  if (s.size()) s += ".in", freopen(s.c_str(), "r", stdin);
}

int tt = 1;
void solve() {
  double h, a;
  cin >> h >> a;
  int c = (int) ceil(h / a);
  cout << c << endl;

}

int main() {
  setIO();
  while (tt--) {
    solve();
  }
  return 0;
}

Measured memory_bytes: 3744
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
ll ans = 0;
bool prime(int num){
  if (num < 2)
    return false;
  else if (num == 2)
    return true;
  else if (num % 2 == 0)
    return false;

  double sqrtNum = sqrt(num);
  for (int i = 3; i <= sqrtNum; i += 2)
  {
    if (num % i == 0)
    {
      return false;
    }
  }
  return true;
}
map<ll,ll> primefactor(ll n){
  map<ll,ll> div;
  ll nn=n;
  for (ll i = 2; i*i <= nn; i++)
  {
    if (n % i == 0)
    {
      div[i]++;
      n/=i;
      i--;
    }
  }
  if(n!=1)div[n]++;
  return div;
}
int main()
{
ll a , b ;
cin >> a >> b ;
if(a==b&&prime(a)){
  cout << 2 << endl;
  return 0;
}
map<ll,ll> p=primefactor(a);
map<ll,ll> pb=primefactor(b);
for (auto i = p.begin(); i != p.end(); ++i) {
  if(pb[i->first]!=0)ans++;
}
cout << ans+1 << endl;
return 0;
}


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

int main() {
    lint n, m;
    cin >> n >> m;
    if (n > m) swap(n, m);
    lint res;
    if (n == 1) {
        if (m == 1) {
            res = 1;
        } else {
            res = m - 2;
        }
    } else {
        res = (n - 2) * (m - 2);
    }
    cout << res << endl;
}

Measured memory_bytes: 256
A, B, M = map(int, input().split())
list_a = []
list_b = []
list_x = []
list_y = []
list_c = []
sum = []

a = input()
list_a = a.split()

b = input()
list_b = b.split()

for i in range(0, M):
    x, y, c = map(int, input().split())
    list_x.append(x)
    list_y.append(y)
    list_c.append(c)

list_d = sorted(list_a)
list_e = sorted(list_b)

sum_1 = int(list_d[0]) + int(list_e[0])
sum.append(sum_1)

for k in range(0, M):
    x_1 = int(list_x[k])
    y_1 = int(list_y[k])
    sum_2 = int(list_a[x_1-1]) + int(list_b[y_1-1]) - list_c[k]
    sum.append(sum_2)

print(min(sum))


Measured memory_bytes: 35108
#include <iostream>
#include <cmath>

using namespace std;

int const N = 1000000;

int ps[N+1];
int cnt[N+1]={};

bool isp[N+1]={};

int idx=0;
inline void add(int n){
    ps[idx++]=n;
}

void init(){
    for(int i=0; i<=N; i++) isp[i]=true;
    add(2);
    for(int i=4; i<=N; i+=2) isp[i]=false;
    for(int i=3; i<=N; i+=2){
        if(!isp[i]) continue;
        add(i);
        for(int j=i+i; j<=N; j+=i) isp[j]=false;
    }
}

int main(){
    init();

    int n;
    while(cin>>n, n){
        int ans = 0;
        for(int i=0; i<idx; i++){
            if(n-ps[i]<0 || ps[i] > n-ps[i]) break;
            if(isp[n-ps[i]]) ans++;
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 4184
#include<bits/stdc++.h>
using namespace std;
int a[101],b[101];
int main(){
	int i,n,ans=0,mn=101;
	cin>>n;
	for(i=1;i<=n;i++){
		cin>>a[i];
		ans+=a[i];
		if(a[i]%10!=0&&a[i]<mn) mn=a[i];
	}
	if(ans%10!=0){
		cout<<ans;return 0;
	}else{
		if(mn==101) cout<<0;
		else cout<<ans-mn;	
	}
	return 0;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
int main() {
    long long n, idx, ans = 0;
    long long a[100001] = {0};
    cin >> n;
    rep(i, n){
        cin >> idx;
        a[idx] += 1;
        ans += idx;
    }
 
    int q;
    cin >> q;
    rep(i, q){
        long long b, c, increment, elements_were_b;
        cin >> b >> c;
        
        increment = c - b;
        elements_were_b = a[b];
        a[c] += a[b];
        a[b] = 0;
        ans += increment * elements_were_b;
 
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 4388
#include <iostream>
#include <set>

using namespace std;

#define MAX_N 200005
int A[MAX_N];
multiset<int> inverted;

int invert(int x) {
    int inv{1};
    while (inv <= x) inv <<= 1;
    return inv - x;
}

int main() {
    int N; scanf("%d", &N);
    for (int i{}; i < N; ++i) scanf("%d", &A[i]);
    sort(A, A + N);

    int count{};
    for (int i{N-1}; i >= 0; --i) {
        if (inverted.count(A[i])) {
            ++count;
            inverted.erase(inverted.find(A[i]));
        } else {
            inverted.insert(invert(A[i]));
        }
    }

    printf("%d\n", count);
    return 0;
}


Measured memory_bytes: 10368
#include <iostream>
#include <cmath>
#include <algorithm>
#include <cstdio>
#include <sstream>
#include <string>
#include <map>
#include <set>
using namespace std;

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

using namespace std;

int main(){
    int n;
    while(cin>>n && n){
        cin.ignore();
        map<char,map<string,int>> m;
        m.clear();
        rep(i,n){
            string s;
            getline(cin,s);
            stringstream ss(s);
            string w;
            while(ss >> w){
                m[w[0]][w]++;
            }
        }
        char c;
        cin >> c;
        typedef pair<string,int> P;
        vector<P> v(m[c].begin(),m[c].end());
        sort(v.begin(),v.end(),[](const P& a, const P& b){
                if(a.second != b.second) return a.second > b.second;
                return a.first < b.first;
            });
        if(v.size()){
            int l=min<int>(5,v.size());
            rep(i,l){
                cout << v[i].first;
                if(i==l-1)cout<<endl;
                else cout << " ";
            }
        }else{
            cout << "NA" << endl;
        }
    }
}

Measured memory_bytes: 1244