akhauriyash/Code-Regression huggingface dataset:
fun main(args: Array<String>) {
    val (N, M) = readLine()!!.split(" ").map { it.toInt() }
    val Plist = IntArray(N) {1}
    val PY = (1..M).mapIndexed { index, i ->
        val (P, Y) = readLine()!!.split(" ").map { it.toInt() }
        Triple(index, P, Y)
    }.sortedBy { it.third }
    val results = arrayListOf<Pair<Int, String>>()
    PY.forEach {
        results.add(Pair(it.first, f(it.second) + f(Plist[it.second-1]++)))
    }
    results.sortedBy { it.first }.forEach { println(it.second) }
}

fun f(n: Int): String {
    var result = ""
    for (i in 0 until 6 - n.toString().length) result += "0"
    return "$result$n"
}

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

int main()
{
    int a,b,c,d,e,f;
    cin >> a >> b >> c >> d >> e >> f;
    int i,j,k,l;
    double temp_density = 0;
    double max_density = 0.0;
    int tempa = 0,tempb = 0,tempc = 0,tempd = 0;
    for(i = 0;i <= f/(100*a);++i){
        for(j = 0;j <= (f-100*i*a)/(100*b);++j){
            int tempk = 0,templ = 0;
            int tempij_max_sugar = min((i*a+j*b)*e,f-100*a*i-100*b*j);
            int temp_sugar = 0;
            int temp_max_sugar = 0;
            for(k = tempij_max_sugar/c;k >= 0;--k){
                l = (tempij_max_sugar-k*c)/d;
                temp_sugar = k*c+l*d;
                if(temp_max_sugar <= temp_sugar){
                    temp_max_sugar = temp_sugar;
                    tempk = k;
                    templ = l;
                }
            }
            if(i == 0 && j == 0 && tempk == 0 && templ == 0){
                continue;
            }
            temp_density = 100.0*((double)(tempk*c+templ*d))/(double)((i*a+j*b)*100.0+tempk*c+templ*d);
            if(max_density <= temp_density){
                max_density = temp_density;
                tempa = i*100*a;
                tempb = j*100*b;
                tempc = tempk*c;
                tempd = templ*d;
            }
        }
    }
    cout << tempa+tempb+tempc+tempd << " " << tempc+tempd << endl;
    return 0;
}

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

int main() {
  string N;
  cin >> N;
  
  
if(N == "Sunny"){
  cout << "Cloudy" << endl;
}
  else if(N == "Cloudy"){
  cout << "Rainy" << endl;
}
  else{
    cout << "Sunny" << endl;
}
    
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static String Y = "Yes";
	public static String N = "No";
	public static String I = "IMPOSSIBLE";
	public static String B = "Bad";
	public static String G = "Good";
	public static long MOD = (long) (Math.pow(10, 9) + 7);
	public static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {

		int n = ni();

		int[] d = new int[n];

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

		int count = 0;
		for (int i = 0; i < n - 1; i++) {
			for (int j = i + 1; j < n; j++) {
				count += d[i] * d[j];
			}
		}

		out(count);

	}

	public static int count(String search, String text) {
		int nsearch = search.length();
		int ntext = text.length();
		int count = 0;

		for (int i = 0; i <= ntext - nsearch + 1; i++) {
			for (int j = i + nsearch - 1; j < ntext; j++) {
				if (search.equals(text.substring(i, j + 1))) {
					count++;
				}
			}
		}

		return count;
	}

	/*
	 * 以下メソッド集
	 */
	static int ni() {
		return sc.nextInt();
	}

	static long nl() {
		return sc.nextLong();
	}

	static double nd() {
		return sc.nextDouble();
	}

	static String n() {
		return sc.next();
	}

	static char[] nc() {
		return sc.next().toCharArray();
	}

	static int kaijo(int n) {
		if (n == 0 || n == 1) {
			return 1;
		} else {
			return n * kaijo(n - 1);
		}
	}

	static int fib(int n) {
		return (n == 1 || n == 0) ? n : fib(n - 2) + fib(n - 1);
	}

	static long lcm(long m, long n) {

		return m * n / gcd(m, n);
	}

	static int lcm(int m, int n) {

		return m * n / gcd(m, n);
	}

	static long gcd(long a, long b) {
		return (b == 0) ? a : gcd(b, a % b);
	}

	static int gcd(int a, int b) {
		return (b == 0) ? a : gcd(b, a % b);
	}

	static void out(String info) {
		System.out.println(info);
	}

	static void out(int info) {
		System.out.println(info);
	}

	static void out(double info) {
		System.out.println(info);
	}

	static void out(long info) {
		System.out.println(info);
	}

	static void out(char info) {
		System.out.println(info);
	}

	static void out(Object obj) {
		System.out.println(obj.toString());
	}

	static void outn(String info) {
		System.out.print(info);
	}

	static void outn(int info) {
		System.out.print(info);
	}

	static void outn(double info) {
		System.out.print(info);
	}

	static void outn(long info) {
		System.out.print(info);
	}

	static void outn(char info) {
		System.out.print(info);
	}

	static int max(int a, int b) {
		return Math.max(a, b);
	}

	static long max(long a, long b) {
		return Math.max(a, b);
	}

	static int min(int a, int b) {
		return Math.min(a, b);
	}

	static long min(long a, long b) {
		return Math.min(a, b);
	}
}

class INF {
	int a;
	int d;

	INF(int a, int d) {
		this.a = a;
		this.d = d;
	}
}


Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
int main( )
{
   ll a,t;
   cin>>a;
   ld b;
   cin>>b;
   ld B=round(b*100);
   t=a*B;
   cout<<(t/100)<<endl;
}

