akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
 
#define int long long
#define FOR(i, a, b) for (int i=(a); i<(b); ++i)
#define ROF(i, b, a) for (int i=(b); i>(a); --i)
#define CASET int _T; cin >> _T; FOR(caset, 0, _T)
#define vi vector<int>
#define vb vector<bool>
#define vs vector<string>
#define vvi vector<vi>
#define vvb vector<vb>
#define pii pair<int,int>
#define t3i tuple<int,int,int>
#define mii map<int,int>
#define vpii vector<pii>
#define vt3i vector<t3i>
#define sq(x) (x)*(x)
#define inv(x) powa(x, MOD-2)
 
long long INF = 1LL<<60;
long long MOD = 1e9+7;
 
template <typename A, typename B> istream &operator>>(istream &is, pair<A, B> &pr) {is >> pr.first >> pr.second; return is;}
template <typename A> istream &operator>>(istream &is, vector<A> &v) {for (auto &x : v) is >> x; return is;}
ostream &operator<<(ostream &os, char &c) {os << (char)c; return os;}
ostream &operator<<(ostream &os, const char s[]) {os << (string)s; return os;}
ostream &operator<<(ostream &os, string &s) {for (char &c : s) os << (char)c; return os;}
template <typename A, typename B> ostream &operator<<(ostream &os, pair<A, B> &pr) {os << '(' << pr.first << ", " << pr.second << ')'; return os;}
ostream &operator<<(ostream &os, vb &v) {
    bool first = true;
    os << '[';
    for (const bool &x : v) {
        if (!first) os << ", ";
        first = false;
        os << x;
    }
    os << ']';
    return os;
}
template <class C> ostream &operator<<(ostream &os, C &v) {
    bool first = true;
    os << '[';
    for (auto &x : v) {
        if (!first) os << ", ";
        first = false;
        os << x;
    }
    os << ']';
    return os;
}
int powa(int base, int exp) {
    int res = 1;
    while (exp) {
        if (exp&1) res = res*base % MOD;
        base = base*base % MOD;
        exp >>= 1;
    }
    return res;
}
bool mini(int &a, int b) { return b < a ? a = b, 1 : 0; }
bool maxi(int &a, int b) { return b > a ? a = b, 1 : 0; }

main() {
    ios::sync_with_stdio(0), cin.tie(0);
    
    string s;
    cin >> s;
    int n = s.size();

    vvi occ(26);
    FOR(i, 0, n) occ[s[i]-'a'].push_back(i);

    int res1 = -2, res2 = -2;
    FOR(c, 0, 26) {
        FOR(i, 1, occ[c].size()) if (occ[c][i] - occ[c][i-1] <= 2) {
            res1 = occ[c][i-1];
            res2 = occ[c][i];
        }
    }
    cout << res1+1 << ' ' << res2+1;
}

Measured memory_bytes: 1612
def dist(A, B):
    return ((A[0]-B[0])**2 + (A[1]-B[1])**2)**(0.5)

from math import factorial
from itertools import permutations
N = int(input())
XY = [list(map(int, input().split())) for _ in range(N)]
dists = 0
for l in permutations(XY):
    for i in range(len(l)-1):
        dists += dist(l[i], l[i+1])

print(dists/factorial(N))        

    

Measured memory_bytes: 3316
#include <bits/stdc++.h>
using i64 = long long;

int main() {
    i64 n, a, b;
    std::cin >> n >> a >> b;
    if (n - a < b - 1 || a * (b - 1) < n - a) {
        std::cout << -1 << std::endl;
        return 0;
    }

    std::deque<i64> q { a };
    if (b - 1) {
        for (int i = 0; i < (n - a) % (b - 1); i++) q.push_back((n - a) / (b - 1) + 1);
        for (int i = (n - a) % (b - 1); i < b - 1; i++) q.push_back((n - a) / (b - 1));
    }
    i64 s = 0;
    for (int i = 0; i < b; i++) {
        for (int j = 0; j < q[i]; j++) {
            std::cout << n - s - q[i] + 1 + j << " ";
        }
        s += q[i];
    }
    std::cout << std::endl;

    return 0;
}


Measured memory_bytes: 3584
#include <iostream>

using namespace std;
int main()
{
	int ans = 0;
	string a;
	cin >> a;
	for (int i = 0; i < a.size(); i++)
	{
		ans += a[i] - 48;
	}
	if (ans % 9 == 0)
	{
		cout << "Yes";
	}
	else cout << "No";
	return 0;
}


Measured memory_bytes: 3716
from fractions import gcd


n = int(input())
li_t = list()

for _ in range(n):
    li_t.append(int(input()))

# a * b = 最小公倍数 * 最大公約数


def lcm(a, b):
    return (a * b) // gcd(a, b)

work = 1

for t in li_t:
    work = lcm(work, t)

print(work)

Measured memory_bytes: 5588
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define pb push_back
#define mp make_pair
#define test long long int t; cin>>t; while(t-->0)
#define fIO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define loop(n) for(long long int i=0;i<n;i++)
using namespace std;
int main()
{
    fIO
    int n;
    cin>>n;
    int a[n+1]={0};
    
    loop(n-1)
    {
        int x;
    cin>>x;
    a[x]++;
    }
    for(int i=1;i<=n;i++)
    {
        cout<<a[i]<<" ";
    }
    return 0;
}
    

Measured memory_bytes: 4440
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    private static final int INF = (int) 1e9 + 5;

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        PrintWriter writer = new PrintWriter(System.out);
        solve(scanner, writer);
        scanner.close();
        writer.close();
    }

    private static final int MOD = (int) Math.pow(10, 9) + 7;
    public static void solve(Scanner scanner, PrintWriter writer) {
        int rows = scanner.nextInt();
        int columns = scanner.nextInt();

        char[][] m = new char[rows][];
        for (int i = 0; i < rows; i++) {
            m[i] = scanner.next().toCharArray();
        }

        // dp[i][j] denote number of paths to square (i,j)
        // dp[i][j] = dp[i-1][j] + dp[i][j-1] if m[i][j] is '.'
        // dp[i][j] = 0 if [i][j] is '#'
        // base case: dp[0][0] = 1;
        int[][] dp = new int[rows][];
        for (int i = 0; i < rows; i++) {
            dp[i] = new int[columns];
        }

        for (int i = 0; i < rows; i++) {
            for (int j = 0; j < columns; j++) {
                if (i == 0 && j == 0) {
                    dp[i][j] = 1;
                } else if (m[i][j] == '#') {
                    dp[i][j] = 0;
                } else if (i - 1 < 0) {
                    dp[i][j] = dp[i][j - 1];
                } else if (j - 1 < 0) {
                    dp[i][j] = dp[i - 1][j];
                } else {
                    dp[i][j] = dp[i - 1][j] + dp[i][j - 1];
                    dp[i][j] %= MOD;
                }
            }
        }

        //for (int i = 0; i < rows; i++) {
        //    writer.println(Arrays.toString(dp[i]));
        //}

        int ans = dp[rows-1][columns-1];

        writer.println(ans);
    }
}


