akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;

class Program
{
    static void Main(string[] args)
    {
        int n = int.Parse(Console.ReadLine());
        string[] input = Console.ReadLine().Split(' ');
        int[] l = new int[n];
        
        for (int i = 0; i < n; i++)
        {
            l[i] = int.Parse(input[i]);
        }

        if (n < 3)
        {
            Console.WriteLine(0);
        }
        else
        {
            int r = 0;
            for (int i = 0; i < n; i++)
            {
                for (int j = 0; j < n; j++)
                {
                    for (int k = 0; k < n; k++)
                    {
                        if (j > i && k > j && l[i] + l[j] > l[k] && l[j] + l[k] > l[i] && l[k] + l[i] > l[j] &&
                            l[i] != l[j] && l[j] != l[k] && l[k] != l[i])  
                        {
                            r++;
                        }
                    }
                }
            }
            Console.WriteLine(r);
        }
    }
}

Measured memory_bytes: 17900
#include <iostream>
#include <algorithm>
#include <iomanip>
using namespace std;

int main() {
	int n;
	int a[1000];
	double r = 0;

	cin >> n;

	for(int i = 0; i < n; i++)
		cin >> a[i];

	sort(a, a + n);

	for(int i = 0; i < n - 1; i++){
		double rt;
		if(i < n - 3)
			rt = (double) (a[n - 2] + a[n - 1]) / (double) (a[i + 1] - a[i]);
		else if(i == n - 3)
			rt = (double) (a[n - 4] + a[n - 1]) / (double) (a[i + 1] - a[i]);
		else if(i == n - 2)
			rt = (double) (a[n - 4] + a[n - 3]) / (double) (a[i + 1] - a[i]);

		if(rt > r)
			r = rt;
	}

	cout << setiosflags(ios::fixed | ios::showpoint) << setprecision(6) << r << endl;

	return 0;
}


Measured memory_bytes: 3292
#include<stdio.h>
#include<string.h>
int main(){
	char r[128],m,s;
	int i,k=0;
	scanf("%s",r);
	m='A';
	for(i=0;i<strlen(r);i++){
		s=r[i];
		if(s-m<=0){
			k++;
		}
		m=s;
	}
	printf("%d\n",k);
    return 0;
}

Measured memory_bytes: 2704
using System;
using System.Linq;
using System.Text;

namespace abc126
{
    class Program
    {
        static void Main(string[] args)
        {
            var tmp = Console.ReadLine().Split(' ').Select(s => int.Parse((string) s)).ToArray();
            var ss = Console.ReadLine();

            var n = tmp[0];
            var k = tmp[1];

            var sb = new StringBuilder();
            for (var i = 0; i < ss.Length; i++)
            {
                if (i == k - 1)
                {
                    sb.Append(ss[i].ToString().ToLower());
                }
                else
                {
                    sb.Append(ss[i]);
                }
            }

            Console.WriteLine(sb.ToString());
        }
    }
}


Measured memory_bytes: 13268
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb(x) push_back(x)
#define f(i,st,n) for(i=st;i<n;i++)
#define vec vector
#define mst(a,b) memset(a,b,sizeof(a))
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;  
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define mod 1000000007
#define sfl(x) scanf("%lld",&x)
#define pfl(x) printf("%lld\n",x)
#define pf(x) printf("%lld",x)
#define all(v) v.begin(),v.end()
#define mpr make_pair
#define fs first
#define se second
#define inf LLONG_MAX
#define nnf LLONG_MIN
 
 
 
ll gcd(ll a,ll b){
    if(a==0){
        return b;
    }                     
    return gcd(b%a,a);
}
ll power(ll x,ll y){            
    ll res=1;
    while(y>0){
        if(y%2==1){
            res=((res%mod)*(x%mod))%mod;
        }
        x=((x%mod)*(x%mod))%mod;
        y=y/2;
    }
    return res;
}
 
 struct custom_hash {
  static uint64_t splitmix64(uint64_t x) {
    // http://xorshift.di.unimi.it/splitmix64.c
    x += 0x9e3779b97f4a7c15;
    x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
    x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
    return x ^ (x >> 31);
  }

  size_t operator()(pair<uint64_t,uint64_t> x) const {
    static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
    return splitmix64(x.first + FIXED_RANDOM)^(splitmix64(x.second + FIXED_RANDOM) >> 1);
  }
};

void get_time(auto start,auto end){
    double time_taken =  
      chrono::duration_cast<chrono::nanoseconds>(end - start).count(); 
  
    time_taken *= 1e-9;
    cout<<"\n";
    cout<<"Time taken : "<<fixed<<time_taken<<setprecision(6);
}




int main(){

   ios_base::sync_with_stdio(false);
   cin.tie(NULL);

  auto start = chrono::high_resolution_clock::now();

  
 

/* #ifndef ONLINE_JUDGE
    
   freopen("input.txt", "r", stdin);
   
   freopen("output.txt", "w", stdout);
   #endif*/

    ll n,k,i;
    cin>>n>>k;
    ll a[n];
    

    f(i,0,n){
      cin>>a[i];
      
    }

    sort(a,a+n);

    //for(i=0;i<n;i++)cout<<a[i]<<"\n";

    ll l=1,r=a[n-1],ans=a[n-1];

    while(l<=r){

      ll mid=(l+r)/2;

      //cout<<mid<<"\n";

      ll op=0;

      for(i=0;i<n;i++){

        if(a[i]<=mid)continue;
        
        op+=(a[i]/mid);


      }

      if(op<=k){
        ans=mid;
        r=mid-1;
      }
      else l=mid+1;
    }


    cout<<ans;



  auto end = chrono::high_resolution_clock::now();

 /* #ifndef ONLINE_JUDGE

   get_time(start,end); 

  #endif*/

    return 0;
 }

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

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define ALL(v) (v.begin(),v.end())
#define COUT(x) cout<<(x)<<"\n"

