akhauriyash/Code-Regression huggingface dataset:
N, M = map(int,input().split())
pyi = [[] for n in range(N)]#県ごとの配列
for i in range(M):
    p, y = map(int,input().split())
    pyi[p-1].append([y,i])
    #最終的にはinput順より誕生年と順番組にして保存
#print(pyi)

ans = []#出力用配列
for i in range(N):
    pyi[i].sort()  #県ごとに誕生した年順に
    for j in range(len(pyi[i])): #県の中での出力準備
        ans.append([(6-len(str(i+1)))*"0" + str(i+1) + (6-len(str(j+1)))*"0" + str(j+1),pyi[i][j][1]])
        
ans.sort(key=lambda x:x[1])
for m in range(M):
    print(ans[m][0])


Measured memory_bytes: 50004
#include <stdio.h>

int main(void){
  int n, m, a, i;
  scanf("%d %d", &n, &m);
  while(scanf("%d", &a) != EOF && i++ < m){
    n -= a;
    if(n < 0){
      n = -1;
      break;
    }
  }
  printf("%d\n", n);
  return 0;
}

Measured memory_bytes: 1720
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
int INF = 1e9+7;
int mod = 1e9+7;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
signed main() {
    int N;
    cin >> N;
    int cnt = 0;
    vector<int>a(N);
    vector<int>b(N);
    for(int i = 0; i < N; i++) cin >> a[i];
    for(int i = 0; i < N; i++) cin >> b[i];
    for(int i = 0; i < N; i++) {
        if(a[i] > b[i]) {
            cnt-=a[i]-b[i];
        }
        else {
            cnt+=(b[i]-a[i]+1)/2-(b[i]-a[i])%2;
        }
    }
    if(cnt < 0) {
        cout << "No" << endl;
    }
    else {
        cout << "Yes" << endl;
    }
}


Measured memory_bytes: 3772
# include <stdio.h>
 int  getMiddle(int left,int right);
int a[100000];
int n;
int main()
{
	scanf("%d",&n);
	for (int i = 0;i < n; i++)
	scanf("%d",&a[i]);
	int v = getMiddle(0,n-1);
    for(int i = 0; i < n-1 ;i++)
    {
    	if(i == v)
    	{
    		printf("[%d] ",a[i]);
		}else{
			printf("%d ",a[i]);
		}
	}
	printf("%d\n",a[n-1]);
 } 
 
 int  getMiddle(int left,int right)
 {
 	int i = left - 1;
 	for(int j = left; j < right; j++)
 	{
 		if(a[j]<=a[right]){
 			i++;
 			int tem = a[j];
 			a[j] = a[i];
 			a[i] = tem;
		 }
	 }
	 	int tem = a[right];
 			a[right] = a[i + 1];
 			a[i + 1] = tem;
	 return i + 1;
 }


Measured memory_bytes: 3132
a, b = map(int, input().split())
s = input()
flag = 0
for i in range(len(s)):
    if i != a and s[i] == "-":
        flag = 1
    if i == a and s[i] != "-":
        flag = 1

if flag == 0:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3060
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
typedef pair<double, long long> pdl;

const long double pi = 3.141592653589793;

#define debug(x) cout << #x << " = " << (x) << endl;
#define rep(i, n) for(int i = 0;i < n;i++)
#define pb push_back
#define mp make_pair
#define mod 1000000007

int N, K;
vector<ll> A(15);
vector<ll> B(15);

int set_bits(int j) {
	int counter = 0;
	while (j != 0) {
		counter += j%2;
		j = j>>1;
	}
	return counter;
}