Measured memory_bytes: 37352
#include<stdio.h>
#include<stdlib.h>
#define NIL NULL

struct node{
  int key;
  struct node *r;
  struct node *l;
  struct node *p;
};

typedef struct node * Node;

Node root;

void insert(int v){
  Node y=NIL;
  Node x=root;
  Node z;

  z=malloc(sizeof(struct node));
  z->key=v;
  z->l=NIL;
  z->r=NIL;

  while(x!=NIL){
    y=x;

    if(z->key < x->key) x=x->l;
    else x=x->r;
  }

    z->p=y;

    if(y==NIL) root=z;
    else if(z->key < y->key) y->l=z;
    else y->r=z;
}

void inorder(Node u){
  if(u!=NIL){
    inorder(u->l);
    printf(" %d",u->key);
    inorder(u->r);
  }
}

void preorder(Node u){
  if(u!=NIL){
    printf(" %d",u->key);
    preorder(u->l);
    preorder(u->r);
  }
}

Node find(Node a,int k){
  if (a==NIL || k==a->key) return a;
  if(k < a->key) return find(a->l,k);
  else return find(a->r,k);
}

Node Min(Node a){
  while(a->l!=NIL){
    a=a->l;
  }
  return a;
}

Node suc(Node a){
  if(a->r!=NIL) return Min(a->r);
  Node y=a->p;
  while(y!=NIL && a==y->r){
    a=y;
    y=y->p;
  }
  return y;
}

void delete(Node a){
  Node y;
  Node x;

  if(a->l==NIL || a->r==NIL) y=a;
  else y=suc(a);

  if(y->l!=NIL) x=y->l;
  else x=y->r;

  if (x!=NIL) x->p=y->p;

  if(y->p==NIL) root=x;
  else if(y==y->p->l) y->p->l=x;
  else y->p->r=x;

  if(y!=a) a->key=y->key;
}


int main(){
  int n,i,x;
  char com[20];

  scanf("%d",&n);

  for(i=0;i<n;i++){
    scanf("%s",com);

  if(com[0]=='i'){
    scanf("%d",&x);
    insert(x);
  }
  else if(com[0]=='p'){
    inorder(root);
    printf("\n");
    preorder(root);
    printf("\n");
  }
  else if(com[0]=='f'){
    scanf("%d",&x);
    Node s=find(root,x);
    if(s!=NIL) printf("yes\n");
    else printf("no\n");
  }
  else if(com[0]=='d'){
    scanf("%d",&x);
    delete(find(root,x));
  }
  }
  return 0;
}

Measured memory_bytes: 19364
import sys

a, b = map(int, sys.stdin.readline().split())

def strongness(x):
    return (x + 11) % 13

def main():
    sa = strongness(a)
    sb = strongness(b)
    if sa == sb:
        return 'Draw'
    elif sa > sb:
        return 'Alice'
    else:
        return 'Bob'
    

if __name__ == '__main__':
    ans = main()
    print(ans)

Measured memory_bytes: 3060
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
typedef  long long ll;
double pi=3.1415926535898;
//double pi=acos(-1.0);
#define speed      ios::sync_with_stdio(false);cin.tie(NULL); cout.tie(NULL);
#define rng(i,a,b) for(int i=a;i>=int(b);i--)
#define rep(i,a,b) for(int i=a;i<=int(b);++i)
#define lop(i,n)   for(int i=0;i<int(n);i++)
#define ms(x,a)    memset(x,a,sizeof(x))
#define all(x)     (x).begin(),(x).end()
#define sz(x)      int(x.size())
#define pb         push_back
#define r0         return 0;
#define CC         continue;
#define bb(x)      cerr<< x <<endl;
#define pii        pair<int,int>
#define pis        pair<int,string>
#define vi         vector<int>
#define F          first
#define S          second
//#define max(a,b) a<b?b:a  __builtin_popcount;
//#define min(a,b) a<b?a:b
//freopen("output.txt","w",stdout),freopen("input.txt","r",stdin);
const ll M  = 1e9+7 ;
const int N = 50500;
const int inf = INT_MAX;
const double eps = 1e-6;
//////////////////////    Hi    ^_^  hack me if you can :P

int main()
{
    ll x,y,ans;
    cin >>x ;

    if (x<=6LL)
    {
        cout<<1;
        r0;
    }
    x-=6LL;
    ans ++;

    if (x<=5LL)
    {
        cout<<2;
        r0;
    }
    x-=5LL;
    ans ++;

    y = x / 11LL ;

    ans += y*2LL ;

    x = x -  (y)*11LL;
    if (x==0LL){
        cout<<ans;
        r0;
    }
    if (x<=6LL) ans++;
    else
        ans +=2LL;

    cout<<ans;
    r0;
}

/*



https://ideone.com/goT6Vy//http:
codeforces.com/problemset/problem/466/D

, vector < pair <int,int > >, greater <pair <int, int> >
http://codeforces.com/contest/295/submission/17929453
freopen("output.txt","w",stdout);
freopen("input.txt","r",stdin);

ll pwmod(ll a, ll n, ll mod)
{
    ll ret = 1;
    while (n)
    {
        if (n & 1) ret = ret * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return ret;
}

for (int i=0; i<n; i++)            Hi    ^_^  hack me if you can :P

int mx[]= {0,0,1,-1, 1,1,-1,-1};
int my[]= {1,-1,0,0, 1,-1,1,-1};
bool inside (int i,int j){return (i>=0 && i<n && j>=0 && j<m);}

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

void gcd(LL n,LL m,LL &d,LL &xx,LL &yy)
{
    if(!m)
    {
        d=n;
        xx=1;
        yy=0;
    }
    else
    {
        gcd(m,n%m,d,yy,xx);
        yy-=xx*(n/m);
    }
}

int getm(int l,int r)
{
    if(l>r)
        return N;
    if(l==r)
        return 0;
    if(l==r-1)
        return s[l] != s[r];
    if(s[l]==s[r])
        return getm(l+1,r-1);
    else
        return 1+min(getm(l+1,r),getm(l,r-1));
}

int BIT[si], a[si], n;
void update(int x, int delta)
{
    for(; x <= N; x += x&-x)
        BIT[x] += delta;
}
int query(int x)
{
    int sum = 0;
    for(; x > 0; x -= x&-x)
        sum += BIT[x];
    return sum;
}

#define sc(x)      scanf("%d",&x)
#define scl(x)     scanf("%lld",&x)
#define pr(x)      printf("%d ",x)
#define prl(x)     printf("%lld ",x)
#define prln(x)    printf("%d\n",x)
#define prlln(x)   printf("%lld\n",x)
#define scd(x)     scanf("%lf",&x)
#define prd(x)     printf("%.10f\n",x)


*/