int main(){
    int n;
    cin >> n;
    int max1 = 1;
    for(int i=2;i<sqrt(n)+1;i++){
        int num = i;
        while(num<=n){
            if(num>max1)max1 = num;
            num *= i;
        }
    }
    COUT(max1);
    return 0;
}

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

class Program
{
    static void Main(string[] args)
    {
        var inputs = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
        var n = inputs[0];
        var m = inputs[1];

        var result = nCk(n,2) + nCk(m,2);

        Console.WriteLine(result);
    }

    public static long nCk(long n, long k)
    {
        if (n < k) return 0;
        if (n == k) return 1;

        long x = 1;
        for (long i = 0; i < k; i++)
        {
            x = x * (n - i) / (i + 1);
        }
        return x;
    }
}

Measured memory_bytes: 13396
#include<iostream>

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(ll i=ll(a);i<=ll(b);++i)
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)

using namespace std;
using ll = long long;

int main()
{
   
    ll a,b,n;
    cin >> a >> b >> n;

    ll max = 0;
    ll x = (n >= b) ? b-1 : n;
    max = ((a*x)/b) - a*(x/b);
//     repi(x,1,b-1){
// //        if((a*x)%b != 0) continue;
//         ll t =((a * x)/b) - (a * (x/b));
//         printf("t:%d\n",t);
//         if(t > max){
//             max = t;
//         }
//     }

    
    cout << max << endl;
    return 0;
}


Measured memory_bytes: 3636
#include<iostream>
#include<string.h>
using namespace std;

int main()
{
    int n;
    long long y; 
    cin >> n >> y;
    int m1000 = -1, m5000 = -1, m10000 = -1;
    int k = 0;

    for (int i=0; i<=n; i++)
    {
        for (int j=0; j<=n-i; j++)
        {
            k = n - i - j;
            if( y == i*10000 + j*5000 + k*1000)
            {
                m10000 = i;
                m5000 = j;
                m1000 = k;
                break;
            }
        }
    }

    cout << m10000 << " " << m5000 << " " << m1000 << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define TRACE(x) x
#define WATCH(x) TRACE( cout << #x" = " << x << endl)
#define PRINT(x) TRACE(printf(x))
#define WATCHR(a, b) TRACE( for(auto c = a; c != b;) cout << *(c++) << " "; cout << endl)
#define WATCHC(V) TRACE({cout << #V" = "; WATCHR(V.begin(), V.end()); } )
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define fi first
#define se second 

using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using ld = long double;
using pll = pair<ll, ll>;

void buff() { ios::sync_with_stdio( false ); cin.tie( nullptr ); }

constexpr ll MOD = 1e9 + 7;

inline ll pow_mod( ll a, ll b, ll mod = MOD) {
    ll res = 1; a %= mod; assert(b >= 0);
    for(;b;b>>=1) {
        if(b&1) res = (res * a) % mod;
        a = (a * a) % mod;
    }
    return res;
}

constexpr int ms = 2e5 + 13;

// End of template code!
int main() 
{
    buff();
    ll n, k;
    cin >> n >> k;
    vector< pair<ll, ll> > cover;
    ll ans = 0ll;
    ll small = 0;
    ll large = 0;
    for(int i = 0; i < n + 1; ++i) {
        small += (i + 1);
        large += (n + 1 - i);
        if(i + 1 >= k) ans = (ans + (large - small + 1) ) % MOD;
    }
    cout << ans << '\n';
    // (1, n + 1) -> (3, 2n + 1) -> (6, 3n) -> (10, 4n - 1) 
    return 0;
}



Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
#define rep(i, n) for(ll i = 0;i < n;i++)
#define all(i) i.begin(), i.end()
template<class T, class U> bool cmax(T& a, U b) { if (a<b) {a = b; return true;} else return false; }
template<class T, class U> bool cmin(T& a, U b) { if (a>b) {a = b; return true;} else return false; }

template<class T>
struct CumulativeSum {
  vector<T> v;

  CumulativeSum(size_t n) : v(n+1) {};
  CumulativeSum(vector<T> v_) {
    v.resize(v_.size()+1);
    for (size_t i = 0; i < v_.size(); i++) v[i+1] = v_[i];
  };

  void add(size_t i, T x) {
    v[i+1] += x;
  }

  // O(N)
  void build() {
    for (size_t i = 0; i < v.size()-1; i++)
      v[i+1] += v[i];
  }

  // O(1) sum [l, r]
  T sum(size_t l, size_t r) const {
    return l == 0 ? v[r+1] : v[r+1]-v[l];
  }

  // O(1) sum [0, r]
  T sum(size_t r) const {
    return v[r+1];
  }

  T& operator[](size_t i) {
    return v[i];
  }

  const T& operator[](size_t i) const {
    return v[i];
  }
};

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

  ll n, m;
  cin >> n >> m;
  vl a(n);
  rep(i, n) {
    cin >> a[i];
  }

  sort(all(a));
  CumulativeSum<ll> cs(a);
  cs.build();

  auto f = [&](ll x) {
    ll cnt = 0;
    ll sum = 0;
    rep(i, n) {
      ll ind = lower_bound(all(a), x-a[i]) - a.begin();
      cnt += n-ind;
      sum += cs.sum(ind, n-1);
      sum += a[i]*(n-ind);
    }
    return make_pair(cnt, sum);
  };

  ll ok = 0;
  ll ng = 1'000'000'000'000LL;
  while (ng-ok > 1) {
    ll mid = (ok+ng)/2;
    if (f(mid).first >= m) ok = mid;
    else ng = mid;
  }

  auto tmp = f(ok);
  ll ans = tmp.second;
  ans -= (tmp.first-m)*ok;
  cout << ans << endl;
}


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

