akhauriyash/Code-Regression huggingface dataset:
//↓見なくていいよ！ここから--------------------------------------------------
var read = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});
var obj;
var inLine = [];
read.on('line', function(input){inLine.push(input);});
read.on('close', function(){
  obj = init(inLine);
  console.error("\n");
  var start = new Date();
  Main();
  var end = new Date() - start;
  
  myerr("time : " + (end) + "ms");
  myerr("memory : " + Math.round(process.memoryUsage().heapTotal / 1024) + "KB");
});
function makeClone(obj){return JSON.parse(JSON.stringify(obj));}
function nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}
function nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}
function next(){return obj.next();} function hasNext(){return obj.hasNext();}
function init(input){  
  var returnObj = {
    list : input, index : 0, max : input.length,
    hasNext : function(){return (this.index < this.max);},
    next : function(){if(!this.hasNext()){throw "ArrayIndexOutOfBoundsException これ以上ないよ";}else{var returnInput = this.list[this.index];this.index++;return returnInput;}}
  };
  return returnObj;
}
function myout(s){console.log(s);}
function myerr(s){console.error("debug:" + require("util").inspect(s,false,null));}
//[no]要素の扱い。数値型
//不明値、異常時:引数そのまま返す 1:数値へ変換
//2:半角SPで分割 4:半角SPで分割し、数値配列へ
//6:1文字で分割  7:1文字で分割し、数値配列へ
//8:半角SPで結合 9:改行で結合 0:文字なしで結合
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 4:return i.split(" ").map(Number);case 6:return i.split("");case 7:return i.split("").map(Number);case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}catch(e){return i;}}

//↑見なくていいよ！ここまで--------------------------------------------------
function Main(){
	var one = nextIntArray();
	var N = one[0];
	var A = one[1];
	var B = one[2];
	myout(Math.min(B, N * A));
}


Measured memory_bytes: 31036
//compiledef
#include <bits/stdc++.h>
#define rep(i, n) for(i=0;i<(n);i++)
#define per(i, n) for(i=(n);i>0;i--)
#define repx(i, n, x) for(i=(x);i<(n);i++)
#define xper(i, n, x) for(i=(n);i>(x);i--)
#define pback push_back

//c++def
using namespace std;
typedef long long int ll;
const ll MOD = 1e9+7;
const ll MOD2 = 998244353;

typedef struct Node *node;
struct Node{
	int key;
	node next;
	node prev;
};
node head;
node search(int key){
	node n = head->next;
	while(n != head && n->key != key) n = n->next;
	return n;
}
void print(){
	node n = head->next;
	while(22){
		if(n == head) break;
		if(n != head->next)printf(" ");
		printf("%d", n->key);
		n = n->next;
	}
	printf("\n");
}
void insert(int key){
	node n;
	n = (node)malloc(sizeof(struct Node));
	n->key = key;
	n->next = head->next;
	head->next->prev = n;
	head->next = n;
	n->prev = head;
}
void del(int x){
	node rst;
	rst = search(x);
	if(rst == head) return;
	rst->prev->next = rst->next;
	rst->next->prev = rst->prev;
	free(rst);
}
void del_p(node x){
	if(x == head) return;
	x->prev->next = x->next;
	x->next->prev = x->prev;
	free(x);
} 

int main(){
	int i;
	int n;
	string com;
	head = (node)malloc(sizeof(node));
	head->next = head;
	head->prev = head;
	int tmp;
	cin >> n;
	rep(i, n){
		cin >> com;
		if(com == "insert"){
			scanf("%d", &tmp);
			insert(tmp);
		}
		else if(com == "delete\0"){
			scanf("%d", &tmp);
			del(tmp);
		}
		else if(com == "deleteFirst"){
			del_p(head->next);
		}
		else if(com == "deleteLast"){
			del_p(head->prev);
		}
#ifdef DBG
		print();
#endif
	}
	print();
}



Measured memory_bytes: 34536
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll const N=1e3+500;
ll INF=0x3f3f3f3f;
int main()
{
    ll n,a[N],b,c;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
        if(a[i]%2==0)
        {
            if(a[i]%3!=0&&a[i]%5!=0)
            {
                cout<<"DENIED"<<endl;
                return 0;
            }
        }
    }
    cout<<"APPROVED"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
char s[100009],s2[100009];
int main()
{
	scanf("%s",s);
	int len=strlen(s);
	for (int i=0;i<len;i++)
	{
		if (s[i]=='b') s2[len-i-1]='d';
		else if (s[i]=='d') s2[len-i-1]='b';
		else if (s[i]=='q') s2[len-i-1]='p';
		else s2[len-i-1]='q';
	}
	if (strcmp(s,s2)==0) printf("Yes");
	else printf("No");
	return 0;
}

Measured memory_bytes: 384
a,b,k = input().split()
a = int(a)
b = int(b)
k = int(k)

if k >= a:
    k -= a
    a = 0
    if k >= b:
        b = 0
        print(str(a) + ' ' + str(b))
    else:
        b -= k
        print(str(a) + ' ' + str(b))
else:
    a -= k
    print(str(a) + ' ' + str(b))

Measured memory_bytes: 3064
//#pragma GCC optimize(2)
#include <bits/stdc++.h>
using namespace std;
//#define int long long
#define rep(i, beg, end) for (int i = (beg); i < (end); i++)
#define rrep(i, beg, end) for (int i = (beg); i >= (end); i--)
#define sp(i) setprecision(i) << fixed
#define ini(a, b) memset(a, b, sizeof(a))
typedef long long ll;
typedef pair<double, double> P;
typedef unsigned long long ull;
const int INF = 0x3f3f3f3f;
const int mod = 1e9 + 7;
const int N = 100010;
ull p_hash(ull x, ull y) { return (x + y) * (x + y + 1) / 2 + y; } //NxN->N
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }

struct E
{
    int a, b, c;
    bool operator<(const E &ot)
    {
        return c < ot.c;
    }
};
vector<E> es;

int id[N];

int root(int u)
{
    if (id[u] != u)
        id[u] = root(id[u]);

    return id[u];
}

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

    string s = "ACL";

    int k;
    cin >> k;
    for(int i = 0; i < k; i++)
    {
        cout << s;
    }

    cout << endl;

    return 0;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
