akhauriyash/Code-Regression huggingface dataset:
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author anand.oza
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        BIronBarCutting solver = new BIronBarCutting();
        solver.solve(1, in, out);
        out.close();
    }

    static class BIronBarCutting {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            long[] a = in.readLongArray(n);
            long[] sum = new long[n + 1];
            for (int i = 0; i < n; i++) {
                sum[i + 1] = sum[i] + a[i];
            }

            long min = Long.MAX_VALUE;
            for (int i = 0; i <= n; i++) {
                min = Math.min(min, Math.abs(sum[i] - (sum[n] - sum[i])));
            }
            long answer = min;

            out.println(answer);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public long[] readLongArray(int n) {
            long[] x = new long[n];
            for (int i = 0; i < n; i++) {
                x[i] = nextLong();
            }
            return x;
        }

    }
}



Measured memory_bytes: 54944
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC061A
{
	class Program
	{
		static void Main(string[] args)
		{
            int a, b, c;

			var word = Console.ReadLine().Split(' ');
            a = int.Parse(word[0]);
            b = int.Parse(word[1]);
            c = int.Parse(word[2]);

            if ((a <= c) && (c <= b))
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }

			Console.ReadKey();
		}
	}
}


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

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

	int c[3] = { 0 };
	int N;
	cin >> N;
	for(int i = 0; i < N; i++) {
		int a;
		cin >> a;
		int cnt = 0;
		while(a % 2 == 0) {
			cnt++;
			a /= 2;
		}
		if(cnt == 0) c[0]++;
		else if(cnt == 1) c[1]++;
		else c[2]++;
	}

	int head = -1;
	if(c[1]){
		head = 1;
	}
	else if(c[0]){
		head = 0;
		c[0]--;
	}
	else {
		head = 2;
		c[2]--;
	}
	while(c[0] != 0 || c[2] != 0) {
		if(head == 2) {
			if(c[0]) {
				c[0]--;
				head = 0;
			}
			else {
				c[2]--;
			}
		}
		else {
			if(c[2] == 0) {
				cout << "No" << endl;
				return 0;
			}
			c[2]--;
			head = 2;
		}
	}
	cout << "Yes" << endl;
}


Measured memory_bytes: 256
N, M = map(int, input().split())
a = [int(input()) for _ in range(M)]

MOD = 10**9 + 7

dp = [1 for _ in range(N + 1)]
#print(dp)
for A in a:
    dp[A] = 0
for i in range(2, N + 1):
    if dp[i]:
        dp[i] = (dp[i - 1] + dp[i - 2]) % MOD
ans = dp[N]
print(ans)


Measured memory_bytes: 7884
import java.util.*;

public class Main {
	public static void main(String[] args) {  
  		Scanner sc = new Scanner(System.in);
      	int N = sc.nextInt();
      	
      	if(N <= 999) {
          	System.out.println("ABC");
        } else {
        	System.out.println("ABD");  
        }
    }
}

Measured memory_bytes: 21716
/*-------enazuma11----------------*/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define pii pair<int,int>
#define pll pair<long long,long long>
#define all(v) v.begin(),v.end()
#define inc(a,n) sort(a,a+n)
#define dec(a,n) sort(a,a+n,greater<int>() )
#define rep(i,a,b) for(i=a;i<b;i++)
#define repr(i,a,b) for(i=a;i>b;i--)
#define F first
#define S second
#define M 1000000007
#define sz(x) (int)x.size()

/* int x[]={-1,-1,0,1,1,1,0,-1};
int y[]={0,1,1,1,0,-1,-1,-1};
*/
/* int x[]={-1,0,1,0};
int y[]={0,1,0,-1};
*/

void solve()
{
int n;
cin>>n;
int a[n];
int i,j;
rep(i,0,n)
cin>>a[i];

double s=0;
rep(i,0,n){
	s+=1.0/a[i];
}
double ans = 1.0/s;
cout<<fixed<<setprecision(6)<<ans<<'\n';
}

int main() 
{
	ios::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
	int t=1;
	//cin>>t;
	while(t--){
		solve();
	}
	return 0;
}

Measured memory_bytes: 256
N, K = map(int, input().split())
R, S, P = map(int, input().split())
T = list(input())

tmp = 1
mod = 1
score =0

while mod <= K:
    i = 0
    while i * K + mod - 1 < len(T):
        if (i + 1) * K + mod - 1 >= len(T):
            if T[i * K + mod - 1] == 'r':
                score += P
            elif T[i * K + mod - 1] == 's':
                score += R
            else:
                score += S
            i += 1
        else:
            if T[i * K + mod - 1] != T[(i + 1) * K + mod - 1]:
                if T[i * K + mod - 1] == 'r':
                    score += P
                elif T[i * K + mod - 1] == 's':
                    score += R
                else:
                    score += S
                i += 1
            else:
                if T[i * K + mod - 1] == 'r':
                    score += P
                elif T[i * K + mod - 1] == 's':
                    score += R
                else:
                    score += S
                i += 2
    mod += 1

print(score)


Measured memory_bytes: 4212
use std::str::FromStr;
use std::collections::HashMap;


fn get_one<T : FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    return s.trim().parse().ok().unwrap();
}

fn get_vec<T : FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    return s.trim().split_whitespace().map(|e| e.parse().ok().unwrap()).collect();
}

fn main() {
    let n : usize = get_one();
    let v : Vec<i64> = get_vec();

    let mut map = HashMap::new();
    for x in v {
        *map.entry(x).or_insert(0) += 1;
    }
    let mut fst : i64 = 0;
    let mut snd : i64 = 0;
    for (k,v) in map.iter() {
        //println!("{} {}", k, v);
        if v >= &4 {
            if fst < *k {
                snd = *k;
                fst = *k;
            }
            else if snd < *k {
                snd = *k;
            }
        }
        else if v >= &2{
            if fst < *k {
                snd = fst;
                fst = *k;
            }
            else if snd < *k {
                snd = *k;
            }
        }
    }
    println!("{}", fst * snd);
}


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