Measured memory_bytes: 256
#include <stdio.h>  
int main()
{
	int r, c, i, j; 
	int hyou[101][101] = {0};
	
	scanf("%d %d", &r, &c);
	
	for(i=0; i<r; i++)
	{
		for(j=0; j<c; j++) 
		{
			scanf("%d",&hyou[i][j]);
		}
	} 
	
	for (i=0; i<r; i++)
	{
		for (j=0; j<c; j++)
		{
			hyou[i][c] += hyou[i][j]; 
		}
	}
	
	for (j=0; j<c+1; j++)
	{
		for (i=0; i<r; i++)
		{
			hyou[r][j] += hyou[i][j];
		}
	}
	
	for (i=0; i<r+1; i++)
	{
		for (j=0; j<c; j++) 
		{
			printf("%d ",hyou[i][j]);
		}
		
		printf("%d\n",hyou[i][c]); 
	}
	return 0;
}

Measured memory_bytes: 648
#include<iostream>
#include<cmath>
#include<utility>
#include<vector>
using namespace std;
vector<long int>ax;
vector<pair<long int,long int>>bx;
int main()
{
    ax.push_back(0);
    bx.push_back(make_pair(0,0));
for(long int i=0;i<200;i++)
{
    for(long int j=0;j<=i;j++)
    {
        long long int x=i*i*i*i*i;
        long long int y=j*j*j*j*j;
        if(x-y<1000000003 && x-y>=0)
        {ax.push_back(x-y);
                bx.push_back(make_pair(i,j));
        }
        if(y-x<1000000003 && y-x>=0)
        {
        ax.push_back(y-x);
         bx.push_back(make_pair(-i,-j));
        }
        if(y+x<1000000003 && y+x>=0)
        {ax.push_back(x+y);
         bx.push_back(make_pair(i,-j));
        }
        if(-y-x<1000000003 && -y-x>=0)
       { ax.push_back(-x-y);
         bx.push_back(make_pair(-i,j));
        }
    }
    
}
int take;
    cin>>take;
    for(int i=0;i<ax.size();i++)
    {
         
        if(ax[i]==take)
        {
           cout<<bx[i].first<<" "<<bx[i].second;
            break;
        }
    }

 return 0; 
}

Measured memory_bytes: 3736
// failed to generate code

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

struct UnionFind {
  vector<int> data;
  UnionFind(int size) : data(size, -1) { }
  bool unionSet(int x, int y) {
    x = root(x); y = root(y);
    if (x != y) {
      if (data[y] < data[x]) swap(x, y);
      data[x] += data[y]; data[y] = x;
    }
    return x != y;
  }
  bool findSet(int x, int y) {
    return root(x) == root(y);
  }
  int root(int x) {
    return data[x] < 0 ? x : data[x] = root(data[x]);
  }
  int size(int x) {
    return -data[root(x)];
  }
};

int main(){	
	ios::sync_with_stdio(false);
	int N,M;
	cin >> N >> M;
	UnionFind uf(N+M);
	for(int i = 0 ; i < N ; i++){
		int K;
		cin >> K;
		for(int j = 0 ; j < K ; j++){
			int x;
			cin >> x;
			--x;
			uf.unionSet(i,N+x);
		}
	}
	for(int i = 0 ; i < N ; i++){
		if( uf.root(i) != uf.root(0) ){
			cout << "NO" << endl;
			return 0;
		}
	}
	cout << "YES" << endl;
	
}


Measured memory_bytes: 1024
#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 DEBUG 0
#define mp(a,b) make_pair(a,b)

const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main(){

	COMinit();

	lli n;
	cin>>n;
	vector<lli> x(n+1);
	lli flag[100100]={0};

	lli left,right;

	REP(i,0,n+1){
		cin>>x[i];
		if(flag[x[i]]){
			left = flag[x[i]];
			right = i+1;
		}
		flag[x[i]] = i+1;
	}

	lli out = (left - 1) + (n+1 - right);

	for(lli i=1;i<=n+1;i++){
		lli ans = COM(n+1,i) + MOD;
		ans -= COM(out,i-1);
		ans %= MOD;
		cout<<ans<<endl;
	}

	return 0;
}

Measured memory_bytes: 14720
#include <stdio.h>
#define black 1
#define white 0
#define BIG 2000000000

int n,c[100][100], A[100], color[100];

void Keiro() {
    int i, min, u, v;
    
    for (i = 0; i < n; ++i) {
        color[i]  = white;
        A[i] = BIG;
    }
    
    A[0] = 0;
    
    while(1) {
        min = BIG;
        
        u = -1;
        for(i = 0; i < n; i++) {
            if (min > A[i] && color[i] != black) {
                min = A[i];
                u = i;
            }
        }
        if (u == -1) break;
        
        color[u] = black;
        for (v = 0; v < n; ++v) {
            if (color[v] != black && c[u][v] != BIG) {
                if (A[v] > A[u] + c[u][v]) {
                    A[v] = A[u] + c[u][v];
                }
            }
        }
        
    }
    
}
int main() {
    int i, j, k, a, b;
    scanf("%d", &n);
    
    for (i = 0; i < n; ++i){
        for (j = 0; j < n; ++j) {
            c[i][j] = BIG;

        }
    }
    for (i = 0; i < n; ++i) {
        scanf("%d %d", &a, &k);
        for (j = 0; j < k; ++j) {
            scanf("%d %d", &a, &b);
            c[i][a] = b;
        }
    }
    Keiro();
    
    for (i = 0; i < n; ++i) {
        printf("%d %d\n", i, A[i]);
    }

    return 0;
}

