akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

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

    int N;
    int M;

    int count = 0;
    int min = 0;


    cin >> N >> M;

    vector<int> X(M);
    vector<int> koma(M);

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

    if(N < M){

        sort(X.begin(), X.end());

        for(int i = 0; i < M - 1; i++){
            int c = X[i + 1] - X[i];
            koma.push_back(c);
            count += c;
        }

        sort(koma.begin(), koma.end(), std::greater<int>());

        for(int i = 0; i < N - 1; i++){
            min += koma[i];
        }
     
        cout << count - min;

    }else{
        cout << 0;
    }
}

Measured memory_bytes: 1408
// https://ei1333.github.io/luzhiled/
// http://beet-aizu.hatenablog.com/entry/2017/01/04/113233
// http://www.prefield.com/algorithm/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
using vd = vector<ld>;
using vs = vector<string>;
using vb = vector<bool>;
using vvl = vector<vector<ll>>;
using vvd = vector<vector<ld>>;
using vvs = vector<vector<string>>;
using vvb = vector<vector<bool>>;
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;
using Graph = vector<vector<ll>>;
const ll INF = 1LL << 60;
void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}
const ll tl= 1000000007;
#define REP(i, n) for (ll i = 0; i < n; i++)
#define REREP(i, n) for (ll i = n; i >= 0; i--)
#define FOR(i, a, n) for (ll i = a; i < n; i++)
#define REFOR(i, n, a) for (ll i = n; i >= a; i--)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() ) //被り削除
#define debug cout << "line : " << __LINE__ << " debug" << endl;
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) long long __VA_ARGS__; in(__VA_ARGS__)
#define ind(...) long double __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
#define inc(...) char __VA_ARGS__; in(__VA_ARGS__)
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << endl;} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
template<typename T>void die(T x){out(x); exit(0);}
#define in1(A) REP(i,A.size()) in(A[i]);
#define in2(A,B) REP(i,A.size()) in(A[i],B[i]);
#define in3(s,t,u) REP(i,sz(s)){in(s[i] , t[i] , u[i]);}
#define in4(s,t,u,v) REP(i,sz(s)){in(s[i] , t[i] , u[i] , v[i]);}
#define each(x,v) for(auto& x : v)
#define all(v) (v).begin(),(v).end()
#define sz(v) ((int)(v).size())
struct Point{ ld x,y; };
ld dist(Point a, Point b){return sqrt(abs(a.x-b.x)*abs(a.x-b.x)+abs(a.y-b.y)*abs(a.y-b.y));} // ２点間の距離 
ll gcd(ll a, ll b) { return b != 0 ? gcd(b, a % b) : a; }
ll lcm(ll a,ll b){ return a / gcd(a,b) * b;} 
ll fact(ll n){ if(n < 2) return 1; return (n * fact(n-1))%tl; } //階乗
inline ll updiv(ll a,ll b){ return (a + b - 1) / b; } //切り上げ
template<typename T,typename U>ll ceil(T a,U b){return (a + b - 1) / b;}
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
//-------------------------------------------------------------------------------------------------
int main(){
    init();
    inl(n,w);
    vl V(n),W(n); in2(V,W); 
    vl dp(w+1,0);
    REP(i,n){
        REP(j,w+1){
            // 容量jにW[i]足した価値と元のj+W[i]のかちを比べる
            if(j+W[i]<=w) chmax(dp[j+W[i]],dp[j]+V[i]);
        }
    }
    out(dp[w]);
}


Measured memory_bytes: 3288
#include <stdio.h>
#include <string.h>

int main(void)
{
  char str[21], *p;

  fgets(str, 21, stdin);
  p = str + strlen(str) - 1;
  if (*p == '\n') p--;
  while (p >= str)
    putchar(*p--);
  printf("\n");

  return 0;
}

Measured memory_bytes: 524
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i <= (n); i++)
#define zep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,m,n) for(ll i = (m); i <= n; i++){cout << (x[i]) << " ";} cout<<endl;

int main(){
	cin.tie(0); ios::sync_with_stdio(false);
	
	string s;
	cin >> s;
	
	bool ans = true;
	ll n = s.size();
	if(n%2 != 0){
		ans = false;
	}
	else{
		zep(i, 0, n/2){
			if(s[2*i] != 'h' || s[2*i+1] != 'i'){
				ans = false;
			}
		}
	}
	print((ans)? "Yes" : "No")
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF (1e9)
#define PI (acos(-1))
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl

int main() {
    int N;  cin >> N;
    vector<int> T(N);  rep(i, N)  cin >> T[i];
    int M;  cin >> M;
    vector<int> P(M);
    vector<int> X(M);
    rep(i, M)  cin >> P[i] >> X[i];

    vector<int> vec;
    rep(i, M) {
        vector<int> temp = T;
        int sum = 0;
        temp[P[i]-1] = X[i];
        rep(j, N) {
            sum += temp[j];
        }
        vec.push_back(sum);
    }
    rep(i, M) print(vec[i]);
}




Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<algorithm>
#include<queue>
#include<cstdio>
#include<string>
#include<math.h>
typedef long long LL;
using namespace std;
int main()
{
  //  freopen("test.txt", "r", stdin);
  //  freopen("testout.txt", "w", stdout);
    int n=0;
    LL x,max_sum,cur_sum;
    while(~scanf("%d",&n)&&n)
    {
        x=0;
        cur_sum=0;
        max_sum=-99999999;
        while(n--)
        {
            cin>>x;
            cur_sum+=x;
            if(max_sum<cur_sum)
                max_sum=cur_sum;
            if(cur_sum<0)
                cur_sum=0;
        }
        cout<<max_sum<<endl;
    }
    return 0;
}


Measured memory_bytes: 3148
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        for (int i = 0; i < 5; i++) {
            if(scanner.nextInt() == 0){
                System.out.println(i + 1);
                break;
            }
        }
    }
}


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

