akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;
 
public class Main {
  public static void swap(int[] array, int x, int y) {
    int temp = array[x];
    array[x] = array[y];
    array[y] = temp;
  }
 
  public static void main(String args[]) {
    Scanner sc = new Scanner(System.in);
    sc.useDelimiter("[\\s,]");
 
    int w = sc.nextInt();
    int n = sc.nextInt();
 
    int[] order = new int[w];
    for(int i = 0; i < w; i++) {
      order[i] = i + 1;
    }
 
    for(int i = 0; i < n; i++) {
      int a = sc.nextInt();
      int b = sc.nextInt();
      swap(order, a - 1, b - 1);
    }
 
    for(int i = 0; i < w; i++) {
      System.out.println(order[i]);
    }
  }
}


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

int main() {
    int N;
    cin >> N;
    vector<int> d(N);
    for(int i=0;i<N;i++){
        cin >> d.at(i);
    }
    int answer = 1;
    int previous = 0;
    sort(d.rbegin(),d.rend());
    for(int i=1;i<N;i++){
        if(d.at(i) < d.at(previous)){
            answer++;
            previous = i;
        }
    }
    cout << answer << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.HashMap;
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {
	final static long MOD = 1000000007;
	static long modpow(long n, long y){
		if(y == 0){
			return 1;
		}else if(y == 1){
			return n % MOD;
		}else{
			if(y % 2 == 0){
				long r = modpow(n , y / 2);
				return (r * r) % MOD;
			}else{
				long r = modpow(n , y / 2);
				long r2 = (r * r) % MOD;
				return (r2 * n) % MOD;				
			}
		}
	}	
	static long gcd(long a , long b){
		if(a < b)return gcd(b, a);
		if(b == 0)return a;
		return gcd(b , a % b);
	}
	static class State{
		long a;
		long b;
		State(long a , long b){
			if(a < 0){
				a = -a;
				b = -b;
			}else if(a == 0){
				b = 1;
			}
			this.a = a;
			this.b = b;
		}
		@Override
		public boolean equals(Object obj) {
			State s = (State)obj;
			return a == s.a && b == s.b;
		}
		@Override
		public int hashCode() {
			return (int)a + 31 * (int)b;
		}
		@Override
		public String toString() {
			return a + " " + b;
		}
	}
	static long solve(long A[] , long B[]){
		HashMap<State, Integer> counter = new HashMap<State, Integer>();
		long zeros = 0;
		for(int i = 0 ; i < A.length ; ++i){
			if(A[i] == 0 && B[i] == 0){
				zeros++;
				continue;
			}
			State s = new State(A[i], B[i]);
			if(!counter.containsKey(s)){
				counter.put(s, 1);
			}else{
				int v = counter.get(s);
				counter.put(s, v + 1);				
			}
		}
		Set<State> ks = new HashSet<State>(counter.keySet());
		long ret = 1;
		for(State s : ks){
			State rs = new State(- s.b , s.a);
			int c = 0;
			int r = 0;
			if(counter.containsKey(s)){
				c = counter.get(s);
				counter.remove(s);
			}
			if(counter.containsKey(rs)){
				r = counter.get(rs);
				counter.remove(rs);
			}
			long t = modpow(2, c) + modpow(2, r) - 1;
			ret = (ret * t) % MOD;
		}
		ret = (ret + zeros - 1 + MOD) % MOD;
		return ret;
	}
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		long A[] = new long[N];
		long B[] = new long[N];
		for(int i = 0 ; i < N ; ++i){
			long a = sc.nextLong();
			long b = sc.nextLong();
			long g = gcd(Math.abs(a) , Math.abs(b));
			if(a == 0 && b == 0){
				A[i] = 0;
				B[i] = 0;
			}else{
				A[i] = a / g;
				B[i] = b / g;								
			}
		}	
		System.out.println(solve(A , B));
	}
}


Measured memory_bytes: 75120
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N=0,a=0,b=0,c=0,ans=0;
    string str;

    cin>>a>>b;

    if(a<=b)ans=a;
    else{
        ans=a-1;
    }

    cout<<ans<<endl;

}


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

typedef long long ll;

const ll mod = 924844033;
const int MAXN = 2010;

ll f[2][2][MAXN][MAXN], g[MAXN];

int main(){
	int N, K, M;
	scanf("%d %d", &N, &K);
	M = N / K + 1;
	f[1][0][0][0] = 1;
	for (int i = 1; i <= M; ++i){
		f[0][0][i][0] = 1;
		for (int j = 1; j <= i; ++j){
			f[0][0][i][j] = (f[1][0][i - 1][j] + f[0][0][i - 1][j] + f[0][0][i - 1][j - 1]) % mod;
			f[0][1][i][j] = (f[1][0][i - 1][j - 1] + f[0][0][i - 1][j - 1]) % mod;
			f[1][0][i][j] = (f[0][1][i - 1][j - 1] + f[1][1][i - 1][j] + f[0][1][i - 1][j]) % mod;
			f[1][1][i][j] = (f[0][1][i - 1][j - 1] + f[1][1][i - 1][j - 1]) % mod;
		}
	}
	g[0] = 1;
	for (int i = 1, d, t; i <= K; ++i){
		d = (N - i) / K + 1;
		for (int j = N; j >= 1; --j)
			for (int k = 1; k <= d && k <= j; ++k){
				t = (f[0][0][d][k] + f[1][0][d][k]) % mod;
				g[j] = (g[j] + g[j - k] * t % mod) % mod;
			}
	}
	ll ans = g[N], fac = 1;
	for (int i = N - 1; i >= 0; --i){
		fac = fac * (N - i) % mod;
		if (i & 1)
			ans = (ans + mod - fac * g[i] % mod) % mod;
		else
			ans = (ans + fac * g[i] % mod) % mod;
	}
	printf("%lld", ans);
	return 0;
}


Measured memory_bytes: 124800
#include<iostream>
using namespace std;
int main()
{
  int n;
  cin>>n;
  int arr[n];
  long int res=1000,stock=0;
  for(int i=0;i<n;i++)
    cin>>arr[i];
  for(int i=0;i<n-1;i++)
  {
    if(arr[i]<arr[i+1]&&stock==0)
    {
      stock=res/arr[i];
      res=res%arr[i];
      continue;
    }
    if(arr[i]>arr[i+1])
    {
      res+=(arr[i]*stock);
      stock=0;
    }
  }  
  res+=(arr[n-1]*stock);
  cout<<res<<endl;
  return 0;
}    

