akhauriyash/Code-Regression huggingface dataset:
import sys

input = sys.stdin.readline


def main():
    n = int(input())
    A = [None] * n
    for i in range(n):
        A[i] = int(input())

    G = []
    g = 1
    while True:
        G.append(g)
        g = 3 * g + 1
        if g >= n:
            break
    G = G[::-1]
    m = len(G)
    cnt = 0

    for g in G:
        for i in range(g, n):
            v = A[i]
            j = i - g
            while j >= 0 and A[j] > v:
                A[j + g] = A[j]
                j -= g
                cnt += 1
            A[j + g] = v

    print(m)
    print(" ".join(map(str, G)))
    print(cnt)
    print("\n".join(map(str, A)))


if __name__ == "__main__":
    main()



Measured memory_bytes: 125976
#include<map>
#include<list>
#include<cmath>
#include<stack>
#include<queue>
#include<vector>
#include<cstring>
#include<iostream>
#include<functional>
#include<algorithm>
using namespace std;
#define LOOP1(n) for(int i=0;i<n;i++)
#define LOOP2(n) for(int j=0;j<n;j++)
#define LOOP3(n) for(int k=0;k<n;k++)
#define Psi pair<string,int>
#define Pis pair<int,string>
#define Pii pair<int,int>
// ??????????????????memset(a,0,sizeof(a));
// ?´???°?????? if(x<2)return0;else if(x==2)return1;if(x%2==0)return0;for(i=3;i*i<=x;i+=2){if(x%i==0)return0;}return1;}p440
//vector size();push_back(x);pop_back();begin();end();insert(p,x);erase(p);clear();
//stack  size();top();pop();push(x);emtpy();
//queue  size();front();pop();push(x);empty();
//priority_queue< ??? , ??\???????????? , less<???> or greater<???> > <int , vector<int> , greater<int> >
/*******************************************/
/* vector<int> v     vector<int> v[100]    */
/* ???[1]          ?????? [1,1][1,2][1,3]     */
/*   [2]               [2,1][2,2][3,3]     */
/*   [3]               [3,1][2,2][3,3]     */
/*******************************************/
static const int MAX = 10000;
static const int WHITE = 1;
static const int GRAY = 2;
static const int BLACK = 3;
static const int INFTY = (1 << 21);
int d[MAX]; int color[MAX]; 
int main(){
	vector<pair<int, int> > v[MAX];
	int n, k, uu;
	cin >> n;
	for (int i = 0; i < n; i++){
		cin >> uu >> k;
		for (int j = 0; j < k; j++){
			Pii p;
			cin >> p.first >> p.second;
			v[i].push_back(p);
		}
	}
	for (int i = 0; i < n; i++){
		d[i] = INFTY;
		color[i] = WHITE;
	}
	d[0] = 0; int u = 0;
	while (1){
		int mincost = INFTY;
		LOOP1(n){
			if (color[i] != BLACK && mincost > d[i]){
				mincost = d[i];
				u = i;
			}
		}
		if (mincost == INFTY) break;
		color[u] = BLACK;
		for (int j = 0; j < v[u].size(); j++){
			if (color[v[u][j].first] != BLACK && d[u] + v[u][j].second < d[v[u][j].first]){
				color[v[u][j].first] = GRAY;
				d[v[u][j].first] = d[u] + v[u][j].second;
			}
		}
	}
	LOOP1(n){
		cout << i << ' ' << d[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 6188
mod = 998244353
n, k = map(int, input().split())
left = []
right = []
for _ in range(k):
  l, r = map(int, input().split())
  left.append(l)
  right.append(r)
dp = [0] * (n + 1)
dp[1] = 1
for i in range(2, n+1):
  for j in range(k):
    dp[i] += dp[max(0, i - left[j])] - dp[max(0, i - right[j] - 1)]
    dp[i] %= mod
  dp[i] = (dp[i-1] + dp[i]) % mod
print((dp[n] - dp[n-1]) % mod)

Measured memory_bytes: 16780
class Bit(val size: Int, val mod: Long) {
    private val array = LongArray(size){0}
    fun add(position: Int, value: Long): Unit {
        var pos = position
        while (pos < size){
            array[pos] = (array[pos] + value) % mod
            pos += pos.inv() and (pos + 1)
        }
    }
    operator fun get(position: Int): Long {
        var pos = position
        var result = 0L
        while (pos >= 0) {
            result = (result + array[pos]) % mod
            pos -= pos.inv() and (pos + 1)
        }
        return result
    }
}
fun main() {
    val MOD = 998244353L
    val (n, k) = readLine()!!.trim().split(' ').map(String::toInt)
    val ranges = List(k){
        val (left, right) = readLine()!!.trim().split(' ').map(String::toInt)
        left to right
    }
    val bit = Bit(n, MOD)
    bit.add(0, 1)
    bit.add(1, MOD - 1)
    for (i in 0 until n) {
        val current = bit[i]
        for ((left, right) in ranges) {
            if (i + left in 0 until n) {
                bit.add(i + left, current)
            }
            if (i + right + 1 in 0 until n) {
                bit.add(i + right + 1, MOD - current)
            }
        }
    }
    println((bit[n - 1] + MOD) % MOD)
}

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

long int X, Y;
int main(){
    cin >> X >> Y;
    long int cnt = 1;
    long int prev = X;
    while(true){
        long int next = 2 * prev;
        if (next > Y){
            break;
        }
        cnt ++;
        prev = next;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
typedef pair<ll,ll> P;
#define fi first
#define se second
#define all(v) (v).begin(),v.end()
const ll inf=(1e18);
const ll mod=1000000007;
const ll mod2=998244353;
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c/gcd(c,d)*d;}
//ios_base::sync_with_stdio(false);
//cin.tie(NULL);
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
map<int,int> mp;
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n;
cin>>n;
vector<int> a(n);
for(int i=0;i<n;i++){
    cin>>a[i];
    mp[a[i]]++;
}
int sum=0,eat=0;
bool ok=true;
for(auto p:mp){
    if(p.se==1)sum++;
    else{
        if(p.se>2){
                  if((p.se-3)%2==0)sum++;
                  else eat+=2;
            }
        else eat+=2;
        if(eat>=3){
            sum+=2;
            eat=0;
        }
    }
}
cout<<sum<<endl;
}

Measured memory_bytes: 5376
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)

bool solve(const string& s) {
  for (const auto e : s) {
    switch (e) {
      case 'N':
        if (s.find("S") == string::npos)
          return false;
        break;
      case 'S':
        if (s.find("N") == string::npos)
          return false;
        break;
      case 'W':
        if (s.find("E") == string::npos)
          return false;
        break;
      case 'E':
        if (s.find("W") == string::npos)
          return false;
        break;
      default:
        break;
    }
  }
  return true;
}

int main() {
  string s;
  cin >> s;
  if (solve(s))
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i,n) for(ll i=0;i<(n);i++)
#define INF 1e9
#define MOD 1000000007
#define All(x) (x).begin(),(x).end()
#define Cout(x) cout << (x) << endl
typedef long long ll;
using namespace std;

int main(void){
  int N,M;
  cin>>N>>M;
  if(N==M)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}








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

using namespace std;

#define int long long
#define endl "\n"

const long long INF = (long long)1e18;
const long long MOD = (long long)1e9 + 7; 

string yn(bool f){return f?"Yes":"No";}
string YN(bool f){return f?"YES":"NO";}


int check(string &s, int k){
	vector<int> sum(s.size()+1, 0);
	
	if(k <= 0) return true;
	if(k > s.size()) return false;
	
	for(int i = 0; i < (int)s.size() - k + 1; i++){
		if((s[i] - '0' + sum[i])%2){
			sum[i]++;
			sum[i+k]--;
		}
		sum[i+1] += sum[i];
	}
	
	for(int i = (int)s.size() - k + 1; i < s.size(); i++){
		sum[i+1] += sum[i];
	}
	
	for(int i = 1; i < k; i++){
		if((s[i] - '0' + sum[i])%2) return false;
	}
	
	return true;
}

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);
	
	string s;
	
	cin>>s;
	
	// for(int i = 1; i <= s.size(); i++){
		// cout<<check(s,i)<<endl;
	// }
	
	int l = 1, r = s.size()+1, m;
	
	while(l + 1 < r){
		m = (l+r)/2;
		
		if(check(s,m)){
			l = m;
		} else {
			r = m;
		}
	}
	
	cout<<l<<endl;
	
	return 0;
}

