akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

const int M = 1000000007;

typedef pair<int, int> P;
struct edge { int to, cap, cost, rev; };

int V;
vector<edge> G[3010];
int h[3010];
int dist[3010];
int prevv[3010], preve[3010];
void add_edge(int from, int to, int cap, int cost) {
    G[from].push_back((edge){ to, cap, cost, (int)G[to].size() });
    G[to].push_back((edge){ from, 0, -cost, (int)G[from].size() - 1 });
}

int min_cost_flow(int s, int t, int f) {
    int res = 0;
    fill(h, h + V, 0);
    while (f > 0) {
        priority_queue<P, vector<P>, greater<P> > q;
        fill(dist, dist + V, M);
        dist[s] = 0;
        q.push(P(0, s));
        while (!q.empty()) {
            P p = q.top();
            q.pop();
            int v = p.second;
            if (dist[v] < p.first) continue;
            for (int i = 0; i < (int)G[v].size(); ++i) {
                edge &e = G[v][i];
                if (e.cap > 0 && dist[e.to] > dist[v] + e.cost + h[v] - h[e.to]) {
                    dist[e.to] = dist[v] + e.cost + h[v] - h[e.to];
                    prevv[e.to] = v;
                    preve[e.to] = i;
                    q.push(P(dist[e.to], e.to));
                }
            }
        }
        if (dist[t] == M) break;
        for (int v = 0; v < V; ++v)
            h[v] += dist[v];

        int d = f;
        for (int v = t; v != s; v = prevv[v])
            d = min(d, G[prevv[v]][preve[v]].cap);

        f -= d;
        if (d * h[t] >= 0) break;
        res += d * h[t];
        for (int v = t; v != s; v = prevv[v]) {
            edge &e = G[prevv[v]][preve[v]];
            e.cap -= d;
            G[v][e.rev].cap += d;
        }
    }
    return res;
}


int main() {
    int n;
    cin >> n;
    vector<vector<int>> a(n, vector<int>(2));
    int cnt[1000010] = {};
    for (int i = 0; i < n; ++i) {
        cin >> a[i][0] >> a[i][1];
        if (a[i][0] > a[i][1]) {
            int t = a[i][0];
            a[i][0] = a[i][1];
            a[i][1] = t;
        }
        ++cnt[a[i][0]];
        ++cnt[a[i][1]];
    }
    int lc = 0;
    int ind[1000010];
    for (int i = 0; i < 1000010; ++i) {
        if (cnt[i])
            ind[i] = lc++;
    }
    V = n + lc + 2;
    for (int i = 0; i < lc; ++i) {
        add_edge(n + i, n + lc + 1, 1, 0);
    }
    int ans = 0;
    for (int i = 0; i < n; ++i) {
        add_edge(n + lc, i, 1, 0);
        add_edge(i, n + ind[a[i][0]], 1, -a[i][1]);
        add_edge(i, n + ind[a[i][1]], 1, -a[i][0]);
    }
    cout << (ans - min_cost_flow(n + lc, n + lc + 1, n)) << "\n";
    return 0;
}

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

