akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
using namespace std;
int main(){
	int n,b,f,r,v,i,j,w,q,a[4][3][10]={0};
	cin>>n;
	for(i=0;i<n;i++){
		cin>>b>>f>>r>>v;
		a[b-1][f-1][r-1]=a[b-1][f-1][r-1]+v;
	}
	for(q=0;q<4;q++){
		for(j=0;j<3;j++){
			for(w=0;w<10;w++){
				cout<<" "<<a[q][j][w];
			}cout<<endl;	
		}if(q!=3){
			cout<<"####################"<<endl;
		}
	}
	return 0;
}


Measured memory_bytes: 3092
#include<iostream>
#include<vector>
#include<cmath>
#include<map>
#include<queue>
#include<stack>
#include<algorithm>
#include<functional>

typedef unsigned long long LL;

using namespace std;

int main() {
	int A, B, C, D, E, F;
	cin >> A >> B >> C >> D >> E >> F;
	double limitNoudo = double(100 * E) / (100 + E);
	double maxNoudo = 0;
	int answerwater = 0;
	int answersugar = 0;
	for (int a = 0; a < 31; a++) {
		if (A*a*100 > F)break;
		for (int b = 0; b < 31; b++) {
			if ((A*a + B*b)*100 > F || (A*a + B*b) * 100 == 0)break;
			//sugar
			int water = (A*a + B*b) * 100;
			for (int c = 0; c*C < F ; c++) {
				for (int d = 0; c*C + d*D < F; d++) {
					int sugar = c*C + d*D;
					if (water + sugar > F) {
						break;
					}
					//noudo
					double currentNoudo = double (100 * sugar) / (water + sugar);
					if (currentNoudo > limitNoudo) {
						break;
					}
					if (currentNoudo > maxNoudo) {
						answerwater = water;
						answersugar = sugar;
						maxNoudo = currentNoudo;
					}
				}
			}
		}
	}
	if (answerwater == 0)answerwater = 100 * A;
	cout << answerwater + answersugar << " " << answersugar << endl;
}

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

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

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template < typename T >
void vprint(T &v){
	REP(i, v.size()){
		cout << v[i] << " ";
	}
	cout << endl;
}

ll dp[101010];
ll N, K;
vector<ll> a(100);

ll rec(ll k){
	if(dp[k]>=0) return dp[k];
	ll flag = 0;
	REP(i, N){
		if(k-a[i]>=0){
			if(rec(k-a[i])==0) flag = 1;
		}
	}
	dp[k] = flag;
	return flag;
}

int main(){
	cin >> N >> K;
	REP(i, N) cin >> a[i];

	memset(dp, -1, sizeof(dp));
	cout << (rec(K)==1?"First":"Second") << endl;

    return 0;
}

Measured memory_bytes: 5760
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <complex>
#include <math.h>

using namespace std;

