akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define LLI long long int
#define ULTRA 2134567890
#define de(x) if(x!=0 && MODE==x)
#define MODE 1
using namespace std;

int A[100007];

int main()
{
    int i,j;
    int N;

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

    LLI h = 0;
    LLI w = 0;
    for( i=0; i<N-1; i++)
    {
        if( A[i]==A[i+1])
        {
            if( h==0)
            {
                h = A[i];
                i++;
            }
            else if( w==0)
            {
                w = A[i];
                break;
            }
        }
    }
    printf("%lld\n", h*w);

    return 0;
}


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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

const int N_MAX = 200005;

ll inv[N_MAX],fac[N_MAX],finv[N_MAX];
void make(){
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    for(int i=2;i<N_MAX;i++){
        inv[i]=mod-inv[mod%i]*(mod/i)%mod;
        fac[i]=fac[i-1]*(ll) i%mod;
        finv[i]=finv[i-1]*inv[i]%mod;
    }
}

ll Combination(ll C, ll D){
	if(C==0 && D==0) return 1;
    if(C<D||C<1) return 0;
    return fac[C]*(finv[D]*finv[C-D]%mod)%mod;
}

int main(){
	ll H, W, A, B;
	cin >> H >> W >> A >> B;
	make();
	ll res = 0;
	REP(i, W-B){
		int tate1 = H-A-1;
		int yoko1 = B+i;
		int tate2 = A-1;
		int yoko2 = W-B-i-1;
		res += (Combination(tate1+yoko1, tate1) * Combination(tate2+yoko2, tate2))%mod;
		res %= mod;
	}
	cout << res << endl;

    return 0;
}

Measured memory_bytes: 4992
#define _USE_MATH_DEFINES // for C++  
#include "bits/stdc++.h"
#define LL long long
#define NUM 1000000007
 
using namespace std;
 
int main() {
    char a, b, c;
    cin >> a >> b >> c;
    if (100*a+10*b+c==100*c+10*b+a)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{

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

		//値分割(購入本数、セットＸの本数と金額、セットＹの本数と金額)
		double buyCount = sc.nextDouble();
		double XsetCount = sc.nextDouble();
		double XsetPrice = sc.nextDouble();
		double YsetCount = sc.nextDouble();
		double YsetPrice = sc.nextDouble();

		//購入本数＜Ｘセット本数　金額
		double XsumPrice = XsetPrice * Math.ceil(buyCount/XsetCount);

		//購入本数＜Ｙセット本数　金額
		double YsumPrice = YsetPrice * Math.ceil(buyCount/YsetCount);

		//金額が小さい方を出力
		if(XsumPrice < YsumPrice) {
			System.out.println((int)XsumPrice);
		}else {
			System.out.println((int)YsumPrice);
		}
		
		sc.close();
	}
}


Measured memory_bytes: 28068
def gcd(a,b):
    if a == 0:
        return b
    if b == 0:
        return a
    r = 1
    while r > 0:
        r = a % b
        a = b
        b = r
    return a


n = int(input())
A = [int(i) for i in input().split()]

L = [0] * (n-1)
L[0] = A[0]
for i in range(1,n-1):
    L[i] = gcd(L[i-1], A[i])

R = [0] * (n-1)
R[0] = A[-1]
for i in range(1,n-1):
    R[i] = gcd(R[i-1], A[-i-1])

R.reverse()

M = [0] * n
for i in range(n):
    if i == 0:
        M[i] = R[0]
    elif i == n-1:
        M[i] = L[-1]
    else:
        M[i] = gcd(L[i-1],R[i])

#print(L,R)
print(max(M))


Measured memory_bytes: 14428
import numpy as np

#v = [int(d) for d in input().split()]
v= list(str(input()))


li = list(np.array_split(v,2))

mae = int(''.join(li[0]))
usiro = int(''.join(li[1]))

ma = 0
usi = 0

if int(usiro) >= 1:
    if int(usiro) <= 12:
        usi = 1
    else:
        usi = 2
else:
    usi = 2

if int(mae) >= 1:
    if int(mae) <= 12:
        ma = 1
    else:
        ma = 2
else:
    ma = 2


if usi == 0:
    print('NA')
    exit()

if ma == 0:
    print('NA')
    exit()

if usi ==1:
    if ma == 1:

        print('AMBIGUOUS')
    else:
        print('YYMM')

if usi == 2:
    if ma == 1:

        print('MMYY')
    else:
        print('NA')

Measured memory_bytes: 21412
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main{
	static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	static int n,s,ans;

	public static void main(String[] args) throws IOException {

		String str;

		while(!(str=br.readLine()).equals("0 0")){
			String strArray[] = str.split(" ");
			n = Integer.parseInt(strArray[0]);
			s = Integer.parseInt(strArray[1]);
			solve();
		}

	}

	static void solve(){
		ans=0;
		cal(0, n, 0);
		System.out.println(ans);
	}

	static void cal(int i, int n, int sum){
		if(n==0){
			if(sum==s){
				ans++;
				return;
			}
		}

		if(i>9)return;
		for(int k=i; k<=9; k++){
			cal(k+1, n-1, sum+k);
		}
	}
}

Measured memory_bytes: 18472
//#define _GLIBCXX_DEBUG
#include "bits/stdc++.h"

using namespace std;

//------------------------------- Type Names -------------------------------//

using i64 = int_fast64_t;

using seika = string;
//{akari : 1D, yukari : 2D, maki : 3D} vector
template <class kizuna>
using akari = vector<kizuna>;
template <class yuzuki>
using yukari = akari<akari<yuzuki>>;
template <class tsurumaki>
using maki = akari<yukari<tsurumaki>>;
//{akane : ascending order, aoi : decending order} priority queue
template <class kotonoha>
using akane = priority_queue<kotonoha, akari<kotonoha>, greater<kotonoha>>;
template <class kotonoha>
using aoi = priority_queue<kotonoha>;

//------------------------------- Libraries ---------------------------------//

//------------------------------- Dubug Functions ---------------------------//

inline void print()
{
    cout << endl;
}
template <typename First, typename... Rest>
void print(const First &first, const Rest &... rest)
{
    cout << first << ' ';
    print(rest...);
}

//------------------------------- Solver ------------------------------------//

