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

const int MAXN = 200005;

char s[MAXN];

int main(){
	scanf("%s", s);
	for(int i = 0; s[i]; i++){
		if(s[i] == '?'){
			s[i] = 'D';
		}
	}
	printf("%s\n", s);
	
	return 0;
}


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

using namespace std;

int main(){
    int n;cin >> n;
    string s;cin >> s;
    for(int i=0;i<s.size();i++){
        if(s[i]+n > 'Z')cout << (char)(s[i] + n - 26);
        else cout << (char)(s[i] + n);
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<ll> vl;
typedef pair<ll, ll> PP;
#define rep(i, n) for(ll i = 0; i < ll(n); i++)
#define all(v) v.begin(), v.end()
#define inputv(v, n)                                                           \
    vl v;                                                                      \
    rep(i, n) {                                                                \
        ll x;                                                                  \
        cin >> x;                                                              \
        v.push_back(x);                                                        \
    }
bool chmin(ll& a, ll& b) { if (b < a) { a = b; return 1; } return 0; }
bool chmax(ll& a, ll& b) { if (b > a) { a = b; return 1; } return 0; }
const ll INF = 999999999999999;
const ll MOD = 1000000007;
const ll MAX_N = 500010;
ll a, b, c, d, e, f, p, t, x, y, z, q, m, n, r, h, k, w, l, ans;
struct Gragh {
    ll N;
    vector<vl> G;
    vl visited;

    Gragh(ll n) {
        N = n;
        G.resize(N);
        resetv();
    }

    void add(ll a, ll b) { G[a].push_back(b); }

    void resetv(void) { visited = vl(N, 0); }

    ll bfs1(ll x) {
        ll a = 0;
        vl dp(N, 0);
        vl visited1(N + 1, 0);
        vl Q1, Q2;
        visited1[x] = 1;
        dp[x]=1;
        for (ll i : G[x]) {
            Q1.push_back(i);
        }
        t = 1;
        while (!Q1.empty()) {
            t++;
            Q2 = vl(0);
            for (ll i : Q1) {
                if (visited1[i] == 0) {
                    visited1[i] = 1;
                    dp[i] = t;
                    for (ll j : G[i]) {
                        if (visited1[j] == 0) {
                            Q2.push_back(j);
                        }
                        else {
                        	//cout<<x<<" "<<i<<" "<<j<<" "<<t<<endl;
                            if (dp[j] != t + 1&&dp[j] != t - 1)a = 1;
                        }
                    }
                }
            }
            Q1=Q2;
            unique(all(Q1));
        }

        if (a == 0)return t;
        return 0;
    }
};
int main() {
    char C, A[200][200];
    cin >> n;
    
    rep(i, n) {
        rep(j, n) {
            cin >> A[i][j];
        }
    }

    Gragh G(n);
    rep(i, n) {
        rep(j, i) {
            if (A[i][j] == '1') {
                G.add(i, j);
                G.add(j, i);
            }
        }
    }

    rep(i, n) {
        ans = max(ans, G.bfs1(i));
    }

    if (ans == 0)cout << -1 << endl;
    else cout << ans << endl;
}


Measured memory_bytes: 1160
#include<stdio.h>
#define NIL 0.1
#define H 250

typedef struct node{
  int parent;
  int left;
  int right;
  int key;
}Node;

Node A[H];

int parent(int);
int left(int);
int right(int);



main(){
  int n,i;

  scanf("%d",&n);

  for( i=1 ; i<=H ; i++ ){
    A[i].key = NIL;
    }


  for( i=1 ; i<=n ; i++ ){
    scanf("%d",&A[i].key);

    A[i].parent = parent(i);
    A[i].left = left(i);
    A[i].right = right(i);

  }

  for( i=1 ; i<=n ; i++ ){
  printf("node %d: key = %d, ",i,A[i].key);

  if( i != 1 )printf("parent key = %d, ",A[A[i].parent].key);
  if( A[i].left <= n )printf("left key = %d, ",A[A[i].left].key);
  if( A[i].right <= n )printf("right key = %d, ",A[A[i].right].key);
  printf("\n");
  }
  return 0;
}

int parent(int i){
  return i/2;
}
int left(int i){
  return 2*i;
}
int right(int i){
  return (2*i+1);
}

Measured memory_bytes: 604
#include<iostream>
#include<algorithm>
#include<cstdio>
#define ll long long 
using namespace std;
int n,x;
ll ans;
int a[100005],b[100005];
int main()
{
	cin>>n;
	for(int i=1;i<=n+1;i++) cin>>a[i];
	for(int i=1;i<=n;i++){
		cin>>b[i];
		if(b[i-1]>=a[i]){ans+=a[i];}
		else if(b[i]+b[i-1]>=a[i])b[i]-=a[i]-b[i-1],ans+=a[i];
		else if(b[i]+b[i-1]<a[i]) ans+=b[i]+b[i-1],b[i]=0;
	}
	printf("%lld",ans+min(a[n+1],b[n]));
}

Measured memory_bytes: 1024
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include <stdbool.h>
#define LL long long
#define INF 1<<31-1
#define MIN(x,y) ((x)<(y)?(x):(y))
#define MAX(x,y) ((x)<(y)?(y):(x))

int main()
{
    int N, L;
    int a, l, n;    
    
    int ans = 0;
    
    scanf("%d %d", &N, &L);

    /* if(L >= 0){ */
    /*     for(int i = 2; i <= N; i++){ans = ans + L + i - 1;} */
    /* } */

    /* else if(L < 0){ */
    /*     if(abs(N) > abs(L)){ */
    /*         for(int i = 1; i <= N;i++){ans = ans + L + i - 1;}                 */
    /*     } */
    /*     else{ */
    /*         for(int i = 1; i < N; i++){ans = ans + L + i - 1;} */
    /*     } */
        
    /* } */
    if(L >= 0){a=L+2-1; l=L+N-1; n=N-1;}

    else if(L < 0){
        if(abs(N) > abs(L)){a=L+1-1; l=L+N-1; n=N;}
        else{a=L+1-1; l=L+N-2; n=N-1;}
        
    }
    ans = n*(a+l)/2;
    
    printf("%d", ans);
    
    return 0;
}


Measured memory_bytes: 128
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		int[] x=new int[n];
		int sum=0;
		int min=999999999;
		for(int i=0;i<n;i++) {
			x[i]=sc.nextInt();
			if(min>=x[i])
				sum++;
			if(x[i]<min)
				min=x[i];
			
			
		}
		System.out.print(sum);
	}
} 