using namespace std;
using ll = long long;
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
    REP(i,v.size()){if(i)os<<" ";os<<v[i];}return os;}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
    REP(i,v.size()){if(i)os<<endl;os<<v[i];}return os;}
#define vi vector<int>
#define vii vector<vector<int>>
#define mii map<int,int>
#define Sort(v) sort(v.begin(),v.end())
#define Reverse(v) reverse(v.begin(),v.end())
#define ALL(a)  (a).begin(),(a).end()
#define pb push_back
#define mp make_pair
//#define int ll

const int md = 1000000007;
const int INF = 1<<30;

int main(){
    ll n,k; cin >> n >> k;
    ll sum = 0;

    rep(i,k,n+2){
        sum += n*(n+1)/2 - (n-i)*(n-i+1)/2 - i*(i-1)/2 +1;
        sum %= md;
        //cout << sum << endl;
    }

    cout << sum << endl;
}


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

int main() {
  int N;
  cin >> N;
  
  vector <int> a(N);
  
  for ( int i = 0; i < N; i++){
    cin >> a.at(i);
  }
  
  sort(a.begin(),a.end());
  reverse(a.begin(),a.end());
  
  int Alice = 0;
  int Bob = 0;
  
  for ( int i =0; i < N; i++){
    if ( i % 2 == 0){
      Alice += a.at(i);
    }else{
      Bob += a.at(i);
    }
  }
  
  cout << Alice - Bob << endl;
  
}

Measured memory_bytes: 256
// Problem : I - Coins
// Contest : AtCoder - Educational DP Contest
// URL : https://atcoder.jp/contests/dp/tasks/dp_i
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/coder3101/cp-editor)

// $%U%$
// Mere bas ka nahi hai
// still i'm trying
// apna time aayega
//
//        .--------------.  
//        | Try First One|
//        '--------------'
//                |     .--------------.
//                |     |              |
//                V     V              |
//              .--------------.       |
//              |      AC.     |<---.  |  
//              '--------------'    |  |
//              (True)|  |(False)   |  |
//           .--------'  |          |  |
//           |           V          |  |
//           |  .--------------.    |  |
//           |  |   Try Again  |----'  |
//           |  '--------------'       |
//           |                         |
//           |  .--------------.       |
//           '->| Try Next One |-------'
//              '--------------'                          		  
//
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll power(ll x,ll y,ll m){if(y==0)return 1;ll p=power(x,y/2,m)%m;p=(p*p)%m;return (y%2==0)?p:(x*p)%m;}
ll nCr(ll n,ll r,ll m){if(r>n)return 0;ll a=1,b=1,i;for(i=0;i<r;i++){a=(a*n)%m;--n;}while(r){b=(b*r)%m;--r;}return (a*power(b,m-2,m))%m;}
#define Test int t;cin>>t;while(t--)
#define endl '\n'
void solve()
{
	int n;
	cin >> n;
	vector<double> dp(n+1);
	dp[0]=1;
	for(int i=0;i<n;++i)
	{
		double t;
		cin >> t;
		for(int j=i+1;j>=0;--j)
		{
			if(j==0)
			dp[j]=dp[j]*(1-t);
			else
			dp[j]=dp[j-1]*t+dp[j]*(1-t);
		}
	}
	double ans=0;
	for(int i=1;i<=n;++i)
	{
		if(i>n-i)
		ans+=dp[i];
	}
	printf("%.10f",ans);
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	//Test
	solve();
	return 0;
}


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

struct Person {
  int a, b, c;
};

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

  int x, y, z; cin >> x >> y >> z;
  int n = x + y + z;
  vector<Person> v(n);
  for (auto &p : v) {
    cin >> p.a >> p.b >> p.c;
  }

  sort(v.begin(), v.end(), [](const Person &a, const Person &b) {
    return a.a - a.b > b.a - b.b;
  });

  vector<long long> pref(n);
  priority_queue<int> pq;
  long long curr = 0;
  for (int i = 0; i < x; ++i) {
    pq.emplace(v[i].c - v[i].a);
    curr += v[i].a;
    pref[i] = curr;
  }

  for (int i = x; i < x + z; ++i) {
    pq.emplace(v[i].c - v[i].a);
    curr += pq.top(); pq.pop();
    curr += v[i].a;
    pref[i] = curr;
  }

  vector<long long> suff(n);
  while (!pq.empty()) pq.pop();
  curr = 0;
  for (int i = n - 1; i >= n - y; --i) {
    curr += v[i].b;
    pq.emplace(v[i].c - v[i].b);
    suff[i] = curr;
  }

  for (int i = n - y - 1; i >= n - y - z; --i) {
    pq.emplace(v[i].c - v[i].b);
    curr += pq.top(); pq.pop();
    curr += v[i].b;
    suff[i] = curr;
  }

  long long ans = 0;
  for (int i = 0; i < n - 1; ++i) {
    ans = max(ans, pref[i] + suff[i + 1]);
  }

  cout << ans << endl;
}


Measured memory_bytes: 3708
package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	N, M := ReadInt(), ReadInt()
	H := ReadInts(N)
	graph := make([][]int, N)
	for i := 0; i < M; i++ {
		a, b := ReadInt()-1, ReadInt()-1
		graph[a] = append(graph[a], b)
		graph[b] = append(graph[b], a)
	}

	cnt := 0
	for i := 0; i < N; i++ {
		ok := true
		for _, j := range graph[i] {
			if H[i] <= H[j] {
				ok = false
				break
			}
		}
		if ok {
			cnt++
		}
	}
	fmt.Println(cnt)
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int)       { Scan(&i); return }
func ReadString() (s string) { Scan(&s); return }
func ReadInts(n int) []int {
	v := make([]int, n)
	for i := 0; i < n; i++ {
		Scan(&v[i])
	}
	return v
}