Measured memory_bytes: 1232
def positive(n):
  for i in range(n-1):
    print(i+1,i+2)
def negative(n):
  for i in range(n-1):
    print(n-i,n-i-1)
N=int(input())
A=list(map(int,input().split()))
mina=min(A)
minin=A.index(mina)
maxa=max(A)
maxin=A.index(maxa)
if mina>=0:
  print(N-1)
  positive(N)
elif maxa<=0:
  print(N-1)
  negative(N)
elif maxa+mina>=0:
  print(2*N-1)
  for i in range(N):
    print(maxin+1, i+1)
  positive(N)
else:
  print(2*N-1)
  for i in range(N):
    print(minin+1, i+1)
  negative(N)

Measured memory_bytes: 3064
#include <stdio.h>
int main(void) {
	while(1){
		int n;
		scanf("%d",&n);
		if(n==0) break;
		int i,p[n];
		for(i=0;i<(n/4);i++){
			scanf("%d",&p[i]);
		}
		int sum=0;
		for(i=0;i<(n/4);i++){
		    sum=sum+p[i];
		}
		printf("%d\n",sum);
	}
	return 0;
}


Measured memory_bytes: 2032
#include <iostream>
#include <cstdlib>
#include <cstring>
using namespace std;

int DFS(bool path[110][110],int begin[],int end[],int v,int n,int t){
    t++;
    begin[v]=t;
    for(int i=0;i<n;i++){
        if(path[v][i]&&begin[i]==0){
            t=DFS(path,begin,end,i,n,t);
        }
    }
    t++;
    end[v]=t;
    return t;
}

int main(void){
    int n,u,k,i,j,x,t;
    bool path[110][110];
    int begin[110],end[110];
    memset(path,0,sizeof(path));
    memset(begin,0,sizeof(begin));
    cin>>n;
    for(i=0;i<n;i++){
        cin>>u>>k;
        u--;
        for(j=0;j<k;j++){
            cin>>x;
            x--;
            path[u][x]=true;
        }
    }
    
    t=0;
    for(i=0;i<n;i++){
        if(begin[i]==0){
            t=DFS(path,begin,end,i,n,t);
        }
    }
    
    for(i=0;i<n;i++){
        cout<<i+1<<" "<<begin[i]<<" "<<end[i]<<endl;
    }
    
    return 0;
}


Measured memory_bytes: 3120
h,w=map(int,input().split())
m=[list(input())for _ in range(h)]
m[0][0]=1
for i in range(h):
    for j in range(w):
        if m[i][j]==".":
            a,b=m[i-1][j],m[i][j-1]
            m[i][j]=(a if type(a)==int else 0)+(b if type(b)==int else 0)
print(m[-1][-1]%(10**9+7))

Measured memory_bytes: 157420
// https://atcoder.jp/contests/agc018/tasks/agc018_a
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <map>
#include <unordered_map>
#include <stack>
#include <queue>
#include <set>
#include <unordered_set>
#include <bitset>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
#define REP(i, n) for(size_t i = 0; i < (n); ++i)

template <class T>
T calcgcd(T x, T y)
{
    if (x < y)
    {
        std::swap(x, y); //小さい方をyとする
    }
    T r = x % y;
    while( r != 0 )
    {
        x = y;
        y = r;
        r = x % y;
    }
    return y;
}

int main()
{
    int N, K;
    cin >> N >> K;
    int minval = numeric_limits<int>::max(), maxval = -1;
    vector<int> A(N);
    REP(i, N) 
    {
        cin >> A[i];
        minval = min(minval, A[i]);
        maxval = max(maxval, A[i]);
        if (K == A[i])
        {
            cout << "POSSIBLE\n";
            return 0;
        }
    }
    if (A.size() == 1 || K > maxval)
    {
        cout << "IMPOSSIBLE\n";
        return 0;
    }
    int c = calcgcd(A[0], A[1]);
    for (int i = 2; i < N; ++i)
    {
        c = calcgcd(c, A[i]);
    }
    if (1 == c)
    {
        cout << "POSSIBLE\n";
        return 0;
    }
    for (int i = maxval; i >= 1; i -= c)
    {
        if (K == i)
        {
            cout << "POSSIBLE\n";
            return 0;
        }
    }
    for (int i = maxval; i >= 1; i -= c)
    {
        if (K == i)
        {
            cout << "POSSIBLE\n";
            return 0;
        }
    }
    cout << "IMPOSSIBLE\n";
    
    return 0;
}

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

