akhauriyash/Code-Regression huggingface dataset:
import numpy as np

N, M = map(int, input().split())
adj = np.zeros((N+1, N+1))
for m in range(M):
  a, b = map(int, input().split())
  adj[a, b] = 1
  adj[b, a] = 1

from itertools import permutations

nodes = [n for n in range(2, N+1)]
ans = 0

for case in permutations(nodes):
  success = True
  for i, nd in enumerate(case):
    if i == 0:
      f = 1
    else:
      f = case[i-1]

    t = case[i]

    if adj[f, t] != 1:
      success = False
      break

  if success:
    ans += 1

print(ans)

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

// template {{{  0 
// using {{{ 1
using ll = long long int;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vii = vector<pii>;
using vll = vector<pll>;
// }}} 1
// definition {{{ 1
// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)
#define Scll(x) scanf("%lld", &x)
#define Scll2(x,y) scanf("%lld%lld", &x, &y)
#define Scll3(x,y,z) scanf("%lld%lld%lld", &x, &y, &z)
#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2
// constants {{{ 2
#define EPS (1e-7)
#define INF (2e9)
#define PI (acos(-1))
// }}} 2
// systems {{{ 2
#define Repe(x,y,z) for(ll x = z; x < y; x++)
#define Rep(x,y) Repe(x,y,0)
#define RRepe(x,y,z) for(ll x = y-z-1; x >= 0; x--)
#define RRep(x,y) RRepe(x,y,0)
// }}} 2
// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n")
#define YESNO(a) (a)?printf("YES\n"):printf("NO\n")
// }}} 2
// }}} 1
// input {{{ 1
// }}} 1
// }}} 0

int main() {

    char s[100020];
    Scs(s);
    int N = strlen(s);
    bool disa = true;
    Repe(i,N-1,1){
        disa = disa && s[i-1]==s[i+1];
    }
    if( disa ){
        printf ("Second\n");
        return 0;
    }

    bool same = s[0] == s[N-1];
    printf ("%s\n", same xor N%2 ? "First" : "Second" );



    return 0;
}



Measured memory_bytes: 384
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

const int MOD = 1e9 + 7;
const int iINF = 1000000000;
const long long int llINF = 1000000000000000000;

using namespace std;
using ll = long long int;
using vv = vector<vector<ll>>;
using edge = struct {
  int to;
  int cost;
};
#define REP(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define AUTO(i, m) for (auto &i : m)
#define ALL(a) (a).begin(), (a).end()
#define MAX(vec) *std::max_element(vec.begin(), vec.end())
#define MIN(vec) *std::min_element(vec.begin(), vec.end())
#define BIT(n, num) std::bitset<(n)>((num)).to_string()
#define REV(T) greater<T>()
#define PQ priority_queue<ll, vector<ll>, greater<ll>>

typedef pair<ll, ll> Pair;
bool pairCompare(const Pair &firstElof, const Pair &secondElof) {
  return firstElof.second > secondElof.second;
}

ll power(ll n, ll m) {
  if (m == 0) {
    return 1;
  } else if (m % 2 == 0) {
    ll tmp = power(n, m / 2);
    return (tmp * tmp) % MOD;
  } else {
    return (n * power(n, m - 1)) % MOD;
  }
}

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

int main() {
  ll N;
  vector<ll> dp(200002, 0);
  cin >> N;
  REP(i, N) {
    ll a = 0;
    cin >> a;
    dp[a] = dp[a - 1] + 1;
  }
  cout << (N - MAX(dp)) << endl;
  return 0;
}


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

using namespace std;

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

#define fi first
#define se second
#define mp make_pair
#define fastIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int N = (int)1e5 + 10;
const int LOG = 60;
ll basis[LOG];
ll a[N];

void insert_basis(ll x){
  for(int i = LOG - 1; i >= 0 ; i -- ){
    if((x & (1ll << i)) == 0) continue;
    if(basis[i] == 0){
      basis[i]=x;
      return;
    }
    x ^= basis[i];
  }
}

int main(){
  fastIO;
  int n;
  cin >> n;
  ll xr = 0;
  for(int i = 1; i <= n; i ++ ){
    cin >> a[i];
    xr ^= a[i];
  }
  ll d;
  for(int i = 1; i <= n; i ++ ){
    a[i] -= (a[i] & xr);
    insert_basis(a[i]);
  }
  ll ans = 0;
  for(int i = LOG - 1; i >= 0 ; i -- ){
    if((ans & (1ll << i))) continue;
    ans ^= basis[i];
    
  }
  cout << 2ll * ans + xr << "\n";
  return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

using ll = long long;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  ll n, m;
  cin >> n >> m;
  vector<ll> as(n);
  for (auto& v : as) cin >> v;
  sort(rbegin(as), rend(as));
  vector<pair<ll, ll>> cbs(m);
  for (auto& p : cbs) cin >> p.second >> p.first;
  sort(rbegin(cbs), rend(cbs));
  cbs.emplace_back(-1, 1);
  int aidx = 0, cidx = 0, cjdx = 0;
  ll sum = 0;
  for (int i = 0; i < n; i++) {
    if (as[aidx] > cbs[cidx].first) {
      sum += as[aidx];
      aidx++;
    }
    else {
      sum += cbs[cidx].first;
      cjdx++;
      if (cjdx == cbs[cidx].second) {
        cjdx = 0;
        cidx++;
      }
    }
  }
  cout << sum << endl;
}


Measured memory_bytes: 5120
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using uint = unsigned int;
const ll mod = (uint)1e9 + 7;

int main() {
  int a, b;
  cin >> a >> b;
  cout << a * b << endl;
  return 0;
}


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

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = std::int64_t;
using P = std::tuple<int,int>;

ll R, D, X[2100];

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

    std::cin >> R >> D >> X[2000];

    for(int i=2001;i<=2010;++i){
        X[i] = R * X[i-1] - D;

        std::cout << X[i] << std::endl;
    }
}


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

