akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

public class Main {
    static int modP = 1000000007;
    static long inf  = Long.MAX_VALUE;
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        Map<Integer, List<E>> map = new HashMap<>();
        for(int i = 0; i < n-1; i++) {
            int a = in.nextInt()-1;
            int b = in.nextInt()-1;
            int c = in.nextInt();

            List<E> leftList = map.containsKey(a) ? map.get(a) : new LinkedList<>();
            E atob = new E(a,b,c);
            leftList.add(atob);
            map.put(a, leftList);
            List<E> rightList = map.containsKey(b) ? map.get(b) : new LinkedList<>();
            E btoa = new E(b,a,c);
            rightList.add(btoa);
            map.put(b, rightList);
        }
        int q = in.nextInt();
        int k = in.nextInt()-1;
        List<Q> queries = new ArrayList<>();
        for(int i = 0; i < q; i++) {
            int x = in.nextInt()-1;
            int y = in.nextInt()-1;
            Q query = new Q(x,y);
            queries.add(query);
        }

        long[] dist = new long[n];
        Arrays.fill(dist, inf);

        dist[k] = 0;
        Stack<Integer> stack = new Stack<>();
        stack.push(k);
        while(!stack.isEmpty()) {
            int currentNode = stack.pop();
            List<E> edges = map.get(currentNode);
            for(E e : edges) {
                if(dist[e.to] != inf) continue;

                stack.push(e.to);
                dist[e.to] = dist[currentNode] + e.w;
            }
        }

        for(int i = 0; i < q; i++) {
            int x = queries.get(i).x;
            int y = queries.get(i).y;
            print(dist[x] + dist[y]);
        }
    }

    static void print(String s) {
        System.out.println(s);
    }

    static void print(int i) {
        System.out.println(i);
    }

    static void print(long i) {
        System.out.println(i);
    }
}

class Q {
    int x, y;
    Q(int x, int y) {
        this.x = x;
        this.y = y;
    }
}

class E {
    int from, to;
    long w;
    E(int from, int to, long w) {
        this.from = from;
        this.to = to;
        this.w = w;
    }
}

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

#define Pi acos(-1.)
#define pb push_back
#define all(x) (x).begin(), x.end()
#define mp make_pair
#define fi first
#define se second
#define pii pair<int, int>
#define FILE "474"
#define standart 1

using namespace std;

typedef long long ll;

const int INF = 1e9 + 322;
const ll LINF = 1e18 + 228;
const int MAXN  = 1e5 + 228;
const int MOD = 1e9 + 7;
const double eps = 1e-14;



void solve() {
    int x; cin >> x;
    int y = x, z = 0;
    while(y) {
        z += y % 10;
        y /= 10;
    }
    cout << (x % z == 0 ? "Yes" : "No") << endl;
}


int main()
{
    if(!standart) {
        freopen(FILE".in", "r", stdin);
        freopen(FILE".out", "w", stdout);
    }
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    int T = 1;
    while(T--)
        solve();

    return 0;
}


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

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



int main(){
    string s;  cin >> s;
    int K; cin >> K;
    
    vector<string> a;
    
    rep(i,s.size()){
        int k = K;
        string t;
        while (k > 0) {
            string x;
            for(int j=0; j<k; j++){
                if(i+j >= s.size()) break;
                x += s[i+j];
            }
            k--;
            
            a.push_back(x);
        }
    }
    int n = s.size();
    sort(a.begin(), a.end());
    unique(a.begin(), a.end());
    
    cout << a[K-1] << endl;
    
    
   
    
}


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

const int mod=2019;

int main(){
  string s;
  cin >> s;
  int n=s.size();
  reverse(s.begin(),s.end());
  int tot=0;
  long long ans=0;
  int x=1;
  vector<int> cnt(mod);
  for(int i=0;i<n;++i){
    cnt[tot]++;
    tot+=(s[i]-'0')*x;
    tot%=mod;
    ans+=cnt[tot];
    x=x*10%mod;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3724
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define bg(a) a.begin()
#define en(a) a.end()
#define all(a) bg(a), en(a)
using namespace std;
using vi = vector<int>;
using vv = vector<vi>;

int main(void){
    string s,t;cin>>s>>t;
    int n = (int)s.size();
    
    rep(i,n){
        if(s==t){
            cout << "Yes" << endl;
            return 0;
        }
        string u = s.substr(n-1,1);
        s.pop_back();
        s = u + s;
    }
    
    cout << "No" << endl;
    
    return 0;
}

Measured memory_bytes: 3604
#include<cstdio>
#include<cmath>
#include<algorithm>
#define mod 1000000007LL
using namespace std;
typedef long long ll;
ll f[105][10][150],sum[10][2];
int main()
{
	int n,m,k;scanf("%d%d%d",&n,&m,&k);
	sum[1][0]=1;
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=m;j++) sum[j][i&1]=0;
		for(int j=1;j<=m;j++)
		for(int s=0;s<(1<<(m-1));s++)
		{
			int fg=0;
			for(int k=0;k<m-2;k++)
			if((s&(1<<k))&&(s&(1<<(k+1)))) fg=1;
			if(fg) continue;
			int pre=j;
			if(s&(1<<(j-1))) pre++;
			else if(s&(1<<(j-2))) pre--;
			f[i][j][s]+=sum[pre][(i-1)&1];f[i][j][s]%=mod;
			sum[j][i&1]+=f[i][j][s];sum[j][i&1]%=mod;
		}
	}
	
	printf("%lld\n",sum[k][n&1]);
	return 0;
}

Measured memory_bytes: 1280
N = int(input())

A = list(map(int, input().split()))

tmp = 0
for i in range(N):
    tmp = A[i] * 2 - tmp

tmp //= 2
ans = []
for i in range(N):
    ans.append(tmp)
    tmp = A[i] * 2 - tmp

print(*ans)

Measured memory_bytes: 14028
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<map>
#include<stack>
#include<cmath>
#include<iomanip>
#include<set>
#include<numeric>
#include<sstream>
#include<random>
#include<cassert>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rrep(i, st, n) for (int i = st; i < n; ++i)
using pii = pair<int, int>;
const int inf = 1e9 + 7;
int dy[] = {0, 0, -1, 1, -1, 1, -1, 1};
int dx[] = {1, -1, 0, 0, -1, 1, 1, -1};
#define ceil(a, b) a / b + !!(a % b)