Measured memory_bytes: 1816
#include <stdio.h>

int main(void) {
  int a, b, c;

  scanf("%d %d %d", &a, &b, &c);

  if(a == 7) {
    if(b == 5 && c == 5) {
      printf("YES\n");
      return 0;
    }
  }
  else if(b == 7) {
    if(a == 5 && c == 5) {
      printf("YES\n");
      return 0;
    }
  }
  else if(c == 7) {
    if(b == 5 && a == 5) {
      printf("YES\n");
      return 0;
    }
  }
  printf("NO\n");
  return 0;
}

Measured memory_bytes: 128
#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>
#include<time.h>
#include<bitset>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
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);}
int p[210000];
int main(){
	int a;scanf("%d",&a);
	for(int i=0;i<a;i++)scanf("%d",p+i);
	long long cur=0;
	long long sum=0;
	for(int i=0;i<a;i++)sum+=p[i];
	long long ret=inf;
	for(int i=0;i<a-1;i++){
		cur+=p[i];
		ret=min(ret,ABS(sum-cur-cur));
	}
	printf("%lld\n",ret);
}


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

static const int N = 100;

int main() {
    int n, p[N+1], m[N+1][N+1];
    cin >> n;
    for (int i = 1; i <= n; i++) {
        cin >> p[i-1] >> p[i];
    }

    for (int i = 1; i <= n; i++) m[i][i] = 0;
    for (int l = 2; l <= n; l++) {
        for (int i = 1 ; i <= n - l + 1; i++) {
            int j = i + l - 1;
            m[i][j] = (1 << 21);
            for (int k = i; k <= j -1 ; k++) {
                m[i][j] = min(m[i][j], m[i][k] + m[k+1][j] + p[i-1] * p[k] * p[j]);
            }
        }
    }

    cout << m[1][n] << endl;

    return 0;
}


Measured memory_bytes: 3120
/* ex3_2
   moka223711 */

#include <stdio.h>

int main(void){
	int Num;
	// 入力Nを受け取る
	scanf("%d", &Num);

	// Num % 10で1の位を取得する
	// switch文で各値に対してNum本の本の読み方を出力する
	switch(Num % 10){
		case 2: case 4: case 5: case 7: case 9:
			printf("hon");
			break;
		case 0: case 1: case 6: case 8:
			printf("pon");
			break;
		default:
			printf("bon");
	}

	return 0;
}


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

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

template<class T> inline T sqr(T x) {return x*x;}

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef long long ll;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int INT_INF = 2147483647;
const long long LL_INF = 1LL<<60;
const long long MOD = 1000000007;

#define CLR(a) memset((a), 0 ,sizeof(a))

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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

int main(void){
    int N,C; cin >> N >> C;
    int D[C][C]; REP(i,C)REP(j,C) cin >> D[i][j];
    int c[N][N];
    REP(i,N)REP(j,N){
        int cc; cin >> cc; cc--;
        c[i][j] = cc;
    }

    int num[3][C];
    REP(i,3)REP(j,C) num[i][j] = 0;
    REP(i,N)REP(j,N) num[(i+j)%3][c[i][j]]++;

    int ans = INT_INF;
    REP(i,C)REP(j,C)REP(k,C){
        if(i==j || j==k || k==i) continue;
        int tmp = 0;
        REP(t,C) tmp += num[0][t]*D[t][i];
        REP(t,C) tmp += num[1][t]*D[t][j];
        REP(t,C) tmp += num[2][t]*D[t][k];
        chmin(ans, tmp);
    }
    cout << ans << endl;
    return 0;
}

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

#define fi first
#define se second
#define pb push_back
#define mod(n,k) ( ( ((n) % (k)) + (k) ) % (k))
#define forn(i,a,b) for(int i = a; i < b; i++)
#define forr(i,a,b) for(int i = a; i >= b; i--)
#define all(x) (x).begin(), (x).end()

typedef long long ll;
typedef long double ld;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

const int maxn = 10;
char A[maxn][maxn];

int main(){
	ios_base::sync_with_stdio(0); cin.tie(0);
	int N,M,K; cin >> N >> M >> K;
	forn(i,0,N)forn(j,0,M)cin >> A[i][j];
	int res = 0;
	forn(mr,0,(1<<N)){
		forn(mc,0,(1<<M)){
			int cnt = 0;
			forn(i,0,N){
				forn(j,0,M){
					if(mr&(1<<i))continue;
					if(mc&(1<<j))continue;
					if(A[i][j] == '#')cnt++;
				}
			}
			if(cnt == K)res++;
		}
	}
	cout << res << '\n';
	return 0;
}
/*
__builtin_mul_overflow(x,y,&x)
-fsplit-stack
*/


Measured memory_bytes: 3616
int main(int argc, const char * argv[]) {
    int x=0,y=0,N,sum=0;
    
    scanf("%d\n",&N);
    
    if(N>=15){
        y = 200*(N/15);
    }
    
    x =800*N;
    
    sum = x-y;
    printf("%d", sum);
    return 0;
}


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

int main(){
  int k, n;
  int a[200005];
  cin >> k >> n;

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

  int mx=0;
  for(int i=1;i<n;i++){
    mx=max(mx, a[i]-a[i-1]);
  }
  
  mx=max(mx, a[0]+k-a[n-1]);
  
  cout << k-mx << endl;
  return 0;
}


Measured memory_bytes: 1024
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		Integer day = sc.nextInt();
      	int minus = 25;
      	System.out.print("Christmas");
      	for(int i = 0; i < (minus - day); i++){
          System.out.print(" Eve");
        }
      	System.out.println("");
	}
}

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

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 (a>b) { a=b; return 1; } return 0; }

#define ld long double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

#define INF LONG_LONG_MAX

