akhauriyash/Code-Regression huggingface dataset:
void main(){
  import std.stdio, std.string, std.conv, std.algorithm;

  int n, q; rd(n, q);
  auto tree=new SquareRootDecomposition(n);
  while(q--){
    auto args=readln.split.to!(int[]);
    if(args[0]==0){
      tree.update(args[1], args[2]+1, args[3]);
    }else{
      writeln(tree.rmin(args[1], args[2]+1));
    }
    // tree.show;
  }
}

class SquareRootDecomposition{
  import std.algorithm;
  int D=1, nil=-1;
  int[] val, buc, laz;
  this(int n){
    while(D*D<n) D++;
    val.length=D*D;
    buc.length=laz.length=D;
    fill(val, (1<<31)-1);
    fill(buc, (1<<31)-1);
    fill(laz, nil);
  }

  void update(int ql, int qr, int x){
    foreach(k; 0..D){
      int l=k*D, r=(k+1)*D;
      if(r<=ql || qr<=l){
        // 
      }else if(ql<=l && r<=qr){
        buc[k]=x;
        laz[k]=x;
      }else{
        push(k);
        foreach(i; max(l, ql)..min(r, qr)) val[i]=x;
        buc[k]=reduce!(min)(val[l..r]); 
      }
    }
  }

  int rmin(int ql, int qr){
    int ret=(1<<31)-1;
    foreach(k; 0..D){
      int l=k*D, r=(k+1)*D;
      if(r<=ql || qr<=l){
        // 
      }else if(ql<=l && r<=qr){
        chmin(ret, buc[k]);
      }else{
        push(k);
        foreach(i; max(l, ql)..min(r, qr)) chmin(ret, val[i]);
      }
    }
    return ret;
  }

  void push(int k){
    if(laz[k]<0) return;
    val[(k*D)..((k+1)*D)]=laz[k];
    laz[k]=-1;
  }

  void chmin(T)(ref T l, T r){
    if(l>r) l=r;
  }

  void show(){
    import std.stdio;
    writeln(buc);
    writeln(laz);
    writeln(val);
  }
}

void rd(T...)(ref T x){
  import std.stdio, std.string, std.conv;
  auto l=readln.split;
  assert(l.length==x.length);
  foreach(i, ref e; x) e=l[i].to!(typeof(e));
}


Measured memory_bytes: 3696
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for (int i = 0; i < n; ++i)
#define REP(i,k,n) for (int i = k; i <= n; ++i)
#define REPR(i,k,n) for (int i = k; i >= n; --i)
#define pb push_back
#define F first
#define mp make_pair
#define debug1(a) cout<<" a : "<<a<<"\n"
#define debug2(a,b) cout<<" a : "<<a<<" b : "<<b<<"\n"
#define debug3(a,b,c) cout<<" a : "<<a<<" b : "<<b<<" c : "<<c<<"\n"
#define M 1000000007

double dp[301][301][301];

double f(int c1, int c2, int c3, int n)
{
	if (c1<0 || c2<0 || c3<0) return 0.0;
	else if (dp[c1][c2][c3]>=0) return dp[c1][c2][c3];
	else if (c1==1 && c2==0 && c3==0) return 1*n;
	else if (c1==0 && c2==1 && c3==0) return 2*n;
	else if (c1==0 && c2==0 && c3==1) return 3*n;
	else dp[c1][c2][c3]=(c1*f(c1-1,c2,c3,n)+c2*f(c1+1,c2-1,c3,n)+c3*f(c1,c2+1,c3-1,n)+n)/(c1+c2+c3);
	return dp[c1][c2][c3];
}
signed main()
{
	//ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	int n;
	cin>>n;
	int a[n];
	int c1=0,c3=0,c2=0;
	rep(i,301)
	{
		rep(j,301)
		{
			rep(k,301) dp[i][j][k]=-1;
		}
	}
	rep(i,n)
	{
		cin>>a[i];
		if (a[i]==1) c1++;
		else if (a[i]==2) c2++;
		else c3++;
	}
	double ans=f(c1,c2,c3,n);
	cout<<fixed<<setprecision(11)<<ans;
}

Measured memory_bytes: 213376
#include <iostream>
#include <complex>
#include <cmath>
using namespace std;

#define X real()
#define Y imag()
#define PI M_PI
#define EPS (1e-10)
typedef complex<double> point;

double angle(point a,point b,point c){ //?§????????¨????????????¢??°
	double A=abs(b-c);
	double B=abs(c-a);
	double C=abs(a-b);
	return acos((B*B+C*C-A*A)/(2.0*B*C)); //??????????????????
}

bool judge(point p,point a,point b,point c){
	double A=angle(p,a,b);
	double B=angle(p,b,c);
	double C=angle(p,c,a);
	return (abs(A+B+C-2*PI)<EPS)? true : false;
}

int main(void){
	point a,b,c,p;
	double x1,y1,x2,y2,x3,y3,xp,yp;

	while(cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> xp >> yp){
		a.X=x1; a.Y=y1;
		b.X=x2; b.Y=y2;
		c.X=x3; c.Y=y3;
		p.X=xp; p.Y=yp;
		if(judge(p,a,b,c)) cout << "YES" << endl;
		else cout << "NO" << endl;
	}
	return 0;
}

Measured memory_bytes: 1280
n = int(input())
s = []
for i in range(n):
    s.append(int(input()))
s.sort()

if sum(s) % 10 != 0:
    print(sum(s))
else:
    for i in range(n):
        tmp = sum(s) - s[i]
        if tmp % 10 != 0:
            print(tmp)
            exit()
    print(0)


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

int a[(int)2e3+5];

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

    int n;
    cin>>n;

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

    int sol=0;

    sort(a+1,a+n+1);

    for(int i=1;i<=n;i++){
        for(int j=i+1;j<=n;j++){
            for(int k=j+1;k<=n;k++){
                if(a[i]+a[j]<=a[k])
                    break;
                sol++;
            }
        }
    }

    cout<<sol;
}



Measured memory_bytes: 256
a, b = map(int, input().split())

def xorEO(e, o):
  return int((o + 1 - e) / 2) % 2

if a == b:
  print(a)
elif a % 2 == 0 and b % 2 != 0: # even, odd
   print(xorEO(a, b))
elif a % 2 == 0 and b % 2 == 0: # even, even
  print(xorEO(a, b - 1) ^ b)