int main(){
  string S; cin >> S;
  for(int i=0; i<3; i++){
    if(S.at(i)=='7'){
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
}

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

main(){
  long K,A,B;
  cin >> K >> A >> B;
  long ans=1;
  if((B-A)/2>1&&A-1<K){
    ans+=(B-A)*((int)(K-(A-1))/2)+A-1;
    if((K-(A-1))%2!=0)ans++;
  }
  else ans+=K;
  cout << ans << endl;
  //  cout << K-(A-1)%2 << endl;
}
  

/*main(){
  long K,A,B;
  long ans=0;
  if((B-A)/2>1){
    if(K%2==0)ans=(B-A)/2*K;
    else ans=(B-A)*(K/2)+1;
  }
  else ans=K;
  }*/


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
#define ep emplace_back
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(v) v.begin(), v.end()
#define revall(v) v.rbegin(), v.rend()
constexpr int mod=1000000007;
constexpr int mod1=998244353;
vector<int> dx={0,1,0,-1},dy={-1,0,1,0};
bool inside(int y,int x,int h,int w){ if(y<h && y>=0 && x<w && x>=0) return true; return false; }
template<class T> inline bool chmin(T& a, T b){ if(a > b){ a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b){ if(a < b){ a = b; return true; } return false; }





int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n,z,w;cin >> n >> z >> w;
	vector<int> a(n);
	rep(i,n) cin >> a.at(i);
	if(n == 1){
		cout << abs(a.at(0) - w) << endl;
		return 0;
	}
	int ans = max(abs(a.at(n - 1) - w), abs(a.at(n - 2) - a.at(n - 1)));
	cout << ans << endl;
}


Measured memory_bytes: 256
// #include {{{
#include <iostream>
#include <cassert>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <ctime>
#include <queue>
#include <set>
#include <map>
#include <stack>
#include <string>
#include <bitset>
#include <vector>
#include <complex>
#include <algorithm>
using namespace std;
// }}}
// #define {{{
typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define de(x) cout << #x << "=" << x << endl
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define per(i,a,b) for(int i=(b)-1;i>=(a);--i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
// }}}

int H , W , d;

int main(){
    cin >> H >> W >> d;
    rep(i,0,H){
        rep(j,0,W) putchar("RYGB"[(((i+j)/d)&1)<<1|(((i-j+W)/d)&1)]);
        puts("");
    }
    return 0;
}


Measured memory_bytes: 512
# include <iostream>
# include <algorithm>
#include <array>
# include <cassert>
#include <cctype>
#include <climits>
#include <numeric>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <tuple>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
# include <chrono>
# include <random>
# include <limits.h>
# include <unordered_map>
# include <unordered_set>
# include <deque>
# include <cstdio>
# include <cstring>
#include <stdio.h>
#include<time.h>
#include <stdlib.h>
#include <cstdint>
#include <cfenv>
#include<fstream>
//#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
long long MOD = 1000000000 + 7;// ;//1000000000 + 7 998244353 924844033 1000000000 + 9;
constexpr long long INF = numeric_limits<LL>::max() / 100;
constexpr long long DINF = 1000000000000;
const double PI = acos(-1);
#define fir first
#define sec second
#define thi third
#define debug(x) cerr<<#x<<": "<<x<<'\n'
typedef pair<LL, LL> Pll;
typedef pair<double, double> Dll;
typedef pair<LL, pair<LL, LL>> Ppll;
typedef pair<LL, pair<LL, bitset<100001>>> Pbll;
typedef pair<LL, pair<LL, vector<LL>>> Pvll;
typedef pair<LL, LL> Vec2;
struct Tll { LL first, second, third; };
struct Fll { LL first, second, third, fourth; };
typedef pair<LL, Tll> Ptll;
#define rep(i,rept) for(LL i=0;i<rept;i++)
#define Rrep(i,mf) for(LL i=mf-1;i>=0;i--)
void YN(bool f) {
	if (f)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
}
void yn(bool f) {
	if (f)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}
struct Edge { LL to, cost; };
struct edge {
	LL from, to, cost;
};
vector<vector<LL>>g;
vector<edge>ed;
vector<Pll>pv;
map<LL, LL>ma;
set<LL>st;
vector<LL>rest;
int di[4][2] = { { 0,1 },{ 1,0 },{ 0,-1 },{ -1,0 } };
LL n, m, k, p, q, w, h, s, t, ans, cnt, sum, a[310000], b[310000];
string str;
bool f;
char c[1100][1100];
int main() {
	cin >> n;
	h = n / 1000000000 + (n % 1000000000 == 0 ? 0 : 1);
	cout << "0 0 " << h << " " << 1 << " " << h * 1000000000 - n << " " << 1000000000 << endl;
	return 0;
}
//|x1y0-x0y1|

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = (int)(n); i >= 0; i--)
#define REP(i, m, n) for (int i = (int)(m); i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
typedef long long ll;

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; }

const long long INF = 1LL << 60;

int main(){
  int n, k;
  cin >> n >> k;
  vector<int> p(n);
  rep(i, n) cin >> p[i];
  sort(all(p));

  int sum = 0;
  rep(i, k){
    sum += p[i];
  }

  cout << sum << endl;

  return 0;
}


Measured memory_bytes: 3632
import java.util.Scanner;

class Main
{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		
		long[][] a = new long[100][100];
		long[][] b = new long[100][100];
		long[][] c = new long[100][100];
		
		int n = scan.nextInt();
		int m = scan.nextInt();
		int l = scan.nextInt();
		
		for(int i=0; i<n; i++){
		for(int j=0; j<l; j++){
			c[i][j] = 0;}}
		
		for(int i=0; i<n; i++){
		for(int k=0; k<m; k++){
			a[i][k] = scan.nextLong();}}
		
		for(int k=0; k<m; k++){
		for(int j=0; j<l; j++){
			b[k][j] = scan.nextLong();}}
			
		for(int i=0; i<n; i++){
		for(int j=0; j<l; j++){
		for(int k=0; k<m; k++){
			c[i][j] += a[i][k] * b[k][j];}}}
			
		for(int i=0; i<n; i++){
		for(int j=0; j<l; j++){
			System.out.print(c[i][j]);
			if(j!=l-1){
				System.out.print(" ");}}
			System.out.print("\n");}
	}
}