Measured memory_bytes: 12932
#include<stdio.h>
int main(void){
int a,b,c,k,i;
    scanf("%d %d %d",&a,&b,&c);
    scanf("%d",&k);

    for(i=0;i<k;i++){
        if(a>=b) b*=2;
        else if(b>=c) c*=2;
    }
    if(a<b && b<c)printf("Yes");
    else printf("No");
return 0;
}

Measured memory_bytes: 1720
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<list>
#include<set>
#include<string>
using namespace std;
int gcd(int a, int b) {
	int c = a % b;
	while (c != 0) {
		a = b;
		b = c;
		c = a % b;
	}
	return b;
}
struct UnionFind {
	vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

	UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
		for (int i = 0; i < N; i++) par[i] = i;
	}

	int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
		if (par[x] == x) return x;
		return par[x] = root(par[x]);
	}

	void unite(int x, int y) { // xとyの木を併合
		int rx = root(x); //xの根をrx
		int ry = root(y); //yの根をry
		if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
		par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
	}

	bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
		int rx = root(x);
		int ry = root(y);
		return rx == ry;
	}
};
typedef long long ll;

const ll M = 1000000007;

vector<ll> fac(300001); //n!(mod M)
vector<ll> ifac(300001); //k!^{M-2} (mod M)

ll mpow(ll x, ll n) {
	ll ans = 1;
	while (n != 0) {
		if (n & 1) ans = ans * x % M;
		x = x * x % M;
		n = n >> 1;
	}
	return ans;
}
ll comb(ll a, ll b) {
	if (a == 0 && b == 0)return 1;
	if (a < b || a < 0)return 0;
	ll tmp = ifac[a - b] * ifac[b] % M;
	return tmp * fac[a] % M;
}

#define INF 1e+15
#define MAX_V 110000

struct edge {
	int to;
	ll cost;
};

// <最短距離, 頂点の番号>
using P = pair<ll, int>;

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

void dijkstra(int s) {
	priority_queue<P, vector<P>, greater<P> > que;
	fill(d, d + V+1, INF);
	d[s] = 0;
	que.push(P(0, s));

	while (!que.empty()) {
		P p = que.top();
		que.pop();
		int v = p.second;
		if (d[v] < p.first) continue;

		for (int i = 0; i < G[v].size(); ++i) {
			edge e = G[v][i];
			if (d[e.to] > d[v] + e.cost) {
				d[e.to] = d[v] + e.cost;
				que.push(P(d[e.to], e.to));
			}
		}
	}
}

int main() {
	cin >> V;
	int E;
	cin >> E;
	int s, t,i,u[111111],v[111111],b[111111];
	cin >> s >> t;
	for (int i = 0; i < E; ++i) {
		int a;
		cin >> u[i] >> v[i] >> a>>b[i];
		edge e = { u[i], a };
		G[v[i]].push_back(e);
		e = { v[i], a };
		G[u[i]].push_back(e);
	}
	ll d1[111111], d2[111111],mi=INF;
	dijkstra(s);
	for (i = 1; i <= V; i++)
		d1[i] = d[i];
	for(i=1;i<=V;i++)
		G[i].erase(G[i].begin(), G[i].end());
	for (i = 0; i < E; i++) {
		edge e = { u[i], b[i] };
		G[v[i]].push_back(e);
		e = { v[i], b[i] };
		G[u[i]].push_back(e);
	}
	dijkstra(t);
	for (i = 1; i <= V; i++)
		d2[i] = d[i];
	ll ans[111111];
	for (i = V; i >=1; i--) {
		mi = min(mi, d1[i] + d2[i]);
		ans[i] = 1000000000000000 - mi;
	}
	for (i = 1; i <= V; i++)
		cout << ans[i] << endl;
}

Measured memory_bytes: 18816
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
#include <map>
#include <cmath>
#include <numeric>
#include <iomanip>
#include <set>
#include <string.h>

using namespace std;

typedef long long ll;

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define REP3(i,st,en) for(ll (i)=(st);(i)<(en);(i)++)

using P = pair<ll, ll>;
const int MOD = 1e9+7;
const ll INF = 1e+14;
const double PI = 3.14159265349;


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

  ll H, N;
  cin >> H >> N;
  vector<ll> A(N), B(N);
  REP(i,N){
    cin >> A[i] >> B[i];
  }

  ll dpmax = H+*max_element(A.begin(), A.end());
  vector<ll> dp(dpmax, INF);
  dp[0] = 0;

  REP(h, dpmax){
    REP(i,N){
      if (h>=A[i]){
        dp[h] = min(dp[h], dp[h-A[i]]+B[i]);
      }
    }
  }

  ll ans = *min_element(dp.begin()+H, dp.end());
  cout << ans << "\n";
}


Measured memory_bytes: 384
//#pragma GCC optimize("trapv")
#include <iostream>
#include <vector>
#include <tuple>
#include <deque>
#include <set>
#include <map>
#include <cmath>
#include <string>
#include <cassert>
#include <iomanip>
#include <algorithm>
#include <unordered_set>
#define int long long
#define all(x) (x).begin(), (x).end()
#define allr(x) (x).rbegin(), (x).rend()

using namespace std;

const int MOD = 1e9 + 7;
const int INF = 2e9;

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

signed main()
{
	fast();
	string s;
	cin >> s;
	int sum = 0;
	for (auto e : s)
		sum += e - '0';
	if (sum % 9 == 0)
		cout << "Yes\n";
	else
		cout << "No\n";
	return 0;
}


Measured memory_bytes: 3688
#include <bits/stdc++.h>
using namespace std;
#define ll long long int

int main(){
   int k,n;
   cin>>n>>k;
   vector<int> arr(n);
   int l=1,r=0;
   for(int i=0;i<n;i++){
       cin>>arr[i];
       r=max(r,arr[i]);
   }
   while(l!=r){
       int m=(l+r)/2;
       int s=0;
       for(int i=0;i<n;i++){
           s+=(arr[i]-1)/m;
       }
       if(s<=k)
        r=m;
       else
        l=m+1;
   }
   cout<<l<<endl;
}
   

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