class MainClass
{
    static void Main()
    {
        var HWK = Console.ReadLine().Split().Select(int.Parse).ToArray();
        int H = HWK[0], W = HWK[1], K = HWK[2];
        var c = new bool[H, W];
        for (int i = 0; i < H; i++)
        {
            var line = Console.ReadLine();
            for (int j = 0; j < W; j++)
            {
                c[i, j] = line[j] == '#';
            }
        }

        int ans = 0;
        for (int i = 0; i < (1<<H); i++)
        {
            for (int j = 0; j < (1<<W); j++)
            {
                int count = 0;
                for (int a = 0; a < H; a++)
                {
                    for (int b = 0; b < W; b++)
                    {
                        if (c[a, b])
                        {
                            if ((i & (1 << a)) > 0 && (j & (1 << b)) > 0)
                                count++;
                        }
                    }
                }

                if (count == K) ans++;
            }
        }
        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 28236
#include <iostream>
#include <sstream>
#include <algorithm>
#include <functional>
#include <iterator>
#include <numeric>
#include <cstdint>
#include <cmath>
#include <bitset>
#include <string>
#include <list>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>

#define N_TIMES(i, n)     for ( uint64_t i = 0;     i <  n; ++i )
#define N_TIMES_REV(i, n) for (  int64_t i = n - 1; i >= 0; --i )

std::string N;
uint64_t D;

uint64_t dp(uint64_t d, uint64_t p, bool f, bool z, std::bitset<3> deg)
{
  if (d == D) {
    return deg.all() ? 1 : 0;
  }
  
  uint64_t X = f ? N[d] - '0' : 9, S = 0;
  for (uint64_t x = 0; x <= X; ++x) {
    if (z && x == 0) {
      bool g = f && (x == X);
      S += dp(d + 1, p, g, true, deg);
    } else if (x == 3 || x == 5 || x == 7) {
      std::bitset<3> new_deg(deg);
      if (x == 3) new_deg.set(0);
      if (x == 5) new_deg.set(1);
      if (x == 7) new_deg.set(2);
      
      uint64_t q = 0;
      if (x == 3) q = p * 10 + x;
      if (x == 5) q = p * 10 + x;
      if (x == 7) q = p * 10 + x;
      
      bool g = f && (x == X);
      S += dp(d + 1, q, g, false, new_deg);
    }
  }
  
  return S;
}

int main(int argc, char **argv)
{
  std::cin >> N;
  
  D = N.size();
  
  uint64_t S = dp(0, 0, true, true, std::bitset<3>(0));
  
  std::cout << S << std::endl;
  
  return 0;
}

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

int main() {
  int n;
  cin>>n;
  int s1[n+1],s2[n+1];
  s1[0]=0;
  s2[0]=0;
  rep(i,n){
    int s;
    cin>>s;
    s1[i+1]=s1[i]+s;
  }
  rep(i,n){
    int s;
    cin>>s;
    s2[i+1]=s2[i]+s;
  }
  int max_ans=0;
  rep(i,n){
    int ans=0;
    ans+=s1[i+1]-s1[0]+s2[n]-s2[i];
    max_ans=max(max_ans,ans);
  }
  cout<<max_ans<<endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i=0;i<((int)(n));i++)
#define reg(i,a,b) for(int i=((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i=((int)(n))-1;i>=0;i--)
#define ireg(i,a,b) for(int i=((int)(b));i>=((int)(a));i--)
typedef long long int lli;
typedef pair<int,int> mp;
#define fir first
#define sec second
#define IINF INT_MAX
#define LINF LLONG_MAX
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
#define pque(type) priority_queue<type,vector<type>,greater<type> >
#define memst(a,b) memset(a,b,sizeof(a))
#define iter(v,ite) for(auto ite=(v).begin();ite!=(v).end();ite++)
#define mimunum(v,x) distance((v).begin(),lower_bound((v).begin(),(v).end(),x))

lli ds[100005];

#define MOD ((lli)(998244353LL))

lli mop(lli p,lli q){
	lli res=1;
	lli b=p;
	while(q){
		if(q & 1)res = (res*b)%MOD;
		q /= 2;
		b = (b*b)%MOD;
		//printf("%lld %lld\n",q,b,res);
	}
	
	return res;
}

map<int,lli> ms;

int main(void){
	int n;
	scanf("%d",&n);
	lli ans=1;
	rep(i,n){
		lli v;
		scanf("%lld",&v);
		if(i==0){
			if(v!=0)ans=0;
		}
		else{
			ms[v] = ms[v] + 1;
		}
	}
	
	vector<pair<int,lli> > kvs;
	iter(ms,ite){
		kvs.push_back(*ite);
	}
	sort(kvs.begin(),kvs.end());
	
	lli lv = 1;
	int lk = 0;
	iter(kvs,ite){
		int k = ite->first;
		lli v = ite->second;
		//printf("%d %lld\n",k,v);
		if(k != lk + 1){
			ans = 0;
			break;
		}
		ans = (ans * mop(lv,v)) % MOD;
		lv = v;
		lk = k;
	}
	
	//printf("%lld\n",mop(2,11));
	printf("%lld\n",ans);
	return 0;
}






Measured memory_bytes: 8696
#include <cstdio>
#define For(i,j,k) for(int i=j;i<=k;i++)
#define Dow(i,j,k) for(int i=j;i>=k;i--)
#define LL long long
using namespace std ;
inline int read() {
	int x = 0 , f = 1 ;
	char ch = getchar() ;
	while(ch<'0'||ch>'9') { if(ch=='-') f = -1 ; ch = getchar() ; }
	while(ch>='0'&&ch<='9') { x = x * 10+ch-48 ; ch = getchar() ; }
	return x * f ;
}

const int N = 1e5+11,mod = 1e9+7;
LL ans1,ans2,sum;
int n;
int a[N];

inline LL abs(LL x) {
	if(x<0) x=-x;
	return x;
}
inline LL min(LL x,LL y) {
	if(x<y) return x;
	return y;
}

int main() {
	n=read();
	For(i, 1, n) a[i]=read();
	For(i, 1, n) {
		sum= sum+a[i];
		if(i%2==1) 
			if(sum<=0) {
				ans1=ans1 + abs(1-sum);
				sum=1;
			}
			else {}
		else 
			if(sum>=0) {
				ans1=ans1 + abs(-1-sum);
				sum=-1;
			}
	}
	
	sum = 0;
	For(i, 1, n) {
		sum = sum+a[i]; 
		if(i%2==0) 
			if(sum<=0) {
				ans2=ans2 + abs(1-sum);
				sum=1;
			}
			else {}
		else 
			if(sum>=0) {
				ans2=ans2 + abs(-1-sum);
				sum=-1;
			}
	}
	printf("%lld\n",min(ans1,ans2));
}






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

#define int long long int
#define rep(a,b,c) for(int a=b;a<c;a++)
#define repm(a,b,c) for(int a=(b-1);a>=c;a--)
#define pb push_back
#define str string
#define sf(a) scanfs("%d",&a)
#define pb push_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) (v).begin(), (v).end()

using namespace std;

const int INF = 1e18 + 9;
const int Mod = 1e9 + 7;
inline int replac(str s){double ans=0;rep(i,0,s.length()){ans+=(s[i]-'0')*pow(10,s.length()-i-1);}return (int)ans;}
inline string numstr(int m){str s="";while(m>0){char c;int a=m/10;if(a>0)a=m%(a*10);else a=m;c=(char)('0'+a);s+=c;m/=10;}str st="";for(int i=s.size()-1;i>=0;i--){st+=s[i];}return st;}
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef vector<pii> vii;
vector<int> load[100001];
vi lo[100001];
vi ki;
int kiki[100001];
int cost[100001];
///(A->to)=cost
struct edge { int to, cost; };
///pii//first...???????????¢///second...????????????
int V;
const int MAX_V = 100001;//?¶??????°!!
vector<edge> G[MAX_V];
int d[MAX_V];

void dijkstra(int s){
    priority_queue<pii, vector<pii>, greater<pii> > que;
    rep(i,0,MAX_V)d[i]=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;
        rep(i,0,G[v].size()){
            edge e = G[v][i];
            //cout << "c" << d[e.to] << " " << d[v]+e.cost << endl;
            if(d[e.to] > d[v] + e.cost) {
                d[e.to] = d[v] + e.cost;
                que.push(pii(d[e.to], e.to));
            }
        }
    }
}
signed main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    rep(i,0,100001){cost[i]=0;kiki[i]=0;}
    int n,m,k,s;cin >> n >> m >> k >> s;
    int pco,qco;cin >> pco >> qco;
    rep(j,0,k){
        int c;
        cin >> c;
        ki.pb(c);
        kiki[c]=1;
    }
    rep(i,0,m){
        int x,y;
        cin >> x >> y;
        if(!kiki[y])load[x].pb(y);
        if(!kiki[x])load[y].pb(x);
    }
    queue<pii> que;
    for(int v:ki){
        // cout << v << endl;
        bool used[100001]={false};
        cost[v]=INF;
        que.push(mp(v,s));
        while(!que.empty()){
            pii q=que.front();que.pop();
            int pla=q.first;int num=q.second;
            if(used[pla])continue;
            used[pla]=true;
            for(int va: load[pla]){
            //    cout << pla<<"<-"<<va << endl;
                if(cost[va]!=INF)cost[va]=qco;
                if((num-1)>0)que.push(mp(va,num-1));
            }
        }
    }
    rep(i,1,n+1){
        if(cost[i]==0)cost[i]=pco;
     //   cout << i << "="<< cost[i] << endl;
    }

