akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
const int maxn=1e5+10;
struct data{int to,next,wi;}e[maxn*2];
int head[maxn];
int cnt=0;
int du[maxn];
queue<int> q;
int vis[maxn];
void ins(int u,int v,int ww)
{
	e[++cnt].to=v;
	e[cnt].next=head[u];
	e[cnt].wi=ww;
	head[u]=cnt;
}
int n,m;
int dis[maxn];
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;i++)
	{
		int x,y,z;
		scanf("%d%d%d",&x,&y,&z);
		ins(x,y,z);
		du[y]++;
	}
	for(int i=1;i<=n;i++)dis[i]=1e9+10;
	int tot=0;
	for(int s=1;s<=n;s++)
	{
		if(du[s]==0)
		{
			tot++;
			dis[s]=0;
			vis[s]=tot;
			q.push(s);
			while(!q.empty())
			{
				int x=q.front();
				q.pop();
				for(int i=head[x];i;i=e[i].next)
				{
					int u=e[i].to;
					if(vis[u]==tot&&dis[u]!=dis[x]+e[i].wi)
					{
						puts("No");
						return 0;
					}
					if(vis[u]==0)
					{
						vis[u]=tot;
						dis[u]=min(dis[u],dis[x]+e[i].wi);
						q.push(u);
					}
				}
			}
		}
	}
	for(int i=1;i<=n;i++)if(vis[i]==0){puts("No");return 0;}
	puts("Yes");
	return 0;
}


Measured memory_bytes: 4608
/*
 *  Created on: 24-May-2019
 *      Author: ankur314
 */
#include<bits/stdc++.h>
#define lli long long int 
#define li long int
#define db double 
#define ldb long double
#define vr vector 
#define it iterator
#define fi(i,a,n) for(int i=a;i<n;i++)
#define fli(i,a,n) for(long int i=a;i<n;i++)
#define flli(i,a,n) for(long long int i=a;i<n;i++)
#define pb(n) push_back(n)
#define ppf() pop_front()
#define pii pair<int,int>
#define MOD 1000000007

#define debug1(x) cout<<x<<"\n"
#define debug2(x,y) cout<<x<<" "<<y<<"\n"
#define debug3(x,y,z) cout<<x<<" "<<y<<" "<<z<<"\n"
#define debug4(x,y,z,w) cout<<x<<" "<<y<<" "<<z<<" "<<w<<"\n"

using namespace std;

int main() {
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    /*freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);*/
    int n,k;cin>>n>>k;
    lli dp[k+1];
    memset(dp,0,sizeof(dp));
    dp[0]=1;
    lli a[k+1];
    //memset(a,0,sizeof(a));
    fi(i,1,n+1)
    {
        int max_candies;
        cin>>max_candies;
        memset(a,0,sizeof(a));
        for(int j=k;j>=0;j--)
        {
            lli tmp = dp[j];
            int L = j+1;
            int R = j+min(max_candies, k-j);
            if(L <= R)
            {
	            a[L] += tmp;
	            if(a[L] >= MOD) a[L] -= MOD;
	            if(R+1 <= k) {a[R+1] -= tmp;
	          	if(a[R+1]<0) a[R+1] += MOD;
	            }
            }
	  
        }
        int pref = 0;
        for(int i=0;i<=k;i++)
        {
        	pref+=a[i];
        	pref %= MOD;
        	dp[i]+=pref;
        	dp[i]%=MOD;
        }
    }
    cout<<dp[k];
    return 0;   
}

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

using namespace std;


int main() {

	int n;cin >> n;
	long long ans{0};

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

		if(i%3==0 || i%5==0) continue;
		ans += (long long)i;
	}
	cout << ans;
}


Measured memory_bytes: 3640
#include<stdio.h>

int main(void)
{
  long int h;
  scanf("%ld",&h);
  
  if(h==1){
    printf("1");
    return 0;
  }
  
  
  long int x;
  x=1;
  while(x<=h){
    x=x*2;
  }
  
  x--;
  printf("%ld",x);
  
  return 0;
}

Measured memory_bytes: 128
import sys


class Node(object):
    __slots__ = ['value', 'parent', 'left', 'right']
    
    def __init__(self, value: int, parent: 'Node' = None):
        self.value = value
        self.parent = parent
        self.left: Node = None
        self.right: Node = None

    def walk(self, a, walk_type):
        if walk_type == 0:
            a.append(self.value)
        if self.left:
            self.left.walk(a, walk_type)
        if walk_type == 1:
            a.append(self.value)
        if self.right:
            self.right.walk(a, walk_type)
        if walk_type == 2:
            a.append(self.value)
        return a


class BinarySearchTree(object):
    __slots__ = ['root']
    
    def __init__(self):
        self.root: Node = None

    def insert(self, x: int):
        if self.root is None:
            self.root = Node(x)
            return
        parent, current = None, self.root

        while current:
            parent = current
            if x < current.value:
                current = current.left
            else:
                current = current.right

        if x < parent.value:
            parent.left = Node(x, parent)
        else:
            parent.right = Node(x, parent)


def solve():
    tree = BinarySearchTree()
    input()
    for l in (l.split() for l in sys.stdin):
        if l[0] == "insert":
            tree.insert(int(l[1]))
        else:
            print('', *tree.root.walk([], 1))
            print('', *tree.root.walk([], 0))


if __name__ == "__main__":
    solve()


Measured memory_bytes: 69108
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<ctime>
#include<cctype>
#include<climits>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<memory>
#include<functional>
#include<set>
 
using namespace std;
 
#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define P(p) cout<<(p)<<endl;
#define p(p) cout<<(p)<<" ";
#define pb push_back
#define mp make_pair
#define INF 1<<25

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pi;
typedef long long ll;

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

int N,M,l,r;
vi a,b,c,d;
int A,B;
void input(){
	cin>>N>>A>>B;
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	input();
	P(min(N*A,B))
	return 0;
}



Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define PI 3.141592
#define LL_INF 9000000000000000000
#define LL_MINF -9000000000000000000
#define INT_INF 2000000000
#define INT_MINF -2000000000
#define all(a) (a).begin(), (a).end()
#define fi first
#define se second
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