int main() {
	
	int h,w;
	cin>>h>>w;
	
	char a[h][w];
	char x;
	for(int i=0;i<h;i++)
		for(int j=0;j<w;j++)
			cin>>a[i][j];
		
	int dp[h][w] {0};	
	if(a[0][0]=='#')
		dp[0][0]=1;
		
	for(int j=1;j<w;j++)
	{
		if(a[0][j]==a[0][j-1])
			dp[0][j]=dp[0][j-1];
		else
			dp[0][j]=dp[0][j-1]+1;
	}
	for(int i=1;i<h;i++)
	{
		if(a[i][0]==a[i-1][0])
			dp[i][0]=dp[i-1][0];
		else
			dp[i][0]=dp[i-1][0]+1;
	}
	
	for(int i=1;i<h;i++)
		for(int j=1;j<w;j++)
			{
				dp[i][j]=min((a[i][j]==a[i-1][j])?dp[i-1][j]:dp[i-1][j]+1, (a[i][j]==a[i][j-1])?dp[i][j-1]:dp[i][j-1]+1);
			}
			
	cout<<(dp[h-1][w-1]+1)/2<<endl;
	/*for(int i=0;i<h;i++)
	{for(int j=0;j<w;j++)
	cout<<dp[i][j];
	cout<<endl;}*/
	
	// your code goes here
	return 0;
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

#define MAX 1299709

int main(){

	int hurui[MAX + 1] = { 0 };
	int n,cnt;

	hurui[0] = 1, hurui[1] = 1;
	for (int i = 0; i <= MAX; i++){
		if (hurui[i] == 0){
			for (int j = i * 2; j <= MAX; j += i){
				hurui[j] = 1;
			}
		}
	}

	while (1){
		cin >> n;
		if (n == 0) break;

		if (hurui[n] == 0){
			cout << "0" << endl;
			continue;
		}

		while (hurui[n] == 1) n--;

		cnt = 1;
		n++;
		while (hurui[n] == 1) n++, cnt++;

		cout << cnt << endl;
	}
	return 0;
}

Measured memory_bytes: 6240
from collections import deque, defaultdict


def partition(A, p, r):
    x = int(A[r][1:])
    i = p - 1
    for j in range(p, r):
        if x >= int(A[j][1:]):
            i += 1
            A[i], A[j] = A[j], A[i]

    A[i+1], A[r] = A[r], A[i+1]

    return i + 1


def quick_sort(A, p, r):
    if p < r:
        q = partition(A, p, r)
        quick_sort(A, p, q-1)
        quick_sort(A, q+1, r)


def main():
    n = int(input())
    A = []
    d = defaultdict(deque)
    stable = True
    for i in range(n):
        inp = input().replace(" ", "")
        A.append(inp)
        d[int(inp[1:])].append(inp[0])
    quick_sort(A, 0, n-1)

    # stableかどうかを確認
    for a in A:
        tmp = d[int(a[1:])].popleft()
        if a[0] != tmp:
            stable = False

    if stable:
        print("Stable")

    else:
        print("Not stable")

    for a in A:
        print(a[0], a[1:])


if __name__ == "__main__":
    main()



Measured memory_bytes: 30704
/*  ex4_3
    pptenshi  */

#include<stdio.h>

int west_tower_num(int height_west, int height_east);
int height_tower(int num);
int snowfall(int height, int height_above_snow);

int main(void) {
    int height_west,  // a 
        height_east;  // b

    // input
    scanf("%d%d", &height_west, &height_east);
    
    // output
    printf(
        "%d\n", 
        snowfall(
            height_tower(west_tower_num(height_west, height_east)), 
            height_west
        ));

    return 0;
}


/*  calculate west tower number
    parameter   height_west : height of west tower above snow,
                height_east : height of east tower above snow    */ 
int west_tower_num(int height_west, int height_east) {
    return height_east - height_west - 1;
}


/*  calculete height of tower
    parameter   num : tower number   */
int height_tower(int num) {
    return num * (num + 1) / 2; 
}

//  calculate snowfall amount 
int snowfall(int height, int height_above_snow) {
    return height - height_above_snow;
}

Measured memory_bytes: 128
#include<cstdio>
#include<algorithm> 
using namespace std; int main(void)
{     
	int card[5];
	char kari;     
	while(1)     
	{         
		for(int i = 0;i < 5;i++)         
		{             
			if(scanf("%d",&card[i])== EOF) goto kitune;             
			if(i < 4)scanf("%c",&kari);         
		}		
		int cnt = 0,check[15] = {0};
		sort(card,card+5);         
		for(int i = 0;i<5;i++)         
		{             
			check[card[i]]++;             
			if(card[i] == 1) check[14] += 1;         
		}         
		for(int i = 0;i<=14;i++) 
		{             
			if(check[i] == 1)
			{                 
				if(check[i+1] == 1)                  
				{                     
					cnt++;                     
					if(cnt == 4) break;              
				}                 
				else cnt = 0;             
			}         
		}           
		int pair = 0;         
		int three = 0;         
		int four = 0;         
		int st = 0;         
		if(cnt == 4)         
		{             
			printf("straight\n");             
			st = 1;
		}         
		else       
		{             
			for(int i = 0;i < 14;i++)     
			{              
				if(check[i] == 2) pair++;  
				else if(check[i] == 3) three++;    
				else if(check[i] >= 4) four++;   
			}     
		}

		if(pair >= 1)     
		{  
			if(three == 1) printf("full house\n");     
			else if(pair == 2) printf("two pair\n");    
			else printf("one pair\n");   
		}       
		else if(three >= 1)    
		{        
			if(pair == 1) printf("full house\n"); 
			else if(three == 2) printf("full house\n");   
			else printf("three card\n");     
		}         
		else if(four >= 1) printf("four card\n");  
		else if(st != 1) printf("null\n");   
	}    
	kitune: 
	return 0; 
}

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

int solve(int dp[], vector<int> es[], int from) {
    if (dp[from] > 0)
        return dp[from];
    int res = 0;
    for (int to: es[from]) {
        res = max(res, solve(dp, es, to) + 1);
    }
    return dp[from] = res;
}

int main() {
    int n, m;
    cin >> n >> m;
    int dp[n];
    vector<int> es[n];
    fill(dp, dp + n, 0);
    for (int i = 0; i < m; i++) {
        int x, y;
        cin >> x >> y;
        x--; y--;
        es[x].push_back(y);
    }
    int ans = 0;
    for (int i = 0; i < n; i++) {
        ans = max(solve(dp, es, i), ans);
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 8832
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=500000004;
const double EPS=1e-6;
const double PI=acos(-1.0);
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
vector<int> g[2100];
int sz[2100];
long long dp[3][2100][2100];
long long dp2[4][2100][4100];
long long fact[3100];
void solve(int a){
//		printf("%d\n",a);fflush(stdout);
	int n=g[a].size();
	dp2[0][0][0]=1;
	for(int i=0;i<g[a].size();i++){
		solve(g[a][i]);
	}
	for(int i=0;i<g[a].size();i++){
		int T=sz[a];
		sz[a]+=sz[g[a][i]];
		int to=g[a][i];
		for(int j=0;j<=sz[a]+10;j++){
			dp2[0][i+1][j]=dp2[1][i+1][j]=dp2[2][i+1][j]=dp2[3][i+1][j]=0;
		}
		for(int j=0;j<=T;j++){
		//	if(a==1&&j<2)printf("%d %d: %lld %lld %lld\n",i,j,dp2[0][i][j],dp2[1][i][j],dp2[2][i][j]);

			for(int k=0;k<=sz[g[a][i]]+1;k++){
				dp2[0][i+1][j+k]=(dp2[0][i+1][j+k]+dp2[0][i][j]*dp[0][to][k])%mod;
				dp2[1][i+1][j+k]=(dp2[1][i+1][j+k]+dp2[0][i][j]*dp[1][to][k])%mod;
				dp2[1][i+1][j+k]=(dp2[1][i+1][j+k]+dp2[1][i][j]*dp[0][to][k])%mod;
				dp2[2][i+1][j+k]=(dp2[2][i+1][j+k]+dp2[2][i][j]*dp[0][to][k])%mod;
				dp2[2][i+1][j+k]=(dp2[2][i+1][j+k]+dp2[0][i][j]*dp[2][to][k])%mod;
				dp2[3][i+1][j+k]=(dp2[3][i+1][j+k]+dp2[1][i][j]*dp[2][to][k])%mod;
				dp2[3][i+1][j+k]=(dp2[3][i+1][j+k]+dp2[2][i][j]*dp[1][to][k])%mod;
				dp2[3][i+1][j+k]=(dp2[3][i+1][j+k]+dp2[3][i][j]*dp[0][to][k])%mod;
				
			}
		}
	}

	//if(a==1)printf("%d %d: %lld %lld %lld\n",4,0,dp2[0][4][0],dp2[1][4][0],dp2[2][4][0]);
	//if(a==1)printf("%d %d: %lld %lld %lld\n",4,1,dp2[0][4][1],dp2[1][4][1],dp2[2][4][1]);

	//	printf("AA\n");fflush(stdout);
	for(int i=0;i<=sz[a];i++){
		dp[0][a][i]=(dp2[0][n][i]+dp2[1][n][i]+dp2[2][n][i]+dp2[3][n][i])%mod;
		dp[1][a][i+1]=(dp2[0][n][i]+dp2[1][n][i])%mod;
		dp[2][a][i+1]=(dp2[0][n][i]+dp2[2][n][i])%mod;
//		if(i<=1)printf("%d %d: %lld %lld\n",a,i,dp[0][a][i],dp[1][a][i]);

	}
//	if(sz[a]+1==1)printf("%d %d: %lld %lld\n",a,sz[a]+1,dp[0][a][sz[a]+1],dp[1][a][sz[a]+1]);
	sz[a]++;
}
int main(){
	int a;scanf("%d",&a);
	for(int i=0;i<a-1;i++){
		int p;scanf("%d",&p);
		p--;
	//	printf("%d %d\n",i+1,p);fflush(stdout);
		g[p].push_back(i+1);
	}
	solve(0);
	long long ret=0;
	fact[0]=1;
	for(int i=1;i<3100;i++)fact[i]=fact[i-1]*i%mod;

	for(int i=0;i<=a;i++){
	//	printf("%d: %lld\n",i,dp[0][0][i]);
		if(i%2==0)ret=(ret+dp[0][0][i]*fact[a-i]%mod)%mod;
		else ret=(ret+mod-dp[0][0][i]*fact[a-i]%mod)%mod;
	}
	printf("%lld\n",ret);
}

Measured memory_bytes: 365184
//AcFreak

#include<bits/stdc++.h>
#define lint long long int 
#define mp make_pair
#define pb push_back
#define f first
#define INF (lint )(1e9)
#define __ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define s second
#define endl '\n'
#define pii pair<int,int >
using namespace std;


int main()
{__
      
      int n;
      cin>>n;
      vector<int >arr(n);

      int i,j;
      for(i=0;i<n;i++)
      	cin>>arr[i];

      int cc=0;
      for(i=0;i<n-1;i++)
      {
      	if(arr[i]==arr[i+1])
      	{
      		arr[i+1]=0;
      		cc++;
      	}
      	else
      		continue;
      }
      cout<<cc<<endl;
      return 0;
}

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

/************************** definations *******************************/
#define pi              2*acos(0.0)
#define ll              long long int
#define sc1(a)          scanf("%lld",&a)
#define sc2(a,b)        scanf("%lld %lld",&a,&b)
#define pf1(a)          printf("%lld\n",a)
#define pf2(a,b)        printf("%lld %lld\n",a,b)
#define Case(a)         printf("Case %d: ",a)
#define Casel(a)        printf("Case %lld: ",a)
#define INF             1e9
#define INFL            1e18
#define XX              first
#define YY              second
#define PB              push_back
#define MP              make_pair
#define NEWLINE         cout << endl;
#define DONE            cerr << "Done" << endl
#define PAUSE           system("pause")
#define DEBUG(x)        cerr << #x << " = " << x << endl
#define READ            freopen("alu.txt", "r", stdin)
#define WRITE           freopen("vorta.txt", "w", stdout)
#define FASTIO          ios_base::sync_with_stdio(false);cin.tie(NULL)
#define M               10000007
#define mod             100000007
/************************** definations *******************************/

int main()
{
    FASTIO;
    int i,n,ans=0; cin >> n;
    string s; cin >> s;
    for(i=0;i<n;i++){
        if(s[i]!=s[i-1]) ans++;
    }
    cout << ans;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back((a))
#define all(x) (x).begin(),(x).end()
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#define fi first
#define se second
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
void _dbg(string){cout<<endl;}
template<class H,class... T> void _dbg(string s,H h,T... t){int l=s.find(',');cout<<s.substr(0,l)<<" = "<<h<<", ";_dbg(s.substr(l+1),t...);}
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

#define INF 1120000000

int main(){
  int n;
  cin>>n;
  cout<< "ABC" << n << endl;

  return 0;
}


Measured memory_bytes: 256
#bubble sort

N=int(input())
A=list(map(int,input().split()))
counter=0
flag=True
string=""
while flag:
    flag=False
    for j in range(N-1,0,-1):
        if A[j]<A[j-1]:
            A[j],A[j-1]=A[j-1],A[j]
            counter+=1
            flag=True

A_str=map(str,A)
string=" ".join(A_str)
print(string)
print(counter)



Measured memory_bytes: 5600
#!/usr/bin/env python
from collections import deque
N, K = map(int, input().split())
V = [int(i) for i in input().split()]
q = deque(V)
l = []
cnt = 0
flag = True
ans = 0
for a in range(K+1):
    for b in range(K+1-a):
        max_ = 0
        q.clear()
        q = deque(V)
        flag = True
        cnt = 0
        l = []
        for _ in range(a):
            if len(q) == 0:
                flag = False
            else:
                l.append(q.popleft())
        if flag:
            for _ in range(b):
                if len(q) == 0:
                    flag = False
                else:
                    l.append(q.pop())
        else:
            continue
        if flag:
            for x in sorted(l):
                cnt += 1
                if x < 0 and cnt <= K-a-b:
                    pass
                else:
                    max_ += x
        else:
            continue
        if max_ > ans:
            ans = max_

print(ans)

Measured memory_bytes: 3444
// inputに入力データ全体が入る
function Main(input) {
	// 1行目がinput[0], 2行目がinput[1], …に入る
	input = input.split("\n");
	tmp = input[0].split(" ");
	//文字列から10進数に変換するときはparseIntを使います
	var n = parseInt(tmp[0], 10);
    var l = parseInt(tmp[1], 10);
    var L =[];S=[];tpai=0;
    for(i=0;i<n;i++){
        var r = i+l-1+1;
        tpai+=r; 
        S[i]=r;
        p = Math.abs(r) ;
         L[i]=p;
    }
 // console.log(S);
//  console.log(L);
    L.sort((a,b) =>(a-b));
  //  console.log(tpai);
  // console.log(S[n-1]);
  
    if ((S[0]<=0)&&(S[n-1]<=0)){console.log(tpai-S[n-1])}
  
    else{console.log(tpai-L[0]);}
    }
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7500
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TupleSections #-}
{-# LANGUAGE RankNTypes #-}
import qualified Data.ByteString.Lazy.Char8 as B
import Data.Maybe
import Data.Bits
-- import Data.List
-- import qualified Data.Vector.Unboxed as VU
-- import qualified Data.Vector.Unboxed.Mutable as VUM
-- import Control.Monad
-- import Control.Monad.ST
-- import Debug.Trace
-- trace _ = id

solve :: Int -> Int -> Int -> Maybe [Int]
solve n a b | even (popCount (xor a b)) = Nothing
            | otherwise = Just (subsolve n n (2^n - 1) a b)

subsolve :: Int -> Int -> Int -> Int -> Int -> [Int]
subsolve n 1 mask a b = [a, b]
subsolve n k mask a b = part1 ++ part2
  where
  t = (xor a b) .&. mask
  lsb = t .&. (-t)
  newMask = xor mask lsb
  inNewMask = newMask .&. (-newMask)
  c = xor a inNewMask
  part1 = subsolve n (k-1) newMask a c
  part2 = subsolve n (k-1) newMask (xor c lsb) b
  
readBInt :: B.ByteString -> Int
readBInt = fst . fromJust . B.readInt

tmain :: B.ByteString -> Maybe [Int]
tmain cont =
  let remLines0 = map B.words (B.lines cont)
      [bs_n,bs_a,bs_b]:remLines1 = remLines0
      n = readBInt bs_n
      a = readBInt bs_a
      b = readBInt bs_b
  in solve n a b

outAnswer :: Maybe [Int] -> IO ()
outAnswer Nothing = putStrLn "NO"
outAnswer (Just xs) = do
  putStrLn "YES"
  putStrLn (unwords (map show xs))

main :: IO ()
main = outAnswer . tmain =<< B.getContents


-------------------------------------------------------------------------------

inp1 = "2 1 3\n"
inp2 = "3 2 1\n"
tv1 = tmain $ B.pack inp1
tv2 = tmain $ B.pack inp2



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

int main() {
    int k,b,i,j,l,count,v,m,n;
    //cin>>k;
    cin>>n>>m;
    int a[m];
    for(i=0;i<m;i++)
    {
        a[i]=0;
    }
    for(i=0;i<n;i++)
    {
        cin>>k;
        for(j=0;j<k;j++)
        {
            cin>>v;
            
          for(l=1;l<=m;l++)
          {
             if(v==l)
             {
                 a[l-1]+=1;
                 //cout<<a[l-1]<<endl;
                 break;
             }
          }
        }
    }
    count=0;
    for(i=0;i<m;i++)
    {
        if(a[i]==n)
        {
            count++;
        }
    }
    cout<<count<<endl;
}


Measured memory_bytes: 256
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
Max = sys.maxsize
def l(): #intのlist
    return list(map(int,input().split()))
def m(): #複数文字
    return map(int,input().split())
def onem(): #Nとかの取得
    return int(input())
def s(x): #圧縮
    a = []
    aa = x[0]
    su = 1
    for i in range(len(x)-1):
        if aa == x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
    a.append([aa,su])
    return a
def jo(x): #listをスペースごとに分ける
    return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
    return max(map(max,x))

n = onem()
l = l()
if n % 2 == 1:
    print(0)
    exit()
co = 0
l.sort()
ll = [0 for i in range(10**5+1)]

for i in range(n):
    ll[l[i]] += 1

for i in range(1,len(ll)):
    ll[i] += ll[i-1]
    if ll[i] == n//2:
        co += 1
print(co)



Measured memory_bytes: 56108
package main

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

const (
	initialBufSize = 10000
	maxBufSize     = 1000000
	mod            = 1e9 + 7
)

var (
	sc *bufio.Scanner = func() *bufio.Scanner {
		sc := bufio.NewScanner(os.Stdin)
		buf := make([]byte, initialBufSize)
		sc.Buffer(buf, maxBufSize)
		sc.Split(bufio.ScanWords)
		return sc
	}()
)

func main() {
	N := getInt()
	A := make([]int, N)
	numberCnt := make(map[int]int)

	for i := 0; i < N; i++ {
		A[i] = getInt()
		numberCnt[A[i]] += 1
	}

	allCnt := 0
	for _, v := range numberCnt {
		allCnt += v * (v-1) / 2
	}

	for i := 0; i < N; i++ {
		fmt.Println(allCnt - (numberCnt[A[i]] - 1))
	}
}

type Graph struct {
	n     int
	edges [][]int
}

func NewGraph(n int) *Graph {
	g := &Graph{
		n:     n,
		edges: make([][]int, n),
	}
	return g
}

func (g *Graph) AddEdge(u, v int) {
	g.edges[v] = append(g.edges[v], u)
	g.edges[u] = append(g.edges[u], v)
}

func dfs(c int, edges [][]int, visited map[int]struct{}) {
	visited[c] = struct{}{}

	for _, v := range edges[c] {
		_, flag := visited[v]
		if flag {
			continue
		}
		dfs(v, edges, visited)
	}
}

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

func abs(a int) int {
	return int(math.Abs(float64(a)))
}

func pow(p, q int) int {
	return int(math.Pow(float64(p), float64(q)))
}

func powMod(n, p int) int {
	if p == 0 {
		return 1
	} else if p%2 == 0 {
		t := powMod(n, p/2)
		return calcMod(t * t)
	} else {
		return n * powMod(n, p-1)
	}
}

func min(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton min() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Min(float64(res), float64(nums[i])))
	}
	return res
}

func max(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton max() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Max(float64(res), float64(nums[i])))
	}
	return res
}

func strSearch(a []string, b string) bool {
	for i := 0; i < len(a); i++ {
		if a[i] == b {
			return true
		}
	}
	return false
}

func printIntArray(array []int) {
	strArray := fmt.Sprint(array)
	fmt.Println(strArray[1 : len(strArray)-1])
}

func calcMod(x int) int {
	return x % mod
}

func reverse(s string) string {
	runes := []rune(s)
	for i, j := 0, len(runes)-1; i < j; i, j = i+1, j-1 {
		runes[i], runes[j] = runes[j], runes[i]
	}
	return string(runes)
}


Measured memory_bytes: 14720
import math

k = int(input())
ans = 0
m = 0
for a in range(1,k+1):
    for b in range(a+1,k+1):
        for c in range(b+1, k+1):
            m = math.gcd(a,b)
            ans += 6*math.gcd(m,c)
for a in range(1,k+1):
    for c in range(a+1,k+1):
        ans += 3*math.gcd(a,c)
for c in range(1,k+1):
    for a in range(c+1,k+1):
        ans += 3*math.gcd(a,c)
for a in range(1,k+1):
    ans += a
print(ans)

Measured memory_bytes: 9224
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll INF = 1LL << 60;
const ll MOD = 998244353;
ll dp[3001][6001];
ll mod_pow(ll a, ll n) {
	if (n == 0) return 1;
	if (n % 2 == 0) {
		ll tmp = mod_pow(a, n / 2);
		return (tmp * tmp) % MOD;
	}
	return (a * mod_pow(a, n - 1)) % MOD;
}

vector<ll> fact;
vector<ll> inv_fact;

void comb_init(int n) {
	fact.resize(n + 1);
	inv_fact.resize(n + 1);
	fact[0] = inv_fact[0] = 1;
	for (int i = 1; i <= n; i++) {
		fact[i] = (fact[i - 1] * i) % MOD;
		inv_fact[i] = (inv_fact[i - 1] * mod_pow(i, MOD - 2)) % MOD;
	}
}

ll comb(int n, int k) {
	if (n < k) return 0;
	ll ret = fact[n];
	(ret *= inv_fact[k]) %= MOD;
	(ret *= inv_fact[n - k]) %= MOD;
	return ret;
}
int main() {
	int N, X;
	cin >> N >> X;
	comb_init(N);
	dp[0][0] = 1;
	for (int i = 0; i < N; i++) for (int j = 0; j <= 2 * i; j++) {
		(dp[i + 1][j + 1] += dp[i][j]) %= MOD;
		(dp[i + 1][j + 2] += dp[i][j]) %= MOD;
	}
	ll ans = 0;
	for (int i = 0; i <= N; i++) {
		ll sum = 0;
		for (int j = i; j < X; j++) (sum += dp[i][j]) %= MOD;
		for (int j = 1; 2 * j <= i; j++) {
			if (X - 1 < 2 * j) break;
			(sum += dp[i - 2 * j][X - 1 - 2 * j]) %= MOD;
		}
		(ans += sum * comb(N, i) % MOD) %= MOD;
	}
	if (X % 2 == 1) {
		for (int i = X; i <= N; i++) (ans += comb(N, i)) %= MOD;
	}
	cout << ans << endl;
 }

Measured memory_bytes: 139136
#include<iostream>
using namespace std;
int main()
{
  int k,a,b;
  cin>>k>>a>>b;
  for(int i=a;i<=b;i++)
  {
    if(i%k==0)
    {
        cout<<"OK";
        return 0;
    }
  }
  cout<<"NG";
}

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

import numpy as np
from heapq import heappush, heappop

N,M,S,T = map(int,input().split())
graph = [[] for _ in range(N+1)]
for _ in range(M):
    u,v,a,b = map(int,input().split())
    graph[u].append((v,a,b))
    graph[v].append((u,a,b))

def dijkstra(start, mode):
    INF = 10 ** 15
    dist = [INF] * (N+1)
    dist[start] = 0
    q = [(0,start)]
    while q:
        d,v = heappop(q)
        if dist[v] < d:
            continue
        for w,*a in graph[v]:
            d1 = d + a[mode]
            if dist[w] > d1:
                dist[w] = d1
                heappush(q, (d1,w))
    return dist

d1 = np.array(dijkstra(S,0))
d2 = np.array(dijkstra(T,1))

d1 += d2
answer = 10 ** 15 - np.minimum.accumulate(d1[::-1])[::-1][1:]

print(*answer, sep='\n')

Measured memory_bytes: 63828
def dfs(s):
    global ans
    for u in v:
        x = s[0] + u[0]
        y = s[1] + u[1]
        if x < h and y < w:
            b[x][y] = "#"
            dfs([x, y])
            b[x][y] = "."
    if a == b:
        ans = 1
    return

h, w = map(int, input().split())
a = [list(input()) for _ in range(h)]
v = [[1, 0], [0, 1]]
b = [["."] * w for _ in range(h)]
b[0][0] = "#"
s = [0, 0]
ans = 0
dfs(s)
print("Possible" if ans == 1 else "Impossible")

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

#define int long long

using namespace std;

#ifdef LOCAL 
#include "/media/brayand/BrayanD/debugger.h"
#else
template<typename... Args>
void db(Args... args){}
#endif

int32_t main()
{
    // ios_base::sync_with_stdio(0);
    // cin.tie(0);

    int T;
    cin >> T;

    while(T--)
    {
    	int N;
    	cin >> N;

    	vector<pair<int,pair<int,int>>> v1;
    	vector<pair<int,pair<int,int>>> v2;

    	for(int i = 0 ; i < N ; i++)
    	{
    		int K, L, R;
    		cin >> K >> L >> R;
    		if(L > R)v1.push_back({K,{L-R,R}});
    		else v2.push_back({K,{R-L,L}});
    	}

    	sort(v1.begin(),v1.end());
    	sort(v2.begin(),v2.end());
    	reverse(v2.begin(),v2.end());

    	int res = 0;

    	int sz1 = v1.size();
    	int sz2 = v2.size();

    	multiset<pair<int,int>> st1, st2;

    	for(int i = sz1 ; i >= 1 ; i--)
    	{
    		while(v1.size() && v1.back().first >= i)
    		{
    			st1.insert({v1.back().second.first,v1.back().second.second});
    			v1.pop_back();
    		}
    	
    		if(st1.size())
    		{
    			pair<int,int> ppp = *(--st1.end());

    			res += ppp.first+ppp.second;

    			st1.erase(--st1.end());
    		}
    	}

    	for(auto x : v1)
    	{
			res += x.second.second;
    	}
    	for(auto x : st1)
    	{
			res += x.second;
    	}
    	
    	for(int i = sz1+1 ; i <= N ; i++)
    	{
    		while(v2.size() && v2.back().first < i)
    		{
    			st2.insert({v2.back().second.first,v2.back().second.second});
    			v2.pop_back();
    		}
    	
    		if(st2.size())
    		{
    			pair<int,int> ppp = *(--st2.end());

    			res += ppp.first+ppp.second;

    			st2.erase(--st2.end());
    		}
    	}

    	for(auto x : v2)
    	{
			res += x.second.second;
    	}
    	for(auto x : st2)
    	{
			res += x.second;
    	}

    	cout << res << '\n';
    }

    return 0;
}

Measured memory_bytes: 14884
#include<stdio.h>

int main(void)
{
   int n, w[100], s1=0, s2=0, i, f=1;

   scanf("%d",&n);
   for(i=0;i<n;i++)
      scanf("%d",&w[i]);

   i=0;
   while(i+f<n+1){
      if(s1>s2){
         s2+=w[n-f];
         f++;
      }
      else{
         s1+=w[i];
         i++;
      }
   }

   if(s1<s2)
      printf("%d\n",s2-s1);
   else
      printf("%d\n",s1-s2);
   return 0;
}

Measured memory_bytes: 1736
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var Arr=(input.trim()).split("\n");
var NK=Arr.shift().split(" ").map(Number);
var N=NK[0];
var K=NK[1];
var rabbit=[];
for(var i=0;i<N;i++)rabbit[i]=true;
var boat=[];
for(var i=0;i<K;i++){
   var v=Arr.shift().split(" ").map(function(value){return (value-0)-1;});
   v.shift();
   boat.push(v);
}
var R=Arr.shift()-0;
var PQ=[];
for(var i=0;i<R;i++){
   var v=Arr.shift().split(" ").map(function(value){return (value-0)-1;});
   PQ.push(v);
}
boat.forEach(function(v){
   PQ.forEach(function(V){
      var a=v.indexOf(V[0]);
      var b=v.indexOf(V[1]);
      if(a!==-1 && b!==-1){
         rabbit[V[0]]=false;
         rabbit[V[1]]=false;
      }
   });
});
var ans=0;
rabbit.forEach(function(v){if(!v)ans++;});
console.log(ans);

Measured memory_bytes: 9940
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Scanner;
import java.util.stream.Collectors;
import java.util.stream.IntStream;

public class Main {
    // TODO solve
    public static void main(final String[] args) {
        final Scanner scanner = new Scanner(System.in);
        final int n = scanner.nextInt();
        final int p = scanner.nextInt();
        final String s = scanner.next();
        final List<Integer> list = IntStream.range(0, n)
                .mapToObj(i -> s.charAt(i) - '0')
                .collect(Collectors.toList());

        long count = 0;
        if (p == 2 || p == 5) {
            for (int i = 0; i < list.size(); i++) {
                final int digit = list.get(i);
                if (digit % p == 0) {
                    count += i + 1;
                }
            }
        } else {
            final Map<Long, Long> counter = new HashMap<>();
            long base = 1;
            long current = 0;
            Collections.reverse(list);
            for (final int digit : list) {
                current = (current + digit * base) % p;
                base = base * 10 % p;
                if (current % p == 0) {
                    count++;
                }
                if (counter.get(current) != null) {
                    count += counter.get(current);
                }
                counter.compute(current, (k, v) -> v == null ? 1 : v + 1);
            }
        }

        System.out.println(count);
    }
}


Measured memory_bytes: 45804
import java.util.*;

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

      String s = sc.next();
      int lng = s.length();
      char[] c = new char[lng];
      for(int i=0;i<lng;i++){
        c[i] = s.charAt(i);
      }

      int ans1 = 0;
      int ans2 = 0;

      for(int i=0;i<lng;i++){
        if(i%2==0 && c[i]=='1'){
          ans1++;
        }
        if(i%2==1 && c[i]=='0'){
          ans1++;
        }
      }

      for(int i=0;i<lng;i++){
        if((i+1)%2==1 && c[i]=='0'){
          ans2++;
        }
        if((i+1)%2==0 && c[i]=='1'){
          ans2++;
        }
      }

      System.out.println(Math.min(ans1,ans2));

    }
}


