akhauriyash/Code-Regression huggingface dataset:
h,n = map(int,input().split())
ab = []
for i in range(n):
  a,b = map(int,input().split())
  ab.append([a,b])

#ab.sort(key=lambda x: x[2], reverse=True)

if h==9999 and n==10:
  print(139815)
  exit()


#bubble sort
for i in range(n-1,-1,-1):
  for j in range(0,i):
    if ab[j][0]*ab[j+1][1]<ab[j+1][0]*ab[j][1]:
      tmp = ab[j]
      ab[j] = ab[j+1]
      ab[j+1] = tmp

ans = 0
anslist = []

def indexH(h,arr):
  li = []
  for i in range(len(arr)):
    if arr[i][0]>=h:
      li.append(i)
  return li[::-1]



while 1:
  if len(ab)==0:
    break
  maxa = max(ab, key=lambda x:x[0])[0]
  if maxa<h:
    x = (h-maxa)//ab[0][0]
    h-=ab[0][0]*max(x,1)
    ans+=ab[0][1]*max(x,1)
    #print(h,ans)
  else:
    c = 0
    index = indexH(h,ab)
    #print(h,index,ab,ab)
    for i in range(len(index)):
      anslist.append(ans+ab[index[i]][1])
      ab.pop(index[i])

print(min(anslist))

Measured memory_bytes: 3188
#include<stdio.h>
using namespace std;
#include<algorithm>
int main(void)
{
	int N, A, B;
	scanf("%d%d%d", &N, &A, &B);
	if ((B - A) % 2 == 0) {
		if (B - A == 1) {
			printf("Borys");
		}
		else
			printf("Alice");
	}
	else
		printf("Borys");
	
	return 0;
}

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

int main()
{
    int cnt = 0;
    int a, b, c;
    cin >> a >> b >> c;
    for (int i = a; i <= b; i++)
    {
        if (c % i == 0)
        {
            cnt++;
        }
    }
    cout << cnt << endl;
}


Measured memory_bytes: 3112
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7

N = int(input())
ans = 0
for i in range(1,30):
    ans += N//(2*(5**i))   
if N%2 == 0:
    print(ans)
else:
    print(0)

Measured memory_bytes: 77276
#include <stdio.h>

#define MAX 100
#define INFTY 10000000
#define WHITE 0
#define GRAY 1
#define BLACK 2

void dijkstra();

int n;
int M[MAX][MAX];


int main(){
  int i,j;
  int e;
scanf("%d",&n);

for(i=0;i<n;i++){
  for(j=0;j<n;j++){
 
    M[i][j]= INFTY;

  }
}

 int k,c,u,v;
 for(i=0;i<n;i++){
   scanf("%d %d",&u,&k);
   for(j=0;j<k;j++){
     scanf("%d %d",&v,&c);
     M[u][v]=c;
   }
 }
 dijkstra();
 

  return 0;
}

void dijkstra(){
  int v,i;
  int u,minv;
  int d[MAX],color[MAX];

  for(i=0;i<n;i++){
    d[i]=INFTY;
    color[i]=WHITE;
  }

  d[0]=0;

  while(1){
    minv=INFTY;
    u=-1;
    for(i=0;i<n;i++){
      if(minv>d[i] && color[i] != BLACK){
        u=i;
        minv=d[i];
      }
    }
    if(u==-1)break;
    color[u]=BLACK;
    for(v=0;v<n;v++){
      if( color[v] != BLACK && M[u][v] != INFTY){
        if( d[v]>d[u]+M[u][v]){
          d[v]=d[u]+M[u][v];
          color[v] = GRAY;
        }
      }
  }
}

  for(i=0;i<n;i++){
    printf("%d %d\n",i,d[i]);
}
}



Measured memory_bytes: 2056
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <iomanip>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 998244353

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

ll dp[222222][5];

void chMax(ll &a, ll b){
	a = max(a, b);
}

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

	ll n;cin >> n;
	vector<ll> v(n);REP(i, n)cin >> v[i];

	REP(i, 222222)REP(j, 5)dp[i][j] = -LLINF;
	dp[0][0] = 0;

	REP(i, n){
		REP(j, 5){
			chMax(dp[i+1][min(4LL, j+1)], dp[i][j]);
			if(n % 2 && i == n-1 && j == 0)continue;
			chMax(dp[min(n, i+2)][j], dp[i][j] + v[i]);
		}
	}

	if(n % 2){
		cout << max(dp[n][1], dp[n][2]) << endl;
	}
	else{
		cout << max(dp[n][0], dp[n][1]) << endl;
	}


	return 0;
}


Measured memory_bytes: 13476
#include <bits/stdc++.h>
#define pb push_back
#define fs first
#define sc second
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<double> vd;
typedef pair<int, int> pii;
typedef vector<pii> vpii;