    rep(i,1,n+1){
        rep(j,0,load[i].size()){
            int a=load[i][j];
            if(cost[a]==INF)continue;
            edge e;
            e.to=a;e.cost=cost[a];
            G[i].pb(e);
            //cout << e.to << "<-" <<  i << "=" <<e.cost << endl;
        }
    }
    dijkstra(1);
    cout << d[n]-cost[n] << endl;
    return 0;
}

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

int main() {
  int n;
  string s;
  cin >> n >> s;
  int ans = 1;
  for (int i = 1; i < n; ++i) {
    if (s[i] != s[i-1]) ans++;
  }
  cout << ans << endl;
  return 0;
}

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

#define lint long long
#define P pair<int, int>
#define LLP pair<long long, long long>
#define REP(i, x, n) for(int i = (x), i##_len = (int)(n) ; i < i##_len ; ++i)
#define rep(i, n) for(int i = 0, i##_len = (int)(n) ; i < i##_len ; ++i)
#define repr(i, n) for(int i = (int)(n) - 1 ; i >= 0 ; --i)
#define SORT(x) sort((x).begin(), (x).end())
#define SORT_INV(x) sort((x).rbegin(), (x).rend())

const int IINF = 1e9 + 100;
const long long LLINF = 2e18 + 129;
const long long MOD = 1e9 + 7;
const int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
const int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};
const double EPS = 1e-8;

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

    int n;
    cin >> n;

    vector<int> t(n);
    rep(i, n){
        cin >> t[i];
    }
    SORT_INV(t);

    vector<int> v;
    for(int i = 1 ; i * i <= t[0] ; ++i){
        if(t[0] % i == 0){
            v.emplace_back(i);
            v.emplace_back(t[0] / i);
        }
    }
    SORT(v);

    int ans = 0;
    REP(i, 1, n){
        auto it = lower_bound(v.begin(), v.end(), t[i]);
        ans += *it - t[i];
    }

    cout << ans << endl;

    return 0;
}


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

typedef long long ll;
#define ar array
#define vi vector<int>
#define vvi vector<vector<int>>
#define vll vector<long long>
#define fork(i, n) for (ll i = 0; i < (n); i++)
#define forn for (ll i = 0; i < (n); i++)
#define fori(i, k, n) for (ll i = k; i < (n); i++)
#define all(x) (x).begin(), (x).end()
#define en '\n'
#define FILL(x, v) memset(x, v, sizeof(x))
#define pb push_back
#define fast                     \
	ios::sync_with_stdio(false); \
	cin.tie(NULL);               \
	cout.tie(NULL);

template <typename A, typename B>
inline void chmin(A &a, B b)
{
	if (a > b)
		a = b;
}
template <typename A, typename B>
inline void chmax(A &a, B b)
{
	if (a < b)
		a = b;
}
template <typename T>
void print(vector<T> &a)
{
	for (int i = 0; i < a.size(); i++)
		cout << a[i] << ' ';
	cout << en;
}
template <typename T>
void print(deque<T> &a)
{
	for (int i = 0; i < a.size(); i++)
		cout << a[i] << ' ';
	cout << en;
}
template <typename T>
void print(vector<vector<T>> &a)
{
	for (int i = 0; i < a.size(); i++)
	{
		for (int j = 0; j < a[i].size(); j++)
			cout << a[i][j] << ' ';
		cout << en;
	}
}