int main(){
long long i;
long long counter=0;
long long A,B,C,X,Y;
cin>>A>>B>>C>>X>>Y;
if(A>=2*C&&B>=2*C){
long long i=2*C*max(X,Y);
cout<<i<<endl;
}
else if(A+B<2*C){
i=A*X+B*Y;
cout<<i<<endl;
}
else{
while(X>0&&Y>0){
X=X-1;
Y=Y-1;
counter=counter+2;}
if(2*C<=A&&X>0){
cout<<C*(counter+2*X)<<endl;}
if(2*C<=B&&Y>0){
cout<<C*(counter+2*Y)<<endl;}
else
cout<<C*counter+X*A+Y*B<<endl;}}





Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
using namespace std;
int main() {
	int a, d = 0, e = 0, f = 101;
	char b, c;
	cin >> a;
	int test[101];
	int aiueo[101];
	for (int h = 1; h <= a; h++) {
		cin >> b;
		test[h] = b;
	}
	for (int j = 1; j <= a; j++) {
		cin >> c;
		aiueo[j] = c;
	}
	for (int i = 1; i <= a; i++) {
		for (int k = 0; k < i; k++) {
			if (test[a - k] == aiueo[i - k]) {
				e++;
			}
		}
		if (e == i) {
			d = a * 2 - i;
		}
		e = 0;
	}
	if (d == 0) {
		cout << a * 2 << endl;
	}
	else {
		cout << d << "\n";
	}
	cin >> e;
}

Measured memory_bytes: 256
// #include <boost/multiprecision/cpp_int.hpp>
// using boost::multiprecision::cpp_int;
#include <bits/stdc++.h>
using namespace std;
// ¯\_(ツ)_/¯
#define f first
#define s second
#define p push
#define mp make_pair
#define pb push_back
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define debug(x) cout << '>' << #x << ':' << x << endl;
#define all(v) v.begin(), v.end()
#define sz(x) ((int)(x).size())
#define endl " \n"
#define newl cout<<"\n"
#define MAXN 100005
#define MOD 1000000007LL
#define EPS 1e-13
#define INFI 1000000000             // 10^9
#define INFLL 1000000000000000000ll //10^18
// ¯\_(ツ)_/¯
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define vll vector<long long>
#define vvll vector<vll>
//vector<vector<int>> v(10, vector<int>(20,500)); 2d vector initialization. of 10 rows and 20 columns, with value 500.
#define pll pair<long long, long long>

#define fast_io()                   \
  ios_base::sync_with_stdio(false); \
  cin.tie(NULL);                    \
  cout.tie(NULL);

ll tc, n, m, k;

int main()
{
    fast_io();
#ifndef ONLINE_JUDGE
    //freopen("../input.txt", "r", stdin);
    //freopen("../output.txt", "w", stdout);
#endif

    cin>>n;
    vll arr(n, 0);
    rep(i, 0, n) cin>>arr[i];
    vvll dp(n, vll(n, 0));

    // dp[0][n-1]
    rep(L, n, 0) {
        rep(R, L, n) {
            if(L == R) dp[L][R] = arr[L];
            else
                dp[L][R] = max(arr[L]-dp[L+1][R], arr[R] - dp[L][R-1]);
        }
    }

    cout<<(dp[0][n-1]);

    return 0;
}

/*
2
4
0 1 0 1
5
0 0 1 0 0
*/

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

signed main(){
    ios::sync_with_stdio(false); cin.tie(NULL);

    string s, t;
    cin >> s >> t;

    int n = s.size();
    int m = t.size();

    int table[n+1][m+1];

    for (int i = 0; i <= n; i++)
        for (int j = 0; j <= m; j++)
            table[i][j] = 0;

    for (int i = 1; i <= n; ++i) {
        for (int j = 1; j <= m; ++j) {
            table[i][j] = max(table[i-1][j], table[i][j-1]);

            if (s[i-1] == t[j-1])
                table[i][j] = max(table[i][j], table[i-1][j-1] + 1);
        }
    }

    // for (int i = 0; i <= n; i++) {
    //     for (int j = 0; j <= m; j++)
    //         cout << table[i][j] << " ";
    //
    //     cout << endl;
    // }

    string r;

    for (int i = n, j = m; i > 0 && j > 0;) {
        if (s[i-1] == t[j-1]) {
            r += s[i-1];
            --i, --j;
        } else if (table[i-1][j] == table[i][j]) {
            --i;
        } else if (table[i][j-1] == table[i][j]) {
            --j;
        }
    }

    reverse(r.begin(), r.end());

    cout << r << '\n';
}


Measured memory_bytes: 38772
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<limits>
#include<sstream> 
#include<unordered_map>      

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
typedef vector<int> vi;
typedef vector<ll> vl;

const int inf = numeric_limits<int>::max() >> 2;
const ll linf = numeric_limits<ll>::max() >> 2;
const ull ulinf = numeric_limits<ull>::max() >> 2;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int dx8[8]={-1,0,1,-1,1,-1,0,1};
const int dy8[8]={-1,-1,-1,0,0,1,1,1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define umap(i,j) unordered_map<i,j>
#define P(p) cout<<(p)<<endl
#define PS(p) cout<<(p)<< " "
#define IN cin >> 
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i = (m-1); i >= (int)(n); i--)
#define inrep(n,a) for(int i = 0; i < (int)(n); i++)cin >> a[i];
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end())
#define rvsort(v) sort(v.begin(), v.end(), greater<c>()) 
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - a) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define ub(a,n,k) (upper_bound(a,a+n,k) - a) 
#define vub(a,k)  (upper_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

vector<string> split(const string &str, char sep){
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}

//ll ncr[100][100];
//ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

//ll npr[100][100]={};
//ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

//ll nHr(int n,int r){ret nCr(n+r-1,r);}

///////////////////////////////////////////////////////////////////////////


int main(){
    int n,m,q;
    cin >> n >> m >> q;
    int d[n+1][n+1] = {};
    int w[n+1][n+1] = {};
    
    rep(i,0,m){
	int l,r;
	cin >> l >> r;
	d[l][r]++;
    }
    rep(i,1,n+1){
	rep(j,1,n+1)w[i][j] = w[i][j-1] + d[i][j];
    }

    rep(i,0,q){
	int p,q;
	cin >> p >> q;
	ll ans = 0;
	rep(i,p,q+1){
	    ans += w[i][q] - w[i][p-1];
	}
	P(ans);
    }
    
    return  0;
}



