akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args){
		
		//テキスト入力クラス
		Scanner sc = new Scanner(System.in);
		
		//入力された値を取ってくる
		int first = sc.nextInt();
		int second = sc.nextInt();
		
		//最初の入力値が、２番目の入力値以下だった場合
		if(first > second){
			System.out.println("a > b");	
		//２番目の入力値のほうが大きかった場合
		}else if(first < second){			
			System.out.println("a < b");
		//等しい場合
		}else{
			System.out.println("a == b");
		}	
	}
}

Measured memory_bytes: 17324
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>

#define rep(i, n) for (int i = 0; i < n; i++)
#define rep1(i, n) for (int i = 1; i <= n; i++)
#define show(a, n) rep(i,n) {cout<<a[i]<<' ';} cout<<endl;

using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long ll;
typedef pair<long long, long long> pll;

const int INF = 1 << 30;
const long long INFL = 1LL << 62;
const int MOD = 1000000007;
const int MAX = 100000;
const int N = 100000;

int main() {
	int n, m;
	cin >> n >> m;
	int l_max = 0;
	int r_min = N + 1;
	rep(i, m) {
		int l, r;
		cin >> l >> r;
		l_max = max(l, l_max);
		r_min = min(r, r_min);
	}
	cout << max(r_min - l_max + 1, 0) << endl;
}


Measured memory_bytes: 384
import sys
import math

while True:
    n = int(sys.stdin.readline())
    if n == 0:
        break
    time = []
    for z in xrange(n):
        start, end = map(int, raw_input().replace(':', '').split())
        time.append((end, start))
    time.sort()
    train = [0]
    for end, start in time:
        for i in xrange(len(train)):
            if train[i] <= start:
                train[i] = end
                break
        else:
            train.append(end)
        train.sort(reverse=True)
    print len(train)

Measured memory_bytes: 5640
#include <bits/stdc++.h>
 
#define full(x,n) x,x+n+1
#define full(x) x.begin(),x.end()
#define finish return 0
 
#define putb push_back
#define f first
#define s second
 
#define putf push_front
#define gainb pop_back
 
#define gainf pop_front
#define len(x) (ll)x.size()
 
typedef double db;
typedef long long ll;
 
const ll ary=1e5+5;
const ll mod=1e9+7;
const ll inf=1e18;
 
using namespace std;
ll n,x[10],y[10],u[10],p[10],t;
double sum;
void rec(ll v=1){
	if(v==n+1){
		t++;
		for(int i=1;i<n;i++){
			double k=sqrt((x[p[i+1]]-x[p[i]])*(x[p[i+1]]-x[p[i]])+(y[p[i+1]]-y[p[i]])*(y[p[i+1]]-y[p[i]]));
			sum+=k;
		}
		return;
	}
	for(int i=1;i<=n;i++){
		if(!u[i]){
			u[i]=1;
			p[v]=i;
			rec(v+1);
			p[v]=0;
			u[i]=0;
		}
	}
}
int main(){
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>x[i]>>y[i];
	}
	rec();
	cout<<fixed<<setprecision(10)<<sum/t;
}

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

#define int         long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define f           first
#define s          second
#define sz(x)       (int)x.size()
#define rep(i,a,b)  for(int i=a;i<b;i++)
#define rep0(a,n)  for(int i=0;i<n;i++)cin>>a[i]
#define si(x)       cin>>x
#define sii(x,y)    cin>>x>>y
#define siii(x,y,z) cin>>x>>y>>z
#define ahell   998244353
#define hell 1000000007
#define N1 100001
#define fl 1.0000000000
//#define mod 998244353
#define cntbit(a) __builtin_popcountl(a)
#define ios ios_base::sync_with_stdio(false); cin.tie(NULL);
using namespace std;
int dp[10003][101][3];

void func(string s,int d)
{

 int i,j,k,n=s.size();
 for(i=0;i<s[0]-'0';i++)
 {
    dp[0][(i)%d][0]++;
 }

 dp[0][(s[0]-'0')%d][1]=1;

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

    for(j=0;j<d;j++)
    {
        for(k=0;k<=9;k++)
        {
            dp[i][(j+k)%d][0]+=(dp[i-1][j][0]);
            dp[i][(j+k)%d][0]%=hell;

        }
    }

    //dp[i-1][s[i]-'1'][1]

    // non-edge

    for(j=0;j<d;j++)
    {
        for(k=0;k<(s[i]-'0');k++)
        {
            dp[i][(j+k)%d][0]+=(dp[i-1][j][1]);
            dp[i][(j+k)%d][0]%=hell;

        }
     // for edge

        dp[i][(j+k)%d][1]+=(dp[i-1][j][1]);
         dp[i][(j+k)%d][1]%=hell;
    }
 }

 int ans=dp[n-1][0][0]+dp[n-1][0][1]-1;
 ans=(ans+hell)%hell;
 cout<<ans;
}
main()
{
  ios
int n,m,i;
int j;
int u,v,q;
int test=1;
//si(test);

while(test--)
{
string s;
int d;
cin>>s;
cin>>d;
func(s,d);
}

}


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

int main() {
    ll x; cin >> x;
    ll nokori = x % 11;
    ll ans = (x-nokori) / 11;
    ans *= 2;
    if(nokori > 6){
        ans += 2;
    } else if(nokori > 0) {
        ans++;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3640
import java.util.Scanner;

public class Main {

	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] m = new int[n];
		int count = 0;
		for (int i = 0; i < n; i++) {
			m[i] = sc.nextInt();
		}
		count++;
		for (int i = 1; i < n; i++) {
			boolean isSeen = true;
			for (int j = 0; j < i; j++) {
				if (m[i] < m[j])
					isSeen = false;
			}
			if (isSeen)
				count++;
		}
		System.out.println(count);
	}
}


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

using ll = long long;
#define rep(n, i) for(ll i = 0; i <= n; ++i)

void solve(void){
  ll a, b, c, x; cin >> a >> b >> c >> x;

  ll res = 0;
  rep(a, i) {
    rep(b, j) {
      rep(c, k) {
        ll tmp = 500 * i + 100 * j + 50 * k;
        if (a + b + c >= 1 && tmp == x) ++res;
      }
    }
  }
  cout << res << endl;
}

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

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <bitset>
#include <vector>
#include <queue>
#include <map>
#include <set>