Measured memory_bytes: 26964
#include <iostream>
#include <algorithm>
#include <cstdlib>
using namespace std;
int main(void){
    // Your code here!
    long S[3][3];
    cin>>S[0][0]>>S[0][1]>>S[0][2];
    cin>>S[1][0]>>S[1][1]>>S[1][2];
    cin>>S[2][0]>>S[2][1]>>S[2][2];
    
    long i,j,k,l,m,n;
    long ii,jj,kk,ll,mm,nn;
    ii=min(min(S[0][0]+1,S[0][1]+1),S[0][2]+1);
    jj=min(min(S[1][0]+1,S[1][1]+1),S[1][2]+1);
    kk=min(min(S[2][0]+1,S[2][1]+1),S[2][2]+1);
    ll=min(min(S[0][0]+1,S[1][0]+1),S[2][0]+1);
    mm=min(min(S[0][1]+1,S[1][1]+1),S[2][1]+1);
    nn=min(min(S[0][2]+1,S[1][2]+1),S[2][2]+1);
    bool flug=false;
    
    
    for (i=0;i<=ii;i++)
    {
        if(flug==true)
        {
            break;
        }
        for (j=0;j<=jj;j++)
        {
            if(flug==true)
            {
                break;
            }
            for (k=0;k<=kk;k++)
            {
                if(flug==true)
                {
                    break;
                }
                for (l=0;l<=ll;l++)
                {
                    if(flug==true)
                    {
                        break;
                    }
                                
                    for (m=0;m<=mm;m++)
                    {
                        if(flug==true)
                    {
                        break;
                    }
                    for (n=0;n<=nn;n++)
                        {
                            
                            if(S[0][0]==i+l && S[1][0]==j+l && S[2][0]==k+l && S[0][1]==i+m && S[1][1]==j+m && S[2][1]==k+m && S[0][2]==i+n && S[1][2]==j+n && S[2][2]==k+n)
                            {
                                cout<<"Yes"<<endl;
                                flug=true;
                                break;
                            
                                
                            }
                        }
                    }
                }
            }
        }
    }
    
    
    
    
    
    
    
    
    
    
    if(flug==false)
    {
        cout<<"No"<<endl;
    
    }
    
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A,B;
  cin >> A >> B;
  int Max,mini;
  Max=max(A,B);
  mini=min(A,B);
  for(int i=0;i<Max;i++){
    cout << mini;
  }
  cout << endl;
}