void solve()
{
    int a, b;
    cin >> a >> b;
    cout << (a > b ? "safe" : "unsafe") << endl;
}

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


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

class UnionFind {
private:
    vector<int> parent;
    vector<int> rank;

public:
    UnionFind(int n) {
        parent.resize(n);
        rank.resize(n);
        for (int i = 0; i < n; i++) {
            parent[i] = i;
            rank[i] = 0;
        }
    }

    int find(int x) {
        if (x == parent[x]) {
            return x;
        } else {
            return parent[x] = find(parent[x]);
        }
    }

    void unite(int x, int y) {
        x = find(x);
        y = find(y);
        if (x == y) return;

        if (rank[x] < rank[y]) {
            parent[x] = y;
        } else {
            parent[y] = x;
            if (rank[x] == rank[y]) {
                rank[x]++;
            }
        }
    }

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

int main() {
    int N, M;
    cin >> N >> M;
    UnionFind unionFind = UnionFind(N);
    for (int i = 0; i < M; i++) {
        int x, y, z;
        cin >> x >> y >> z;
        x--; y--;
        unionFind.unite(x, y);
    }

    unordered_set<int> set;
    for (int i = 0; i < N; i++) {
        set.insert(unionFind.find(i));
    }

    cout << set.size() << endl;
    return 0;
}

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

int a[310][310], p[310];
bool del[310];
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n, m;
    cin >> n >> m;
    for(int i=0; i<n; i++){
        for(int j=0; j<m; j++){
            cin >> a[i][j];
        }
    }
    int ans = n;
    for(int i=0; i<m-1; i++){ // delete round
        int num[310] = {0};
        for(int j=0; j<n; j++){
            num[ a[j][p[j]] ]++;
        }
        int Max = -1, idx;
        for(int j=1; j<=m; j++){
            if( num[j] > Max ){
                Max = num[j];
                idx = j;
            }
        }
        ans = min( ans, Max );
        del[idx] = true;
        for(int j=0; j<n; j++){
            while( del[ a[j][p[j]] ] ) p[j]++;
        }
    }
    cout << ans << "\n";
    return 0;
}

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


int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    long long x,k,d; cin >> x >> k >> d;
    if (x < 0)x *= -1ll;
	long long tmp = min(k, x / d);
	k -= tmp, x -= tmp * 1ll * d;
	if (k & 1)x -= d;
    cout << (long long)fabs(x) << endl;
    return 0;
}


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

using i32 = std::int_fast32_t;
using i64 = std::int_fast64_t;
template <typename T> constexpr T inf = numeric_limits<T>::has_infinity ? numeric_limits<T>::infinity() : numeric_limits<T>::max() / 4;

#define REP(i, stop) FOR(i, 0, stop)
#define FOR(i, start, stop) for (int i = start, i##_len = stop; i < i##_len; ++i)
#define RREP(i, n) for (int i = n; i-- > 0;)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define COMP(key) [](const auto& a, const auto& b) { return a.key < b.key; }

struct InitCpp { InitCpp() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(10); } } initCpp;

signed main() {
	i64 n;
	cin >> n;
	i64 a = 0;
	for (i64 r = 1; r * r <= n; ++r) {
		if (n / r == n % r) {
			a += r;
		}
		i64 q = (n - 1) / r;
		if (q > 0 && q != r && n / q == n % q) {
			a += q;
		}
	}
	cout << a << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <stdio.h>
using namespace std;



int main(void) {
	string str;
	cin >> str;

	vector<int> oddposition;
	vector<int> evenposition;

	int prevstopposi = 0;

	for (int i = 0; i != str.size(); i++) {
		int j = i;
		int stopposi = 0;
		while (1) {
			if (str[i] == 'R') {
				if (i != 0) {
					if (str[i - 1] == 'R') {
						stopposi = prevstopposi;
						break;
					}
				}
				if (str[j] == str[j + 1]) {
					j++;
				}
				else {
					stopposi = j;
					break;
				}
			}
			else if (str[i] == 'L') {
				if (i != 0) {
					if (str[i - 1] == 'L') {
						stopposi = prevstopposi;
						break;
					}
				}
				if (str[j] == str[j - 1]) {
					j--;
				}
				else {
					stopposi = j;
					break;
				}
			}
		}

		prevstopposi = stopposi;

		if (str[i] == 'R') {
			if ((stopposi - i) % 2 == 0) {
				evenposition.push_back(stopposi);
				oddposition.push_back(stopposi + 1);
			}
			else {
				oddposition.push_back(stopposi);
				evenposition.push_back(stopposi + 1);
			}
		}
		else if (str[i] == 'L') {
			if ((stopposi - i) % 2 == 0) {
				evenposition.push_back(stopposi);
				oddposition.push_back(stopposi - 1);
			}
			else {
				oddposition.push_back(stopposi);
				evenposition.push_back(stopposi - 1);
			}
		}
	}

	vector<int> vnKids(str.size(), 0);

	for (int i = 0; i != str.size(); i++) {
		int finposi = evenposition[i];
		vnKids[finposi] += 1;
	}

	for (int i = 0; i != str.size(); i++) {
		cout << vnKids[i] << " " << endl;
	}

	return 0;
}



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

#define MOD 1000000007
#define ll long long int 
#define off ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

double dp[3000][3001];

int main()
{
    off;
  
    ll n;cin>>n;
    ll f[3] = {0,0,0};

    for (int i = 0; i < n; ++i)
    {
        ll t;cin>>t;
        f[t-1]++;
    }

    double dp[f[0]+f[1]+f[2]+1][f[1]+f[2]+1][f[2]+1];

    dp[0][0][0] = 0L;

    double precise = 1000000000000L;
    for (ll z = 0; z <= f[2]; ++z)
    {
      for (ll y = 0; y + z <= n && y+z<=f[1]+f[2]; ++y)
      {
        for (ll x = 0; x + y + z <= n && x+y+z<=f[0]+f[1]+f[2];++x)
        {
          double t = x + y + z ;
          dp[x][y][z] = (double)0;
          if(x)
            dp[x][y][z] += (precise * dp[x-1][y][z] * (double)x)/t;
          if(y)
            dp[x][y][z] += (precise * dp[x+1][y-1][z] * (double)y)/t;
          if(z)
            dp[x][y][z] += (precise * dp[x][y+1][z-1] * (double)z)/t;
          if(t)
            dp[x][y][z] += (precise * (double)n)/t;
          dp[x][y][z] /= precise;
        }
      }
    }

    cout.precision(14);
    cout<<fixed<<dp[f[0]][f[1]][f[2]];

    return 0;
}


Measured memory_bytes: 211584
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  int N,M; cin >> N >> M; vector<pair<int,int>> X(M);
  for(int i = 0; i < M; i++){ 
    int a,b; cin >> a >> b; a--; b--; X[i] = make_pair(a,b);}
  sort(X.begin(),X.end());
  
  int anchor = X[0].second-1; int bridge = 1;
  
  for(int i = 1; i < M; i++){
    int c = X[i].first; int d = X[i].second;
    if( c <= anchor){ anchor = min( anchor, d-1);}
    else{ anchor = d-1; bridge++;}
  }
  
  cout << bridge << endl; return 0;}
      