Measured memory_bytes: 87604
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <vector>
#include <cstring>
#include <climits>
#include <queue>
#include <map>
#include <sstream>
using namespace std;

#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define EPS 1e-9
int n;
int card[3][10],num[10];
char co[10];

bool ok(){
	int ret = 0;
	rep(i,3){
		for(int j=1; j<=7; j++){
			if( card[i][j]>0 && card[i][j+1]>0 && card[i][j+2]>0 ){
				ret++;
				card[i][j]--; card[i][j+1]--; card[i][j+2]--;
				j--;
			}
		}
		for(int j=1; j<=9; j++){
			if( card[i][j]>=3 ){
				ret++;
				card[i][j] -= 3;
			}
		}
	}
	//printf("ret:%d\n",ret);
	return ret==3;
}
int main(){
	cin>>n;
	while(n--){
		memset(card,0,sizeof(card));
		rep(i,9)cin>>num[i];
		rep(i,9)cin>>co[i];
		rep(i,9){
			int k = co[i]=='R'?0:co[i]=='G'?1:2;
			card[k][num[i]]++;
		}
		//rep(i,9)printf("%d ",num[i]);puts("");
		//rep(i,9)printf("%c ",co[i]);puts("");
		
		puts(ok()?"1":"0");
	}
	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
int main(){
long long n;
long long a,b;
cin>>n>>a>>b;
long long ans=b-a;
if(ans%2==0){
  ans=ans/2;

}
else{
  long long ans1=a-1+1+ans/2;
  long long ans2=n-b+1+ans/2;
  ans=min(ans1,ans2);
}
cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i ++)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i ++)
#define MP make_pair

using namespace std;
typedef long long LL;
typedef pair<int, int> PII;
const int MOD = 998244353;

int main()
{
	LL a, v, b, w, t;
	cin >> a >> v >> b >> w >> t;
	if(a - v * t <= b - w * t && a + v * t >= b + w * t) printf("YES\n");
	else printf("NO\n");
	return 0;
}

Measured memory_bytes: 3640
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <cmath>
using namespace std;
int c[2]={0,1};
int main( ){
    int a,i=0,k,t;
    int remainder[3000]={0};
    scanf("%d",&a);
    if(a==0){
    	printf("0\n");
    	return 0;
    }
	while(a != 0){
		k = a % (-2);
		t = a / (-2);
		if(k < 0){
		k -= (-2);
		t++;
		}
		i++;
		a = t;
		remainder[i]=c[k];
	}
    for (;i>=1;i--){
        printf("%d",remainder[i]);
    } 
    return 0;
} 

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static long[] ATSUSAdp = new long[51];

    static {
        ATSUSAdp[0] = 1L;
        for (int i = 0; i < 50; i++) {
            ATSUSAdp[i + 1] = 3L + 2 * ATSUSAdp[i];
        }
    }

    public static long[] PCOUNTdp = new long[51];

    static {
        PCOUNTdp[0] = 1;
        for (int i = 0; i < 50; i++) {
            PCOUNTdp[i + 1] = 1L + 2 * PCOUNTdp[i];
        }
    }


    public static long ans = 0L;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long x = sc.nextLong();

        makeBGI(n, x);
        System.out.println(ans);
    }

//    private static String makeBG(int n) {
//        if (n == 0) return "P";
//
//        StringBuilder sb = new StringBuilder("B");
//        sb.append(makeBG(n - 1));
//        sb.append("P");
//        sb.append(sb);
//        sb.deleteCharAt(sb.length() - 1);
//        return sb.toString();
//    }

    /**
     * @param level ハンバーガーのレベル
     * @param rest  残りの食べるべき数
     * @return 新しい残り
     */
    private static long makeBGI(int level, long rest) {
        if(level==0) {
            if(rest > 0) ans++;
            return rest-1;
        }

        if (rest >= ATSUSAdp[level]) {
            rest -= ATSUSAdp[level];
            ans += PCOUNTdp[level];
            return rest;
        } else {
            rest--;//B part
            if(rest > 0) rest = makeBGI(level - 1, rest);// n-1 BG part
            if (rest > 0) {
                rest--;
                ans++;//P part
            }
            if(rest > 0) {
                rest = makeBGI(level - 1, rest);
                rest--;
            }
            return rest;
        }
    }
}

Measured memory_bytes: 22996
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define ll long long
#define _GLIBCXX_DEBUG
const ll MOD = 1000000007;
const ll Mod = 998244353;
const int MAX = 510000;
const double PI = 3.14159265358979;
const vector<int> dx = {1, 0};
const vector<int> dy = {0, 1};