elif b % 2 != 0: # odd, odd
  print(a ^ xorEO(a + 1, b))
else:  # odd, even
  print(a ^ xorEO(a + 1, b - 1) ^ b)

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

// types
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;

// macros
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};


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

  ll r,g,b;
  cin >> r >> g >> b;

  ll a = r*100+g*10+b*1;
  if(a%4 == 0)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <list>
#include <set>
#include <stack>
#include <queue>
#include <cmath>
#include <algorithm>
#include <utility>
#include <functional>
#include <fstream>
#define debug(x) cout << #x << " = " << x << endl
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define repr(i,n) for(int i = (n); i > -1; i--)
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const double EPS = 1e-9;


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

  int n;
  cin>>n;
  vector<int> v;
  int x;
  rep(i,n) {
    cin>>x;
    v.push_back(x);
  }
  sort(v.begin(), v.end());
  map<int, int> m;
  rep(i,n) m[v[i]]++;
  int ans = 0;
  for(int i = v.size() - 1; i >= 0; i--) {
    if(m[v[i]] == 0) continue;
    int p;
    FOR(j, 1, 32) {
      if(v[i] < (int)pow(2, j)) {
        p = pow(2,j) - v[i];
        break;
      }
    }
    if(m[p] > 0 && !(m[p] == 1 && p == v[i])) {
      ans++;
      m[p]--;
    }
    m[v[i]]--;
  }
  cout << ans << endl;


  return 0;

}


Measured memory_bytes: 19828
import java.util.*;

public class Main{

  public static void main(String[] args) {

    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int[] a = new int[n];

    for(int i = 0;i < n;i++){
      a[i] = sc.nextInt();
    }

    Arrays.sort(a);

    int x = a[0] -a[n-1];
    int y = Math.abs(x);

    System.out.println(y);




  }

}

Measured memory_bytes: 23252
n,l=map(int,input().split())
A=[int(i) for i in input().split()]

wa=[A[i]+A[i+1] for i in range(n-1)]
lim=max(wa)
knot=wa.index(lim)

go=False
if l<=lim:
    print("Possible")
    go=True
else:
    print("Impossible")
    
if go:
    for i in range(knot):
        print(i+1)
    for i in range(n-knot-2):
        print(n-i-1)
    print(knot+1)
        

Measured memory_bytes: 14076
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <ctype.h>
#define abc 'a'-'A'
int main(void)
{
  int n,k;
  char s[55];

  scanf("%d %d",&n,&k);
  k--;
  scanf("%s",s);
  s[k] = tolower(s[k]);

  printf("%s\n",s);

  return 0;
}


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

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

int main() {
  int N;
  long long int X;
  cin >> N >> X;
  vector<long long int> x(N);
  for (int i = 0; i < N; i++){
    cin >> x.at(i);
    x.at(i) -= X;
    if (x.at(i) < 0){
      x.at(i) *= -1;
    }
  }
  sort(x.begin(), x.end());
  int a = 0;
  for (int i = 0; i < N; i++){
    a = gcd (x.at(i), a);
  }
  cout << a << endl;
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9+7;
int main() {
    ll n,k,s;
    cin >> n >> k >> s;
    vector<ll>ans(n,s);
    for(ll i=k;i<n;i++){
        ans[i]--;
      if(s==1)ans[i]+=2;
    }
    for(ll i=0;i<n;i++){
        cout << ans[i] << " ";
    }
    cout << endl;
}

Measured memory_bytes: 3968
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7
#s=input().rstrip()
u=input().rstrip()
if u=="A":
    print("T")
elif u=="T":
    print("A")
elif u=="G":
    print("C")
else:
    print("G")

Measured memory_bytes: 3316
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<algorithm>
#include <functional>

using namespace std;

int INF = 10000000;

bool f[50][50];
bool cell[50][50];
int w,h;

int dfs(int i,int j)
{
	if(i < 0 || j < 0 || i >= h || j >= w || f[i][j])return 0;

	if(!cell[i][j])return 0;

	f[i][j] = true;

	dfs(i-1,j);
	dfs(i+1,j);
	dfs(i,j+1);
	dfs(i,j-1);
	
	dfs(i-1,j-1);
	dfs(i-1,j+1);
	dfs(i+1,j-1);
	dfs(i+1,j+1);

	return 1;
}

int cast()
{
	int sum = 0;
	for(int i = 0;i < h;i++)
	{
		for(int j = 0;j < w;j++)
		{
			sum += dfs(i,j);
		}
	}
	return sum;
}



int main()
{

	while(1)
	{
		cin >> w >> h;

		if(!w && !h)break;

		memset(f,0,50*50*sizeof(bool));
		memset(cell,0,50*50*sizeof(bool));

		for(int i = 0;i < h;i++)
		{
			for(int j = 0;j < w;j++)
			{
				cin >> cell[i][j];
			}
		}

		cout << cast() << endl;
	
	}

  return 0;
}

Measured memory_bytes: 1272
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] p = new int[N];
        for (int i = 0; i < N; i++) {
            p[i] = sc.nextInt();
        }

        int total = 0;
        for (int i : p) {
            total += i;
        }

        int max = 0;
        for (int i : p) {
            if (max < i) {
                max = i;
            }
        }

        System.out.println(total - max / 2);
    }
}


Measured memory_bytes: 21588
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const int inf = 1<<30;
const int mod = 1e9+7;

int main() {
  int H, W; cin >> H >> W;
  int N; cin >> N;
  vector<int> a(N);
  int ans[110][110];
  for(int i = 0; i < N; i++) cin >> a[i];
  int y = 0, x = 0;
  bool f = true;
  for(int i = 0; i < N; i++) {
    while(a[i]--) {
      if(f) {
        ans[y][x++] = i+1;
        if(x==W) {
          y++;
          x--;
          f = false;
        }
      } else {
        ans[y][x--] = i+1;
        if(x==-1) {
          y++;
          x++;
          f = true;
        }
      }
    }
  }

  for(int i = 0; i < H; i++) {
    for(int j = 0; j < W; j++) {
      if(j) cout << " ";
      cout << ans[i][j];
    }
    cout << endl;
  }

  return 0;
}