#define i64 int64_t
#define ff(ii,nn,mm) for(int ii=nn;ii<mm;ii++)
#define ffrvs(ii,nn,mm) for(int ii=nn;ii>=mm;ii--)
#define srt(vvv) sort(vvv.begin(),vvv.end())
#define srtrvs(vvv) reverse(vvv.begin(),vvv.end())
#define Graph vector<vector<int>>
int inf = 1000000007;
i64 giant = 4000000000000000037;

using namespace std;

//メモリ置き場
int a, p;

//inputします
void input() {
    cin >> a >> p;
}

//ライブラリ置き場

//main
int main() {
    input();
    int ans = a * 3 + p;
    cout << ans / 2 << endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void) {
	char a[4];

	scanf("%s", a);

	char s;
	int i, j;
	for (i = 0;i < 3;i++) {
		for (j = 0;j < 3;j++) {
			if (a[j] > a[j + 1]) {
				s = a[j];
				a[j] = a[j + 1];
				a[j + 1] = s;
			}
		}
	}

	if (a[0] == a[1] && a[2] == a[3] && a[0] != a[2]) {
		printf("Yes\n");
	}
	else {
		printf("No\n");
	}
	
	return 0;
}

Measured memory_bytes: 128
n,k = map(int,input().split())
s = [int(input()) for i in range(n)]

s.sort()
d = []
for i in range(n-1):
    d.append(s[i+1]-s[i])


ans = 0
for i in range(k-1):
    ans += d[i]

tmp = ans
for i in range(n-k):
    tmp -= d[i]
    tmp += d[i+k-1]
    ans = min(tmp,ans)

print(ans)







Measured memory_bytes: 11212
#include<bits/stdc++.h>
using namespace std;
int main()
{
   int n,w;
   cin>>n>>w;
   vector<pair<long long,long long>> a;
   for(int i=0;i<n;i++)
   {
       long long x,y;
       cin>>x>>y;
       a.push_back(make_pair(x,y));
   }
   vector<long long> ans(w+1);
   for(int i=0;i<n;i++)
   {
       vector<long long> ansi=ans;
       if(a[i].first<=w)
       {
           for(int j=1;j<=w;j++)
           {
               if(ansi[j]&&j+a[i].first<=w){
                   ans[j+a[i].first]=max(ans[j+a[i].first],ansi[j]+a[i].second);
               }
           }
           ans[a[i].first]=max(ans[a[i].first],a[i].second);
       }
       //for(auto x: ans)cout<<x<<" ";
       //cout<<endl;
   }
   cout<<*max_element(ans.begin(),ans.end());
}

Measured memory_bytes: 1804
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
    ll n;
    cin>>n;
    string s="";
    while(n>=1) {
        if(n%26==0)
            n=n-26;
        int x = n%26;
        if(x==0)
        {
            x=26;
        }
        s+=char(96+x);
        n=n/26;
    }
    for(int i=s.size()-1;i>=0;i--)
        cout<<s[i];
    cout<<"\n";
}


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

int main(){
    int k;
    cin >> k;
    string ans = "";
    rep(i, k){
        ans += "ACL";
    }
    cout << ans << endl;
    return 0; 
}
 

Measured memory_bytes: 3572
N = int(input())
s = []
for i in range(N):
	s.append(list(input()))
for i in range(N):
	s[i].sort()
s.sort()
total = 0
num = 0
for i in range(N - 1):
	for x in range(10):
		if s[i][x] != s[i+1][x]:
			total += num*(num+1)//2
			num = 0
			break
		if x == 9:
			num += 1
total += num*(num+1)//2

print(total)

Measured memory_bytes: 98756
from heapq import heappush, heappushpop
import sys
input = sys.stdin.readline

Q = int(input())
small = []
large = []
const = 0
total = 0
s = 0
n = 0
m = 0
for _ in range(Q):
    q, *nums = map(int, input().split())
    if q == 1:
        n += 1
        a, b = nums
        total += a
        const += b
        if n % 2 == 0:
            if a > large[0]:
                a = heappushpop(large, a)
            heappush(small, -a)
            m = -small[0]
            s += a
        else:
            if small and a < -small[0]:
                s += a
                a = -heappushpop(small, -a)
                s -= a
            heappush(large, a)
            m = large[0]
    else:
        ans = const + total - 2*s
        if n % 2 == 1:
            ans -= m
        print(m, ans)


Measured memory_bytes: 73432
#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);
template <class T>void UNIQUE(vector<T> &x){
	sort(all(x));
	x.erase(unique(all(x)), x.end());
}

// }}} End Header
int main() {
	ll x;
	cin >> x;
	vector<ll> a(3*x);
	loop(i, 2, 3*x){
		if(a[i]==0 && i>=x){
			cout << i << endl;
			return 0;
		}
		for(ll j=i; j<3*x; j+=i){
			a[j]++;
		}
	}

	return 0;
}


Measured memory_bytes: 5560
import math
n, d = map(int, input().split())

X = [[0]*d for _ in range(n)]

for i in range(n):
    X[i] = list(map(int ,input().split()))

cnt = 0

for i in range(n-1):
    for j in range(i+1, n):
        dist= 0
        for k in range(d):
            dist += (X[i][k]-X[j][k])**2
        
        if math.sqrt(dist) == int(math.sqrt(dist)):
            cnt += 1
        
print(cnt)


Measured memory_bytes: 9052
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ul unsigned long long int
#define ld long double
#define f(t) for(ll i =0;i<t;i++)
#define vi vector<int>
#define vl vector<ll>
#define pb push_back
#define ff first
#define ss second
#define MOD 1000000007
#define inf 4e18
#define EPS 1e-3
#define PI 3.1415926535897932385
#define display(v) f(v.size())cout << v[i]<<" "
const double h = 1e-6;
const int MAX_  = 200005;
#define all(v) v.begin(),v.end()

inline ll mul(ll a, ll b){ return (a * 1ll * b) % MOD; }
inline ll sub(ll a, ll b){ ll c = a - b; if(c < 0) c += MOD; return c; }
inline ll add(ll a, ll b){ ll c = a + b; if(c > MOD) c -= MOD; return c; }
ll sqr(ll x)
{
    return x*x;
}
 //////////////////////*********CODE***********/////////////////////
 //////////////////////////////////////////////////////////////////


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n ; cin>>n;
    ll val = 100;
    int year = 0;
    while(1){
        val = val + 0.01*val;
        year ++;
        if(val >= n)break;

    }
    cout << year;
    return 0;
}

    