int main() {
  int N;
  cin >> N;
  vector<ll> A(N);
  for (int i=0; i<N; i++) cin >> A[i];
  ll res = 1000;
  for (int i=0; i<N-1; i++) {
    ll stocks = 0;
    if (A[i]<A[i+1]) stocks = res/A[i];
    res += (A[i+1]-A[i])*stocks;
  }
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 3596
/*
Arthor : Ender_zzm
E-mail zzm_ender_wiggin@outlook.com
Blog oi.ender-zzm.pro
*/
#include <bits/stdc++.h>
using namespace std;

inline int Isdigit(char c) {
	if (c < '0' || c > '9') return 0;
	return 1;
}
inline int readint(){
    register int x = 0, flag = 1;
    register char ch;
    while (!Isdigit(ch = getchar())) if (ch == '-') flag = -1;
    while (Isdigit(ch)) x = x * 10 + (ch & 15), ch = getchar();
	return x * flag;
}

inline long long readlong() {
	register long long x = 0, flag = 1;
	register char ch;
	while (!Isdigit(ch = getchar())) if (ch == '-') flag = -1;
    while (Isdigit(ch)) x = x * 10 + (ch & 15), ch = getchar();
	return x * flag;
}
template <class T>
inline void write(T x){
    if (x < 0)
        putchar('-'), x = -x;
    if(x >= 10) write(x / 10); 
    putchar(x % 10 + '0');
}

template<class T> inline bool Chkmax(T& x, const T& y) { return x < y ? x = y, true : false; }
template<class T> inline bool Chkmin(T& x, const T& y) { return x > y ? x = y, true : false; }

#define debug(x) cout << #x << " = " << x << endl;
#define For(i, x, y) for (int i = (x); i <= (y); i++) 
#define Rep(i, x, y) for (int i = (x); i >= (y); i--) 
#define ri readint
#define rl readlong

#define int long long
const int Mod = 1e9 + 7;
inline int Pow(int x, int y) {
	int ans = 1;
	while (y) {
		if (y & 1) ans = 1ll * ans * x % Mod;
		x = 1ll * x * x % Mod;
		y >>= 1;
	}
	return ans;
}
signed main() {
	int n = ri();
	int ans = 0;
	ans = Pow(10, n);
	ans = (ans - 1ll * 2 * Pow(9, n) % Mod + Mod) % Mod;
	ans = (ans + Pow(8, n) % Mod) % Mod;
	cout << ans << endl;
	return 0;
}


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

#define INF (int)1e9+7
#define rep(i,a,b) for(int i=a;i<b;++i)
#define rrep(i,a,b) for(int i=a;i>=b;--i)
#define vi vector<int>
#define vl vector<ll>
#define vii vector<vector<int>>
#define vll vector<vector<long long>>
#define pii pair<int,int>
#define pll pair<long,long>
#define vpii vector<pii>
#define vpll vector<pll>
#define N 100005
#define pb push_back
#define mp make_pair
#define PI 3.1415926535897932384626433832795

ll f(ll a)
{
  ll cnt=0,i;
  if (a==2)return 1;
  for(i=2;i*i<a;i++)
  {
if(a%i==0)cnt+=2;
  }
  if(i*i==a)cnt++;
  return cnt;
}

//vl a(1001);

ll powM(ll a,ll b, ll m)
{ 
  ll ans=1;
  while(b>0)
  {
    if(b&1)ans=ans*a%m;
    a=a*a%m;
    b>>=1;
  }

return ans%m;
}

ll g(ll a,ll n)
{
  if(a<0)return ((a%n)+n)%n;
  else return a%n;
}
char A[51][51]={0};
char B[51][51]={0};

ll solve(ll x,ll y,ll na,ll ma,ll nb,ll mb)
{
  ll cnt=0;
  for(int i=1;i<=na;i++)
  {
    //ll temp1=x+i;
    if(x+i<=0)continue;
    else if(x+i>nb)break;
    else 
      {
        for(int j=1;j<=ma;j++)
        {
          if(y+j<=0)continue;
          else if(y+j>mb)break;
          else 
            {
              cnt+=A[i][j]=='1'&&B[i+x][j+y]=='1';
            }
        }
      }
  }
  return cnt;
}

int main()
{
ll a,b;
cin>>a>>b;
if(b==1)cout<<0<<"\n";
else{
for(int i=1;i<=20;i++)
{
  if(a*i-(i-1)>=b)
  {
    cout<<i<<endl;
    break;
  }
}
}
  return 0;

}


Measured memory_bytes: 256
#include <stdio.h>
int main(){
	char i[10];
	char ans[7];
	scanf("%s",i);
	if(i[0]=='S'){
		printf("Cloudy\n");
	}
	else if(i[0] =='C'){


	printf("Rainy\n");
	}
	else{
		printf("Sunny\n");
	}
	
		
	

	return 0;
}

Measured memory_bytes: 128
#include <stdio.h>

int main(void){
    int ss;
    int h_mod;
    int h,m,s;
    
    scanf("%d",&ss);
    h=ss/3600;
    m=(ss % 3600)/60;
    s=(ss % 60 );
    
    printf("%d:%d:%d\n",h,m,s);
    
    return 0;
}



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

#ifndef LOCAL
#define fprintf if(false) fprintf
#endif
#define debug_int(x) fprintf(stderr, "%s = %d\n", #x, x)
#define debug_double(x) fprintf(stderr, "%s = %llf\n", #x, x)
#define debug_array(v,n) fprintf(stderr, "%s = [ ", #v); for(int i=0; i<n; i++) fprintf(stderr, "%d ", v[i]); fprintf(stderr, "]\n")
#define forr(i,start,end) for(int i=start; i<end; i++)

using lli = long long int;
using ii = pair<int, int>;

const int MAXN = 100010;

int main() {
    int k;
    char s[128];
    scanf("%d %s", &k, s);
    int n = strlen(s);
    if(n <= k) {
        printf("%s\n", s);
    }
    else {
        s[k] = 0;
        printf("%s...\n", s);
    }
}


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

const int inf = 1e9;
const ll linf = 1e18;

int main()
{
    int n; cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    sort(a.begin(), a.end(), greater<int>());
    int score[] = {0, 0};
    for (int i = 0; i < n; i++) {
        score[i%2] += a[i];
    }
    cout << score[0] - score[1] << endl;
    return 0;
}

Measured memory_bytes: 256
#include<map>
#include<set>
#include<list>
#include<cmath>
#include<queue>
#include<stack>
#include<cstdio>
#include<string>
#include<vector>
#include<complex>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<numeric>
#include<sstream>
#include<iostream>
#include<algorithm>
#include<functional>
#include<cctype>

#define mp make_pair
#define pb push_back
#define REP(i,a,n) for(int i = a;i < (n);i++)
#define rep(i,n) for(int i = 0;i < (n);i++)
#define all(s) s.begin(), s.end()
#define rall(s) s.rbegin(), s.rend()
#define range(x,min,max) ((min) <= (x) && (x) <= (max)) 

using namespace std;

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

const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};

int n,m;
VI A,B;
VII C(2);

int dijkstra(int s,int g,int mode){
	VI dist(m + 1,INT_MAX);
	priority_queue<PII,vector<PII >,greater<PII > > que;
	que.push(mp(0,s));
	dist[s] = 0;
	while(!que.empty()){
		int d = que.top().first, u = que.top().second;
		que.pop();
		if(dist[u] < d) continue;
		rep(i,n){
			if(u == A[i] && dist[u] + C[mode][i] < dist[B[i]]){
				dist[B[i]] = dist[u] + C[mode][i];
				que.push(mp(dist[B[i]],B[i]));
			}
			if(u == B[i] && dist[u] + C[mode][i] < dist[A[i]]){
				dist[A[i]] = dist[u] + C[mode][i];
				que.push(mp(dist[A[i]],A[i]));
			}
		}
	}
	return dist[g];
}