int main(){
    string S;
    cin >> S;
    map<char,int> count;
    for(char s : S) count[s]++;
    bool ok = true;
    for(auto p : count){
        if(p.se != 1) ok = false;
    }
    if(ok) puts("yes");
    else puts("no");
}


Measured memory_bytes: 3596
n, m = map(int, input().split())
a = list()
for i in range(n):
    a.append(list(map(int, input().split())))
b = list()
for i in range(m):
    b.append(int(input()))
for i in range(n):
    ans = 0
    for j in range(m):
        ans += a[i][j] * b[j]
    print(ans)
    


Measured memory_bytes: 6012
x = int(input())
if x>=400 and x<=599:
  print(8)
elif x>=600 and x<=799:
  print(7)
elif x>=800 and x<=999:
  print(6)
elif x>=1000 and x<=1199:
  print(5)
elif x>=1200 and x<=1399:
  print(4)
elif x>=1400 and x<=1599:
  print(3)
elif x>=1600 and x<=1799:
  print(2)
elif x>=1800 and x<=1999:
  print(1)

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

int main() {
  int N;
  cin >> N;
  int a,b,c,d;
  a = (N - N % 1000) / 1000;
  b = (N % 1000 - N % 100) / 100;
  c = (N % 100 - N % 10) / 10;
  d = N % 10;

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

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define vll vector<ll>
#define vi vector<int>
#define vpll vector<pair<ll,ll>>
#define pii pair<int,int>
#define REP(i,a) for(int (i)=0; (i)<(a); (i)++)
#define RREP(i,a) for(int (i)=a-1; (i)>=(0); (i)--)
#define REP2(i,a,b) for(int (i)=(a); (i)<(b); (i)++)
#define MOD 1000000007
#define ALL(v) v.begin(), v.end()
#define m0(x) memset(x,0,sizeof(x))
typedef long long ll;
using namespace std;



int main(){
	ll K; cin >> K;
    int ans = 0;
    for(int a = 1; a<=K; a++){
      for(int b = 1; b<=K; b++){
        for(int c = 1; c<=K; c++){
          ans += gcd(gcd(a,b),c);
        }}}
    cout << ans;
  	return 0;
}


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

using namespace std;
using ll =long long;
typedef pair<int,int> P;
#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
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; }
//Write From this Line