Measured memory_bytes: 3592
#include<bits/stdc++.h>
#include <iomanip>
#include <iostream>
#include <vector>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
const ll INF = 1LL << 30;

int N;
vector<int> h;
vector<int> dp;

// int req(int v){
//     if(v == 0) return 0;
//     ll a1 = INF, a2 = INF;
    
//     cout << "v: " << v+1 << " " << v << " " << v-1 << "\n";
//     a1 = req(v-1) + abs(h[v] - h[v-1]);
//     if(v > 1) a2 = req(v-2) + abs(h[v] - h[v-2]);
    
//     return min(a1, a2);
// }

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

int req(int v){
    
    if(dp[v] != -1) return dp[v];
    
    if(v == 0) return 0;
    
    ll res = INF;
    
    res = min(res, req(v-1) + abs(h[v] - h[v-1]));
    if(v > 1) res = min(res, req(v-2) + abs(h[v] - h[v-2]));
    
    return dp[v] = res;
}

int main(void){
    int N; cin >> N;
    vector<pair<int,int>> A(N);
    for(int i = 0; i < N; i++){
        cin >> A[i].first;
        A[i].second = i + 1;
    }
    sort(A.begin(), A.end());
    // reverse(A.begin(), A.end());
    for(int i = 0; i < N; i++){
        cout << A[i].second << " ";
    }
}


Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned ui;
typedef unsigned long long ul;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;
typedef vector<int> vi;
#define pb push_back
#define fi first
#define se second
#define do(i, j, k) for(int i = j; i <= (k); i ++)
#define open(i, j, k) for(int i = j; i < (k); i ++)
#define dec(i, j, k) for(int i = j; i >= (k); i --)
#define mfil(x, k) memset(x, k, sizeof x)
#define mcpy(x, y) memcpy(x, y, sizeof x)
#define fio(x) freopen(x".in", "r", stdin); freopen(x".out", "w", stdout)
template <class T> bool chkmin(T &x, T y)
{ return y < x ? (x = y, true) : false; }
template <class T> bool chkmax(T &x, T y)
{ return y > x ? (x = y, true) : false; }
struct __init { __init()
{
    ios::sync_with_stdio(false); cin.tie(0);
    cout.precision(16); cout << fixed;
    srand(time(0) ^ ul(new char));
} } static __init__;
/* default code ends here */