//conversion
//------------------------------------------
inline long toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
inline long toLong(string s) {long 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> PII;
typedef pair<long, long> PLL;
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
//--------------------------------------------

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

const long double EPS = 1e-12;
const int INF = 10000;

struct edge{
	int l,r,h;
	bool operator<( const edge& right ) const {
        return h == right.h ? r < right.r : h < right.h;
    }
};


int main(){
	long e;
	while(cin>>e){
		if(e==0)break;
		long sum=10000000;
		for(long i=0;i*i*i<=e;i++){
			for(long j=0;i*i*i+j*j<=e;j++){
				sum=min(sum,i+j+(e-i*i*i-j*j));
			}
		}
		cout<<sum<<endl;
	}
	return 0;
}

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

using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define MIN(a, b) ((a) > (b) ? (b) : (a))
#define MAX(a, b) ((a) < (b) ? (b) : (a))

const long long INF = 1LL << 60;
typedef unsigned long long ll;
const long long MOD = 1000000000 + 7;

int main()
{
    int h, w;
    cin >> h >> w;
    string s[h];
    rep(i, h) cin >> s[i];
    vector<vector<string>> out(h, vector<string>(w));
    int dx[] = {-1, -1, -1, 0, 0, 1, 1, 1};
    int dy[] = {1, 0, -1, 1, -1, 1, 0, -1};
    rep(i, h)
    {
        rep(j, w)
        {
            int cnt = 0;
            if (s[i][j] == '#')
            {
                out[i][j] = '#';
                continue;
            }
            rep(k, 8)
            {
                int x = j + dx[k];
                int y = i + dy[k];
                if (x >= 0 && y >= 0 && x < w && y < h)
                {
                    if (s[y][x] == '#')
                        cnt++;
                }
            }
            out[i][j] = to_string(cnt);
        }
    }
    rep(i, h)
    {
        rep(j, w) cout << out[i][j];
        cout << endl;
    }
    return 0;
}

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

int main(){
  int n;
  cin >> n;
  vector<int> r(n);
  for(int i = 0; i<n; ++i){
    cin >> r.at(i);}
  
  sort(r.begin(),r.end());
  int a=0,b=0;
  for(int i = n-1; i >= 0; i -=2){
  a += r.at(i);
    if(i == 0){break;}
  b += r.at(i-1);}
  
  int num = a-b;
  cout << num << endl;
}

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

#define PI 3.14159265359
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define bit(n,k) (((ll)n>>(ll)k)&1) /*nのk bit目*/
#define pb push_back
#define eb emplace_back
#define SZ(x) ((ll)(x).size())
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
const long long INF= 1e+18+1;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll> >vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
const ll MOD=1000000007LL;
//const ll MOD=998244353LL;
//const ll MOD=1777777777LL;
//const ll MAX_V=114514LL;
//const ll MAX = 500010LL;
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
vl dx={0,0,1,-1};
vl dy={1,-1,0,0};

//素因数分解O(√n)
map<ll,ll>prime_factor(ll n){
  map<ll,ll>res;
  for(ll i=2;i*i<=n;i++){
    while(n%i==0){
      res[i]++;
      n/=i;
    }
  }
  if(n!=1)res[n]=1;
  return res;
}

const ll MAX = 510000;
long long fac[MAX], finv[MAX], inv[MAX];
//finvが階乗の逆元

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

ll modpow(ll a, ll n, ll mod) {
  
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}



int main(){
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  cout << fixed << setprecision(10);
  /*--------------------------------*/
  ll n;cin>>n;ll m;cin>>m;
  vector<P>vec(n);
  rep(i,n)cin>>vec[i].first>>vec[i].second;
  sort(all(vec));
  vl a(n),b(n);
  rep(i,n){
    a[i]=vec[i].first;
    b[i]=vec[i].second;
  }
  ll i=0;
  ll cnt=0;
  ll ans=0;
  while(cnt<m){
    if(cnt+b[i]<m){
      ans+=b[i]*a[i];
      cnt+=b[i];
      i++;
    }
    else if(cnt+b[i]>=m){
      ans+=(m-cnt)*a[i];
      cnt=m;
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 6328
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<int(n);i++)
#define FOR(i,n,m) for(int i=n;i<int(m);i++)
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;

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

int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a*b/gcd(a,b);}	

const ll mod=1e9+7;
const int INF=INT_MAX/2;
const int N_MAX=100010;

int main(){
	int n,k;
	cin>>n>>k;
	cout<<n-k+1<<endl;
	return 0;
}



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

using namespace std;
typedef long long int ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) for (int i = 0; i < (n); i++)
#define fst first
#define snd second
#define ALL(obj) (obj).begin(), (obj).end()
#define debug(x) cout << #x << ": " << x << endl
#define out(x) cout << x << endl
//#define int long long int
const int MOD = 1000000007;
const ll LINF = (ll)1e20;
const int INF = 1e9;
const double EPS = 0.000000001;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  VI w(n);
  int ans = INF;
  int r = 0;
  int l = 0;
  REP(i, n){
    cin >> w[i];
    r += w[i];
  }
  REP(i, n){
    l += w[i];
    r -= w[i];
    ans = min(ans, abs(l - r));
  }
  out(ans);
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef long double ld;
const double pi=acos(-1.0);
const ll mod=pow(10,9)+7;
const ll INF=pow(2,31)-1;
typedef pair<int,int> P;
typedef vector<int> vi;

ll gcd(ll a,ll b){
    ll v0=a,v1=b,v2=a%b;
    while(v2!=0){
        v0=v1;
        v1=v2;
        v2=v0%v1;
    }
    return v1;
}

ll lcm(ll a,ll b){
    return (a*b/gcd(a,b));
}

int MAX_N=8;

int main(){
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    int x[MAX_N],y[MAX_N];
    rep(i,n){
        cin >> x[i] >> y[i];
    }
    auto dist=[&](int i,int j){
        double dx=x[i]-x[j];
        double dy=y[i]-y[j];
        return pow(dx*dx+dy*dy,0.5);
    };
    vector<int> v(n);
    rep(i,n){
        v[i]=i;
    }
    double sum=0.0;
    int cnt=0;
    do{
        rep(i,n-1){
            sum+=dist(v[i],v[i+1]);
        }
        cnt++;
    } while(next_permutation(v.begin(),v.end()));
    printf("%.10f\n", sum/cnt);
    return 0;
}

Measured memory_bytes: 384
// failed to generate code

#include <bits/stdc++.h>
using namespace std;


template <class Data> struct ConvexHullTrick {
    std::deque<std::pair<Data, Data>> l;
    bool check(std::pair<Data, Data> l3) {
        const auto l1 = *prev(end(l), 2);
        const auto l2 = *prev(end(l), 1);
        Data a = (l2.first - l1.first) * (l3.second - l2.second);
        Data b = (l2.second - l1.second) * (l3.first - l2.first);
        return a >= b;
    }
    bool empty() const { return l.empty(); }
    void add(Data a, Data b) {
//        cerr << "Add " << a << "x + (" << b << ")" << endl;
        if (!empty()) assert(l.back().first >= a);
        std::pair<Data, Data> n(a, b);
        while ((int)l.size() >= 2 && check(n)) l.pop_back();
        l.emplace_back(n);
    }
    Data f(int k, Data x) { return l[k].first * x + l[k].second; }
    Data minimum(Data x) {
        assert(!empty());
        while ((int)l.size() >= 2 && f(0, x) >= f(1, x)) l.pop_front();
        return f(0, x);
    }
};


int main(){	
    ios::sync_with_stdio(false);
    ConvexHullTrick<long long> cht;

    int n;
    long long c;
    cin >> n >> c;

    vector<long long> h(n);
    for(int i = 0 ; i < n ; i++) cin >> h[i];

    cht.add(-2 * h[0], h[0] * h[0]);

    long long vvv = 0;
    for(int i = 1 ; i < n ; i++){
        long long dpv = h[i] * h[i] + c + cht.minimum(h[i]);
        cht.add(-2*h[i], dpv + h[i] * h[i]);
        vvv = dpv;
    }
    cout << vvv << endl;

}


Measured memory_bytes: 4096
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>
#include <random>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
//#define int long long

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;
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; }

void solve() {
    int n;
    cin >> n;
    VVLL cnt(51,VLL(31));
    string s;
    REP(i,0,n) {
        cin >> s;
        if (s.find('.') == string::npos) {
            int v = stoi(s);
            VI c(2);
            while (v > 0 && v % 2 == 0) {
                c[0]++;
                v /= 2;
            }
            while (v > 0 && v % 5 == 0) {
                c[1]++;
                v /= 5;
            }
            cnt[c[0]+13][c[1]+10]++;
            continue;
        }
        LL v = stol(s.substr(0,s.find('.')));
        string t = s.substr(s.find('.')+1);
        REP(j,0,t.size()) v *= 10;
        v += stol(t);
        int mi = t.size();
        VI c(2);
        while (v > 0 && v % 2 == 0) {
            c[0]++;
            v /= 2;
        }
        while (v > 0 && v % 5 == 0) {
            c[1]++;
            v /= 5;
        }
        if (c[0]-mi+13 >= 0 && c[1]-mi+10 >= 0) cnt[c[0]-mi+13][c[1]-mi+10]++;
    }
    LL ans = 0;
    REP(i,0,51) REP(j,0,31) {
        REP(k,0,51) REP(l,0,31) {
            if (i + k < 26 || j + l < 20) continue;
            ans += 1LL * cnt[i][j] * cnt[k][l];
            if (i == k && j == l) ans -= cnt[i][j];
        }
    }

    ans /= 2;
    cout << ans << endl;
}

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