Measured memory_bytes: 3788
#include <iostream>
using namespace std;
int main(){
  int a,b;
  cin >> a >> b;
  int cnt = 0;
  for(int i=a;i<=b;i++){
    if((i/10000==i%10) && (i/1000%10==i/10%10)){
      cnt++;
    }
  }
  cout << cnt << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define SZ(v) ((int)(v).size())
#define zero(v) memset(v,0,sizeof(v))
#define rep(i,n) for(int i=0;i<(n);i++)
#define foreach(it,c) for(__typeof(c.begin()) it=c.begin();it!=c.end();it++)
#define all(v) (v).begin(),(v).end()
template<typename T>inline bool chkmin(T &a,const T &b){return a>b?a=b,1:0;}
template<typename T>inline bool chkmax(T &a,const T &b){return a<b?a=b,1:0;}
typedef long long ll;
typedef unsigned uint;
const int INF=0x3f3f3f3f;
const double EPS=1e-10;
typedef pair<int,int>P;
int inline in(){int x=0,c;for(;(uint)((c=getchar())-'0')>=10;)
{if(c=='-')return -in();if(!~c)throw ~0;}do{x=(x<<3)+(x<<1)+(c-'0');}
while((uint)((c=getchar())-'0')<10);return x;}
int main(){
	int n;
	cin>>n;
	set<string>S;
	rep(i,n){
		string s;
		cin>>s;
		S.insert(s);
	}
	cout<<SZ(S)<<endl;
	return 0;
}


Measured memory_bytes: 19088
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<math.h>
#include<queue>
#include<complex>
using namespace std;

int main() {
	long long int n,m,a,b,c,d,e;
	string str;
	long long int x[130]={};
	cout << fixed << setprecision(10);
	cin>>a>>b>>c>>d>>e>>n;
	if(max({a,b,c,d,e})-min({a,b,c,d,e})>n){
		cout<<":(";
	}else{cout<<"Yay!";}




	cout<<endl;
} 


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

#define pll pair<ll,ll>
#define ff first
#define snd second
#define pb push_back
#define vll vector<ll>
#define vpll vector<pll>
#define endl "\n"
#define MOD 1000000007
using namespace std;

ll const N = 1e5+1;


void solve()
{
   string s,t;
   cin>>s>>t;
   t.pop_back();
   if(s!=t)
   {
           cout<<"No";
   }
   else
   {
           cout<<"Yes";
   }
}
 
int main() {
            ios_base::sync_with_stdio(false);
            cin.tie(NULL);
	    int t=1;
	    //cin>>t;
	    while(t--)
	    {
	            solve();
	    }
	    return 0;
}

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

const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

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

int main(){
    int n;
    cin >> n;
    vpll xy(n);
    rep(i, n) cin >> xy[i].first >> xy[i].second;
    vll f0(n), f1(n);
    rep(i, n) f0[i] = xy[i].first - xy[i].second;
    rep(i, n) f1[i] = xy[i].first + xy[i].second;
    VSORT(f0); VSORT(f1);
    ll ans = max(f0.back()-f0[0], f1.back()-f1[0]);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 9588
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;

#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
#define ll long long
#define ull unsigned long long
#define N 100005
#define mod 1000000007
//#define mod 1e18
#define boost ios_base::sync_with_stdio(false);cin.tie(0)
#define prec(n) fixed<<setprecision(n)

#define mii map<int,int>
#define mll map<ll,ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define fi  first

#define se second
#define pb push_back
#define mp make_pair
#define pp pop_back
#define vii vector<int>
#define vll vector<ll>
#define vpii vector<pii>
#define vpll vector<pll>
#define all(c) c.begin(),c.end()
#define tr(it,c) for(it = c.begin() ; it!=c.end() ; it++)
int inf = INT_MAX ;
ll modulo(ll num,ll MOD=mod){ return ((num%MOD)+MOD)%MOD;} // for negative integer
ll power(ll b,ll e,ll MOD=mod){ll ans=1; while(e){if(e%2) ans=(ans*b)%MOD; b=(b*b)%MOD; e/=2;} return ans;}
ll inv(ll num,ll MOD=mod){ return power(modulo(num),MOD-2,MOD); }
ll gcd(ll a,ll b){ return ((b==0) ? a:gcd(b,a%b));}

int main(){
	boost;
	char c;
	cin>>c;
	
	if(isupper(c)){
		cout<<'A';
	}else{
		cout<<'a';
	}
	return 0;
}


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

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<ll> vll;
// #define int long long
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000               // 2e9
#define LLINF 2000000000000000000ll  // 2e18 (llmax:9e18)
#define fi first
#define sec second
#define all(x) (x).begin(), (x).end()
#define sq(x) ((x) * (x))
#define dmp(x) cerr << #x << ": " << x << endl;

template <class T>
void chmin(T &a, const T &b) {
  if (a > b) a = b;
}
template <class T>
void chmax(T &a, const T &b) {
  if (a < b) a = b;
}

template <class T>
using MaxHeap = priority_queue<T>;
template <class T>
using MinHeap = priority_queue<T, vector<T>, greater<T>>;
template <class T>
vector<T> vect(int len, T elem) {
  return vector<T>(len, elem);
}

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << p.fi << ',' << p.sec;
  return os;
}
template <class T, class U>
istream &operator>>(istream &is, pair<T, U> &p) {
  is >> p.fi >> p.sec;
  return is;
}
template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  for (int i = 0; i < vec.size(); i++) {
    os << vec[i];
    if (i + 1 < vec.size()) os << ' ';
  }
  return os;
}
template <class T>
istream &operator>>(istream &is, vector<T> &vec) {
  for (int i = 0; i < vec.size(); i++) is >> vec[i];
  return is;
}
void fastio() {
  cin.tie(0);
  ios::sync_with_stdio(0);
  cout << fixed << setprecision(20);
}

#define endl "\n"

void solve() {
  ll a, b, c;
  cin >> a >> b >> c;
  if (c - a - b < 0) {
    cout << "No" << endl;
    return;
  }
  if (4 * a * b < sq(c - a - b))
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return;
}

signed main() {
  fastio();
  solve();
  // int t; cin >> t; while(t--)solve();
  return 0;
}


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

