akhauriyash/Code-Regression huggingface dataset:
function Main(input) {
  input = input.split("\n");
  var A = BigInt(input[0].split(" ")[0]);
  var B = BigInt(parseInt(input[0].split(" ")[1].split(".")[0])*100+parseInt(input[0].split(" ")[1].split(".")[1]));
  var ans = A * B /100n;
  var ans = ans.toString();


  console.log('%s', ans);
  return ans;
}

function debug(n){
  var input = document.getElementById("input"+n).value;
  var ans=Main(input);
  var result="WA";
  if(ans==document.getElementById("output"+n).value.split("\n")[0]){
    result="AC";
  }
  document.getElementById("result"+n).innerHTML=result;
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


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

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

  vector<pair<int,int>> vec(m);
  for (int i = 0; i < m; i++)
  {
    int a,b;
    cin >> a >> b;
    a--;b--;
    vec[i] = make_pair(b,a);
  }
  sort(vec.begin(),vec.end());

  int ans = 0;
  int p = -1;
  for (int i = 0; i < m; i++)
  {
    int a = vec[i].second;
    int b = vec[i].first;
    if(p>=a) continue;
    ans++;
    p=b-1;
  }
  cout << ans << endl;
}

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

using namespace std;

const int N = 2000 * 1000 + 17;
const int MOD = 1000 * 1000 * 1000 + 7;

int k, n;

bool read() {
    if (!(cin >> k >> n))
        return false;

    return true;
}

void solve() {
    if (k % 2 == 0) {
        cout << k / 2 << ' ';

        for (int i = 0; i < n - 1; ++i)
            cout << k << ' ';

        cout << endl;
        return ;
    }

    vector<int> ans(n, (k + 1) / 2);

    for (int t = 0; t < n / 2; ++t) {
        --ans.back();

        if (ans.back() == 0)
            ans.pop_back();
        else
            for (; ans.size() < n; ans.emplace_back(k)) { }
    }

    for (const auto& i : ans)
        cout << i << ' ';

    cout << endl;
}

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

    while (read())
        solve();

    return 0;
}



Measured memory_bytes: 3456
#include <iostream>
#include <cstring>
#include <cmath>
using namespace std;



int main() {
	char a[11] = {}, b[11] = {}, c[11] = {};

	cin >> a >> b >> c;

	cout << char(int(a[0])-32) << char(int(b[0]) - 32) << char(int(c[0]) - 32);

}

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

typedef long long ll;
ll mod = 1000000007;

ll power(ll x, ll y)
{
    ll res = 1;
    x = x%mod;
    while (y)
    {
        if (y&1) res = ((res%mod)*(x%mod))%mod;

        y>>=1;
        x = ((x%mod)*(x%mod))%mod;
    }
    return res;
}