Measured memory_bytes: 2944
s = input().split()
l = []
for i in range(len(s)):
    p = ""
    if s[i].isdecimal() == False:
        x = l.pop()
        y = l.pop()
        p += y + s[i] + x
        l.append(str(eval(p)))
    else:
        l.append(s[i])
print(l[0])



Measured memory_bytes: 5572
#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<algorithm>
#include<map>
#include<cstdlib>
#include<cmath>
#include<numeric>
#include<iomanip>
#include<functional>
#include<cstdlib>
#include<queue>
#include<deque>
const double PI = acos(-1);
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
using ll =long long;
const int mod = 1000000007;

//map<string>a
class mint {
	long long x;
public:
	mint(long long x = 0) : x((x% mod + mod) % mod) {}
	mint operator-() const {
		return mint(-x);
	}
	mint& operator+=(const mint & a) {
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint & operator-=(const mint & a) {
		if ((x += mod - a.x) >= mod) x -= mod;
		return *this;
	}
	mint & operator*=(const  mint & a) {
		(x *= a.x) %= mod;
		return *this;
	}
	mint operator+(const mint & a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint & a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint & a) const {
		mint res(*this);
		return res *= a;
	}
	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}
	// for prime mod
	mint inv() const {
		return pow(mod - 2);
	}
	mint& operator/=(const mint & a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint & a) const {
		mint res(*this);
		return res /= a;
	}

	friend ostream& operator<<(ostream & os, const mint & m) {
		os << m.x;
		return os;
	}
};
int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}
//組み合わせ
void recursive_comb(vector<int> indexes, int s, int rest, std::function<void(vector<int>)> f) {
	if (rest == 0) {
		f(indexes);
	}
	else {
		if (s < 0) return;
		recursive_comb(indexes, s - 1, rest, f);
		indexes[rest - 1] = s;
		recursive_comb(indexes, s - 1, rest - 1, f);
	}
}

// nCkの組み合わせに対して処理を実行する
void foreach_comb(int n, int k, std::function<void(vector<int>)> f) {
	vector<int>indexes(k);
	recursive_comb(indexes, n - 1, k, f);
}

ll gcd(ll a, ll b) {
	if (a % b == 0) {
		return b;
	}
	else {
		return gcd(b, a % b);
	}
}
ll lcm(ll a, ll b) {
	return a * b / gcd(a, b);
};
//fixed << setprecision(2)
ll number(char c, int i) {
	ll tmp = (ll)c;
	tmp = tmp - 48;
	tmp *= pow(10, i);
	return tmp;
}
int main() {
	string s;
	cin >> s;
	int n = s.size()-1;
	ll ans=0;
	int head;
	for (int bit = 0; bit < (1 << n); ++bit) {
		vector<int> S;
		for (int i = 0; i < n; ++i) {
			if (bit & (1 << i)) { // 列挙に i が含まれるか
				S.push_back(i);
			}
		}
		head = 0;
		for (int i = 0; i < (int)S.size(); ++i) {
			for (int j = head; j <= S[i];j++) {

				ans += number(s[j],S[i]-j);

			}
			head = S[i]+1;

		}
		for (int j = head; j <s.size(); j++) {
			ans += number(s[j], s.size()-1-j);
		}
		
	}
	cout << ans;
}
	


Measured memory_bytes: 4048
#include <bits/stdc++.h>
#define eb emplace_back
#define mp make_pair
using namespace std;
typedef long long LL;

const int N = 1e5 + 5;
char s[N];
int n, k;

