akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,digit;
    cin>>n;
    
       if(n%10==3)
        {
            cout<<"bon"<<endl;
            //break;
        }
        else if(n%10==0||n%10==1||n%10==6||n%10==8)
        {
            cout<<"pon"<<endl;
        }
        else
        {
            cout<<"hon"<<endl;
        }
    
}

Measured memory_bytes: 3592
# -*- coding: utf-8 -*-
import numpy as np
from collections import deque
from collections import defaultdict
import heapq
import collections
import itertools
import bisect


mod = 10 ** 9 + 7
N = int(input())
A, B = [0]*N, [0]*N
time = 0
for i in range(N):
    a, b = list(map(int, input().split()))
    A[i] = a
    B[i] = b

tmp = zip(B, A)
tmp = sorted(tmp)
for b, a in tmp:
    time += a
    if (time > b):
        print('No')
        exit()
print('Yes')
# for deadline in sorted(cost.keys()):
#     time += cost[deadline]
#     print(deadline)


Measured memory_bytes: 41784
#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 pq priority_queue
#define P pair<int,int>
#define P2 pair<int,P>
#define P3 pair<int,P2>
typedef long long ll; typedef long double ld;
using namespace std;
const int INF=1e9, MOD=1e9+7, around[]={0,1,1,-1,-1,0,-1,1,0,0};
const ll LINF=1e18;
const ld PI=abs(acos(-1));
int n,q;

struct SegmentTree{
	vector<int> data;
	int sz;
	
	SegmentTree(int n){
		sz = 1;
		while(sz<n) sz *= 2;
		data.assign(2*sz, 0);
	}
	
	void update(int k,int x){
		k += sz-1;
		data[k] += x;
		while(k){
			k = (k-1)/2;
			data[k] = data[2*k+1] + data[2*k+2];
		}
	}
	
	int get(int a,int b){
		return _get(a, b, 0, 0, sz);
	}
	
	int _get(int a,int b,int k,int l,int r){
		if(b<=l||r<=a) return 0;
		if(a<=l&&r<=b) return data[k];
		
		return _get(a, b, 2*k+1, l, (l+r)/2) + _get(a, b, 2*k+2, (l+r)/2, r);
	}
};

int main(){
	cin >> n >> q;
	
	SegmentTree seg(n);
	REP(i,0,q){
		int a,b,c;
		cin >> a >> b >> c;
		if(a == 0) seg.update(b-1,c);
		else if(a == 1) cout << seg.get(b-1, c) << endl;
	}
	return 0;
}



Measured memory_bytes: 3904
#include <iostream>

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

int main(void){
    int n, m; scanf("%d%d", &n, &m);
    int A[n+1][m+1];
    rep_eq(i, n) A[i][m] = 0; rep_eq(j, m) A[n][j] = 0;
    rep(i, n) rep(j, m){
        scanf("%d", &A[i][j]);
        A[i][m] += A[i][j];
        A[n][j] += A[i][j];
        A[n][m] += A[i][j];
    }
    rep_eq(i, n) rep_eq(j, m){
        printf("%d", A[i][j]);
        putchar(j == m ? '\n' : ' ');
    }
    return 0;
}


Measured memory_bytes: 3260
list=[int(input()) for i in range(20)]

W=[]
for j in range(10):
    W.append(list[j])
K=[]
for n in range(10,20):
    K.append(list[n])

w=sorted(W)
k=sorted(K)

wsum=0
ksum=0

for m in range(7,10):
    wsum+=int(w[m])
    ksum+=int(k[m])

print(wsum,ksum)


Measured memory_bytes: 5604
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <numeric>
typedef long long Int;
#define rep(i,a,b) for(Int i=a;i<b;++i)
#define rrep(i,a,b) for(Int i=a;i>=b;--i)
using namespace std;

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

    Int N; cin >> N;
    vector<pair<Int, Int>> X(N);
    vector<Int> res(N);
    rep(i, 0, N) {
        Int x; cin >> x;
        X[i] = make_pair(x, i);
    }
    sort(X.begin(), X.end());
    reverse(X.begin(), X.end());

    rep(i, 0, N/2) res[X[i].second] = X[N/2].first;
    rep(i, N/2, N) res[X[i].second] = X[N/2-1].first;

    rep(i, 0, N) cout << res[i] << "\n";
}


Measured memory_bytes: 6912
#include<stdio.h>

int main(){

	int N=0;
	int sum=0;
	int max = 0;
	scanf("%d",&N);

	char S[N];
	scanf("%s",S);

	for(int i=0; i<N; i++){
		if(S[i]=='I'){
			sum ++;
		}else if(S[i]=='D'){
			sum--;
		}
		if( max < sum ){
			max = sum;
		}

	}

	printf("%d",max);

	return 0;


}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define INCANT cin.tie(0), ios::sync_with_stdio(false), cout << fixed << setprecision(20);
#define int long long
#define double long double
#define vi vector<int>
#define vd vector<double>
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define sz(x) (x).size()
#define all(x) (x).begin(), (x).end()
#define sortv(v) sort(all(v))
#define sortg(v) sort(all(v), greater<int>())
#define countv(v, c) count(all(v), c)
#define gcd __gcd
#define _rep(i, m, n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i, n) _rep(i, 0, n)
#define _rev(i, m, n) for(int i=(int)(m-1);i>=(int)(n);i--)
#define rev(i, n) _rev(i, n, 0)
#define each(i, n) for(auto&& i: n)
void in(){}
template<typename F, typename... R>
bool in(F& f, R&... r){
	if(cin >> f){in(r...);return true;}
	else{return false;}
}
#define inv(x) each(i, x) in(i)
#define out(x) cout << (x)
#define space() cout << " "
#define indent() cout << '\n'
void print(){}
template<typename F, typename... R>
void print(F f, R... r){out(f), indent(), print(r...);}
#define printv(x) each(i, x) out(i), space(); indent()
#define debughead(x) cerr << "Line " << __LINE__ << ": " << #x << ": "
#define debugout(x) cerr << (x) << " "
#define debugindent() cerr << '\n'
#define debug(x) debughead(x), debugout(x), debugindent()
#define debugv(x) debughead(x); each(i, x) debugout(i); debugindent()
#define YN(x) out((x) ? "YES" : "NO"), indent()
#define Yn(x) out((x) ? "Yes" : "No"), indent()
#define yn(x) out((x) ? "yes" : "no"), indent()
const int INF = 1e18;
const int MOD = 1e9 + 7;
const double EPS = 1e-15;
const double PI = acos(-1);
const int dx[] = {0, 0, 1, 0, -1, -1, 1, 1, -1};
const int dy[] = {0, -1, 0, 1, 0, -1, -1, 1, 1};
const string alphabet = "abcdefghijklmnopqrstuvwxyz";
const string ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
template<typename T>
bool chmax(T& a, T b){return (a = max(a, b)) == b;}
template<typename T>
bool chmin(T& a, T b){return (a = min(a, b)) == b;}
int lcm(int a, int b){return a / gcd(a, b) * b;}
int factorial(int a){return a < 2 ? 1 : factorial(a - 1) * a;}
int summation(int a){return a < 1 ? 0 : (a * a + a) / 2;}
int combination(int n, int r){
	int res = 1;
	_rep(i, 1, r + 1){
		res *= n--, res /= i;
	}
	return res;
}
bool isPrime(int n){
	_rep(i, 2, sqrt(n) + 1){
		if(i > 3){
			i++;
		}
		if(!(n % i)){
			return false;
		}
	}
	return true;
}
vector<int> divisor(int n){
	vector<int> ans;
	_rep(i, 1, sqrt(n) + 1){
		if(!(n % i)){
			ans.pb(i);
			if(i * i < n){
				ans.pb(n / i);
			}
		}
	}
	return ans;
}
map<int, int> factorization(int n){
	map<int, int> ans;
	_rep(i, 2, sqrt(n) + 1){
		if(i > 3){
			i++;
		}
		while(!(n%i)){
			ans[i]++, n /= i;
		}
	}
	if(n > 1){
		ans[n]++;
	}
	return ans;
}
signed main(){INCANT;
	/*-----------------------------------------------*/
	
	int A, B; in(A, B);
	print(lcm(A, B));

	/*-----------------------------------------------*/
}