Measured memory_bytes: 1152
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream> 
#include<map>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
using namespace std;
#define MAX_MOD 1000000007
#define REP(i,n) for(long long i = 0;i < n;++i)
#define LONG_INF 1000000000000
int main() {
	string s;
	cin >> s;
	string hoge[2] = { "Second","First" };
	int wow = s.length();
	if (s[0] == s[s.length() - 1])wow++;
	cout << hoge[wow % 2] << endl;
	return 0;
}

Measured memory_bytes: 512
/* Bismillahir Rahmanir Rahim */

#include <bits/stdc++.h>

#define rep(i, n)	for(int i=0;i<n;i++)
#define repn(i, n)	for(int i=1;i<=n;i++)
#define set(i, n)	memset(i, n, sizeof(i))

#define pb	push_back

using namespace std;

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

const int N = 100004;

int n, a[N], dp[N][2];;

int main(){
    scanf("%d", &n);
    repn(i, n) scanf("%d", &a[i]);

    dp[1][0] = 1;
    dp[1][1] = 1;
    int oo = 1e9;

    for(int i=2;i<=n;i++){
        dp[i][0] = min(dp[i-1][0], dp[i-1][1]) + 1;
        dp[i][1] = min(dp[i-1][0], dp[i-1][1]) + 1;
        if(a[i] >= a[i-1]) dp[i][0] = min(dp[i][0], dp[i-1][0]);
        if(a[i] <= a[i-1]) dp[i][1] = min(dp[i][1], dp[i-1][1]);
    }
    cout << min(dp[n][0], dp[n][1]) << endl;

	return 0;
}



Measured memory_bytes: 1408
N = int(input())
ori = [int(i) for i in input().split()]
count = ori.count(1)
if count == 0:
    print(-1)

else:
    savepoint = 0
    for j in range(1,N+1):
        for i in range(savepoint,N):
            if ori[i] == j:
                savepoint = i
                #print(savepoint)
                #print(j,i)
                sub = j
                break
        if i == N-1:
            break
    print(N-sub)

Measured memory_bytes: 26268
//bubble sin_port
#include<iostream>

using namespace std;
static const int MAX = 100;

void bubbleSort(int array[],int N){
  int i,j,tmp;
  int count = 0;
  for(i = 1 ; i < N ; i++)
  for(j = N-1 ; j >= i ; j--){
    if(array[j] < array[j-1]){
      tmp = array[j];
      array[j] = array[j-1];
      array[j-1] = tmp;
      count++;
    }
  }
  for(i = 0 ; i < N ; i++){
    if(i > 0) cout << " ";
    cout << array[i];
  }
  cout << endl;
  cout << count << endl;
}

int main(){
  int array[MAX],N;

  cin >> N;

  for(int i = 0 ; i < N ; i++) cin >> array[i];

  bubbleSort(array,N);
}



Measured memory_bytes: 3084
import heapq
n = int(raw_input())
heap = [map(int, raw_input().split(' '))[::-1] for _ in range(n)]
heapq.heapify(heap)
def f(heap):
	t = 0
	while(heap):
		nd,d = heapq.heappop(heap)
		gap = nd - t - d
		if gap < 0:
			return False
		t += d
		
	return True
print 'Yes' if f(heap) else 'No'

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

using namespace std;

int main(){

    int H, W, h, w, counter = 0;

    cin >> H >> W >> h >> w;

    int arr[H][W] = {0};

    for(int i = 0; i < H; i++){
        for(int j = 0; j < W; j++){
            arr[i][j] = 0;
            //cout << arr[i][j] << " ";
        }
        //cout << endl;
    }
    //cout << "-------" << endl;
    for(int i = 0; i < h; i++){
        for(int j = 0; j < W; j++){
            arr[i][j] = 1;
        }
    }

    for(int i = 0; i < H; i++){
        for(int j = 0; j < w; j++){
            arr[i][j] = 1;
        }
    }



    for(int i = 0; i < H; i++){
        for(int j = 0; j < W; j++){
            if(arr[i][j] == 0){
                counter++;
            }
        }
    }

    cout << counter << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mp make_pair
#define deb(x) cout<< #x << " " << x << "\n";
#define MAX 9223372036854775807
#define MIN -9223372036854775807
#define PI 3.141592653589
#define setbits(n) __builtin_popcountll(n)
const ll mod=1e9+7;

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;
#define oset tree<long long, null_type,less<long long>, rb_tree_tag,tree_order_statistics_node_update> 
//order_of_key (k) : Number of items strictly smaller than k.
//find_by_order(k) : K-th element in a set (counting from zero).

int main() {
    
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll T=clock();
    
    ll n,k;
    cin>>n>>k;
    vector<ll> a(n);
    for(ll i=0;i<n;i++)
        cin>>a[i];
    vector<ll> dp(n,MAX);
    dp[0]=0; dp[1]=abs(a[0]-a[1]);
    for(ll i=2;i<n;i++){
        for(ll j=max(0ll,i-k);j<i;j++)
            dp[i]=min(dp[i],dp[j]+abs(a[i]-a[j]));
    }
    cout<<dp[n-1];


    cerr<<"\n\nTIME: "<<(double)(clock()-T)/CLOCKS_PER_SEC<<" sec\n";
    T = clock();
    return 0;
}

Measured memory_bytes: 4812
import java.util.Arrays;
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		final int cnt=sc.nextInt();
		for(int i=0;i<cnt;i++){
			Integer side[]=new Integer[3];
			side[0]=sc.nextInt();
			side[1]=sc.nextInt();
			side[2]=sc.nextInt();
			Arrays.sort(side);
			if((side[0]*side[0]+side[1]*side[1])==side[2]*side[2]){
				System.out.println("YES");
			}else System.out.println("NO");
		}
		sc.close();
	}
}

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

