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

int main(){ 
  string s;
  cin >> s;
  
  bool frag=true;
  
  for(int i=0;i<s.size();i++){
    if(i%2==1){
      if(s.at(i)=='R'){
        frag=false;
      }
    }
    if(i%2==0){
      if(s.at(i)=='L'){
        frag=false;
      }
    }
  }
  if(frag==true){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
 
#define REPI(i, n) for(int i = 0; i < n; i++)
#define REPJ(j, n) for(int j = 0; j < n; j++)
 
using ll = long long;
using namespace std;
 
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
 
    ll n, ans = 0; cin >> n;
    int a[n]; REPI(i, n) cin >> a[i];
 
    sort(a, a + n, greater<int>());
 
    for(ll i = 0; i < n - 2; i++)
        for(ll j = i + 1; j < n - 1; j++)
            for(ll k = j + 1; k < n; k++)
                if(a[i] < a[j] + a[k] && a[j] < a[k] + a[i] && a[k] < a[i] + a[j])
                    ans++;
 
    cout << ans;
}

Measured memory_bytes: 256
#素数かどうか

import numpy as np
def list_primes(N):
    is_prime = np.ones(N+1, dtype=np.bool)
    # iが素数ならTrue，素数でないならFalse
    is_prime[0] = False
    is_prime[1] = False
    for i in range(N+1):
        if is_prime[i]:
            is_prime[2*i::i] = False
            # iの倍数の部分をスライスで選択して「素数でない」に設定
    #return is_prime.nonzero()
    return is_prime
    # is_primeがTrueになるもののindexのarray
    
N = 10**5
is_prime = list_primes(N)


#2017ににた数のリストの作成
def solve(is_prime):
    ans = []
    for i in range(len(is_prime)-1):
        if i % 2 == 1:
            if is_prime[i] and is_prime[(i+1)//2]:
                ans.append(i)
    return ans

like2017 = solve(is_prime)



#二分探索
def nibu_right(a,A): #a in A(sorted)
    if a<A[0]:return 0
    elif A[-1]<=a:return len(A)
    else:
        mi = 0
        ma = len(A)-1
        while ma-mi>1:
            mid = (ma+mi)//2
            if a > A[mid]:
                mi = mid
            else:
                ma = mid
        # A[mi]<a  a<=A[ma]
        if A[ma] == a:return ma+1
        else: return ma

def nibu_left(a,A): #a in A(sorted)
    if a<=A[0]:return 0
    elif A[-1]<a:return len(A)
    else:
        mi = 0
        ma = len(A)-1
        while ma-mi>1:
            mid = (ma+mi)//2
            if a < A[mid]:
                ma = mid
            else:
                mi = mid
        # A[mi]<=a  a<A[ma]
        if A[mi] == a:return mi
        else: return mi+1






Q = int(input())
for _ in range(Q):
    l,r = map(int,input().split())
    l_index = nibu_left(l,like2017)
    r_index = nibu_right(r,like2017)
    print(r_index - l_index)

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

int main(){

    int n,a,b;

    cin >> n >> a >>b;

    cout << min(a,b) << " " << max(0,a+b-n) << endl;

    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

int riku[200][200];//陸のワーシャルフロイド
int umi[200][200];//海のワーシャルフロイド
ll dp[1001][200];//i番目のクエリまでこなしたときの船がjにあるときの最短ルート
int z[1001];

int main()
{
	while(1)
	{
		int n,m;
		cin>>n>>m;
		if(n==0)
			break;
		fill(riku[0],riku[200],1e8-1);
		fill(umi[0],umi[200],1e8-1);
		fill(dp[0],dp[1001],1e14-1);
		for(int i=0;i<m;i++)
		{
			int x,y,t;
			char s;
			cin>>x>>y>>t>>s;
			x--;y--;
			if(s=='L')
			{
				riku[x][y]=t;
				riku[y][x]=t;
			}else{
				umi[x][y]=t;
				umi[y][x]=t;
			}
		}
		int r;
		cin>>r;
		z[0]=0;
		for(int i=0;i<r;i++)
		{
			int f;
			cin>>f;
			f--;
			z[i+1]=f;
		}
		//ワーシャルフロイド
		for(int i=0;i<n;i++)
		{
			riku[i][i]=0;
			umi[i][i]=0;
		}
		for(int k=0;k<n;k++)
		{
			for(int i=0;i<n;i++)
			{
				for(int j=0;j<n;j++)
				{
					riku[i][j]=min(riku[i][j],riku[i][k]+riku[k][j]);
					umi[i][j]=min(umi[i][j],umi[i][k]+umi[k][j]);
				}
			}
		}
		//到達不能な場所は-1に直す
		for(int i=0;i<n;i++)
		{
			for(int j=0;j<n;j++)
			{
				if(riku[i][j]==1e8-1)
					riku[i][j]=-1;
				if(umi[i][j]==1e8-1)
					umi[i][j]=-1;
			}
		}
		//start dp
		dp[1][z[1]]=0;
		for(int i=2;i<r+1;i++)
		{
			//船の置いてある場所
			for(int j=0;j<n;j++)
			{
				if(dp[i-1][j]!=-1)
				{
					int s=z[i-1];
					int t=z[i];
					//陸路だけの場合を調べる
					if(riku[s][t]!=-1)
						dp[i][j]=min(dp[i][j],dp[i-1][j]+(ll)riku[s][t]);
					//船を置く場所を全探索
					for(int k=0;k<n;k++)
					{
						if(riku[s][j]==-1 || umi[j][k]==-1 || riku[k][t]==-1)
							continue;
						dp[i][k]=min(dp[i][k],dp[i-1][j]+(ll)(riku[s][j]+umi[j][k]+riku[k][t]));
					}
				}
			}
		}
		//end dp
		ll ans=1e14-1;
		for(int i=0;i<n;i++)
		{
			ans=min(ans,dp[r][i]);
		}
		cout<<ans<<endl;
	}
	return 0;
}


Measured memory_bytes: 4960
#include <iostream>
#include <vector>
#include <set>
using namespace std;

int solve(vector<bool> selected, int s, int n,set<vector<bool> > &visited){
  int cnt=0;
  if(visited.find(selected)!=visited.end())return 0;
  visited.insert(selected);
  if(n==0){
  	if(s==0)return 1;
  	else return 0;
 	}
  for(int i=0;i<=9;++i){
    if(!selected[i]){
    	selected[i]=true;
    	cnt+=solve(selected,s-i,n-1,visited);
    	selected[i]=false;
    }
  }
  return cnt;
}

int main(void){
  int n,s;
  while(cin>>n>>s,n||s){
  	set<vector<bool> > visited;
    vector<bool> a(10);
    cout<<solve(a,s,n,visited)<<endl;
  }
}

Measured memory_bytes: 1320
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
  string s,t;
  cin>>s>>t;
  sort(s.begin(),s.end());
  sort(t.begin(),t.end());
  reverse(t.begin(),t.end());
  if (s<t) {
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
}







Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;
int main()
{
    int N;
    cin >> N;
    vector<string> s(N);
    vector<int> t(N);

    rep(i, N) cin >> s[i] >> t[i];

    string X;
    cin >> X;

    int ans = 0;
    bool flag = false;
    rep(i, N) {
        if (flag) ans += t[i];
        if (X == s[i]) {
            flag = true;
        }
    }

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

Measured memory_bytes: 256
// In the name of God

#include <bits/stdc++.h>

using namespace std;

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

	vector<long long> v(5);

	cin >> n;
	for(int i = 0; i < 5; i++) cin >> v[i];

	long long mn = *min_element(v.begin(), v.end());

	long long ans = 5;

	ans += (n+mn-1)/mn - 1;

	cout << ans;


	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
int main(){
  LL l,r;
  cin >> l >> r;
  LL min1,min2;
  min1=min2=2020;
  LL res = BIG_NUM;
  int rW = min(r,l+2020);
  for(LL i=l;i<rW;i++){
    for(LL j= i+1;j<=rW;j++){
      res = min(res,((i%2019)*(j%2019))%2019);
    }
  }
  cout << res << endl;
	return 0;
}
  



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

using namespace std;

using LL = long long;

template<typename T>
ostream& operator << (ostream& out, const vector<T>& v) {
    out << "[";
    for(auto& x : v) {
        out << x << ", ";
    }
    return out << "]";
}

template<typename S, typename T>
ostream& operator << (ostream& out, const pair<S, T>& p) {
    return out << "{" << p.first << ", " << p.second << "}";
}

const LL MOD = 998244353;
LL dp[310][610][610];

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
    string S;
    int K;
    cin >> S >> K;
    vector<LL> V = {0};
    LL ones = 0;
    for(auto c : S) {
        if(c == '0') {
            V.push_back(0);
        } else {
            V.back()++;
            ++ones;
        }
    }
    
    for(int n = 0; n < int(V.size()); ++n) {
        for(int k = 0; k <= ones; ++k) {
            for(int b = 0; b <= ones; ++b) {
                if(n == 0) {
                    dp[n][k][b] = (k == b) ? (1) : (0);
                    continue;
                }
                dp[n][k][b] = dp[n - 1][k][b];
                for(int i = 1; i <= b and i <= k; ++i) {
                    dp[n][k][b] = (dp[n][k][b] + dp[n - 1][k - i][b - i]) % MOD;
                }
                for(int i = 1; i <= V[n]; ++i) {
                    dp[n][k][b] = (dp[n][k][b] + dp[n - 1][k][b + i]) % MOD;
                }
            }
        }
    }
    
    LL ans = 0;
    for(int k = 0; k <= K and k <= ones; ++k) {
        ans = (ans + dp[V.size() - 1][k][0]) % MOD;
    }
    cout << ans << "\n";
    
    return 0;
} 


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

map<long long, long long> prime_list(long long n){
  map<long long, long long> ans;
  for(long long i=2;i*i<=n;++i){
    while(n%i==0){
      ++ans[i];
      n=n/i;
    }
  }
  if(n!=1){
    ++ans[n];
  }
  return ans;
}

int main(){
	long long N;
	cin >> N;
	map<long long, long long> primemap = prime_list(N);

	long long ans = 0;
	for(auto it = primemap.begin(); it != primemap.end(); it++) {
		long long val = it->second;
		long long i = 1;
		while(1) {
			if(val < i) {
				break;
			}
			val -= i;
			i++;
			ans++;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define rep(i,n) for (int i=0;i<(int)(n);i++)
#define codefor int test;scanf("%d",&test);while(test--)
#define yn(ans) cout<<(ans?"Yes":"No")<<endl
#define YN(ans) cout<<(ans?"YES":"NO")<<endl
#define umap unordered_map
#define uset unordered_set
using namespace std;
using ll = long long;
const int MOD=1000000007;
//入力系
void scan(int& a){scanf("%d",&a);}
void scan(long long& a){scanf("%lld",&a);}
template<class T> void scan(T& a){cin>>a;}
template<class T> void scan(vector<T>& vec){for(auto&& it:vec)scan(it);}
void in(){}
template <class Head, class... Tail> void in(Head& head, Tail&... tail){scan(head);in(tail...);}
//出力系
void print(const int& a){printf("%d",a);}
void print(const long long& a){printf("%lld",a);}
void print(const double& a){printf("%.15lf",a);}
template<class T> void print(const T& a){cout<<a;}
template<class T> void print(const vector<T>& vec){if(vec.empty())return;print(vec[0]);for(auto it=vec.begin();++it!= vec.end();){putchar(' ');print(*it);}}
void out(){putchar('\n');}
template<class T> void out(const T& t){print(t);putchar('\n');}
template <class Head, class... Tail> void out(const Head& head,const Tail&... tail){print(head);putchar(' ');out(tail...);}
//デバッグ系
template<class T> void dprint(const T& a){cerr<<a;}
template<class T> void dprint(const vector<T>& vec){if(vec.empty())return;cerr<<vec[0];for(auto it=vec.begin();++it!= vec.end();){cerr<<" "<<*it;}}
void debug(){cerr<<endl;}
template<class T> void debug(const T& t){dprint(t);cerr<<endl;}
template <class Head, class... Tail> void debug(const Head& head, const Tail&... tail){dprint(head);cerr<<" ";debug(tail...);}

int main(){
    int n,k;
    in(n,k);
    vector<int> vec(n);
    int minv,mini;
    rep(i,n){
        in(vec[i]);
        if(vec[i]==1){
            minv=vec[i];
            mini=i;
        }
    }
    int l,r,ans=10000000,kaisuu;
    for(int i=0;i<k;i++){
        l=mini-i;
        r=mini+k-1-i;
        debug(l,r);
        kaisuu=1;
        if(l>0){
            kaisuu+=l/(k-1);
            if(l%(k-1)!=0)kaisuu++;
        }
        if(r<n){
            kaisuu+=(n-1-r)/(k-1);
            if((n-1-r)%(k-1)!=0)kaisuu++;
        }
        ans=min(ans,kaisuu);
    }
    out(ans);
}

Measured memory_bytes: 3796
#include <iostream>
#include <iomanip>
#include <cstdint>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <algorithm>

int main(void)
{
    int64_t N, K;
    std::cin >> N >> K;

    std::vector<int64_t> P(N);
    for (auto& p : P) {
        std::cin >> p;
    }

    std::sort(P.begin(), P.end());

    int64_t sum = 0;
    for (int64_t i = 0; i < K; ++i) {
        sum += P.at(i);
    }

    std::cout << sum << std::endl;

    return 0;
}

Measured memory_bytes: 3600
#include<bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
int n;
main(){
	cin>>n;
	vector<int>v(n);
	r(i,n)cin>>v[i];
	if(prev_permutation(v.begin(),v.end())){
		r(i,n)cout<<v[i]<<(i!=n-1?' ':'\n');
	}
	next_permutation(v.begin(),v.end());
	r(i,n)cout<<v[i]<<(i!=n-1?' ':'\n');
	if(next_permutation(v.begin(),v.end())){
		r(i,n)cout<<v[i]<<(i!=n-1?' ':'\n');
	}
}


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

#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)

using namespace std;

const int IINF = INT_MAX;
int H,W,mincost;
int P[10][10],bin[10],bc[(1<<10)];
int put[10][10],weight[10][10],counter[10][10];

bool can_put(int len,int x,int y){
  REP(i,y,y+len)REP(j,x,x+len) if( !P[i][j] ) return false;
  return true;
}

void dfs(int cur,int cost,int remain){

  if( cost >= mincost ) return;
  if( cost + ((remain>0)?1:0) >= mincost ) return;

  if( cur >= H*W ) {
    mincost = min(mincost,cost);
    return;
  }

  int x = cur % W, y = cur / W;
//  if( cost + max(0,weight[y][x]-4) >= mincost ) return;

  if( !P[y][x] || counter[y][x] == 1 ) {
    dfs(cur+1,cost,remain);
    return;
  }

  if( (bin[y]>>x) & 1 ) dfs(cur+1,cost,remain);

  int len = put[y][x];
  int bitmask = ((1<<len)-1)<<x;
  int buf[len];
  int add = 0, nremain = remain;
  rep(j,len) {
    buf[j] = bin[y+j];
    add += len - bc[((1<<len)-1)&(bin[y+j]>>x)];
    bin[y+j] |= bitmask;
  }
  nremain -= add;
  if( add ) dfs(cur+1,cost+1,nremain);
  rep(j,len) bin[y+j] = buf[j];

}

int par[110];
int dx[] = {0,1,0,-1};
int dy[] = {1,0,-1,0};

int find(int x){
  if( x == par[x] ) return x;
  return par[x] = find(par[x]);
}

inline void unit(int x,int y){
  x = find(x), y = find(y);
  if( x != y ) par[x] = par[y];
}

bool isValid(int x,int y){ return 0 <= x && x < W && 0 <= y && y < H; }

int main(){

  rep(i,(1<<10)) bc[i] = __builtin_popcount(i);

  while( scanf("%d%d",&W,&H), W | H ){

    rep(i,H){
      bin[i] = 0;
      rep(j,W){
        cin >> P[i][j];
        put[i][j] = 0;
      }
    }


    rep(i,H*W) par[i] = i;

    rep(i,H)rep(j,W)if(!P[i][j])rep(k,4){
      int nx = j + dx[k], ny = i + dy[k];
      if( !isValid(nx,ny) ) continue;
      if( !P[ny][nx] ) unit(j+i*W,nx+ny*W);
    }

    rep(i,H)rep(j,W)weight[i][j] = 0;

    set<int> S;
    bool first = false;
    for(int i=H-1;i>=0;i--) for(int j=W-1;j>=0;j--) {
        if( P[i][j] ) first = true;
        if( first && !P[i][j] ) S.insert(find(j+i*W));
        weight[i][j] = S.size();
      }

    rep(y,H) rep(x,W) if( P[y][x] ) {
      for(int len=min(H,W);len>=1;len--){
        if( x + len - 1 < W && y + len - 1 < H ) {
          if( can_put(len,x,y) ){
            put[y][x] = len;
            break;
          }
        }
      }
    }

    rep(i,H)rep(j,W) counter[i][j] = 0;
    rep(i,H)rep(j,W)if(P[i][j]){
      REP(y,i,i+put[i][j])REP(x,j,j+put[i][j]){
        counter[y][x]++;
      }
    }

    rep(i,H){
      rep(j,W){
        if( counter[i][j] == 1 ){
          REP(y,i,i+put[i][j])REP(x,j,j+put[i][j]){
            bin[y] |= (1<<x);
          }
        }
      }
    }

    int add = 0;
    int remain = 0;
    mincost = 0;
    rep(i,H)rep(j,W)remain += ((bin[i]>>j)&1),mincost += P[i][j];
    remain = mincost - remain;
    dfs(0,0,remain);

    rep(i,H)rep(j,W)if(counter[i][j]==1)add++;
    cout << mincost+add << endl;

  }
  return 0;
}

Measured memory_bytes: 1260
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AOJ
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            Console.WriteLine(getFactional(n));
        }

        static Int64 getFactional(int v)
        {
            if (v == 0) return (Int64)1;
            return getFactional(v-1)*v;
        }
    }
}

Measured memory_bytes: 5600
#include<bits/stdc++.h>
#define mod 1000000007
#define ll long long int
#define ar array
#define mp make_pair
using namespace std;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	int n;
	cin>>n;
	ll a[n];
	for(int i = 0;i <n; i++)
		cin>>a[i];
	ll ans[2] ={0};
	for(int t = 0; t<2 ; t++)
	{
		ll sum = 0;
		for(int i = 0; i<n; i++)
		{
			sum += a[i];
			if((i&1)==t)
			{
				if(sum<=0)
				{
					ans[t] += 1-sum;
					sum = 1;
				}
			}
			else
			{
				if(sum>=0)
				{
					ans[t] += sum+1;
					sum = -1;
				}
			}
		}
	}
	cout<<min(ans[0],ans[1])<<endl;
	return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int main(void){

  int N,T;
  scanf("%d %d", &N, &T);

  int *A, *B;
  A = (int*)malloc(N*sizeof(int));
  B = (int*)malloc(N*sizeof(int));
  for(int i=0; i<N; i++){
    scanf("%d %d", &A[i], &B[i]);
  }

  int ans=1001;

  for(int i=0; i<N; i++){
    if(B[i]<=T && A[i]<ans){
      ans = A[i];
    }
  }

  if(ans==1001){
    printf("TLE\n");
  }else{
    printf("%d\n", ans);
  }

  return 0;
}



Measured memory_bytes: 128
#include<stdio.h>
int main(void)
{
	int a[10],b[10];
	int i,s[10],hito[10];
	char c[10];
	
	for(i=0;i<9;i++){
		scanf(" %s %d %d",&c,&a[i],&b[i]);
		s[i]=a[i]*200+b[i]*300;
		hito[i]=a[i]+b[i];
/*	}
	for(i=0;i<9;i++){*/
		printf("%s %d %d\n",c,hito[i],s[i]);
	}
	return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll vis[100001];
ll val[100001];
vector<ll> adj[100001];
ll ans=0;
ll dfs(ll a)
{
    ll i,b,k=0;
    vis[a]=1;
    for(i=0;i<adj[a].size();i++)
    {
        b=adj[a][i];
        if(vis[b]==0) k=max(dfs(b)+1,k);
        else k=max(val[b]+1,k);
    }
    val[a]=k;
    ans=max(ans,k);
    return k;
}
int main()
{
    ll n,m,i,x,y;
    cin>>n>>m;
    for(i=0;i<m;i++)
    {
        cin>>x>>y;
        adj[x].push_back(y);
    }
    memset(vis,0,8*(n+1));
    memset(val,0,8*(n+1));
    for(i=1;i<=n;i++)
    {
        if(vis[i]==0) dfs(i);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 9344
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		Dice ref = new Dice();
		for (int i = 0; i < 6; i++) {
			ref.side[i] = sc.nextInt();
		}
		Dice d = new Dice();
		for (int i = 0; i < 6; i++) {
			d.side[i] = sc.nextInt();
		}


		int isCon = 0;
		isCon += d.tryCheckSequence(ref.side);

		d.rollN();
		isCon += d.tryCheckSequence(ref.side);
		d.rollN();
		isCon += d.tryCheckSequence(ref.side);
		d.rollW();
		isCon += d.tryCheckSequence(ref.side);
		d.rollE();
		isCon += d.tryCheckSequence(ref.side);
		d.rollE();
		isCon += d.tryCheckSequence(ref.side);
		
		if(isCon >= 1) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
		
		sc.close();
	}
}

class Dice {
	int[] side = new int[6];

	public void getUpperSide() {
		System.out.println(this.side[0]);
	}

	public int getR(int top, int frt) {
		int[][] mtx = { { 0, 3, 5, 2, 4, 0 },
				{ 4, 0, 1, 6, 0, 3 },
				{ 2, 6, 0, 0, 1, 5 }, { 5, 1, 0, 0, 6, 2 },
				{ 3, 0, 6, 1, 0, 4 }, { 0, 4, 2, 5, 3, 0 } };
		int aI = top; //a Index of side[]
		int bI = frt; //b Index of side[]
		for (int i = 0; i < 6; i++) {
			if (top == this.side[i]) {
				aI = i;
			}
			if (frt == this.side[i]) {
				bI = i;
			}
			if (aI >= 0 && bI >= 0)
				break;
		}

		return (this.side[mtx[aI][bI] - 1]);
	}
	
	public int checkCon(int[] ref) {
		int isCon = 0;
		int cnt = 6;
		for (int i = 0; i < 6; i++) {
			if (this.side[i] == ref[i]) cnt--;
		}
		if(cnt == 0) {
			isCon = 1;
		}
		return(isCon);
	}

	public int tryCheckSequence(int[] ref) {
		int cnt = 0;
		cnt += checkCon(ref);
		for (int i = 0; i < 3; i++) {
			this.rotR();
			cnt += checkCon(ref);
		}
		return(cnt >= 1 ? 1 : 0);
	}

	public void rollE() {
		int w = this.side[5];
		this.side[5] = this.side[2];
		this.side[2] = this.side[0];
		this.side[0] = this.side[3];
		this.side[3] = w;
	}

	public void rollW() {
		int w = this.side[5];
		this.side[5] = this.side[3];
		this.side[3] = this.side[0];
		this.side[0] = this.side[2];
		this.side[2] = w;
	}

	public void rollN() {
		int w = this.side[5];
		this.side[5] = this.side[4];
		this.side[4] = this.side[0];
		this.side[0] = this.side[1];
		this.side[1] = w;
	}

	public void rollS() {
		int w = this.side[5];
		this.side[5] = this.side[1];
		this.side[1] = this.side[0];
		this.side[0] = this.side[4];
		this.side[4] = w;
	}

	public void rotR() {
		int w = this.side[1];
		this.side[1] = this.side[2];
		this.side[2] = this.side[4];
		this.side[4] = this.side[3];
		this.side[3] = w;
	}
}



Measured memory_bytes: 26384
n, m, x = map(int, input().split())
a = list(map(int, input().split()))
ans1 = 0
ans2 = 0
for i in range(x+1, n+1):
        if i in a:
                ans1 += 1

for i in range(x):
        if i in a:
                ans2 += 1
print(min(ans1, ans2))

Measured memory_bytes: 38256
#include <iostream>
#include <sstream>
#include <vector>
#include <algorithm>
int main()
{
    int N;
    std::vector<int> L;
    std::cin >> N;
    int sum=0;
    for(int i=0; i<N; i++){
      int A;
        std::cin >> A;
L.push_back(A);
    }
    std::sort(L.begin(),L.end());
    for(int i=0; i<N-1; i++){
        sum+=L[i];
    }
    if(L[N-1] < sum){
        std::cout <<"Yes" << std::endl;
    }else{
        std::cout << "No" << std::endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#define rep(index,num) for(int index=0;index<num;index++)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-15
typedef long long ll;
using namespace std;
int main(){
	int N,a[100];
	vector<int>onaji;
	int nowonaji=-1,nowkosu=1;
	scan(N);
	int kaisu=0;
	rep(i,N){
		scan(a[i]);
		if(a[i]==nowonaji){
			nowkosu++;
			if(i==N-1){
				kaisu+=nowkosu/2;
			}
		}
		else if(a[i]!=nowonaji&&nowkosu>=2){
			kaisu+=nowkosu/2;
			nowkosu=1;
			nowonaji=a[i];
		}
		else{
			nowkosu=1;
			nowonaji=a[i];
		}
	}
	prin(kaisu);
	return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline


class BinaryIndexedTree:
    """一点加算、区間総和クエリをそれぞれO(logN)で答えるデータ構造。"""
    def __init__(self, n):
        self.size = n
        self.bit = [0] * (n + 1)

    def build(self, array):
        """arrayを初期値とするBinaryIndexedTreeを構築する。O(N)"""
        for i, val in enumerate(array):
            self.bit[i + 1] = val
        for i in range(1, self.size):
            if i + (i & -i) > self.size:
                continue
            self.bit[i + (i & -i)] += self.bit[i]

    def _sum(self, i):
        s = 0
        while i > 0:
            s += self.bit[i]
            i -= i & -i
        return s % MOD

    def add(self, i, val):
        """i番目の要素にvalを加算する。O(logN)"""
        i += 1
        while i <= self.size:
            self.bit[i] += val
            self.bit[i] %= MOD
            i += i & -i

    def sum(self, l, r):
        """区間[l, r)の和を求める。O(logN)"""
        return (self._sum(r) - self._sum(l)) % MOD


n, k = map(int, input().split())
dist = [list(map(int, input().split())) for i in range(k)]
MOD = 998244353


bit = BinaryIndexedTree(n + 1)
bit.add(1, 1)

for i in range(2, n + 1):
    ptn = 0
    for l0, r0 in dist:
        l = i - r0
        r = i - l0 + 1
        l, r = max(l, 0), max(r, 0)
        ptn += bit.sum(l, r)
    bit.add(i, ptn)
    
print(bit.sum(n, n + 1) % MOD)

Measured memory_bytes: 70980
""" AtCoder """

A, B, K = map(int, input().split())

l = []
for i in range(A, A + K + 1):
    l.append(i)
for i in range(B - K, B + 1):
    l.append(i)

ans = []

if B - A < K:
    for i in range(A, B + 1):
        ans.append(i)
else:
    for i in range(A, A + K + 1):
        l.append(i)
    for i in range(B - K, B + 1):
        l.append(i)
    for i in range(K):
        ans.append(l[i])
        ans.append(l[-i-1])

ans = set(ans)

ans = sorted(ans)

for i in range(len(ans)):
    print(ans[i])


Measured memory_bytes: 3064
Imports System.Collections.Generic
Imports System.Console

Module Program
    Dim N As Integer = NextInt()
    Dim K As Integer = NextInt()
    Dim D(K - 1) As Integer

    Sub Main()
        For i As Integer = 0 To UBound(D)
            D(i) = NextInt()
        Next

        For i As Integer = 0 To Integer.MaxValue
            DFS("", i)
        Next
    End Sub

    Sub DFS(s As String, m As Integer)
        If s <> "" AndAlso CInt(s) >= N Then
            WriteLine(s)
            End
        End If

        If s.Length = m Then Return

        For i As Integer = 0 To 9
            If Not Contains(D, i) Then DFS(i.ToString & s, m)
        Next
    End Sub

    Function Contains(A As Integer(), x As Integer) As Boolean
        For Each Ai As Integer In A
            If Ai = x Then Return True
        Next
        Return False
    End Function

    Function NextInt() As Integer
        Return CInt(NextString())
    End Function

    Function NextString() As String
        Dim result As New List(Of Char)
        Do
            Dim tmp As Integer = Read()
            If tmp < 0 Then Exit Do
            Dim nextChar As Char = Chr(tmp)

            If Not Char.IsWhiteSpace(nextChar) Then
                result.Add(nextChar)
            ElseIf nextChar <> vbCr Then
                Exit Do
            End If
        Loop
        Return New String(result.ToArray())
    End Function
End Module


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

int main(){
 int n;
 double p[3],max=0,sum; 

 cin >> n ;
 double x[n],y[n];
 for(int i=0;i<n;i++){
  cin >> x[i] ;
 }
 for(int i=0;i<n;i++){
  cin >> y[i] ;
 }

 for(int j=1;j<4;j++){
  sum=0;
  for(int i=0;i<n;i++){
   sum+=pow(fabs(x[i]-y[i]),j) ;
  }
  p[j-1]=pow(sum,1.0/j);
 }

 for(int i=0;i<n;i++){
  if(fabs(x[i]-y[i])>max) max=fabs(x[i]-y[i]);
 }

 cout << fixed << p[0] << endl << p[1] << endl << p[2] << endl << max << endl;

 return 0;
}

Measured memory_bytes: 3460
n = int(input())
a = list(map(int,input().split()))

min1 = min(a)
max1 = max(a)
idx1 = a.index(min1)
idx2 = a.index(max1)

print(2*n-2)

if abs(min1) < abs(max1):
    for i in range(n):
        if i != idx2:
            print(idx2+1, i+1)
    for i in range(n-1):
        print(i+1, i+2)

else:
    for i in range(n):
        if i != idx1:
            print(idx1+1, i+1)
    for i in range(n-1):
        print(n-i, n-i-1)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define PI 3.141592653589793
#define MOD 1000000007
#define rep(i, n) for (ll i = 0; i < n; i++)
#define all(v) v.begin(), v.end()
typedef long long ll;
typedef long double ld;

int main(){
    ll D, T, S;
    cin >> D >> T >> S;
    if(D / S < T || (D / S == T && D % S == 0)){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}


Measured memory_bytes: 3560
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define INF (1LL<<57)
#define MV 200001
#define LMV 21
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define emp emplace
#define whoami(x) cerr<<#x<<" "<<x<<"\n";
#define mp make_pair
#define ins insert
#define sz size

void FLASH() {ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);}
void SETF() {cout.ios_base::setf(ios_base::fixed);}
void UNSETF() {cout.ios_base::unsetf(ios_base::fixed);}

typedef long long ll;
typedef long double ld;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
typedef pair<PII, int> PPII;
typedef pair<PLL, ll> PPLL;
typedef map<int, int> MII;

const int MOD = 1000000007;

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <typename T>
using ordered_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;

struct h_llint {
  static uint64_t splitmix64(uint64_t x) {    // http://xorshift.di.unimi.it/splitmix64.c
    x += 0x9e3779b97f4a7c15;
    x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
    x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
    return x ^ (x >> 31);
  }
  size_t operator()(uint64_t x) const {
    static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
    return splitmix64(x + FIXED_RANDOM);
  }
};

struct h_pair{
  size_t operator()(const PLL&x)const{
    return hash<ll>()(((ll)x.ff)^(((ll)x.ss)<<32));
  }
};

typedef map<ll, ll> MLL;
typedef map<PII, int> MPII;
typedef map<PLL, ll> MPLL;
typedef set<int> SI;
typedef set<ll> SL;
//ordered_set = order_of_key(.)
//ordered_set = find_by_order(.)
typedef ordered_set<int> OSI;
typedef ordered_set<ll> OSL;
typedef ordered_multiset<int> MOSI;
typedef ordered_multiset<ll> MOSL;
typedef unordered_map<ll, int, h_llint> UMLI;
typedef unordered_map<ll, ll, h_llint> UMLL;
typedef unordered_map<PLL, int, h_pair> UMPI;
typedef unordered_map<PLL, ll, h_pair> UMPL;

int ar[MV];
ll arr[MV];

void solve(int T)
{
	string s;
	cin>>s;
	if((s[2] == s[3]) && (s[4] == s[5]))
	cout<<"Yes\n";
	else cout<<"No\n";
	return;	
}

int main(void)
{
	FLASH();
	int T;
	T = 1;

// #ifndef ONLINE_JUDGE
// 	time_t time_t1, time_t2;
// 	time_t1 = clock();
// #endif

	while(T--)
	solve(T);

// #ifndef ONLINE_JUDGE
// 	time_t2 = clock();
// 	SETF();
// 	cout<<"Time taken: "<<setprecision(7)<<(time_t2 - time_t1)/(double)CLOCKS_PER_SEC<<"\n";
// 	UNSETF();
// #endif

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define fi first
#define se second
#define pb push_back
#define pii pair<int,int>
#define vi vector<int>
using namespace std;
const int N = 1e5+5;
int h[N],n,k,ans[N];
main() {
    cin >> n;
    k = 2;
    cin >> k;
    for (int i = 1; i <= n; i++)
        cin >> h[i];
    for (int i = 2; i <= n; i++) {
            ans[i] = 1000000000;
        for (int j = max(1,i - k); j < i; j++)
        ans[i] = min(ans[i],ans[j] + abs(h[i] - h[j]));
    }
    cout << ans[n];




}


Measured memory_bytes: 4344
#B問題
#しりとりが成立していたか確認する
#(同名禁止)

w=[]
N=int( input() )

for i in range (0,N):
    wi= input()
    w.append(wi)

#w[0]で一単語目
#w[0][1]で一単語目の二文字目を参照できる
comment="Yes"
for i in range (1,N):#二番目からスタート
    xyz=len(w[i-1])-1#一つ前のお尻の番号
    if(w[i][0]==w[i-1][xyz]):
        pass
    else:#前のお尻と先頭が一致しなければ
        #print("no")
        comment="No"
        break


#もうひとつの条件
#かぶり不可の確認
for i in range(0,N):#i最初から最後まで
    if(comment=="No"):break
    for u in range(i+1,N):#u 今の位置から後ろだけ
        if(w[i]==w[u]):#かぶりが存在した
            comment="No"
            break
print(comment)


Measured memory_bytes: 3064
import java.util.*;
public class Main{
    public static void main(String[] args)
    {
        Scanner sc = new Scanner(System.in);
        int x ;
        int i = 1;
        do
        {
            x = sc.nextInt();
            if(x == 0) break;
            System.out.println("Case " + i + ": " + x);
            i ++ ;
        } while(true);
        sc.close();
        
    }
}


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

int main()
{
    char a, b, c, d, e, f;
    cin >> a >> b >> c >> d >> e >> f;
    if (a == f && b == e && c == d)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define intl long long
#define maxn 201000
using namespace std;

const intl Mo = 1000000007LL;

int n, top;
vector<int> vec[maxn];
int L[maxn], R[maxn], CNT[maxn], cnt[maxn];
intl fac[maxn], inv[maxn];
int x, y;
intl ans;

intl fpm(intl a, intl b) {
	if (!a) return 0LL;
	intl ans = 1LL;
	for (; b; b >>= 1) {
		if (b & 1LL) ans *= a, ans %= Mo;
		a *= a; a %= Mo;
	}
	return ans;
}

intl C(int a, int b) {
	return fac[a] * inv[b] % Mo * inv[a - b] % Mo;
}

int main() {
	scanf("%d %d %d",&n,&x,&y);
	fac[0] = 1;
	for (int i = 1; i <= n; i++)
		fac[i] = fac[i - 1] * (intl) i % Mo;
	inv[n] = fpm(fac[n], Mo - 2LL);
	for (int i = n; i >= 1; i--)
		inv[i - 1] = inv[i] * (intl) i % Mo;	
	for (int i = 1; i <= n; i++) {
		int c, w;
		scanf("%d %d",&c,&w);
		vec[c].push_back(w);
	}
	for (int i = 1; i <= n; i++)
		sort(vec[i].begin(), vec[i].end());
	int just = 1 << 30;
	int tp = 0;
	L[0] = just;
	for (int i = 1; i <= n; i++) {
		if (!vec[i].empty()) {
			if (just > vec[i][0]) tp = i;
			just = min(just, vec[i][0]);
		}
		L[i] = just;
	}

	just = 1 << 30;
	R[n + 1] = 1 << 30;
	for (int i = n; i >= 1; i--) {
		if (!vec[i].empty()) {
			just = min(just, vec[i][0]);
		}
		R[i] = just;
	}
	for (int i = 1; i <= n; i++) {
		int jus = min(L[i - 1], R[i + 1]);
		for (auto j = vec[i].begin(); j != vec[i].end(); j++)
			if (vec[i][0] + *j <= x || j == vec[i].begin() || jus + *j <= y) cnt[i]++;		
	}
	CNT[++top] = cnt[tp];
	for (int i = 1; i <= n; i++) {
		if (vec[i].empty() || i == tp) continue;
		if (vec[i][0] + just <= y) CNT[++top] = cnt[i];
		//else TNC[++tp] = cnt[i];
	}
	for (int i = 1; i <= top; i++) CNT[i] += CNT[i - 1];
	ans = 1LL;
	for (int i = top; i >= 1; i--)
		(ans *= C(CNT[i], CNT[i - 1])) %= Mo;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 15616
#include <stdio.h>
#include <algorithm>
#include <vector>
using namespace std;
#define PB push_back
const int N=1e4+10;
const int INF=1e9+10;
int max(int a,int b){return a>b?a:b;}
int min(int a,int b){return a>b?b:a;}
int main(){
	int ans=0,val[N],cost,m,n,temp;
	vector<int> v;
	scanf("%d%d",&m,&n);
	for(int i=0;i<m;i++){
		scanf("%d",&temp);
		v.PB(temp);
	}
	sort(v.begin(),v.end());
	v.PB(0);
	reverse(v.begin(),v.end());
	for(int i=1;i<v.size();i++)v[i]+=v[i-1];
	for(int i=0;i<=m;i++)val[i]=INF;
	val[0]=0;
	for(int i=0;i<n;i++){
		scanf("%d%d",&temp,&cost);
		for(int i=m;i>=temp;i--)val[i]=min(val[i],val[i-temp]+cost);
		for(int i=0;i<temp;i++)val[i]=min(val[i],cost);
	}
	for(int i=0;i<=m;i++)ans=max(ans,v[i]-val[i]);
	printf("%d\n",ans);
}



Measured memory_bytes: 2920
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>
#include <tuple>
#include <queue>
#include <bitset>
#include <set>
#include <map>
#include <list>

using ll = long long;
using ld = long double;
using namespace std;
const int INF = 1e9+100;
const ll INF64 = 7e18l;
const int mod = 1000000007;
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(a) (a).begin(), (a).end()
#define FIN ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);


int main(){
    FIN;
    string s,t;
    cin >> s >> t;
    vector<int> a(26,0); //もうあったか
    vector<int> b(26,0); //どの文字か
    bool ok = true;
    for(int i=0;i<s.size();i++){
        int S = s[i] - 'a';
        int T = t[i] - 'a';
        if(a[S] != 0  and  b[S] != T){
            ok = false;
            break;
        }
        a[S] = 1;
        b[S] = T;
    }
    if(!ok){
        cout << "No" << endl;
        return 0;
    }


    vector<int> A(26,0); //もうあったか
    vector<int> B(26,0); //どの文字か
    for(int i=0;i<s.size();i++){
        int S = s[i] - 'a';
        int T = t[i] - 'a';
        if(A[T] != 0  and  B[T] != S){
            ok = false;
            break;
        }
        A[T] = 1;
        B[T] = S;
    }


    if(ok) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 3800
#include<iostream>
using namespace std;
int main(){
    int n,x;
    long long sum=0;
    int max=-1000000;
    int min=1000000;
    cin>>n;
    for(int i =0;i<n;i++){
        cin>>x;
        sum=sum+x;
        if(max<x){
            max=x;
        }
        if(min>x){
            min=x;
        }
        
    }
    cout<<min<<" "<<max<<" "<<sum<<endl;
    return 0;
}



Measured memory_bytes: 3116
#include <iostream>
#include<algorithm>
using namespace std;
int main(){
  int K,N;
  cin>>K>>N;
  int A[2*100004];
  for ( int i=0; i<N; i++) cin>>A[i];
  int dif[2*100004];
  for ( int i=0; i<N-1; i++){
    dif[i]=A[i+1]-A[i];}
  sort(dif,dif+(N-1));
  int t=dif[N-2];
    int u=K-A[N-1]+A[0];
  int v=max(t,u);
  cout<<K-v<<endl;
}
    
  

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#include <string.h>
#include <math.h>

using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265359

int main(void)
{
	int n;
	double p1, p2, p3, p9;
	long l;


	cin >> n;
	vector<int> x(n);
	vector<int> y(n);
	rep(i, n)
		cin >> x.at(i);
	rep(i, n)
		cin >> y.at(i);

	p1 = 0;
	rep(i, n) {
		p1 += abs(x.at(i) - y.at(i));
		}

	l = 0;
	rep(i, n) {
		l += pow(abs(x.at(i) - y.at(i)),2);
	}
	p2 = sqrt(l);

	l = 0;
	rep(i, n) {
		l += pow(abs(x.at(i) - y.at(i)), 3);
	}
	p3 = cbrt(l);

	p9 = 0;
	rep(i, n) {
		if (p9 < abs(x.at(i) - y.at(i)))
			p9 = abs(x.at(i) - y.at(i));
	}

	cout << fixed << setprecision(6) << p1 << endl;
	cout << fixed << setprecision(6) << p2 << endl;
	cout << fixed << setprecision(6) << p3 << endl;
	cout << fixed << setprecision(6) << p9 << endl;
}



Measured memory_bytes: 3484
#include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <map>
#include <set>
#include <stack>
#include <queue>

 
using namespace std;
 
#define pb(n)	push_back(n)
#define mp(n,m) make_pair(n,m)
#define fi 	first
#define se 	second
#define all(r) (r).begin(),(r).end()
 
#define REP(i,s,e)	for(int i=(s); i<(e); i++)
#define rep(i,n)	REP(i,0,n)
#define REPE(i,s,e)	for(int i=s; i>e; i--)
#define repe(i,n)	REPE(i,n,-1)


typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
 
typedef vector<vi> vvi;
 
const int IMAX=((1<<30)-1)*2+1;
const int INF=IMAX;//=100000000;
const double EPS=1e-10;
//int mod=1000000007
 

const int MAX_V = 110000;


struct edge{ int to, cost; };


int V;
vector<edge> G[MAX_V];
int d[MAX_V];


void dijkstra(int s){
	//greater<pii>????????????????????¨??§first????°???????????????????????????????????????????
	priority_queue<pii, vector<pii>, greater<pii> > que;
	fill(d, d + V, INF);
	d[s] = 0;
	que.push(pii(0, s));

	while(!que.empty()){
		pii p = que.top();
		que.pop();
		int v = p.second;
		if(d[v] < p.first) continue;
		for(int i = 0; i < G[v].size(); i++){
			edge e = G[v][i];
			if(d[e.to] > d[v] + e.cost){
				d[e.to] = d[v] + e.cost;
				que.push(pii(d[e.to],e.to));
			}
		}
	}
}



int main(){
	int E, r;
	cin>>V>>E>>r;
	int s,e,co;
	edge es;
	rep(i, E){
		cin>>s>>e>>co;
		es.to = e;
		es.cost = co;
		G[s].pb(es);
	}
	dijkstra(r);
	rep(i, V) {
		if(d[i] == INF) cout<<"INF"<<endl;
		else cout<<d[i]<<endl;
	}
}

Measured memory_bytes: 11536
#include<bits/stdc++.h>
#include<string>
#include<map>
#define ll          long long
#define pb          push_back
#define mp          make_pair
#define pii         pair<int,int>
#define pll         pair<ll,ll>
#define vii         vector<pair<ll,ll> >
#define vi          vector<int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (int)x.size()
#define hell        1000000007
#define endl        '\n'
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define rep1(i,a,b) for(ll i=a;i<= b;i++)
#define PI          3.14159
#define MAX         100000001
#define fast_io      ios_base::sync_with_stdio(false);  cin.tie(0); cout.tie(0);
#define scan(var)    scanf("%lld",&var)
#define print(var)   printf("%lld\n", var);
#define BLOCK 317
#define double       long double
#define mod          998244353
using namespace std;
ll dp[3001][3001];
char arr[3001][3001];
ll solvedp(ll x1,ll y1,ll n,ll m)
{
  if(x1 == n || y1 == m)
  {
    return 0;
  }
  if(x1 == n - 1 && y1 == m - 1)
  {
    return 1;
  }
  if(arr[x1][y1] == '#')
  {
    return 0;
  }
  if(dp[x1][y1] != -1)
  {
    return dp[x1][y1];
  }
  ll ans = 0;
  ans = (ans + solvedp(x1 + 1,y1,n,m) + solvedp(x1,y1 + 1,n,m))%hell;
  dp[x1][y1] = ans;
  return ans;
}
int main()
{
  fast_io
  ll n,m;
  cin >> n >> m;
  rep(i,0,n)
  {
    rep(j,0,m)
    {
      cin >> arr[i][j];
    }
  }
  memset(dp,-1,sizeof(dp));
  cout << solvedp(0,0,n,m);
  return 0;
}



Measured memory_bytes: 75392
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>

using namespace std;

#define ll long long int

void solve();

int main() {

   solve();
   return 0;

}

void solve() {
   ll N,M;
   cin >>N >>M;
   vector<pair<ll,ll>> v(M);
   vector<ll> ans(N+1);

   for (ll i = 0; i < M; i++) {

      cin >> v[i].first >> v[i].second;
      ans[v[i].first]++;   ans[v[i].second]++;
   }

   for (ll i = 1; i <= N; i++) {

      cout << ans[i] << endl;

   }

}

Measured memory_bytes: 256
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
f = int(input())
g = int(input())
h = int(input())
i = int(input())
j = int(input())

hights = [a,b,c,d,e,f,g,h,i,j]
hights.sort(reverse = True)
print(hights[0],hights[1],hights[2],sep="\n")



Measured memory_bytes: 5600
#include <iostream>
#include <ccomplex>
#include <vector>
#include <cassert>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <numeric>
#include <list>
#include <assert.h>
#include <math.h>
#include <valarray>
#include <stdio.h>
#include <algorithm>
#include <set>
#include <complex>
#include <list>
#include <time.h>
#include <stack>
#include <locale>
#include <clocale>
#include <ctype.h>
#include <wchar.h>
#include <random>
#include <vector>
#include <unordered_map>
#include <bitset>

using namespace std;
typedef long long int LL;
typedef long long int ll;
typedef pair<long long int, long long int> pii;
typedef pair<double, double> pdd;

#define SORT(c) sort((c).begin(),(c).end())
#define BACKSORT(c) sort((c).begin(),(c).end(),std::greater<LL>())
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

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

  vector<int> v(4);
  cin >> v[0] >> v[1] >> v[2] >> v[3];
  SORT(v);
  if(v[0]==1&&v[1]==4&&v[2]==7&&v[3]==9){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <cmath>

using namespace std;

int main()
{
    int n;
    int a[100010];
    bool same[100010] = {};
    int ans = 0;

    cin >> n;

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

    for (int i = 0; i < n; i++) {
        if (same[i]) {
            if (same[i+1]) {
                ans++;
                same[i+1] = false;
            }
            else {
                ans++;
            }
        }
    }

    cout << ans << endl;
}



Measured memory_bytes: 768
#include<math.h>
#define min(x,y)((x)<(y)?(x):(y))
n,r[12];
double d[12][12],smemo[1<<12][12];
double shortest(restbits,last){
	int i;
	double s,t;
	if(restbits==0)
		return r[last];
	if(smemo[restbits][last])
		return smemo[restbits][last];
	s=1e3;
	for(i=0;i<n;i++){
		if(restbits&(1<<i)){
			t=d[last][i]+shortest(restbits-(1<<i),i);
			s=min(s,t);
		}
	}
	return smemo[restbits][last]=s;
}
main(){
	int L,i,j;
	char c;
	double s,t;
	for(;~scanf("%d",&L);){
		for(n=0;scanf("%d%c",r+n++,&c),c!='\n';);
		for(i=0;i<n;i++)
			for(j=0;j<n;j++)
				d[i][j]=2*sqrt(r[i]*r[j]);
		memset(smemo,0,sizeof(smemo));
		s=1e3;
		for(i=0;i<n;i++){
			t=r[i]+shortest((1<<n)-1-(1<<i),i);
			s=min(s,t);
		}
		puts(s<=L?"OK":"NA");
	}
}

Measured memory_bytes: 0
word_list = input().split(' ')

word_dict = {}

longest_word_len = 0
longest_word = ''

high_freq_word_num = 0

for word in word_list:
    if longest_word_len < len(word):
        longest_word_len = len(word)
        longest_word = word

    if word not in word_dict:
        word_dict[word] = 1
    else :
        word_dict[word] += 1

    if high_freq_word_num < word_dict[word]:
        high_freq_word_num = word_dict[word]

for word in word_list:
    if word_dict[word] == high_freq_word_num:
        print(word + ' ' + longest_word)
        break


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

#define REP(i,n) for(int i = 0; i < (n); ++i)
#define REP1(i,n) for(int i = 1; i <= (n); ++i)
#define RREP(i, n) for(int i = (n) - 1; i >= 0; --i)
#define ALL(a) begin(a), end(a)
#define MP(a,b) make_pair((a), (b))
#define ROUNDUP(a,b) ((a) / (b) + ((a) % (b) == 0 ? 0 : 1))
#define X first
#define Y second
#define DEBUG(a) cout << #a << ": " << a << "\n"
// #define DEBUG(a) {}

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

constexpr int MOD = 1e9 + 7;
constexpr int INF = 1e9 + 1;
constexpr ll LLINF = 4 * 1e18 + 1;
// constexpr int INF = 2147483647; // 2 * 1e9
// constexpr ll LLINF = 9223372036854775807; // 9 * 1e18

int dx[] = {1, 0, -1, 0, 1, -1, -1, 1, 0};
int dy[] = {0, 1, 0, -1, 1, 1, -1, -1, 0};

template<typename T>
T debug(T x) {
	DEBUG(x);
	return x;
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int n, h;
	cin >> n >> h;
	vi a(n), b(n);
	REP(i, n) cin >> a[i] >> b[i];
	int aa = *max_element(ALL(a));
	sort(ALL(b), greater<int>());
	int i = 0;
	int ans = 0;
	while(h > 0){
		if(i < b.size() && b[i] > aa){
			h -= b[i];
			i++;
			ans++;
		}
		else{
			ans += (h + aa - 1) / aa;
			break;
		}
	}
	cout << ans << "\n";
	return 0;
}


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

using ll = long long; using ld = long double; using ull = unsigned long long; using uint = unsigned int;
using vi  = vector<int>; using vb  = vector<bool>; using vd  = vector<double>; using vl  = vector<ll>;
using vvi = vector<vi>;  using vvb = vector<vb>;   using vvd = vector<vd>;     using vvl = vector<vl>;

#define REP(i,n) for(ll i=0; i<(n); ++i)
#define FOR(i,b,n) for(ll i=(b); i<(n); ++i)
#define ALL(v) (v).begin(), (v).end()
#define TEN(x) ((ll)1e##x)

template<typename T> inline string join(const vector<T>& vec, string sep = " ") { stringstream ss; REP(i, vec.size()) ss << vec[i] << ( i+1 == vec.size() ? "" : sep ); return ss.str(); }


///////////////

#define EPS (1e-10)
#define NEXT(x, i) (x[(i + 1) % x.size()])

template<class T> using CR = const T &;
using P = complex<ld>;
using G = vector<P>;

int sgn(ld a, ld b = 0) {
	if (a > b + EPS) return 1;
	if (a < b - EPS) return -1;
	return 0;
}

ld dot(P a, P b) { return real(conj(a)*b); }
ld cross(P a, P b) { return imag(conj(a)*b); }

int ccw(P a, P b, P c) {
	b -= a;
	c -= a;
	if (sgn(cross(b, c))) return sgn(cross(b, c)); // clockwise or counter clockwise
	if (sgn(dot(b, c)) == -1) return 2;            // c--a--b
	if (sgn(norm(b), norm(c)) == -1) return -2;    // a--b--c
	return 0;                                      // a--c--b
}

#define PREV(x, i) (x[(i+x.size()-1) % x.size()])
#define NEXT(x, i) (x[(i + 1) % x.size()])
bool is_convex(CR<G> g) {
	REP(i, g.size()) if (ccw(PREV(g, i), g[i], NEXT(g, i)) == -1) return false;
	return true;
}


//////////////

int main() {
#ifdef INPUT_FROM_FILE
	ifstream cin("sample.in");
	ofstream cout("sample.out");
#endif
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(30);
	ll n; cin >> n;

	G g(n);
	REP(i,n){
		ld x, y;
		cin >> x >> y;
		g[i] = { x, y };
	}
	cout << is_convex(g) << endl;

	return 0;
}

Measured memory_bytes: 3316
#include<iostream>
#include<cstring>
#include<algorithm>
using namespace std;
int dp[10][100001];

void printD(){
  for(int i=0;i<10;i++){
    for(int j=0;j<=15;j++){
      cout << dp[i][j] << " ";
    }
    cout << endl;
  }
}

int main(){
  int n,m;
  string id;
  int even=1;
  cin>>n>>id>>m;
  if(n&1)even=0;
  int a[m];
  memset(dp,0,sizeof(dp));
  for(int i=0;i<m;i++)cin>>a[i];

  dp[0][0]=1;
  for(int i=0;i<n;i++){
    int val;
    for(int j=0;j<10;j++){
      if(id[i]!='*'){
	val=(id[i]-'0')<<even;
	val=val%10 + val/10;
	dp[(j+val)%10][i+1]=dp[j][i];
      }else{
	for(int k=0;k<m;k++){
	  val=a[k]<<even;
	  val=val%10 + val/10;
	  dp[(j+val)%10][i+1]+=dp[j][i];
	}
      }
    }
    even=!even;
  }
  //printD();
  cout << dp[0][n] << endl;
  return 0;
}

Measured memory_bytes: 5248