int main()
{
	int n, k;
	cin >> n >> k;
	
	vector<ll> x(n), y(n);
	vector<ll> xary, yary;
	rep(i,n){
	cin >> x[i] >> y[i];
		xary.push_back(x[i]);
		yary.push_back(y[i]);
	}
	SORT(xary);
	SORT(yary);

	ll ans = 1LL * (xary[n-1] - xary[0]) * (yary[n-1] - yary[0]);

	for(ll xi = 0; xi < n; ++xi){
		for(ll xj = xi + 1; xj < n; ++xj){
			for(ll yi = 0; yi < n; ++yi){
				for(ll yj = yi + 1; yj < n; ++yj){
					ll num = 0;
					ll lx = xary[xi], rx = xary[xj];
					ll ly = yary[yi], ry = yary[yj];
					for(ll i = 0; i < n; ++i){
						if(lx <= x[i] && rx >= x[i] && ly <= y[i] && ry >= y[i]) num++;
					}
					if(num >= k) chmin(ans, 1LL* (ry - ly) * (rx - lx));
				}
			}
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 384
main(){
  int i,j,a[10],y;
  for(i=0;i<=9;i++)
    scanf("%d",&a[i]);
  for(i=0;i<=8;i++)
    for(j=i+1;j<=9;j++){
      if(a[i]<a[j]){
	y=a[i];
	a[i]=a[j];
	a[j]=y;
      }}
  for(i=0;i<3;i++)
    printf("%d\n",a[i]);
  return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <string>
#include <set>
#include <map>
#include <vector>

using namespace std;


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

  int H, W;
  cin >> H >> W;
  for(int i=0; i<W+2; i++){
	cout << "#";
  }
  cout << endl;
  for(int i=0; i<H; i++){
	string str;
	cin >> str;
	cout << "#" << str << "#" << endl;
  }
  for(int i=0; i<W+2; i++){
	cout << "#";
  }
  cout << endl;
  

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <string>
#include <iostream>
#include <iomanip>
using namespace std;
#define rep(i, N) for (ll i = 0; i < (N); i++)
typedef long long ll;

int main()
{
    ll X;
    cin >> X;
    ll a = X / 500;
    ll b = X % 500;
    ll c = b % 5;
    ll d = b - c;
    ll ans;
    ans = a * 1000 + 5 * (d / 5);
    cout << ans << endl;
}

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

int main() {
  long long n, k;
  cin>>n>>k;
  if (n == 0) {
    cout<<0<<endl;
    return 0;
  }
  if (k == 1) {
    cout<<0<<endl;
    return 0;
  }
  cout<<min(n - n/k*k, (n/k+1)*k - n)<<endl;
}

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

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    N,M=MI()
    cnt=[0]*N
    for i in range(M):
        a,b=MI()
        a-=1
        b-=1
        cnt[a]+=1
        cnt[b]+=1
        
    for i in range(N):
        print(cnt[i])

main()


Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<char,char> P;

void Main() {
  ll n,m;
  string s;
  cin >> n >> m >> s;
  P a[m];
  rep(i,m) cin >> a[i].F >> a[i].S;
  ll l=0,r=n;
  while(l+1<r) {
    ll mm=(l+r)/2;
    ll x=mm;
    rep(i,m) {
      if(x==-1||x==n) break;
      if(s[x]==a[i].F) {
        if(a[i].S=='L') x--;
        else x++;
      }
    }
    if(x<0) l=mm;
    else r=mm;
  }
  ll x1=r;
  l=0,r=n;
  while(l+1<r) {
    ll mm=(l+r)/2;
    ll x=mm;
    rep(i,m) {
      if(x==-1||x==n) break;
      if(s[x]==a[i].F) {
        if(a[i].S=='L') x--;
        else x++;
      }
    }
    if(x>=n) r=mm;
    else l=mm;
  }
  pr(r-x1);
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


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

int main(){
  int N;
  cin >> N;
  
  for(int i = 0; i < 26; i++){
    for(int j = 0; j < 15; j++){
      if(N == i * 4 + j * 7){
         cout<<"Yes"<<endl;
        return 0;
      }
    }
  }
  
  cout << "No" << endl;
  return 0;
}

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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int INF = 1e9;

int main() {
  ll n, k, ans = 0;
  cin >> n >> k;
  vector<ll> h(n);
  rep(i, n) cin >> h[i];
  sort(h.rbegin(), h.rend());
  for (int i = k; i < n; ++i) ans += h[i];

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


Measured memory_bytes: 1920
from math import gcd
counter = 0
K = int(input())
for a in range(1,K+1):
    for b in range(1,K+1):
        if gcd(a,b)==1:
            counter += K
        else:
            for c in range(1,K+1):
                d = gcd(a,b)
                counter += gcd(c,d)


print(counter)

Measured memory_bytes: 9136
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i,n) for(ll i=0;i<n;i++)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define fi first
#define se second
#define endl "\n"

template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){int len=d.size();rep(i,len){s<<d[i];if(i<len-1) s<<" ";}return s;}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){int len=d.size();rep(i,len){s<<d[i]<<endl;}return s;}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){s<<"{"<<endl;for(auto itr=m.begin();itr!=m.end();++itr){s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;}s<<"}"<<endl;return s;}

const ll mod=1e9+7;
const ll inf=1e17;
const int INF=1e9;
const double PI=acos(-1);
const double EPS=1e-10;

int main(){
	cin.tie(0);ios::sync_with_stdio(false);
	string s;
	cin>>s;
	int n=s.size();
	if(s[0]!=s[n-1]){
		if(n%2) cout<<"First"<<endl;
		else cout<<"Second"<<endl;
	}else{
		if(n%2) cout<<"Second"<<endl;
		else cout<<"First"<<endl;
	}
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int n,s,ans;
char c;
int main(void)
{
	scanf("%d",&n);
	for(int i=0;i<n;i++)
	{
		cin>>c;
		if(c=='I') s++;
		else s--;
		ans=max(ans,s);
	}
	printf("%d\n",ans);
}

Measured memory_bytes: 256
//WeLoveGolf.java
import java.util.Scanner;
class Main
{
	public static void main(String args[])
	{
		Scanner sc=new Scanner(System.in);
		int k=sc.nextInt();
        int a=sc.nextInt();
        int b=sc.nextInt();

        int sum=b/k;
        int ans=k*sum;
        //System.out.println("sum"+sum);
        //System.out.println("ans"+ans);

        if(ans>=a){
            System.out.println("OK");
        }
        else{
            System.out.println("NG");
        }
        sc.close();
    }
}

Measured memory_bytes: 35700
import math

n,k = (int(x) for x in input().split())
w = list()

for i in range(0, n):
    w.append(int(input()))

def check(P):
    i = 0
    for j in range(0, k):
        summ = 0
        while(summ + w[i] <= P):
            summ += w[i]
            i += 1
            if(i == n): #最後までしまえたら終了
                return n

    return i #入りきらなかったら終了

def Binary_Search():
    left = 0
    right = 100000*100000
    while(right - left > 1):
        mid = math.floor((left + right) / 2)
        if(check(mid) >= n): #全部トラックに入ったなら範囲の最大値をを狭める
            right = mid
        else:
            left = mid

    return right

ans = Binary_Search()

print(ans)



Measured memory_bytes: 9624
import scala.math._

object Main {
  val sc = new java.util.Scanner(System.in)
  def main(args: Array[String]) {
    while(true) {
      val n = sc.nextInt()
      if(n == 0) return

      var ans = 0
      for(i <- 1 to n/4) {
        ans += sc.nextInt()
      }
      println(ans)
    }
  }
}

Measured memory_bytes: 44692
#include<stdio.h>
#include <unistd.h>
#include <stdlib.h>

int mf(int*,int,int);
int sort(int*,int,int,int);

int n,count =0;
int main(){
  int i,a[500000];
  scanf("%d",&n);
  for(i=0;i<n;i++)  scanf("%d",&a[i]);
  mf(a,0,n);
  i=0;
  printf("%d",a[i]);
  for(i=1;i<n;i++)
  printf(" %d",a[i]);
  
  printf("\n%d\n",count);
}
int mf(int *a,int l,int r){
  if(l+1<r){
  int mid;
  mid=(l+r)/2;
    mf(a,l,mid);
    mf(a,mid,r);
    sort(a,l,mid,r);

  }

}
int sort(int *a,int l,int m,int r){
  int n1,n2;
  int i,j,k,*la,*ra;
  n1=m-l;
  n2=r-m;
  la = malloc(sizeof(int)*n1+1);
  ra = malloc(sizeof(int)*n2+1);
  
  
  for(i=0;i<n1;i++) la[i]=a[l+i];
  la[i]=-1;
  for(i=0;i<n2;i++) ra[i]=a[m+i];
  ra[i]=-1;
  i=0;
  j=0;
  for(k=l;k<r;k++){
    if((la[i] < ra[j] || ra[j] == -1) && la[i] != -1){
      a[k]=la[i];
      i++;
    }else{
      a[k]=ra[j];
      j++;

    }
    count++;

  }
  free(ra);
  free(la);
}



Measured memory_bytes: 5516
// https://atcoder.jp/contests/abc126/tasks/abc126_b
#include <bits/stdc++.h>
using namespace std;

int main(void){
  string S;
  cin >> S;
  string ans;

  int s01 = stoi(S.substr(0, 2));
  int s23 = stoi(S.substr(2, 2));
  bool s01f = false;
  bool s23f = false;

  if (0 < s01 && s01 < 13)
    s01f = true;
  if (0 < s23 && s23 < 13)
    s23f = true;
  
  if (s01f && s23f)
    ans = "AMBIGUOUS";
  else if (s01f)
    ans = "MMYY";
  else if (s23f)
    ans = "YYMM";
  else
    ans = "NA";
    
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define MOD 1000000007
#define INF 1e18
#define PI 3.14159265358979

using namespace std;

ll gcd(ll a, ll b);
ll power(ll n, ll k);
ll inv(ll n);
ll genfact(ll n, ll k);
ll fact(ll n);
ll nck(ll n, ll k);

int main(void){
  string s, t;
  cin >> s >> t;

  int ok = 0;
  for (int i = 0; i < s.size(); i++){
    if (s == t)
      ok = 1;


    s = s[s.size() - 1] + s.substr(0, s.size() - 1);
  }


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

  return 0;
}

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

ll power(ll n, ll k){
  ll res = 1;
  while(k > 0){
    if (k & 1) 
      res = res * n % MOD;
    n = n * n % MOD;
    k >>= 1;
  }
  return res;
}

ll genfact(ll n, ll k){

  ll res = 1;
  while (k >= 0){
    res = (res * (n - k)) % MOD;
    k--;
  }

  return res;
}

ll inv(ll n){
  return power(n, MOD - 2);
}

ll fact(ll n){
  return genfact(n, n - 1);
}

ll nck(ll n, ll k){
  if (k == 0)
    return 1;
  if (n <= 0)
    return 0;

  return ((genfact(n, k) % MOD) * inv(fact(k))) % MOD;
}


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

int main(void){
    while(1){
        int n, x;
        cin >> n >> x;
        if(n == 0) break;
        int cnt = 0;
        for(int i = 1; i <= n; i++){
            for(int j = i + 1; j <= n; j++){
                for(int k = j + 1; k <= n; k++) if(i + j + k == x) cnt++;
            }
        }
        cout << cnt << endl;
    }
    return 0;
}


Measured memory_bytes: 3076
package main

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

const M = 1046527

func converter(char byte) int {
	switch char {
	case 'A':
		return 1
	case 'C':
		return 2
	case 'G':
		return 3
	case 'L':
		return 4
	default:
		return 0
	}
}

func getKey(str string) int {
	sum, p := 0, 1
	for i := 0; i < len(str); i++ {
		sum += p * converter(str[i])
		p *= 5
	}
	return sum
}

func hash1(key int) int {
	return key%M
}

func hash2(key int) int {
	return 1 + key%(M-1)
}

func find(hashTable []string, target string) bool {
	//fmt.Println("called find")
	key := getKey(target)
	//fmt.Printf("key: %d\n", key)
	h := 0
	for i := 0; ; i++ {
		h = (hash1(key) + i * hash2(key)) % M
		// fmt.Printf("h: %d\n", h)
		if hashTable[h] == target {
			return true
		} else if len(hashTable[h]) == 0 {
			return false
		}
	}
}

func insert(hashTable []string, target string) []string {
	//fmt.Println("called insert")
	key := getKey(target)
	for i := 0; ; i++ {
		h := (hash1(key) + i * hash2(key)) % M
		// fmt.Printf("h: %d\n", h)
		if hashTable[h] == target {
			return hashTable
		} else if len(hashTable[h]) == 0 {
			hashTable[h] = target
			return hashTable
		}
	}
}

func answer(r io.Reader) string {
	hashTable := make([]string, M)
	scanner := bufio.NewScanner(r)
	scanner.Scan()
	n, _ := strconv.Atoi(scanner.Text())

	memo := bytes.Buffer{}

	for i := 0; i < n; i++ {
		scanner.Scan()
		operation := strings.Fields(scanner.Text())
		switch operation[0] {
		case "insert":
			insert(hashTable, operation[1])
			//fmt.Println(hashTable)
		case "find":
			if find(hashTable, operation[1]) {
				memo.WriteString("yes\n")
			} else {
				memo.WriteString("no\n")
			}
		}
	}
	return strings.TrimRight(memo.String(), "\n")
}

func main() {
	fmt.Println(answer(os.Stdin))
}


Measured memory_bytes: 45976
#include<iostream>
#include<algorithm>
#include<cmath>
#include<map>
#include<stdio.h>
#include<vector>
using namespace std;
#define int long long
#define rep(s,i,n) for(int i=s;i<n;i++)
#define c(n) cout<<n<<endl;
#define ic(n) int n;cin>>n;
#define sc(s) string s;cin>>s;
#define mod 1000000007
#define inf 1000000000000000007
#define f first
#define s second
#define mini(c,a,b) *min_element(c+a,c+b)
#define maxi(c,a,b) *max_element(c+a,c+b)
#define P pair<int,int>
//printf("%.12Lf\n",);
int keta(int x){
	rep(0,i,30){
		if(x<10){
			return i+1;
		}
		x=x/10;
	}
}
int gcd(int x,int y){
	int aa=x,bb=y;
	rep(0,i,1000){
		aa=aa%bb;
		if(aa==0){
			return bb;
		}	
		bb=bb%aa;
		if(bb==0){
			return aa;
		}
	}
}	
int lcm(int x,int y){
	int aa=x,bb=y;
	rep(0,i,1000){
		aa=aa%bb;
		if(aa==0){
			return x/bb*y;
		}	
		bb=bb%aa;
		if(bb==0){
			return x/aa*y;
		}
	}
}
bool p(int x){
	if(x==1)return false;
	rep(2,i,sqrt(x)+1){
		if(x%i==0&&x!=i){
			return false;
		}
	}	
	return true;
}
int max(int a,int b){
	if(a>=b)return a;
	else return b;
}
int min(int a,int b){
	if(a>=b)return b;
	else return a;
}	
int n2[41];		
int nis[41]; 
int nia[41];
int mody[41];
int nn;
int com(int n,int y){
	int ni=1;
	for(int i=0;i<41;i++){
		n2[i]=ni;
		ni*=2;
	}
	int bunsi=1,bunbo=1;
	rep(0,i,y)bunsi=(bunsi*(n-i))%mod;
	rep(0,i,y)bunbo=(bunbo*(i+1))%mod;
	mody[0]=bunbo;
	rep(1,i,41){
		bunbo=(bunbo*bunbo)%mod;
		mody[i]=bunbo;
	}
	rep(0,i,41)nis[i]=0;
	nn=mod-2;
	for(int i=40;i>=0;i-=1){
		if(nn>n2[i]){
			nis[i]++;
			nn-=n2[i];
		}
	}
	nis[0]++;
	rep(0,i,41){
		if(nis[i]==1){
			bunsi=(bunsi*mody[i])%mod;
		}
	}
	return bunsi;
}
int yakuwa(int n){
	int sum=0;
	rep(1,i,sqrt(n+1)){
		if(n%i==0)sum+=i+n/i;
		if(i*i==n)sum-=i;
	}
	return sum;
}	
bool hei(int n){
	rep(0,i,100){
		if(i*i==n){
			return true;
		}
	}
	return false;
}
int pow(int b,int a){	
	int aa=1;
	rep(0,i,a)aa*=b;	
	return aa;
}
int sankaku(int a){
	return a*(a+1)/2;
} 
char c[15][1145];
int a[1145][15];
signed main(){
	sc(s)
	int n=s.size();
	int t=0;
	int ans=0;
	for(int i=n-1;i>=0;i-=1){
		if(s[i]=='S'){
			if(t>0){
				ans++;
				t-=1;
			}
		}
		else t++;
	}
	c(n-ans*2)		
}	

Measured memory_bytes: 640
#include <iostream>
#include <string>

std::string str;

int main() {

    std::cin>>str;

    std::string ss=str;
    for(int i=1;i<str.size();++i)
        ss[i]='9';

    char ch=str[0];

    if(ss==str)
        std::cout<<((str.size()-1)*9+atoi(&ch))<<std::endl;
    else
        std::cout<<((str.size()-1)*9+atoi(&ch)-1)<<std::endl;

    std::cout<<std::endl;

    return 0;
}

Measured memory_bytes: 256
#![allow(unused_parens)]
#![allow(unused_imports)]
#![allow(non_upper_case_globals)]
#![allow(non_snake_case)]
#![allow(unused_mut)]
#![allow(unused_variables)]
#![allow(dead_code)]

use itertools::Itertools;
use proconio::input;
use proconio::marker::{Chars, Usize1};

#[allow(unused_macros)]
#[cfg(debug_assertions)]
macro_rules! mydbg {
    //($arg:expr) => (dbg!($arg))
    //($arg:expr) => (println!("{:?}",$arg));
      ($($a:expr),*) => {
          eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
      }
}
#[cfg(not(debug_assertions))]
macro_rules! mydbg {
    ($($arg:expr),*) => {};
}

macro_rules! echo {
    ($($a:expr),*) => {
          $(println!("{}",$a))*
      }
}

use std::cmp::*;
use std::collections::*;
use std::ops::{Add, Div, Mul, Sub};

#[allow(dead_code)]
static INF_I64: i64 = 92233720368547758;
#[allow(dead_code)]
static INF_I32: i32 = 21474836;
#[allow(dead_code)]
static INF_USIZE: usize = 18446744073709551;
#[allow(dead_code)]
static M_O_D: usize = 1000000007;
#[allow(dead_code)]
static PAI: f64 = 3.1415926535897932;

trait IteratorExt: Iterator {
    fn toVec(self) -> Vec<Self::Item>;
}

impl<T: Iterator> IteratorExt for T {
    fn toVec(self) -> Vec<Self::Item> {
        self.collect()
    }
}

trait CharExt {
    fn toNum(&self) -> usize;
    fn toAlphabetIndex(&self) -> usize;
    fn toNumIndex(&self) -> usize;
}
impl CharExt for char {
    fn toNum(&self) -> usize {
        return *self as usize;
    }
    fn toAlphabetIndex(&self) -> usize {
        return self.toNum() - 'a' as usize;
    }
    fn toNumIndex(&self) -> usize {
        return self.toNum() - '0' as usize;
    }
}

trait VectorExt {
    fn joinToString(&self, s: &str) -> String;
}
impl<T: ToString> VectorExt for Vec<T> {
    fn joinToString(&self, s: &str) -> String {
        return self
            .iter()
            .map(|x| x.to_string())
            .collect::<Vec<_>>()
            .join(s);
    }
}

trait StringExt {
    fn get_reverse(&self) -> String;
}
impl StringExt for String {
    fn get_reverse(&self) -> String {
        self.chars().rev().collect::<String>()
    }
}

trait UsizeExt {
    fn pow(&self, n: usize) -> usize;
}
impl UsizeExt for usize {
    fn pow(&self, n: usize) -> usize {
        return ((*self as u64).pow(n as u32)) as usize;
    }
}

fn main() {
    input! {
       N: usize,
       M:usize,
       X:usize,
    }
    let mut price = vec![];
    let mut info = vec![];
    for _ in 0..N {
        input! {
            C:usize,
            D:[usize;M],
        }
        price.push(C);
        info.push(D);
    }

    let mut ans: usize = 1000000000;
    for i in 0..(1 << N) {
        let mut rikai = vec![0; M];
        let mut sum = 0;
        for j in 0..N {
            if i >> j & 1 == 1 {
                sum += price[j];
                for k in 0..M {
                    rikai[k] += info[j][k];
                }
            }
        }
        if rikai.iter().filter(|&a| *a >= X).count() == M {
            ans = min(ans, sum);
        }
    }

    echo!(if ans == 1000000000 { -1 } else { ans as i64 });
}


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

int main() {
  int N,C,K;
  cin>>N>>C>>K;
  vector<int> t(N);
  for(int j=0;j<N;j++){
    cin>>t[j];
  }
  sort(t.begin(),t.end());
  int bus=0,passenger=0;
  int i=0;
  while(i<N){
    int first = t[i];
    passenger++;
    i++;
    while(t[i]<=first+K && passenger<C && i<N){
      passenger++;
      i++;
    }
    bus ++;
    //cout << passenger<<endl;
    //i++;
    passenger =0;
  }
  cout << bus<<endl;
}


Measured memory_bytes: 640
#ABC063

n = int(input())
s = sorted([int(input()) for _ in range(n)])

#print(s,sum(s))

if sum(s) % 10 != 0:
    print(sum(s))
else:
    for i in range(n):
        if s[i] % 10 != 0:
            print(sum(s)-s[i])
            break
    else:
        print(0)




Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
int main(){
  string N;int K;cin>>N>>K;
  vector<vector<long>> DP(N.length(),vector<long>(4,0));
  DP[0][0]=1;
  DP[0][1]=(int)N[0]-48;
  int c=1;
  for(int i=1;i<N.length();i++){
    DP[i][0]=1;
    for(int j=1;j<=3;j++){
      DP[i][j]=DP[i-1][j]+DP[i-1][j-1]*9-(c+1==j?9-((int)N[i]-48):0);
    }
    if((int)N[i]-48!=0)c++;
  }
  cout<<DP[N.length()-1][K];
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(100000000)
n = int(input())
S = list(map(int, input().split()))
q = int(input())
T = list(map(int, input().split()))

def bs(num, Arr, left, right):
  center = (right + left) // 2
  if Arr[center] == num:
    return True
  elif right - left <= 1:
    return False
  elif Arr[center] > num:
    return bs(num, Arr, left, center)
  elif Arr[center] < num:
    return bs(num, Arr, center+1, right)

counter = 0
for t in T:
  counter += bs(t, S, 0, len(S))
print(counter)


Measured memory_bytes: 16712
#include<iostream>
#include<algorithm>
#include<iomanip>
#include<string>
#include<vector>

typedef unsigned long long ULL;
typedef long long LL;

using namespace std;

void process();

int main(){
    int N,M;
    int *A;
    int count;
    int i;
    int sum = 0;
    cin >> N >> M;
    A = new int[N];
    for(i=0;i<N;i++){
        cin >> A[i];
        sum += A[i];
    }
    sort(A,A+N);
    count = 0;
    for(i=0;i<M;i++){
        if(A[N-i-1] * 4 * M < sum ){
            break;
        }
    }
    if( i == M){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

void process(){
    
}

Measured memory_bytes: 256
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::{Write, BufWriter};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, [ $t:tt ]) => {{
        let len = read_value!($next, usize);
        (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    }};

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused)]
macro_rules! debug {
    ($($format:tt)*) => (write!(std::io::stderr(), $($format)*).unwrap());
}
#[allow(unused)]
macro_rules! debugln {
    ($($format:tt)*) => (writeln!(std::io::stderr(), $($format)*).unwrap());
}

fn solve() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (let _ = write!(out,$($format)*););
    }
    input!(a: [i64; 3]);
    puts!("{} {} {}\n", a[2], a[0], a[1]); 
}

fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


Measured memory_bytes: 8572
MOD = 1000000007

def conv(a,b)
  if b > a/2
    b = a - b
  end
  ans = 1
  for i in 1..b
    ans = ((ans * (a - (i - 1))) * INV[i]) % MOD
  end
  ans % MOD
end

def pow(x,n)
  if n == 0
    1
  elsif n % 2 == 0
    pow(x*x%MOD, n/2) % MOD
  else
    x * pow(x, n-1) % MOD
  end
end

INV = []
def calc_fact(n)
  INV[0] = pow(1, MOD-2)
  for i in 1..n
    INV[i] = pow(i, MOD-2)
  end
end

n,a,b=gets.chomp.split(" ").map(&:to_i)

all = (pow(2,n) - 1) % MOD
if a > n/2
  a = n - a
end
if b > n/2
  b = n - b
end

calc_fact(a > b ? a : b)

all = all - conv(n,a) - conv(n,b)
all %= MOD

puts all

Measured memory_bytes: 3528
#n = input()
#n = int(input())
a,b = map(int,input().split())
#a_L = map(int,input().split())
rank_dic = {1:300000,2:200000,3:100000}

if a == 1 and b ==1:
    print(1000000)
    exit()

ans = 0
try:
    ans += rank_dic[a]
except:
    pass

try:
    ans += rank_dic[b]
except:
    pass

print(ans)

Measured memory_bytes: 38256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
using ll=long long;
static const ll mod = 1e9 + 7;
static const ll INF = 1LL << 50;
using namespace std;

int main() {
	ll n, k;
	cin >> n >> k;
	vector<ll>t(n), d(n);
	vector<pair<ll, ll>>p;
	rep(i, n) {
		cin >> t[i] >> d[i];
		p.eb(d[i], t[i]);
	}
	sort(p.begin(), p.end(), greater<pair<ll,ll>>());
	map<ll,int>mp;
	rep(i, n) {
		if (!mp[p[i].se]) {
			mp[p[i].se]++;
			p[i].second = 1;
		}
		else p[i].second = 0;
	}
	ll type = 0, oisisa = 0;
	priority_queue<pair<ll, ll>,vector<pair<ll,ll>>,greater<pair<ll,ll>>>pq;
	rep(i, k) {
		oisisa += p[i].first;
		if (p[i].second == 0)pq.push(p[i]);
		else type++;
	}
	ll maxv = oisisa +type*type;
	rep(i, n) {
		if (k + i >= n)break;
		if (pq.empty())break;
		if (p[k + i].second == 1) {
			oisisa -= pq.top().first;
			pq.pop();
			oisisa += p[k + i].first;
			type ++;
			maxv = max(maxv, oisisa +type*type);
		}
	}
	cout << maxv << endl;
}

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

int main() {

    //入力
    int x;
    string ans;

    cin >> x;
    if (x >= 30)
        ans = "Yes";
    else
        ans = "No";

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)

ll mod = 1e09;

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

  ll a, b, k;
  cin >> a >> b >> k;

  ll lb = a + k - 1, hb = b - k + 1;
  if(lb < hb){
    REP(i, k) cout << a + i << endl;
    REP(i, k) cout << hb + i << endl;
  }
  else{
    REP(i, b - a + 1) cout << a + i << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n-1);i>=0;i--)
#define FOR(i,n,m) for(int i=n;i<=(int)(m);i++)
#define RFOR(i,n,m) for(int i=(int)(n);i>=m;i--)
#define all(x) (x).begin(),(x).end()
#define sz(x) int(x.size())
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
using namespace std;
int main(){
    int cnt=0;
    vector<pair<int,int>> ans;
    
    int n;
    cin>>n;
    vector<int> a(n);
    int max=-1,max_index=-1;
    int min=INF,min_index=-1;
    rep(i,n){
        cin>>a[i];
        if(a[i]<0 && a[i]<min){
            min=a[i];
            min_index=i;
        }
        else if(a[i]>=0 && a[i]>max){
            max=a[i];
            max_index=i;
        }
    }
    
    if(max!=-1 && min!=INF){
        if(abs(max)>=abs(min)){
            rep(i,n){
                if(i==max_index) continue;
                if(a[i]<0){
                    a[i]+=max;
                    ans.emplace_back(max_index,i);
                    cnt++;
                }
            }
        }
        else{
            rep(i,n){
                if(i==min_index) continue;
                if(a[i]>=0){
                    a[i]+=min;
                    ans.emplace_back(min_index,i);
                    cnt++;
                }
            }
        }
    }
    
    if(a[0]>=0){
        rep(i,n-1){
            if(a[i]>a[i+1]){
                a[i+1]+=a[i];
                ans.emplace_back(i,i+1);
                cnt++;
            }
        }
    }
    else{
        rrep(i,n-1){
            if(a[i]>a[i+1]){
                a[i]+=a[i+1];
                ans.emplace_back(i+1,i);
                cnt++;
            }
        }
    }
    
    
    cout<<cnt<<endl;
    for(auto p:ans){
        int x,y;
        tie(x,y)=p;
        cout<<x+1<<" "<<y+1<<endl;
    }
    
    //for(int x:a) cout<<x<<endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
long A, B, K, T, S; cin >> A >> B >> K;
if(A>=K){ T=A-K;S=B; }else if(B>=K-A){ T=0;S=B-(K-A); }else{ T=0;S=0; }
cout << T << " " << S << "\n";
}

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

struct sqrt_decomposition{
	using F = function<int(int, int)>;
	int n, sz, len;
	vector<int> v;
	vector<int> w;
	F f;
	int e;
	sqrt_decomposition(vector<int> _v, F _f, int _e): v(_v), f(_f), e(_e){
		n = v.size();
		sz = 1;
		while((sz+1) * (sz+1) < n) ++sz;
		len = n / sz;
		w.resize(len, e);
		for(int i=0; i<sz; ++i)
			for(int j=0; j<sz; ++j)
				if(i*sz + j < n)
					w[i] = f(w[i], v[i*sz + j]);
	}
	void point_set(int a, int x){
		v[a] = x;
		int b = a / sz;
		w[b] = e;
		for(int i=0; i<sz&&b*sz+i<n; ++i)
			w[b] = f(w[b], v[b*sz+i]);
	}
/*	void range_set(int a, int b, int x){
		while(a < b && a % sqrt_n != 0){
			v[a] = x;
			++a;
		}
		while(a + sqrt_n <= b){
			w[a / sqrt_n] = x;
			a += sqrt_n;
		}
		while(a < b){
			v[a] = x;
			++a;
		}
	}
*/	int point_get(int a){
		int b = a / sz;
		return f(w[b], v[a]);
	}
	int range_get(int a, int b){
		int res = e;
		while(a < b && a % sz != 0){
			res = f(res, v[a]);
			++a;
		}
		while(a + sz <= b){
			res = f(res, w[a / sz]);
			a += sz;
		}
		while(a < b){
			res = f(res, v[a]);
			++a;
		}
		return res;
	}
};

int main(){
//	cin.tie(0);
//	ios::sync_with_stdio(false);
	int n, q, inf = INT_MAX;
	cin >> n >> q;
	sqrt_decomposition sd(vector<int>(n, inf), [](int x, int y){return min(x, y);}, inf);
	while(q--){
		int c, x, y;
		cin >> c >> x >> y;
		if(c == 0){
			sd.point_set(x, y);
		}else{
			cout << sd.range_get(x, y+1) << "\n";
		}
	}
//	for(int i=0; i<n; ++i)
//		cout << i << " " << sd.v[i] << "\n";
//	for(int i=0; i<n/sd.sz; ++i)
//		cout << i << " " << sd.w[i] << "\n";
}


Measured memory_bytes: 3676
#include<bits/stdc++.h>
#define INF 0x7fffffff
using namespace std;
typedef long long ll;
int a,b,c,ans;
int main()
{
    cin>>a>>b>>c;
    cout<<max(a,max(b,c))-min(a,min(b,c))<<endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		int[]x = new int[5];
		int ans =0;
		for(int i=0; i<5; i++) {
			 x[i] = s.nextInt();
			if(x[i] == 0 ) {ans =i+1;}
		}
		System.out.println(ans);
	}

}
  

Measured memory_bytes: 35708
import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Scanner;
import java.util.Set;

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

		int numberOfSwitch = stdIn.nextInt();
		int numberOfLights = stdIn.nextInt();

		stdIn.nextLine();//改行のため

		Map<Integer, LightSwitch> switchMap = new LinkedHashMap<>();
		// set input
		for (int i = 1; i <= numberOfLights; i++) {
			switchMap.put(i, new LightSwitch(i, stdIn.nextLine()));
		}
		for (int i = 1; i <= numberOfLights; i++) {
			switchMap.get(i).setMod(stdIn.nextInt());
		}

		// execute
		int allSize = (int) Math.pow(2, numberOfSwitch);
		int cnt = 0;

		for (int i = 0; i < allSize; i++) {

			String boolStr = String.format("%" + numberOfSwitch + "s", Integer.toBinaryString(i)).replaceAll(" ", "0");

			if (canAllLightUp(switchMap, boolStr)) {
				cnt++;
			}
		}

		System.out.println(cnt);

		stdIn.close();
	}

	private static boolean canAllLightUp(Map<Integer, LightSwitch> switchMap, String boolStr) {
		for (LightSwitch swt : switchMap.values()) {
			if (!swt.canLightsUp(boolStr)) {
				return false;
			}
		}

		return true;
	}
}