Measured memory_bytes: 3664
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<queue>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SORT(list) sort(ALL((list)));
#define MOD 1000000007
using namespace std;
using ll = long long;
int main(){
    ll n;
    cin >> n;
    ll a,b;
    for(ll i = 1;i*i <= n;i++){
        if(n%i == 0){
            a = i;
            b = n/i;
        }
    }
    cout << a+b-2 << endl;
    return 0;
}

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

int main(){
    int a, b;
    cin >> a >> b;
    if(a == b){
        cout << "Draw";
    }else if(a == 1){
        cout << "Alice";
    }else if(b == 1){
        cout << "Bob";
    }else if(a > b){
        cout << "Alice";
    }else{
        cout << "Bob";
    }
    return 0;
}

Measured memory_bytes: 256
N = int(input())
Snew =[]
Sold = list(map(int,input().split()))
Snew = Sold[::1]
Snew.sort()
count = 0
for i in range(N):
  if Sold[i] != Snew[i]:
    count += 1
if count <= 2:
  print("YES")
else:
  print("NO")

Measured memory_bytes: 3060
#!/usr/bin/env python3
import sys
input = sys.stdin.readline
def INT(): return int(input())
def MAP(): return map(int,input().split())
def LI(): return list(map(int,input().split()))

def main():
    n = INT()
    P = LI()
    cost = [[min(i, n-i-1, j, n-j-1) for j in range(n)] for i in range(n)]
    issit = [[True for _ in range(n)] for _ in range(n)]
    ans = 0

    for p in P:
        i,j = divmod(p-1,n)
        issit[i][j] = False
        ans += cost[i][j]

        q = [(i, j, cost[i][j])]
        while q:
            n_i, n_j, cur_cost = q.pop()

            if n_i > 0 and cost[n_i-1][n_j] > cur_cost:
                cost[n_i-1][n_j] = cur_cost
                q.append((n_i-1,n_j,cur_cost+issit[n_i-1][n_j]))

            if n_i < n-1 and cost[n_i+1][n_j] > cur_cost:
                cost[n_i+1][n_j] = cur_cost
                q.append((n_i+1,n_j,cur_cost+issit[n_i+1][n_j]))

            if n_j > 0 and cost[n_i][n_j-1] > cur_cost:
                cost[n_i][n_j-1] = cur_cost
                q.append((n_i,n_j-1,cur_cost+issit[n_i][n_j-1]))
 
            if n_j < n-1 and cost[n_i][n_j+1] > cur_cost:
                cost[n_i][n_j+1] = cur_cost
                q.append((n_i,n_j+1,cur_cost+issit[n_i][n_j+1]))
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 188740
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		while (true) {
            int n = sc.nextInt();
            int x = sc.nextInt();
            if(n == 0 && x == 0)
            	break;
            int count = 0;
            for (int i = 1; i <= n; i++) {
                for (int j = i + 1; j <= n; j++) {
                    for (int k = j + 1; k <= n; k++) {
                        if (i + j + k == x) {
                            count++;
                        }
                    }
                }
            }
            System.out.println(count);
        }
    }
	}