int main()
{
	fast;
	ll n;
	cin >> n;
	string a;
	while (n > 26)
	{
		int cur = n % 26;
		if (cur == 0)
			cur = 26;
		a += (char(cur + 96));
		n -= cur;
		n /= 26;
	}
	a += char(n + 96);
	reverse(a.begin(), a.end());
	cout << a << en;
}

Measured memory_bytes: 3672
//
//  main.c
//  Practice
//
//  Created by hoshino on 2015/10/19.
//  Copyright ?? 2015??´ hoshino. All rights reserved.
//

#include <stdio.h>

int main(void) {
    int a,b,c;
    
    scanf("%d %d %d", &a,&b,&c);
    if(a<b && b<c){
        printf("Yes\n");
    }else
    {printf("No\n");
    }
    
    // insert code here...
    
    return 0;
}

Measured memory_bytes: 580
#include<bits/stdc++.h>
#define ll long long int
#define ull unsigned long long 
#define mod 1000000007;
using namespace std;
int main()
{
     ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;
    cin>>n;
    if(n==1)
    {
        cout<<"Yes";
        return 0;
    }
    ll arr[n];
    for(int i=0;i<n;i++)
    cin>>arr[i];
    for(int i=n-2;i>=0;i--)
    {
        if(arr[i]<=arr[i+1])
        continue;
        else
        {
            arr[i]-=1;
            if(arr[i]<=arr[i+1])
            continue;
            else
            {
                cout<<"No";
                return 0;
            }
        }
    }
    cout<<"Yes";

    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pii  pair<int,int>
#define vpii vector<pii>
#define vll  vector<ll>
#define vi  vector<int>
#define pb push_back
#define f  first
#define s  second

int main() {

    
    map<ll,ll> mp;
    
    ll n;
    cin>>n;
    mp[n]++;
    ll ct=1;
    while(1){
    if(n%2==0){
        ct++;
        mp[n/2]++;
        n = n/2;
    }
    else
      {
          ct++;
         mp[(3*n)+1]++;
      n = 3*n+1;
      }
      if(mp[n]>1)
        break;
    }
    cout<<ct;
	return 0;
}

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

typedef long long ll;

// static const int MAX = 1e6;
// static const int NIL = -1;
// static const ll INF = 1<<21;
// static const ll MOD = 1e9 + 7;

bool compPair(const pair<int, int>& arg1, const pair<int, int>& arg2) {
    return arg1.first > arg2.first;
}

int main(void) {
    int n;
    cin >> n;

    int t=0, x=0, y=0;
    int ttmp, xtmp, ytmp;
    for(int i=0;i<n;i++) {
        cin >> ttmp >> xtmp >> ytmp;
        if((ttmp%2!=(xtmp+ytmp)%2)||(abs(x-xtmp)+abs(y-ytmp))>abs(t-ttmp)) {
            cout << "No" << endl;
            return 0;
        }
        t = ttmp;
        x = xtmp;
        y = ytmp;
    }

    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;
#define IOS ios::sync_with_stdio(false)
typedef long long ll;
const int maxn = 2e5 + 5;
const int mod = 1e9 + 7;
ll sum[maxn], arr[maxn];
void solve() {
	int n;
	cin >> n;
	for (int i = 1; i <= n; ++i) {
		cin >> arr[i];
		sum[i] = (sum[i - 1]+ arr[i]);
	}
	ll ans = 0;
	for (int i = 1; i <= n; ++i) {
		ans = (ans+ arr[i] * ((sum[n] - sum[i]) % mod) % mod) % mod;
	}
	cout << ans << endl;
}
int main() {
	IOS;
	solve(); 
	return 0;
}


Measured memory_bytes: 6752
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstdio>
using namespace std;
#define MAX 100010

int main(){
	int a[MAX], b[MAX], c[MAX], n;
	while(cin >> n, n){
		fill(a, a+MAX, 0);
		fill(b, b+MAX, 0);
		int x, w = 0, d = 0;
		
		int flag;
		for(int i = 1;i <= n;i++){
			cin >> x;c[i] = x;
			if(i == 1)flag = x;
			
			if(i%2 == 0){	//??¶??°
				if(x && !c[i-1]){
					a[w--] = 0;
					b[d--] = 0;
					if(w == -1)w = 0;
					if(d == -1)d = 0;
				}
				if(!x && c[i-1]){
					b[d--] = 0;
					a[w--] = 0;
					if(w == -1)w = 0;
					if(w == -1)d = 0;
				}
			}
			if(x){if(flag)d++, flag = 0;b[d] = i;}
			if(!x){if(!flag)w++, flag = 1;a[w] = i;}
		}
		
		int ans = 0;
		if(a[1] < b[1]){
			ans = a[1];
			for(int i = 2;i <= w;i++)ans += a[i] - b[i-1];
		}else for(int i = 1;i <= w;i++)ans += a[i] - b[i];
		cout << ans << endl;
		
	}
	
	return 0;
}

Measured memory_bytes: 4252
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;
template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}
int search(double ans, int p, int q, int a, int n, int cnt, int ma, double add, int mul, double now) {

  if(add > abs(ans - now) + eps || n == cnt) {
    return abs(ans - now) < eps;
  }
  
  int res = 0;
  for(int i=min(ma, a/mul);i>0;--i) {
    add = 1.0 / i;
    res += search(ans, p, q, a, n, cnt+1, i, add, mul * i, now + add);
  }
  return res;
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  while(1) {
    int p, q, a, n; cin >> p >> q >> a >> n;
    if(p == 0 && q == 0) break;
    double ans = (double)p / q;
    double add = 1.0/5000;
    cout << search(ans, p, q, a, n, 0, 5000, add, 1, 0) << endl;
  }
}


Measured memory_bytes: 3164
#include<bits/stdc++.h>
using namespace std;
int main()
{

    int a;
    int n,tmp,sum=0,ma=0,f=0;
    cin>>a;
    cin>>n;
    a-=1;
    tmp=n;
    //cout<<tmp<<endl;
    while(a--)
    {
        cin>>n;
        if(tmp>=n)
        {
            sum+=1;
            //cout<<"sum " <<sum<<endl;
           // f=0;
            if(sum>ma)
            ma=sum;
        }
        else
        {
            if(sum>ma)
            ma=sum;
            //cout<<"sum = "<<sum<<" ma = "<<ma<<endl;
            sum=0;
            //f=1;

        }
        tmp=n;
        //cout<<tmp<<endl;

    }
    cout<<ma<<endl;

}


Measured memory_bytes: 256
import math
n = int(raw_input())
N = []
for i in xrange(n):
    N.append(int(raw_input()))

def isPrime(x):
    if x == 2:
        return True

    if x < 2 or x % 2 == 0:
        return False

    i = 3
    while i <= math.sqrt(x):
        if x % i == 0:
            return False
        i += 2

    return True

def main():
    cnt = 0
    for x in N:
        if isPrime(x):
            cnt += 1
    print cnt

    return 0

main()

Measured memory_bytes: 6628
#include<bits/stdc++.h>
#define rint register int
using namespace std;
inline int read(){
	int s=0,f=1;char c=getchar();
	while(c<'0'||c>'9'){if(c=='-')f=0;c=getchar();}
	while(c>='0'&&c<='9')s=(s<<1)+(s<<3)+c-48,c=getchar();
	return f?s:-s;
}
int n,h,ind[410],outd[410];
int fa[410],vis[410];
int get_fa(int x){
	return fa[x]==x?x:fa[x]=get_fa(fa[x]);
}
int main(){
//	freopen("jigsaw.in","r",stdin);
//	freopen("jigsaw.out","w",stdout);
	n=read(); h=read();
	for(rint i=1;i<=h+h;++i) fa[i]=i;
	for(rint i=1;i<=n;++i){
		int a=read(),b=read(),c=read(),d=read();
		int x=c>0?c:-a,y=d>0?-d:b;
		x+=h; y+=h;
		if(get_fa(x)!=get_fa(y)) fa[get_fa(x)]=get_fa(y);
		++ind[y]; ++outd[x];
	}
	for(rint i=-h;i<0;++i)
		if(ind[i+h]>outd[i+h]){
			printf("NO\n");
			return 0;
		}
	for(rint i=1;i<=h;++i)
		if(ind[i+h]<outd[i+h]){
			printf("NO\n");
			return 0;
		}
	for(rint i=0;i<=h+h;++i)
		if(ind[i]!=outd[i]) vis[get_fa(i)]=true;
    for(rint i=0;i<=h+h;++i) 
		if(ind[i]&&outd[i]&&!vis[get_fa(i)]){
			printf("NO\n");
			return 0;
		}
	printf("YES\n");
	return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define all(v) ((v).begin()),((v).end())
#define ll long long
#define fastIO cout << fixed << setprecision(12), ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr)
double const EPS = 1e-9, PI = acos(-1);
const int N = 4e2 + 9, M = 1e5 + 9, OO = 1e9 + 7, MOD = 1e9 + 7;
const ll inf = 1e18;

ll mem[N][N], arr[N], pre[N];

ll solve(int start, int end) {
  if(start >= end)
    return 0;
  ll& ret =mem[start][end];
  if(~ret)
    return ret;
  ret = inf;
  for (int i = start; i < end; ++i) {
    ll c1 = solve(start, i);
    ll c2 = solve(i+1, end);
    ll sumL = pre[i] - pre[start - 1], sumR = pre[end] - pre[i];
    ret = min(ret, c1 + c2 + sumL + sumR);
  }
  return ret;
}

int main() {
  fastIO;
#ifdef LOCAL
  freopen("input.in", "rt", stdin);
#endif
  memset(mem, -1, sizeof mem);
  int n;
  cin >> n;
  for (int i = 1; i <= n; ++i)
    cin >> arr[i], pre[i] += pre[i-1] + arr[i];
  cout << solve(1, n);
  return 0;
}


Measured memory_bytes: 1664
#include <bits/stdc++.h>
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define rep(i,N) for(long long i = 0; i < (long long)(N); i++)
#define repr(i,N) for(long long i = (long long)(N) - 1; i >= 0; i--)
#define rep1(i,N) for(long long i = 1; i <= (long long)(N) ; i++)
#define repr1(i,N) for(long long i = (N) ; (long long)(i) > 0 ; i--)
#define each(x,v) for(auto& x : v)
#define all(v) (v).begin(),(v).end()
#define sz(v) ((int)(v).size())
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) long long __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
using namespace std; void solve();
using ll = long long; template<class T = ll> using V = vector<T>;
using vi = V<int>; using vl = V<>; using vvi = V< V<int> >;
constexpr int inf = 1001001001; constexpr ll infLL = (1LL << 61) - 1;
struct IoSetupNya {IoSetupNya() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); cerr << fixed << setprecision(7);} } iosetupnya;
template<typename T, typename U> inline bool amin(T &x, U y) { return (y < x) ? (x = y, true) : false; }
template<typename T, typename U> inline bool amax(T &x, U y) { return (x < y) ? (x = y, true) : false; }
template<typename T, typename U> ostream& operator <<(ostream& os, const pair<T, U> &p) { os << p.first << " " << p.second; return os; }
template<typename T, typename U> istream& operator >>(istream& is, pair<T, U> &p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator <<(ostream& os, const vector<T> &v) { int s = (int)v.size(); rep(i,s) os << (i ? " " : "") << v[i]; return os; }
template<typename T> istream& operator >>(istream& is, vector<T> &v) { for(auto &x : v) is >> x; return is; }
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << "\n";} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
template<typename T>void die(T x){out(x); exit(0);}
#ifdef NyaanDebug
  #include "NyaanDebug.h"
  #define trc(...) do { cerr << #__VA_ARGS__ << " = "; dbg_out(__VA_ARGS__);} while(0)
  #define trca(v,N) do { cerr << #v << " = "; array_out(v , N);cout << endl;} while(0)