int main() {
#ifdef ANONYM
  freopen("in", "r", stdin);
  freopen("out", "w", stdout);
#endif

  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> k >> s + 1;
  int l = strlen(s + 1);
  int ans = 0, cnt = 0;
  for (int i = 1; i <= n; i++) {
    int cur = i;
    while (s[cur+1] == s[cur]) {
      cur++;
    }
    cnt++;
    ans += cur - i;
    i = cur;
  }
  if (k >= cnt / 2) {
    if (cnt % 2 == 0) ans += (cnt - 1) / 2 * 2 + 1;
    else ans += cnt / 2 * 2;
  } else {
    ans += k * 2;
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999
#define m0(x) memset(x,0,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define p(x) cout<<x<<endl;
#define pe(x) cout<<x<<" ";
//#define int long long


using namespace std;


int dy[4] = { 0,0,1,-1 };
int dx[4] = { 1,-1,0,0 };
int dxx[8] = { 0,0,1,1,1,-1,-1,-1 };
int dyy[8] = { 1,-1,0,1,-1,0,1,-1 };




ll gcd(ll x, ll y) {
	ll m = max(x, y), n = min(x, y);
	if (m%n == 0)return n;
	else return gcd(m%n, n);
}
ll lcm(ll x, ll y) {
	return x / gcd(x, y)*y;
}

ll myPow(ll x, ll n, ll m) {
	if (n == 0)
		return 1;
	if (n % 2 == 0)
		return myPow(x * x % m, n / 2, m);
	else
		return x * myPow(x, n - 1, m) % m;
}

ll pow2(ll a, ll n) {//aのn乗を計算します。
	ll x = 1;
	while (n > 0) {//全てのbitが捨てられるまで。
		if (n & 1) {//1番右のbitが1のとき。
			x = x * a;
		}
		a = a * a;
		n >>= 1;//bit全体を右に1つシフトして一番右を捨てる。
	}
	return x;
}

long long nCr(int n, int r) {
	if (r > n / 2) r = n - r; // because C(n, r) == C(n, n - r)
	long long ans = 1;
	int i;

	for (i = 1; i <= r; i++) {
		ans *= n - r + i;
		ans /= i;
	}

	return ans;
}


const int MOD = 1000000007;

bool arr[1050000];
int sosuu[100010];
void Eratosthenes() {
	ll N = 1050000;
	int c = 0;
	for (int i = 0; i < N; i++) {
		arr[i] = 1;
	}
	for (int i = 2; i < sqrt(N); i++) {
		if (arr[i]) {
			for (int j = 0; i * (j + 2) < N; j++) {
				arr[i *(j + 2)] = 0;
			}
		}
	}

	for (int i = 2; i < N; i++) {
		if (arr[i]) {
			sosuu[c] = i;
			//cout << sosuu[c] << " ";
			c++;
		}
	}
	//cout << endl;
	//cout << c << endl;
}


vector<int> graph[100010];
int color[100010];
bool visited[100010][10];
int v[100010], d[100010], c[100010];

void func(int d, int v, int c) {
	if (d == 0) {
		if(!visited[v][0])color[v] = c;
		visited[v][0] = true;
	}
	else {
		if (!visited[v][d - 1]) {
			func(d - 1, v, c);
			for(int i=0;i<=d-1;i++)visited[v][i] = true;
		}
		for (auto x : graph[v]) {
			if (!visited[x][d - 1]) {
				func(d - 1, x, c);
				for (int i = 0; i <= d - 1; i++)visited[x][i] = true;
			}
		}
	}
}
int main() {
	m0(visited);
	int N, M; cin >> N >> M;
	REP(i, M) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		graph[a].pb(b);
		graph[b].pb(a);
	}
	int Q; cin >> Q;
	REP(i, Q) {
		cin >> v[i] >> d[i] >> c[i];
		v[i]--;
	}
	REPR(i, Q-1) {
		func(d[i], v[i], c[i]);
	}
	REP(i, N) {
		p(color[i]);
	}
}

Measured memory_bytes: 10232
#include <iostream>

using namespace std;

#define maxN 102
#define maxK 100010

int as[maxN];
bool cache[maxK];
bool cached[maxK];
int n, K;

bool wins(int k) {
    if (k < 0) return true;
    if (k == 0) return false;
    if (cached[k]) return cache[k];
    cached[k] = true;
    bool canWin = false;
    for (int i = 0; i < n; i++) {
        int a = as[i];
        if (!wins(k - a)) {
            canWin = true;
            break;
        }
    }
    cache[k] = canWin;
    return canWin;
}

int main() {
    cin >> n >> K;
    for (int i = 0; i < n; i++) {
        cin >> as[i];
    }
    for (int i = 0; i <= K; i++) cache[i] = -1;
    cout << (wins(K) ? "First" : "Second") << endl;
    return 0;
}

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

int n,m,k,ans=1;
string s,t;

int main() {
  cin >> n >> k;
  while(n/=k) ans++;
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include<cmath>

using namespace std;

int main() {
    int N; cin >> N;
    int t, a; cin >> t >> a;
    long long int nt = t, na = a;
    for (int i = 1; i < N; i++) {
        int t, a; cin >> t >> a;
        //long long int p = max((nt + t - 1)/ t, (na + a - 1)/ a);
        long long int p = max(ceil((long double)nt/t), ceil((long double)na/a));
        nt = t * p;
        na = a * p;
    }
    cout << nt+na << endl;
    return 0;
}


Measured memory_bytes: 384
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int D = sc.nextInt();
    StringBuilder sb = new StringBuilder();
    sb.append("Christmas");
    for(int i = 0; i < 25 - D; i++){
      sb.append(" Eve");
    }
    System.out.println(sb.toString());
  }
}

Measured memory_bytes: 21844
def green_bin(s, N):
    anagram_num = 0
    sorted_s_sub = []
    sorted_s = []
        
    for i in range(N):
        sorted_si = sorted(s[i])
        sorted_s_sub.append(''.join(sorted_si))

    sorted_s = sorted(sorted_s_sub)

    i = 0
    item_count = []
    while i < N:
        item = sorted_s[i]
        j = i + 1
        count = 1
        while j < N:
            if item == sorted_s[j]:
                count += 1
                j += 1
            else:
                break
        item_count.append(count)
        i += count  # count だけ進める
    
    for count in item_count:
        
        anagram_num += int(count * (count - 1) / 2)

    return anagram_num


if __name__ == '__main__':
    N = int(input())
    s = []
    for n in range(N):
        sn = input()
        s.append(sn)
    print(green_bin(s, N))


Measured memory_bytes: 19152
#include <bits/stdc++.h>
using namespace std;
int main() {
    int N, K; cin >> N >> K;
    vector<bool> unlike(10, false);
    for(int i = 0; i < K; i++) {
        int a; cin >> a;
        unlike[a] = true;
    }
    int i = 0;
    while (true)
    {
        int m = N + i;
        int d = m;
        bool ok = true;
        while (d)
        {
            if(unlike[d % 10] == true) {
                ok = false;
                break;
            }
            d /= 10;
        }
        if(ok) {
            cout << m << endl;
            return 0;
        }
        i++;
    }

    return 0;
}

Measured memory_bytes: 256
n=int(input())
S=list(input())
dp=[[0]*(8) for i in range(n+1)]
dp[0][0]=1
for i in range(1,n+1):
  if S[i-1]=="R":
    for j in range(8):
      dp[i][j]=dp[i-1][j]
    dp[i][1]+=dp[i-1][0]
    dp[i][4]+=dp[i-1][2]
    dp[i][6]+=dp[i-1][3]
    dp[i][7]+=dp[i-1][5]
  elif S[i-1]=="G":
    for j in range(8):
      dp[i][j]=dp[i-1][j]
    dp[i][2]+=dp[i-1][0]
    dp[i][4]+=dp[i-1][1]
    dp[i][5]+=dp[i-1][3]
    dp[i][7]+=dp[i-1][6]
  else:
    for j in range(8):
      dp[i][j]=dp[i-1][j]
    dp[i][3]+=dp[i-1][0]
    dp[i][5]+=dp[i-1][2]
    dp[i][6]+=dp[i-1][1]
    dp[i][7]+=dp[i-1][4]
a=0
for i in range(n-2):
  for j in range(i+1,n-1):
    k=j*2-i
    if k>=n:
      continue
    if S[i]!=S[j] and S[j]!=S[k] and S[k]!=S[i]:
      a=a+1
print(dp[n][7]-a)

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

long long int ar[100005];
int n;
long long int dp[100005];

long long int solve(int x){
    if(x >= n-1)
        return 0;
    if(dp[x] != -1)
        return dp[x];
    dp[x] = min( (abs(ar[x+1]-ar[x]) + solve(x+1)) , (abs(ar[x+2]-ar[x]) + solve(x+2)));
    return dp[x];
}

