akhauriyash/Code-Regression huggingface dataset:
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <queue>

using namespace std;

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

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

  int N, T, L, B;
  while(cin>>N>>T>>L>>B,N){
	bool lose[101], back[101];
	fill(lose, lose+101, false);
	fill(back, back+101, false);
	REP(i,L){
	  int n; cin >> n;
	  lose[n] = true;
	}
	REP(i,B){
	  int n; cin >> n;
	  back[n] = true;
	}

	double prob[2][101];
	fill((double*)prob, (double*)prob+2*101, 0.);
	queue<pair<PII,double>> q;
	int crt = 0, nxt = 1;
	prob[crt][0] = 1.;
	double ans = 0.;
	REP(t,T){
	  fill(prob[nxt], prob[nxt]+101, 0.);
	  while(!q.empty() && q.front().first.first == t){
		pair<PII, double> piid = q.front(); q.pop();
		prob[crt][piid.first.second] += piid.second;
	  }
	  
	  REP(i,N){
		if(prob[crt][i] == 0.) continue;
		FOR(j,1,7){
		  int moved = i + j;
		  if(moved > N) moved = N - (i+j-N);
		  if(back[moved]) moved = 0;
		  if(lose[moved])
			q.push(MP(MP(t+2, moved), prob[crt][i] / 6.));
		  else
			prob[nxt][moved] += prob[crt][i] / 6.;
		}
	  }
	  swap(crt, nxt);
	  ans += prob[crt][N];
	}
	cout << fixed << setprecision(6) << ans << endl;
  }
  
  return 0;
}

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

const int mod = 1000000007;

int main() {
  string s;
  cin >> s;
  string pre, back;
  int qu;
  bool rev = true;
  cin >> qu;
  struct query {
    int num;
    int f;
    char c;
  };
  vector<query> q(qu);
  for (int i = 0; i < qu; i++) {
    cin >> q[i].num;
    if(q[i].num==2){
      cin >> q[i].f >> q[i].c;
      q[i].f--;
    }
  }
  // cout << s << endl;
  for (int i = 0; i < qu; i++) {
    if (q[i].num == 1) {
      if (rev) {
        rev = false;
      } else {
        rev = true;
      }
    } else {
      if (q[i].f == !rev) {
        pre = q[i].c + pre;
      } else {
        back = back + q[i].c;
      }
    }
  }
  // cout << s << endl;
  //cout << pre <<endl<< back << endl;
  //cout << s << endl;
  if (!rev) {
    reverse(s.begin(), s.end());
    reverse(pre.begin(), pre.end());
    reverse(back.begin(), back.end());
    s = s + pre;
    s = back + s;
  }else{
    s = pre + s;
    s = s + back;
  }
  cout << s << endl;
}


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

typedef long long ll;

int main(){
	int n,a;
	int x[52];
	scanf("%d%d",&n,&a);
	for(int i = 0 ; i < n ; i ++){
		scanf("%d",&x[i]);
	}
	
	static ll dp[52][2502] = {};
	dp[0][n*a] = 1;
	ll ret = 0;
	for(int i = 0 ; i < n ; i ++){
		ret += dp[i][n*a+a-x[i]];
		for(int j = 0 ; j < 2502 ; j ++){
			dp[i+1][j] = dp[i][j];
		}
		for(int j = 0 ; j < 2502 ; j ++){
			if(0 <= j+x[i]-a && j+x[i]-a < 2502){
				dp[i+1][j+x[i]-a] += dp[i][j];
			}
		}
	}
	cout << ret << endl;
}



Measured memory_bytes: 1280
#include <stdio.h>
 