int main(void) {
	int p, q, r;
	cin >> p >> q >> r;
	int ans = 201;
	ans = min(ans, p+q);
	ans = min(ans, p+r);
	ans = min(ans, q+r);
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define endl '\n'
#define pb push_back
#define mp make_pair
#define LL long long
#define INF 0x3f3f3f3f
#define Inf 1000000000000000000LL
#define F first
#define S second
using namespace std;
typedef pair<int,int>pii;
char s[210];
int n;
bool check(int l,int r){
	for(int i=l,j=r;i<j;i++,j--){
		if(s[i]!=s[j])return 0;
	}
	return 1;
}
int main(){
	cin>>(s+1);
	n=strlen(s+1);
	if(!check(1,n))return puts("No"),0;
	if(!check(1,(n-1)/2))return puts("No"),0;
	if(!check((n+3)/2,n))return puts("No"),0;
	puts("Yes");
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>  
#include <algorithm>  
#include <assert.h>
#include <bitset>
#include <cmath>  
#include <complex>  
#include <deque>  
#include <functional>  
#include <iostream>  
#include <limits.h>  
#include <map>  
#include <math.h>  
#include <queue>  
#include <set>  
#include <stdlib.h>  
#include <string.h>  
#include <string>  
#include <time.h>  
#include <unordered_map>  
#include <unordered_set>  
#include <vector>

#pragma warning(disable:4996)  
#pragma comment(linker, "/STACK:336777216")  
using namespace std;

#define mp make_pair  
#define Fi first  
#define Se second  
#define pb(x) push_back(x)  
#define szz(x) ((int)(x).size()) 
#define all(x) (x).begin(), (x).end()  
#define ldb ldouble  

typedef tuple<int, int, int> t3;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;
#define rep(i, n) for(int i=0;i<n;i++)

int IT_MAX = 1 << 17;
const ll MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x1f3f3f3f3f3f3f3f;
const db PI = acos(-1);
const db ERR = 1e-12;

ll C[4050][4050];
ll F[4050];

ll sum[4050];
int main() {
	int A, B, i, j, k;
	scanf("%d %d", &A, &B);

	F[0] = 1;
	for (i = 1; i <= 4000; i++) F[i] = (F[i - 1] * i) % MOD;
	for (i = 0; i <= 4000; i++) {
		C[i][0] = C[i][i] = 1;
		for (j = 1; j < i; j++) C[i][j] = (C[i - 1][j - 1] + C[i - 1][j]) % MOD;
	}

	ll ans = A + 1;
	for (int y = 1; y <= A; y++) {
		sum[0] = C[y - 1][0];
		for (int i = 1; i <= y - 1; i++) sum[i] = (sum[i - 1] + C[y - 1][i]) % MOD;
		for (int xz = 0; xz + y <= A; xz++) {
			ll v = xz + 1;
			v = v * C[B - 1][y] % MOD;
			v = v * sum[min(y - 1, A - xz - y)] % MOD;
			ans = (ans + v) % MOD;
		}
	}
	return !printf("%lld\n", ans);
}

Measured memory_bytes: 125568
package main

import (
        "fmt"
        "math"
)

func main() {
        var a, b, x, d float64
        fmt.Scanf("%f %f %f", &a, &b, &x)
        c := x / a / a
        if c*2 > b {
                // b:c*2-b = a+e:e
                // d = a+e
                d = a + (2*c-b)*a/(2*b-2*c)
        } else {
                d = x / a / b * 2
        }
        fmt.Println(math.Atan(b/d) / math.Pi * 180)

}

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

#define rep(i, n) for(int i = 0; i<(n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;

const int MOD = 1000000007;

struct Pos {
    int x;
    int y;
    long long h;
};

int main() {
    int N;
    cin >> N;
    int x, y, h, maxH;
    vector<Pos> pos(N);
    rep(i, N) {
        cin >> x >> y >> h;
        pos[i] = {x, y, h};
        chmax(maxH, h);
    }


    rep(h, 200) {
        int H = maxH + h;
        rep(i, 101) {
            rep(j, 101) {
                bool ok = true;
                rep(k, N) {
                    Pos p = pos[k];
                    if (p.h != max(H - abs(p.x - i) - abs(p.y - j), 0)) {
                        ok = false;
                        break;
                    }
                }

                if (ok) {
                    cout << i << " " << j << " " << H;
                    exit(0);
                }
            }
        }
    }
}

Measured memory_bytes: 256
import java.util.*;

class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String s = sc.nextLine();
		int n = s.length();
		if((is_Palindrome(s, n))){
			int n1 = (n - 1)/ 2;
			int n2 = (n + 3)/ 2 - 1;
			String s1 = s.substring(0,n1);
			String s2 = s.substring(n2, n);
			//System.out.println(s1);
			//System.out.println(s2);
			if(is_Palindrome(s1, n1)){
				if(is_Palindrome(s2, n1)){
					System.out.println("Yes");
				}
				else{
				System.out.println("No");
			}
		}else{
			System.out.println("No");
			}
		}
		else{
			System.out.println("No");
		}
		
	}
	
	public static boolean is_Palindrome(String s, int n){
		boolean flag = true;
		if(n % 2 != 0){
			int n3 = (n - 1)/ 2;
			int i = 0;
			while(i < n3){
				if(s.charAt(i) != s.charAt(n - i - 1)){
					flag = false;
					break;
				}
				i++;
			}
		}
		else{
			int n3 = (n - 1)/ 2 + 1;
			int i = 0;
			while(i < n3){
				if(s.charAt(i) != s.charAt(n - i - 1)){
					flag = false;
					break;
				}
				i++;
			}
		}
		return flag;
	}
	
	}

Measured memory_bytes: 23124
program prob5
    implicit none
    integer, allocatable::a(:,:)
    integer::c(10,10), n(10), t1(10), dp(10)
    integer::h, w, i, j, k, ans
    read(*,*) h, w
    allocate(a(h,w))
    do i = 1, 10
        read(*,*) c(i,:)
    end do

    n = 0
    do i = 1, h
        read(*,*) a(i,:)
        do j = 1, w
            if(a(i,j) > -1) then 
                n(a(i,j)+1) = n(a(i,j)+1) + 1
            end if
        end do
    end do
    dp(:) = c(:,2)
    do k = 1, 10
        do i = 1, 10
            do j = 1, 10
                dp(i) = min(dp(i),dp(j)+c(i,j))
            end do
        end do
    end do
    ans = 0
    do i = 1, 10
        ans = ans + n(i)*dp(i)
    end do
    write(*,*) ans
    stop
end program

Measured memory_bytes: 3064
#include <cstdlib>
#include <cmath>
#include <iomanip>
#include <iostream>

using namespace std;

