akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cstdlib>
#include <map>
using namespace std;
typedef long long ll;
#define GG puts("FUCK")
#define N 300050
ll fac[N],inv[N],A,B,K;
int n;
const int mod=998244353;
ll qp(ll x,int y) {
	ll re=1;
	for(;y;y>>=1,x=x*x%mod) if(y&1) re=re*x%mod;
	return re;
}
void init() {
	int i;
	for(fac[0]=1,i=1;i<=n;i++) fac[i]=fac[i-1]*i%mod;
	inv[n]=qp(fac[n],mod-2);
	for(i=n-1;i>=0;i--) inv[i]=inv[i+1]*(i+1)%mod;
}
ll C(ll n,ll m) {
	if(n<m) return 0;
	return fac[n]*inv[m]%mod*inv[n-m]%mod;
}
ll ans;
int main() {
	scanf("%d%lld%lld%lld",&n,&A,&B,&K);
	init();
	int i;
	for(i=0;i<=n;i++) {
		ll lft=K-A*i;
		if(lft>=0&&lft%B==0) {
			int j=lft/B;
			ans=(ans+C(n,i)*C(n,j)%mod)%mod;
		}
	}
	printf("%lld\n",ans);
}


Measured memory_bytes: 4864
#include <bits/stdc++.h>
#define endl '\n'
using namespace std;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n,m,sum=0;
    double tmp;
    bool b=0;
    cin>>n>>m;
    int a[n];
    for(int i=0;i<n;i++){
    	cin>>a[i];
    	sum+=a[i];
	}
	tmp=0.1*10*sum/(4*m);
	for(int i=0;i<n;i++){
		if(a[i]>=tmp){
			m--;
			if(m==0){
				b=1;
				cout<<"Yes";
				break;
			}
		}
	}
	if(b==0){
		cout<<"No";
	}
    
//system("pause");
return 0;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
//#pragma GCC optimize("Ofast","no-stack-protector","unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,sse4.2,popcnt,abm,mmx,avx")
//#include<bits/extc++.h>
//using namespace __gnu_pbds;
using namespace std;
#define int long long
#define F(i,L,R) for(int i=L;i<R;++i)
#define FE(i,L,R) for(int i=L;i<=R;++i)
#define getI(a) scanf("%lld",&a)
#define getII(a,b) scanf("%lld%lld",&a,&b)
#define getIII(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define VgetI(n) int (n); scanf("%lld",&(n))
#define VgetII(n,m) int (n),(m); scanf("%lld%lld",&(n),&(m))
#define VgetIII(n,m,k) int (n),(m),(k); scanf("%lld%lld%lld",&(n),&(m),&(k))
#define debug(x) cout<<(#x)<<"="<<x<<"\n";
#define qq cout<<"QQ\n";
#define pb push_back
#define pii pair<int,int>
#define mp make_pair
#define f first
#define s second
#define INF 2000000000
void solve(int a,int b,int k){
	FE(i,a,b) if(i%k==0){
		puts("OK");
		return;
	}
	puts("NG");
}
main(){
	int a,b,k;
	while(~getIII(k,a,b)) solve(a,b,k);
}


Measured memory_bytes: 3696
import sys
sys.setrecursionlimit(10**7)
input = sys.stdin.readline

n = int(input())
tree = [list() for _ in range(n)]
ans = [0] * n

for _ in range(n-1):
    u, v, w = map(int, input().split())
    u -= 1; v -= 1
    tree[u].append((v, w % 2))
    tree[v].append((u, w % 2))    

def dfs(v, p, dist):
    ans[v] = dist % 2
    for nv, w in tree[v]:
        if nv == p: continue
        dfs(nv, v, dist + w)

dfs(0, -1, 0)
print(*ans, sep="\n")


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

#define rep(i, a, b) for(int i = (a); i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) ((int)(x).size())
#define pb push_back
#define fst first
#define snd second
#define PI (acos(-1))
#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))

#define MAXN 1123456
#define MOD 1000000007

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pii;
typedef vector<ll> vi;
typedef vector<pii> vii;
typedef vector<vi> vvi;

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

  int N, k, s;
  cin >> N >> k >> s;

  int n = N;
  int l = n-k+1;
  int f = s/l;
  while (not f) {
    --l;
    --n;
    l = n-k+1;
    f = s/l;
  }
  vi ans(N, 1e9);
  rep(i,0,n) ans[i] = f;
  for (int e = 0; e < n; e += l)
    ans[e] += s%l;
  
  trav(k,ans) cout << k << ' ';
  cout << endl;
}

Measured memory_bytes: 2176
/**
 * Created by hiramekun at 19:56 on 2019-12-29.
 */
#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using vl = vector<ll>;
using vvl = vector<vl>;
using vb = vector<bool>;
using P = pair<ll, ll>;
template<typename T> using pq = priority_queue<T>;
template<typename T> using minpq = priority_queue<T, vector<T>, greater<T>>;
template<typename T, typename K> using ump = unordered_map<T, K>;
const ll dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll e5 = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = ll(n - 1); i >= 0; i--)
#define each(i, mp) for(auto& i:mp)
#define eb emplace_back
#define F first
#define S second
#define all(obj) (obj).begin(), (obj).end()

template<class T>
ostream &operator<<(ostream &out, const vector<T> &list) {
    ll n = list.size();
    rep(i, n) out << list[i] << ' ';
    return out;
}

template<class T>
istream &operator>>(istream &in, vector<T> &list) {
    ll n = list.size();
    rep(i, n) in >> list[i];
    return in;
}

template<class T>
ostream &operator<<(ostream &out, const vector<vector<T>> &list) {
    ll n = list.size();
    rep(i, n) out << list[i] << '\n';
    return out;
}

/* ------------- ANSWER ------------- */
/* ---------------------------------- */

void solve() {
    string s, t;
    cin >> s >> t;
    cout << t + s << '\n';
    vector<ll> v2;
    vl v = v2;
}