Measured memory_bytes: 3540
#include <bits/stdc++.h>
#define owo(i,a, b) for(int i=(a);i<(b); ++i)
#define uwu(i,a, b) for(int i=(a)-1; i>=(b); --i)
#define senpai push_back
#define ttgl pair<int, int>
#define ayaya cout<<"ayaya~"<<endl
 
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
gp_hash_table<int, gp_hash_table<int, int>> mp;
using ll = long long;
using ld = long double;
const ll MOD = 1000000000;
const ll root = 62;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
ll binpow(ll a,ll b){ll res=1;while(b){if(b&1)res=(res*a)%MOD;a=(a*a)%MOD;b>>=1;}return res;}
ll modInv(ll a){return binpow(a, MOD-2);}
const double PI = acos(-1);
const double eps = -1e6;
const int INF = 0x3f3f3f3f;
const int NINF = 0xc0c0c0c0;
const ll INFLL = 0x3f3f3f3f3f3f3f3f;
const ll NINFLL = 0xc0c0c0c0c0c0c0c0;
const int mxN = 200001;
int h, w;
int n;
pair<int, ttgl> arr[mxN];
int dsu[mxN];
int sz[mxN];
int esz[mxN];
ll ans = 0;
int find(int a) {
    return a==dsu[a] ? a : dsu[a] = find(dsu[a]);
}
void merge(int a, int b, int val) {
    a = find(a);
    b = find(b);
    if(a==b) {
        if(esz[a]<sz[a]) {
            esz[a]++;
            ans+=val;
        }
    }else {
        if(sz[a]<sz[b])swap(a, b);
        if(esz[a]<sz[a]||esz[b]<sz[b]) {
            dsu[b] = a;
            sz[a]+=sz[b];
            esz[a]+=esz[b];
            esz[a]++;
            ans+=val;
        }
    }
}
int main() {
    //freopen("file.in", "r", stdin);
    //freopen("file.out", "w", stdout);
    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
    cin.tie(0)->sync_with_stdio(0);
    cin>>n>>h>>w;
    owo(i, 0, mxN){
        sz[i] = 1;
        esz[i] = 0;
        dsu[i] = i;
    }
    owo(i, 0, n) {
        cin>>arr[i].second.first>>arr[i].second.second>>arr[i].first;
        arr[i].second.first--;
        arr[i].second.second+=h-1;
    }
    sort(arr, arr+n);
    reverse(arr, arr+n);
    owo(i, 0, n) {
        merge(arr[i].second.second, arr[i].second.first, arr[i].first);
    }
    cout<<ans<<"\n";
    return 0;
}


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

#define pp push_back
#define pf push_front
#define mp make_pair
#define fs first
#define sc second
#define sf scanf

using namespace std;

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

const int N = (int) 1e5;
const int INF = (int) 1e9 + 7;

int main(int argc, char *argv[])
{
	// ios_base::sync_with_stdio(false);
	// cin.tie(NULL);

	int n;
	sf("%d", &n);
	bool ok = false;
	while (n) {
		if (n % 10 == 7) ok = true;
		n /= 10;
	}
	puts(ok ? "Yes" : "No");

	return 0;
}


Measured memory_bytes: 3808
#include <stdio.h>

int main(void)
{
	char c;
	
	while (1){
		c = getc(stdin);
		if (c == '\n'){
			break;
		}
		
		if ('a' <= c && c <= 'z'){
			c -= 0x20;
		}
		
		printf("%c", c);
	}
	
	printf("\n");
	
	return (0);
}

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

public class Main {

	public static void main(String[] args) throws IOException {
		// Xを取得
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		int x = Integer.parseInt(in.readLine());

		// X以上の整数を条件を満たすまで調べる
		for (;; x++) {

			// xが素数か調べる
			boolean isPrime = checkPrime(x);

			// 素数である場合、調べ終わる
			if (isPrime) {
				break;
			}

		}

		// 結果を出力
		System.out.println(x);

	}

	private static boolean checkPrime(final int x) {

		// 2から(x-1)までで割り切れるか確認する
		for (int i = 2; i < x; i++) {

			// 割り切れるものがある場合、素数ではない
			if (x % i == 0) {
				return false;
			}
		}

		// 割り切れるものがない場合、素数である
		return true;
	}

}