int main(){
    cin >> n;
    for(int i=0;i<n;i++)
        dp[i] = -1;
    for(int i=n;i<100005;i++)
        dp[i] = INT_MAX;
    for(int i=0;i<n;i++)
        cin >> ar[i];
    ar[n] = INT_MAX;
    cout << solve(0) << endl;
}


Measured memory_bytes: 4096
#include <bits/stdc++.h>
using namespace std;
template <class T> inline void read(T &x) {
	x = 0; int c = getchar(), f = 1;
	for (; !isdigit(c); c = getchar()) if (c == 45) f = -1;
	for (; isdigit(c); c = getchar()) (x *= 10) += f*(c-'0');
}
int n, m, a[100005]; bool f[100005];
int main() {
	read(n), read(m);
	for (int i = 1; i <= n; i++) read(a[i]);
	for (int i = 1; i <= m; i++)
		for (int j = 1; j <= n; j++)
			if (i >= a[j]) f[i] |= !f[i-a[j]];
	return puts(f[m] ? "First" : "Second"), 0;
}


Measured memory_bytes: 384
import sys
import math as mas

x=[0]*60
for i in range(10):
	for j in range(10):
		for k in range(10):
			for l in range(10):
				x[i+j+k+l]+=1
for i in sys.stdin:
	print(x[int(i)])

#	a,b=map(int,i.split())
#	print(gcd(a,b),lcm(a,b))

Measured memory_bytes: 7640
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<set>
#include<queue>
#define _USE_MATH_DEFINES
#include<math.h>
#include<cmath>
#include<ctime>
#include<map>
#define R(i, n) for(int i = 0;i < n; i++)
#define S(a) scanf("%d", &a)
#define S2(a, b) scanf("%d%d", &a, &b)
#define S3(a, b, c) scanf("%d%d%d", &a, &b, &c)
#define SL(a) scanf("%lld", &a)
#define SL2(a, b) scanf("%lld%lld", &a, &b)
#define SL3(a, b, c) scanf("%lld%lld%lld", &a, &b, &c)
#define SA(i, n, a) R(i, n) scanf("%d", a + i)
#define SAL(i, n, a) R(i, n) scanf("%lld", a + i)
#define SC(a) scanf("%c", &a);
#define P(a) printf("%d", a)
#define PL(a) printf("%lld", a)
using namespace std;
using ll = long long;
using PR = pair<int, int>;
const ll MOD = 1e+9 + 7;
const int INF = 1e+9;

int N;
string s, t;

int main() {
	S(N);
	cin >> s >> t;
	int ans = 2 * N;
	for (int i = 1; i <= N; i++) {
		if (s.substr(N - i, i) == t.substr(0, i)) {
			ans = 2 * N - i;
		}
	}
	P(ans);
}

Measured memory_bytes: 256
lines = []
while line = gets
    lines << line.chomp.split(' ').map(&:to_i)
end

N = lines[0][0]

min = 100000000000000000000
answer = 0
for i in 1..N do
  if lines[1][i-1] <= min then
    answer += 1
    min = lines[1][i-1]
  end
end
  
print answer

Measured memory_bytes: 16516
#include <cstdio>
#include <cstring>

#define maxn 200010
#define cmin(_a, _b) (_a > (_b) ? _a = (_b) : 0)
int a[maxn];
int f0[maxn], f1[maxn], g0[maxn], g1[maxn];
int main()
{
	int n; scanf("%d", &n);
	for (int i = 1; i <= n; ++i) scanf("%d", a + i);
	memset(f0, 63, sizeof (f0));
	memset(f1, 63, sizeof (f1));
	memset(g0, 63, sizeof (g0));
	memset(g1, 63, sizeof (g1));
	f0[0] = f1[0] = g0[n] = g1[n] = 0;
	int sum = 0;
	for (int i = 1; i <= n; ++i)
	{
		sum += a[i]; cmin(sum, n + 1);
		if (a[i] % 2 == 0)
		{
			f0[i] = f0[i - 1] + (!a[i] ? 2 : 0);
			cmin(f0[i], sum);
			f1[i] = f1[i - 1] + 1;
		}
		else
		{
			f0[i] = f0[i - 1] + 1;
			f1[i] = f1[i - 1];
		}
		cmin(f1[i], f0[i]);
	}
	sum = 0;
	for (int i = n; i; --i)
	{
		sum += a[i]; cmin(sum, n + 1);
		if (a[i] % 2 == 0)
		{
			g0[i - 1] = g0[i] + (!a[i] ? 2 : 0);
			cmin(g0[i - 1], sum);
			g1[i - 1] = g1[i] + 1;
		}
		else
		{
			g0[i - 1] = g0[i] + 1;
			g1[i - 1] = g1[i];
		}
		cmin(g1[i], g0[i]);
	}
	int ans = 0x7fffffff;
	for (int i = 0; i <= n; ++i)
	{
		cmin(ans, f0[i] + g1[i]),
		cmin(ans, f1[i] + g0[i]),
		cmin(ans, f0[i] + g0[i]);
		// printf("i = %d %d %d %d %d\n", i, f0[i], f1[i], g0[i], g1[i]);
	}
	printf("%d\n", ans );
	return 0;
}

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