Measured memory_bytes: 57508
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <stdio.h>
using namespace std;

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

	int S1 = S / 100; //上二けた
	int S2 = S % 100; //下二けた

	if (0 < S1 && S1 <= 12 && 0 < S2 && S2 <= 12) {
		cout << "AMBIGUOUS" << endl;
	} 
	else if (0 <= S1 && S1 <= 99 && 0 < S2 && S2 <= 12) {
		cout << "YYMM" << endl;
	}
	else if (0 < S1 && S1 <= 12 && 0 <= S2 && S2 <= 99) {
		cout << "MMYY" << endl;
	}
	else {
		cout << "NA" << endl;
	}
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <cstring>
#include <numeric>
#include <algorithm>
#include <functional>
#include <array>
#include <map>
#include <queue>
#include <limits.h>
#include <set>
#include <stack>
#include <random>
#include <time.h>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#define rep(i,s,n) for(int i = (s); (n) > i; i++)
#define REP(i,n) rep(i,0,n)
#define RANGE(x,a,b) ((a) <= (x) && (x) <= (b))
#define DUPLE(a,b,c,d) (RANGE(a,c,d) || RANGE(b,c,d) || RANGE(c,a,b) || RANGE(d,a,b))
#define INCLU(a,b,c,d) (RANGE(a,c,d) && (b,c,d))
#define PW(x) ((x)*(x))
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MODU 1000000007
#define bitcheck(a,b)   ((a >> b) & 1)
#define bitset(a,b)      ( a |= (1 << b))
#define bitunset(a,b)    (a &= ~(1 << b))
#define MP(a,b) make_pair((a),(b))
#define Manh(a,b) (abs((a).first-(b).first) + abs((a).second - ((b).second))
#define pritnf printf
#define scnaf scanf
#define itn int
#define PI 3.141592653589
#define Graph vector<vector<int>>

#define izryt bool

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T &val) {
	std::fill((T*)array, (T*)(array + N), val);
}

struct UnionFind {
	vector<int> data;
	UnionFind(int size) : data(size, -1) { }
	bool unionSet(int x, int y) { //ｘの入ってる集合と yの入ってる集合を併合
		x = root(x); y = root(y);
		if (x != y) {
			if (data[y] < data[x]) swap(x, y);
			data[x] += data[y]; data[y] = x;
		}
		return x != y;
	}
	bool findSet(int x, int y) { //xとyが同じ集合に入っているかどうかを判定
		return root(x) == root(y);
	}
	int root(int x) {
		return data[x] < 0 ? x : data[x] = root(data[x]);
	}
	bool isroot(int x) {
		return data[x] < 0;
	}
	int size(int x) {
		return -data[root(x)];
	}
};
signed main() {
	int n, k, l;
	scanf("%d %d %d", &n, &k, &l);
	UnionFind road(n), train(n);

	REP(i, k) {
		int a, b;
		scanf("%d %d", &a, &b);
		road.unionSet(--a, --b);
	}

	REP(i, l) {
		int a, b;
		scanf("%d %d", &a, &b);
		train.unionSet(--a, --b);
	}


	map<pii, int> cou;
	REP(i, n)
		cou[{road.root(i), train.root(i)}]++;

	REP(i, n) {
		printf("%d\n", cou[{road.root(i), train.root(i)}]);
	}
	return 0;
}

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

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

    vector< int > zl(26, 1e9);
    
    int n;
    cin >> n;
    while (n--)
    {
        string s; cin >> s;
        vector< int > lz(26);
        for (char c : s)
            ++lz[c - 'a'];
        for (int i = 0; i < 26; ++i)
            zl[i] = min(zl[i], lz[i]);
    }

    for (int i = 0; i < 26; ++i)
        while (zl[i]--)
            cout << (char)(i + 'a');
    cout << '\n';
}

Measured memory_bytes: 256
#include <iostream>
#include <array>
#include <algorithm>
#include <vector>
#include <set>
#include <cmath>
#include <complex>
#include <deque>
#include <iterator>
#include <numeric>
#include <map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
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;}

const ll MOD = 1000000007;
const ll HIGHINF = (ll)1e18;

ll n;
string s;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n;
  cin >> s;
  vll lr(2*n); // 0: White, 1: Black
  ll lc=0;
  REP(i, s.size()) {
    if (i%2==0) {
      if (s[i]=='W') {
        lr[i]=1;
      } else{
        lr[i]=0; lc++;
      }
    } else {
      if (s[i]=='B') {
        lr[i]=1;
      } else {
        lr[i]=0; lc++;
      }
    }
  }
  if (s[0]=='W'||s[2*n-1]=='W'||lc!=n) {cout << 0 << '\n'; return 0;}
  ll ans = 1;
  lc = 0;
  REP(i, lr.size()) {
    if (lr[i]==0) lc++;
    else ans = ans*(lc--)%MOD;
  }
  rep(i, 1, n+1) ans = ans*i%MOD;
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 2196
#include <cstdio>
#include <cstdint>
#include <iostream>
#include <iomanip>
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <utility>
#include <functional>
#include <cmath>
#include <climits>
#include <bitset>

#define ll long long int
#define pb push_back
#define mk make_pair
#define pq priority_queue

using namespace std;
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
const int inf = 1e9;
const ll linf = 1LL << 50;
const double EPS = 1e-10;