using namespace std;
using ll = long long;

using Field = vector<vector<int>>;
using Graph = vector<vector<int>>;
using VI = vector<int>;
using VC = vector<char>;
using PI = pair<int, int>;

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

const long long INF = 1LL<<60;
const int mod = 1000000007;

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

int N;
vector<ll> A;

vector<vector<ll>> dp(3010, vector<ll>(3010, 0));

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

    cin >> N;
    A.resize(N + 10);
    REP(i, N) cin >> A.at(i);

    REP(i, N) dp.at(i).at(i)= 0;

    for (int len = 1; len <= N; len++) {
        for (int left = 0; left + len <= N; left++) {
            int right = left + len; 

            if ((N - len) % 2 == 0) {
                dp.at(left).at(right) = max(dp.at(left + 1).at(right) + A.at(left), dp.at(left).at(right - 1) + A.at(right - 1));
            } else {
                dp.at(left).at(right) = min(dp.at(left + 1).at(right) - A.at(left), dp.at(left).at(right - 1) - A.at(right - 1));
            }
        }
    }

    cout << dp.at(0).at(N) << endl;
    
    return 0;
}

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

int main(){
    init();
    inl(n);
    ll ans= 0;
    for(ll i=1; i<=n; i+=2){
        ll cnt= 0;
        for(ll j=1; j<=i; j+=2){
            if(i%j==0) cnt++;
        }
        if(cnt==8) ans++;
    }
    out(ans);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
// Begin Header {{{
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i,n) for(ll i=0; i<n; i++)
#define loop(i, j, n) for(ll i=j; i<n; i++)
#define all(x) (x).begin(), (x).end()
constexpr int INF  = 0x3f3f3f3f;
const long long mod=1e9+7;
const long double PI = acos(-1);
// }}} End Header

int main() {
	ll n, m, k, sum = 0;
	cin >> n >> m >> k;
	vector<ll> a(n+1);
	vector<ll> b(m+1);
	loop(i, 1, n+1) cin >> a[i];
	loop(i, 1, m+1){
		cin >> b[i];
		sum+=b[i];
	}

	ll cnt_b = m, ans=0;
	loop(i, 0, n+1){
		sum+=a[i];
		while(sum>k && cnt_b>0){
			sum-=b[cnt_b];
			cnt_b--;
		}
		if(sum > k) break;
		if(ans < cnt_b+i) ans = cnt_b+i;
	}
	cout << ans << endl;
}

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

/*
#define mygc(c) (c)=getchar_unlocked()
#define mypc(c) putchar_unlocked(c)
void reader(int *x){int k,m=0;*x=0;for(;;){mygc(k);if(k=='-'){m=1;break;}if('0'<=k&&k<='9'){*x=k-'0';break;}}for(;;){mygc(k);if(k<'0'||k>'9')break;*x=(*x)*10+k-'0';}if(m)(*x)=-(*x);}
template <class T, class S> void reader(T *x, S *y){reader(x);reader(y);}
void writer(int x, char c){int s=0,m=0;char f[10];if(x<0)m=1,x=-x;while(x)f[s++]=x%10,x/=10;if(!s)f[s++]=0;if(m)mypc('-');while(s--)mypc(f[s]+'0');mypc(c);}
template<class T> void writerLn(T x){writer(x,'\n');}
*/

#define incID(i, l, r) for(int i = (l); i < (r); i++)
#define inc(i, n) incID(i, 0, n)
template<typename T> bool setmin(T &a, T b) { if(a <= b) { return false; } else { a = b; return true; } }
template<typename T> bool setmax(T &a, T b) { if(b <= a) { return false; } else { a = b; return true; } }


// ---- ----

int n, k;
vector<int> vec[100000];
bool has[100000];
int mi[100000];
int ma[100000];

void prod(int x, int y) {
	if(has[y]) {
		bool flag = true;
		if(has[x] && (mi[x] - mi[y]) % 2 == 0) { flag = false; }
		setmax(mi[x], mi[y] - 1);
		setmin(ma[x], ma[y] + 1);
		has[x] = true;
		if(mi[x] > ma[x]) { flag = false; }
		if(! flag) {
			cout << "No\n";
			exit(0);
		}
	}
}

bool dfs(int node, int pre) {
	if(pre != -1) { prod(node, pre); }
	for(auto && e : vec[node]) {
		if(e != pre) {
			dfs(e, node);
			prod(node, e);
		}
	}
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	cin >> n;
	inc(i, n - 1) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		vec[a].push_back(b);
		vec[b].push_back(a);
	}
	fill(mi, mi + n, -1000000);
	fill(ma, ma + n,  2000000);
	cin >> k;
	inc(j, k) {
		int v, p;
		cin >> v >> p;
		v--;
		mi[v] = p;
		ma[v] = p;
		has[v] = true;
	}
	
	dfs(0, -1);
	dfs(0, -1);
	
	cout << "Yes\n";
	inc(i, n) { cout << mi[i] << "\n"; }
	
	return 0;
}


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

const ll mx = 1e18;
 
int main()
{
    int n;
    cin >> n;
    ll ans = 1;
    bool ok = true;
    rep(i, n)
    {
        ll a;
        cin >> a;
        
        if(a==0)
        {
            pri(0);
            return 0;
        }
        if( (mx+1)/ans < a || ans*a > mx)
        {
            ans = -1;
            ok = false; 
        }
        if(ok)
            ans *= a;
    }
    
    pri(ans);
    return 0;
}


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

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

    vector<int>color(N+1,-1);
    vector<vector<int>>edge_gragh(N+1, vector<int>());
    vector<vector <long long> > distance (N+1,vector<long long>());

    for (int i = 0; i < N-1; ++i) {
        int u,v;
        long long w;
        cin>>u>>v>>w;
        edge_gragh[u].push_back(v);
        distance[u].push_back(w%2);
        edge_gragh[v].push_back(u);
        distance[v].push_back(w%2);

    }
    color[1]=0;
    queue<int>q;
    q.push(1);
    while (!q.empty()){
        int now = q.front();
        q.pop();
        for (int i = 0; i < edge_gragh[now].size(); ++i) {
            int U =edge_gragh[now][i];
            int W=distance[now][i];
            if (color[U] != -1) continue;
                color[U] =(color[now]+W) % 2;
                q.push(U);
        }
    }
    for (int j = 1; j < N+1; ++j) {
        cout<<color[j]<<endl;
    }

}