int main(){
	cin.tie(0);
   	ios::sync_with_stdio(false);
	while(1){
		A.clear();
		B.clear();
		C[0].clear();
		C[1].clear();
		cin >> n >> m;
		if(n == 0 && m == 0) break;
		
		rep(i,n){
			int a,b,c,t;
			cin >> a >> b >> c >> t;
			A.pb(a);
			B.pb(b);
			C[0].pb(c);
			C[1].pb(t);
		}
		int k;
		cin >> k;
		rep(i,k){
			int s,g,mode;
			cin >> s >> g >> mode;
			int ans = dijkstra(s,g,mode);
			cout << ans << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1316
#include <bits/stdc++.h>
#define MOD 1000000007
#define mod 1000003
#define ll long long
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define REP(a,b) for (int i = a ; i < b ; i++)
#define PI 3.1415926536

using namespace std ;

int main(){

    ios_base::sync_with_stdio(0);
    int a , b ;
    cin >> a >> b; 
    if (a <= 8 && b<=8 )
        cout << "Yay!";
    else
        cout << ":(";
    return 0 ;

}


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

using namespace std;
typedef long long ll;

ll ABS(ll a) {
  if (a < 0) return -a;
  else return a;
}

int main() {
  ll X,K,D;
  cin >> X >> K >> D;
  ll i = min(ABS(X) / D, K);
  X = ABS(X) - D * i;
  for (; i < K;) {
    if (ABS(X+D) > ABS(X-D)) { X = X-D; }
    else X = X+D;

    i++;
    if (ABS(X) <= D) {
      if ((K- i) % 2 == 0) break;
      else {
        if (ABS(X+D) > ABS(X-D)) { X = X-D; }
        else X = X+D;
        break;
      }
    }
  }
  cout << ABS(X) << endl;
  return 0;
}


Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
int INF = 1e9+7;
int mod = 998244353;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
int cnt[100005];
signed main() {
    int N;
    cin >> N;
    vector<int>D(N);
    for(int i = 0; i < N; i++) {
        cin >> D[i];
        cnt[D[i]]++;
    }
    if(cnt[0] != 1 || D[0] != 0) {
        cout << 0 << endl;
        return 0;
    }
    int ans = 1;
    for(int i = 1; i <= N; i++) {
        for(int j = 1; j <= cnt[i]; j++) {
            ans*=cnt[i-1];
            ans%=mod;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 4816
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define x first
#define y second

using namespace std;

typedef long long ll;

const int MX = 2000 * 2000 + 1;

bitset <MX> dp[2];

int main()
{
    ios_base::sync_with_stdio(0); //cin.tie(0);
    int n, sum = 0;
    cin >> n;
    dp[0] = 1;
    for (int i = 1; i <= n; i++)
    {
        int x;
        cin >> x;
        sum += x;

        int t = (i & 1);
        dp[t] = (dp[t ^ 1] | (dp[t ^ 1] << x));
    }

    int t = (n & 1);
    for (int i = (sum + 1) / 2; i <= sum; i++)
        if (dp[t][i]) cout << i, exit(0);
    return 0;
}



Measured memory_bytes: 2688
import sys
from statistics import *
from collections import *
from operator import itemgetter
from fractions import gcd
stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline()
def lcm(x, y):
    return (x * y) // gcd(x, y)


x, y = na()
if x * 2 > y:
    print(1)
else:
    ct = 2
    num1 = x
    num2 = x*2
    while True:
        g = lcm(num1, num2)
        if g * 2 <= y:
            ct += 1
            num1 = num2
            num2 = g * 2
        else:
            break
    print(ct)

Measured memory_bytes: 5272
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,o,n) for(long long i = o;i<n;i++)
#define oneforall ios::sync_with_stdio(false);cin.tie(0);
#define all(v) (v).begin(),(v).end()
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) long long __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
#define int long long 
const long long INF=1e18;
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << "\n";} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
typedef vector<int> vi;
typedef vector<long long> vl;
typedef long long ll;
typedef vector<pair<long, long > > vpll;
typedef vector<pair<int, int > > vpii;



int32_t main() {
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall 
	oneforall
	
	ini(n);
	vector<bool> morty(100004,true);
	for(int i = 2;i*i<=100004;i++){
		if(morty[i]){
			for(int i1 = i*i;i1<=100004;i1+=i){
				morty[i1] = false;
			}
		}
	}
	vi morty1(100004,0);
	for(int i = 3;i<100004;i+=2){
		if(morty[i] == true and morty[(i+1)/2] == true)morty1[i] = 1;
	}
	//FOR(i,1,31)out(morty[i]);
	FOR(i,1,100004)morty1[i]+=morty1[i-1];
	FOR(i,0,n){
		ini(x);
		ini(x1);
		//out(morty1[x1],morty1[x-1]);
		out(morty1[x1]-morty1[x-1]);
	}















	return 0;
}

Measured memory_bytes: 1408
#include <iostream>
#include <string>
#include <cstring>
#include <fstream>
#include <random>
#include <cmath>
#include <iomanip>
#include <climits>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <map>
#include <deque>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <unordered_map>
#include <bitset>
#include <sstream>

typedef  long long ll;
#define mop 1000000007
using namespace std;

long long fastPow(long long a, long long b, long long mod=0){
    if(a == 0 and b == 0){
        return -1;
    }
    if(a == 0){
        return 0;
    }
    if(b == 0){
        return 1;
    }
    long long tmp = fastPow(a,b/2,mod);
    if(mod != 0) {
        if (b % 2 == 0) {
            return (tmp * tmp) % mod;
        } else {
            return ((tmp*tmp) % mod * (a % mod)) % mod;
        }
    }else{
        if (b % 2 == 0) {
            return (tmp*tmp);
        } else {
            return tmp * tmp * a;
        }
    }
}
long long extGCD(long long a, long long b, long long &x, long long &y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    long long d = extGCD(b, a%b, y, x); // 再帰的に解く
    y -= a / b * x;
    return d;
}

// 負の数にも対応した mod (a = -11 とかでも OK)
inline long long mod(long long a, long long m) {
    return (a % m + m) % m;
}

// 逆元計算 (ここでは a と m が互いに素であることが必要)
long long modinv(long long a, long long m) {
    long long x, y;
    extGCD(a, m, x, y);
    return mod(x, m); // 気持ち的には x % m だが、x が負かもしれないので
}

unsigned long long nCr(long n, long r) {
    unsigned long long ans = 1;
    for (long i = 1 ; i < r + 1; ++i) {
        ans = ans * (n-i+1) % mop * modinv(i,mop) % mop;
    }
    return ans;
}

int main() {
    
    ll n,a,b;
    cin >> n >> a >> b;
    ll ans = 0;
    ans += fastPow(2,n,mop);
    ans -= nCr(n,a);
    ans -= nCr(n,b);
    ans -= 1;
    cout << mod(ans, mop) << endl;

}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static System.Math;

namespace AtCoderProject
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = ReadLineIntArray();
            int A = input[0];
            int B = input[1];
            int K = input[2];

            int maxOutputNum = B - A + 1;
            if (2 * K >= maxOutputNum)
            {
                for (int i = A; i <= B; i++)
                    Console.WriteLine(i);
                return;
            }


            for (int i = 0; i < K; i++)
                Console.WriteLine(A + i);


            for (int i = K - 1; i >= 0; i--)
                Console.WriteLine(B - i);

            //Console.WriteLine(res);
        }


        #region READER
        static int ReadLineInt() => int.Parse(Console.ReadLine());
        static int[] ReadLineIntArray() => Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();

        static IEnumerable<string> ReadInputEnumruble(int count = int.MaxValue)
        {
            for (int i = 0; i < count; i++)
            {
                yield return Console.ReadLine();
            }
        }
        static int[] ReadInputInt(int count = int.MaxValue)
        {
            return ReadInputEnumruble(count).Select(s => int.Parse(s)).ToArray();
        }
        #endregion
    }
}


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