int main(){
    ll x;
    cin >> x;
    ll a = 100;
    ll cnt = 0;
    while(a<x){
        a = a * 1.01;
        cnt++;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 3636
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int main(void){
  int ans = 0;
  int cnt = 0;
  int n;
  int old, new;

  scanf("%d", &n);
  scanf("%d", &old);

  for(int i = 1; i < n; i++){
    scanf("%d", &new);

    if(old == new){
      cnt++;
      if(cnt % 2 == 1){
	ans++;
      }
    }else{
      cnt = 0;
    }
    old = new;
  }

  printf("%d\n", ans);

  return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<utility>
#include<set>
#include<stack>
#include<list>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cstring>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<cmath>
#include<cctype>


#define pb push_back
#define mp make_pair
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define ren(i,a,b) for(int i=a;i>=b;i--)
#define ff first
#define ss second
#define pll pair<long long int,long long int>
#define pii pair<int,int>
#define vll vector<long long int>
#define vii vector<int>
#define gi(n) scanf("%d",&n)
#define gll(n) scanf("%lld",&n)
#define gstr(n) scanf("%s",n)
#define gl(n) cin >> n
#define oi(n) printf("%d",n)
#define oll(n) printf("%lld",n)
#define ostr(n) printf("%s",n)
#define ol(n) cout << n
#define os cout<<" "
#define on cout<<"\n"
#define o2(a,b) cout<<a<<" "<<b
#define all(n) n.begin(),n.end()
#define present(s,x) (s.find(x) != s.end())
#define cpresent(s,x) (find(all(s),x) != s.end())
#define tr(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++)
using namespace std;

typedef unsigned long long int ull;
typedef long long int ll;
typedef long double ld;
typedef vector<vector<ll> > mat;

int main()
{ios_base::sync_with_stdio(false);
int a[4];
string s;
cin>>s;
rep(i,0,3)a[i]=s[i]-'0';

rep(msk,0,7)
{
	int res=a[0];
	rep(i,0,2)
	{
		if(msk&(1<<i))
		res+=a[i+1];
		else
		res-=a[i+1];
	}
	if(res==7)
	{
		ol(a[0]);
		rep(i,0,2)
		{
			if(msk&(1<<i))ol("+");
			else ol("-");
			ol(a[i+1]);
		}
		ol("=7");
		return 0;
	}
}


return 0;
}



Measured memory_bytes: 256
class Dice():
    def __init__(self):
        self.nums = list(range(6))
        self.work = list(range(6))

    def set_nums(self, n0, n1, n2, n3, n4, n5):
        self.nums[0] = n0
        self.nums[1] = n1
        self.nums[2] = n2
        self.nums[3] = n3
        self.nums[4] = n4
        self.nums[5] = n5

    def rotate(self, cmd):
        for i in range(6):
            # deepcopy
            self.work[i] = self.nums[i]

        if cmd == 'N':
            self.set_nums(self.work[1], self.work[5], self.work[2], self.work[3], self.work[0], self.work[4])
        elif cmd == 'S':
            self.set_nums(self.work[4], self.work[0], self.work[2], self.work[3], self.work[5], self.work[1]),
        elif cmd == 'E':
            self.set_nums(self.work[3], self.work[1], self.work[0], self.work[5], self.work[4], self.work[2])
        else:
            self.set_nums(self.work[2], self.work[1], self.work[5], self.work[0], self.work[4], self.work[3])

    def top(self):
        return self.nums[0]

    def right(self, top, front):
        # サイコロの面IDを返す
        if top == 1:
            return [3,5,2,4][front-2]
        elif top == 6:
            return [4,2,5,3][front-2]
        elif top == 2:
            # 0が返る場合は不正なサイコロ
            return [4,0,1,6,0,3][front-1]
        elif top == 5:
            # 0が返る場合は不正なサイコロ
            return [3,0,6,1,0,4][front-1]
        elif top == 3:
            # 0が返る場合は不正なサイコロ
            return [2,6,0,0,1,5][front-1]
        elif top == 4:
            # 0が返る場合は不正なサイコロ
            return [5,1,0,0,6,2][front-1]
        else:
            pass

nums = [int(arg) for arg in input().split()]
d = Dice()
d.set_nums(*nums)
for _ in range(int(input())):
    top, front = [int(arg) for arg in input().split()]
    right_id = d.right(nums.index(top)+1, nums.index(front)+1)
    print(nums[right_id-1])



Measured memory_bytes: 5620
#include <bits/stdc++.h>
#include <math.h>
#include <cmath>

using namespace std;
using ll =long long;
using vi = vector<int>; 
using vvi = vector<vi>; 
using vl = vector<ll>; 
using vvl = vector<vl>; 
using vs = vector<string>;
using vvs = vector<vs>; 
using vc = vector<char>;
using vvc = vector<vc>; 
using vb = vector<bool>;
using vvb = vector<vb>; 

#define rep(i,n) ;for( int i =0; i < n ; i ++)
#define all(a) a.begin(),a.end()
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define f(i,a,b) for(int i=a;i<b;i++)
#define pri(a)  printf("%.14lf\n",a);
#define MOD 1000000007
bool is_int_lround(double x){
  return std::lround(x)==x;
}
ll keta(ll x){
  ll n=0;
  while(x>0){
    x /=10 ;
    n ++;
  }
  return n;
}

ll conbi(int n,int m){
  
  cin>>n>>m;
  vector<ll> a(100);
  a[0] =1;
  for(int i=0;i<14;i++){
    a[i+1]=a[i]*(i+1);
  }
  return a[n] /(a[m] *a[n-m]);
}

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;//繰り返し二乗法
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
ll kaijo(ll x){
  ll z=1;
  if(x==0){
    return 1;
  }
  while(x>0){
    z *=x;
    z %=MOD;
    x--;
  }
  return z;
}
ll yakusu_num(ll n){
  vl yakusu(n+1,1);
  for(ll i=2;i*i<=n;i++){ 
    while(n%i==0){
      n /=i;
      yakusu[i]++;
    }
  }
  if(n!=1)yakusu[n]++;
  ll num=1;
  for(ll i=0;i<=n;i++){
    num*=yakusu[i];
  }
  return num;
}

int H,W;
vs s(50);
vi dv ={-1,0,1,0};vi du={0,-1,0,1};
int cnt=1;
int dfs(int u,int v){
  s[u][v]='.';
  
  rep(i,4){
   
      int nu =u +du[i],nv=v+dv[i];
      if(nu<0||nu>=H||nv<0||nv>=W)continue;
      if(s[nu][nv]=='.')continue;
      cnt ++;
      dfs(nu,nv);
    
  }
  return cnt;

}
int keta_wa(int x){
  int tot=0;
  while(x>0){
    tot +=x%10;
    x/=10;
  }
  return tot;
}

//vc alp(26) ={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
//cout<<""<<endl;
int main(){
  ll N;cin>>N;vl a(N);rep(i,N)cin>>a[i];
  sort(all(a));
  bool ok=true;
  ll ans=0;
  for(int i=0;i<N;i++){
    ll j=i+1;
    ll cnt= 1;
    while(a[i]==a[j] && j<N){
      cnt++;
      j++;
    }
    if(cnt<a[i] ){
      ans +=cnt;
    }
    else if(cnt>a[i]){
      ans +=cnt-a[i];
    }
    i =j-1;
  }
  cout<<ans<<endl;

}







Measured memory_bytes: 1024
import itertools
n,m=map(int,input().split())
A=[]
for i in range(m):
  a,b=map(int,input().split())
  A.append([a,b])
N=[int(i+2) for i in range(n-1)]
def f(list,n):
  path=0
  if [1,list[0]] in A:
    path+=1
  for i in range(1,n-1):
    if [list[i],list[i-1]] in A or [list[i-1],list[i]] in A:
      path+=1
  if path==n-1:
    return 1
  else:
    return 0  
ans=0
for p in itertools.permutations(N,n-1):
  ans+=f(list(p),n)
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
#include <cctype>
using namespace std;
long long n, k;
long long a[200020];
int main() {
#define int long long
	vector<int> kei;
	cin >> n >> k;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	kei.push_back(1);
	set<int> st;
	st.emplace(1);
	if (k < 1000000) {
		for (int i = 0; i < k; i++) {
			long long v = kei.size();
			kei.push_back(a[kei[v - 1] - 1]);
			st.emplace(a[kei[v - 1] - 1]);
		}
		int v = kei.size();
		cout << kei[v - 1] << endl;
		return 0;
	}
	for (;;) {
		long long v = kei.size();
		kei.push_back(a[kei[v - 1] - 1]);
		long long co = st.size();
		st.emplace(a[kei[v - 1] - 1]);
		if (co == st.size()) {
			long long ans = kei.size() - 1;
			long long co2;
			for (int i = 0; i <= ans; i++) {
				if (kei[i] == a[kei[v - 1] - 1]) {
					ans = ans - i;
					k -= i;
					co2 = i;
					break;
				}
			}
			cout << kei[k % ans + co2] << endl;
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 13632
/**
 *    author  : 𝒌𝒚𝒐𝒎𝒖𝒌𝒚𝒐𝒎𝒖𝒑𝒖𝒓𝒊𝒏
 *    created : 2020-03-27 14:35:03
**/

#include <iostream>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
#include <bitset>
#include <cassert>
#include <cctype>
#include <iomanip>
#include <random>
#include <utility>
#include <chrono>

using namespace std;

using int64 = long long;

template<class T> using binary_heap = std::priority_queue<T, std::vector<T>, std::greater<T>>;
template<class T> std::ostream& operator<<(std::ostream& os, const std::vector<T>& vec) { os << '{'; size_t n = vec.size(); for (size_t i = 0; i < n; ++i) { os << vec[i]; if (i != n - 1) os << ','; } os << '}'; return os; }
template<class T, class U> std::ostream& operator<<(std::ostream& os, const std::pair<T, U>& p) { return os << '{' << p.first << " " << p.second << '}'; }
template<class T, class U> std::ostream& operator<<(std::ostream& os, const std::map<T, U>& mp) { os << '{'; for (auto it = mp.begin(); it != mp.end(); ++it) { os << '{' << it->first << ':' << it->second << '}'; if (it != --mp.end()) os << ','; } os << '}'; return os; }
template<class T> std::ostream& operator<<(std::ostream& os, const std::set<T>& st) { os << '{'; for (auto it = st.begin(); it != st.end(); ++it) { os << *it; if (it != --st.end()) os << ','; } os << '}'; return os; }
template<class T> std::istream& operator>>(std::istream& is, std::vector<T>& vec) { size_t n = vec.size(); for (size_t i = 0; i < n; ++i) is >> vec[i]; return is; }

#define all(_) begin(_), end(_)
#define rall(_) rbegin(_), rend(_)

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]: ", debug_out(__VA_ARGS__)
#else
#define debug(...) 1728
#endif

void debug_out() { std::cerr << '\n'; }

template <class Head, class... Tail>
void debug_out(Head&& head, Tail&&... tail) {
  std::cerr << head;
  if (sizeof...(Tail) != 0) std::cerr << ", ";
  debug_out(std::forward<Tail>(tail)...);
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);

  int64 a, b; cin >> a >> b;
  int64 x; cin >> x;

  auto f = [&](int64 t) -> int64 {
    if (t < 0) return 0LL;
    else return t / x + 1LL;
  };

  cout << f(b) - f(a - 1LL) << endl;

  return 0;
}

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

int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    sort(a.begin(), a.end());
    vector<int> tmp;
    vector<int> id;
    int now = -1;
    int cnt = 0;
    for (int i = 0; i < n; i++)
    {
        if (a[i] != now)
        {
            tmp.push_back(cnt);
            id.push_back(now);
            now = a[i];
            cnt = 1;
        }
        else
            cnt++;
    }
    tmp.push_back(cnt);
    id.push_back(now);
    int before = -1;
    for (int i = id.size() - 1; i >= 0; i--)
    {
        if (before != -1 && tmp[i] >= 2)
        {
            cout << (long long)before * id[i] << endl;
            return 0;
        }
        else if (tmp[i] >= 4)
        {
            cout << (long long)id[i] * id[i] << endl;
            return 0;
        }
        else if (before == -1 && tmp[i] >= 2)
            before = id[i];
    }
    cout << 0 << endl;
}

Measured memory_bytes: 1660
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const ll inf =1LL << 62;
const ll mod=1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b,const ll &mod) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b,const ll &mod) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b,const ll &mod) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b,const ll &mod) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
random_device rd;
mt19937 mt(rd());
uniform_int_distribution<int> dice(1,6);
uniform_real_distribution<double> score(0.0,10.0);

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

    string in; cin >> in;
    int n = (int)in.size();

    int l = 0, r = n - 1;
    int res = 0;
    while(r - l >= 1){
        if(in[l] == 'x'){
            if(in[r] == 'x'){
                l++;
                r--;
            }
            else {
                res++;
                l++;
            }
        }
        else {
            if(in[r] == 'x'){
                res++;
                r--;
            }
            else {
                if(in[l] != in[r]){
                    res = -1;
                    break;
                }
                l++;
                r--;
            }
        }
    }
    cout << res << endl;

    return 0;
}