int main(int argc, char const* argv[])
{
  ll n;
  cin >> n;
  vector<ll> a;
  ll sum = 0;
  for(int i = 0; i < n; i++){
    ll x;
    cin >> x;
    a.pb(x);
    sum += x;
  }
  if(sum % ((ll)n * (n + 1) / 2) != 0){
    cout << "NO" << endl;
    return 0;
  }
  ll k = sum / ((ll)n * (n + 1) / 2);
  a.pb(a[0]);
  for(int i = 0; i < n; i++){
    if(((ll)(n - 1) * k + a[i + 1] - a[i]) % (ll)n != 0 || ((ll)(n - 1) * k + a[i + 1] - a[i]) < 0){
      cout << "NO" << endl;
      return 0;
    }
    ll l = ((n - 1) * k + a[i + 1] - a[i]) / n;
    if(a[i] < l + n * (k - l) || a[i + 1] < k - l + 2 * l){
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
	return 0;
}


Measured memory_bytes: 1400
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){return o<<"("<<p.fs<<","<<p.sc<<")";}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){o<<"sz = "<<vc.size()<<endl<<"[";for(const T& v:vc) o<<v<<",";o<<"]";return o;}
typedef long long ll;
int N;
ll X,Y;
ll a[2000];
ll last;
ll T;
bool memo[2010][2];
bool vis[2010][2];
bool Xwin(int y,bool xturn){
	if(y>=0 && vis[y][xturn]) return memo[y][xturn];
	vis[y][xturn] = 1;

	if(xturn){
		for(int nx = y+1;nx<N-1;nx++){
			if(abs(a[nx]-last) < T) continue;
			if(Xwin(nx,0)) return memo[y][xturn] = 1;
		}
		return memo[y][xturn] = 0;
	}else{
		for(int nx = y+1;nx<N-1;nx++){
			if(abs(a[nx]-last) >= T) continue;
			if(!Xwin(nx,1)) return memo[y][xturn] = 0;
		}
		return memo[y][xturn] = 1;
	}
}
bool can(ll t){
	rep(i,2010) rep(j,2) vis[i][j] = 0;
	T = t;
	if(abs(Y-last)>=t) return 1;
	return Xwin(0,-1);
}
int main(){
	cin>>N>>X>>Y;
	rep(i,N) cin>>a[i];
	last = a[N-1];
	ll ub = 1e9, lb = 0;
	while(ub-lb>1){
		ll m = (ub+lb)/2;
		if(can(m)) lb = m;
		else ub = m;
	}
	cout<<lb<<endl;
}


Measured memory_bytes: 256
def ok(last4):
    ret = True
    if last4 in ["ATGC","AGGC","AGTC"]:
        ret = False
    elif True in [s in last4 for s in ["AGC","ACG","GAC"]]:
        ret = False
    return ret
N = int(input())
mod = 10**9+7
memo = [{} for i in range(N+1)]

def dfs(current, last3):
    if last3 in memo[current]:
        return memo[current][last3]
    if current == N:
        return 1
    ret = 0
    for c in "ATGC":
        if ok(last3+c):
            ret += dfs(current+1, last3[1:]+c)
            ret %= mod
    memo[current][last3] = ret
    return ret

print(dfs(0, "TTT"))

Measured memory_bytes: 3796
#include<bits/stdc++.h>
#include<atcoder/all>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; using namespace atcoder;
void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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; }
//---------------------------------------------------------------------------------------------------
struct UnionFind {
	using T = int;
	const T def = 0;
	T f(T a, T b) { return a + b; }
	//==========================================
    vector<int> par; 
	vector<T> value;
    UnionFind() {}
    UnionFind(int NV) { init(NV); }
	void init(int NV) { par.clear(); rep(i, 0, NV) par.push_back(i); value.resize(NV, 1); }
    void reset() { rep(i, 0, par.size()) par[i] = i; }
	int operator[](int x) {
		if (par[x] == x) return x;
		else {
			int res = operator[](par[x]);
			if (res != par[x]) {
				value[res] = f(value[res], value[par[x]]);
				value[par[x]] = def;
			}
			return par[x] = res;
		}
	}
	// uf(x,y)->y
    void operator()(int x, int y) {
		x = operator[](x); y = operator[](y); 
		if (x != y) {
			value[y] += value[par[x]];
			value[par[x]] = def;
			par[x] = y;
		}
	}
	T getValues(int x) { return value[operator[](x)]; };
};
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     @hamayanhamayan0
　　　　／　　　＼　 　  |　|
　　　 /　　 /￣￣￣￣/　　|
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿
　 　　　＼/＿＿＿＿/　（u　⊃
---------------------------------------------------------------------------------------------------*/














int N;
vector<tuple<int, int, int>> points;
//---------------------------------------------------------------------------------------------------
void _main() {
	cin >> N;
	rep(i, 0, N) {
		int x, y; cin >> x >> y;
		points.push_back(make_tuple( x, y, i ));
	}
	sort(all(points));

	set<pair<int, int>> rest;
	UnionFind uf(N);
	rep(i, 0, N) {
		int x, y, id;
		tie(x, y, id) = points[i];
		while (0 < rest.size()) {
			auto ite = rest.lower_bound({ y, -1 });
			if (ite != rest.begin()) {
				ite--;
				uf(ite->second, id);
				y = ite->first;
				rest.erase(ite);
			}
			else {
				break;
			}
		}
		rest.insert({ y, id });
	}

	rep(i, 0, N) printf("%d\n", uf.getValues(i));
}







Measured memory_bytes: 11968
#include <iostream>

using namespace std;

struct Dice {
  int values[6];

  int top;
  int bottom;
  int front;
  int back;
  int left;
  int right;

  void Init() {
    top = 1;
    bottom = 6;
    front = 2;
    back = 5;
    left = 4;
    right = 3;
  }

  int Value() const {
    return values[top - 1];
  }

  void Next(char d) {
    int temp = 0;
    switch (d) {
      case 'S':
        temp = front;
        front = top;
        top = back;
        back = bottom;
        bottom = temp;
        break;
      case 'N':
        temp = back;
        back = top;
        top = front;
        front = bottom;
        bottom = temp;
        break;
      case 'E':
        temp = right;
        right = top;
        top = left;
        left = bottom;
        bottom = temp;
        break;
      case 'W':
        temp = left;
        left = top;
        top = right;
        right = bottom;
        bottom = temp;
        break;
    }
  }
};

int main() {
  Dice dice;
  dice.Init();
  for (int i = 0; i < 6; ++i) {
    cin >> dice.values[i];
  }
  string ops;
  cin >> ops;
  for (size_t i = 0; i < ops.size(); ++i) {
    dice.Next(ops[i]);
  }

  cout << dice.Value() << endl;
  return 0;
}

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