#define ll long long
int check_palindrome(string s)
{
    int j = 0;
    int l = s.size();
    for(int i=0; i<=l/2; i++)
    {
        if(s[i]!=s[l-i-1])
        {
            j=1;
        }
    }
    return j;
}

int main()
{
    int a,b;
    scanf("%d %d", &a, &b);
    int cnt = 0;
    for(int i = a; i <= b; i++)
    {
        string s = to_string(i);
        if(!check_palindrome(s))
            cnt++;
    }
    cout << cnt;
    return 0;
}


Measured memory_bytes: 3756
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <string>

using namespace std;
typedef pair<string, int> P;

void solve()
{
	int n;
	while(cin >> n, n)
	{
		vector<P> data;
		bool point[21][31] = {false};
		for(int i = 0; i < n; ++i)
		{
			string name;
			cin >> name;
			data.push_back(P(name, 0));
			int m;
			cin >> m;
			while(m--)
			{
				int d;
				cin >> d;
				point[i][d] = true;
			}
		}
		for(int i = 0; i < 31; ++i)
		{
			int count = 0;
			for(int j = 0; j < n; ++j)
			{
				if(point[j][i])
				{
					++count;
				}
			}
			for(int j = 0; j < n; ++j)
			{
				if(point[j][i])
				{
					data[j].second += n - count + 1;
				}
			}
		}
		sort(data.begin(), data.end());
		int minIndex = 0;
		int min = 999999999;
		for(int i = 0; i < n; ++i)
		{
			if(min > data[i].second)
			{
				min = data[i].second;
				minIndex = i;
			}
		}
		cout << data[minIndex].second << " " << data[minIndex].first << endl;
	}
}

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

Measured memory_bytes: 1228
//package ABC;
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		
		int n=sc.nextInt();
		int m=sc.nextInt();
		
		int all=0;
		int[] a =new int[n];
		
		for(int i=0;i<n;i++){
			a[i]=sc.nextInt();
			all=all+a[i];
		}
		//System.out.println(all);
		
		double min=1.0 * all/(m*4);
		//System.out.println(min);
		
		int check=0;
		for(int i=0;i<n;i++){
			if(a[i]>=min){
				check++;
				
			}
		}
		//System.out.println(check);
		if(check<m){
			System.out.println("No");
		}else{
			System.out.println("Yes");
		}

		
	}
	
}


Measured memory_bytes: 23380
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
int main (){
int a,b,x,az,bz,abh=0;
cin>>a>>b>>x;
//////////////////az//////////////////
if (x<a){
        az=a;
}
else {
        az=x/1000*a;
        if (x%1000!=0){
                az+=a;
        }
}
//////////////////bz//////////////////
if (x<b){
        bz=b;
}
else {
        bz=x/500*b;
        if (x%500!=0){
                bz+=b;
        }
}
/////////////////abh//////////////////
if (b*2<a){
        abh+=x/500*b;
        if (x%500!=0){
                abh+=min(a,b);
        }
}
else {  //b*2>a
        abh+=x/1000*a;
        if (x%1000!=0){
                if (x%1000<=500){
                        abh+=min(a,b);
                }
               else {
                        abh+=min(a,b*2);
                }
        }
}

int ans=min(abh,min(az,bz));
cout<<ans<<endl;
return 0;
}



Measured memory_bytes: 3136
#include<bits/stdc++.h>
using namespace std;
int main(){
  int H,R;
  cin >> H >> R;
  if(H<0){
    if(R+H>0) cout << 1 << endl;
    if(R+H==0) cout << 0 << endl;
    if(R+H<0)cout << -1 << endl;
  }else{
    cout << 1 << endl;
  }
  return 0;

}



Measured memory_bytes: 3104
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
REP(i,v.size()){if(i)os<<" ";os<<v[i];}return os;}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
REP(i,v.size()){if(i)os<<endl;os<<v[i];}return os;}

int DigitSum(int n){
	int sum;
	while(n){
		sum += n%10;
		n = n/10;
	}
	return sum;
}