Measured memory_bytes: 512
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;



int main() {
    int d, g;
    cin >>d >> g;
    vi p(d), c(d);
    rep(i, d)  {
        cin >> p[i] >> c[i];
    }

    vvi dp(d+1, vi(d*100+1, -1));
    dp[0][0] = 0;
    rep(i, d) {
        rep(j, d*100+1) {
            if(j >= p[i]) {
                rep(k, p[i]) {
                    if(dp[i][j-k] == -1) continue;
                    dp[i+1][j] = max(dp[i+1][j], dp[i][j-k] + (i+1)*100*k);
                }
                if(dp[i][j-p[i]] != -1) dp[i+1][j] = max(dp[i+1][j], dp[i][j-p[i]] + (i+1)*100*p[i] + c[i]);
            } else {
                rep(k, j+1) {
                    if(dp[i][j-k] == -1) continue;
                    dp[i+1][j] = max(dp[i+1][j], dp[i][j-k] + (i+1)*100*k);
                }
            }
        }
    }

    rep(i, d*100+1) {
        if(dp[d][i] == -1) {
            dp[d][i] =2*1e9;
        }
    }

    vi::iterator itr = lower_bound(all(dp[d]), g);
    cout << distance(dp[d].begin(), itr) << endl;
}

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

int main()
{
  int N, K;
  cin >> N >> K;
  vector<int> D(10);
  int d;
  for (int i = 0; i < K; i++)
  {
    cin >> d;
    D[d] = 1;
  }

  for (int i = N; i <= 100000; i++)
  {
    int c = i;
    bool ok = true;
    while (c)
    {
      if (D[c % 10])
      {
        ok = false;
        break;
      }
      c /= 10;
    }
    if (ok)
    {
      cout << i << endl;
      return 0;
    }
  }
  
  return 0;
}


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