int main()
{
    int n, max = -1000000;
    cin >> n;
    int v[n], c[n];
    for (auto i = 0; i < n; i++)
    {
        /* code */
        cin >> v[i];
    }

    for (auto i = 0; i < n; i++)
    {
        /* code */
        cin >> c[i];
    }

    for (auto i = 0; i < 1 << n; i++)
    {
        /* code */
        int X = 0, Y = 0;
        for (auto j = 0; j < n; j++)
        {
            if ((1 & i >> j) == 1)
            {
                X += v[j];
                Y += c[j];
            }
        }
        int ans = X - Y;
        if (max < ans)
        {
            max = ans;
        }
    }
    cout << max << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <unordered_map>
#include <vector>

#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>


namespace std {
  template<class T>
  using tree = __gnu_pbds::tree<T,
                                __gnu_pbds::null_type,
                                less<T>,
                                __gnu_pbds::rb_tree_tag,
                                __gnu_pbds::tree_order_statistics_node_update>;
};


#define INF 4000000000000000000LL
#define MOD 1000000007
#define ALL(x) std::begin(x), std::end(x)


int main(int argc, char** argv)
{
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(0);

  std::cout << std::fixed << std::setprecision(6);
  std::cerr << std::fixed << std::setprecision(6);

  int N, a[222222];

  long long K, acc[222222], x = 0, C = 0;

  std::cin >> N >> K;

  acc[0] = 0;

  std::tree<std::pair<long long, int>> tree;
  
  for (int i = 0; i < N; i ++) {
    std::cin >> a[i];
    
    tree.insert(std::make_pair(acc[i + 1] = a[i] + acc[i] - K, i));
  }

  for (int i = 0; i < N; i ++) {
    int nth = tree.order_of_key(std::make_pair(x, 0));

    C += N - i - nth;
    
    tree.erase(std::make_pair(acc[i + 1], i));

    x += a[i] - K;
  }

  std::cout << C << std::endl;

  return 0;
}


Measured memory_bytes: 15360
#include <algorithm>
#include <array>
#include <iostream>
#include <numeric>
#include <string>
#include <vector>

int main() {
  using namespace std;

  int n;
  long long sum = 0;
  cin >> n;

  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      for (int k = 1; k <= n; k++) {
        sum += std::gcd(std::gcd(i, j), k);
      }
    }
  }
  cout << sum << endl;
}

Measured memory_bytes: 3632
#include<stdio.h>
#include<stdlib.h>
int asc(const void* a, const void* b)
{
	if (*(long long int*)a > * (long long int*)b)return 1;
	if (*(long long int*)a < *(long long int*)b)return -1;
	return 0;
}
int main()
{
	int n;
	scanf("%d", &n);
	int i;
	long long int a[100005];
	for (i = 0; i < n; i++)
		scanf("%lld", &a[i]);
	qsort(a, n, sizeof(long long int), asc);
	long long int ans;
	if (n % 2 == 0)
	{
		ans = 0;
		for (i = 0; i < n / 2; i++)
			ans -= 2 * a[i];
		ans += a[n / 2 - 1];
		for (i = n / 2; i < n; i++)
			ans += 2 * a[i];
		ans -= a[n / 2];
	}
	else
	{
		long long int b, c;
		b = c = 0;
		for (i = 0; i <= n / 2; i++)
			b -= 2 * a[i];
		b += a[n / 2] + a[n / 2 - 1];
		for (i = n / 2 + 1; i < n; i++)
			b += 2 * a[i];
		for (i = 0; i < n / 2; i++)
			c -= 2 * a[i];
		for (i = n / 2; i < n; i++)
			c += 2 * a[i];
		c -= a[n / 2] + a[n / 2 + 1];
		if (b < c)
			ans = c;
		else
			ans = b;
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define INF 1000000000
#define pi 3.14159265358979323846264338327950L
#define FOR(i,a,b) for(int i=a;i<=b;i++)
int main()
{
    //freopen("contest.txt","r",stdin);
    //freopen("contest.txt","w",stdout);
    IOS
    int a;
    int k,b;
    cin>>k>>a>>b;
    FOR(i,a,b)
    {
        if(i%k==0)
        {
            cout<<"OK"<<endl;
            return 0;
        }

    }

    cout<<"NG"<<endl;



    return 0;
}


Measured memory_bytes: 3576
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] arr = new int[n + 1];
		for (int i = 1; i <= n; i++) {
			arr[i] = sc.nextInt();
		}
		Arrays.sort(arr);
		for (int i = 1; i <= n; i += 2) {
			arr[i] = 24 - arr[i];
		}
		Arrays.sort(arr);
		int min = 24;
		for (int i = 1; i < n + 1; i++) {
			int d = arr[i] - arr[i - 1];
			if (min > d) {
				min = d;
			}
		}
		if (min > 24 - arr[n]) {
			min = 24 - arr[n];
		}
		System.out.println(min);
	}
}


Measured memory_bytes: 25172
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
const double PI  = 3.1415926535897932384626433832795028841971;
const int    INF = 100000000;
const double EPS = 1e-10;
const int    MOD = 1000000007;
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int n;
int x[4];

int main(){
	string str;
	cin >> str;
	rep(i,str.size()){
		if(str[i]=='N')x[0]++;
		if(str[i]=='W')x[1]++;
		if(str[i]=='S')x[2]++;
		if(str[i]=='E')x[3]++;
	}
		if((x[0] > 0 && x[2] == 0)||
			(x[2] > 0 && x[0] == 0) ||
			(x[1] > 0 && x[3] == 0) ||
			(x[1] == 0 && x[3] > 0)){
				cout << "No" << endl;
		}
		else cout << "Yes" << endl;

}

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

int main() {

	int num,a[4];

	cin >> num;
	
	a[0] = num / 1000;
	a[1] = num % 1000 / 100;
	a[2] = num % 100 / 10;
	a[3] = num % 10;

	if (a[1] == a[2] && a[2] == a[3] || a[0] == a[1] && a[1] == a[2]) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}


	return 0;
}

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

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

  queue<string> q;
  q.push("a");

  while (q.size() != 0) {
    string s = q.front();
    if (s.size() == n)
      cout << s << endl;
    else {
      int x = 'a';
      for (int i = 0; i < s.size(); i++) x = max(x, (int)s[i]);
      for (int i = 'a'; i <= x + 1; i++) q.push(s + (char)i);
    }
    q.pop();
  }
}

Measured memory_bytes: 9728
#include <bits/stdc++.h>
using i64 = long long;

int main() {
    i64 n, m, v, p;
    std::cin >> n >> m >> v >> p;
    std::vector<i64> a(n);
    for (auto &e : a) std::cin >> e;
    std::sort(a.begin(), a.end());

    int l = -1, r = n - p;
    while (r - l > 1) {
        int k = (l + r) / 2;
        auto b(a);
        b[k] += m;
        i64 rem = (v - 1) * m, t = b[k];
        for (int i = 0; rem && i < n; i++) {
            if (i == k) continue;
            i64 d = std::min({ rem, m, std::max(0ll, t - a[i])});
            b[i] += d;
            rem -= d;
        }
        for (int i = n - 1; rem && i >= 0; i--) {
            i64 d = std::min({ m, rem, a[i] + m - b[i] });
            b[i] += d;
            rem -= d;
        }
        std::sort(b.begin(), b.end());
        if (b[n - p] <= t) r = k;
        else l = k;
    }

    std::cout << n - r << std::endl;

    return 0;
}