int main(void)
{
	int a;
	int b;
	int c;
	int d;
	scanf("%d %d",&a,&b);
	c=b/a;
	d=c*a;
	if (b==d)
		printf("%d\n",a+b);
	else
		printf("%d\n",b-a);
	return(0);
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#define rep(i,n) for(int (i) = 0;(i) < (n);(i)++)
#define SORT(c) sort((c).begin(),(c).end())
#define MOD 1000000007 //S(vector).size()
using namespace std;
typedef long long ll;

int main(void){
	int a;
	string s;
	cin >> a >> s;

	cout << (a >= 3200 ? s : "red");

	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <cmath>
#include <ctype.h>
#include <string> 
#include <cstring>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <iomanip>
#include <stack>
  
using namespace std;

#define pi 3.141592653589793

int main()
{
	int n, m, k;
	while(1){
		cin >> n >> m >> k;
		if(n == 0 && m == 0 && k == 0) break;
		double result[n * m + 1][n + 1];
		for(int i = 0; i < n * m + 1; i++){
			for(int j = 0; j < n + 1; j++){
				result[i][j] = 0.0;
			}
		}
		for(int i = 1; i < m + 1; i++){
			result[i][1] = (double)1 / m;
		}
		for(int i = 2; i < n + 1; i++){
			for(int j = 1; j < m * (i - 1) + 1; j++){
				for(int k = 1; k < m + 1; k++){
					result[j + k][i] += (double)result[j][i - 1] / m;
				}
			}
		}
		double ans = 0;
		for(int i = 1; i < n * m + 1; i++){
			if(i > k){
				ans += (i - k) * result[i][n];
			} else {
				ans += result[i][n];
			}
		}
		printf("%15.10f\n", ans);
	}
	return 0;
}

Measured memory_bytes: 1356
#include<bits/stdc++.h>
using namespace std;
long n,a[1000005],dem;
bool d[1000005];
int main(){
cin>>n;
for(int i=1;i<=n;i++){
    cin>>a[i];
    if(a[i]==i) d[i]=true;
}
int i=1;
while(i<=n){
    if(d[i]==true&&d[i+1]==true) {swap(a[i],a[i+1]);i=i+2;dem++;}
    else if(d[i]==true) {swap(a[i],a[i+1]);i=i+1;dem++;}
    else i++;

}
cout<<dem;}


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

using namespace std;

typedef vector<int> vi;

int main() {
    ios::sync_with_stdio(false);

    int n, m;
    cin >> n >> m;
    string s;
    cin >> s;

    vi go;
    for (int i = 0; i <= n; i++) {
        if (s[i] == '0') {
            go.push_back(i);
        }
    }

    vi ans;
    for (int i = go.size() - 1; i > 0; ) {
        int x = i;
        while (x >= 0 && go[i] - go[x] <= m) {
            x--;
        }

        x++;
        if (x == i) {
            cout << -1 << endl;
            return 0;
        }

        ans.push_back(go[i] - go[x]);
        i = x;
    }

    for (int i = ans.size() - 1; i >= 0; i--) {
        cout << ans[i] << " \n"[i==0];
    }

    return 0;
}


Measured memory_bytes: 1480
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <numeric>
#include <functional>
#include <set>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cctype>
#include <climits>
#include <fstream>
#include <bitset>
#include <time.h>
#include <assert.h>

#define LL long long
#define VI vector<int>
#define VL vector<long long>
#define FOR(i,a,b) for(int i= (a); i<((int)b); ++i)
#define RFOR(i,a) for(int i=(a); i >= 0; --i)
#define FOE(i,a) for(auto i : a)
#define ALL(c) (c).begin(), (c).end()
#define RALL(c) (c).rbegin(), (c).rend()
#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v,x) (std::find(v.begin(), v.end(), x) != v.end())
#define BIT(n) (1LL<<(n))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
#define EPS 1e-14

using namespace std;

int N, Ma, Mb, a, b, c;
vector<vector<int>> v;
map<tuple<int, int, int>, LL> memo;

LL dfs(int i, int a, int b) {
    if (a != 0 && b != 0) {
        int d = max(Ma, a) / min(Ma, a);
        if (Ma * d == a && Mb * d == b) {
            return 0;
        }
        if (a * d == Ma && b * d == Mb) {
            return 0;
        }

    }

    if (i == N) {
        return 1e10;
    }

    if (memo.find(make_tuple( i, a, b)) != memo.end()) {
        return memo[make_tuple(i, a, b)];
    }

    LL ans = dfs(i + 1, a + v[i][0], b + v[i][1]) + v[i][2];
    ans = min(ans, dfs(i + 1, a, b));

    return memo[make_tuple(i, a, b)] = ans;

}


int main(int argc, char *argv[]) {

    cin >> N >> Ma >> Mb;

    FOR(_, 0, N) {
        cin >> a >> b >> c;
        v.push_back({ a, b, c });
    }

    LL ans = dfs(0, 0, 0);
    if (ans >= 1e9) {
        cout << -1 << endl;
    }
    else {
        cout << ans << endl;
    }

    return 0;
}



Measured memory_bytes: 17408
#include<bits/stdc++.h>
using namespace std ;
typedef long long ll ;
const int maxn = 1e5 + 5 ;
int main()
{
	int a , b , c ;
	scanf("%d%d%d" , &a , &b , &c) ;
	if(a + b + c >= 22)
	  printf("bust\n") ;
	else
	  printf("win\n") ;
}

Measured memory_bytes: 256
import java.util.*;

import static java.lang.System.*;

public class Main {
    static Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        String S = ns();
        String T = ns();

        Map<Character, Character> s2T = new HashMap<>();
        Map<Character, Character> t2S = new HashMap<>();
        for (int i = 0; i < S.length(); i++) {
            char s = S.charAt(i);
            char t = T.charAt(i);

            if (t2S.containsKey(t) && t2S.get(t) != s) {
                out.println("No");
                return;
            }

            if (s2T.containsKey(s) && s2T.get(s) != t) {
                out.println("No");
                return;
            }

            s2T.put(s, t);
            t2S.put(t, s);
        }

        out.println("Yes");
    }

    static int ni() {
        return sc.nextInt();
    }

    static long nl() {
        return sc.nextLong();
    }

    static String ns() {
        return sc.next();
    }

    static int[] niarr(int N) {
        int[] a = new int[N];
        for (int i = 0; i < N; i++) {
            a[i] = sc.nextInt();
        }
        return a;
    }

    static long[] nlarr(int N) {
        long[] a = new long[N];
        for (int i = 0; i < N; i++) {
            a[i] = sc.nextLong();
        }
        return a;
    }
}

Measured memory_bytes: 28876
#include <algorithm>
#include <iostream>
#include <set>
#include <cmath>

using namespace std;


int main() {
    int k, s;
    cin >> k >> s;
    int count = 0;
    for (int x = 0; x <= k; ++x) {
        for (int y = 0; y <= k; ++y) {
            int z = s - x - y;
            if (z < 0) break;
            if (z <= k) {
                ++count;
            }
        }
    }
    cout << count << endl;
    return 0;
}


Measured memory_bytes: 764
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll;
const int MM = 1000000000;
const int MOD = MM + 7;
const int MAX = 510000;
#define rep(i, n) for(ll i=0; i<n; i++)
#define Rep(i, j, n) for(ll i=j; i<n; i++)
#define all(vec) vec.begin(), vec.end()
template<class T> inline bool chmin(T& a, T b) {if(a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if(a < b) {a = b; return true;} return false;}
const ll INF = 1LL << 60;


int main() {
    int n; cin >> n;
    vector<pair<int, int>> p(n);
    rep(i, n) {
        int x, y; cin >> x >> y;
        p[i] = make_pair(x, y);
    }
    double ans = 0;
    int x = 0;
    sort(all(p));
    do {
        double sum = 0;
        rep(i, n-1) sum += sqrt((p[i].first - p[i+1].first)*(p[i].first - p[i+1].first) + (p[i].second - p[i+1].second)*(p[i].second - p[i+1].second));
        ans += sum;
        x++;
        // cout << sum << endl;
    } while(next_permutation(all(p)));
    cout << setprecision(15) << (double)(ans / x) << endl;
}

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

int main() {
  int n;
  cin >> n;
  vector<int> a(n), b(n);
  rep(i, n) cin >> a[i] >> b[i];

  vector<P> c(n);
  rep(i, n) c[i] = make_pair(-a[i]-b[i], i);
  sort(c.begin(), c.end());
  ll ans = 0;
  rep(i, n) {
    if (i % 2 == 0) ans += a[c[i].second];
    else ans -= b[c[i].second];
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 4848
#include <bits/stdc++.h>
#define pq priority_queue
#define mp make_pair
#define cauto const auto &

#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define all(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())

#define clr(ar, val) memset(ar, val, sizeof(ar))

template <class T> bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}

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

using namespace std;

typedef long long int64;
typedef long long lint;
typedef long long lli;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
typedef pair<ll, ll> pll;

const int iinf = 1 << 29;
const long long linf = 1ll << 61;

int x[3],ans;
int main() {
    REP(i,3){
        cin>>x[i];
    }
    sort(x,x+3);

    int times=(x[2]-x[0])/2;
    ans+=times;
    x[0]+=2*times;
    times=(x[2]-x[1])/2;
    ans+=times;
    x[1]+=2*times;

    sort(x,x+3);

    if(x[0]==x[2])cout<<ans<<endl;
    else if(x[1]!=x[2])cout<<ans+1<<endl;
    else cout<<ans+2<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << '\n';
#define CFYN(n) cout << ( (n) ? "YES":"NO") << '\n';
#define OUT(n) cout << (n) << '\n';
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

int main(void)
{
    IOS
    ll h; cin >> h;
    ll ans = 0;
    ll x = 1;
    while(h > 0) {
        h /= 2;
        ans += x;
        x *= 2;
    }
    
    cout << ans << '\n';
    
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rrep(i,n) for(int i=(n)-1; i>=0; i--)
#define FOR(i,a,b) for(int i=(a); i<(b); i++)
#define RFOR(i,a,b) for(int i=(b-1); i>=(a); i--)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define pb push_back
using ll = long long;
using D = double;
using LD = long double;
using P = pair<int, int>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main(){
    int h,w,k; cin >> h >> w >> k;
    vector<vector<char>> c(h, vector<char> (w));
    rep(i,h){
        rep(j,w){
            cin >> c[i][j];
        }
    }
    int ans = 0;
    rep(bit,(1<<(h+w))){
        int cnt = 0;
        rep(i,h){
            rep(j,w){
                if(((bit >> i) & 1) || ((bit >> (j+h)) & 1)) continue;
                if(c[i][j] == '#') cnt++;
            }
        }
        if(cnt == k) ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3624
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {
        n: usize,
        a: [i64; n],
    }

    const MOD: i64 = 1000000007;
    let mut ans = 0;
    let a_len = a.len();

    // Accumulation
    let mut acc_a = vec![0; n+1];
    for i in 0..a_len {
        acc_a[i+1] = acc_a[i] + a[i]
    }

    for i in 0..a_len {
        let calc = (acc_a[a_len] - acc_a[i+1]) % MOD;
        ans += a[i]*calc;
        ans %= MOD
    }

    //println!("{:?}", acc_a);
    println!("{}", ans)
}


Measured memory_bytes: 7244
import java.util.*;

public class Main{
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        int A = s.nextInt();
        int B = s.nextInt();
        int ans = A + B;
        if (ans <24) {
            System.out.print(ans);
        }
        if (ans >24) {
            System.out.print(ans - 24);
        }
        if(ans==24){
            System.out.print(0);
        }
    }
}

Measured memory_bytes: 21844
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main
{
    
    public static void main(String[] args) throws IOException
    {
        BufferedReader r = new BufferedReader(new InputStreamReader(System.in), 1);
        String s = r.readLine();
        char a = s.charAt(0);
        char b = s.charAt(1);
        char c = s.charAt(2);
        
        System.out.println(700 + (a == 'o' ? 100 : 0) + (b == 'o' ? 100 : 0) + (c == 'o' ? 100 : 0));
    }
    
}


Measured memory_bytes: 21076
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
void p(vector<int> A){rep(i,A.size()){cout << A[i] << " ";}cout << "\n";}

int main(){
    int x;
    cin >> x;
    vector<bool> expo(x+1);
    expo[1] = 1;
    for(int i = 2;i <= x;i++){
        int v = i*i;
        while(v <= x){
            expo[v] = 1;
            v *= i;
        }
    }
    for(int i = x;i >= 1;i--){
        if(expo[i]){cout << i;
        return 0;}
    }
}


Measured memory_bytes: 3616
#include<bits/stdc++.h> 
using namespace std;
 
typedef long long int64;
typedef unsigned long long uint64;
#define two(X) (1<<(X))
#define twoL(X) (((int64)(1))<<(X))
#define contain(S,X) (((S)&two(X))!=0)
#define containL(S,X) (((S)&twoL(X))!=0)
const double pi=acos(-1.0);
const double eps=1e-11;
template<class T> inline void ckmin(T &a,T b){if(b<a) a=b;}
template<class T> inline void ckmax(T &a,T b){if(b>a) a=b;}
template<class T> inline T sqr(T x){return x*x;}
typedef pair<int,int> ipair;
#define SIZE(A) ((int)A.size())
#define LENGTH(A) ((int)A.length())
#define MP(A,B) make_pair(A,B)
#define PB(X) push_back(X)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,a) for(int i=0;i<(a);++i)
#define ALL(A) A.begin(),A.end()
 
const int oo=1000000000;
 
int n,m;
int f[1<<15][16][16];
int g[16][16];
 
int main()
{
	while (cin>>n>>m)
	{
		memset(g,255,sizeof(g));
		REP(i,m)
		{
			int x,y,z;
			cin>>x>>y>>z;
			--x;
			--y;
			g[x][y]=g[y][x]=z;
		}
		REP(set,two(n))
		{
			REP(x,n) REP(y,n) f[set][x][y]=oo;
			if (!contain(set,0)) continue;
			if (contain(set,n-1) && set!=two(n)-1) continue;
			REP(x,n) f[set][x][x]=0;
			for (int set1=set-1;set1>0;set1=((set1-1)&set))
			{
				if (!contain(set1,0)) continue;
				int set2=(set^set1);
				int base=0;
				REP(x,n) if (contain(set1,x)) REP(y,n) if (contain(set2,y) && g[x][y]>=0) base+=g[x][y];
				REP(x,n) if (contain(set1,x)) REP(y,n) if (contain(set1,y)) 
					REP(z,n) if (contain(set2,z) && g[y][z]>=0)
					{
						ckmin(f[set][x][z],base+f[set1][x][y]-g[y][z]);
					}
			}
		}
		printf("%d\n",f[two(n)-1][0][n-1]);
	return 0;
	}
}


Measured memory_bytes: 33024
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
constexpr int MOD = 1000000007;
constexpr int INF = 2147483647;
void yes(bool expr) {
  cout << (expr ? "Yes" : "No") << "\n";
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    lint A, B, N;
    cin >> A >> B >> N;
    if(N<B-1) {
        lint ans = floor(A*N/B);
        cout << ans << endl;
    } else {
        lint ans = floor(A*(B-1)/B);
        cout << ans << endl;
    }
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define pb push_back

int main(){
    ll n,k,s;
    cin >> n >> k >> s;
    if(s!=1e9){
        for(ll i=0;i<k;i++){
            cout << s << " ";
        }
        for(ll i=k;i<n;i++){
            cout << s+1 << " ";
        }
        cout << endl;
    }else{
        for(ll i=0;i<k;i++){
            cout << s << " ";
        }
        for(ll i=k;i<n;i++){
            cout << 1 << " ";
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 1280
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

#define _CRT_SECURE_NO_WARNINGS
#define REP(i, n) for(int i=0; i<n; i++)
#define FOR(i, m, n) for(int i=m; i<n; i++)
#define ALL(x) (x).begin(),(x).end()
#define INF 999999999

typedef vector<int> VI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

int main() {
	string s;
	cin >> s;
	cout << s[0] << s.size() - 2 << s[s.size() - 1] << endl;
}

Measured memory_bytes: 256
#!/usr/bin/env python
import sys

def _s(): return sys.stdin.readline().strip()
def _i(): return int(sys.stdin.readline().strip())

n = _i()
s = _s()

ans = "No"
if n%2==0:
    nh = n//2
    if s[:nh]==s[nh:]: ans = "Yes"
#
print(ans)


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

void solv() {
    int A, B;
    cin >> A >> B;
    int sum = A - 2 * B;
    if(sum < 0){
        cout << "0" << endl;
    }
    else{
        cout << sum << endl;
    }
}

int main() {
    solv();
    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; scanf("%d",&n);

	int ans=0,mn=n;
	rep(i,n){
		int p; scanf("%d",&p);
		if(p<=mn) ans++, mn=p;
	}
	printf("%d\n",ans);

	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int main(){
  int x, y, temp, i, d;

  scanf("%d %d", &x, &y);
  if(x < 1 || pow(10, 9) < x || y < 1 || pow(10, 9) < y)
    exit(1);

  if(x < y){
    temp = y;
    y = x;
    x = temp;
  }

  if(x == y)
    d = x;
  else{
    temp = x % y;
    for(i = 1; i < temp; i++)
      if(y % i == 0 && temp % i == 0)
	d = i;
  }

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

  return 0;
}

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

int main() {
   int a, p;
   cin >> a >> p;

   cout << (3 * a + p) / 2 << endl;
}

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

int main(){
    int m, f, r;

    while(cin>>m>>f>>r){
        if(m==-1 && f==-1 && r==-1){
            break;
        }else{
            if(m==-1 || f==-1){
                cout << "F\n";
            }else if(m+f>=80){
                cout << "A\n";
            }else if(80>m+f && m+f>=65){
                cout << "B\n";
            }else if(65>m+f && m+f>=50){
                cout << "C\n";
            }else if(50>m+f && m+f>=30){
                if(r>=50){
                    cout << "C\n";
                }else{
                    cout << "D\n";
                }
            }else{
                cout << "F\n";
            }
        }
    }
    return 0;
}

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

#ifdef LOCAL_DEBUG
  #include "LOCAL_DEBUG.hpp"
#endif

signed main(){

  int n,k; cin >> n >> k;
  vector<int> a(n);
  int sum = 0;
  for(int i = 0; i < n; i++){
    cin >> a[i];
    sum += a[i];
  }

  vector<int> ans;
  for(int i = 1; i <= sqrt(sum); i++){
    if(sum%i == 0){
      ans.push_back(i);
      ans.push_back(sum/i);
    }
  }

  int res = 0;
  for(int p : ans){
    vector<int> v = a;
    for(int i = 0; i < n; i++){
      v[i] = a[i]%p;
    }
    sort(v.begin(),v.end());

    vector<int> small(n),large(n);
    for(int i = 0; i < n; i++){
      if(i == 0) small[i] = v[i], large[i] = p - v[i];
      else {
        small[i] = small[i-1] + v[i];
        large[i] = large[i-1] + p - v[i];
      }
    }

    for(int i = 0; i < n; i++){
      int t = max(small[i],large[n-1] - large[i]);
      if(t <= k) res = max(res,p);
    }
  }
  cout << res << endl;

  return 0;
}


Measured memory_bytes: 256
/*
これを入れて実行
g++ code.cpp
./a.out
 */

#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <tuple>
#include <iomanip>

using namespace std;
typedef long long ll;
typedef long double ld;

int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};

const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;

bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}

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

ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}

ll nCr(ll n, ll r){
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return (nCr(n - 1, r) + nCr(n - 1, r - 1));
}

ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}

//-----------------------ここから-----------

int main(void){
    int h, w;
    cin >> h >> w;
    vector<string> c(h);
    for(int i = 0; i < h; i++){
        cin >> c[i];
    }
    vector<string> ans;
    for(int i = 0; i < h; i++){
        ans.push_back(c[i]);
        ans.push_back(c[i]);
    }

    for(int i = 0; i < ans.size(); i++){
        cout << ans[i] << endl;
    }

}

Measured memory_bytes: 256
a,b,c,d = list(input())

ls = ["+"] * 3


for i in range(2**3):
    ls = ["+"] * 3
    for j in range(len(ls)):
        
        if (i >> j) & 1:
            ls[j] = "-"

    if eval(a+ls[0]+b+ls[1]+c+ls[2]+d) == 7:
        print(a+ls[0]+b+ls[1]+c+ls[2]+d+"=7")
        break

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(a)     (a).begin(),(a).end()
#define MOD 1000000007

typedef long long int ll;

const ll INF=(ll)1e19;
//const int INF=(1<<30);


int main(){
  ll N,M;
  cin >> N >> M;

  cout << abs((N-2)*(M-2)) << endl;
}



Measured memory_bytes: 256
import java.io.*;

public class Main {
	public static void main(String[] args)throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder data = new StringBuilder();
		 
        while(true){
    		int sum = 0;                   //sum??????????????????????????????????¨??????¨???.???????????????????????¨?????????????????????????¨????
            String str = br.readLine();    
            int strsize = str.length();    //strsize?????????????????????????????¨???
                if(str.equals("0")) break;
                
     //??°?????????????????????????????????????????????       
                else if(strsize >= 1) {
                int i = 0;
                while(i < strsize){
                    sum += Integer.parseInt(String.valueOf(str.charAt(i))); //????????§????????????????????¨???????????????????????????
                    i++;
                }
            }
              data.append(sum).append("\n"); //?????£??????????????????????????????????????????????????????????????????????????????????????£??????????????????????????????
        
        } //while?????????
        
     //??????????????????  
        System.out.print(data);

	}
}

Measured memory_bytes: 25152
#include <bits/stdc++.h>
#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 For(i,a,b) for(int i=a;i<=b;i++)
#define Forenska(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define sqr(x) ((x)*(x))
#define lowbit(x) ((x)&(-x))
#define GREATER(x) x,vector<x>,greater<x>
#define randIn(L,R) (((LL)rand()*rand())%(R-L)+L)
#define __lcm(a,b) ((a)/__gcd(a,b)*(b))
using namespace std;
typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pLL;
typedef vector<int> vec;
typedef vector<LL> vecL;
typedef vector<pii> vecP;
typedef vector<pLL> vecPL;
typedef vector<string> vecS;
typedef vector<vec> mat;
typedef complex<double> point;
const long double PI=3.14159265358979323846264338327950288419716939937510582097;
const LL INFLL=0x3f3f3f3f3f3f3f3f;
const int INF=0x3f3f3f3f;
const long double EPS=1e-10;
int read()
{
    int x=0;
    char ch=' ';
    bool flag=false;
    while(ch<'0' || ch>'9')
    {
        if(ch=='-')flag=true;
        ch=getchar();
    }
    while(ch>='0' && ch<='9')
    {
        x=(x<<3)+(x<<1)+ch-'0';
        ch=getchar();
    }
    return flag?-x:x;
}
#define int LL
const int MAX_N=100005;
int x[MAX_N];
signed main()
{
	int n,X;
	cin>>n>>X;
	int Min=INFLL;
	rep(i,0,n)Min=min(Min,x[i]=read()-X);
	int ans=0;
	rep(i,0,n)ans=__gcd(ans,x[i]-Min);
	Min=INFLL;
	rep(i,0,n)Min=min(Min,abs(x[i]));
	if(ans==0)ans=Min;
	ans=min(ans,Min);
	cout<<ans<<endl;
	return 0;
}



Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef string str;
static const long long INF = 1LL<<59;
static const long long MOD = (ll)1e9+7;

#define endl "\n"
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL)
#define REP(i, n) for(ll i=0;i<n;i++)
#define SZ(v) (ll)((v).size())
#define WHOLE(v) (v).begin(), (v).end()
#define ASC(v) sort((v).begin(), (v).end())
#define DESC(v) sort((v).rbegin(), (v).rend())
#define INV(v) reverse((v).begin(), (v).end())
#define FOLDL(src, dst, lambda) partial_sum((src).begin(), (src).end(), (dst).begin(), lambda)
#define FOLDR(src, dst, lambda) INV(src);partial_sum((src).begin(), (src).end(), (dst).begin(), lambda);INV(dst)
#define CUMSUML(src, dst) FOLDL(src, dst, [](auto a, auto b) {return a+b;})
#define CUMSUMR(src, dst) FOLDR(src, dst, [](auto a, auto b) {return a+b;})
#define ACCUM(v, d0, lambda) accumulate((v).begin(), (v).end(), d0, lambda)
#define SUM(v, d0) ACCUM(v, d0, [](auto a, auto b) {return a+b;})
#define ERASE(v, i) v.erase(v.begin() + i)
#define UNIQ(v) ASC(v);v.erase(unique(v.begin(), v.end()), v.end())

template <typename T>void debug(T t) {cerr << t << endl;}
template <typename T, typename ...Args>void debug(T t, Args ...args) {cerr << t << " ";debug(args...);}
template <typename T>void out(T t) {cout << t << endl;}
template <typename T, typename ...Args>void out(T t, Args ...args) {cout << t << " ";out(args...);}

void solve() {
    ll D, G;
    cin >> D >> G;
    vll P(D), C(D);
    REP(i, D) cin >> P[i] >> C[i];
    ll ans = INF;
    for(int i = 0; i <= (1 << D); i++) {
        ll pts = 0, qn = 0, par = 0;
        for(int bit = 0; bit < D; bit++) {
            ll f = (i >> bit) & 1;
            if(f) {
                pts += C[bit] + P[bit] * (bit+1) * 100;
                qn += P[bit];
            }else {
                par = bit;
            }
        }
        if(pts >= G) {
            ans = min(ans, qn);
        }else {
            ll rest = (G - pts - 1) / ((par + 1) * 100) + 1;
            if(rest <= P[par]) {
                ans = min(ans, qn+rest);
            }
        }
    }
    out(ans);
}

int main() {
    fast_io;
    solve();
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll              long long int
#define int             ll
#define ff              first
#define ss              second
#define pb              emplace_back
#define mpair           make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define sbits(x)      __builtin_popcountll(x)
#define zbits(x)      __builtin_popcountlliltin_ctzll(x)
#define w(t)            int t;cin>>t;while(t--)
#define uset            unordered_set
#define forr(i, a, b)   for(int i =int(a);i<=int(b);i++)
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__,__VA_ARGS__)
    template <typename Arg1>
     void __f(const char* name,Arg1&& arg1){
        cout<<name<<" : "<<arg1<<std::endl;
     }
     template <typename Arg1, typename... Args>
     void __f(const char* names,Arg1&& arg1,Args&&... args){
        const char* comma = strchr(names+1 ,',');
        cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
     }
#else
#define trace(...)
#endif
/*     
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
*/
double pi = 2.0*acos(0);
void fast(){ios_base::sync_with_stdio(false);cin.tie(NULL);cout<<fixed<<setprecision(10);}
int max2(int a,int b){ if(a>b) return a;return b;}
int min2(int a,int b){ if(a<b)return a;return b;}
int max3(int a,int b,int c){ return max2(a,max2(b,c));}
int min3(int a,int b,int c){ return min2(a,min2(b,c));}

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


void solve(){
   int a,b,c,k;
   cin>>a>>b>>c>>k;

   int sum = 0;
   if(k<=a)
    {
        sum+=k;
        k =0;
    }
   else
   {
      sum+=a;
      k = k-a;
   }
   if(k<=b)
    {
        k =0; 
    }
    else
    {
         k = k-b;
    }
    sum= sum-k;

  cout<<sum<<endl;
        
 }


signed main(void)
{
      fast();
      //w(t)
      solve();

}

Measured memory_bytes: 3652
#include <stdio.h>

using namespace std;

int main(){
	int n,x;
	scanf("%d",&n);

	for(int i = 1; i<= n; i++)
	{
		if(i%3 == 0){
			printf(" %d",i);
		}else{
			x = i;
			do{
				if(x%10 == 3){
					printf(" %d",i);
					break;
				}
				x /=10;
			}while(x);
		}
	}
	printf("\n");
}


Measured memory_bytes: 2752
/*Bismillahir Rahmanir Rahim*/
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,i,j,k,N,b[1000],max=0,sum=0;
    cin>>N;
    for(i=0; i<N; i++)
    {
        cin>>b[i];
        sum=sum+b[i];
        if(max<b[i])
        {
            max=b[i];
        }
    }
    max=max/2;
    sum=sum-max;
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1e9+7,MAX = 1e5;

int M[10][10];
int back(int n)
{
	int res;
	while(n)
	{
		res = n;
		n/=10;
	}
	return res;
}

int main()
{
	int n;
	cin >>n;
	for(int i =1;i<=n;i++)
	{
		int b = back(i);
		int a = i%10;
		M[a][b]++;
	}

	ll ans = 0;
	for(int i = 1;i<=9;i++)
	{
		for(int j = 1;j<=9;j++)
		{
			ans += M[i][j]*M[j][i];
			//ans += M[j][i]*M[i][j];
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
st=list(input())
kn=int(input())

def ans(s,k):
    if len(s)>=k:
        for i in range(k):
            if s[i]!="1":
                return s[i]
        return 1
    else:
        for i in range(len(s)):
            if s[i]!="1":
                return s[i]
print(ans(st,kn))

Measured memory_bytes: 3060
#include <functional>
#include <algorithm>
#include <iostream>
#include <cstring>
#include <vector>
#include <cstdio>
#include <stack>
#include <map>
 
using namespace std;
 
void solve();
 
int main() {
	solve();
}
 
// ============= actual code starts here =================
 
const int limit = 100500 * 2;
char s[ limit ];
 
void solve() {
	scanf("%s", &s);
 
	int hmd = 0;
	for(int i = 0; i < strlen(s); i++) {
		hmd = (hmd + s[ i ] - '0') % 9;
	}
 
	if(!hmd)
		printf("Yes\n");
	else
		printf("No\n");
}

Measured memory_bytes: 3836
#include<iostream>
#include<stdio.h>
//#include <bits/stdc++.h>
#include<vector>
#include<float.h>
#include<iomanip>
#include<algorithm>
#include<string>
#include<cstring>
#include<math.h>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include <cassert>
#include <cmath>
#include<cstdint>

#define INF 1e9
#define rep(i,n)for(int i=0;(i)<(int)(n);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
#define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
#define vec(type,n) vector<type>(n)
#define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
#define ALL(a)  (a).begin(),(a).end()

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<int,ll>;

vector<int>bitSearch(int bit,int n){
    vector<int>S;
    rep(i,n)if(bit&(1<<i))S.push_back(i);
    return S;
}

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

ll res,n;

void ans(ll now,bool f,bool g,bool h){
    if(now>n)return;
    if(f && g && h)res++;
    ans(now*10+3,true,g,h);
    ans(now*10+5,f,true,h);
    ans(now*10+7,f,g,true);
}

int main(){
    cin>>n;
    ans(0,false,false,false);
    cout<<res;
}



Measured memory_bytes: 256
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <iterator>
#pragma warning(disable:4996)
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define MOD 1000000007
using namespace std;


int main(int argc, char* argv[])
{
    char str[105]={0};
    scanf("%s", str);
    long i;
    long count=0;
    for(i=0; i<3; i++) {
        if(str[i]=='1')
            count++;
    }
    printf("%ld\n", count);

    return 0;
}


Measured memory_bytes: 128
H, W = [int(x) for x in input().split()]
rows = [input() for _ in range(H)]
lst = []
tmp = []
for row in rows:
    if '#' in row: lst.append(row)
for i in range(W):
    column = ''
    for row in lst:
        column += row[i]
    if '#' not in column: 
        tmp.append(i)
for row in lst:
    for i in range(W):
        if (i in tmp): continue
        print(row[i], end='')
    print()


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

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

const ll mod=1'000'000'007;
const ll inf=1'000'000'000'000'000'00;
const int INF=1'000'000'000;
const double EPS=1e-10;
const double PI=acos(-1);

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    string s,t;
    cin>>s>>t;
    ll n=s.size(),m=t.size();
    map<char,vector<ll>> mp;
    rep(i,n){
        mp[s[i]].push_back(i);
    }
    ll ans=0,ind=-1;
    for(auto c:t){
        if(mp.count(c)==0){
            cout<<-1<<endl;
            return 0;
        }
        auto itr=upper_bound(begin(mp[c]),end(mp[c]),ind);
        if(itr==mp[c].end()){
            ans++;
            ind=mp[c][0];
        }else{
            ind=*itr;
        }
    }
    cout<<ans*n+ind+1<<endl;
}

Measured memory_bytes: 4644
#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;
int func(int num){
	int k;	
	if(num==1||num==0) return 0;
	if(num==2) return 1;
      for(k=2;k<=sqrt(num)+1;k++){
			if(num%k==0) return 0;	     	 
		}
    return 1;
   } 
   
int main(){
	int q,i,j,l,r;   
	int c[100001],js[100001];
	js[1]=0;
	for(i=2;i<=100000;i++){
		if (func(i)==1&func((i+1)/2)) js[i]=js[i-1]+1;
		else js[i]=js[i-1];
    	}
   scanf("%d",&q);
	for(i=1;i<=q;i++){
	     scanf("%d %d",&l,&r);  
	      c[i]=js[r]-js[l-1];	    	
		 }	       
    for(i=1;i<=q;i++){
		printf("%d\n",c[i]);
     	} 
	return 0;
    } 

Measured memory_bytes: 3984
#include <bits/stdc++.h>
using namespace std; 
typedef long long lli;
#define mod 1000000007
const int INF = 1e6;
const int MAX = 1e5+10;
#define fori(n) for(int i=0;i<n;i++)
#define forj(n) for(int j=0;j<n;j++)
#define forli(n) for(lli i=0;i<n;i++)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define vi vector<int>
#define vli vector<lli>
#define fast ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define endl "\n"
#define print(a) cout<<a<<endl
#define print2(a,b) cout<<a<<" "<<b<<endl
#define print3(a,b,c) cout<<a<<" "<<b<<" "<<c<<endl
#define sortvec(a) sort(a.begin(),a.end())
#define pdd pair<lli,lli>
 
//FUNCTONS
lli llipower(lli x, lli y){lli res = 1;x = x % mod; while (y > 0){if (y & 1) res = (res*x) % mod; y = y>>1;x = (x*x) % mod;}return res;}
lli gcd(lli a, lli b){ if (!a) return b; return gcd(b%a,a);}
lli binarySearch(vector<int> arr, int l, int r, int x){ 
	if (r >= l) { 
		lli mid = l + (r - l) / 2; 
		if (arr[mid] == x) return mid; 
		if (arr[mid] > x) return binarySearch(arr, l, mid - 1, x); 
		return binarySearch(arr, mid + 1, r, x); 
	} 
	return -1;
}
template <typename T>
void printvec(vector<T> inp){
	for(int i=0;i<inp.size();i++){
		cout<<inp[i]<<" ";
	}
	cout<<endl;
}
template <typename T>
T ceildiv(T x, T y){
	return 1 + ((x - 1) / y);
}
bool pd(string s1,string s2){
	string temp=s1;
	reverse(temp.begin(),temp.end());
	if(temp==s2) return true;
	return false;
	
}
int main(){
	int n;
	cin>>n;
	int temp;
	bool con=true;
	fori(n){
		cin>>temp;
		if(temp%2==0){
			if(temp%3==0 || temp%5==0) ;
			else{
				con=false;
				break;
			}
		}
	}
	if(!con) cout<<"DENIED"<<endl;
	else cout<<"APPROVED"<<endl;
	
}
 
 

Measured memory_bytes: 256
// Ver19.03
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define INF 1 << 29
#define LLINF 4545454545454545454
#define MOD 1000000007
#define ll long long
#define ull unsigned long long
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
int upll(const void *a, const void *b) { return *(ll *)a < *(ll *)b ? -1 : *(ll *)a > *(ll *)b ? 1 : 0; }
int downll(const void *a, const void *b) { return *(ll *)a < *(ll *)b ? 1 : *(ll *)a > *(ll *)b ? -1 : 0; }
void sortup(ll *a, int n) { qsort(a, n, sizeof(ll), upll); }
void sortdown(ll *a, int n) { qsort(a, n, sizeof(ll), downll); }

int main()
{
  ll n, ans;
  scanf("%lld", &n);
  for (int i = 0; i < n; i++)
  {
    ll a, b;
    scanf("%lld%lld", &a, &b);
    ans += b - a + 1;
  }
  printf("%lld\n", ans);
  return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
#include <stdlib.h>


int compare(int *a, int *b){
  return *a - *b;
}

int main(){
  int n,k,
      a[500],b[500],sum=0,l,t,y,
      i,j;
  
  scanf("%d%d", &n, &k);
  
  for(i=0;i<n;i++){
	scanf("%d", &a[i]);
    sum += a[i];
  }
  
  l = sum;
  while(1){
    if(sum%l == 0){
      for(i=0;i<n;i++){
        b[i] = a[i] % l;
      }
      qsort(b, n, sizeof(int), compare);
      i=0;
      j=n-1;
      y=0;
      t=0;
      while(i <= j){
        if(0 >= y){
          y += b[i];
          t += b[i];
          i++;
        }else{
          y -= (l - b[j]);
          j--;
        }
      }
      if(t <= k){
        printf("%d", l);
        return 0;
      }
    }
    l--;
  }
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(int (i) = (s);(i) <= (e);(i)++)
#define all(x) x.begin(),x.end()

i64 MOD = 998244353;

long long inv_mod(long long a, long long m = MOD) {
  long long b, x, u, q, abs_m, tmp;

  abs_m = (m < 0) ? -m : m;
  b = m;
  x = 1;
  u = 0;
  while (b > 0) {
    q = a / b;
    tmp = u;
    u = x - q * u;
    x = tmp;
    tmp = b;
    b = a - q * b;
    a = tmp;
  }

  return (x < 0) ? abs_m + x : x;
}


i64 fact[101010];
i64 inv[101010];

void init() {
  fact[0] = 1;
  for(int i = 1;i < 101010;i++) {
    fact[i] = fact[i - 1] * i % MOD;
  }
  inv[101010 - 1] =  inv_mod(fact[101010 - 1]) % MOD;
  for(int i = 101010 - 1;i >= 1;i--) {
    inv[i - 1] = inv[i] * i % MOD;
  }
}

i64 comp(i64 n, i64 k) {
  if(n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fact[n] * inv[k] % MOD * inv[n - k] % MOD;
}

int main() {
  init();
  i64 K, N;
  cin >> K >> N;

  for(int i = 2; i <= 2 * K;i++) {
    i64 p = i;
    if(i > K + 1) p = (K + 1) * 2 - p;
    p /= 2;

    i64 ans = 0;

    for(int j = 0;j <= p;j++) {
      auto res = comp(p, j) * comp(K + N - 2 * j - 1, N - 2 * j) % MOD;
      if(j & 1) ans = (ans - res % MOD + MOD) % MOD;
      else ans = (ans + res) % MOD;
    }
    cout << ans << endl;
  }
}


Measured memory_bytes: 1920
from collections import deque

n = int(input())
nums = [-1 for _ in range(n)]
edges = [[] for _ in range(n)]
for _ in range(n-1):
    a, b = list(map(lambda x: int(x) - 1, input().split()))
    edges[a].append(b)
    edges[b].append(a)

cs = sorted(list(map(int, input().split())), reverse=True)
cost = sum(cs[1:])
cs = deque(cs)

start = -1
for i, e in enumerate(edges):
    if len(e) == 1:
        start = i
        break

q = deque([start])
while len(q) > 0:
    p = q.popleft()
    c = cs.popleft()
    nums[p] = c
    for np in edges[p]:
        if nums[np] == -1:
            q.append(np)

print(cost)
print(' '.join(map(str, nums)))

Measured memory_bytes: 6788
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=(ll)1e9+7;
const ll INF=(ll)1e18+10;
const double PI=acos(-1);

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
int dy[]={-1,1,0,0};
int dx[]={0,0,-1,1};

void solve() {
    int K,T; cin>>K>>T;
    vector<int> a(T);
    for (int i = 0; i < T; ++i) {
        cin>>a[i];
    }
    sort(a.rbegin(),a.rend());
    cout<<max(0, a[0]-(K-a[0])-1)<<endl;
}


#define SINGLE
int main() {
#ifdef SINGLE
    solve();
#else
    int N;
    cin>>N;
    for(int i=0;i<N;++i){
        solve();
    }
#endif
    return 0;
}


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

int main() {
	string s;
	cin >> s;
	int n = s.size();
	for (ll i = 0; i < n / 2; ++i) {
		if (s[i] != s[n - 1 - i]) {
			cout << "No";
			return 0;
		}
	}
	string s1 = s.substr(0, n / 2);
	string s2 = s.substr(n / 2 + 1, n / 2);
	int n12 = s1.size();
	for (ll i = 0; i < n12 / 2; ++i) {
		if (s1[i] != s1[n12 - 1 - i] || s2[i] != s2[n12 - 1 - i]) {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
}

Measured memory_bytes: 256