//-------------------------------------------------

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,k; cin>>n>>k;
    vll x(n),y(n);
    rep(i,n) cin>>x[i]>>y[i];
    vll sx, sy;
    sx = x, sy = y;
    sort(all(sx));
    sort(all(sy));
    ll ans=INF;
    rep(a,n)rep(b,n)rep(c,n)rep(d,n){
        if (a>b || c>d) continue;
        int cnt=0;
        rep(i,n)if(sx[a]<=x[i]&&x[i]<=sx[b]&&sy[c]<=y[i]&&y[i]<=sy[d]){
            cnt++;
        }
        if (cnt>=k) chmin(ans,(sx[b]-sx[a])*(sy[d]-sy[c]));
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
N,A,B = map(int,input().split())
h = [int(input()) for _ in range(N)]

left = 1
right = max(h)
import math
def judge(x):
    cnt = 0
    tmp = 0
    for i in range(N):
        tmp = h[i] - B * x
        if tmp > 0:
            cnt += math.ceil(tmp/(A-B))
    if cnt <= x:
        return True
    else:
        return False
    
def binary(left,right):
    c = (left + right)//2
    if left >= right:
        for i in range(3):
            idx = left -1 + i
            if judge(idx):
                return (idx)
    if judge(c):
        right = c -1
        return binary(left,right)
    else:
        left = c + 1
        return binary(left,right)
    
    
ans = binary(left,right)
print(ans)
    


Measured memory_bytes: 7128
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <set>
#include <numeric>
#include <cmath>

using namespace std;

typedef long long int lld;

const lld mod = 1e9+7;
const lld INF = 1e9;
//const lld MAXN = 1e9;

int main()
{
    lld n,y;

    cin >> n >> y;

    y /= 1000;

    lld dama = y - n;

    lld man = 0, go = 0, sen = 0;

    for(int i = 0; i <= dama / 4 + 1 ; i++)
    {
        //cout << dama << endl;
        if (dama % 9 == 0)
        {
            man = dama / 9;
            go = i;
            sen = n - man - go;

            if (man + sen + go == n && sen >= 0)
            {
                cout << man << " " <<  go << " " <<  sen << endl;
                return 0;
            }
        }

        dama -= 4;
    }

    dama = y - n;

    for(int i = 0; i <= dama / 9 + 1 ; i++)
    {
        //cout << dama << endl;
        if (dama % 4 == 0)
        {
            go = dama / 4;
            man = i;
            sen = n - man - go;

            if (man + sen + go == n && sen >= 0)
            {
                cout << man << " " <<  go << " " <<  sen << endl;
                return 0;
            }
        }

        dama -= 9;
    }

    cout << -1 << " " <<  -1 << " " <<  -1 << endl;


    return 0;
}

Measured memory_bytes: 256
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop

import collections

h,w = map(int,input().split())
li = ["."*(w+2)]
for i in range(h):
    in_data = input()
    data = "." + in_data + "."
    li.append(data)
li.append("."*(w+2))

for i in range(1,h):
    for j in range(1,w):
        if li[i][j] == ".":
            continue
        if li[i-1][j] == "." and li[i+1][j] == "." and li[i][j-1] == "." and li[i][j+1] == ".":
            print("No")
            sys.exit()
print("Yes")


Measured memory_bytes: 3316
import itertools
n = int(input())
p = tuple(((map(int,input().split()))))
q = tuple(((map(int,input().split()))))

num = []
for i in range(1,n+1):
    num.append(i)
ans = []
for i in itertools.permutations(num,n):
    ans.append(i)

print(abs(ans.index(p)-ans.index(q)))

Measured memory_bytes: 7924
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key

typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    int a,b;
    cin>>a>>b;
    if(a+b>=10){
        cout<<"error"<<endl;
    }
    else{
        cout<<a+b<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
  int a, b, c;
  cin >> a >> b >> c;
  if(a == b && a == c){
    cout << "No";
    return 0;
  }
  if(a == b || a == c || b == c){
    cout << "Yes";
    return 0;
  }
  cout << "No";
}

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

using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0;i<(int)(n);i++)

int main(){
    int n,wei;
    int v[105]={};
    int w[105]={};
    cin>>n>>wei;
    REP(i,n)cin>>v[i]>>w[i];
    
    int mat[105][10005]={};
    REP(i,105)REP(j,10005)mat[i][j]=1LL<<30;
    mat[0][0]=0;
    REP(i,n){
        REP(j,10005){
            if(mat[i][j]!=1LL<<30){
                mat[i+1][j]=min(mat[i+1][j], mat[i][j]);
                if(j+v[i]<10005){
                    if(mat[i][j]+w[i]<=wei)mat[i+1][j+v[i]] = min(mat[i+1][j+v[i]], mat[i][j]+w[i]);
                }
            }
        }
    }
    ll maxval=-1;
    REP(i,n+1)REP(j,10005)if(mat[i][j]!=1LL<<30 && maxval<j)maxval=j;
    cout<<maxval<<endl;
    /*REP(i,n+1){
        REP(j,30) cout<<mat[i][j]<<" ";
        cout<<endl;
    }*/
}


Measured memory_bytes: 7216
#include <bits/stdc++.h>
using namespace std;
typedef long long lint;
typedef pair<int,int> P;
const int    INF=(int)1e9;
const int    MOD=(int)1e9+7;
const double EPS=(double)1e-10;
struct Accelerate_Cin{
    Accelerate_Cin(){
        cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);
    };
};

int N;
vector<int>v;

int main(){
  cin>>N;
  for(int t=1;t<=N;t++){
    int temp;
    cin>>temp;
    temp--;
    v.push_back(temp);
  }

  int now=0,cont=0;
  while(true){
    if(now==1){
      cout<<cont<<"\n";
      return 0;
    }
    if(cont>N){
      cout<<"-1"<<"\n";
      return 0;
    }
    cont++;
    now=v[now];
  }
}


Measured memory_bytes: 892
#include <cassert>
#include <iostream>

using namespace std;

const int pows[] = {1, 10, 100, 1000, 10000, 100000, 1000000,
                    10000000, 100000000, 1000000000};

const int MOD = 1000000007;
const int THRESHOLD = 8;