int main(){
  int N;
  string s;
  cin >> N >> s;
  rep(i, s.size())
    rep(j, N)
      s.at(i) != 'Z' ? s.at(i)+=1 : s.at(i)='A';
  cout << s;
  return 0;
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author ky112233
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        BCollatzProblem solver = new BCollatzProblem();
        solver.solve(1, in, out);
        out.close();
    }

    static class BCollatzProblem {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int s = in.nextInt();
            Set<Integer> set = new HashSet<>();
            int cnt = 1;
            int temp = s;
            do {
                set.add(temp);
                if (temp % 2 == 0) temp /= 2;
                else temp = temp * 3 + 1;
                cnt++;
            } while (!set.contains(temp));
            out.println(cnt);
        }

    }
}



Measured memory_bytes: 21844
#include <bits/stdc++.h>
#include <algorithm>
#include <functional>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define DEBUG
#define PI 3.141592653589793238462643383279
 
#define _GLIBCXX_DEBUG
#ifdef DEBUG
#define s(...) show(__VA_ARGS__);
#define sl(...) show(__VA_ARGS__);cout<<endl;
#else
#define s(...)
#define sl(...)
#endif
void show() {}
template <class Head,class... Args>void show(Head t,Args... args){std::cout<<t<<" ";show(args...);}
#define REP(i, n) for(ll i = 0; i < n; i++)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOR(i, m, n) for(ll i = m; i < n; i++)
#define REP1(i, n) for(ll i = 1; i <= n; i++)
#define REPR1(i, n) for(ll i = n; i >= 1; i--)
#define FOR1(i, m, n) for(ll i = m; i <= n; i++)
const ll INF = LLONG_MAX;
#define VEC(type,A,N) vector<type> A(N)
#define VECi(type,A,N,i) vector<type> A(N,i)
#define VEC2(type,A,N,M) vector<vector<type>> A(N,vector<type>(M))
#define VEC2i(type,A,N,M,i) vector<vector<type>> A(N,vector<type>(M,i))
#define ALL(v) v.begin(), v.end()
ll frac(ll k){
    int s = 1;
    for (ll i=1; i<=k; ++i)s *= i;
    return s;
}
ll gcd(ll a, ll b){
   if (a%b==0)return(b);
   else return(gcd(b, a%b));
}
ll lcm(ll a,ll b){
    return a*b/gcd(a,b);
}
ll antidiv(ll N,ll C,ll D){
    return N-floor(N/C)-floor(N/D)+floor(N/lcm(C,D));
}
vector<ll> yakusuu(ll N){
    vector<ll> ret;
    for (ll i = 1; i * i <= N; i++) {
        if (N % i == 0) {
            ret.push_back(i);
            if (i * i != N) ret.push_back(N / i);
        }
    }
    sort(ret.begin(), ret.end());
    return ret;
}
int main(){
    ld N,K;
    cin>>N>>K;
    cout<<N*K;return 0;
    VEC(ld,kiti,N);
    VEC(ld,sum,N);
    ld m=0;
    REP(i,N){
        ld p;
        cin>>p;
        kiti[i]=(1.0+p)/2.0/p*p;
        if(i==0)sum[i]=kiti[i];else sum[i]=kiti[i]+sum[i-1];
        if(i>=K-1){
            m=max(m,sum[i]-sum[i-K]);
        }
    }
    if(K==N) cout<<fixed<<setprecision(10)<<sum[N-1];
    else cout<<fixed<<setprecision(10)<<m;
    //cout<<fixed<<setprecision(32)<<m;
    //sort(ALL(C),[](auto& a, auto& b) {return a[2] < b[2];});
    //if(equal(D.begin(), D.end()-1, K.begin()))cout<<"Yes";else cout<<"No";
    cout<<endl;
    return 0;
}