int main()
{
    int N,T[10000],P[100],M,X[10000],sum=0;
    cin >> N;
    for(int i = 0;i<N;i++){
        cin >> T[i];
        sum+=T[i]; //25
    }
    cin >> M;
    for(int i = 0;i<M;i++){
        cin >> P[i] >> X[i];
    }
    for(int i = 0;i<M;i++){
        cout << sum + (X[i] - T[P[i]-1]) << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include <algorithm>
#include <string>
#define syso(s) std::cout<<s<<endl;
#define sc(i) std::cin>>i;
using namespace std;
int main() {
	int a,b;
	string str;
	sc(a)
	sc(str)
	sc(b)
	int ans=0;
	if (str == "+") {
	ans=a+b;
	}
	else {
		ans=a-b;
	}
	syso(ans)
	return 0;
}

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

#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define eb push_back
#define endl '\n'
#define all(x) (x).begin(), (x).end()
#define output(x) cout<<x<<endl;
#define fre(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
#define frd(i, a, b) for (int i = (int)(a); i >= b; --i)

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<pair<int,int> > vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;
const ll mod=1e9+7;
const int maxn = 2e5+10;

bool Q;
struct Line {
    mutable ll k, m, p;
    bool operator<(const Line& o) const {
        return Q ? p < o.p : k < o.k;
    }
};
struct LineContainer : multiset<Line> {
    const ll inf = LLONG_MAX;
    ll div(ll a, ll b){
        return a / b - ((a ^ b) < 0 && a % b);
    }
    bool isect(iterator x, iterator y) {
        if (y == end()) { x->p = inf; return false; }
        if (x->k == y->k) x->p = x->m > y->m ? inf : -inf;
        else x->p = div(y->m - x->m, x->k - y->k);
        return x->p >= y->p;
    }
    void add(ll k, ll m) {
        auto z = insert({k, m, 0}), y = z++, x = y;
        while (isect(y, z)) z = erase(z);
        if (x != begin() && isect(--x, y)) isect(x, y = erase(y));
        while ((y = x) != begin() && (--x)->p >= y->p)
            isect(x, erase(y));
    }
    ll query(ll x) {
        assert(!empty());
        Q = 1; auto l = *lower_bound({0,0,x}); Q = 0;
        return l.k * x + l.m;
    }
};

ll dp[maxn];

int main(){
	cin.tie(0);ios_base::sync_with_stdio(0);	
	LineContainer l;
	int n;
	cin>>n;
	ll c;
	cin>>c;
	ll h[n];
	for (int i = 0; i < n; ++i)
	{
		cin>>h[i];
	}
	l.add(2*h[0] , -h[0]*h[0]);
	fre(i,1,n-1){
		ll temp=l.query(h[i]);
		temp=0-temp;
		dp[i]=h[i]*h[i]+c+temp;
		l.add(2*h[i] , -dp[i]-h[i]*h[i]);
	}	
	output(dp[n-1]);
	return 0;
}

Measured memory_bytes: 15872
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <list>
#include <iterator>
#include <assert.h>
#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 LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
using namespace std;


ll a[16][16];
ll dp[1<<16];

int main(int argc, char* argv[])
{
    int n;
    scanf("%d", &n);

    int i,j;
    for(i=0; i<n; i++) {
        for(j=0; j<n; j++) {
            scanf("%lld", &a[i][j]);
        }
    }

    int mm=(1<<n);
    int z[17];
    int k;
    for(k=0; k<mm; k++) {
        int siz=0;
        for(i=0; i<n; i++) {
            if(k & (1<<i)) z[siz++]=i;
        }

        dp[k]=0;
        for(i=0; i<siz; i++) {
            for(j=i+1; j<siz; j++) {
                dp[k] += a[z[i]][z[j]];
            }
        }
    }

    for(k=0; k<mm; k++) {
        int siz=0;
        for(i=0; i<n; i++) {
            if(k & (1<<i)) z[siz++]=i;
        }
        ll max=0;
        int MM=(1<<(siz-1));
        for(i=0; i<MM; i++) {
            int tmp0=0;
            for(j=0; j<siz; j++) {
                if(i & (1<<j)) tmp0 |= (1<<z[j]);
            }
            ll val = dp[tmp0]+dp[k^tmp0];
            max = MAX(max, val);
        }
        dp[k] = max;
    }
    printf("%lld\n", dp[mm-1]);

    return 0;
}


Measured memory_bytes: 640
n,m = gets.split(" ").map(&:to_i)
prefs = []
n.times do
  prefs << gets.split(" ").map(&:to_i)
end

cands = prefs.shift[1..-1]
prefs.each do |p|
  p = p[1..-1]
  cands = cands & p
end


puts cands.count

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

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

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

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

  for (int i = 1, m = 7 % K; i <= 1 << 20; ++i) {
    if (m == 0) {
      cout << i << endl;
      return 0;
    }
    m = (m * 10 + 7) % K;
  }

  cout << -1 << endl;

  return 0;
}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define For(i,a,b) for(i=a;i<b;i++)
#define rep(i,N) For(i,0,N)
#define rep1(i,N) For(i,1,N)
#define mod 1000000007

long mmid(long a,long b,long c){return a<b?(b<c?b:max(a,c)):(b>c?b:min(a,c));}

ll modinv(ll a) {
  ll b=mod,u=1,v=0,t;
  while(b){
    t=a/b;
    a-=t*b; swap(a,b);
    u-=t*v; swap(u,v);
  }
  return (u+mod)%mod;
}

ll moddevide(ll a,ll b){return (a*modinv(b))%mod;}

ll modncr(ll n,ll r){
  ll i,plus=1;
  rep(i,r){
    plus=(plus*(n-i))%mod;
    plus=moddevide(plus,i+1);
  }
  return plus;
}

ll euclidean_gcd(ll a, ll b) {
  if(a<b) return euclidean_gcd(b, a);
  ll r;
  while ((r=a%b)){a=b;b=r;}
  return b;
}

void printmap(vector<ll>& a,ll H,ll W){
  ll i,j;
  For(i,0,H+2){
    For(j,0,W+2){cout<<a[i*(W+2)+j];}
    cout<<endl;
  }
}
void inputmap(vector<ll>& a,ll H,ll W){
  ll i,j;
  string ss;
  For(i,1,H+1){
    cin>>ss;
    For(j,1,W+1){
      if(ss[j-1]=='#'){
        a[i*(W+2)+j]=1;
      }else{
        a[i*(W+2)+j]=0;
      }
    }
  }
}


int main(){
  int i=2,j,N,K=100000,l,r;
  vector<int> a(K+1,1),suma(K+1,0);
  a[0]=a[1]=0;
  while(i<=K){
    if(a[i]==1){
      j=2;
      while(j*i<=K){
        a[j*i]=0;
        j++;
      }
    }
    i++;
  }
  for(i=3;i<=K;i+=2){
    if(a[i]==1&&a[(i+1)/2]==1){
      suma[i]=suma[i-2]+1;
    }else{
      suma[i]=suma[i-2];
    }
  }
  cin>>N;
  while(N--){
    cin>>l>>r;
    if(l>1)l-=2;
    cout<<suma[r]-suma[l]<<endl;
  }
  return 0;
}

Measured memory_bytes: 1408
import sys
input = sys.stdin.readline
from collections import Counter

N = int(input())
Ss = Counter([input().rstrip() for _ in range(N)])
m = max(Ss.values())
ans = []
for k, v in Ss.items():
    if v == m:
        ans.append(k)
ans.sort()
print(*ans, sep="\n")

Measured memory_bytes: 35572
#include<algorithm>     //sort,二分探索,など
#include<bitset>        //固定長bit集合
#include<cmath>         //pow,logなど
#include<complex>       //複素数
#include<deque>         //両端アクセスのキュー
#include<fstream>       //ファイルストリーム（標準入力変更用）
#include<functional>    //sortのgreater
#include<iomanip>       //setprecision(浮動小数点の出力の誤差)
#include<iostream>      //入出力
#include<iterator>      //集合演算(積集合,和集合,差集合など)
#include<map>           //map(辞書)
#include<numeric>       //iota(整数列の生成),gcdとlcm(c++17)
#include<queue>         //キュー
#include<set>           //集合
#include<stack>         //スタック
#include<string>        //文字列
#include<unordered_map> //イテレータあるけど順序保持しないmap
#include<unordered_set> //イテレータあるけど順序保持しないset
#include<utility>       //pair
#include<vector>        //可変長配列

//名前
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef map<string, int> msi;
typedef map<string, ll> msll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pllll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
typedef vector<vector<string>> vvs;
typedef vector<vector<bool>> vvb;

//定数
const ll MOD = 1000000007;
const ll INF = 1000000000000000000;

//マクロ
#define rep(i,n) for(int i=0;i<n;i++)
#define reps(i,s,e) for(int i=s;i<e;i++)
#define repse(i,s,e) for(int i=s;i<=e;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define in1(x1) cin >> x1
#define in2(x1, x2) cin >> x1 >> x2
#define in3(x1, x2, x3) cin >> x1 >> x2 >> x3
#define inN(x, N) rep(i, N) in1(x[i])
#define outl(x) cout << x << endl
#define out2l(x, y) cout << x << " " << y << 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; }

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

    //標準入力をファイルに変更
    //std::ifstream in("input.txt");
    //std::cin.rdbuf(in.rdbuf());

    int N;
    in1(N);

    if (N == 1)
    {
        outl("Hello World");
    }
    else
    {
        int A, B;
        in2(A, B);
        outl(A + B);
    }
    return 0;
}


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