int main() {
#ifdef MY_DEBUG
    while (true) {
#endif
        solve();
#ifdef MY_DEBUG
    }
#endif
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;
typedef long long ll;
typedef long  l;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<n;i++)
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
const double PI=3.141592653589;
const int INF=1000000007;
const ll LMAX=1000000000000001;
ll gcd(ll a,ll b){if(a<b)swap(a,b);ll c=a%b;while(c!=0){a=b;b=c;c=a%b;}return b;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
int dx[]={-1,0,1,0};
int dy[]={0,1,0,-1};

int main(){
  string s; cin>>s;
  int q; cin>>q;
  deque<char> dq;
  rep(i,s.size()) dq.pb(s[i]);
  bool k=1;
  rep(i,q){
    int t; cin>>t;
    if(t==1){
      if(k) k=0;
      else k=1;
    }else{
      int f; cin>>f;
      char c; cin>>c;
      if(f==1){
        if(k) dq.push_front(c);
        else dq.pb(c);
      }else{
        if(!(k)) dq.push_front(c);
        else dq.pb(c);
      }
    }
  }
  if(k){
    while(!(dq.empty())){
      cout<<dq.front();
      dq.pop_front();
    }
    cout<<endl;
  }else{
    while(!(dq.empty())){
      cout<<dq.back();
      dq.pop_back();
    }
    cout<<endl;
  }

  return 0;
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v).begin(), (v).end()
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define DEBUG
#define int long long
#define INF 1e18
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }
template<class T>void show(vector<T>v){for (int i = 0; i < v.size(); i++){cerr<<v[i]<<" ";}cerr<<"\n";}
typedef long long ll;

signed main(){
    char c;
    cin >> c;
    cout << (char)(c + 1) << endl;

    return 0;
}

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

if N % 4 == 0:
    print("Yes")
    exit()
elif N % 7 == 0 :
    print("Yes")
    exit()