using namespace std;

#define loopinc(i, a, b, inc) for(int i = a; i < (b); i += inc)
#define loop(i, a, b) for(int i = a; i < (b); i++)
#define rep(i, n) loop(i, 0, n)
#define endl "\n"
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef tuple<int, int, int> tii;

int main() {
	// freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
	std::ios::sync_with_stdio(false);
	cin.tie(0);
	
	int x;
	cin >> x;
	cout << M_PI*2*x << endl;
}


Measured memory_bytes: 3800
#include<bits/stdc++.h>
using namespace std;
int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	string s;
	cin >> s;
	int len = s.length();
	vector<int> a(len);
	for (int i = 0; i < len; i++)
		a[i] = s[len-1-i] - '0';
	a.push_back(0);
	int cnt = 0;
	for (int i = 0; i < len; i++) {
		a[i+1] += a[i]/10;
		a[i] %= 10;
		if (a[i] < 5 || (a[i] == 5 && a[i+1] < 5)) cnt += a[i];
		else {
			a[i+1]++;
			cnt += (10-a[i]);
		}
	}
	cnt += a[len];
	cout << cnt << "\n";
	return 0;
}

Measured memory_bytes: 11164
def main():
	N, L = map(int, input().split())
	min_a = 0
	if L > 0:
		min_a = L
	elif L+N-1 < 0:
		min_a = L+N-1
	print((N*(2*L+N-1))//2 - min_a)

if __name__ == '__main__':
	main()

Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int main(){
	int K;
	string S;
	cin>>K>>S;
	if(S.length()<=K)cout<<S;
	else{
		for(int i=0;i<K;i++){
			cout<<S[i];
		}
		cout<<"...";
	}
	return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
using namespace std;

#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define all(v) begin(v), end(v)
#define pb(a) push_back(a)
#define fr first
#define sc second
#define INF 2000000000
#define int long long int

#define X real()
#define Y imag()
#define EPS (1e-10)
#define EQ(a,b) (abs((a) - (b)) < EPS)
#define EQV(a,b) ( EQ((a).X, (b).X) && EQ((a).Y, (b).Y) )
#define LE(n, m) ((n) < (m) + EPS)
#define LEQ(n, m) ((n) <= (m) + EPS)
#define GE(n, m) ((n) + EPS > (m))
#define GEQ(n, m) ((n) + EPS >= (m))

typedef vector<int> VI;
typedef vector<VI> MAT;
typedef pair<int, int> pii;
typedef long long ll;

typedef complex<double> P;
typedef pair<P, P> L;
typedef pair<P, double> C;

int const MOD = 1000000007;
ll mod_pow(ll x, ll n) {return (!n)?1:(mod_pow((x*x)%MOD,n/2)*((n&1)?x:1))%MOD;}
int madd(int a, int b) {return (a + b) % MOD;}
int msub(int a, int b) {return (a - b + MOD) % MOD;}
int mmul(int a, int b) {return (a * b) % MOD;}
int minv(int a) {return mod_pow(a, MOD-2);}
int mdiv(int a, int b) {return mmul(a, minv(b));}

namespace std {
    bool operator<(const P& a, const P& b) {
        return a.X != b.X ? a.X < b.X : a.Y < b.Y;
    }
}

int dp[303][303][303];

// i, x, l
int infomi[303][4], infoma[303][4];
int n, m;
int di[] = {1, 0, 0}, dj[] = {0, 1, 0}, dk[] = {0, 0, 1};
void chadd(int &a, int b) {a = madd(a, b);}

signed main() {
    cin >> n >> m;
    repq(i,0,n) rep(j,0,4) {
        infomi[i][j] = INF;
        infoma[i][j] = -1;
    }
    rep(i,0,m) {
        int l, r, x; cin >> l >> r >> x;
        infomi[r][x] = min(infomi[r][x], l);
        infoma[r][x] = max(infoma[r][x], l);
    }

    dp[0][0][0] = 1;
    int ans = 0;
    rep(i,0,n) rep(j,0,n) rep(k,0,n) {
        rep(s,0,3) {
            int z = max({i, j, k}) + 1;
            int ni = z*di[s] + (di[s]^1) * i;
            int nj = z*dj[s] + (dj[s]^1) * j;
            int nk = z*dk[s] + (dk[s]^1) * k;
            int x, y;
            if(ni == z) x = min(nj, nk), y = max(nj, nk);
            if(nj == z) x = min(ni, nk), y = max(ni, nk);
            if(nk == z) x = min(ni, nj), y = max(ni, nj);

            bool ok = true;
            if(infoma[z][3] > x) ok = false;
            if(infomi[z][2] <= x) ok = false;
            if(infoma[z][2] > y) ok = false;
            if(infomi[z][1] <= y) ok = false;
            if(ok) {
                if(z == n) chadd(ans, dp[i][j][k]);
                chadd(dp[ni][nj][nk], dp[i][j][k]);
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 217344
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
struct UnionFind {
	vector<int> par;
	UnionFind(int x) : par(x, -1) {}
	void init(int x) { par.assign(x, -1); }
	int root(int x) {
		if (par[x] <= -1) return x;
		else return root(par[x]);
	}
	bool issame(int x, int y) {
		return root(x) == root(y);
	}
	bool merge(int x, int y) {
		x = root(x); y = root(y);
		if (x == y) return false;
		if (par[x] > par[y]) swap(x, y);
		par[x] += par[y];
		par[y] = x;
		return true;
	}
	int size(int x) {
		return -par[root(x)];
	}
};

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, M;
    cin >> N >> M;
    UnionFind UF(400010);
    set<int> st;
    rep(i, N) {
        int K; cin >> K;
        st.insert(i);
        rep(j, K) {
            int L; cin >> L;
            L--;
            UF.merge(i, L + 200000);
            st.insert(L + 200000);
        }
    }
    //rep(i, N) cout << i << " " << UF.size(i) << " " << st.size() << endl;
    rep(i, N) {
        if(UF.size(i) != st.size()) {
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;

    return 0;
}


Measured memory_bytes: 6528
#include <iostream>
#include <vector>
#define N 1000000
using namespace std;

int main(){
  bool isP[N];
  vector<long> v;

  for( int i=0;i<N;i++ ) isP[i]=true;

  v.push_back( 0 );
  //  int k=0;
  for( int i=2;i<N && v.size()<=N+1 ;i++ ){
      if( !isP[i] ) continue;
      v.push_back( i+v.back() );
      // ++k;
      for( int j=i*2;j<N;j+=i ) isP[j] = false;
  }
	 //	 cout << "k="<<k<<endl;

	 int n;
       while( cin>>n && n )
	 cout << v[n] << endl;

	 return 0;

};

Measured memory_bytes: 0
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

if sum(A) < sum(B):
    print(-1)
else:
    D = [A[i] - B[i] for i in range(N)]
    F = [True if D[i] >= 0 else False for i in range(N)]
    if sum(F) == len(F):
        print(0)
    else:
        Dp = [D[i] for i in range(N) if F[i] == True]
        Dm = [D[i] for i in range(N) if F[i] == False]
        Sm = sum(Dm)
        R  = len(Dm)
        Dp.sort()
        while Sm < 0:
            R  += 1
            Sm += Dp[-1]
            del Dp[-1]
        print(R)


Measured memory_bytes: 19508
// 6/28 バーチャル参加
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
using Graph = vector<vector<int>>;

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

    ll res = 0;

    for (int k = 1; k <= N; k++) {
        for (int i = k; i <= N; i += k) {
            res += i;
        }
    }

    cout << res << endl;
}

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

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)
#define TO_STRING(VariableName) # VariableName
#define LOG(x) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<endl;
#define LOG2(x,y) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<endl;
#define LOG3(x,y,z) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<endl;
#define LOG4(w,x,y,z) if(DEBUG)cout<<TO_STRING(w)<<"="<<w<<" "<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<endl;

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

void func(long long N, std::vector<long long> A){

    lli sum = 0;
    lli sumXor = 0;

    lli ans = 0;
    lli rig=-1;
    for(lli lef=0;lef<N;lef++){
        if(rig<lef){
            rig = lef;
            sum = A[lef];
            sumXor = A[lef];
        }
        while(rig+1 < N && (sum+A[rig+1] == (sumXor^A[rig+1])))
        {
            sum += A[rig+1];
            sumXor ^= A[rig+1];
            rig++;
        }
        LOG3(ans,lef,rig);
        LOG2(sum,sumXor);
        ans += (rig-lef+1);
        sum -= A[lef];
        sumXor ^= A[lef];
    }
    cout<<ans<<endl;

}

int main(){
    // cout << fixed << setprecision(5);

    long long N;
    scanf("%lld",&N);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    func(N, std::move(A));
    return 0;
}


Measured memory_bytes: 4836
#include <stdio.h>

int main()
{
	int w, h, x, y, r;
	scanf("%d %d %d %d %d", &w, &h, &x, &y, &r);

	if (x-r >= 0 && x+r <= w && y-r >= 0 && y+r <= h) {
		printf("Yes\n");
	} else {
		printf("No\n");
	}

	return 0;
}

Measured memory_bytes: 584
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int n;
vi x, y;

double d(int i, int j) {
  return sqrt(pow(x[i] - x[j], 2) + pow(y[i] - y[j], 2));
}

int main() {
  cin >> n;
  x = vi(n);
  y = vi(n);
  rep(i, n) cin >> x[i] >> y[i];
  vi v;
  rep(i, n) v.push_back(i);
  double ans = 0;
  do {
    rep(i, n - 1) ans += d(v[i], v[i + 1]);
  } while(next_permutation(all(v)));
  rep(i, n) ans /= (i + 1);
  printf("%.10f\n", ans);
}

Measured memory_bytes: 384
def gcd(x, y):
    """
    ユークリッドの互除法を用いてxとyの最大公約数を求める。
    """
    while True:
        r = x % y
        if r == 0:
            break
        x = y
        y = r
    return y


def prime_factorize(x):
    """
    素因数分解
    """
    res = []
    while x % 2 == 0:
        res.append(2)
        x = x // 2
    p = 3
    while p * p <= x:#　このやり方だと複数出てくる。2,2,2など。だから最後にset
        while x % p == 0:
            res.append(p)
            x = x // p
        p += 2
    if x != 1:
        res.append(x)
    return res


A, B = map(int, input().split())
print(len(set(prime_factorize(gcd(A, B)))) + 1)

Measured memory_bytes: 3316
/// Bismillahir Rahmanir Rahim
//Author: Tanvir Hussain
//ICE,NSTU
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
const long long MOD = 1000000007;
#define SET(x) memset(x, 0, sizeof(x))
#define SET2d(x,m,n) memset(x, 0, sizeof(x[0][0]) * m * n)
#define SETBOOL(x) memset(x,false,sizeof(x))
#define CLR(x) memset(x, -1, sizeof(x))
#define CLR2d(x,m,n) memset(x, -1, sizeof(x[0][0]) * m * n)
#define mp make_pair
#define PII pair<int, int>
#define pf printf
#define sf scanf
#define ALL(x) x.begin(),x.end()
#define pb push_back
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define np std::string::npos
#define highest(x) numeric_limits<x>::max()
#define lowest(x) numeric_limits<x>::min()
#define Inf INFINITY
#define minv(v) *min_element(v.begin(),v.end())
#define maxv(v) *max_element(v.begin(),v.end())
#define cases(cs,t) for(int cs=1;cs<=t;cs++)
#define PI acos(-1)
#define no1 __builtin_popcount
#define BOUNDARY(i, j) ((i >= 0 && i < row) && (j >= 0 && j < column))
#define uniq(vec) vec.resize(distance(vec.begin(),unique(vec.begin(),vec.end())))
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define sz(a) int(a.size())
#define ff first
#define ss second
#define endl "\n"
#define forch(it,s) for(auto it:s)
#define each(it,s) for(auto it = s.begin(); it != s.end(); ++it)
#define rep(i,a) for(int i=0; i<a;i++)
#define rep1(i,a,b) for(int i=(a);i<=(b);++i)
#define irep(i,b,a) for(int i=(b);i>=(a);--i)
#define bits(n) __builtin_popcount(n)
#define maxpq priority_queue<int>
#define minpq priority_queue<int, vector<int>, greater<int> >


int gcd(int a, int b) { if (a == 0) return b; return gcd(b % a, a);}
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pair<int,int>> vpii;
typedef tree<pair<int, int>,null_type,less<pair<int, int>>,rb_tree_tag,tree_order_statistics_node_update> ordered_multiset;
int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1};
int dy8[] = {1,-1, 1, -1, 0, 0, -1, 1};
int dx4[] = {0, 0, 1, -1};
int dy4[] = {1, -1, 0, 0};
const int maxx=100005;

//this fuction sorts vector pair according to first element in descending order.
bool sortinrev(const pair<int,int> &a,const pair<int,int> &b)
{
    return a.first>b.first;
}

template<typename T>inline T Bigmod(T base, T power, T MOD){
    T ret=1;
    while(power)
    {
        if(power & 1)ret=(ret*base)%MOD;
        base=(base*base)%MOD;
        power>>=1;
    }
    return ret;
}
double sq(double x) {return x*x;}
ll po(ll b,ll p){
    ll res=1;
    while(p){
        res*=b;
        p--;
    }
    return res;
}
ll lg2(ll x){
    ll res=0;
    while(x>1){
        res++;
        x/=2ll;
    }
    return res;
}
void solve(){
    int n,m;
    cin>>n>>m;
    if(n==m) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

signed main()

{
    IOS;
    /*#ifndef ONLINE_JUDGE
        freopen ("data.in","r",stdin);
        freopen ("data.out","w",stdout);
    #endif*/
    int t;
    t=1;
    while(t--){
        solve();
    }

     return 0;

}
///Alhamdulillah




Measured memory_bytes: 3636
#(X,Y)について実験をすると、

##X012345
#Y0BBAAAA...
##1BBBAAA...
##2ABBBAA...
##3AABBBA...
##4AAABBBA...
##5AAAABBBA...

#となるので、 Y-1 <= X <= Y+1 の時のみBが勝つ
X, Y = map(int, input().split())
if Y-1 <= X <= Y+1:
  print('Brown')
else:
  print('Alice')

Measured memory_bytes: 2940
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
		int a = in.nextInt();
		int b = in.nextInt();
		int r = solve(a, b);
		System.out.println(r);
	}

	private static int solve(int a, int b) {
		if (Math.min(a, b) == 1)
			if (Math.max(a, b) == 2)
				return 3;
			else
				return 2;
		else
			return 1;
	}
}

Measured memory_bytes: 21844
N , Y = map(int,input().split())
for k in range(N + 1):
    for k5 in range(N + 1):
        k10 = N - k - k5
        if k10 < 0:
            continue
        if 1000 * k + 5000 * k5 + 10000 * k10 == Y:
            print(k10, k5, k)
            exit()
print('-1 -1 -1')

Measured memory_bytes: 40812
n=int(input())
a=list(map(int, input().split()))
odd=[]
even=[]
for i in range(len(a)):
    if(a[i]%2==0):
        even.append(a[i])
    else:
        odd.append(a[i])
if(len(odd)%2==1):
    print('NO')
else:
    print('YES')

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

using namespace std;

#define fcout(d) cout << fixed << setprecision(d)
#define rep(i,n) for(int (i)=0; (i)<n; ++(i))
#define rep1(i,n) for(int (i)=1; (i)<=n; ++(i))
#define repU(i,bottom,ceiling) for(int (i) = (bottom); (i) <= (ceiling); ++(i))
#define repD(i,ceiling,bottom) for(int (i) = (ceiling); (i) >= (bottom); --(i))
#define pub push_back
#define pob pop_back
#define prf printf
#define scf scanf
#define mkp make_pair
#define fir first
#define sec second
#define clr(a) memset((a),0,sizeof(a))

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

const vector<pair<int,int>> DIR = { {1,0},{0,1},{-1,0},{0,-1},{1,1},{-1,1},{-1,-1},{1,-1} };
const int INF = (int)2e9 + 1e8;
const int MOD = (int)1e9 + 7;

template<typename T,typename U>
inline pair<T,U> operator+(const pair<T,U> & l,const pair<T,U> & r) {
    return {l.fir+r.fir,l.sec+r.sec};
}

template<typename T,typename U>
inline pair<T,U> operator-(const pair<T,U> & l,const pair<T,U> & r) {
    return {l.fir-r.fir,l.sec-r.sec};
}

template<typename T,typename U>
inline pair<T,U> operator*(const pair<T,U> & l,const pair<T,U> & r) {
    return {l.fir*r.fir,l.sec*r.sec};
}

template<typename T> inline T gcd(T a,T b){ if(a % b){ return gcd(b,a % b); }else{ return b; } }

template<typename T> inline T lcm(T a,T b){ return a / gcd(a,b) * b; }

inline long long Pow(const long long n,long long m,const int mod = MOD){
	long long res = 1,pow = n;
	while(m) {
		if(m & 1) res = (res * pow) % mod;
		pow = (pow * pow) % mod;
		m >>= 1;
	}
	return res;
}

inline vector<long long> Frac(const int range,const int mod = MOD){
	vector<long long> frac;
	frac.push_back(1);
	for(int i = 1; i <= range; ++i) frac.push_back((long long)frac.back() * i % mod);
	return frac;
}

inline int Comb(const int n,const int m,const int mod = MOD){
	if(n < m || m < 0) return 0;
	vector<long long> frac(Frac(n,mod));
	long long rev = Pow((long long)frac[m] * frac[n-m] % mod,mod-2,mod);
	return rev * frac[n] % mod;
}

template<typename T> inline bool v_find(const vector<T> v,const T obj){
	auto itr = find(v.begin(), v.end(), obj);
	size_t index = distance(v.begin(),itr);
	if (index != v.size()) { return true; }
	return false;
}

template<typename T> inline bool v_erase(vector<T> &v,const T obj){
	auto itr = find(v.begin(), v.end(), obj);
	size_t index = distance(v.begin(),itr);
	if (index != v.size()) {
		v.erase(itr);
		return true;
	}
	return false;
}

template<class T,class U> inline auto LB(const T v,const U in){ return lower_bound(v.begin(),v.end(),in); }

template<class T,class U> inline auto UB(const T v,const U in){ return upper_bound(v.begin(),v.end(),in); }

ll n,m,res;

inline void solve(){
  if(abs(n-m)>1){
    cout<<0;
    return;
  }
  vector<ll> frac(Frac(n+1));
  if(n==m){
    res=2*Pow(frac[n],2)%MOD;
  }else{
    res=frac[n]*frac[m]%MOD;
  }
  cout<<res;
  return;
}

inline void input(){
  cin>>n>>m;
  return;
}

int main(){
  cin.tie(0);
	ios::sync_with_stdio(false);
	input();
	solve();
	return 0;
}


Measured memory_bytes: 1400
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		// ?????????????????\????????????
		Scanner sc = new Scanner(System.in);

		// ??\?????°????????????????????°
		int input = sc.nextInt();

		// ???????????????
		int[][] card = new int[4][13];

		// ?????°????????????????????????????????°????????????
		String mark;
		int num;

		// ?????????????????°?????????
		int cnt;

		// ??????????????????????????????
		for (cnt = 0; cnt < input; cnt++) {

			mark = sc.next();
			num = sc.nextInt();

			switch (mark) {

			case "S":
				card[0][num - 1] = 1;
				break;

			case "H":
				card[1][num - 1] = 1;
				break;

			case "C":
				card[2][num - 1] = 1;
				break;

			case "D":
				card[3][num - 1] = 1;
				break;
			}

		}

		// ?????????????´¢??????????????????????????°?????????
		int left, right;

		// ???????????????????????\????????????
		for (left = 0; left <= 3; left++) {

			for (right = 0; right <= 12; right++) {

				if (card[left][right] == 0) {

					switch (left) {

					case 0:
						System.out.println("S " + (right+1));
						break;

					case 1:
						System.out.println("H " + (right+1));
						break;

					case 2:
						System.out.println("C " + (right+1));
						break;

					case 3:
						System.out.println("D " + (right+1));
						break;
					}

				}

			}

		}
		sc.close();
	}

}

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

typedef long long LL;

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ALL(x) (x).begin(),(x).end()
const int IINF = 1e9;
const LL LINF = 1e18;
const LL mod = 1e9+7;

int main() {
    int H, W;
    cin >> H >> W;
    vector<string> s(H);
    vector<vector<bool>> visited(H, vector<bool>(W, false));
    queue<tuple<int, int, int>> q;
    REP(i, H) {
        cin >> s[i];
    }
    int black = 0;
    REP(i, H) {
        REP(j, W) {
            if(s[i][j] == '#') {
                black++;
            }
        }
    }
    q.push(make_tuple(0, 0, 0));

    auto judge = [H, W](auto i, auto j){return 0 <= i && i < H && 0 <= j && j < W;};
    for(;!q.empty();) {
        auto f = q.front();
        q.pop();
        int i, j, dis;
        tie(i, j, dis) = f;
        if(i == H - 1 && j == W - 1) {
            cout << H*W - black - (dis + 1) << endl;
            return 0;
        }
        FOR(k, i - 1, i + 2) {
            FOR(l, j - 1, j + 2) {
                if((i == k || j == l) && judge(k, l) && !visited[k][l] && s[k][l] == '.') {
                    visited[k][l] = true;
                    q.push(make_tuple(k, l, dis + 1));
                }
            }
        }
    }
    cout << -1 << endl;
    return 0;
}


Measured memory_bytes: 256
import math


A, B = map(int, input().split())
ans = 0
while True:
    if ans == 0:
        tap = 1
    elif ans == 1:
        tap = A
    else:
        tap = A + (A-1) * (ans - 1)
    if tap >= B:
        break
    ans += 1
print(ans)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define REP(i,x,n) for(int i=x;i<(int)n;i++)
#define rep(i,n) REP(i,0,n)
#define sp(p) cout<<setprecision(16)<<fixed<<p<<endl;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define SORT(a) sort(all(a))
#define RSORT(a) sort(rall(a))
#define UNIQ(a) unique(all(a))
#define UNIQNUM(a) UNIQ(a)-a.begin()
#define UNIQIT(a) a.erase(UNIQ(a), a.end());
#define VOUT(v,i) cout<<#v<<": ";for(int i=0;i<(int)v.size();i++){cout<<v[i]<<" ";}cout<<"\n";
#define vout(v) VOUT(v,z);
#define vmin(v) *min_element(all(v))
#define vmax(v) *max_element(all(v))
#define vsum(v) accumulate(all(v), 0LL);
#define MOUT(m,r,c) rep(i,r){rep(j,c){cout<<m[i][j]<<" ";}cout<<endl;}
#define mout(m) MOUT(m,m.size(),m[0].size())
#define debg(a) cout<<#a<<": "<<a<<endl;
#define show(a) for(cont &y:a){for(cont &x:y){cout<<x<<" ";}cout<<endl;}
#define digit(a) to_string(a).length();
template<class T>inline int out(const T &t){ print(t); putchar('\n'); return 0; }
template<class T>inline T gcd(T a,T b){if(b==0)return a; return(gcd(b,a%b));}
template<class T>inline T lcm(T a,T b){return a/gcd(a,b)*b;}
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef vector<ll> V;
// const long long MOD=1000000007;
const long long INF = 1e18;
#define EPS (1e-7)
#define PI (acos(-1))
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;
}


void solve(long long N, long long K, std::vector<long long> H){
    RSORT(H);
    ll sum=0;
    for (ll i = K; i < N; i++) {
        sum+=H[i];
    }
    cout << sum << "\n";
}

int main(){
    long long N;
    scanf("%lld",&N);
    long long K;
    scanf("%lld",&K);
    std::vector<long long> H(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&H[i]);
    }
    solve(N, K, std::move(H));
    return 0;
}


Measured memory_bytes: 1792