const int mod = 1e9+7;
int A[100105],B[100105];

int main(){
	int n,a=0,b=0,cnt=0,cnt2=0;
	long long ans = 1;
	cin >> n;
	for(int i=0;i<n;i++) cin >> A[i];
	for(int i=0;i<n;i++) cin >> B[i];
	sort(A,A+n);
	sort(B,B+n);
	
	for(int i=0;i<2*n;i++){
		if(a<n && (b==n || A[a]<B[b]) ){
			if(cnt2 > 0){
				ans = ans*cnt2%mod;
				cnt2--;
			}
			else
				cnt++;
			a++;
		}
		else{
			if(cnt > 0){
				ans = ans * cnt%mod;
				cnt--;
			}
			else
				cnt2++;
			b++;
		}
	}
	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1024
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <climits>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <string>
#include <sstream>
#include <vector>
#include <map>
#include <set>
#include <complex>
#include <functional>
#include <utility>
#include <iterator>

#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, m, n) for(int i = (m); i < (int)(n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define INF 2000000000

#ifdef LOCAL
  #define dprintf(...) fprintf(stdout, __VA_ARGS__)
#else
  #define dprintf(...) 0
#endif

using namespace std;

int main() {
  vector<int> v(3);
  REP(i, 3) {
    cin >> v[i];
  }
  sort(ALL(v));
  cout << v[0] + v[1] << '\n';

  return 0;
}


Measured memory_bytes: 256
const val mod = 1000000007

fun main() {
	val (n,k) = readLine()!!.split(" ").map {it.toInt()}
	val a = LongArray(n+1) {it.toLong()}
	for(i in 1..n)
		a[i] = (a[i]+a[i-1])%mod

	(k-1..n).map {
		(a[n]-a.elementAtOrElse(n-1-it) {0}-a[it]+1+mod*2)%mod
	}.fold(0L) {a,b-> (a+b)%mod}
			.let {println(it)}
}


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


public class Main {

	/**
	 * @param args
	 * @throws IOException 
	 */
	public static void main(String[] args) throws IOException {
		// TODO Auto-generated method stub
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        
		String[] str = br.readLine().split(" ");
		
		int a = Integer.parseInt(str[0]);
		int b = Integer.parseInt(str[1]);
		int c = Integer.parseInt(str[2]);
		int d = Integer.parseInt(str[3]);
		int e = Integer.parseInt(str[4]);
		int f = Integer.parseInt(str[5]);
		
		double maxDensity = 0;
		int swMax = 0;
		int sugarMax = 0;
		for(int i = 0; 100*i*a <= f; i++){
			for(int j = 0; 100*(i*a+j*b) <= f; j++){
				int water = 100*(i*a+j*b);
				int sugarLimit = (i*a+j*b)*e;
				
				for(int k = 0; k*c <= sugarLimit && water + k*c <= f; k++){
					for(int l = 0; k*c + l*d <= sugarLimit && water + k*c + l*d <= f; l++){
						//System.out.println("LOOP");
						
						int sugar = k*c + l*d;
						double tmpDens = (double)sugar/(sugar+water);
						
						if(tmpDens > maxDensity){
							maxDensity = tmpDens;
							swMax = sugar+water;
							sugarMax = sugar;
						}
					}
				}
			}
		}
		
		if(sugarMax == 0){
			System.out.println(100*a + " " + sugarMax);
		}
		else {
			System.out.println(swMax + " " + sugarMax);
		}
	}

}


Measured memory_bytes: 21204
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1e9;
const int MOD = 1000000007;
const double PI = acos(-1);
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};

void solve() {
	int k, t;
	cin >> k >> t;
	vector<int> v(t);
	rep(i,t) cin >> v[i];
	int mx = 0;
	rep(i,t) {
		mx = max(mx, v[i]);
	}
	int sum = k - mx;
	if (mx - 1 <= sum) {
		cout << 0 << endl;
	} else {
		cout << mx - sum - 1 << endl;
	}
}

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

Measured memory_bytes: 3560
#include <stdio.h>

int main(void)
{
 int T,X;
 double t;

 scanf("%d%d",&T,&X);
 if((1 <= T <= 100) && (1 <= X <= 100))
 t =(double) T / (double)X ;

 printf("%14.10lf\n", t);
 return 0;
}


Measured memory_bytes: 128
// ConsoleApplication9.cpp : アプリケーションのエントリ ポイントを定義します。
//


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

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


using namespace std;


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




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

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

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

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

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

	return ans;
}


const int MOD = 1000000007;

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

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


bool prime(ll n) {
	if (n == 1)return false;
	if (n == 2)return true;
	for (int i = 2; i < (int)sqrt(n) + 1; i++) {
		if (n%i == 0)return false;
	}
	return true;
}

vector<ll>v;
void func(int n,ll x) {
	if (n < 10) {
		v.pb(x);
		func(n + 1, 10 * x + 3);
		func(n + 1, 10 * x + 5);
		func(n + 1, 10 * x + 7);
	}
}
bool found[10];
bool judge(ll N,ll x) {
	if (x > N)return false;
	found[3] = false, found[5] = false, found[7] = false;
	while (x > 0) {
		int k = x % 10;
		found[k] = true;
		x /= 10;
	}
	if (found[3] && found[5] && found[7])return true;
	return false;
}

int main() {
	ll N; cin >> N;
	ll ans = 0;
	func(1, 3); func(1, 5); func(1, 7);
	//for (auto x : v)p(x);
	for (auto x : v) {
		if (judge(N, x))ans++;
	}
	p(ans);
}



Measured memory_bytes: 640
#include <bits/stdc++.h>
#define ll long long int
#define N 1000
#define M 1000000007
#define f(i, a, b) for (ll i = (ll)a; i <= (ll)b; i++)
#define rf(i, a, b) for (ll i = (ll)a; i >= (ll)b; i--)
#define po pop_back
#define pb push_back
#define lb lower_bound
#define fi first
#define se second
#define mp make_pair
#define bs binary_search
#define debug(x) cout << #x << " = " << x << endl
#define ub upper_bound
#define ibs ios_base::sync_with_stdio(false)
#define cti cin.tie(0)
#define all(x) x.begin(), x.end()
#define PI 3.14159265
#define cot cout.tie(0)
using namespace std;
/**
  * @author :: Rishabh
  *
  */