Measured memory_bytes: 12288
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(I,A,B) for(ll I = int(A); I < int(B); ++I)
int main(){	
	string in;
	cin >> in;
	FOR(i,0,(1<<3)){
		int w = in[0]-'0';
		FOR(j,0,3){
			if(i&(1<<j)) w+=in[j+1]-'0';
			else 			 w-=in[j+1]-'0';
		}
		if(w==7){
			cout << in[0];
			FOR(j,0,3){
				cout << (i&(1<<j)?'+':'-');
				cout << in[j+1];
			}

			cout << "=7" << endl;
			return 0;
		}
	}
}

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

using namespace std;

int main() {
	string s, t;
	cin >> s >> t;
	int l = s.size();
	for (int i = 0; i < l; ++i) {
		if (s == t) {
			cout << "Yes";
			return 0;
		}
		char c = s[s.size() - 1];
		s.erase(s.size() - 1);
		s = c + s;
	}
	cout << "No";
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
// #include "prettyprint.hpp"

int main() {
  char c;
  cin >> c;
  cout << (char)(c + 1) << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
//KaLLIkeT
int main()
{
	int n, x, ans = 1;
	cin >> n >> x;
	int c = 0;
	for (int i = 1; i < n + 1; ++i) {
		int p;
		cin >> p;
		c += p;
		if (c > x) {
			//haboh dogich
		}
		else {
			++ans;
		}
	}
	cout << ans;
}


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

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

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

    int res = INT_MAX;
    for(int i = 0; i < 101; ++i)
    {
        int sum = 0;
        for(int j = 0; j < n; ++j)
        {
            sum += (a[j] - i) * (a[j] - i);
        }
        res = min(sum, res);
    }

    cout << res << "\n";
    return 0;
}

Measured memory_bytes: 3624
def dis_func(x, y):
    dis = [round(0, 6) for i in range(4)]
    for x, y in zip(x, y):
        tmp = abs(x - y)
        dis[0] += tmp
        dis[1] += (tmp ** 2)
        dis[2] += (tmp ** 3)
        dis[3] = max(dis[3], tmp)

    dis[1] = dis[1] ** (1/2)
    dis[2] = dis[2] ** (1/3)
    print('\n'.join(list(map(str, dis))))


if __name__ == '__main__':
    n = int(input())
    x = list(map(int, input().split()))
    y = list(map(int, input().split()))

    dis_func(x, y)

Measured memory_bytes: 7780
from heapq import heappop, heappush
N, M = map(int, input().split())
A = list(map(int, input().split()))
H = []
for a in A:
    heappush(H, -a)

for _ in range(M):
    a = heappop(H)
    heappush(H, -((-a)//2))

print(-sum(H))

Measured memory_bytes: 64792
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define INF 2100000000
#define MOD 1000000007

int main(){
  ll N;
  ll x;
  cin>>N>>x;
  vector<ll> a(N);
  for(int i=0;i<N;i++){
    cin>>a.at(i);
  }

  vector<vector<ll>> minimum(N,vector<ll>(N));
  for(int i=0;i<N;i++){
    minimum.at(i).at(0)=a.at(i);
  }
  for(int j=1;j<N;j++){
    for(int i=0;i<N;i++){
      minimum.at(i).at(j)=min<ll>(minimum.at((i+N-1)%N).at(j-1),a.at(i));
    }
  }

  ll ans=10000000000000;
  for(ll j=0;j<N;j++){
    ll sub=0;
    for(int i=0;i<N;i++){
      sub+=minimum.at(i).at(j);
    }
    sub+=j*x;
    ans=min<ll>(ans,sub);
  }
  cout<<ans<<endl;
}


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

int main(void){

    string M = "CODEFESTIVAL2016";
    string S;
    cin >> S;
    
    int cont = 0;
    for(int i = 0; i < S.size();i++){
       if(M[i]!=S[i])cont++; 
    }
    

    cout << cont << endl;    
}


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

const int MaxN = 1e5 + 10;
int n, m;
vector <int> e[MaxN];
int col[MaxN];
long long a, b, c;

bool bip(int x) {
    bool ret = true;
    for (int y : e[x]) {
        if (col[y] == 0) {
            col[y] = 3 - col[x];
            ret &= bip(y);
        } else if (col[y] == col[x])
            ret = false;
    }
    return ret;
}

int main() {
    cin >> n >> m;
    while (m--) {
        int x, y;
        cin >> x >> y;
        e[--x].push_back(--y);
        e[y].push_back(x);
    }
    for (int i = 0; i < n; i++) {
        if (col[i]) continue;
        if (e[i].size() == 0)
           c++;
        else {
            col[i] = 1;
            if (bip(i))
                a++;
            else
                b++;
        }
    }
    cout << 2*a*a + b*b + 2*a*b + 2*c*n - c*c;
	return 0;
}

Measured memory_bytes: 9984
#!/usr/bin/env python3
import sys


def solve(N: int, a: "List[int]"):
    color = set()
    rainbow_count = 0
    for i in range(N):
        if a[i]<=399:
            color.add("gray")
        elif a[i]<=799:
            color.add("brown")
        elif a[i]<=1199:
            color.add("green")        
        elif a[i]<=1599:
            color.add("lightblue")        
        elif a[i]<=1999:
            color.add("blue")        
        elif a[i]<=2399:
            color.add("yellow")
        elif a[i]<=2799:
            color.add("orange")        
        elif a[i]<=3199:
            color.add("red")
        else:
            rainbow_count+=1
    
    min_answer = len(color)
    max_answer = len(color) + rainbow_count
    
    if not color and rainbow_count >0:
      min_answer=1
      max_answer=rainbow_count
    print(min_answer,max_answer)

    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    a = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, a)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
using namespace std;
#include <bits/stdc++.h>
#define FASTIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long
#define debug(x) cout << #x <<" = " << x << endl
void solve()
{
int n;
cin>>n;
ll int arr[n];
for (int i = 0; i < n; i++)
{
    cin>>arr[i];
}
ll int ans=0;
for (int i = 1; i < n; i++)
{
    if(arr[i]<arr[i-1])
    {
        ans+=abs(arr[i]-arr[i-1]);
        arr[i]=arr[i-1];
    }
}
cout<<ans<<endl;
}
int main()
{

FASTIO
 long long int t;
 t=1;
 while(t--)
  solve();
  return 0;
}


Measured memory_bytes: 5068
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;
typedef long long ll;

int main() {
    int n;
    ll m;
    cin >> n >> m;
    vector<ll> a(n);
    for (int i = 0; i < n; i++)cin >> a[i];
    sort(a.begin(), a.end());

    int ok = 0, ng = 200001;
    while (ng - ok > 1) {
        int mid = (ok + ng) / 2;

        ll now = 0;
        for (int i = 0; i < n; i++)now += a.end() - lower_bound(a.begin(), a.end(), mid - a[i]);

        if (now >= m)ok = mid;
        else ng = mid;
    }

    vector<ll> c_sum(n + 1);
    for (int i = 0; i < n; i++)c_sum[i + 1] = c_sum[i] + a[i];

    ll ret = 0, count = 0;
    for (int i = 0; i < n; i++) {
        int x = a.end() - lower_bound(a.begin(), a.end(), ok - a[i]);
        ret += a[i] * x + c_sum[n] - c_sum[n - x];
        count += x;
    }

    cout << ret - ok * (count - m) << endl;
    return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<vector>

using namespace std;

int main() {
    int x;
    cin >> x;
    for (int i=0; i<=1e+4; ++i) {
        for (int j=i; j<=1e+4; ++j) {
            if ((j*j*j*j*j - i*i*i*i*i) == x) {
                cout << j << " " << i;
                return 0;
            }
        }
    }
    for (int i=0; i<1e+4; ++i) {
        for (int j=0; j>=-1e+4; --j) {
            if ((i*i*i*i*i - j*j*j*j*j) == x) {
                cout << i << " " << j;
                return 0;
            }
        }
    }
}


Measured memory_bytes: 3580
a,b,c = map(int, input().split())
s1 = a + b
s2 = b + c
s3 = c + a

if s1 <= s2:
  if s1 <= s3:
    print(s1)
  elif s3 <= s1:
    print(s3)
elif s2 <= s1:
  if s2 <= s3:
    print(s2)
  elif s3 <= s2:
    print(s3)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long int64;
typedef vector<int> vec;
typedef vector<int64> vec64;
#define ss cout << " ";
#define nn cout << "\n";
#define ct(x) cout << x;
#define cts(x) cout << x << " ";
#define ctn(x) cout << x << "\n";
#define db(x) cout << "> " << #x << ": " << x << "\n";
#define qr queries();
void solve();
void YN(bool b){if (b){ctn("YES");}else{ctn ("NO");}};
void yn(bool b){if (b){ctn("Yes");}else{ctn ("No");}};
void queries(){int n;cin >> n;while (n--)solve();}
// // // // // // // // // // // // // // // // // // // // // // 
/*                  TEMPLATE - VANILLA                         */
// // // // // // // // // // // // // // // // // // // // // //
const int maxn = 200200;

void solve(){

    return;
}


int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);
    int64 n, k;
    cin >> n >> k;
    vec64 arr (n);
    for (int i = 0; i < n; i++){
        cin >> arr[i];
    }
    int64 sum = 0;
    for (int i = 0; i < k - 1; i++){
        sum+=arr[i];
    }
    vec64 rs;
    for (int i = k - 1; i< n; i++){
        sum+= arr[i];
        sum-=arr[i - k];
        rs.push_back(sum);
    }
    for (int i = 1; i < rs.size(); i++){
        if (rs[i] > rs[i-1]){
            ctn("Yes");
        }
        else{
            ctn("No");
        }
    }
    return 0;
}

Measured memory_bytes: 6892
#include <stdio.h>

int main(void)
{
	int i, n;
	
	for (i = 1; i < 10; i++){
		for (n = 1; n < 10; n++){
			printf("%dx%d=%d\n", i, n, i * n);
		}
	}
	
	return (0);
}

Measured memory_bytes: 524
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, M, K;
    cin >> N >> M >> K;
    REP(i, 0, N) {
        REP(j, 0, M) {
            //cout << i << " " << j << " " << M * i + j * (N - i) - j * i<< endl;
            if (M * i + j * (N - i) - j * i == K) {
                cout << "Yes" << endl;
                return 0;
            } 
        }
    }
    cout << "No" << endl;

    return 0;
}


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