Measured memory_bytes: 3820
n, m = map(int, input().split())
edge = [list(map(int, input().split())) for _ in range(m)]


def dfs(v):
    global visited
    visited[v] = 1
    for u in range(1, n + 1):
        global graph
        if u in graph[v] and visited[u] == 0:
            dfs(u)


def main():
    ans = m
    for i in range(m):
        global graph
        graph = [[] for _ in range(n + 1)]
        for j, e in enumerate(edge):
            if i == j:
                continue
            v, u = e
            graph[v].append(u)
            graph[u].append(v)
        global visited
        visited = [0] * (n + 1)
        dfs(1)
        if all(visited[1:]):
            ans -= 1
    print(ans)


if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
#include <set>
#include <map>
#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>
using namespace std;
using ll = long long;
using VL=vector<ll>;

#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++)
constexpr long long INF = 999999999;

long long dp[105][100010],N,W,w[110],v[110];

int main(){
  cin >> N >>W;
  REP(i,N){
    cin >> w[i]>>v[i];
  }
  REP(i,W+1){
    dp[0][i]=0;
  }
  FOR(i,1,N+1){
    REP(j,W+1){
      if(j-w[i-1]>=0)dp[i][j]=max(dp[i-1][j],dp[i-1][j-w[i-1]]+v[i-1]);
      else dp[i][j]=dp[i-1][j];
    }
  }
  cout << dp[N][W]<<endl;
}

Measured memory_bytes: 80128
#include<bits/stdc++.h>
#define pb push_back
#define ef(i,u) for(int i=b[u];i;i=nxt[i])
#define rep(i,a,b) for(int i=a;i<=b;++i)
#define per(i,b,a) for(int i=b;i>=a;--i)
#define gcd(a,b) __gcd(a,b)
#define MEM(a,x) memset(a,x,sizeof(a))
#define VI vector<int>
#define PII pair<int,int>
#define ull unsigned long long
#define ll long long
#define fi first
#define se second
#define INF 0x3f3f3f3f
using namespace std;
const int N=2e5+5;
template<class T>inline void read(T &res)
{
char c;T flag=1;
while((c=getchar())<'0'||c>'9')if(c=='-')flag=-1;res=c-'0';
while((c=getchar())>='0'&&c<='9')res=res*10+c-'0';res*=flag;
}
ll x;
map<ll,ll>mp;
int main(){
    read(x);
    ll b=1;
    while(b*b*b*b*b<=1e11){
        mp[b*b*b*b*b]=b;
        b++;
    }
    for(ll i=1;i<=1e5;++i){
        ll t=i*i*i*i*i;
        if(x>t&&mp[x-t]){
            printf("%lld %lld\n",i,-mp[x-t]);
            break;
        }else if(x<t&&mp[t-x]){
            printf("%lld %lld\n",i,mp[t-x]);
            break;
        }else if(x==t){
            printf("%lld 0\n",i);
            break;
        }
    }
	return 0;
}


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

using namespace std;

int sum_digits(int n) {

  int sum = 0;

  while (n > 0) {
    sum += n % 10;
    n = n / 10;
  }

  return sum;
}

int main () {

  int a;
  cin >> a;

  int sum = sum_digits(a);

  if (a % sum == 0) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }


  return 0;
}

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

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = numeric_limits<int>::max();
constexpr ll L_INF = numeric_limits<ll>::max();

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

ll N, A, B, C, D;
unordered_map<ll, ll> dp;

ll dfs(ll x) {
    if (dp.find(x) != dp.end()) {
        return dp[x];
    }

    if (x == 0) {
        dp[x] = 0;
        return dp[x];
    }

    if (x == 1) {
        dp[x] = D;
        return dp[x];
    }

    ll res = L_INF;

    ll r2 = x % 2;
    ll r3 = x % 3;
    ll r5 = x % 5;

    // goto 0
    if (x < L_INF / D) {
        res = dfs(0) + x * D;
    }

    // 2
    res = min(res, dfs(x / 2) + A + r2 * D);
    res = min(res, dfs((x + 1) / 2) + A + r2 * D);

    // 3
    res = min(res, dfs(x / 3) + B + r3 * D);
    res = min(res, dfs((x + 2) / 3) + B + (3 - r3) * D);

    // 5
    res = min(res, dfs(x / 5) + C + r5 * D);
    res = min(res, dfs((x + 4) / 5) + C + (5 - r5) * D);

    dp[x] = res;
    return res;
}

void solve() {
    int Q;
    cin >> Q;
    while (Q--) {
        cin >> N >> A >> B >> C >> D;
        dp.clear();
        ll res = dfs(N);
        cout << res << "\n";
    }
}

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