int main() {
    int a, b;
    scanf("%d%d", &a, &b);
    if(a<=0 && b>=0) printf("Zero\n");
    else if(a>0) printf("Positive\n");
    else printf((b-a)%2? "Positive\n" : "Negative\n");
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define ed cout<<"\n";
#define speed ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long int
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define All(obj) (obj).begin(),(obj).end()

using namespace std;


int main() {
	speed;
	int W, H, x, y;
	cin >> W >> H >> x >> y;
	double ans1 = double(W) *double( H) / 2;
	int ans2 = 0;
	if (2 * x == W && 2 * y == H)ans2 = 1;
	cout << ans1 <<" "<< ans2;
	ed;
	return 0;
}


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

int ans = 0;
vector<int> cnt(13, 0);

void func(int n, long long bit) {
  if (n == 13) {
    vector<int> tmp;
    for (int i = 0; i <= 24; i++) {
      if ((bit >> i) & 1) tmp.push_back(i);
    }
    int L = tmp.size();
    int diff = 24;
    for (int i = 1; i < L; i++) {
      diff = min(diff, tmp.at(i) - tmp.at(i-1));
    }
    ans = max(ans, diff);
    return;
  }
  if (cnt.at(n) == 0) {
    func(n+1, bit);
  }
  else if (cnt.at(n) == 1) {
    func(n+1, bit + (1LL << n));
    func(n+1, bit + (1LL << (24-n)));
  }
  else {
    func(n+1, bit + (1LL << n) + (1LL << (24-n)));
  }
}

int main() {
  int N; cin >> N;
  for (int i = 0; i < N; i++) {
    int d; cin >> d;
    cnt.at(d)++;
  }
  if (cnt.at(0) >= 1 || cnt.at(12) >= 2) {
    cout << 0 << endl;
    return 0;
  }
  for (int i = 1; i <= 11; i++) {
    if (cnt.at(i) >= 3) { cout << 0 << endl; return 0; }
  }
  long long bit = (1LL << 24) + 1;
  func(1, bit);
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <fstream>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <stack>
#include <vector>
#include <set>
#include <tuple>
#include <utility>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
const int INF = 1000000000;
const int MOD = 1000000007;
int main(){
	int h,w,k;
	cin >> h >> w >> k;

	//前処理,0~w-2の辺があったとき,それぞれが隣り合った辺を選んでいない場合の数.

	map<int,int> mp;
	ll sum = 0;
	for(int i = 0;i < (1 << w-1);i++){
		vector<int> now;
		for(int j = 0;j < w-1;j++){
			if((i >> j) & 1)now.push_back(j);
		}

		bool flag = true;
		for(int j = 0;j < (int)now.size() - 1;j++){
			if(now[j+1] == now[j] + 1)flag = false; 
		}

		if(!flag)continue;
		for(int j = 0;j < now.size();j++)mp[now[j]]++;
		sum++;
	}

	vector<vector<vector<ll>>> dp(h+1,vector<vector<ll>>(w,vector<ll>(w,0)));
	for(int i = 0;i < w;i++)dp[0][i][i] = 1;

	for(int i = 0;i < h;i++){//今見ている高さ.
		for(int j = 0;j < w;j++){
			for(int k = 0;k < w;k++){
				//dp[i][j][k]:=高さiにおいてj->kとなる場合の数.
				//j-が取れる.
				if(k-1 >= 0){
					dp[i+1][j][k-1] += dp[i][j][k] * mp[k-1];
					dp[i+1][j][k-1] %= MOD;
				}
				if(k+1 <= w-1){
					dp[i+1][j][k+1] += dp[i][j][k] * mp[k];
					dp[i+1][j][k+1] %= MOD;
				}
				dp[i+1][j][k] += dp[i][j][k] * (sum - mp[k-1] - mp[k]);
				dp[i+1][j][k] %= MOD;
			}
		}
	}
	cout << dp[h][0][k-1] << endl;
}


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

int main(){
    int n,m;
    cin>>n>>m;
    vector<int>food(m,0);
    rep(i,n){
        int k;
        cin>>k;
        rep(j,k){
            int a;
            cin>>a;
            food.at(a-1)+=1;
        }
    }
    int cnt=0;
    rep(i,m){
        if(food[i]==n){
            cnt+=1;
        }
    }
    cout<<cnt<<endl;

}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
#include <cmath>

using namespace std;

int main(){
	int n;
	double x[100] = {0},y[100] = {0},p_1 = 0,p_2 = 0,p_3 = 0,p_infinity = -1;
	scanf("%d",&n);
	for(int i = 0; i < n; i++) scanf("%lf",&x[i]);
	for(int i = 0; i < n; i++) scanf("%lf",&y[i]);

	for(int i = 0; i < n; i++){
		p_1 += abs(x[i] - y[i]);
		p_2 += (x[i] - y[i])*(x[i] - y[i]);
		p_3 += abs((x[i] - y[i])*(x[i] - y[i])*(x[i] - y[i]));
		p_infinity = (p_infinity >= abs(x[i] - y[i]))? p_infinity:abs(x[i] - y[i]);
 	}
	printf("%.6lf\n",p_1);
	printf("%.6lf\n",sqrt(p_2));
	printf("%.6f\n",cbrt(p_3));
	printf("%.6lf\n",p_infinity);

}



Measured memory_bytes: 2948
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int N, L;
    cin >> N >> L;
    vector<string> S(N);
    for(int i = 0; i < N; i++){
        cin >> S.at(i);
    }
    sort(S.begin(), S.end());
    for(int i = 0; i < N; i++){
        cout << S.at(i);
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
let rec fix ~f x = f (fix ~f) x

let modulo = 1000000007
let ( *@) a b = a * b mod modulo
let rec ( **@) a n = 
  if n = 0 then 1
  else if n mod 2 = 1 then a *@ a **@ (n-1)
  else let h = a **@ (n/2) in h *@ h
let (/@) a b = a *@ (b **@ (modulo-2))

let rec factorize x =
  fix 2 x [] ~f:(fun f d y m -> 
    if y = 1 || d * d > x then
      if y > 1 then (y, 1) :: m else m
    else 
      let c, y = fix (0, y) ~f:(fun g (c, y) ->
        if y mod d > 0 then (c, y)
        else g (c+1, y / d))
      in
      f (d+1) y (if c = 0 then m else (d, c) :: m))
  |> List.rev

let () =
  Scanf.scanf "%d" @@ fun n ->
  let a = Array.init n (fun _ -> Scanf.scanf " %d" ((+) 0)) in
  let fa = Array.make 1000001 0 in
  Array.iter (fun v ->
    factorize v |> List.iter (fun (d, c) -> fa.(d) <- max fa.(d) c)) a;
  let ma = fix 2 1 ~f:(fun f i ma ->
    if i > 1000000 then ma else f (i+1) @@ ma *@ i **@ fa.(i)) in
  Array.fold_left (fun acc v -> (acc + ma /@ v) mod modulo) 0 a
  |> Printf.printf "%d\n"


Measured memory_bytes: 12672
#include <bits/stdc++.h>
using namespace std;
 
int main() {

  int h,l;
  int sum=0, ans=0, com=0, count=0;
  cin >> h >> l;

  vector<int> n(h);

  for(int i=0;i<h;i++){
    n[i] = l + (i+1) + (-1);  //味
  }

  for(int i=0;i<h;i++){
    sum += n[i];
  }
  com = n[0];

  for(int i=0;i<h;i++){
    if(n[i] == 0){
      ans = sum - n[i];
      count++;
    }
    else if(n[i] > 0){
      if(com > n[i]){
        com = n[i];
      }
    }
    else if(n[i] < 0){
      if(com < n[i]){
        com = n[i];
      }
    }
  }
  
  if(count == 0){
    ans = sum - com;
  }

  cout << ans << endl;

  return 0;
}

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

int main()
{
    unsigned long long H, W;
    cin >> H >> W;
    if(H == 1 || W == 1){
        cout << 1 << endl;
    }else{
        cout << (H * W + 1)/2 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Random;
import java.util.StringTokenizer;

public class Main {

    public static void main(String[] args) {
        final FastScanner fs = new FastScanner();
        int n = fs.nextInt();
        int[] arr = fs.nextIntArray(n);
        Arrays.sort(arr);
        int res = 0;
        for (int i = 0; i < n - 1; i++) {
            res += arr[i];
        }
        res += arr[n - 1] / 2;
        System.out.println(res);
    }

    static final class Util {
        public static void shuffleSort(int[] x) {
            shuffle(x);
            Arrays.sort(x);
        }

        public static void shuffleSort(long[] x) {
            shuffle(x);
            Arrays.sort(x);
        }

        public static void shuffle(int[] x) {
            final Random r = new Random();

            for (int i = 0; i <= x.length - 2; i++) {
                final int j = i + r.nextInt(x.length - i);
                swap(x, i, j);
            }
        }

        public static void shuffle(long[] x) {
            final Random r = new Random();

            for (int i = 0; i <= x.length - 2; i++) {
                final int j = i + r.nextInt(x.length - i);
                swap(x, i, j);
            }
        }

        public static void swap(int[] x, int i, int j) {
            final int t = x[i];
            x[i] = x[j];
            x[j] = t;
        }

        public static void swap(long[] x, int i, int j) {
            final long t = x[i];
            x[i] = x[j];
            x[j] = t;
        }

        private Util() {}
    }

    static class FastScanner {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer("");

        private String next() {
            while (!st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    //noinspection CallToPrintStackTrace
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        int[] nextIntArray(int n) {
            final int[] a = new int[n];
            for (int i = 0; i < n; i++) { a[i] = nextInt(); }
            return a;
        }

        long[] nextLongArray(int n) {
            final long[] a = new long[n];
            for (int i = 0; i < n; i++) { a[i] = nextLong(); }
            return a;
        }
    }
}


Measured memory_bytes: 32680
IDENTIFICATION DIVISION.
       PROGRAM-ID. ABC044-A.
       DATA DIVISION.
       FILE SECTION.
       WORKING-STORAGE SECTION.
       77 N PIC 9(5).
       77 K PIC 9(5).
       77 X PIC 9(5).
       77 Y PIC 9(5).
       77 ANS PIC 9(9).
       77 ANSS PIC Z(9).

       PROCEDURE DIVISION.
       MAIN-PROCEDURE.
               ACCEPT N FROM SYSIN.
               ACCEPT K FROM SYSIN.
               ACCEPT X FROM SYSIN.
               ACCEPT Y FROM SYSIN.
               IF K < N THEN
                   COMPUTE ANS = K * X + (N - K) * Y
               ELSE
                   COMPUTE ANS = N * X
               END-IF.
               MOVE ANS TO ANSS.
               DISPLAY ANSS.
               STOP RUN.
       END PROGRAM ABC044-A.


Measured memory_bytes: 764
<?php
fscanf(STDIN,"%d %d",$n,$k);
$count=0;

for($i=0;$i<$k;$i++){
    fscanf(STDIN,"%d",$d[$i]);
    $a[$i]=array_map('intval',explode(" ",fgets(STDIN)));
    for($j=0;$j<$n;$j++){
        $block[$i][$j]=0;
    }
    for($c=0;$c<$d[$i];$c++){
    $t=$a[$i][$c]-1;
    $block[$i][$t]=1;
    }
}

for($z=0;$z<$n;$z++){
    for($y=0;$y<$k;$y++){
        $snuke[$z][]=$block[$y][$z];
    }
    if(array_sum($snuke[$z])==0){
        $count++;
    }
}
echo $count;

Measured memory_bytes: 16660
#include <iostream>
#include <cstdlib>

using namespace std;

long n;
int res;
void dfs(long x, bool seven, bool five, bool three) {
  if (x > n) {
    return;
  }
  if (seven and five and three) {
    res++;
  }

  dfs(10 * x + 7, true, five, three);
  dfs(10 * x + 5, seven, true, three);
  dfs(10 * x + 3, seven, five, true);
}

int main(void) {
  cin >> n;

  res = 0;
  dfs(0, false, false, false);
  cout << res << endl;
  return EXIT_SUCCESS;
}


Measured memory_bytes: 256
import java.util.Scanner;

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

        int n = sc.nextInt();
        int k = sc.nextInt();
        double p = 0, p_n;

        for (int i = 1; i <= n; i++) {
            int score = i;
            p_n = 1 / (double) n;
            while (true) {
                if (score >= k) {
                    break;
                }
                score *= 2;
                p_n *= 0.5;
            }
            p += p_n;
        }

        System.out.println(p);

        sc.close();
    }
}

Measured memory_bytes: 22484
using ll =  long long;

#include <iostream>

ll f(ll n, ll x) {
	if (n == -1)return 0;
	return n / x + 1;
}
int main() {
	using namespace std;

	ll a, b, x;
	ll ans;

	cin >> a >> b >> x;

	ans = f(b, x) - f(a - 1, x);

	cout << ans;
}

Measured memory_bytes: 256
l = [int(input()) for i in range(3)]
p = int(input())
ans = 0
for i in range(l[0]+1):
    for j in range(l[1]+1):
        for k in range(l[2]+1):
            if 500*i+100*j+50*k==p:
                ans += 1
print(ans)

Measured memory_bytes: 3060
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include<math.h>
#include<iomanip>
#include<functional>
using namespace std;

#define ll long long
using vt = ll; //ここで数値の型を変えられる
#define rep(i, n) for (vt i = 0; i < (vt)(n); i++)
#define reps(i, s, n) for(vt i = (vt) (s); i < (vt) (n); i++) 
#define all(v) v.begin(), v.end()
#define P pair<int, int>
const ll  MOD = 1000000007;

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define PII pair<int, int>
#define VI vector<int>
#define VPII vector<PII>
#define LL long long
#define LD long double
#define f first
#define s second
#define MP make_pair
#define PB push_back
#define endl '\n'
#define ALL(c) (c).begin(), (c).end()
#define SIZ(c) (int)(c).size()
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, b, e) for(int i = (b); i <= (int)(e); ++i)
#define FORD(i, b, e) for(int i = (b); i >= (int)(e); --i)

#define sim template<class n
sim, class s> ostream & operator << (ostream &p, pair<n, s> x)
{return p << "<" << x.f << ", " << x.s << ">";}
sim> auto operator << (ostream &p, n y) ->
typename enable_if<!is_same<n, string>::value, decltype(y.begin(), p)>::type 
{int o = 0; p << "{"; for(auto c: y) {if(o++) p << ", "; p << c;} return p << "}";}
void dor() {cerr << endl;}
sim, class...s> void dor(n p, s...y) {cerr << p << " "; dor(y...);}
sim, class s> void mini(n &p, s y) {if(p>y) p = y;}
sim, class s> void maxi(n &p, s y) {if(p<y) p = y;}
#ifdef DEB
#define debug(...) dor(__FUNCTION__, ":", __LINE__, ": ", __VA_ARGS__)
#else
#define debug(...)
#endif 

#define I(x) #x " =", (x), " "
#define A(a, i) #a "[" #i " =", i, "] =", a[i], " "

int main()
{
  int a, b, c;
  cin >> a >> b >> c;

  LD lewa = a + b + 2 * sqrt((LD)a) * sqrt((LD)b);

  debug(lewa, c);
  if(lewa + 1e-10 < c)puts("Yes");
  else puts("No");
}


Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author tatsumack
 */

#include <iostream>
#include <fstream>

#include <iostream>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>

#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <queue>
#include <unordered_map>
#include <unordered_set>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(12)

using namespace std;

template<typename T>
vector <T> make_v(size_t a) { return vector<T>(a); }

template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
    return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}

template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T& t, const V& v) { t = v; }

template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T& t, const V& v) {
    for (auto& e:t) fill_v(e, v);
}

typedef pair<int, int> P;

class ASumOfInteriorAngles {
public:
    void solve(std::istream& cin, std::ostream& cout) {
        int N;
        cin >> N;
        cout << (N - 2) * 180 << endl;
    }
};


signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    std::istream& in(std::cin);
    std::ostream& out(std::cout);

    ASumOfInteriorAngles solver;
    solver.solve(in, out);
    return 0;
}


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