Measured memory_bytes: 22612
def medians(nums):
    n = len(nums)
    num_orig_pos = list(zip(nums, range(n)))
    nums_sorted = sorted(num_orig_pos)
    medians = []
    med_left = nums_sorted[(n + 1)//2][0]
    med_right = nums_sorted[(n + 1)//2 - 1][0]
    for i in range((n + 1)//2):
        medians.append((med_left, nums_sorted[i][1]))
    for i in range((n + 1)//2, n):
        medians.append((med_right, nums_sorted[i][1]))
    return map(lambda x: x[0], sorted(medians, key=lambda x: x[1]))


if __name__ == '__main__':
    _ = input()
    nums = list(map(int, input().split()))
    for i in medians(nums):
        print(i)

Measured memory_bytes: 55060
package main

import (
	"fmt"
	"strconv"
)

func dfs(s string, i int, lasti int, sum int) int {
	if i == len(s) {
		if lasti == i {
			return sum
		}
		return 0
	}

	n, _ := strconv.Atoi(s[lasti : i+1])
	sum1 := dfs(s, i+1, lasti, sum)
	sum2 := dfs(s, i+1, i+1, sum+n)

	return sum1 + sum2
}

func main() {
	var s string
	fmt.Scan(&s)

	sum := dfs(s, 0, 0, 0)
	fmt.Println(sum)
}


Measured memory_bytes: 512
#include <iostream>
#include <cmath>
#include <algorithm>

using namespace std;

int main() {
    int A,B,C,K;
    cin>>A>>B>>C;
    cin>>K;
    int sum=A+B+C;

    int MAX;
    MAX=std::max(A,B);
    MAX=std::max(B,C);
    sum-=MAX;
    cout<<sum+MAX*pow(2,K)<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//Author: Ezio Sam
/* Shorthands */
#define ll long long
#define pb push_back 
#define mp make_pair
#define sp " "
#define cs "Case "
#define fi first
#define sn second 
#define po(x) x*x
/* STL */
#define vi vector<int>v
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mem(a,n) memset(a, n, sizeof(a));
#define all(x) x.begin(),x.end()
#define alr(x) x.rbegin(),x.rend()
#define sz(x)  (int)x.size()
#define mx(v)  *max_element(v.begin(),v.end())
#define mxi(v) distance(v.begin(),max_element(v.begin(),v.end()))
#define mxa(a) *max_element(a, a.size())
#define r(a) reverse(a.begin(),a.end())
/* loops */
#define fr(i,n)   for(__typeof(n) i=0;i<(n);i++)
#define fn(i,n)   for(__typeof(n)i=1;i<=(n);i++)
#define fa(i,a,n) for(int  i=a;i<=b;i++)
/*Special*/
#define Ezio ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define db(something)  cerr<<#something<<" - "<<something<<"\n";         

int main()
{
  
   Ezio
   ll t,m,n,x(0),a,b;
   string s;
   
   cin>>n;
   vector<ll>v(n);
   
   fr(i,n)cin>>v[i];
   
   fr(i,n){
     if((i+1 & 1)and v[i] & 1) x++;
   }
   cout<<x<<endl;
   return 0;
}
    

Measured memory_bytes: 3672
#include <bits/stdc++.h>
#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 INF 2e9
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;

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

int main()
{
	int x[4], y[4];
	REP(i, 2) cin >> x[i] >> y[i];

	x[2] = x[1] + (y[0] - y[1]);
	y[2] = y[1] - (x[0] - x[1]);
	x[3] = x[2] + (x[0] - x[1]);
	y[3] = y[2] + (y[0] - y[1]);

	cout << x[2] << " " << y[2] << " " << x[3] << " " << y[3] << endl;
}


Measured memory_bytes: 256
from heapq import *
import sys
sys.setrecursionlimit(10**6)
I=sys.stdin.readlines()
N,K=map(int,I[0].split())
t,d=0,0
X=[]
for i in range(N):
  t,d=map(int,I[i+1].split())
  X.append((d,t))
X.sort()
Q=[]
heapify(Q)
C=[0]*N
V=0
S=0
for i in range(K):
  heappush(Q,X[-1])
  if C[X[-1][1]-1]==0:
    V+=1
  S+=X[-1][0]
  C[X[-1][1]-1]+=1
  del X[-1]
def f(q,c,s,x,v):
  y=0
  r=s+v*v
  for i in range(len(q)):
    y=heappop(q)
    if c[y[1]-1]>=2:
      s-=y[0]
      c[y[1]-1]-=1
      break
    if len(q)==0:
      return r
  for i in range(len(x)):
    if c[x[-1][1]-1]==0:
      heappush(q,x[-1])
      s+=x[-1][0]
      c[x[-1][1]-1]=1
      v+=1
      del x[-1]
      return max(r,f(q,c,s,x,v))
    del x[-1]
  return r
print(f(Q,C,S,X,V))

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

using namespace std;

int main(int argc, char *argv[]) {
	int A1, A2, A3;
	cin >> A1 >> A2 >> A3;
	vector<int> costs = {A1, A2, A3};

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

	int sum_cost = 0;
	sum_cost += (costs[1] - costs[0]);
	sum_cost += (costs[2] - costs[1]);
	cout << sum_cost << endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <math.h>
#include <cmath>
#include<complex>
#include<cctype>
#include<string>
#include<set>
#include<iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include<bitset>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
using namespace std;
using Complex = complex<double>;
using ll = long long;
template<typename T>using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll inf = 1145141919810364364LL;
double PI = acos(-1.0);
#define all(x) (x).begin(),(x).end()
#define puts(x) cout << x << endl
#define rep(i,m,n) for(ll i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(ll i = m;i >= n;--i)


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

	ll a, b, c;
	cin >> a >> b >> c;
	if (c - a - b <= 0)puts("No");
	else if(4LL * a*b < (c - a - b)*(c - a - b))puts("Yes");
	else puts("No");

	return 0;
}

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

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using WGraph = vector<vector<pair<int, ll>>>;

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

constexpr int dx[4] = {-1, 0, 0, 1}, dy[4] = {0, -1, 1, 0};
constexpr int INF = 1e9;
constexpr long long LINF = 1e18;
#pragma endregion

void solve() {
    int h, w;
    cin >> h >> w;
    vector<string> field(h);
    for (int i=0; i<h; i++) {
        cin >> field.at(i);
    }

    int ans = -1;
    for (int i=0; i<h*w; i++) {
        int start_x = i%h, start_y = i/h;
        int maxi = 0;
        if (field.at(start_x).at(start_y) == '#') continue;
        queue<pair<int, int>> que;
        vector<vector<int>> dis(h, vector<int>(w, INF));
        que.push(make_pair(start_x, start_y));
        dis.at(start_x).at(start_y) = 0;
        while (!que.empty()) {
            int curx = que.front().first, cury = que.front().second; que.pop();
            for (int i=0; i<4; i++) {
                int nextx = curx + dx[i], nexty = cury + dy[i];
                if (nextx < 0 || nextx > h-1 || nexty < 0 || nexty > w-1) continue;
                if (field.at(nextx).at(nexty) == '.' && dis.at(nextx).at(nexty) > dis.at(curx).at(cury) + 1) {
                    dis.at(nextx).at(nexty) = dis.at(curx).at(cury) + 1;
                    chmax(maxi, dis.at(nextx).at(nexty));
                    que.push(make_pair(nextx, nexty));
                }
            }
        }
        chmax(ans, maxi);
    }
    cout << ans << "\n";
}

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

    solve();

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main()
{   
    int n;
    
    scanf("%d",&n);
    
    int i, arr[100];
    
    for(i=0;i<3;i++)
    {
        arr[i]=n%10;
        n=n/10;
    }
    
    int cnt=0;
    
    for(i=0;i<3;i++)
    {
        if(arr[i]==1)
        cnt++;
    }
    printf("%d\n",cnt);
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <vector>
#define fs first
#define se second

using namespace std;
typedef long long llong;
typedef pair<int, int> pii;

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    int k, a, b;
    cin >> k >> a >> b;
    llong ans = k + 1;
    k -= a - 1;
    if (k > 0 && a < b) {
        ans = max(ans, a + (b - a) * (k / 2ll) + (k & 1));
    }
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 256
#include<algorithm>
#include<vector>
#include<cstdio>
#define ll long long
#define MaxN 270000
using namespace std;
const int mod=998244353;
int read(){
  int X=0;char ch=0;
  while(ch<'0'||'9'<ch)ch=getchar();
  while('0'<=ch&&ch<='9')X=X*10+(ch^48),ch=getchar();
  return X;
}
ll powM(ll a,int t=mod-2){
  ll ret=1;
  while(t){
    if (t&1)ret=ret*a%mod;
    a=a*a%mod;t>>=1;
  }return ret;
}
void FWT(ll *f,int n)
{
  for (int l=1;l<n;l<<=1)
    for (int p=0;p<n;p+=l+l)
      for (int k=0;k<l;k++){
        ll sav=f[p|k];
        f[p|k]+=f[p|l|k];
        f[p|l|k]=sav-f[p|l|k];
      }
  for (int i=0;i<n;i++)f[i]%=mod;
}
ll R[MaxN],sR,F[MaxN],sF;
int main()
{
  int n=1<<read();
  for (int i=0;i<n;i++)sR+=(R[i]=read());
  sR=powM(sR);
  for (int i=0;i<n;i++)R[i]=R[i]*sR%mod;
  R[0]--;FWT(R,n);
  for (int i=1;i<n;i++)F[i]=mod-1;
  F[0]=n-1;FWT(F,n);
  for (int i=1;i<n;i++){
    F[i]=F[i]*powM(R[i])%mod;
    sF+=F[i];
  }F[0]=mod-sF%mod;
  FWT(F,n);
  ll inv=powM(n);
  for (int i=0;i<n;i++){
    F[i]=F[i]*inv%mod;
    printf("%lld\n",(F[i]+mod)%mod);
  }return 0;
}

Measured memory_bytes: 6976
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <queue>

using namespace std;



int main(){

	int n,r,k,to,table[101][101],num_of_packet,start,goal,t_limit,memo[101][101],P[101],D[101],num,min,min_index,current;

	for(int i=1; i < 101; i++){
		for(int k=1; k < 101; k++){
			table[i][k] = 0;
			memo[i][k] = 0;
		}
	}

	scanf("%d",&n);

	for(int i = 0; i < n; i++){
		scanf("%d %d",&r,&k);
		for(int p=0;p < k; p++){
			scanf("%d",&to);
			table[r][to] = 1;
		}
	}

	scanf("%d",&num_of_packet);


	for(int i=0; i < num_of_packet; i++){
		scanf("%d %d %d",&start,&goal,&t_limit);

		if(t_limit <= 1){
			printf("NA\n");
			continue;
		}

		if(memo[start][goal] != 0){
			if(memo[start][goal] <=  t_limit){
				printf("%d\n",memo[start][goal]);
			}else{
				printf("NA\n");
			}
			continue;
		}

		for(int index=1; index <= n; index++){
			P[index] = 0; //???????????????????????¨???????????????
			D[index] = 1000000000; //start??°?????????????????¢?????¨???????????????
		}

		P[start] = 1; //??????????????°????????????????????¨??????
		num = 1;

		for(int index = 1; index <= n; index++){
			if(index != start && table[start][index] == 1){
				D[index] = 1;  //start??°???????????????????????????start??°??????????????¢1??¨??????
			}
		}

		while(num < n){
			min = 1000000000;
			for(int index=1;index <= n; index++){  //??????????????°?????????????????????????????¢???
				if(P[index] == 0 && D[index] < min){ //?????????????????§?????????????????????????????????
					min = D[index];
					min_index =index;
				}
			}

			if(min == 1000000000)break; //?????????????????????????????????????????°break

			P[min_index] = 1; //min_index?????????????????¨??????
			current = min_index;
			num++; //???????????????????????°???1?¢???????

			for(int i=1; i <= n; i++){
				if(table[current][i] == 1){	//start???????????????????????¨???????????£????????????
					D[i] = (D[i] <= (D[current]+1))?D[i]:(D[current]+1); //?????????????????´??\????????¢??¨???current????????±???????????¢???????????????D??¨??????
				}
			}

		}

		if(D[goal] >= t_limit){
			printf("NA\n");
		}else{
			memo[start][goal] = D[goal]+1;
			printf("%d\n",D[goal]+1);
		}

	}

    return 0;
}

Measured memory_bytes: 2792
#include <iostream>
#include <vector>
#include <array>
#include <deque>
#include <stack>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>
#include <iomanip>

using namespace std;
using ll=long long int;

ll get(ll n, ll i) {
    return (n >> (i * 10)) & ((1LL << 10) - 1);
}

int main() {
    ll l[3];
    for (auto &e: l) cin >> e;
    ll k;
    cin >> k;
    vector<ll> a[3];
    for (ll i = 0; i < 3; ++i) a[i].resize(l[i]);
    for (auto &v: a) for (auto &e: v) cin >> e;
    for (auto &v: a) sort(v.begin(), v.end(), greater<ll>());

    priority_queue<pair<ll, ll>> s;
    set<ll> used;
    ll c = 0;
    for (auto &v: a) c += v[0];
    s.push(make_pair(c, 0LL));
    used.insert(0);
    ll cnt = 0;
    while (cnt < k) {
        auto fr = s.top(); s.pop();
        cout << fr.first << endl;
        ++cnt;
        for (ll i = 0; i < 3; ++i) {
            ll idx = fr.second;
            idx += 1LL << (i * 10);
            if (get(idx, i) >= l[i]) continue;
            if (used.count(idx) > 0) continue;

            ll cost = fr.first;
            cost -= a[i][get(idx, i) - 1];
            cost += a[i][get(idx, i)];

            s.push(make_pair(cost, idx));
            used.insert(idx);
        }
    }

    return 0;
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)n; i++)
#define rep1(i, n) for (ll i = 1; i <= (ll)n; i++)
#define PI 3.14159265358979323846
#define vll vector<long long>
#define vvll vector<vector<long long>>
#define pll pair<long long, long long>
using namespace std;
using ll = long long;
using ld = long double;

const ll MOD = 1e9+7;

// グローバル変数（入力）
ll n,k;

void input() { 
  cin >> n >> k;
}

void solve() {
  vll rl(n+1),ru(n+1);
  rl[0]=0;ru[0]=n;
  rep1(i,n){
    rl[i]=rl[i-1]+i;
    ru[i]=ru[i-1]+(n-i);
  }
  ll ans=0;
  for (ll i=k-1; i<=n; i++){
    ans += (ru[i]-rl[i]+1)%MOD;
    ans %= MOD;
  }
  cout << ans << endl;
}

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


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

int main(){
    int k,i;
    string s;
    cin>>k>>s;

    if(s.size()<=k){
        cout<<s;
    }else{
        rep(i,k){
            cout<<s[i];
        }
        cout<<"..."<<endl;
    }

}

Measured memory_bytes: 3620
import sys

n = int(input())

ab = []

for i in range(0,n):
    a, b = map(int, input().split())
    ab.append( [a, b] )

ab.sort(key=lambda x: x[1])

sumA = 0

available = True

for a, b in ab :
    sumA += a
    if sumA>b:
        available = False
        break

if available == False:
    print('No')
else :
    print('Yes')

Measured memory_bytes: 38084
import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
		// your code goes here
		try {
		    Scanner sc=new Scanner(System.in);
		    int n=sc.nextInt();
		    int b=n/500;
		    n=n%500;
		    int sum=0;
		    sum+=(b*1000)+((n/5)*5);
		    System.out.println(sum);
		    
		} catch(Exception e) {
		}
	}
}


Measured memory_bytes: 21844
#include <algorithm>
#include <iostream>
#include <string>
#include <stack>
#include <utility>
#include <vector>

#define rep(i, n) for (auto i = 0; i < (n); i++)
#define MOD 1e9 + 7
typedef long long ll;

using namespace std;

int main() {
  int ans = 0;
  string s;
  cin >> s;
  if (s == "RRR") cout << 3 << endl;
  else if (s == "RRS" || s == "SRR") cout << 2 << endl;
  else if (s == "SSS") cout << 0 << endl;
  else cout << 1 << endl;

  return 0;
}



Measured memory_bytes: 3232
def find(L,R):
    if R-L>=2019:
        return 0
    MIN=2019
    for i in range(L,R+1):
        for j in range(i+1,R+1):
            MIN=min((i*j)%2019,MIN)
    return MIN
L,R=list(map(int,input().strip().split(' ')))
print(find(L,R))

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

#define _CRT_SECURE_NO_WARNINGS
#define TLong long long
#define TBMod 1000000007

int main(int argc, char const *argv[])
{
	int n,k;
	int display = 1;
	scanf("%d%d",&n,&k);
	for (int i = 0; i < n; ++i)
	{
		if(display < k)	display *= 2;
		else display += k;
	}
	printf("%d\n",display);
	return 0;
}


Measured memory_bytes: 128
//c++ テンプレ
#include<bits/stdc++.h>
using namespace std;

typedef long long llint;
typedef long double ld;

#define inf 1e18
constexpr long long INFLL = 1e18;
#define mod 1000000007
priority_queue<llint,vector<llint>,greater<llint> > que;
priority_queue<llint> Que;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

void solve(){
    llint a;
    double b;
    cin >> a >> b;
    llint x=a*(llint)(b*100+0.5)/100;
    cout << x << endl;
}

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


Measured memory_bytes: 3660
#include<iostream>

int main(){

	int a=0,i,b;

	for(i=1;i<10;i++){
		a=a+1;
		for(b=1;b<10;b++){
			std::cout<<a<<"x"<<b<<"=";
			std::cout<<a*b<<std::endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1116
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

int main(){
  int a,b,n,f=0;
  string s;
  for(;cin>>n,n;){
    if(f)cout<<endl;
    vector<pair<int,string> >v;
    for(f=0;f<n;v.push_back(make_pair(a*3+b,s)),f++)
      cin>>s>>a>>b>>b;
    for(a=0;a<n;a++)
      for(b=0;b<n-1;b++)
        if(v[b].first<v[b+1].first)iter_swap(v.begin()+b,v.begin()+b+1);
    for(a=0;a<n;a++)
      cout<<v[a].second<<','<<v[a].first<<endl;
    f=1;
  }
}

Measured memory_bytes: 0
using System;

namespace LuckyPIN
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            String S = Console.ReadLine();
            bool[] flag;
            int now;
            String pass;
            int result=0;
            for(int i = 1000; i < 2000; i++)
            {
                flag= new bool[] { false, false, false };
                pass = i.ToString();
                now = 0;
                for(int j = 0; j < N; j++)
                {
                    if (S[j] == pass[now+1])
                    {
                        flag[now] = true;
                        now++;
                        if (now == 3)
                        {
                            break;
                        }
                    }
                }
                if (flag[2])
                {
                    result++;
                }
            }
            Console.WriteLine(result);
        }
    }
}


Measured memory_bytes: 11164
#include <bits/stdc++.h>
#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 INF 2e9
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
 
//const int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
//const int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

double abs(double x);

double abs(double x)
{
	if (x < 0) return -x;
	return x;
}

int main()
{
	 int n, t, a;
	 cin >> n >> t >> a;

	 int h[n];
	 REP(i, n) cin >> h[i];

	 float tmp[n];
	 REP(i, n) tmp[i] = t - (h[i] * 0.006);

	 REP(i, n) tmp[i] = tmp[i] - a;

	 int index;
	 double min = INF;
	 REP(i, n){
		 if (min > abs(tmp[i])){
			 min = abs(tmp[i]);
			 index = i + 1;
		 }
	 }
	 cout << index << endl;
}


Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
 
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
 
template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;
 
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
 
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 1000001; //check the limits, dummy
 
pi demap(int X) {
	int A = X % 1000;
	int B = X / 1000;
	return {B, A};
}
 
int mapTo(pi X) {
	return min(X.f, X.s)  + max(X.f, X.s)*1000;
}
 
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);    
	
	int N; cin >> N;
	
	vector<vi> graph(MX);
	
	int ind[MX]; F0R(i, MX) ind[i] = 0;
	
	F0R(i, N) {
		int lst; cin >> lst; lst--;
		F0R(j, N-2) {
			int cur; cin >> cur; cur--;
			
			int ear = mapTo({i, lst});
			int lat = mapTo({i, cur});
			graph[ear].pb(lat);
			ind[lat]++;
			lst = cur;
		}
		
	}
	
	vi tbr;
	F0R(i, MX) if (ind[i] == 0) tbr.pb(i);
	
	int proc = 0;
	
	int day = 0;
	
	while (sz(tbr) != 0) {
		day++;
		proc += sz(tbr);
		
		vi nxtTbr;
		
		F0R(x, sz(tbr)) {
			//if (demap(tbr[x]).f < 4 && demap(tbr[x]).s < 4) cout << "on day " << day << " processed " << demap(tbr[x]).f << " " << demap(tbr[x]).s << endl;
			int i = tbr[x];
			F0R(y, sz(graph[i])) {
				int nxt = graph[i][y];
				ind[nxt]--;
				if (ind[nxt] == 0) nxtTbr.pb(nxt);
			}
			
		}
		
		tbr = nxtTbr;
	}
	
	if (proc != MX) {
		cout << -1 << endl;
	} else {
		cout << day << endl;
	}
	
	return 0;
}


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

int main()
{
  int n,num=0;
 cin>>n;
 num=pow(2,n);
 vector< pair<int,int> > v[n+1];
for(int i=1;i<=n;i++)
{
  int q;
   cin>>q;
 while(q--)
 {
   int x,y;
  cin>>x>>y;
  v[i].push_back({x,y});
 }
}
int ans=0;
for(int i=0;i<num;i++)
{
  int c=i,z=1,cnt=0,l=0;
  int arr[n+1];
  while(c)
 {
   l++;
   if((c%2)==1)
     cnt++;
   arr[l]=c%2;
   c/=2;
  }
  for(int j=l+1;j<=n;j++)
    arr[j]=0;
  for(int j=1;j<=n;j++)
  {
    if(arr[j]==1)
   {
    for(int k=0;k<v[j].size();k++)
    {
      int x,y;
      x=v[j][k].first;
      y=v[j][k].second;
      if(arr[x]!=y)
        z=0;
     }
    }
 }
  if(z)
    ans=max(ans,cnt);
 }
cout<<ans;
 return 0;
}

Measured memory_bytes: 256
S = input()[::-1]

length = len(S)
dp = [0] * (length + 2)

times = 1
for x in range(1, length + 1):
    dp[x] += dp[x - 1]
    dp[x] %= 2019
    dp[x] += int(S[x - 1]) * times
    dp[x] %= 2019
    times *= 10
    times %= 2019


cnt = [0] * 2020
for x in range(length + 1):
    cnt[dp[x]] += 1

ans = 0
for c in cnt:
    ans += (c * (c - 1)//2)

print(ans)




Measured memory_bytes: 70268
import java.util.Scanner;

public class Main {
	private Scanner sc;

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

		while (sc.hasNextLine()) {
			String[] nico = sc.nextLine().split(",");

			double x0 = Double.parseDouble(nico[0]);
			double y0 = Double.parseDouble(nico[1]);
			double x1 = Double.parseDouble(nico[2]);
			double y1 = Double.parseDouble(nico[3]);
			double xq = Double.parseDouble(nico[4]);
			double yq = Double.parseDouble(nico[5]);
			
			double d = 0.0;
			if (x0 != x1) {
				double a = (y0 - y1) / (x0 - x1);
				double b = y0 - x0 * a;
				
				d = (yq - a * xq - b) / Math.sqrt(1 + a * a);
				
				double rad = Math.atan(a);
				
				System.out.println((xq + 2 * d * Math.sin(rad)) + " " + (yq - 2 * d * Math.cos(rad)));
			} else {
				System.out.println((xq - 2 * (xq - x0)) + " " + yq);
			}
		}
	}
}

Measured memory_bytes: 26136
//abc088_a.cpp
//Sun Feb 18 19:35:18 2018

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

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

	int x = n%500;

	if (x<=a){
		cout << "Yes" << endl;
	}else {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <sstream>
#define LL long long
#define MP make_pair
#define PII pair<int, int>
#define F first
#define S second
using namespace std;
int n,m,k;
int a[510][510];
int main()
{
	cin >>n>>m>>k;
	for (int i=0;i<m;i++)
	{
		int x,y;
		cin >>x>>y;
		a[x][y]++;
	}
	for (int i=1;i<=n;i++)
	{
		for (int j=2;j<=n;j++)
		    a[i][j]+=a[i][j-1];
	}
	for (int j=1;j<=n;j++)
	{
		for (int i=2;i<=n;i++)
		    a[i][j]+=a[i-1][j];
	}
	for (int i=0;i<k;i++)
	{
		int x,y;
		cin >>x>>y;
		cout <<a[y][y]-a[x-1][y]-a[y][x-1]+a[x-1][x-1]<<"\n";
	}
	return 0;
}

Measured memory_bytes: 1920
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<iomanip>
using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0; i<(n); i++)
#define FOR(i,a,b) for(int i=(a); i<(b); i++)
const long long INF = 1LL << 60;

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

    sort(d.begin(),d.end());
    int bdl = d[n / 2 - 1];
    int bdr = d[n / 2];

    cout << bdr - bdl << endl;

    return 0;
}