bool solve(vi v)
{
    int tot = 0;
    bool flag = false;
    for(int x : v)
    {
        flag |= x == 1;
        tot += x - 1 & 1;
    }
    if(tot == 0)
        return false;
    if(tot & 1)
        return true;
    if(!flag && tot == v.size() - 1)
    {
        int g = 0;
        for(int x : v)
            g = __gcd(g, x / 2 * 2);
        open(i, 0, v.size())
            v[i] /= g;
        return !solve(v);
    }
    return false;
}

int main()
{
    int n;
    vi v;
    cin >> n;
    int x;
    do(i, 1, n)
    {
        cin >> x;
        v.pb(x);
    }
    cout << (solve(v) ? "First\n" : "Second\n");
    return 0;
}

Measured memory_bytes: 10232
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define sd(n) scanf("%d",&n)
#define sl(n) scanf("%lld",&n)
#define pd(n) printf("%d",n)
#define pl(n) printf("%lld",n)
#define sf(n) scanf("%f",&n)
#define pf(n) printf("%.12f",n)
#define psp printf(" ")
#define endc printf("\n")

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;

//const int maxn = 2e5 + 7; 
//const int md = 1e9 + 7;

int main() {
    int a,b; cin>>a>>b;
	string s; cin>>s; s = " " + s;
	
	if (s[a + 1] != '-') { cout<<"No"<<endl; return 0; }
	for (int i = 1; i < s.size(); i++) {
	    if (i == a + 1) continue;
	    if (0 <= s[i] - '0' && s[i] - '0' <= 9) continue;
	    cout<<"No"<<endl; return 0;
    }
    cout<<"Yes"<<endl;
}