Measured memory_bytes: 26956
#include<bits/stdc++.h>
using namespace std;
#define itn int
#define rep(i,x,y) for(int i=x;i<y;i++)
#define range(a) a.begin(),a.end()
#define print(A,n) rep(i,0,n){cout<<(i ? " ":"")<<A[i];}cout<<endl;
#define pprint(A,m,n) rep(j,0,m){print(A[j],n);}
const long mod=1e9+7;
const int size=2e5;
const int INF=1e9;
int N;
long A[size],B[size];//bool check[size]={};
long s,t;long ans=0;
void calculate(int m,int &k){
    if(B[m]<A[m]){ k=1; return; }
	int a=(m-1+N)%N;int c=(m+1)%N;
    long temp=(B[m]-A[m])/(B[a]+B[c]);
    B[m]-=temp*(B[a]+B[c]);
    t-=temp*(B[a]+B[c]);
    ans+=temp;
	if(temp){
		calculate(a,k);
		calculate(c,k);
        k=0;
	}else k=1;
    return;
}
int main(){
	cin>>N;
	rep(i,0,N){ cin>>A[i];s+=A[i]; }
	rep(i,0,N){ cin>>B[i];t+=B[i]; }
	int i=0;int count=0;int k=0;
	while(s!=t&&count<=N){
		calculate(i,k);
        if(k==1) count++;
        else count=0;
		(i+=1)%=N;
	}
    rep(i,0,N){
        if(A[i]!=B[i]){ cout<<-1<<endl; return 0; }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
#define sz(c)      int(c.size())
#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)
using namespace std;
using ll = long long;
using matrix = int[3][3];

int M;

inline int madd(int x,int y) {
	if (x+y<M) return x+y; else return x+y-M;
}
inline int msub(int x,int y) {
	if (x-y>=0) return x-y; else return x-y+M;
}
inline int mmul(int x,int y) {
	return int(ll(x)*y % M);
}
void matmul(matrix &res, const matrix &A, const matrix &B,
            int n, int p, int m) {  // res[n x m] = A[n x p] * B[p x m]
	static matrix tmp;
	rep(i,0,n) rep(j,0,m) tmp[i][j]=0;
	rep(i,0,n) rep(j,0,m) rep(k,0,p) {
		tmp[i][j]=madd(tmp[i][j], mmul(A[i][k],B[k][j]));
	}
	rep(i,0,n) rep(j,0,m) res[i][j]=tmp[i][j];
}
void matpow(ll pow, matrix &res, const matrix &A,
            int n, int m) {  // res[n x m] = res[n x m] * (A[m x m]^pow)
	static matrix tmp;
	rep(i,0,m) rep(j,0,m) tmp[i][j]=A[i][j];

	while (pow>0) {
		if (pow%2) matmul(res,res,tmp,n,m,m);
		matmul(tmp,tmp,tmp,m,m,m);
		pow/=2;
	}
}

int len(ll x) {
	assert(x>0);
	int res=0;
	while (x>0) {
		x/=10;
		res++;
	}
	return res;
}

ll find_len(ll L,ll A,ll B) {
	int z=len(A);
	ll l=0,r=L;
	while (l<r) {
		ll m=l+(r-l)/2;
		if (z==len(A+B*m)) l=m+1; else r=m;
	}
	return l;
}

int main() {
	cin.tie(0);
	ios_base::sync_with_stdio(0);
	cout<<fixed<<setprecision(10);

	ll L,A,B;
	cin>>L>>A>>B>>M;
	
	int sum=0;
	while (L>0) {
		ll k=find_len(L,A,B);
		int p=1;
		rep(i,0,len(A)) p=mmul(p,10);
		matrix r={{sum,int(A%M),1}};
		matrix X={{p,0,0},
		          {1,1,0},
		          {0,int(B%M),1}};
		matpow(k,r,X,1,3);
		
		sum=r[0][0];
		L-=k;
		A+=B*k;
	}
	
	cout<<sum<<"\n";
}


Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const ll mod = 1e9 + 7;
ll modpow(ll A, ll B) {
	ll kotae = 1;
	while (B > 0) {
		if (B & 1) kotae = kotae * A % mod;
		A = A * A % mod;
		B >>= 1;
	}
	return kotae;
}

ll kotae = 0;
int N;
vector<int> E[200001];
int dfs(int v, int prev) {
	int kazu = 1;
	int honsuu = 0;

	for (int to : E[v]) {
		if (to != prev) {
			int k = dfs(to, v);
			kazu += k;
			honsuu++;
			kotae += modpow(2, k) - 1;
			kotae %= mod;
		}
	}
	if (honsuu == 0) {
		kotae += modpow(2, N - 1);
	}
	else if (prev == 0 && honsuu == 1) {
		kotae += 1;
	}
	else {
		kotae += 1;
		if (prev) {
			int k = N - kazu;
			kotae += modpow(2, k) - 1;
			kotae %= mod;
		}
	}
	kotae = (kotae + mod) % mod;

	return kazu;
}

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


	cin >> N;
	rep(i, N - 1) {
		int a, b;
		cin >> a >> b;
		E[a].pb(b);
		E[b].pb(a);
	}
	dfs(1, 0);
	ce(kotae);
	ll igai = modpow(2, N - 1) * N % mod;
	kotae = (igai - kotae + mod) % mod;


	ll waru = modpow(2, N);
	kotae = kotae * modpow(waru, mod - 2) % mod;

	co(kotae);

	Would you please return 0;
}

Measured memory_bytes: 22272
#include <iostream>
#include <string>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <list>
#include <iomanip>
#include <vector>
#include <functional>
#include <algorithm>
#include <cstdio>
#include <random>
#include <ctime>
#include <cstdlib>
#include <unordered_map>
#include <string.h>
#include <iostream>

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(begin, i, end) for (int i = begin; i < (int)(end); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1000000007;

int main()
{
    string S;
    cin >> S;
    sort(all(S));
    rep(0, i, S.size() - 1)
    {
        if (S.at(i) == S.at(i + 1))
        {
            cout << "no" << endl;
            return 0;
        }
    }
    cout << "yes" << endl;
}

Measured memory_bytes: 256
N = int(input())
plans = [list(map(int, input().split())) for _ in range(N)]
dp = [[0] * (3) for _ in range(N+1)]

def chmax(a, b):
    if a >= b:
        return a
    else:
        return b

for i in range(N):
    for j in range(3):
        for k in range(3):
            if j == k:
                continue
            else:
                dp[i+1][k] = chmax(dp[i+1][k], dp[i][j] + plans[i][k])
                
res = 0
for j in range(3):
    res = chmax(res, dp[-1][j])
print(res)

Measured memory_bytes: 47336
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int a = sc.nextInt();
		List<Info> list = new ArrayList<Info>();
		int minX = 101;
		int minY = 101;
		int maxX = -1;
		int maxY = -1;
		for (int i = 0; i < a; i++) {
			int x = sc.nextInt();
			int y = sc.nextInt();
			int h = sc.nextInt();
			list.add(new Info(x, y, h));
			minX = Math.min(minX, x);
			minY = Math.min(minY, y);
			maxX = Math.max(maxX, x);
			maxY = Math.max(maxY, y);
		}
		boolean flag = true;
		for (int x = minX; x <= maxX; x++) {
			for (int y = minY; y <= maxY; y++) {
				flag = true;
				int distance;
				long height = 0;
				for (Info i : list) {
					if (i.h != 0) {
						distance = Math.abs(x - i.x) + Math.abs(y - i.y);
						height = distance + i.h;
						break;
					}
				}
				for (Info i : list) {
					int dis = Math.abs(x - i.x) + Math.abs(y - i.y);
					if(height - dis < 0 && i.h == 0) {

					} else if (height != dis + i.h) {
						flag = false;
						break;
					}

				}

				if (flag) {
					System.out.println(x + " " + y + " " + height);
					break;
				}
			}
			if (flag) {
				break;
			}
		}

	}
}

class Info {
	int x;
	int y;
	long h;

	public Info(int x, int y, long h) {
		super();
		this.x = x;
		this.y = y;
		this.h = h;
	}
}


Measured memory_bytes: 25300
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define MOD (ll) (1e9+7)
int main()
{
  ll w,s;
  cin>>s>>w;
  if(w>=s)
  {
    cout<<"unsafe\n";
  }
  else{
    cout<<"safe\n";
  }
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
#define ll long long
#define int long long

#define sz(c) c.size()
#define fr first
#define sc second
#define pb push_back
#define sz(c) c.size()
#define ppb  pop_back
#define all(a)      (a).begin(),(a).end()
#define rep(i,a,n)   for( int i=a ; i<n ; i++)
#define U 1000000007
#define N 100005
#define ins insert
using namespace std;
signed main()
{
  ios_base::sync_with_stdio(false);
  int n;
  cin>>n;
  long double p[n+1];
  p[0]=0;
  rep(i,1,n+1) cin>>p[i];

  long double dp[n+1][n+1];
  dp[0][0]=1;
  rep(j,1,n+1) dp[0][j]=0;
  rep(i,1,n+1)
  {
    rep(j,0,n+1)
    {
      if(j==0)
        dp[i][j] = dp[i-1][j]*(1-p[i]);
      else
        dp[i][j] = (dp[i-1][j-1]*p[i] + dp[i-1][j]*(1-p[i]));
      //cout<<dp[i][j]<<" ";
    }
   // cout<<endl;
  }

  long double ans=0;
  rep(i,n/2+1,n+1) ans+=dp[n][i];

  cout<<setprecision(11)<<ans;

 



}

Measured memory_bytes: 140928
#include <bits/stdc++.h>
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i,a,b) for (ll i=(a);i<(ll)b; i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define INF 1000000000000000
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; }
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll,ll> p;
constexpr int MOD = 1000000007;

