akhauriyash/Code-Regression huggingface dataset:
N = int(input())
ab = [tuple(map(int,input().split())) for _ in range(N - 1)]
M = int(input())
uv = [tuple(map(int,input().split())) for _ in range(M)]
route = [[] for _ in range(N)]

for i, (a, b) in enumerate(ab):
    a -= 1
    b -= 1
    route[a].append((b, i))
    route[b].append((a, i))

path = [0] * M
for i, (u, v) in enumerate(uv):
    u -= 1
    v -= 1
    stack = [u]
    visited = [0] * N
    visited[u] = 1
    dire = [[] for _ in range(N)]
    while True:
        s = stack.pop()
        for g, j in route[s]:
            if visited[g]:
                continue   
            stack.append(g)
            dire[g].append((s, j))
            visited[g] = 1
        if visited[v]:
            break
    s = v
    while True:
        g, num = dire[s][0]
        path[i] |= (1 << num)
        if g == u:
            break
        s = g

data = [0] * (1 << M)
ans = 2 ** (N - 1)
for i in range(1, 1 << M):
    k = len(bin(i)) - 3
    data[i] = data[i - (2 ** k)] | path[k]
    power = bin(data[i]).count("1")
    judge = bin(i).count("1")
    ans += (-2 ** (N - 1 - power) if judge % 2 else 2 ** (N - 1 - power))
print(ans)


Measured memory_bytes: 44548
#include <map>
#include <list>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
string s1,s2,s3;
int main()
{
	cin>>s1>>s2>>s3;
	cout<<s1[0]<<s2[1]<<s3[2];
	return 0;
}

Measured memory_bytes: 256
r,g,b,n = [int(i) for i in input().split()]