Measured memory_bytes: 256
#ifndef LOCAL
#pragma GCC optimize("O3")
#endif
#include "bits/stdc++.h"
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);
typedef long long ll;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set; 

int main(){
    fastio
    int a , b ; 
    cin >> a >> b ; 
    cout << max({a+b,a-b,a*b}) << endl;
    return 0 ;
}


Measured memory_bytes: 256
x1,y1,x2,y2= map(int,input().split())

x12 = x2 -x1
y12 = y2 -y1

x3 = x2-y12
y3 = y2+x12

x4 = x1-y12
y4 = y1+x12

print("{} {} {} {}".format(x3,y3,x4,y4))

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

//#define DEBUG
#ifdef DEBUG
#define debug(x) x
#else
#define debug(x)
#endif

struct Sakumotu
{
    int profit;
    double cost;
    std::string name;

    bool operator<(const Sakumotu &other) const {
        if (std::abs(cost - other.cost) < 1e-10) {
        //if (cost == other.cost) {
            return name < other.name;
        } else {
            return cost > other.cost;
        }
    }
};

int main() {
    int n;
    int p, a, b, c, d, e, f, s, m;
    while (std::cin >> n, n) {
        std::vector<Sakumotu> ss(n);
        for (int i = 0; i < n; ++i) {
            std::cin >> ss[i].name >> p >> a >> b >> c >> d >> e >> f >> s >> m;
            ss[i].profit = s * f * m - p;
            const int time = a + b + c + (d + e) * m;
            ss[i].cost = static_cast<double>(ss[i].profit) / time;
        }

        std::sort(ss.begin(), ss.end());

        for (auto& v : ss) {
            std::cout << v.name << debug(", profit: " << v.profit << ", cost: " << v.cost <<) std::endl;
        }
        std::cout << "#" << std::endl;
    }
    return 0;
}