int main() {
    ios::sync_with_stdio(false);

    int S;
    cin >> S;

    int start = 1, end = 2;
    int s_idx = 1, e_idx = 1;
    
    long long sum = 1;
    long long ans = 0;
    
    while (start < pows[THRESHOLD-1]) {
        while (sum < S) {
            sum += e_idx;
            end++;
            if (end == pows[e_idx])
                e_idx++;
        }
        
        if (sum == S)
            ans++;
        
        sum -= s_idx;
        start++;
        if (start == pows[s_idx])
            s_idx++;
    }

    long long num = 9LL * pows[THRESHOLD-1];
    
    for (int digits = THRESHOLD; digits <= S; digits++) {
        // All f(x) = digits

        if (S % digits == 0) {
            int select = S/digits;
            ans += num - select + 1;
            ans = (ans % MOD + MOD) % MOD;
        }        
        num = num * 10 % MOD;

        // Some f(x) = digits and some f(x) = digits+1
        // k * digits + l * (digits+1) = S
        // => k = (S - l * (digits+1)) / digits
        
        int ell = S % digits;
        if (ell == 0)
            ell = digits;
        
        long long val = S - (long long)ell*(digits+1);
        assert(val % digits == 0);

        if (val > 0) {
            ans += 1 + (val-1)/(digits*(long long)(digits+1));
            if (ans >= MOD)
                ans -= MOD;
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#ifdef _LOCAL //
#define dout cout
#define debug() if (true)
#define dvout(v) vout(v)
#else
#define dout   \
	if (false) \
	cout
#define debug() if (false)
#define dvout(v) if(false) vout(v)
#endif //
#define next asdnext
#define prev asdprev
#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define vrep(i, v) for (auto &i : v)
#define all(x) (x).begin(), (x).end()
#define vout(v)           \
	for (auto &i : v)     \
	{                     \
		cout << i << " "; \
	}                     \
	cout << "\n"; //配列出力
#define vin(v)        \
	for (auto &i : v) \
		cin >> i; //配列入力
#define vecin(v,n)	\
	vec(v,n);		\
	vin(v);
#define vec(v, n) vector<int> v(n, 0);
#define mod (int)(1e9+7)
typedef long long ll;
typedef unsigned long long ull;
#define _n "\n"
#define _n2 "\n\n"
#define _t "\t"



void Main()
{
	int N;
	cin>>N;
	vec(A, N);
	vin(A);
	int ans = 0;
	int _max=0;
	rep(i,N){
		_max=max(_max, A[i]);
	}
	vector<int> flag(_max+1,0); 

	rep(i,N){
		for(int j=A[i];j<=_max; j+=A[i])flag[j]++;
	}

	rep(i,N){
		dout<<A[i]<<" "<<flag[A[i]]<<_t;
		if(flag[A[i]]<=1)ans++;
	}
	dout<<_n2;
	cout<<ans<<endl;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << std::fixed << std::setprecision(15);
	Main();
	return 0;
}


Measured memory_bytes: 7916
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,-1,sizeof(x))
const int INF = 1000000001;

int main(){
  string s;
  cin >> s;
  cout << 700 + 100*count(all(s),'o') <<endl;
}

Measured memory_bytes: 256
from collections import defaultdict
N, K = map(int, input().split())
A = [int(i) for i in input().split()]
D = defaultdict(int)

for i in range(N):
    D[A[i]] += 1

over = max(0, len(D) - K)
Dkey = sorted(D.items(), key = lambda x:x[1])

change = 0
current = 0
while over > 0:
    change += Dkey[current][1]
    over -= 1
    current += 1
print(change)

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

vector<int> conn[200000];
int p[200000];

int stamp[200000];

void dfs(int u, int t) 
{
    stamp[u] = t;
    for (int& v: conn[u]) {
        if (!stamp[v]) {
            dfs(v, t);
        }
    }
}

int main()
{
    int n, m;
    cin >> n >> m;

    for (int i = 1; i <= n; i++) {
        cin >> p[i];
    }

    while (m--) {
        int x, y;
        cin >> x >> y;

        conn[x].push_back(y);
        conn[y].push_back(x);
    }

    for (int i = 1, t = 1; i <= n; i++) {
        if (!stamp[i]) {
            dfs(i, t++);
        }
    }

    int mx = 0;
    for (int i = 1; i <= n; i++) {
        if (stamp[i] == stamp[p[i]]) {
            mx++;
        }
    }
    cout << mx << '\n';

}


Measured memory_bytes: 10880
def c():
    li = list(input())
    syms = ['+', '-']
    calc = li[0]
    for i in range(2):
        i_calc = calc
        calc += syms[i] + li[1]
        for j in range(2):
            j_calc = calc
            calc += syms[j] + li[2]
            for k in range(2):
                k_calc = calc
                calc += syms[k] + li[3]
                res = eval(calc)
                if res == 7:
                    print(calc+"=7")
                    return
                calc = k_calc
            calc = j_calc
        calc = i_calc


if __name__ == '__main__':
    c()


Measured memory_bytes: 38256
#include<bits/stdc++.h>
 
#define rep(i,n) for(ll i = 0;i < n;++i)
#define all(v) v.begin(),v.end()
using namespace std;
using ll = long long;
typedef pair<int,int> P;
 
const int INF = 1001001001;
const long double PI = (acos(-1));
const int mod = 1e9+7;
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};


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

    int n;
    cin >> n;
    vector<int> t(n+1);
    vector<int> x(n+1);
    vector<int> y(n+1);
    rep(i,n){
        cin >> t[i+1] >> x[i+1] >> y[i+1];
    }
    x[0] = y[0] = t[0] = 0;
    int dx,dy,dt;
    rep(i,n){
        dx = abs(x[i+1] - x[i]);
        dy = abs(y[i+1] - y[i]);
        dt = abs(t[i+1] - t[i]);
        if((dx+dy) % 2 != dt%2) {
            cout << "No" << endl;
            return 0;
        }
        if(dt < dx+dy) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;


    cout << endl;
    return 0;
}


Measured memory_bytes: 1408
//
//  main.cpp
//  AtCoderABC176
//
//  Created by Glen Cahilly on 9/2/20.
//  Copyright © 2020 Glen Cahilly. All rights reserved.
//

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

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    long double n, x, t;
    cin >> n >> x >> t;
    if (x==0) {
        cout << 0 << "\n";
    } else {
        long k = ceil(n/x)*t;
        cout << k << "\n";
        
    }
}


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

int main(){
    int H,W;
    cin>>H>>W;
    string dots(W,'.');
    vector<string> ans;
    for(int i=0;i<H;i++){
        string x;
        cin>>x;
        if(x!=dots) ans.push_back(x);
    }

    H=ans.size();
    //for(int i=0;i<H;i++) cout<<ans.at(i)<<endl;
    //cout<<H;
    vector<bool> y(W,false);
    for(int i=0;i<W;i++){
        for(int j=0;j<H;j++){
            if(ans.at(j).at(i)=='#') y.at(i)=true;
        }
    }
    //for(int i=0;i<W;i++) cout<<y.at(i)<<' ';

    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            if (y.at(j)) cout<<ans.at(i).at(j);
        }
        cout<<endl;
    }
}

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