Measured memory_bytes: 256
#!/usr/bin/env python3
n = int(input())
a = list(map(int, input().split()))
s = [0] * (n + 2)
rs = [0] * (n + 2)
for i in range(n):
    s[i + 1] = s[i] ^ a[i]
    rs[n - i] = rs[n - i + 1] ^ a[-i - 1]
ans = all(a[i] == rs[i + 2] ^ s[i] for i in range(n))
print(['No', 'Yes'][ans])


Measured memory_bytes: 14120
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
#define INF 100000000
#define rep(i,a,b) for(int (i)=a;(i)<(int)(b);(i)++)

int main(){
    int A,B,C,D;
    cin >> A >> B >> C >> D;
    int takahashi = C/B;
    if(C%B !=0) takahashi ++;
    int aoki = A/D;
    if(A%D !=0) aoki++;
    if(takahashi<=aoki) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

int main()
{
    int H, W, N;
    cin >> H >> W >> N;
    vector<pair<int, int>> color(N);
    rep(i, N)
    {
        int a;
        cin >> a;
        color[i] = make_pair(a, i + 1);
    }
    sort(color.rbegin(), color.rend());
    vector<int> ans;
    rep(i, N)
    {
        rep(j, color[i].first)
        {
            ans.push_back(color[i].second);
        }
    }

    rep(i, H)
    {
        rep(j, W)
        {
            if (i % 2 == 0)
                cout << ans[i * W + j] << " ";
            else
                cout << ans[i * W + W - 1 - j] << " ";
        }
        cout << endl;
    }

    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vel;
typedef vector<int> vei;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> ve_vel;
typedef vector<vector<int>> ve_vei;
typedef vector<vector<char>> ve_vec;
typedef vector<vector<bool>> ve_veb;
typedef vector<vector<string>> ve_ves;
#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 rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pub push_back
#define puf push_front
#define pob pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }



int main() {
    int X, A, B, N; cin >> X >> A >> B >> N;
    rep(i,N) {
        string s; cin >> s;
        if(s[0] == 'n') X = max(X + A, 0);
        if(s[0] == 't') X = max(X+B, 0);
        if(s[0] == 'k') X = 0;
    }
    cout << X << endl;
    return 0;
}


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

memo = collections.defaultdict(lambda : 0)

for i in a:
    memo[i] = memo[i] + 1

b = sorted(memo.keys(), reverse=True)

ret = 0
pot = [1] * 35
for i in range(len(pot)-1):
    pot[i+1] = pot[i] * 2

for i in b:
    for j in range(34, -1, -1):
        if pot[j] - i <= 0:
            t = pot[j+1] - i
            break

    if i == t:
        ret += memo[i] // 2
    else:
        c = min([memo[i], memo[t]])
        memo[t] -= c
        ret += c

print(ret)

Measured memory_bytes: 56004
input_data = [int(i) for i in input().split()]
W = input_data[0]
H = input_data[1]
x = input_data[2]
y= input_data[3]
r = input_data[4]
if ((x+r)<=W and (x-r)>=0) and ((y+r)<=H and (y-r)>=0):
	print("Yes")
else:
	print("No")
	

Measured memory_bytes: 7728
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <stack>
#include <numeric>
#include <algorithm>
#include <stdio.h>
#include <bitset>
#include <complex>
#include <math.h>
#include <iomanip>
using namespace std;
//using ll = long long;
#define MM 1000000000
#define MOD MM+7
#define pi pair<int32,int32>
#define pl pair<int64,int64>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
const long double PI = acos(-1);
const long long INF = 1e15;
int dx[8] = {-1,0,1,0,-1,-1,1,1};
int dy[8] = {0,-1,0,1,-1,1,1,-1};
template<typename T>
T GCD(T u,T v){
    return v ? GCD(v,u%v) : u;
}
int main(){
    vector<int> ans(0);
    double m,n,y; cin >> m;
    for (int i = 0; i < m; i++){
        int res = 0;
        int sum;
        cin >> sum >> y >> n;
        int check;
        double per,giv;
        for(int j = 0; j < n; j++){
            cin >> check >> per >> giv;
            int tmp = 0,sum2 = sum;
            if (check == 0){
                for (int k = 0; k < y; k++){
                    tmp += sum2*per;
                    sum2 -= giv;
                }
                tmp += sum2;
            } else {
                for (int k = 0; k < y; k++){
                    sum2 *= (1.0+per);
                    sum2 -= giv;
                }
                tmp = sum2;
            }
            res = max(res,tmp);
        }
        ans.push_back(floor(res));
    }
    for(int i = 0; i < ans.size(); i++){
        cout << ans[i] << endl;
    }
}
  




Measured memory_bytes: 3220
// AOJ Volume 1 Problem 0159 The Best Body

#include <stdio.h>

#define ABS(x)  ((x) < 0.0 ? ((x) * -1.0) : (x))


double cal_bmi(int h, int w)
{
    double bmi;
    
    bmi = (double)w / ((h / 100.0) * (h / 100.0));
    
    return (bmi);
}

int main(void)
{
    int n;
    int i, h, w;
    double bmi;
    int ideal_no;
    double ideal_bmi;
    int j;

    while (1){
        scanf("%d", &n);
        if (n == 0){
            break;
        }
        scanf("%d%d%d", &i, &h, &w);

        ideal_no = i;
        ideal_bmi = cal_bmi(h, w);
        
        for (j = 1; j < n; j++){
            scanf("%d%d%d", &i, &h, &w);
            bmi = cal_bmi(h, w);
            if (ABS(22.0 - bmi) < ABS(22.0 - ideal_bmi)){
                ideal_no = i;
                ideal_bmi = bmi;
            }
        }
        printf("%d\n", ideal_no);
    }

    return (0);
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define rep(N) for (int i = 0; i < N; ++i)
#define Rep(a, b) for (int i = a; i < b; ++i)
#define For(i, N) for (int i = 0; i < N; ++i)
#define all(v) v.begin(), v.end()
#define rev(v) v.rbegin(), v.rend()
#define makei(N) int N; cin >> N;
#define makel(N) ll N; cin >> N;
#define makes(s) string s; cin >> s;
#define maked(d) double d; cin >> d;
#define makev(v, N) vi v(N); rep(N)cin >> v[i];
#define mod 1000000007
#define re return 0
#define distance(x1,y1,x2,y2) sqrt((x1 - x2)*(x1 - x2) + (y1 - y2)*(y1 - y2));

using namespace std;
using ll = long long int;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vector<bool>>;
using vs = vector<string>;
using pii = pair<int, int>;
using pis = pair<int, string>;
using msi = map<string, int>;

template<typename T>
void say(T s) {
	cout << s << "\n";
}

template<typename T>
void say(vector<T> s) {
	auto itr = s.begin();
	cout << *(itr++);
	while (itr != s.end()) {
		cout << " " << *(itr++);
	}
	cout << "\n";
}

void yn(bool b) {
	if (b)say("Yes");
	else say("No");
}

template<typename T>
void maxi(T &a, T b) {
	a = max(a, b);
}

template<typename T>
void mini(T &a, T b) {
	a = min(a, b);
}

int main() {
	makei(N);
  say(N<1000?"ABC":"ABD");
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
  int d,s;
  int t;
  while(scanf("%d",&d)!=EOF){
    s=0;
    for(t=d;t<600;t+=d){
      s+=t*t*d;
    }
    printf("%d\n",s);
  }
  return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
char s[105], t[105];
int main(){
	scanf("%s%s", s, t);
	int n = strlen(s);
	for(int i=0;i<n;i++){
		int p1 = i, p2 = 0;
		while(p2 < n && s[p1] == t[p2]){
			p1++;
			p2++;
			p1%=n;
		}
		if(p2 == n) return !printf("Yes\n");
	}
	printf("No\n");
}

Measured memory_bytes: 256
// This is the start of  template//
#include<bits/stdc++.h>
using namespace std;
#define endl "\n"
#define int long long int
#define double long long double
#define vll vector<int>
#define pb push_back
#define pll pair<int,int>
#define mp(a,b) make_pair(a,b)
#define ff first
#define ss second
void input(){
#ifndef ONLINE_JUDGE 
freopen("input.txt","r",stdin);
freopen("output.txt","w",stdout); 
#endif
}
#define INF LONG_LONG_MAX
#define mod 1000000007
#define array(a,n) vll a(n); rep(i,0,n) cin>>a[i];
#define all(x) x.begin(),x.end()
#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 cases int t; cin>>t; while(t--)
#define printall(a) rep(i,0,a.size()) cout<<a[i]<<" "; cout<<endl;

int32_t main()
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  input();
  int h,w,m,ans=0,ans2 = 0,flag = 1;
  cin>>h>>w>>m;
  vector<int>optx,opty;
  vector<int> x(h+1,0),y(w+1,0);
  map<pair<int,int>,int>targets;
  rep(i,0,m)
  {
    int x1,y1;
    cin>>x1>>y1;
    targets[{x1,y1}]++;
    x[x1]++;
    y[y1]++;
  }
  for(int x1 = 0 ;x1<=h ;x1++)
  {
     if(ans<=x[x1])
    {
      if(ans<x[x1])
        optx.clear();
      ans = x[x1];
      optx.push_back(x1);
    }
    
  }
   for(int y1 = 0 ;y1<=w ;y1++)
  {
     if(ans2<=y[y1])
    {
      if(ans2<y[y1])
        opty.clear();
      ans2 = y[y1];
      opty.push_back(y1);
    }
    
  }
  for(auto x1:optx)
  {
    for(auto y1:opty)
    {
        if(!targets.count({x1,y1}))
        {
          flag = 0;
          break;
        }
    }
  }
  cout<< ans + ans2 -flag<<endl;
  return 0;
}



Measured memory_bytes: 35048
#include <bits/stdc++.h>
 
using namespace std;
 
int arr[5][5];
 
int main()
{
  
  for(int i=1;i<=3;i++)for(int j=1;j<=3;j++)cin >> arr[i][j];
  
  int n ;
  cin >> n;
  while(n--)
  {
    int x;
    cin >> x;
    for(int i=1;i<=3;i++)for(int j=1;j<=3;j++)if(arr[i][j]==x)arr[i][j]=-1;
  }
  
  for(int i=1;i<=3;i++)
  {
    for(int j=1;j<=3;j++)
    {
      if(arr[i][j]==arr[i][j-1] and arr[i][j]==arr[i][j+1])
      {
        cout << "Yes";
        return 0;
      }
      if(arr[i][j]==arr[i-1][j] and arr[i][j]==arr[i+1][j])
      {
        cout << "Yes";
        return 0;
      }
      if(arr[i][j]==arr[i-1][j-1] and arr[i][j]==arr[i+1][j+1])
      {
        cout << "Yes";
        return 0;
      }
      if(arr[i][j]==arr[i-1][j+1] and arr[i][j]==arr[i+1][j-1])
      {
        cout << "Yes";
        return 0;
      }
    }
  }
  
  cout << "No";
  
  
}


Measured memory_bytes: 256
#!/usr/bin/env python3
n = int(input())
s = input()

lww = 0
lee = s[1:].count("E")
ans = lww + lee

for i in range(1, n):
    if s[i] == "E":
        lee -= 1
    if s[i - 1] == "W":
        lww += 1

    ans = min(ans, lee + lww)
    
print(ans)

Measured memory_bytes: 9732
#include <iostream>
//#include <algorithm>
#include <vector>
#define NMAX 105
#define WMAX 10005
//#define SELECTED 1
//#define UNSELECTED 0

using namespace std;

struct Item {
    int value,weight;
};

int N,W;
Item items[NMAX+1]; // ??°????¬¬i???????????????????????????
int C[NMAX+1][WMAX+1]; // C[i][w]??¨??????i??????????£???\?????????W???????????¶?????????????????§???
//int G[NMAX+1][WMAX+1]; // G[i][w]??°?????¨?????????w????????????????????????????¢??????????

void compute(int &maxValue
//            , vector<int> &selection
            ) {
    //????????§?°?w???0?????????????????°i???0??¶?????????????????????0?????????C???w=0???i=0????????????????´??????¨??¨????§???????0.
    for(int w=0;w<=W;w++)
        C[0][w]=0;
    for(int i=1;i<=N;i++)
        C[i][0]=0;
    
    for(int i=1;i<=N;i++) {
        for(int w=1;w<=W;w++) {
            C[i][w]=C[i-1][w];// C[i][w]????°??????\??§???C[i-1][w]?????§?°?
//            G[i][w]=UNSELECTED;
            if(items[i].weight>w) // ???????¬¬i???????????????????¶???????w?????£?????????????????????
                continue;
            if(items[i].value+C[i-1][w-items[i].weight]>C[i-1][w]){// ?????????????????¶??????
                C[i][w]=items[i].value+C[i-1][w-items[i].weight];// ??´?????¨???????????????w????????????????¬¬i??¶???????????\???
//                G[i][w]=SELECTED;
            }
        }
    }
    maxValue=C[N][W];
//    selection.clear();
//    for(int i=N,w=W;i>=1;i--) {
//        if(G[i][w]==SELECTED) {
//            selection.push_back(items[i].value);
//            w-=items[i].weight;
//        }
//    }
//    reverse(selection.begin(), selection.end());
}

void input() {
    cin>>N>>W;
    for(int i=1;i<=N;i++)
        cin>>items[i].value>>items[i].weight;
}

int main() {
    int maxValue;
    vector<int> selection;
    input();
    compute(maxValue
//            ,selection
    );

    cout<<maxValue<<endl;

    /*cout<<endl;
    for(int n=0;n<=N;n++)
    {
        for(int m=0;m<=W;m++)
        cout<<G[n][m]<<" ";
        cout<<endl;
    }*/
    /*cout<<"??????????????????????????????";
    for(int i=0;i<selection.size();i++)cout<<selection[i]<<" ";*/

}

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

int main(){
  int N,Y;
  cin >> N >> Y;
  int a=10000;
  int b=5000;
  int c=1000;
  int nmax=Y/a;
  rep(n,nmax+1){
    int mmax=(Y-a*n)/b;
    rep(m,mmax+1){
      if(a*n+b*m+c*(N-m-n)==Y){
	//cout << nmax << " " << mmax << endl;
	cout << n << " " << m << " " << N-m-n << endl;
	return 0;
      }
    }
  }
  cout << -1 << " " << -1 << " " << -1 << endl;
  return 0;

}


Measured memory_bytes: 256
a = int(input())
b = list(map(int,input().split()))
cost = [0]*a
cost[1] = abs(b[0] - b[1])
for i in range(2,a):
    cost[i] = min(cost[i-2] + abs(b[i-2] - b[i]),cost[i-1] + abs(b[i-1] - b[i]))
print(cost[a-1])

Measured memory_bytes: 13928
#include <cstdio>
#include <algorithm>

using namespace std;

char grid[5][5][4];
char puzzles[9][7];
bool mask[5][5]={
    {1,1,1,1,1},
    {1,0,0,0,1},
    {1,0,0,0,1},
    {1,0,0,0,1},
    {1,1,1,1,1}
};

const int diff=abs('A'-'a');

int solve(int pos,int comb){
    // printf("pos=%d\n",pos);
    if (pos>=9) return 1;
    int x=pos%3+1,y=pos/3+1;
    int ret=0;

    //全てのパズルを試す
    for(int pid=0;pid<9;pid++){
        if ((1<<pid)&comb) continue;
        // printf("pid=%d\n",pid);
        const auto &pz=puzzles[pid];

        //パズルを回す
        for(int r=0;r<4;r++){
            if (!mask[x-1][y]&&abs(grid[x-1][y][2]-pz[r])!=diff) continue;
            if (!mask[x][y-1]&&abs(grid[x][y-1][3]-pz[(r+1)%4])!=diff) continue;
            // puts("rot");
            for(int i=0;i<4;i++) grid[x][y][i]=pz[(r+i)%4];
            ret+=solve(pos+1,comb|(1<<pid));
        }

    }

    return ret;
}

int main(){

    int n;
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        for(int i=0;i<9;i++) scanf("%5s",puzzles+i);
        // for(int i=0;i<9;i++) printf("%s\n",puzzles+i);
        printf("%d\n",solve(0,0));

    }

    return 0;
}


Measured memory_bytes: 2580
#include "bits/stdc++.h"
#define ll long long
#define rep2(i,a,b) for(int i=a;i<=b;++i)
#define rep(i,n) for(int i=0;i<n;i++)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define tii tuple<int,int,int>
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define edge(v,a,b) v[a].pb(b);v[b].pb(a);
ll MOD=1e9+7;
#define INF 2*1e9
#define N 1000010
#define MAX_V 900010
using namespace std;
ll int inv[N],comb[N],prd[N],invprd[N];
void calc_inv(){
    inv[1]=1;
    rep2(i,2,N){
        inv[i]=((-(MOD/i)*inv[MOD%i])%MOD+MOD)%MOD;
    }
    return;
}
void calc_comb(ll int n){
    comb[0]=1;
    rep2(i,1,n){
        comb[i]=comb[i-1]*(n+1-i)*inv[i]%MOD;
    }
    return;
}
void calc_product(){
    prd[0]=prd[1]=1;
    invprd[0]=invprd[1]=1;
    rep2(i,2,N){
        prd[i]=i*prd[i-1]%MOD;
        invprd[i]=inv[i]*invprd[i-1]%MOD;
    }
    return ;
}
ll cmb(int a,int b){
    return prd[a]*invprd[b]%MOD*invprd[a-b]%MOD;
}
ll modpow(ll x,ll n){
    if(n==0) return 1;
    ll res=modpow(x*x%MOD,n/2);
    if(n&1) res=res*x%MOD;
    return res;
}
main(){
    int n,m,x,y;
    cin>>n>>m>>x>>y;
    int xx=x,yy=y;
    rep(i,n){
        int t;cin>>t;
        xx=max(xx,t);
    }
    rep(i,m){
        int t;cin>>t;
        yy=min(yy,t);
    }
    if(xx<yy)cout<<"No War";
    else cout<<"War";
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
money = 1000
stock = 0
for i in range(N-1):
    if A[i+1] > A[i]:
        stock = money // A[i]
        money = money % A[i]
        money += stock * A[i+1]
print(money)

Measured memory_bytes: 9188
#include <iostream>
#include <fstream>
#include <cstdio>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <stack>
#include <queue>
#include <algorithm>
#include <string.h>
#include <string>
#include <math.h>
#include <iomanip>
using namespace std;

#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define pb push_back

typedef pair<int, int> pii;
typedef long long ll;
typedef unsigned long long ull;

const int mod = (int)1e9 + 7;
const int mod2 = 998244353;

ll exp(ll taban, ll us, ll md) {
    ll carpan = taban % md;
	if(carpan == 0) return 0;
    ll temp = us;
    ll res = 1;
    while(temp){
        if(temp % 2) res = (res*carpan) % md;
        temp /= 2;
        carpan = (carpan*carpan) % md;
    }
    return res;
}
 
ll ebob(ll a, ll b){
    if(!a)return b;
    return ebob(b%a, a);
}

ll ekok(ll a, ll b){
    return (a*b)/ebob(a, b);
}

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

vector<ll> fact;
vector<ll> inv_fact;
void fact_init(int n){
	fact.resize(n+5);
	inv_fact.resize(n+5);
	fact[0] = inv_fact[0] = 1;
	for(int i = 1; i <= n; i++){
		fact[i] = (fact[i-1] * i) % mod;
		inv_fact[i] = exp(fact[i], mod-2, mod);
	}
}

ll komb(ll a, ll b){
	if(a < b) return 0;
	return fact[a] * (inv_fact[a-b] * inv_fact[b] % mod) % mod;
}

const int N = 1e5+5;
int ans;

int main(){
	ios::sync_with_stdio(false); cin.tie(NULL);
	int n, k, q; cin>>n>>k>>q;
	int cnt[n+1] = {};
	int top = q;
	while(q--){
		int s; cin>>s; cnt[s]++;
	}
	for(int i = 1; i <= n; i++) cnt[i] = k - top + cnt[i];
	for(int i = 1; i <= n; i++) cnt[i] > 0 ? cout<<"Yes\n" : cout<<"No\n";
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int mod=7+1e9;
ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
ll lcm(ll x,ll y){return x/gcd(x,y)*y;}
ll qpow(ll a,ll b,ll p){a%=p; ll ret=1;for(;b;b>>=1,a=a*a%p) if(b&1) ret=ret*a%p; return ret;}
ll getInv(ll x,ll p){return qpow(x,p-2,p);}

int main(){
    string s; cin>>s;
  	if(s=="ABC") puts("ARC");
  	else puts("ABC");
}

Measured memory_bytes: 3588
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace AOJ_Practice
{
    class Program
    {
        static void Main(string[] args)
        {
            var questStr = Console.ReadLine();
            var targetStr = Console.ReadLine();

            var isMatch = false;
            for (int i = 0; i < questStr.Length; i++)
            {
                var questIndex = i;
                var targetIndex = 0;
                for (int j = 0; j < targetStr.Length; j++)
                {

                    if (targetStr[targetIndex] != questStr[questIndex])
                    {
                        // 不一致なら抜ける
                        break;
                    }
                    // 最後の文字列以外ならカウントアップする
                    else if (j + 1 != targetStr.Length)
                    {
                        questIndex = ++questIndex >= questStr.Length ? 0 : questIndex;
                        targetIndex++;
                        continue;
                    }
                    else
                    {
                        // 最後まで一致した場合trueにする。
                        isMatch = true;
                    }
                }

                if (isMatch)
                {
                    break;
                }
            }

            Console.WriteLine(isMatch ? "Yes" : "No");
        }
    }
}



Measured memory_bytes: 15896
# -*- coding: utf-8 -*-
# テキストの入力
S = input()
T = input()

#　文字数取得
mojisuu=len(S)
Ans=0

# 文字数分ループを回して1文字ずつ比較
for i in range(mojisuu):
  if S[i] != T[i]:
    Ans += 1

print(Ans)

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

int main(){
    ll X,Y; cin>>X>>Y;
    for (int i = 0; i < 101; i++){
        for (int j = 0; j < 101; j++){
            if(i+j==X&&2*i+4*j==Y){
                cout<<"Yes"<<endl;
                return 0;
            }
        }
    }
    cout<<"No"<<endl;
    
}

Measured memory_bytes: 3624
#include <stdio.h>

int main() {
    int n = 0;
    scanf("%d\n", &n);
    int max = 0;
    int sum = 0;
    int buf = 0;
    for (int i=0; i<n; i++) {
        scanf("%d", &buf);
        sum += buf;
        if (buf > max) max = buf;
    }
    printf("%d\n", sum - max/2);
    return 0;
}


Measured memory_bytes: 128
package main

import (
	"fmt"
)

func main(){
	var x, y int
	fmt.Scan(&x, &y)
	if x < y{
		x, y = y, x
	}
	for{
		if x == 0{
			fmt.Println(y)
			break
		} else if y == 0{
			fmt.Println(x)
			break
		}
		x, y = y, x%y
	}
}


Measured memory_bytes: 1160
#include <bits/stdc++.h>
 
using namespace std;
#define ll long long
const ll INF=1e15;
#define int long long
#define pb push_back
#define mp make_pair
#define endl "\n"
#define fastio cin.tie(NULL); cout.tie(NULL); ios_base::sync_with_stdio(false)
const double pi = acos(-1.0);
int gcd (int a, int b) {
    while (b) {
        a %= b;
        swap(a, b);
    }
    return a;
}
int lcm (int a, int b) {
    return a / gcd(a, b) * b;
}

long long binpows(long long a, long long b) {
    long long res = 1;
    while (b > 0) {
        if (b & 1)  //impar
            res = res * a;
        a = a * a;
        b >>= 1;  // /2
    }
    return res;
}
const int mod=1e9+7;
int binpow(int a, int b, int m) {
    a %= m;
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a % m;
        a = a * a % m;
        b >>= 1;
    }
    return res;
}
//CHECAR SE PRECISA DE LONG LONG
int n,m;
char mat[1234][1234];
int dp[1234][1234];
int resolve(int i, int j){
	if(i>=n or j>=m)
		return 0;
	if(mat[i][j]=='#')
		return 0;
	if(i==n-1 and j==m-1)
		return 1;
	int &x=dp[i][j];
	if(x!=-1)
		return x;
	x=0;
	x+=resolve(i+1,j);
	x+=resolve(i,j+1);
	return x%mod;
}
void solve(){
	memset(dp,-1,sizeof(dp));
	cin>>n>>m;
	for(int i=0; i<n; i++){
		for(int j=0; j<m; j++){
			cin>>mat[i][j];
		}
	}
	cout<<resolve(0,0)<<endl;
}
//revise as variaveis e a ordem nas funções
signed main(){
    int t=1;
    //cin>>t;
    while(t--){
        solve();
    }
}

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

int main(){
ll n;
cin>>n;
ll x[n][3];
for(int i=0;i<n;i++)
    for(int j=0;j<3;j++)
        cin>>x[i][j];
ll dp[n][3];
for(int i=0;i<3;i++)
    dp[0][i]= x[0][i];
for(int i=1;i<n; i++){
    dp[i][0]= x[i][0] + max(dp[i-1][1] , dp[i-1][2]);
    dp[i][2]= x[i][2] + max(dp[i-1][1] , dp[i-1][0]);
    dp[i][1]= x[i][1] + max(dp[i-1][0] , dp[i-1][2]);
}
cout<< max(dp[n-1][0], max(dp[n-1][1], dp[n-1][2]));
return 0;

}


Measured memory_bytes: 4992
data = []
kekka = []
for i in range(5):
    n = int(input())
    data.append(n)
for i in range(5):
    if data[i]<40:
        kekka.append(40)
    else:
        kekka.append(data[i])
print(int(sum(kekka)/5))        


Measured memory_bytes: 5596
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
using namespace std;
typedef pair<double,int> p;

int main(){
    vector<p> v,th;
    int n = 3,num;
    double data;
    
    while(n--){
        v.clear();
        for(int i = 0 ; i < 8 ; i++){
            cin >> num >> data;
            v.push_back(p(data,num));
        }
        sort(v.begin(),v.end());
        printf("%d %.2f\n" ,v[0].second,v[0].first);
        printf("%d %.2f\n" ,v[1].second,v[1].first);
        th.push_back(v[2]);
    }
    sort(th.begin(),th.end());
    printf("%d %.2f\n" ,th[0].second,th[0].first);
    printf("%d %.2f\n" ,th[1].second,th[1].first);
    return 0;
}

Measured memory_bytes: 1252
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>

using namespace std;

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

	int n, m;
	cin >> n >> m;
	vector<int> p(m);
	vector<vector<int>> sw(n);
	for (int bl = 0; bl < m; bl++) {
		int k;
		cin >> k;
		while (k--) {
			int x;
			cin >> x;
			x--;
			sw[x].push_back(bl);
		}
	}
	for (auto &t : p) {
		cin >> t;
		t ^= 1;
	}
	int ans = 0;
	for (int i = 0; i < (1 << n); i++) {
		vector<int> cp = p;
		for (int j = 0; j < n; j++) {
			if ((i >> j) & 1) {
				for (auto x : sw[j]) cp[x] ^= 1;
			}
		}
		int ok = 1;
		for (int j = 0; j < m; j++) {
			ok &= (cp[j]);
		}
		ans += ok;
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include<cstdio>
#include<utility>
#include<vector>
#include<cmath>
#include<algorithm>
using namespace std;

int g[100000]={};
int dfs(int n){
  if(g[n]==n)
    return n;
  g[n]=dfs(g[n]);
  return g[n];
}

int main(){
  int n,ans=0;
  vector<pair<int ,pair<int,int> > > e;
  pair<int,int> x[100000];
  pair<int,int> y[100000];
  scanf("%d",&n);
  for(int i=0;i<n;i++){
    g[i]=i;
    x[i].second=y[i].second=i;
    scanf("%d %d",&x[i].first,&y[i].first);
  }
  sort(x,x+n);
  sort(y,y+n);
  for(int i=0;i<n-1;i++){
    e.push_back(make_pair(abs(x[i].first-x[i+1].first),make_pair(x[i].second,x[i+1].second)));
    e.push_back(make_pair(abs(y[i].first-y[i+1].first),make_pair(y[i].second,y[i+1].second)));
  }
  sort(e.begin(),e.end());
  for(int i=0;i<e.size();i++){
    if(dfs(e[i].second.first)!=dfs(e[i].second.second)){
      //printf("g[%d]=%d g[%d]=%d\n",e[i].second.second,g[e[i].second.second],e[i].second.first,g[e[i].second.first]);
      if(g[e[i].second.first]<g[e[i].second.second])
        g[g[e[i].second.second]]=g[g[e[i].second.first]];
      else
        g[g[e[i].second.first]]=g[g[e[i].second.second]];
      ans+=e[i].first;
    }
    //printf("%d %d %d\n",e[i].second.second,e[i].second.first,e[i].first);
  }
  printf("%d\n",ans);
  /*for(int i=0;i<n;i++)
    printf("%d\n",g[n]);*/
}

Measured memory_bytes: 6900
#include<iostream>
#include<algorithm>
using namespace std;
 
int i,j,k,h,w,ii,jj,cnt=0,ans=0;
int a[6],b[6];
char c[6][6];
 bool f=0;
 
int main (void)
{
 
  cin>>h>>w>>k;
  for(i=0;i<h;i++)for(j=0;j<w;j++)cin>>c[i][j];
  int n=1;
  for(i=0;i<h+w;i++){n*=2;}
  for(i=0;i<n;i++)
  {
    int aa=i;
    for(j=0;j<h+w;j++)
    {
      if(j<h){a[j]=aa%2;}
      else{b[j-h]=aa%2;}
      aa/=2;
    }
    for(ii=0;ii<h;ii++)
    {
      for(jj=0;jj<w;jj++)
      {
      if(a[ii]==0&&b[jj]==0&&c[ii][jj]=='#'){cnt++;}
      }
    }
    if(cnt==k)ans++;
    cnt=0;
  }
 
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3596
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>

using namespace std;

int main() {
	vector<string> masu;
	int H, W;

	cin >> H >> W;
	string box;
	for (int i = 0; i < H; i++) {
		cin >> box;
		masu.push_back(box);
	}

	string safe = ".";
	string out = "#";
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			int count = 0;

			if (masu[i].substr(j, 1) == safe) {
				if (j > 0)
					if (masu[i].substr(j - 1, 1) == out)
						count++;
				
				if (j < W - 1)
					if (masu[i].substr(j + 1, 1) == out)
						count++;

				if (i > 0)
					if (masu[i - 1].substr(j, 1) == out)
						count++;

				if (i < H - 1)
					if (masu[i + 1].substr(j, 1) == out)
						count++;

				if (i > 0 && j > 0)
					if (masu[i - 1].substr(j - 1, 1) == out)
						count++;

				if (i < H - 1 && j > 0)
					if (masu[i + 1].substr(j - 1, 1) == out)
						count++;

				if (i > 0 && j < W - 1)
					if (masu[i - 1].substr(j + 1, 1) == out)
						count++;

				if (i < H - 1 && j < W - 1)
					if (masu[i + 1].substr(j + 1, 1) == out)
						count++;

				masu[i][j] = ('0' + count);//charへのキャスト
			}
		}
	}

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

Measured memory_bytes: 256
import sys
a=[[0 for i in range(3)] for j in range(3)]
for i in range(3):
    a[i]=list(map(int,input().split()))
n=int(input())
for _ in range(n):
    m=int(input())
    for i in range(3):
        for j in range(3):
            if m==a[i][j]:
                a[i][j]=0
    for k in range(3):
        if a[k][0]==0 and a[k][1]==0 and a[k][2]==0:
            print('Yes')
            sys.exit()
        if a[0][k]==0 and a[1][k]==0 and a[2][k]==0:
            print('Yes')
            sys.exit()
    if a[0][0]==0 and a[1][1]==0 and a[2][2]==0:
        print('Yes')
        sys.exit()
    if a[0][2]==0 and a[1][1]==0 and a[2][0]==0:
        print('Yes')
        sys.exit()
print('No')

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

namespace ABC044_C
{
    class Program
    {

        static void Main()
        {
            var array = Utility.ReadIntArray();
            var N = array[0];
            var A = array[1];
            var X = Utility.ReadIntArray();

            var dp = new long[N + 1, N + 1, (N + 1) * 50];
            dp[0, 0, 0] = 1;
            for (var i = 0; i < N; i++)
            {
                for (var j = 0; j < N; j++)
                {
                    for (var k = 0; k < dp.GetLength(2); k++)
                    {
                        if (dp[i, j, k] != 0)
                        {
                            dp[i + 1, j, k] += dp[i, j, k];
                            dp[i + 1, j + 1, k + X[i]] += dp[i, j, k];
                        }
                    }
                }
            }
            long ans = 0;
            for (var i = 1; i <= N; i++)
            {
                ans += dp[N, i, i * A];
            }
            Console.WriteLine($"{ans}");
        }
    }
    public static class Utility
    {
        public static string ReadString() => Console.ReadLine();
        public static string[] ReadStringArray() => ReadString().Split(' ');
        public static int ReadInt() => int.Parse(ReadString());
        public static int[] ReadIntArray() => ReadStringArray().ParseInt().ToArray();
        public static IEnumerable<int> ParseInt(this IEnumerable<string> source) => source.Select(v => int.Parse(v));
    }
}


Measured memory_bytes: 64352
#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;

class UnionFind {
    public:
        vector<ll> rank, p, size;

        UnionFind() {}
        UnionFind(int s) {
            rank.resize(s, 0);
            p.resize(s, 0);
            size.resize(s, 0);
            rep (i, s) makeSet(i);
        }

        void makeSet(int x) {
            p[x] = x;
            rank[x] = 0;
            size[x] = 1;
        }

        bool same(int x, int y) {
            return findSet(x) == findSet(y);
        }

        void unite(int x, int y) {
            link(findSet(x), findSet(y));
        }

        void link(int x, int y) {
            if (rank[x] > rank[y]) {
                p[y] = x;
                size[x] += size[y];
            } else {
                p[x] = y;
                size[y] += size[x];
                if (rank[x] == rank[y]) {
                    rank[y]++;
                }
            }
        }

        int findSet(int x) {
            if (x != p[x]) {
                p[x] = findSet(p[x]);
            }
            return p[x];
        }

        ll getSize(int x) {
            return size[findSet(x)];
        }
};

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    ll n, m;
    cin >> n >> m;
    vector<int> a(m), b(m);
    vector<ll> v(m + 1);
    UnionFind uf = UnionFind(n);
    rep (i, m) {
        cin >> a[i] >> b[i];
        a[i]--, b[i]--; 
    }
    v[m] = n * (n - 1) / 2;
    for (int i = m - 1; i >= 0; --i) {
        if (uf.same(a[i], b[i])) {
            v[i] = v[i + 1];
            continue;
        }
        ll sa, sb;
        sa = uf.getSize(a[i]), sb = uf.getSize(b[i]);
        v[i] =  v[i + 1] - sa * sb;
        uf.unite(a[i], b[i]);
    }

    FOR (i, 1, v.size()) {
        cout << v[i] << endl;
    }
    
    return 0;
}



Measured memory_bytes: 5248
#include"bits/stdc++.h"
using namespace std;
namespace ORIGIN {
#define LL long long
#define VLL vector<long long>
#define SORT(x) sort(x.begin(),x.end())
#define REVE(x) reverse(x.begin(),x.end())
#define rep(i,n) for(int i=0;i<n;i++)
#define COUT(x) cout<<x<<endl
#define WHOLE(x) x.begin(),x.end()
	double pai = 3.1415926535;
	string atc = "atcoder";
	typedef pair<long long, long long> data_t;
	string strnum = "0123456789";
	string alpS = "abcdefghijklmnopqrstuvwxyz";
	string alpL = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
	int sizealp = (int)(alpS.size());
	int mod = 1e9 + 7;
	bool test = false;
}
using namespace ORIGIN;

void Test(char a) {
	if (test) {
		printf("%c", a);
	}
}
int gcd(LL a, LL b) {
	if (a == 0 || b == 0)return 0;
	if (a < b)swap(a, b);
	if (a % b == 0)return b;
	else gcd(b, a % b);
}
vector<int> nsinsuu(int base,int keta) {

}
int main() {
	string s;
	cin >> s;
	bool MMYY=false, YYMM=false;
	if ((s[2] == '0' && s[3] != '0') || (s[2] == '1' && (s[3] == '0' || s[3] == '1' || s[3] == '2')))MMYY = true;
	if ((s[0] == '0' && s[1] != '0') || (s[0] == '1' && (s[1] == '0' || s[1] == '1' || s[1] == '2')))YYMM = true;
	if (MMYY) {
		if (YYMM) {
			COUT("AMBIGUOUS");
		}
		else
			COUT("YYMM");
	}
	else if (YYMM)
		COUT("MMYY");
	else
		COUT("NA");
	return 0;
}


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

using namespace std;
int i, N, M;
pair<int, int> PD[10010];

struct sort_first{
    bool operator()(const std::pair<int,int> &left, const std::pair<int,int> &right) {
        return left.first < right.first;
    }
};
int main(){
  while (cin >> N >> M){
    if(N == 0 && M == 0){break;}
    int d = 0, p = 0;
    for (i = 0; i < 10010; ++i){
      PD[i] = make_pair(p,d);
    }
    for (i = 0; i < N; ++i){
      cin >> d >> p;
      PD[i] = make_pair(p,d);
    }
    sort(begin(PD), end(PD), sort_first());
    reverse(begin(PD), end(PD));
    // for (i = 0; i < N; ++i){
    //   cout << PD[i].first << endl; 
    // }
    int S = 0;
    for (i = 0; i < N; ++i){S += PD[i].first * PD[i].second;}
    for (i = 0; i < N; ++i){
      if(M <= 0){break;}
      int guarded = min(M, PD[i].second);
      S -= PD[i].first * guarded;
      M -= guarded;
    }
    cout << S << endl;
  }
}

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(a)     (a).begin(),(a).end()
#define VI         vector<int>
#define MOD 1000000007

typedef long long int ll;

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

const ll INF=(ll)1e19;
//const int INF=(1<<30);

int main(){
  ll a,b,n;

  cin >> a >> b >> n;

  ll x = min(b-1, n);

  cout << (a*x)/b - a*(x/b) << endl;

}



Measured memory_bytes: 3604
#include <bits/stdc++.h>
#define ll long long int
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define pi 3.141592653589793
using namespace std;


int main() {
//    cout << fixed << setprecision(10);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    string s;
    cin >> s;
    cout << string((int) s.size(), 'x');

}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#define REP(i,n) for(int i=0;i<n;i++)
using namespace std;

int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);
   	int a[5];
   	int sum = 0;
   	int point = 0;
   	int where = 0;
   	REP(i, 5){
   		//int a;
   	    cin >> a[i];
   	    int tmp =  (int)((a[i]+9)/10)*10;
   	    if(tmp - a[i] > point){
   	    	point = tmp - a[i];
   	    	where = i;
   	    }
   	    
   	    //cout << i << a << "\n";
   	}
   	REP(i, 5){
   		if(i != where)sum += (int)((a[i]+9)/10)*10; else sum+=a[i];
   	}
   	cout <<sum << endl;
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
namespace AtCoder
{
    class Program
    {
        static public int[] Sarray() { return ReadLine().Split().Select(int.Parse).ToArray(); }
        static public List<int> Slist() { return ReadLine().Split().Select(int.Parse).ToList(); }

        static int N;
        static int[,] Move;
        static int[,] dp;
        static void Main(string[] args)
        {
            var NW = Sarray();
            var N = NW[0];
            var W = NW[1];
            var v = new long[N];
            var w = new long[N];
            for(var i=0;i<N;++i)
            {
                var t = Sarray();
                w[i] = t[0];
                v[i] = t[1];
            }
            var nw = new long[W + 1];
            nw[w[0]] = v[0];
            for (var i = 1; i < N; ++i)
            {
                var next = new long[W + 1];
                for (var j = 1; j < W; ++j)
                {
                    if (nw[j] != 0)
                    {
                        next[j] = Max(next[j], nw[j]);
                        if (j + w[i] <= W)
                            next[j + w[i]] = nw[j] + v[i];
                    }
                }
                next[w[i]] = Max(next[w[i]], v[i]);
                nw = next;
            }
            WriteLine(nw.Max());
        }
    }
}


Measured memory_bytes: 31240
def bb
    n = gets.chomp.to_i
    if n < 4
        puts 'No'
        exit
    end

    if n%4 == 0 or n%7 == 0
        puts 'Yes'
        exit
    end

    for i in 1..100/4
        for j in 1..100/7
            k = i*4 + j*7
            if k == n
                puts 'Yes'
                exit
            end
        end
    end

    puts 'No'
end

bb


Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define REPL(i,m,n) for(ll i=(ll)(m); i<(ll)(n); i++)
#define repl(i,n) REPL(i,0,n)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 998244353;
int main() {
  int N, S;
  cin >> N >> S;
  vector<int> A(N);
  rep(i, N) cin >> A[i];
  vector<vector<vector<ll> > > dp(N+1, vector<vector<ll> >(S+1, vector<ll>(3)));
  dp[0][0][0] = 1;
  rep(i, N) {
    rep(s, S+1) {
      (dp[i+1][s][0] += dp[i][s][0]) %= mod;
      (dp[i+1][s][1] += dp[i][s][1] + dp[i][s][0]) %= mod;
      (dp[i+1][s][2] += dp[i][s][2] + dp[i][s][1] + dp[i][s][0]) %= mod;
      if(s+A[i] < S+1) {
	(dp[i+1][s+A[i]][1] += dp[i][s][0] + dp[i][s][1]) %= mod;
	(dp[i+1][s+A[i]][2] += dp[i][s][0] + dp[i][s][1]) %= mod;
      }
    }
  }
  cout << dp[N][S][2] << endl;
  return 0;
}


Measured memory_bytes: 493056
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        PriorityQueue<Integer> front = new PriorityQueue<>();
        PriorityQueue<Integer> back = new PriorityQueue<>();
        int[] arr = new int[n];
        long frontSum = 0;
        long backSum = 0;
        for (int i = 0; i < n; i++) {
            int x = sc.nextInt();
            frontSum += x;
            front.add(x);
        }
        for (int i = 0; i < n; i++) {
            arr[i] = sc.nextInt();
        }
        for (int i = 0; i < n; i++) {
            int x = sc.nextInt();
            backSum += x;
            back.add(-x);
        }
        long[] values = new long[n + 1];
        values[0] = frontSum;
        values[n] = - backSum;
        for (int i = 0; i < n; i++) {
            frontSum += arr[i];
            front.add(arr[i]);
            frontSum -= front.poll();
            values[i + 1] += frontSum;
            backSum += arr[n - i - 1];
            back.add(- arr[n - i - 1]);
            backSum += back.poll();
            values[n - i - 1] -= backSum;
        }
        long max = Long.MIN_VALUE;
        for (int i = 0; i <= n; i++) {
            max = Math.max(max, values[i]);
        }
        System.out.println(max);
    }
}

Measured memory_bytes: 98764
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
using namespace std;
char sign[307];
string ans;
int a, b, c;
int A, B;
string print(int n) {
	string s = "";
	for (int j = 0; j < n; j++) {
		s += "|";
	}
	return s;
}

int main()
{
	int a, b; cin >> a >> b;
	if (2 * b >= a)
		cout << 0 << endl;
	else {
		cout << a - 2 * b << endl;
	}
	return 0;
}


Measured memory_bytes: 256