Measured memory_bytes: 3208
#[allow(unused_imports)]
use itertools::Itertools;
#[allow(unused_imports)]
use num::Integer;
#[allow(unused_imports)]
use proconio::derive_readable;
use proconio::fastout;
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;
#[allow(unused_imports)]
use std::cmp;

#[fastout]
fn main() {
  input! {
    s: String,
  }

  println!("{}", if s == "ABC" { "ARC" } else { "ABC" });
}


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

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

    int n;
    string temp;
    cin >> n;
    set<string> s;

    while(n--){
        cin >> temp;
        s.insert(temp);
    }

    cout << s.size()<<endl;

    return 0;
}


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

#define int long long
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i < b; i++)
#define out(x) cout << x << endl
#define EPS (1e-7)
#define gearup 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<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<bool> > vvb;
typedef vector<vector<double> > vvd;
typedef vector<vector<string> > vvs;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};
//以降 cin の入力元が 'input.txt' になる
//std::ifstream in("input.txt");
//std::cin.rdbuf(in.rdbuf());

signed main()
{
    gearup;
    ll n,k; cin >> n >> k;
    vl a(n);
    rep(i,n)cin>>a[i];
    for(int i=k;i<n;i++){
        ll pre = a[i - k];
        if(pre > a[i])out("No");
        else if (pre == a[i])out("No");
        else out("Yes");
    }
}