cnt = 0
for i in range(n//r+1):
  n_r = i*r
  if n_r > n:
    break
  for j in range(n//g+1):
    n_rg = j*g + n_r
    if n_rg > n:
      break
    if (n-n_rg)%b == 0:
      cnt += 1
        
print(cnt)

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

int main() {
  long X, money, year, N;
  year = 0;
  money = 100;
  N = 99999999999999999999999;
  cin >> X;
  for(int i = 0; i < N; i++){
    double risi = 1.01;
    money *= risi;
    year++;
    if(money >= X){
        break;
     }
   }
  cout << year << endl;
}


Measured memory_bytes: 3540
/*ANKON GHOSH
  KUET,ECE 2K16*/
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define inf 1e10
#define MAX 100005
#define mod 998244353
#define sf(a) scanf("%lld",&a)
#define sff(a,b) scanf("%lld %lld",&a,&b)
#define sfff(a,b,c) scanf("%lld %lld %lld",&a,&b,&c)
#define Case(i) printf("Case %lld:\n",i)
#define pf(a) printf("%lld ",a)
#define pfsn printf("NO\n")
#define pfs  printf("YES\n")
#define pff(a,b) printf("%lld %lld\n",a,b)
#define FOR(i,n) for(ll i=0;i<n;i++)
#define FOR1(i,n) for(ll i=1;i<=n;i++)
#define LOOP(x,y) for(ll r=x;r<=y;r++)
#define RFOR(i,n) for(ll i=n-1;i>=0;i--)
#define RFOR1(i,n) for(ll i=n;i>0;i--)
#define RLOOP(x,y) for(ll i=y;i>=x;i--)
#define m_p(a,b) make_pair(a,b)
#define p_b(a) push_back(a)
#define ff first
#define ss second
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL)
map<ll,ll>mp,mp1;
vector<pair<ll,pair<ll,pair<ll,ll> > > >vpp,vpp1;
vector<pair<ll,ll> >vp,fin;
vector<ll>v,v1,v2,dummy;
map<pair<ll,ll>,ll>mpp;
///map<ll,bool>mb;
ll n,x,k,a,b,c,d,ta,sum=0,cnt=0,m,l,req,sz,w;
bool sortbysec(const pair<pair<ll,ll>,ll> &a,const pair<pair<ll,ll>,ll> &b)
{
    return (a.second < b.second);
}
string s,t;
ll dp[3005][3005];
string ans;
void calc(ll x,ll y)
{
    ///cout<<x<<" "<<y<<endl;
    if(x==0 or y==0)
    {
        ///cout<<"ankon"<<endl;
        return;
    }
    ll curr=dp[x][y];
    ll left=dp[x-1][y];
    ll up=dp[x][y-1];
    ll cor=dp[x-1][y-1];
    if(curr==left)
    {
        calc(x-1,y);
    }
    else if(curr==up)
    {
        calc(x,y-1);
    }
    else{
        ans+=s[x];
        calc(x-1,y-1);
    }
}
int main()
{
    ///reset();
    ///freopen("input.txt","r",stdin);
    fast;
    cin>>s>>t;
    ll x,y;
    x=s.size();
    y=t.size();
    s='#'+s;
    t='#'+t;
    memset(dp,0,sizeof dp);
    for(ll i=1; i<=x; i++)
    {
        for(ll j=1; j<=y; j++)
        {
            if(s[i]==t[j])
            {
                dp[i][j]=dp[i-1][j-1]+1;

            }
            else
            {
                dp[i][j]=max(dp[i][j-1],dp[i-1][j]);
            }
        }
    }
    calc(x,y);
    reverse(ans.begin(),ans.end());
    ///cout<<dp[x][y];
    cout<<ans;

    return 0;
}


Measured memory_bytes: 70784
#include <iostream>

using namespace std;

int main(){
    int n;
    cin >> n;
    int a[n+1], b[n];
    for(int i = 0; i < n+1; i++){
        cin >> a[i];
    }
    for(int i = 0; i < n; i++){
        cin >> b[i];
    }

    long long ans = 0;
    for(int i = 0; i < n; i++){
        if(a[i] >= b[i]){
            ans += b[i];
        }else if(a[i] + a[i+1] >= b[i]){
            ans += b[i];
            a[i+1] = a[i+1] - (b[i] - a[i]);
        }else{
            ans = ans + a[i] + a[i+1];
            a[i+1] = 0;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>
#include <stdlib.h>

#define MAX_N (100)
#define SIZE_BUF (30)

int main(int argc, char *argv[]) {
  // read inputs
  int N;
  char cs[MAX_N + 1], buf[SIZE_BUF];
  scanf("%d", &N);
  fgets(buf, SIZE_BUF, stdin);
  scanf("%s", cs);

  // solve
  int cnt_r = 0, cnt_b = 0;
  for (int i = 0; i < N; i++) {
    if (cs[i] == 'R') {
      cnt_r++;
    } else {
      cnt_b++;
    }
  }
  if (cnt_r > cnt_b) {
    printf("Yes\n");
  } else {
    printf("No\n");
  }
  
  return 0;
}


Measured memory_bytes: 128
import heapq
N, K = map(int, input().split())
A = list(map(int, input().split()))
F = list(map(int, input().split()))
S = sum(A)
if S <= K:
    print(0)

else:
    A.sort()
    F.sort(reverse=True)

    r = A[-1]*F[0]

    l = 0

    while(1):
        tmp = (l+r)//2
        k = 0
        for x, y in zip(A, F):
            k += max(0, x - (tmp // y))
        if k > K:
            l = tmp
        else:
            r = tmp

        if l+1 == r:
            print(r)
            exit(0)


Measured memory_bytes: 119500
import sys
def input(): return sys.stdin.readline().rstrip()
def make_divisors(n):
    divisors = []
    for i in range(1,int(n**0.5)+1):
        if n%i==0:
            divisors.append(i)
            if i!=n//i:
                divisors.append(n//i)
    divisors.sort()
    return divisors
import bisect
def main():
    n,m=map(int,input().split())
    div=make_divisors(m)
    print(div[bisect.bisect(div,m//n)-1])
    

if __name__=='__main__':
    main()

Measured memory_bytes: 3188
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>
#define rep(i,n) for(int i=0;i<n;i++)

typedef int long long ll;
using namespace std;
typedef pair<int,int> P;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
const ll MOD=1e9+7;
static const int MAX = 100;
static const int INF = (1<<23);
template<class T> T gcd(T a, T b){return b? gcd(b,a%b) : a;}
template<class T> T lcm(T a,T b){return a / gcd(a,b)*b;}

int main(){
    string s,t;
    cin>>s>>t;
    cout<<t<<s<<endl;



    
return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define int ll
#define Mid ((l+r)/2)
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
#define drep(i,a,b) for(int i=(a);i>=(b);--i)
#define file(a) freopen(#a".in","r",stdin),freopen(#a".out","w",stdout);
const int maxn=1e5+5,mod=1e9+7,inf=1e18+7;
int n,m,Q,K,T;
int read(){
    int x=0,f=1;char c=getchar();
    while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
    while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}
    return x*f;
}

signed main(){
    //file(a);
    int a=read(),b=read(),c=read(),d=read();
    int ans=-inf;
    ans=max(ans,max(a*c,max(a*d,max(b*c,b*d))));
    printf("%lld\n",ans);



    return 0;
}


Measured memory_bytes: 3768
#include<bits/stdc++.h>
using namespace std;
const int MAX_N = 1<<17;
int bit[MAX_N+1],n;

int sum(int i){
  int s=0;
  while(i>0){
    s+=bit[i];
    i-=i&-i;
  }
  return s;
}

void add(int i,int x){
  while(i<=n){
    bit[i]+=x;
    i+=i&-i;
  }
}

int main(){
  int q;
  cin>>n>>q;
  while(q--){
    int com,x,y;
    cin>>com>>x>>y;
    if(com==0)add(x,y);
    if(com==1)cout<<sum(y)-sum(x-1)<<endl;;
  }
}

Measured memory_bytes: 3440
#include <bits/stdc++.h>
#include <iomanip>
#include <math.h>
//#include <unistd.h>
//#include <stdio.h>
#define rep(i,x) for(ll i = 0;i<x;i++)
#define all(a) (a).begin(),(a).end()
#define vecin(a) rep(i,a.size())cin >> a[i]
using ll = long long;
using ld = long double;
using namespace std;
using dou = double;
const ll inf = 2147483647;
const ll INF = 1LL << 60;
const ld pi = 3.14159265358;
const ll mod = 1000000007;
typedef pair<ll,ll> P;
using graph = vector<vector<ll>>;
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;}
template<class T> inline bool change(T a,T b){if(a > b){swap(a,b);return true;}return false;}
ll gcd(ll a,ll b){
    if(a < b)swap(a,b);
    if(a % b == 0)return b;
    else return gcd(b,a%b);
}
//素数判定O(sqrt(N))
bool isp(ll n){
    bool res = true;
    if(n == 1)return false;
    else{
        for(ll i = 2;i * i <= n;i++){
            if(n % i == 0){
                res = false;
                break;
            }
        }
        return res;
    }
}
const ll cmax = 1000000;
ll fac[cmax], finv[cmax], inv[cmax];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < cmax; 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 nCk(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}
//nのm乗をMODで割ったあまりO(logN)
ll modpow(ll n,ll m,ll MOD){
    ll res = 1;
    while(m){
        if(m & 1)res = (res * n) % MOD;
        m >>= 1;
        n *= n;
        n %= MOD;
    }
    return res;
}

//printf("%.10f\n", N);
/*  vector<ll> vec = {1,2,5,6,8,9,10};
    cout << binary_search(all(vec),5) << endl; -> true*/
/*
    vector<ll> vec = {1,2,5,6,8,9,10};
    auto n = upper_bound(all(vec),4);
    cout << *n << endl; -> 5*/

//    cout << fixed << setprecision(15);

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll N,M;
    cin >> N >> M;
    if((N + M) % 3 != 0){
        cout << "0\n";
        return 0;
    }
    if(N > M)swap(N,M);
    if(N * 2 < M){
        cout << 0 << endl;
        return 0;
    }
    ll kai = (N + M) / 3;
    ll two = N - kai;
    COMinit();
    cout << nCk(kai,two) << endl;
}

Measured memory_bytes: 27120
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <set>
#include <string>
#include <cstring>
#include <cmath>
#include <map>
#define N 100005
using namespace std;
typedef long long ll;
int vis[N],a[N];
void creat()
{
    for(int i=2; i<=400; i++)
    {
        if(!vis[i])
        {
            for(int j=i*2; j<=N; j+=i)
                vis[j]=1;
        }
    }
}
int main()
{
 
    memset(vis,0,sizeof(vis));
    creat();
    vis[1]=1;
    int sum=0,n;
    for(int i=1; i<=N; i++)
    {
        if(i%2==1)
        {
            if(vis[i]==0&&vis[(i+1)/2]==0)
                sum++;
        }
 
        a[i]=sum;
    }
    while(scanf("%d",&n)==1)
    {
        while(n--)
        {
            int c,b;
            scanf("%d%d",&c,&b);
 
            printf("%d\n",a[b]-a[c-1]);
        }
    }
}

Measured memory_bytes: 4584
#include<iostream>
using namespace std;
int main(){
	int a[9];
	cin>>a[0]>>a[1]>>a[4];
	int all;
	all=a[4]*3;
	a[2]=all-a[0]-a[1];
	a[7]=all-a[1]-a[4];
	a[8]=all-a[0]-a[4];
	a[6]=all-a[4]-a[2];
	a[3]=all-a[0]-a[6];
	a[5]=all-a[2]-a[8];
	for(int i=0;i<3;i++){
		for(int j=0;j<3;j++){
			cout<<a[i*3+j]<<" ";
		}
		cout<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
N=int(input())
slime=list(map(int,input().split()))
slime+=[0]

num=1
score=0
for i in range(1,N+1):
    if slime[i]==slime[i-1]:
        num+=1
    else:
        score+=num//2
        num=1

    #print(score,num)

print(score)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define loop(i,a,b) for (int i=a; i<b; ++i)
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int N;
    cin >> N;
    vector <int> X(N);
    loop(i,0,N) cin >> X[i];
    vector <int> Y=X;
    sort(X.begin(), X.end());
    int count=0;
    int ind1=-1, ind2=-1;
    loop(i,0,N)
    {
        if (X[i]!=Y[i])
        {
            count++;
            if (ind1==-1) ind1=i;
            else if (ind2==-1) ind2=i;
        }
    }
    if (ind1==-1 && ind2==-1) cout << "YES\n";
    else if (count>2) cout << "NO\n";
    else
    {
        swap(Y[ind1], Y[ind2]);
        if (X==Y) cout << "YES\n";
        else cout << "NO\n";
    }  
    return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**7)
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return sys.stdin.readline().strip()
INF = 10 ** 18
MOD = 10 ** 9 + 7

def even_digits(i):
    if (1 <= i <= 9) or (100 <= i <= 999) or (10000 <= i <= 99999) or (1000000 <= i <= 9999999):
        return True
    else: return False

def main(): 
    N = II()
    counter = 0
    for i in range(1, N+1):
        if even_digits(i):
            counter+=1
    print(counter)

main()

Measured memory_bytes: 39024
//n種類のトッピングを任意に選んで、カロリー/合計コストを最大化する。
//考察：
//トッピングの値段が全て同じなのだから、カロリーの高いトッピングを
//乗せたほうが良いに決まっている。

#include<iostream>
#include<algorithm>
#include<functional>
using namespace std;

int n, a, b, c;
int cal[100];

int main() {
	int i;
	cin >> n >> a >> b >> c;
	for (i = 0; i < n; i++) {
		cin >> cal[i];
	}
	sort(cal, cal + n, greater<int>());
	
	int sumcost = a;
	int sumcal = c;
	int ans = 0;
	for (i = 0; i < n; i++) {
		ans = max(ans, sumcal/sumcost);
		sumcost += b;
		sumcal += cal[i];
	}
	ans = max(ans, sumcal/sumcost);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1176
#!/usr/bin/env python3
# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools
import sys
import bisect

INF = 1145141919

a = []
dp = []
ans = []
T = []


def dfs(v: int, p: int):
    index = bisect.bisect_left(dp, a[v])
    dp[index], a[v] = a[v], dp[index]

    ans[v] = bisect.bisect_left(dp, INF)

    for u in T[v]:
        if u != p:
            dfs(u, v)

    dp[index], a[v] = a[v], dp[index]


def solve(N: int, tmp_a: "List[int]", tmp_T: "List[List[int]]"):
    sys.setrecursionlimit(10 ** 6)

    global dp, ans, a, T
    dp = [INF] * N
    ans = [0] * N
    a = tmp_a
    T = tmp_T

    dfs(0, -1)

    print("\n".join(map(str, ans)))


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    a = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    T = [[] for _ in range(N)]  # type: "List[List[int]]"
    for i in range(N - 1):
        u = int(next(tokens)) - 1
        v = int(next(tokens)) - 1
        T[u].append(v)
        T[v].append(u)
    solve(N, a, T)


if __name__ == '__main__':
    main()


Measured memory_bytes: 351504
import collections
n=int(input())
s = []
sort=[]
for i in range(n):
    s.append(input())
ans=collections.Counter(s).most_common()
oldnum=ans[0][1]
for i in range(len(ans)):
    if oldnum == ans[i][1]:
        sort.append(ans[i][0])
        oldnum=ans[i][1]
    else:
        break
sort.sort()
for i in range(len(sort)):
    print(sort[i])


Measured memory_bytes: 45040
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n,s=0,w=0;
char a;
cin>>n;
for(int i=1;i<=n;i++)
{
cin>>a;
if(a=='I')s++;
else s--;
w=max(s,w);
}
cout<<w<<endl;
return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<set>
#include<vector>
#include<algorithm>
#include<queue>
#include<map>
#include<cstdlib>
#include<time.h>
#include<string>
#include<stack>
#include<cmath>
#include<iostream>
#include<iomanip>
#include<cstring>
#include<complex>
using namespace std;
#define FOR(i,j,k) for(int i=j;i<k;i++)
#define FORD(i,j,k) for(int i=j;i>=k;i--)
#define ll long long
#define ull unsigned long long int
//Make sure no overflow problems
#define pii  pair<int, int>
#define vi vector<int >
#define pb push_back
#define mp make_pair
#define x first
#define y second
#define VAR(i,n) __typeof(n) i = (n)
#define FOREACH(i,c) for(VAR(i,(c).begin());i!=(c).end();i++)
#define FORDEACH(i,c) for( VAR(i,(c).rbegin()),i!=(c).rend();i++)
#define REP(i,n) FOR(i,0,n)
#define ld long double
const int INF = 1000000009;
const long long INFLL = (ll)INF * (ll)INF;
const ld EPS = 10e-9;

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


           int n;
           double total = 0;
        cin >> n;
        int x[n], y[n];
        FOR(i,0,n)
            cin >> x[i] >> y[i];
        FOR(i,0,n)
            FOR(j,i+1,n)
                total += 2*sqrt((x[i]-x[j])*(x[i]-x[j]) + (y[i]-y[j])*(y[i]-y[j]));
        cout << setprecision(10) << fixed << total/n << endl;
           return 0;
}



Measured memory_bytes: 256
// Problem : B - ... (Triple Dots)
// Contest : AtCoder - AtCoder Beginner Contest 168
// URL : https://atcoder.jp/contests/abc168/tasks/abc168_b
// Memory Limit : 1024 MB
// Time Limit : 2000 ms

#include <bits/stdc++.h>

using namespace std;

#define ll long long int

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0), cout.tie(0);
	
	int k;
	string n;
	
	cin >> k >> n;
	
	if( (int)n.size() > k )
		n = n.substr( 0, k ) + "...";
	
	cout << n << endl;
	
	return 0;
}


Measured memory_bytes: 3576
package main

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

// define
var (
	sc = bufio.NewScanner(os.Stdin)
)

func bordersInt(in_map [][]int, invalid int) [][]int{
	H, W := len(in_map), len(in_map[0])
	out_map := make([][]int, H+2)
	for h:=0; h<H+2; h++ {
		out_map[h] = make([]int, W+2)
		for w:=0; w<W+2; w++ {
			out_map[h][w] = invalid
		}
	}
	for h:=0; h<H; h++{
		for w:=0; w<W; w++{
			out_map[h+1][w+1] = in_map[h][w] 
		}
	}
	return out_map
}

func bordersString(in_map [][]string, invalid string) [][]string{
	H, W := len(in_map), len(in_map[0])
	out_map := make([][]string, H+2)
	for h:=0; h<H+2; h++ {
		out_map[h] = make([]string, W+2)
		for w:=0; w<W+2; w++ {
			out_map[h][w] = invalid
		}
	}
	for h:=0; h<H; h++{
		for w:=0; w<W; w++{
			out_map[h+1][w+1] = in_map[h][w] 
		}
	}
	return out_map
}

func scanIntLine(len int) []int{
	arr := make([]int, len)
	for i:=0; i<len; i++{
		sc.Scan()
		tmp, err := strconv.Atoi(sc.Text())
		if err == nil{
			arr[i] = tmp
		}
	}
	return arr
}

func scanStringLine(len int) []string{
	arr := make([]string, len)
	for i:=0; i<len; i++{
		sc.Scan()
		arr[i] = sc.Text()
	}
	return arr
}

func scanIntSplit(len int) []int{
	arr := make([]int, len)
	sc.Scan()
	for i, v := range strings.Split(sc.Text(), " "){
		tmp, err := strconv.Atoi(v)
		if err == nil{
			arr[i] = tmp
		}
	}
	return arr
}

func main(){
	buf := make([]byte, 0)
	sc.Buffer(buf, 1000000009)
	var S string
	cnt0, cnt1 := 0, 0
	fmt.Scan(&S)
	for _, v := range S {
		if v == '0' {
			cnt0++
		} else {
			cnt1++
		}
	}
	if cnt0 < cnt1 {
		fmt.Println(cnt0*2)
	} else {
		fmt.Println(cnt1*2)
	}
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
const long long INF = 1e15;

#include <math.h>
#define PI 3.14159265358979323846264338327950L

bool isPrime(long long x) {
    if (x == 1) return true;
    for (long long i = 2; i*i <= x; i++) {
        if (x % i == 0) return false;
    }
    return true;
}

long long gcd(long long a, long long b) {
    if (a == 0)
        return b;
    return gcd(b % a, a);
}

vector<long long> common_divisors(long long a, long long b) {
    long long n = gcd(a, b);
    vector<long long> ans;
    for (long long i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            if (n / i == i) {
                ans.push_back(i);
            }
            else {
                ans.push_back(n / i);
                ans.push_back(i);
            }
        }
    }
    return ans;
}
vector<int> get_divisors(long long n) {
    vector<int> ans;
    for (long long i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            if (i == n / i) {
                ans.push_back(i);
            }
            else {
                ans.push_back(n / i);
                ans.push_back(i);
            }
        }
    }
    sort(ans.rbegin(), ans.rend());
    return ans;
}

bool is_sorted(vector<int> a) {
    int n = a.size();
    for (int i = 0; i < n - 1; i++) {
        if (a[i + 1] < a[i]) return false;
    }
    return true;
}

int mxN = 1e5;
int main() {
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    long long sum = 0;
    int ans = 1;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        sum += a[i];
    }

    vector<int> div = get_divisors(sum);
    for (int t = 0; t < div.size(); t++) {
        int d = div[t];
        long long total = 0;
        vector<int> remainders;
        for (int i = 0; i < n; i++) {
            remainders.push_back(a[i] % d);
        }
        sort(remainders.begin(), remainders.end());
        int i = 0;
        while (i < (int)remainders.size() && remainders[i] == 0) i++;
        int j = (int)remainders.size() - 1;
        while (i < (int)remainders.size() && i < j) {
            int sum = min(d - remainders[j], remainders[i]);
            remainders[i] -= sum;
            remainders[j] += sum;
            if (remainders[i] == 0) i++;
            if (remainders[j] == d) j--;
            total += sum;
        }
        if (total <= k) {
            ans = d;
            break;
        }
    }
    printf("%d", ans);
    return 0;
}

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

long long dfs(long long sum, int N, vector<int> &oknum){
    if (sum>=N){
        //cout << sum << endl;
        return sum;
    }

    long long minsum = 100000;
    for(int x: oknum){
        long long nv =sum*10 + x;
        if (nv==0) continue;
        long long s = dfs(nv, N, oknum);
        minsum = min(s, minsum);
        //cout << x << " " << s << endl;
    }
    return minsum;
}

int main()
{
    int N, K;
    cin >> N>>K;
    vector<int> ngnum(10);
    REP(i, K){
        int a;
        cin >> a;
        ngnum[a] = 1;
    }
    vector<int> oknum;
    REP(i, 10){
        if (ngnum[i] == 0){
            oknum.push_back(i);
            //cout << i << " ";
        }
    }
    //cout << endl;
    long long minsum = dfs(0,N, oknum);
    cout << minsum << endl;
   return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
//code start
 
int main()
{
    // freopen("/root/Programming/input.txt", "r", stdin);
    // freopen("/root/Programming/output.txt", "w", stdout);
    string str, sb;
    cin >> str;
    int q;
    scanf("%d", &q);
    int ti, fi;
    bool flag = true;
    vector<string> vstart, vend;
    while (q--)
    {
        scanf("%d", &ti);
        if (ti == 1)
        {
            flag = !flag;
        }
        else
        {
            scanf("%d", &fi);
            getchar();
            cin >> sb;
            if (fi == 1)
            {
                if (flag)
                    vstart.push_back(sb);
                else
                    vend.push_back(sb);
            }
            else
            {
                if (flag)
                    vend.push_back(sb);
                else
                    vstart.push_back(sb);
            }
        }
    }
    if (flag)
    {
        int x = vstart.size();
        for (int i = x - 1; i > -1; i--)
        {
            cout << vstart[i];
        }
        cout << str;
        for (int i = 0; i < vend.size(); i++)
        {
            cout << vend[i];
        }
        printf("\n");
    }
    else
    {
        // cout<<"wojfoej";
        int x = vend.size();
        for (int i = x - 1; i > -1; i--)
        {
            reverse(vend[i].begin(), vend[i].end());
            cout << vend[i];
        }
        reverse(str.begin(), str.end());
        cout<<str;
        for (int i = 0; i < vstart.size(); i++)
        {
            reverse(vstart[i].begin(), vstart[i].end());
            cout << vstart[i];
 
        }
        printf("\n");
    }
    // cout << str << endl;
    return 0;
}


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

int main(){
  int a,b,c,d, si;
  string str;

  while(1){
    int map[20][20] = {}, h = 1, w = 1, counta; 
    cin>>str;
    if(str == "#") break;
    cin>>a>>b>>c>>d;
    si = str.size();
    for(int i = 0; i < si; i++){
      if(h==a&&w==b) str[i] = '1';
      if(str[i] == 'b'){map[h][w] = 1;w++;}
      else if(str[i] == '/'){h++;w=1;}
      else w+= str[i]-'0';
    }map[c][d] = 1;
    for(int i = 1; i <= h; i++){
      counta = 0;
      for(int j = 1; j < w; j++){
	counta++;
	if(map[i][j] == 1){
	  if(counta-1)cout<<counta-1;
	  cout<<'b';
	  counta = 0;
	}
      }
      if(counta)cout<<counta;
      if(i!=h)cout<<'/';
    }cout<<endl;
  }

  return 0;
}



Measured memory_bytes: 3140
#include "bits/stdc++.h"
using namespace std;
typedef pair<int, int> P;
typedef pair<int, P> E;
typedef long long LL;
const int MAX = 1000000;
vector<int> vanish[MAX + 1];
bool done[200];
struct UnionFind {
	int *par;
	int *rank;
	int size;
	int cnt;
	UnionFind(int n) :size(n) {
		par = new int[size];
		rank = new int[size];
		cnt = size;
		for (int i = 0; i < size; i++) {
			par[i] = i;
			rank[i] = 0;
		}
	}
	int find(int x) {
		if (x == par[x]) return x;
		return par[x] = find(par[x]);
	}
	bool same(int x, int y) {
		return find(x) == find(y);
	}
	void unite(int x, int y) {
		x = find(x);
		y = find(y);
		if (x == y) return;
		cnt--;
		if (rank[x] < rank[y]) {
			par[x] = y;
		}
		else {
			par[y] = x;
			if (rank[x] == rank[y]) rank[x]++;
		}
	}
	int count() {
		return cnt;
	}
};
int main() {
	int N, M;
	while (cin >> N >> M, N) {
		for (int i = 0; i <= MAX; i++) vanish[i].clear();
		for (int i = 0; i < N; i++) {
			int h;
			cin >> h;
			vanish[h].push_back(i);
		}
		vector<E> edge;
		for (int i = 0; i < M; i++) {
			int a, b, c;
			cin >> a >> b >> c;
			a--; b--;
			edge.emplace_back(c, P(a, b));
		}
		sort(edge.begin(), edge.end());
		UnionFind uf(N);
		for (auto e : edge) uf.unite(e.second.first, e.second.second);
		if (uf.count() > 1) {
			cout << 0 << endl;
			continue;
		}
		int last = -1;
		memset(done, 0, sizeof(done));
		for (int t = 0; t <= MAX; t++) {
			if (vanish[t].empty()) continue;
			for (int v : vanish[t]) done[v] = 1;
			UnionFind u(N);
			for (auto e : edge) {
				if (done[e.second.first] || done[e.second.second]) continue;
				u.unite(e.second.first, e.second.second);
			}
			int sz = 1;
			for (int i = 0; i < N; i++) {
				if (done[i]) sz++;
			}
			if (u.count() != sz) {
				last = t;
				break;
			}
		}
		LL ans = 0;
		UnionFind u(N);
		memset(done, 0, sizeof(done));
		for (int t = last; t <= MAX; t++) {
			if (vanish[t].empty()) continue;
			for (int v : vanish[t]) done[v] = 1;
		}
		for (auto e : edge) {
			if (!done[e.second.first] || !done[e.second.second]) continue;
			if (u.same(e.second.first, e.second.second)) continue;
			ans += e.first;
			u.unite(e.second.first, e.second.second);
		}
		for (int t = last - 1; t >= 0; t--) {
			if (vanish[t].empty()) continue;
			for (int v : vanish[t]) done[v] = 1;
			for (auto e : edge) {
				if (!done[e.second.first] || !done[e.second.second]) continue;
				if (u.same(e.second.first, e.second.second)) continue;
				ans += e.first;
				u.unite(e.second.first, e.second.second);
			}
		}
		cout << ans << endl;
	}
}


Measured memory_bytes: 27964
#include<stdio.h>

void trace(int A[],int N){
	for(int i=0; i<N;i++){
		if(i>0) printf(" ");
		printf("%d",A[i]);
		}
	printf("\n");
	}

		
		

void insertionSort(int A[],int N){
	for(int i = 1;i<N;i++){
		int v = A[i];
		int j=i-1;
		while(i>=0&&A[j]>v){
			A[j+1]=A[j];
			j--;
			}
		A[j+1]=v;
		trace(A,N);
		}
	}

int main(){
	int N;
	scanf("%d",&N);
	int A[100];
	for(int i=0;i<N;i++){
		scanf("%d",&A[i]);
		}
	trace(A,N);
	insertionSort(A,N);
	
	return 0;
}

Measured memory_bytes: 1032
package main

import (
	"fmt"
)

func main() {
	var a, b int
	fmt.Scan(&a)
	fmt.Scan(&b)
	if a < b {
		fmt.Println("a < b")
	} else if a > b {
		fmt.Println("a > b")
	} else {
		fmt.Println("a == b")
	}
}

Measured memory_bytes: 1104
#include <cstdio>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <cmath>
#include <climits>
#include <unordered_map>

using namespace std;

#define size_t int

int iswin(int a, int b) {
  if ((a == 1 && b == 1)||(a == 1 && b == 0)||(a == 0 && b == 1)) {
    return 1;
  }
  int win = 0;
  if (a - 1 >= 0 && b - 1 >= 0) {
    win |= !iswin(a-1,b-1);
  }
  if (b - 1 >= 0) {
    win |= !iswin(a,b-1);
  }
  if (a - 1 >= 0) {
    win |= !iswin(a-1,b);
  }
  return win;
}

int main(int argc, char const *argv[]) {
  long N;
  scanf("%ld", &N);
  int a[N];
  for (size_t i = 0; i < N; i++) {
    scanf("%d", &a[i]);
  }
  for (size_t i = 0; i < N; i++) {
    if (a[i] % 2) {
      printf("first\n");
      return 0;
    }
  }
  printf("second\n");
}


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

using namespace std;

inline int read()
{
	int x=0,f=1; char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1; ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0'; ch=getchar();}
	return x*f;
}

int n,st,x,l,r; char s[10];
int main()
{
	n=read(); l=0; r=n-1;
	printf("0\n");
	fflush(stdout);
	scanf("%s",s);
	if(s[0]=='V') return 0;
	st=s[0]=='M';
	while(l<=r)
	{
		int mid=(l+r)>>1;
		printf("%d\n",mid);
		fflush(stdout);
		scanf("%s",s);
		if(s[0]=='V') return 0;
		x=s[0]=='M';
		if(mid&1) 
		{
			if(x^st) l=mid+1;
			else r=mid-1;
		}
		else 
		{
			if(x^st) r=mid-1;
			else l=mid+1;
		}
	}
	return 0;
}

Measured memory_bytes: 852
def main():
    N, M, C = map(int, input().split())
    B = list(input().split(' '))
    for i in range(M):
        B[i] = int(B[i])

    all_A = []
    clear_count = 0
    cal = 0

    for i in range(N):
        A = list(input().split(' '))
        for j in range(M):
            A[j] = int(A[j])
        all_A.append(A)

    #print(all_A)

    for A in all_A:
        cal = 0
        for i in range(M):
            cal += A[i] * B[i]
        cal += C
        #print(cal)
        if cal > 0:
            clear_count += 1

    print(clear_count)


if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const string ln = "\n";
constexpr int INF = 1001001001;
constexpr int MOD = 1000000007;

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

  ll n, p;
  cin >> n >> p;
  vector<ll> a(n);
  ll e = 0;
  ll o = 0;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    if (a[i] % 2) {
      o++;
    } else {
      e++;
    }
  }

  ll ans = 0;
  if(e == n) {
    ans = p ? 0 : pow(2, e);
  } else {
    ans = pow(2, n - 1);
  }

  cout << ans << ln;

  return 0;
}

Measured memory_bytes: 256
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
// #define main int main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
#define stlice(from, to) substr(from, (to) - (from) + 1)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
using namespace std;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef vector<pii> vpii;
typedef vector<vi> vvi;
typedef vector<vb> vvb;
typedef vector<vpii> vvpii;
const int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
const int MOD = 1000000007;
const double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
bool odd(const int &n) { return n & 1; }
bool even(const int &n) { return !odd(n); }
template<typename V> typename V::value_type sum(const V &v) { return accumulate(all(v), 0); }
void solve();
main { solve(); return 0; }
// clang-format on

void solve() {
  vi a(4), b(4);
  while (cin >> a[0] >> a[1] >> a[2] >> a[3] >> b[0] >> b[1] >> b[2] >> b[3]) {
    vi c, d;
    int jimei = 0;
    rep(i, 4) {
      if (a[i] == b[i]) {
        jimei++;
      } else {
        c.pb(a[i]), d.pb(b[i]);
      }
    }
    vi fooooo;
    sort(all(c)), sort(all(d));
    set_intersection(all(c), all(d), back_inserter(fooooo));
    cout << jimei << ' ' << fooooo.size() << endl;
  }
}

Measured memory_bytes: 2948
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

// fn read_array<T: FromStr>(n: u32) -> Vec<T> {
//     (0..n).map(|_| read()).collect()
// }

fn main() {
    let n: u32 = read();
    let a: u32 = read();
    let b: u32 = read();
    let ans = (1..n + 1)
        .filter(|x| {
            let sum = x.to_string()
                .chars()
                .map(|c| (c as u8 - b'0') as u32)
                .sum::<u32>();
            a <= sum && sum <= b
        })
        .sum::<u32>();
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define rep( i, n, m ) for(int i = ( n ); i < ( m ); i++)
#define rep_d( i, n, m ) for(int i = ( n ) - 1; i >= ( m ); i--)
#define sort_asc( X ) sort(( X ).begin(), ( X ).end())
#define sort_desc( X ) sort(( X ).begin(), ( X ).end(), greater <>())

template <class T> bool chmax( T& a, T b );
template <class T> bool chmin( T& a, T b );
int* eratosthenes( int N );
bool bit_search( int pattern, int N );
template <class T> void cumulative_sum( T array, size_t N );

const ll INF = 1LL << 60;
const int k_mod = 1e9 + 7;

long long int* fac, *finv, *inv;

void comInit(int max) {
	max++;
	fac = new long long int[max];
	finv = new long long int[max];
	inv = new long long int[max];
	fac[0] = fac[1] = inv[1] = finv[0] = finv[1] = 1;
	for (int i = 2; i < max; ++i) {
		fac[i] = fac[i - 1] * i % k_mod;
		inv[i] = k_mod - inv[k_mod % i] * (k_mod / i) % k_mod;
		finv[i] = finv[i - 1] * inv[i] % k_mod;
	}
}
long long nCr(int n, int r) {
	if (n < r || n < 0 || r < 0) return 0;
	return fac[n] * (finv[r] * finv[n - r] % k_mod) % k_mod;
}
int main( void ){
	int N, K;
	cin >> N >> K;
	comInit(2001);
	rep(i,1,K+1){
		cout << (nCr(N-K+1, i)* nCr(K-1, i-1))%k_mod << endl;
	}
}

int* eratosthenes( int N ){
	int* prime_array = new int[ N + 1 ];
	int lim = N;
	prime_array[ 0 ] = 0;
	prime_array[ 1 ] = 0;
	rep( i, 2, N + 1 ){
		prime_array[ i ] = 1;
	}
	rep( i, 2, lim ){
		if (prime_array[ i ] == 0)
			continue;
		lim = N / i;
		for(int j = i * 2; j < N + 1; j += i){
			prime_array[ j ] = 0;
		}
	}
	return prime_array;
}
template <class T> void cumulative_sum( T array, size_t N ) {
	rep( i, 1, N + 1 ){
		array[ i ] += array[ i - 1 ];
	}
}
template <class T> bool chmax( T& a, T b ) {
	if (a < b){
		a = b; return true;
	}
	return false;
}
template <class T> bool chmin( T& a, T b ) {
	if (a > b){
		a = b; return true;
	}
	return false;
}
bool bit_search( int pattern, int N ){
	int cnt = 0;
	rep( bit, 0, N ){
		if (pattern & ( 1 << bit )){
			cnt++;
		}
	}
	return true;
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		sc.next();
		sc.next();
		int X = sc.nextInt();
		int Y = sc.nextInt();
		sc.nextLine();

		int maxX = Arrays.stream(sc.nextLine().split(" ", 0)).mapToInt(Integer::parseInt).max().getAsInt();
		int minY = Arrays.stream(sc.nextLine().split(" ", 0)).mapToInt(Integer::parseInt).min().getAsInt();
		System.out.println((Math.min(Y, minY) > Math.max(X, maxX)) ? "No War" : "War");
		sc.close();
	}
}


Measured memory_bytes: 28372
#include <iostream>
#include <string>
using namespace std;
int N;
string s1,s2;
long long int ans,mod=1000000007;

int main(){
  cin >> N;
  cin >> s1;
  cin >> s2;
  int i=0;
  if(s1[0]==s2[0]){ans=3;i=1;}
  else{ans=6;i=2;}
  while(i<N){
    if(s1[i]==s2[i]){
      if(s1[i-1]==s2[i-1])ans*=2;
      else ans*=1;
      i++;
    }
    else{
      if(s1[i-1]==s2[i-1])ans*=2;
      else ans*=3;
      i+=2;
    }
    ans%=mod;
  }
  cout << ans << endl;
  return 0;
}


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

#define SIZE_OF_ARRAY(array) sizeof(array)/sizeof(array[0])
typedef long long ll;

int main() {
    ll A,B,C;
    cin >> A >> B >> C;
    if(A==B && A!=C){
        cout << "Yes" << endl;
    } else if(A==C && A!=B) {
        cout << "Yes" << endl;
    } else if(B==C && B!=A) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// #include <boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision;
// using namespace __gnu_pbds;
#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define vi vector<int>
#define pii pair<int, int>
#define vii vector<pii>
#define mii map<int, int>
#define msi map<string, int>
#define pb push_back
#define ff first
#define ss second
#define coutp cout<<fixed<<setprecision
#define FR(n) for(int i=0;i<n;i++)
#define W(n) while(n--)
#define I(v) for(int i=0;i<v.size();i++)
#define srt(v) sort(v.begin(),v.end())
#define srtd(v) sort(v.begin(),v.end(),greater<int> ())
#define ALL(v) v.begin(),v.end()
#define IT(m) for(auto it=m.begin();it!=m.end();it++)
#define M 1000000007
#define imin INT_MIN
#define imax INT_MAX
#define SIEVE 100000

int n,m,k,a,b,mx=imin,mn=imax,mxi,mni;
double x,y;
string s,s1,s2;
vector<bool> prime(SIEVE+1,1);
vi primes;

void precomputation();
void solve();
void solvecase();
void sieve();
int pow(int, unsigned int, int);
bool miillerTest(int, int);
bool isPrime(int, int);

int32_t main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	clock_t start_time = clock();
	precomputation();
	solve();
	clock_t end_time = clock();
  	double elapsed_secs = double(end_time - start_time) / CLOCKS_PER_SEC;
	cerr<<elapsed_secs<<"\n";
	return 0;

}

void solvecase(){
	cin>>n;
	n%=1000;
	cout<<(1000-n)%1000;
}

void solve(){
	int T=1;
	//cin>>T;
	for(int i=1;i<=T;i++)
	{
		//cout<<"Case #"<<i<<":"<<" ";
		solvecase();
		cout<<"\n";
	}
}

void precomputation(){
}

void sieve(){
	prime[0]=0;
	prime[1]=0;
	for(int i=2;i<=SIEVE;i++){
		if(prime[i]){
			primes.pb(i);
			for(int j=i+i;j<=SIEVE;j+=i){
				prime[j]=0;
			}
		}
	}
	sort(primes.begin(),primes.end());
}

int pow(int X, unsigned int Y, int P)
{
	int res = 1;
	X = X % P;
	while (Y > 0)
	{
		if (Y & 1)
			res = (res*X) % P;
		Y = Y>>1;
		X = (X*X) % P;
	}
	return res;
}

bool miillerTest(int D, int N)
{
	int A = 2 + rand() % (N - 4);
	int X = pow(A, D, N);
	if (X == 1 || X == N-1)
	return true;
	while (D != N-1)
	{
		X = (X * X) % N;
		D *= 2;
		if (X == 1)	 return false;
		if (X == N-1) return true;
	}
	return false;
}

bool isPrime(int N, int K)
{
	if (N <= 1 || N == 4) return false;
	if (N <= 3) return true;
	int D = N - 1;
	while (D % 2 == 0)
		D /= 2;
	for (int i = 0; i < K; i++)
		if (!miillerTest(D, N))
			return false;
	return true;
}


Measured memory_bytes: 3848
H,W=map(int,input().split())
a=[list(map(str, input())) for _ in range(H)]

c=[]
for li in a:
    if li!=['.']*len(li):
        c.append(li)

b=[]
for lc in zip(*c):
    if lc!=('.',)*len(lc):
        b.append(lc)

for ld in zip(*b):
    print(''.join(ld))






Measured memory_bytes: 3188
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <stack>
#include <numeric>
#include <algorithm>
#include <tuple>
#include <stdio.h>
#include <bitset>
#include <limits.h>
#include <complex>
#include <deque>
#include <iomanip>
#include <list>
#include <cstring>
using namespace std;
#define pi pair<int,int>
#define pl pair<long long,long long>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
#define en cout << endl //セミコロンつけろ
//#define MM 1000000000
//#define MOD MM+7
typedef long long ll;
const int MM = 1e9;
const int MOD = MM+7;
const long double PI = acos(-1);
const long long INF = 1e15;
int dx[8] = {-1,0,1,0,-1,-1,1,1};
int dy[8] = {0,-1,0,1,-1,1,1,-1};
// 'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122
template<typename T>
T GCD(T u,T v){
    return v ? GCD(v,u%v) : u;
}
template<typename T>
T LCM(T x,T y){
    T gc = GCD(x,y);
    return x*y/gc;
}
struct edge {
    int to,cost;
};
int main(){
    int N; cin >> N;
    int u,v,w;
    vector<vector<edge> > g(N);
    vector<int> dist(N,-1);
    for (int i = 0; i < N-1; i++){
        cin >> u >> v >> w;
        u--; v--;
        w = w % 2;
        g[u].push_back({v,w});
        g[v].push_back({u,w});
    }
    dist[0] = 1;
    
    queue<int> que;
    que.push(0);
    while (que.size()){
        int now = que.front();
        que.pop();
        for (auto e : g[now]){
            if (dist[e.to] != -1) continue;
            if (dist[now] == 0){
                if (e.cost == 0) dist[e.to] = 0;
                else dist[e.to] = 1;
            } else if (dist[now] == 1){
                if (e.cost == 0) dist[e.to] = 1;
                else dist[e.to] = 0;
            }
            que.push(e.to);
        }
    }
    for (auto e : dist){
        if (e == -1) cout << 0 << endl;
        else cout << e << endl;
    }
}

Measured memory_bytes: 6784
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<string>

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
ll nc=1744;
bool check(vector<ll> v){
  for(int i=2;i<=9;i++){
    if(v[i]!=v[1]) return false;
  }
  for(int i=11;i<=12;i++){
    if(v[i]!=v[10]) return false;
  }
  for(int i=14;i<=15;i++){
    if(v[i]!=v[13]) return false;
  }
  for(int i=17;i<=18;i++){
    if(v[i]!=v[16]) return false;
  }
  for(int i=20;i<=21;i++){
    if(v[i]!=v[19]) return false;
  }
  for(int i=23;i<=30;i++){
    if(v[i]!=v[22]) return false;
  }
  return true;
}
vector<ll> v_change(vector<ll> v,ll f){
  vector<ll> ret=v;

  if(f==1){
    swap(ret[1],ret[24]);
    swap(ret[4],ret[27]);
    swap(ret[7],ret[30]);
    swap(ret[10],ret[21]);
    swap(ret[16],ret[18]);
  }
  else if(f==2){
    swap(ret[10],ret[12]);
    swap(ret[13],ret[18]);
    swap(ret[7],ret[22]);
    swap(ret[8],ret[23]);
    swap(ret[9],ret[24]);
  }
  else if(f==3){
    swap(ret[12],ret[19]);
    swap(ret[13],ret[15]);
    swap(ret[9],ret[28]);
    swap(ret[6],ret[25]);
    swap(ret[3],ret[22]);
  }
  else if(f==4){
    swap(ret[19],ret[21]);
    swap(ret[15],ret[16]);
    swap(ret[1],ret[28]);
    swap(ret[2],ret[29]);
    swap(ret[3],ret[30]);
  }
  return ret;
}
ll solve(vector<ll> v,ll num){
  if(check(v)) return num;
  if(num>=8) return 1744;
  if(num>=nc) return 1744;
  else{
    ll kans=1744;
    for(int i=1;i<=4;i++){
      vector<ll> kv=v_change(v,i);
      kans=min(kans,solve(kv,num+1));
      if(nc>kans){
        nc=kans;
        //cout<<"NC update:"<<nc<<endl;
      }
    }
    return kans;
  }
}

int main(){
  ll n;
  cin>>n;
  for(int i=0;i<n;i++){
    vector<ll> vec;
    vec.push_back(0);
    nc=1744;
    for(int j=0;j<30;j++){
      ll col;
      cin>>col;
      vec.push_back(col);
    }
    cout<<solve(vec,0)<<endl;
  }
}



Measured memory_bytes: 3184
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
using namespace std;

int main() {
	vector<int>a(5);
	for (int b = 0; b < 5; b++)cin >> a[b];
	sort(a.begin(), a.end());
	cout << a[4] << " " << a[3] << " " << a[2] << " " << a[1] << " " << a[0] << endl;
}

Measured memory_bytes: 3168
import java.lang.Integer.min
import java.util.*
import kotlin.math.max

fun readInt(): Int = readLine()!!.toInt()
fun readInts(): List<Int> = readLine()!!.split(" ").map { it.toInt() }

fun parseInt(): Int {
    var digit = System.`in`.read()
    while(digit <= 32) {
        digit = System.`in`.read()
    }

    val negative = digit == '-'.toInt()
    if (negative) {
        digit = System.`in`.read()
    }
    var res = 0
    while (digit in '0'.toInt()..'9'.toInt()) {
        res *= 10
        res += digit - '0'.toInt()
        digit = System.`in`.read()
    }
    return if (negative) -res else res
}

fun gcd(x : Int, y : Int) : Int {
    var a = x
    var b = y
    var r = 0
    while(b > 0) {
        r = a % b
        a = b
        b = r
    }
    return a
}

fun main() {
//    val t = readLine()!!.toInt()
    val t = 1

    for(testNumber in 1..t) {
        val n = readInt()
        val lpd = IntArray(n + 1) { i -> i }

        for(i in 2..n) {
            if (lpd[i] == i) {
                for (j in i..n step i) {
                    lpd[j] = min(lpd[j], i)
                }
            }
        }

        val ans = IntArray(n + 1) { 1 }

        for(i in 2..n) {
            val p = lpd[i]
            var e = 0
            var x = i

            while(x % p == 0) {
                x /= p
                ++e
            }

            ans[i] = (e + 1) * ans[x]
        }

        var s = 0L
        for(i in 1..n) s += 1L * i * ans[i]

        println(s)
    }
}

Measured memory_bytes: 131712
#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <unordered_map>
#include <vector>

using namespace std;

int gcd(int n, int m) {
    if (n == 0)
        return m;
    return gcd(m % n, n);
}

int bit_count(int i) {
    i = i - ((i >> 1) & 0x55555555);
    i = (i & 0x33333333) + ((i >> 2) & 0x33333333);
    i = (i + (i >> 4)) & 0x0f0f0f0f;
    i = i + (i >> 8);
    i = i + (i >> 16);
    return i & 0x3f;
}

int main() {
    int p, q, r;
    cin >> p >> q >> r;
    int m = p + q;
    m = min(m, q + r);
    m = min(m, r + p);
    cout << m << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <set>
using namespace std;
const int N = 502;

int n, x[N], ans[N * N];

struct Item {
    int pre, x, y; // in pre, x show y times
    bool operator < (const Item & o) const{
        return pre < o.pre;
    }
} it[N];

int cnt[N];

void print() {
    bool ok = 1;
    for (int i = 1; i <= n * n; i ++) {
        cnt[ans[i]] ++;
        if (cnt[ans[i]] == ans[i] && i != x[ans[i]]) {
            // printf("val = %d, cnt = %d, pos = %d\n", ans[i], cnt[ans[i]], i);
            ok = 0;
        } 
    }
    if (!ok) printf("No\n");
    else {
        printf("Yes\n");
        for (int i = 1; i <= n * n; i ++) {
            printf("%d ", ans[i]);
        }
    }
}

int main() {
    scanf("%d", &n);
    set<int> st;
    for (int i = 1; i <= n * n; i ++) {
        st.insert(i); 
    }
    for (int i = 1; i <= n; i ++) {
        scanf("%d", &x[i]); ans[x[i]] = i;
        it[i] = (Item){x[i] - 1, i, i - 1};
        st.erase(x[i]);
    }

    sort(it + 1, it + 1 + n);
    for (int i = 1; i <= n; i ++) {
        for (int j = 1; j <= it[i].y; j ++) {
            if (st.size()) {
                ans[ * st.begin() ] = it[i].x;
                st.erase(st.begin());
            }
        }
    }

    for (int i = 1; i <= n; i ++) {
        for (int j = 1; j <= n - it[i].x; j ++) {
            if (st.size()) {
                ans[ * st.begin() ] = it[i].x;
                st.erase(st.begin());
            }         
        }
    }

    print();
}

Measured memory_bytes: 13824