Measured memory_bytes: 640
n, m, c = list(map(int, input().split()))
b = list(map(int, input().split()))
res = 0
for i in range(n):
    temp = 0
    a = list(map(int, input().split()))
    for j in range(m):
        temp += a[j] * b[j]
    temp += c
    if temp>0:
        res += 1
print(res)


Measured memory_bytes: 9168
import collections
num_val = int(input())
text_list = [input() for i in range(num_val)]

check_list = collections.Counter(text_list).most_common()
max_val = max([i[1] for i in check_list])
for i in sorted([i[0] for i in check_list if i[1] == max_val]):
    print(i)

Measured memory_bytes: 45032
#include <iostream>
#include <bits/stdc++.h>
#define mod 1000000007
using namespace std;
typedef long long ll;
char a[10005];
int d,len;
ll dp[10005][105][3];

ll solve(int idx,int sum,int pre){

    if(idx == len){
        if(sum == 0) return dp[idx][sum][pre] = 1;
        return dp[idx][sum][pre] = 0;
    }
    if(dp[idx][sum][pre] != -1) return dp[idx][sum][pre];

    ll ret = 0;
    if(idx == 0 || pre == 1){
    for(int i = 0;i <= (a[idx]-'0'); i++){
        if(i == a[idx]-'0')
        ret = (ret % mod + solve(idx+1,(sum + i)%d, 1) % mod) % mod;
        else
        ret = (ret % mod + solve(idx+1,(sum+i)%d,0) % mod) % mod;
        }
    }
    else{
        for(int i=0;i < 10; i++){
        ret = (ret % mod + solve(idx+1,(sum + i)%d, pre) % mod) % mod;
        }
    }
    return dp[idx][sum][pre] = ret;
}