for i in range(1, (N // 7) + 1):
    div = 7 * i
    ret = N -  div 
    if ret % 4 == 0:
        print("Yes")
        exit()
print("No")


Measured memory_bytes: 2940
#include<stdio.h>

static const int N = 1000;

void trace(int A[], int n){
  int i;
  for ( i = 1; i <= n; i++ ){
    if ( i > 1 ) printf(" ");
    printf("%d", A[i]);
  }
  printf("\n");
}

int main(){
  int n, i, j;
  int v;
  int A[N+1];
  scanf("%d", &n);

  for ( i = 1; i <= n; i++ ) scanf("%d", &A[i]);
  //trace(A, n);
  /*my code*/
  for(i=1;i<=n;i++){
    //  trace(A, n);
    v=A[i];
    j=i-1;
  //    printf("%d\n",i);
    while(j>=0 && A[j]>v){
      A[j+1]=A[j];
      j--;
    }
    A[j+1]=v;
    trace(A, n);
  }
  return 0;
}

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

int main(){
  int M, D; cin >> M >> D;
  if(D<22 || 4>M){
    cout << 0 << endl;
    return 0;
  }
  int ans=0;
  for(int i=4;i<=M;i++){
    for(int j=22;j<=D;j++){
      if((j%10)*(j/10)==i && j%10>=2){
        ans++;
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mod 1000000007
#define f first
#define second s
using namespace std;
int ar[100001];
int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL); 
	int n , l , r , ans = 0;
	cin >> n;
	for( int i = 1; i <= n; i++ ){
		cin >> l >> r;
		for( int j = l; j <= r; j++ ){
			ar[j] = 1;
		}
	}
	for( int i = 1; i <= 100000; i++ ){
		ans += ar[i];
	}
	cout << ans;
}    
 

Measured memory_bytes: 640
package main

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

func main() {
	var n, x int
	fmt.Scan(&n, &x)

	sc := bufio.NewScanner(os.Stdin)
	min := 10000
	for i := 0; i < n; i++ {
		sc.Scan()
		m, _ := strconv.Atoi(sc.Text())
		x -= m
		if m < min {
			min = m
		}
	}
	fmt.Println(n + x/min)
}


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

using namespace std;
using ll = long long;
using vl = vector<ll>;
using pll = pair<ll, ll>;

#define rep(i, n) for (ll i = 0, xxx_rep_end = (n); i < xxx_rep_end; ++i)
#define all(x) (x).begin(), (x).end()

template <class T1, class T2>
inline void chmax(T1 &a, const T2 &b)
{
    if (a < b)
    {
        a = b;
    }
}
template <class T1, class T2>
inline void chmin(T1 &a, const T2 &b)
{
    if (a > b)
    {
        a = b;
    }
}

constexpr ll INF = 0x3f3f3f3f3f3f3f3fLL;

int main()
{
    ll a;
    cin >> a;
    cout << a + a * a + a * a * a << endl;
}

Measured memory_bytes: 3576
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {
	public static void main(String[] args) {
		var sc = new Scanner(System.in);
		var n = sc.nextInt();
		var k = sc.nextInt();
		var a = IntStream.range(0, n).map(i -> sc.nextInt()).toArray();
		sc.close();

		for (var i = 0; i < n - k; i++) {
			System.out.println(a[i] < a[i + k] ? "Yes" : "No");
		}
	}
}


Measured memory_bytes: 60496
#include<stdio.h>
int main(void){
  	int a;
  long int k = 0;
  scanf("%d",&a);
  for(int i = 1; i <= a; i++){
		if(i % 3 != 0 && i % 5 != 0){
			k += i;
        }
           }
printf("%ld",k);
           return 0;
           }


Measured memory_bytes: 1732
#include <iostream>
#include <cstdio>
#include <vector>
#include <list>
#include <algorithm>
#include <cmath>
#include <stack>
#include <map>
#include <numeric>
#include <sstream>
#include <queue>
using namespace std;

#define REP(i,n) for(int (i)=0; (i)<(n); (i)++)
#define FOR(i,a,b) for(int (i)=(a); (i)<(b); (i)++)
#define PUSH(n,v) for(int i=0; i<(n); i++) {int j; cin >> j; v.push_back(j);}
#define ALL(v) v.begin(), v.end()
#define print(s) cout << (s) << endl

typedef pair<int,int> P;
const P NOT_FOUND = make_pair(-1,-1);

bool isbomb(int x, int y, int bd[8][8]) {
    return 0<=x && x<8 && 0<=y && y<8 && bd[x][y];
}

void solve71(int cnt) {
    int bd[8][8];
    REP(i,8) {
        string s;
        cin >> s;
        REP(j,8) {
            bd[i][j] = s[j] - '0';
        }
    }
    // input ends
    int x,y;
    cin >> x >> y;
    P first = make_pair(y-1, x-1);
    queue<P> willExplode;
    willExplode.push(first);
    while (willExplode.size()) {
        P bomb = willExplode.front();
        willExplode.pop();
        int x,y;
        x = bomb.first, y = bomb.second;
        bd[x][y] = 0;
        if (isbomb(x-3,y,bd)) {
            willExplode.push(make_pair(x-3,y));
        }
        if (isbomb(x-2,y,bd)) {
            willExplode.push(make_pair(x-2,y));
        }
        if (isbomb(x-1,y,bd)) {
            willExplode.push(make_pair(x-1,y));
        }
        if (isbomb(x+1,y,bd)) {
            willExplode.push(make_pair(x+1,y));
        }
        if (isbomb(x+2,y,bd)) {
            willExplode.push(make_pair(x+2,y));
        }
        if (isbomb(x+3,y,bd)) {
            willExplode.push(make_pair(x+3,y));
        }
        if (isbomb(x,y-3,bd)) {
            willExplode.push(make_pair(x,y-3));
        }
        if (isbomb(x,y-2,bd)) {
            willExplode.push(make_pair(x,y-2));
        }
        if (isbomb(x,y-1,bd)) {
            willExplode.push(make_pair(x,y-1));
        }
        if (isbomb(x,y+1,bd)) {
            willExplode.push(make_pair(x,y+1));
        }
        if (isbomb(x,y+2,bd)) {
            willExplode.push(make_pair(x,y+2));
        }
        if (isbomb(x,y+3,bd)) {
            willExplode.push(make_pair(x,y+3));
        }
    }
    cout << "Data " << cnt + 1 << ":" << endl;
    REP(i,8) {
        REP(j,8) {
            cout << bd[i][j];
        }
        cout << endl;
    }
}

int main() {
    int n;
    cin >> n;
    REP(i,n) {
        solve71(i);
    }
    return 0;
}

Measured memory_bytes: 1244
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int m,k;
	scanf("%d%d",&m,&k);
	if(k==0){
		for(int i=0;i<(1<<m);i++)
			printf("%d %d ",i,i);
		printf("\n");
	}
	else if(m==1){
		if(k>=1)
			puts("-1");
		else puts("1 1 0 0");
	}
	else{
		if(k>=(1<<m))
			puts("-1");
		else{
			printf("%d ",k);
			for(int i=0;i<(1<<m);i++)
				if(i!=k)
				printf("%d ",i);
			printf("%d ",k);
			for(int i=(1<<m)-1;i>=0;i--)
				if(i!=k)
				printf("%d ",i);
		}
	}	
}

Measured memory_bytes: 1792
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cassert>
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>
using namespace std;

#define LET(name, value) __typeof(value) name = value
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define FOR(i, a, b) for (int i = (a); i < (int)(b); ++i)
#define FOREQ(i, a, b) for (int i = (a); i <= (int)(b); ++i)
#define ALL(c) (c).begin(), (c).end()
#define FOREACH(i, c) for (LET(i, (c).begin()); i != (c).end(); ++i)

struct Edge {
  int src;
  string label;

  Edge(int src, const char* label): src(src), label(label) {}
};

const int MAX_VERTEX_COUNT = 40;
const int MAX_SPELL_LEN = 2*6*40+1;

vector<Edge> edges[MAX_VERTEX_COUNT];
string dp[MAX_SPELL_LEN+1][MAX_VERTEX_COUNT];

int main() {
  int n, a, s, g;
  while (scanf("%d%d%d%d", &n, &a, &s, &g), n|a|s|g) {
    REP(v, n) { edges[v].clear(); }

    REP(i, a) {
      int x, y;
      char label[10];
      scanf("%d%d%s", &x, &y, label);
      edges[y].push_back(Edge(x, label));
    }

    REP(v, n) {
      dp[0][v] = (v == s) ? "" : "~";
    }

    int max_spell_len = 2*6*n+1;
    FOREQ(l, 1, max_spell_len) {
      REP(v, n) {
        string val = "~";
        FOREACH(it, edges[v]) {
          int u = it->src;
          const string& label = it->label;
          if ((int)label.size() > l) { continue; }
          const string& spell = dp[l - label.size()][u];
          if (spell == "~") { continue; }
          val = min(val, spell + label);
        }
        dp[l][v] = val;
      }
    }

    string ans = "~";
    FOREQ(l, 0, max_spell_len) {
      ans = min(ans, dp[l][g]);
    }
    if (ans != "~" && (int)ans.size() < max_spell_len / 2) {
      puts(ans.c_str());
    } else {
      puts("NO");
    }
  }
}

Measured memory_bytes: 8724
#include<bits/stdc++.h>
#define rep(i,n) for (int i=0;i<(n);i++)
#define PI 3.14159265358979323846264338327950L
using namespace std;
using P = pair<int,int>;
using ll = long long;
using namespace std;
int main(void){
    int n;
    cin >> n;
    int w[n]; rep(i, n){cin >> w[i];}
    int sum1=0; int sum2=0;
    int mini = 1000000000;
    for(int t = 0; t < n-1; ++t){
        for(int j = 0; j <= t; ++j){
            sum1 += w[j];
        }
        for(int j = t+1; j < n; ++j){
            sum2 += w[j];
        }
        mini = min(mini, abs(sum1-sum2));
        sum1 = 0;
        sum2 = 0;
    }
    cout << mini << endl;
}


Measured memory_bytes: 3568
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define N 100005
#define MOD 1000000007
#define dd double
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;



int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
//ios_base& scientific (ios_base& str);

string s;
cin >> s;
ll n = s.length();
ll last, res, ans=0;

for(ll i =0; i< 1<<n-1; i++){
	last=0, res=0;
	for(int j =0; j<n; j++){
		last = last*10 + (s[j]-'0');
		if(i & (1<<j)){
			res+=last;
			last=0;
		}
	}

	ans+=res+last;
}

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



Measured memory_bytes: 256
#include <stdio.h>
int main(){
	int x,y,d,tmp;
	
	scanf("%d %d",&x,&y);
	
	if(x<y){
	    tmp=x;
	    x=y;
	    y=tmp;
	}
	
	while(y>0){
		d=x%y;
		x=y;
		y=d;
	}
	
	printf("%d\n",x);
	
	return 0;
}


Measured memory_bytes: 2140
from collections import deque
k = int(input().strip())
a = [k+1] * k
q = deque()
q.append((1, 1))
while q:
    i, m = q.popleft()
    while 1:
        if a[i] <= m:
            break
        if i == 0:
            print(m)
            raise SystemExit
        a[i] = m
        q.append(((i+1)%k, m+1))
        i = i * 10 % k


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

#define mainspring cout<<"mainspring\n";
#define barrel cout<<"barrel\n";
#define escapement cout<<"escapement\n";

#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(), (v).end() 
#define sz(v) (int)((v).size())
#define fs first
#define sd second
#define tik(i,a,b) for(int i = a; i < b; i++)
#define tok(i,a,b) for(int i = a; i >= b; i--)
#define error(args...) {string _s = #args; replace(_s.begin(), _s.end(), ',',' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it,args);}

typedef long long ll;
typedef unsigned long long ull;

#define int ll 

typedef pair < int, int > pi;
typedef pair < pi, int > ppi;

typedef vector < int > vi;
typedef vector < vector < int > > vvi;
typedef vector < pi > vpi;
typedef vector < vpi > vvpi;
typedef vector < ppi > vppi;

void fast() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}

void err(istream_iterator<string> it) {cout << endl;}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a << " ";
    err(++it, args...);
}

ll pow(ll x, ll y) {
	if(y == 0)
	return 1;
	ll temp = pow(x, y/2);
	temp = (temp*temp);
	if(y%2 == 1)
		temp *= x;
	return temp;
}

int32_t main() {
	int x, y, a, b, c;
	cin >> x >> y >> a >> b >> c;
	int p[a], q[b], r[c];
	for(int i = 0; i < a; i++)
		cin >> p[i];
	for(int i = 0; i < b; i++)
		cin >> q[i];
	for(int i = 0; i < c; i++)
		cin >> r[i];
	sort(p, p + a, greater<int>());
	sort(q, q + b, greater<int>());
	sort(r, r + c, greater<int>());
	int pa = x - 1, push_back = y - 1, pr = -1;
	for(int i = 0; i < c; i++) {
		if(pa >= 0 && pb >= 0 && r[i] > p[pa] && r[i] > q[pb]) {
			if(p[pa] >= q[pb]) {
				pb--;
				pr++;
			}
			else { 
				pa--;
				pr++;
			}
		}
		else if(pa >= 0 && p[pa] < r[i]) {
			pr++;
			pa--;
		}
		else if(pb >= 0 && q	[pb] < r[i]) {
			pr++;
			pb--;
		}
		else
			break;
	}
	int answer = 0;
	//error(pa, pb, pr);
	for(int i = 0; i <= pa; i++)
		answer += p[i];
	for(int i = 0; i <= pb; i++)
		answer += q[i];
	for(int i = 0; i <= pr; i++)
		answer += r[i];
	cout << answer;
}

Measured memory_bytes: 2560
#include<iostream>
using namespace std;
int main(){
  int h1,m1,s1,h2,m2,s2;
  int h,m,s,result;
   
  for(int i=0;i<3;i++){
  cin >>h1>>m1>>s1>>h2>>m2>>s2;
   
  result=(h2*3600+m2*60+s2)-(h1*3600+m1*60+s1);
  h=result/3600;
  result-=h*3600;
  m=result/60;
  result-=m*60;
  s=result;
  cout<<h<<" "<<m<<" "<<s<<endl;
  }
  return 0;
}
  

Measured memory_bytes: 2952
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcount
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define df(x) int x = in()
#define dame { puts("-1"); return 0;}
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,vector<T>,greater<T> >
#define bn(x) ((1<<x)-1)
#define newline puts("")
#define v(T) vector<T>
#define vv(T) vector<vector<T>>
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
inline void priv(vi a) { rep(i,sz(a)) printf("%d%c",a[i],i==sz(a)-1?'\n':' ');}
template<typename T>istream& operator>>(istream&i,vector<T>&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const vector<T>&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>ostream& operator<<(ostream&o,const vector<T>&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
const int MX = 200005, INF = 1001001001;
const ll LINF = 1e18;
const double eps = 1e-10;



int main() {
  string s;
  cin>>s;
  rep(i,8) {
    int x = s[0]-'0';
    string ans = "";
    ans += s[0];
    rep(j,3) {
      if (i>>j&1) {
        x += s[j+1]-'0';
        ans += '+';
      } else {
        x -= s[j+1]-'0';
        ans += '-';
      }
      ans += s[j+1];
    }
    if (x == 7) {
      ans += "=7";
      cout<<ans<<endl;
      return 0;
    }
  }
  cout<<-1<<endl;
  return 0;
}






















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

int main(){
  int64_t n;
  cin >> n;
  vector<int64_t> A(n);
  vector<int64_t> B(n);
  vector<int64_t> C(n);
  rep(i, n) cin >>A[i];
  rep(i, n){
    int64_t t = A[i]-1;
    B[t] += 1; 
  }
  int64_t sum = 0LL;
  rep(i, n){
    if(B[i] == 1) C[i] = 0LL;
    else if(B[i] == 0) C[i] = 0LL;
    else {
      int64_t q = B[i];
      C[i] = q*(q-1)/2;
    }
  }
  rep(i, n) sum += C[i];
  rep(i, n){
    int64_t t = A[i]-1;
    int64_t b = B[t]-1;
    int64_t c = C[t];
    int64_t so = sum-b;
    cout << so << endl;
    /*if(b==0) cout << so << endl;
    else if(b==1) cout << so << endl;
    else {
      int64_t g = b*(b-1)/2;
      cout << so+g << endl;
    }*/
  }
  //rep(i, n) cout << C[i] << endl;
  //cout << sum << endl;
}

Measured memory_bytes: 7296
def digitSum(num):
    res = 0
    while num > 0:
        res = res + num % 10
        num = int(num / 10)
    return res


def main():
    n,a,b = map(int, (input().split()))

    ans = 0;
    for i in range(n):
        ds = digitSum(i + 1)
        if ds >= a and ds <= b:
            ans = ans + i + 1

    print (ans)

main()


Measured memory_bytes: 3060
a = gets.to_i + 1
b = gets.to_i + 1
c = gets.to_i + 1
x = gets.to_i

t = 0
a.times do |i|
  _a = 500 * i

  if _a == x
    t += 1
    next
  end

  b.times do |j|
    _b = 100 * j

    if (_a + _b) == x
      t += 1
      next
    end

    c.times do |k|
      _c = 50 * k

      if (_a + _b + _c) == x
        t += 1
        next
      end
    end
  end
end

puts t

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

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

long long MOD = 10000000000 + 7;

int main(){
  cout << setprecision(10);
  int N, K;
  cin >> N;
  K = 2;
  vector<ll> dp(N, 1000000000000);
  vector<ll> v(N);

  for(int i = 0; i < N; i++){
    cin >> v.at(i);
  }
  dp[0] = 0;
  for(int i = 0; i < N-1; i++){
    for(int j = 1; j <= K; j++){
      if(i+j < N) dp[i+j] = min(dp[i+j], dp[i] + abs(v[i+j] - v[i]));
    }
  }
  cout << dp[N-1] << endl;
}



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

int main()
{

  int a,b,c = 0;

  for(int i=1; i>0; i++){
    cin >> a;
    if(a == 0){
      break;
    }
    else{
    cout << "Case " << i << ": " << a << endl;
    }
  }
}

Measured memory_bytes: 1160
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)
	ct := 0
	check := func(n int) bool {
		a, b, c := false, false, false
		for i := n; i > 0; i /= 10 {
			switch i % 10 {
			case 3:
				a = true
			case 5:
				b = true
			case 7:
				c = true
			default:
				return false
			}
		}
		if a && b && c {
			return true
		}
		return false
	}
	dfs := func() {
		sta := make([]int, 0, 19683)
		sta = append(sta, 0)
		for len(sta) != 0 {
			var x int
			sta, x = sta[:len(sta)-1], sta[len(sta)-1]
			if check(x) {
				ct++
			}
			if y := x*10 + 3; y <= n {
				sta = append(sta, y)
			}
			if y := x*10 + 5; y <= n {
				sta = append(sta, y)
			}
			if y := x*10 + 7; y <= n {
				sta = append(sta, y)
			}
		}
	}
	dfs()
	fmt.Println(ct)
}


Measured memory_bytes: 512
#include <cstdio>
#include <array>
using namespace std;

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

	bool *d = new bool[10000000];

	while (n--) {
		long c = getchar_unlocked(), e;
		long t = 1;
		while (getchar_unlocked() != ' ')
			;
		while ((e = getchar_unlocked()) != '\n') {
			t <<= 2;
			t += (e == 'A' ? 0 : e == 'C'? 1 : e == 'G'? 2 : 3);
		}
		switch(c) {
		case 'i':
			d[t] = true; break;
		case 'f':
			puts(d[t] ? "yes" : "no");
		}
	}
}