using namespace std;

int main(){

int a,b;
cin>>a>>b;

if(a>b) cout<< "a > b" << endl;
if(a<b) cout<< "a < b" <<endl  ;
if(a==b) cout<<"a == b"<<endl;

return 0;
}




Measured memory_bytes: 3076
#include <iostream>

using namespace std;

int main(void)
{
    int a, b, c;

    cin >> a >> b >> c;

    if(a+b==c || b+c==a || c+a==b){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>

long long mygcd(long long a, long long b) {
	if (a < b) std::swap(a, b);
	long long r = a % b;
	while (r) {
		a = b;
		b = r;
		r = a % b;
	}
	return b;
}

int main() {
	long long x, y;
	std::cin >> x >> y;
	std::cout << mygcd(x, y) << '\n';
}


Measured memory_bytes: 3084
import sys
import math
import bisect

def main():
    n, m, c = map(int, input().split())
    B = list(map(int, input().split()))
    A = []
    for i in range(n):
        A.append(list(map(int, input().split())))
    ans = 0
    for i in range(n):
        val = 0
        for j in range(m):
            val += A[i][j] * B[j]
        val += c
        if val > 0:
            ans += 1
    print(ans)

if __name__ == "__main__":
    main()


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int a[105];
bool flag[105];
int main()
{
	int x,n,i;
	cin>>x>>n;
	for(i=0;i<n;i++)
	{
		cin>>a[i];
		flag[a[i]]=true;
	}
	for(i=0;i<=x;i++)
		if(!flag[x-i])
		{
			cout<<x-i;
			return 0;
		}
		else
			if(!flag[x+i])
			{
				cout<<x+i;
				return 0;
			}
	return 0;
}

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

int main(){
  int n,m;
  vector<int> p;
  
  while(true){
    int ans = 0;
    cin >> n >> m;

    if(n + m == 0) break;

    p.resize(n);

    for(int i=0; i<n;++i){
      cin >> p[i];
    }
    
    sort(p.begin(), p.end());

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

    for(int i = m - 1; i < n; i += m){
      p[i] = 0;
    }

     for(int i = 0; i < n; ++i){
       ans += p[i];
    }
     
     cout<<ans<<endl;
  }
  return 0;
}



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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
string char_to_string(char val) {
  return string(1, val);
}
int char_to_int(char val) {
  return val - '0';
}
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 vector_finder(std::vector<ll> vec, int number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return 1;
  }
  else { // 発見できなかったとき
    return 0;
  }
}
struct edge {
  ll to, cost;
};

int main() {
  int P, Q, R; cin >> P >> Q >> R;
  cout << min({P + Q, Q + R, R + P}) << endl;
}

Measured memory_bytes: 3592
#include <iostream>
#include <stdio.h>
#include <cmath>
#include <algorithm> // sort
#include <map>       // pair
#include <vector>
using namespace std;

#define REP(a,b) for(int i =(a);i < (b);i++)
#define FOR(n) for(int i = 0; i<(n); i++)
#define COUT(c)  cout<<(c)<<endl


const int INF = 100100100;
const int MOD = (int)1e9 +7;
const double EPS = 1e-9; 

typedef long long int ll;

//char in[120];
//ex. pair
//pair<pair<string,int>,int> p[110];

int main(){
    int a,b;cin>>a>>b;
    int diff = abs(a-b);
    if ((diff%2) ==0) cout<<diff/2 + min(a,b)<<endl;
    else COUT("IMPOSSIBLE");

    return 0;    
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main() {
    long long n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a.at(i);
    }
    vector<int> b(n);
    for (int i = 0; i < n; ++i) {
        cin >> b.at(i);
    }
    vector<int> c(n);
    for (int i = 0; i < n; ++i) {
        cin >> c.at(i);
    }

    sort(a.begin(), a.end());
    sort(c.begin(), c.end());

    long long answer = 0;
    for (int i = 0; i < n; ++i) {
        answer += (lower_bound(a.begin(), a.end(), b.at(i)) - a.begin())
                  * (c.end() - upper_bound(c.begin(), c.end(), b.at(i)));
    }
    cout << answer << "\n";
}


Measured memory_bytes: 1408
import java.util.*;
import java.lang.Math.*;
import java.math.BigDecimal;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// スペース区切りの整数の入力
		long syaink = sc.nextLong();
        BigDecimal ss = BigDecimal.valueOf(syaink);
        double syainj = sc.nextDouble();
        BigDecimal ssc =BigDecimal.valueOf(syainj);
      BigDecimal b3 = ss.multiply(ssc);
      BigDecimal result3 = b3.setScale(0, BigDecimal.ROUND_DOWN);
      System.out.println(result3);
}
}