Measured memory_bytes: 384
def solve():
    N, W = map(int, input().split())
    weight = [0 for i in range(N)]
    value = [0 for i in range(N)]
    for i in range(N):
        weight[i], value[i] = map(int, input().split())
    dp = [W + 1 for i in range(N * 1000 + 1)]
    dp[0] = 0
    V = 0

    for i in range(N):
        wi = weight[i]
        vi = value[i]
        for v in range(V, -1, -1):
            w = dp[v] + wi
            if dp[v + vi] <= w: continue
            dp[v + vi] = w
        V += vi

    for i in range(V, -1, -1):
      if dp[i] <= W: return i
    return 0

print(solve())


Measured memory_bytes: 7088
m :: Int
m = 1000000007

fpm :: Int -> Int -> Int
fpm a e
  | e == 0 = 1
  | odd e = p * p `mod` m * a `mod` m
  | otherwise = p * p `mod` m
  where
  p = fpm a (e `div` 2)

main :: IO ()
main = do
  n <- read <$> getLine
  putStrLn $ show $ (fpm 10 n + m - (fpm 9 n) * 2 + fpm 8 n) `mod` m


Measured memory_bytes: 3876
#include <stdio.h>
#define rep(i,l,r)for(int i=(l);i<(r);i++)

int n;
int a[200010];
int q[200010];
int c[200010];

int f(int m){
	int qc=0;
	q[0]=a[0];
	c[0]=1;
	qc=1;
	rep(i,1,n){
		if(a[i]>q[qc-1]){
			q[qc]=a[i];
			c[qc]=1;
			qc++;
		}else if(a[i]==q[qc-1]){
			c[qc-1]++;
		}else{
			while(qc&&q[qc-1]>a[i])qc--;
			if(qc==0||q[qc-1]<a[i]){
				q[qc]=a[i];
				c[qc]=2;
				qc++;
			}else{
				c[qc-1]++;
			}
		}
		
		if(c[qc-1]>m){
			int t=a[i];
			//末尾は(t,>m)なので、これをpopして(t-1,*)をincしたい
			while(c[qc-1]>m){
				if(t==1)return 0;
				qc--;//pop
				if(qc&&q[qc-1]==t-1){
					c[qc-1]++;
				}else{
					q[qc]=t-1;
					c[qc]=2;
					qc++;
				}
				t--;
			}
			//(a[i],1)を追加し直す
			q[qc]=a[i];
			c[qc]=1;
			qc++;
		}
	}
	return 1;
}


int main(){
	scanf("%lld",&n);
	rep(i,0,n)scanf("%lld",a+i);
	
	int lans=0,rans=200010;//lはng,rはok
	while(rans-lans>1){
		int m=(lans+rans)/2;
		if(f(m))rans=m;
		else lans=m;
	}
	printf("%d",rans);
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define up(i, a, b) for (int i = a, _b = b; i <= _b; i++)
#define down(i, a, b) for (int i = a, _b = b; i >= _b; i--)
#define long long long
#define endl '\n'
#define X first
#define Y second
#define II pair<int, int>
#define debug(X) cerr << #X << " = " << X << endl
#define debug2(X, Y) cerr << #X << " = " << X << " , " << #Y << " = " << Y << endl
#define show(X, a, b) { cerr << #X << " = "; up(_, a, b) cerr << X[_] << " "; cerr << endl; }
#define gc getchar
#define pc putchar
using namespace std;
inline void read(int &x) {
        register int c = gc();
        x = 0;
        int neg = 0;
        for (; ((c<48 || c>57) && c != '-'); c = gc());
        if(c=='-') {neg=1; c=gc();}
        for(; c>47 && c<58; c = gc()) {x = (x<<1) + (x<<3) + c - 48;}
        if(neg) x=-x;
}
inline void writeln(int x) {

        char buffor[21];
        register int i=0;
        int neg=0; if (x<0) {neg=1; x= -x;}
        do {
                buffor[i++]=(x%10)+'0';
                x/=10;
        } while(x);
        i--;
        if (neg) pc('-');
        while(i>=0) pc(buffor[i--]);
        pc('\n');
}
int n, a[200010];
map<int, int> rr;
priority_queue<int, vector<int>, greater<int> > pq[200010];
deque<int> dq;
void input() {
        cin >> n;
        up(i, 1, n) cin >> a[i], rr[a[i]] = 1;
        int cnt = 0;
        for (auto u: rr) rr[u.X] = ++cnt;
        up(i, 1, n) a[i] = rr[a[i]];
}
void merge(int u, int v) {
        if (pq[u].size() > pq[v].size()) pq[u].swap(pq[v]);
        while (!pq[u].empty()) pq[v].push(pq[u].top()), pq[u].pop();
}
void solve() {
        up(i, 1, n) pq[i].push(a[i]), dq.push_back(i);
        long res = 0;
        up(i, 1, n) {
            while (dq.size() > 1 && pq[dq.front()].top() != i) {
                int u = dq.front(); dq.pop_front();
                int v = dq.front(); merge(u, v);
            }
            int v = dq.front(); dq.pop_front();
            pq[v].pop(); res += pq[v].size();
            if (!pq[v].empty()) dq.push_back(v);
        }
        cout << res << endl;
}
int main() {
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);

  #ifdef I_Love_Pork
  #define TASK "tmp"
        freopen(TASK ".inp","r",stdin);
        freopen(TASK ".out","w",stdout);
  #endif


        input();
        solve();



        return 0;
}



Measured memory_bytes: 27840
//#include<iostream>
//#include<algorithm>
//#include<string>
//#include <cmath>
//#include <vector>
#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define REP(x,n) for(int x=0;x<n;x++)

//vector//
#define vei vector<int> 
#define velli vector<long long int> 
#define pb(x) push_back(x) // 末尾にxを加える
#define pb2 pop_back() // 末尾削除
#define all(x) (x).begin(),(x).end() //イテレーター
#define be(x) (x).begin()
//auto  auto begin = v.begin()とか

typedef pair<int,int> P;  //q(p.first,p.second)

int main(){
    // 入力
    int n, m; cin >> n >> m;
    vector<vector<int>> s(m);
    for(int i=0; i<m; i++){
        int k; cin >> k;
        for(int j=0; j<k; j++){
            int ss; cin >> ss;
            ss--;
            s[i].push_back(ss);
        }
    }
    vector<int> p(m);
    for(int i=0; i<m; i++){
        cin >> p[i];
    }

    int ans = 0;
    // bit全探索　swichのonoff全通り
    for(int bit=0; bit < (1 << n); bit++){

        int ok = 1;

        for(int li=0; li<m; li++){
            int num_swi = 0;

            for(int i=0; i<s[li].size(); i++){
                if(bit & (1 << s[li][i])) num_swi++;
            }

            if(num_swi % 2 != p[li]){
                ok = 0;
                break;
            }

        }

        if(ok==1) ans++;

    }

    cout << ans;

}