int main()
{
	ibs;
	cti;
	int n,m;
	cin>>n>>m;
	int dp[n][m];
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<m;j++)
		{
			char c;
			cin>>c;
			if(c=='.')
			dp[i][j]=0;
			else
			dp[i][j]=-1;
		}
	}
	for(int i=0;i<m;i++)
	{
		if(dp[0][i]==0)
		dp[0][i]=1;
		else if(dp[0][i]==(-1))
		{
			dp[0][i]=0;
			break;
		}
	}
	for(int i=0;i<n;i++)
	{
		if(dp[i][0]==0)
		dp[i][0]=1;
		else if(dp[i][0]==(-1))
		{
			dp[i][0]=0;
			break;
		}
	}
	for(int i=1;i<n;i++)
	{
		for(int j=1;j<m;j++)
		{
			if(dp[i][j]==-1)
			dp[i][j]=0;
			else
			{
				if(dp[i-1][j]==(-1))
				dp[i-1][j]=0;
				else if(dp[i][j-1]==(-1))
				dp[i][j-1]=0;
				dp[i][j]=(dp[i-1][j]%M+dp[i][j-1]%M)%M;
			}
		}
	}
	cout<<dp[n-1][m-1]%M<<"\n";
	return 0;
}

Measured memory_bytes: 4224
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<functional>
using namespace std;
int n,m,c,s,g,A,B,C,D,z[22][22000],r1[22][60],r2[22][60],r0[22],dp[102];
vector<pair<int,int>>X[22][102];
int dist[22][102][102],dist2[102][102];
priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> Q;
void dijkstra(int s1,int s2){
	for(int i=0;i<102;i++)dist[s1][s2][i%102]=1<<30;
	dist[s1][s2][s2]=0;Q.push(make_pair(0,s2));
	while(!Q.empty()){
		int a1=Q.top().first,a2=Q.top().second;Q.pop();
		for(int i=0;i<X[s1][a2].size();i++){
			int to=X[s1][a2][i].first;
			if(dist[s1][s2][to]>a1+X[s1][a2][i].second){
				dist[s1][s2][to]=a1+X[s1][a2][i].second;
				Q.push(make_pair(dist[s1][s2][to],to));
			}
		}
	}
}
int main(){
	while(true){
		for(int i=0;i<2244;i++)X[i/102][i%102].clear();
		for(int i=0;i<10404;i++)dist2[i/102][i%102]=1<<30;
		cin>>n>>m>>c>>s>>g;if(n==0)break;
		for(int i=0;i<m;i++){
			cin>>A>>B>>C>>D;
			X[D][A].push_back(make_pair(B,C));
			X[D][B].push_back(make_pair(A,C));
		}
		for(int i=1;i<=c;i++)cin>>r0[i];
		for(int i=1;i<=c;i++){
			for(int j=1;j<r0[i];j++)cin>>r1[i][j];
			for(int j=0;j<r0[i];j++)cin>>r2[i][j];
			int C=0;
			for(int j=0;j<22000;j++){
				z[i][j]=z[i][r1[i][C]]+(j-r1[i][C])*r2[i][C];
				if(C!=r0[i]-1 && r1[i][C+1]<=j)C++;
			}
		}
		for(int i=1;i<=c;i++){
			for(int j=1;j<=n;j++)dijkstra(i,j);
		}
		for(int i=1;i<=c;i++){
			for(int j=1;j<=n;j++){
				for(int k=1;k<=n;k++){
					if(dist[i][j][k]>=22000)continue;
					dist2[j][k]=min(dist2[j][k],z[i][dist[i][j][k]]);
				}
			}
		}
		for(int i=0;i<102;i++){dp[i]=1000000000;}dp[s]=0;
		for(int i=0;i<n;i++){
			for(int j=1;j<=n;j++){
				for(int k=1;k<=n;k++){
					dp[k]=min(dp[k],dp[j]+dist2[j][k]);
				}
			}
		}
		if(dp[g]>=1000000000)dp[g]=-1;
		cout<<dp[g]<<endl;
	}
	return 0;
}

Measured memory_bytes: 6060
a = int(input())
b = int(input())
c = int(input())
x = int(input())