void print(const std::vector<int>& v)
{
  std::for_each(v.begin(), v.end(), [](int x) {
    std::cout << x << " ";
  });
  std::cout << std::endl;
}

int main ()
{
    int N;    cin>>N;
    vector<int> V(N),C(N),D(N);
    REP(i,N) cin>>V[i];
    REP(i,N) cin>>C[i];
    REP(i,N) D[i] = V[i] - C[i];
    ll ans = 0;
    REP(i,N){
        if(D[i]>0) ans += D[i];
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <queue>
#include <string>
#include <set>
#include <map>
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)
#define INF 1000000000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;

int main(){
  ll x,y;
  cin >> x >> y;
  ll ans = 0;
  while(x<=y){
    ans++;
    x = x * 2;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <numeric>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

#define rep(i, N) for(int i = 0; i < N; ++i)

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

#define IN(l, r, x) ((l) <= (x) && (x) < (r))


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

    string s;
    cin >> s;
    if (s == "ABC") cout << "ARC\n";
    else cout << "ABC\n";

    return 0;
}



Measured memory_bytes: 3612
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder.Abc
{
    class A_162_Lucky7
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            // 文字列の入力
            string s = Console.ReadLine();

            if (s.Contains("7") == true)
            {
                Console.WriteLine("Yes");
            }
            else if (s.Contains("7") == false)
            {
                Console.WriteLine("No");
            }

            Console.Out.Flush();
        }
    }
}


Measured memory_bytes: 25848
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1 {
    class Program {
        static void Main(string[] args) {
            var s = Console.ReadLine().Split();
            var n = long.Parse(s[0]);
            var l = long.Parse(s[1]);
            var a = Console.ReadLine().Split().Select(long.Parse).ToArray();
            var pos = new long();
            bool flag = true;
            for (int i = 0; i < n - 1; i++) {
                if (a[i + 1] + a[i] >= l) {
                    flag = false;
                    pos = i;
                    break;
                }
            }
            if (!flag) {
                Console.WriteLine("Possible");
                for (long i = 0; i < pos; i++) {
                    Console.WriteLine(i + 1);
                }
                for (long i = n - 1; i > pos; i--) {
                    Console.WriteLine(i);
                }
            }
            else {
                Console.WriteLine("Impossible");
            }
        }
    }
}


Measured memory_bytes: 31748
n, m, l = map(int, input().split())
a = [list(map(int, input().split())) for i in range(n)]
b = [list(map(int, input().split())) for i in range(m)]

c = [[0] * l for i in range(n)]
for i in range(n):
    for j in range(l):
        for k in range(m):
            c[i][j] += a[i][k] * b[k][j]
    print(*c[i])


Measured memory_bytes: 7032
#include<stdio.h>
#include<math.h>
int main()
{
    int n, m, q, i, c, k, score=0, max;
    scanf("%d%d%d", &n, &m, &q);

    int seq[n], ai[50], bi[50], ci[50], di[50];

    for(i=0; i<q; i++){
        scanf("%d%d%d%d",  &ai[i], &bi[i], &ci[i], &di[i]);
    }

    for(i=0; i<n; i++){
        seq[i]=1;
    }
    max=score;
    while(1){

        score=0;
        for(i=0; i<q; i++){
            if((seq[bi[i]-1]-seq[ai[i]-1])==ci[i]){
                score+=di[i];
            }
        }
        if(max<score){
            max=score;
        }

        if(seq[0]==m) break;

        seq[n-1]++;

        if(seq[n-1]>m){
            for(c=n-1; c>=0; c--){
                if(seq[c]>m){
                    seq[c-1]++;
                    for(k=c; k<n; k++){
                        seq[k]=seq[c-1];
                    }
                }
                else break;
            }
        }
    }

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

Measured memory_bytes: 1732
n,k = map(int, input().split())
P = list(map(int, input().split()))
a = []
for p in P:
    a.append((1+p)/2)
ans = [sum(a[:k])]
for i in range(1,len(a)-(k-1)):
    ans.append(ans[-1]-a[i-1]+a[i+k-1])
print(max(ans))

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

// typedef
// -----------------------------------------------------------------------------
typedef long long ll;
typedef long double ld;

// container util
// -----------------------------------------------------------------------------
#define ALL(c)  (c).begin(),(c).end()
#define SZ(c) ((ll)(c).size())
#define MAX(c) *max_element(ALL(c))
#define MIN(c) *min_element(ALL(c))
#define SORT(c) sort((c).begin(),(c).end())

// repetition
// -----------------------------------------------------------------------------
#define FOR(i, a, b) for(int i= (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)

// constant
// -----------------------------------------------------------------------------
const int INF = 1e9;
const int MOD = 1e9 + 7;
const double EPS = 1e-9;
const double PI = acos(-1.0);

// debug
// -----------------------------------------------------------------------------
#define DUMP(x)  cerr << #x << " = " << (x) << endl


int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(15);
    char a; cin >> a;
    if (isupper(a)) {
        cout << "A" << "\n";
    } else {
        cout << "a" << "\n";
    }
}

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

#define fr(i,n) for(int i = 0; i<n; i++)
#define sz(v) (int)(v.size())
#define prin(a) cout << #a << " = " << a << endl
#define all(v) (v).begin(),(v).end()

typedef long long ll;