Measured memory_bytes: 1792
#include <cstdio>
#include <queue>
#include <algorithm>
using namespace std;

class player {
public:
    int id;
    double time;
    player(int _id, double _time) { id = _id; time = _time; }
};

int main()
{
    int id; double time;
    auto comp = [](const player &a, const player &b) {
        return a.time > b.time;
    };
    priority_queue<player, vector<player>, decltype (comp)> pq1(comp), pq2(comp), pq3(comp), b3(comp);
    for (int i = 0; i < 8; i++) { scanf("%d %lf", &id, &time); pq1.push(player(id, time)); }
    for (int i = 0; i < 8; i++) { scanf("%d %lf", &id, &time); pq2.push(player(id, time)); }
    for (int i = 0; i < 8; i++) { scanf("%d %lf", &id, &time); pq3.push(player(id, time)); }
    for (int i = 0; i < 2; i++) { printf("%d %.2lf\n", pq1.top().id, pq1.top().time); pq1.pop(); }
    b3.push(pq1.top());
    for (int i = 0; i < 2; i++) { printf("%d %.2lf\n", pq2.top().id, pq2.top().time); pq2.pop(); }
    b3.push(pq2.top());
    for (int i = 0; i < 2; i++) { printf("%d %.2lf\n", pq3.top().id, pq3.top().time); pq3.pop(); }
    b3.push(pq3.top());
    for (int i = 0; i < 2; i++) { printf("%d %.2lf\n", b3.top().id, b3.top().time); b3.pop(); }
    return 0;
}



Measured memory_bytes: 2684
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stdlib.h>
#include <cmath>
#include <numeric>
#include <functional>
#include <stack>
#include <iomanip>
#include <map>
#include <cstdio>

int main() {
	std::string s;

	std::cin >> s;

	if (s[0] == s[1] && s[1] == s[2]) {
		std::cout << "No" << std::endl;
	}
	else {
		std::cout << "Yes" << std::endl;
	}

	return 0;
}


Measured memory_bytes: 256
import sys
import copy
input = lambda: sys.stdin.readline().rstrip()
inpl = lambda: list(map(int,input().split()))
N, M = inpl()
uv = [ set() for _ in range(N)]
vu = [ set() for _ in range(N)]
for _ in range(M):
    A, B = inpl()
    uv[A-1].add(B-1)
    vu[B-1].add(A-1)

EMPTY, LOOP, TREE = 0, 1, 2
ENTER, EXIT = 0, 1
status = [EMPTY] * N
for s in range(N):
    states_pool = [(s,[],ENTER)]
    while states_pool:
        u, chain, flag = states_pool.pop()
        if flag == EXIT or status[u] == TREE:
            status[u] = TREE
            continue
        elif status[u] == LOOP:
            break
        else: # ENTER, EMPTY
            status[u] = LOOP
            states_pool.append((u,chain,EXIT))
            new_chain = copy.copy(chain)
            new_chain.append(u)
            for c in uv[u]:
                states_pool.append((c, new_chain, ENTER))
    else:
        continue
    break
else:
    print(-1)
    exit()

n = 0
while chain[n] != u:
    n += 1
chain = chain[n:]
L = len(chain)
nextnode = [None]*N
for i in range(L-1):
    nextnode[chain[i]] = chain[i+1]
nextnode[chain[L-1]] = chain[0]
pos = [None]*N
for p in range(len(chain)):
    pos[chain[p]] = p
i = 0
while i < L:
    h = 1
    c = chain[(i+1)%L]
    for j in uv[chain[i % L]]:
        p = pos[j]
        if p is None:
            continue
        else:
            if (p-i)%L > h:
                h = (p-i)%L
                c = j
    nextnode[chain[i % L]] = c
    i += 1
    while chain[i % L] != c:
        pos[chain[i % L]] = None
        i += 1

loop = [c]
k = c
while nextnode[k] != c:
    k = nextnode[k]
    loop.append(k)
print(len(loop))
for l in loop:
    print(l+1)

Measured memory_bytes: 44656
a = []
b = []
i = 0
while i < 3000:
    c,d = map(int, input().split())
    if c == 0 and d == 0:
        break
    elif c < d:
        a.append(c)
        b.append(d)
    else:
        a.append(d)
        b.append(c)
for j in range(len(a)):
    print(a[j],b[j])


