akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
// rep macro
#define rep(i, n)        for (int i = 0; i < (int)(n); i++)
#define rev(i, n)        for (int i = (int)(n - 1); i >= 0; i--)
#define rep2(i, s, n)    for (int i = (s); i < (int)(n); i++)
#define rev2(i, s, n)    for (int i = (int)(n) - 1; i >= (int)(s); i--)
#define bitrep(i, n)     for (int i = 0; i < (1 << (int)(n)); i++)
#define bitrep2(i, s, n) for (int i = (s); i < (1 << (int)(n)); i++)
const int di[8] = {-1, 0, 1, 0, -1, -1, 1, 1};
const int dj[8] = {0, 1, 0, -1, -1, 1, 1, -1};
// type macro
using ll = int64_t;
// vector macro
#define all(v) v.begin(), v.end()
using  vi = vector<int>;
using vvi = vector<vector<int>>;
using  vu = vector<size_t>;
using vvu = vector<vector<size_t>>;
using  vl = vector<ll>;
using vvl = vector<vector<ll>>;
using  vd = vector<double>;
using vvd = vector<vector<double>>;
using  vb = vector<bool>;
using vvb = vector<vector<bool>>;
using  vc = vector<char>;
using vvc = vector<vector<char>>;
using  vs = vector<string>;
using vvs = vector<vector<string>>;
// pair macro
#define fi first
#define sj second
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pdd = pair<double, double>;
// math macro
#define lcm(a, b) a / __gcd(a, b) * b
#define dist(a, b) sqrt(pow(a.fi - b.fi, 2) + pow(a.sj - b.sj, 2))
// print macro
#define println(x) cout << x << endl
#define Yes println("Yes")
#define No println("No")
#define YES println("YES")
#define NO println("NO")
// memo
// desc sort: sort(vec.begin(), vec.end(), greater<int>());

bool on_grid(int i, int j, int r, int c)
{
    return (i >= 0 && i < r && j >= 0 && j < c);
}

int main()
{
    int h, w; cin >> h >> w;
    vvc g(h, vc(w));
    int num_walls = 0;
    rep(i, h)
        rep(j, w)
        {
            cin >> g[i][j];
            if (g[i][j] == '#') num_walls++;
        }
    queue<pii> q;
    q.push(pii(0, 0));
    vvb seen(h, vb(w, false));
    seen[0][0] = true;
    int cnt = 0;
    bool success = false;
    while (!q.empty())
    {
        queue<pii> qt;
        while (!q.empty())
        {
            qt.push(q.front()); q.pop();
        }
        while (!qt.empty())
        {
            pii now = qt.front(); qt.pop();
            rep(i, 4)
            {
                if (on_grid(now.fi+di[i], now.sj+dj[i], h, w)
                && g[now.fi+di[i]][now.sj+dj[i]] == '.'
                && seen[now.fi+di[i]][now.sj+dj[i]] == false)
                {
                    seen[now.fi+di[i]][now.sj+dj[i]] = true;
                    q.push(pii(now.fi+di[i], now.sj+dj[i]));
                }
            }
        }
        cnt++;
        if (seen[h-1][w-1] == true) { success = true; break; }
    }
    int ans = h * w - num_walls - (cnt + 1);
    if (success) println(ans);
    else println(-1);
}

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

int main(){
  double N, T, A;
  cin >> N >> T >> A;
  vector<double> H(N);
  double Temp=0;
  double Min=10000;
  double Ans=0;
  for(double i=0; i<N; i++){
    cin >> H.at(i);
    Temp=T-H.at(i)*0.006;
    if(abs(A-Temp)<Min){
      Min=abs(A-Temp);
      Ans=i+1;
    }
  }
  cout << Ans << endl;
}
  

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define forn for(int i=0;i<n;i++)
#define pr pair<int,int>
#define ll long long int
const int mod=1e9+7;
const ll inf=1e14+5;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n,W;
    cin>>n>>W;
    ll w[n],v[n];
    forn
    cin>>w[i]>>v[i];
    ll dp[n][n*1000+1];
    //memset(dp,0,sizeof(dp));
    for(int i=0;i<n;i++)
    for(int j=0;j<=n*1000;j++)
    dp[i][j]=inf;
    dp[0][v[0]]=w[0];
    for(int i=0;i<n;i++)
    dp[i][0]=0;
    for(int i=1;i<n;i++)
    {
    	for(int j=0;j<=n*1000;j++)
    	{
    		if(j>=v[i])
    		dp[i][j]=(ll)min(dp[i-1][j-v[i]]+w[i],dp[i-1][j]);
    		else
    		dp[i][j]=dp[i-1][j];
		}
	}
	for(int i=n*1000;i>=0;i--)
	{
		if(dp[n-1][i]<=W)
		{
			
			cout<<i<<" \n";
			return 0;
		}
	}
    cout<<0;
    
}



Measured memory_bytes: 78336
#include <cstdio>
#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
using namespace std;
int main() {
	int x[4];
	for(int i = 0; i < 4; i++ ) {
		scanf("%d", x + i);
	}
	int l = MAX(x[0], x[2]);
	int r = MIN(x[1], x[3]);
	int n = MAX(r - l, 0);
	printf("%d", n);
}

Measured memory_bytes: 128
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<string>
#include<iostream>
#include<cctype>
#include<cstdio>
#include<vector>
#include<stack>
#include<queue>
#include <algorithm>
#include<math.h>
#include<set>
#include<map>
#include<iomanip>

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


using namespace std;



int main() {

	long long int ans = 1;
	int n;
	cin >> n;
	for (long long int i = 1; i <= n; i++) {
		ans *= i;
		ans %= 1000000007;
	}
	cout << ans << endl;


	return 0;

}




Measured memory_bytes: 256
import java.util.Scanner;
public class Main
{
	public static void main(String arg[])
	{
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		double d=100000;
		for(int i=0; i<n; i++)
		{
			d=d*1.05;
			if(d%1000!=0)
				d+=1000;
			d=(int)d/1000;
			d=(int)d*1000; 
		}
		System.out.println((int)d);
	}
}