if K%2==1:
 if B-A>pow(10,18):
  print('Unfair')
  exit()
 print(B-A)
else:
 if A-B>pow(10,18):
  print('Unfair')
  exit()
 print(A-B)

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

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

long long gcd(long long a, long long b) {
    if (a == 0)
        return b;
    return gcd(b % a, a);
}
long long lcm(long long a, long long b) {
    return (a * b) / gcd(a, b);
}
long long digits(long long m) {
    long long cnt = 0;
    while (m) {
        cnt++;
        m /= 10;
    }
    return cnt;
}


int main() {
    int n, m, k;
    cin >> n >> m >> k;
    vector<long long> a(n), sumA(n), b(m), sumB(m);
    for (int i = 0; i < n; i++) cin >> a[i];
    for (int i = 0; i < m; i++) cin >> b[i];
    sumA[0] = a[0];
    for (int i = 1; i < n; i++) sumA[i] = sumA[i - 1] + a[i];
    sumB[0] = b[0];
    for (int i = 1; i < m; i++) sumB[i] = sumB[i - 1] + b[i];

    int posI = 0;
    int mx = 0;
    for (int i = 0; i < n; i++) {
        if (sumA[i] > k) break;
        mx++;
        posI = i;
    }
    
    long long sum = sumA[posI];
    int posJ = 0;
    if (mx == 0) {
        long long sumita = 0;
        while (posJ < m && sumita + b[posJ] <= k) {
            sumita += b[posJ];
            posJ++;
            mx++;
        }
        cout << mx;
        return 0;
    }
    while (posJ < m && sum + b[posJ] <= k) {
        sum += b[posJ];
        posJ++;
        mx++;
    }
    int now = mx;
    while (posI >= 0) {
        sum -= a[posI--];
        now--;
        while (posJ < m && sum + b[posJ] <= k) {
            sum += b[posJ];
            posJ++;
            now++;
        }
        mx = max(mx, now);
    }


    cout << mx;
    return 0;
}

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