Measured memory_bytes: 37708
#include <iostream>
#include <vector>
#include <array>
#include <algorithm>
#include <limits>
#include <cmath>
#include <numeric>
#include <string>

using namespace std;

using ll = long long int;
using ull = unsigned long long int;
#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 REP(i, a, b) for(int i = (a); i <= (b); ++i )
#define RREP(i, a, b) for(int i = (a); i >= (b); --i )
#define ullrep(i, a, b) for(ull i = (a); i < (b); ++i )
#define ullrrep(i, a, b) for(ull i = (a); i > (b); --i )
#define ullREP(i, a, b) for(ull i = (a); i <= (b); ++i )
#define ullRREP(i, a, b) for(ull i = (a); i >= (b); --i )

int main() {
    ll A, B, C;
    ull K;
    cin >> A >> B >> C >> K;
    if (K % 2) {
        cout << B - A << endl;
    }else{
        cout << A - B << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <queue>
#include <algorithm>
#include <stack>
#include <cmath>
#include <map>
#include <cstring>
using namespace std;
#define mod 1000000007
#define PI acos(-1.0)
const long long MAX=200005;
typedef long long ll;
const int INF=0x3f3f3f3f;
//int d[8][2]={-1,0,0,-1,0,1,1,0,1,1,-1,-1,-1,1,1,-1};
int main()
{
    int n,m,sum,g=0;
    int t[100005],x[100005],y[100005];
    t[0]=x[0]=y[0]=0;
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
        scanf("%d%d%d",&t[i],&x[i],&y[i]);
        m=t[i]-t[i-1];
        sum=abs(x[i]-x[i-1])+abs(y[i]-y[i-1]);
        if(m<sum||(m-sum)%2!=0) g=1;
    }
    if(g)printf("No\n");
    else printf("Yes\n");
    return 0;
}


Measured memory_bytes: 1408
N,M,*S = $<.read.split.map &:to_i
A = [[]]*(N+1)
m = 1
M.times {|i|
  s = S[i+i,2]
  a,b = r = s.dup
  x,y = s.map {|i;j| r<< i=j while (j=A[i])[0]; i}
  x,y = y,x  if x > y
  g,h = [A[x],A[y]].map{|h| h.empty? ? {a=>0,b=>0} : h}
  g,h = h,g  if g.size > h.size
  h.merge! g  if h.object_id != g.object_id
  r.each {A[_1] = y}
  A[y] = h
  m < s=h.size and m = s
}
p m

Measured memory_bytes: 96452
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <stack>
#include <set>
#include <map>
#include <unordered_map>


using namespace std;

unordered_map<string, int> stringmap;

int main(int argc, const char * argv[]) {
    int n;
    string str;
    char last;
    cin >> n;
    cin >> str;
    last = str.back();
    stringmap[str] = 1;
    for(int i = 2; i <= n; i++) {
        cin >> str;
        if(str.front() != last || stringmap[str] == 1) {
            cout << "No\n";
            exit(0);
        }
        stringmap[str] = 1;
        last = str.back();
    }
    cout << "Yes\n";
    exit(0);
}


Measured memory_bytes: 256
<?php
list($n) = ints();
list($s) = strs();
$max = 0;
for ($i = 0; $i < $n; ++$i) {
    $t = substr($s, $i);
    $lcp = zAlgo($t);
    for ($j = 0; $j < $n - $i; ++$j)
        $max = max($max, min($j, $lcp[$j]));
}
echo $max;
// sとs[i:]が、先頭から最大で何文字まで一致しているか格納した配列を返す
// O(N)
function zAlgo(string $s): array
{
    $n = strlen($s);
    $res = array_fill(0, $n, 0);
    $res[0] = $n;
    $i = 1;
    $len = 0;
    while ($i < $n) {
        while ($i + $len < $n && $s[$len] === $s[$i + $len]) ++$len;
        $res[$i] = $len;
        if ($len === 0) {
            ++$i;
            continue;
        }
        $k = 1;
        while ($i + $k < $n && $k + $res[$k] < $len) {
            $res[$i + $k] = $res[$k];
            ++$k;
        }
        $i += $k;
        $len -= $k;
    }
    return $res;
}
function strs()
{
    return explode(' ', trim(fgets(STDIN)));
}
function ints()
{
    return array_map('intval', explode(' ', trim(fgets(STDIN))));
}


Measured memory_bytes: 16624
#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
  int N, M, L;
  cin >> N >> M >> L;
  int P[N], T[N], V[N];
  for(int i = 0; i < N; ++i){
    cin >> P[i] >> T[i] >> V[i];
  }
  double prob[N][M+1];

  for(int i = 0; i < N; ++i) prob[i][0] = 1.0;
  for(int i = 0; i < N; ++i){

    for(int j = 1; j <= M; ++j){
      prob[i][j] = prob[i][j-1]*P[i]/100.0*(M-j+1)/j;
    }
    double t = 1.0;
    for(int j = M; j >= 0; --j){
      prob[i][j] *= t;
      t *= (1.0 - (double)P[i]/100.0);
    }
  }
  double acum[N][M+2];
  for(int i = 0; i < N; ++i) acum[i][M+1] = 0;
  for(int i = 0; i < N; ++i){
    for(int j = M; j >= 0; --j){
      acum[i][j] = acum[i][j+1] + prob[i][j];
    }
  }
  vector< vector<double> > time(N,vector<double>(M+1));
  for(int i = 0; i < N; ++i) time[i][0] = (double)L/V[i];
  for(int i = 0; i < N; ++i){
    for(int j = 1; j <= M; ++j){
      time[i][j] = time[i][j-1] + T[i];
    }
  }
  for(int i = 0; i < N; ++i){
    double ans = 0.0;
    for(int j = M; j >= 0; --j){
      double t = prob[i][j];
      for(int k = 0; k < N; ++k){
        if(k == i) continue;
        int id = upper_bound(time[k].begin(),time[k].end(),time[i][j]) - time[k].begin();
        if(id > M){
          t = 0;
          break;
        }
        t *= acum[k][id];
      }
      ans += t;
    }
    printf("%.12f\n",ans);
  }
  return 0;
}