Measured memory_bytes: 3988
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  while(cin>>s&&s!="."){
    string an;
    for(int i=0,c;i<s.size();i++){
      c=0;
      while(s[i]=='+'||s[i]=='-'){
	if(s[i]=='+')c++;
	else c--;
	i++;
      }
      if(s[i]=='['||s[i]==']')an+=s[i];
      else if(s[i]=='?')an+='A';
      else an+=(char)(((s[i]-'A'+c)%26+26)%26+'A');
    }
    
    stack<int> st;
    for(int i=0;i<an.size();i++){
      if(an[i]=='[')st.push(i);
      if(an[i]==']'){
	int t=st.top();
	st.pop();
	reverse(an.begin()+t,an.begin()+i);
      }
    }
    for(int i=0;i<an.size();i++){
      if(an[i]=='['||an[i]==']')continue;
      cout<<an[i];
    }
    cout<<endl;
  }
  return 0;
}

Measured memory_bytes: 1188
#include <stdio.h>

using namespace std;

int main() {
    int N, K;
    scanf("%d", &N);
    scanf("%d", &K);

    int x[N];
    for (int i = 0; i < N; ++i) {
        scanf("%d", &x[i]);
    }

    int ans = 0;
    for (int i = 0; i < N; ++i) {
        int a = x[i];
        int b = K - x[i];
        int c = a < b ? a : b;
        ans += 2 * c;
    }

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

    return 0;
}


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