class LightSwitch {
	private int switchId;
	private Set<Integer> useSwitchSet = new HashSet<>();
	private int mod;

	public LightSwitch(int switchId, String useSwitchStr) {
		this.switchId = switchId;

		String[] strArray = useSwitchStr.split(" ");

		for (int i = 1; i < strArray.length; i++) {
			useSwitchSet.add(Integer.parseInt(strArray[i]));
		}
	}

	public boolean canLightsUp(String switchArrayStr) {
		int cnt = 0;

		for (Integer switchId : useSwitchSet) {
			if (switchArrayStr.charAt(switchId - 1) == '1') {
				cnt++;
			}
		}

		return cnt % 2 == mod;

	}

	public int getMod() {
		return mod;
	}

	public void setMod(int mod) {
		this.mod = mod;
	}

	public int getSwitchId() {
		return switchId;
	}

}

Measured memory_bytes: 27732
n = gets.to_i
as = gets.split.map(&:to_i)

sums = []
sum = 0
total = as.sum
as.each_with_index do |a, i|
  sums << (total - sum) % (10**9+7)
  sum += a
end

ans = 0
(0..n-2).each do |i|
  ans += (as[i] * sums[i+1]) % (10**9+7)
end

puts ans % (10**9+7)

Measured memory_bytes: 29852
import sys