Measured memory_bytes: 3388
module Main where

    import Debug.Trace

    readLine:: IO [Int]
    readLine = fmap (map read . words) getLine
    
    while :: Int -> Int -> IO ()
    while x y = if not (x==0 && y== 0) 
        then do
            putStrLn $ if x <=y then (show x ++" "++ show y) else (show y ++" "++ show x)    
            [x', y']    <- readLine
            while x' y'
        else return ()

    main :: IO() 
    main = do
        let i = 1
        [x, y]    <- readLine
        while x y
    


Measured memory_bytes: 4120
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<utility>
#include<numeric>
#include<vector>
#include<map>
#include<unordered_map>
#include<set>
#include<tuple>
#include<stack>
#include<queue>
#include<functional>
#include<iterator>
#include<cmath>
#include<cctype>

using namespace std;

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

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

struct edge{int to,cost;};

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

	string s;
	cin >> s;

	if(s.size() == 2) cout << s << "\n";
	else{
		cout << s[2] << s[1] << s[0] << "\n";
	}
	return 0;
}

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

int main() {
	int A,B,K;
	cin >> A >> B >> K;

	int count = 0;

  for(int i = min(A,B);1<=i;i--){
		if((A%i) == 0 && (B%i) == 0) count++;

		if(count == K){
			cout << i << endl;
			return 0;
		}
	}
}

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

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

	int A,B;
	int i,j;
	int tmp;
	int flags[3]={1,1,1};
	int answer;
	int counter=0;
	double ave;
	vector<int> given;

	cin >> A >> B;
	
	flags[A-1]=0;
	flags[B-1]=0;

	for(i=0;i<3;i++){
		if(flags[i]){
			answer=i+1;
			break;
		}
	}
	
	cout << answer << endl;

	return 0;
}