int gcd(long long a, long long b){
  if(max(a, b) % min(a,b) == 0) return min(a,b);
  return gcd(min(a,b), max(a,b)%min(a,b));
}


int main() {
    ios::sync_with_stdio(false);
    long long a, b, g, l;
    while(cin >> a >> b){
      g = gcd(a, b);
      l = (a*b)/g;
      cout << g << " " << l << endl;
    }
    return 0;
}

Measured memory_bytes: 1188
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
  
int main() {
  int N,x;
  cin >> N >> x;
  if(N==x) {
    cout << "Yes" << endl;
    rep(i,2*N-1) {
      cout << i+1 << endl;
    }
    return 0;
  }
  if(x==1||x>=2*N-1) {
    cout << "No" << endl;
    return 0;
  }
  cout << "Yes" << endl;
  int k = 2;
  rep(i,N-2) {
    if(k==x) k++;
    cout << k << endl;
    k++;
  }
  if(x==2*N-2) {
    cout << 1 << endl;
    cout << 2*N-1 << endl;
    cout << x << endl;
    cout << k << endl;
    k++;
  } else {
    cout << 2*N-1 << endl;
    cout << 1 << endl;
    cout << x << endl;
    cout << 2*N-2 << endl;
  }
  rep(i,N-3) {
    if(k==x) k++;
    cout << k << endl;
    k++;
  }
  return 0;
}

Measured memory_bytes: 1536
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 1000001;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

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

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

struct edge {
	ll ind;
	ll to;
	ll d;
};


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



int main() {
	ll X, A;
	cin >> X >> A;
	if (X < A) { cout << 0; }
	else { cout << 10; }

	system("PAUSE");
}

Measured memory_bytes: 504
#include <iostream>
#include <stdlib.h>
#include <math.h>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <queue>

using namespace std;


int main(void){
    bool cards[4][13];
    int num;
    int cardNum;
    char c;
    
    for(int i = 0;i < 4;++i){
        for(int j = 0;j < 13;++j){
            cards[i][j] = false;
        }
    }
    
    cin >> num;
    
    for(int i = 0;i < num;++i){
        cin >> c >> cardNum;
        
        switch(c){
            case 'S':
                cards[0][cardNum - 1] = true;
                break;
            case 'H':
                cards[1][cardNum - 1] = true;
                break;
            case 'C':
                cards[2][cardNum - 1] = true;
                break;
            case 'D':
                cards[3][cardNum - 1] = true;
                break;
        }
    }
    
    for(int i = 0;i < 4;++i){
        for(int j = 0;j < 13;++j){
            if(!cards[i][j]){
                switch (i) {
                    case 0:
                        cout << "S" << " " << j + 1 << endl;
                        break;
                    case 1:
                        cout << "H" << " " << j + 1 << endl;
                        break;
                    case 2:
                        cout << "C" << " " << j + 1 << endl;
                        break;
                    case 3:
                        cout << "D" << " " << j + 1 << endl;
                        break;
                    default:
                        break;
                }
            }
        }
    }
    return 0;
}