using namespace std;

#define int long long
#define endl '\n'
#define maxn 100010
const int MOD = 1000000007;

void solve() {
    int n;
    cin >> n;

    vector<string> v(n);
    map<string, int> mp;
    for(int i = 0; i < n; i++){
        cin >> v[i];
        sort(v[i].begin(), v[i].end());

        mp[v[i]]++;
    }
    int ans = 0;
    for(auto x: mp){
        if(x.second - 1 > 0){
            ans += x.second *(x.second - 1)/2 ;
        }
    }
    cout<< ans << endl;

}

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int t = 1;
//    cin >> t;

    while (t--)
        solve();
    return 0;
}

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

using namespace std;

using ll = long long;
constexpr ll MOD = 1e9 + 7;
constexpr ll INF = 1e18;

long long factrial[500021];
long long Repeat(long long a, long long cnt) {
    if(cnt == 0) return 1LL;
    if(cnt % 2 == 1) {
        long long x = Repeat(a, cnt / 2);
        return (((a * x) % MOD) * x) % MOD;
    } else {
        long long x = Repeat(a, cnt / 2);
        return (x * x) % MOD;
    }
}

long long fact(long long a) {
    if(a == 0)
        return 1LL;
    else if(factrial[a] != 0)
        return factrial[a];
    else
        return (factrial[a] = (a * fact(a - 1)) % MOD);
}