bool is_palindrome(string str) {
    int head = 0;
    int tail = (int)str.size() - 1;
    while (head <= tail) {
        if (str[head] != str[tail]) {
            return false;
        }
        head++;
        tail--;
    }
    return true;
}

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

    string s;
    cin >> s;

    int n = s.size() / 2;

    string first = s.substr(0, n);
    string second = s.substr(n + 1);
    // cout << first << endl;
    // cout << second << endl;
    bool str_good = is_palindrome(s);
    bool first_good = is_palindrome(first);
    bool second_good = is_palindrome(second);

    if (str_good == true && first_good == true && second_good == true) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(shoki,i,n) for(int i=shoki; i<n; i++)
#define _GLIBCXX_DEBUG
using ll = long long;
using vi = vector<int>;
using vs = vector<string>;
using vvi = vector<vector<int>>;

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


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <math.h>
using namespace std;

int main()
{
	int64_t n, d;
	cin >> n >> d;

	vector<int64_t> x(n);
	vector<int64_t> y(n);
	for (int i = 0; i < n; i++)
	{
		cin >> x[i] >> y[i];
	}

	int count = 0;

	for (int i = 0; i < n; i++)
	{
		if (x[i] * x[i] + y[i] * y[i] <=  d * d)
		{
			count++;
		}
	}

	cout << count << endl;

	return 0;
}

Measured memory_bytes: 6420
N,M = map(int,input().split())
list = []
for _ in range(N):
  a,b = map(int,input().split())
  list.append([a,b])
list.sort()
ans = 0
for a,b in list:
  ans += min(b,M)*a
  M = max(0,M-b)
print(ans)

Measured memory_bytes: 24236
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(in) in.begin(),in.end()
#define fi first
#define se second
using namespace std;

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; }

using ll = long long;
using pp = pair<pair<ll,ll>,ll>;

const ll MAX = 200200, MOD = 1000000007;
ll fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