#else
  #define trc(...)
  #define trca(...)
  int main(){solve();}
#endif

#define inc(...) char __VA_ARGS__; in(__VA_ARGS__)
#define in2(N,s,t) rep(i,N){in(s[i] , t[i]);}
#define in3(N,s,t,u) rep(i,N){in(s[i] , t[i] , u[i]);}
using vd = V<double>; using vs = V<string>; using vvl = V< V<> >;
template<typename T>using heap = priority_queue< T , V<T> , greater<T> >;

using P = pair<int,int>; using vp = V<P>;
constexpr int MOD = /**/ 1000000007; //*/ 998244353;
//////////////////

void solve(){
  inl(K , A , B);
  if(B - A <= 2) out(K + 1);
  else if(A + 1 > K) out(K + 1);
  else{
    ll L = K - A + 1;
    ll ans = A;
    // L / 2回A -> Bをやる
    ans += (B - A) * (L / 2);
    ans += (L & 1);
    out(ans);
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <math.h>

using namespace std;

typedef long long int ll;
typedef long double ld;

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define vsort(a) sort(a.begin(), a.end())
#define rev(a) reverse(a.begin(), a.end());

const int MOD = 1000000007;
const int INF = INT_MAX;



int main()
{
    string in;
    cin >> in;

    string s = "Sunny";
    string c = "Cloudy";
    string r = "Rainy";

    string res;
    if (s == in) res = c;
    else if (c == in) res = r;
    else res = s;

    cout << res << endl;


    return 0;
}




//              g++ -std=c++1z  

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

int main() {
	string s;
	cin>>s;
	
	if(s[2]==s[3] && s[4]==s[5]){
	    cout<<"Yes"<<endl;
	}else{
	    cout<<"No"<<endl;
	}
	return 0;
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;
import java.util.stream.Collectors;

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

        int n = sc.nextInt();
        int[] a = new int[n];
        for (int i = 0; i < a.length; ++i) {
            a[i] = sc.nextInt();
        }

        System.out.println(solve(a));

        sc.close();
    }

    static String solve(int[] a) {
        int[] result = new int[a.length];
        int leftIndex;
        int rightIndex;
        boolean leftOrRight;
        if (a.length % 2 == 0) {
            leftIndex = a.length / 2 - 1;
            rightIndex = a.length / 2;
            leftOrRight = false;
        } else {
            leftIndex = a.length / 2;
            rightIndex = a.length / 2 + 1;
            leftOrRight = true;
        }

        for (int i = 0; i < a.length; ++i) {
            if (leftOrRight) {
                result[leftIndex] = a[i];
                --leftIndex;
            } else {
                result[rightIndex] = a[i];
                ++rightIndex;
            }

            leftOrRight = !leftOrRight;
        }

        return Arrays.stream(result).mapToObj(String::valueOf).collect(Collectors.joining(" "));
    }
}

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

int n, s;
int main()
{
	cin >> n;
	while (n > 0) {
		s += n % 10;
		n /= 10;
	}
	if (s == 1) {
		cout << 10;
	} else cout << s;
    return 0;
}


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

signed main(void)
{
	int n, cnt;
	cin >> n;
	vector<bool> red(n, true);
	vector<P> r(n), b(n);

	rep(i, n) cin >> r[i].first >> r[i].second;
	rep(i, n) cin >> b[i].first >> b[i].second;
	sort(r.begin(), r.end());
	sort(b.begin(), b.end());
	cnt = 0;
	rep(i, n)
	{
		int j = 0;
		vector<P> tmp;
		while(r[j].first < b[i].first && j < n)
		{
			if (red[j] && r[j].second < b[i].second)
				tmp.push_back(P(r[j].second, j));
			j++;
		}
		if (tmp.size() != 0)
		{
			sort(tmp.rbegin(), tmp.rend());
			red[tmp[0].second] = false;
			cnt++;
		}
	}
	cout << cnt << endl;
	return 0;
}


Measured memory_bytes: 256
from collections import Counter, defaultdict
import sys
sys.setrecursionlimit(10 ** 5 + 10)
# input = sys.stdin.readline
from math import factorial
import heapq, bisect
import math
import itertools


import queue
from collections import deque




def main():
    num = int(input())
    data1 = list(map(int, input().split()))
    data2 = list(map(int, input().split()))

    dp1 = [0 for i in range(num)]
    dp2 = [0 for i in range(num)]

    dp1[0] = 1
    for i in range(1, num):
        if data1[i] > data1[i - 1]:
            dp1[i] = 1
        # else:
        #     dp1[i] = data1[i]

    data2 = data2[::-1]
    dp2[0] = 1
    for i in range(1, num):
        if data2[i] > data2[i - 1]:
            dp2[i] = 1
        # else:
        #     dp1[i] = data1[i]
    dp2 = dp2[::-1]
    data2 = data2[::-1]

    ans = 1
    mod = 10 ** 9 + 7
    for i in range(num):
        if dp1[i] and dp2[i]:
            if data1[i] == data2[i]:
                pass
            else:
                ans *= 0
        elif dp1[i]:
            if data1[i] <= data2[i]:
                pass
            else:
                ans *= 0
        elif dp2[i]:
            if data2[i] <= data1[i]:
                pass
            else:
                ans *= 0
        else:
            ans *= min(data1[i], data2[i])
        ans %= mod

    print(ans)






if __name__ == '__main__':
    main()



Measured memory_bytes: 87776
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n, a, b;
  
  cin >> n;
  cin >> a;
  cin >> b;
  
  if ((n * a) > b) {
    cout << b << endl;
  } else {
    cout << (n * a) << endl;
  }
  
  return 0;
}


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