int main() {
	int n; cin >> n;
	if (n%DigitSum(n) == 0) cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 256
use std::cmp::*;
use std::io::*;

fn main() {
    let mut s: String = String::new();
    std::io::stdin().read_to_string(&mut s).ok();
    let mut itr = s.trim().split_whitespace();
    let s = itr.next().unwrap();

    let n = s.len();
    let t = s[0..n / 2].to_string();
    let u = s[(n + 1) / 2..].to_string();

    let rs = s.chars().rev().collect::<String>();
    let rt = t.chars().rev().collect::<String>();
    let ru = u.chars().rev().collect::<String>();
    if s == rs && t == rt && u == ru {
        println!("Yes");
    } else {
        println!("No")
    }
}


Measured memory_bytes: 2092
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define db double
#define pii pair<int,int>
#define pli pair<ll,int>
#define pil pair<int,ll>
#define pll pair<ll,ll>
#define mat vector<vector<int>>
const int inf = 1 << 30;
const ll linf = 1e18;
const db EPS = 1e-7;
template<class T> void chmin(T& x, T y){if(x > y) x = y;}
template<class T> void chmax(T& x, T y){if(x < y) x = y;}

struct dat{
    int node, par;
};

template<class T>
struct union_find{
    int N;
    vector<int> par, rank;
    vector<int> time;
    vector<T> sz;

    union_find(int N, int M) : N(N), par(N + 1), rank(N + 1, 1), time(M + 1, 0), sz(N + 1, 1){
        for(int i = 0; i <= N; ++i) par[i] = i;
    }

    void init(int n, T s){sz[n] = s;}

    int find(int v){
        return (v == par[v] ? v : find(par[v]));
    }

    void unite(int x, int y, int t){
        x = find(x);
        y = find(y);
        if(x == y) return;

        if(rank[x] > rank[y]){
            time[t] = y;
            par[y] = x;
            sz[x] += sz[y];
        }else{
            time[t] = x;
            par[x] = y;
            sz[y] += sz[x];
            if(rank[x] == rank[y]) rank[y]++;
        }
    }

    void cut(int t){
        int u = time[t];
        int v = u;
        while(v != par[v]){
            v = par[v];
            sz[v] -= sz[u];
        }
        par[u] = u;
    }

    T get_sz(int x){
        return sz[find(x)];
    }
};

struct arc{
    int from, to, idx;
    ll Y;
    bool operator < (const arc& e1) const {
        return Y < e1.Y;
    }
    bool operator > (const arc& e1) const {
        return Y > e1.Y;
    }
};

struct edge{
    int to, idx;
    ll Y;
};

int N, M;
ll X[100010];
bool ok[100010], used[100010];
vector<edge> G[100010];

void dfs(int v, ll Y){
    if(used[v]) return;
    used[v] = true;
    for(auto u : G[v]){
        if(u.Y > Y) continue;
        ok[u.idx] = true;
        dfs(u.to, Y);
    }
}


int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> N >> M;

    union_find<ll> uf(N, M);
    for(int i = 1; i <= N; ++i){
        cin >> X[i];
        uf.init(i, X[i]);
    }

    vector<arc> as;
    for(int i = 1; i <= M; ++i){
        int A, B;
        ll Y;
        cin >> A >> B >> Y;
        as.emplace_back(arc{A, B, i, Y});
        G[A].emplace_back(edge{B, i, Y});
        G[B].emplace_back(edge{A, i, Y});
    }

    sort(as.begin(), as.end());
    for(int i = 0; i < M; ++i){
        uf.unite(as[i].to, as[i].from, i);
    }

    for(int i = M - 1; i >= 0; --i){
        if(ok[as[i].idx]) continue;
        if(uf.get_sz(as[i].to) >= as[i].Y){
            dfs(as[i].to, as[i].Y);
        }
        uf.cut(i);
    }
    int ans = M;
    for(int i = 1; i <= M; ++i) ans -= ok[i]; 
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 16176
n,a,b = list(map(int,input().split()))

s = input()

for i in s:
    if i == 'c':
        print('No')
    elif i == 'a' and (a+b>=1):
        if a>0:
            a -= 1
        else:
            b -= 1
        print('Yes')
    elif i =='b' and b > 0:
        b -= 1
        print('Yes')
    else:
        print('No')

Measured memory_bytes: 4016
module.exports=function(r){var t={};function e(n){if(t[n])return t[n].exports;var o=t[n]={i:n,l:!1,exports:{}};return r[n].call(o.exports,o,o.exports,e),o.l=!0,o.exports}return e.m=r,e.c=t,e.d=function(r,t,n){e.o(r,t)||Object.defineProperty(r,t,{enumerable:!0,get:n})},e.r=function(r){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(r,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(r,"__esModule",{value:!0})},e.t=function(r,t){if(1&t&&(r=e(r)),8&t)return r;if(4&t&&"object"==typeof r&&r&&r.__esModule)return r;var n=Object.create(null);if(e.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:r}),2&t&&"string"!=typeof r)for(var o in r)e.d(n,o,function(t){return r[t]}.bind(null,o));return n},e.n=function(r){var t=r&&r.__esModule?function(){return r.default}:function(){return r};return e.d(t,"a",t),t},e.o=function(r,t){return Object.prototype.hasOwnProperty.call(r,t)},e.p="",e(e.s=0)}([function(r,t,e){e(1)(e(2).readFileSync("/dev/stdin","UTF-8"))},function(r,t){function e(r,t){return function(r){if(Array.isArray(r))return r}(r)||function(r,t){var e=[],n=!0,o=!1,u=void 0;try{for(var i,f=r[Symbol.iterator]();!(n=(i=f.next()).done)&&(e.push(i.value),!t||e.length!==t);n=!0);}catch(r){o=!0,u=r}finally{try{n||null==f.return||f.return()}finally{if(o)throw u}}return e}(r,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}()}r.exports=function(r){for(var t=e(r.split("\n")[0].split(" ").map(function(r){return Number(r)}),2),n=t[0],o=t[1],u=0,i=1;i<=n;i++){var f=n%i;u+=Math.floor(n/i)*Math.max(0,i-o)+Math.max(0,f-o+1)}0==o&&(u-=n),console.log(u)}},function(r,t){r.exports=require("fs")}]);

Measured memory_bytes: 8764
N = int(input())
A = input()
B = input()
C = input()

ans = 0
for i in range(N):
  if A[i] == B[i] == C[i]:
    ans += 0

  elif A[i] == B[i]:
    ans += 1

  elif A[i] == C[i]:
    ans += 1

  elif B[i] == C[i]:
    ans += 1

  elif A[i] != B[i] and B[i] != C[i]:
    ans += 2

print(ans)

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