int main() {
  	//freopen("input.in","r",stdin);
  	//freopen("output.out","w",stdout);
	cin>>N>>K;
	rep(i, N) cin>>B[i];
	ll min_cost = LONG_LONG_MAX;
	int pw = pow(2, N);
	rep(i, pw) {
		if(set_bits(i) != K) continue;
		rep(i, N) A[i] = B[i];
		ll cost = 0;
		int maxindex = 0;
		for(int j = 1;j < N;j++) {
			if(1<<j & i) {
				if(A[j] > A[maxindex]) {
					maxindex = j;
					continue;
				}

				cost += A[maxindex]-A[j]+1;
				A[j] = A[maxindex]+1;
				maxindex = j;

			} else {
				if(A[j] > A[maxindex])
					maxindex = j;
			}
		}

		//debug(K);
		min_cost = min(min_cost, cost);
	}

	cout<<min_cost<<endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
int main()
{
    string S; cin >> S;
    int A = 0, B = 0, C = 0, N = S.size();
    for (auto c : S) (c == 'a' ? A : c == 'b' ? B : C)++;
    if (max({A, B, C}) <= (N + 2) / 3) {
        cout << "YES\n";
    } else {
        cout << "NO\n";
    }
    return 0;
}

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

int main() {
	long long n, a, b;
	cin >> n >> a >> b;
	long long ans = 0;
	if (a > b) {
		cout << 0 << endl;
		return 0;
	}
	if (a == b) {
		cout << 1 << endl;
		return 0;
	}
	if (n < 2) {
		cout << 0 << endl;
		return 0;
	}
	ans = (n - 1)*b + a - (n - 1)*a - b + 1;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner

import scala.collection.mutable.ListBuffer
import scala.util.control.Breaks

object Main {
  def main (args: Array[String]) = {
    val in = new Scanner(System.in)
    var list = new ListBuffer[Int]

    val brk = new Breaks
    brk.breakable {
      while (true) {
        val next = in.nextLine.toInt
        if (0 != next) list += next else brk.break()
      }
    }

    list.zipWithIndex.foreach{ v =>
      println("Case %d: %d" format(v._2 + 1, v._1))
    }
  }
}

Measured memory_bytes: 100816
//#include <bits/stdc++.h>
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <math.h>
#include <string>
#define FOR(N) for(int i=0;i<N;i++)
#define FOR2(N) for(int j=0;j<N;j++)
using namespace std;
typedef long long ll;


int main() {
	int N, R,S;
	cin >> N >> R;
	if (N >= 10)
		S = R;
	else
		S = (10 - N) * 100 + R;
	cout << S << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);cout.tie(NULL);
        string s;
        cin>>s;
        vector<string>day(7);
        day[0]="SUN";
        day[1]="MON";
        day[2]="TUE";
        day[3]="WED";
        day[4]="THU";
        day[5]="FRI";
        day[6]="SAT";
        for(int j=0;j<7;j++){
                if(day[j]==s){
                        cout<<7-j;
                }
        }
        return 0;
}
/*

        creation time:  13.09.2020 09:23:27

*/                      



Measured memory_bytes: 3532
s=list(map(str,input().split()))
c=[]
for i in range(len(s)):
    if s[i]=="+":
        a=c.pop(-1)
        b=c.pop(-1)
        c.append(b+a)
    elif s[i]=="-":
        a=c.pop(-1)
        b=c.pop(-1)
        c.append(b-a)
    elif s[i]=="*":
        a=c.pop(-1)
        b=c.pop(-1)
        c.append(b*a)
    else:
        c.append(int(s[i]))
print(c[0])
    





Measured memory_bytes: 5604
#include <stdio.h>

int main(){
  int N;
  scanf("%d", &N);
  int i, ans=0;
  for(i=0;i<=N/4;i++){
    if((N-4*i)%7 == 0 && ans == 0){
      puts("Yes");
      ans++;
    }
  }
  if(ans == 0) puts("No");
  return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
int main(int argc, char *argv[])
{
	int a,b,c,max,min;
	scanf("%d%d%d",&a,&b,&c);
	max=(a>b?a:b)>c?(a>b?a:b):c;
	min=(a>b?b:a)>c?c:(a>b?b:a);
	printf("%d\n",max-min);
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<algorithm>
#include<queue>
using namespace std;
const long long inf=0x3f3f3f3f3f3f3f3fll;
const int MOD=1e9+7;
int n,m,S,T;
struct edge
{
	int v,w;
	edge *next,*rev;
}*h[233333],pool[555555];
int top;
inline void addedge(int u,int v,int w)
{
	edge *tmp=&pool[top++];tmp->v=v;tmp->w=w;tmp->next=h[u];h[u]=tmp;
	edge *pmt=&pool[top++];pmt->v=u;pmt->w=w;pmt->next=h[v];h[v]=pmt;
	tmp->rev=pmt;pmt->rev=tmp;
}
long long dis[233333],dp[233333],dp2[233333];
#define mp make_pair
priority_queue<pair<long long,int>,vector<pair<long long,int> >,greater<pair<long long,int> > > q;
int ord[233333],pot;
int main()
{
	scanf("%d%d",&n,&m);
	scanf("%d%d",&S,&T);
	int a,b,c;
	for(int i=1;i<=m;i++)
	{
		scanf("%d%d%d",&a,&b,&c);
		addedge(a,b,c*2);
	}
	memset(dis,0x3f,sizeof(dis));
	q.push(mp(0ll,S));dis[S]=0;
	while(!q.empty())
	{
		int u=q.top().second;
		if(dis[u]!=q.top().first)
		{
			q.pop();
			continue;
		}
		ord[++pot]=u;
		q.pop();
		for(edge *tmp=h[u];tmp;tmp=tmp->next)
		{
			if(dis[tmp->v]>dis[u]+tmp->w)
			{
				dis[tmp->v]=dis[u]+tmp->w;
				q.push(mp(dis[tmp->v],tmp->v));
			}
		}
	}
	//for(int i=1;i<=n;i++)cout<<ord[i]<<' ';cout<<endl;
	dp[S]=1;
	for(int i=1;i<=n;i++)
	{
		int u=ord[i];
		for(edge *tmp=h[u];tmp;tmp=tmp->next)
		{
			if(dis[tmp->v]==dis[u]+tmp->w)
			{
				dp[tmp->v]+=dp[u];
				dp[tmp->v]%=MOD;
			}
		}
	}
	long long half=dis[T]/2,ans=dp[T]*dp[T]%MOD;
//	cout<<"half: "<<half<<endl;
//	cout<<"ans: "<<ans<<endl;
	dp2[T]=1;
	for(int i=n;i>=1;i--)
	{
		int u=ord[i];
		if(dis[u]==half)
		{
			//cout<<"subtracted point "<<u<<','<<dp[u]*dp2[u]<<' '<<dp[u]*dp2[u]%MOD<<endl;
			ans-=dp[u]*dp[u]%MOD*dp2[u]%MOD*dp2[u]%MOD;
			ans%=MOD;
			if(ans<0)ans+=MOD;
		}
		for(edge *tmp=h[u];tmp;tmp=tmp->next)
		{
			if(dis[u]==dis[tmp->v]+tmp->w)
			{
				//cout<<u<<' '<<tmp->v<<' '<<dis[u]<<' '<<dis[tmp->v]<<endl;
				if(dis[u]>half&&dis[tmp->v]<half)
				{
					//cout<<"subtracted "<<u<<" to "<<tmp->v<<endl;
					ans-=dp[tmp->v]*dp[tmp->v]%MOD*dp2[u]%MOD*dp2[u]%MOD;
					ans%=MOD;
					if(ans<=0)ans+=MOD;
				}
				dp2[tmp->v]+=dp2[u];
				dp2[tmp->v]%=MOD;
			}
		}
	}
	//for(int i=1;i<=n;i++)cout<<dp[i]<<' ';cout<<endl;
	//for(int i=1;i<=n;i++)cout<<dp2[i]<<' ';cout<<endl;
	ans%=MOD;
	if(ans<0)ans+=MOD;
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 19440
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i,n) for(int i=0;i<(n);++i)
#define ll long long
const long long INF = 1LL<<60;
const long long mod = 1e9 + 7;
using Graph = vector<vector<int>>;

int main(){
    int N,R;
    cin >> N >> R;
    if(N<10) R+=100*(10-N);
    cout << R << endl;
}

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

int main(){
    long long N, H;
    cin >> N >> H;
    vector<pair<long long, long long>> katana(N);
    for(int i = 0; i < N; i++){
        cin >> katana[i].first >> katana[i].second;
    }
    sort(katana.begin(), katana.end());
    reverse(katana.begin(), katana.end());
    
    long long M = katana[0].first;//振り最強
    
    long long ans = 0;
    
    
    priority_queue<long long> thr;
    for(int i = 0; i < N; i++){
        if(M <= katana[i].second){
            thr.push(katana[i].second);
        }
    }
    
    
    while(!thr.empty() && H > 0){
        H -= thr.top();
        ans++;
        thr.pop();
    }
    
    
    if(H > 0){
        ans += (H / M);
        if(H % M != 0)ans++;
    }
    
    cout << ans << endl;
    return 0;
}

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

int arr[200005];

int main(){
    int n;
    scanf("%d",&n);
    long long ans = 0;
    for (int x = 0; x<n; x++){
        scanf("%d",&arr[x]);
        if (x==0){
            if (arr[x]!=0){
                printf("-1");
                return 0;
            }
        }
        else{
            if (arr[x]>arr[x-1]+1){
                printf("-1");
                return 0;
            }
            if (arr[x]==arr[x-1]+1){
                ans ++;
                continue;
            }
            if (arr[x]>x){
                printf("-1");
                return 0;
            }
            ans += arr[x];
        }
    }
    printf("%lld",ans);
}


Measured memory_bytes: 4600
N = int(input())
lst = []
for i in range(N):
	lst.append(int(input()))

sorted_lst = sorted(lst)
max_1 = sorted_lst[-1]
max_2 = sorted_lst[-2]

for i in lst:
  if (i == max_1):
    print(max_2)
  else:
    print(max_1)

Measured memory_bytes: 14112
#include "bits/stdc++.h"

using namespace std;
typedef long long int ll;
typedef pair<ll, ll > pi;  
typedef pair<pair<ll, ll >, ll > pii;  
vector<ll > vec;
vector<vector<ll > > vec2;
ll MOD = 1000000007;
ll INF = ll(1e18)+1919;

//なるべく右端を見つける
ll plus_check(ll tmp, ll comp, ll ok, ll ng){
    while(ok + 1 < ng){
        ll mid = (ng + ok) / 2;
        if(tmp * vec[mid] <= comp){
            ok = mid;
        }else{
            ng = mid;
        }
    }
    return ok;
}

//なるべく左端を見つける
ll minus_check(ll tmp, ll comp, ll ok, ll ng){
    while(ng + 1 < ok){
        ll mid = (ng + ok) / 2;
        if(tmp * vec[mid] <= comp){
            ng = mid;
        }else{
            ok = mid;
        }
    }
    return ok;
}

int main() {

    ll N, K;
    cin >> N >> K;

    for(ll i = 0; i < N; i++){
        ll t; cin >> t;
        vec.push_back(t);
    }
    sort(vec.begin(), vec.end());

    //K個目になる(条件を満たす)最小値
    ll ng = -INF; ll ok = INF;
    while(ng + 1 < ok){
        ll mid = (ng + ok) / 2;
        //midを満たすような（以下になる）組み合わせはいくつ？
        ll cn = 0;
        //さらに二分探査
        for(ll i = 0; i < N - 1; i++){
            ll tmp = vec[i];
            //プラスとマイナスで二分探査の向きが逆転
            if(tmp > 0){
                //プラスのとき
                if(tmp * vec[i+1] > mid) continue; //そもそも条件を最初から満たしていないとき,自分かける自分はされないのでvec[i+1]
                else if(tmp * vec[N-1] <= mid) cn += N-i-1; //全て条件を満たしているとき
                else{
                    //条件を満たす中で最大の値
                    ll ok2 = i + 1; ll ng2 = N - 1;
                    while(ok2 + 1 < ng2){
                        ll mid2 = (ng2 + ok2) / 2;
                        if(tmp * vec[mid2] <= mid){
                            ok2 = mid2;
                        }else{
                            ng2 = mid2;
                        }
                    }
                    cn += ok2 - i;
                    //cn += plus_check(tmp ,mid ,i+1 , N-1) - i;
                }
            }else if(tmp == 0){
                //0が条件に当てはまる可能性があるとき
                if(0 <= mid) cn += N-i-1;
            }else{
                //マイナスのとき
                if(tmp * vec[N-1] > mid) continue;
                else if(tmp * vec[i+1] <= mid) cn += N-i-1;
                else{
                    //cn += N - minus_check(tmp ,mid ,i+1 , N-1);
                    ll ng2 = i + 1; ll ok2 = N - 1;
                    while(ng2 + 1 < ok2){
                        ll mid2 = (ng2 + ok2) / 2;
                        if(tmp * vec[mid2] <= mid){
                            ok2 = mid2;
                        }else{
                            ng2 = mid2;
                        }
                    }
                    cn += N - ok2;
                }
            }
        }

        //条件を満たしているか？
        //cn--;
        if(cn >= K){
            ok = mid;
        }else{
            ng = mid;
        }
        //cout << mid << " " << cn << endl;
    }
    //最小値
    cout << ok << endl;    

}


Measured memory_bytes: 2420
using System;
using System.Collections.Generic;
using System.Linq;

namespace v0_0005
{
    class Program
    {
        static List<int> div = new List<int>() { 2 };

        static void Main(string[] args)
        {
            string line;
            while (!string.IsNullOrEmpty(line = Console.ReadLine()))
            {
                var ab = line.Split(' ');
                var a = int.Parse(ab[0]);
                var b = int.Parse(ab[1]);
                int LCM = 1;
                int GCD = 1;

                int divVal;
                while ((divVal = GetDivisor(a, b)) != -1)
                {
                    a /= divVal;
                    b /= divVal;
                    GCD *= divVal;
                }
                LCM = GCD * a * b;

                Console.WriteLine("{0} {1}", GCD, LCM);
            }
        }

        static int GetDivisor(int a, int b)
        {
            foreach (var d in div)
            {
                if ((a % d == 0) && (b % d == 0)) { return d; }
            }

            int st = div.Min() + 1;
            for (int i = (st % 2 == 0) ? st + 1 : st; i <= Math.Max(a, b); i += 2)
            {
                if ((a % i == 0) && (b % i == 0))
                {
                    if (!div.Contains(i)) { div.Add(i); }
                    return i;
                }
            }
            return -1;
        }
    }
}

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

using namespace std;

int p[200010];

int main(){
	// freopen("test.txt","r",stdin);
	cin.sync_with_stdio(0); cin.tie(0);
	int n; cin >> n;
	for (int i=0; i<n; ++i){
		int x; cin >> x;
		p[x] = i;
	}
	int maxlen = 0, cur = 1e9, cnter = 0;
	for (int i=1; i<=n; ++i){
		if (cur > p[i]){
			cnter = 1;
		}
		else{
			cnter++;
		}
		cur = p[i];
		maxlen = max(maxlen, cnter);
	}
	cout << n - maxlen;

	return 0;	
}

Measured memory_bytes: 1024
//
// AGC025A: Digits Sum
//
//

#include <iostream>
using namespace std;


int CountDigitsSum(int n) {
	int sumA=0;

	while (n > 0) {
		sumA += n % 10;
		n = n  / 10;
	}
	return sumA;
}

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

	int sumB =1000000;
	for(int a=1; a<=N-1; a++) {
		int b = N - a;
		int xx = CountDigitsSum(a) + CountDigitsSum(b);
		if ( xx < sumB ) {
			sumB = xx;
		}
	}
	cout << sumB << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int(i) = 0; (i) < (n); (i)++)
#define all(x) (x).begin(), (x).end()
#define print(x) cout << (x) << endl

using namespace std;

int main()
{
    int n, target, pre, ans = 0;
    cin >> n;
    rep(i, n)
    {
        cin >> target;
        if (i == 0)
        {
            ans++;
            pre = target;
            continue;
        }

        bool flag = true;
        if (target <= pre)
        {
            ans++;
        }
        pre = min(pre, target);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
n = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

prev = n
total = 0
for i in range(n):
	cur = A[i]
	total += B[cur-1]
	if cur == prev + 1:
		total += C[prev-1]
	prev = cur 
print(total)

Measured memory_bytes: 38256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define pb push_back
#define vi vector<long long>
#include <ext/pb_ds/assoc_container.hpp> // Common file  
#include <ext/pb_ds/tree_policy.hpp>  
#include <functional> // for less   
using namespace __gnu_pbds;  
using namespace std;  
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> set1;
ll mod=1000000007;
ll large=1e18;
ll neg=-1e18;
ll N=500000;
ll mod1=998244353;
struct pii
{
   ll x;
   ll y;
};
struct edge
{
   ll from;
   ll to;
   ll w;
   ll id;
};
ll find(ll a,ll p[])
{
   //cout<<"find "<<a<<endl;
   if(a==p[a])
   return a;
   else return p[a]=find(p[a],p);

}
void join(ll a,ll b,ll p[],ll sz[])
{
   a=find(a,p);
   b=find(b,p);
   if(a!=b)
   {
      if(sz[a]<sz[b])
      swap(a,b);
      sz[a]+=sz[b];
      p[b]=a;
   }
}
ll power(ll a,ll b,ll mod)
{
   ll res=1;
   while(b>0)
   {
      if(b&1)
      res=(res*a)%mod;
      b=b/2;
      a=(a*a)%mod;
   }
   return res;
}
ll inverse(ll x, ll p)
{
   return power(x,p-2,p);
}
ll hash1(ll x,ll y)
{
   return x+y+x*y;
}
/*ll f[200000]={0};

void ini()
{
   f[0]=1;
   for(ll i=1;i<=200000;i++)
   f[i]=(i*f[i-1])%mod;
}*/
void build(ll tree[],ll v,ll l,ll r,ll dp[])
{
   if(l==r)
      tree[v]=dp[l];
   else
   {
      ll m=(l+r)/2;
      build(tree,2*v,l,m,dp);
      build(tree,2*v+1,m+1,r,dp);
      tree[v]=max(tree[2*v],tree[2*v+1]);
   }
}
ll query(ll tree[],ll v,ll l,ll r,ll tl,ll tr)
{
   if(l==tl && tr==r)
   {
    //  cout<<"max of "<<tl<<" "<<tr<<" "<<tree[v]<<endl;
      return tree[v];
   }
   else
   {
      ll m=(l+r)/2;
      if(tr<=m)
      {
         ll z1= query(tree,2*v,l,m,tl,tr);
     //    cout<<"max of "<<tl<<" "<<tr<<" "<<z1<<endl;
         return z1;
      }
      else if(tl>m)
      {
         ll z2= query(tree,2*v+1,m+1,r,tl,tr);
      //   cout<<"max of "<<tl<<" "<<tr<<" "<<z2<<endl;
         return z2;
      }
      else 
      {
         ll z=query(tree,2*v,l,m,tl,m);
         ll z1=query(tree,2*v+1,m+1,r,m+1,tr);
       //  cout<<"max of "<<tl<<" "<<tr<<" "<<max(z1,z)<<endl;
         return max(z1,z);
      }
      
      
   }
}
void update(ll tree[],ll v,ll l,ll r,ll pos,ll element)
{
   if(l==r && l==pos)
   tree[v]=element;
   else
   {
      ll m=(l+r)/2;
      if(pos<=m)
      update(tree,2*v,l,m,pos,element);
      else
      update(tree,2*v+1,m+1,r,pos,element);
      tree[v]=max(tree[2*v],tree[2*v+1]);
   }
}

/*ll ncr(ll n,ll r)
{
   ll res=1;
   ll k=f[n];
   ll v=inverse(f[n-r],mod);
   ll u=inverse(f[r],mod);
   ll x=(u*v)%mod;
   k=(k*x)%mod;
   return k;
}*/
int main()
{
   ios_base::sync_with_stdio(false);
   cin.tie(NULL);
  ll a,b,v,w,t;
  cin>>a>>v>>b>>w>>t;
  if(w>=v)
  cout<<"NO"<<endl;
  else
  {
     double r=abs(a-b);
     double z=abs(v-w);
     double m=r/z;
     if(m<=(double)t)
     cout<<"YES"<<endl;
     else
     cout<<"NO"<<endl;
  }
  return 0;
}

Measured memory_bytes: 3660
import java.util.Scanner;

class Stack {
	private int top;
	private int[] a;
	
	Stack(){
		this.top=0;
		this.a=new int[200];
	}
	
	void push(int x){
		a[top++]=x;
	}
	
	int pop(){
		top--;
		return a[top];
	}
	
}

class Main {
	public static void main(String[] args){
		Scanner scan=new Scanner(System.in);
		Stack S=new Stack();
		
		while(scan.hasNext()){
			String str=scan.next();
			if(Character.isDigit(str.charAt(0))){
				S.push(Integer.parseInt(str));
			}
			else {
				int a=S.pop(); int b=S.pop();
				switch(str.charAt(0)){
					case '+':S.push(b+a);
							 break;
					case '-':S.push(b-a);
							 break;
					case '*':S.push(b*a);
							 break;
				}
			}
		}
		System.out.println(S.pop());
	}
}


Measured memory_bytes: 26008
#include <iostream>

using namespace std;

int main()
{
  int a,b;
  cin >> a >> b;
  if(b==100) b=101;
  if(a==0) cout << b << endl;
  else if(a==1) cout << b << "00" << endl;
  else cout << b << "0000" << endl;
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define PI 3.141592653589
#define ll long long
using namespace std;

int main(){  
  int n, m;
  cin >> n >> m;
  
  int h[n], mn[n];

  for(int i=1; i<=n; ++i){
    cin >> h[i];
    mn[i] = 0;
  }

  for(int i=0; i<m; ++i){
    int a, b;
    cin >> a >> b;

    mn[a] = max(mn[a], h[b]);
    mn[b] = max(mn[b], h[a]);
  }
  int ans = 0;
  for(int i=1; i<=n; ++i){
  ans += h[i] > mn[i];
  }

  cout << ans;
  return 0;

}

Measured memory_bytes: 4352
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<string>
#include<cmath>
#include<numeric>
using namespace std;


int main(void) {

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

  sort(a.begin(), a.end());
  for(int i=4; i>=1; i--) cout << a[i] << " ";
  cout << a[0] << endl;
  return 0;
}

Measured memory_bytes: 3152
N,M = map(int,input().split())

ab = [0]*N

for i in range(N):
    ab[i]=input().rstrip().split()

for i in range(N):
    ab[i][0]=int(ab[i][0])
    ab[i][1]=int(ab[i][1])

ab = sorted(ab)

sum = 0
sum_money = 0
for i in range(N):
    if sum + ab[i][1]< M:
        sum += ab[i][1] 
        sum_money += ab[i][1]*ab[i][0]
    else:
        while(sum!=M):
            sum_money += ab[i][0]
            sum += 1




print(sum_money)

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

int d[100][100];
int dx[2]={1,0},dy[2]={0,1};
typedef pair<int,int> P;
typedef pair<int,P> IP;

signed main(){
  int h,w;cin>>h>>w;
  vector<string> s(h);
  for(int i=0;i<h;i++)cin>>s[i];
  priority_queue<IP,vector<IP>,greater<IP>> que;
  for(int i=0;i<h;i++)for(int j=0;j<w;j++)d[i][j]=100000000;
  d[0][0]=(s[0][0]=='#');
  que.push(IP(s[0][0]=='#',P(0,0)));
  while(que.size()){
    IP p=que.top();que.pop();
    int va=p.first,y=p.second.first,x=p.second.second;
    for(int i=0;i<2;i++){
      int Y=y+dy[i],X=x+dx[i];
      if(Y<0||Y>=h||X<0||X>=w)continue;
      int nv=va+(s[y][x]=='.'&&s[Y][X]=='#');
      if(d[Y][X]>nv){
        d[Y][X]=nv;que.push(IP(nv,P(Y,X)));
      }
    }
  }
  cout<<d[h-1][w-1]<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<queue>
#include<cmath>
#include<iomanip>
#include<algorithm>
#define lint long long int
#define FOR(x, to) for(int x=0; x<(to); x++) // for簡略表記
#define DUMP(ar) for(int i=0; i<ar.size(); i++) cout << "[" << i << "]:" << ar[i] << endl // 配列一覧表示
#define COUT(x) cout << x << endl // 単要素出力
#define ALL(ar) ar.begin(), ar.end() // コンテナの全要素
using namespace std;
// cout << fixed << setprecision(4) で小数点以下4桁の桁そろえ
// goto ANSWER; で最後へ飛ぶ
// getline(cin, [変数]); で空白など(ホワイトスペース)を含む入力
// cin >> ws; でそこまでに入力ストリームに残されたホワイトスペースを取り除く(=以降のgetlineの有効化)

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n, q;
    cin >> n;
    vector<int> a(n);
    FOR(i, n) cin >> a[i];
    cin >> q;
    vector<int> m(q);
    FOR(i, q) cin >> m[i];

    vector<int> table(pow(2, n));
    vector<bool> pick(n, false);
    *(pick.end()-1) = true;

    int k=0;
    while(true){
        int sum = 0;
        for(int i=0; i<n; i++){
            if(pick[i]) sum += a[i];
        }
        table[k++] = sum;

        // cout << "aaa" << endl;

        bool flag = true;
        for(int i=0; i<n; i++){
            if(!pick[i]) flag = false;
        }
        if(flag) break;

        if(pick.back()){
            *(pick.end()-1) = false;
            int target = pick.size()-1;
            while(target >= 1){
                if(pick[target-1]) { pick[--target] = false; }
                else{ pick[--target] = true; break; }
            }
        }else{
            *(pick.end()-1) = true;
        }
    }

    sort(ALL(table));
    for(int i=0; i<q; i++){
        int right = table.size(), left = 0;
        int center;
        bool flag = false;
        // cout << "m[" << i << "]: " << m[i] << "探索中" << endl;
        while(true){
            center = (right + left) / 2;
            // cout << "center: " << center << " table[" << center << "]: " << table[center] << endl;
            if(m[i] < table[center]){
                right = center;
            }
            else if(m[i] > table[center]){
                if(left == right -1 ){ 
                    if(m[i] == table[right]) flag = true;
                    break;
                }
                left = center;
            }
            else if(m[i] == table[center]){
                flag = true; break;
            }
            if(right == left) break;
        }
        if(flag) cout << "yes\n";
        else cout << "no\n";
    }
    cout << flush;

    // DUMP(table);
    
ANSWER:
    return 0;
}


Measured memory_bytes: 7028
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <limits.h>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string>
#include <vector>
#include <cstdio>
#include <iomanip>
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;i++)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(int i=a;i>=b;i--)
#define REP(e,v) for(auto e:v)
#define queint queue<int>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pq priority_queue<int>//大きい順
#define pqg priority_queue<int,vec,greater<int>>//小さい順
#define pb push_back
#define vec vector<int>
#define vecvec vector<vector<int>>
#define vecll vector<ll>
#define vecvecll vector<vector<ll>>
#define bs binary_search
#define All(c) (c).begin(),(c).end()
#define mp make_pair
using namespace std;
int in(){int x;scanf("%d",&x);return x;}
string stin(){string s;cin>>s;return s;}
ll lin(){ll x;scanf("%lld",&x);return x;}
int main(){
    int n=in(),m=in();
    vector<vec> a(m,vec());
    rep(i,m){
        int k=in();
        a[i].resize(k);
        rep(j,k){
            a[i][j]=in()-1;
        }
    }
    vec p(m);
    rep(i,m)p[i]=in();
    int ans=0;
    rep2(bit,0,(1<<n)-1){
        vec cnt(m);
        rep(i,n){
            if(bit&(1<<i)){
                rep(j,m){
                    REP(x,a[j]){
                        if(x==i)cnt[j]++;
                    }
                }
            }
        }
        bool flag=true;
        rep(i,m){
            if(cnt[i]%2!=p[i])flag=false;
        }
        if(flag){
            ans++;
        }
    }
    cout<<ans<<endl;
}


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

/*#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")*/
#define mp make_pair
#define pb push_back
#define pll pair<LL,LL>
#define pii pair<int,int>
#define y second
#define x first
#define LL long long 
#define sqr(x) ((x)*(x))
#define pi acosl(-1)
#define MEM(x) memset(x,0,sizeof(x))
#define MEMS(x) memset(x,-1,sizeof(x))
using namespace std;
/*
struct matrix{
    LL a[2][2];
};
int mod=998244353;
matrix operator*(const matrix &a,const matrix &b){
    matrix c;
    for(int i = 0;i<2;i++){
        for(int j = 0;j<2;j++){
            c.a[i][j]=0;
        }
    }
    for(int i = 0;i<2;i++){
        for(int j = 0;j<2;j++)[
            for(int k =0;k<2;k++){
                c.a[i][j]+=a.a[i][k]*b.a[k][j]%mod;
            }
            c.a[i][j]%=mod;
        ]
    }
    return c;
}
matrix f_pow(matrix a,int b){
    matrix res,tmp=a;
    res.a[0][0]=res.a[1][1]=1;
    res.a[0][1]=res.a[1][0]=0;
    while(b){
        if(b&1)res=res*tmp;
        tmp=tmp*tmp;
        b>>=1;
    }
    return res;
}*/
const int mod=998244353;
LL f_pow(LL a,LL b){
    LL res=1,temp=a;
    while(b){
        if(b&1)res=res*temp%mod;
        temp=temp*temp%mod;
        b>>=1;
    }
    return res;
}
LL s[200005];
LL sum[200005];
void add(LL x,LL k,LL *S){
   // printf("%lld\n",x);
    for(int i = x;i<200005;i+=i&-i){
        S[i]+=k;
        S[i]%=mod;
    }
    //return res;
}
LL query(LL x,LL *S){
    LL res=0;
    for(int i = x;i>0;i-=i&-i){
        res+=S[i];
    }
    return res%mod;
}
void solve(){
    int n,k;
    scanf("%d %d",&n,&k);
    LL ans=0;
    LL aa=(k-1)*f_pow(k,mod-2)%mod;
    for(int i = 1;i<=n;i++){
        int x;
        scanf("%d",&x);
        LL q1=query(x-1,s),q2=((query(n,s)-query(x-1,s))%mod+mod)%mod;
        ans+=(q1+q2)*f_pow(aa,max(i-k,0))%mod*((mod+1)/2)%mod;
      //  printf("%lld %lld %lld %lld\n",q1,q2,ans,i-1-query(x,sum));
        ans+=((i-1-query(x,sum)-q2*f_pow(aa,max(i-k,0)))%mod+mod)%mod;
        ans%=mod;
        add(x,1,sum);
        add(x,f_pow(f_pow(aa,max(i-k,0)),mod-2),s);
        //printf("%lld %lld %lld\n",q1,q2,ans);
    }
    printf("%lld\n",ans);
}
int main(){
    int t=1;
    //scanf("%d",&t);
    while(t--){
        solve();
    }
}
/*
1 6 6
2 7 4
3 5 2
4 3 1
5 2 5
6 4 0
7 1 3
*/
/*
100
5
5 4
4 2
4 2 3
5 4 2 3 1
*/


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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long
#define ll long long
#define REP(i,a,b) for (int i=a; i<b; i++)

using namespace std;
typedef vector<int> vi;
typedef pair<int,int> pi;

struct DSU {
  std::vector<int> size;
  std::vector<int> parent;
  int connected;

  static DSU make_set(int n) {
    DSU dsu;
    int size[n], parent[n];
    for (int i = 0; i < n; i++) {
      dsu.parent.push_back(i);
      dsu.size.push_back(1);
    }
    dsu.connected = n;
    return dsu;
  }

  int find(int u) {
    if (parent[u] == u) {
      return u;
    }
    return parent[u] = find(parent[u]); // compression
  }

  int unite(int u, int v) {
    int up = find(u);
    int vp = find(v);
    if (up == vp) {
      return up;
    }

    parent[vp] = up;
    size[up] += size[vp];
    connected--;
    return up;
  }

  int getSize(int u) {
    return size[find(u)];
  }
};

signed main() {
  IOS;
  int N,M,X,Y,Z;
  cin >> N >> M;
  DSU dsu = DSU::make_set(N);
  REP(i, 0, M) {
    cin >> X >> Y >> Z;
    dsu.unite(X-1, Y-1);
  }
  cout << dsu.connected << endl;
  return 0;
}


Measured memory_bytes: 2036
import sys
n = int(input())
words = []
for i in range(n):
    w = input()
    if w in words:
        print('No')
        sys.exit()
    w_list = list(w)
    if i == 0:
        last = w_list[-1]
    elif i != 0 and i != n-1:
        start = w_list[0]
        if start != last:
            print('No')
            sys.exit()
        last  = w_list[-1]
    else:
        start = w_list[0]
        if start != last:
            print('No')
            sys.exit()
    words.append(w)
print('Yes')

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

const int MAXN = 100100;
const int MAXD = 15;

int N, M, Q;
int a, b;
vector<int> v[MAXN];
int x, y, z;
vector<vector<int>> d, t;
int tnum;
vector<bool> u;

void dfs(int pos) {
  u[pos] = true;
  for (int next : v[pos]) {
    if (!u[next]) {
      dfs(next);
    }
    const vector<int>& next_d = d[next];
    const vector<int>& next_t = t[next];
    for (int i = 1; i < MAXD; ++i) {
      if (next_t[i] > t[pos][i - 1]) {
        t[pos][i - 1] = next_t[i];
        d[pos][i - 1] = next_d[i];
      }
    }
  }
}

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

  cin >> N >> M;
  for (int i = 0; i < M; ++i) {
    cin >> a >> b;
    --a, --b;
    v[a].push_back(b);
    v[b].push_back(a);
  }

  d.assign(N, vector<int>(MAXD, 0));
  t.assign(N, vector<int>(MAXD, -1));

  cin >> Q;
  for (int i = 0; i < Q; ++i) {
    cin >> x >> y >> z;
    --x;
    d[x][y] = z;
    t[x][y] = ++tnum;
  }

  for (int j = 0; j < MAXD; ++j) {
    u.assign(N, false);
    for (int i = 0; i < N; ++i) {
      if (!u[i]) {
        dfs(i);
      }
    }
  }

  for (int i = 0; i < N; ++i) {
    int mx_t_pos = 0;
    for (int j = 0; j < MAXD; ++j) {
      if (t[i][j] > t[i][mx_t_pos]) {
        mx_t_pos = j;
      }
    }
    cout << d[i][mx_t_pos] << endl;  
  }
}

Measured memory_bytes: 27392
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;

const int mx=200010;
const ll mod=1e9+7;

string s;

int main(){
  cin >> s;
  int n = s.size();
  vector<int> next(n),ans(n);

  for(int i=0; i<n; i++){
    if(s[i]=='R'){
      next[i] = i+1;
    } else {
      next[i] = i-1;
    }
  }
  
  for(int t=0; t<1000; t++){
    vector<int> dnext(n);
    for(int i=0; i<n; i++){
      dnext[i] = next[next[i]];
    }
    dnext.swap(next);
  }
  
  for(int i=0; i<n; i++){
    ans[next[i]]++;
  }
  for(int i=0; i<n; i++){
    cout << ans[i] << " ";
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 1904
#include <stdio.h>
#include <string.h>

#define M 1046257
#define NIL (-1)
#define L 14

char H[M][L];

/* 文字から数値に変換 */
int getChar(char ch) {
  if ( ch == 'A' ) return 1;
  else if ( ch == 'C' ) return 2;
  else if ( ch == 'G' ) return 3;
  else if ( ch == 'T' ) return 4;
  return 0;
}

/* 文字列から数値へ変換して key を生成する */
long long getKey(char str[]) {
  long long sum = 0, p = 1, i;
  for(i=0;i<strlen(str);i++) {
    sum += p*(getChar(str[i]));
    p*= 5;
  }
  return sum;
}

int h1(int key){ return key % M; }
int h2(int key){ return 1 + (key % (M-1)); }

int find(char str[]) {
  long long key, i, h;
  key = getKey(str); /* 文字列を数値に変換 */
  for(i=0; ;i++) {
    h = (h1(key) + i*h2(key)) % M;
    if( strcmp(H[h],str) == 0) return 1;
    else if ( strlen(H[h]) == 0 ) return 0;
  }
  return 0;
}

int insert(char str[]) {
  long long key, i, h;
  key = getKey(str); /* 文字列を数値に変換 */
  for(i=0; ; i++) {
    h = (h1(key) + i * h2(key)) %M;
    if(strcmp(H[h],str) == 0) return 1;
    else if(strlen(H[h]) == 0) {
      strcpy(H[h],str);
      return 0;
    }
  }
  return 0;
}

int main(void) {
  int i, n;
  char str[L], com[9];
  for(i=0;i<M;i++) H[i][0] = '\0';
  scanf("%d",&n);
  for(i=0;i<n;i++) {
    scanf("%s %s",com,str);
    if(com[0] == 'i') {
      insert(str);
    } else {
      if(find(str)){
        printf("yes\n");
      } else {
        printf("no\n");
      }
    }
  }
  return 0;
}


Measured memory_bytes: 16080
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef vector<pair<ll, ll>> pll;
 
#define mod 1000000007
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define popcount(x) __builtin_popcountll(x)
 
const long double PI = acos(-1);
 
ll gcd(ll a,ll b){return b ? gcd(b,a%b) : a;}
ll lcm(ll a,ll b){return a / gcd(a,b) * b;}
ll stringcount(string s, char c){return count(s.cbegin(), s.cend(), c);}
bool isInteger(double x){return floor(x) == x;}


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

  ll n, x;
  cin >> n >> x;
  ll ans = 0;
  cin >> ans;
  ans = abs(ans - x);
  for(ll i = 1; i < n; i++){
    ll a = 0;
    cin >> a;
    ans = gcd(ans, abs(x-a));
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int k;
    int a,b;
    cin>>k;
    cin>>a;
    cin>>b;
    int c=0;
    for(int i=a/k;i<=(b/k)+2;i++)
    {
        if(i*k<=b && i!=0 && i*k>=a)
        {
            c=1;
            cout<<"OK"<<endl;
            break;
        }
    }
    if(c==0)
    {
        cout<<"NG"<<endl;
    }
}

Measured memory_bytes: 3592
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Kein Yukiyoshi
 */

#include "bits/stdc++.h"
#define int long long
#define rep(i, n)           for (int i = 0; i < (int)(n); i++)
#define REP(i, a, b)        for (int i = (int)(a); i < (int)(b); i++)
#define FOR(i, a)           for (auto &i : a)
#define ALL(obj)            begin(obj), end(obj)
#define MAX(x)              *max_element(ALL(x))
#define MIN(x)              *min_element(ALL(x))
#define SUM(x)              accumulate(ALL(x), 0LL)
#define LOWER_BOUND(A, key) distance(A.begin(), lower_bound(ALL(A), key))
#define UPPER_BOUND(A, key) distance(A.begin(), upper_bound(ALL(A), key))

using namespace std;
const int MOD    = (int)(1e9 + 7);
const int INF    = (int)(1e13 + 7);
const double EPS = 1e-14;
const double PI  = acos(-1);

int CEIL(int a, int b) { return (a >= 0 ? (a + (b - 1)) / b : (a - (b - 1)) / b); } //ceil() for int
int mod(int a, int b) { return a >= 0 ? a % b : a - (b * CEIL(a, b)); }             //always return positive num
int bpm(int a, int b) {                                                             //return x^y in order(log(y))
  int res = 1;
  for (a %= MOD; b; a = a * a % MOD, b >>= 1)
    if (b & 1) res = res * a % MOD;
  return res;
}

class CMarks {
public:
  static void solve(istream &cin, ostream &cout) {
    int N, K;
    cin >> N >> K;
    vector<int> A(N);
    rep(i, N) cin >> A[i];
    REP(i, K, N) {
      if (A[i] > A[i - K]) {
        cout << "Yes" << endl;
      } else {
        cout << "No" << endl;
      }
    }
  }
};


signed main() {
  cin.tie(0);
  cout.tie(0);
  ios_base::sync_with_stdio(false);
  cout<<fixed<<setprecision(15);
  CMarks solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}


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

int main(){
	int p = 700;
	string S;
	cin >> S;
	if (S[0] == 'o') p += 100;
	if (S[1] == 'o') p += 100;
	if (S[2] == 'o') p += 100;
	cout << p << endl;
	return 0;
}


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

//Function Macros:
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define all(v) (v).begin(), (v).end()
#define setpre(n) cout << fixed << setprecision(n)

//Type / Class / Struct Definitions:
using ll = long long;
using ull = unsigned long long;

//Constants:
const int INF = (1ll << 30) - 1;  //nearly 1.07e9
const ll INFLL = 1ll << 60;       //nearly 1.15e18
const int MOD = 1e9 + 7;
const long double EPS = 1.0e-14;

//Global Variables:

//Prototype Declarations:
int gcd(int, int);
template <class T>
inline bool chmin(T&, T);
template <class T>
inline bool chmax(T&, T);

//================ Main Loop ================
int main() {
    ll x;
    cin >> x;
    cout << (x / 500) * 1000 + (x % 500) / 5 * 5 << endl;
    return 0;
}
//===========================================

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

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


Measured memory_bytes: 256
import sys

def warshall_floyd(v_count: int, matrix: list) -> list:
    """ ワーシャルフロイド
    :param v_count: 頂点数
    :param matrix: 隣接行列
    """
    for i in range(v_count):
        for j, c2 in enumerate(row[i] for row in matrix):
            for k, (c1, c3) in enumerate(zip(matrix[j], matrix[i])):
                if c1 > c2+c3:
                    matrix[j][k] = c2+c3
    return matrix


def has_negative_cycle(matrix: list) -> bool:
    """ 負閉路チェック
    :param matrix: 隣接行列(ワーシャルフロイドの結果)
    """
    return any(row[i] < 0 for i, row in enumerate(matrix))


V, E = map(int, input().split())
inf = float("inf")
matrix = [[inf]*V for _ in [0]*V]
for i in range(V):
    matrix[i][i] = 0
for s, t, d in (map(int, l.split()) for l in sys.stdin):
    matrix[s][t] = d
warshall_floyd(V, matrix)
if has_negative_cycle(matrix):
    print("NEGATIVE CYCLE")
else:
    for row in matrix:
        print(" ".join(map(lambda n: str(n) if n!=inf else "INF", row)))


Measured memory_bytes: 6236
#include<iostream>
#include<string.h>
#include<ctype.h>
#include<string>
#include<math.h>
#define pi 3.141592653589
#include<iomanip>
using namespace std;
#include<algorithm>
#define rep(i,a,n) for(int i=a;i<n;i++)
#define INF 1e9
#define LINF 1e17
#define ll long long
#define MOD (int)(1e9+7)
 
 
 
int main(){
    
    char a[100][100];
    int h,w;
    
    cin>>h>>w;
    rep(i,0,h){
        rep(j,0,w){
            cin>>a[i][j];
        }
    }
    rep(i,0,h+2){
        rep(j,0,w+2){
            if(i==0||i==h+1)cout<<"#";
            else{
                if(j==0||j==w+1)cout<<"#";
                else cout<<a[i-1][j-1];
            }
        }
        cout<<endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll INF=1LL<<60;
const int inf=1<<30;
const int mod=1e9+7;
const int nmax=200005;
ll fac[nmax],finv[nmax],inv[nmax];
void COMinit(){
  fac[0]=fac[1]=1;
  finv[0]=finv[1]=1;
  inv[1]=1;
  for(int i=2;i<nmax;i++){
    fac[i]=fac[i-1]*i%mod;
    inv[i]=mod-inv[mod%i]*(mod/i)%mod;
    finv[i]=finv[i-1]*inv[i]%mod;
  }
}
ll com(int n,int k){
  if(n<k||n<0||k<0){
    return 0;
  }
  return fac[n]*(finv[k]*finv[n-k]%mod)%mod;
}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,m,k;cin >> n >> m >> k;
    COMinit();
    ll ans=0;
    for(ll i=0;i<n;i++){
        (ans+=i*(n-i)%mod*m%mod*m%mod)%=mod;
    }
    for(ll i=0;i<m;i++){
        (ans+=i*(m-i)%mod*n%mod*n%mod)%=mod;
    }
    (ans*=com(n*m-2,k-2))%=mod;
    cout << ans << endl;
}

Measured memory_bytes: 4992
import java.util.*;

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

	public Main(){
		new AOJ2508().doIt();
	}

	class AOJ2508{
		int n;
		int[] key;
		char[] list;
		char[] station;
		void doIt(){
			String a = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
			station = a.toCharArray();
			while(in.hasNext()){
				int n = in.nextInt();
				if(n==0)break;
				key = new int[n];for(int i=0;i<n;i++)key[i] = in.nextInt();
				list = in.next().toCharArray();
				ArrayList<Character> result = new ArrayList<Character>();
				for(int i=0;i<list.length;i++){
					int index = i%n;
					int b = key[index];
					for(int s=52;s<=52*2;s++){
						if(list[i]==station[s]){
							result.add(station[s-b]);
							break;
						}
					}
				}
				for(int i=0;i<result.size();i++)System.out.print(result.get(i));
				System.out.println();
			}
		}
	}

}

Measured memory_bytes: 25828
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
using namespace std;
int main()
{
    string s;
    cin >> s;

    for (int i = 0; i < s.length(); i++)
    {
        if (s[i] == '1') cout << '9';
        else if (s[i] == '9') cout << '1';
        else cout << s[i];
    }
    cout << '\n';
    return 0;
}

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

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();

		int sum = 0;

		boolean flag = false;

		for(int i=0;i<N+1;i++) {

			for(int j=0;j<N-i+1;j++) {

				sum = 4*i + 7*j;

				if(sum == N) {

					flag = true;

				}

			}

		}

		if(flag == true) {

			System.out.println("Yes");
		}else {

			System.out.println("No");
		}

	}

}


Measured memory_bytes: 21844
#include<cstdio>
#include<cstring>
char s[100];
int ans,flag;
int main()
{
	scanf("%s",s);
	ans=9*(strlen(s)-1)+s[0]-'0'-1;
	flag=1;
	for (int i=1;i<strlen(s);i++) if (s[i]!='9') flag=0;
	printf("%d\n",ans+flag);
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#pragma GCC optimize ("-O3")
    using namespace std;
    #define ll long long
    #define ld long double
    #define vll vector<ll>
    #define mll map<ll,ll>
    #define pll pair<ll,ll>
    #define ff first
    #define ss second
    #define pb push_back
    #define deb(x) cout<<#x<<" : "<<x<<endl;
    #define deb2(x,y) cout<<#x<<" : "<<x<<"\t"<<#y<<" : "<<y<<endl;
    #define deb3(x,y,z) cout<<#x<<" : "<<x<<"\t"<<#y<<" : "<<y<<"\t"<<#z<<" : "<<z<<endl;
    #define deb4(w,x,y,z) cout<<#w<<" : "<<w<<"\t"<<#x<<" : "<<x<<"\t"<<#y<<" : "<<y<<"\t"<<#z<<" : "<<z<<endl;
    #define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    #define printv(a)  for(ll i=0;i<a.size();i++)  cout<<a[i]<<" ";
   
   
    const int mod=998244353.;
    const int N=1e6+5; 
   
    bool sortbysec(const pair<pair<ll,ll>,ll> &a, 
                      const pair<pair<ll,ll>,ll> &b) 
        { 
            return (a.second > b.second); 
        } 
        ll powermod(ll x, ll y, ll p)
        {
            ll res = 1;
            x = x % p;
            while (y > 0)
            {
                if (y & 1) res = (res*x) % p;
                y = y>>1;
                x = (x*x) % p;
            }
            return res;
        }
       
        bool isprime(int n) 
        { 
            if (n <= 1)  return false; 
            if (n <= 3)  return true; 
            if (n%2 == 0 || n%3 == 0) return false; 
            for (int i=5; i*i<=n; i=i+6) 
                if (n%i == 0 || n%(i+2) == 0) 
                   return false; 
           return true; 
        }
       
       
        int main()
    {
        FAST;
      ll n;
      cin>>n;
      vll dp(3);
      for(ll i=0;i<n;i++)
      {
          vll c(3);
          for(ll j=0;j<3;j++)
          cin>>c[j];
          vll new_dp(3,0);
          for(ll k=0;k<3;k++)
          {
              for(ll l=0;l<3;l++)
              {     
                  if(k!=l)
                  {
                      new_dp[l]=max(new_dp[l],dp[k]+c[l]);
                  }
              }
          }
         
          dp=new_dp;
      }
      cout<<*max_element(dp.begin(),dp.end());
      
        
        
        
        return 0;
    }

Measured memory_bytes: 256
S = {}
for i, s in enumerate(input()):
    if not s in S.keys():
        S[s] = [i]
    else:
        S[s].append(i)

T = {}
for i, t in enumerate(input()):
    if not t in T.keys():
        T[t] = [i]
    else:
        T[t].append(i)

Sa = sorted(S.values())
Ta = sorted(T.values())

if Sa == Ta:
    ans = 'Yes'
else:
    ans = 'No'

print(ans)

Measured memory_bytes: 20144