ans = 0
for ia in range(0, min((x//500)+1,a+1)):
    y = x-500*ia
    for ib in range(0, min((y//100)+1, b+1)):
        z = y-100*ib
        if z%50 == 0 and z//50 <= c:
            ans += 1

print(ans)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(), a.end()
#define maxs(x, y) (x = max(x, y))
#define mins(x, y) (x = min(x, y))
#define pb push_back
#define sz(x) (int)(x).size()
#define PQ(T) priority_queue<T, v(T), greater<T>>
#define bn(x) ((1 << x) - 1)
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int mod = 1000000007;

int main(){
    int x, y, z;
    cin >> x >> y >> z;

    cout << z << " " << x << " " << y;


    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <cmath>
using namespace std;

#define FOR(i,s,e) for (int i = int(s); i < int(e); i++)
#define FORIT(i,c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); i++)
#define ISEQ(c) (c).begin(), (c).end()

int main(){
	int GROUP[] = {-1,0,2,0,1,0,1,0,0,1,0,1,0};
	int x,y;
	cin >> x >> y;

	string ret = "";
	if (GROUP[x] == GROUP[y]) ret = "Yes";
	else ret = "No";

	cout << ret << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define FOR(i, N) for (long i = 0; i < (N); i++)

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

    if (N % 1000 == 0) {
        cout << 0 << endl;
    } else {
        cout << 1000 - (N % 1000) << endl;
    }

    return 0;
}


Measured memory_bytes: 3660
import java.util.*;
import static java.lang.Math.*;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		
		// 入力
		int n = sc.nextInt();
		long[] sum = new long[n+1];
		for(int i = 0; i < n; i++){
		    long a = sc.nextLong();
		    if(i == 0){
		        sum[i+1] = a;
		    }else{
		        sum[i+1] = sum[i] + a;
		    }
		}
		
		// 計算
		long result = 0;
		long cnt = 0;
		long plus = 0;
		sum[0] = -1;
		for(int i = 0; i < n; i++){
		    long prev = sum[i] + plus;
		    long now = sum[i+1] + plus;
		    if(Long.signum(prev)*Long.signum(now) == -1) continue;
		    cnt += abs(now) + 1;
		    plus += (abs(now) + 1)*Long.signum(prev)*(-1);
		}
		result = cnt;
		cnt = 0;
		plus = 0;
		sum[0] = 1;
		for(int i = 0; i < n; i++){
		    long prev = sum[i] + plus;
		    long now = sum[i+1] + plus;
		    if(Long.signum(prev)*Long.signum(now) == -1) continue;
		    cnt += abs(now) + 1;
		    plus += (abs(now) + 1)*Long.signum(prev)*(-1);
		}
		result = min(result, cnt);
		
		// 出力
		System.out.println(result);
	}
}



Measured memory_bytes: 57996
// Karm Kar, Phal Ki Chinta na Kar:)
#include <iostream>
#include <bits/stdc++.h>
#include <fstream>
using namespace std;
typedef long long int ll;
#define MOD 1000000007
int main()
{
    ll n,i,j;
    cin>>n;
    ll A[n];
    for(i=0;i<n;i++)
    {
        cin>>A[i];
    }
    ll ans=0;
    sort(A,A+n);
    for(i=0;i<n;i++)
    {
        for(j=i+1;j<n;j++)
        {
            ll lo=j+1,hi=n-1;
            ll res=-1,tar=A[i]+A[j];
            while(lo<=hi)
            {
                ll  mid=(lo+hi)/2;
                if(A[mid]<tar)
                {
                    res=mid;
                    lo=mid+1;
                }
                else
                {
                    hi=mid-1;
                }
            }
            if(res!=-1)
            {
                ans+=(res-j);
            }
        }
    }
    cout<<ans;
}



Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#define MAX 100000


struct node{
  int key;
  struct node *right;
  struct node *left;
  struct node *parent;
};
typedef struct node * Node;
#define NIL NULL

Node root;

void print(Node );
void preorder(Node );
void inorder(Node );
void insert(int);
int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
  
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      //   Node t = treeSearch(root, x);
      //    if ( t != NIL ) printf("yes\n");
      //   else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if ( com[0] == 'd' ){
      //     scanf("%d", &x);
      //     treeDelete(treeSearch(root, x));
    }
  }

  return 0;
}


void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x != NIL){
    y = x;
    if(z->key < x->key){
      x = x->left;
    }
    else{
      x = x->right;
    }
  }
  z->parent = y;   
  if(y == NIL) {
    root = z; //Tが空
  }
  else if(z->key < y->key ){
    y->left = z;
  }
  else y->right = z;
}

void print(Node root){
  inorder(root);
  preorder(root);
}

void preorder(Node u){
  if(u==NIL) return;
  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);
}

void inorder(Node u){
  if(u == NIL) return;
  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);
}



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

#define ll long long
#define endl "\n"
#define FAST ios_base::sync_with_stdio(false); cin.tie(NULL);
#define M 1000000007

void solve()
{	
	string s1,s2,s3;
	cin>>s1>>s2;
	s3=s2.substr(0,s1.length());
	if(s3==s1) cout<<"Yes";
	else cout<<"No";
}

int main()
{
	FAST
	ll t=1;
	//cin>>t;
	for(ll i=0;i<t;i++) solve();
	return 0;
}

Measured memory_bytes: 3672
l=list(input())
if l[0]==l[1]==l[2]==l[3]:
  print("No")
elif l[0]==l[1] and l[2]==l[3]:
  print("Yes")
elif l[0]==l[2] and l[1]==l[3]:
  print("Yes")
elif l[0]==l[3] and l[1]==l[2]:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 9132
# 左右の範囲を絞っていくことで共通要素のみを炙り出す
n,m = map(int,input().split())
l = -1
r = n+1
for i in range(m):
    l_i,r_i = map(int,input().split())
    l = max(l,l_i)
    r = min(r,r_i)
print(max(0,r-l+1))

Measured memory_bytes: 3060
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define NIL NULL
struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
Node root;
Node treeMinimum(Node x){

}
Node treeMaximum(Node x){

}
Node treeSearch(Node x, int k){
  if(x==NIL || k==x->key)return x;
  if(k < x->key)return treeSearch(x->left, k);
  else return treeSearch(x->right, k);
}
Node treeSuccessor(Node x){

}
void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y

  }
void insert(int k){ //k=(加える整数)
  Node y = NIL;//xの親
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;
  while(x!=NIL){
    y=x;
    if(z->key < x->key)x = x->left;// 左の子へ移動
    else x = x->right;// 右の子へ移動
  }
  z->parent=y;
  if(y==NIL)root=z; // T が空の場合
  else if(z->key < y->key)y->left = z; // z を y の左の子にする
  else y->right = z; // z を y の右の子にする
}
void inorder(Node x){
  if(x!=NIL){
    inorder(x->left);
    printf(" %d",x->key);
    inorder(x->right);
  }
}
void preorder(Node x){
  if(x!=NIL){
    printf(" %d",x->key);
    preorder(x->left);
    preorder(x->right);
  }
}
int main(){
  int n, i, x;
  char com[20];
  
  scanf("%d", &n);
  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t=treeSearch(root,x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d",&x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root,x));
    }
  }
  return 0;
}



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

int main(){
  string s;
  cin >> s;
  int ans=0;
  for(int i=0,l=s.size();i<l;i++)
    ans+=s.at(i)-48;
  cout << (ans%9==0?"Yes":"No") << endl;
  return 0;
}

Measured memory_bytes: 3720