int main(){
  string s;
  cin >> s;
  bool ans=true;
  sort(s.begin(),s.end());
  for(int i=0;i<s.size();i++){
    if(s[i]==s[i+1]){
      ans=false;
      break;
    }
  }
  if(ans){
    cout << "yes" << endl;
  }else{
    cout << "no" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll =long long;
using vl=vector<ll>;
using vb=vector<bool>;
using vs=vector<string>;
using vvl=vector<vl>;
using pll=pair<ll,ll>;
const ll oo =0x3f3f3f3f3f3f3f3fLL;
const double eps=1e-9;
#define sz(c) ll((c).size())
#define all(c) begin(c),end(c)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define FOR(i,a,b) for(ll i=(a); i<(b); i++)
#define FORD(i,a,b) for(ll i=ll(b)-1;i>=(a);i--)
#define TR(X) ({if(1) cerr << "TR: " << (#X) << " = " << (X) << endl; })
int main(){ cin.sync_with_stdio(0);
	ll N; cin >> N;
	cout << (N * (N-1))/2 << endl;
} //cin.tie(0) bei schnellem Wechseln


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
vector<vector<bool>> path(8,vector<bool>(8,false));

int dfs(int v,int n, vector<bool> checked){
    int ans = 0;
    bool all_visited = true;
    for(int i=0;i<n;i++){
        if(checked.at(i) == false){
            all_visited = false;
            break;
        }
    }
    if(all_visited){
        return 1;
    }
    for(int i=0;i<n;i++){
        if(path.at(v).at(i) == false || checked.at(i) == true){
            continue;
        }
        checked.at(i) = true;
        ans += dfs(i,n,checked);
        checked.at(i) = false;
    }
    return ans;
}


int main(){
    int n,m;
    cin >> n >> m;

    for(int i=0;i<m;i++){
        int a,b;
        cin >> a >> b;
        path.at(a-1).at(b-1) = true;
        path.at(b-1).at(a-1) = true;
    }
    vector<bool> checked(8,false);
    checked.at(0) = true;
    int ans = dfs(0,n,checked);
    cout << ans << endl;
    return 0;
}

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

//#define int long long
typedef long long ll;
//const int INF = 2e9;
//const ll INF = 9e18;


signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N;
    cin >> N;
    vector<int> L(N);
    for (int i=0;i<N;i++) cin >> L[i];
    sort(L.begin(),L.end());
    int ans = 0;
    for (int a=0;a<N-2;a++){
        for (int b=a+1;b<N-1;b++){
            for (int c=b+1;c<N;c++){
                if (L[a] == L[b]) continue;
                if (L[b] == L[c]) continue;
                if (L[c] == L[a]) continue;
                if (L[a]+L[b] > L[c]) ans++;
            }
        }
    }
    cout << ans << "\n";
}

Measured memory_bytes: 3648
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;
typedef long long int ll;

int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	int a,b,p,q,r; cin >> a >> b >> p >> q >> r;
	double dif=p*b-(b-a)*q;
	printf("%.8f\n",b+dif/(double)(q+r) );
}


Measured memory_bytes: 3248
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin>>N;
  vector<uint32_t> A(N);
  uint32_t a=0;
  for(uint32_t &i:A){
    uint32_t j;
    cin>>j;
    i=j;
    a^=i;
  }
  for(int i=0;i<N;i++){
    cout<<(a^A[i])<<endl;
  }
}

Measured memory_bytes: 4008
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<queue>
#include<stack>
#include<map>
using namespace std;

int read(){
	int x=0,f=1;
	char c=getchar();
	while(!isdigit(c)){if(c=='-')f=-1;c=getchar();}
	while(isdigit(c)){x=(x<<3)+(x<<1)+c-48;c=getchar();}
	return x*f;
}

int main(){
	int n=read(),d=read();
	if(n%(2*d+1)==0)n=n/(2*d+1);
	else n=n/(2*d+1)+1;
	printf("%d\n",n);
	return 0;
}

Measured memory_bytes: 256
import numpy as np
 
MOD = 10 ** 9 + 7
 
N = int(input())
A = np.array(list(map(int, input().split())),np.int64)
 
answer = 0
for n in range(63):
    B = (A >> n) & 1
    x = np.count_nonzero(B)
    y = N - x
    x *= y
    for _ in range(n):
        x *= 2
        x %= MOD
    answer += x
answer %= MOD
print(answer)

Measured memory_bytes: 48844
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
using namespace std;

template <class T>
class cumulativeSum
{
private:
    int ny, nx;
    vector<vector<T> > sum;
public:
    cumulativeSum(const vector<vector<T> >& a)
    {
        ny = a.size();
        nx = a[0].size();
        sum.assign(ny+1, vector<T>(nx+1, 0));
        for(int i=0; i<ny; ++i){
            for(int j=0; j<nx; ++j){
                sum[i+1][j+1] = a[i][j] + sum[i][j+1] + sum[i+1][j] - sum[i][j];
            }
        }
    }
    T getSum(int y1, int x1, int y2, int x2)
    {
        y1 = max(y1, 0);
        x1 = max(x1, 0);
        y2 = min(y2, ny-1);
        x2 = min(x2, nx-1);
        if(y1 > y2 || x1 > x2)
            return 0;
        return sum[y2+1][x2+1] - sum[y1][x2+1] - sum[y2+1][x1] + sum[y1][x1];
    }
};

int main()
{
    int n, k;
    cin >> n >> k;
    vector<vector<vector<int>>> v(2, vector<vector<int>>(k*2, vector<int>(k*2, 0)));
    for(int i=0; i<n; ++i){
        int x, y;
        char c;
        cin >> x >> y >> c;
        y %= k * 2;
        x %= k * 2;
        int a = (c == 'B') ? 0 : 1;
        ++ v[a][y][x];
    }

    int ans = 0;
    vector<cumulativeSum<int>> cs = {v[0], v[1]};
    for(int y=0; y<2*k; ++y){
        for(int x=0; x<2*k; ++x){
            int sum = 0;
            for(int i=0; i<4; ++i){
                for(int j=0; j<4; ++j){
                    int a = (i + j) % 2;
                    int y2 = y + (i - 2) * k;
                    int x2 = x + (j - 2) * k;
                    sum += cs[a].getSum(y2, x2, y2+k-1, x2+k-1);
                }
            }
            ans = max(ans, sum);
        }
    }
    cout << ans << endl;

    return 0;
}


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

typedef long long  ll;

ll MOD = 1000000007;
ll INF = 1000000000000000000;
double PI = 3.1415926535;

template<typename T>
void remove(std::vector<T>& vector, unsigned int index)
{
    vector.erase(vector.begin() + index);
}

int main(){
  ll N,X;
  cin >> N >> X;
  vector<ll> A(N);
  ll sum = 0;
  for(int i = 0;i < N;i++){
    cin >> A[i];
    sum += A[i];
  }
  sort(A.begin(),A.end());
  ll cnt = 0;
  ll ans = 0;
  for(int i = 0;i < N;i++){
    if(A[i] + cnt <= X){
      ans++;
      cnt += A[i];
    }
  }
  if(sum < X)ans--;
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <queue>
#include <random>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <sys/timeb.h>
#include <vector>

using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;
#define FOR(NAME, START, NUM) for (ll NAME = START; NAME < (NUM); NAME++)
#define REP(NAME, NUM) for (ll NAME = 0; NAME < (NUM); NAME++)
#define BREP(NAME, NUM) for (ll NAME = (NUM)-1; NAME >= 0; NAME--)
#define ALL(NAME) (NAME).begin(), (NAME).end()
const ll LINF = 1e18;
const int INF = 1e9;
const int mod = 1e9+7;

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  vector<int> b(n);
  
  REP(i, n){
	cin >> a[i];
	b[i] = a[i];
  }
  
  sort(ALL(b));
  reverse(ALL(b));
  
  REP(i, n){
	if(a[i] == b[0])
	  cout << b[1] << endl;
	else
	  cout << b[0] << endl;
  }
}