int main() {
  int N; string S;
  cin >> N >> S;
  int ans = 1;
  for (int i = 1; i < N; i++) {
    if (S[i-1] != S[i]) ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 512
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
 
long long int dp[110][100010];
long long int w[110];
long long int v[110];
 
 
long long int max(long long int a, long long int b) {
	if (a < b)
		return b;
	else
		return a;
}
 
int main() {
 
	double maxweight = pow(10, 5);
	double maxvalue = pow(10, 9);
	int item = 0;
	int capacity = 0;
	int i = 0;
	int j = 0;
	long long int value = 0;
 
	if (scanf("%d", &item) > 0) {
		if (0 >= item || item > 100)
			exit(1);
	}
	if (scanf("%d", &capacity) > 0) {
		if (0 >= capacity || capacity > maxweight)
			exit(1);
	}
 
	for (i = 0; i < item; i++)
	{
		if (scanf("%lld", &w[i]) > 0) {
			if (0 >= w[i] || w[i] > maxweight)
				exit(1);
		}
		if (scanf("%lld", &v[i]) > 0) {
			if (0 >= v[i] || v[i] > maxvalue)
				exit(1);
		}
	}
 
	for (i = 0; i < item; i++) {
		for (j = 0; j < capacity; j++) {
			dp[i][j] = 0;
		}
	}
 
	for (i = 0; i < item; i++) {
		for (j = 0; j < capacity + 1; j++) {
			if (w[i] <= j)
			{
				dp[i + 1][j] = max(dp[i][j - w[i]] + v[i], dp[i][j]);
			}
			else
				dp[i + 1][j] = dp[i][j];
		}
	}
  
	for (i = 0; i < capacity; i++) {
		value = max(dp[item][i], dp[item][i + 1]);
	}
		
	printf("%lld", value);
  
  return 0;
}

Measured memory_bytes: 80000
#include<bits/stdc++.h>
using namespace std;
int main(){
    long long n;
    cin >> n;
    vector<long long> v;
    for(int i = 0; i < n; ++i){
        long long x;
        cin >> x;
        v.push_back(x);
    }
    long long m;
    cin >> m;
    for(int i = 0; i < m; ++i){
        long long a, b;
        cin >> a >> b;
        long long ans = 0;
        for(int j = 0; j < v.size(); ++j){
            if(a-1 == j){
                ans += b;
            } else {
                ans += v[j];
            }
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define rrep2(ri,x,n) for(int ri = (int)(n-1); ri >= (int)(x); ri--)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

int main(){
  ll s;
  cin >> s;
  const ll v = 1e9;
  ll x = (s+v-1) / v;
  int y = v*x-s;
  cout << "0 0 1 1000000000 ";
  cout << x << " "<< y << endl;
  return 0;
}

Measured memory_bytes: 3600
import collections

N = int(input())


def prime_factorization(n):
    """Algorithm: trial division"""
    divs = []
    div = 2
    while n % div == 0:
        divs.append(div)
        n //= div
    div = 3
    while div ** 2 <= n:
        if n % div == 0:
            divs.append(div)
            n //= div
        else:
            div += 2
    if n != 1:
        divs.append(n)
    return divs


div_count_map = collections.Counter(prime_factorization(N))
ans = 0
for div, cnt in div_count_map.items():
    e = 1
    while e <= cnt:
        ans += 1
        cnt -= e
        e += 1
print(ans)


Measured memory_bytes: 66120
#include<iostream>
#include<algorithm>
#include<vector>
#include<string.h>
#include<cstdlib>
#include<map>
#include<fstream>
#include<string>
#include<sstream>
#include<iomanip>
#include<cmath>
#include<random>
#include<set>
#include<queue>

using namespace std;

long long dp[3][100100] = {};
const long long INF = 1LL << 60;
#define MOD 1000000007
#define Int int64_t
#define PI 3.14159265358979
#define dump(a) cout << a << endl; 

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

/**
* @fn
* 最大値を取ります.Vector<int>を渡すこと.
*/
long long int imax(vector<int> a) {
	int MAX = -10000000;
	for (int i = 0; i < a.size(); i++) {
		if (MAX < a.at(i)) MAX = a.at(i);
	}
	return MAX;
}

/**
* @fn
* 最小値を取ります.Vector<int>を渡すこと.
*/
long long int imin(vector<int> a) {
	int MIN = 1000000000;
	for (int i = 0; i < a.size(); i++) {
		if (MIN > a.at(i)) MIN = a.at(i);
	}
	return MIN;
}

/**
* @fn
* 自然数について、桁数を求める
*/
Int getDigit(Int num) {
	return (Int)(log10(num)) + 1;
}


int get2Digit(Int num) {
	int cnt = 0;
	while (num > 0) {
		if (num % 2 != 0) {
			return cnt;
		}
		cnt++;
		num /= 2;
	}
}

long long int absmin(vector<int> a, long long int b) {
	int mini = 100000000;
	int d = 0;
	for (int i = 0; i < a.size(); i++) {
		if (mini > abs(a.at(i) - b)) {
			mini = abs(a.at(i) - b);
			d = i;
		}
	}
	return d;
}


long long int absmax(vector<int> a, long long int b) {
	int max = -100000000;
	int d = 0;
	for (int i = 0; i < a.size(); i++) {
		if (max < abs(a.at(i) - b)) {
			max = abs(a.at(i) - b);
			d = i;
		}
	}
	return d;
}

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

void haerobatya(int start, int end, char level) {
	if (start > end) swap(start, end);
	for (int i = start; i <= end; i++) {
		if (i < 100) {
			cout << "https://atcoder.jp/contests/abc0" << i << "/tasks/abc0" << i << "_" << level << endl;
		}
		else {
			cout << "https://atcoder.jp/contests/abc" << i << "/tasks/abc" << i << "_" << level << endl;
		}
	}
}

long long int cntmod(long long int warareru, long long int mod) {
	long long int i = 0;
	for (i = 0; true; i++) {
		if (warareru % mod == 0 && warareru >= mod) {
			warareru /= mod;
		}
		else {
			return i;
		}
	}
}

void ansYes(bool a) {
	if (a == true) cout << "Yes" << endl;
	else cout << "No" << endl;
}

void ansYES(bool a) {
	if (a == true) cout << "YES" << endl;
	else cout << "NO" << endl;
}


Int euclidean_gcd(Int a, Int b) {
	while (true) {
		if (a < b) swap(a, b);
		if (!b) break;
		a %= b;
	}
	return a;
}

typedef pair<int, int> pai;


//ここまでライブラリ
//ここから本文
int main() {
	int n;
	cin >> n;
	dump(n* 800 - 200*(n/15))
}

Measured memory_bytes: 256
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
 
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
 
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, T = MAP()
L = [LIST() for i in range(N)]

dp = [[0] * (T) for i in range(N+1)]

L.sort()
for i in range(N):
    for j in range(T):
        if j - L[i][0] >= 0:
            dp[i+1][j] = max(dp[i+1][j], dp[i][j-L[i][0]]+L[i][1])
        dp[i+1][j] = max(dp[i+1][j], dp[i][j])
# print(dp[N][T-1])

ans = 0
for k in range(N):
    # k番目を食べずにk-1番目まで食べたT-1秒以下での最大値に，
    # k番目のものをT-1秒目に食べた値の中での最大値
    # 一番いいものを最後に食べる
    ans = max(dp[k][T-1] + L[k][1], ans)
print(ans)





Measured memory_bytes: 133464
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define All(V) v.begin(), v.end()
typedef long long int ll;
typedef pair<int, int> P;
const ll MOD = 1e9+7, INF = 1e9;

vector<vector<pair<int, int>>> v;
int main()
{
  int a[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 
  2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  int k; cin >> k;
  cout << a[k-1] << endl;
  system("pause");
}

Measured memory_bytes: 504
def gcd(x,y):
    a=max(x,y)
    b=min(x,y)
    if a%b==0:
        return b
    else:
        return gcd(a%b,b)
def lcm(x,y):
    return (x*y)//gcd(x,y)
N,M=map(int,input().split())
S=input()
T=input()
X=lcm(N,M)
Y=gcd(N,M)
A=N//Y
B=M//Y
for i in range(Y):
    if S[i*A]!=T[i*B]:
        print(-1)
        exit()
print(X)


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

int main () {
  vector<char> line(9) ;
  
  for ( int i = 0  ; i < 9 ; i++ ) {
    cin >> line.at(i) ;
  }
  
  cout << line.at(0) << line.at(4) << line.at(8) << endl ;
}

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

int N;
int d[50];

signed main() {
  cin >> N;
  for(int i=0; i<N; i++) cin >> d[i];

  int sum = 0;
  for(int i=0; i<N; i++) for(int j=i+1; j<N; j++) 
    sum += d[i] * d[j];

  cout << sum << endl;

}


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

int main() {
  int H,N;
  cin >> H >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++) cin >> A[i];
  sort(A.begin(), A.end());
  for (int i = 0; i < N; i++)
  {
    H -= A[i];
  }
  if (H>0)
  {
    cout << "No" << endl;
  } else {
    cout << "Yes" << endl;
  }
  
  
 return 0;
}

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

#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define rep(i, k, n) for (int i = (int)(k); i < (int)(n); ++i)
#define rrep(i, k, n) for (int i = (int)(n) - 1; i >= (int)(k); --i)

typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef vector<vii> vv_ii;
typedef pair<int,ii> i_ii;
typedef vector<i_ii> vi_ii;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;

template <class T>
inline ostream& operator<<(ostream & o, vector<T> const& v) {
    for (int i = 0; i < (int)(v.size()) - 1; ++i)
        o << v[i] << ' ';
    if (!v.empty())
        o << v.back();
    return o;
}

template <class T, class Q>
inline ostream& operator<<(ostream & o, pair<T,Q> const& p) {
    o << "(" << p.fi << "," << p.se << ")";
    return o;
}

#define PI acos(-1)

int main(){

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

    
    int r;
    cin >> r;
    cout << r * r << '\n';

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#define LL long long
using namespace std;

LL gcd(LL x, LL y)
{
	if (x < y) return gcd(y, x);
	if (x == y) return x;
	if (x == 1ll || y == 1ll) return 1ll;
	int mod = x % y;
	if (mod == 0ll) return y;
	return gcd(y, mod);
}

int main(int argc, char const *argv[])
{
	LL a, b;
	cin >> a >> b;
	cout << a * b / gcd(a, b);
	return 0;
}

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

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define LL long long
#define INF INT_MAX/3

const double EPS = 1e-14;
const double PI  = acos(-1.0);


LL dp[51][51][2501];

int main(){
  int n, a;

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

  vector<int> v(n);
  REP (i, n) {
    cin >> v[i];
  }

  REP (j, 2501) dp[0][0][j] = 0;

  FOR (i, 1, n + 1) {
    FOR (j, 1, n + 1) {
      REP (k, 2501) {
        int x = k - v[i - 1];
        if (x == 0 && j == 1) {
          dp[i][j][k] = dp[i - 1][j - 1][x] + dp[i - 1][j][k] + 1;
        } else if (0 < x && dp[i - 1][j - 1][x] > 0) {
          dp[i][j][k] = dp[i - 1][j - 1][x] + dp[i - 1][j][k];
        } else {
          dp[i][j][k] = dp[i - 1][j][k];
        }
      }
    }
  }

  LL ans = 0;
  FOR (j, 1, n + 1) {
    REP (k, 2501) {
      if (j * a == k) ans += dp[n][j][k];
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 50048
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define endl "\n"
#define mod 1000000007
#define fastio std::ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define deb(x) cout<<#x<<" "<<x<<endl;

int main()
{
	fastio;
	ll n;
	cin>>n;
	n = n-1;
	ll ans =  (n*(n+1))/2;
	std::cout << ans << '\n';
}


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

int main(void){
    int N,M,sum=0;
    cin>>N;
    int T[N];
    for(int i=0;i<N;i++){
        cin>>T[i];
        sum+=T[i];
    }
    cin>>M;
    int P[M],X[M];
    for(int i=0;i<M;i++){
        cin>>P[i]>>X[i];
        cout<<sum+X[i]-T[P[i]-1]<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <iostream>
#include <set>
#include <string>
#include <vector>

typedef long long ll;
using namespace std;

int main() {
  ll N;
  cin >> N;
  vector<char> cs;
  int q;
  while (N != 0) {
    q = N % 26;
    if (q == 0) {
      cs.push_back('z');
      N -= 26;
    } else {
      cs.push_back('a' + q - 1);
      N -= q;
    }
    N /= 26;
  }
  for (int i = (int)cs.size() - 1; i >= 0; i--) {
    cout << cs[i];
  }
  cout << endl;
}

Measured memory_bytes: 3636
w,h,n=map(int,input().split())
pic=[[1 for i in range(w)] for j in range(h)]
for i in range(n):
    x,y,a=map(int,input().split())
    if a==1:
        for j in pic:
            for k in range(x):
                j[k]=0
    elif a==2:
        for j in pic:
            for k in range(x,w):
                j[k]=0
    elif a==3:
        for j in range(y):
            for k in range(w):
                pic[j][k]=0
    elif a==4:
        for j in range(y,h):
            for k in range(w):
                pic[j][k]=0 
ans=0
for i in pic:
    ans+=sum(i)
print(ans) 

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define rep(i,s,t) for(int i=(s);i<(t);++i)
#define per(i,s,t) for(int i=((t)-1);i>=s;--i)
#define repb(i,s,t) for(int i=(s);i<=(t);++i)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)x.size())
#define mst(a,b) memset(a,b,sizeof(a))
#define mcpy(des,sor) memcpy(des,sor,sizeof(sor))
#define dd(x) cout<<#x<<'='<<x<<' '
#define de(x) cout<<#x<<'='<<x<<'\n'
#define fi first
#define se second
#define sq(x) ((x)*(x))
typedef long long ll;
typedef pair<int,int> pii;
typedef double db;

const int inf = 0x3f3f3f3f;
const ll mod = 1e9+7;
const db eps = 1e-8;


int main()
{
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int n,a;ll s=0,t;vector<int> v;
	cin>>n;
	rep(i,0,n){cin>>a;v.pb(a);}
	sort(all(v));reverse(all(v));
	if(sz(v)%2==0)
	{
		rep(i,0,sz(v)/2)s+=2*v[i];
		s-=v[sz(v)/2-1];
		rep(i,sz(v)/2,sz(v))s-=2*v[i];
		s+=v[sz(v)/2];
		cout<<s<<endl;
	}
	else
	{
		t=0;
		rep(i,0,sz(v)/2)t+=2*v[i];
		rep(i,sz(v)/2,sz(v))t-=2*v[i];
		t+=v[sz(v)/2],t+=v[sz(v)/2+1];
		s=max(s,t);
		t=0;
		rep(i,0,sz(v)/2+1)t+=2*v[i];
		t-=v[sz(v)/2];t-=v[sz(v)/2-1];
		rep(i,sz(v)/2+1,sz(v))t-=2*v[i];
		s=max(s,t);
		cout<<s<<endl;
	}
}

Measured memory_bytes: 892
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<cmath>
#include<climits>
#include<queue>
#include<stack>
#include<numeric>
#include<set>
#include<iomanip>
#include<map>
#include<type_traits>
#include<tuple>
#include<deque>
#include<cassert>
#include<bitset>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
const int mod = 1000000007;

int main() {
  ll n;
  cin >> n;
  vector<ll> a(n + 1);
  rep(i, n) cin >> a[i];
  ll ans = 0;
  rep(i, n) {
    ans += a[i] / 2;
    a[i] %= 2;
    if(a[i] && a[i + 1]) {
      ans++;
      a[i + 1]--;
    }
  }
  cout << ans << endl;

}

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

using namespace std;

const long long INF = 1e16;
int N, W, w[100], v[100];
long long dp[109][100009];

int main(){
	cin >> N >> W;
	for(int i = 0; i < N; ++i) cin >> w[i] >> v[i];
	
	int maxv = N * 1000;
	for(int i = 0; i <= N; ++i) for(int j = 0; j <= maxv; ++j) dp[i][j] = INF;
	dp[0][0] = 0;
	
	for(int i = 0; i < N; ++i){
		for(int j = 0; j <= maxv; ++j){
			dp[i+1][j+v[i]] = min(dp[i+1][j+v[i]], dp[i][j]+w[i]);
			dp[i+1][j] = min(dp[i+1][j], dp[i][j]);
		}
	}
	
	long long ans = 0;
	for(int j = 0; j <= maxv; ++j) if(dp[N][j] <= W) ans = j;
	cout << ans << endl;
}

Measured memory_bytes: 80128
import java.util.*;
import static java.lang.System.*;

public class Main {

	Scanner sc = new Scanner(in);
	String[] a = new String[10];
	String[] b = new String[10];
	int dlen;
	
	String substitute(String s, int i) {
		StringBuilder res = new StringBuilder();
		int index = 0, n = s.length(), len = a[i].length();
		boolean flag = false;
		while (index < n) {
			if (index+len <= n && s.substring(index, index+len).equals(a[i])) {
				res.append(b[i]);
				index += len;
				flag = true;
			} else {
				res.append(s.charAt(index));
				index++;
			}
		}
		if (!flag || res.length() > dlen)
			return null;
		else
			return res.toString();
	}
	
	void run() {
		Queue<String> que = new LinkedList<String>();
		Queue<Integer> num = new LinkedList<Integer>();
		W:while (true) {
			int n = sc.nextInt();
			if (n == 0) break;
			for (int i = 0; i < n; i++) {
				a[i] = sc.next();
				b[i] = sc.next();
			}
			String c = sc.next(), d = sc.next();
			dlen = d.length();
			que.clear();
			num.clear();
			que.add(c);
			num.add(0);
			while (!que.isEmpty()) {
				String s = que.poll();
				int count = num.poll();
				for (int i = 0; i < n; i++) {
					String t = substitute(s, i);
					if (t != null) {
						if (t.equals(d)) {
							out.println(count+1);
							continue W;
						}
						que.add(t);
						num.add(count+1);
					}
				}
			}
			out.println(-1);
		}
	}
	
	public static void main(String[] args) {
		new Main().run();
	}

}

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

typedef long long ll;
#define all(x) (x).begin(),(x).end()

int main(){
    
    ll N;cin>>N;
    bool flag=true;
    for(ll a=1;a<=3500;a++){
        for(ll b=1;b<=3500;b++){
            if(4*a*b-N*a-N*b!=0){
            ll c=N*a*b/(4*a*b-N*a-N*b);
            if(c>0){
            if(4*a*b*c==N*(a*b+b*c+c*a)){
                cout<<a<<" "<<b<<" "<<c<<endl;
                flag=false;
                break;
            }
            }
            }
        }
        if(!flag) break;
    }
}


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

public class Main {

    private static final String BLANK = " ";

    public static void main(String[] args) {

        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        String input = null;

        try {
            while ((input = in.readLine()) != null) {

                String[] dataArrray = input.split(BLANK);

                double xa = Double.valueOf(dataArrray[0]);
                double ya = Double.valueOf(dataArrray[1]);
                double xb = Double.valueOf(dataArrray[2]);
                double yb = Double.valueOf(dataArrray[3]);
                double xc = Double.valueOf(dataArrray[4]);
                double yc = Double.valueOf(dataArrray[5]);
                double xp = Double.valueOf(dataArrray[6]);
                double yp = Double.valueOf(dataArrray[7]);

                // a -> bとa -> pの外積
                double crossPrdct1 = (xb - xa) * (yp - ya) - (yb - ya)
                        * (xp - xa);

                // b -> cとb -> pの外積
                double crossPrdct2 = (xc - xb) * (yp - yb) - (yc - yb)
                        * (xp - xb);

                // c -> aとc -> pの外積
                double crossPrdct3 = (xa - xc) * (yp - yc) - (ya - yc)
                        * (xp - xc);

                // 全て同じ符号ならば三角形の内部
                if ((crossPrdct1 > 0.0 && crossPrdct2 > 0.0 && crossPrdct3 > 0.0)
                        || (crossPrdct1 < 0.0 && crossPrdct2 < 0.0 && crossPrdct3 < 0.0)) {

                    System.out.println("YES");
                } else {
                    System.out.println("NO");
                }
            }
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            try {
                in.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
}

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

using namespace std;

/*******  All Required define Pre-Processors and typedef Constants *******/
#define in1(n) cin>>n;
#define in2(n, k) cin>>n>>k;
#define in3(n, k, s) cin>>n>>k>>s;
#define scn(t) scanf("%d", &t)
#define scnld(t) scanf("%ld", &t)
#define scnlld(t) scanf("%lld", &t)
#define scnc(t) scanf("%c", &t)
#define scns(t) scanf("%s", t)
#define scnf(t) scanf("%f", &t)
#define scnlf(t) scanf("%lf", &t)
#define mem(a, b) memset(a, (b), sizeof(a))
#define nloop(i, j, k, in) for (int i = j; i < k; i += in)
#define rloop(i, j, k, in) for (int i = j; i >= k; i -= in)
#define rep(i, j) nloop(i, 0, j, 1)
#define rrep(i, j) rloop(i, j, 0, 1)
#define inar(n, a) \
    rep(i, n)\
        cin>>a[i];
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define foreach(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define IN(A, B, C) assert(B <= A && A <= C)
#define MP make_pair
#define PB push_back
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define fast  \
    ios_base::sync_with_stdio(false);\
    cin.tie(NULL);
#define INF (int)1e9
#define EPS 1e-9
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
#define read(type) readInt<type>()
#define test  \
    int t;    \
    cin >> t; \
    while (t--)
const double pi = acos(-1.0);
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<PII> VII;
typedef vector<VI> VVI;
typedef map<int, int> MPII;
typedef set<int> SETI;
typedef multiset<int> MSETI;
typedef long int int32;
typedef unsigned long int uint32;
typedef long long int int64;
typedef unsigned long long int uint64;

int main()
{
    fast
    int k, a, b;
    in3(k,a,b)
    for(int i = 1; i*k <= b; i++)
    {
        if (k * i >= a && k * i <= b)
        {
            cout << "OK";
            return 0;
        }
    }
    cout<<"NG";
    return 0;
}

Measured memory_bytes: 3612
def resolve():
    N = int(input())
    cnts = [0] * (10**4 + 1)
    for i in range(1, 100):
        for j in range(1, 100):
            for k in range(1, 100):
                num = i * i + j * j + k * k + i * j + j * k + i * k
                if num <= 10**4:
                    cnts[num] += 1
    for i in range(1, N + 1):
        print(cnts[i])


resolve()


Measured memory_bytes: 9244
// Undone
#include <bits/stdc++.h>
#define int long long
#define double long double
#define INF 1e18
#define MOD 1000000007
using namespace std;
signed main() {
  int P,Q,R;
  cin>>P>>Q>>R;
  cout << min(P+Q, min(Q+R, P+R)) << endl;  
}



Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;

template<class TH> void _dbg(const char *sdbg, TH h){ cerr<<sdbg<<'='<<h<<endl; }
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',')cerr<<*sdbg++;
  cerr<<'='<<h<<','; _dbg(sdbg+1, a...);
}

#ifdef LOCAL
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define debug(...) 42
#endif

typedef long long ll;
const int maxn = 1e5+100;
ll n;
ll a[200];
int main()
{
    cin >> n;
    for (int i = 0; i < n; ++i)
        cin >> a[i];
    ll res = 1000,sto = 0;
    int i = 0;
    while (i < n-1)
    {
        if (a[i] <= a[i+1])
        {
            sto += res / a[i];
            res -= (res/a[i])*a[i];
        }
        else 
        {
            res += sto*(a[i]);
            sto = 0;
        }
        i++;
    }
    if (sto) res += sto*a[n-1];
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
int main ()
{
    long long n, m, k;
    cin >> n >> k >> m;
    if (n<0)
        n*=-1;
    if (n/m>=k)
        cout << n-m*k << endl;
    else if (n%m<abs(n%m-m))
    {
        k-=(n/m);
        if (k%2==1)
            cout << abs(n%m-m) << endl;
        else
            cout << n%m << endl;
    }
    else if (n%m>abs(n%m-m))
    {
        k-=(n/m);
        if (k%2==1)
            cout << abs(n%m-m) << endl;
        else
            cout << n%m << endl;
    }
    else if (n%m==abs(n%m-m))
    {
        cout << n%m << endl;
    }
}


Measured memory_bytes: 3632
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
 
#define FOR(i,k,n) for (int (i)=(k); (i)<(n); ++(i))
#define rep(i,n) FOR(i,0,n)
#define all(v) begin(v), end(v)
#define debug(x) cerr<< #x <<": "<<x<<endl
#define debug2(x,y) cerr<< #x <<": "<< x <<", "<< #y <<": "<< y <<endl
 
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<ll> vll;
typedef vector<vector<ll> > vvll;
typedef deque<bool> db;
template<class T> using vv=vector<vector< T > >;

int n, k;
string s;
int cnt;

deque<int> ar;
bool top_is_a;
void print_ans() {
  int ab = (top_is_a) ? 0 : 1;
  int m = (int)ar.size();
  rep (i, m) {
    char c = 'A' + ((i + ab) % 2);
    rep (j, ar[i]) {
      printf("%c", c);
    }
  }
  printf("\n");
  exit(0);
}

void manipulate() {
  if (top_is_a) {
    if (ar[0] > 1) {
      ar[0] -= 1;
      ar.push_front(1);
    } else {
      ar.pop_front();
      ar[0] += 1;
    }
    top_is_a = false;
  } else {
    if ((int)ar.size() % 2 == 1) { // tail is 'B'
      if (ar[0] > 1) {
        ar[0] -= 1;
        ar.back() += 1;
        top_is_a = true;
      } else {
        ar.pop_front();
        ar.back() += 1;
      }
      return;
    }
    if (ar[0] > 1) {
      ar[0] -= 1;
      ar.push_back(1);
      top_is_a = true;
    } else {
      ar.pop_front();
      ar.push_back(1);
    }
  }
}

int main() {
  cin >> n >> k;
  cin >> s;
  {
    int ind = 0;
    rep (i, n) {
      if (s[i] != s[ind]) {
        ar.push_back(i - ind);
        ind = i;
      }
    }
    ar.push_back(n - ind);
  }
  top_is_a = (s[0] == 'A');
  cnt = 0;
  while (cnt < k) {
    if (n % 2 == 0) {
      if ((!top_is_a) && (int)ar.size() == n) {
        print_ans();
      }
    } else {
      if (top_is_a && (int)ar.size() == n) {
        if ((k - cnt) % 2 == 1) {
          manipulate();
        }
        print_ans();
      }
    }

    cnt += 1;
    manipulate();
  }
  print_ans();

  return 0;
}


Measured memory_bytes: 1404
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <queue>
#include <stack>

using namespace std;
typedef long long ll;

int main()
{
    int n,d,x,y;
    cin>>n>>d;
    int sum=0;
    for(int i=0;i<n;i++)
    {
        cin>>x>>y;
        double f=sqrt(pow(x,2)+pow(y,2));
        if(f<=1.0*d)
            sum++;
    }
    cout<<sum;
    return 0;
}


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

using namespace std;

int main () {
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	char c; 
	int res;
	while (cin >> c) {
		res += int (c) - int('0');
	}
	if(res % 9 == 0) cout << "Yes";
	else cout << "No";
}


Measured memory_bytes: 3672
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let a: i64 = read();
    let b: i64 = read();
    println!("{}", (a + b) % 24);

}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll MAX=1e18;
ll mod=1e9+7;
#define pb push_back
#define se second
#define fi first
#define maxe max_element
#define mine min_element
#define debug(x) cout<<#x<<" :: "<<x<<endl;
#define debug2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<endl;
#define debug3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<endl;
#define debug4(x,y,z,w) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\t"<<#w<<" :: "<<w<<endl;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define boost  ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
vector<int> graph[205];
int color[205];
int nCk[100][100];
bool bipartite_jugding(int v, int c){
    color[v] = c;
    for(int i = 0; i < graph[v].size(); ++i){
        if(color[graph[v][i]] == c) return false;
        if(color[graph[v][i]] == 0 && !bipartite_jugding(graph[v][i], -c)){
            return false;
        }
    }
    return true;
}

 void combi() {
	for (int i = 0; i <= 99; ++i) nCk[i][0] = 1;
	for (int i = 1; i <= 99; ++i) for (int j = 1; j <= i; ++j) {
		nCk[i][j] = (nCk[i-1][j] + nCk[i-1][j-1]) % mod;
	}
}

long long expo(ll x,ll n,ll M)
{

    if(n==0)
        return 1;
    else if(n%2 == 0)        //n is even
        return expo((x*x)%M,n/2,M);
    else                             //n is odd
        return (x*expo((x*x)%M,(n-1)/2,M))%M;

}

void solve()
{
   int n;
   cin>>n;
   vector<int> p(n+1);set<int> st;
   for(int i=1;i<=n;i++)
   cin>>p[i];
   for(int i=1;i<=n;i++)
    st.insert(p[i]);
int ans=0;
   for(int i=n;i>0;i--)
   {
       st.erase(p[i]);
       set<int>::iterator itr,it;
      itr=st.lower_bound(p[i]);
      if(itr==st.begin())
        {ans++;}
   }
   cout<<ans<<endl;


}

int main(){
    boost;
  solve();
}


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

int binarySearch(int key);

int *S, n, k = 0;

int main()
{
  int *T;
  int q, i, tmp;

  scanf("%d", &n);
  S = (int *)malloc(n * sizeof(int));
  for(i = 0; i < n; i++)
    scanf("%d", &S[i]);

  scanf("%d", &q);
  T = (int *)malloc(q * sizeof(int));
  for(i = 0; i < q; i++)
    scanf("%d", &T[i]);

  /* printf??§??????????¢????
     for(i = 0; i < n; i++)
     printf("%d ", S[i]);
     printf("\n");

     for(i = 0; i < q; i++)
     printf("%d ", T[i]);
     printf("\n");
  */

  for(i = 0; i < q; i++){
    tmp = binarySearch(T[i]);
    //  printf("tmp = %d\n", tmp);
    //if(tmp == 0)
    //  fprintf(stderr, "NOT_FOUND\n");
    }

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


int binarySearch(int key)
{
  int left = 0, right = n, mid;

  while(left < right){
    mid = (left + right) / 2;
    if(S[mid] == key){
      k++;
      return mid;
    }
    else if(key < S[mid])
      right = mid;
    else
      left = mid + 1;
  }
  return 0;
}

Measured memory_bytes: 1188
#include<cstdio>
using namespace std;
typedef long long LL;
const int N=100005;
LL S[N],s[N],l[N],k,x;
int i,j,n,m,g,Q;
char c;

inline char getc()
{
	#define VV 10000000
	static char s[VV],*l=s,*r=s;
	if (l==r)
		l=s,r=s+fread(s,1,VV,stdin);
	return l==r?0:*l++;
}

LL read(){ LL z=0; do c=getc(); while (c<'0'||c>'9'); while (c>='0'&&c<='9') z*=10,z+=c-'0',c=getc(); return z; }

int find(LL z,int R)
{
	int L=1;
	while (L<R)
	{
		int mid=L+R+1>>1;
		if (l[mid]>z) R=mid-1; else L=mid;
	}
	return L;
}

int main()
{
	//freopen("1.in","r",stdin);
	l[g=1]=n=read(),Q=read()+1;
	for (i=2;i<=Q;++i)
	{
		x=read();
		for (;g&&x<=l[g];--g);
		l[++g]=x;
	}
	s[g]=1;
	for (i=g;i>1;--i)
	{
		s[i-1]+=l[i]/l[i-1]*s[i],k=l[i]%l[i-1];
		j=i;
		while (k>l[1])
		{
			j=find(k,j-1),
			s[j]+=k/l[j]*s[i],k%=l[j];
		}
		S[k]+=s[i];
	}
	S[l[1]]+=s[1];
	for (i=l[1];i;--i)
		S[i]+=S[i+1];
	for (i=1;i<=n;++i)
		printf("%lld\n",S[i]);
	return 0;
}

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

int main() {
  long int k,a,b,x;
  cin>>k>>a>>b;
  x=1;
  
  if(b-a<=2)x+=k;
  else if((k-a+1)%2==0)x+=a-1+(k-a+1)*(b-a)*1/2;
  else x+=a+(k-a)*(b-a)*1/2;
  cout<<x<<endl;
}

    

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<utility>
#include<algorithm>
#include<string>
#include<cstdio>
#include<queue>
#include<functional>
#include <tuple>
#include<iomanip>
#include<stack>
#include<cmath>
#define ll long long
#define N 1000000007
using namespace std;
ll power(ll x) {
	ll n = 1;
	for (ll i = 2; i <= x; ++i) {
		n = n * i;
		if (n%N != 0) n %= N;
	}
	return n;
}
ll fuc(ll x, ll y) {
	if (y == 0) return 1;
	return y % 2 == 1 ? x * fuc(x, y - 1) % N: fuc(x*x % N, y / 2);
}
int main() {
	ll x, y; cin >> x >> y;
	ll k = (2 * x - y) / 3, l = (2 * y - x) / 3;
	if (k<0||l<0||(2*x-y)%3!=0||(2*y-x)%3!=0) {
		cout << "0" << endl;
		return 0;
	}
	cout << (power(k+l)*fuc(power(k),N-2)%N)*fuc(power(l),N-2)%N << endl;
	return 0;
}

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

typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> II;
typedef vector<II> VII;

#define REP(x, n) for (int x = 0; x < (n); ++x)
#define INF (1e9 + 1)
#define EPS 1e-9
#define PB push_back
#define MP make_pair
#define F first
#define S second

int main() {
    
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
    int n;
    cin >> n;
    VI dishes(n), points(n), bonus(n - 1);
    REP (i, n) {
        cin >> dishes[i];
    }
    REP (i, n) {
        cin >> points[i];
    }
    REP (i, n - 1) {
        cin >> bonus[i];
    }
    int sum = 0;
    for (int dish : dishes) {
        sum += points[dish - 1];
    }
    for (int i = 0; i < n - 1; ++i) {
        if (dishes[i + 1] - dishes[i] == 1) {
            //printf("%d is greater than %d at %d\n", dishes[i + 1], dishes[i], i);
            sum += bonus[dishes[i] - 1];
        }
    }
    cout << sum << '\n';
    return 0;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

#define MAX 100

#define WHITE 0
#define GRAY 1
#define BLACK 2
#define INFTY 1<<21

int n;
int color[MAX],p[MAX],d[MAX],M[MAX][MAX];

void dijkstra(){
  for(int i=0;i<n;i++){
    color[i] = WHITE;
    p[i] = -1;
    d[i] = INFTY;
  }

  d[0] = 0;
  p[0] = -1;
  color[0] = GRAY;

  while(true){

    int minicost = INFTY;
    int u=-1;

    for(int i=0;i<n;i++){
      if(color[i] != BLACK && minicost > d[i]){
        minicost = d[i];
        u = i;
      }
    }
    if(u==-1){
      break;
    }
    color[u] = BLACK;

    for(int i=0;i<n;i++){
      if( color[i] != BLACK && d[i] > d[u] + M[u][i] ){
        d[i] = d[u] + M[u][i];
        p[i] = u;
        color[i] = GRAY;
      }
    }
  }

  for(int i=0;i<n;i++){
    cout << i << " " << d[i] << endl;
  }

}


int main(void){
  cin >> n;
  int u,k;
  int s, t;

  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      M[i][j] = INFTY;
    }
  }

  for(int i=0;i<n;i++){
    cin >> u >> k;
    for(int j=0;j<k;j++){
      cin >> s >> t;
      M[u][s] = t;  
    }
  }

  dijkstra();

  return 0;
}



Measured memory_bytes: 3124
import java.util.List;
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();

        List<Integer> list = new ArrayList<>();

        for (int i = 3; i <= n; i++) {
            boolean judge = false;

            if (i % 3 == 0) {
                judge = true;
            } else if ((String.valueOf(i)).indexOf("3") != -1) {
                judge = true;
            }

            if (judge == true) {
                list.add(i);
            }
        }

        for (int i = 0; i < list.size(); i++) {
            System.out.print(" " + list.get(i));
        }

        System.out.print("\n");

        sc.close();
    }
}


Measured memory_bytes: 30284
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<vector>
#include<list>
#include<algorithm>
#include<math.h>
#include<map>
#include<iomanip>
#include<functional>
#include<limits>
#include <unordered_map>
#include <numeric>
#include <array>
#include <queue>
#include <chrono>
#include <random>
#include <fstream>


using namespace std;
using  ull = unsigned long long int;

#define rep(i,n,m) for(long long int i=n;i<(long long int)(m);i++)
#define INF (1<<29)
#define MD 1000000007

int main() {
	
	int a, b, x;
	cin >> a >> b >> x;

	if (a<=x && x<=a+b)cout << "YES" << endl;
	else cout << "NO" << endl;








	return 0;
}


Measured memory_bytes: 256
import numpy as np
from scipy.sparse.csgraph import floyd_warshall as wf
n=int(input())
s=np.array([list(map(int,input().split()))for i in range(n)])
if np.any(s!=wf(s,directed=False)):
    print(-1)
else:
    c=0
    for i in range(n):
        s[i][i]=10**10
    for i in range(n):
        for j in range(i+1,n):
            d=np.min(s[i]+s[j])
            if s[i,j]!=d:
                c+=s[i,j]
    else:
        print(c)

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

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

  vector<int> a(N, 0);
  for (int i = 0; i < N; i++) {
    scanf("%d", &a.at(i));
  }

  int bucket_size = 99999;
  int buckets[bucket_size] = {0};
  for (auto x : a) {
    buckets[x]++;
  }

  int ans = 0;
  for (int i = 0; i <= bucket_size - 2; i++) {
    int count = buckets[i] + buckets[i + 1] + buckets[i + 2];
    if (count > ans) ans = count;
  }

  printf("%d", ans);
}

Measured memory_bytes: 1024
/*

            Question ID-> 
                                       */
#include<bits/stdc++.h>
#include<cmath>
#include<cstring>
#include<climits>
#define int long long
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);
#define asc(a,n) sort(a,a+n);
#define dsc(a,n) sort(a,a+n,comp);
#define fo(i,x,y) for(int i=x;i<y;i++)
#define inarr(x) int n; cin>>n; int x[n]; fo(i,0,n){cin>>x[i];}
#define test int t; cin>>t; while(t--)
using namespace std;

int basic(){freopen("input.txt","r",stdin);
freopen("output.txt","w",stdout);return 0;}
bool comp(int a,int b){return a>b;}



int32_t main()
{ //basic(); 
  fast; 
  int n; cin>>n; 
  if(n%10==2 or n%10==4 or n%10==5 or n%10==7 or n%10==9){cout<<"hon"; return 0;}
  if(n%10==0 or n%10==1 or n%10==6 or n%10==8){cout<<"pon"; return 0;}
  if(n%10==3){cout<<"bon"; return 0;}

  return 0;
}










Measured memory_bytes: 3648
#include<cstdio>
#include<cstring>
#include<map>
#include<queue>
#include<iostream>
#include<algorithm>
#define maxn 100050
using namespace std;
typedef long long LL;

int n;
LL D[maxn];

int pos[maxn];

LL ans[maxn];

LL size[maxn];

map<LL,int> mp;

void init()
{
	scanf("%d",&n);
	for (int i=1;i<=n;++i)
	{
		pos[i]=i;
		scanf("%lld",&D[i]); 
		mp[D[i]]=i;
	}
}

int fa[maxn];

bool vis[maxn];

bool cmp(int i,int j)
{
	return D[i]>D[j];
}

int find(LL x)
{
	return mp.count(x)?mp[x]:0;
}

bool solve()
{
	sort(pos+1,pos+n+1,cmp);
	for (int k=1;k<n;++k)
	{
		
		int i=pos[k],j=find(D[i]+2LL*++size[i]-n);
//		cout<<"out:"<<i<<" "<<ans[i]<<endl;
		
		vis[i]=1;
//		cout<<i<<" "<<j<<" "<<D[i]+2LL*size[i]-n<<endl;
		if (!j||vis[j])
			return 0;
		fa[i]=j;
		size[j]+=size[i];
		ans[j]+=ans[i]+size[i];
	}
	
//	cout<<ans[pos[n]]<<" "<<D[pos[n]]<<endl;
	if (ans[pos[n]]!=D[pos[n]])
		return 0;
//	puts("YES");
	for (int k=1;k<=n;++k)
	{
		int u=pos[k];
		if (fa[u])
			printf("%d %d\n",u,fa[u]);
	}
	return 1;
}

int main()
{
//    freopen("c.in","r",stdin);
//    freopen("c.out","w",stdout);
    init();
    if (!solve())
    	printf("-1\n");
    return 0;
}

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

int main() {
	int N;
  	string S;
  	cin >> N >> S;
  
  	int cut = 1;
  	int maxi = 0;
  
  	while(cut < N - 1) {
      int ans = 0;
      vector<bool> alpha(26,false);
      
      for(int i = 0; i < cut;i++) {
          for(int j = cut; j < N; j++) {
		if(S.at(i) == S.at(j)) {
        	alpha.at(S.at(i) - 'a') = true;
       	  }
        }
      }
      
      	for(int i = 0; i < 26; i++) {
        if(alpha.at(i)) ans++;
        }
      
      	maxi = max(maxi,ans);
      	cut++;
    }
  
  	cout << maxi << endl;
}


Measured memory_bytes: 256
import itertools

N = int(input())
c = []
d = 0


for i in range(N):
  x1, y1 = map(int, input().split())
  c.append((x1,y1))
  
cp = list(itertools.permutations(c))
x = len(cp)

for i in range(x):
  for j in range(N-1):
  	d += ((cp[i][j][0]-cp[i][j+1][0])**2 + (cp[i][j][1] - cp[i][j+1][1])**2)**0.5
  
  
print(d/x)

Measured memory_bytes: 13864
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; ++i)
#define REPP(i, n) for(int i = 1; i <= n; ++i)
#define REPR(i, n) for(int i = n-1; i >= 0; --i)
#define FOR(i, m, n) for(int i = m; i < n; ++i)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
const int MOD = 1000000007;

template<typename T1,typename T2> inline void chmin(T1 &a,T2 b) {if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b) {if(a<b) a=b;}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >>  n;
    string s; cin >> s;
    int ans = 0;
    REP(i,n) {
        while(i+1<n && s[i]==s[i+1]) {
            ++ i;
        }
        ++ ans;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define brep(i,n) for(int i=n-1;i>=0;i--)
#define rep1(i,n) for(int i=1;i<n;i++)
#define cY cout<<"YES"<<endl
#define cN cout<<"NO"<<endl
#define ll long long

unsigned const int MOD = 1e9+7;



int main(void){
    ll a[5];
    rep(i,5){
        a[i]= 0;
    }
    rep(i,3){
        int n,m;
        cin >> n >> m;
        a[n]++;
        a[m]++;
    }
    rep1(i,5){
        if(a[i] >=3){cN;return 0;}
    }
    cY;
    return 0;
}

Measured memory_bytes: 256