int main() {
    int W, H, N; cin >> W >> H >> N;
    int lx = 0, rx = W, by = 0, uy = H;
    rep(i, N) {
        int x, y, a; cin >> x >> y >> a;
        if (a == 1) lx = max(lx, x);
        else if (a == 2) rx = min(rx, x);
        else if (a == 3) by = max(by, y);
        else uy = min(uy, y);
    }
    int ans = (rx - lx) * (uy - by);
    if ((rx - lx) > 0 && (uy - by) > 0) cout << ans << endl;
    else cout << 0 << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define itn int
#define gI gi
#define int long long

using namespace std;

typedef long long ll;

inline int gi()
{
	int f = 1, x = 0; char c = getchar();
	while (c < '0' || c > '9') {if (c == '-') f = -1; c = getchar();}
	while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
	return f * x;
}

inline ll gl()
{
	ll f = 1, x = 0; char c = getchar();
	while (c < '0' || c > '9') {if (c == '-') f = -1; c = getchar();}
	while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
	return f * x;
}

int n, m, k;

signed main()
{
	//freopen(".in", "r", stdin);
	//freopen(".out", "w", stdout);
	n = gi(), m = gi(), k = gi();
	if (n <= k) 
	{
		k = k - n, printf("0 ");
		printf("%lld\n", max(1ll * 0, m - k));
	}
	else 
	{
		printf("%lld %lld\n", n - k, m);
	}
	return 0;
}
//
//

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
using vll = vector<vl>;
using Pll = pair<ll, ll>;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(v) v.begin(), v.end()
#define sz(x) ((int) x.size())
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define F first
#define S second
const int MOD = 1e9+7;
const int INF = 2e9;
template<class T> void print(const T& t){ cout << t << endl; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}

int main(){
  ll x, y;
  cin >> x >> y;
  bool ans = false;
  rep(i,x+1){
    if(2*i+4*(x-i)==y)ans = true;
  }
  if(ans){
    print("Yes");
  }
  else{
    print("No");
  }
}

Measured memory_bytes: 3632
#include <iostream>
#include <map>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <sstream>
#include <cmath>
#include <math.h>
#include <string>
#include <queue>
#include <utility>
using namespace std;
typedef long long ll;
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector <ll> a(n) , b(n);
    for ( int i = 0 ; i < n ; i++ ) {
		cin >> a[i];
		b[i] = a[i]; 
	} 
    sort( b.begin() , b.end() );
    int x = ( n - 2 ) / 2;
    for ( int i = 0 ; i < n ; i++ ) {
        if ( a[i] <= b[x] ) cout << b[x + 1] << endl;
        else cout << b[x] << endl;
    } 
}