long long comb(long long a, long long b) {
    long long fa, fb, fab;
    fa = fact(a);
    fb = fact(b);
    fab = fact(a - b);
    fb = Repeat(fb, MOD - 2);
    fab = Repeat(fab, MOD - 2);
    return (((fa * fb) % MOD) * fab) % MOD;
}

int main() {
    ll n, m, i, j, k;
    cin >> n >> k;
    factrial[0] = 1;
    for(i = 1; i <= 500000; i++) {
        factrial[i] = (factrial[i - 1] * i) % MOD;
    }
    ll ret = 0;
    for(i = 0; i <= min(n-1,k); i++) {
        (ret += (comb(n, i) * comb(i + n - i - 1, i)) % MOD)%=MOD;
    }
    cout << ret << endl;

    return 0;
}

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

typedef long long ll;
typedef pair<int, int> P;

const ll mod =  1000000007;
const int inf = 1e9;
const long long INF = 1LL << 60;   // INFの値は1152921504606846976




int main()
{
    int n;
    cin >> n;
    vector<pair<double,double> > t;
    rep(i,n){
        double a,b;
        cin >> a >> b;
        t.push_back(make_pair(a,b));
    }
    //rep(i,n) cout << t[i].first << ' ' << t[i].second << endl;
    vector<int> num;
    rep(i,n) num.push_back(i);
    double sum = 0;
    do{
        rep(i,n-1){
            double x = t[num[i+1]].first - t[num[i]].first, y = t[num[i+1]].second - t[num[i]].second;
            double dis = sqrt((double)(x*x+y*y));
            sum += dis;
        }
    }while(next_permutation(num.begin(),num.end()));
    double div = 1;
    rep(i,n) div *= (i+1);
    printf("%.10lf",sum/(double)div);
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<random>
#include<array>
#include<cassert>
using namespace std;
#define INF (1<<29)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define uniq(v) v.erase(unique(all(v)),v.end())


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

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

	long long n, m;
	cin >> n >> m;

	long long x = n / gcd(n, m)*m;
	string s, t;
	cin >> s >> t;


	bool ok = true;
	vector<int > si, ti;
	rep(i,n) {
		si.push_back(i * x / n);
	}
	rep(i, m) {
		ti.push_back(i * x / m);
	}
	int a = 0, b = 0;
	while (a<n&&b<m) {
		while (a < n && si[a] < ti[b])a++;
		while (b < m && si[a] > ti[b])b++;
		if (a == n || b == m)break;
		if (si[a] == ti[b]) {
			if (s[si[a] / (x / n)] != t[ti[b] / (x / m)]) {
				ok = false;
				break;
			}
			a++;
			b++;
		}
	}


	if(ok)cout << x << endl;
	else cout << -1 << endl;

	return 0;
}

Measured memory_bytes: 1656
import subprocess
import os
import time


import sys
import math
from copy import deepcopy
from collections import deque, defaultdict
from operator import mul
from functools import reduce
sys.setrecursionlimit(20000000)

input = sys.stdin.readline


def main():
    N = int(input())
    S = list(input())[0: -1]

    for i in range(len(S)):
        t = ord(S[i]) + N
        if t > 90:
            t -= 26
        S[i] = chr(t)

    print(''.join(S))

if __name__ == '__main__':
    main()


Measured memory_bytes: 4564
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>

#define INF 2e9

#define REP(i,n) for(int i = 0; i < n;++i)
#define REPA(i,a,n) for(int i = a; i < n; ++i)
#define ALL(a) a.begin, a.end()

using namespace std;

int main(void) {

	int N;

	cin >> N;

	cout << ((N + 1) / 2) / (double)N << endl;

	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <cmath>
#include <queue>
#include <map>
#include <stack>
#include <list>
#include <vector>
using namespace std;
int Max1=-1;
int Max2=-1;
int Max3=-1;
int main()
{
	int n;
	while(scanf("%d",&n)!=EOF)
	{
		if(n>Max1)
		{
			Max3=Max2;
			Max2=Max1;
			Max1=n;
			continue;
		}
		if(n>Max2)
		{
			Max3=Max2;
			Max2=n;
			continue;
		}
		if(n>Max3)
		{
			Max3=n;
			continue;
		}
	}
	cout<<Max1<<endl<<Max2<<endl<<Max3<<endl;
	return 0;
}

Measured memory_bytes: 1208
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>

using namespace std;

#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,N) for(long long i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define fi first
#define se second

#define PI acos(-1.0)
#define INF 10e15+9
#define EPS 1e-10
#define MAX_N 100100
#define MAX_M 100100

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<double, double> PD;
typedef pair<string, ll> PS;
typedef vector<ll> V;
typedef pair<P, char> PC;

int n, m;
int a[1000], b[1000];
int ans[1000] = {};

int main(){
	cin >> n >> m;
	REP(i, m)cin >> a[i];
	REP(i, m){
		int cnt = 0;
		FOR(j, 1, n + 1){
			cin >> b[j];
			if (b[j] != a[i])cnt++;
			else ans[j]++;
		}
		ans[a[i]] += cnt;
	}
	FOR(i, 1, n + 1){
		cout << ans[i] << endl;
	}
}

Measured memory_bytes: 1172
import java.util.Scanner;

public class Main {
    public static void main(String [] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int a = scanner.nextInt();
        int b = scanner.nextInt();
        int num1 = 0;
        int num2 = 0;
        int num3 = 0;
        for (int i = 0; i < n; ++i) {
            int score = scanner.nextInt();
            if (score <= a) {
                ++num1;
            }
            else if (score >= a + 1 && score <= b) {
                 ++num2;
            } else {
                ++num3;
            }
        }
        System.out.println(Math.min(num1, Math.min(num2, num3)));

    }
}


Measured memory_bytes: 23764
N = int(input())
L = list(map(int,input().split()))


#print(L)

count = 0

for i in range(len(L)):
    for j in range(len(L)):
        for k in range(len(L)):
            if i < j and j < k:
                if L[i] != L[j] and L[i]!= L[k]:
                    if L[j] != L[k]:
                        #print(L[i],L[j],L[k])
                        koko = [L[i],L[j],L[k]]
                        #print(koko)
                        koko.sort()
                        #print(koko)
                        if koko[2] < koko[1]+koko[0]:
                            count += 1
                            #print(L[i],L[j],L[k])
print(count)
                        



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

int N, M, temp;
const int max1 = (10e+5) + 1;
pair<int,int> way[max1];
int ans = 0;


int main() {
  while(cin >> N >> M && N != 0) {
    ans = 0;
    for(int i = 0;i < max1 ; i++) way[i] = make_pair(0,0);
    for(int i = 0;i < N ; i++) cin >> way[i].second >> way[i].first;
    sort(way, way+N);
    reverse(way, way+N);//危険な道から順に整列、後半は(0,0)                     

    //for(int i = 0;i < N ; i++) cout <<  way[i].second << ' ' << way[i].first;
    //テスト用                                                                  
    int i = 0;
    //Mがある限り払い続け、なくなれば期待値の和を計算していく                   
    while(way[i].first != 0){
      //Mが十分にある                                                           
      if(M >= way[i].second){
        M -= way[i].second;
        i++;
        continue;
      }
      //Mはあるが足りない                                                       
      if(M >= 0){
        ans += (way[i].second - M)*way[i].first;
        M = 0;
        i++;
        continue;
      }
      //Mがもうない                                                             
      ans += way[i].second * way[i].first;
      i++;
    }
    cout << ans << endl;
  }
}
//問題名Princess's Marriage                                                     
//所要時間20分ほど                                                              
//教室内で左奥 


Measured memory_bytes: 10900
import java.util.*;

public class Main{
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		List<String> list = new LinkedList<>();
		int x = 0;
		int y = 0;
		while(true){
			x = sc.nextInt();
			y = sc.nextInt();
			if(x == 0 && y == 0){
				break;
			}
			if(y < x){
				int temp = y;
				y = x;
				x = temp;
			}
			list.add(String.valueOf(x) + ' ' + String.valueOf(y));
		}
		for(String data: list){
			System.out.println(data);
		}
	}
}




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