Measured memory_bytes: 17156
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)a;i<(int)b;++i)
int main(){
    int n,x;cin>>n>>x;
    int minv=1e9;
    int sum=0;
    rep(i,n){
        int c;cin>>c;
        sum+=c;
        minv=min(minv,c);
    }
    int ans=n;
    x-=sum;
    ans+=x/minv;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#137-c
n = int(input())
buf = []

for i in range(n):
    s  = input()
    l = list(s)
    l.sort()
    sort_s = "".join(l)
    buf.append(sort_s)

buf.sort()    
ans = 0
same = 1
s = buf[0]
for i in range(1,n):
    if buf[i]==s:
        same += 1
    else:
        ans += same*(same-1)//2
        same = 1
        s = buf[i]

ans += same*(same-1)//2
print(ans)

Measured memory_bytes: 10584
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const int inf = 1000000000;
const int dx[]={1,0,-1,0};
const int dy[]={0,1,0,-1};
const ll mod = 1e9+7;

const ll d = 40;
const ll mm = 1e5+5;

//ll to[d][mm];

int main(){
    ll n,m,x;
    cin >> n >> x >> m;
    ll xx = x;
    ll xxx = x;
    set<ll> s;
    ll tot = 0;
    ll cnt = 0;
    while(true){
        if(s.count(x)) break;
        tot+=x;
        s.insert(x);
        cnt++;
        x=(x*x)%m;
        //cout << x << endl;
    }
    ll totot = 0;
    ll cntt = 0;
    while(true){
        if(xx == x) break;
        totot+=xx;
        //s.insert(x);
        cntt++;
        xx=(xx*xx)%m;
    }
    //cout << tot << " " << cnt << " " << totot << " " << cntt << endl;
    ll ans = 0;
    if(n <= cntt){
    for(ll i=0; i<n; i++){
        ans+=xxx;
        //s.insert(x);
        //cntt++;
        xxx=(xxx*xxx)%m;
    }
    }
    else{
        ans += totot+((n-cntt)/(cnt-cntt))*(tot-totot);
        for(ll i=0; i<(n-cntt)%(cnt-cntt); i++){
            ans+=x;
            x=(x*x)%m;
        }
    }
    cout << ans << endl;
}

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

bool is_prime(ll n) {
    for (ll i=2;i*i<=n;++i) {
        if (n%i==0)return false;
    }
    return n!=1;
}

ll get(ll n) {
    ll d = 0;
    while (n) {
        n /= 10;
        d++;
    }
    return d;
}

ll F(ll a, ll b) {
    return max(get(a), get(b));
}

int main() {
    ll n;
    cin >> n;
    if (is_prime(n)) {
        cout << F(1, n) << endl;
    }
    else {
        ll ma = -1;
        for (ll i=sqrt(n); i>=1; --i) { if (n%i == 0) { ma = i; break; } }
        cout << F(ma, n/ma) << endl;
    }
}


Measured memory_bytes: 256
#pow(a,b,mod)
#np.gcd.outer
from math import gcd
from functools import reduce
from itertools import product ##for i in z for j in z -> for i,j in product(z,z)   ||  for i,j in product(z,repeat=2)
k=int(input())
z=range(1,k+1)
print(sum(gcd(i,gcd(j,k)) for i,j,k in product(z, repeat=3)))


Measured memory_bytes: 68516
#include <algorithm>
#include <iostream>
#include <vector>
 
typedef unsigned uint;
 
bool is_exist_bin_search(uint v, std::vector<uint> &s){
  uint min = 0, max = s.size();
  while(min < max){
    uint mid = (min + max) / 2;
    uint v_mid = s[mid];
    if(v_mid == v) return true;
 
    if(v_mid >= v) max = mid;
    else min = mid+1;
  }
  return false;
}
 
unsigned count(std::vector<uint> &s, std::vector<uint> &t){
  uint n = 0;
  for(uint i = 0; i < t.size(); i++){
    if(is_exist_bin_search(t[i],s)) n++;
  }
  return n;
}
 
int main(){
  std::ios_base::sync_with_stdio(false);
 
  uint n;
  std::cin >> n;
  std::vector<uint> s(n,0);
  for(uint i = 0; i < n; i++){
    std::cin >> s[i];
  }
 
  uint q;
  std::cin >> q;
  std::vector<uint> t(q,0);
  for(uint i = 0; i < q; i++){
    std::cin >> t[i];
  }
 
  std::cout << count(s,t) << '\n';
}

Measured memory_bytes: 1580
m,f,r = 0,0,0
while True:
    m,f,r = [int(i) for i in input().split()]
    if m+f+r == -3:
        break
    elif -1 in {m,f}:
        print("F")
    elif 80 <= m+f:
        print("A")
    elif 65 <= m+f <= 80:
        print("B")
    elif 50 <= m+f <= 65:
        print("C")
    elif 30 <= m+f <= 50:
        if 50 <= r:
            print("C") 
        else:
            print("D")
    elif m+f <= 30:
        print("F")

Measured memory_bytes: 7688
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#define ArraySizeOf(array)     (sizeof(array) / sizeof(array[0]))
#define res(i,n) for(int i=n;;i++)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define REV(i,n) for(int i=n-1;i>0;i--)
#define req(i,n,m) for(int i=n;i<m;i++)
#define REQ(i,n,m,l) for(int i=n;i<m;i+=l) 
#define _GLIBCXX_DEBUG
int INF = 1e9 + 7;
unsigned NthDayOfWeekToDay(unsigned n, unsigned dow, unsigned dow1)
{
    unsigned day;
    if (dow < dow1) dow += 7;
    day = dow - dow1;
    day += 7 * n - 6;
    return day;
}
signed gcd(int x, int y) {
    if (y == 0)return x;
    return gcd(y, x % y);
}
signed lcm(int x, int y) {
    return x / gcd(x, y) * y;
}
unsigned DayToWeekNumber(unsigned day)
{
    return (day - 1) / 7 + 1;
}
unsigned AnotherDayOfWeek(unsigned day, unsigned day0, unsigned dow0)
{
    return (dow0 + 35 + day - day0) % 7;
}
using namespace std;
int main() {
    int K, N; cin >> K >> N;
    vector<int>A(N);
    vector<int>B(N);
    int count = 0;
    rep(i, N) {
        cin >> A[i];
        count += A[i];
    }
    rep(i, N) {
        if (i == 0)B[i] = A[i]+(K-A[N-1]);
        else B[i] = A[i] - A[i - 1];
    }
    sort(B.begin(), B.end());
    cout << K - B[N-1] << endl;
}

Measured memory_bytes: 4844
#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, m, n) for(int i=(m); i<(n); ++i)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define Cout(x) cout << (x) << endl
#define Cout2(x, y) cout << (x) << " " << (y) << endl
#define dump(x) cerr << #x << " = " << (x) << endl;
typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
const int inf = (int)1e9;
const double pi = acos(-1.0);

int main() {
	int h, w; cin >> h >> w;
	VVI d(10, VI(10,inf));
	rep(i, 10)rep(j, 10)cin >> d[i][j];
	rep(i, 10)rep(j, 10)rep(k, 10)d[j][k] = min(d[j][k], d[j][i] + d[i][k]);

	VVI a(h, VI(w));
	int ans = 0;
	rep(i, h)rep(j, w) {
		int x; cin >> x;
		if (x != -1) {
			ans += d[x][1];
		}
	}
	Cout(ans);
}

Measured memory_bytes: 384
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <vector>

using namespace std;

int main(void)
{
    int n;
    cin >>n;

    bool can = true;
    int maxH = 0;
    for(int i = 0; i < n; i++){
        int tmp;
        cin >>tmp;
        if(tmp < maxH - 1){
            can = false;
            break;
        }
        maxH = max(tmp, maxH);
    }

    if(can){
        printf("Yes\n");
    }else{
        printf("No\n");
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <iomanip>
#include <map>
#include <set>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <iterator>
#include <string>
#include <limits>

using namespace std;

using i64 = int64_t;
using P = pair<i64, i64>;
i64 mod = 1000000007;
//i64 mod = 998244353;
int int_max = 2147483647;
i64 INF = 1e16;
int max_n = 1e5;

void elt(i64 n, vector<i64>& v) {
    v = vector<i64>(n+1, 2);
    v[0] = 0;
    v[1] = 1;
    double sq = sqrt(n);
    for (i64 i=2; i*i<=n; ++i) {
        for (i64 j=2; j*i<=n; ++j) {
            ++v[j*i];
            if (sq < j) ++v[j*i];
        }
    }
}

int main(int argc, char **argv) {
    i64 n;
    cin >> n;
    vector<i64> v;
    elt(n, v);
    i64 ans{0};
    for (i64 i=0; i<=n; ++i) {
        //cout << i<< " " << v[i] <<endl;
        ans += v[i] * i;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 81460
// Can U hack it?

#include<bits/stdc++.h>

#define F first
#define S second
#define PB push_back
#define sz(s) int((s).size())
#define bit(n,k) (((n)>>(k))&1)

using namespace std;

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

const int maxn=1e5+10,mod=1e9+7;

int fac[maxn],ifac[maxn],inv[maxn],f[maxn];

int main(){
    inv[1]=ifac[0]=fac[0]=1;
    for(int i=2;i<maxn;i++)
	inv[i]=((1ll*inv[mod%i]*(-mod/i))%mod)+mod;
    for(int i=1;i<maxn;i++){
	fac[i]=1ll*i*fac[i-1] %mod;
	ifac[i]=1ll*ifac[i-1]*inv[i] %mod;
	f[i]=(1ll*f[i-1]*i+1ll*fac[i-1])%mod;
    }
    int n,ans=0;cin>>n;
    for(int i=0;i<n;i++){
	int x;cin>>x;
	int num=1ll*fac[n]*(1ll*f[i+1]*ifac[i+1]%mod + 1ll*f[n-i]*ifac[n-i]%mod -1)%mod;
	ans=(1ll*ans+1ll*x*num)%mod;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 1792
#include <cstdio>
#define MAXN 503
int n, m, q;
int a[MAXN][MAXN], s[MAXN][MAXN];
int main()
{
    scanf("%d%d%d", &n, &m, &q);
    for (int i = 0; i < m; ++i) {
        int l, r;
        scanf("%d%d", &l, &r);
        a[l][r]++;
    }
    for (int i = n; i >= 1; --i)
        for (int j = 1; j <= n; ++j)
            s[i][j] = s[i + 1][j] + s[i][j - 1] - s[i + 1][j - 1] + a[i][j];
    for (int i = 0; i < q; ++i) {
        int l, r;
        scanf("%d%d", &l, &r);
        printf("%d\n", s[l][r]);
    }
    return 0;
}

Measured memory_bytes: 2816
#include <stdio.h>
using namespace std;
static const int MAX = 100;
static const int INFTY = (1<<21);
static const int WHITE = 0;
static const int GRAY = 1;
static const int BLACK = 2;

int n, M[MAX][MAX];

int prim() {
    int d[n], p[n];
    int color[n];
    
    for(int i=0; i<n; i++) {
        color[i] = WHITE;
        d[i] = INFTY;
        p[i] = -1;
    }
    
    d[0] = 0;
    
    while(1) {
        int u;
        int mincost = INFTY;
        for (int i=0; i<n; i++) {
            if (color[i] != BLACK && d[i] < mincost) {
                mincost = d[i];
                u = i;
            }
        }
        
        if (mincost == INFTY) break;
        
        color[u] = BLACK;
        
        for (int v=0; v<=n; v++) {
            if (color[v] != BLACK && M[u][v] != INFTY) {
                if(M[u][v] < d[v]) {
                    d[v] = M[u][v];
                    p[v] = u;
                    color[v] = GRAY;
                }
            }
        }
    }
    
    int sum = 0;
    for (int i=0; i<n; i++) {
        if(p[i] != -1) sum += M[i][p[i]];
    }
    return sum;
}

int main() {
    scanf("%d", &n);
    for (int i=0; i<n; i++) {
        for (int j=0; j<n; j++) {
            int tmp;
            scanf("%d", &tmp);
            M[i][j] = (tmp == -1) ? INFTY : tmp;
        }
    }
    
    int sum = prim();
    printf("%d\n", sum);
    
    return 0;
}


Measured memory_bytes: 2748
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections
import copy


if __name__ == "__main__":
    n = int(input())
    s = [input() for i in range(n)]
    c  = ["AC","WA","TLE","RE"]
    cnt = [0]*4
    for i in s:
        if i == "AC":
            cnt[0]+=1
        elif i == "WA":
            cnt[1]+=1
        elif i == "TLE":
            cnt[2]+=1
        else:
            cnt[3]+=1
    print("AC x " + str(cnt[0]) )
    print("WA x " + str(cnt[1]) )
    print("TLE x " + str(cnt[2]) )
    print("RE x " + str(cnt[3]) )

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

int main()
{
  long long n;
  cin>>n;
  long long a[n];
  map<long long,int>mp={};
  int flag=0;
  for(int i=0;i<n;i++)
 { cin>>a[i];
 
 mp[a[i]]+=1;
 if(mp[a[i]]>1)
 {flag=1;
 //cout<<a[i]<<" "<<mp[a[i]]<<endl;
 	
 }	
 }
 if(flag==1)
 cout<<"NO"<<endl;
 else
 cout<<"YES"<<endl;
   
	return 0;
}


Measured memory_bytes: 14336
#include <iostream>
#include <algorithm>

#define N 3

using std::cin;
using std::cout;
using std::endl;
using std::max_element;
using std::min_element;

int main() {
	int arr[N];
	cin >> arr[0] >> arr[1] >> arr[2];
	cout << *min_element(arr,arr + N) << " " << *max_element(arr,arr + N) << endl;
}


Measured memory_bytes: 3136
#include <iostream>
#include <cstring>
#include <stdlib.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <math.h>
#include <string>
#include <map>
#include <iomanip>
using namespace std;

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

void print_vector(vector<ll> vt){
    for(auto v: vt){
        cout << v;
    }
    cout << endl;
}

int main()
{
    int priceA, priceB, priceAB, Anum, Bnum;
    cin >> priceA >> priceB >> priceAB >> Anum >> Bnum;
    ll ans=10000000000;
    for(int ab=0; ab/2<=max(Anum, Bnum); ab+=2){
        ans=min(ans, ll(ab*priceAB+max(int(Anum-ab*0.5), 0)*priceA+max(0, int(Bnum-ab*0.5))*priceB));
    }
    cout << ans << endl;

    

    return 0;
}


Measured memory_bytes: 764
#include <stdio.h>

int main()
{
  int i,j,s,p,n,x[1000],m[1000][1000];
  scanf("%d",&n);

  for(i = 0;i < n;i++)
    for(j = 0;j < n;j++)
      m[i][j] = 0;
  
  for(i = 0;i < n;i++){
    scanf("%d",&s);
    scanf("%d",&p);
    for(j = 0;j < p;j++){
      scanf("%d",&x[j]);
      m[s][x[j]] = 1;
    }
  }

  for(i = 1;i < n+1;i++){
    for(j = 1;j < n+1;j++){
      if(j != 1) printf(" ");
      printf("%d",m[i][j]);
    }
    printf("\n");
  }
  return 0;
}



Measured memory_bytes: 2144
import java.util.Scanner;

public class Main {

	@SuppressWarnings("resource")
	public static void main(String args[]) {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		int Y = scanner.nextInt();

		for (int x = 0; x <= n; x++) {
			for (int y = 0; y <= n; y++) {
				int z = n - x - y;
				if ((10000 * x + 5000 * y + 1000 * z) == Y && z >= 0) {
					System.out.println(x + " " + y + " " + z);
					return;
				}
			}
		}

		System.out.println(-1 + " " + -1 + " " + -1);
	}
}


Measured memory_bytes: 23760
s = list(input())
S = []
for i in s:
    if i == "0":
        S.append(0)
    elif i == "1":
        S.append(1)
    elif i == "B":
        if len(S) != 0:
            del S[-1]

for i in S:
    print(i, end = "")
print()


Measured memory_bytes: 2940
#include <iostream>
#include <vector>
using namespace std;
int main()
{
	std::vector<int> a(0);
	int s;
	int i = 0,m = 0;
	cin >> s;
	a.push_back(s);
	++i;
	while (1) {
		if (a[i - 1] % 2 == 0)a.push_back(a[i - 1] / 2);
		else a.push_back(a[i - 1] * 3 + 1);
		//cout <<i<<":"<<a[i] << "\n";
		for (int j = 0; j < i; ++j) {
			if (a[j] == a[i]) { 
				m = 1;
				break;
			}
		}
		if (m == 1)break;
		++i;
	}
	cout << i+1 << "\n";
	return 0;
}

Measured memory_bytes: 256
def main():
    from collections import deque
    import sys
    buf = sys.stdin.buffer
    
    n = int(buf.readline())
    E = map(int, (buf.read().split()))
    edges = [[] for i in range(n)]
    
    for a, b in zip(E, E):
        edges[a-1].append(b-1)
        edges[b-1].append(a-1)
    
    todo = deque([0, n-1])
    
    colors = [0] * n
    colors[0] = 1
    colors[-1] = 2
    
    while todo:
        node = todo.popleft()
        color = colors[node]
    
        for to in edges[node]:
            if colors[to]:
                continue
            else:
                colors[to] = color
                todo.append(to)
    
    fennec_count = colors.count(1)
    if fennec_count > n // 2:
        print('Fennec ')
    
    else:
        print('Snuke ')


if __name__ == '__main__':
    main()

Measured memory_bytes: 30968
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long int llu;
typedef long double ld;
#define vi vector<int>
#define vl vector<ll>
#define vp vector<pair<int,int>>
#define pb push_back
#define pf push_front
#define mp map<ll,ll>
#define INF 1000000000000000000
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
ll gcd(ll a,ll b)
{
    if(a==0)
    {
        return b;
    }
    else
    {
        return gcd(b%a,a);   
    }
}
ll lcm(ll a,ll b)
{
    return a*b/gcd(a,b);
}
int f(char c)
{
    return (int)c-48;
}
/**********************************************************************
***********************************************************************
*********************ACTUAL CODE BEGINS HERE***************************/
int main()
{   
    fast;
    string s;
    cin>>s;
    int sum=0;
    int n=s.size();
    for(int i=0;i<n;i++)
    {
        sum+=f(s[i]);
    }
    if(sum%9==0)
    {
        cout<<"Yes";
    }
    else
    {
        cout<<"No";
    }
    
    return 0;
}

Measured memory_bytes: 3780
#include <iostream>
#include <vector>
#include <list>
#include <string>
#include <queue>
#include <algorithm>
#include <set>
#include <map>

using namespace std;
typedef long long ll;
using P = pair<ll,ll>;

int main() {
    ll N,M;
    cin >> N >> M;
    vector<ll> X(M);
    
    for(int i=0;i<M;i++){
        cin >> X[i];
    }
    sort(X.begin(),X.end());
    priority_queue<ll,vector<ll>,greater<ll>> que;
    for(int i=0;i<M-1;i++){
        que.push(X[i+1]-X[i]);
    }
    ll ans=0;
    for(int i=0;i<M-N;i++){
        ll tmp = que.top();que.pop();
        ans+=tmp;
    }
    cout << ans << endl;
}


Measured memory_bytes: 2168
#include <bits/stdc++.h>
#define PI 3.1415926535897
using namespace std;
typedef long long ll;
const int INF = 1000000000;
const ll LINF = 1000000000000000000; //1e18
const double EPS = 1e-10;

int main(void)
{
    ll A, B, N;
    cin >> A >> B >> N;

    // 最大値を取るためには、XができるだけNの最大まで引き伸ばす。
    // ただし後半部分を０にしたいために、XはB-1までがいい

    ll X = min(N, B - 1);
    ll ans = floor((A * X) / B) - A * floor(X / B);
    // ll ans2 = floor((A * N) / B) - A * floor(N / B);

    // for (int x = 1; x <= N; x++)
    // {
    //     ans = floor((A * x) / B) - A * floor(x / B);
    //     printf("x = %d, ans = %d\n", x, ans);
    // }
    cout << ans << endl;
    return (0);
}

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

int main() {
  long N, K, modz, modh, ans;
  ans = 0;
  modh = 0;
  cin >> N >> K;
  modz = N / K;
  ans += modz * modz * modz;
  if(K % 2 == 0){
    modh = modz;
    if(N / K * K + K / 2 <= N){
    modh++;
    }
  }  
  ans += modh * modh * modh;
  
  cout << ans <<endl;
  return 0;
}


Measured memory_bytes: 256
from itertools import combinations_with_replacement
n, m, q = map(int, input().split())
p = 0
rs = []
for i in range(q):
    rs.append(list(map(int, input().split())))

def dsum(A):
    s = 0
    for r in rs:
        a, b, c, d = r
        if A[b-1] - A[a-1] == c:
            s += d
    return s

ma = 0
for a in combinations_with_replacement(range(1, m+1), n):
    ma = max(ma, dsum(a))
print(ma)

Measured memory_bytes: 68124
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <time.h>
#include <vector>

using namespace std;
typedef long long ll;
template <class T = ll>
T in() {
    T x;
    cin >> x;
    return (x);
}
template <class T>
void print(T x) {
    cout << x << "\n";
}
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define reps(x, c) for (auto x : c)
#define all(x) begin(x), end(x)
#define pb(a) emplace_back(a)
#define mp(a, b) make_pair((a), (b))
#define pl pair<ll, ll>
#define INF 2147483600
#define MOD 1000000007
#define fi first
#define se second
#define dbg(x) cerr << #x "=" << (x) << "\n"
#define dbgv(x) \
    cerr << #x << "\n"; \
    reps(y, x) { cerr << y << " "; } \
    cerr << "\n"

inline char tc() {
    static char fl[100], *A = fl, *B = fl;
    return A == B && (B = (A = fl) + fread(fl, 1, 100, stdin), A == B) ? EOF
                                                                       : *A++;
}
inline ll read() {
    ll a = 0;
    static char c;
    while ((c = tc()) < 48 || c > 57) {
    };
    while (c >= 48 && c <= 57) a = a * 10 + c - 48, c = tc();
    return a;
}

int main() {
    vector<int> x(4);
    rep(i, 4) { x[i] = read(); }
    vector<vector<ll>> a(3);
    rep(i, 3) {
        a[i].resize(x[i]);
        rep(j, x[i]) { a[i][j] = read(); }
    }
    int temp = min(3000, x[0] * x[1]);
    vector<ll> ab(x[0] * x[1]), abc(temp * x[2]);
    rep(i, x[0]) {
        rep(j, x[1]) { ab[i * x[1] + j] = a[0][i] + a[1][j]; }
    }
    sort(all(ab), greater<ll>());
    rep(i, temp) {
        rep(j, x[2]) { abc[i * x[2] + j] = ab[i] + a[2][j]; }
    }
    sort(all(abc), greater<ll>());
    rep(i, x[3]) { printf("%lld\n", abc[i]); }
}

Measured memory_bytes: 31616
#include <cstdio>

const int maxn = 100005;
char buf[maxn];
int n, a, b;

int main() {
    scanf("%d%d%d", &n, &a, &b);
    scanf("%s", buf);
    int sa = 0, sb = 0;
    for (int i = 0; i < n; ++i) {
        if (buf[i] == 'c') puts("No");
        else if (buf[i] == 'a') {
            if (sa + sb < a + b) {
                puts("Yes");
                ++sa;
            } else puts("No");
        } else {
            if (sb < b && sa + sb < a + b) {
                puts("Yes");
                ++sb;
            } else puts("No");
        }
    }
    return 0;
}


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

using namespace std;

int main() {
    vector<int> vt(3);

    for (int i = 0; i < 3; ++i) {
        cin >> vt[i];
    }
    sort(vt.begin(), vt.end());
    int a = vt[0], b = vt[1], c = vt[2];

    int ans = c - b + (b - a) / 2;
    if ((b - a) % 2 != 0) {
        ans += 2;
    }

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

Measured memory_bytes: 256
#define rep(i, a, b) for(int i = a; i < (int)(b); i++)
#include <bits/stdc++.h>

typedef long long ll;
using namespace std;
template<class T> inline void chmax(T &a, const T &b) {if(a < b) a = b;}
template<class T> inline void chmin(T &a, const T &b) {if(a > b) a = b;}
const long long INF = 1LL<<60;
const long long MOD = (ll)1e9+7;
const long long MAX = (ll)1e5+100;


int main(void) {
   ll N,K;
   cin>>N>>K;
   string S;
   cin>>S;
   set<ll> confl;
   rep(i,0,S.size()) {
      if (i == 0 && S[i] == 'L') confl.insert(i);
      else if (i == S.size()-1 && S[i] == 'R') confl.insert(i+1);
      if (i !=S.size()-1) {
         if (S[i]=='R' && S[i+1]=='L') confl.insert(i);
      }
   }
   ll ans = 0;
   rep(i,0,S.size()-1) {
      if (S[i]==S[i+1]) ans++;
   }
   for (auto el: confl) {
      if (el!= 0 && el != S.size()) {
         ans += 2;
         K--;
      }
      if (K==0) break;
   }
   if (K>0 && confl.count(0)) {
      ans++;
      K--;
   }
   if (K>0 && confl.count(S.size())) {
      ans++;
      K--;
   }
   cout<<min(ans,N-1)<<endl;







   return 0;
}

Measured memory_bytes: 2688
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0;i<(int)(n);i++)
#define all(x)    (x).begin(),(x).end()
typedef long long ll;
const int MOD = (int)1e9 + 7;

int solve(vector<int> num, int depth, bool three, bool five, bool seven, bool bound){
  if (depth == num.size()){
    return (three && five && seven ? 1 : 0);
  }
  int digit = num[num.size()-1-depth];
  int buf = 0;
  if(bound || digit >= 3) buf += solve(num,depth+1,true,five,seven,(digit > 3) || bound);
  if(bound || digit >= 5) buf += solve(num,depth+1,three,true,seven,(digit > 5) || bound);
  if(bound || digit >= 7) buf += solve(num,depth+1,three,five,true,(digit > 7) || bound);
  return buf;
}

int main(){
  int n;
  cin >> n;
  vector<int> num;
  int digit = 0;
  while(n>0){
    num.push_back(n%10);
    n /= 10;
    digit++;
  }
  int ans = 0;
  while(digit>3){
    ans += pow(3,digit-1) - pow(2,digit-1)*3 + 3;
    digit--;
  }
  cout << ans + solve(num,0,false,false,false,false) << endl;
}



Measured memory_bytes: 512
r = [[] for _ in range(200001)] 
n, m = map(int, input().split())

for _ in range(m):
    a, b = map(int, input().split())
    r[a].append(b)

k = [1]
flag = 0
for _ in range(2):
    if flag == 1:
        break
    for j in k:
        kk = []
        kk += r[j]
        if n in r[j]:
            flag = 1
            break
    k = kk[:]

if flag == 1:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

Measured memory_bytes: 34888
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

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

    static class ADigitsSum {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();

            int answer = Integer.MAX_VALUE;
            for (int a = 1; a < n; a++) {
                int b = n - a;
                answer = Math.min(answer, sum(a) + sum(b));
            }

            out.println(answer);
        }

        static int sum(int n) {
            int result = 0;
            while (n > 0) {
                result += n % 10;
                n /= 10;
            }
            return result;
        }

    }

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

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

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

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

    }
}



Measured memory_bytes: 20820
#include<iostream>
#include<stdio.h>
using namespace std;


int main()
{
 double a,b,c,d,e,f;
 double x,y;
	while( cin>>a>>b>>c>>d>>e>>f )
	{
	x =  (c*e - f*b) / (a*e - d*b);
	y =  (a*f - d*c) / (a*e - d*b);

	x *= 1000;
	y *= 1000;
	x = int(x);
	y= int(y);
	x = x / 1000;
	y = y / 1000;
 	
 	printf("%.3lf %.3lf\n",x,y);
	}
 return 0;
}

Measured memory_bytes: 1236
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<iomanip>
#include<queue>
#include<stack>
#include<time.h>
#define rep(i,n)for(int i=0;i<n;i++)
#define int long long
#define ggr getchar();getchar();return 0;
#define prique priority_queue
#define mod 1000000007
#define inf 1e15
#define key 1e9
using namespace std;
typedef pair<int, int>P;
void yes() { cout << "Yay!" << endl; }
void no() { cout << ":(" << endl; }
template<class T> inline void chmax(T& a, T b) {
	a = std::max(a, b);
}
template<class T> inline void chmin(T& a, T b) {
	a = std::min(a, b);
}
bool prime(int n) {
	int cnt = 0;
	for (int i = 1; i <= sqrt(n); i++) {
		if (n % i == 0)cnt++;
	}
	if (cnt != 1)return false;
	else return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y)* mod_pow(kai(y, y), mod - 2, mod) % mod;
}
void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
	cerr << " " << to_string(H);
	debug_out(T...);
}

#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
struct edge { int to, cost; };
int par[114514], rrank[114514];//親、木の深さ
void init(int n) {
	rep(i, n) {
		par[i] = i;
		rrank[i] = 0;
	}
}
int find(int x) {
	if (par[x] == x) {
		return x;
	}
	else return par[x] = find(par[x]);
}
void unite(int x, int y) {
	x = find(x);
	y = find(y);
	if (x == y)return;
	if (rrank[x] < rrank[y]) {
		par[x] = y;
	}
	else {
		par[y] = x;
		if (rrank[x] == rrank[y])rrank[x]++;
	}
}
bool same(int x, int y) {
	return find(x) == find(y);
}
int n;
int a[214514];
signed main() {
	cin >> n;
	rep(i, n)cin >> a[i];
	int m = mod_pow(2, n, mod);
	sort(a, a + n);
	reverse(a, a + n);
	int ans = 0;
	if (n == 1)cout << (a[0] * 2) % mod << endl;
	else {
		rep(i, n) {
			ans += (a[i] * ((mod_pow(2, n - 1, mod) + (mod_pow(2, n - 2, mod) * i) % mod) % mod)) % mod;
			ans %= mod;
		}
		cout << (ans* m) % mod << endl;
	}
	ggr
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<long long, long long> P;
struct edge{long long to,cost;};
const int inf = 1 << 27;
const long long INF = 1LL << 60;
const int COMBMAX = 1001001;
const long long MOD = 1000000007;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define eachdo(v, e) for(const auto& e : (v))
#define all(v) (v).begin(), (v).end()
#define lower_index(v, e) (long long)distance((v).begin(), lower_bound((v).begin(), (v).end(), e))
#define upper_index(v, e) (long long)distance((v).begin(), upper_bound((v).begin(), (v).end(), e))
long long mpow(long long a, long long n, long long mod = MOD){long long res = 1; while(n > 0){if(n & 1)res = res * a % mod; a = a * a % mod; n >>= 1;} return res;}
void yn(bool j){cout << (j ? "Yes" : "No") << endl; return;}
template<class Head> void pt(Head&& head){cout << head << endl; return;}
template<class Head, class... Tail> void pt(Head&& head, Tail&&... tail){cout << head << " "; pt(forward<Tail>(tail)...);}
template<class T> void debug(T v){rep(i, v.size()) cout << v[i] << " " ; cout << endl;}
template<class T> void debug2(T v){rep(i, v.size()){rep(j, v[i].size()) cout << v[i][j] << " " ; cout << endl;}}
template<class T1, class T2> long long bcount(T1 v, T2 a){return upper_index(v, a) - lower_index(v, a);} 
template<class T1, class T2> inline bool chmin(T1 &a, T2 b){if(a > b){a = b; return true;} return false;}
template<class T1, class T2> inline bool chmax(T1 &a, T2 b){if(a < b){a = b; return true;} return false;}
template<class T1, class T2> void sortTwoVecter(vector<T1> &f, vector<T2> &s, bool isReverse = false){
    vector<pair<T1, T2>> p;
    rep(i, f.size()) p.emplace_back(make_pair(f[i], s[i]));
    if (!isReverse) sort(p.begin(), p.end());
    else sort(p.rbegin(), p.rend());
    rep(i, f.size()) tie(f[i], s[i]) = p[i];
    return;
}

int main(){
    ll X; cin >> X;
    for(int i = 1; i < 1231321 ; i++){
        if (((i - 1) * i) / 2 < X && X <= ((i) * (i + 1)) / 2){
            cout << i << endl;
            return 0;
        } 
    }
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include<iostream>
#include<fstream>
#include<string>
#include<vector>
#include<utility>
#include<algorithm>
#include<climits>
#include<set>
#include<map>
#include<cmath>
#include<iomanip>
#include<iterator>
#include<queue>
#include<stack>
#include<cctype>
#include<deque>
#include<time.h>
#include<bitset>
#include<random>
#include<unordered_set>
#include<unordered_map>
#include<sstream>
#include<random>
#include<numeric>
//by Skeef79

typedef long long ll;
typedef long double ld;

typedef unsigned long long ull;

#pragma warning(disable : 4996)
#pragma comment(linker, "/STACK:16777216")
#define pb push_back
#define en '\n'
#define for0(i,n) for(int i = 0;i<n;i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define vec vector
#define pii pair<int,int>
#define pll pair<ll,ll>
#define SZ(a) int(a.size())

using namespace std;

const int INF = 2000000000;
const ll LINF = 2000000000000000000;

template<typename T> void print(vector<T>& a)
{
	for (int i = 0; i < a.size(); i++)
		cout << a[i] << ' ';
	cout << en;
}

template<typename T> void print(deque<T>& a)
{
	for (int i = 0; i < a.size(); i++)
		cout << a[i] << ' ';
	cout << en;
}

template<typename T> void print(vector<vector<T>>& a)
{
	for (int i = 0; i < a.size(); i++)
	{
		for (int j = 0; j < a[i].size(); j++)
			cout << a[i][j] << ' ';
		cout << en;
	}
}

template <typename T> void input(vector<T>& a)
{
	for (int i = 0; i < a.size(); i++)
		cin >> a[i];
}

template<typename T> void input(deque<T>& a)
{
	for (int i = 0; i < a.size(); i++)
		cin >> a[i];
}

template<typename T> void input(vector<vector<T>>& a)
{
	for (int i = 0; i < a.size(); i++)
		for (int j = 0; j < a[i].size(); j++)
			cin >> a[i][j];

}

void solve()
{
	int x;
	cin >> x;
	cout << (x == 1 ? 0 : 1);
}

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

#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
#endif

	//freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);

	int tst = 1;
	//cin >> tst;

	while (tst--)
		solve();
}


Measured memory_bytes: 3616
n, m, qq = map(int, input().split())
lr = [[0] * n for _ in range(n)]
for _ in range(m):
    l, r = map(int, input().split())
    lr[l - 1][r - 1] += 1

for i in range(n):
    for j in range(n - 1):
        lr[i][j + 1] += lr[i][j]
for j in range(n):
    for i in range(n-1, 0, -1):
        lr[i - 1][j] += lr[i][j]

for _ in range(qq):
    p, q = map(int, input().split())
    if q == n:
        print(lr[p - 1][q - 1])
    else:
        print(lr[p - 1][q - 1] - lr[q][q - 1])


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

typedef long long ll;
typedef double ld;
#define loop(x) for(int i = 0;i<(x);i++)


int main(){
   ld L,x;cin>>L;
   x = L/3.0;

   cout<<fixed<<setprecision(12)<<pow(x,3);
}


Measured memory_bytes: 256
/*************************************************\
           In the name of almighty ALLAH
                 MD.Faysal Hasan
                Comilla Univesity
\*************************************************/

#include<bits/stdc++.h>
using namespace std;

#define     ikarus_101  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

typedef     long long             ll;
typedef     long double           ld;
typedef     unsigned long long    ull;
typedef     vector<ll>            vll;
typedef     pair<ll,ll>           pll;
typedef     vector<pll>           vpl;
typedef     map<ll,ll>            mll;
typedef     multiset<ll>          msl;
typedef     multimap<ll,ll>       Mll;
using pqboro=priority_queue<ll,vll,less<ll>>;
using pqchoto=priority_queue<ll,vll,greater<ll>>;

#define    all(str)       str.begin(),str.end()
#define    sajo(str)      sort(str.begin(),str.end())
#define    rev(str)       reverse(str.begin(),str.end())
#define    usajo(str)     sort(str.rbegin(),str.rend())
#define    vin(a)         for(auto &it : a) cin>>it
#define    vout(a)        for(auto it:a) cout<<it<<' ';cout<<nn
#define    vmax(a)        *max_element(all(a))
#define    vmin(a)        *min_element(all(a))
#define    pb             push_back
#define    eb             emplace_back
#define    mkp(x,y)       make_pair(x,y)
#define    F              first
#define    S              second
#define    yes            cout<<"YES"<<nn
#define    no             cout<<"NO"<<nn
#define    nn             "\n" ///endl
#define    rep(i,n)       for (i=0;i<n;++i )
#define    rep1(i,n)      for (i=1;i<=n;++i )

#define    min3(a,b,c)    min(a,min(b,c))
#define    max3(a,b,c)    max(a,max(b,c))
#define    sqr(x)         ((x)*(x))
#define    pi             2*acos(0.0)
#define    gcd(a,b)       __gcd(a,b)
#define    lcm(a,b)       (a/gcd(a,b))*b
#define    mem(a,b)       memset(a,b,sizeof (a))
#define    dec(x)         cout<<fixed<<setprecision(x)
#define    none(n)         __builtin_popcountll(n)

template < typename T > string toString ( T Number ) { stringstream ss ; ss << Number ; return ss.str() ; }
template < typename T > ll toll ( T str ) { stringstream ss ; ss << str ; ll num ; ss >> num ; return num ; }

const   int  N   =   2e5+7;
const   int  M   =   1e9+7;
const   ll  inf  =   0x7f7f7f7f7f7f7f7f;
const   int dx[] =   {+1,+2,+2,+1,-1,-2,-2,-1};
const   int dy[] =   {-2,-1,+1,+2,+2,+1,-1,-2};

int main() {ikarus_101

    int  n , m , i , j , k , x ;


    cin >> x;
    cout << (x+1)%2 << endl;












    return 0;
}


Measured memory_bytes: 3632
n = int(input())
s = input()
f = "ABC"
cnt = 0
tmp = None
for s_ in s:
    if not tmp and s_ == "A":
        tmp = "A"
    elif tmp == "A" and s_ == "B":
        tmp = "B"
    elif tmp == "B" and s_ == "C":
        cnt += 1
        tmp = None
    elif s_ == "A":
        tmp = "A"
    else:
        tmp = None
print(cnt)

Measured memory_bytes: 3064
// A: Placing Marbles
"use strict";

const DEBUG_MODE = false;
const rawInput = DEBUG_MODE
  ? "000"
  : require("fs")
      .readFileSync("/dev/stdin", "utf8")
      .trim();

const process = inputRaw => {
  console.log((inputRaw.match(/1/g) || []).length);
};

process(rawInput);


Measured memory_bytes: 21192
#include <bits/stdc++.h>
#define rep(i, x, y) for(int i = x; i <= y; i ++)
#define rrep(i, x, y) for(int i = x; i >= y; i --)
#define ll long long
#define X first
#define Y second
#define pb push_back
#define mp make_pair
#define pii pair<ll, ll>
#define ls rt << 1
#define rs rt << 1 | 1
#define sz(x) (int)(x).size()
#define ALL(x) (x).insgin(), (x).end()
#define vi vector<int>
#define EPS 1e-8
using namespace std;
inline int read()
{
	int x = 0, f = 1; char ch = getchar();
	while (ch < '0' || ch > '9') { if (ch == '-') f = -1; ch = getchar(); }
	while (ch >= '0' && ch <= '9') { x = x * 10 + ch - '0'; ch = getchar(); }
	return x * f;
}
inline ll read1()
{
	ll x = 0, f = 1; char ch = getchar();
	while (ch < '0' || ch > '9') { if (ch == '-') f = -1; ch = getchar(); }
	while (ch >= '0' && ch <= '9') { x = x * 10 + ch - '0'; ch = getchar(); }
	return x * f;
}

int main()
{
	char a[110];
	scanf("%s", a + 1);
	int n = strlen(a + 1);
	int pp = 0;
	rep(i, 2, n)
		if(a[i] != '9') 
			pp = 1;
	cout << a[1] - '0' - pp + (n - 1) * 9;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h> 
#define REP(i, b) for(int i = 0; i < (b); i++)
#define REPS(i, b) for(int i = 1; i <= (b); i++)
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vb = vector<bool>;
const int INF = 1e9;
const int MOD = 1e9+7;

signed main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);

    string S, T; cin >> S >> T;
    vi A(26, -1), B(26, -1);
    REP(i, S.length())
    {
        if(A[S[i]-'a'] < 0) A[S[i]-'a'] = T[i]-'a';
        else
        {
            if(A[S[i]-'a'] != T[i]-'a')
            {
                cout << "No" << endl;
                return 0;
            }
        }
        if(B[T[i]-'a'] < 0) B[T[i]-'a'] = S[i]-'a';
        else
        {
            if(B[T[i]-'a'] != S[i]-'a')
            {
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 916
N = int(input())
ans = 0
from itertools import product
for i in range(3,10):
  for p in product(['3','5','7'], repeat=i):
    s = ''.join(p)
    if '3' in s and '5' in s and '7' in s and int(s)<=N:
      ans += 1
print(ans)
  

Measured memory_bytes: 43376
#include <iostream>
using namespace std;
int main (void) {
    string s;

    cin >> s;

    int A = s[0] - '0';
    int B = s[1] - '0';
    int C = s[2] - '0';
    int D = s[3] - '0';

    if (A + B + C + D == 7) cout << A << "+" << B << "+" << C << "+" << D << "=7" << endl;
    else if (A + B + C - D == 7) cout << A << "+" << B << "+" << C << "-" << D << "=7" << endl;
    else if (A + B - C + D == 7) cout << A << "+" << B << "-" << C << "+" << D << "=7" << endl;
    else if (A + B - C - D == 7) cout << A << "+" << B << "-" << C << "-" << D << "=7" << endl;
    else if (A - B + C + D == 7) cout << A << "-" << B << "+" << C << "+" << D << "=7" << endl;
    else if (A - B + C - D == 7) cout << A << "-" << B << "+" << C << "-" << D << "=7" << endl;
    else if (A - B - C + D == 7) cout << A << "-" << B << "-" << C << "+" << D << "=7" << endl;
    else if (A - B - C + D == 7) cout << A << "-" << B << "-" << C << "-" << D << "=7" << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<cstring>
#include<map>
#include<vector>
#include<queue>
#include<climits>
#include<set>
#include<utility>
using namespace std;
typedef long long int ll;

int main(){

	int n, m, a[200001], b[200001];
	bool flag_1=false, flag_n=false;
	cin >> n >> m;
	bool x[200001], y[200001];
	memset(x, 0, sizeof(x));
	memset(y, 0, sizeof(y));
	for(int i=0; i<m; i++){
		cin >> a[i] >> b[i];
		if(a[i]==1){
			flag_1=true;
			x[b[i]]=true;
		}
		if(b[i]==n){
			flag_n=true;
			y[a[i]]=true;
		}
	}

	if(!flag_1 || !flag_n){
		cout << "IMPOSSIBLE" << endl;
		return 0;
	} else {
		for(int i=0; i<200001; i++){
			if(x[i] && y[i]){
				cout << "POSSIBLE" << endl;
				return 0;
			}
		}
	}
	cout << "IMPOSSIBLE" << endl;

	return 0;
}

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

using namespace std;

const int MAX_N = 2e5 + 5;
const long long MOD = 1e9 + 7;

typedef long long ll;

struct item {
    int id, score;
    string name;
};

bool cmp(item a, item b) {
    if (a.name == b.name) return a.score > b.score;
    else return a.name < b.name;
};

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    int n; cin >> n;
    item arr[n + 1];
    for (int i = 1; i <= n; i++) {
        cin >> arr[i].name >> arr[i].score;
        arr[i].id = i;
    }
    sort(arr + 1, arr + n + 1, cmp);
    for (int i = 1; i <= n; i++)
        cout << arr[i].id << "\n";
}



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

int main(){
  int a,b,c;
  cin >> a >> b; 
  if((a % 3 == 0) || (b % 3 == 0) || ((a+b) % 3 == 0)){
    cout << "Possible";
  }else{
    cout << "Impossible";
  }
  cout << endl;
}


Measured memory_bytes: 256