int main(){

    ios::sync_with_stdio(false);
    cin.tie(0);

    ll n, m;
    cin >> n >> m;
    n==m?cout<<"Yes\n":cout<<"No\n";

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//自分の解答の清書 
int main() {
  int n; cin >>n;
  string s;
  cin>>s;
  int cnt_l=0;
  int cnt_r=0;
  vector<bool> hantei(n,0);
  for(int i=0;i<n-1;i++){
    if(s[i]=='(' && hantei[i]==false){
      for(int j=i+1;j<n;j++){
        if(s[j]==')'&&hantei[j]==false){
          hantei[i]=true;
          hantei[j]=true;
          break;
        }
      }
    }
  }
  for(int i=0;i<s.size();i++){
    if(s[i]=='('&&hantei[i]==false)cnt_l++;
    else if(s[i]==')'&&hantei[i]==false)cnt_r++;
  }
  for(int j=0;j<cnt_l;j++)s.push_back(')');
  for(int j=0;j<cnt_r;j++)s.insert(0,"(");
  cout<<s<<endl;
  return 0;
}

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

using namespace std;

int n;
int a[100000][3];
int b[100000];
int c[100000];
int dp[100001][4];

int main()
{
	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> a[i][0] >> a[i][1] >> a[i][2];
	memset(dp, 0, sizeof(dp));
	for (int i = 0; i <= n; i++)
	{
		for (int j = 0; j < 3; j++)
		{
			if (i == 0)
				dp[i][j] = 0;
			else
			{
				for (int k = 0; k < 3; k++)
				{
					if (k != j)
						dp[i][j] = max(dp[i][j], a[i - 1][j] + dp[i - 1][k]);
				}
			}
		}
	}
	int ans = max(max(dp[n][0], dp[n][1]), dp[n][2]);
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 2944
//日野茜★担当
//的場梨沙★担当
//結城晴★副担当
#include <vector>
#include <list>
#include <map>
#include <climits>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string.h>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
#include <random>
#include <cctype>
#include <complex>
#include <regex>
#include <unordered_map>
#include <string>
#include <algorithm>
#include <cctype>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <iomanip>
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <vector>
#include <stdio.h>

using namespace std;

int main(void) {
    int A,B,C,D;
    cin>>A>>B>>C>>D;
    int a=0;
    int c=0;

    while(A>0){

        A-=D;
        a++;

    }

    while(C>0){

        C-=B;
        c++;

    }

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


}

Measured memory_bytes: 3584
#include<bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
#define pb push_back
int dy[]={0, 0, 1, -1, 1, 1, -1, -1};
int dx[]={1, -1, 0, 0, 1, -1, -1, 1};

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define mp make_pair
#define fi first
#define sc second
ll n;
ll  a[400][400];
ll b[400][400];
bool f[400][400];
int main(){
	cin >> n;
	REP(i,n)
	{
		REP(j,n) {
			cin >> a[i][j];
			b[i][j] = a[i][j];
			f[i][j] = true;
		}
	}
	

	REP(k,n) {
		REP(i,n) {
			REP(j,n) {
				if(b[i][j] >= b[i][k] + b[k][j]){
					if(i != k && j != k)
						f[i][j] = false;
					b[i][j] = b[i][k] + b[k][j];
				}
			}
		}
	}

	REP(i,n) {
		REP(j,n) {
			if(a[i][j] != b[i][j]) {
				cout << -1 << endl;
				return 0;
			}
		}
	}

	ll ans = 0;
	REP(i,n) {
		FOR(j,i + 1,n) {
			if(f[i][j]) {
				ans += b[i][j];
			}
		}
	}

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


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

int main(){
    char s1[1000001];
    char s2[10001];
    int i, j, k;
    int n1, n2;
    scanf("%s %s", s1, s2);
    n1= strlen(s1);
    n2 = strlen(s2);
    for (i = 0 ; i < n1 ; i++) {
        if(strncmp(s2, &s1[i], n2)==0) printf("%d\n", i);
    }
    return 0;
}



Measured memory_bytes: 2784
#include<stdio.h>
#define LARGE 2000
#define INF 1000000000
#define MIN(a, b) ((a) < (b) ? (a) : (b))

int V,e;


typedef struct edge{
	int from;
	int to;
	int cost;
}edge;

int BellmanFord(edge E[],int C[]){
	int i,j;
	int cnt=0;
	for(j=0;j<V-1;j++){
	
		for(i=0;i<e;i++){
			if(C[E[i].from]!=INF && C[E[i].to] > C[E[i].from]+E[i].cost){
				C[E[i].to]=C[E[i].from]+E[i].cost;
				cnt++;
			}
		}
		
	}
	
	if(cnt>e){
		printf("NEGATIVE CYCLE\n");
		return 0;
	}
	
	return 1;
}
	
	

int main(){
	int start;
	int s,t,d;
	int i,flg;
	int C[LARGE];
	edge E[LARGE];
	
	scanf("%d %d %d",&V,&e,&start);
	
	for(i=0;i<e;i++){
		scanf("%d %d %d",&s,&t,&d);
		E[i].from=s;
		E[i].to=t;
		E[i].cost=d;
	}
	
	for(i=0;i<V;i++){
		C[i]=INF;
	}
	
	C[start]=0;
	
	flg=BellmanFord(E,C);
	
	if(flg==0)return 0;
	
	for(i=0;i<V;i++){
		if(C[i]==INF)printf("INF\n");
		else printf("%d\n",C[i]);
	}
	
	return 0;
	
}


Measured memory_bytes: 2108
from sys import stdin
N = int(stdin.readline().rstrip())
data = [int(x) for x in stdin.readline().rstrip().split()]
data = [0] + data + [0]
ab = [0] * (N+1)
for i in range(0,N+1):
    ab[i] = abs(data[i] - data[i+1])

S = sum(ab)

for j in range(0,N):
    print(S - ab[j] - ab[j+1] + (abs(data[j] - data[j+2])))
  

Measured memory_bytes: 14048
A, B, C, X, Y = map(int, input().split())
ans = float('inf')
for ab in range(0, 2 * (max(X, Y) + 1), 2):
  cost = ab * C + max(0, (X - ab // 2)) * A + max(0, (Y - ab // 2)) * B
  ans = min(ans, cost)
print(ans)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
		using namespace std;
		#define ll long long
		#define endl "\n"
		ll mod=1e9+7;
		void solve();
		ll exp(ll base,ll power,ll mod){
			power=power%mod;
			ll ans=1;
			while(power){
				if(power & 1){
					ans=(ans*base)%mod;
					power=power-1;
				}
				else{
					base=(base*base)%mod;
					power=power/2;
				}
			}
			return ans%mod;
		}
		int main()
		{	
			ios_base::sync_with_stdio(false);
			cin.tie(NULL);

		/*#ifndef ONLINE_JUDGE
			freopen("input.txt","r",stdin);
			freopen("output.txt","w",stdout);
		#endif*/
		
			int t=1;
			//cin>>t;
			while(t--){
			solve();
			cout << endl;
			}

			cerr << "time taken : "	<< (float)clock() / CLOCKS_PER_SEC << " secs" << endl; 
			return 0;		
		}
		void solve(){
			map<ll,ll>m;
			ll n,num,cnt=0;
			cin>>n;
			for (int i = 0; i < n; ++i)
			{
				cin>>num;
				m[num]++;
			}
			if(m[0]>1){
				cout<<0<<endl;
				return;
			}
			else{
				for(auto x: m){
					if(x.second==2){
						cnt++;
					}
					else if(x.second>2){
						cout<<0<<endl;
						return;
					}
				}
			}
			cout<<exp(2,cnt,mod)%mod;

		}
	

Measured memory_bytes: 4224
import java.util.*;
// import java.io.*;
// import java.time.*;

public class Main {
    static StringBuilder sb;

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

        int num = sc.nextInt();

        ArrayList<Integer> array = new ArrayList<>();
        for (int i = 0; i < num; i++) {
            array.add(sc.nextInt());
        }

        int num_query = sc.nextInt();

        for (int i = 0; i < num_query; i++) {
            int key = sc.nextInt();
            if (Collections.binarySearch(array, key) < 0) sb.append(0).append("\n");
            else sb.append(1).append("\n");
        }

        System.out.print(sb);
        
        sc.close();
    }

    public static int binarySearch(List<Integer> list, int key) {
        int lower = 0;
        int middle = -1;
        int upper = list.size();

        while (upper > lower + 1) {
            middle = lower + (upper - lower) / 2;
            if (list.get(middle) > key) upper = middle;
            else lower = middle;
        }

        return upper;
    }
}



Measured memory_bytes: 108208
#include <iostream>
#include <stdio.h>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <numeric>
#include <queue>
#include <numeric>
#include <iomanip>
#include <sstream>
#include <cmath>
#include <map>
#include <functional>
#include <limits>
#define rep(i,a,b) for((i)=a;i<(int)(b);i++)
#define max(a,b) (a < b ? b : a)
#define min(a,b) (a > b ? b : a)
#define AAA (1000000007)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define MMM (305)

int i, j, k;
int H, W;
//p行のqから下のイチゴを探す
int SearchDown(int A[MMM][MMM], int p, int q) {
	for (i = q; i < H; i++) {
		if (A[i][p] == 1)
			return i;

	}
	return -1;


}
//p行のqから下のイチゴを探す
int down(int A[MMM][MMM], int p, int q) {
	for (i = q; i < H; i++) {
		if (A[i][p] != 0)
			return i-1;

	}
	return H - 1;


}

//p行のqから上のイチゴを探す
int top(int A[MMM][MMM], int p, int q) {
	for (i = q ; i >= 0; i--) {
		if (A[i][p] !=0)
			return i+1;


	}
	return 0;

}

//p列のqからrまでをスライド右
int right(int A[MMM][MMM], int p, int q,int r) {
	for (i = p + 1; i < W; i++) {
		for (j = q; j <= r; j++) {
			if (A[j][i] !=0)
				return i - 1;

		}
			   		 	  
	}
	return W - 1;


}
//p列のqからrまでをスライド左
int left(int A[MMM][MMM], int p, int q, int r) {
	for (i = p -1; i >=0; i--) {
		for (j = q; j <= r; j++) {
			if (A[j][i] != 0)
				return i + 1;

		}

	}
	return 0;


}

//pからq, rからs
void change(int A[MMM][MMM], int p, int q, int r, int s) {
	static int id = 1;
	id++;
	rep(i, p, q+1) {
		rep(j, r, s + 1) {
			A[i][j] = id;
		}

	}

}

//int A[MMM][MMM] = { 0 };

int main() {
	int K;
	int A[MMM][MMM] = { 0 };
	cin >> H >> W >> K;
	rep(i, 0, H)rep(j, 0, W) {
		char c;
		cin >> c;
		if (c == '#')
			A[i][j] = 1;
		else
			A[i][j] = 0;

	}
	bool isFin = false;
	int a = 0;
	int b = 0;
	while(!isFin){
		a = SearchDown(A, b, a);
		if (a == -1) {
			b++;
			a = 0;
			if (b >= W)
				break;
			continue;
		}
		int p = top(A, b, a-1);
		int q = down(A, b,a + 1);
		int r = left(A, b, p, q);
		int s = right(A, b, p, q);
		change(A, p, q, r, s);
		r = r;

	}
	rep(i, 0, H) {
		rep(j, 0, W) {
			cout << A[i][j] - 1;
			cout << " ";
		}
		cout << endl;
	}
	return 0;
}



Measured memory_bytes: 1152
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

signed main()
{
    int N; cin>>N;
    vint x(N),y(N),h(N);
    REP(i,N) cin>>x[i]>>y[i]>>h[i];

    REP(cx,101) REP(cy,101){
        int H;
        REP(i,N) if(h[i]>0) H=h[i]+abs(x[i]-cx)+abs(y[i]-cy);
        bool ok=true;
        REP(i,N){
            if(h[i]>0){
                if(h[i]+abs(x[i]-cx)+abs(y[i]-cy)!=H) ok=false;
            }
            else{
                if(H-abs(x[i]-cx)-abs(y[i]-cy)>0) ok=false;
            }
        }
        if(ok){
            cout<<cx<<' '<<cy<<' '<<H<<endl;
            return 0;
        }
    }
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<string>
#include<cstring>
#include<cstdlib>
#include<cctype>
#include<bitset>
#include<functional>
#include<climits>
using namespace std;
typedef pair<int,int>pii;
const int INF=1e9;
const int dx[]={0,-1,0,1},dy[]={-1,0,1,0};


int main(){
    unsigned int n;
    while(scanf("%u",&n),n){
        unsigned int sum=0;
        for(int i=0;i<n;i++){
            unsigned int val;
            scanf("%u",&val);
            sum+=val;
        }
        unsigned int r[70000];
        for(int i=0;i<n-1;i++)scanf("%u",&r[i]);
        sort(r,r+n-1,greater<unsigned int>());
        unsigned int ma=sum*n,cnt=n;
        for(int i=0;i<n-1;i++){
            sum+=r[i];
            cnt--;
            ma=max(ma,sum*cnt);
        }
        printf("%u\n",ma);
    }
    return 0;
}

Measured memory_bytes: 1472
import kotlin.String

fun main(args: Array<String>) {
    val n = readInt()
    val p = List(n) { readIntList() }.sortedBy { it[1] }

    var past = 0L
    p.forEach { (a, b) ->
        past += a
        if (past > b) {
            println("No")
            return
        }
    }
    println("Yes")
}

// read
fun readString() = readLine()!!
fun readInt() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readStringList() = readLine()!!.split(" ")
fun readIntList() = readLine()!!.split(" ").map(String::toInt)
fun readLongList() = readLine()!!.split(" ").map(String::toLong)

Measured memory_bytes: 85136
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <bitset>

#define lp(n) for(int i=0;i<n;i++)
#define LP(n,i) for(int i=0;i<n;i++)
#define mod 1000000007
#define sp ' '
#define intmax 2147483647
#define intmin -2147483637
#define llmax 9223372036854775807
typedef long long ll;

using namespace std;

int n,a,b;
ll v[51],cnt,cnt2,cnt3,mxcnt,cnt4,mxcnt2,mx;

/*ll gcd(ll x,ll y){
	if(y==0)return x;
	return gcd(y,x%y);
}
ll lcm(ll x,ll y){
	ll g=gcd(x,y);
	return x/g*y;
}*/

int main(){
	cin>>n>>a>>b;
	lp(51)
		v[i]=0;
	lp(n)
		cin>>v[i];
	sort(v,v+n,greater<ll>());
	cnt=0;
	mx=0;
	cnt3=0;
	mxcnt2=1;
	lp(n){
		if(v[i]==v[i+1])
			cnt3++;
		else cnt3=0;
		cnt+=v[i];
		if(b<i+1)break;
		if(a<=i+1){
			if(mx*(i+1)<cnt*mxcnt2){
				mx=cnt;
				mxcnt2=i+1;
				mxcnt=0;
				cnt2=0;
				for(int j=i+1;j<n;j++){
					if(v[j-1]==v[j])cnt2++;
					else break;
				}
				cnt4=1;
				LP(cnt3,j)cnt4=cnt4*(cnt2+cnt3-j)/(j+1);
				mxcnt+=cnt4;
			}
			else if(mx*(i+1)==cnt*mxcnt2){
				cnt2=0;
				for(int j=i+1;j<n;j++){
					if(v[j-1]==v[j])cnt2++;
					else break;
				}
				cnt4=1;
				LP(cnt3,j)cnt4=cnt4*(cnt2+cnt3-j)/(j+1);
				mxcnt+=cnt4;
			}			
		}
	}
	printf("%.6f",double(mx)/mxcnt2);
	cout<<endl<<mxcnt<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <array>
#include <cstdlib>
#include <functional>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string>
#include <vector>

#define INF 1000000000
#define MOD 1000000007
#define ll long long
#define rep(i,a,b) for(i = (a); i < (b); i++)
#define bitget(a,b) (((a) >> (b)) & 1)
#define vint vector<int>
#define vvint vector<vector<int>>
#define vsort(x) sort(x.begin(),x.end())

using int64 = uint64_t;

using namespace std;

int main() {

	int i, j, k;
	int n;
	cin >> n;
	vint r(n), t(n);
	rep(i, 0, n)
		cin >> r[i] >> t[i];
	rep(i, 0, n) {
		if (r[i] % 100 == 0) {
			if (t[i] % 30 == 0) {
				cout << (r[i] / 100) + 5 * (t[i] / 30)<<endl;
			}
			else {
				cout << (r[i] / 100) + 5 * (t[i] / 30) << " " << (r[i] / 100) + 5 * (t[i] / 30) + 5 << endl;
			}
		}
		else {
			if (t[i] % 30 == 0) {
				cout << (r[i] / 100) + 5 * (t[i] / 30) << " " << (r[i] / 100) + 5 * (t[i] / 30) + 1 << endl;
			}
			else {
				cout << (r[i] / 100) + 5 * (t[i] / 30) << " " << (r[i] / 100) + 5 * (t[i] / 30) + 1 << " " << (r[i] / 100) + 5 * (t[i] / 30) + 5 << " " << (r[i] / 100) + 5 * (t[i] / 30) + 6 << endl;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 3096
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
const long long INF = 1LL<<60;
#define rev(s) (string((s).rbegin(), (s).rend()))
typedef pair<ll,int> p;

int main() {

    int n;cin>>n;
    
    set<int> st;
    rep(i,n) {
        int a;cin>>a;
        st.insert(a);
    }

    cout<<st.size()<<endl;

}

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

int main(){
  int L, R, d;
  cin >> L >> R >> d;
  int ans = 0;
  for(int i=L;i<=R;i++){
    if(i%d==0){
      ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3592
#include<iostream>
#include<string>
#include<vector>
using namespace std;
typedef long long ll;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S;
    cin >> S;
    string SS;
    bool is_BC = false;
    for (int i = 0; i < S.length(); i++) {
        if (S[i] == 'B') {
            if (is_BC) {
                SS.push_back('B');
            }
            else is_BC = true;
        }
        else if (S[i] == 'C') {
            if (is_BC) {
                SS.push_back('Z');
                is_BC = false;
            }
            else SS.push_back(S[i]);
        }
        else {
            if (is_BC) {
                is_BC = false;
                SS.push_back('B');
                SS.push_back(S[i]);
            }
            else SS.push_back(S[i]);
        }
    }
    if (is_BC) SS.push_back('B');
    ll ans = 0, A_cnt = 0, Z_cnt = 0;
    for (int i = 0; i < SS.length(); i++) {
        if (SS[i] == 'A') A_cnt++;
        else if (SS[i] == 'Z') ans += A_cnt;
        else {
            A_cnt = 0;
            Z_cnt = 0;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 916
/*********************************************************************/
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <math.h>
#include <stdio.h>
#include <ctype.h>
#include <ios> 
#include <iomanip>
using namespace std;

#define N_MAX   (100000)
#define LL_MAX_NUM (1LL<<60)
#define INF 1e7

typedef long long ll;
typedef long long int lli;

int main() {
	int A, P; cin >> A >> P;
	cout << (A*3+P)/2 << endl;
	return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func main() {
	io := NewIo()
	defer io.Flush()
	for {
		n := io.NextInt()
		if n == 0 {
			break
		}
		accum := make([]int, 86401)
		for i := 0; i < n; i++ {
			s, e := io.Next(), io.Next()
			hs, _ := strconv.Atoi(s[:2])
			ms, _ := strconv.Atoi(s[3:5])
			ss, _ := strconv.Atoi(s[6:8])
			accum[hs*60*60+ms*60+ss]++
			he, _ := strconv.Atoi(e[:2])
			me, _ := strconv.Atoi(e[3:5])
			se, _ := strconv.Atoi(e[6:8])
			accum[he*60*60+me*60+se]--
		}
		ans := 0
		for i := 1; i < 86401; i++ {
			accum[i] += accum[i-1]
			ans = intMax(accum[i], ans)
		}
		io.Println(ans)
	}
}

func intMax(a, b int) int {
	if a < b {
		return b
	}
	return a
}

// I/O template
type Io struct {
	reader    *bufio.Reader
	writer    *bufio.Writer
	tokens    []string
	nextToken int
}

func NewIo() *Io {
	return &Io{
		reader: bufio.NewReader(os.Stdin),
		writer: bufio.NewWriter(os.Stdout),
	}
}

func (io *Io) Flush() {
	err := io.writer.Flush()
	if err != nil {
		panic(err)
	}
}

func (io *Io) NextLine() string {
	var buff []byte
	for {
		line, isPrefix, err := io.reader.ReadLine()
		if err != nil {
			panic(err)
		}
		buff = append(buff, line...)
		if !isPrefix {
			break
		}
	}
	return string(buff)
}

func (io *Io) Next() string {
	for io.nextToken >= len(io.tokens) {
		line := io.NextLine()
		io.tokens = strings.Fields(line)
		io.nextToken = 0
	}
	s := io.tokens[io.nextToken]
	io.nextToken++
	return s
}

func (io *Io) NextInt() int {
	i, err := strconv.Atoi(io.Next())
	if err != nil {
		panic(err)
	}
	return i
}

func (io *Io) NextFloat() float64 {
	i, err := strconv.ParseFloat(io.Next(), 64)
	if err != nil {
		panic(err)
	}
	return i
}

func (io *Io) Println(a ...interface{}) {
	fmt.Fprintln(io.writer, a...)
}

func (io *Io) Printf(format string, a ...interface{}) {
	fmt.Fprintf(io.writer, format, a...)
}

func (io *Io) PrintIntSlice(a []int) {
	b := []interface{}{}
	for _, x := range a {
		b = append(b, x)
	}
	io.Println(b...)
}

func (io *Io) PrintStringSlice(a []string) {
	b := []interface{}{}
	for _, x := range a {
		b = append(b, x)
	}
	io.Println(b...)
}

func Log(name string, value interface{}) {
	fmt.Fprintf(os.Stderr, "%s=%+v\n", name, value)
}

func ExampleIo() {
	io := NewIo()
	defer io.Flush()
	a := make([]int, 0, 3)
	a[0], a[1], a[2] = io.NextInt(), io.NextInt(), io.NextInt()
	io.Println(a)
	io.PrintIntSlice(a)
	Log("io", a)
}



Measured memory_bytes: 6852
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define x first
#define y second
#define pb push_back
#define mp make_pair
#define all(v) v.begin(),v.end()
#define sz(v) (int)v.size()
#define up_b upper_bound
#define low_b lower_bound
#define nl '\n'

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<int,ll> pil;
typedef pair<ll,int> pli;
typedef pair<ll,ll> pll;

typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;

const int N=1e5+11;
const int M=2e6+11;
const int W=1e3+11;
const int inf=1e9;
const ll INF=1e18;
const ll mod=1e9+7;
const ld EPS=1e-9;

int main(){
  ios_base::sync_with_stdio(0);
  cin.tie(0),cout.tie(0);
  string s;
  cin>>s;
  int n=sz(s);
  for(int i=0;i<n;i++)cout<<'x';
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
#define out(v) cout<<v<<"\n"
#define rep(i,n) for(int i=0;i<(n);++i)

using ll = long long;
using vi = vector<int>;

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

  char before = '<';
  int len = 0;
  ll ans = 0;
  vector<int> v;
  rep(i, N) {
    if (before == S[i])
      ++len;
    else {
      v.push_back(len);
      len = 1;
    }
    before = S[i];
  }
  v.push_back(len);
  rep(i, v.size()) {
    ll len = v[i];
    if (i % 2 == 0) {
      // <
      ans += len * (len + 1) / 2;
    } else {
      // >
      if (v[i-1] >= len) {
        ans += (len - 1) * len / 2;
      } else {
        ans -= v[i-1];
        ans += len * (len + 1) / 2;
      }
    }
  }
  cout << ans << "\n";

  return 0;
}


Measured memory_bytes: 2332
#include <cstdio>

void SR(char S[], int countsl);

int main(){
    char S[101],T[101];
    scanf("%s\n%s",S,T);
    int countsl = 0;
    for(int i = 0; S[i] != '\0'; i++){
        countsl++;
    }
    int n;
    for(int i = 0; i < countsl; i++){
        SR(S, countsl);
        n = 0;
        for(int j = 0; j < countsl; j++){
            if(S[j] == T[j]){
                n++;
            }else{
                break;
            }
        }
        if(n == countsl){
            printf("Yes\n");

            return 0;
        }
    }
    printf("No\n");

    return 0;
}

void SR(char S[], int countsl){
    char E,P,Q;
    E = S[countsl - 1];
    P = S[0];
    for(int i = 1; i < countsl; i++){
        Q = S[i];
        S[i] = P;
        P = Q;

    }
    S[0] = E;

}

Measured memory_bytes: 128
{-# LANGUAGE BangPatterns #-}
 
module Main
  ( main
  )
where
 
import           Control.Applicative
import           Control.Monad
import           Control.Monad.ST
import           Data.Bits
import qualified Data.ByteString.Char8         as BS
import           Data.Char
import           Data.List
import           Data.Maybe
import           Data.Ord
import qualified Data.Vector                   as V
import qualified Data.Vector.Mutable           as MV
import qualified Data.Vector.Unboxed           as UV

parse = fst . fromJust
parseInt = parse . BS.readInt
parseInteger = parse . BS.readInteger
readInt = parseInt <$> BS.getLine
readInteger = parseInteger <$> BS.getLine
readIntList = map parseInt . BS.words <$> BS.getLine
readIntegerList = map parseInteger . BS.words <$> BS.getLine


main = do
  [c] <- getLine
  let list = ['a', 'e', 'i', 'o', 'u']
  putStrLn $ if c `elem` list then "vowel" else "consonant"
 

Measured memory_bytes: 380
import itertools as itr

def main():
	N, M, Q = list(map(int, input().split()))
	LR      = [map(int, input().split()) for _ in range(M)]
	pq      = [map(int, input().split()) for _ in range(Q)]

	cnt = [[0 for _ in range(N+10)] for _ in range(N+10)]
	for L, R in LR:
		cnt[L][R] += 1
	
	for i, j in itr.product(range(N+1), repeat = 2):
		cnt[i+1][j] += cnt[i][j]
	for i, j in itr.product(range(N+1), repeat = 2):
		cnt[i][j+1] += cnt[i][j]

	for p, q in pq:
		print( cnt[q][q] - cnt[p-1][q] - cnt[q][p-1] + cnt[p-1][p-1] )

	return


main()



Measured memory_bytes: 144508
from collections import Counter

w = raw_input()
x = []
f = True
for i in w:
    x.append(i)
counter = Counter(x)
for word,cnt in counter.most_common():
    if not cnt % 2 == 0:
        f = False

if f:
    print 'Yes'
else:
    print 'No'


Measured memory_bytes: 2808
import Control.Applicative
import Control.Monad
import Data.List
import Data.IntSet (IntSet)
import qualified Data.IntSet as IS

main :: IO ()
main = do
  n <- readLn
  map solve <$> replicateM n readLn >>= mapM_ print

solve :: Int -> Int
solve x = g 0 IS.empty x
  where
    f (x, d) = let (q, r) = divMod x d
               in if q == 0
                  then Nothing
                  else Just (q * r, (x, d * 10))
    g ct st x
      | IS.member x st = (-1)
      | x < 10 = ct
      | otherwise = g (ct + 1) (IS.insert x st) (maximum . unfoldr f $ (x, 10))



Measured memory_bytes: 4168
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define RREP(i, n) for (int i = n - 1; i >= 0; i--)
#define dump(x) cerr << #x << " = " << (x) << endl

using namespace std;

int N, K;

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

    cin >> N >> K;
    if (N % K == 0)
    {
        cout << 0 << endl;
    }
    else
    {
        cout << 1 << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<math.h>

typedef long long int int64;

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))

void run(void){
  int64 n,k;
  scanf("%lld%lld",&n,&k);
  if(k==0){
    printf("%lld\n",n*n);
    return;
  }
  int64 ans=0;
  int64 b;
  for(b=k+1;b<=n;b++){
    ans+=(n/b)*(b-k)+MAX(n%b-(k-1),0);
  }
  printf("%lld\n",ans);
}

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


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

using namespace std;

const int maxn = 100100;

int n,A,B,dp[maxn];
vector<int> g[maxn];

bool visit(int u,int pa) {
    vector<int> temp;
  //  cout<<u<<endl;
    if (g[u].size()%2) temp.push_back(-1);
    for (int j=0;j<g[u].size();j++) {
        int v = g[u][j];
        if (v!=pa) {
            if (!visit(v,u)) return false;
            if (dp[v]!=-1) temp.push_back(dp[v]);
        }
    }
    sort(temp.begin(),temp.end());
   // cout<<u<<" "<<temp.size()<<endl;
   // if (temp.size()>0) for (int i=0;i<temp.size();i++) cout<<temp[i]<<" ";
   // cout<<endl;
  //  cout<<"-------------"<<endl;
    if (temp.size()%2) {
        int ll=-1,rr=temp.size();
        while (ll+1<rr) {
            int x = (ll+rr)/2;
            bool ok = true;
            int p1=0,p2=temp.size()-1;
           // cout<<x<<endl;
            while (p1<p2) {
                if (p1==x) p1++;
                if (p2==x) p2--;
                if (temp[p1] + temp[p2] + 2 > B) {
                    ok = false;
                    break;
                }
                p1++;
                p2--;
            }
            if (ok) {
                rr = x;
            }
            else ll = x;
        }
       // cout<<rr<<endl;
        if (rr==temp.size()) return false;
        dp[u] = temp[rr] + 1;
        return true;
    }
    else {
        for (int i=0;i<temp.size();i++)
            if (temp[i] + temp[temp.size()-i-1] + 2 > B) return false;
        dp[u]=-1;
        return true;
    }
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
   // freopen("inp.txt","r",stdin);
    cin>>n;
    for (int i=1;i<n;i++) {
        int a,b;
        cin>>a>>b;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    A=0;
    for (int i=1;i<=n;i++) A+=g[i].size()%2;
    cout<<A/2<<" ";
    int l=-1,r=n+1;
    while (l+1<r) {
        B = (l+r)/2;
        if (visit(1,-1)) r = B;
        else l = B;
    }
    cout<<r;
}


Measured memory_bytes: 16768
#include<iostream>
#include<map>
#include<set>

using namespace std;

double R;

int shrink(double d){
  return (d+1e7)/(R*1.01);
}

int main(){
  int N;
  cin>>N>>R;
  map<int,set<int> > m;
  int ans=0;
  while(N--){
    double x,y;
    cin>>x>>y;
    int sx=shrink(x),sy=shrink(y);
    bool f=false;
    for(int i=0;i<3;i++){
      f|=m[sx+i-1].lower_bound(sy-1)!=m[sx+i-1].lower_bound(sy+2);
    }
    if(!f){
      ans++;
      m[sx].insert(sy);
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 53772
#include <iostream>
#include <fstream>
#include <stdio.h>
#include <algorithm>
#include <string>
#include <cmath>
#include <functional>
#include <cstdint>
#define REP(i, n) for(ll i = 0; i < n; i++)
using namespace std;


int main() {

  cin.tie(0);
  ios::sync_with_stdio(false);

  int a,b,c,x,y,ans;
  cin >> a >> b >> c >> x >> y;
  
  if(a+b > c*2){
    int ans1;
    if(x<y){
      ans1 = c*2*x + (y-x)*b;
    } else {
      ans1 = c*2*y + (x-y)*a;
    }
    int ans2 = c*2*max(x,y);
    ans = min(ans1, ans2);

  } else {
    ans = a*x + b*y;
  }
  cout << ans << endl;

}
  


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
def gcd(a, b):
    if (b == 0):
        return a
    return gcd(b, a % b)


n = int(input())
a = list(map(int, input().split()))
li = [0] * (n + 1)
r = [0] * (n + 1)

for i in range(n):
    li[i + 1] = gcd(li[i], a[i])

for i in range(n - 1, -1, -1):
    r[i] = gcd(r[i + 1], a[i])

ans = 0
for i in range(n):
    ans = max(ans, gcd(li[i], r[i + 1]))

print(ans)


Measured memory_bytes: 14076
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int a = scan.nextInt();
        int b = scan.nextInt();
        int c = scan.nextInt();
        int d = scan.nextInt();
        for(int i = 0; i < 1000; i++){
            if(i % 2 == 0){
                c -= b;
                if(c <= 0){
                    System.out.println("Yes");
                    System.exit(0);
                }
            }else{
                a -= d;
                if(a <= 0){
                    System.out.println("No");
                    System.exit(0);
                }
            }
        }
    }
}

Measured memory_bytes: 27220
#define _USE_MATH_DEFINES
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 30;
const int MOD = 1e9 + 7;

typedef complex<double> atom;

const int N = 2e5 + 10;
char s[N];

typedef complex<double> atom;

void bit_reverse(vector<atom>& a) {
  int n = a.size();
  for (int i = 1, j = n / 2; i < n - 1; ++i) {
    if (i < j) {
      swap(a[i], a[j]);
    }
    int k = n / 2;
    while (j >= k) {
      j -= k;
      k /= 2;
    }
    if (j < k) j += k;
  }
}

void fft(vector<atom>& a, int flag) {
  int n = a.size();
  bit_reverse(a);
  vector<atom> wn(n);
  for (int i = 0; i < n; ++i) {
    wn[i] = atom{cos(flag * 2 * M_PI / n * i), sin(flag * 2 * M_PI / n * i)};
  }
  for (int k = 2; k <= n; k <<= 1) {
    for (int i = 0; i < n; i += k) {
      int wi = 0, step = n / k;
      for (int j = i; j < i + k / 2; ++j) {
        atom u = a[j];
        atom v = wn[wi] * a[j + k / 2];
        a[j] = u + v;
        a[j + k / 2] = u - v;
        wi += step;
      }
    }
  }
  if (flag < 0) {
    for (int i = 0; i < n; ++i) {
      a[i] /= n;
    }
  }
}

vector<int> mul(const vector<int>& f, const vector<int>& g) {
  int n = f.size(), m = g.size();
  int len = 1;
  while (len < n + m - 1) len <<= 1;
  vector<atom> x(len), y(len);
  copy(f.begin(), f.end(), x.begin());
  copy(g.begin(), g.end(), y.begin());
  fft(x, 1);
  fft(y, 1);
  for (int i = 0; i < x.size(); ++i) {
    x[i] *= y[i];
  }
  fft(x, -1);
  vector<int> ret(len);
  for (int i = 0; i < x.size(); ++i) {
    ret[i] = (int)(x[i].real() + 0.5);
  }
  return ret;
}

int main() {
  scanf("%s", s);
  int n = strlen(s);
  // int n = 20000;
  // for (int i = 0; i < n; ++i) {
  //   s[i] = rand() % 26 + 'a';
  // }
  int64 ret = 0;
  for (int k = 0; k < 26; ++k) {
    int64 cnt = 0;
    for (int i = 0; i < n; ++i) {
      if (s[i] - 'a' == k) ++cnt;
    }
    ret += cnt * (cnt - 1) / 2;
  }
  printf("%lld\n", (int64)n * (n - 1) / 2 - ret + 1);
  return 0;
}


Measured memory_bytes: 384
#include<cstdio>
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>

using namespace std;

struct node{int a;int b;}g[60];

bool f[60],map[60][60];
int q[900];

int main(){
	int n,m,i,j,cnt=0,x,y;
	int head,tail;
	scanf("%d%d",&n,&m);
	for(i=1;i<=m;i++){
		scanf("%d%d",&x,&y);
		g[i].a=x;
		g[i].b=y;
		map[x][y]=map[y][x]=true;
	}
	for(i=1;i<=m;i++){
		map[g[i].a][g[i].b]=map[g[i].b][g[i].a]=false;
		for(j=1;j<=n;j++)f[j]=false;
		head=1;
		tail=2;
		q[1]=1;
		f[1]=true;
		while(head!=tail){
			x=q[head++];
			for(j=1;j<=n;j++)
				if(map[x][j]&&!f[j]){
					f[j]=true;
					q[tail++]=j;
				}
		}
		for(j=1;j<=n;j++)
			if(!f[j]){
				cnt++;
				break;
			}
		map[g[i].a][g[i].b]=map[g[i].b][g[i].a]=true;
	}
	printf("%d",cnt);
	return 0;
}		

Measured memory_bytes: 256
N = int(input())
nums = list(map(int, input().split()))
L = [0 for _ in range(N)]
R = [0 for _ in range(N)]
L[0] = nums[0]
for i in range(N-1):
  L[i+1] = L[i] + nums[i+1]
  R[N-i-2] = R[N-i-1] + nums[N-i-1]
ans = 10**20
for i in range(N):
  ans = min(ans, abs(R[i]-L[i]))
print(ans)

  

Measured memory_bytes: 119320
#include<iostream>
#include<string>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<queue>
#include<stack>
#include<map>
using namespace std;
#define ll long long
int main(){
    ll N,A,B;
    cin >> N >> A >> B;
    ll i;
    ll tmp,cnt,ans=0;
    for(i=1;i<=N;i++){
      tmp=i;
      cnt=0;
      while(tmp!=0){
        cnt+=tmp%10;
        tmp=tmp/10;
      }
      if(A<=cnt&&cnt<=B)ans+=i;
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 256
s = input()
a = s[:2]
b = s[2:]
if int(a) == 0 or int(a) > 12:
	if int(b) == 0 or int(b) > 12:
		print("NA")
	else:
		print ("YYMM")
else:
	if int(b) == 0 or int(b) > 13:
		print ("MMYY")
	else:
		print ("AMBIGUOUS")

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  cin>>n;
  int h[n];
  int d[n];
  for(int i=0;i<n;i++)
    cin>>h[i];
  d[0]=0;d[1]=abs(h[1]-h[0]);
  for(int i=2;i<n;i++)
    d[i]=min( d[i-1]+abs(h[i]-h[i-1]) , d[i-2]+abs(h[i]-h[i-2]) );
  cout<<d[n-1];
}
 


Measured memory_bytes: 1024
a, b, c, x = [int(input()) for i in range(4)]
ans = 0
for i in range(a + 1):
    for j in range(b + 1):
        for k in range(c + 1):
            if 500 * i + 100 * j + 50 * k == x:
                ans += 1
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n, u, k, v, c, l[101][101], ans[101];
    for (int i = 0; i < 101; i++) ans[i] = 1e9;
    ans[0] = 0;
    for (int i = 0; i < 101; i++) for (int j = 0;j < 101; j++)l[i][j] = 1e9;
    queue<int> q;
    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> u >> k;
        for(int j = 0;j < k; j++){
            cin >> v >> c;
            l[u][v] = c;
        }
    }
    q.push(0);
    while(!q.empty()){
        int _u = q.front();
        q.pop();
        for (int i = 0; i < n; i++){
            if (l[_u][i] != 1e9){
                if (ans[i] > ans[_u] + l[_u][i]){
                    ans[i] = ans[_u] + l[_u][i];
                    q.push(i);
                }
            }
        }
    }
    for (int i = 0 ; i < n; i++) cout << i << " "<< ans[i] << endl;
}



Measured memory_bytes: 3100
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#include <iostream>
#include <set>
 
int main(void){
  string s;cin >> s;
  vector<int> v(26,0);
  for(char c:s) v[c-'a']++;
  for(int i;i<26;i++){
    if(!v[i]) {
      char c = 'a' +i;
      cout << c <<endl;
      return 0;
    }
  }
  cout << "None" << endl;
  return 0;
}

Measured memory_bytes: 3720
import sys
Debug = lambda *args: None
if len(sys.argv) > 1:
	sys.stdin = open("io/test.in", "r")
	Debug = lambda *args: print('\033[0;31m', *args, '\033[0m', file=sys.stderr)


# Author: Narut Sereewattanawoot
###
def Rd(f=int):
	return [f(x) for x in input().split()]


def JoinF(arr):
	return ' '.join('{:.10f}'.format(x) for x in arr)


###


def main():
	n = int(input())
	S = set(input() for _ in range(n))
	print(len(S))


main()


Measured memory_bytes: 31140
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<vector>
#define SF scanf
#define PF printf
#define MAXN 100010
using namespace std;
typedef long long ll;
int n,fr,la;
ll a[MAXN],pos[MAXN],ans,s;
int ord[MAXN];
int main(){
    SF("%d%lld",&n,&s);
    for(int i=1;i<=n;i++)
        SF("%lld%lld",&pos[i],&a[i]);
    fr=1,la=n;
    int top=n;
    while(s>pos[fr]&&s<pos[la]){
        if(a[fr]<a[la]){
            a[la]+=a[fr];
            ord[top--]=fr;
            fr++;
        }
        else{
            a[fr]+=a[la];
            ord[top--]=la;
            la--;
        }
    }
    if(s<pos[fr]){
        for(int i=1;i<=top;i++)
            ord[i]=fr+i-1;
    }
    else{
        for(int i=1;i<=top;i++)
            ord[i]=la-i+1;
    }
    for(int i=1;i<=n;i++){
        ans+=abs(s-pos[ord[i]]);
        s=pos[ord[i]];
    }
    PF("%lld",ans);
}


Measured memory_bytes: 2176
import java.util.Scanner;

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

        long N = sc.nextLong();
        long x;
        long y;
        char[] out = new char[11];  // 1000000000000001 <= 26^10とちょっとくらい？なので11桁

        for (int i = 0; i < 11; i++) {
            N = N - 1;  // 
            x = N / 26;
            y = N % 26;
            out[i] = (char) ('a' + y);
            if (x == 0) {
                break;
            }
            N = x;
        }

        for (int i = 10; i >= 0; i--) {
            if (out[i] == Character.MIN_VALUE) {
                continue;
            }
            System.out.print(out[i]);
        }
    }
}

Measured memory_bytes: 27104
#include <iostream>
#include <sstream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <bitset>
#include <assert.h>
#include <deque>
using namespace std;

typedef unsigned long long UL;
typedef long long LL;
typedef long double LD;
#define LP(i, a, b) for (LL i = int(a); i < int(b); i++)
#define LPE(i, a, b) for (LL i = int(a); i <= int(b); i++)
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
typedef vector<vector<PII> > WAL;
typedef vector<vector<int> > SAL;
#define Ep 1e-8
#define INF 1e9
#define LINF 1e18

LL const MaxSize = 100 + 5;
LL const MOD = 1e9 + 7;
LL const BASE = 256;

/*


 */

int N;

int main() {
	ios_base::sync_with_stdio(false);
	//freopen("/Users/georgeli/A_1.in", "r", stdin);
	int a, b, c;
	cin >> a >> b >> c;

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

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <stdlib.h>
#include <cstdint>
using namespace std;

#define N 200000

int a[N];
 
int main()
{
	int a, b, c, d;

	cin >> a >> b >> c >> d;

	if( abs(b - a) <= d &&  abs(c - b) <= d || abs(c - a) <= d ) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int A[100],N,i,j,k,l,temp,count=0,minj;
  scanf("%d",&N);
  for(i=0;i<N;i++)scanf("%d",&A[i]);

  /*selection sort 0-origin*/
  for(j=0;j<N-1;j++){
    minj=j;
    for(k=j;k<N;k++){
      if(A[k]<A[minj]) minj=k;
    }
    temp=A[j];
    A[j]=A[minj];
    A[minj]=temp;
    if(j!=minj) count++;
  }
  for(l=0;l<N-1;l++)printf("%d ",A[l]); printf("%d",A[N-1]);
  printf("\n%d\n",count);
  return 0;
}



Measured memory_bytes: 2700
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <cstring>
#include <map>
#include <set>
#include <algorithm>
#include <functional>
#include <queue>
#include <deque>
using namespace std;

int main(){
    int N;
    cin>>N;
    vector<int> height(N,0);
    for(int i=0;i<N;i++)
        cin>>height[i];
    int last=height[0];
    int res=1;
    for(int i=1;i<N;i++){
        if(height[i]>=last){
            res++;
            last=height[i];
        }
    }
    cout<<res;
}


Measured memory_bytes: 256
n,m,x,y=map(int,input().split())
xlist=list(map(int,input().split()))
ylist=list(map(int,input().split()))


xmax=max(x,max(xlist))
ymin=min(y,min(ylist))

if xmax +1 <= ymin:
    print('No War')
else:
    print('War')

Measured memory_bytes: 3060
package main

import "fmt"

func checkContain(a int, arr []int) bool {
	for i := 0; i < len(arr); i++ {
		if arr[i] == a {
			return true
		}
	}
	return false
}

func main() {
	var x, n, tmp int
	var arr []int
	fmt.Scanf("%d %d \n", &x, &n)
	for i := 0; i < n; i++ {
		fmt.Scanf("%d", &tmp)
		arr = append(arr, tmp)
	}

	if n == 0 {
		fmt.Println(x)
	} else {
		var count = 0
		for true {
			if !checkContain(x-count, arr) {
				fmt.Println(x - count)
				break
			}
			if !checkContain(x+count, arr) {
				fmt.Println(x + count)
				break
			}
			count++
		}
	}
}


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

int main() {
	int H,W,N;
	cin >> H >> W >> N;
    cout << (N + max(H, W)-1) / max(H, W) << endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
signed main(){
	int x,y;
	cin>>x>>y;
	for(int i=0;i<=x;i++){
		int c=i*2;
		int t=4*(x-i);
		int ans=c+t;
		if(c+t==y){cout<<"Yes"<<endl; return 0;
		}
	}
	cout<<"No"<<endl; return 0;
} 

Measured memory_bytes: 3648
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def TUPLE(): return tuple(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7 
#mod = 998244353
from decimal import *
#import numpy as np
#decimal.getcontext().prec = 10

H, W = MAP()

a = [LIST() for _ in range(H)]
cnt = 0

ans = []
for y in range(H):
	x = 0
	while x < W:
		if x < W-1 and a[y][x]%2:
			ans.append((y+1, x+1, y+1, x+2))
			cnt += 1
			a[y][x] -= 1
			a[y][x+1] += 1
		x += 1

y = 0
while y < H-1 :
	if a[y][-1]%2:
		ans.append((y+1, W, y+2, W))
		cnt += 1
		a[y][-1] -= 1
		a[y+1][-1] += 1
	y += 1

print(cnt)
for x in ans:
	print(*x)

Measured memory_bytes: 31884
#include<iostream>
using namespace std;
char c;
bool b=1,flag;
int main()
{
	while(cin>>c)
	{
		if(b==0&&c=='F')flag=1;
		if(c=='C')b=0;
	}
	if(flag)cout<<"Yes";
	else cout<<"No";
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

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

    int N = scanner.nextInt();
    int A = scanner.nextInt();

    if ( N%500 <= A) {
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }
  }

}

Measured memory_bytes: 21716
import java.util.*;
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in));
        
        Long count = new Long(0);

        Integer n = Integer.parseInt(stdin.readLine());
        
        Map<String, Integer> map = new HashMap<>();
        
        // 標準入力を1行ずつ読み出す。
        String line;
        while ((line = stdin.readLine()) != null) {
            char[] chars = line.toCharArray();
            Arrays.sort(chars);
            String newStr = new String(chars);
            Integer temp = map.get(newStr);
            if (temp == null) {
                map.put(newStr, 1);
            } else {
                count += temp;
                map.put(newStr, temp+1);
            }
        }
        System.out.println(count);
    }
}

Measured memory_bytes: 49512
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
using namespace std;
int n,m;

vector<int>visited,dp;

vector<vector<int>> edge2;
int bfs(int nod)
{
  queue<int> que;
  que.push(nod);
  int res=0;
  while(!que.empty())
  {
    int no;
    no=que.front();que.pop();
    for(int nn:edge2[no])
    {
      visited[nn]--;
      if(visited[nn]==0)
      {
        que.push(nn);
        //cout<<nn<<endl;
        dp[nn]=max(dp[nn],dp[no]+1);
        res=max(res,dp[nn]);

      }
      else
      {
        dp[nn]=max(dp[nn],dp[no]+1);
      }

    }
  }
  return res;
}

int main()
{
  ios::sync_with_stdio(false);
  int n,m;
  cin>>n>>m;
  edge2=vector<vector<int>>(n+1) ;
  visited=vector<int>(n+1,1);
  dp=vector<int>(n+1,-1);

  for(int i=0;i<m;i++)
  {
    int a,b;
    cin>>a>>b;
    edge2[a].push_back(b);
    visited[b]++;
  }
  for(int i=0;i<n;i++)
  {
    edge2[0].push_back(i+1);
  }
  cout<<bfs(0)<<endl;


  return 0;

}


Measured memory_bytes: 7164