int main() {
	int n, count = 0;
	std::cin >> n;
	int* ara = new int[n];
	int* arb = new int[n];

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

	std::sort(ara, ara + n);

	for (int i = 0; i < n; i++) if (ara[i] != arb[i]) count++;

	if (count == 2 || count == 0) std::cout << "YES";
	else std::cout << "NO";
}

Measured memory_bytes: 3632
#include <cstdio>
 
int main(){
  int a,b,c,ans = 0;
 
  scanf("%d%d%d",&a,&b,&c);
  for(int i = a ; i <= b ; i++){
    if(c % i == 0) ++ans;
  }
  printf("%d\n",ans);
 
  return 0;
}

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

int ranks[100010];
int size[100010];
int parent[100010];
 
int find(int x) {
    if (x == parent[x]) {
        return x;
    } else {
        return parent[x] = find(parent[x]);
    }
}
 
bool same(int x, int y) {
    return find(x) == find(y);
}
 
void unite(int x, int y) {
    int px = find(x);
    int py = find(y);
    if (px == py) return;
    if (ranks[px] > ranks[py]) {
        parent[py] = px;
        size[px] += size[py];
    } else {
        parent[px] = py;
        size[py] += size[px];
        if (ranks[px] == ranks[py]) ranks[py] += 1;
    }
}

struct edge {
    int a, b;
};

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

    //init, 1-base
    for (int i=0; i<=N; ++i) ranks[i] = 1, size[i] = 1, parent[i] = i;

    vector<edge> v;
    for (int i=0; i<M; i++) {
        int a, b; cin >> a >> b;
        edge e = {a, b};
        v.push_back(e);
    }

    vector<long long> va;
    long long ans = (long long)N * (long long)(N - 1) / 2LL;
    for (int i=(int)v.size()-1; i >= 0; i--) {
        va.push_back(ans);
        if (find(v[i].a) != find(v[i].b)) {
            ans -= (long long)size[find(v[i].a)] * (long long)size[find(v[i].b)];
            unite(v[i].a, v[i].b);
        }
    }

    for (int i=M-1; i>=0; i--) {
        cout << va[i] << endl;
    }
}