int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    cin>>a>>d;
    len = strlen(a);
    memset(dp,-1,sizeof(dp));
    cout<<(((solve(0,0,0)-1) + mod)%mod)%mod;

    return 0;
}


Measured memory_bytes: 29052
#include <bits/stdc++.h>
typedef long long ll;
#define mod 1000000007
using namespace std;
int main()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("outp.txt","w",stdout);
    #endif
    ll n,i,q,x,y;map<ll,ll> m;
    cin>>n;vector<ll> v(n+1);
    ll sum=0;
    for(i=1;i<=n;i++)
    {    
        cin>>v[i];
        m[v[i]]++;
        sum=sum+v[i];
    }
    cin>>q;
    for(i=0;i<q;i++)
    {
        cin>>x>>y;
        m[y]=m[y]+m[x];
        sum=sum+((y-x)*m[x]);
        m[x]=0;
        cout<<sum<<endl;
    }
}

    


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

using namespace std;
using ll = long long;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  ll a, b, n;
  cin >> a >> b >> n;
  ll x = 1;
  ll l = 1, r = n;
  while(l <= r) {
    ll m = (l + r) >> 1;
    if((a * m) / b < a) {
      x = m;
      l = m + 1;
    } else {
      r = m - 1;
    }
  }
  assert(x <= n);
  cout << (x * a) / b - a * (x / b) << '\n';
  return 0;
}


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