int main() {
#ifdef FASTIO
    cin.tie(0), cout.tie(0);
    ios::sync_with_stdio(false);
#endif
#ifdef FILEINPUT
    ifstream ifs("./in_out/input.txt");
    cin.rdbuf(ifs.rdbuf());
#endif
#ifdef FILEOUTPUT
    ofstream ofs("./in_out/output.txt");
    cout.rdbuf(ofs.rdbuf());
#endif
    solve();
    cout << flush;
    return 0;
}


Measured memory_bytes: 4164
#include <iostream>
using namespace std;
int main() {
  int n, x;
  cin >> n >> x;
  int m[n];
  for (int i = 0; i < n; i++) {
    cin >> m[i];
  }
  int min = m[0];
  int x1 = x;
  for (int i = 0; i < n; i++) {
    x1 = x1 - m[i];
    if (min >= m[i])
      min = m[i];
  }
  int a;
  a = x1 / min + n;
  cout << a << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <math.h>
#include <string>
#include <cctype>
#include <map>
#include <queue>

using namespace std;

const int mod = 1000000007;
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))
#define ll long long

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

    if (a >= d || b <= c)
    {
        cout << 0 << endl;
        return 0;
    }

    vector<int> vec(b-a+1);
    for (int i = a; i < b; i++)
    {
        vec.push_back(i);
    }
    
    int sum = 0;
    for (int i = c; i < d; i++)
    {
        auto itr = find(vec.begin(), vec.end(), i);
        if (itr == vec.end())
        {
            continue;
        }
        sum++;
    }
    
    cout << sum << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cstring>
#include <algorithm> // sort

#define REP(i, n) for (long long i = 0; i < (n); i++) 
typedef long long ll;
static const ll MOD = 1000000007;
static const ll INF = 1000000000000000000LL;
using namespace std;

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

  //全部9ならおろさなくてよい
  bool flg = true;
  for(ll i = 1; i < S.size(); ++i)
  {
    if(S[i] != '9')flg = false;
  }

  ll sum = 0;

  if(flg == false)
  {
    --sum;
  }

  sum += S[0] - '0';

  for(ll i = 1; i < S.size(); ++i)
  {
    sum += 9;
  }

  cout << sum << endl;


  return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcount

#define INF INT_MAX/3
#define mod 1000000007

int w,h,k,n,m;
vector<int> ps[10010];
int dp[5005];

int main(){
  cin>>w>>h>>k;
  cin>>n;
  rep(i,n){
    int a,b;
    cin>>a>>b;
    a--;b--;
    ps[b].push_back(a);
  }
  rep(i,h)sort(all(ps[i]));
  m=(w-1)/2+1;
  if(k<m){
    cout<<-1<<endl;
    return 0;
  }
  k-=m;
  int res=0;
  int cnt=0;
  for(int i=1;i<h;i+=2){
    rep(j,m+1)dp[j]=INF;
    dp[0]=0;
    rep(j,m){
      int idx1=lower_bound(all(ps[i]),j*2)-ps[i].begin();
      int idx2=lower_bound(all(ps[i]),j*2+1)-ps[i].begin();
      int v1=(idx1<ps[i].size()&&ps[i][idx1]==(j*2)?1:0);
      int v2=(idx2<ps[i].size()&&ps[i][idx2]==(j*2+1)?1:0);
      minch(dp[j+1],dp[j]+v1);
      if(j+2<=m)minch(dp[j+2],dp[j]+v2*2);
    }
    cnt+=dp[m];
    res+=dp[m]*2+(m-dp[m])*1;
  }
  if(cnt>k){
    res-=2*k;
  }else{
    res-=2*cnt+(k-cnt);
  }
  cout<<max(0,res)<<endl;
  return 0;
}



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

using namespace std;

int main() {
  int K, S;

  cin >> K >> S;

  int ans = 0;
  for (int x = 0; x <= K; x++) {
    for (int y = 0; y <= K; y++) {
      int z = S - (x + y);
      if (0 <= z && z <= K) {
        ans++;
      }
    }
  }
  cout << ans << endl;

  return 0;
}


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

using namespace std;
int main() {
	std::string _num;
	std::getline(std::cin, _num);
	int num = stoi(_num);
	if (num / 9 == 10 || num % 10 == 9) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env pypy3
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
import itertools


def main():
    S=input()
    
    def calc(L):
        temp=int(S[0])
        for i in range(3):
            a=1
            if L[i]==0:
                a=-1
            temp+=int(S[i+1])*a
        return temp
    
    ans=S[0]
    for ite in itertools.product([0,1], repeat=3):
        if calc(ite)==7:
            for i in range(3):
                if ite[i]==1:
                    ans+="+"
                else:
                    ans+="-"
                ans+=S[i+1]
            break
    print(ans+"=7")
    
            
        
    

main()


Measured memory_bytes: 38384
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  ll N; cin >> N;
  vector<ll> num(N);
  for(ll i = 0; i < N; i++) {
    num.at(i) = i + 1;
  }
  ll cnt = 0;
  for(int j = 0; j < 1; ) {
    bool judge = false;
    for(ll i = 0; i < N; i++) {
      if(num.at(i) % 2 == 0) {
        //cout << num.at(i) << endl;
        num.at(i) /= 2;
        judge = true;
      }
    }
    if(judge) cnt++;
    else break;
  }
  ll x = pow(2, cnt);
  cout << x << endl;
}

Measured memory_bytes: 4084
#include <bits/stdc++.h>
using namespace std;
int main(){
	string s;
	cin >> s;
	int size=s.size();
	for(int i=0;i<size;i++){
		s.pop_back();
		int ss=s.size();
		if (s.substr(0, ss/2) == s.substr(ss/2, ss/2)) {
            cout << ss - 1 << endl;
            return 0;
        }
	}
    return 0;
}


Measured memory_bytes: 256