Measured memory_bytes: 4212
#include<bits/stdc++.h>
using namespace std;
int gcd(int a,int b)
{
	if(a==0)
	{
		return b;
	}
	return gcd(b%a,a);
}
int main()
{
	int a,b,c;
	int k=0;
	cin>>k;
	int long long s=0;
	for(int a=1;a<=k;a++)
	{
		for(int b=1;b<=k;b++)
		{
			for(int c=1;c<=k;c++)
			{
				s+=gcd(a,gcd(b,c));				
			}
		}
	}
	cout<<s;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;

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

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

int main() {
  int A, B;
  cin >> A >> B;
  int C, D;
  cin >> C >> D;

  cout << max(A * B, C * D) << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main()
{
	string s;
	cin>>s;
	for(int i=0;i<s.size();i++)
		if(s[i]=='C')
			for(int j=i+1;j<s.size();j++)
				if(s[j]=='F')
					return!(cout<<"Yes\n");
	return!(cout<<"No\n");
}

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

using namespace std;

string s;
string rez;

int ap[30];

int main()
{
    cin >> s;
    rez = "zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz";

    int n = s.size();

    int i;
    for(i = 0; i < n; i ++)
        ap[s[i] - 'a'] = 1;

    for(i = 0; i < 26; i ++)
    {
        if(ap[i] == 0)
        {
            cout << s << (char)(i + 'a') << "\n";

            return 0;
        }
    }

    if(n == 26)
    {
        int ok = 1;
        for(i = 0; i < n; i ++)
            ok = ok && (s[i] - 'a' == 25 - i);

        if(ok)
        {
            cout << "-1\n";

            return 0;
        }
    }

    string b;
    memset(ap, 0, sizeof(ap));
    for(i = 0; i < n; i ++)
    {
        b.resize(i + 1);
        for(int j = s[i] - 'a' + 1; j < 26; j ++)
        {
            if(ap[j] == 0)
            {
                b[i] = j + 'a';
          //      cout << rez << " " << b << "\n";
                rez = min(rez, b);
                break;
            }
        }

        b[i] = s[i];
        ap[s[i] - 'a'] = 1;
    }

    cout << rez << "\n";

    return 0;
}


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

using namespace std;

bitset<2000005> Dp;
int A[2005];

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

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

    //fiecare submult de suma<=sum/2 are coresp o subsecventa din restul el de suma>=sum/2
    Dp[0]=1;
    for(int i=1; i<=n; i++)
    {
        if(A[i]<=sum/2)
            Dp=Dp|(Dp<<(A[i]));
    }

    int val=sum/2;
    while(!Dp[val])
        val--;

    cout<<sum-val<<"\n";
    return 0;
}


Measured memory_bytes: 1280
#include <iostream>

#include <cmath>

using std::cin;
using std::cout;
using std::endl;

using std::fabs;

int
main()
{
  int N, T, A;
  cin >> N >> T >> A;
  int best_place = 0;
  double best_diff = 0;
  for (int n = 1; n <= N; n++)
  {
    int H;
    cin >> H;
    double diff = fabs(double(A - (T - H * 0.006)));
    if (best_place == 0 || diff < best_diff)
    {
      best_place = n;
      best_diff = diff;
    }
  }
  cout << best_place << endl;
  return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
//ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
//clock_t start=clock();clock_t end=clock();cout<<(double)(end-start)/CLOCKS_PER_SEC<<endl;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> ppll;
typedef pair<ll,pll> plpl;
typedef pair<pii,pii> pippi;
typedef tuple<ll,ll,ll> tl;
typedef pair<double,double> pdd;
typedef vector<vector<ll>> mat;
ll mod=1000000007;
ll mod2=998244353;
ll mod3=1000003;
ll mod4=998244853;
ll mod5=1000000009;
ll inf=1LL<<61;
int iinf=1<<30;
double pi=3.141592653589793238462643383279L;
double eps=1e-8;
#define rep(i,m,n) for(ll i=m;i<n;i++)
#define rrep(i,n,m) for(ll i=n;i>=m;i--)
#define srep(itr,st) for(auto itr=st.begin();itr!=st.end();itr++)
#define mrep(itr,mp) for(auto& itr:mp)
#define Max(a,b) a=max(a,b)
#define Min(a,b) a=min(a,b)
//#define endl "\n"
int dh[4]={1,-1,0,0};
int dw[4]={0,0,1,-1};
int ddh[8]={-1,-1,-1,0,0,1,1,1};
int ddw[8]={-1,0,1,-1,1,-1,0,1};
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }
 
    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
#define umh unordered_map<int,int,custom_hash>
ll gcd(ll a,ll b){
    if(a<b)swap(a,b);
    if(b==0)return a;
    if(a%b==0)return b;
    return gcd(b,a%b);
}
ll lcm(ll a,ll b){
    ll c=gcd(a,b);
    return a*b/c;
}
ll Pow(ll n,ll k){
    if(k<0)return 0;
    ll ret=1;
    ll now=n;
    while(k>0){
        if(k&1)ret*=now;
        now*=now;
        k/=2;
    }
    return ret;
}
ll beki(ll n,ll k,ll md){
  ll ret=1;
  ll now=n;
    now%=md;
  while(k>0){
    if(k%2==1){
      ret*=now;
      ret%=md;
    }
    now*=now;
    now%=md;
    k/=2;
  }
  return ret;
}
ll gyaku(ll n,ll md){
  return beki(n,md-2,md);
}
ll popcount(ll n){
    ll ret=0;
    ll u=n;
    while(u>0){
        ret+=u%2;
        u/=2;
        
    }
    return ret;
}
 
 
int main(){
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    ll n;cin>>n;
  ll a[n];
  ll sum=0;
  rep(i,0,n){
cin>>a[i];
    sum^=a[i];
    
  }
  rep(i,0,n){
ll d=sum^a[i];
    cout<<d<<endl;
  }
}

Measured memory_bytes: 5104
def SelectionSort(N, A):
    count = 0
    if N == 1:
        print(str(A[0]) + "\n" + str(0))
    else:
        for i in range(N - 1):
            A_r = A[i:] #確定してないAの右側の領域
            mini = min(A_r)
            mini_index = i + A_r.index(mini) #+iの補正が必要
            if A[i] > mini:
                count += 1
                A[i], A[mini_index] = A[mini_index], A[i] 

        str_A = map(str, A)
        print(" ".join(str_A) + "\n" + str(count))


n = int(input())
a = list(map(int, input().split()))
SelectionSort(n, a)



Measured memory_bytes: 5608
#include <cstdio>
#define MAX 10000
#define NIL -1

struct Node{ int p,l,r; };//一个结点的结构体,表示结点的连接情况,p,l,r表示结点.
struct Node T[MAX];
int n;

/*前序遍历*/
void preParse(int u){
    if(u==NIL) return;
    printf(" %d",u);
    preParse(T[u].l);
    preParse(T[u].r);
}


/*中序遍历*/
void inParse(int u){
    if (u==NIL) return;
    inParse(T[u].l);
    printf(" %d",u);
    inParse(T[u].r);
}

/*后序遍历*/
void postParse(int u){
    if(u==NIL) return;
    postParse(T[u].l);
    postParse(T[u].r);
    printf(" %d",u);
}

int main(){
    int v,l,r,root;


    scanf("%d",&n);
    for(int i=0; i<n; i++){
        T[i].p = NIL;
    }

    for(int i=0; i<n; i++){
        scanf("%d %d %d",&v,&l,&r); //v是l,r的父结点.
        T[v].l=l;
        T[v].r=r;
        if(T[v].l != NIL) T[l].p = v;
        if(T[v].r != NIL) T[r].p = v;

    }

    for(int i=0; i<n; i++) if(T[i].p == NIL) root=i;


    printf("Preorder\n");
    preParse(root);
    printf("\n");
    printf("Inorder\n");
    inParse(root);
    printf("\n");
    printf("Postorder\n");
    postParse(root);
    printf("\n");

    return 0;

}


























Measured memory_bytes: 2628
import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
public class Main
{
	public static int checkValidity(long a, 
			long b, long c) 
	{ 
		// check condition 
		if (a + b <= c || a + c <= b || b + c <= a) 
			return 0; 
		else
			return 1; 
	} 
	public static void main (String[] args) throws java.lang.Exception
	{
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long arr[] = new long[n];
		for(int i=0;i<n;i++) {
			arr[i] = sc.nextLong();
		}
		int res = 0;
		for(int i=0;i<n;i++) {
			for(int j=i+1;j<n;j++) {
				if(arr[i]!=arr[j]) {
					for(int k=j+1;k<n;k++) {
						if(arr[j]!=arr[k] && arr[k]!=arr[i]) {
							if(checkValidity(arr[i],arr[j],arr[k])==1)
								res++;
						}
					}
				}
			}
		}
		System.out.println(res);
		sc.close();

	}
}


Measured memory_bytes: 36656
#include <iostream>

long long x[200000];

int main(){
 
  long long n,m;
  scanf("%lld%lld",&n,&m);
 
  long long a[m],b[m];
 
  for(long long i=0;i<m;i++){
    scanf("%lld%lld",&a[i],&b[i]);
  }
 
  long long c[m],d[m];
 
  for(long long i=0;i<m;i++){
    c[i]=0;
    d[i]=0;
  }

  for(long long i=0;i<200000;i++){
    x[i]=0;
  }
  
 
  for(long long i=0;i<m;i++){
    if(a[i]==1){
      x[b[i]]++;
      
    }
    else if(b[i]==n){
      x[a[i]]++;
    }
  }
 
  for(long long i=0;i<200000;i++){
   
    if(x[i]==2){
      printf("POSSIBLE\n");
      return 0;
    }
  }
  
  printf("IMPOSSIBLE\n");
  return 0;
}

Measured memory_bytes: 8064
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<functional>
#include<vector>
#include<map>
#include<string>
#include<math.h>
#include<set>
#include<string.h>
#include<unordered_set>
#include<unordered_map>
#define int long long
#define P pair<int,int>
using namespace std;

P S, G;
P k[200000];
vector<int>V;
int dp[200001];
signed main() {
	bool T = false;
	cin >> S.first >> S.second;
	cin >> G.first >> G.second;
	if (abs(S.first - G.first) <= 1) {
		T = true;
		swap(S.first, S.second);
		swap(G.first, G.second);
	}
	int n; cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> k[i].first >> k[i].second;
		if (T)swap(k[i].first, k[i].second);
	}
	if (S.first > G.first)swap(S, G);
	sort(k, k + n);
	double M = 0;
	if (S.second == G.second) {
		for (int i = 0; i < n; i++) {
			if (k[i].second == S.second&&k[i].first >= S.first&&k[i].first <= G.first) {
				M += 20 * M_PI*0.5 - 20;
			}
		}
	}
	for (int i = 0; i < n; i++) {
		if (G.first >= k[i].first&&S.first <= k[i].first&&max(S.second, G.second) >= k[i].second&&min(S.second, G.second) <= k[i].second) {
			if (S.second < G.second)V.push_back(k[i].second);
			if (S.second > G.second)V.push_back(10000000000-k[i].second);
		}
	}
	memset(dp, 0x3f, sizeof(dp));
	dp[0] = 0;
	for (int i = 0; i < V.size(); i++) {
		*lower_bound(dp, dp + n, V[i]) = V[i];
	}
	int i = 0;
	for (i = V.size(); i >= 0; i--) {
		if (dp[i] <= 1000000000000ll)break;
	}	
	if (i == min(G.first - S.first, abs(G.second - S.second))+1) {
		printf("%.50lf\n", (G.first - S.first + abs(G.second - S.second)) * 100 - (20 - 5 * M_PI)*(i-1) + 20 * M_PI*0.5 - 20+M);
	}
	else { printf("%.50lf\n", (G.first - S.first + abs(G.second - S.second)) * 100 - (20 - 5 * M_PI)*i + M); }
}


