akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main() {
vector<int> A(6);
  for(int i = 0; i < 6; i++) cin >> A.at(i);

  multiset<int> Path;
  for(int i = 0; i < 6; i++) Path.insert(A.at(i));
 
  if(Path.count(1) == 3 || Path.count(2) == 3 || Path.count(3) == 3 || Path.count(4) == 3){
    cout << "NO" << endl;
    return 0;
  }
cout << "YES" << endl;
}

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

int main() {
    int r, g, b, n;
    cin >> r >> g >> b >> n;
    int ans = 0;
    for (int i = 0; i * r <= n; i++) {
        for (int j = 0; i * r + j * g <= n; j++) {
            if ((n - i * r - j * g) % b == 0) {
                ans++;
            }
        }
    }

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


Measured memory_bytes: 256
import bisect
import copy
import heapq
import math
import sys
from collections import *
from itertools import accumulate, combinations, permutations, product
from math import gcd
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

s=input()
if s=="ABC":
    print("ARC")
else:
    print("ABC")

Measured memory_bytes: 68292
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <climits>
#include <sstream>

using namespace std;

int main(){
  int H, W, c;
  char S[55][55], ans[51][51];

  cin >> H >> W;

  for(int y = 0; y < H+2; y++){
    for(int x = 0; x < W+2; x++){
      S[y][x] = '0';
    }
  }

  for(int y = 0; y < H; y++){
    for(int x = 0; x < W; x++){
      cin >> S[y+1][x+1];
    }
  }

  for(int y = 1; y < H+1; y++){
    for(int x = 1; x < W+1; x++){
      if(S[y][x] == '#'){
        ans[y-1][x-1] = '#';
        continue;
      }
      c = 0;
      if(S[y-1][x-1] == '#') c++;
      if(S[y-1][x] == '#') c++;
      if(S[y-1][x+1] == '#') c++;
      if(S[y][x-1] == '#') c++;
      if(S[y][x+1] == '#') c++;
      if(S[y+1][x-1] == '#') c++;
      if(S[y+1][x] == '#') c++;
      if(S[y+1][x+1] == '#') c++;
      ans[y-1][x-1] = '0' + c;
    }
  }

  for(int y = 0; y < H; y++){
    for(int x = 0; x < W; x++){
      cout << ans[y][x];
    }
    cout << endl;
  }


	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
using ll = long long;
#define MOD 1000000007
using namespace std;

int main(){
    string S;
    cin >> S;
    for(int i = (int)S.length(); i >= 0; i--)//length
    {
        for(int j = 0; j < (int)S.length()-i+1; j++)
        {
            for(int k = j; k < j+i; k++)
            {
                if (S[k] != 'A' && S[k] != 'C' && S[k] != 'G' && S[k] != 'T') {
                    break;
                }
                else if (k == j+i-1) {
                    cout << i << endl;
                    return 0;
                }
            }
        }
    }
    cout << 0 << endl;
    return 0;
}

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

const int MaxN = 100000 + 5;

int N;
int A[MaxN], D[MaxN];

struct BIT {
  int t[MaxN];
  inline int lowbit(int i) { return i & -i; }

  inline void update(int x, int v) {
    for (int i = x; i <= N; i += lowbit(i))
      t[i] = max(t[i], v);
  }

  inline int query(int x) {
    int res = 0;
    for (int i = x; i > 0; i -= lowbit(i))
      res = max(res, t[i]);
    return res;
  }
} T;

void init() {
  scanf("%d", &N);
  for (int i = 1; i <= N; ++i) scanf("%d", &A[i]), D[i] = A[i];
  sort(D + 1, D + 1 + N);
  for (int i = 1; i <= N; ++i) A[i] = lower_bound(D + 1, D + 1 + N, A[i]) - D;
}

void solve() {
  for (int i = 1; i <= N; ++i)
    T.update(N - A[i] + 1, T.query(N - A[i] + 1) + 1);
  printf("%d\n", T.query(N));
}

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

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

int main() {
string A,B,C;
cin >> A >> B >> C;
if(A.at(A.size()-1)==B.at(0) && B.at(B.size()-1)==C.at(0)){
    cout << "YES" <<endl;
}
else{
    cout << "NO" <<endl;
}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int MaxN = 803;
int h,w,k,sx,sy;
bool e[MaxN][MaxN],f[MaxN][MaxN];
struct Statu{
	int x,y,k;
	Statu() {}
	Statu(int X,int Y,int K) :x(X),y(Y),k(K) {}
};
deque<Statu> q;
int main() {
	scanf("%d%d%d",&h,&w,&k);
	for (int i=1;i<=h;i++)
		for (int j=1;j<=w;j++) {
			register char ch=getchar();
			while (ch==' ' || ch=='\n') ch=getchar();
			e[i][j]=(ch!='#');
			if (ch=='S') sx=i,sy=j;
		}
	if (sx==1 || sx==h || sy==1 || sy==w) {
		puts("0");return 0;
	}
	f[sx][sy]=true;
	q.push_back(Statu(sx,sy,0));
	while (!q.empty()) {
		int tx=q.front().x,ty=q.front().y,tk=q.front().k;
		q.pop_front();
		if (tk==k) continue;
		if (tx==1 || tx==h || ty==1 || ty==w) {
			puts("1");
			return 0;
		}
		const int v[4][2] = {{-1,0},{0,-1},{1,0},{0,1}};
		for (int i=0;i<4;i++) {
			int vx=tx+v[i][0],vy=ty+v[i][1];
			if (vx<1 || vx>h || vy<1 || vy>w) continue;
			if (!f[vx][vy] && e[vx][vy]) {
				f[vx][vy]=true;
				q.push_back(Statu(vx,vy,tk+1));
			}
		}
	}
	int ans=0x7fffffff;
	for (int i=1;i<=h;++i) for (int j=1;j<=w;++j) if (f[i][j]) {
		int dist=min(min(i-1,j-1),min(h-i,w-j));
		int r=(dist+k-1)/k;
		ans=min(r+1,ans);
	}
	printf("%d\n",ans);
	return 0;
}

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

#define MP make_pair
#define PB push_back
#define ALL(x) (x).begin(),(x).end()
#define REP(i,n) for(int i=0;i<(n);i++)
#define REP1(i,n) for(int i=1;i<(n);i++)
#define REP2(i,d,n) for(int i=(d);i<(n);i++)
#define RREP(i,n) for(int i=(n);i>=0;i--)
#define CLR(a)      memset((a),0,sizeof(a))
#define MCLR(a)     memset((a),-1,sizeof(a))
#define RANGE(x,y,maxX,maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<LL> VLL;
typedef pair<int,int> PII;

const int INF = 0x3f3f3f3f;
const LL INFL = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-9;

const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};

int main(){
    string w;
    cin >> w;
    REP(i, 26){
        int cnt = 0;
        REP(j, w.size()){
            cnt += w[j] == ('a' + i);
        }
        if(cnt % 2 == 1){
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  string a, b, ans="";cin>>a>>b;
  int len=a.size()+b.size();
  for(int i=0;i<len;i++){
    if(i%2==0){
      ans+=a.at(0);
      a=a.substr(1, a.size()-1);
    }else{
      ans+=b.at(0);
      b=b.substr(1, b.size()-1);
    }
  }
  cout << ans << endl;
}

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

using namespace std;
#define int long long


#define ff first
#define ss second
#define endl "\n"
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x.size())
#define PI 3.1415926535897932384626433832795
int MOD=1e9+7;
int powmod(int a,int l, int md){int res=1;while(l){if(l&1)res=res*a%md;l/=2;a=a*a%md;}return res;}
int binpow(int a,int l){int res=1;while(l){if(l&1)res=res*a;l/=2;a=a*a;}return res;}
typedef long long ll; typedef vector<ll> vi; typedef pair<ll, ll> ii; typedef vector<ii> vii;
#define pb push_back
int __set(int b, int i) {return b|(1<<i);} //set ith bit
int __unset(int b, int i) {return b&(~(1UL<<i));}
int __check(int b, int i) {return b&(1<<i);} //returns 0 if ith bit is 0
int mulmod(int a, int b, int md) {return ((a%md)*(b%md))%md;}
int addmod(int a, int b, int md) {return (a+b)%md;}
int submod(int a, int b, int md) {return (((a-b)%md)+md)%md;}
int divmod(int a, int b, int md) {return mulmod(a, powmod(b, md-2, md), md);} //if md is prime;
const ll inf = 0xFFFFFFFFFFFFFFFL; //very large number
priority_queue<int, vector<int>, greater<int> > pq; //for min priority_queue
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
clock_t time_p=clock();
void time()
{
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}

#define arr (int)(4e3)

int f[arr];
int rf[arr];

int C(int l,int k, int md) 
{
    if (k<0||k>l){
        return 0;
    }
    return f[l]*rf[k]%md*rf[l-k]%md;
}

void precfac() {
    f[0]=1;
    for (int i=1;i<arr;i++){
        f[i]=f[i-1]*i%MOD;
    }
    rf[arr-1]=powmod(f[arr-1],MOD-2, MOD);
    for (int i=arr-2;i>=0;i--){
        rf[i]=rf[i+1]*(i+1)%MOD;
    }
}

signed main(void)
{
	IOS;
	// int n;
	// cin>>n;
	// vi a(n); vi b(n);
	// for(int  i = 0; i < n; i++) {
	// 	cin>>a[i];
	// }
	// for(int i = 0; i < n; i++)
	// 	cin>>b[i];
	// vi c=a; vi d=b;
	// int cnt=0;
	// while(1) {
	// 	int no=0;
	// 	for(int i = 0; i < n; i++) {
	// 		if(d[i]!=a[i]) {
	// 			no=1;
	// 			break;
	// 		}
	// 	}
	// 	if(!no) {
	// 		cout<<cnt<<endl;
	// 		return 0;
	// 	}
	// 	if(!next_permutation(all(d))) {
	// 		break;
	// 	}
	// 	cnt++;
	// }
	// cnt=0;
	// while(1) {
	// 	// for(int i: c)
	// 	// 	cout<<i<<" ";
	// 	// cout<<endl;
	// 	// for(int i: b)
	// 	// 	cout<<i<<" ";
	// 	// cout<<endl;
	// 	int no=0;
	// 	for(int i = 0; i < n; i++) {
	// 		if(c[i]!=b[i]) {
	// 			no=1;
	// 			break;
	// 		}
	// 	}
	// 	if(!no) {
	// 		cout<<cnt<<endl;
	// 		return 0;
	// 	}
	// 	if(!next_permutation(all(c))) {
	// 		break;
	// 	}
	// 	cnt++;
	// }


	int cnt=0;
	int n; cin>>n;
	string s; cin>>s;
	for(int i = 0; i <= n-3; i++) {
		if(s[i]=='A' && s[i+1]=='B' && s[i+2]=='C') {
			cnt++;
		}
	}
	cout<<cnt<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<numeric>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<map>
#include<utility>
#include<cmath>
#include<tuple>
#include<string>
#include<bitset>
#include<set>
#include<queue>
#include<stack>
#include<cstdio>
using namespace std;
using ll = long long;

int main(){
    int n;
    cin>>n;
    vector<ll> a(n),b(n);
    for(int i=0;i<n;i++) cin>>a[i];
    b[0]=a[0];
    for(int i=1;i<n;i++){
        b[i]=b[i-1]+a[i];
    } 
    ll ans=0;
    for(int i=0;i<n-1;i++){
        ll sum=b[n-1]-b[i];
        sum%=1000000007;
        ans+=a[i]*sum;
        ans%=1000000007;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 6376
#include <bits/stdc++.h>
using namespace std;
int main()
{
    string str;
    cin >> str;
    array<int, 500> unk;
    for (int& i : unk) {
        i = 0;
    }
    for (char c : str) {
        unk[c] += 1;
    }
    for (int i : unk) {
        if (i != 2 && i != 0) {
            cout << "No" << endl;
            exit(0);
        }
    }
    cout << "Yes" << endl;
}

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

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

  char c;
  for (int i; i < n; i++) {
    std::cin >> c;
    if (c == 'Y'){
      std::cout << "Four" << std::endl;
      return 0;
    }
  }

  std::cout << "Three" << std::endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String[] args) {
        // input
        Scanner sc = new Scanner(System.in);
        long a = sc.nextInt();
        long b = sc.nextInt();
        long c = sc.nextInt();
        long v = c - a - b;
        System.out.println(v > 0 && v * v > 4 * a * b ? "Yes" : "No");
    }
}

Measured memory_bytes: 21844
import java.util.*;
public class Main{
 public static void main(String[] args){
   Scanner sc = new Scanner(System.in);
 
   int N = sc.nextInt();
 
   Integer[] beki = new Integer[43];
   for(int i=1;i<=31;i++) beki[i-1]=i*i;
   for(int i=2;i<=10;i++) beki[i+29]=i*i*i;
   for(int i=2;i<=3;i++) beki[i+38]=i*i*i*i*i;
   beki[42]=128;
   
   for(int i=N;true;i--)
   {
     if(Arrays.asList(beki).contains(i))
     {
       System.out.println(i);
       break;
     }
   }
 }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
template<class T> inline bool chmin(T&a, T b){if(a > b){a = b; return true;}else{return false;}}
template<class T> inline bool chmax(T&a, T b){if(a < b){a = b; return true;}else{return false;}}
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define pi (double) acos(-1.0)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using namespace std;

int main() {
    int n, m;
    cin >> n >> m;
    vector<int> a(m), b(m), dp(1<<n, mod);
    vector<vector<int>> c(m);
    rep(i, m){
        cin >> a[i] >> b[i];
        c[i].resize(b[i]);
        rep(j, b[i]){
            cin >> c[i][j];
            c[i][j]--;
        }
    }
    dp[0] = 0;
    rep(bit, (1<<n)){
        rep(i, m){
            int next = bit;
            rep(j, b[i])next |= (1<<c[i][j]);
            chmin(dp[next], dp[bit] + a[i]);
        }
    }
    cout << (dp[(1<<n)-1] == mod ? -1 : dp[(1<<n)-1]) << endl;
}

Measured memory_bytes: 3676
#include <iostream>
#include <string>
using namespace std;
int main() {
    string x;
    while (cin >> x) {
        if (x == "0") {
            break;
        }
        int sum = 0;
        for (int i=0; i<x.size(); ++i) {
            sum += x[i] - '0';
        }
        cout << sum << "\n";
    }
    return 0;
}

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

int main(){
	int i, j, n, a[100];
	cin >> n;
	
	for ( i = 0; i < n; i++ ){
		cin >> a[i];
	}
	
	for ( j = n-1; j >= 0 ; j-- ){
	    cout << a[j];
	    if ( j != 0 ) cout << " ";
	    if ( j == 0 ) cout << endl;
	}
	
	return 0;
}


Measured memory_bytes: 3096
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define repb(i, n) for (int i = (int)n; i >= 0; i--)
#define reps(i, m, n) for (int i = (int)m; i < (int)n; i++)
#define repsb(i, m, n) for (int i = (int)m; i >= (int)n; i--)
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define pb(a) push_back(a)
#define INF 999999999999999999
#define ll long long int
int dy[] = {0, 0, 1, -1, 0};
int dx[] = {1, -1, 0, 0, 0};
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;
}
//vector<vector<int>> vec(n_rows, vector<int>(n_cols, value));
using namespace std;
int main(int argc, char const *argv[])
{
    int a, b, c;
    cin >> a >> b >> c;
    cout << c << " " << a << " " << b;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < (int)n; i++)
#define REPvec(itr, mp) for(auto itr = mp.begin();itr != mp.end(); itr ++)
#define all(x) x.begin(), x.end()
#define MOD 1000000007//1e9+7
using namespace std;
typedef long long ll;
typedef vector<int >    vecint;
typedef vector<vector<int> >    vec2int;
typedef vector<vector<bool> >    vec2bool;
typedef vector<bool >    vecbool;
typedef vector<string > vecstr;
int main()
{
  vec2int a(3, vecint(3,0));
  REP(i, 3){
    REP(j, 3){
      cin >> a[i][j];
    }
  }
  int n;cin >> n;
  vec2bool mp(3,vecbool(3,false));
  int tmp = 0;
  REP(i,n) {
    cin >> tmp;
    REP(i2, 3){
      REP(j2, 3){
	if(a[i2][j2] == tmp){
	  mp[i2][j2] = true;
	  break;
	}
      }
    }
  }



  //tate
  bool ok = false;
  REP(i,3){
    ok = true;
    REP(j,3){
      if(!mp[i][j]){
	ok = false;
	break;
      }
    }
    if(ok){
      cout << "Yes" << endl;
      return 0;
    }
  }
  // yoko
  REP(i,3){
    ok = true;
    REP(j,3){
      if(!mp[j][i]){
	ok = false;
	break;
      }
    }
    if(ok){
      cout << "Yes" << endl;
      return 0;
    }
  }
  // naname
  ok = true;
  REP(i,3){
    if(!mp[i][i]){
      ok = false;
      break;
    }
  }
  if(ok){
    cout << "Yes" << endl;
    return 0;
  }
  ok = true;
  REP(i,3){
    if(!mp[i ][2 - i]){
      ok = false;
      break;
    }
  }
  if(ok){
    cout << "Yes" << endl;
    return 0;
  }else{
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
#include <iostream> // cin, cout, cerr, clog
#include <algorithm> // minmax, sort, swap
#include <numeric> // iota, accumulate, inner_product
#include <cstdio> // printf, scanf
#include <climits> // INT_MIN, LLONG_MIN
#include <cmath> // long, trig, pow
#include <string> // string, stoi, to_string
#include <vector> // vector
#include <queue> // queue, priority_queue
#include <deque> // deque
#include <stack> // stack
#include <map> // key-value pairs sorted by keys
#include <set> // set
#include <unordered_map> // hashed by keys
#include <unordered_set> // hashed by keys
#include <iomanip> // cout<<setprecision(n)
#include <functional> // std::function<void(int)>

#define rep(i,n) for(int i = 0; i < n; i++)
#define ENDL "\n"
#define print(i) std::cout << (i) << "\n"

#define int long long // at least int64 > 9*10^18
#define all(v) v.begin(), v.end()

#define dump1(v) for(auto i:v) std::cout << i << ' '; std::cout << "\n";

signed main() {
	int n,k;
	std::cin >> n >> k;
	std::string s;
	std::cin >> s;
	int l,r;
	l=r=0;
	for(int i=0;i<k;) {
		while(s[r]=='1') {
			r++;
			if(r==n) { print(n); return 0; }
		}
		while(s[r]=='0') {
			r++;
			if(r==n) { print(n); return 0; }
		}
		i++;
	}
	while(s[r]=='1') {
		r++;
		if(r==n) { print(n); return 0; }
	}
	int max = r-l;
	while(1) {
		while(s[l]=='1') {
			l++;
			if(l==n) break;
		}
		if(l==n) break;
		while(s[l]=='0') {
			l++;
			if(l==n) break;
		}
		if(l==n) break;
		while(s[r]=='0') {
			r++;
			if(r==n) goto evaluate;
		}
		while(s[r]=='1') {
			r++;
			if(r==n) goto evaluate;
		}
evaluate:
		max = std::max(max,r-l);
	}
	print(max);
}


Measured memory_bytes: 512
import java.util.Arrays;
import java.util.Scanner;

public class Main {

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

		int n = Integer.parseInt(sc.next());
		int[] pro = new int[n];

		for (int i = 0; i < n; i++) {
			pro[i] = Integer.parseInt(sc.next());
		}

		Arrays.sort(pro);

		System.out.println(pro[n / 2] - pro[n / 2 - 1]);
	}
}

Measured memory_bytes: 48656
#include "bits/stdc++.h"
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
string s,ans;
int a,b,c,d,B,C,D;
int main() {
	cin >>s;
	a = s[0] - '0';
	b = s[1] - '0';
	c = s[2] - '0';
	d = s[3] - '0';
		for (int j = 0; j < 2; j++) {
			B = b - (j * 2 * b);
			for (int k = 0; k < 2; k++) {
				C = c - (k * 2 * c);
				for (int l = 0; l < 2; l++) {
					D = d - (l * 2 * d);
					if (a + B + C + D == 7) {
						ans += s[0];
						B < 0 ? ans += "-" : ans += "+";
						ans += s[1];
						C < 0 ? ans += "-" : ans += "+";
						ans += s[2];
						D < 0 ? ans += "-" : ans += "+";
						ans += s[3];
						ans += "=7";
						cout << ans << endl;
						return 0;
					}
				}
			}
		}
	}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int h,w,i,j;
  while(1){
  scanf("%d %d",&h, &w);
  if(w*h==0)break;
  for(j=0;j<h;j++){
    for(i=0;i<w;i++){
      printf("#");
    } 
    printf("\n");
 }
  printf("\n");
  }
  return 0;
}

Measured memory_bytes: 572
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <iomanip>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define pie 3.141592653589793238462643383279
#define mod 1000000007
#define inf 10000000000000007
#define vsort(vec) sort(vec.begin(),vec.end())
#define vreverse(vec) reverse(vec.begin(),vec.end())
#define ggr getchar(); getchar();return 0;
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
bool prime(int x) {
	for (int i = 2; i <= sqrt(x); i++) {
		if (x%i == 0)return false;
	}
	return true;
}

int n, ta, mu;
string s;

signed main() {
	cin >> n >> s;
	rep(i, s.size()) {
		if (s[i] == 'R')ta++;
		else mu++;
	}
	if (ta > mu)cout << "Yes" << endl;
	else cout << "No" << endl;
	ggr
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define INF 2147483647//int max
const int MOD = 1000000007;
using namespace std;
using ll = long long;
using P = pair<int,int>;


int main() {
    int r,g;
    cin >> r >> g;
    cout << 2*g - r << endl;
    return 0;
}

/*
やっほい！
　　　　　　　やほほい！
　　　　+　　 　*
　　　 ∧∧　　. ∧∞∧　*
*　ヽ(=´ω｀)人(´ω｀*)ﾉ
　.～（ O x.） （ 　 O)～　+
。*　 　∪　　　　∪
*/

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<tuple>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-15
#define mp(a1,a2) make_pair(a1,a2)
typedef long long ll;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
ll N;
int a[100001];
int asort[100001];
ll Merge(std::vector<ll>& a, ll i, ll chunk_size, std::vector<ll>& tmp) {
     std::vector<ll>::iterator a1 = a.begin() + i;
     ll l1 = chunk_size;
     std::vector<ll>::iterator a2 = a1 + l1;
     ll l2 = (a.size() > i + chunk_size * 2) ? chunk_size : a.size() - i - chunk_size;

     tmp.clear();
     ll res = 0;

     for (ll i1 = 0, i2 = 0; i1 != l1 || i2 != l2; ) {
          if (i1 == l1) {
               tmp.push_back(a2[i2++]);
          } else if (i2 == l2) {
               tmp.push_back(a1[i1++]);
          } else if (a1[i1] < a2[i2]) {
               tmp.push_back(a1[i1++]);
          } else if (a2[i2] < a1[i1]) {
               tmp.push_back(a2[i2++]);
               res += l1 - i1;
          } else {
               std::cerr << "Oops" << std::endl;
          }
     }

     for (ll di = 0; di < tmp.size(); ++di)
          a[i + di] = tmp[di];

     return res;
}

ll CountCross(std::vector<ll>& a) {
     ll res = 0;
     std::vector<ll> tmp(a.size());

     for (ll chunk_size = 1; chunk_size < a.size(); chunk_size *= 2)
          for (ll i = 0; i + chunk_size < a.size(); i += chunk_size * 2)
               res += Merge(a, i, chunk_size, tmp);

     return res;
}
int tyuou(int ximin,int ximax){
	int endflag=0;
	if(ximin+1>=ximax) endflag=1;
	int ximid=(ximin+ximax)/2+(ximin+ximax)%2;
	int x=asort[ximid];
	vll S;
	S.push_back(0);
	rep(i,N){
		if(a[i]<x){
			S.push_back(S.back()-1);
		}
		else{
			S.push_back(S.back()+1);
		}
	}
	rep(i,N+1){
		S[i]=S[i]*1e+9+i;
	}
	ll zeroijo=N*(N+1)/2-CountCross(S);
	//printf("min:%d max:%d mid:%d zeroijo:%lld\n",ximin,ximax,ximid,zeroijo);
	if(zeroijo>=N*(N+1)/2/2+N*(N+1)/2%2){
		if(endflag) return x;
		else return tyuou(ximid,ximax);
	}
	else{
		if(endflag) return asort[ximid-1];
		return tyuou(ximin,ximid);
	}
}
int main(){
	scan(N);
	rep(i,N){
		scan(a[i]);
		asort[i]=a[i];
	}
	sort(asort,asort+N);
	prin(tyuou(0,N-1));
	return 0;
}


Measured memory_bytes: 16104
import java.util.Scanner;
public class Main{
    public static void main(String [] args){
        Scanner scan=new Scanner (System.in);
        int a=scan.nextInt();
        int b=scan.nextInt();
        int ans=0;
        if(a<b){
            ans+=b;
            b--;
        }else{
            ans+=a;
            a--;
        }
        if(a<b){
            ans+=b;
            b--;
        }else{
            ans+=a;
            a--;
        }
        System.out.println(ans);
        
    }
}

Measured memory_bytes: 22996
#include <bits/stdc++.h>
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>*/
 
#define pll              pair <long long,long long>
#define pb               push_back
#define ll               long long
#define ff               first
#define ss               second
#define D(x)             cerr<<#x " = "<<(x)<<endl
#define vll              vector <ll>
#define IOS              ios_base::sync_with_stdio(0); cin.tie(NULL);
#define endl             '\n'   
using namespace std;
int main()
{
    IOS
 	// freopen("input.txt","r",stdin);
 	// freopen("output.txt","w",stdout);
 	// freopen("error.txt","w",stderr);
 	ll n,k;
 	cin>>n>>k;
 	long double p[n];
 	for(ll i=0;i<n;i++)
 	{
 		cin>>p[i];
 	}
 	long double ans=0.0;
 	long double cur=0.0;
 	ll l=0,r=-1;
 	for(ll i=0;i<n;i++)
 	{
 		if(r-l+1<k)
 		{
 			r=i;
 			cur+=(p[i]+1)/2;
 			ans=max(ans,cur);
 		}
 		else
 		{
 			cur-=(p[l]+1)/2;
 			l++;
 			r=i;
 			cur+=(p[i]+1)/2;
 			ans=max(ans,cur);
 		}
 	}
 	cout<<fixed<<setprecision(12)<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3456
import sys
import collections

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline


def main():
    N, M = [int(x) for x in input().split()]
    AB = [[int(x) for x in input().split()] for _ in range(M)]

    c = collections.Counter()
    for a, b in AB:
        c[a] += 1
        c[b] += 1

    for k in c.keys():
        if c[k] % 2 == 1:
            print("NO")
            return
    else:
        print("YES")


if __name__ == '__main__':
    main()


Measured memory_bytes: 29732
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e18;
const int inf = 1e9;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define per(i, b, a) for (int i = a - 1; i >= b; i--)
using Graph = vector<vector<int>>;
using pint = pair<int, int>;
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
int dxx[8] = {1, 1, 1, 0, 0, -1, -1, -1}, dyy[8] = {-1, 0, 1, -1, 1, -1, 0, 1};

int main() {
    int x[5];
    rep (i, 0, 5) {
        cin >> x[i];
        if (x[i] == 0) {
            cout << i + 1 << "\n";
            return 0;
        }
    }
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
//#include <mylib.h>
using namespace std;
//cin.sync_with_stdio(false);

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define FOR_EQ(i,a,b) for(int i = (a); i <= (b); ++i)
#define FOR_RE(i,a,b) for(int i = (a); i > (b); --i)
#define rep(i,n) FOR(i,0,n)
#define rep_eq(i,n) FOR_EQ(i,0,n)
#define rep_re(i,n) FOR_RE(i,n,0)
//1個上から時計周り
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
//上右下左
const int dx[4] = {0, 1, 0, -1};
const int dy[4] = {1, 0, -1, 0};
static const int NIL = -1;

typedef unsigned long long ull;
typedef long long ll;
typedef vector<int> Vector;
typedef vector<Vector>	DVector;
int n;

//配列の表示
void printArray(int array[], int n){
    rep(i, n){
        if(i)   cout << " ";
        cout << array[i];
    }
    cout << endl;
}

int main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    int a[3];
    rep(i, 3)   cin >> a[i];
    
    sort(a, a + 3);
    int one, two;
    one = a[2] * 10 + a[1];
    two = a[0];
    cout << one + two << endl;
}

Measured memory_bytes: 256
n = int(input())

a = [0] * 10010

# x,y,z
for x in range(1, 101):
  for y in range(1, 101):
    for z in range(1, 101):
      if x*x + y*y + z*z + x*y + y*z + z*x > n:
        continue
      a[x*x + y*y + z*z + x*y + y*z + z*x] += 1


for i in range(1, n+1):
  print(a[i])


Measured memory_bytes: 9140
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations,permutations,accumulate # (string,3) 3回
#from collections import deque
from collections import deque,defaultdict,Counter
#import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
#mod = 9982443453
def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())
n = I()
A = readInts()
q = I()
dic = Counter(A)
SUM = sum(A)
#print(dic)
for i in range(q):
    b,c = readInts()
    SUM -= b * dic[b]
    SUM += c * dic[b]
    dic[c] += dic[b]
    dic[b] = 0
    print(SUM)
#print(dic)


Measured memory_bytes: 23976
N = int(input())
TA = [list(map(int, input().split())) for _ in range(N)]

pa = 1
pt = 1
for t, a in TA:
    k = max(pt//t, pa//a)
    if a*k < pa or t*k < pt:
        k += 1
    pa = a*k
    pt = t*k

print(pa+pt)

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

using namespace std;

int main(void)
{
    string s;

    cin >> s;

    bool a_flg = false, b_flg = false;
    for(int i=0; i<s.size(); i++)
    {
        if(s[i] == 'A')
        {
            a_flg = true;
        }
        else
        {
            b_flg = true;
        }
        
    }

    if((a_flg) && (b_flg) )
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
//

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
namespace mp = boost::multiprecision;
// 任意長整数型
using mp_int = mp::cpp_int;
// 仮数部が1024ビットの浮動小数点数型
using mp_float = mp::number<mp::cpp_dec_float<1024>>;

int main() {
	mp_float A, B;

	cin >> A >> B;

	ll ans = (ll)(A * B);

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3956
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <iomanip>
#include <bitset>
#include <set>
#include <map>
#include <stdio.h>
#include <numeric>

#define rep(i,n) for (long long int i = 0; i < (n); i++)
#define rep1(i,n) for (long long int i = 1; i < (n); i++)
#define FOR(i,a,b) for (int i=(a); i < (b); i++)
#define INF 100000000000
#define MOD 1000000007 //10^9+7
using namespace std;
using ll = long long;
using P = pair<int, int>;

// 負の数にも対応した % 演算
long long mod(long long val, long long m) {
    long long res = val % m;
    if (res < 0) res += m;
    return res;
}

long long gcd(ll a, ll b) 
{
    if (a % b == 0) {
        return b;
    } else {
        return gcd(b, a % b);
    }
}

long long lcm(ll a, ll b)
{
    return a / gcd(a, b) * b ;
}

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

    if (a % 2 == 0 || b % 2 == 0 || c % 2 == 0) {
        cout << 0 << endl;
        return 0;
    } else {
        cout << min(a*b,min(b*c,c*a)) << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  long long int h, w, ans;
  cin >> h >> w;
  if(h==1 or w==1) ans = 1;
  else if(h%2==1 and w%2==1) ans = (h*w+1)/2;
  else ans = h*w/2;
  cout << ans << "\n";
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using ll=long long;
#define rep(i,a,b) for(ll i=a;i<ll(b);i++)
#define repr(i,a,b) for(ll i=a;i>=ll(b);i--)
#define endl "\n"
#define ALL(x) x.begin(),x.end()
#define ALLR(x) x.rbegin(),x.rend()
using namespace std;

const ll MAX = 1e18;
int n;
int main() {
	cin >> n;
	vector<ll> a(n);
	rep(i, 0, n){
		ll tmp; cin >> tmp;
		if(tmp==0){
			cout << 0 << endl;
			return 0;
		}
		a[i] = tmp;
	}

	long double log = 0;
	rep(i, 0, n) log += log10(a[i]);
	if(log > 18) {
		cout << "-1" << endl;
		return 0;
	}

	ll ans = 1;
	rep(i, 0, n){
		ans *= a[i];
		if(ans > MAX){
			cout << "-1" << endl;
			return 0;
		}
	}

	cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3676
#include <iostream>

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define IN(v) int v;cin>>v;
#define OUT(v) cout<<v<<"\n"
const int MAX_N = 200000;
const int MAX_M = 200000;

int A[MAX_M], B[MAX_M];
bool reachable[MAX_N+1];
int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  IN(N); IN(M);

  REP(i, N+1)
    reachable[i] = false;
  REP(i, M) {
    cin >> A[i] >> B[i];
    if (A[i] == 1)
      reachable[B[i]] = true;
  }
  REP(i, M) {
    if (reachable[A[i]] && B[i] == N) {
      OUT("POSSIBLE");
      return 0;
    }
  }
  OUT("IMPOSSIBLE");
  return 0;
}


Measured memory_bytes: 2048
#!/usr/bin/env python3
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys
import collections
from decimal import Decimal # 10進数で考慮できる

mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000

d = collections.deque()
def LI(): return list(map(int, sys.stdin.readline().split()))

N = int(input())

s = str(N)[-1]
if s == "3":
    ans = "bon"
elif s in ["0", "1", "6", "8"]:
    ans = "pon"
else:
    ans = "hon"

print(ans)

Measured memory_bytes: 10832
#include<bits/stdc++.h>
using namespace std;
#define FIO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define mod 1000000007
#define test ll tx; tx=1; while(tx--)
typedef long long int ll;
int main() {
    FIO;
    test{
        ll a,b,c,d,flag=1,win;
        cin>>a>>b>>c>>d;
        while(flag==1){
            c-=b;
            if(c<=0){
                win=1;
                flag=0;
            }
            else{
                a-=d;
                if(a<=0){
                    win=0;
                    flag=0;
                }
            }
        }
        win==1 ? cout<<"Yes\n" : cout<<"No\n";
    }
	return 0;
}


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

int cnt[6];

int main(void){
  int n;
  cin >> n;
  for(int i = 0; i < n; i++){
    double h;
    cin >> h;
    if(h < 165.0) cnt[0]++;
    else if(h < 170.0) cnt[1]++;
    else if(h < 175.0) cnt[2]++;
    else if(h < 180.0) cnt[3]++;
    else if(h < 185.0) cnt[4]++;
    else cnt[5]++;
  }
  for(int i = 0; i < 6; i++){
    cout << (i + 1) << ":";
    for(int j = 0; j < cnt[i]; j++) cout << "*";
    cout << endl;
  }
  return 0;
}

Measured memory_bytes: 1232
#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 rep1(i,n) for(int i = 1; i <= (n); i++)
#define rrep1(i,n) for(int i = (n); i > 0; i--)

#define ll long long
#define pi pair<int, int>
#define pll pair<ll, ll>

#define MOD 1000000007
#define INF 1000000000000000LL

using namespace std;

#define MAXN 10000
#define MAXD 100

int dp[MAXN+1][MAXD+1][2];

int main(){
  string s;cin>>s;
  int n = s.size();
//  reverse(s.begin(), s.end());
  int d;cin>>d;

  dp[0][0][1]=1;

  rep(i, n)rep(j, d)rep(k, 10){
    int cd = s[i]-'0';

    int nj = (j+k)%d;

//cout<<cd<<' '<<j<<'>'<<nj<<' '<<k<<endl;

    if(k==cd){
      dp[i+1][nj][1] += dp[i][j][1];
      dp[i+1][nj][0] += dp[i][j][0];
    }else if(k<cd){
      dp[i+1][nj][0] += dp[i][j][1] + dp[i][j][0];
    }else{
      dp[i+1][nj][0] += dp[i][j][0];
    }
    dp[i+1][nj][1] %= MOD;
    dp[i+1][nj][0] %= MOD;
  }

  ll result = (dp[n][0][1]+dp[n][0][0])%MOD;
  cout << (result-1+MOD)%MOD << endl;

  return 0;

cout<<dp[n][0][1]<<' '<<dp[n][0][0]<<endl;
cout<<dp[n][0][1]<<' '<<dp[n][0][0]<<endl;

rep(i, n+1){
  rep(j, d+1)cout<<dp[i][j][0]+dp[i][j][1]<<' ';
  cout<<endl;
}

  return 0;
}



Measured memory_bytes: 11516
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
using ll = long long;
int INF = 1000000009;
int main()
{
    int a,b,c,x,y;
    cin >> a >> b >> c >> x >> y;
    if(x < y){
        swap(x, y);
        swap(a, b);
    }
    ll ans = min(a + b, 2 * c) * min(x, y) + min(a, 2 * c) * (x - y);
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.io.*;
public class Main{
    public static void main(String[] args) throws IOException{
        Reader r = new Reader();      
        int N = r.i();
        int x = N/100;
        x = 100*x+10*x+x;
        print(N <= x ? x : x+111);
    }
    static void print(Object o){
        System.out.println(o.toString());
    }
    static class Reader extends BufferedReader{
        Reader(){
            super(new InputStreamReader(System.in));
        }
        String s() throws IOException{
            return readLine();
        }
        String[] ss() throws IOException{
            return s().split(" ");
        }
        int Int(String s){
            return Integer.parseInt(s);
        }
        int i() throws IOException{
            return Int(s());
        }
        int[] ii() throws IOException{
            String[] ss = ss();
            int size = ss.length;
            int[] ii = new int[size];
            for(int j = 0; j < size; j++) ii[j] = Int(ss[j]);
            return ii;
        }
    }
}

Measured memory_bytes: 21076
#include<iostream>
#include<algorithm>
#include<stdio.h>
#include<string>
#include<vector>
using namespace std;



int main(){
    int r, d, x;
    cin >> r >> d >> x;
    for(int i = 0; i < 10; i++){
        x = r * x - d;
        cout << x << endl;
    }

}

Measured memory_bytes: 256
IDENTIFICATION DIVISION.
        PROGRAM-ID. AtCoder.
      
        ENVIRONMENT DIVISION.
      
        DATA DIVISION.
        WORKING-STORAGE SECTION.
        01 INP PIC X(100).
        01 A PIC 9(15).
        01 B PIC 9(15).
        01 C PIC 9(15).
      	01 D PIC 9(15).
      	01 F PIC 9(15).
      	01 E PIC ZZZZZZZZZZZZ9.
	    01 temp1 PIC 9(15).
        01 temp2 PIC 9(15).
        01 N PIC 9(15).
      
        PROCEDURE DIVISION.
      	MAIN.
			ACCEPT INP.
        	PERFORM VARYING temp1 FROM 1 BY 1
            UNTIL INP(temp1:1) = SPACE
        	END-PERFORM.
        	SUBTRACT 1 FROM temp1.
        	MOVE INP(1:temp1) TO A.
        	ADD 2 TO temp1.
        	PERFORM VARYING temp2 FROM temp1 BY 1
            UNTIL INP(temp2:1) = SPACE
        	END-PERFORM.
        	COMPUTE N = temp2 - temp1.
        	MOVE INP(temp1:N) TO B.
      		IF A = B THEN
      			COMPUTE E = 2 * B
      		ELSE
      			IF A >= B THEN
      				COMPUTE E = 2 * A - 1
      			ELSE
      				COMPUTE E = 2 * B - 1
      			END-IF
      		END-IF.
      		DISPLAY E.
		STOP RUN.

Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n; cin >> n;
    long long a[100010];
    long long res;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        if (a[i] == 0) {
            cout << 0 << endl;
            return 0;
        }
    }
    res = 1;
    for (int i = 0; i < n; i++) {
        res *= a[i];
        if (res > 1000000000000000000LL || res <= 0) {
            cout << -1 << endl;
            return 0;
        }
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 4416
#include<iostream>
using namespace std;
int main()
{
  int a,b,m=0;
  cin>>a>>b;
  for(int i=a;i<=b;i++){
    int n=i;
    int d,e,f,g;
    d=n%10;
    n/=10;
    e=n%10;
    n/=100;
    f=n%10;
    n/=10;
    g=n;
    if(d==g&&f==e){
        m++;
    }
   }
   cout<<m;
   return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n, x, y;
	cin >> n >> x >> y;
	--x; --y;
	
	vector<int> v(n);
	vector<vector<int>> dist(n,vector<int>(n));
	for(int i=0; i<n; ++i){
		for(int j=0; j<n; ++j){
			dist[i][j]=abs(i-j);
		}
	}
	for(int i=0; i<n; ++i){
		for(int j=0; j<n; ++j){
			dist[i][j]=min(dist[i][j],dist[i][x]+dist[y][j]+1);
			dist[i][j]=min(dist[i][j],dist[i][y]+dist[x][j]+1);
			++v[dist[i][j]];
		}
	}


	for(int k=1; k<n; ++k){
		cout << v[k]/2 << endl;
	}
}

Measured memory_bytes: 16000
#[allow(unused)]
use std::io::*;
#[allow(unused)]
use std::str::*;
#[allow(unused)]
use std::collections::*;

pub fn read_from<T: FromStr, R: Read>(s: &mut R) -> T {
    let s = s.bytes().map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect::<String>();
    if s.is_empty() {
        if cfg!(local) {
            // eprintln!("reached to EOF");
        }
        std::process::exit(0)
    }
    s.parse::<T>().unwrap_or_else(|_| panic!("faild to parse {}", s))
}

pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let mut stdin = stdin.lock();
    read_from(&mut stdin)
}

pub const MOD: u64 = 1000000007;

fn main() {
    loop {
        let n = read();
        let max_t: u32 = read();
        let ans: Option<u32> = (0..n).map(|_| (read::<u32>(), read::<u32>()))
            .filter(|&(_, t)| t <= max_t)
            .min_by_key(|&(c, _)| c)
            .map(|(c, _)| c);
        if let Some(c) = ans {
            println!("{}", c);
        } else {
            println!("TLE");
        }
    }
}


Measured memory_bytes: 4352
#include<iostream>
#include<vector>
#include<algorithm>
#include<stdlib.h>
#include<utility>
#include<functional>
#include<cfenv>
#include<cmath>
#include<string>
#include<queue>
#include<stack>
#include<map>
#include<set>

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define vint vector<int>
#define vvint vector<vint>
#define P pair<int,int>
#define INT_MAX 2147483647
#define MOD 1000000007
using namespace std;
typedef long long ll;



int main(void) {
	ll x; cin >> x;
	ll a, b;
	ll k = x % 5;
	ll t = 0;
	while (true) {
		for (a = 1; a < 150; a++) {
			b = a - (5*t+k);
			if (abs(b) > abs(a)) {
				continue;
			}
			if (a*a*a*a*a - b*b*b*b*b == x) {
				cout << a << ' ' << b << endl;
				return 0;
			}
		}
		t++;
	}
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
map<int,int> e;	//<end,start>

bool insert(int x){
	//  [0]
	if(e.find(0)!=e.end())return false;

	auto itr = e.lower_bound(x);
	bool touchleft = (e.find(x-1)!=e.end());

	if(itr==e.end()){
		//  [  ]X #
		if(touchleft){
			e[x]=e[x-1];
			e.erase(x-1);
		}
		//  __X__#
		else e[x]=x;
		return true;
	}
	
	//  [left    right]
	int left=itr->second, right=itr->first;

	//  0[__X__ ]  or  0[  X]  [  ]
	if(left==1 && (x<right || (int)e.size()>1)) return false;

	if(left<=x){
		//  [   X]
		if(x==right)e.erase(itr);
		//  [__X ]
		else e[right] = x+1;
		return insert(left-1);
	}

	// __X__[  ]
	e[x]=x;

	// [  ]X__[  ]
	if(touchleft){
		e[x]=e[x-1];
		e.erase(x-1);
	}	

	//  X[  ]
	if(x==left-1){
		e[right] = e[x];
		e.erase(x);
	}
	return true;
}

int main(void){
	int n,x;
	cin>>n;
	while(n--){
		cin>>x;
		if(insert(x))cout<<"Yes"<<endl;
		else cout<<"No"<<endl;
	}
	return 0;
}

Measured memory_bytes: 9896
#!/usr/bin/env python3
def main():
    N, X = map(int, input().split())
    nums = [None] * (N+1)# nums[i]: i次元バーガーの層の数
    pnums = [None] * (N+1)# pnums[i]: i次元バーガーのパティの枚数
    nums[0] = 1
    pnums[0] = 1
    for i in range(N):
        nums[i+1] = nums[i]*2 + 3
        pnums[i+1] = pnums[i]*2 + 1
    
    ans = 0
    while N >= 0:
        if N == 0:
            print(ans+1)
            break
        if X == 1:
            print(ans)
            break
        elif X <= nums[N-1]+1:# N-1次元バーガの中をさらに探索
            X -= 1
            N -= 1
        elif X == nums[N-1]+2:# ぴったり真ん中のパティまで到達
            print(ans+pnums[N-1]+1)
            break
        elif X < nums[N]:
            X -= nums[N-1]+2
            ans += pnums[N-1]+1
            N -= 1
        else:
            print(ans+pnums[N])
            break
    # print(N,X)

if __name__ == "__main__":
    main()


Measured memory_bytes: 9240
#define _USE_MATH_DEFINES 
#include <iomanip> 
#include <cmath>  
#include<iostream>
#include <fstream>
#include<vector>
#include<algorithm>
#include<bitset>
#include<map>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define repi(i,a,b) for(ll i = (ll)(a) ; i < (ll)(b) ; i++)
#define repd(i,a,b) for(ll i = (ll)(a) ; i > (ll)(b) ; i--)
#define rd(x) cin >> x
#define wr(x)  cout << x
#define wrln(x) cout << x << endl


int main() {
	while (1) {
		string input;
		stack<char> st;
		getline(cin, input);
		if (input.length() == 1 && input[0] == '.')break;
		repi(i, 0, input.length()) {
			char ch = input[i];
			if (ch == '(' || ch == '[') st.push(ch);
			if (ch == ')' || ch == ']') {
				if (st.size() == 0 || (st.top()=='(' && ch== ']') || (st.top() == '[' && ch == ')')) {
					wrln("no");
					break;
				}
				else {
					st.pop();
				}
			}
			if (i == input.length() - 1) {
				if (st.size() == 0) wrln("yes");
				else wrln("no");
			}
		}
	}
	return 0;
}


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

bool is_square(int d2) {
    int i;
    for (i = 0; i * i < d2; i++) {}
    return i * i == d2;
}

int dist2(int x[], int d, int i, int j) {
    int ret = 0;
    for (int k = 0; k < d; k++) {
        int dx = (x[i * d + k] - x[j * d + k]);
        ret += dx * dx;
    }
    return ret;
}

int main(void) {
    int n, d;
    cin >> n >> d;
    int x[n * d];
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < d; j++) {
            cin >> x[i * d + j];
        }
    }
    int ans = 0;
    for (int i = 0; i < n; i++) {
        for (int j = i + 1; j < n; j++) {
            if (is_square(dist2(x, d, i, j))) {
                ans++;
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import sys
readline = sys.stdin.buffer.readline
def even(n): return 1 if n%2==0 else 0
n,r = map(int,readline().split())
mod = 10**9+7

# 包除原理を用いたスターリング数
# AOJ Balls and Boxes 9で動作済み
def pow(n,p,mod=mod): #繰り返し二乗法(nのp乗)
    res = 1
    while p > 0:
        if p % 2 == 0:
            n = n ** 2 % mod
            p //= 2
        else:
            res = res * n % mod
            p -= 1
    return res % mod

def factrial_memo(n=10**5,mod=mod):
    fact = [1, 1]
    for i in range(2, n + 1):
        fact.append((fact[-1] * i) % mod)
    return fact

fact = factrial_memo()

def permutation(n,r): #nPr
    return fact[n]*pow(fact[n-r],mod-2)%mod
def combination(n,r): #nCr
    return permutation(n,r)*pow(fact[r],mod-2)%mod
    #return fact[n]*pow(fact[n-r],mod-2)*pow(fact[r],mod-2)
def homogeneous(n,r): #nHr
    return combination(n+r-1,r)%mod
    #return fact[n+m-1]*pow(fact[n-1],mod-2)*pow(fact[r],mod-2)

def stirling(n,r): #nSr
    res = 0
    for i in range(r): #包除原理で「箱区別あり」を求める
        res += pow(-1,i)*combination(r,i)*pow(r-i,n)
        res %= mod
    for i in range(1,r+1): #r!で除する
        res *= pow(i,mod-2)%mod
        res %= mod
    return res

print(stirling(n,r))


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

typedef long long ll;
typedef pair<ll, ll> P;


#define rep(i,n) for(ll (i)=0; (i)<(ll)(n); (i)++)
#define frep(i,m,n) for(ll (i)=(m); (i)<=(ll)(n); (i)++)
#define rrep(i,n) for(ll (i)=(n)-1; (i)>-1; (i)--)
#define frrep(i,m,n) for(ll (i)=(n); (i)>(ll)(m); (i)--)
#define ALL(x) (x).begin(), (x).end()

const ll INF = 100100100100100100;
const ll MOD = 1000000007;

// get abs
ll my_abs(ll a);
// a^n
ll a_n(ll a, ll n);
// get gcd
ll my_gcd(ll a, ll b);
// a^(-1) % MOD 
ll inv(ll a);
// (a+b+c)%MOD
ll madd(ll a, ll b, ll c);
// (a-b)%MOD
ll msub(ll a, ll b);
// (a*b*c)%MOD
ll mtime(ll a, ll b, ll c);


int main() {
    ll n; cin >> n;
    vector<ll> a(n);
    rep(i, n) {
        ll x; cin >> x;
        x -= (i+1);
        a[i] = x;
    }
    sort(ALL(a));
    ll mid = a[n/2], ans = 0;
    rep(i, n) {
        ans += my_abs(a[i]-mid);
    }
    cout << ans << endl;

    return 0;
}

ll my_abs(ll a) {
    if(a >= 0) return a;
    else return -1 *a;
}

ll a_n(ll a, ll n) { 
    if(n == 0) return 1;
    
    ll ret = a, count = 1;
    while(count * 2 < n) {
        ret *= ret;
        count *= 2;
    }
    if(count == n) return ret;
    else return (ret * a_n(a, n-count));
}

ll my_gcd(ll a, ll b) {
    if(b == 0) return a;
    return my_gcd(b, a%b);
}

ll inv(ll a) {
    return a_n(a, MOD-2);
}

ll madd(ll a, ll b, ll c) {
    ll ret = (a+b) % MOD;
    return (ret+c) % MOD;
}

ll msub(ll a, ll b) {
    if(a < b) return (a-b+MOD) % MOD;
    else return (a-b) % MOD;
}

ll mtime(ll a, ll b, ll c) {
    ll ret = (a*b) % MOD;
    return (ret*c) % MOD;
}


Measured memory_bytes: 4708
# 前から計算して見つかったら止めるのが一番早い
l,r=map(int, input().split())
import sys
ans = 2018
for i in range(l,r):
    for j in range(i+1,r+1):
        a = (i*j) % 2019
        if a < ans:
            ans = a
        if ans == 0:
            print(ans)
            sys.exit()
print(ans)

Measured memory_bytes: 3060