class banboo{
    private:
        int a;
        int b;
        int c;
    
    public:
        banboo(int aa=0,int bb=0,int cc=0){
            a=aa;
            b=bb;
            c=cc;
        }
        
        int getA(){
            return a;
        }
        
        int getB(){
            return b;
        }
        
        int getC(){
            return c;
        }
        
        friend istream &operator>>(istream &is,banboo &obj){
            is>>obj.a>>obj.b>>obj.c;
            return is;
        }
        
        friend ostream &operator<<(ostream &os,const banboo &obj){
            os<<obj.a<<" "<<obj.b<<" "<<obj.c;
            return os;
        }
        
        ~banboo(){
            a=0;
            b=0;
            c=0;
        }
};

bool judge(int a,int b,int c){
    if(b-a==c-b)return true;
    else return false;
}

int main(){
    banboo a;
    string b[2]={"NO","YES"};
    cin>>a;
    cout<<b[judge(a.getA(),a.getB(),a.getC())];
    return 0;
}

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

int main() {
    int D;
    long long int G;
    cin >> D >> G;

    int p[D], c[D];
    for (int i=0; i<D; ++i) cin >> p[i] >> c[i];

    int ans = 9999999;
    for (int i=0; i<(1<<D); ++i) {
        long long int score=0;
        int num=0;
        int maxmid = -1;
        for (int j=0; j<D; ++j) {
            if (i >> j & 1) {
                score += 100 * (j+1) * p[j] + c[j];
                num += p[j];
            } else maxmid = j;
        }
        if (score < G) {
            if ((G - score) <= 100 * (maxmid+1) * (p[maxmid]-1)) {
                num += ((G - score) + (100 * (maxmid + 1)) - 1) / (100 * (maxmid + 1)); 
            } else num = 9999999;
        }
        if (num < ans) ans = num;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
INF = float('inf')

N,M,RR = map(int,input().split(" "))
R = list(map(lambda x:int(x)-1,input().split(" ")))
G = [[] for i in range(N)]
sq = [[0 for x in range(RR)] for y in range(RR)]
for i in range(M):
    a,b,c = map(int,input().split(" "))
    a -= 1
    b -= 1
    G[a].append((b,c))
    G[b].append((a,c))

for i in range(RR):
    E = [INF]*N
    F = [1]*N
    E[R[i]] = 0
    F[R[i]] = 0
    q = R[i]
    c = 1
    while c != N:
        for a,b in G[q]:
            if F[a]:
                E[a] = min(E[a],E[q] + b)
        a = [x for x in range(N) if F[x]]
        q = min(a,key=lambda x:E[x])
        F[q] = 0
        c += 1
    for j in range(RR):
        sq[i][j] = E[R[j]]

q = [[[],0,0]]
s = []
while len(q):
    a,b,c = q.pop()
    if b == RR:
        s.append(c)
        continue
    for i in range(RR):
        if i in a:
            continue
        d = c
        d += b and sq[a[-1]][i]
        q.append([a+[i],b+1,d])

print(min(s))


Measured memory_bytes: 8336
#include <string>
#include <iostream>
using namespace std;
int N, Q, v[1000], w[1000], x; string s[1000];
int main() {
	while (cin >> N >> Q, N | Q) {
		for (int i = 0; i < N; i++) cin >> s[i] >> v[i] >> w[i];
		for (int i = 0; i < Q; i++) {
			cin >> x; int f = 0;
			for (int j = 0; j < N; j++) {
				if (w[j] - v[j] < x && x <= w[j]) {
					cout << s[j] << ' ' << x - w[j] + v[j] << endl; f = 1; break;
				}
			}
			if (!f) cout << "Unknown" << endl;
		}
	}
}

Measured memory_bytes: 3248
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
const ld eps = 1e-10;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, k; cin >> n >> k;
  vector<ll> A(n); rep(i, n) cin >> A[i];
  rep(i, n-k) {
    cout << (A[k+i]>A[i] ? "Yes" : "No") << "\n";
  }
  return 0;
}


Measured memory_bytes: 4776
import math
def getinputdata():

    # 配列初期化
    array_result = []
    
    data = input()
    
    array_result.append(data.split(" "))

    flg = 1

    try:

        while flg:

            data = input()

            if(data != ""):
                
                array_result.append(data.split(" "))

            else:

                flg = 0
    finally:

        return array_result

arr_data = getinputdata()

n = int(arr_data[0][0])

cnt=1

mindata=10**10    
while cnt<=int(math.sqrt(n)):
    
    if n % cnt==0:
    
        mindata=min(mindata,max(len(str(cnt)),len(str(n//cnt))))
    
    cnt+=1
    
print(mindata)
    
    

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
int GCD(int a,int b){return b?GCD(b,a%b):a;}
int LCM(int a,int b){return (a*b)/GCD(a,b);}
int abs(int x){return x>0?x:-x;}
 
//const int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
//const int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

int main()
{
	int a, b, c, d, e;
	cin >> a >> b >> c >> d >> e;
	int k;
	cin >> k;

	if (e - a > k) cout << ":(" << endl;
	else cout << "Yay!" << endl;

}


Measured memory_bytes: 256
// https://atcoder.jp/contests/abc106/tasks/abc106_a

#[allow(unused)]
use std::cmp::{max, min, Ordering};
#[allow(unused)]
use std::collections::{HashSet, VecDeque};
use std::io;
use std::io::{BufRead, Read, Write};
use std::str::FromStr;

/* Input macro */

#[allow(unused)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

#[allow(unused)]
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

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

#[allow(unused)]
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

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

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

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

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

#[allow(unused, non_snake_case)]
pub fn solve<R: BufRead, W: Write>(mut io: Io<R, W>) {
    let input = io.read_all();
    input! {
        source = input,
        A: usize,
        B: usize,
    }

    let res = (A-1) * (B-1);
    io.println(res);
}

#[allow(dead_code)]
fn main() {
    let stdin = io::stdin();
    let stdin_lock = stdin.lock();
    let stdout = io::stdout();
    let stdout_lock = stdout.lock();

    let io = Io {
        reader: stdin_lock,
        writer: stdout_lock,
    };

    solve(io);
}

/* IO helpers */

pub struct Io<R, W>
where
    R: BufRead,
    W: Write,
{
    pub reader: R,
    pub writer: W,
}

#[allow(dead_code)]
impl<R, W> Io<R, W>
where
    R: BufRead,
    W: Write,
{
    fn println<T: std::fmt::Display>(&mut self, value: T) {
        writeln!(&mut self.writer, "{}", value).expect("Unable to write");
    }

    fn print<T: std::fmt::Display>(&mut self, value: T) {
        write!(&mut self.writer, "{}", value).expect("Unable to write");
    }

    fn debug<T: std::fmt::Debug>(&mut self, value: T) {
        writeln!(&mut self.writer, "{:?}", value).expect("Unable to write");
    }

    fn next<T: FromStr>(&mut self) -> T {
        let token = self
            .reader
            .by_ref()
            .bytes()
            .map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        token.parse::<T>().ok().expect("Unable to parse")
    }

    fn nexts<T: FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.next::<T>()).collect::<Vec<T>>()
    }

    fn read_all(&mut self) -> String {
        let mut res = String::new();
        self.reader.read_to_string(&mut res).unwrap();
        res
    }
}

/* Structure helpers */

trait IteratorExt: Iterator + Sized {
    fn vec(self) -> Vec<Self::Item> {
        self.collect()
    }
}

impl<T: Iterator> IteratorExt for T {}


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

const int N = 200000;

bool is_prime[N];

int main() {
  
  int X;
  cin >> X;
  
  int ans;
  
  for (int i = 0; i < N; i++) is_prime[i] = true;
  is_prime[0] = is_prime[1] = false;
  for (int i = 2; i < N; i++) {
    if (is_prime[i]) {
      for (int j = 2 * i; j <= N; j += i) is_prime[j] = false;
    }
    if (is_prime[i] && X <= i) {
      ans = i;
      break;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 384