Measured memory_bytes: 3192
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<queue>
#include<cmath>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<stack>
#include<cstdio>
#include<cstring>
#include<bitset>
#include<unordered_map>
#include<climits>
#include<fstream>
#include<time.h>
#include<cassert>

using namespace std;
typedef long long ll;
typedef long double ld;
#define all(a) (a).begin(),(a).end()
#define EPS (1e-5)
#define bit(n,k) ((n>>k)&1)
const ll Mod = 1000000007;
const ll mod = 998244353;
struct H {
	ll x, y;
	bool operator<(const H& b) const {
		if (x != b.x) return x < b.x;
		return y < b.y;
	}
	bool operator>(const H& b) const {
		if (x != b.x) return x > b.x;
		return y > b.y;
	}
	bool operator==(const H& b) const { return x == b.x && y == b.y; }
	bool operator!=(const H& b) const { return (*this) != b; }
};
struct P {
	ll pos, cost;
	bool operator<(const P& b) const { return cost < b.cost; }
	bool operator>(const P& b) const { return cost > b.cost; }
};
struct B {
	ll to, cost;
};
struct E {
	ll from, to, cost;
	bool operator<(const E& b) const { return cost < b.cost; }
	bool operator>(const E& b) const { return cost > b.cost; }
};
template<typename T, typename U>
void chmin(T& a, U b) {
	if (a > b) a = b;
}
template<typename T, typename U>
void chmax(T& a, U b) {
	if (a < b) a = b;
}
template<typename T>
T max_0(T a) {
	if (a < 0) return 0;
	return a;
}
template<typename T>
T min_0(T a) {
	if (a > 0) return 0;
	return a;
}
ll read() {
	ll u;
	ll k = scanf("%lld", &u);
	return u;
}
ll gcd(ll i, ll j) {
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcd(j % i, i);
}
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * x % p;
		x = x * x % p;
		n >>= 1;
	}
	return res;
}//x^n%p
ll bitcount(ll x) {
	int sum = 0;
	for (int i = 0; i < 20; i++)
		if ((1ll << i) & x) sum++;
	return sum;
}
ll fact_[5000000];
ll comb(ll x, ll y, ll mod = Mod) {
	if (!fact_[0]) {
		fact_[0] = 1;
		for (int i = 1; i < 5000000; i++) {
			fact_[i] = fact_[i - 1] * i % mod;
		}
	}
	if (x < y) return 0;
	return mod_pow(fact_[x], mod, mod) *
		mod_pow(fact_[x - y], mod - 2, mod) % mod *
		mod_pow(fact_[y], mod - 2, mod) % mod;
}//xCy
const ll Inf = 3023372036854775807;
const int inf = 1500000000;
#define int long long
//----------------------------------------------------
int n;
int dp[200000];
signed main() {
	cin >> n;
	for (int i = 0; i < 200000; i++) {
		dp[i] = Inf;
	}
	deque<H>deq{ H{1,1} };
	while (!deq.empty()) {
		H t = deq.front(); deq.pop_front();
		if (dp[t.x] < Inf) continue;
		dp[t.x] = t.y;
		if (dp[(t.x + 1) % n] == Inf) {
			deq.push_back(H{ (t.x + 1) % n,t.y + 1 });
		}
		if (dp[(t.x * 10) % n] == Inf) {
			deq.push_front(H{ (t.x * 10) % n,t.y });
		}
	}
	cout << dp[0] << endl;
}

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

int main() {

  int N;
  cin >> N;

  double answer = 0;

  for (int i = 0; i < N; i++) {
    int A;
    cin >> A;
    answer += (double) 1 / A;
  }

  cout << setprecision(11) <<(double) 1 / answer << endl;

}

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

int main()
{
  int n;
  string s;
  char a;
  cin >> n >> s;

  for(int i = 0; i < (int)s.size(); i++){
    for(int j=0; j<n; j++){
      s[i]++;
      if(s[i]>90){
        s[i]=65;
      }
    }
}

  cout << s << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int t[] = new int [n + 1];
		int x[] = new int [n + 1];
		int y[] = new int [n + 1];
		t[0] = 0;
		x[0] = 0;
		y[0] = 0;
		for(int i = 1; i <= n; i++) {
			 t[i] = sc.nextInt();
			 x[i] = sc.nextInt();
			 y[i] = sc.nextInt();
		}
		for(int i = 0; i < n; i++) {
				if(t[i + 1] - t[i] < Math.abs(x[i + 1] - x[i]) + Math.abs(y[i + 1] - y[i])
				   ||(t[i] + t [i + 1] + x[i] + y[i] - x[i + 1] - y[i + 1]) % 2 != 0) {
					System.out.println("No");
		            return;
				}
		}
		System.out.println("Yes");
	}
}

Measured memory_bytes: 92488
D=int(input())
*c,=map(int,input().split())
s=[]
for i in range(D):
    *x,=map(int,input().split())
    s.append(x)

def score(T):
    last=[-1]*26
    v=0
    for d in range(D):
        v+=s[d][T[d]-1]
        last[T[d]-1]=d
        for i in range(26):
            v-=c[i]*(d-last[i])
    return v

import random
best=0

for x in range(4000):
    if x==0:
        tmp=[random.randint(1, 26) for _ in range(D)]
        tbest=tmp
    else:
        tmp=[random.randint(1, 26) for _ in range(D)]
    if score(tmp)>best:
        tbest=tmp
    else:
        continue

for t in tbest:
    print(t)


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

#ifdef ONLINE_JUDGE
#define freopen(N, M, Q)
#endif

#define ll long long
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define all(N) N.begin(), N.end()

using namespace std;

const ll INF = 1e9;

int main() {
    ios_base::sync_with_stdio(false);
	//freopen("input.txt", "r", stdin);

	int n;
	cin >> n;

	vector<ll> h(n);
	for (auto &i : h)
	    cin >> i;

	int loc = 0, ans = 0;
	for (int i = 0 ; i < n - 1; ++i) {
	    if (h[i] >= h[i + 1]) {
	        loc++;
        } else {
            ans = max(ans, loc);
            loc = 0;
        }
    }

    ans = max(ans, loc);

    cout << ans << endl;
    

    return 0;
}


Measured memory_bytes: 1024
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)
	a := make([]int, n)
	for i := range a {
		fmt.Scan(&a[i])
	}
	fmt.Println(monster(a))
}

func monster(a []int) int {
	g := gcd(a[0], a[1])
	for i := 2; i < len(a); i++ {
		g = gcd(g, a[i])
	}
	return g
}

func gcd(a, b int) int {
	for b != 0 {
		a, b = b, a%b
	}
	return a
}


Measured memory_bytes: 5504
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 100000001