Measured memory_bytes: 3200
#include  <bits/stdc++.h>
using namespace std;
static int fast_io = []() { std::ios::sync_with_stdio(false); cin.tie(nullptr); return 0; }();

int main(){ 
  int n;
  cin>>n;
  unsigned long long int range = 1000000000000000000;
  vector<unsigned long long int> nums(n);
  bool hasZero=false;
  for(int i = 0;i<n;i++){
    cin>>nums[i];
    if(nums[i]==0){
      hasZero=true;
    }
  } 
  unsigned long long int a,sum=1;
  if(hasZero){
    cout<<0<<"\n";
    return 0;  
  }
  while(n--){
    a=nums[n];
    if(a<=range/sum){
      sum*=a;
    }
    else {
      sum=1000000000000000001;
      break;
    }
  }
  if(sum<1000000000000000001)
    cout<<sum<<"\n";  
  else{
    cout<<-1<<"\n";  
  }
  return 0; 
}

Measured memory_bytes: 3980
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <cstdlib>
#define rep(i,x) for(int i=0;i<x;i++)
#define all(a) (a).begin(),(a).end()
using namespace std;
using ld = long double;
using ll = long long;
const ll INF = 10010010010;
typedef pair<ll, ll> P;
const ll mod = 1000000007;
ll gcd(ll a, ll b) {//a>b
    if (a < b)swap(a, b);
    if (a % b == 0) return b;
    else return gcd(b, a % b);
}

int main() {
    string S;
    cin >> S;
    map<char, bool> letter;
    ll s = S.size();
    bool ans = true;
    rep(i, s) {
        if (letter[S[i]])ans = false;
        else letter[S[i]] = true;
    }
    if (ans) cout << "yes" << endl;
    else cout << "no" << endl;
}

Measured memory_bytes: 256
N, W = map(int, input().split())
vw = [list(map(int, input().split())) for _ in range(N)]

inf=float("inf")
dp=[[-inf for i in range(W+1)] for j in range(N+1)]
for i in range(W+1): dp[0][i]=0

#DP
for i in range(N):
    for w in range(W+1):
        if vw[i][1] <= w: #dp[i][w-weight[i]の状態にi番目の荷物が入る可能性がある
            dp[i+1][w] = max(dp[i][w - vw[i][1]] + vw[i][0], dp[i][w])
        else: #入る可能性はない
            dp[i+1][w] = dp[i][w]

print(dp[N][W])


Measured memory_bytes: 42484
/// Containers Start
#include <algorithm>
#include <bitset>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <regex>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
/// C Header Files
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <math.h>
#include <stdio.h>
/// Containers End

using namespace std;

/// Math Start
#define PI acos(-1.0)
#define Pi 3.141592653589793
#define EPS (1e-7)
#define INF (0x3f3f3f3f)
/// Math End

/// Extra Start
#define nn '\n'
#define pb push_back
#define ull unsigned long long
#define ll long long
#define MOD 1000000007
#define sz(a) int((a).size())
#define space " "
#define All(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
/// Extra End

#define rep(i, n) for (int i = 0; i < n; i++)
#define Cini(a)                                                                \
    int a;                                                                     \
    cin >> a;
#define Cinii(a, b)                                                            \
    int a, b;                                                                  \
    cin >> a >> b;
#define Ciniii(a, b, c)                                                        \
    int a, b, c;                                                               \
    cin >> a >> b >> c;
#define Cins(s)                                                                \
    string s;                                                                  \
    cin >> s;
#define Cinss(s1, s2)                                                          \
    string s1, s2;                                                             \
    cin >> s1 >> s2;
#define Cinc(c)                                                                \
    char c;                                                                    \
    cin >> c;
/// Functions End

/// Debug Start
#define deb(x) cout << #x << ": " << x << endl
#define deb2(x, y) cout << #x << ": " << x << '\t' << #y << ": " << y << endl;
#define deb3(x, y, z)                                                          \
    cout << #x << ": " << x << '\t' << #y << ": " << y << '\t' << #z << ": "   \
         << z << endl;
/// Debug End

int dx[] = {-1, 0, 1, 0};
int dy[] = {0, -1, 0, 1};

/**>>>>>>>>>>>>>>>>>>> END <<<<<<<<<<<<<<<<<<**/

/// template

signed main(void) {
    cin.sync_with_stdio(false);
    cin.tie(0);
    Cinii(n,m);
    cout << (n+m-1)/m << nn;
    return 0;
}

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

using namespace std;
int main()
{
  int a,b,c;
  scanf("%d%d%d",&a,&b,&c);
  int x=a*100+b*10+c;
  if(x%4==0)
      printf("YES");
  
  else
      printf("NO");
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
    while (true){
        int w,h;
        cin >> w >> h;
        if (w == 0 && h == 0){
            break;
        }
        for (int i = 0; i < w; i++){
            for (int j = 0; j < h; j++){
                if ((j + i) % 2 == 0){
                    cout << "#";
                }else {
                    cout << ".";
                }
            }
            cout << endl;
        }
        cout << endl;
    }
}


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

using namespace std;

#define FOR(i,s,e) for(int i=(s);(i)<(int)(e);(i)++)
#define REP(i,e) FOR(i,0,e)
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define all(o) (o).begin(), (o).end()
#define pb(x) push_back(x)
#define mp make_pair
#define mt make_tuple
#define t0(t) get<0>((t))
#define t1(t) get<1>((t))
#define t2(t) get<2>((t))

typedef long long ll;