int main(){
    string ss;
    cin>>ss;
    for(int i=0;i<ss.length();i++){
        if(ss[i]=='7'){
            cout<<"Yes";
            return 0;
        }
    }
    cout<<"No";
    return 0;
}


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

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

    char dif = 'A' - 'a';
 
    cout << (char)(a[0] + dif) << (char)(b[0] + dif) << (char)(c[0] + dif) << endl;

    return 0;
}

Measured memory_bytes: 256
A = [3,5]
Q = []

def a(x,y,z)
 Q << [?+,x,y,z]*" "
 A[z] = (A[x]||=0) + (A[y]||=0)
end

def c(x,y,z)
 Q << [?<,x,y,z]*" "
 A[z] = (A[x]||=0) < (A[y]||=0) ? 1 : 0
end

c(3,0,3)
63.times{|i|
 a(3+i,3+i,4+i)
}

def to_b(x,s)
 a(x,3,x)
 63.downto(0){|i|
  a(3+i,s+64+i+1,s+64+i)
  c(s+64+i,x,s+i)
  a(s+i,2,s+64+i)
  i.times{a(s+64+i,s+64+i,s+64+i)}
  a(s+64+i,s+64+i+1,s+64+i)
 }
end

to_b(0,67)
to_b(1,195)

32.times{|i|
 32.times{|j|
  a(67+i,195+j,324)
  c(3,324,325)
  a(326+i+j,325,326+i+j)
 }
}

64.times{|i|
 i.times{a(326+i,326+i,326+i)}
 a(2,326+i,2)
}

# STDERR.puts "Q = #{Q.size}"
# STDERR.puts A.map.with_index{|x,i|x||=0;"#{i}:#{x}"}*" "

puts Q.size
puts Q


Measured memory_bytes: 15780
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#define IO(i, o) freopen(i, "r", stdin), freopen(o, "w", stdout)

using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
mt19937 rng((uint32_t)chrono::steady_clock::now().time_since_epoch().count());

int a, b;