int main(){

	int N;
	cin>>N;
	
	vector<int> A(N);
	long long maxi;
	long long ans = 0LL;
	
	for(int i=0;i<N;i++){
		cin>>A[i];
		if(i==0)maxi = A[i];
		else{
			maxi = max(maxi,(long long)A[i]);
			ans += abs(maxi-A[i]);
		}
	}
	
	cout<<ans<<endl;
	
	return 0;
}

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

using namespace std;
#define int long long
#define x first
#define y second
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define forn(i,n) for(int i=0;i<(int)n;i++)
#define pb push_back
#define sz(a) (int)(a.size())

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

const int N = 1e7+2;
int f[N];

signed main(){
	IOS
	int ans = 0;
	int n;cin>>n;
	for(int i=1;i<=n;i++){
		ans+=i*f[i]+i;
		for(int j=i+i;j<=n;j+=i){
			f[j]++;
		}
	}
	cout<<ans;
}

Measured memory_bytes: 81768
#include<stdio.h>
#include<iostream>
#include<cmath>
#include<string>
#include<cassert>

#define N 4
#define N2 16
#define LIMIT 100

using namespace std;

static const int dx[4] = {0, -1, 0, 1};
static const int dy[4] = {1, 0, -1, 0};
static const char dir[4] = {'r', 'u', 'l', 'd'};
int MDT[N2][N2];

struct Puzzle {
  int f[N2], space, MD;
};

Puzzle state;
int limit;
int path[LIMIT];

int getAllMD(Puzzle pz){
  int sum = 0;
  for(int i=0; i<N2; i++){
    if(pz.f[i] == N2) continue;
    sum += MDT[i][pz.f[i]-1];
  }
  return sum;
}

bool isSolved(){
  for(int i=0; i<N2; i++)
    if(state.f[i] != i+1) return false;
  return true;
}

bool dfs(int depth, int prev){
  if(state.MD == 0) return true;

  if(depth+state.MD > limit) return false;

  int sx = state.space / N;
  int sy = state.space % N;
  Puzzle tmp;

  for(int r=0; r<4; r++){
    int tx = sx + dx[r];
    int ty = sy + dy[r];
    
    if(tx<0 || ty<0 || tx>=N || ty>=N) continue;
       if(max(prev, r)-min(prev, r) == 2) continue;
       tmp = state;

       state.MD -= MDT[tx*N+ty][state.f[tx*N+ty]-1];
       state.MD += MDT[sx*N+sy][state.f[tx*N+ty]-1];
       swap(state.f[tx*N+ty], state.f[sx*N+sy]);
       state.space = tx*N+ty;
       if(dfs(depth+1,r) ) {path[depth] = r; return true; }
       state = tmp;
  }       
       
    return false;
  
}    


string iterative_deepening(Puzzle in){
  in.MD = getAllMD(in);

  for(limit = in.MD; limit <= LIMIT; limit++){
    state = in;
    if(dfs(0, -100) ){
      string ans = "";
      for(int i = 0; i<limit; i++) ans += dir[path[i]];
      return ans;
    }
  }

  return "unsolvable";
}

int main(){
  for(int i=0; i<N2; i++)
    for(int j=0; j<N2; j++)
      MDT[i][j] = abs(i/N - j/N) + abs(i%N - j%N);

  Puzzle in;

  for(int i=0; i<N2; i++){
    cin >> in.f[i];
    if(in.f[i] == 0){
      in.f[i] = N2;
      in.space = i;
    }
  }
  string ans = iterative_deepening(in);
  cout << ans.size() << endl;

  return 0;

}



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

lint gcd(lint x, lint y) {
  if(x == 0) { return y; }
  else { return gcd(y%x,x); }
}

lint lcm(lint x, lint y) { return x/gcd(x,y)*y; }

lint C(lint n, lint k) {
  if(n == k) { return 1; }
  else if(n < k) { return 0; }
  else if(k == 0) { return 1; }
  else if(k == 1) { return n; }
  else return C(n-1,k-1) + C(n-1,k);
}

lint P(lint n, lint k) {
  if(k == 1) { return n; }
  return (n*(P(n-1,k-1)%1000000007)%1000000007);
}


int main() {
  lint n,k,r,s,p; cin >> n >> k >> r >> s >> p;
  string t; cin >> t;

  lint size=(lint)t.size(), ans=0;

  for(lint i=size-1;i>=0;i--) {
    if(i+k < size && t[i] == t[i+k]) { t[i] = 'x'; }
    if(t[i] == 'r') { ans += p; }
    else if(t[i] == 's') { ans += r; }
    else if(t[i] == 'p') { ans += s; }
  }

  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int>pint;
typedef vector<int>vint;
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);i++)
template<class T,class U>void chmin(T &t,U f){if(t>f)t=f;}
template<class T,class U>void chmax(T &t,U f){if(t<f)t=f;}

#define int long long

int getint(int bit){
    return (bit&0x7ffffff8)>>7;
}

int getfrac(int bit){
    int ret=0;
    int mask=10000000;

    for(int i=6;i>=0;i--){
        if(bit>>i&1)ret+=mask>>(7-i);
    }
    return ret;
}

void solve(){
    int val;
    scanf("%x",&val);
    if(val>>31&1)cout<<"-";
    cout<<getint(val)<<".";
    int frac=getfrac(val);
    if(frac==0){
        cout<<0<<endl;
    }
    else{
        int lost=(int)log10(10000000)-(int)log10(frac);
        rep(i,lost-1)cout<<0;
        while(frac%10==0)frac/=10;
        cout<<frac<<endl;
    }
}

signed main(){
    int Q;
    cin>>Q;
    while(Q--)solve();
}

Measured memory_bytes: 1292
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {

      Scanner sc = new Scanner(System.in);
      int a = sc.nextInt();
      int b = sc.nextInt();


      int sum = a + b;
      int sub = a - b;
      int mul = a * b;
      
      int max = sum;
      if(sub > max) {
    	  max = sub;
      }
      if(mul > max) {
    	  max = mul;
      }
      
      System.out.println(max);

      sc.close();

    }
}


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

struct cake{
  int w,d;
};

struct cake c[101];

void change(int n,int p,int s,int w,int d,bool wj){
  for(int i=p;i<n-1;i++) c[i]=c[i+1];
  if(wj){
    if(s<=w-s){
      c[n-1].w=s; c[n].w=w-s;
    } else{
      c[n-1].w=w-s; c[n].w=s;
    }
    c[n-1].d=c[n].d=d;
  } else{
    if(s<=d-s){
      c[n-1].d=s; c[n].d=d-s;
    } else{
      c[n-1].d=d-s; c[n].d=s;
    }
    c[n-1].w=c[n].w=w;
  }
}