int main() {
  int kk, s;
  fscanf(stdin, "%d%d ", &kk, &s);
  int res = 0;
  REP(x,kk+1) REP(y,kk+1) {
    int z = s - x - y;
    if (0 <= z && z <= kk) res++;
  }
  fprintf(stdout, "%d\n", res);
  return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

template <typename TYPE>
void print_vec(const vector<TYPE>& v){
	for(int i=0; i<v.size(); i++){
		cout << v[i] << " ";
	}
	cout << endl;
}

template <typename TYPE>
void print_vec2(const vector<vector<TYPE>>& v){
  cout << endl;
  for(int i=0; i<v[0].size(); i++) cout << i << "   "; 
  cout << endl;
	for(int i=0; i<v.size(); i++){
		cout << "i=" << i << ":   " << endl;
		for(int j=0; j<v[i].size(); j++){
			if(v[i][j] == 0) cout << "\x1B[0m" << v[i][j] << "   ";
      else cout << "\x1B[31m" << v[i][j] << "   ";//https://stackoverrun.com/ja/q/12618775
		}
		cout << "\x1B[0m" << endl;
	}
}
 
int main(){
  int D;
  cin >> D;
  vector<int> c(26, 0);
  for(int i=0; i<26; i++) cin >> c[i];
  vector<vector<int>> s(D, vector<int>(26, 0));
  for(int i=0; i<D; i++){
    for(int j=0; j<26; j++){
      cin >> s[i][j];
    }
  }


  int type = 0;
  for(int d=0; d<D; d++){
    
    for(int j=0; j<26; j++){
      if(s[d][j] > s[d][type]) type = j;
    }
    
    cout << type + 1 << endl;
  }

  // B問題 　ローカル確認用
  // vector<int> t(D);
  // for(int i=0; i<D; i++){
  //   cin >> t[i];
  //   t[i]--;
  // }
  // // cout << " c: " ; print_vec(c);
  // // //cout << " s: " << endl; print_vec2(s);
  // // cout << " t: " ; print_vec(t);
  // //vector<vector<int>> last(D, vector<int>(26, 0));
  // vector<int> last(26, -1);
  // ll score = 0;
  // for(int d=0; d<D; d++){
  //   int type = t[d];
  //   score += s[d][type];
  //   last[type] = d;
  
    
  //   for(int i=0; i<26; i++){
  //     score = score - c[i] * (d - last[i]);
  //     //cout << " d: " << d << " i: " << i << " c[]: " << c[type] << " score: " << score << endl;
  //   }
  //   //cout << " c[3]: " << c[3] << " (d - last[3]): "<< (d - last[3]) << "  c[3] * (d - last[3]): " << c[3] * (d - last[3]) << endl;
  //   cout << score << endl;
  // }

    
}


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

// Shortcut

#define int long long
#define endl '\n'
#define eb emplace_back
#define pb push_back
#define pob pop_back
#define mp make_pair
#define upb upper_bound
#define lwb lower_bound
#define fi first
#define se second
#define For(i, l, r) for (int i = l; i < r; i++)
#define ForE(i, l, r) for (int i = l; i <= r; i++)
#define Ford(i, r, l) for (int i = r; i > l; i--)
#define FordE(i, r, l) for (int i = r; i >= l; i--)
#define Fora(i, a) for (auto i : a)

// I/O & Debug

#define PrintV(a) for (int iiii = 0; iiii < a.size(); iiii++) cout << a[iiii] << ' ';
#define PrintVl(a) for (int iiii = 0; iiii < a.size(); iiii++) cout << a[iiii] << endl;
#define PrintA(a, n) for (int iiii = 0; iiii < n; iiii++) cout << a[iiii] << ' ';
#define PrintAl(a, n) for (int iiii = 0; iiii < n; iiii++) cout << a[iiii] << endl;
#define Ptest(x) return cout << x, 0;
#define gl(s) getline(cin, s);
#define setpre(x) fixed << setprecision(x)
/*
#define debug(args...){ string _sDEB = #args; replace(_sDEB.begin(), _sDEB.end(), ',', ' '); stringstream _ssDEB(_sDEB); istream_iterator<string> _itDEB(_ssDEB); DEB(_itDEB, args); }
void DEB(istream_iterator<string> it) {}
template<typename T, typename... Args>
void DEB(istream_iterator<string> it, T a, Args... args){
    cout << *it << " = " << a << endl;
    DEB(++it, args...);
}
*/

// Functions

//#define isvowel(a) (a == 'a' || a == 'e' || a == 'i' || a == 'o' || a == 'u')
#define bend(a) a.begin(), a.end()
#define rbend(a) a.rbegin(), a.rend()
#define mset(a) memset(a, 0, sizeof(a));
#define mmset(a) memset(a, 0x3f, sizeof(a));
//mt19937 rando(chrono::steady_clock::now().time_since_epoch().count());

// Data Structure

#define pque priority_queue
#define mts multiset
typedef long long ll;
typedef long double ld;
typedef vector <int> vi;
typedef vector <ll> vll;
typedef vector <ld> vld;
typedef vector <string> vs;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef vector <vi > vvi;
typedef vector <vll > vvll;
typedef vector <pii > vpii;
typedef vector <pll > vpll;

const int N = 1e5 + 5, mod = 1e9 + 7, inf = 1e9 + 7;

int n, m;
vi a;
vpii b;

bool cmp(pii x, pii y){
    if (x.se != y.se) return x.se > y.se;
    return x.fi > y.fi;
}

signed main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    cin >> n >> m;
    a.resize(n);
    b.resize(m);
    For(i, 0, n){
        cin >> a[i];
    }
    sort(bend(a));
    For(i, 0, m){
        cin >> b[i].fi >> b[i].se;
    }
    sort(bend(b), cmp);
    int idx = 0;
    For(i, 0, m){
        int t = b[i].fi;
        while (t && idx < n && a[idx] < b[i].se){
            a[idx] = b[i].se;
            idx++;
            t--;
        }
    }
    int sum = 0;
    For(i, 0, n){
        sum += a[i];
    }
    cout << sum;
}

/*
==================================+
INPUT:                            |
------------------------------    |

------------------------------    |
==================================+
OUTPUT:                           |
------------------------------    |

------------------------------    |
==================================+
*/

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

using namespace std;
using ll = long long;
using ld = long double;

//#define int long long
//signed main(){
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n,m;
    cin >> n >> m;
    vector<pair<int,int>> ba(m);
    for(int i = 0; i < m; i++) {
        cin >> ba[i].second >> ba[i].first;
    }
    sort(ba.begin(),ba.end());
    int prev=0;
    int cnt=0;
    for(int i = 0; i < m; i++) {
        if(ba[i].second>prev){
            prev=ba[i].first-1;
            cnt++;
        }
    }
    cout << cnt << "\n";

    return 0;
}

Measured memory_bytes: 3980