Measured memory_bytes: 4756
package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

type Restaurant struct {
	Index int
	Point int
	Name  string
}

type Restaurants []Restaurant

func (r Restaurants) Len() int {
	return len(r)
}

func (r Restaurants) Less(i, j int) bool {
	if r[i].Name != r[j].Name {
		return r[i].Name < r[j].Name
	} else {
		return r[i].Point > r[j].Point
	}

}

func (r Restaurants) Swap(i, j int) {
	r[i], r[j] = r[j], r[i]
}

func main() {
	sc.Split(bufio.ScanWords)
	var n = nextInt()
	restaurants := make([]Restaurant, n)
	for i := 0; i < n; i++ {
		var r = Restaurant{}
		r.Index = i + 1
		r.Name = nextLine()
		r.Point = nextInt()
		restaurants[i] = r

	}
	sort.Sort(Restaurants(restaurants))

	for _, restaurant := range restaurants {
		fmt.Printf("%+v\n", restaurant.Index)
	}

}


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

for h in range(3501):
    for n in range(1,3501):
        a = 4*h*n - N*(h+n)
        if a>0:
            w = N*h*n / a
            if w==int(w):
                print("{} {} {}".format(int(w),n,h))
                exit()


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

int main()
{
	//freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
	ll n,m,ans=0;
	cin>>n>>m;
	if (2*n<=m){
		ans=n;
		m-=2*n;
		ans+=m/4;
	}
	else {
		ans=m/2;
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
input_line = str(input())

results = []
for i in range(len(input_line)-1):
    if input_line[i]=="?":
        if i==0:
            if input_line[i+1]=="D":
                results.append("P")
            elif input_line[i+1]=="P":
                results.append("D")
            elif input_line[i+1]=="?":
                results.append("P")
        else:
            if results[i-1]=="P":
                results.append("D")
            elif results[i-1]=="D" and input_line[i+1]=="D":
                results.append("P")
            elif results[i-1]=="D" and input_line[i+1]=="P":
                results.append("D")
            elif input_line[i+1]=="P":
                results.append("D")
            elif input_line[i+1]=="D":
                results.append("P")
            elif input_line[i+1]=="?":
                results.append("P")
    else:
        results.append(input_line[i])

if input_line[-1]=="P":
    results.append(input_line[-1])
elif input_line[-1]=="D":
    results.append(input_line[-1])
elif input_line[-1]=="?":
    results.append("D")

for s in results:
    print(s, end="")

Measured memory_bytes: 88132