Measured memory_bytes: 3088
#include <iostream>
using namespace std;
int main(){
  string N;
  cin >> N;
  int ans = N[0] - '0';
  bool f = false;
  for(int i = 1; i < N.length(); ++i){
    int k = N[i] - '0';
    if(k < 9 && (f || N[i-1] > '0')){
      N[i] = '9';
      ans += 9;
      if(!f) --ans;
      f = true;
    }else{
      ans += k;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target ("avx2")

#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <queue>
#include <stack>

#include <x86intrin.h>

using namespace std;

typedef long long int ll;
typedef pair<int, int> Pii;

const ll mod = 1000000007;

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

  int n;
  cin >> n;
  vector<ll> a(n+16);
  for (int i = 0; i < n; i++) cin >> a[i];

/*
  if (n % 2 == 0) {
    ll now = 0;
    for (int i = 0; i < n; i += 2) now += a[i];
    ll maximum = now;
    for (int i = n-2; i >= 0; i -= 2) {
      now += (a[i+1] - a[i]);
      if (now > maximum) maximum = now;
    }

    cout << maximum << endl;
  }
  else {
    vector<vector<ll> > dp(n+2, vector<ll>(3, (ll) -1e18));
    dp[0][0] = a[0];
    dp[1][1] = a[1];
    dp[2][2] = a[2];
    for (int i = 0; i < n; i++) {
      if (i+2 < n) dp[i+2][0] = max(dp[i+2][0], dp[i][0] + a[i+2]);
      if (i+2 < n) dp[i+2][1] = max(dp[i+2][1], dp[i][1] + a[i+2]);
      if (i+2 < n) dp[i+2][2] = max(dp[i+2][2], dp[i][2] + a[i+2]);
      if (i+3 < n) dp[i+3][1] = max(dp[i+3][1], dp[i][0] + a[i+3]);
      if (i+3 < n) dp[i+3][2] = max(dp[i+3][2], dp[i][1] + a[i+3]);
      if (i+4 < n) dp[i+4][2] = max(dp[i+4][2], dp[i][0] + a[i+4]);
    }

    cout << max(max(dp[n-3][0], dp[n-2][1]), dp[n-1][2]) << endl;
  }
*/

  vector<vector<ll> > dp(3, vector<ll>(n/2, (ll) -1e18));
  dp[0][0] = a[0];
  // for (int i = 1; i < n/2; i++) {
  //   dp[i][0] = dp[i-1][0];
  //   dp[i][1] = max(dp[i][0], dp[i-1][1]);
  //   dp[i][2] = max(dp[i][1], dp[i-1][2]);
  //   dp[i][0] += a[i*2];
  //   dp[i][1] += a[i*2+1];
  //   dp[i][2] += a[i*2+2];
  // }
  for (int i = 1; i < n/2; i++) {
    dp[0][i] = dp[0][i-1] + a[i*2];
  }
  dp[1][0] = a[1];
  for (int i = 1; i < n/2; i++) {
    dp[1][i] = max(dp[0][i-1], dp[1][i-1]) + a[i*2+1];
  }
  dp[2][0] = a[2];
  for (int i = 1; i < n/2; i++) {
    dp[2][i] = max(max(dp[0][i-1], dp[1][i-1]), dp[2][i-1]) + a[i*2+2];
  }

  ll ans = max(dp[0][n/2-1], dp[1][n/2-1]);
  if (n % 2 == 1) ans = max(ans, dp[2][n/2-1]);

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 7928
package main

import "fmt"

func main() {
	var N int
	var S string
	fmt.Scan(&N, &S)

	ans := ""
	for i := 0; i < len(S); i++ {
		a := S[i] + byte(N)
		if a > 'Z' {
			a = a - 26
		}
		ans += string(a)
	}
	fmt.Println(ans)
}


Measured memory_bytes: 6656
# 1度`BC`を`D`に置き換えて操作を考える
S = input()

new_s = ""
pointa = 0
while pointa != len(S):
    if pointa == len(S) - 1:
        new_s += S[pointa]
        break
    if S[pointa] == "B" and S[pointa+1] == "C":
        new_s += "D"
        pointa += 2
    else:
        new_s += S[pointa]
        pointa += 1

# Dが出現した時、その直前に存在するAの回数だけ操作を行うことができる
count = 0
ans = 0
for i in range(len(new_s)):
    if new_s[i] == "D":
        ans += count
    elif new_s[i] == "A":
        count += 1
    else:
        count = 0
print(ans)


Measured memory_bytes: 3500
/*
         Md.Fagun Molla
         18ICTCSE006
         BSMRSTU(SHIICT)
*/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define End return 0;

int main ()
{
    ll n;
    cin>>n;
    ll aa[n];
    ll bb[n];
    for(ll i=0; i<n; i++)
        cin>>aa[i];
    for(ll i=0; i<n; i++)
        cin>>bb[i];

    ll ans=0;
    for(ll i=0; i<n; i++){
        if(aa[i]>bb[i]){
            ans+=(aa[i]-bb[i]);
        }
    }


    cout<<ans<<endl;
    End;
}
/* pray for me
All is well
*/



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int64_t INF = 1LL << 60;

int main() {
  int N;
  cin>>N;
  vector<int>H(N);
  for(int i=0;i<N;i++){
    cin>>H[i];
  }
  int pre=0;
  for(int i=0;i<N;i++){
    if(pre<=H[i]-1){
      pre=H[i]-1;}
    else if(pre<=H[i]){
      pre=H[i];}
    else{cout<<"No"<<endl;return 0;}
    }
    cout<<"Yes"<<endl;
  return 0;}

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

int main(){
  using ll = long long;
  string N;
  int K;
  cin >> N >> K;
  vector<vector<ll>> dp(K+1,vector<ll>(2,0));
  dp[0][1] = 1;
  for(size_t i = 0; i < N.length(); ++i){
    vector<vector<ll>> dp_(K+1,vector<ll>(2,0));
    for(int j = 0; j <= K; ++j){
      dp_[j][0] += dp[j][0];// 1~9
      if(j+1 <= K) dp_[j+1][0] += dp[j][0]*9;// 0
      
      if(N[i] == '0'){
        dp_[j][1] += dp[j][1];
      }else{
        if(j < K) dp_[j+1][1] += dp[j][1];
        dp_[j][0] += dp[j][1];
      }
      if(j < K)
        dp_[j+1][0] += dp[j][1]*max(0,N[i]-'1');
    }
    swap(dp,dp_);
  }
  cout << dp[K][0]+dp[K][1] << endl;
}


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

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)

#define INF 100000000
#define MOD 1000000007
#define writeln(n) cout<<n<<endl
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
//vector<tuple<long long, long long, long long>>vec;

template<class T>
inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

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

const int inf=100000000;

llong pownew(llong m, llong n) {
        if (n == 0) { return 1; }
        if (n % 2 == 0) { return pow(m*m, n/2); }
        return pow(m, n-1) * m;
    }

bool isprime(int p) {
    if (p == 1) return false;
    for (int i = 2; i < p; i++) {
        if (p%i == 0) return false;
    }
    return true;
}
const int nmax=40,abmax=10;
int a[nmax],b[nmax],c[nmax];
int dp[nmax+1][nmax*abmax+1][nmax*abmax+1];

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n; cin>>n;
    int ma,mb; cin>>ma>>mb;
    REP(i,n)
    {
    cin>>a[i]>>b[i]>>c[i];
    }

    for(int i=0; i<=n; i++)
    {
        for(int ca=0; ca<=nmax*abmax; ca++)
        {
            for(int cb=0; cb<=nmax*abmax; cb++)
            {
                dp[i][ca][cb]=inf ;
            }
        }
    }
    dp[0][0][0]=0;
    for(int i=0; i<n; i++)
    {
        for(int ca=0; ca<=nmax*abmax; ca++)
        {
            for(int cb=0; cb<=nmax*abmax; cb++)
            {
                if(dp[i][ca][cb]==inf) continue;
                dp[i+1][ca][cb]=min(dp[i+1][ca][cb],dp[i][ca][cb]);
                dp[i+1][ca+a[i]][cb+b[i]]=min(dp[i+1][ca+a[i]][cb+b[i]],dp[i][ca][cb]+c[i]);
            }
        }
    }
    int ans=inf;
    for(int ca=1; ca<=nmax*abmax; ++ca)
    {
        for(int cb=1; cb<=nmax*abmax; ++cb)
        {
            if(ca*mb==cb*ma) ans=min(ans,dp[n][ca][cb]);
        }
    }
    if(ans==inf) ans=-1;
    cout<<ans<<endl;
    return  0;
}


Measured memory_bytes: 25984
#include <iostream>
#include <vector>
#include <algorithm>
#define pii pair<int,int>
#define F first
#define S second

using namespace std;
const int MAX_N = 1e5+10;
const int INF = 1e9+10;
typedef long long ll;
vector <int> vec[MAX_N];
bool ans[MAX_N],mark[MAX_N];
int dp[MAX_N],depth[MAX_N];
void dfs(int v,int cnt,int l){
	depth[v]=cnt+1;
	mark[v]=true;
	int nd=0;
	for(int u:vec[v]){
		if(u==l)
            continue;
		if(mark[u])
			dp[v]=min(dp[v],depth[u]);
		else{
			dfs(u,cnt+1,v);
			dp[v]=min(dp[v],dp[u]);
			if(dp[u]>=depth[v])
                ans[v]=true;
            nd++;
		}
	}
    if(l==-1&&nd<2)
        ans[v]=false;
}
int main(){
    int n,m;
    cin>>n>>m;
    fill(dp,dp+max(n,m),INF);
    for(int i=0;i<m;i++){
        int a,b;
        cin>>a>>b;
        vec[a].push_back(b);
        vec[b].push_back(a);
    }
    dfs(0,0,-1);
    for(int i=0;i<n;i++)
        if(ans[i])
            cout<<i<<endl;
}

Measured memory_bytes: 7128
n, m, d = map(int, input().split())
if d >= n:
  print(0)
elif d == 0:
  print((n * (m - 1) * 10000000 / (n ** 2)) / 10000000)
else:
  print((2 * (n - d) * (m - 1) * 10000000 / (n ** 2)) / 10000000)


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using V = vector<int>;
using VV = vector<V>;
using VVV = vector<VV>;
using VL = vector<ll>;
using VVL = vector<VL>;
using VVVL = vector<VVL>;
template<class T> using VE = vector<T>;
template<class T> using P = pair<T, T>;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define REP(i,k,n) for(int i=(k);i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define output(x,y) cout << fixed << setprecision(y) << x << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
ll upper = MOD + MOD;
ll under = -upper;
ll UPPER = MOD * MOD;
ll UNDER = -UPPER;
const long double pi = 3.141592653589793;
const int N = 101010;
VE<P<int>> e[N];
void dijkstra(int r, VL& dist) {
	priority_queue<P<int>, VE<P<int>>,greater<P<int>>> pq;
	pq.push(make_pair(0, r));
	while (!pq.empty()) {
		int nd = pq.top().first;
		int nv = pq.top().second;
		pq.pop();
		if (dist[nv] < nd) continue;
		rep(i, e[nv].size()) {
			int nxtv = e[nv][i].first;
			int nxtd = e[nv][i].second;
			if (chmin(dist[nxtv], dist[nv] + nxtd)) pq.push(make_pair(dist[nxtv], nxtv));
		}
	}
}
int main() {
	int n, E, r;
	cin >> n >> E >> r;
	rep(i, E) {
		int a, b, c;
		cin >> a >> b >> c;
		e[a].push_back(make_pair(b, c));
	}
	VL dist(n, UPPER);
	dist[r] = 0;
	dijkstra(r, dist);
	rep(i, n) {
		if (dist[i] == UPPER) cout << "INF" << endl;
		else cout << dist[i] << endl;
	}
	return 0;
}


Measured memory_bytes: 13408
/**Bismillahir Rahmanir Rahim.**/
/*
         Md.Fagun Molla
         18ICTCSE006
         BSMRSTU(SHIICT)
*/
#include <bits/stdc++.h>
using namespace std;


#define  gcd(a,b)         __gcd(a,b)
#define  lcm(a,b)         (a*b)/gcd(a,b)
#define  ll               long long
#define  vi               std::vector<int>
#define  pb               push_back
#define  MAX              100007
#define  End              return 0;
#define                   pi acos(-1)


int main () {
    ll n;
    cin>>n;
    ll aa[n];
    ll s=0;
    for(ll i=0; i<n; i++){
        cin>>aa[i];
        s+=aa[i];
    }
    sort(aa,aa+n);
    ll m=s/n;
    if(s%n!=0)
        m++;
    ll sum=0;
    for(ll i=0; i<n; i++){
        sum+=((aa[i]-m)*(aa[i]-m));
    }
    m--;
    ll sum2=0;
    for(ll i=0; i<n; i++){
        sum2+=((aa[i]-m)*(aa[i]-m));
    }
    cout<<min(sum,sum2)<<endl;
    End;
}
/* pray for me
All is well
*/





Measured memory_bytes: 256
import java.util.Scanner;

class Main {
    private static long gcd(long a, long b) {
        if (a % b == 0) {
            return b;
        } else {
            return gcd(b, a % b);
        }
    }

    private static long lcm(long a, long b) {
        long gcd = gcd(a, b);
        return a * b / gcd;
    }

    private static int calcK(int a, int m) {
        int result = 0;
        int x = 1;
        do {
            result++;
            x = (a * x) % m;
        } while (x != 1);
        return result;
    }

    private static void solve() {
        Scanner scanner = new Scanner(System.in);
        
        while (true) {
            int a1 = scanner.nextInt();
            int m1 = scanner.nextInt();
            int a2 = scanner.nextInt();
            int m2 = scanner.nextInt();
            int a3 = scanner.nextInt();
            int m3 = scanner.nextInt();

            if (a1 + m1 + a2 + m2 + a3 + m3 == 0) {
                break;
            }

            int k1 = calcK(a1, m1);
            int k2 = calcK(a2, m2);
            int k3 = calcK(a3, m3);

            System.out.println(lcm(lcm(k1, k2), k3));
        }
    }

    public static void main(String... args) {
        solve();
    }
}

Measured memory_bytes: 12000
object Main {
  def main(args: Array[String]): Unit = {
    var monster_hp = io.StdIn.readLong()
    var divide_num = 0
    var attack_num = 0.toLong

    while( monster_hp > 0 ) {
      divide_num += 1
      monster_hp /= 2.toLong
    }

    ( 0 until divide_num ).foreach { i =>
      attack_num += Math.pow( 2, i ).toLong
    }

    println( attack_num )
  }
}

Measured memory_bytes: 54572
// clang-format off
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define rep1(i,n) for(ll i=1, i##_len=(n); i<=i##_len; ++i)
#define rrep(i,n) for(ll i=n-1; i>=0; --i)
#define rrep1(i,n) for(ll i=n; i>0; --i)
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort(all(x))
#define SORT_DESC(x) sort(all(x), greater<>())
#define pb push_back
#define mp make_pair
#define coutl cout<<fixed<<setprecision(10)
#define ANS(ans) cout<<ans<<endl;
const ll LINF = (1LL << 62) - 1;
const int INF = (1 << 30) - 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 (b<a){a=b;return 1;}return 0;}
// clang-format on

void solve(long long N, std::vector<long long> X) {
  ll ans = 0, min = LINF;
  rep1(p, 100) {
    ll v = 0;
    rep(i, N) v += pow(X[i] - p, 2);
    if (v < min) {
      min = v;
    }
  }
  ANS(min);
}

// clang-format off
int main() {
  long long N;
  scanf("%lld",&N);
  std::vector<long long> X(N);
  for(int i = 0 ; i < N ; i++){
    scanf("%lld",&X[i]);
  }
  solve(N, std::move(X));
  return 0;
}


Measured memory_bytes: 256
#include <iostream> 
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mk make_pair
#define MAX 1000001
ll prime[MAX];
#define FAST           ios_base::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);
#define mod 1000000007

ll rec(vector<vector<ll> >& dp,vector<ll>& arr,int n,int i,int k,int w)
{
  ll ans=0;
  if(i>=n)
    return 0;

  if(dp[i][k]!=-1)
    return dp[i][k];


  if(k!=0)
  ans=max(rec(dp,arr,n,i+1,w,w),arr[i]+rec(dp,arr,n,i+1,k-1,w));
  else
  ans=max(rec(dp,arr,n,i+1,k,w),rec(dp,arr,n,i+1,w,w));

  return dp[i][k]=ans;

}

//ll t[400008];
// void build(vector<ll>& a, int v, int tl, int tr) {
//     if (tl == tr) {
//         t[v] = a[tl];
//     } else {
//         int tm = (tl + tr) / 2;
//         build(a, v*2, tl, tm);
//         build(a, v*2+1, tm+1, tr);
//         t[v] = max(t[v*2] ,t[v*2+1]);
//     }
// }

// ll maxi(int v, int tl, int tr, int l, int r) {
//     if (l > r) 
//         return 0;
//     if (l == tl && r == tr) {
//         return t[v];
//     }
//     int tm = (tl + tr) / 2;
//     return max(maxi(v*2, tl, tm, l, min(r, tm)) ,maxi(v*2+1, tm+1, tr, max(l, tm+1), r));
// }



// void update(int v, int tl, int tr, int pos, ll new_val) {
//     if (tl == tr) {
//         t[v] = new_val;
//     } else {
//         int tm = (tl + tr) / 2;
//         if (pos <= tm)
//             update(v*2, tl, tm, pos, new_val);
//         else
//             update(v*2+1, tm+1, tr, pos, new_val);
//         t[v] = max(t[v*2] ,t[v*2+1]);
//     }
// }


struct hash_pair {
   template <class T1, class T2>
   size_t operator()(const pair<T1, T2>& p) const{
      auto hash1 = hash<T1>{}(p.first);
      auto hash2 = hash<T2>{}(p.second);
      return hash1 ^ hash2;
   }
};

ll rec(ll a[],ll first,ll last,int n)
{
  if(first>last)
    return 0;

  ll temp=1000000000;
  ll ind=0;
  for(ll i=first;i<=last;i++)
   {
    if(temp>a[i])
    {
      temp=a[i];
      ind=i;
    }
   }
   for(ll i=first;i<=last;i++)
    a[i]-=temp;


return min(last-first+1,(rec(a,first,ind-1,n)+rec(a,ind+1,last,n)+temp));

}
int main() { 
int d,t,s;
cin>>d>>t>>s;

if(d<=t*s)
  cout<<"Yes";
else
  cout<<"No";


return 0;

}


Measured memory_bytes: 3616