int main(){
	ll n; cin >> n;
	
	vector<pair<ll,ll>> v;
	
	for(ll i = 2; i*i<=n; i++){
		if(n%i==0){
			int freq = 0;
			while(n%i==0){
				n/=i;
				freq++;
			}
			v.emplace_back(i,freq);
		}	
	}
	if(n>1) v.emplace_back(n,1);
	
	int ans = 0;
	for(auto &par : v){
		ll p, k; tie(p,k) = par;
		int add = 1;
		int cur = 0;
		while(cur+add<=k){
			cur+=add;
			add++;
		}
		add--;
		ans+=add;
	}
	
	cout << ans << endl;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
#define rep(i,n) for (ll i=0;i<n;++i)
const ll MOD=1000000007;

int main(){
    int N;
    ll C;
    cin >> N >> C;
    vector<ll> x(N),y(N),vx(N),vy(N);
    rep(i,N){
        cin >> x[i] >> vx[i];
        y[N-1-i]=C-x[i];
        vy[N-1-i]=vx[i];
    }
    rep(i,N-1){
        vx[i+1]+=vx[i];
        vy[i+1]+=vy[i];
    }
    vector<ll> vvx(N),vvy(N);
    vvx[0]=vx[0]-x[0];
    vvy[0]=vy[0]-y[0];
    rep(i,N-1){
        vvx[i+1]=max(vvx[i],vx[i+1]-x[i+1]);
        vvy[i+1]=max(vvy[i],vy[i+1]-y[i+1]);
    }
    ll ans=0;
    rep(i,N){
        ans=max(max(ans,vvx[N-1]),vvy[N-1]);
    }
    rep(i,N-1){
        ans=max(max(ans,vx[i]-2*x[i]+vvy[N-i-2]),vy[i]-2*y[i]+vvx[N-i-2]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 4992
#include <iostream>
#include <cmath>
#include <algorithm>
using namespace std;
int main() {
	double d,w,h,n,r,a,b,c,m;
	while(cin>>d>>w>>h,d!=0&&w!=0&&h!=0){
		a=sqrt(d*d+w*w);
        b=sqrt(d*d+h*h);
        c=sqrt(w*w+h*h);
		m=min(a,min(b,c));
		cin>>n;
		while(n--){
			cin>>r;
			r=r*2;
			if(m<r)cout<<"OK\n";
			else cout<<"NA\n";
		}
	}
	return 0;
}

Measured memory_bytes: 1184
#include <iostream>
#include <iomanip>
typedef long long ll;
using namespace std;
const ll INF = 1e9;
const ll MOD = 1e9 + 7;
#define repi(i, n, init) for (ll i = init; i < (n); i++)

int main()
{
    int x;
    cin >> x;
    int cnt = x / 100, exc = x % 100;
    if (cnt == 0)
    {
        cout << 0 << endl;
    }
    else if (exc == 0)
    {
        cout << 1 << endl;
    }
    else
    {
        repi(i, cnt + 1, 1)
        {
            if (5 * (i - 1) < exc && exc <= 5 * i)
            {
                cout << 1 << endl;
                return 0;
            }
        }
        cout << 0 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <deque>
using namespace std;
using P = pair<int,int>;
typedef long long int ll;
#define rep(i, n) for (int(i) = 0; (i) < (n); (i)++)

int main(){ 
  ll x; cin >> x;
  ll time=0;
  ll now = 0;
  while(1){
    if(now>=x)break;
    time++;
    now+=time;
  }
  cout << time << endl;
  return 0;
}




Measured memory_bytes: 256
N=int(input())
T= list(map(int,input().split())) ##Time for each prob

M=int(input())
P=[None for i in range(M)]
X=[None for i in range(M)]

for i in range(M):
    P[i],X[i]= input().split()

P= list(map(int,P)) ##Index of drink
X= list(map(int,X)) ##Time for problem after drink


for i in range (M):
    temp= T[P[i]-1]

    T[P[i]-1]=X[i]
    print(sum(T))
    T[P[i] - 1]=temp

Measured memory_bytes: 3064
#include <cstdio>
#include <iostream>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); ++i(

typedef long long ll;
int main(void) {
  int a, b;
  cin >> a >> b;
  int res = 0;
  for(int i = 1; i <= a; ++i) {
    if(i < a || a <= b) {
      ++res;
    }
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x) for(ll i = 0; i < (ll)(x); i++)
#define rrep(i,x) for(ll i = (ll)(x)-1;0 <= i; i--)
#define reps(i,x) for(ll i = 1; i < (ll)(x)+1; i++)
#define rreps(i,x) for(ll i = (ll)(x); 1 <= i; i--)
#define debug(x) cerr << #x << ": " << (x) << "\n";
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<ll>>> vvvl;
const ll INF = numeric_limits<ll>::max()/4;
const int n_max = 1e5+10;
#define int ll

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    ll n; cin >> n;
    vector<ll> a(n);
    rep(i,n) cin >> a[i];
    vector dp(n+1, 0LL);
    ll sum = a[0];
    dp[0] = dp[1] = 0;
    for(int i = 2; i <= n; i++) {
        if(i % 2 == 0){
            dp[i] = max(dp[i-2] + a[i-1], sum);
            if(i < n)sum += a[i];
        }
        else {
            dp[i] = max(dp[i-2] + a[i-1], dp[i-1]);
        }
    }

    cout << dp[n] << endl;
}


Measured memory_bytes: 6364
n = int(input())
li = list(map(int,input().split()))
s = sum(li)
lee = len(li)
kumi = lee//2
tmp = 0
for i in range(1,kumi+1):
    tmp += 2*li[2*(i-1)]
last = s - tmp
#print(last)
first = li[-1]*2-last
ans_li = [first]
for l in li:
    target = ans_li[-1]
    ans_li.append(l*2-target)
ans_li.pop(-1)
print(*ans_li)

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

int main(void){
  int n, k, x, y, sum;
  cin >> n >> k >> x >> y;
  if(n > k){
    sum = k*x;
    sum += (n-k)*y;
  }else{
    sum = n*x;
  }
  cout << sum << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <math.h>
#include <sstream>
#include <numeric>
#include <string>
#include <cassert>

using namespace std;
typedef long long ll;

int main() {
  int N;
  cin >> N;
  vector<pair<int, int> > vp;
  for (int id = 1; id <= N; ++id) {
    int A;
    cin >> A;
    vp.push_back(make_pair(A, id));
  }
  sort(vp.begin(), vp.end());
  for (auto p : vp) {
    cout << p.second << " ";
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 1780
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace AtCoder
{
	public class ABC
	{
		static public void Main(string[] args)
		{
			Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });
			Solve(args);
			Console.Out.Flush();
		}

		private const int mod = 1000000007;  // 10^9+7

		static public void Solve(string[] args)
		{
			//string s = Console.ReadLine();
			int n = int.Parse(Console.ReadLine());
			//long x = long.Parse(Console.ReadLine());
			//int[] vs = Console.ReadLine().Split().Select(int.Parse).ToArray();
			//long[] vs = Console.ReadLine().Split().Select(long.Parse).ToArray();

			HashSet<string> set = new HashSet<string>();
			for (int i = 0; i < n; i++) {
				string s = Console.ReadLine();
				if (!set.Contains(s)) {
					set.Add(s);
				}
			}
			Console.WriteLine(set.Count);
		}

	}
}


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

int main(){
  int D;
  cin >> D;
  if(D==22){
    cout << "Christmas Eve Eve Eve" << endl;
  }
  else if(D==23){
    cout << "Christmas Eve Eve " << endl;
  }
  else if(D==24){
    cout << "Christmas Eve" << endl;
  }
  else{
    cout << "Christmas" << endl;
  }
}

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

int main() {
	int n, m;
	priority_queue<int>pq;
	cin >> n >> m;
	for (int i = 0; i < n; i++) {
		int x;
		cin >> x;
		pq.push(x);
	}

	for (int i = 0; i < m; i++) {
		int price = pq.top(); 
		pq.pop();
		price /= 2;
		pq.push(price);
	}
	long long sum = 0;
	for (int i=0; i < n; i++) {

		int price = pq.top();
		pq.pop();
		sum += price;
	}

	cout << sum << endl;

	return 0;
}

Measured memory_bytes: 892
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
    int K, A, B;
    cin >> K >> A >> B;
    string ans = "NG";
    for (int i = A; i <= B; i++)
    {
        if(i%K==0)ans = "OK";
    }
    

    cout << ans << endl;
}

Measured memory_bytes: 3632
import heapq
X, Y, Z, K = map(int,input().split())
A = list(map(lambda x: -1 * int(x),input().split()))
B = list(map(lambda x: -1 * int(x),input().split()))
C = list(map(lambda x: -1 * int(x),input().split()))
A.sort()
B.sort()
C.sort()
Q = []
heapq.heappush(Q, (A[0] + B[0] + C[0], 0, 0, 0))
for _ in range(K):
    SUM, a, b, c = heapq.heappop(Q)
    print(-1 * SUM)
    if a <= X - 2 and not (A[a+1] + B[b] + C[c], a+1, b, c) in Q:
        heapq.heappush(Q, (A[a+1] + B[b] + C[c], a+1, b, c))
    if b <= Y - 2 and not (A[a] + B[b+1] + C[c], a, b+1, c) in Q:
        heapq.heappush(Q, (A[a] + B[b+1] + C[c], a, b+1, c))
    if c <= Z - 2 and not (A[a] + B[b] + C[c+1], a, b, c+1) in Q:
        heapq.heappush(Q, (A[a] + B[b] + C[c+1], a, b, c+1))

Measured memory_bytes: 3956
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
typedef long long ll;
typedef pair<int, int> P;
typedef pair<pair<int, int>, int> PP;
typedef bitset<60> Bitset;
const ll INFL = 1LL << 60;
const int INF = 500000;
const int MAX = 300000;
const int MOD = 1000000007;
ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
ll LCM(ll a, ll b) { return (a * b) / GCD(a, b); }
//------------------------------------------------------------------------------------------------------------------------------


int main(void) {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n,w = 0,r = 0;cin>>n;
    int W = 0,R = 0;
    int ans = INF;
    string s;cin>>s;
    for(int i = 0; i < n; i++) {
        if(s[i]=='W') W++;
        else R++;
    }
    if(W==0||R==0){
        cout<<0<<endl;
        return 0;
    }
    for(int i = 0; i < n; i++) {
        if(s[i]=='W') w++;
        else r++;
        int t = min(w,R-r);
        ans = min(ans,w+R-r-t);
    }
    cout<<ans<<endl;
}


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

int main() {
    int N;
    int t[110000], x[110000], y[110000];
    cin >> N;
    t[0] = x[0] = y[0] = 0;  // 初期状態
    for (int i = 0; i < N; ++i) cin >> t[i+1] >> x[i+1] >> y[i+1];  // 1-index にしておく

    bool can = true;
    for (int i = 0; i < N; ++i) {
        int dt = t[i+1] - t[i];
        int dist = abs(x[i+1] - x[i]) + abs(y[i+1] - y[i]);
        if (dt < dist) can = false;
        if (dist % 2 != dt % 2) can = false;  // dist と dt の偶奇は一致する必要あり！
    }

    if (can) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 4712
import java.io.PrintWriter
import java.util.*
import java.math.*
import java.lang.*

val pw = PrintWriter(System.out)
val MOD: Long = (1e+9 + 7).toLong()

fun main(args: Array<String>) {
    val n = readInt()
    val plans = mutableListOf<Triple<Int, Int, Int>>()
    for(i in 0 until n) {
        val (t, x, y) = readListOfInt()
        plans.add(Triple(t, x, y))
    }

    var isAble = true
    var cpos = Triple(0, 0, 0)
    plans.forEach { next ->
        val(ct, cx, cy) = cpos
        val(nt, nx, ny) = next
        val route = Math.abs(nx - cx) + Math.abs(ny - cy)
        val t = nt - ct
        if(!(t >= route && t % 2 == route % 2)) {
            isAble = false
        }
    }
    println(if(isAble) "Yes" else "No")


    pw.flush()
}

/****** Decrared Functions and Data Structures ******/
// IO
fun read() = readLine()!!
fun readInt() = read().toInt()
fun readLong() = read().toLong()
fun readDouble() = read().toDouble()
fun readListOfString() = read().split(" ")
fun readListOfInt() = readListOfString().map { it.toInt() }
fun readListOfLong() = readListOfString().map { it.toLong() }
fun readListOfDouble() = readListOfString().map { it.toDouble() }

fun Double.format(digits: Int) = String.format("%.${digits}f", this)

fun print(value: Any) { pw.print(value) }
fun println(value : Any) { pw.println(value) }

fun<T> permutations(src: List<T>): List<List<T>> {
    if(src.size == 1) return listOf(src)
    val perms = mutableListOf<List<T>>()
    val insertElement = src[0]
    permutations(src.drop(1)).forEach { perm ->
        for(i in 0..perm.size) {
            val newPerm = perm.toMutableList()
            newPerm.add(i, insertElement)
            perms.add(newPerm.toList())
        }
    }
    return perms
}

// return nCr, if you want nCr, please access v[n][r]
fun combinations(n: Long): List<List<Long>> {
    val v = (0..n).map { (0..n).map{0L}.toMutableList() }.toMutableList()
    for(i in 0 until v.size) {
        v[i][0] = 1L
        v[i][i] = 1L
    }
    for(i in 0 until v.size) {
        for(j in 1 until i) {
            v[i][j] = (v[i-1][j-1] + v[i-1][j] % MOD)
        }
    }
    val rtn = v.map { it.toList() }.toList()
    return rtn 
}

fun gcd(a: Long, b: Long): Long = 
if(b != 0L) a else gcd(b, a % b)

fun lcm(a: Long, b: Long) = 
if(b==0L) a else gcd(b, a % b)

fun sumDigits(num_: Long): Long {
    var num = num_
    var rtn: Long = 0
    while(num != 0.toLong()) {
        val tmp = num % 10
        rtn += tmp
        num /= 10
    }
    return rtn
}

fun isDecimal(v: Double): Boolean = ((v - Math.floor(v)) != 0.0)

// Data Structures
class Stack<T>(private var st: MutableList<T> = mutableListOf<T>()) {
    fun isEmpty() = st.isEmpty()
    fun top(): T = st.last()
    fun push(e: T) { st.add(e) }
    fun pop() { st = st.dropLast(1).toMutableList() }
}

class Queue<T>(private var que: MutableList<T> = mutableListOf<T>()) {
    fun isEmpty() = que.isEmpty()
    fun top(): T = que.first()
    fun push(e: T) { que.add(e) }
    fun pop() { que = que.drop(1).toMutableList() }
}


Measured memory_bytes: 68788
x, y = map(int, input().split())
if (x+y)%3 != 0:
    print(0)
    exit()

def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod
 
mod = 10**9+7
N = 10**6
g1 = [1, 1]
g2 = [1, 1]
inverse = [0, 1]
 
for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )
 
 
a = (2*x-y)//3
b = (2*y-x)//3
n = a+b
r = a
res = cmb(n,r,mod)
print(res)

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

int main() {
  int64_t n, m, s = 0, t = 0;
  cin >> n >> m;
  vector<pair<int64_t, int64_t>> v(n);
  rep(i, n) cin >> v[i].first >> v[i].second;
  sort(v.begin(), v.end());
  rep(i, n){
    if(t + v[i].second >= m){
      s += (m-t) * v[i].first;
      break;
    }
    else{
      s += v[i].first * v[i].second;
      t += v[i].second;
    }
  }
  cout << s << endl;
  return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define il inline
#define re register
#define debug printf("Now is Line : %d\n",__LINE__)
#define file(a) freopen(#a".in","r",stdin);freopen(#a".out","w",stdout)
#define rep(i, a, b) for(re int i = (a); i <= (b); ++ i)
#define drep(i, a, b) for(re int i = (b); i >= (a); -- i)
#define Next(i, u) for(re int i = head[u]; i; i = e[i].next)
#define mem(k, p) memset(k, p, sizeof(k))
#define D double
#define inf 1023456789
#define mod 1000000007
#define lb(x) (x)&(-(x))
il int read() {
    re int x = 0, f = 1; re char c = getchar();
    while(c < '0' || c > '9') { if(c == '-') f = -1; c = getchar();}
    while(c >= '0' && c <= '9') x = x * 10 + c - 48, c = getchar();
    return x * f;
}
#define maxn 1000005
int n, m, ch[maxn][27], rt, cnt, is[1000005][27], ton[27], fa[1000005], pax, ans;
struct node {
    string c;
    int len;
}e[maxn];
il bool cmp(node a, node b) {
    return a.len > b.len;
}
il void insert(int &now, int pa, int x) {
    if(x == -1) return;
    if(!now) now = ++ cnt;
    pax = now;
    insert(ch[now][e[pa].c[x] - 'a' + 1], pa, x - 1);
    fa[ch[now][e[pa].c[x] - 'a' + 1]] = now;
}
il int find(int now, int pa, int x) {
    if(x == 0) return is[now][e[pa].c[0] - 'a' + 1];
    if(ch[now][e[pa].c[x] - 'a' + 1]) return find(ch[now][e[pa].c[x] - 'a' + 1], pa, x - 1);
    return 0;
}
signed main() {
	n = read();
    rep(i, 1, n) cin >> e[i].c, e[i].len = e[i].c.size();
    sort(e + 1, e + n + 1, cmp);
    rep(i, 1, n) {
        ans += find(rt, i, e[i].len - 1);
        insert(rt, i, e[i].len - 1);
        rep(j, 0, e[i].len - 1) {
            ton[e[i].c[j] - 'a' + 1] = 1;
            rep(k, 1, 26) is[pax][k] += ton[k];
            pax = fa[pax];
        }
        rep(i, 1, 26) ton[i] = 0;
    }
    cout << ans;
	return 0;
}

Measured memory_bytes: 300636
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
#include <deque>
#include <iomanip>
#include <limits>
#include <fstream>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int X; cin >> X;
  string week[7] = {"mon", "tue", "wed", "thu", "fri", "sat", "sun"};
  int i = 5;
  for(int j = 0; i + j <= 30; j++){
    int k = (i + j) % 7;
    if(j + 9 == X) {
      cout << week[k] << endl;
      return 0;
    }
  }
  FOR(j,1,9){
    int k = (i - j + 7) % 7;
    if(9 - j == X) {
      cout << week[k] << endl;
      return 0;
    }
  }
}



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

int main() {
  int long N,B,R,count,sum;
  
  cin >> N >> B >> R;
  count = N/(B+R);
  for (int long i=0; i<count; i++) {
    sum += B;
  }
  
  if (N - count*(B+R) >= B) {
    sum += B;
  } else {
    sum += N - count*(B+R);
  }
  cout << sum << endl;
}

Measured memory_bytes: 256