void cut(int p,int s,int n){
  int w=c[p].w,d=c[p].d;
  s%=2*w+2*d;
  if(s<w){
    change(n,p,s,w,d,true);
  } else if(s<w+d){
    s-=w;
    change(n,p,s,w,d,false);
  } else if(s<2*w+d){
    s-=w+d;
    change(n,p,s,w,d,true);
  } else{
    s-=2*w+d;
    change(n,p,s,w,d,false);
  }
}

int main(){
  int n,w,d,p,s;

  for(;;){
    cin>>n>>w>>d;
    if(n==0&&w==0&&d==0) break;
    c[0].w=w; c[0].d=d;
    for(int i=0;i<n;i++){
      cin>>p>>s;
      cut(p-1,s,i+1);
    }
    vector<int> area;
    for(int i=0;i<=n;i++) area.push_back(c[i].w*c[i].d);
    sort(area.begin(),area.end());
    for(int i=0;i<n;i++) cout<<area[i]<<" ";
    cout<<area[n]<<endl;
  }
}


Measured memory_bytes: 1220
#include<bits/stdc++.h>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
using namespace std;
typedef long long ll;

int main(){
ll k,t,n,m,a,b;
cin>>a;
for(ll i=-4570;i<4570;i++){
   // cout<<i*i*i*i*i<<endl;
    for(ll j=-4570;j<4570;j++){

       if((i*i*i*i*i)-(j*j*j*j*j)==a){
            a=i;b=j;
            cout<<a<<" "<<b;
            return 0;
       }
    }
}

}


Measured memory_bytes: 3584
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int Q = sc.nextInt();
		String S = sc.next();
		int[] cnt = new int[N+1];
		for(int i = 0;i < N-1;i++) {
			cnt[i+1] = cnt[i] + (S.substring(i,i+2).equals("AC") ? 1 : 0);
		}
		String SLastSub = String.valueOf(S.charAt(N-2)+S.charAt(N-1));
		cnt[N] = cnt[N-1] + (SLastSub.equals("AC") ? 1 : 0);
		for(int i = 0;i < Q;i++) {
			int L = sc.nextInt();
			int R = sc.nextInt();
			System.out.println(cnt[R-1]-cnt[L-1]);
		}
		sc.close();
	}
}

Measured memory_bytes: 76256
import java.util.*;

import java.io.*;

public class Main {
	public static void main(String args[]) throws Exception {

		FastReader sc = new FastReader();
		PrintWriter out = new PrintWriter(System.out);
		long x = sc.nextLong();
		long y = sc.nextLong();
		int s = 0;
		while (x <= y) {
			x *= 2;
			s++;
		}
		out.println(s);

		out.close();

	}

	static class FastReader {
		BufferedReader br;
		StringTokenizer st;