ll COM(int n, int k){
    if (n < 0 || k < 0 || n < k) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
ll COM2(int x, int y){ return COM(x+y, y); }

int main(){
    int h, w, n; cin >> h >> w >> n;
    vector<pair<ll,ll>> data(n+1);
    rep(i,n) cin >> data[i].fi >> data[i].se, data[i].fi--, data[i].se--;
    data[n] = make_pair(h-1,w-1);
    sort(all(data));
  
  COMinit();

    vector<ll> dp(n+1,0);
    rep(i,n+1){
        dp[i] = COM2(data[i].fi, data[i].se);
        rep(j,i){
            int dx = data[i].fi - data[j].fi;
            int dy = data[i].se - data[j].se;
            if(dx >= 0 && dy >= 0) dp[i] = (dp[i] - dp[j]*COM2(dx, dy)%MOD + MOD) % MOD;
        }
    }
    cout << dp[n] << endl;
    return 0;
}

Measured memory_bytes: 8380
#include <iostream>
    #include <vector>
    #include <algorithm>
    #include <queue>
     
    int main()
    {
        using namespace std;
        int32_t N;
        cin >> N;
     
        vector<int32_t> X1(N), X2(N);
        for (auto j=0; j < N; ++j) {
            int32_t n;
            cin >> n;
            X1[j] = X2[j] = n;
        }
        
        int32_t half = N / 2;
        
        sort(X1.begin(), X1.end());
        int32_t left=X1[half-1], right=X1[half];
        
        for (auto j = 0; j < N; j++) {
            if (X2[j] < right) {
                cout << right << endl;
            } else {
                cout << left << endl;
            }
        }
        
    }

Measured memory_bytes: 3712
#include<stdio.h>
typedef struct Dice{int t,s,e,w,n,b;}dice;

void koro(dice *d,char *h){
	dice dbuf;
	dbuf.t=d->t;dbuf.s=d->s;dbuf.e=d->e;dbuf.w=d->w;dbuf.n=d->n;dbuf.b=d->b;
	switch(*h){
		case 'S':
			d->t=dbuf.n;
			d->s=dbuf.t;
			d->e=dbuf.e;
			d->w=dbuf.w;
			d->n=dbuf.b;
			d->b=dbuf.s;
			break;
		case 'E':
			d->t=dbuf.w;
			d->s=dbuf.s;
			d->e=dbuf.t;
			d->w=dbuf.b;
			d->n=dbuf.n;
			d->b=dbuf.e;
			break;
		case 'W':
			d->t=dbuf.e;
			d->s=dbuf.s;
			d->e=dbuf.b;
			d->w=dbuf.t;
			d->n=dbuf.n;
			d->b=dbuf.w;
			break;
		case 'N':
			d->t=dbuf.s;
			d->s=dbuf.b;
			d->e=dbuf.e;
			d->w=dbuf.w;
			d->n=dbuf.t;
			d->b=dbuf.n;
			break;
	}
}

int main(void){
	dice di;
	int i,dice[7];
	char hoko[101]={NULL};
	for(i=0;i<6;i++)scanf("%d",&dice[i]);
	di.t=dice[0];di.s=dice[1];di.e=dice[2];di.w=dice[3];di.n=dice[4];di.b=dice[5];
	scanf("%s",hoko);
	for(i=0;(int)hoko[i];i++) koro(&di,&hoko[i]);
	printf("%d\n",di.t);
	return 0;
}

Measured memory_bytes: 596
import sys

sys.setrecursionlimit(1000000)
n=int(input())
mat=[[] for i in range(n)]
group=[0]*n
group[0]=1
for i in range(n-1):
    u, v, w = map(int, input().split())
    mat[u-1].append((v-1, w))
    mat[v-1].append((u-1, w))
def C(kw, p, l):
    global group
    k, w = kw
    if w%2==1:
        p*=-1
    group[k]=p
    for kwi in mat[k]:
        if kwi[0]!=l:
            C(kwi, p, k)
for kwi in mat[0]:
    C(kwi, 1, 0)
for gi in group:
    if gi>0:
        print(1)
    else:
        print(0)


Measured memory_bytes: 79408
mozi = input()
a = list(mozi)
if a[0] == 'R' and a[1] == 'R' and a[2] == 'R':
    print(3)
elif a[0] == 'R' and a[1] == 'R':
    print(2)
elif a[1] == 'R' and a[2] == 'R':
    print(2)
elif a[0] == 'R':
    print(1)
elif a[1] == 'R':
    print(1)
elif a[2] == 'R':
    print(1)
else:
    print(0)


Measured memory_bytes: 9128
#include <iostream>
#include <vector>

int main() {
    int n; std::cin >> n;
    std::vector<int> v(n);
    std::vector<int> sv(n);

    for (int i = 0; i < n; i++) {
        std::cin >> v[i];
        sv[i] = v[i];
    }

    std::sort(sv.begin(), sv.end());
    int l = sv[n/2-1];
    int r = sv[n/2];

    for (int i = 0; i < n; i++) {
        std::cout << ((v[i] <= l)?r:l) << std::endl;
    }
    return 0;
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
//T+N
//#pragma GCC optimize ("O3")
//#pragma GCC target ("sse4")
#define endl "\n"
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
template<class T, class T2> inline bool chkmax(T &x, const T2 &y) { return x < y ? x = y, 1 : 0; }
template<class T, class T2> inline bool chkmin(T &x, const T2 &y) { return x > y ? x = y, 1 : 0; }
const ll mod = 1e9 + 7;
template<class T> inline void fix(T &x) {if(x >= mod | x <= -mod) {x %= mod;} if(x < 0) {x += mod;}}
#define out(x) cout << __LINE__ << ": " << (#x) << " = " << (x) << endl

const ll MAX_N = 1e6 + 10;
ll ans[MAX_N];
ll pw[MAX_N][3], hsh[3];

ll popcount(ll x) {
    ll ret = 0;
    while(x) {
        ret += x & 1;
        x /= 2;
    }
    return ret;
}

signed main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    ans[0] = 0;
    for(ll i = 1; i < MAX_N; i ++) {
        ll to = i % popcount(i);
        ans[i] = ans[to] + 1;
    }
    ll n;
    string in;
    cin >> n;
    cin >> in;
    reverse(in.begin(), in.end());
    ll cnt = 0;
    for(ll i = 0; i < n; i ++) {
        if(in[i] == '1') {
            cnt ++;
        }
    }
    pw[0][0] = pw[0][1] = pw[0][2] = 1;
    for(ll i = 1; i < n; i ++) {
        for(ll j = 0; j < 3; j ++) {
            ll nowMod = cnt - 1 + j;
            if(nowMod == 0) {continue;}
            pw[i][j] = (pw[i - 1][j] * 2) % nowMod;
        }
    }
    for(ll i = 0; i < n; i ++) {
        for(ll j = 0; j < 3; j ++) {
            ll nowMod = cnt - 1 + j;
            if(nowMod == 0) {continue;}
            if(in[i] == '1') {
                hsh[j] = (hsh[j] + pw[i][j]) % nowMod;
            }
        }
    }
    for(ll i = n - 1; i >= 0; i --) {
        if(in[i] == '0') {
            ll nowMod = cnt + 1;
            ll now = hsh[2];
            now = (now + pw[i][2]) % nowMod;
            cout << ans[now] + 1 << endl;
        } else {
            ll nowMod = cnt - 1;
            if(nowMod == 0) {
                cout << 0 << endl;
                continue;
            }
            ll now = hsh[0];
            now = (now - pw[i][0] + nowMod) % nowMod;
            cout << ans[now] + 1 << endl;
        }
    }
    return 0;
}




Measured memory_bytes: 16240
#include <stdio.h>
//#define rep(i,n) for(int i=0;i<n;i++)

int A[100001],n;

int Binary(int key){
    int left=0;
    int right=n;
    int mid;
    while(left<right){
        mid=(left+right)/2;
        if(A[mid]==key) return 1;
        if(A[mid]<key) left=mid+1;
        else if(A[mid]>key) right=mid;
    }
    return 0;
}

int main(void){
    int i=0,key,q,sum=0;

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

    scanf("%d",&q);
    for(i=0;i<q;i++){
        scanf("%d",&key);
        if( Binary(key)) sum++;
    }
    printf("%d\n",sum);
}

Measured memory_bytes: 2108
#include<bits/stdc++.h>
using namespace std;
#define FastRead ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long int
#define endl '\n'
#define ld long double
#define FOR(i,a,n) for (ll i=(a);i<=(n);++i)
#define RFOR(i,a,n) for (ll i=(n);i>=(a);--i)
#define FI(i,n) for (ll i=0; i<(n); ++i)
#define ZERO(a) memset((a),0,sizeof((a)))
#define MINUS(a) memset((a),-1,sizeof((a)))
#define f first
#define s second
#define pb push_back
#define mk make_pair
#define all(g) g.begin(),g.end()
int fastMax(int x, int y) { return (((y-x)>>(32-1))&(x^y))^y; }
int fastMin(int x, int y) { return (((y-x)>>(32-1))&(x^y))^x; }
 
// I want to be the very best, like no one ever was, I will battle everyday to claim my rightful place
// Not gonna give up until it's over
// #include <ext/pb_ds/assoc_container.hpp> // Common file
// #include <ext/pb_ds/tree_policy.hpp>     // Including tree_order_statistics_node_updat
// using namespace __gnu_pbds;
// typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
 
// I am questioning life and universe and 
// everything else after looking at this

const ll MAXN = 51;
ll mat[MAXN][MAXN];
const ll MOD = 1e9 + 7;

void mul(ll A[][MAXN],ll B[][MAXN]){
    ll C[MAXN][MAXN];

    FOR(i,0,MAXN-1) FOR(j,0,MAXN-1) C[i][j] = 0;

    FOR(i,1,MAXN-1){
        FOR(j,1,MAXN-1){
            FOR(k,1,MAXN-1){
                C[i][j] = (C[i][j] + (A[i][k]*B[k][j])%MOD)%MOD;
            }
        }
    }

    FOR(i,1,MAXN-1) FOR(j,1,MAXN-1) A[i][j] = C[i][j];
}

void power_mat(ll A[][MAXN],ll p){
    ll res[MAXN][MAXN];
    ZERO(res);

    FOR(i,1,MAXN-1) res[i][i] = 1;

    while(p){
        if(p&1) mul(res,A);
        mul(A,A);
        p >>= 1;
    }
    FOR(i,1,MAXN-1) FOR(j,1,MAXN-1) A[i][j] = res[i][j];
}

void solve(){
    ll n,k; cin>>n>>k;

    FOR(i,1,n) FOR(j,1,n) cin>>mat[i][j];

    power_mat(mat,k);

    ll ans = 0;

    FOR(i,1,n) FOR(j,1,n) ans = (ans + mat[i][j])%MOD;

    cout<<ans<<endl;
}

signed main(){
 
   FastRead;    
 

    ll t;
    t = 1; 
    // cin>>t;
    FOR(i,1,t){
        // cout<<"Case #"<<i<<": ";
        solve();
    }
}

Measured memory_bytes: 384