int main(){
	//IO("input.txt", "output.txt");
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> a >> b;
	cout << ((b % a == 0) ? a + b : b - a);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define endl '\n'
#define FOR(i, a, n) for (int i = (a); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
using namespace std;

const int MOD = 1000000007;
string S;
int dp[100010][13];

void _main() {
    cin >> S;
    dp[0][0] = 1;
    REP (i, S.size()) REP (j, 13) {
        if (S[i] == '?') REP (k, 10) (dp[i + 1][(10 * j + k) % 13] += dp[i][j]) %= MOD;
        else (dp[i + 1][(10 * j + (S[i] - '0')) % 13] += dp[i][j]) %= MOD;
    }
    cout << dp[S.size()][5] << endl;
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(10);
    _main();
    return 0;
}

Measured memory_bytes: 10604
#include <iostream>
#include <string>
#include <algorithm>
#include <utility>
#include <iomanip>
#include <functional>
#include <queue>
#include <stack>
#include <map>
#include <vector>
#include <cmath>
#include <cctype>
#include <cstdio>
#define ll long long
#define INF 1e+9
#define MOD 1000000007
using namespace std;


int main(){
    int N;
    cin >> N;
    string S;
    cin >> S;
    
    int left=0;
    
    int temp=0;
    for(int i=0; i<N; i++){
        if(S[i]=='('){
            temp++;
        }else if(S[i]==')'){
            if(temp>0){
                temp--;
            }else{
                left++;
            }
        }
    }
    
    int right=temp;
   
    for(int i=0; i<left; i++){
        cout<<'(';
    }
    cout<<S;
    for(int i=0; i<right; i++){
        cout<<')';
    }
    cout<<endl;
    return 0;
}


Measured memory_bytes: 256
A,B=map(int,input().split())
ans=[[] for _ in range(100)]
for i in range(100):
  for j in range(100):
    if i<50:
      ans[i].append(".")
    else:
      ans[i].append("#")
A-=1
B-=1
for i in range(0,50,2):
  for j in range(0,100,2):
    if B>0:
      ans[i][j]="#"
      B-=1
for i in range(51,100,2):
  for j in range(0,100,2):
    if A>0:
      ans[i][j]="."
      A-=1
print(100,100)
for i in range(100):
  print("".join(ans[i]))

Measured memory_bytes: 66524
X,N = map(int,input().split())
if N != 0:
    p = list(map(int,input().split()))

    p.sort()

    for i in range(100):
        a = X+i
        b = X-i
        if not b in p:
            print(b)
            break
        elif not a in p:
            print(a)
            break
else:
    print(X)

Measured memory_bytes: 61632
# coding: utf-8
def main():
    N, K = map(int, input().split())
    H = input().split()
    H = [int(i) for i in H]

    H = sorted(H)
    if N < K:
        print(0)
    elif K == 0:
        print(sum(H))
    else:
        H = H[:-K]
        print(sum(H))


if __name__ == '__main__':
    main()


Measured memory_bytes: 26024
#include <iostream>
using namespace std;
int main(){
    int n,k;
    cin>>n;
    cin>>k;
    int ans=0;
    for(int i=0;i<n;i++){
        int h;
        cin>>h;
        if(h>=k){
            ans++;
        }
    }
    cout<<ans<<endl;
    return 0;
}


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

n = int(input())
b = tuple(map(int, input().split()))

a = [inf] * n
for i in range(n - 2, -1, -1):
    a[i + 1] = min(a[i + 1], b[i])
    a[i] = min(a[i], b[i])
print(sum(a))


Measured memory_bytes: 2940
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class AtCoderA
{
    static void Main()
    {
        var sc = new Scanner();

        long q = sc.NextLong();

        long max = 100000;

        bool[] isPrimes = new bool[max + 1];
        for (int i = 2; i < max + 1; i++)
        {
            isPrimes[i] = true;
        }

        for (int i = 2; i * i < max + 1; i++)
        {
            if (!isPrimes[i])
            {
                continue;
            }
            for (int j = i + 1; j < max + 1; j++)
            {
                if (j % i == 0)
                {
                    isPrimes[j] = false;
                }
            }
        }

        long[] sums = new long[max + 1];
        for (int i = 1; i < max + 1; i++)
        {
            sums[i] = sums[i - 1] + ((isPrimes[i] && isPrimes[(i + 1) / 2]) ? 1 : 0);
        }

        for (int i = 0; i < q; i++)
        {
            long l = sc.NextLong();
            long r = sc.NextLong();

            var answer = sums[r] - sums[l - 1];

            Console.WriteLine(answer);
        }
    }

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}


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

int main(){
    int w,h,x,y,r;
    cin >> w >> h >> x >> y >> r;
    if (((0<=(x-r))&&((x+r)<=w))&&((0<=(y-r))&&((y+r)<=h))) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 3116
n = int(input())
dic = {i+1: [] for i in range(n)}

for i in range(n):
    a = int(input())
    for j in range(a):
        x, y = map(int, input().split())
        dic[i+1].append((x, y))
#print(dic)
ans = 0
for i in range(1 << n):
    flag = 0
    s = str(bin(i))
    cnt = s.count("1")
    #print(s,cnt)

    for j in range(n):
        if (i >> j) & 1:
            for x, y in dic[j + 1]:
                if str(bin((i>>(x-1))))[-1] == str(y):
                    continue
                else:
                    flag = 1
                    break
            
            
            
    if flag != 1:
        ans = max(ans, cnt)

print(ans)


            


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

int main() {
	int n[32] = { 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51 };
	int k;
	cin >> k;
	cout << n[k - 1];
	return 0;
}

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

#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <algorithm>

#include <bits/stdc++.h>
#include <cmath>
#include <limits>

using namespace std;

int main(int argc, char* argv[]){
	int N, K;
	cin >> N >> K;

	int i=0;
	long double ans = 0.0;
	for(int s=1; s<=N; s++){
		int u = s, n = 1;
		long double p = 1;
		while(u<K){
			u *= 2;
			//n *= 2;
			p /= 2;
		}
		//p = 1.0/n;
		ans += p;
	}
	ans = ans/N;
	printf("%.12Lf\n", ans);
	return 0;
}

Measured memory_bytes: 256
from collections import deque
n , u , v = map(int,input().split())
u -= 1
v -= 1
route = [[] for i in range(n)]
for i in range(n-1):
    a , b = map(lambda x:int(x)-1,input().split())
    route[a].append(b)
    route[b].append(a)

takyori = [-1 for i in range(n)]
takyori[u] = 0
d = deque()
d.append(u)
while d:
    now = d.popleft()
    for i in route[now]:
        if takyori[i] == -1:
            takyori[i] = takyori[now] + 1
            d.append(i)

aokyori = [-1 for i in range(n)]
aokyori[v] = 0
d = deque()
d.append(v)
while d:
    now = d.popleft()
    for i in route[now]:
        if aokyori[i] == -1:
            aokyori[i] = aokyori[now] + 1
            d.append(i)
ans = 0
for i in range(n):
    if takyori[i] <= aokyori[i]:
        ans = max(ans,aokyori[i]-1)
print(ans)

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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;

#define each(i,a) for (auto&& i : a)
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
#define pb push_back
#define all(a) (a).begin(),(a).end()
#define chmin(x,v) x = min(x, v)
#define chmax(x,v) x = max(x, v)

const ll linf = 1e18;
const double eps = 1e-12;
const double pi = acos(-1);

template<typename T>
istream& operator>>(istream& is, vector<T>& vec) {
    each(x,vec) is >> x;
    return is;
}
template<typename T>
ostream& operator<<(ostream& os, const vector<T>& vec) {
    rep(i,vec.size()) {
        if (i) os << " ";
        os << vec[i];
    }
    return os;
}
template<typename T>
ostream& operator<<(ostream& os, const vector< vector<T> >& vec) {
    rep(i,vec.size()) {
        if (i) os << endl;
        os << vec[i];
    }
    return os;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s; cin >> s;
    if (s.find("AC") < s.size()) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
   long long n, m, x, i, a[100100], ans0=0, ansn=0;
   cin >> n >> m >> x;
   for(i=0;i<m;i++){
      cin >> a[i];
   }
   for(i=x;i>=0;i--){
      for(int j=0;j<m;j++){
         if(a[j]==i) ans0++;
      }
   }
   for(i=x;i<=n;i++){
      for(int j=0;j<m;j++){
         if(a[j]==i) ansn++;
      }
   }
   cout << min(ans0, ansn) <<endl;
   return 0;
}



Measured memory_bytes: 256
n = int(input())
dp = [200000] * (n+10)
dp[0] = 0
for i in range(1,n+1):
    dp[i] = min(dp[i-1]+1, dp[i])
    
    six = 6
    while i - six >= 0:
        dp[i] = min(dp[i-six]+1, dp[i])
        six *= 6 

    nine = 9
    while i - nine >= 0:
        dp[i] = min(dp[i-nine]+1, dp[i])
        nine *= 9

print(dp[n])

Measured memory_bytes: 3828
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define int long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define _GLIBCXX_DEBUG
const int INF=1e18;

signed main(){
  	int N,K;cin>>N>>K;
    vector<int>A;
    vector<int>B;
  	A.pb(0);B.pb(0);
    REP(i,N){
        int a;cin>>a;
        if(a<0)A.pb(-a);
        if(a>0)B.pb(a);
        if(a==0)K--;
    }
    sort(A.begin(),A.end());
    sort(B.begin(),B.end());
    int ans=INF;
    for(int i=0;i<A.size();i++){
      	for(int j=0;j<B.size();j++){
          	if(i+j!=K)continue;
          	int preans=(A[i]+B[j])+min(A[i],B[j]);
          	ans=min(ans,preans);
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 1656
def main():
    X, Y = [int(x) for x in input().split()]
    print(a(X)+a(Y)+ (400000 if X==Y==1 else 0))

def a(i):
    if i == 1:
        return 300000
    elif i == 2:
        return 200000
    elif i == 3:
        return 100000
    else:
        return 0
main()

Measured memory_bytes: 2940
#include<cstdio>
#include<cstring>
#include<vector>
#include<algorithm>
#include<queue>
#include<set>
using namespace std;

const int N = 2e5 + 10;

#define pb push_back

int n, m;
vector<int> V[N];
int edge[N][3];
struct Edge{
	int to, line;
	Edge(){}
	Edge(int to, int line):to(to),line(line){}
	bool operator <(const Edge &A)const{
		return line < A.line;
	}
};
vector<Edge> G[N];
set<int> ST[N];

struct Node{
	int to, line, u;
	Node(){}
	Node(int to, int line, int u):to(to),line(line),u(u){}
	bool operator < (const Node &A)const{
		return u > A.u;
	}
};

int find_index(int x, int y){
	int n = G[x].size();
	int low=0, top=n-1, ret=top, mid;
    while(low <= top){
		mid = low + top >> 1;
		if(G[x][mid].line >= y){
			ret = min(ret, mid);
			top = mid - 1;
		} else {
			low = mid + 1;
		}
    }
    return ret;
}

int solve(){
	priority_queue<Node> Q;
	Node nd;
    Q.push(Node(1, 0, 1));
    int st, ed;
    while(!Q.empty()){
		nd = Q.top(); Q.pop();
        if(nd.to == n){
			return nd.u;
        }
        if(ST[nd.to].count(nd.line)){
			continue;
        }
        ST[nd.to].insert(nd.line);
        if(nd.line){
			if(!ST[nd.to].count(0)){
                Q.push(Node(nd.to, 0, nd.u+1));
			}
			st = find_index(nd.to, nd.line);
			for(int i=st; i<G[nd.to].size(); i++){
				if(G[nd.to][i].line != nd.line){
					break;
				}
				int j = G[nd.to][i].to;
				if(!ST[j].count(nd.line)){
					Q.push(Node(j, nd.line, nd.u));
				}
			}
        } else {
			for(int i=0; i<V[nd.to].size(); i++){
				int j = V[nd.to][i];
				if(!ST[nd.to].count(j)){
					Q.push(Node(nd.to, j, nd.u));
				}
			}
        }
    }
    return -1;
}

int main(){
	int x, y, z;
	while(~scanf("%d %d", &n, &m)){
        for(int i=1; i<=n; i++){
			V[i].clear();
			G[i].clear();
			ST[i].clear();
        }
        for(int i=0; i<m; i++){
			scanf("%d %d %d", &x, &y, &z);
			edge[i][0] = x;
			edge[i][1] = y;
			edge[i][2] = z;
			V[x].pb(z);
			V[y].pb(z);
			G[x].pb(Edge(y, z));
			G[y].pb(Edge(x, z));
        }
        for(int i=1; i<=n; i++){
			sort(V[i].begin(), V[i].end());
			V[i].erase(unique(V[i].begin(), V[i].end()), V[i].end());

			sort(G[i].begin(), G[i].end());
        }
        printf("%d\n", solve());
	}
	return 0;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

typedef pair<int, int> ii;
typedef pair<ll, ll> pll;

int main( int argc, char *argv[] ) {
	ll n, k, res = 0, tmp;
	cin >> n >> k;

	if ( k == 0 ){
		res = n * n;
	}else{
		for ( ll mod = k + 1 ; mod < n + 1 ; mod++ ){
			res += (mod - k) * ( n / mod );
			tmp = n % mod - k + 1;
			res += tmp > 0 ? tmp : 0;
		}
	}
	cout << res << "\n";
	return 0;
}


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

int main() {
        int a, b;
        vector<pair<int, int>> es;
        while (~scanf("%d%d", &a, &b)) es.emplace_back(a, b);
        int k  = 0;
        while (k < es.size()) {
                vector<int> deg(105);
                while (es[k].first != 0) {
                        deg[es[k].first] ++;
                        deg[es[k].second] ++;
                        k ++;
                }
                k ++;
                bool ok = true;
                for (int i = 3; i <= 105; i ++) if (deg[i] & 1) ok = false;
                if (deg[1] % 2 == 0 || deg[2] % 2 == 0) ok = false;
                puts(ok ? "OK" : "NG");
        }
        return 0;
}

Measured memory_bytes: 2644
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#define MOD 1000000007LL
using namespace std;

int main(){
	long long int a, b, x;
	cin >> a >> b >> x;
	cout << ((((a / x) * x + (a % x != 0) * x) * -1) + ((b / x) * x)) / x + 1 << endl;
	return 0;
}

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

using namespace std;

string A, B;

int main(void)
{
	cin >> A >> B;
	if(A.size() > B.size()){
		string T = A, A = B, B = T;
	}
	
	string Z = "";
	for(int i = 0; i < (int)B.size() - (int)A.size(); i++){
		Z += "0";
	}
	A = Z + A;
	
	for(int i = 0; i < A.size(); i++){
		if(A[i] < B[i]){
			cout << "LESS" << endl;
			return 0;
		}
		else if(A[i] > B[i]){
			cout << "GREATER" << endl;
			return 0;
		}
	}
	
	cout << "EQUAL" << endl;
	return 0;
}

Measured memory_bytes: 256
<?php
  $n = trim(fgets(STDIN));
  $t = explode(" ", trim(fgets(STDIN)));
  $m = trim(fgets(STDIN));
  $sum = array_sum($t);
  for($i=0; $i<$m; $i++){
      $_sum = $sum;
      fscanf(STDIN, "%d %d", $p,$x);
      $_sum -= $t[$p-1];
      $_sum += $x;
      echo $_sum."\n";
  }

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


int main() {
	int n,m;
	cin >> n >> m;
	
	if (n==m){
	    cout << "Yes" << endl;
	}else{
	    cout << "No" << endl;
	}
	
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

void calcSimulataneousEquation(double a, double b, double c, double d, double e, double f, double *x, double *y) {
  *x = (c * e - f * b) / (a * e - d * b) + 0.0;
  *y = (a * f - d * c) / (a * e - d * b) + 0.0;
}

int main(void) {
  double a, b, c, d, e, f;
  double x, y;

  while (scanf("%lf %lf %lf %lf %lf %lf", &a, &b, &c, &d, &e, &f) != EOF) {
    calcSimulataneousEquation(a, b, c, d, e, f, &x, &y);
    printf("%.3f %.3f\n", x, y);
  }

  return 0;
}

Measured memory_bytes: 648
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <unordered_map>
#include <limits>
#include <map>
#include <cassert>
#include <utility>
#include <algorithm>
#include <functional>

struct Edge {
  size_t from, to, distance, attack;
};

struct Info {
  size_t attacks, place, money;

  friend bool operator >(Info const& lhs, Info const& rhs) {
    if (lhs.attacks != rhs.attacks) {
      return lhs.attacks > rhs.attacks;
    }
    if (lhs.money != rhs.money) {
      return lhs.money < rhs.money;
    }
    return lhs.place > rhs.place;
  }
};

size_t solve(size_t N, size_t M, size_t L) {
  std::vector<std::vector<Edge>> adj_list(N);
  for (size_t i = 0; i < M; i++) {
    size_t f, t, d, e;
    std::cin >> f >> t >> d >> e;
    adj_list[f - 1].push_back(Edge{f - 1, t - 1, d, e});
    adj_list[t - 1].push_back(Edge{t - 1, f - 1, d, e});
  }
  
  std::priority_queue<Info, std::vector<Info>, std::greater<Info>> queue;
  // ??°???n??????????????????????°?attack
  std::vector<std::vector<size_t>> min_attacks(N, std::vector<size_t>(L + 1, 2 << 29));
  min_attacks[0][L] = 0;
  queue.push(Info{0, 0, L});
  while (!queue.empty()) {
    auto info = queue.top();
    queue.pop();
    //std::cout << "info " << info.attacks << " " << info.place << " " << info.money << std::endl;
    if (min_attacks[info.place][info.money] < info.attacks) {
      continue;
    }
    for (auto const& edge : adj_list[info.place]) {
     if (edge.distance <= info.money) {
       if (info.attacks < min_attacks[edge.to][info.money - edge.distance]) {
         min_attacks[edge.to][info.money - edge.distance] = info.attacks;
         queue.push(Info{info.attacks, edge.to, info.money - edge.distance});
       }
     }
     if (info.attacks + edge.attack < min_attacks[edge.to][info.money]) {
       min_attacks[edge.to][info.money] = info.attacks + edge.attack;
       queue.push(Info{info.attacks + edge.attack, edge.to, info.money});
     }
    }
  }
  size_t min_attack = 2 << 29;
  for (auto const& attacks : min_attacks[N - 1]) {
    if (min_attack > attacks) {
      min_attack = attacks;
    }
  }
  return min_attack;
}

int main() {
  size_t N, M, L;
  while (std::cin >> N >> M >> L) {
    if (N == 0 && M == 0 && L == 0) {
      break;
    }
    std::cout << solve(N, M, L) << std::endl;
  }
}

Measured memory_bytes: 4388
using System;
public class Hello{
    static long GCM(long a,long b){
        long A = Math.Max(a,b);
        long B = Math.Min(a,b);
        
        while(A % B != 0){
            long C = A % B;
            A = B;
            B = C;
        }
        return B;
    }
    static long LCM(long a,long b){
        long A = Math.Max(a,b);
        long B = Math.Min(a,b);
        
        return A / GCM(a,b) * B;
    }
    public static void Main(){
        int N = int.Parse(Console.ReadLine());
        long[] time = new long[N];
        
        for(var i = 0;i < N;i++){
            time[i] = long.Parse(Console.ReadLine());
        }
        
        long ans = time[0];
        for(var i = 1;i < N;i++){
            ans = LCM(ans,time[i]);
        }
        Console.WriteLine(ans);
    }
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repi(i, s, n) for (int i = (s); i < (n); i++)
typedef pair<int, int> P;
typedef long long ll;
const int INF = 100100100;
const int MOD = 1e9 + 7;

int main() {

  int N;
  cin >> N;

  vector<int> a(N);
  vector<int> b(N);
  vector<int> c(N);
  rep(i, N) { cin >> a[i]; }
  rep(i, N) { cin >> b[i]; }
  rep(i, N) { cin >> c[i]; }

  sort(a.begin(), a.end());
  sort(b.begin(), b.end());
  sort(c.begin(), c.end());

  ll ans = 0;
  rep(i, N) {
    int mid = b[i];
    ll low_cnt, high_cnt;

    // 下段の２分探索
    auto liter = lower_bound(a.begin(), a.end(), mid);
    low_cnt = distance(a.begin(), liter);

    // 上限の２分探索
    auto hiter = upper_bound(c.begin(), c.end(), mid);
    high_cnt = N - distance(c.begin(), hiter);

    ans += low_cnt * high_cnt;
  }
  cout << ans << endl;
}

Measured memory_bytes: 1408
import java.util.Scanner;

public class Main {

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

        int N = sc.nextInt();
        int Y = sc.nextInt();

        int x = 0;
        int y = 0;
        int z = 0;
        boolean flg = false;
        
        Loop:
        for (x = 0; x <= N; x++) {
            for (y = 0; y <= N - x; y++) {
                z = N - x - y;
                int total = x * 10000 + y * 5000 + z * 1000;
                if (total == Y) {
                    flg = true;
                    break Loop;
                }
            }
        }

        if (flg) {
            System.out.println(x + " " + y + " " + z);
        } else {
            System.out.println("-1 -1 -1");
        }
        
    }
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const int MOD = 1e9 + 7;

signed main(){
    string s;
    cin >> s;
    int start, end;
    REP(i, s.size()){
        if(s[i] == 'A'){
            start = i;
            break;
        }
    }
    for(int i = s.size() - 1; i >= 0; i--){
        if(s[i] == 'Z'){
            end = i;
            break;
        }
    }
    cout << end - start + 1 << endl;
}

Measured memory_bytes: 640
#include <math.h>
#include <algorithm>
#include <functional>
#include <iostream>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

using ll = long long;

int R, G;

int main() {
    cin >> R;
    cin >> G;

    cout << 2 * G - R << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define STLL(s) strtoll(s.c_str(), NULL, 10)
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
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;}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;
const double EPS = 1e-9;



int main() {
    
    int n,m;
    cin>>n>>m;
    vvc v(n,vc(m));
    rep(i,n){
        string S;
        cin>>S;
        rep(j,m){
            v[i][j]=S[j];
        }
    }
    vvll dp(n+1,vll(m+1,0));
    rep(i,n){
        if(v[i][0]=='#'){
            break;
        }
        dp[i][0]=1;
    }
    rep(i,m){
        if(v[0][i]=='#'){
            break;
        }
        dp[0][i]=1;
    }
    rep(i,n){
        rep(j,m){
            if(!i||!j)continue;
            if(v[i][j]=='#')dp[i][j]=0;
            else chmax(dp[i][j],(dp[i-1][j]+dp[i][j-1])%MOD);
        }
    }
    fin(dp[n-1][m-1]);
    // rep(i,n){
    //     rep(j,m)cout<<dp[i][j]<<" ";
    //     cout<<endl;
    // }
}

Measured memory_bytes: 9088
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()) {
			int n = sc.nextInt();
			int cnt = 0;
			for(int a = 0; a <= 9; a++) {
				for(int b = 0; b <= 9; b++) {
					for(int c = 0; c <= 9; c++) {
						for(int d = 0; d <= 9; d++) {
							int k = a + b + c + d;
							if(k == n) {
								cnt++;
							}
						}
					}
				}
			}
			System.out.println(cnt);
		}
		sc.close();
	}
}


Measured memory_bytes: 26616
#include <iostream>
using namespace std;
int main()
{
  int n, m, votes = 0;
  cin >> n >> m;
  int arr[n];
  for(int i = 0; i < n; i++)
  {
    cin >> arr[i];
    votes += arr[i];
  }
  
  float bar = 1.0 * (0.25 * votes)/m;

  for(int i = 0; i < n ; i++ )
  {
	  if(arr[i] >= bar)
		m--;
  }
  if(m <= 0)
	cout << "Yes" << endl;
  else
	cout << "No" << endl;
	
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main  {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String S = scan.next();
		int w = scan.nextInt();
		scan.close();
		StringBuilder sb = new StringBuilder();
		for(int i = 0; i < S.length(); i +=w) {
			sb.append(S.substring(i, i + 1));
		}
		System.out.println(sb.toString());
	}
}

Measured memory_bytes: 21972
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int[] a = new int[n];
        int x = 0;
        if (n%2==0){
            for (int i=0;i<n;i++){
                if (i%2==0){
                    a[(n+i)/2]=scanner.nextInt();
                    x = (n+i)/2;
                }else {
                    a[n-x-1]=scanner.nextInt();
                }
            }
        }else {
            for (int i=0;i<n;i++){
                if (i%2==0){
                    a[(n-i-1)/2]=scanner.nextInt();
                    x = (n-i-1)/2;
                }else {
                    a[n-x]=scanner.nextInt();
                }
            }
        }
        for (int i=0;i<n;i++){
            System.out.print(a[i]+" ");
        }
    }
}


Measured memory_bytes: 92208