akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_ll.hpp>
//typedef boost::multiprecision::cpp_ll ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
string alp="abcdefghijklmnopqrstuvwxyz";
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);

ll p;

ll hpow(ll x,ll y){
    ll ans=1;
    ll i=x;
    if(y==0)return 1;
    while(y>0){
        if(y%2==1){
            ans=(ans*i)%p;
        }
        i=(i*i)%p;
        y=y/2;
        
    }
    return ans;
}

int main(){
    ll n;cin>>n>>p;
    string s;cin>>s;
    if(p==2){
        ll ans=0;
        rep(i,0,n-1){
            if((s[i]-'0')%2==0){
                ans+=(i+1);
            }
        }
        cout<<ans<<endl;
        return 0;
    }else if(p==5){
        ll ans=0;
        rep(i,0,n-1){
            if((s[i]-'0')%5==0){
                ans+=(i+1);
            }
        }
        cout<<ans<<endl;
        return 0;
    }
    ll r[n+1];
    r[n]=0;
    ll c[p];
    rep(i,0,p-1)c[i]=0;
    c[0]++;
    for(ll i=n-1;i>=0;i--){
        r[i]=(r[i+1]+(ll)(s[i]-'0')*hpow(10,n-1-i))%p;
        c[r[i]]++;
    }
    ll ans=0;
    rep(i,0,p-1){
        //cout<<c[i]<<endl;
        ans=ans+(c[i]*(c[i]-1))/2;
    }
    cout<<ans<<endl;
    
    return 0;
}




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

typedef pair<int,int> PII;
int n,i,x;
vector<PII> a;
int ans[200007];

int main() {
	scanf("%d",&n);
	for (i=0 ; i<n ; i++) {
		scanf("%d",&x);
		a.push_back(PII(x,i));
	}
	
	sort(a.begin(), a.end());
	
	
	
	for (i=0 ; i<n ; i++) {
		//printf("%d %d\n",a[i].first,a[i].second);
		if (i < n/2) ans[a[i].second] = a[n/2].first; else ans[a[i].second] = a[n/2-1].first;
	}
	
	for (i=0 ; i<n ; i++) printf("%d\n",ans[i]);
}


Measured memory_bytes: 4720
#include <iostream>
#include <string>
#include <vector>
#include <climits>
#include <set>
#include <algorithm>
#include <unordered_map>
#include <queue>
#include <iomanip>
#include <map>
#include <utility>
#include <numeric>
#include <chrono>
#include <ctime>
#include <bitset>
#include <iterator>

#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define P pair<long long, long long>
#define debug(x) cerr << #x << ": " << x << ", "
#define debugln(x) cerr << #x << ": " << x << '\n'

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 namespace std;
using ll = long long;
const ll mod = 1e9 + 7;

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

  int h, w; cin >> h >> w;
  vector<string> a(h);
  rep(i, w+2) {
    cout << '#';
  }
  cout << endl;
  rep(i, h) {
    cin >> a[i];
    cout << '#';
    rep(j, w) {
      cout << a[i][j];
    }
    cout << '#' << endl;
  }
  rep(i, w+2) {
    cout << '#';
  }
  cout << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>

#define MIN(X, Y) (((X) < (Y)) ? (X) : (Y))
#define MAX(X, Y) (((X) > (Y)) ? (X) : (Y))
#define ll long long