int main( ) {
  int A, B, C;
  cin >> A >> B >> C;
  vector<int> vec = {A, B, C};
  // sort
  sort(vec.begin(), vec.end(), greater<int>() );
  
  cout << ((vec.at(0)*10 + vec.at(1)) + vec.at(2) ) << endl;
  
}

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

using namespace std;

bool renzoku(int a,int b,int c){
	if(a+1==b && a+2==c){	return true;	}
	else return false;}

bool onazi(int a,int b,int c){
	if(a==b && a==c){	return true;	}
	else return false;}

int main() 
{
	int n;
	cin >> n;
	for(int k=0;k<n;k++)
	{
		
		int in[9]={};
		
		for(int i=0;i<9;i++){	cin >> in[i] ;}
		
		for(int i=0;i<9;i++)
		{
			char t;
			cin >> t;
			if(t=='G')	in[i]+=10;
			else if(t=='B')	in[i]+=20;
		}
		
		sort(in,in+9);
		
		int ans(0);
		do{
			if(
				(renzoku(in[0],in[1],in[2]) || onazi(in[0],in[1],in[2]))
				&&(renzoku(in[3],in[4],in[5]) || onazi(in[3],in[4],in[5]))
				&&(renzoku(in[6],in[7],in[8]) || onazi(in[6],in[7],in[8]))
				)	ans =1;
		}while (next_permutation(in,in+9));
		
		cout << ans << endl;
	}
	return 0 ;
}

Measured memory_bytes: 1180
#include<cstdio>
#include<vector>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
char a[101010];
int main()
{
	int n,i,now;
	scanf("%s",a+1);
	n=strlen(a+1);
	if(a[n]=='1'||a[1]=='0')
	{
		puts("-1");
		return 0;
	}
	for(i=1;i<n;i++)
	{
		if(a[i]!=a[n-i])
		{
			puts("-1");
			return 0;
		}
	}
	now=2;
	printf("1 2\n");
	for(i=2;i<n;i++)
	{
		printf("%d %d\n",now,i+1);
		if(a[i]=='1')
			now=i+1;
	}
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
 	return 0;
}


Measured memory_bytes: 1536