N, Y = map(int, input().split())

y = Y // 1000

for a in range(N+1):
    b = (y - N - 9 * a) // 4
    if a + b > N or b < 0:
        continue
    c = N - a - b
    if 10000 * a + 5000 * b + 1000 * c == Y:
        print(a, b, c)
        sys.exit(0)

print("-1 -1 -1")


Measured memory_bytes: 3060
#include<iostream>
using namespace std;
int main(){
  while(true){
    int n;
    int ages[7]={0,};
    cin >> n;
    if( n==0 )break;
    for(int i = 0; i < n; ++i){
      int age; cin >> age; if(age>=70)age=60;ages[age/10]++;
    }
    for(int i = 0; i < 7; ++i){
      cout << ages[i] << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 868
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <vector>

#define min(a, b) ( (a) < (b) ? (a) : (b) )
#define max(a, b) ( (a) > (b) ? (a) : (b) )
#define sz(x) (int)((x).size())
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define FOR(i, a, n, step) for (int (i) = (a); (i) < (n); (i) += (step))
#define FOREACH(it, v) for (auto (it) : (v))

using namespace std;

typedef unsigned long long ull;
typedef long long ll ;
typedef long double ld;
typedef pair <int, int> pii;
typedef vector <int> vi;

template <class T>
const bool is_impar(T x) {return (bool) (x & 1);}

int a, b;

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin >> a >> b;
    cout << max(a + b, max(a - b, a * b));

}


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

int main(){
    string s;
    vector<vector<int>> v(26);
    int a = -2, b = -2;

    cin >> s;
    for(int i = 0; i < s.length(); i++){
        v[s[i]-'a'].push_back(i);
    }

    for(int i = 0; i < 26; i++){
        if(v[i].empty())    continue;
        for(int j = 0; j < v[i].size()-1; j++){
            if((v[i][j+1]-v[i][j]+1)/2 < 2){
                a = v[i][j], b = v[i][j+1];
            }
        }
    }

    cout << a+1 << " " << b+1 << endl;

    return 0;
}

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

using namespace std;

#define all(v) (v).begin(), (v).end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, f, n) for(int i = (int)(f); i < (int)(n); i++)

typedef pair<int, int> P;

const int inf = 1 << 25;

struct edge
{
  int to, cost;
  edge(){}
  edge(int to, int cost):to(to), cost(cost){}
};

vector< vector<edge> > graph;
vector< vector<int> > mincost;

void dijkstra(int s)
{
  priority_queue<P, vector<P>, greater<P> > que;
  que.push(P(0, s));
  mincost[s][s] = 0;
  while(!que.empty()) {
    int cost, now;
    tie(cost, now) = que.top(); que.pop();
    if(mincost[s][now] < cost) continue;
    for(edge& e : graph[now]) {
      if(e.cost + cost < mincost[s][e.to]) {
	mincost[s][e.to] = e.cost + cost;
	que.push(P(mincost[s][e.to], e.to));
      }
    }
  }
}

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

  int N, R;
  cin >> N >> R;
  graph.resize(N);
  rep(i, R) {
    int s, t, d;
    cin >> s >> t >> d; s--, t--;
    graph[s].emplace_back(t, d);
    graph[t].emplace_back(s, d);
  }

  mincost.resize(N, vector<int>(N, inf));
  int maxdist = 0;
  rep(i, N) dijkstra(i);
  rep(i, N) reps(j, i+1, N) maxdist = max(maxdist, mincost[i][j]);

  vector<P> ep;
  rep(i, N) reps(j, i+1, N) {
    if(mincost[i][j] == maxdist) ep.emplace_back(i, j);
  }

  vector<int> ans;
  rep(i, N) {
    bool flag = true;
    for(auto& p : ep) {
      int s, t; tie(s, t) = p;
      if(mincost[s][i] + mincost[i][t] == maxdist) flag = false;
    }
    if(flag) ans.push_back(i+1);
  }
  
  cout << ans.size() << endl;
  rep(i, ans.size()) cout << ans[i] << endl;
  
  return 0;
}

Measured memory_bytes: 28240
#include<iostream>
#include<map>
#include<string>

int main()
{
    std::map<std::string, bool > dic ;

    std::string com ;
    std::string tex ;

    int n ;
    std::cin >> n ;

    for( int i = 0 ; i < n ; ++i )
    {
        std::cin >> com >> tex ;
        if( com == "insert" )
        {
            dic[tex] = 1 ;
        }
        else
        {
            if( dic[tex] )
            {
                std::cout << "yes" << std::endl ;
            }
            else
            {
                std::cout << "no" << std::endl ;
            }
        }
    }
}




Measured memory_bytes: 52568
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rep2(i,n) for (int i = 1; i < (n); ++i)
using namespace std;
typedef long long ll;
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll N, A, B, C, D, E;
    cin >> N >> A >> B >> C >> D >> E;
    ll mn = min ({ A, B, C, D, E });
    cout << (N + (mn - 1)) / mn +  4 << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static int N;
	public static int R;

	public static void main(String[] args) {
		init();
		if (N >= 10) {
			System.out.println(R);
		} else {
			System.out.println((R + 100 * (10 - N)));
		}

	}

	public static void init() {
		Scanner sc = new Scanner(System.in);
		try {
			N = sc.nextInt();
			R = sc.nextInt();
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}


Measured memory_bytes: 21844