int main(void)
{
    int n,x,a,b,c;
    ll sum;
    while(1)
    {
    scanf("%d%d",&n,&x);
    if(n==0&&x==0)
        break;
    sum=0;
    for(a=1;a<=n;a++)
        for(b=2;b<=n;b++)
            for(c=3;c<=n;c++)
            {
                if(a==b||a==c||b==c)
                    continue;
                if(b>a&&c>b&&a+b+c==x)
                {
                    sum++;
                }
            }

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




Measured memory_bytes: 2092
import sys
input=sys.stdin.readline
sys.setrecursionlimit(10 ** 8)
from itertools import accumulate
from itertools import permutations
from itertools import combinations
from collections import defaultdict
from collections import Counter
import fractions
import math
from collections import deque
from bisect import bisect_left
from bisect import bisect_right
from bisect import insort_left
import itertools
from heapq import heapify
from heapq import heappop
from heapq import heappush
import heapq
from copy import deepcopy
from decimal import Decimal
alf = list("abcdefghijklmnopqrstuvwxyz")
ALF = list("ABCDEFGHIJKLMNOPQRSTUVWXYZ")
#import numpy as np
INF = float("inf")
#d = defaultdict(int)
#d = defaultdict(list)
N = int(input())
table = [False for i in range(N+1)]
def primes(n):#nまでの素数を列挙0は入れちゃダメ
    is_prime = [True]*(n+1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2,int(n**(0.5)+1)):
        if not is_prime[i]:
            continue
        for j in range(i*2,n+1,i):
            is_prime[j] = False
    return is_prime

p = primes(N)
pr = []
for i in range(N+1):
    if p[i]:
        pr.append(i)
n = len(pr)
ans = 1
def dfs(cur_num,index,s,pre,me):
    global ans
    for i in range(index,n):
        if i == index:
            if cur_num*pr[i] <= N:
                ans += (pre*(me+2))*cur_num*pr[i]
                dfs(cur_num*pr[i],index,s+pre*(me+2),pre,me+1)
            else:
                break
        else:
            if cur_num*pr[i] <= N:
                ans += pre*(me+1)*2*cur_num*pr[i]
                dfs(cur_num*pr[i],i,s+pre*(me+1)*2,pre*(me+1),1)
            else:
                break
    return 
dfs(1,0,1,1,0)
print(ans)

Measured memory_bytes: 362872
#include <bits/stdc++.h>
#define all(vec) vec.begin(), vec.end()
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
constexpr ll INF = (1LL << 30) - 1LL;
constexpr ll LINF = (1LL << 60) - 1LL;
constexpr ll MOD = 1e9 + 7;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }
ll n, m, v, p;
vector<ll> a;
bool check(int t) {
    ll sum = 0, co = 0;
    for (int i = 0; i < n; i++) {
        if (i == t) {
            continue;
        }
        if (a[i] > a[t] + m) {
            co++;
        } else {
            sum += min(m, a[t] + m - a[i]);
        }
    }
    ll ok = p - 1 - co;
    for (int i = 0; i < n; i++) {
        if (i == t || a[i] > a[t] + m) {
            continue;
        }
        if (ok == 0 || a[t] + m - a[i] > m) {
            break;
        }
        sum += m - (a[t] + m - a[i]);
        --ok;
    }
    if (co >= p) {
        return false;
    }
    return sum >= (v - co - 1LL) * m;
}
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n >> m >> v >> p;
    a.resize(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    sort(all(a));
    reverse(all(a));
    int ok = 0, ng = n;
    while (ng - ok > 1) {
        int mid = (ok + ng) / 2;
        if (check(mid)) {
            ok = mid;
        } else {
            ng = mid;
        }
    }
    cout << ok + 1 << endl;
}


Measured memory_bytes: 1152
#include<bits/stdc++.h>
    #include<algorithm>
    #include<cmath>
    #include<climits>
    using namespace std;
    typedef long long int lli;
    typedef vector<int> vi;
    typedef vector<long long int> vlli;
    typedef pair<int,int> pii;
    typedef pair<long long int,long long int> plli;
    typedef vector< vi > vvi ;
    typedef vector< vlli > vvlli  ;
    #define fi(i,a,b) for(int i=a;i<=b;i++)
    #define flli(i,a,b) for(long long int i=a;i<=b;i++)
    #define bi(i,a,b) for(int i=a;i>=b;i--)
    #define blli(i,a,b) for(long long int i=a;i>=b;i--)
    #define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
    #define all(x) x.begin(),x.end()
    #define sz(x) x.size()
    #define pi 2*acos(0.0)
    #define pb push_back
    #define tr(v,it) for(decltype(v.begin()) it=v.begin();it!=v.end();it++)
    #define present(v,num) (v.find(num)!=v.end())
    #define cpresent(v,num) (find(v.begin(),v.end(),num)!=v.end())
    #define pq priority_queue
    #define mp make_pair
    const int inf=INT_MAX;
    const lli INF =LLONG_MAX;
    const lli mod = 1e9+7;
    int main() {
        #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
        #endif
        fast;
        lli n;cin>>n;
        vlli ans(n+1,0);
        flli(i,1,10000)
        {
            if(i*i>n)break;
            flli(j,1,10000)
            {
                if(i*i+j*j+i*j>n)break;
                flli(k,1,10000)
                {
                    lli var=i*i+j*j+k*k+i*j+j*k+k*i;
                    if(var>n)break;
                    if(var<=n)ans[var]++;
                }
            }
        }
        flli(i,1,n)cout<<ans[i]<<endl;
        cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
        return 0;
    }

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

#define ll long long
#define str string
#define pii pair<int, int>
#define pll pair<ll, ll>
#define fi first
#define se second

#define vc vector<char>
#define vvc vector<vc>
#define vi vector<int>
#define vll vector<ll>
#define vvi vector<vi>
#define vvll vector<vll>
#define vvvll vector<vvll>
#define vs vector<str>
#define vvs vector<vs>
#define vpii vector<pii>
#define vvpii vector<vpii>
#define vpll vector<pll>
#define vvpll vector<vpll>
#define vb vector<bool>
#define vvb vector<vb>
#define rep(i, a, b) for (int i = (a); i < int(b); i++)
#define repi(i, a, b) for (int i = (a); i <= int(b); i++)


using namespace std;
ll INF = LONG_LONG_MAX;
ll mod = 1000000000 + 7;

template <typename T, typename L>
void readVector(vector<T> & _data, L & _size, bool _shift) {
    _data.resize(_size + (ll)_shift);
    for (ll i = (ll)_shift; i < _size + (ll)_shift; i++)
        cin >> _data[i];
}

template <typename T, typename L>
void readMatrix(vector<vector<T>> & _data, L & _rows, L & _cols, bool _shiftRows, bool _shiftCols) {
    _data.resize(_rows + (ll)_shiftRows);
    for (ll i = 0; i < _rows + (ll)_shiftRows; i++)
        _data[i].resize(_cols + (ll)_shiftCols);
    for (ll i = (ll)_shiftRows; i < _rows + (ll)_shiftRows; i++)
        for (ll j = (ll)_shiftCols; j < _cols + (ll)_shiftCols; j++)
            cin >> _data[i][j];
}


//TODO: SOLUTION

ll n;
vll a, b;

void solve() {

    cin >> n;
    a.resize(n);
    b.resize(n);
    ll sum = 0;
    rep(i, 0, n) {
        cin >> a[i] >> b[i];
        sum += a[i];
    }

    ll ans = INF;
    rep(i, 0, n) {
        if (a[i] > b[i])
            ans = min(ans, b[i]);
    }

    if (ans == INF) {
        cout << 0 << endl;
    }
    else {
        cout << sum - ans;
    }
}


int main() {

    // TODO: Set value of this variable manually
    bool _multipleTestCases = false;

    if (_multipleTestCases) {
        ll t; cin >> t;
        while (t--)
            solve();
    }
    else {
        solve();
    }

    return 0;
}

Measured memory_bytes: 3656
#include <bits/stdc++.h>
#define WHOLE(v) (v).begin(), (v).end()
#define REV_WHOLE(v) (v).rbegin(), (v).rend()
using i64 = int64_t;
using namespace std;
template<class F>auto recursive(F f){return[f](auto...a){return f(f,a...);};}
template<class T>using rev_priority_queue=priority_queue<T,vector<T>,greater<T>>;
template<class T>using vector2d=vector<vector<T>>;
struct fixprec{int p;fixprec(int p):p(p){}};
ostream&operator<<(ostream&o,fixprec f){return o<<fixed<<setprecision(f.p);}
int main() {
    const int M = 30000;
    int N;
    cin >> N;
    vector<int> ans;
    if(N == 3) ans = {2, 3, 25};
    for(int i = 1; ans.size() <= N - 2 && i < M; i++) {
        int q = i / 12, r = i % 12;
        if(r <= 1 || r >= 6 || 12 % r != 0) continue;
        ans.push_back(12 * q + r);
        ans.push_back(12 * q + 12 - r);
    }
    for(int i = 1; ans.size() <= N - 2 && 24 * i <= M; i++) {
        ans.push_back(24 * i - 18);
        ans.push_back(24 * i - 6);
    }
    for(int i = 1; ans.size() < N && 12 * i <= M; i++) {
        ans.push_back(12 * i);
    }
    assert(ans.size() == N);
    string delim = "";
    for(int i = 0; i < N; i++) {
        cout << delim << ans[i];
        delim = " ";
    }
    return 0;
}

Measured memory_bytes: 512
import numpy as np

H, W = map(int, input().split())
ans = []

for _ in range(H):
    line = list(str(input()))
    if '#' not in line:
        continue
    else:
        ans.append(line)

ans = np.array(ans).T.tolist()
hoge = []
for i in range(len(ans)):
    line = ans[i]
    if '#' not in line:
        continue
    else:
        hoge.append(line)

ans = np.array(hoge).T.tolist()

for a in ans:
    print("".join(a))


Measured memory_bytes: 21512
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define all(v) v.begin(), v.end()
#define ll long long
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<long long>;
using vvll = vector<vll>;

//snippets:tmp,cl,cvl,cs,co,coy,con,cov

int main(){
    ll k;
    cin >> k;
    ll a;
    cin >> a;
    ll b;
    cin >> b;
    if(((a-1)/k+1)*k<=b) cout << "OK" << endl;
    else cout << "NG" << endl;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define endl '\n'
#define _ ios::sync_with_stdio(false);cin.tie(0);

using namespace std;

int main() {_
    string str1, str2;
    cin >> str1 >> str2;
    int sum=0;
    for(int i=0; i<str1.size();i++){
        if(str1[i]!=str2[i])
            sum++;
    }
    cout << sum << endl;


    return 0;
}


Measured memory_bytes: 3792
#include <bits/stdc++.h>
#define base 1000000007LL
#define ll long long
#define X first
#define Y second
#define mp make_pair
#define pb push_back
#define CLR(a) memset(a,0,sizeof(a))
#define FOR(i,a,b) for(ll i=(a),_b=(b); i<=_b; i++)
#define FORE(i,a,b) for(ll i=(a),_b=(b); i>=_b; i--)

using namespace std;

typedef pair<int, int> II;
typedef vector<II> vi;

ll n, s;

int main()
{
    ios::sync_with_stdio(0);
    //freopen("inp.txt", "r", stdin);
    cin >> n >> s;
    if (n < s) {
        cout << -1;
        return 0;
    }
    if (n == s) {
        cout << n+1;
        return 0;
    }
    ll res = 1000000000000LL;
    ll o = n-s;
    FOR(i,1,(ll)sqrt(o))
        if (o % i == 0) {
            ll k = o / i;
            if (i+1 <= n && i+1 > (ll)sqrt(n) && n / (i+1) == k) res = min(res, i+1);
            if (k+1 <= n && k+1 > (ll)sqrt(n) && n / (k+1) == i) res = min(res, k+1);
        }
    FOR(i,2,(ll)sqrt(n)) {
        ll p = n;
        ll r = 0;
        while (p) {
            r += p % i;
            p /= i;
        }
        if (r == s) {
            cout << i;
            return 0;
        }
    }
    if (res == 1000000000000LL) res = -1;
    cout << res;
    return 0;
}


Measured memory_bytes: 256
/*
[diverta2019-2] A - Ball Distribution
*/

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;

int N, K;

ll solve() { return K == 1 ? 0 : N - K; }

int main() {
    cin >> N >> K;

    cout << solve() << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define dunk(a) cout << (a) << endl
using namespace std;
typedef long long ll;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	vector<vector<char>> c(3, vector<char>(3));
	rep(i, 3)rep(j, 3) cin >> c[i][j];

	cout << c[0][0] << c[1][1] << c[2][2] << endl;

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<fstream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<stack>
#include<climits>
#include<cstring>
#include<queue>
#include<map>
#include<set>
#include<complex>
#include<typeinfo>
using namespace std;

typedef unsigned long long ull;

int main(){
    ull N, M;
    cin >> N >> M;
    if(M%2==1) M--;

    if(N == M/2){
        cout << N << endl;
    }else if(N > M/2){
        cout << M/2 << endl;
    }else{
        M = M - 2*N;
        cout << N + M/4 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long int
using namespace std;
const int INF = 3e18;
const int MOD = 1e9 + 7;

int n, a, b, s[100010];

queue<int> qx, qy;
int dpx[100010], dpy[100010];

signed main()
{
  cin >> n >> a >> b;
  for(int i = 1; i <= n; i++)
    cin >> s[i];

  s[0] = -INF, s[n + 1] = INF, dpx[0] = 1;

  for(int i = 1; i <= n; i++){

    if(s[i] - s[i - 1] >= a)
      dpx[i] += dpx[i - 1];
    else
      while(!qx.empty())
	qx.pop();
    if(s[i] - s[i - 1] >= b)
      dpy[i] += dpy[i - 1];
    else
      while(!qy.empty())
	qy.pop();

    qx.push(i - 1);
    qy.push(i - 1);
    
    while(!qx.empty() && s[i + 1] - s[qx.front()] >= b){
      dpx[i] += dpy[qx.front()];
      qx.pop();
    }
    while(!qy.empty() && s[i + 1] - s[qy.front()] >= a){
      dpy[i] += dpx[qy.front()];
      qy.pop();
    }

    dpx[i] %= MOD;
    dpy[i] %= MOD;

  }

  cout << (dpx[n] + dpy[n]) % MOD << endl;
  return 0;
}


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


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

Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(vec) vec.begin(), vec.end()
using namespace std;
typedef long long ll;
ll gcd(ll x, ll y){
  return y == 0 ? x : gcd(y, x % y);
}
ll lcg(ll x, ll y){
  return x * y / gcd(x, y);
}

int main(){
  ll n, y; cin >> n >> y;
  
  //string ans = "Yes";
  //string ans = "No";
  //string ans = "YES";
  //string ans = "NO";
  ll ans = 0;
  ll man = -1, o = -1, cheon = -1;
  rep(a, n + 1){
    rep(b, n - a + 1){
      ll c = n - a - b;
      ll total = 10000 * a + 5000 * b + 1000 * c;
      if (total == y) man = a, o = b, cheon = c;
    }
  }

  //cout << ans << endl;
  cout << man << " " << o << " " << cheon << endl;
}

Measured memory_bytes: 764
#include <iostream>
#include <stdint.h>
#include <utility>
#include <map>
#include <limits.h>

using namespace std;

uint16_t N, C;

uint16_t D[30][30];

typedef uint16_t Color;

class ColorCounter : public map<Color, uint32_t> {
public:
  void add(uint16_t color) {
    if (this->find(color) == this->end())
      this->emplace(color,1);
    else
      this->at(color)++;
  }

  void print() {
    for (auto x : *this)
      cerr << x.first << ":" << x.second << endl;
  }
    
};

class ColorChangeCost : public map<Color, uint32_t> {
public:
  ColorChangeCost(ColorCounter counter) {
    for (Color c=0; c<C; ++c) {
      this->emplace(c,0);
    }

    for (auto& color_dist : *this) {
      for (auto color_count : counter) {
	Color origin = color_count.first;
	uint32_t cost_per_tile = D[origin][color_dist.first];
	uint32_t cost_all = cost_per_tile *= color_count.second;
	color_dist.second += cost_all;
      }
      //cerr << "paint to " << color_dist.first << ":" << color_dist.second << endl;
    }
  }

  // std::pair<Color,uint32_t> min_cost(Color exception) {
  //   uint32_t min = UINT_MAX;
  //   Color min_color = 30;
  //   for (auto x : *this) {
  //     if (x.first == exception)
  // 	continue;
  //     if (x.second < min) {
  // 	min = x.second;
  // 	min_color = x.first;
  //     }
  //   }
  //   return make_pair(min_color,min);
  // }

  uint32_t cost(Color to) {
    return this->at(to);
  }
};
  
int main()
{
  cin >> N >> C;

  for (uint16_t c1=0; c1<C; ++c1) {
    for (uint16_t c2=0; c2<C; ++c2) {
      uint16_t d;
      cin >> d;
      D[c1][c2] = d;
    }
  }

  uint16_t c[500][500];
  ColorCounter count_color[3];
  
  for (uint16_t n1=0; n1<N; ++n1) {
    for (uint16_t n2=0; n2<N; ++n2) {
      uint16_t cc;
      cin >> cc;
      --cc;
      c[n1][n2] = cc;
      uint16_t residue = (n1+n2)%3;
      count_color[residue].add(cc);
    }
  }

  // for (auto cc: count_color) {
  //   //cc.print();
  //   //cerr << endl;
  // }

  //cerr << endl;
  ColorChangeCost* change_costs[3];
  for (int r=0; r<3; ++r) {
    change_costs[r] = new ColorChangeCost(count_color[r]);
    //cerr << endl;
  }

  uint32_t min_cost = UINT_MAX;
  for (Color c0=0; c0<C; ++c0) {
    uint32_t cost0 = change_costs[0]->cost(c0);
    for (Color c1=0; c1<C; ++c1) {
      if (c1 == c0)
	continue;
      uint32_t cost1 = change_costs[1]->cost(c1);
      for (Color c2=0; c2<C; ++c2) {
	if (c2 == c0 || c2 == c1)
	  continue;
	uint32_t cost2 = change_costs[2]->cost(c2);
	uint32_t cost = cost0 + cost1 + cost2;
	min_cost = min(min_cost,cost);
      }
    }
  }

  cout << min_cost << endl;
	
  
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <random>
#include <cstdio>
#include <cmath>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int) n; i++)

int main() {
    int k; cin >> k;
    if (k % 2 == 0)
    {
        int ans = (k/2)*(k/2);
        cout << ans << endl;
    } else {
        int ans = (k/2+1)*(k/2);
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 256
class Proq
	attr_reader:name
	def initialize(line)
		d = line.split(" ")
		@name = d[0]
		@time = d[1].to_i
	end
	def cul(t)
		@time -= t
	end
end

queue = Array.new

d = gets.chomp.split(" ").map(&:to_i)
n,q = d[0],d[1]
n.times { queue << Proq.new(gets) }

time = 0
while queue.length > 0
	time += q
	p = queue.slice!(0)
	remain = p.cul(q)
	if remain > 0
		queue << p
	else
		time += remain
		puts "#{p.name} #{time}"
	end
end

Measured memory_bytes: 14848
import java.util.Scanner;

public class Main {


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

		while(true){
			int num = 0;
			String moji = scan.next();
			int moji_len = moji.length();
			//??§????????¨?°????????????\??????????????????
			for(int cnt_len = 0; cnt_len < moji_len; cnt_len++){
				char moji_one = moji.charAt(cnt_len);
				String moji_str = String.valueOf(moji_one);
				int moji_int = Integer.decode(moji_str);
				num += moji_int;
			}
			//0?????\???????????????????????¨?????????????????????
			if(num == 0)
				break;
			else
				System.out.println(num);
		}
		//????§????
		scan.close();
	}
}

Measured memory_bytes: 27084
#include<bits/stdc++.h>
using namespace std;
double ans,f[305][305][35];
int n,C,L[9],id[9],i,j,k,mx,z;
int main(){
	scanf("%d%d",&n,&C);mx=C*n;
	for(i=1;i<=n;++i)scanf("%d",L+i),id[i]=i;
	sort(L+1,L+n+1);
	do{
		memset(f,0,sizeof f);f[0][L[n]*n][0]=1;
		for(i=0;i<mx;++i)for(j=i;j<=mx;++j)for(k=0;k<1<<n-1;++k)if(f[i][j][k]>0){
			if(i<j)f[i+1][j][k]+=f[i][j][k];
			z=i%n;if(z && !(k>>z-1&1))f[i+1][min(mx,max(j,i+L[id[z]]*n))][k|(1<<z-1)]+=f[i][j][k]/C;
		}
		ans+=f[mx][mx][(1<<n-1)-1];
	}while(next_permutation(id+1,id+n));
	for(i=1;i<n;++i)ans/=i;printf("%.14f\n",ans);
}

Measured memory_bytes: 25728
using System;
using System.Linq;

namespace ABC082
{
    class Program
    {
        static void Main(string[] args)
        {
            // A
            //var input = Console.ReadLine();

            //Console.WriteLine(A_RoundUptheMean.RoundUp(input));

            // B
            var s = Console.ReadLine();
            var t = Console.ReadLine();

            Console.WriteLine(B_TwoAnagrams.CharSort(s, t));
        }
    }
  public class B_TwoAnagrams
    {
        public static string CharSort(string s, string t)
        {
            var sArray = s.ToArray();
            var tArray = t.ToArray();

            Array.Sort(sArray);
            Array.Sort(tArray);
            Array.Reverse(tArray);

            var sString = string.Join("", sArray);
            var tString = string.Join("", tArray);

            var result = sString.CompareTo(tString) == -1 ? "Yes" : "No";

            return result;
        }
    }
}


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

int main(){
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  if ((a + b) > (c + d))
    cout << "Left" << endl;
  else if ((a + b) == (c + d))
    cout << "Balanced" << endl;
  else
    cout << "Right" << endl;
  return 0;
}

Measured memory_bytes: 256
# -*- coding:utf-8 -*-
import sys
S = list(input())
a = list(reversed(S))
for tmp in range(len(a)):
    if a[tmp] == 'b':
        a[tmp] = 'd'
    elif a[tmp] == 'd':
        a[tmp] = 'b'
    elif a[tmp] == 'p':
        a[tmp] = 'q'
    else:
        a[tmp] = 'p'

    if S[tmp] != a[tmp]:
        print("No")
        sys.exit()

print("Yes")

Measured memory_bytes: 4652
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include <cstdint>
#include <utility>
#include <tuple>
#include <map>    
#include <queue> 
#include <set>  
#include <stack> 
#include <deque>  
#include <unordered_map> 
#include <unordered_set> 
#include <bitset>

using namespace std;

int main() {
	int M, D;
	cin >> M >> D;

	int count = 0;
	for (int i = 1; i <= M; i++) {
		for (int j = 1; j <= D; j++) {
			int d1 = j % 10;
			int d10 = (j / 10) % 10;
			if (d1 >= 2 && d10 >= 2 && d1*d10 == i) {
				count++;
			}
		}
	}
	cout << count << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
long long mod = 1e9 + 7;
void add(long long &n , long long m){
    n += m;
    if(n >= mod){
        n -= mod;
    }
}
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    int n , m ; cin>>n>>m;
    int ans = m / 2;
    ans += (3 * n  + m % 2)/ 2;
    cout<<ans<<endl;
}


Measured memory_bytes: 256
//include
//------------------------------------------
#include <bits/stdc++.h>
using namespace std;
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef long long ll;
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const ll INF = 1000000007;
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
// chmax chmin
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main(void){
    int N;
    ll W;
    cin >> N >> W;
    ll v[N], w[N];
    REP(i,N) cin >> w[i] >> v[i];

    ll dp[N+1][N+1][3*N];
    REP(i,N+1)REP(j,N+1)REP(k,3*N) dp[i][j][k] = 0;

    ll ans = 0;
    for(ll i=1; i<N+1; i++)for(ll j=1; j<N+1; j++)for(ll k=0; k<3*N; k++){
        if(k-(w[i-1]-w[0]) >= 0) chmax(dp[i][j][k], dp[i-1][j-1][k-(w[i-1]-w[0])]+v[i-1]);
        chmax(dp[i][j][k], dp[i-1][j][k]);
        if((ll)j*w[0]+k <= W) chmax(ans, dp[i][j][k]);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 24192
n = int(input())
a = [int(input()) for i in range(n)]
check = [0 for i in range(n)]
check[0] = 1
i = 0
cnt = 0
while True:
	cnt += 1
	x = a[i]
	if x-1 == 1:
		print (cnt)
		exit()
	if check[x-1] == 1:
		print(-1)
		exit()
	else:
		check[x-1] = 1
	i = x-1

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

#define FORE(i, a) for (auto i = a.begin(); i != a.end(); ++i)
#define REPU(i, a, b) for (int i = (a); i < (b); ++i)
#define REPD(i, a, b) for (int i = (a); i > (b); --i)
#define MEM(a, x) memset(a, x, sizeof(a))
#define ALL(a) a.begin(), a.end()
#define UNIQUE(a) a.erase(unique(ALL(a)), a.end())

vector<string> split(const string &s, char c) {
	vector<string> v;
	stringstream ss(s);
	string x;
	while (getline(ss, x, c)) v.push_back(x);
	return v;
}

#define DEBUG(args...) { vector<string> _v = split(#args, ','); err(_v.begin(), args); }

void err(vector<string>::iterator it) {}

template<typename T, typename... Args>
void err(vector<string>::iterator it, T a, Args... args) {
	cerr << "[DEBUG] " << it -> substr((*it)[0] == ' ', it -> length()) << " = " << a << '\n';
	err(++it, args...);
}

typedef long long ll;
const int MOD = 1000000007;

template<class T, class U> inline T tmin(T a, U b) { return (a < b) ? a : b; }
template<class T, class U> inline T tmax(T a, U b) { return (a > b) ? a : b; }
template<class T, class U> inline void amax(T &a, U b) { if (b > a) a = b; }
template<class T, class U> inline void amin(T &a, U b) { if (b < a) a = b; }
template<class T> inline T tabs(T a) { return (a > 0) ? a : -a; }
template<class T> T gcd(T a, T b) { while (b != 0) { T c = a; a = b; b = c % b; } return a; }

int main(int argc, char *argv[]) {
	ios_base::sync_with_stdio(false);

	int a[3];

	REPU(i, 0, 3) cin >> a[i];
	REPU(i, 0, 3) {
		if (a[i] % 2 == 0) {
			puts("0"); return 0;
		}
	}
	sort(a, a + 3);
	printf("%lld\n", a[0] * 1LL * a[1]);

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define FORR(i,a,b) for (int i=(a);i>=(b);i--)
#define pb push_back
#define pcnt __builtin_popcount
#define show(x) cout<<#x<<" = "<<x<<endl;
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define fi first
#define se second
#define rng(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define sz(x) (int)(x).size()
#define mp make_pair

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef set<int> si;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pll> vpll;
typedef set<ll> sl;
typedef __int128_t lll;
typedef pair<lll,lll> plll;
typedef vector<lll> vlll;
template<typename T>string join(vector<T>&v)
{stringstream s;FOR(i,0,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename A, size_t N, typename T>void Fill(A (&array)[N], const T&v)
{fill((T*)array,(T*)(array+N),v);}
ll gcd(ll a,ll b){if(a>b)swap(a,b);for(;a>0;b%=a,swap(a,b));return b;}
int modpow(ll a,ll n,int m){if(a==0)return a;ll p=1;for(;n>0;n/=2,a=a*a%m)if(n&1)p=p*a%m;return(int)p;}
void dout(double d){printf("%.12f\n",d);}

const int iinf = 1e9;
const ll linf = 1e18;
const int mod = 1e9+7;
const double pi = acos(-1);
const double eps = 1e-10;

struct LCA{
  int ln;
  vector<vector<pair<int, ll> > > *G;
  vvi parent;
  vi depth;
  vl dd;
  void dfs(int pos, int pre, int d){
    depth[pos] = d;
    each(itr, (*G)[pos]){
      if(pre == itr->fi) continue;
      parent[0][itr->fi] = pos;
      dd[itr->fi] = dd[pos] + itr->se;
      dfs(itr->fi, pos, d+1);
    }
  }
  int root(int a, int b){
    if(depth[a] > depth[b]) swap(a, b);
    int d = depth[b] - depth[a];
    FOR(i, 0, ln) if((1<<i)&d) b = parent[i][b];
    if(a == b) return a;
    FORR(i, ln-1, 0) if(parent[i][a] != parent[i][b]) a = parent[i][a], b = parent[i][b];
    return parent[0][a];
  }
  void build(vector<vector<pair<int, ll> > > *G, int r){
    this->G = G;
    int n = sz(*G);
    for(ln = 0; (1<<ln) < n; ln++);
    parent = vvi(n);
    FOR(i, 0, ln) parent[i] = vi(n);
    depth = vi(n);
    dd = vl(n);
    dfs(r, -1, 0);
    FOR(i, 1, ln)FOR(j, 0, n) parent[i][j] = (parent[i-1][j] == -1 ? -1 : parent[i-1][parent[i-1][j]]);
  }
};

vector<vector<pair<int, ll> > > G;
int n, q, k;
LCA lca;
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n;
  G.resize(n);
  FOR(i, 0, n-1){
    int a, b;
    ll c;
    cin >> a >> b >> c;
    a--; b--;
    G[a].pb(mp(b, c));
    G[b].pb(mp(a, c));
  }
  cin >> q >> k;
  k--;
  lca.build(&G, k);
  FOR(i, 0, q){
    int x, y;
    cin >> x >> y;
    x--; y--;
    cout << lca.dd[x] + lca.dd[y] << "\n";
  }
  return 0;
}

Measured memory_bytes: 22656
#include<stdio.h>
int main(void){
    int a,b,i,k,n,s;
    k = 0;
    s = 0;
    scanf("%d",&n);
    for(i=1;i<n+1;i++){
        scanf("%d",&a);
        scanf("%d",&b);
        if(a == b)
        k = k + 1;
        if(a != b)
        k = 0;
        if(k == 3)
        s = 100;
    }
    if(s == 100)
    printf("Yes\n");
    else
    {
        printf("No\n");
    }
        return 0;
    
    
}

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

using namespace std;

#define pb push_back
#define mp make_pair
#define ff first
#define ss second

typedef long long int ll;
typedef vector< pair<int, int> > vii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long long int> vll;
typedef pair<int, int> pii;

const ll INF = 1e18;
const int inf = 1e9;
const int MOD = 1e9 + 7;
const int nax = 1000000 + 10;

int n, arr[nax];
int main()
{
    ios::sync_with_stdio(0);
    int n;
    cin >> n;
    set<int> set1;
    while(n--)
    {
        int num; cin >> num;
        if(set1.find(num) != set1.end())
            set1.erase(num);
        else
            set1.insert(num);
    }
    cout << (int)set1.size();
    return 0;
}


Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())
#define endl "\n"

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    ll n, a, b;
    cin >> n >> a >> b;
    cout << min(a * n, b) << endl;
    return 0;
}


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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using edge = pair<ll, P>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
using Graph = vector<vector<ll>>;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    string S, T;
    cin >> S >> T;
    ll cnt = 0;
    ll pre = -1;

    unordered_map<ll, vector<ll>> pos;
    rep(i, S.length()) {
        pos[S[i]].push_back(i);
    }
    rep(i, T.length()) {
        char t = T[i];
        if (pos[t].size() >= 1) {
            auto idx = upper_bound(pos[t].begin(), pos[t].end(), pre);
            if (idx == pos[t].end()) {
                pre = -1;
                auto idx = upper_bound(pos[t].begin(), pos[t].end(), pre);
                cnt++;
                pre = pos[t][idx-pos[t].begin()];
            } else {
                pre = pos[t][idx-pos[t].begin()];
            }
        } else {
            cout << -1 << endl;
            return;
        }
    }
    cout << cnt * S.length() + pre +1<< endl;

}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
}


Measured memory_bytes: 1736
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>
// #include <set>
// #include <cmath>
// #include <string>
// #include <map>
// #include <iomanip>

// #define MOD 1000000007

using namespace std;
// typedef unsigned long long ull;
typedef long long ll;

void p() {
    cout << "\n";
}
template<class Head, class... Body>
void p(Head head, Body... body) {
    cout << head << ",";
    p(body...);
}


template<typename T>
ostream& operator<<(ostream& os, const vector<T>& v) {
    os << "[";
    for (const auto& i : v) {
        os << i << " ";
    }
    os << "]";
    return os;
}

int main(int argc, char const *argv[]) {
    int N;
    ll A, B;
    cin >> N >> A >> B;
    vector<ll> hp(N);
    for (int i = 0; i < N; i++) {
        cin >> hp[i];
    }

    ll l = 0;
    ll h = 1000000000;
    while (h - l > 1) {
        ll m = (l + h) / 2;
        // p(l, h, m);
        vector<ll> hp_cp = hp;
        for (int i = 0; i < N; i++) {
            if (B*m < hp_cp[i]) {
                hp_cp[i] -= B*m;
            } else {
                hp_cp[i] = 0;
            }
        }
        // cout << hp_cp << endl;
        ll count = 0;
        for (int i = 0; i < N; i++) {
            count += (hp_cp[i] + A-B-1) / (A-B);
            if (count > m) {
                break;
            }
        }
        if (count > m) {
            l = m;
            // p("ng");
        } else {
            h = m;
            // p("ok");
        }
    }

    cout << h << endl;
    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define modulo 1000000007
#define fast_io ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
using namespace std;
int main(){
	fast_io;
	string s;
	cin>>s;
	ll n=s.length();
	ll a[n][13];
	memset(a,0,sizeof(a));
	if(s[0]=='?'){
		for (int i = 0; i <= 9; ++i){
			a[0][i]=1;
		}
	}
	else
		a[0][(s[0]-'0')]++;
	for (int i = 1; i < n; ++i){
		vector<ll>v;
		if(s[i]!='?')
			v.pb((s[i]-'0'));
		else{
			v.pb(0);v.pb(1);v.pb(2);v.pb(3);v.pb(4);v.pb(5);v.pb(6);v.pb(7);v.pb(8);v.pb(9);
		}
		for (int j = 0; j < v.size(); ++j){
			ll x=v[j];
			for (int k = 0; k < 13; ++k){
				a[i][(x+k*10)%13]=(a[i-1][k]+a[i][(x+k*10)%13])%modulo;
			}
		}
	}
	cout<<a[n-1][5]<<"\n";
	return 0;
}

Measured memory_bytes: 13920
#include <bits/stdc++.h>
#include <string>
#include <algorithm>
#include <string.h>
#include <ctype.h>
#include <math.h>
#include <float.h>
#include <iomanip>
#include <iostream>
using namespace std;

int main()
{
    int A,B,C;
    cin>>A>>B>>C;
    if(C>=A&&C<=B){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
#include <deque>
#include <iomanip>
#include <limits>
#include <fstream>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;
const int MAXE = 2020;
const int MAXV = 1010;
struct edge {
  int from;
  int to;
  int cost;
};
edge es[MAXE];
int d[MAXV];
int V, E;
void shortest_path(int s){
  for(int i=0;i<=V;i++) d[i]=1e9;
  d[s]=0;
  int cnt=0;
  while(true){
    cnt++;
    if(cnt > E + 1) {
        cout<<"NEGATIVE CYCLE"<<endl;
        exit(0);
    }
    bool update=false;
    for(int i=0;i<E;i++){
      if(d[es[i].from]!=1e9&&d[es[i].to]>d[es[i].from]+es[i].cost){
        d[es[i].to]=d[es[i].from]+es[i].cost;
        update=true;
      }
    }
    if(!update)break;
  }
}
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int r;
  cin>>V>>E>>r;
  FOR(i,0,E){
      cin>>es[i].from>>es[i].to>>es[i].cost;
  }
  shortest_path(r);
  FOR(i,0,V){
      if(d[i] == 1e9) cout<<"INF"<<endl;
      else cout<<d[i]<<endl;
  }
}


Measured memory_bytes: 3196
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cout << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cout<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 200010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = 1 << 29;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
///////////////////////////////////////////////////////////////////////////////////////////////////

int N, K, C;
ll dp[2010][2010];

void solve() {
	cin >> N >> K;
	C = N - K;
	ll pow2 = 1;
	rep(i, 0, C - 1) MUL(pow2, 2);
	rep(i, 0, C + 1) dp[i][0] = pow2;
	rep(k, 1, K) {
		ll tmp = 0;
		rep(i, 1, C + k) {
			ADD(tmp, dp[i][k - 1]);
			dp[i][k] = tmp;
		}
		dp[C + k][k] = (tmp + dp[C + k - 1][k - 1]) % mod;
	}
	cout << dp[N - 1][K - 1] << "\n";
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
	srand((unsigned int)time(NULL));
#ifdef LOCAL
	//freopen("in.txt", "wt", stdout); //for tester
    freopen("in.txt", "rt", stdin);
#endif	
	solve();
#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}



Measured memory_bytes: 31104
#include <bits/stdc++.h>
#define all(vec) vec.begin(), vec.end()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
template <class T>
using V = vector<T>;
template <class T>
inline void chmin(T &a, const T &b) { a = min(a, b); }
template <class T>
inline void chmax(T &a, const T &b) { a = max(a, b); }
template <class T>
inline bool kbit(const T &x, const int &k) { return ((x >> k) & 1LL); }
inline int popcount(const int &n) { return __builtin_popcount(n); }
inline ll popcountll(const ll &n) { return __builtin_popcountll(n); }
template <class T>
void zip(V<T> &v) {
    sort(all(v));
    v.erase(unique(all(v)), v.end());
}
void dump() {
    cerr << '\n';
}
template <class Head, class... Tail>
void dump(Head &&head, Tail &&... tail) {
    cerr << head << (sizeof...(Tail) == 0 ? " " : ", ");
    dump(std::move(tail)...);
}
template <class T>
void print(const vector<T> &v) {
    for (int i = 0; i < v.size(); i++) cout << v[i] << (i + 1 == v.size() ? '\n' : ' ');
}
template <class T>
void read(vector<T> &v) {
    for (int i = 0; i < v.size(); i++) cin >> v[i];
}
constexpr char sp = ' ', newl = '\n';
constexpr int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};
constexpr ll INF = (1LL << 30) - 1LL;
constexpr ll MOD = 1e9 + 7;
const double eps = 1e-9;
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    ll a;
    cin >> a;
    double c;
    cin >> c;
    c *= 100.0;
    ll b = ll(floor(c + eps));
    ll res = a * b;
    res /= 100LL;
    cout << res << newl;
}

Measured memory_bytes: 3820
#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>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
using namespace std;
typedef  long long int lint;
typedef pair<int, int> P;
typedef pair<lint, lint> LLP;
typedef pair<char, char>CP;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define llower(v,hoge) *lower_bound(v.begin(), v.end(), hoge)
#define lupper(v,hoge) *upper_bound(v.begin(), v.end(), hoge)
/*
vector<char>al(26);
al = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
vector<char>AL(26);
AL = {'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
vector<char>NUM(10);
	NUM = { '0','1','2' ,'3' ,'4' ,'5' ,'6' ,'7' ,'8' ,'9' };
*/



int main() {
	int N, M, X;
	cin >> N >> M >> X;
	vector<int>A(M);
	rep(i, M) {
		cin >> A[i];
	}
	sort(A);
	int L = lower(A, X)-A.begin();
	cout << min(L, M - L) << endl;
}

Measured memory_bytes: 256
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];
		for (int i = 0; i < n; i++) {
			arr[i] = sc.nextInt();
		}
		if (arr[0] != 0) {
			System.out.println(-1);
			return;
		}
		long count = 0;
		for (int i = 1; i < n; i++) {
			if (arr[i - 1] < arr[i]) {
				if (arr[i] - arr[i - 1] == 1) {
					count++;
				} else {
					System.out.println(-1);
					return;
				}
			} else {
				count += arr[i];
			}
		}
		System.out.println(count);
	}
}


Measured memory_bytes: 86756
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N=2e5+5;
int a[N],num[N];
int main() {
    //freopen("in.txt","r",stdin);
    int n;
    scanf("%d",&n);
    for(int i=1;i<=n;i++) {
        scanf("%d",&a[i]);
        num[a[i]]++;
    }
    ll ans=0;
    for(int i=1;i<=n;i++) {
        ans+=1LL*num[i]*(num[i]-1)/2;
    }
    for(int i=1;i<=n;i++) {
        ans-=1LL*num[a[i]]*(num[a[i]]-1)/2;
        num[a[i]]--;
        printf("%lld\n",ans+1LL*num[a[i]]*(num[a[i]]-1)/2);
        num[a[i]]++;
        ans+=1LL*num[a[i]]*(num[a[i]]-1)/2;
    }
    return 0;
}

Measured memory_bytes: 3712
//
//  main.cpp
//  at
//
//  Created by 黄道煜 on 2018/8/18.
//  Copyright © 2018年 黄道煜. All rights reserved.
//

#include <iostream>
#include <cstdio>
using namespace std;

int main()
{
    int a, b;
    scanf("%d%d", &a, &b);
    printf("%d\n", a*b-a-b+1);
}


Measured memory_bytes: 256
import itertools

N=int(input())
A=[0]*N
for i in range(N):
    A[i]=int(input())

m=sum(A)

if(m%10==0):
    A=sorted(A)
    for a in A:
        if a%10!=0:
            print(m-a)
            exit()
    print(0)
else:
    print(m)



Measured memory_bytes: 38256
//6:48
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <map>

using namespace std;
typedef long long ll;
ll max(ll a, ll b){return(a>b)?a:b;}
ll min(ll a, ll b){return(a<b)?a:b;}
ll abss(ll a){return(a<0)?-a:a;}

ll gcd(ll a, ll b){
        if(b > a){
                ll tmp = b;
                b = a;
                a = tmp;
        }
        if(b == 0) return a;
        else return gcd(b, a%b);
}
ll lcm(ll a, ll b){
        ll gcdi = gcd(a,b);
        return a/gcdi*(b);
}

int main(){
        ll N,M;
        scanf("%lld %lld",&N,&M);

        ll ans = min(N,M/2);
        M -= ans*2;
        N -= ans;
        if( M >= 2 ){
                ans += M/4;
        }
        printf("%lld\n",ans);
}

Measured memory_bytes: 128