Measured memory_bytes: 3620
var line = require('fs').readFileSync('/dev/stdin', 'utf8').split(/ |\n/);
var n = Number(line[0]);
var q = Number(line[1]);

var name = new Array(n);
var rest = new Int32Array(n);
var next = new Int32Array(n);

(function init() {
    var i, j = 2;
    for (i = 0; i < n; i++) {
        name[i] = line[j++];
        rest[i] = Number(line[j++]);
        next[i] = i + 1;
    }
})();

(function simulate() {
    var time = 0, idx, end = false, delta;
    while (!end) {
        end = true;
        for (idx = 0; idx < n; idx = next[idx]) {
            if (rest[idx] == 0) continue;
            end = false;
            delta = (rest[idx] < q) ? rest[idx] : q;
            rest[idx] -= delta;
            time += delta;
            if (rest[idx] == 0) {
                console.log(name[idx], time);
                if (idx != 0 && idx != n - 1) {
                    next[idx - 1] = next[idx];
                }
            }
        }
    }
})();

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

int main() {
    int n;
    cin >> n;
    int ans = 0;
    rep(i,n){
        int a;
        cin >> a;
        if((i+1)%2==1&&a%2==1){
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3488
while true do
  num=Array.new
  str=gets.chomp
  number=str.split
  num[0]=number[0].to_i
  num[1]=number[1].to_i
  if num[0]==0 && num[1]==0 then
    break
  end
  for i in 1..num[0] do
    for j in 1..num[1] do
      if i%2==1 && j%2==1 then
        print "#"
      elsif i%2==1 && j%2==0 then
        print "."
      elsif i%2==0 && j%2==1 then
        print "."
      else
        print "#"
      end
    end
    print "\n"
  end
  print "\n"
end

Measured memory_bytes: 8728
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define INF 999999999
#define rep(i,n) for(int i=0;i<n;i++)
const int MOD = 1000000007;


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

    for(int i=pow(n,0.5)+1;i>0;i--){
        if( n%i == 0 ){
            x = i;
            y = n/i;
            break;
        }
    }
    cout << (x-1)+(y-1) << endl;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define per(i, n) for (int i = (int)(n-1); i >= 0; i--)
#define sz(x) int(x.size())
#define all(x) (x).begin(), (x).end()
#define INF 2e9
#define LINF 1e18
typedef long long ll;
typedef pair<int, int> P;

int main() {
    int n;
    ll k;
    cin >> n >> k;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];
    
    vector<int> cnt(40);
    rep(i, n) {
        ll tmp = a[i];
        rep(j, 40) {
            if (tmp & 1) cnt[j]++;
            tmp >>= 1;
        }
    }

    ll x = 0;
    ll y = pow(2, 39);
    rep(i, 40) {
        if (cnt[39-i] < (n+1)/2) {
            if (x + y <= k) x += y;
        } 
        y /= 2;
    }
    ll ans = 0;
    rep(i, n) {
        ans += x^a[i];
    }
    cout << ans << endl;
}


Measured memory_bytes: 1024
A, B, K = map(int,input().split())

for i in range(K):
    if i%2==0:
        if A%2==1:
            A=A-1
        A=A/2
        B=B+A
    else:
        if B%2==1:
            B=B-1
        B=B/2
        A=B+A

print(int(A),int(B))



Measured memory_bytes: 2940
package main

import(
    "fmt"
)



func main() {
    var a,b,c int
    fmt.Scan(&a,&b,&c)
    ans := c
    switch{
        case b==c:
            ans = a
        case a==c:
            ans = b
    }
    fmt.Println(ans)
}





func abs32(a int) int {
    if a<0{
        return -a
    }
    return a
}

func abs64(a int64) int64 {
    if a<0{
        return -a
    }
    return a
}

func min32(a, b int) int {
    if a >= b {
        return b
    }
    return a
}

func max32(a, b int) int {
    if a >= b {
        return a
    }
    return b
}

func min64(a, b int64) int64 {
    if a >= b {
        return b
    }
    return a
}

func max64(a, b int64) int64 {
    if a >= b {
        return a
    }
    return b
}

func gcd(a, b int64) int64 {
    if a % b == 0 {
        return b
    } else {
        return gcd(b, a%b)
    }
}

func lcm(a, b int64) int64 {
    return a / gcd(a, b) * b
}

func scanNums(len int) (nums []int){
    var num int
    for i:=0; i<len; i++{
        fmt.Scan(&num)
        nums = append(nums,num)
    }
    return
}

func scanNums64(len int) (nums []int64){
    var num int64
    for i:=0; i<len; i++{
        fmt.Scan(&num)
        nums = append(nums,num)
    }
    return
}

func scanString(len int) (str []string){
    var s string
    for i:=0; i<len; i++{
        fmt.Scan(&s)
        str = append(str,s)
    }
    return
}

func scanTwoNums(n,m int) ([][]int){
    Nums := make([][]int, n)
    for i:=0; i<n; i++{
        Nums[i] = make([]int, m)
    }
    return Nums
}


Measured memory_bytes: 512
{-# LANGUAGE BangPatterns #-}
import Control.Arrow
import Control.Applicative
import Control.Monad.Fix
import Control.Monad.ST
import Data.Int
import Data.Foldable
import Data.List
import qualified Data.Vector as V
import qualified Data.Vector.Unboxed as VU
import qualified Data.ByteString.Char8 as B
import Debug.Trace

solve :: Int -> Int -> Int -> VU.Vector Int -> Int
solve !n !z !w !an = if n == 1
  then abs (an VU.! 0 - w)
  else max (abs $ an VU.! (n - 1) - w) (abs $ an VU.! (n - 2) - an VU.! (n - 1))

main = do
  let readInt :: Integral a => B.ByteString -> Maybe (a, B.ByteString)
      readInt = fmap (first fromIntegral . second B.tail) . B.readInt

  (n, z, w) <-
    (\vec -> (vec VU.! 0, vec VU.! 1, vec VU.! 2))
    .   VU.unfoldrN 3 readInt
    <$> B.getLine
  an <- VU.unfoldrN n readInt <$> B.getLine
  print $ solve n z w an


Measured memory_bytes: 764
#include <cstdio>
#include <iostream>
#include <algorithm>
#define maxn 100005
using namespace std;

typedef long long ll;
ll a[maxn], b[maxn], c[maxn];
// a[i] means at the i-th day do activity a, the biggest value of happiness

int main(){
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    for (int i = 0; i < n; ++i){
        cin >> a[i] >> b[i] >> c[i];
    }
    for (int i = 1; i < n; ++i){
        a[i] += max(b[i - 1], c[i - 1]);
        b[i] += max(a[i - 1], c[i - 1]);
        c[i] += max(b[i - 1], a[i - 1]);
    }
    cout << max(max(a[n - 1], b[n - 1]), c[n - 1]) << endl;
    return 0;
}

Measured memory_bytes: 2560
#include<algorithm>
#include<iostream>
using namespace std;
double concentration(int sugar, int water) {
	double ds = (double)sugar;
	double dw = (double)water;
	return ds / (ds + dw);
}
int main() {
	int A, B, C, D, E, F;
	cin >> A >> B >> C >> D >> E >> F;
	int max_a = F / (100 * A);
	int max_b = F / (100 * B);
	int max_c = F / C;
	int max_d = F / D;
	double con_e = concentration(E, 100);
	double max_con = -0.5;
	int max_water = 0;
	int max_sugar = 0;
	for (int i = 0;i <= max_a;i++) {
		for (int j = 0;j <= max_b;j++) {
			for (int k = 0;k <= max_c;k++) {
				for (int l = 0;l <= max_d;l++) {
					//i = 0, 1, 2, ..., max_a - 1;
					int water_a = 100 * A*i;
					int water_b = 100 * B*j;
					int sugar_c = C*k;
					int sugar_d = D*l;
					int all_mass = water_a + water_b + sugar_c + sugar_d;
					double all_con = concentration((sugar_c + sugar_d), (water_a + water_b));
					if (all_mass <= F) {
						if (all_con <= con_e) {
							if (all_con > max_con) {
								max_con = all_con;
								max_water = water_a + water_b;
								max_sugar = sugar_c + sugar_d;
 
 
							}
						}
					}
 
				}
			}
		}
	}
	cout << max_water+max_sugar << " " << max_sugar << endl;
}

Measured memory_bytes: 256
n = int(input())

dic = {"AC": 0, "WA": 0, "TLE": 0, "RE": 0}

for _ in range(n):
  dic[input()] += 1

print("AC x " + str(dic["AC"]))
print("WA x " + str(dic["WA"]))
print("TLE x " + str(dic["TLE"]))
print("RE x " + str(dic["RE"]))

Measured memory_bytes: 9196
#include <bits/stdc++.h>
#define fi first
#define se second
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define space putchar(' ')
#define enter putchar('\n')
#define MAXN 200005
#define eps 1e-12
//#define ivorysi
using namespace std;
typedef long long int64;
typedef unsigned int u32;
typedef double db;
template<class T>
void read(T &res) {
    res = 0;T f = 1;char c = getchar();
    while(c < '0' || c > '9') {
        if(c == '-') f = -1;
        c = getchar();
    }
    while(c >= '0' && c <= '9') {
        res = res * 10 + c - '0';
        c = getchar();
    }
    res *= f;
}
template<class T>
void out(T x) {
    if(x < 0) {x = -x;putchar('-');}
    if(x >= 10) {
        out(x / 10);
    }
    putchar('0' + x % 10);
}
int N,p[MAXN],tot;
int st[2][MAXN][19],len[MAXN],pos[MAXN];
pii t[MAXN];
vector<int> son[MAXN];
set<pii > S;
int query_min(int k,int l,int r) {
    int s = len[r - l + 1];
    return min(st[k][l][s],st[k][r - (1 << s) + 1][s]);
}
int build_tree(int l,int r) {
    if(r < l) return 0;
    int k = (l & 1);
    int a = query_min(k,l,r);
    int b = query_min(k ^ 1,pos[a] + 1,r);
    t[++tot] = mp(a,b);
    int res = tot;
    son[res].pb(build_tree(l,pos[a] - 1));
    son[res].pb(build_tree(pos[a] + 1,pos[b] - 1));
    son[res].pb(build_tree(pos[b] + 1,r));
    return res;
}
void Solve() {
    read(N);
    for(int i = 1 ; i <= N ; ++i) {
        read(p[i]);
        st[i & 1][i][0] = p[i];
        st[(i & 1) ^ 1][i][0] = 0x7fffffff;
        pos[p[i]] = i;
    }
    for(int k = 0 ; k <= 1 ; ++k) {
        for(int j = 1 ; j <= 18 ; ++j) {
            for(int i = 1 ; i <= N ; ++i) {
                if(i + (1 << j) - 1 > N) break;
                st[k][i][j] = min(st[k][i][j - 1],st[k][i + (1 << j - 1)][j - 1]);
            }
        }
    }
    for(int i = 2 ; i <= N ; ++i) {
        len[i] = len[i / 2] + 1;
    }
    int rt = build_tree(1,N);
    S.insert(mp(t[rt].fi,rt));
    while(!S.empty()) {
        auto b = *S.begin();S.erase(S.begin());
        out(t[b.se].fi);space;out(t[b.se].se);space;
        for(auto k : son[b.se]) {
            if(k) S.insert(mp(t[k].fi,k));
        }
    }
}
int main() {
#ifdef ivorysi
	freopen("f1.in","r",stdin);
#endif
    Solve();
}


Measured memory_bytes: 49152
n = int(input())
alfa = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w','x', 'y', 'z']
re = []
while n > 26:
    re.append(int(n % 26))
    if int(n%26) == 0:
        n -= 1
    n = int(n / 26)
re.append(n % 26)
result = ''
for i in range(len(re)):
    result += alfa[re[len(re)-i-1]-1]
print(result)


Measured memory_bytes: 9132
A = int(input())
B = int(input())
C = int(input())
X = int(input())

N = 0
a = b = c = 0

for c in range(C+1):
    if (X-50*c)%100 == 0:
        for b in range(B+1):
            if (X-50*c-100*b)%500 == 0:
                if 0<= int((X-50*c-100*b)/500) <= A:
                    N += 1

print(N)

Measured memory_bytes: 3060
def is_ok(h, w, ptn, c, k):
    cnt = 0

    for i in range(h):
        for j in range(w):
            ch = c[i][j]
            if ch == '#' and i not in ptn and (j + h) not in ptn:
                cnt += 1

    if cnt == k:
        return True
    else:
        return False


h, w, k = map(int, input().split())
c = [input() for _ in range(h)]

n = h + w
cnt = 0

for i in range(2 ** n):
    ptn = []
    for j in range(n):
        if ((i >> j) & 1):
            ptn.append(j)
    if is_ok(h, w, ptn, c, k):
        cnt += 1

print(cnt)


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

int main(void) {
	int h, w, k;
	string c[6];
	int ans = 0;
	cin >> h >> w >> k;
	for(int i = 0; i < h; i++) {
		cin >> c[i];
	}
	for(int row = 0; row < (1 << h); row++) {
		for(int col = 0; col < (1 << w); col++) {
			int black = 0;
			for(int i = 0; i < h; i++) {
				for(int j = 0; j < w; j++) {
					if(!((row >> i) & 1) && !((col >> j) & 1)
					   && c[i][j] == '#') {
						black++;
					}
				}
			}
			if(black == k) {
				ans++;
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3628
#include<iostream>

using namespace std;

int main(){
    char a;
    cin >> a;
    if(a=='A')
    {
        cout << "T" << endl;
    }
    else if (a=='C')
    {
        cout << "G" << endl;
    }
    else if (a=='G')
    {
        cout << "C" << endl;
    }
    else if (a=='T')
    {
        cout << "A" << endl;
    }
    return 0;
}

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

int main(){
  int r,g,b,n;
  cin>>r>>g>>b>>n;
  int ans=0;
  for(int i=0; i<=n/r; ++i){
    for(int j=0; j<=n/g; ++j){
      if((n-i*r-j*g)%b==0 && (n-i*r-j*g)/b>=0)++ans;
    }
  }

  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <iomanip>
#include <queue>
#include <deque>
#include <map>
#include <unordered_map>
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define repr(e,x) for(auto& e:x)
using namespace std;
typedef long long ll;

int N,M;
map<int,int> m;

int main(){
    cin>>N>>M;
    rep(i,M){
        int a,b;
        cin>>a>>b;
        m[a]++;
        m[b]++;
    }

    repr(e,m){
        if(e.second&1){
            cout<<"NO"<<endl;
            return 0;
        }
    }

    cout<<"YES"<<endl;
}

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

#define int long long
#define endl "\n"
#define REP(i,a,n) for(int i=a;i<n;++i)
#define RUP(a,b) ((a+b-1)/(b))
#define SORTG(v) sort(v.begin(),v.end(),greater<>())
#define SORT(v) sort(v.begin(),v.end())
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define MOD 1000000007
#define INF LLONG_MAX/3

typedef long long ll;
typedef pair<int,int> Pii;
typedef tuple<int,int,int> Tiii;
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef vector<string> Vs;

template<class T> void chmax(T& a, T b) {if(a<b){a=b;}}
template<class T> void chmin(T& a, T b) {if(a>b){a=b;}}
void YesNo(int a) {if(a){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}}
void YESNO(int a) {if(a){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}}
void AorB(int a,string b,string c) {if(a){cout<<b<<endl;}else{cout<<c<<endl;}}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
void start(){cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);}

signed main(){start();
    int a,b,c;
    cin>>a>>b>>c;
    if(a%2==0 || b%2==0 || c%2==0){
        cout<<0<<endl;
        return 0;
    }
    cout<<min({a*b,b*c,c*a})<<endl;
    return 0;
}


Measured memory_bytes: 256
import numpy as np
N, M = list(map(int, input().split()))
LR_array = np.array([[int(i) for i in input().split()] for i in range(M)])
num_range_accepted_by_gate = np.vstack([LR_array[:,0], LR_array[:,0]+LR_array[:,1]])
#num_range_accepted_by_gate = [[LR_array[i][0], LR_array[i][0]+LR_array[i][1]] for i in range(M)]
min_number_accepted_by_all_gates = max(LR_array[:,0])
max_number_accepted_by_all_gates = min(LR_array[:,1])
if(max_number_accepted_by_all_gates - min_number_accepted_by_all_gates < 0):
    print(0)
else:
    print(max_number_accepted_by_all_gates - min_number_accepted_by_all_gates + 1)

Measured memory_bytes: 31620
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include<numeric>
#include<cmath>
#include<map>
#include<iomanip>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int,int>;
using pll = pair<ll,ll>;
using pdd = pair<double,double>;
using vvi = vector<vector<int> >;
using vvll =  vector<vector<ll> >;

const ll inf = 1LL << 60;
vector<pdd> points;
int N;


double calc_dist(pdd p1, pdd p2){
	double res = pow(p1.first - p2.first, 2) + pow(p1.second - p2.second, 2);
	return sqrt(res);
}

double calc_r(pdd p){
	double maxi = 0;
	REP(i,N){
		maxi = max(maxi, calc_dist(p, points[i]));
	}
	return maxi;
}

double tripley(double x1){
	double left = 0;
	double right = 1000;
	while(right - left > pow(10,-8)){
		double nowl = (2*left + right) / 3;
		double nowr = (left + 2*right) / 3;
		double leftmax = calc_r(pdd(x1,nowl));
		double rightmax = calc_r(pdd(x1, nowr));
		if(leftmax > rightmax) left = nowl;
		else right = nowr;
	}
	return left;
}

pdd triplex(){
	double left = 0;
	double right = 1000;
	while(right - left > pow(10,-8)){
		double c1 = (2*left + right) / 3;
		double c2 = (left + right*2) / 3;
		double y1 = tripley(c1);
		double y2 = tripley(c2);
		if(calc_r(pdd(c1,y1)) > calc_r(pdd(c2,y2))) left = c1;
		else right = c2;
	}

	return pdd(left, tripley(left));
}

int main(){
    cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	cin >> N;
	points.resize(N);
	
	REP(i,N){
		double x,y; cin>>x >>y;
		points[i] = pdd(x,y);
	}
	
	//cout << minx << " " << miny << endl;
	pdd ansp = triplex();
    //cout << ansp.first << " " << ansp.second << endl;
	cout << calc_r(ansp) << endl;
}

Measured memory_bytes: 3816
#include <bits/stdc++.h>
#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define sort(a) sort((a).begin(),(a).end())
#define rev(a) reverse((a).begin(),(a).end())
using db = double;
using namespace std;
typedef long long ll;


int main() {
  string s;
  cin >> s;
  int n = 0;
  rep(i,4) {
    if (s[i] == '+') n++;
    if (s[i] == '-') n--;
  }
  cout << n << endl;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
  static class Count { int value; }
  public static void main(String[] args) {
    String s = new Scanner(System.in).next();
    HashMap<Character,Count> map = new HashMap<>();
    for (int i = 0; i < 4; i++) {
      char ch = s.charAt(i);
      Count x = map.get(ch);
      if (x == null) {
        x = new Count();
        map.put(ch, x);
      }
      x.value++;
    }
    if (map.size() != 2) {
      System.out.println("No");
      return;
    }
    for (Count c : map.values()) {
      if (c.value != 2) {
        System.out.println("No");
        return;
      }
    }
    System.out.println("Yes");
  }
}

Measured memory_bytes: 21588
#include <iostream>
using namespace std;
int main(void){
    string S;
    char tap[2];
    tap[0] = 'L';
    tap[1] = 'R';
    cin >> S;
    int n = S.length();
    int i;
    for(i=1;i<=n;i++){
        if((i%2==1 && S[i-1]==tap[0])||(i%2==0 && S[i-1]==tap[1])){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes";
    return 0;
}


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

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

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcount

#define INF 1e16

ll t;
ll H,h0,m0,s0;

int main(){
  while(1){
    cin>>H>>h0>>m0>>s0;
    if(H==0)break;
    ll d=119*H-1;
    ll n=s0*d;
    ll h=h0,m=m0;
    ll mod=360*10*H*d;
    while(1){
      ll ang_h=(3600*h*d+60*m*d+n)%mod;
      ll ang_m=(60*H*m*d+H*n)%mod;
      ll ang_s=(60*H*n)%mod;
      ang_h=(ang_h-ang_s+mod)%mod;
      ang_m=(ang_m-ang_s+mod)%mod;
      if(ang_m!=ang_h&&min(ang_m,ang_h)==mod-max(ang_m,ang_h))break;
      n++;
      if(n==60*d)n=0,m++;
      if(m==60)m=0,h++;
      if(h==H)h=0;
    }
    ll g=__gcd(n,d);
    cout<<h<<" "<<m<<" "<<n/g<<" "<<d/g<<endl;
  }
  return 0;
}



Measured memory_bytes: 3080
import sys
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def POW(x, y):
    if y == 0:
        return 1
    elif y == 1:
        return x
    elif y % 2 == 0:
        return POW(x, y // 2) ** 2 % MOD
    else:
        return POW(x, y // 2) ** 2 * x % MOD
def mod_factorial(x, y): return x * POW(y, MOD - 2) % MOD
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 input()
from collections import Counter

# prime numbers
_nprime = 10 ** 5 + 1
primes = list(range(int(_nprime) + 1))
primes[1] = 0
for i in range(2, int((_nprime + 1) ** 0.5) + 1):
    if primes[i]:
        for j in range(2 * i, _nprime + 1, i):
            primes[j] = 0

def main():
    S = SI()
    ans = [0, 0]
    i = 0
    for s in S:
        if int(s) == i:
            ans[0] += 1
        else:
            ans[1] += 1
        i = 1 - i
    ans = min(ans)
    return ans

print(main())


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

int main() {
  ll N, X; cin >> N >> X;
  ll a = N-X;
  ll b = X;
  ll res = N;
  while (a > 0 && b > 0) {
    if (a > b && a % b > 0) {
      res += (a/b)*2*b;
      a %= b;
    }
    if (a >= b && a % b == 0) {
      res += (a/b)*2*b;
      res -= b;
      a = 0; break;
    }
    if (a < b && b % a > 0) {
      res += (b/a)*2*a;
      b %= a;
    }
    if (b > a && b % a == 0) {
      res += (b/a)*2*a;
      res -= a;
      b = 0; break;
    }
  }
  cout << res << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>

using namespace std;

void sort(int *array, int num){
	for(int i = 0; i < num - 1; i++){
		for(int j = i + 1; j < num; j++){
			if(array[i] < array[j]){
				int temp = array[i];
				array[i] = array[j];
				array[j] = temp;
			}
		}
	}
}

int main(){
	int N, result = 0;
	int L[200];
	cin >> N;
	for(int i = 0; i < 2 * N; i++)
		cin >> L[i];
	sort(L,2*N);

	for(int i = 0; 2*i + 1 <= 2*N; ++i){
		result += L[2*i + 1];
	}
	printf("%d\n",result);
	return 0;
}

Measured memory_bytes: 888
def main():
    n, *i = map(int, open(0).read().split())
    a = i[:n]
    _ = i[n]
    s = sum(a)

    m = [0] * (10 ** 5 + 1)
    for x in a:
        m[x] += 1

    ans = []
    for b, c in zip(*[iter(i[n + 1:])] * 2):
        m[c] += m[b]
        s += (c - b) * m[b]
        m[b] = 0
        ans.append(s)

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

if __name__ == '__main__':
    main()

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

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

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

    int result=0;
    int x;
    for(int i=1; i<=k; i++){
        for(int j=1; j<=k; j++){
            for(int l=1; l<=k; l++){
                x = gcd(i,j);
                result += gcd(x,l);
            }
        }
    }
    cout << result << endl;
    return 0;
}

Measured memory_bytes: 3588
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Scanner;
import java.util.stream.Collectors;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		Prime prime = new Prime();
		prime.addPrime(n);
//		prime.printPrime(n);
		List<Integer> list = new ArrayList<>();
		for (int i = 1; i <= n; i++) {
			list.addAll(prime.getPrimeFactor(i));
		}
		Map<Integer, List<Integer>> map = list.stream()
			.collect(Collectors.groupingBy(i -> i));
		List<Integer> list2 = map.keySet()
			.stream()
			.map(e -> map.get(e).size())
			.collect(Collectors.toList());
		long ans = 1l;
		for (Integer integer : list2) {
			ans = (ans * (integer + 1) ) % 1000000007;
		}
		System.out.println(ans);
	}
	
	public static class Prime {
		private List<Integer> list = new ArrayList<>();
		public Prime() {
			list.add(2);
			list.add(3);
		}

		/**
		 * リストにn未満の素数があるかを判定する
		 * @return trueであればリストされている
		 */
		public boolean isListed(int n) {
			return list.get(list.size() - 1) >= n;
		}

		/**
		 * n未満の素数を表示する
		 * @param n nの数字
		 */
		public void printPrime(int n) {
			if (!isListed(n)) {
				addPrime(n);
			}
			list.stream()
				.filter(e -> e < n)
				.forEach(System.out::println);
		}

		/**
		 * n未満の整数をリストに追加する
		 * @param n
		 */
		public void addPrime(int n) {
			if (n <= 2) {
				return;
			}
			for (int i = list.get(list.size() - 1) + 2; i < n; i += 2) {
				if (new Check() {
					@Override
					public boolean accept(int i) {
						for (Integer integer : list) {
							int sq = (int) Math.sqrt(i);
							if (integer > sq) {
								return true;
							}
							if (i % integer == 0) {
								return false;
							}
						}
						return true;
					}
				}.accept(i)) {
					list.add(i);
				}
				
			}
		}

		/**
		 * @param n 素因数分解する変数を代入する
		 * @return 素因数因子のリストを返却する
		 */
		public List<Integer> getPrimeFactor(int n) {
			if (!isListed(n + 1)) {
				addPrime(n + 1);
			}
			int a = n;
			List<Integer> list = new ArrayList<>();
			for (int i = 0; i < this.list.size(); i++) {
				int b = this.list.get(i);
				if (a % b == 0) {
					list.add(b);
					i--;
					a /= b;
				}
				if (a < b ) {
					break;
				}
			}
			return list;
		}
	}
	public static interface Check{
		public boolean accept(int i);
	}
}


Measured memory_bytes: 16128
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int INF = 0x3f3f3f3f;
const LL mod = 1e9 + 7;
const int N = 100005;

int main() {
    int n;
    cin >> n;
    int mi1 = 1e9, mi2 = 1e9, mx1 = -1e9, mx2 = -1e9;
    for (int i = 0; i < n; i++) {
        int x, y;
        cin >> x >> y;
        mi1 = min(mi1, x - y);
        mi2 = min(mi2, x + y);
        mx1 = max(mx1, x - y);
        mx2 = max(mx2, x + y);
    }
    cout << max(mx1 - mi1, mx2 - mi2) << endl;
    return 0;
}


Measured memory_bytes: 3616
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<math.h>
 
using namespace std;
 
int main() {
	long long N;
	cin >> N;
	long long power = 1;
	for (int i = 1; i <= N; i++) {
		power = power * i;
		power = power % (1000000000 + 7);
	}
 
	cout << power << endl;
 
	
	return 0;
}

Measured memory_bytes: 256
import sys
#sys.stdin=open("data.txt")
input=sys.stdin.readline

MOD=10**9+7

def powmod(b,e):
    global MOD
    if e==0: return 1
    if e&1: return (powmod((b*b)%MOD,e//2)*b)%MOD
    return powmod((b*b)%MOD,e//2)

n=int(input())
h=[1]+list(map(int,input().split()))

"""
# naive solution, O(sum h_i)
archive=[]

# do rows
a1=[1]
for i in range(1,n+1):
    if h[i]<=h[i-1]:
        c=0
        while len(a1)>h[i]:
            c+=a1.pop(-1)
        a1[0]=((a1[0]+c)*2)%MOD
    else:
        a1[0]=(a1[0]*2)%MOD
        mul=powmod(2,h[i]-h[i-1])
        for j in range(1,len(a1)):
            a1[j]=(a1[j]*mul)%MOD
        extras=[a1[0]]
        for _ in range(h[i]-h[i-1]-1):
            extras.append(extras[-1]*2)
        a1+=extras[::-1]
    archive.append(a1)

print(sum(a1)%MOD)
"""

# smarter solution? i think it's O(N^2)
root=1      # number of times that this column just alternates
pos=[]      # [x,y] means it starts at x, and its size is y blocks
sz=1
for i in range(1,n+1):
    if h[i]<=h[i-1]:
        c=0
        while pos and sz-pos[-1][1]>=h[i]:
            a,b=pos.pop(-1)
            c+=(a*(powmod(2,b)-1))%MOD
            sz-=b
        if sz>h[i]:
            a,b=pos.pop(-1)
            pos.append([(a*powmod(2,sz-h[i]))%MOD,b-(sz-h[i])])
            c+=(a*(powmod(2,sz-h[i])-1))%MOD
            sz=h[i]
        root=((root+c)*2)%MOD
    else:
        root=(root*2)%MOD
        mul=powmod(2,h[i]-h[i-1])
        for j in range(len(pos)):
            pos[j][0]=(pos[j][0]*mul)%MOD
        pos.append([root,h[i]-h[i-1]])
        sz=h[i]

# get answer
for a,b in pos:
    root+=(a*(powmod(2,b)-1))%MOD
print(root%MOD)

Measured memory_bytes: 51820
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		 Scanner sc = new Scanner(System.in);
	     List<String> getParamsStr = Arrays.asList(sc.nextLine().split(" "));
	     Integer paramL = Integer.parseInt(getParamsStr.get(0));
	     Integer paramR = Integer.parseInt(getParamsStr.get(1));
	     Integer paramD = Integer.parseInt(getParamsStr.get(2));

	     int resultCount = 0;

	     for(Integer i = paramL; i <= paramR; i++) {
	    	 if(i % paramD == 0) {
	    		 resultCount++;
	    	 }

	     }
	     System.out.println(resultCount);
    }
}


Measured memory_bytes: 35568
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main() {
	// your code goes here
	string s;
	cin>>s;
	ll c=0;
	for(ll i=0;i<s.size();i++)
	{
	    c+=s[i]-'0';
	}
	if(c%9==0)
	   cout<<"Yes"<<endl;
	else
	   cout<<"No"<<endl;
}


Measured memory_bytes: 3724
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		int number = sc.nextInt();
		int sum = 0;
		for (int i=1; i <= number; i++){
			sum += i;
		}
		
		System.out.println(sum);

	}

}


Measured memory_bytes: 8788
#include <stdio.h>

int main(void)
{

  int x[5];


  scanf("%d", &x[0]);
  scanf("%d", &x[1]);
  scanf("%d", &x[2]);
  scanf("%d", &x[3]);
  scanf("%d", &x[4]);

  int count = 0;
while(x[count]!=0){

  count++;
}

printf("%d\n",count+1);

  return 0;
}

Measured memory_bytes: 1676