Measured memory_bytes: 256
//#include<bits/stdc++.h>
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<numeric>
#include<vector>
#include<set>
#include<map>
#include<unordered_map>
#include<stack>
#include<queue>
#include<list>
using namespace std;

#define INF 100000

int main(){
  int n,a,b,c,d;
  cin >> n >> a >> b >> c >> d;
  string s;
  cin >> s;
  s = " "+s;
  bool flag = true;
  for(int i=a+1;i<=c;i++){
    if(s[i] == '#' && s[i-1] == '#') flag = false;
  }
  for(int i=b+1;i<=d;i++){
    if(s[i] == '#' && s[i-1] == '#') flag = false;
  }

  if(c < d){
    if(flag) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
  }
  if(!flag){
    cout << "No" << endl;
    return 0;
  }
  flag = false;
  for(int i=b;i<=d;i++){
    if(s[i+1] == '.' && s[i] == '.' && s[i-1] == '.'){
      flag = true;
      break;
    }
  }

  if(flag) cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;
}


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

#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define all(x) x.begin(),x.end()
typedef long long ll;
ll mod = 1000000007;
ll inf = 1e18;
int main(){

    string s,t;
    cin >> s >> t;
    int n=s.size(),m=t.size();
    int ans=m;

    rep(i,n-m+1){
        int count=0;
        rep(j,m) if(s[i+j]==t[j]) count++;
        ans=min(ans,m-count);
    }

    cout << ans << endl;
    
    return 0;
}

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

using namespace std;

typedef long long int ll;
typedef vector<ll> vll;

ll ad(ll a, ll b){
    return abs(a - b);
}

int main(){
    int n;
    cin>>n;
    vll height(n + 1);
    vll dp(n + 1);
    for(int i = 1; i <= n; ++i)
        cin>>height[i];
    dp[0] = INT_MAX;
    dp[1] = 0;
    height[0] = INT_MAX;
    for(int i = 2; i <= n; ++i){
        dp[i] = min(dp[i - 1] + ad(height[i], height[i - 1]), dp[i - 2] + ad(height[i], height[i - 2]));
        //cout<<dp[i]<<endl;
    }
    cout<<dp[n]<<endl;
    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <algorithm>

using int64 = long long;

using namespace std;
using int_vec = vector<int64>;

void heapify(int_vec& v, int i) {
    int max;

    auto h = v.size();
    auto l = i * 2 + 1;
    auto r = i * 2 + 2;
    if (l < h && v[l] > v[i]) {
        max = l;
    } else {
        max = i;
    }
    if (r < h && v[r] > v[max]) {
        max = r;
    }

    if (max != i) {
        swap(v[i], v[max]);
        heapify(v, max);
    }
}

int parent(int i) {
    return (i - 1) / 2;
}

void insert(int_vec& v, int64 x) {
    v.push_back(x);

    int i = v.size() - 1;
    while (i > 0 && v[parent(i)] < v[i]) {
        swap(v[parent(i)], v[i]);
        i = parent(i);
    }
}

int main() {
    int_vec v;

    while (1) {
        string s;
        cin >> s;
        if (s == "end")
            break;

        if (s == "insert") {
            int x;
            cin >> x;
            insert(v, x);
        } else if (s == "extract") {
            cout << v[0] << endl;
            swap(v[0], v.back());
            v.pop_back();
            heapify(v, 0);
        }
    }

    return 0;
}

Measured memory_bytes: 11152
#include <cstdio>
#include <algorithm>
#include <map>

using namespace std;

int n, p;
long long x, y, z;
map<int, int> m;

int main()
{
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) scanf("%d", &p), m[-p]++;
	for (auto i : m) if (i.second >= 2) 
	{
		if (!x) x = -i.first; else
		if (!y) y = -i.first;
		if (i.second >= 4 && !z) z = -i.first;
	}
	printf("%lld", max(x * y, z * z));
	return 0;
}

Measured memory_bytes: 4864
N,W=map(int,input().split())
v=[None]*N
w=[None]*N

for i in range(N):
    v[i],w[i]=map(int,input().split())

dp=[]
for i in range(N+1):
    dp.append([0]*(W+1))

for i in range(N-1,-1,-1):
    for j in range(W+1):
        if j-w[i]<0:
            dp[i][j]=dp[i+1][j]
        else:
            dp[i][j]=max(dp[i+1][j],dp[i+1][j-w[i]]+v[i])

print(dp[0][W])


Measured memory_bytes: 24284
import java.io.*;

class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    String str = br.readLine();
    String ans = "";
    switch(str) {
      case "25" :
        ans = "Christmas";
        break;
      case "24" :
        ans = "Christmas Eve";
        break;
      case "23" :
        ans = "Christmas Eve Eve";
        break;
      case "22" :
        ans = "Christmas Eve Eve Eve";
        break;
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 20692
import java.util.Scanner;

public enum Main{
	LF("light fly"), FL("fly"), BT("bantam"), FE("feather"), LG("light"), LW("light welter"),
	WT("welter"), LM("light middle"), MI("middle"), LH("light heavy"), HV("heavy"); 
	
	private String s;
	private Main(String str) { this.s = str;}
	public String toString() { return this.s;}
	
	private static Main classify(double weight) {
		if(weight <= 48) return LF;
		else if(weight <= 51) return FL;
		else if(weight <= 54) return BT;
		else if(weight <= 57) return FE;
		else if(weight <= 60) return LG;
		else if(weight <= 64) return LW;
		else if(weight <= 69) return WT;
		else if(weight <= 75) return LM;
		else if(weight <= 81) return MI;
		else if(weight <= 91) return LH;
		else return HV;
	}
	
	public static void main(String... args) {
		Scanner sc = new Scanner(System.in);
		while(sc.hasNextDouble()) System.out.println(classify(sc.nextDouble()));
		sc.close();
	}
}

Measured memory_bytes: 19144