		public FastReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		String next() {
			while (st == null || !st.hasMoreElements()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

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

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

		double nextDouble() {
			return Double.parseDouble(next());
		}

		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return str;
		}
	}
}


Measured memory_bytes: 23252
def factorize(n):
    fct=[]
    b,e=2,0
    while b*b<=n:
        while n%b==0:
            n=n//b
            e=e+1
        if e>0:
            fct.append((b,e))
        b,e=b+1,0
    if n>1:
        fct.append((n,1))
    return fct

n = int(input())
ans = str(n) + ":"
for i,v in factorize(n):
    ans += (" "+str(i))*v
print(ans)


Measured memory_bytes: 5600
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
using namespace std;

int main()
{
    const char H = 'H';
    const char D = 'D';

    char a[2];
    char b[2];

    if (scanf("%s%s", a, b) < 2) return 0;

    printf("%c\n", a[0] == H ? b[0] : b[0] == H ? D : H);
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
map<int, int> mp;
int main(){
	IOS
	int n,mn=1e6,mx=-1;
	cin>>n;
	for(int i=1;i<=n;i++){
		int a;
		cin>>a;
		mp[a]++;
		if(mp[a]==n){
			if(a==n-1||a*2<=n){
				cout<<"Yes";
			}
			else{
				cout<<"No";
			}
			return 0;
		}
		if(a<mn){
			mn=a;
		}
		if(a>mx){
			mx=a;
		}
	}
	if(mp.size()!=2){
		cout<<"No";
		return 0;
	}
	if((mx-mp[mn])*2<=mp[mx]&&mp[mn]<=mn){
		cout<<"Yes";
	}
	else{
		cout<<"No";
	}
	return 0;
}
/*

*/

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

#define rep3(i, s, n ,a) for (int i = (s); i < (int)(n); i+=a)
#define rep2(i, s, n) rep3(i, s, n, 1)
#define rep(i, n) rep2(i, 0, n)

int main(){
    string s;
    cin >> s;
    if(s[1]=='B'){
        cout << "ARC" << endl;
    }else{
        cout << "ABC" << endl;
    }
    return 0;
}

Measured memory_bytes: 3544
/*
Contest: NOMURA Programming Competition 2020
Problem: nomura2020 B
Author: tzc_wk
Time: 2020.5.30
*/
#include <bits/stdc++.h>
using namespace std;
#define fi			first
#define se			second
#define fz(i,a,b)	for(int i=a;i<=b;i++)
#define fd(i,a,b)	for(int i=a;i>=b;i--)
#define foreach(it,v) for(__typeof(v.begin()) it=v.begin();it!=v.end();it++)
#define all(a)		a.begin(),a.end()
#define giveup(...) return printf(__VA_ARGS__),0;
#define fill0(a)	memset(a,0,sizeof(a))
#define fill1(a)	memset(a,-1,sizeof(a))
#define fillbig(a)	memset(a,0x3f,sizeof(a))
#define fillsmall(a) memset(a,0xcf,sizeof(a))
#define mask(a)		(1ll<<(a))
#define maskx(a,x)	((a)<<(x))
#define _bit(a,x)	(((a)>>(x))&1)
#define _sz(a)		((int)(a).size())
#define filei(a)	freopen(a,"r",stdin);
#define fileo(a)	freopen(a,"w",stdout);
#define fileio(a) 	freopen(a".in","r",stdin);freopen(a".out","w",stdout)
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
#define put(x)		putchar(x)
#define eoln        put('\n')
#define space		put(' ')
#define y1			y1010101010101
#define y0			y0101010101010
typedef pair<int,int> pii;
inline int read(){
	int x=0,neg=1;char c=getchar();
	while(!isdigit(c)){
		if(c=='-')	neg=-1;
		c=getchar();
	}
	while(isdigit(c))	x=x*10+c-'0',c=getchar();
	return x*neg;
}
inline int qpow(int x,int e,int _MOD){
	int ans=1;
	while(e){
		if(e&1)	ans=ans*x%_MOD;
		x=x*x%_MOD;
		e>>=1;
	}
	return ans;
}
char s[200005];
int n;
signed main(){
	cin>>s+1;
	n=strlen(s+1);
	fz(i,1,n){
		if(s[i]=='P')	cout<<'P';
		if(s[i]=='D')	cout<<'D';
		if(s[i]=='?')	cout<<'D';
	}
	puts("");
	return 0;
}

Measured memory_bytes: 3824
#include<bits/stdc++.h>
#include<algorithm>
using namespace std;
 
#define ll long long
#define ld long double
 
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define repb(i,a,b) for(ll i=a;i>=b;i--)
 
#define err() cout<<"=================================="<<endl;
#define errA(A) for(auto i:A)   cout<<i<<" ";cout<<endl;
#define err1(a) cout<<#a<<" "<<a<<endl
#define err2(a,b) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<endl
#define err3(a,b,c) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<endl
#define err4(a,b,c,d) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<" "<<#d<<" "<<d<<endl
 
#define pb push_back
#define all(A)  A.begin(),A.end()
#define allr(A)    A.rbegin(),A.rend()
#define ft first
#define sd second
 
#define pll pair<ll,ll>
#define V vector<ll>
#define S set<ll>
#define VV vector<V>
#define Vpll vector<pll>
 
#define endl "\n"
 
const ll logN = 20;
const ll N=100005;
const ll M = 1000000007;
const ll INF = 1e12;
#define PI 3.14159265
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
ll pow1(ll a,ll b){
    ll res=1;
    while(b>0){
        if(b&1){
        	res=(res*a)%M;
		}
        a=(a*a)%M;
        b>>=1;
    }
    return res%M;
}

// struct segtree{
//     ll x,y;
//     ll tree[4*N];

//     void build_tree(vector<ll>&v , ll ind,ll l, ll r)
//     {
//         if(l==r)
//         {
//             tree[ind]=v[l];
//             return;
//         }
//         ll mid=(l+r)/2;
//         build_tree(v,2*ind,l,mid);
//         build_tree(v,2*ind+1,mid+1,r);
//         tree[ind]=max(tree[2*ind],tree[2*ind+1]);
//     }

//     ll query(ll ind, ll l, ll r)
//     {
//         // cout<<l<<" "<<r<<" "<<endl;
//         if(x>r || y<l)return -LLONG_MAX;
//         if(l>=x && r<=y)return tree[ind];
//         ll mid=(l+r)/2;
//         return max(query(2*ind,l,mid),query(2*ind+1,mid+1,r));
//     }
// }obj;

int main()
{
    fast;

    #ifndef ONLINE_JUDGE
    freopen("../input.txt", "r", stdin);
    freopen("../output.txt", "w", stdout);
    #endif
    
    ll T=1;
//     cin>>T;
    while(T--)
    {
        ll n;
        cin>>n;
        V a(n);
        rep(i,0,n)cin>>a[i];
        ll sum=0;
        rep(i,1,n)
        {
            if(a[i]<a[i-1])
            {
                sum+=(a[i-1]-a[i]);
                a[i]=a[i-1];
            }
        }
        cout<<sum<<endl;
    }

}

Measured memory_bytes: 4780
N = int(input())
A = [int(i) for i in input().split()] # 上
B = [int(i) for i in input().split()] # 中
C = [int(i) for i in input().split()] # 下

A.sort()
B.sort()
C.sort()

# a < b < c
from bisect import bisect_right

Bcnt = [0] * N
for i,b in enumerate(B):
    r = bisect_right(C, b)
    Bcnt[i] = N - r

from itertools import accumulate

Bcnt = list(accumulate([0] + Bcnt))

Acnt = [0] * N
for i,a in enumerate(A):
    r = bisect_right(B, a)
    Acnt[i] = Bcnt[N] - Bcnt[r]

print(sum(Acnt))

Measured memory_bytes: 25024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, N) for (int i = 0; i < (int)N; ++i)
#define all(a) (a).begin(), (a).end()

int N, M;
vector<vector<int>> G;

int main() {
  cin >> N >> M;
  G.resize(N);

  rep(i, M) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }

  auto ok = [&]() {
    for (int u : G[0]) {
      for (int v : G[u]) {
        if (v == N - 1) return true;
      }
    }
    return false;
  };

  cout << (ok() ? "POSSIBLE" : "IMPOSSIBLE") << endl;
  return 0;
}


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

using namespace std;
using ll = long long;

int main()
{
    ll n, k;
    cin >> n >> k;
    vector<ll> a(n);
    for(ll i = 0; i< n; i++){
        cin >> a[i];
    }
    for(ll i = 0; i< n; i++){
        if(i >= k){
            if(a[i-k] < a[i]) cout << "Yes" << endl;
            else cout << "No" << endl;
            //cout << "pre" << pre << endl;
            //cout << "score" << score << endl;   
        }
    }
    return 0;
}

Measured memory_bytes: 4840
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1000000007;

const int MAX = 510000;
ll fac[MAX], finv[MAX], inv[MAX];

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

ll com(ll n, ll k)
{
  if (n<k) return 0;
  if (n<0 || k<0) return 0;
  return fac[n] * (finv[k] * finv[n-k] % mod) % mod;
}