Measured memory_bytes: 6128
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define inf 2147483647 //int値の最大値
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define cint(n) int n;cin>>n;
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;
}
int gcd(int a, int b) {
    if (b==0) return a;
    else return gcd(b, a%b);
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
int main() {
    ll s;cin>>s;
    int ans=inf;
    int rec=0;
    while(s>=100){
        rec=s%1000;
        ans=min(ans,abs(753-rec));
        s/=10;
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = (int)(n - 1); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) int(x.size())
#define get_unique(x) x.erase(unique(all(x)), x.end());
typedef long long ll;
typedef complex<double> Complex;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll LINF = 1e18;
template <class T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T& a, const T& b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> v) {
    for (int i = 0; i < sz(v); i++) {
        os << v[i];
        if (i < sz(v) - 1) os << " ";
    }
    return os;
}
int main() {
    int n, k;
    cin >> n >> k;
    vector<bool> v(n);
    rep(i, k) {
        int d;
        cin >> d;
        rep(j, d) {
            int a;
            cin >> a;
            v[--a] = 1;
        }
    }
    int ans = 0;
    rep(i, n) ans += v[i] == 0;
    cout << ans << endl;
}

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

int main(){
  int N=0, K=0, x=0, sum=0;
  cin >> N >> K;
  
  for(int i=0; i<N; i++){
    cin >> x;
    if(x < (K - x))
      sum += 2*x;
    else
      sum += 2*(K - x);
  }
  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 256
using System;
    using System.Text;
    using System.Collections.Generic;
    using static System.Math;
    using System.Linq;
    using static System.Array;
    
    namespace ConsoleApp2
    {
    class Program
    {
        static long H;
        static long W;
        static String[] map;
        static void Main(string[] args)
        {

            //var NK = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            var X = long.Parse(Console.ReadLine());

            var ans = 1L;
            for (int i = 2; i <= 100; i++)
            {
                for (int j = 2;; j++)
                {
                    var tmp = (long)Pow(i, j);
                    if (X >= tmp)
                    {
                        ans = Max(ans, tmp);
                    }
                    else
                    {
                        break;
                    }
                        
                }
            }

            Console.WriteLine(ans);
            
        }
    }

}


Measured memory_bytes: 11092
N,M=map(int,input().split())
L=sorted([list(map(int,input().split())) for _ in range(N)])
i=0
n=0
m=0
while n<M:
  n+=L[i][1]
  m+=L[i][0]*L[i][1]
  i+=1
print(m+(M-n)*L[i-1][0])

Measured memory_bytes: 28656
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define tii tuple<int,int,int>
signed main(){
  int N; cin>>N;
  vi P(N),Q(N),R(N);
  rep(i,0,N){
    cin>>P[i];
    R[i]=i+1;
  }
  rep(i,0,N) cin>>Q[i];
  int p,q;
  int count=0;
  do{
    count++;
    int i=0;
    bool F=1,G=1;
    for(int X:R){
      if(X!=P[i])
        F=0;
      if(X!=Q[i])
        G=0;
      if(!F&&!G)
        break;
      i++;
    }
    if(F)
      p=count;
    if(G)
      q=count;
  }while(next_permutation(ALL(R)));
  cout<<abs(p-q)<<endl;
  }




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

int main()
{
    std::string str;
    std::getline(std::cin, str);

    std::istringstream s_str(str);
    std::vector<std::string> vec(3);
    s_str >> vec[0] >> vec[1] >> vec[2];

    for (auto itr = vec.begin(); itr != vec.end(); itr++)
        std::cout << (*itr)[0];
    std::cout << '\n';
}


Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int N,ans=0;cin>>N;
   vector<int>L(N);
   for(int i = 0; i < N; i++)
   {
       cin>>L.at(i);
   }
   sort(L.begin(),L.end());
   for(int i = 0; i < N-1; i++)
   {
       ans+=L.at(i);
   }
   if(L.at(N-1)<ans)
   cout<<"Yes"<<endl;
   else
   {
       cout<<"No"<<endl;
   }
   
    }
    

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using P = pair<int, int>;
using vec = vector<int>;
using mat = vector<vector<int>>;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define endl "\n"

constexpr int MOD = 1000000007;
const int INF = 1 << 30;

int main() {
    int x, y;
    cin >> x >> y;
    int res = 0;

    switch (x)
    {
    case 1:
        res += 300000;
        break;
    case 2:
        res += 200000;
        break;
    case 3:
        res += 100000;
    default:
        break;
    }

    switch (y)
    {
    case 1:
        res += 300000;
        break;
    case 2:
        res += 200000;
        break;
    case 3:
        res += 100000;
    default:
        break;
    }

    if (x+y==2) res += 400000;
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 3568
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int a = sc.nextInt();
    int b = sc.nextInt();
    int sum = 0;
    for(int i = 1; i <= n; i++){
      int tmp = 0;
      int num = i;
      while(num != 0){
        tmp += num % 10;
        num /= 10;
      }
      if(a <= tmp && tmp <= b){
        sum += i;
      }
    }
    System.out.println(sum);
  }
}

Measured memory_bytes: 21460
#include<bits/stdc++.h>
//CLOCKS_PER_SEC
#define se second
#define fi first
#define ll long long
#define Pii pair<int,int>
#define Pli pair<ll,int>
#define ull unsigned long long
#define pb push_back
#define fio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
const int N=1e5+10;
const int INF=0x3f3f3f3f;
const int mod=1e9+7;
using namespace std;
int n,val[N<<1];
int a[N],b[N];
int sum[N];
void add(int x){
	while(x<N*2){
		val[x]+=1;
		x+=x&-x;
	}
}
ll get(int x){
	ll ans=0;
	while(x>0){
		ans+=val[x];x-=x&-x;
	}
	return ans;
}
bool check(int x){
	for(int i=1;i<=n;++i)sum[i]=sum[i-1]+(a[i]>=x?1:-1);
	ll tot=0;
	memset(val,0,sizeof(val));
	for(int i=0;i<=n;++i){
		tot+=get(sum[i]+N);
		add(sum[i]+N);
	}
	return tot>=1LL*n*(n+1)/4;
}
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;++i){
		scanf("%d",&a[i]);b[i]=a[i];
	}
	sort(b+1,b+1+n);
	int l=1,r=n;
	int ans=1;
	while(l<=r){
		int mid=(l+r)>>1;
		if(check(b[mid])){
			ans=mid;
			l=mid+1;
		}
		else r=mid-1;
	}
	cout<<b[ans]<<endl;
	return 0;
}  

Measured memory_bytes: 2176
//#include "pch.h"
//#include "stdafx.h"
#include <iostream>
#include <queue>
#include <vector>
#include <algorithm>
#include <math.h>
#include <string>

using namespace std;

/*-----------------------------------------------------------------------------
定義
-------------------------------------------------------------------------------*/
#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))
#define INF			2e9
#define MOD			1e9+7
#define MIN(a, b)	((a) < (b) ? a : b)
#define MAX(a, b)	((a) > (b) ? a : b)
#define IsOdd(x)	(((x)&0x01UL) == 0x01UL)		/* 奇数 */
#define IsEven(x)	(!IsOdd((x)))					/* 偶数 */

typedef long long int QWORD;
typedef long long int ll;

/*-----------------------------------------------------------------------------
処理
-------------------------------------------------------------------------------*/
int main()
{
	int val;

	cin >> val;

	int valH = (val / 100);
	int valL = (val % 100);

	if (((valH == 0) || (13 <= valH)) && ((valL == 0) || (13 <= valL))) {
		cout << "NA";
	} else if (((1 <= valH) && (valH <= 12)) && (!((1 <= valL) && (valL <= 12)))) {
		cout << "MMYY";
	} else if ((!((1 <= valH) && (valH <= 12))) && ((1 <= valL) && (valL <= 12))) {
		cout << "YYMM";
	} else {
		cout << "AMBIGUOUS";
	}

	return 0;

}



Measured memory_bytes: 256