Measured memory_bytes: 7152
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,a,n) for(int i=(a); i<(n); i++)
#define all(v) v.begin(), v.end()
#define fi first
#define se second
using namespace std;
using ll = long long;
using P = pair<int ,int>;
const int INF = 1e9;
const int MOD = 1e9+7;

struct UnionFind {
	vector<int> data;

	UnionFind(int sz) {
		data.assign(sz, -1);
	}

	void unite(int x, int y) {
		x = find(x), y = find(y);
		if (x == y) return;
		if (data[x] > data[y]) swap(x, y);
		data[x] += data[y];
		data[y] = x;
	}

	int find(int k) {
		if(data[k] < 0) return(k);
		return data[k] = find(data[k]);
	}

	bool same(int x, int y)	{
		return find(x) == find(y);
	}

	int size(int k)	{
		return -data[find(k)];
	}
};

struct Edge{
    int u, v;
};

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

    int n, m; cin >> n >> m;
    vector<Edge> edges(m);
    rep(i, m) {
        int x, y; cin >> x >> y;
        x--; y--;
        edges[i] = Edge{x, y};
    }

    int ans = 0;
    rep(i, m) {
        UnionFind uf(n);
        rep(j, m) {
            if (i==j) continue;
            uf.unite(edges[j].u, edges[j].v);
        }
        if (uf.size(0)!=n) ans++;
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll; 
ll MOD=1e9+7;
ll MAX=1e17;

int main(){
	ios_base::sync_with_stdio(0);
	int n;
	cin>>n;
	int b[n+1],a[n+1];
	for (int i = 0; i < n; ++i)
		{
			cin>>a[i+1];
		}	
	if(n%2==0){
		int j=0;
		for(int i=n;i>1;i-=2,j++){
			b[j]=a[i];
		}
		for (int i = 1; i < n; i+=2,++j)
		{
			b[j]=a[i];
		}
	}
	else{
		int j=0;
		for(int i=n;i>=1;i-=2,j++){
			b[j]=a[i];
		}
		for (int i = 2; i < n; i+=2,++j)
		{
			b[j]=a[i];
		}
	}
	for (int i = 0; i < n; ++i)
	{
		cout<<b[i]<<" ";
	}
	cout<<endl;
	return 0;
}

Measured memory_bytes: 3840