int main()
{
  ll H; cin >> H;
  ll W; cin >> W;
  ll A; cin >> A;
  ll B; cin >> B;

  cominit();
  ll ans = 0;
  for (int i=1; i<=W-B; i++) {
    ans = (ans + com(B+i-1+H-A-1, H-A-1)*com(W-B-i+A-1, A-1)) % mod;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 12160
#include<stdio.h>

int fibonacci(int);
#define N 10000

int F[N];

int main(){
  int num;
  int i;

  scanf("%d",&num);

  for(i=0;i<N;i++) F[i] = -1;
  
  printf("%d\n",fibonacci(num));


  return 0;

}

int fibonacci(int n){
  
  
  if( n == 0 || n == 1) return F[n] = 1;

  if(F[n] != -1) return F[n];

  return F[n] = fibonacci(n-2) + fibonacci(n-1);

}



Measured memory_bytes: 2744
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <numeric>
#include <bitset>

using namespace std;
using ll = long long;
using ld = long double;
const ll mod =  1000000007;
const ll inf = 1e18;

#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define REP_FROM(i, j, n) for (ll i = (j); i < (n); ++i)
#define all(x) (x).begin(),(x).end()

ll power(ll base, ll exponent){ if(exponent % 2){ return power(base, exponent - 1) * base % mod; }else if(exponent){ ll root_ans = power(base, exponent / 2); return root_ans * root_ans % mod; }else{ return 1; }}
ll inverse(ll x){ return power(x, mod - 2);}
ll gcd(ll a, ll b) {if(a < b) gcd(b, a);ll r;while(r=a%b) {a=b;b=r;}return b;}
template<typename T> ll sum(T begin, T end) {return accumulate(begin, end, 0ll);}
struct combination{ vector<ll> fact, inv; combination(int sz) : fact(sz + 1), inv(sz + 1){ fact[0] = 1; for(int i = 1; i <= sz; i++){ fact[i] = fact[i - 1] * i % mod; } inv[sz] = power(fact[sz], mod - 2); for(int i = sz - 1; i >= 0; i--){ inv[i] = inv[i + 1] * (i + 1) % mod; } } ll C(int p, int q) const{ if(q < 0 || p < q) return 0; return (fact[p] * inv[q] % mod * inv[p - q] % mod); } };

int bsearch(const vector<ll>& a, ll x){
  int lft = 0;
  int rgt = a.size();
  while (rgt - lft > 1) {
    int mid = (lft + rgt) / 2;
    if(a[mid] < x) {
      lft = mid;
    }
    else {
      rgt = mid;
    }
  }
  return lft;
}

struct UnionFind {
  vector<int> par;

  UnionFind(int n) : par(n, -1) {}
  void init(int n) { par.assign(n, -1); }

  int root(int x) {
    if (par[x] < 0)
      return x;
    return par[x] = root(par[x]);
  }

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

  bool same(int x, int y) {
    int rx = root(x);
    int ry = root(y);
    return rx == ry;
  }
  int size(int x) { return -par[root(x)]; }
};


signed main() {
  ios::sync_with_stdio(false);
  ll n, k,l;
  cin >> n >> k >> l;
  UnionFind treeR(n);
  UnionFind treeT(n);
  REP(i, k) {
    int a, b;
    cin >> a >> b;
    a--;b--;
    treeR.unite(a, b);
  }
  REP(i, l) {
    int a, b;
    cin >> a >> b;
    a--;b--;
    treeT.unite(a, b);
  }
  using Pair = pair<ll, ll>;
  map<Pair, ll> m;
  REP(i, n) {
    Pair tmp = make_pair(treeR.root(i), treeT.root(i));
    if(m.count(tmp)) m[tmp]++;
    else m[tmp] = 1;
  }
  REP(i, n) cout << m[make_pair(treeR.root(i), treeT.root(i))] << " ";
  cout << endl;
  return 0;
}


Measured memory_bytes: 13568
#include<iostream>
using namespace std;
int main() {
	int n, m;
	cin >> n >> m;
	int kyougi[1010];
	int hyou[1010] = { 0 };
	for (int i = 1; i < n + 1; i++) {
		cin >> kyougi[i];
	}
	for (int i = 0; i < m; i++) {
		int a; cin >> a;
		for (int j = 1; j < n + 1; j++) {
			if (kyougi[j] <= a) {
				hyou[j]++;
				break;
			}
		}
	}
	int maxk, maxh;
	maxk = 1;
	maxh = hyou[1];
	for (int i = 2; i < n + 1; i++) {
		if (hyou[i] > maxh) {
			maxk = i;
			maxh = hyou[i];
		}
	}
	cout << maxk << endl;
	char c; cin >> c;
}

Measured memory_bytes: 3096
using System;
using System.Collections.Generic;

class Program
{
    public void Proc()
    {
        String[] inpt = Console.ReadLine().Split(' ');
        int a = int.Parse(inpt[0]);
        int b = int.Parse(inpt[1]);
        string ans = (a * b) + " " + ((a + b) * 2);
        Console.WriteLine(ans);
    }



    static void Main(string[] args)

    {

        Program prg = new Program();
        prg.Proc();

    }
}

Measured memory_bytes: 9028
#define MOD 1000000007
long long n, m, i, j, k, dp[305][305][305];

main () {
	scanf("%llu%llu", &n, &m);
	dp[0][1][0] = 1;
	for (i = 0; i < m; i++) {
		for (j = 1; j <= n; j++) {
			for (k = 0; k <= n - j; k++) {
				dp[i + 1][j + k][0] += dp[i][j][k] * j % MOD;
				dp[i + 1][j + k][0] %= MOD;
				dp[i + 1][j][k] += dp[i][j][k] * k % MOD;
				dp[i + 1][j][k] %= MOD;
				dp[i + 1][j][k + 1] += dp[i][j][k] * (n - j - k) % MOD;
				dp[i + 1][j][k + 1] %= MOD;
			}
		}
	}

	printf("%lld\n", dp[m][n][0]);
}


Measured memory_bytes: 218496
N = int(input())
prev_t, prev_x, prev_y = 0, 0, 0
for _ in range(N):
    t, x, y = map(int, input().split())
    dt = t - prev_t
    dx = x - prev_x
    dy = y - prev_y
    if dt < dx + dy:
        print("No")
        break
    elif (dx + dy - dt) % 2 == 0:
        prev_t, prev_x, prev_y = t, x, y
    else:
        print("No")
        break
else:
    print("Yes")

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

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  int s = a + b + c;
  cout << (int)(sqrt(s * (s - 2 * a) * (s - 2 * b) * (s - 2 * c)) / 4);
  return 0;
}

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

const int N = 1e5 + 10;

int n;


signed main ( void ) {
	ios::sync_with_stdio(false);
	cin.tie(0),cout.tie(0);
	cin>>n;
	int ans = ( 1 + n - 1 ) * ( n - 1 ) / 2;
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
import itertools

N = int(input())
P = tuple(map(int,input().split()))
Q = tuple(map(int,input().split()))

jyunretsu = [i for i in range(1,N+1)]
jyun_list = list(itertools.permutations(jyunretsu))

ans = abs(jyun_list.index(P)-jyun_list.index(Q))

print(ans)

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

int main(){
  int N,L[100];cin >> N;
  for(int i=0;i<N;i++)cin >> L[i];
  int max=L[0],sum=0;
  for(int i=0;i<N;i++){
    sum+=L[i];
    if(max<L[i]){
      max=L[i];
    }
  }
  if(sum-max>max){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    static final int ZERO = 1;
    static final int NINE = 10;

    int[][] DP = new int[30][12];

    public Main() {
        Scanner scanner = new Scanner(System.in);
        int K = scanner.nextInt();

        if(K < 10){
            System.out.println(K);
            return;
        }

        for (int i = ZERO; i <= NINE; i++) {
            DP[0][i] = 1;
        }

        K -= 9;

        int D = 1;
        while(true){
            for (int n=ZERO;n<=NINE;n++){
                DP[D][n] = DP[D-1][n-1] + DP[D-1][n] + DP[D-1][n+1];

                if(n == ZERO) continue;

                if(K-DP[D][n] <= 0){
                    System.out.print(n-ZERO);
                    D--;

                    int tempN = n;
                    while(D >= 0){
                        for(int i = -1;i <= 1;i++){
                            if(K - DP[D][tempN+i] > 0){
                                K -= DP[D][tempN+i];
                            } else {
                                System.out.print(tempN+i-ZERO);
                                tempN = tempN+i;
                                break;
                            }
                        }
                        D--;
                    }

                    System.out.println("");
                    return;
                }

                K -= DP[D][n];
            }
            D++;
        }
    }

    public static void main(String[] args) {
        new Main();
    }
}


Measured memory_bytes: 35776
N = int(input())
C = [[0 for i in range(10)] for j in range(10)]
for i in range(1,N+1):
    s = str(i)
    i1,i2 = int(s[0]),int(s[-1])
    C[i1][i2] += 1
ans = 0
for i in range(10):
    for j in range(10):
        if i == 0 or j == 0:
            continue
        ans += C[i][j]*C[j][i]
print(ans)

Measured memory_bytes: 3064
S=input()

if S=="SUN":
    print(7)
elif S=="MON":
    print(6)
elif S=="TUE":
    print(5)
elif S=="WED":
    print(4)
elif S=="THU":
    print(3)
elif S=="FRI":
    print(2)
elif S=="SAT":
    print(1)

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

int main(){
  int n,k;
  cin >> n >> k;
  string s;
  cin >> s;
  for(int j = 0;j < n;j++){
    if(j == k-1){
      s.at(j) += 32;
       cout << s.at(j);
    }else{
      cout << s.at(j);
    }
  }
    cout << endl;
  return 0;
}

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

int main(void) {

  int A, B;
  cin >> A >> B;

  if(A == B) {
    cout << "Draw" << endl;
    return 0;
  }

  if(A == 1) {
    cout << "Alice" << endl;
    return 0;
  }

  if(B == 1) {
    cout << "Bob" << endl;
    return 0;
  }
  
  if(A > B) cout << "Alice" << endl;
  else cout << "Bob" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>

#define rep(i,n) for (int i = 0; i < (n); ++i)

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;

int main() {
  int a, b;
  cin >> a >> b;
  
  if (a * b % 2 == 0) cout << "Even" << endl;
  else cout << "Odd" << endl;

  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
int a[85][85],b[85][85];
bool dp[82][82][25445];  //一共有80*159*2=25440种取值，从-12720~12720 
int main()
{
	int m,n,derta,max,min;
	scanf("%d%d",&m,&n);
	for(int i=0;i<m;i++)for(int j=0;j<n;j++)scanf("%d",&a[i][j]);
	for(int i=0;i<m;i++)for(int j=0;j<n;j++)scanf("%d",&b[i][j]);
	derta=b[0][0]-a[0][0];
	max=12720+fabs(derta);
	min=12720-fabs(derta);
	dp[0][0][derta+12720]=true;
	dp[0][0][-derta+12720]=true;
	for(int i=0;i<m;i++)
	{
		for(int j=0;j<n;j++)
		{
			for(int k=(min<80?0:min-80);k<=(max>25366?25440:max+80);k++)
			{
				if(j>0)if(dp[i][j-1][k-(b[i][j]-a[i][j])])dp[i][j][k]=true;
				if(i>0)if(dp[i-1][j][k-(b[i][j]-a[i][j])])dp[i][j][k]=true;
				if(j>0)if(dp[i][j-1][k-(a[i][j]-b[i][j])])dp[i][j][k]=true;
				if(i>0)if(dp[i-1][j][k-(a[i][j]-b[i][j])])dp[i][j][k]=true;
				if(dp[i][j][k]==true&&k<min)min=k;
				if(dp[i][j][k]==true&&k>max)max=k;
			}
		}
	}
	int ans=25441,temp;
	for(int i=0;i<25441;i++)
	{
		if(dp[m-1][n-1][i]==true)if(fabs(i-12720)<ans)ans=fabs(i-12720);
		if(i>12720&&i>ans)break;
	}
	printf("%d\n",ans);
}

Measured memory_bytes: 162944
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

int main() {
  int H, W, A, B;
  cin >> H >> W >> A >> B;
  rep(i, B) {
    rep(j, A) cout << 1;
    rep(j, W-A) cout << 0;
    cout << endl;
  }
  rep(i, H-B) {
    rep(j, A) cout << 0;
    rep(j, W-A) cout << 1;
    cout << endl;
  }
  return 0;
}



Measured memory_bytes: 1280
#pragma region include
#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <tuple>
#include <bitset>

#include <queue>
#include <complex>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <fstream>
#include <random>
//#include <time.h>
#include <ctime>
#pragma endregion //#include
/////////
#define REP(i, x, n) for(int i = x; i < n; ++i)
#define rep(i,n) REP(i,0,n)
/////////
#pragma region typedef
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
#pragma endregion //typedef
////定数
const int INF = (int)1e9;
const LL MOD = (LL)1e9+7;
const LL LINF = (LL)1e18+20;
const double PI = acos(-1.0);
const double EPS = 1e-9;
/////////
using namespace::std;

void solve(){
	int N;
	cin >> N;
	vector<int> A(N);
	for(int i=0;i<N;++i){
		cin >> A[i];
		--A[i];
	}
	int ans = 0;
	for(int i=0;i<N;++i){
		if( A[ A[i] ] == i ){
			++ans;
		}
	}
	cout << ans/2 << endl;
}

#pragma region main
signed main(void){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	

	solve();
}
#pragma endregion //main()


Measured memory_bytes: 640
#include<iostream>
#include<string>
using namespace std;
int main()
{
	int a,b,k;
	cin>>a>>b>>k;
	int factor[110],num=0;
	for(int i=1;i<=100;i++)
		if(a%i==0 && b%i==0){
			factor[num++]=i;
		}
	cout<<factor[num-k]<<endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
#define Max 1000000
int main(void)
{
	int i,j,prime[Max]={0},Ans=0,n;
	prime[0]=1;
	prime[1]=1;
	for(i=2;i<=sqrt(Max);i++){
		for(j=2;i*j<Max;j++){
			prime[i*j]=1;
		}
	}
	while(scanf("%d",&n)!=EOF){
		for(i=1;i<=n;i++){
			if(prime[i]==0){
				Ans++;
			}
		}
		printf("%d\n",Ans);
		Ans=0;
	}
	return 0;
}

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

int main() {
    int n;
    cin >> n;
    vector<double> a(n);
    for (int i = 0; i < n; i++) { 
    	cin >> a[i];
    }
    
    sort(a.begin(), a.end());
    double greater = a[n - 1];

    vector<double> div(n);
    double sum2 = 0;
    for (int i = 0; i < n; i++) {
    	div[i] = greater / a[i];
    	sum2 += div[i];
    }	

    cout << setprecision(12) << greater / sum2 << "\n";

    return 0;
}

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

int main(void){
  int N;
  int A = 0; // xxxxxA
  int B = 0; // Bxxxxxx
  int AB = 0; // BxxxxxxA
  int out = 0;

  cin >> N ;
  for(int i = 0; i < N;i++){
    string s;
    cin >> s ;
    if (s[0] == 'B'){
      if(s[s.size() - 1] == 'A')AB++;
      else B++;
    }
    else{
      if(s[s.size() - 1] == 'A')A++;
    }
    for( int j = 0; j < s.size()-1;j++)
      if(s[j] == 'A' && s[j+1] == 'B')out++;
  }
  int k = min(A,B) + AB;
  if(A+B == 0 && AB != 0)k--;
  out += k;
  cout << out << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1LL<<60;
#define all(x) (x).begin(),(x).end()
#define REP(i,n) for(int i=0;i<(n);++i)
#define FOR(i,k,n) for(int i=(k);i<(n);++i)

const ll MOD = 1000000007;
const int MAX = 1000005;

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

inline ll add(ll x,ll y) {return (x+y)%MOD;}
inline ll mul(ll x,ll y) {return (x*y)%MOD;}
inline ll sub(ll x,ll y) {
    ll res = x - y;
    return (res>=0?res:res+MOD);
}

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

long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


int main() {
    int N,K; cin >> N >> K;
    vector<ll> A(N);
    REP(i,N) cin >> A[i];
    sort(all(A));
    COMinit();
    map<ll,int> mp;
    REP(i,N) mp[A[i]]++;
    int cnt = 0;
    ll ans = 0;
    for (auto p:mp) {
        int num = p.second;
        ll a = p.first;
        ans += mul(sub(COM(cnt+num,K),COM(cnt,K)),a); ans %= MOD;
        ans = sub(ans,mul(sub(COM(N-cnt,K),COM(N-cnt-num,K)),a));
        cnt += num;
    }
    cout << ans << endl;
}

Measured memory_bytes: 30208
#include<bits/stdc++.h>
using namespace std;
int main(){
  pair<int,int>a[1000];
  int c=0,t[1000];
  char cc;
  while(1){
    scanf("%d,%d",&a[c].second,&a[c].first);
      c++;
      if(a[c-1].first==0&&a[c-1].second==0)goto L;
    }
  L:c--;
  stable_sort(a,a+c);
  int r=1;
  t[a[c-1].second]=1;
  for(int i=c-2;i>=0;i--){
    if(a[i+1].first!=a[i].first){
      t[a[i].second]=(++r);
    }
    else{
      t[a[i].second]=r;
    }
  }
  while(cin>>c)cout<<t[c]<<endl;
}

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

#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)

using ll = long long;
#define INF 1e9

int N;
string S;

int main(){
  cin >> N;
  cin >> S;
  vector<int> cntW(N+1, 0), cntE(N+1, 0);
  REP(i, N){
    cntW[i+1] = cntW[i];
    cntE[i+1] = cntE[i];
    if(S[i] == 'W'){
      cntW[i+1]++;
    }
    else{
      cntE[i+1]++;
    }
  }
  int ans = INF;
  REP(i, N){
    int cost = cntW[i] + cntE[N] - cntE[i+1];
    ans = min(cost, ans);
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3076
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;

int main(){
  
  int d, n;
  
  cin >> d >> n;
  
  d = pow(100, d);
  
  if(n <= 99) cout << n * d << endl;
  else cout << 101 * d << endl;
  
  return 0;
}

Measured memory_bytes: 256
# ABC129D - Lamp
import sys

input = sys.stdin.readline


def check_light():
    L, R = [[0] * W for _ in range(H)], [[0] * W for _ in range(H)]
    U, D = [[0] * W for _ in range(H)], [[0] * W for _ in range(H)]
    for i in range(H):
        for j in range(W):
            if S[i][j] == "#":
                L[i][j] == 0
                U[i][j] == 0
            else:
                if j == 0:
                    L[i][j] = 1
                else:
                    L[i][j] = L[i][j - 1] + 1
                if i == 0:
                    U[i][j] = 1
                else:
                    U[i][j] = U[i - 1][j] + 1
            if T[i][j] == "#":
                R[i][j] == 0
                D[i][j] == 0
            else:
                if j == 0:
                    R[i][j] = 1
                else:
                    R[i][j] = R[i][j - 1] + 1
                if i == 0:
                    D[i][j] = 1
                else:
                    D[i][j] = D[i - 1][j] + 1
    return U, L, D, R


def main():
    global H, W, S, T
    H, W = tuple(map(int, input().split()))
    S = tuple(input().rstrip() for _ in range(H))
    T = [s[::-1] for s in S[::-1]]  # reversed S
    U, L, D, R = check_light()
    D, R = [d[::-1] for d in D[::-1]], [r[::-1] for r in R[::-1]]
    ans = max(
        L[i][j] + R[i][j] + U[i][j] + D[i][j] - 3 for i in range(H) for j in range(W)
    )
    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 254216
#include <stdio.h>
int main(void){
    double r, are, circ, p;
    p = 3.141592653589;
    scanf("%lf",&r);
    are = p * r * r;
    circ = 2 * p * r;
    printf("%lf %lf\n", are, circ);
    
    return 0;
}


Measured memory_bytes: 2072
import java.util.Scanner;                                                                            
                                                                                                     
public class Main{                                                                                   
    public static void main(String args[]){                                                          
        Scanner sc = new Scanner(System.in);                                                         
        String a = "";                                                                               
        String b = sc.next();                                                                        
        if(b .equals("A")){                                                                          
            a = "T";                                                                                 
        }else if(b.equals("C")){                                                                     
            a = "G";                                                                                 
        }else if(b.equals("T")){                                                                     
            a = "A";                                                                                 
        }else if(b.equals("G")){                                                                     
            a = "C";                                                                                 
        }                                                                                            
        System.out.println(a);                                                                       
    }                                                                                                
}    

Measured memory_bytes: 21716