Measured memory_bytes: 6288
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
ll n,m,d;
//void dfs(int x){
//    if(x==m+1){
//        for(int i=2;i<=m;++i)if(abs(a[i]-a[i-1])==d)++ans;
//        return;
//    }
//    for(int i=1;i<=n;++i){
//        a[x]=i;
//        dfs(x+1);
//    }
//}
ll q_pow(ll a, ll b){
    ll ans=1;
    while(b){
        if(b&1)ans=ans*a;
        a=(a*a);
        b>>=1;
    }
    return ans;
}
int main() {
    scanf("%lld%lld%lld",&n,&m,&d);
////    for(n=1;n<=10;++n)
////    for(m=2;m<=10;++m)
////        for(d=0;d<n;++d){
//        ans=0;
//        dfs(1);
//        printf("%d %d %d %d\n",n,m,d,ans);
////    }
    double d0 = n, d1 = (n-1.0)*2.0;
    if(d==0){
        double ans = 1.0*d0*(m-1.0)/n/n;
        printf("%.8f\n",ans);
    }
    else if(d==1){
        double ans = 1.0*d1*(m-1.0)/n/n;
        printf("%.8f\n",ans);
    }
    else {
        double dd = d1 - 1.0*(d-1.0)*2.0;
        double ans = 1.0*dd*(m-1.0)/n/n;
        printf("%.8f\n",ans);
    }
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int n,a[100020];
int main(){
    scanf("%d",&n);
    for(int i =0;i<n;i++) scanf("%d",a+i);
    int flag = 1;
    a[0]--;
    for(int i = 1;i<n;i++){
        if(a[i]>a[i-1]) a[i]--;
        if(a[i]<a[i-1]) {
            flag = 0;
            break;
        }
    }
    if(flag) printf("Yes\n");
    else printf("No\n");
    return 0;
}

Measured memory_bytes: 512
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<ll, int> P;
ll x[1000][3];
int main() {
	int N, M;
	cin >> N >> M;
	for (int i = 0; i < N; i++) {
		cin >> x[i][0] >> x[i][1] >> x[i][2];
	}
	ll ans = 0;
	for (int bit = 0; bit < (1 << 3); bit++) {
		vector<P> vec;
		for (int i = 0; i < N; i++) {
			ll s = 0;
			for (int j = 0; j < 3; j++) {
				if (bit&(1 << j)) {
					s += x[i][j];
				}
				else {
					s -= x[i][j];
				}
			}
			vec.emplace_back(s, i);
		}
		sort(vec.begin(), vec.end(), greater<P>());
		ll sum_x[3] = {};
		for (int i = 0; i < M; i++) {
			for (int j = 0; j < 3; j++) {
				sum_x[j] += x[vec[i].second][j];
			}
		}
		ll sum = abs(sum_x[0]) + abs(sum_x[1]) + abs(sum_x[2]);
		ans = max(ans, sum);
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
def check_same_sentence(big_str, small_str):
    num_b = len(big_str)
    num_s = len(small_str)
    ans = 0
    for i in range(num_b - num_s + 1):
        tmp = 0
        for j in range(num_s):
            if big_str[i+j] == small_str[j]:
                tmp += 1
        ans = max(ans, tmp)
    # 最大で何文字同じかを返す
    return ans

S = input()
T = input()

ans = check_same_sentence(S, T)
print(len(T)-ans)

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

int main() {
	int N;
	cin >> N;

	int n1 = N / 1000;
	int n2 = (N - n1 * 1000) / 100;
	int n3 = (N - n1 * 1000 - n2 * 100) / 10;
	int n4 = N - n1 * 1000 - n2 * 100 - n3 * 10;

	if ((n1 == n2 && n2 == n3) || (n2 == n3 && n3 == n4)) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define ll long long
using ull = unsigned long long;
using namespace std;
const int INF = 10101010101010101ll;
const int MOD = 1e9 + 7;
#define dump(x)                             \
    if (dbg) {                              \
        cout << #x << " = " << (x) << endl; \
    }
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define FORR(i, a, b) for (int i = (a); i <= (b); ++i)
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(), (v).end()
#define SZ(x) ((int)(x).size())
#define P pair<int, int>
#define V vector<int>
#define S set<int>
#define itn int
bool dbg = 0;
itn N, A[202020];
int d[202020], MIN, MAX;
int dif(int x[])
{
    MAX = -1;
    MIN = INF;
    FOR(i, 0, 4)
    {
        if (x[i + 1] <= x[i]) {
            return INF;
        }
        MIN = min(MIN, d[x[i + 1] - 1] - d[x[i] - 1]);
        MAX = max(MAX, d[x[i + 1] - 1] - d[x[i] - 1]);
    }
    return MAX - MIN;
}
int f(itn x)
{
    itn ans = INF;
    itn sml = d[x - 1], smr = d[N] - d[x - 1];
    auto itl = ub(d + 1, d + x - 1, sml / 2);
    auto itr = ub(d + x + 1, d + N, smr / 2 + d[x - 1]);
    int L = itl - d;
    itn R = itr - d;
    //cout << 0 << " " << L << " " << x << " " << R << " " << N << endl;
    int t[5] = {1, L, x, R, N + 1};
    FORR(i, -2, 2)
    {
        FORR(j, -2, 2)
        {
            t[1] = L + i;
            t[3] = R + j;
            ans = min(ans, dif(t));
            /*
            if (ans == 325361182) {
                FOR(i, 0, 5)
                    cout << t[i] << endl;
                return ans;
            }*/
        }
    }
    return ans;
}
void solve()
{
    itn ans = INF;
    FORR(i, 1, N)
    {
        d[i] = d[i - 1] + A[i];
    }
    FORR(i, 3, N - 1)
    {
        dump(i);
        ans = min(ans, f(i));
    }
    cout << ans << endl;
}

signed main()
{
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cin >> N;
    FORR(i, 1, N)
    cin >> A[i];
    solve();
    return 0;
}


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

int main(){
  ll n, m;
  cin >> n >> m;
  if(abs(n-m)>1){
    cout << 0 << endl;
    return 0;
  }
  ll sum = 1;
  for(int i=1; i<=n; i++){
    sum *= i;
    sum %= mod;
  }
  for(int i=1; i<=m; i++){
    sum *= i;
    sum %= mod;
  }
  if(n==m){
    sum *= 2;
    sum %= mod;
  }
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 3588
MOD = 10 ** 9 + 7
INF = 10 ** 13
import sys
sys.setrecursionlimit(100000000)
dy = (-1,0,1,0)
dx = (0,1,0,-1)
from heapq import heapify,heappop,heappush

def dijkstra(G,s = 0): #sを始点とした最短経を求める
    n = len(G)
    dist = [INF] * n
    dist[s] = 0

    q = [(0,s)]
    heapify(q)

    while q:
        d,v = heappop(q)
        if dist[v] < d:
            continue
        for e,cost in G[v]:
            if dist[e] > dist[v] + cost:
                dist[e] = dist[v] + cost
                heappush(q,(dist[e],e))
    
    return dist

def main():
    n,m,s = map(int,input().split())
    MAXV = 2500*n
    G = [[] for _ in range(MAXV)]
    for _ in range(m):
        u,v,a,b = map(int,input().split())
        u -= 1
        v -= 1
        for i in range(2500 - a):
            G[u*2500 + i + a].append((v*2500 + i,b))
            G[v*2500 + i + a].append((u*2500 + i,b))
    
    for i in range(n):
        c,d = map(int,input().split())
        for j in range(2500 - c):
            G[i*2500 + j].append((i*2500 + j + c,d))
  
    dist = dijkstra(G,min(s,2499))
    for i in range(1,n):
        ans = min(dist[2500*i:2500*(i + 1)])
        print(ans) 

if __name__ == '__main__':
    main()


Measured memory_bytes: 95120
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <algorithm>
#include <functional>
//#include <math.h>
using namespace std;
typedef long long LL;

int main()
{
	int H, W;
	cin >> H >> W;

	char g[51][51];
	for (int h = 0; h < H; h++)
		for (int w = 0; w < W; w++)
			cin >> g[h][w];

	auto q = new queue<int>();
	auto qpush = [=, &q, &g](int c, int px, int py) {
		if (0 <= px && px < W && 0 <= py && py < H)
			if (g[py][px] == '.') {
				g[py][px] = 'a';
				q->push((c << 16) | (py << 8) | px);
			}
	};
	qpush(1, 0, 0);

	int goal = 0;
	while (!q->empty() && !goal) {
		auto pos = q->front();	q->pop();
		int x = pos & 0xff;
		int y = (pos >> 8) & 0xff;
		int cnt = pos >> 16;

		if (x + 1 == W && y + 1 == H)
			goal = pos;
		else {
			cnt++;
			qpush(cnt, x + 1, y);
			qpush(cnt, x - 1, y);
			qpush(cnt, x, y + 1);
			qpush(cnt, x, y - 1);
		}
	}

	int res = -1;
	if (goal) {
		int bcnt = 0;
		for (int h = 0; h < H; h++) 
			for (int w = 0; w < W; w++)
				if (g[h][w] == '#') 
					bcnt++;


		res = H * W - bcnt - (goal >> 16) ;
	}

	cout << res << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <fstream>
#include <string>
#include <math.h>
#include <cstdlib>
#include <istream>
#include <sstream>
#include <cctype>
#include <iomanip>
#define rep(i,N) for(int i=0;i<(int)N;++i)
//cout << fixed << setprecision(20) << *** << endl;
typedef long long ll;
using namespace std;
ll gcd(ll a,ll b){
	ll t;
	if(a<b){
		t=a;
		a=b;
		b=t;
	}
	if(a%b==0)return b;
	return gcd(b,a%b);
}
int main()
{
	ll A,B,ANS=-1;
	cin>>A>>B;
	for(ll i=0;i<=10000;i++){
		//cout<<i<<":"<<floor(i*0.08)<<":"<<floor(i*0.10)<<endl;
		if(floor(i*0.08)==A&&floor(i*0.10)==B){
			ANS=i;
			break;
		}
	}
	cout<<ANS<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void){
  int x;
  int min=0,sec=0;

  for(int i=0;i<4;i++){
    x=0;
    scanf("%d",&x);
    sec+=x;
  }
  while(sec>=60){
    sec-=60;
    min++;
  }
  printf("%d\n",min);
  printf("%d\n",sec);

  return 0;
}



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

ll N;
vector<int> sft;
int getd(ll x){
    int cnt=0;
    while(x>0){
        x/=10;
        cnt++;
    }
    return cnt;
}

ll pow(int x, int n){
    ll res = 1;
    while(n>0){
        if(n&1) res = res * x;
        x = x * x;
        n >>=1;
    }
    return res;
}

ll make753(int n){
    ll num=0;
    for(int i=3; i<n; i++){
        num = num + pow(3, i) -3 * pow(2, i) + 3;
        //1eN-1までの753数の和
    }
    return num;
}

ll check(string back,string str, int d,string strn, int dig){
    str = str+back;
    if(d == dig){
        return  (str<=strn && str.find("3") != string::npos &&str.find("5") != string::npos &&str.find("7")!=string::npos) ? 1: 0;
    }else{
    ll t3 = check("3",str, d+1, strn, dig);
    ll f5 = check("5",str, d+1, strn, dig);
    ll s7 = check("7",str, d+1, strn, dig);
    return t3 + f5 + s7;
    }
}

ll makeN753(ll n, int dig){
    string strn = to_string(n);
    string str = "";
    ll t3 = check("3",str, 1, strn, dig);
    ll f5 = check("5",str, 1, strn, dig);
    ll s7 = check("7",str, 1, strn, dig);
    return t3 + f5 + s7;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin >> N;
    if(N<=100){
        cout << 0 << endl;
        return 0;
    }
    ll n753 = make753(getd(N));
    // cout << n753 << endl;
    n753 = n753 + makeN753(N, getd(N));
    cout << n753 << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n,m;
  cin>>n>>m;
  priority_queue<int> d;
  for(int i=0;i<n;i++){
    int y;
    cin>>y;
    d.push(y);
  }
  while(m>0 && d.top()>0){
    int h;
    h=d.top()/2;

    d.pop();

    d.push(h);
    m--;
  }
  int64_t ans=0;
  while (!d.empty()) {
    ans+=d.top();
    d.pop();
  }
  cout<<ans<<endl;
}


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

int main(){
	int money = 100000;
	int n;
	cin >> n;
	for(int i = 0; i < n; i++){
		money = (int)(money * 1.05);
		if(money % 1000 != 0){
			money = money - money % 1000 + 1000;
		}
	}
	cout << money << endl;
	return 0;
}

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

int main(){
    string s;
    cin >> s;
    int K;
    cin >> K;
    vector<string> sub_s;
    rep(i,s.size()){
        for(int j=1;j<=K;j++){
            if(i+j>s.size())continue;
            string tmp=s.substr(i,j);
            sub_s.push_back(tmp);
        }
    }

    sort(sub_s.begin(),sub_s.end());
    string ans="";
    int cnt=0;

    rep(i,sub_s.size()){
        if(ans!=sub_s[i]){
            ans=sub_s[i];
            cnt++;
        }
        if(cnt==K)break;
    }

    cout << ans << endl;
}

Measured memory_bytes: 1660
#include <bits/stdc++.h>
#define rep(i,n) for(long long int i = 0; i < n; i++)
#define _rep(i,m,n) for(long long int i = m; i < n; i++)
#define print(n) std::cout << n << std::endl
#define _print(n) std::cout << n
using namespace std;
typedef long long ll;
const int N = 1000000;
const ll mod = 1000000007;

int main() {
    ll n,a,b,c,d; cin >> n >> a >> b >> c >> d;
    string s; cin >> s;
    s = '#' + s + '#';
    n = s.size();
    bool flag = false;

    if(c < d){
        flag = true;
    }else {
        for (int i = b; i <= d; ++i) {
            if (s[i - 1] == '.' && s[i] == '.' && s[i + 1] == '.') {
                flag = true;
            }
        }
    }
    for (ll i = a; i <= max(c,d); ++i) {
        if (s[i - 1] == '#' && s[i] == '#') {
            flag = false;
        }
    }
    if(flag)print("Yes");
    else print("No");
}

Measured memory_bytes: 772
#include <iostream>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
using namespace std;

typedef long long ll;
#define rep(i, n) for(int i = 0; i < n; i++)

#define pi 3.1415926535989793

int main(){
    double A, B, H, M;
    cin >> A >> B >> H >> M;
    double a_rad = 0;
    double b_rad = 0;
    double min = H * 60 + M;
    a_rad = (H / 12) * 2 * pi + (M / 60) * (2 * pi / 12);
    b_rad = 2 * pi * M / 60;

    double drad = a_rad - b_rad;
    double num = pow(A, 2) + pow(B, 2) - 2 * A * B * cos(drad);
    double ans = sqrt(num);
    printf("%.11f\n", ans);
    return 0;
}

Measured memory_bytes: 4228
import sys
from copy import deepcopy

def canMake(k, Nums):#Numsにある数でkを作れるか
    L = len(Nums)
    index = 0
    bit = dict()
    for i in reversed(range(60)): #掃き出し法
        flag = 0
        tp = (1 << i)
        for j in range(index, L):
            if Nums[j] & tp == tp:
                flag = 1
                Nums[index], Nums[j] = Nums[j], Nums[index]
                bit[i] = index
                break
        if flag == 1:
            for j in range(L):
                if Nums[j] & tp == tp and index != j: Nums[j] ^= Nums[index]
        if flag == 1: index += 1

    #実際にkを作ることができるか
    ans = 0
    for i in range(60):
        if k & (1 << i) == (1 << i):
            if i in bit: ans ^= Nums[bit[i]]
    if ans == k: return True
    else: return False


def solve():
    input = sys.stdin.readline
    T = int(input())
    Ans = [0] * T
    for t in range(T):
        N = int(input())
        A = [int(a) for a in input().split()]
        S = input().strip("\n")
        used = []
        for i in reversed(range(N)):
            if S[i] == "0":
                used.append(A[i])
            else:
                compare = deepcopy(used)
                if not canMake(A[i], compare):
                    Ans[t] = 1
                    break
    
    print(*Ans, sep="\n")

    return 0

if __name__ == "__main__":
    solve()


Measured memory_bytes: 73840
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <queue>
#include <sstream>
#include <stack>
#include <time.h>
#include <vector>
#include <complex>
#include <map>
#include <set>
#include <iomanip>
using namespace std;
int a[200008];
int b[200008];
int main(){
  int n,k;
  cin>>n;
  k=n / 2;
  for (int i=0;i<n;i++){
    cin>>a[i];
    b[i]=a[i];
}
  sort(a,a+n);
  for (int j=0;j<n;j++){
    if (b[j]<a[n-k]) cout<<a[n-k]<<endl;
    else cout<<a[n-k-1]<<endl;
}
  return 0;
}

Measured memory_bytes: 3712
#include <stdio.h>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
#include <functional>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef vector<vector<int>> v2int;
typedef vector<ll> vll;
typedef vector<vector<ll>> v2ll;
typedef list<int> liint;
typedef pair<int, int> pint;
const int INF = int(2e9);
const ll LINF = ll(2e9) * ll(2e9);
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T, class C> void chmax(T& a, C b) { a > b ? : a = b; }
template<class T, class C> void chmin(T& a, C b) { a < b ? : a = b; }

ll calc(string& S, ll p, char last) {
    int last_count = 0;
    ll ret = 1;
    for (int i = S.size() - 1; i >= 0; i--){
        if (S[i] == last) {
            last_count++;
        }
        else {
            ret *= last_count;
            ret %= p;
            last_count--;
        }
    }
    return ret;
}

int main() {
    int N;
    ll p = 1000000007;
    cin >> N;
    vll a(N), b(N);
    vector<pair<ll, char>> P(2 * N);
    rep(i, N) {
        ll a;
        cin >> a;
        P[i] = make_pair(a, 'a');
    }
    rep(i, N) {
        ll b;
        cin >> b;
        P[i + N] = make_pair(b, 'b');
    }
    sort(P.begin(), P.end());
    
    int a_count = 0;
    int b_count = 0;
    string a_first = "";
    string b_first = "";
    rep(i, N * 2) {
        if (P[i].second == 'a') {
            if (b_count > 0) {
                b_count--;
                b_first += 'a';
            }
            else {
                a_count++;
                a_first += 'a';
            }
        }
        else {
            if (a_count > 0) {
                a_count--;
                a_first += 'b';
            }
            else {
                b_count++;
                b_first += 'b';
            }
        }
    }

    ll ans1, ans2, ans;
    ans1 = calc(a_first, p, 'b');
    ans2 = calc(b_first, p, 'a');
    cout << (ans1 * ans2) % p << endl;
    return 0;
}

Measured memory_bytes: 5376
#include<cstdio>
#include<algorithm>
using namespace std;

long long n,a[105],ans=0x7fffffff;

int main()
{
	scanf("%lld",&n);
	
	for (int i=1 ; i<=n ; i++)
	    scanf("%lld",&a[i]);
	
	for (int i=1 ;i<=100 ; i++)
	{
		long long sum=0;
		for (int j=1 ; j<=n ; j++)
		    sum+=(a[j]-i)*(a[j]-i);
		
		ans=min(ans,sum);
	}
	
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0),cin.tie();
int main()
{
	//IOS;
	int a,b,c;
	while(cin>>a>>b>>c)
	{
		map<int,int> m;
		m[a]++;
		m[b]++;
		m[c]++;
		if(m.size()!=2) 
		{
			cout<<"No\n";
		}
		else
		{
			cout<<"Yes\n";
		}
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main ()
{
	long long a[100000], b, i, dem = 0;
	cin >> b;
	for (i = 1; i <= b; i++)
		cin >> a[i];
	if (b == 1)
	{
		cout << "Yes";
		return 0;
	}
	for (i = 1; i < b; i++)
	{
		if (a[i] > a[i+1])
			dem++;
		else if (a[i] < a[i+1])
			dem = 0;
		if (a[i] - a[i+1] > 1)
		{
			cout << "No";
			return 0;
		}
		if (dem >= 2)
		{
			cout << "No";
			return 0;
		}
	}
	cout << "Yes";
	return 0;
}

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

int main(){
    int a,b,c,d,e;
    cin >> a >> b >> c >> d >> e;
    int ans = 0;
    if(a <= 0){
        ans = b*e + d - a*c;
    }
    else if(a > 0){
        ans = (b - a)*e;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3084
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.root = [-1]*n
        self.rank = [0]*n

    def find(self, x):
        if self.root[x-1] < 0:
            return x
        else:
            self.root[x-1] = self.find(self.root[x-1])
            return self.root[x-1]

    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x==y:
            return
        elif self.rank[x-1] > self.rank[y-1]:
            self.root[x-1] += self.root[y-1]
            self.root[y-1] = x
        else:
            self.root[y-1] += self.root[x-1]
            self.root[x-1] = y
            if self.rank[x-1] == self.rank[y-1]:
                self.rank[y-1] += 1

    def same(self, x, y):
        return self.find(x)==self.find(y)

    def count(self, x):
        return -self.root[self.find(x)-1]

N,M=map(int,input().split())
uf=UnionFind(N)
for i in range(M):
    x,y,z=map(int,input().split())
    uf.unite(x,y)
s=set()
ans=0
for i in range(1,N+1):
    if uf.find(i) not in s:
        s.add(uf.find(i))
        ans+=1
print(ans)

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

void swap(int *aptr, int *bptr);
int main() {
	int a,b,c;
	cin >> a >> b >> c;
	if(a>b)
		swap(&a,&b);
	if(b>c)
		swap(&b,&c);
	if(a>b)
		swap(&a,&b);
	cout << a << " " << b << " " << c << endl;
	return 0;
}

void swap(int *aptr, int *bptr){
	int temp;
	temp = *aptr;
	*aptr = *bptr;
	*bptr = temp;
}



Measured memory_bytes: 3100
#include <iostream>
#include <vector>
#include <unordered_map>
#include <deque>
#include <list>
#include <set>
#include <random>
#include <iomanip>

using namespace std;
using ll = long long;
const int BIG = 100000007;



int main(){
    ll a,b;
    string s;
    cin >> a;
    cin >> s;
    b = 0;
    for(char c:s){
        if(c == '.')continue;
        b *= 10;
        b += (c - 48);
    }

    ll d = a * b;

    cout << (a * b) / 100 << endl;
}


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


using namespace std;
#define ll  long long
#define ld  long double
#define endl '\n'
#define FAST ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const ll mod = 1e9 + 7;
const double PI = 3.141592653589793238463;
const int MAXN = 2e3 + 5;
bool isPrime[MAXN];
void sevie() {
    memset(isPrime, 1, sizeof(isPrime));
    isPrime[0] = isPrime[1] = 0;
    for (ll i = 2; i * i <= MAXN; i++) {
        if (isPrime[i]) {
            for (ll j = i * 2; j <= MAXN; j += i) {
                isPrime[j] = 0;

            }
        }
    }
}
ll fastPow(ll x, ll b) {
    if (b == 0)
        return 1;
    else if (!(b & 1)) {
        return fastPow(x * x, b / 2);
    } else
        return x * fastPow(x * x, (b - 1) / 2);
}
//__builtin_popcount ();
bool isPrim(int n) {
    if (n == 1 || n == 0)
        return false;
    for (int i = 2; i * i <= n; i++) {
        if (n % i == 0)
            return false;
    }
    return true;
}



int main() {
    FAST
int n;
    cin>>n;
    int arr[n];
    for(int i=0;i<n;i++)
        cin>>arr[i];
    int c=1;
    int mn=arr[0];
    for(int i=1;i<n;i++)
    {
        if(arr[i]<=mn)
        {
            mn=arr[i];
            c++;
        }
    }
    cout<<c<<endl;
    return 0;
}


Measured memory_bytes: 1024
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#define INF 2e9
#define MOD 1000000007
#define MOD9 998244353
#define intMAX 51000;
#define PI 3.14159265359
using namespace std;
typedef long long llong;
typedef long double ldouble;

using Graph = vector<vector<int>>;

// int ctoi(const char c){
//   if('0' <= c && c <= '9') return (c-'0');
//   return -1;
// }

// int gcd(int a, int b){
//   int ma = max(a,b);
//   int mi = min(a,b);
//   if(mi == 0) return ma;

//   return gcd(mi, ma%mi);
// }

// llong POW(llong a, llong b){
//   if(b == 0) return 1;
//   else{
//     if(b%2 == 0) return POW(a * a % MOD, b / 2) % MOD;
//     else return a * POW(a * a % MOD, b / 2) % MOD;
//   }
// }

int main(){
	ldouble sum = 0;
	ldouble con = 380000;
	int N;
	cin >> N;
	for(int i=0; i<N; ++i){
		string U;
		ldouble X;
		cin >> X >> U;
		if(U=="JPY") sum += X;
		else sum += X * con;
	}
	cout << fixed << setprecision(16) << sum << endl;
}

Measured memory_bytes: 256
open System


[<EntryPoint>]
let main argv =
    let rec f n = if n%2<>0 then 0 else (f (n/2))+1
    let n =stdin.ReadLine()
    stdin.ReadLine().Split()
    |>Array.map int
    |>Seq.sumBy(fun c -> f c)
    |>stdout.WriteLine
    0

Measured memory_bytes: 11872
package main

import (
	"fmt"
	"math"
)

func main() {
	// Code for D - Caracal vs Monster
	var H int
	fmt.Scanf("%d", &H)

	var count int = 1
	var ans int
	for {
		if H == 0 {
			break
		} else {
			H = int(math.Floor(float64(H) / 2))
			ans += count
			count *= 2
		}
	}

	fmt.Println(ans)
}


Measured memory_bytes: 1836
#include<bits/stdc++.h>
using namespace std;
#define minc *(c.begin())
#define maxc *(c.end()-1)
main(){
  int n;
  cin>>n;
  vector<int> a(n);
  for(auto& i:a)cin>>i;
  vector<int> c;
  c.push_back(a[n-1]);
  //for(auto k:c)cerr<<" "<<k;
  //cerr<<"  ["<<minc<<","<<maxc<<"]("<<a[n-1]<<")\n"<<flush;
  for(int i=n-2;i>=0;--i){
    if(a[i]<minc)c[0]=a[i];
    else if(maxc<=a[i])c.push_back(a[i]);
    else {
      auto itr=lower_bound(c.begin(),c.end(),a[i]+1);
      int k=*itr;
      c.erase(itr);
      assert(a[i]<k);
      auto itr2=c.insert(lower_bound(c.begin(),c.end(),a[i]),a[i]);
      if(itr2==c.end()-1)maxc=*(c.end()-1);
      else if(itr2==c.begin())minc=c[0];
    }
    //for(auto k:c)cerr<<" "<<k;
    //cerr<<"  ["<<minc<<","<<maxc<<"]("<<a[i]<<")\n"<<flush;
  }
  cout<<c.size();
}

Measured memory_bytes: 1276
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <vector>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;

void solve() {
  int n, k;
  cin >> n >> k;
  vector<int> xs;
  vector<pii> v;
  for(int i = 0; i < n; i++) {
    int x, y;
    cin >> x >> y;
    v.emplace_back(x, y);
    xs.push_back(x);
  }
  sort(xs.begin(), xs.end());
  xs.resize(unique(xs.begin(), xs.end()) - xs.begin());
  ll ret = 4e18;
  for(int xR: xs) {
    for(int xL: xs) {
      if(xL > xR) continue;
      vector<int> ys;
      for(pii out: v) {
        if(out.first >= xL && out.first <= xR) ys.push_back(out.second);
      }
      sort(ys.begin(), ys.end());
      for(int i = k; i <= ys.size(); i++) {
        ll cand = xR - xL;
        cand *= (ys[i-1] - ys[i-k]);
        ret = min(ret, cand);
      }
    }
  }
  cout << ret << "\n";
}


void casesolve() {
  int t;
  cin >> t;
  for(int i = 1; i <= t; i++) {
    cout << "Case #" << i << ": ";
    solve();
  }
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL); cout.tie(NULL);
  solve();
  // casesolve();
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define xrep(i, a, b) for (int i = int(a); i < int(b); ++i)
int K;
int A, B;
int main() {
    cin >> K;
    cin >> A >> B;
    bool ansFlag = false;
    xrep(i, A, B+1) {
        if(i%K==0) {
            ansFlag = true;
        }
        else{
            continue;
        }
    } 

    if(ansFlag) cout << "OK" << endl;
    else cout << "NG" << endl;
    return 0;
}

Measured memory_bytes: 3660
#include <stdio.h>

int myabs(int a) {
	return a<0?-a:a;
}

int mymax(int a,int b) {
	return a>=b?a:b;
}

int getCost(int sx,int sy,int tx,int ty) {
	int dx=myabs(sx-tx);
	int dy=myabs(sy-ty);
	if((sx-tx)*(sy-ty)>=0) {
		return mymax(dx,dy);
	} else {
		return dx+dy;
	}
}

int main(void) {
	int N,i;
	int x,y;
	int answer=0;
	scanf("%*d%*d%d",&N);
	scanf("%d%d",&x,&y);
	for(i=1;i<N;i++) {
		int next_x,next_y;
		scanf("%d%d",&next_x,&next_y);
		answer+=getCost(x,y,next_x,next_y);
		x=next_x;
		y=next_y;
	}
	printf("%d\n",answer);
	return 0;
}

Measured memory_bytes: 596
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <bitset>
#include <numeric>
#include <complex>
#include <iomanip>
#include <cassert>
#include <random>


int main() {
    int n, k; std::cin >> n >> k;
    if (k > (n - 1)*(n - 2) / 2) {
        std::cout << -1 << std::endl;
        return 0;
    }
    bool edg[102][102];
    for (int i = 0; i < n; i++)
        for (int j = 0; j < n; j++)
            edg[i][j] = false;
    std::vector<std::pair<int, int>> ans;
    for (int i = 0; i < n - 1; i++) {
        ans.emplace_back(i + 1, n);
        edg[i][n - 1] = true;
    }
    for (int t = 0; t < (n - 1)*(n - 2) / 2 - k; t++) {
        [&]() {
            for (int i = 0; i < n; i++) {
                for (int j = i + 1; j < n; j++) {
                    if (edg[i][j]) continue;
                    edg[i][j] = true;
                    ans.emplace_back(i + 1, j + 1);
                    return;
                }
            }
        }();
    }
    std::cout << ans.size() << std::endl;
    for (const auto &e : ans)
        std::cout << e.first << " " << e.second << std::endl;
    return 0;
}


Measured memory_bytes: 384
#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
#include <string>
#include <algorithm>
#include <iostream>
#include <string>
#include <map>
#include <set>
#include <functional>
#include <iostream>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int n,m;
int a[1001];

int main(void){
	scanf("%d%d",&n,&m);
	for(int i=0;i<n;i++){
		scanf("%d",&a[i]);
	}
	int v=0,sum=0;
	while(1){
		int ma=a[v],mi=a[v];
		v=(v+1)%n;
		for(int i=1;i<m;i++){
			ma=max(ma,a[v]);
			mi=min(mi,a[v]);
			v=(v+1)%n;
		}
		sum+=ma-mi;
		if(v==0)break;
	}
	printf("%d\n",sum);
	return 0;
}

Measured memory_bytes: 3204
using System;

class program
{
    public static int Main()
    {
        var S = int.Parse(Console.ReadLine());

        var h = S / (60 * 60);
        S %= (60 * 60);
        var m = S / 60;
        S %= 60;
        var s = S;

        Console.WriteLine("{0}:{1}:{2}", h, m, s);

        return 0;
    }
}

Measured memory_bytes: 19944
#include<iostream>
#include<cstdio>
#include<cstring>
namespace Jiang_Guo_De_Ti
{
	const int N=101000,M=N*2;
	int begin[N],next[M],to[M];
	int f[N];
	int n,e;
	void add(int x,int y,bool k=1)
	{
		to[++e]=y;
		next[e]=begin[x];
		begin[x]=e;
		if(k)add(y,x,0);
	}
	void initialize()
	{
		e=0;
		scanf("%d",&n);
		for(int i=1,u,v;i<n;i++)
			scanf("%d%d",&u,&v),add(u,v);
	}
	void dfs(int p,int h=0)
	{
		for(int i=begin[p];i;i=next[i])
			if(to[i]!=h)dfs(to[i],p);
		f[p]=0;
		for(int i=begin[p],q;i;i=next[i])
			if((q=to[i])!=h)f[p]^=f[q]+1;
	}
	void solve()
	{
		initialize();
		dfs(1);
		if(f[1])printf("Alice\n");
		else printf("Bob\n");
	}
}
int main()
{
	Jiang_Guo_De_Ti::solve();
	return 0;
}


Measured memory_bytes: 7296
#include <bits/stdc++.h>
using namespace std;
int main () {
    int N;
    cin >> N;
    long long x = 0, y = 0;
    for (int i = 0; i < N; i++) {
        long long T, A;
        cin >> T >> A;
        if (i == 0) {
            x = T, y = A;
        }
        else {
            long long a = x/T, b = y/A;
            if (a*T < x) a++;
            if (b*A < y) b++;
            x = max(a, b) * T, y = max(a, b) * A;
        }
    }
    cout << x+y << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
  int num[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  int k;
  scanf("%d", &k);
  printf("%d", num[k-1]);
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout<< (x) << " "

int main(){
    ll d,n;cin>>d>>n;
    if(d==0){co(n==100?101:n);return 0;}
    if(d==1){co(n==100?101*100:100*n);return 0;}
    if(d==2){co(n==100?101*10000:10000*n);return 0;}
}

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

void input_vec(vector<int>& vec, int j){
	int p, c, x;
	cin >> p >> c;
	vec.clear();

	vec.push_back(0);
	for(int i=1; i<p+1; i++){
		vec.push_back(vec[i-1] + 100*j);
	}
	vec[vec.size()-1] += c;
}

void update_dp(vector<int>& a, vector<int>& b){
	vector<int> res(a.size() + b.size() - 1);
	for(int i=0; i<b.size(); i++){
		for(int j=0; j<a.size(); j++){
			res[i+j] = max(res[i+j], a[j]+b[i]);
		}
	}
	a = res;
}

int main(){
	int d, g;
	cin >> d >> g;
	vector<int> a;
	vector<int> b;

	input_vec(a, 1);
	for(int j=1; j<d; j++){
		input_vec(b, j+1);
		update_dp(a, b);
	}

	for(int i=0; i<a.size(); i++){
		if(a[i] >= g){
			cout << i << endl;
			return 0;
		}
	}
}

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


using namespace std;

typedef long long ll;

#define pi 2*acos(0.0)
#define eps 1e-9
const int N = 10000000;
bool isprime[N+1];

void sieve()
{
    memset(isprime,true,sizeof(isprime));
    isprime[0]=isprime[1]=false;

    for(ll i=2; i*i<=N; i++)
    {
        if(isprime[i])
        {
            for(ll j=i*i; j<=N; j+=i)
            {
                isprime[j]=false;
            }
        }
    }
}


int main(void)
{
    //ios_base::sync_with_stdio(false);
    //cin.tie(0);
    //cout.tie(0);

    ll n,ans=0;
    cin>>n;
    ans += (n/500) * 1000;
    n = n%500;
    ans += (n/5)*5;
    cout<<ans<<endl;



}



Measured memory_bytes: 3632
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N = 2e5 + 10;
#define fi first
#define se second
#define pb push_back
#define wzh(x) cerr<<#x<<'='<<x<<endl;
int r,c,k;
struct uzi{
  int r,c,v;
  bool operator <(const uzi & t)const{
    if(r==t.r)return c<t.c;
    return r<t.r;
  }
}p[N];
int ok[3333];
LL dp[3333][3333];
LL st[3333][4];
int main() {
  ios::sync_with_stdio(false);
  cin>>r>>c>>k;
  for(int i=1;i<=k;i++){
    cin>>p[i].r>>p[i].c>>p[i].v;
  }
  sort(p+1,p+1+k);
  int l=1;
  for(int i=1;i<=r;i++){
    while(l<=k&&p[l].r<i)l++;
    for(int j=1;j<=c;j++){
      dp[i][j]=dp[i-1][j];
      for(int ne=0;ne<=3;ne++)st[j][ne]=0;
    }
    if(p[l].r!=i){
      continue;
    }
    int ra=l;
    for(int j=1;j<=c;j++)ok[j]=0;
    while(ra+1<=k&&p[ra+1].r==i)ra++;

  //  cout<<i<<' '<<l<<' '<<ra<<endl;
    for(int j=l;j<=ra;j++){
      ok[p[j].c]=p[j].v;
    }
    for(int j=1;j<=c;j++){
      if(ok[j]){
        for(int ne=1;ne<=3;ne++){
          st[j][ne]=max(st[j-1][ne-1]+ok[j],st[j-1][ne]);
        }
        st[j][1]=max(st[j][1],dp[i-1][j]+ok[j]);
        st[j][0]=max(st[j-1][0],dp[i-1][j]);
      }else{
        for(int ne=1;ne<=3;ne++){
          st[j][ne]=st[j-1][ne];
        }
        st[j][0]=max(st[j-1][0],dp[i-1][j]);
      }
      for(int ne=0;ne<=3;ne++){
        dp[i][j]=max(dp[i][j],st[j][ne]);
      }
    }
    l=ra+1;
  }
  cout<<dp[r][c];
  return 0;
}


Measured memory_bytes: 84160
#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, ans = 0, a, b = -1;
  cin >> n;
  rep(i, n) {
    cin >> a;
    if (b > 0 && a > 0) a--, ans++;
    ans += a / 2;
    b = a % 2;
  }

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


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define itn int
#define rep(i, n) for (int i = 0; i < n; i++)

using namespace std;
typedef long long ll;

int main() {
    int a,b,c;
    cin >> a >> b >> c;
    if(a<c&&b>c){
        cout << "Yes" << endl;
    }
    else if(a>c&&b<c){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}

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

void init() {
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
}

void solve() {
	int n, t; scanf("%d %d", &n, &t);
	int minc = 2e9, maxc = 0;
	vector<int> v;
	for (int i = 0; i < n; ++i) {
		int a; scanf("%d", &a);
		if (a < minc) {
			if (maxc) {
				v.push_back(maxc-minc);
			}
			minc = maxc = a;
		}
		if (a > maxc) maxc = a;
	}
	v.push_back(maxc-minc);
	sort(v.begin(), v.end(), greater<int>());
	int ans = 1, c = v[0];
	for (int i = 1; v[i] == c; ++i) ++ans;
	printf("%d", ans);
}

int main() {
	init();
	int t = 1; //scanf("%d", &t);
	while (t--) {
		solve();
	}
	return 0;
}


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

using namespace std;

inline int read()
{
   int x=0,f=1;char ch=getchar();
   while (!isdigit(ch)){if (ch=='-') f=-1;ch=getchar();}
   while (isdigit(ch)){x=(x<<1)+(x<<3)+ch-'0';ch=getchar();}
   return x*f;
}

const int maxn = 1e6+1e2;

struct Node{
	int vis[410];
};

int x[maxn],y[maxn];
Node a[410];
int n,m;
int ans;
int tag[maxn];

int main()
{
  n=read(),m=read();
  for (register int i=1;i<=m;++i)
    x[i]=read(),y[i]=read();
  for (register int i=1;i<=n;++i)
  {
  	 a[i].vis[i]=1;
  	 for (register int j=m;j>=1;--j)
	   {
  	       if ((!a[i].vis[x[j]]) && (!a[i].vis[y[j]])) continue;
		   if (a[i].vis[x[j]] &&a[i].vis[y[j]]) tag[i]=1;
		   a[i].vis[x[j]]=1;
		   a[i].vis[y[j]]=1;	
  	   }
  }
  for (register int i=1;i<=n;++i)
  {
  	 if (tag[i]) continue;
  	 for (register int j=i+1;j<=n;++j)
  	 {
  	 	if (tag[j]) continue;
  	 	int k;
  	 	for (k=1;k<=n;++k)
  	 	  if (a[i].vis[k] && a[j].vis[k]) break;
  	 	if (k==n+1) ++ans;
  	 }
  }
  cout<<ans;
  return 0;
}


Measured memory_bytes: 6400
#include <stdio.h>
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>


using namespace std;

int main() {
    long long N;
    scanf("%lld", &N);
    vector<long long> A;
    A.resize(N);
    for(long long i = 0;i < N;i++) {
        scanf("%lld", &A[i]);
        A[i] -= i + 1;
    }
    sort(A.begin(), A.end());
    vector<long long> S;
    S.resize(N);
    S[0] = A[0];
    for(long long i = 1;i < N;i++) {
        S[i] = A[i] + S[i - 1];
    }
    long long x = N/2;
    long long saisyo = 2*(x + 1)*A[x] - 2*S[x] - N*A[x] + S[N - 1];
    for(long long b = A[x];b <= A[x + 1];b++) {
        long long po = 2*b*(x + 1) - 2*S[x] - N*b + S[N - 1];
        saisyo = min(saisyo, po);
    }
    printf("%lld\n", saisyo);
    return 0;
}

Measured memory_bytes: 3328
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
main(){
    int N,X;
    cin >> N >> X;
    rep(i,0,N*2-1){
        cout << X - N + i + 1 << " ";
    }
}

Measured memory_bytes: 256
a, b, k = map(int, input().split())

s1 = [i for i in range(a, a+k) if i<=b]
s2 = [i for i in range(b-k+1, b+1) if i>=a]

s = list(set(s1+s2))
s.sort()

for i in s:
    print(i)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
//const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i <= (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,m,n) for(ll i = (m); i <= n; i++){cout << (x[i]) << " ";} cout<<endl;

ll x, y;

#include <iostream>
using namespace std;

const int MAX = 700000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main(){
	cin.tie(0); ios::sync_with_stdio(false);
	
	cin >> x >> y;
	if(x > y){
		ll tmp = x;
		x = y;
		y = tmp;
	}
	if(y-x > x){print(0) return 0;}
	if((x+y)%3 != 0){print(0) return 0;}
	ll n = (x+y)/3;
	ll m = x-y;
	ll a = (n-m)/2;
	ll b = a+m;

	COMinit();
	cout << COM(n, a) << endl;
	return 0;
}

Measured memory_bytes: 16640