akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
using namespace std;
int n, a, b, f;
string s, t, ans;
int main()
{
    f = 0;
    cin >> n >> s >> t;
    ans.resize(n * 2 + 1);
    for (int i = 0; i < n; i++)
    {
        ans[f] = s[i];
        ans[f + 1] = t[i];
        f = f + 2;
    }
    for (int i = 0; i < n * 2; i++)
    {
        cout << ans[i];
    }
    cout << endl;
}

Measured memory_bytes: 256
#!/usr/bin/env python
# -*- coding: utf-8 -*-


def main():
  _, N = map(int, input().split())
  stats = list(map(int, input()))
  values = []
  prev = -1

  for s in stats:
    if s == prev:
      values[-1][1] += 1
    else:
      values.append([s, 1])
      prev = s

  values.append([1, 0])

  window = N * 2 + 1
  length = 0
  max_length = 0

  for i in range(len(values)):
    if i - window >= 0:
      length -= values[i - window][1]

    length += values[i][1]

    if values[i][0] == 1:
      max_length = max(length, max_length)

  print(max_length)


if __name__ == '__main__':
  main()



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

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

int main() {
	int N;
	while (cin >> N && N) {
		int W, H;
		cin >> W >> H;
		vector<vector<int>>fld(300, vector<int>(300, 0));
		rep(i, N) {
			int x, y;
			cin >> x >> y;
			x--; y--;
			fld[y][x] = 1;
		}
		int S, T;
		cin >> S >> T;
		int ans = 0;
		rep(ny, H) {
			rep(nx, W) {
				int now = 0;
				for (int y = ny; y < T + ny; y++) {
					for (int x = nx; x < S + nx; x++) {
						if (fld[y][x] == 1)now++;
					}
				}
				ans = max(ans, now);
			}
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 3196
#include <bits/stdc++.h>
using namespace std;
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int (i)=0;i<(n);i++)
#define rrep(i,n) for(int (i)=1;i<=(n);i++)
#define REP(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define MOD 1000000007
#define INF 1e18
#define int long long
#define endl "\n"
#define yorn(f) puts((f)?"Yes":"No")
#define YORN(f) puts((f)?"YES":"NO")
typedef long long ll;
typedef pair<int, int> P;
int gcd(int a,int b){return b?gcd(b,a%b):a;};
int lcm(int a,int b){return a/gcd(a,b)*b;};
int mod(int a,int b){return (a+b-1)/b;};
template<typename A, size_t N, typename T>
void Fill(A(&array)[N],const T &val){std::fill((T*)array,(T*)(array+N),val);}
template<class T>inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;};
template<class T>inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;};



signed main() {
    cin.tie(nullptr);
    cout.tie(nullptr);
    ios::sync_with_stdio(false);
    //cout << fixed << setprecision(15);
    
    int n;
    cin >> n;
    int cnt = 0;
    bool f = 0;
    rep(i, n) {
        int a, b;
        cin >> a >> b;
        if(a == b) cnt++;
        if(a != b) cnt = 0;
        
        if(cnt >= 3) {
            if(!f) cout << "Yes" << endl;
            f = 1;
        }
        // cout << cnt << endl;
    }
    if(!f) cout << "No" << endl;
    return 0;
}

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

int main()
{
 	int n, k, a[1010], sum=0;
  cin >> n >> k;
  for(int  i = 0; i < n; i++) cin >> a[i];
  sort(a, a+n);
  for(int i = 0; i < k; i++)
    sum+=a[i];
  cout << sum << endl;
}

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

int main() {
	int N, K, x;
	cin >> N >> K;
	int Kyori = 0;
		for (int i = 0; i < N; i++){
			cin >> x;
        	if (x * 2 <= (K - x) * 2){
         		Kyori = Kyori + x * 2;	
            }else{
            	Kyori = Kyori + (K - x)* 2;
            }
        }cout << Kyori << endl;
}

Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() -> () {
    input!{
        n: usize,
        x: usize,
        xi: [usize; n],
    }

    let mut xs = xi;
    xs.push(x);
    xs.sort();
    let f = xs.first().unwrap().clone();
    for x in xs.iter_mut() {
        *x -= f;
    }
    xs.remove(0);
    let mut f = xs.first().unwrap().clone();
    for x in xs.iter() {
        f = gcd(f, *x);
    }
    println!("{}", f);
}

fn gcd(x: usize, y: usize) -> usize {
    let mut x = x;
    let mut y = y;
    while y != 0 {
        let t = y;
        y = x % y;
        x = t;
    }
    x
}


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

int main(){
  int n, m, x, a[101];
  cin >> n >> m >> x;
  for(int i = 0; i < m; i++){
    cin >> a[i];
  }
  int left = 0;
  int right = 0;
  for(int i = 0; i < m; i++){
    if(a[i] < x) left++;
    else right++;
  }
  cout << min(left, right) << endl;
  return 0;
}

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

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

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

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

using namespace std;

int main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n; cin >> n;
	vll a(n);
	ll sum=0, cnt=0;
	rep(i, n){
		cin >> a[i];
		if (a[i] < 0){
			a[i] = -a[i];
			cnt++;
		}
		sum += a[i];
	}
	if (cnt % 2 == 1){
		sort(all(a));
		sum -= 2*a[0];
	}

	cout << sum << "\n";

	return 0;
}


Measured memory_bytes: 1024
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <fstream>
#include <iomanip>
using namespace std;
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toStr(T x) { ostringstream sout; sout << x; return sout.str(); }
typedef vector<int> vi;
typedef vector<vi>  vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n) FOR(i,0,(n)-1)
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = INT_MAX / 2;
const int MOD = 1000000007;

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

	cout << N / 3 << endl;
	return 0;
}

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

int main() {
	int a,b;
	int ans;
	cin >> a >> b;
	if(a < b) swap(a,b);
	
	if (a > b) {
		ans = a + (a - 1);
	} else if(a == b){
		ans = a * 2;
	}	
	
	cout << ans << endl;
}

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

void check(char one, char two, ll N, const std::string& s)
{
    vector<char> ans(N);
    ans[0] = one;
    ans[1] = two;

    if ((one == 'S' && s[0] == 'o') || (one == 'W' && s[0] == 'x')) {
        ans[N - 1] = two;
    } else {
        ans[N - 1] = two == 'S' ? 'W' : 'S';
    }

    for (ll i = 1; i < N - 2; i++) {
        if ((ans[i] == 'S' && s[i] == 'o') || (ans[i] == 'W' && s[i] == 'x')) {
            ans[i + 1] = ans[i - 1];
        } else {
            ans[i + 1] = ans[i - 1] == 'S' ? 'W' : 'S';
        }
    }

    if ((ans[N - 2] == 'S' && s[N - 2] == 'o') || (ans[N - 2] == 'W' && s[N - 2] == 'x')) {
        if (ans[N - 1] != ans[N - 3]) {
            return;
        }
    } else {
        if (ans[N - 1] == ans[N - 3]) {
            return;
        }
    }
    if ((ans[N - 1] == 'S' && s[N - 1] == 'o') || (ans[N - 1] == 'W' && s[N - 1] == 'x')) {
        if (ans[0] != ans[N - 2]) {
            return;
        }
    } else {
        if (ans[0] == ans[N - 2]) {
            return;
        }
    }

    copy(begin(ans), end(ans), ostream_iterator<char>(cout));
    cout << "\n";
    exit(EXIT_SUCCESS);
}

void solve(long long N, std::string s)
{
    check('S', 'S', N, s);
    check('S', 'W', N, s);
    check('W', 'S', N, s);
    check('W', 'W', N, s);

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

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
// clang-format off
#pragma GCC diagnostic ignored "-Wunused-result"
int main(){
    long long N;
    scanf("%lld",&N);
    std::string s;
    std::cin >> s;
    solve(N, s);
    return 0;
}


Measured memory_bytes: 512
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<cstdlib>
#include<iomanip>
#include<queue>
#include<set>
#include <valarray>
#include<stack>
#include<sstream>
#include<math.h>
   
using namespace std;
   
void Solution()
{
   int a, b;
    
    cin>>a>>b;
    
    cout<<fixed<<setprecision(4)<<(double)a * b / 3.305785 <<endl;
}
   
int main()
{
    Solution();
    return 0;
}

Measured memory_bytes: 1232
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <string>
#include <map>
#include <cmath>
#include <cstring>

#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
using P = pair<int, int>;

const ll LINF = 1001002003004005006LL;
const int INF = 1001001001;

const int mod = 1000000007;

int main() {
    int n; cin >> n;
    n %= 10;
    if (n == 2 || n == 4 || n == 5 || n == 7 || n == 9) cout << "hon" << endl;
    else if (n == 0 || n == 1 || n == 6 || n == 8) cout << "pon" << endl;
    else if (n == 3) cout << "bon" << endl;
    return 0;
}

Measured memory_bytes: 3636
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sstream>
#include <iostream>
#include <math.h>
#include <time.h>
#include <unistd.h>
#include <algorithm>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <string>

#ifndef ONLINE_JUDGE
	#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#else
	#define DEBUG(x) do {} while(0);
#endif

#define pb push_back
#define mp make_pair
#define X first
#define Y second
#define FOR(i, A, N) for(int (i) = (A); (i) < (N); (i)++)
#define REP(i, N) for(int (i) = 0; (i) < (N); (i)++)

using namespace std;
typedef long long ll;
inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; }

int n,m;

int main() {
	ll a,b;
	scanf("%lld%lld", &a, &b);
	int ans = 1;
	vector<ll> pa, pb;
	for(ll d = 2; d*d <= a; d++) {
		if(a % d == 0) {
			while(a % d == 0)
				a /= d;
			pa.pb(d);
		}
	}
	if(a > 1) pa.pb(a);
	for(ll d = 2; d*d <= b; d++) {
		if(b % d == 0) {
			while(b % d == 0)
				b /= d;
			pb.pb(d);
		}
	}
	if(b > 1) pb.pb(b);
	sort(pa.begin(), pa.end());
	sort(pb.begin(), pb.end());
	REP(i, pa.size()) {
		bool found = false;
		REP(j, pb.size()) {
			if(pa[i] == pb[j]) {
				found = true;
			}
			if(pa[i] < pb[j])
				break;
		}
		if(found) ans++;
	}
	printf("%d\n", ans);
	return 0;
}


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

#define PI 3.1415926535

int main(){
    int n, x, sum = 0;
    cin >> n;
    vector<int> a(n), b(n), c(n - 1);
    for (int i = 0; i < n; i++)
        cin >> a.at(i);
    for (int i = 0; i < n; i++)
        cin >> b.at(i);
    for (int i = 0; i < n-1; i++)
        cin >> c.at(i);

    for (int i = 0; i < n; i++){
        sum += b.at(i);
        if (i > 0 && a.at(i) ==a.at(i - 1)+1){
            x = a.at(i - 1)-1;
            sum += c.at(x);
        }
    }
    cout << sum << endl;

return 0;
}


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

if (b-a) % 2 == 0:
    print(abs(b-a)//2)
else:
    c = a+(b-a-1)//2
    a = n+1-a
    b = n+1-b
    d = b+(a-b-1)//2
    # print(c,d)
    print(min(c,d))


Measured memory_bytes: 38256
import java.io.*;
public class Main{

public static void main(String[] args){
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
try{
        //Input x
String line = reader.readLine();
   
    int x = Integer.parseInt(line);
    int result = 1;
    for(int i=0; i<3; i++){
        result *= x;
    }
     System.out.println(result);

} catch(IOException e){
System.out.println(e);
     }
}
}


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

using namespace std;

int main()
{
  int H,W;
  scanf("%d%d",&H,&W);
  char s[310][310];
  for(int i=0;i<H;i++){
    scanf("%s",s[i]);
  }
  int ans=0;
  for(int i=0;i+1<W;i++){
    int dp0[310][310],dp[310][310];
    for(int j=0;j<=H;j++){
      for(int k=0;k<=H;k++){
	if(j==0||k==0){
	  dp0[j][k]=0;
	}
	else{
	  dp0[j][k]=dp0[j-1][k-1]+(s[j-1][i]==s[k-1][i+1]?1:0);
	}
      }
    }
    for(int j=0;j<=H;j++){
      for(int k=0;k<=H;k++){
	if(j==0||k==0){
	  dp[j][k]=0;
	}
	else{
	  dp[j][k]=min(dp[j-1][k],dp[j][k-1])+dp0[j][k];
	}
      }
    }
    ans+=dp[H][H];
  }
  printf("%d\n",ans);
  return 0;
}


Measured memory_bytes: 1152
package main

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

func solve() {
	_ = getInt()
	s := getRunes()

	pins := make([]int, 1000)
	for pNum := range pins {
		pin := []rune(fmt.Sprintf("%03d", pNum))
		cursor := 0
		for _, r := range s {
			if r == pin[cursor] {
				cursor++
			}

			if cursor == 3 {
				pins[pNum] = 1
				break
			}
		}
	}

	ans := sum(pins...)
	fmt.Fprintln(wr, ans)
}

func sum(ns ...int) int {
	var sum int
	for _, n := range ns {
		sum += n
	}
	return sum
}

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

const (
	inf = 1 << 60
	// mod = 1000000007
)

var (
	sc = bufio.NewScanner(os.Stdin)
	wr = bufio.NewWriter(os.Stdout)
)

func main() {
	// buf := 200001
	// sc.Buffer(make([]byte, buf), buf)
	sc.Split(bufio.ScanWords)
	solve()
	wr.Flush()
}

func getInt() int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return i
}

func getIntSlice(n int) []int {
	is := make([]int, n)
	for i := range is {
		is[i] = getInt()
	}
	return is
}

func getString() string {
	sc.Scan()
	s := sc.Text()
	return s
}

func getRunes() []rune {
	return []rune(getString())
}


Measured memory_bytes: 896
#!/usr/bin/env python3
N = int(input())

if N >= 64:
    N = 64
elif N >= 32:
    N = 32
elif N >= 16:
    N = 16
elif N >= 8:
    N = 8
elif N >= 4:
    N = 4
elif N >= 2:
    N = 2
elif N == 1:
    N = 1

print(N)

Measured memory_bytes: 2940
//#include <bits/stdc++.h>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <stack>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <functional>
//#include <unordered_set>
#define INF 2147483647
#define MAXN  1000100
#define PII pair<int, int>
#define mp(a,b) make_pair(a,b)
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
const int maxn = 35;
ll a[MAXN];

int main()
{
	//ios::sync_with_stdio(false);
	cin.tie(0);
#ifdef local_debug
	ifstream inputs("input.txt");
	cin.rdbuf(inputs.rdbuf());
	freopen("input.txt", "r", stdin);
#endif
	int n, k;
	while (cin >> n >> k) {
		ll ans = 0;
		for (int i = k + 1; i <= n; i++) {
			int sz = n / i;
			ans += sz * (i - k);
			int j = n % i;
			if (j - k + 1 > 0)
				ans += j - k + 1;
		}
		if (k == 0)
			ans -= n;
		cout << ans << endl;
	}
	return 0;
}

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

#define Q int t; scanf("%d", &t); for(int q=1; q<=t; q++)
typedef long long int lli;
typedef pair<lli, lli> pi;

#define N 2005

lli ncr[N][N], mod = 1000000007;

void getcom()
{
    for(int i=0; i<N; i++){
        ncr[i][0] = ncr[i][i] = 1LL;
        ncr[i][1] = i;
    }
    for(int i=3; i<N; i++){
        for(int j=2; j<i; j++){
            ncr[i][j] = (ncr[i-1][j-1]+ncr[i-1][j]) % mod;
        }
    }
}

int main()
{
    getcom();
    int n, k;
    cin >> n >> k;

    int x = n-k;
    for(int i=1; i<=k; i++){
        if(i == 1){
            cout << x+1 << "\n";
        }
        else{
            cout << ncr[k-1][i-1]*ncr[x+1][i]%mod << "\n";
        }
    }

    return 0;
}


Measured memory_bytes: 30208
import java.util.Scanner;
import java.util.ArrayList;
import java.util.Set;
import java.util.HashSet;
import java.util.Collections; 
 
public class Main {  
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    Set<Integer> Aset = new HashSet<Integer>();
    for (int i =0; i<N; i++) {
      int a = sc.nextInt();
      if (Aset.contains(a)) {
        Aset.remove(a);
      } else {
        Aset.add(a);
      }
    }
    System.out.println(Aset.size());  
  }
}

Measured memory_bytes: 64820
def swap_ij(xs, i, j):
    xs[i], xs[j] = xs[j], xs[i]


def main():
    N = int(input())
    p = [int(x) for x in input().split()]
    sorted_p = sorted(p)

    for i in range(N):
        for j in range(i, N):
            swap_ij(p, i, j)
            if p == sorted_p:
                print("YES")
                return
            else:
                swap_ij(p, i, j)

    print("NO")


if __name__ == "__main__":
    main()


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

using ll = long long;
using ld = long double;
using pii = pair<int, int>;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))

int dx4[4] = {1,0,-1,0}, dy4[4] = {0,1,0,-1};

int main(){
    vector<int> v(6);
    int cnt[4];
    for(int i = 0; i < 4; i++)
    {
        cnt[i]=0;
    }
    
    for(int i = 0; i < 6; i++)
    {
        cin>>v[i];
        cnt[v[i]-1]++;
    }
    bool ok = true;
    for(int i = 0; i < 4; i++)
    {
        if(cnt[i]>2)
        {
            ok = false;
        }
    }
    
    if(ok)
    {
        cout<<"YES"<<endl;
    }
    else
    {
        cout<<"NO"<<endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
using namespace std;
int i, a;
double n, b, x;
int main() {
cin>>n;
  for (i=1; i<=n; i++)
    if (i%2==1)
      x++;
b=x/n;
cout<<fixed;
cout<<setprecision(9)<<b;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    long n,k,r,s,p,ans = 0;
    string t;
    cin >> n >> k >> r >> s >> p >> t;
    for(int i=0;i<k;i++){
        char cur = 'n';
        for(int j=0;j<=(n/k)*k;j+=k){
            if(n<=i+j) continue;
            char a = t[i+j];
            if(cur!=a){
                cur = a;
                if(a=='r') ans += p;
                if(a=='s') ans += r;
                if(a=='p') ans += s;
                continue;
            }
            if(cur==a) cur = 'n';
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i < n; ++i)
#define repe(i, n) for(int i=0; i <= n; ++i)
#define repr(i, n) for(int i=n-1; i > 0; --i)
#define all(x) (x).begin(), (x).end()
#define pb(x) push_back(x)
#define eb(x,y) emplace_back(x,y)
#define PI 3.14159265359
using namespace std;
template <class T> bool chmax(T &a, const T &b) {if (a<b) {a = b; return 1;} return 0;}
template <class T> bool chmin(T &a, const T &b) {if (b<a) {a = b; return 1;} return 0;}
template <class T> using V=vector<T>;
typedef long long ll;
const int INF = 1e9;
const ll MOD = 1000000007;
const ll MAX = 510000;
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a * b / gcd(a, b); }
long long fac[MAX], finv[MAX], inv[MAX];
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
vector<int> Eratosthenes(const int N)
{
    vector<bool> is_prime(N+1, true);
    vector<int> P;
    for(int i=2; i<=N; i++) {
        if (is_prime[i]) {
            for(int j=2*i; j<=N; j+=i) {
                is_prime[j] = false;
            }
            P.emplace_back(i);
        }
    }
    return P;
}
 
int main() {
    int n;
    cin >> n;
    set<int> st;
    rep(i,n) {
        int a;
        cin >> a;
        st.insert(a);
    }
    if (st.size()==n) {
        cout << "YES" << "\n";
    } else {
        cout << "NO" << "\n";
    }
}

Measured memory_bytes: 9600
A = [[i for i in map(int, input().split())] for _ in range(3)]
N = int(input())
b = set(int(input()) for _ in range(N))
ans = False

ans = False
for row in A:
    if all(x in b for x in row):
        ans = True
for j in range(3):
    if all(A[i][j] in b for i in range(3)):
        ans = True
if all(A[i][i] in b for i in range(3)):
    ans = True
if all(A[i][2 - i] in b for i in range(3)):
    ans = True
print("Yes" if ans else "No")

Measured memory_bytes: 9148
from collections import defaultdict
from operator import itemgetter

N = int(input())
p = []
for _ in range(N):
    p.append(tuple(map(int, input().split())))
p.sort(key=itemgetter(0), reverse=True)

if N == 1:
    print(1)
else:
    d = defaultdict(int)
    for i, pp1 in enumerate(p):
        for j in range(N):
            if i == j:
                continue
            pp2 = p[j]
            d[(pp1[0] - pp2[0], pp1[1] - pp2[1])] += 1
    # print(d)

    print(N - max(d.values()))


Measured memory_bytes: 3820
n = int(input())
l = list(map(int,input().split()))

sw='n'
ans=0
for i in range(1,n):
    if sw=='u':
        if l[i-1]-l[i]<=0:
            continue
        else:
            ans+=1
            sw='n'
    elif sw=='d':
        if l[i-1]-l[i]>=0:
            continue
        else:
            ans+=1
            sw='n'
    else:
        if l[i-1]-l[i]<0:
            sw='u'
        elif l[i-1]-l[i]>0:
            sw='d'
        else:
            continue

print(ans+1)

Measured memory_bytes: 20404
n = int(input())
XYH = [list(map(int, input().split())) for _ in range(n)]
#print(XYH)

for x1, y1, h1 in XYH:
    if h1 > 0:
        for Cx in range(101):
            for Cy in range(101):
                H = h1 + abs(x1 - Cx) + abs(y1 - Cy)
                # print(Cx, Cy, H)
                if all(h == max(H - abs(x - Cx) - abs(y - Cy), 0) for x, y, h in XYH):
                  print(Cx, Cy, H)
                  exit()

Measured memory_bytes: 9204
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
const ll INF=1e18;


int main() {
  int n,w,count=0;
  cin >>n;
  set<int> s;
  rep(i,n){
    cin >>w;s.insert(w);
  }
  for(auto au:s){
    count++;
  }
  cout<< count<<endl;
}

Measured memory_bytes: 3600
#include <stdio.h>

int main() {
  int a, b, c, buff;
  scanf("%d%d%d", &a, &b, &c);
  if (a > b) {
    buff = a;
    a = b;
    b = buff;
  }
  if (b > c) {
    buff = b;
    b = c;
    c = buff;
  }
  if (a > b) {
    buff = a;
    a = b;
    b = buff;
  }

  printf("%d %d %d\n", a, b, c);
  return 0;
}


Measured memory_bytes: 2108
#include <bits/stdc++.h>
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
 //Compiler version g++ 6.3.0

 int main()
 {
 	int n,m,c,ans=0;
 	cin >> n>>m>>c;
 	int b[m];
 	for (int i = 0; i < m; i++){
 		cin >> b[i];
 	}
 	for (int i = 0; i < n; i++){
 		int x=0;
 		for (int j = 0; j < m; j++){
 			int y;
 			cin >> y;
 			x+=b[j]*y;
 		}
 		if(x+c>0){
 			ans++;
 		}
 	}
 	cout << ans << endl;
 }

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

int main() {
	
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	
	int n;
	cin>>n;
	long long int res=0;
	for(int i=1;i<=n;i++)
	{
		if(i%3!=0 && i%5!=0)
			res+=i;
	}
	cout<<res<<"\n";
	return 0;
	
}


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

import static java.lang.Integer.parseInt;

public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line;

		while ((line = br.readLine()) != null && !line.isEmpty()) {
			int n = parseInt(line);
			if (n == 0) break;

			boolean[][] privacy = new boolean[n + 1][n + 1];
			boolean[] suspects = new boolean[n + 1];

			// privacy[j][i] -> j known by i.
			for (int i = 1; i < n + 1; i++) {
				StringTokenizer st = new StringTokenizer(br.readLine());
				st.nextToken();
				while (st.hasMoreTokens()) {
					privacy[parseInt(st.nextToken())][i] = true;
				}
			}

			//
			StringTokenizer st = new StringTokenizer(br.readLine());
			st.nextToken();

			Arrays.fill(suspects, true);
			while (st.hasMoreTokens()) {
				int l = parseInt(st.nextToken());
				for (int i = 1; i < n + 1; i++) suspects[i] &= privacy[l][i];
			}

			//
			int suspect = 0, count = 0;
			for (int i = 1; i < n + 1; i++) {
				if (suspects[i]) {
					suspect = i;
					count++;
				}
			}
			System.out.println(count == 1 ? suspect : -1);

		} //end while
	} //end main
}

Measured memory_bytes: 36632
N = int(input())
a_d = {}
for i in range(N):
    a_d[i] = int(input())

sorted_a_d = sorted(a_d.items(),key=lambda x:-x[1])
for i in range(N):
    if(sorted_a_d[0][0]!=i):
        print(sorted_a_d[0][1])
    else:
        print(sorted_a_d[1][1])




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

void fnMaxHeapifyUp(vector<int>& rvnPrtyHeap, int nx)
{
  int nParnt = nx / 2;
  int nLrge = nx;

  if (nParnt > 0  &&
      rvnPrtyHeap[nParnt] < rvnPrtyHeap[nLrge])
  {
    swap(rvnPrtyHeap[nParnt], rvnPrtyHeap[nLrge]);
    fnMaxHeapifyUp(rvnPrtyHeap, nParnt);
  }
}

void fnMaxHeapifyDown(vector<int>& rvnPrtyHeap, int nx)
{
  int nLeft = nx * 2;
  int nRigt = nLeft + 1;
  int nLrge = nx;

  if (nLeft < rvnPrtyHeap.size()  &&
      rvnPrtyHeap[nLrge] < rvnPrtyHeap[nLeft])  
    nLrge = nLeft;
  if (nRigt < rvnPrtyHeap.size()  &&
      rvnPrtyHeap[nLrge] < rvnPrtyHeap[nRigt])
    nLrge = nRigt;

  swap(rvnPrtyHeap[nx], rvnPrtyHeap[nLrge]);
  if (nx != nLrge)
    fnMaxHeapifyDown(rvnPrtyHeap, nLrge);
}

void fnPriorityQueue(vector<int>& rvnPrtyHeap)
{
  rvnPrtyHeap.push_back(-1);
  string sCmd;
  while (cin >> sCmd && sCmd != "end")
  {
    if (sCmd[0] == 'i')
    {
      int nNo;
      cin >> nNo;
      rvnPrtyHeap.push_back(nNo);
      int nx = rvnPrtyHeap.size() - 1;
      fnMaxHeapifyUp(rvnPrtyHeap, nx);
    }
    else if (sCmd[0] == 'e')
    {
      cout << rvnPrtyHeap[1] << endl;
      rvnPrtyHeap[1] = rvnPrtyHeap.back();
      rvnPrtyHeap.pop_back();
      if (rvnPrtyHeap.size() > 1)
        fnMaxHeapifyDown(rvnPrtyHeap, 1);
    }
    else;
  }
}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  vector<int> vnPrtyHeap; 

  fnPriorityQueue(vnPrtyHeap);
  return 0;
}

Measured memory_bytes: 6992
import java.util.Scanner;

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

		Scanner sc = new Scanner(System.in);
		String s = sc.next();
//		int a = sc.nextInt();

		StringBuffer sb = new StringBuffer();
		for(int i=0;i<s.length();i++) {
			sb.append('x');
		}

		System.out.println(sb.toString());



	}
}


Measured memory_bytes: 23636
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <queue>
#define MOD (1000000007l)
#define rep(i, n) for(long i = 0; i < n; i++)

using namespace std;

void solve() {
  string S;
  cin >> S;
  long ans = 0;
  for (char it: S) if (it == '1') ans++;
  cout << ans << endl;
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout.precision(12);
  solve();
  return 0;
}


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

typedef long long ll;
typedef long double ld; 
typedef double db; 
typedef string str; 

typedef pair<int, int> pi;
typedef pair<ll,ll> pl; 
typedef pair<ld,ld> pd; 

typedef vector<int> vi; 
typedef vector<ll> vl;
typedef vector<ld> vd; 
typedef vector<str> vs; 
typedef vector<pi> vpi;
typedef vector<pl> vpl; 

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)
#define trav(a,x) for (auto& a: x)

#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)

#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound 
#define ub upper_bound 

const int MOD = 998244353;
const ll INF = 1e18;
const int MX = 1000001;

int main() {
	cin.sync_with_stdio(0); cin.tie(0);
    ll X; cin >> X;
    ll ans = 0;
    ans += X / 500 * 1000;
    X %= 500;
    ans += (X / 5) * 5;
    cout << ans;
    return 0;
    // You should actually read the stuff at the bottom
}

/* Stuff to Look For
 * -----------------
 * Int overflow, array bounds
 * Initializing all variables, avoid weird behavior
 * Edge cases(n = 0, n = 1)
 * Just return 0 after result
 */


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

int main()
{
    int n;
    scanf("%d",&n);
    int sum=0;
    int mn=INF;
    int x;
    for(int i=0;i<n;++i)
    {
        scanf("%d",&x);
        sum+=x;
        if(x%10!=0) mn=min(mn,x);
    }
    if(sum%10!=0)
    {
        printf("%d\n",sum);
        exit(0);
    }
    printf("%d\n",max(0,sum-mn));
    return 0;
}


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

int main() {
//    freopen("test.txt", "r", stdin);
    int n, tmp;
    scanf("%d", &n);
    int cnt1 = 0, cnt4 = 0;
    for (int i = 0; i < n; i++) {
        scanf("%d", &tmp);
        if (tmp % 4 == 0) cnt4++;
        else if (tmp % 2 != 0) cnt1++;
    }
    if (cnt4 >= n-cnt4-1 || cnt4 >= cnt1) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define N 500001
int dat[N];
void update(int i,int x){
  for(;i<N;i+=i&-i) dat[i]+=x;
}
int sum(int i){
  int s=0;
  for(;i>0;i-=i&-i)s+=dat[i];
  return s;
}
int rangesum(int l, int r){
  return sum(r)-sum(l-1);
}
  
int main()
{
  cin.tie(0);
  ios::sync_with_stdio(0);
  int n,q;
  cin>>n>>q;
  vector<int> ql[n+1],qid[n+1];
  int a[n+1];
  for(int i=1;i<=n;i++)
    cin>>a[i];
  for(int i=1;i<=q;i++){
    int l,r;
    cin>>l>>r;
    ql[r].push_back(l);
    qid[r].push_back(i);
  }
  int ans[q+1],temp[n+1];
  for(int i=1;i<=n;i++) temp[i]=0;
  for(int i=1;i<=n;i++){
    if(temp[a[i]]!=0) update(temp[a[i]],-1);
    temp[a[i]]=i;
    update(i,1);
    for(int j=0;j<ql[i].size();j++){
      ans[qid[i][j]]=rangesum(ql[i][j],i);
    }
  }
  for(int i=1;i<=q;i++) cout<<ans[i]<<endl;
  return 0;
}


Measured memory_bytes: 53048
# 2020/05/31
# AtCoder Beginner Contest 169 - B

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

# Calc
a.sort()
ans = a[0]
for i in range(1, n):
    ans = ans * a[i]
    if ans > 10**18:
        ans = -1
        break

# Output
print(ans)


Measured memory_bytes: 21700
#include<stdio.h>

int main(void)
{
   long long int n, a, b;

   scanf("%lld%lld%lld",&n,&a,&b);

   if(n%(a+b)==0)
      printf("%lld",(n/(a+b)*a));

   else if(n%(a+b)>a)
      printf("%lld",(n/(a+b)*a+a));

   else
      printf("%lld",(n/(a+b)*a+(n%(a+b))));

   return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main(){
  //入力
  int N,M;
  cin>>N>>M;
  vector<vector<int>> G(N,vector<int>());//グラフ
  for(int i=0;i<M;i++){
    int a,b;
    cin>>a>>b;
    a--;
    b--;
    G.at(a).push_back(b);
    G.at(b).push_back(a);
  }
  
  queue<int> seen;
  int dist[N];//距離
  bool judge[N];//通ったか否か
  for(int i=0;i<N;i++){
    dist[i]=0;
    judge[i]=false;
  }
  
  judge[0]=true;
  seen.push(0);
  //bfs
  while(!(seen.empty())){
    int S=seen.front();//Sは目印とする洞窟の番号
    //目印確認
    for(int i=0;i<G.at(S).size();i++){
      int nv=G.at(S).at(i);
      if(judge[nv]){
        continue;
      }
      dist[nv]=S;
      seen.push(nv);
      judge[nv]=true;
    }
    seen.pop();
  }
  cout<<"Yes"<<endl;
  for(int i=1;i<N;i++){
    cout<<dist[i]+1<<endl;
  }
}


Measured memory_bytes: 10188
import java.util.*;

public class Main {
  static final long MOD = 1000000007;

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int k = sc.nextInt();
    long nums[] = new long[k+1]; // 最大公約数がちょうどindexである個数
    long res = 0;
    for (int i = k; i >= 1; i--) {
      long num = modpow(k/i, n)%MOD; // 最大公約数がiの倍数である個数num
      for (int j = 2; j <= k/i; j++) { // 最大公約数がちょうど2i,3i,...である個数を除く
        num -= nums[i*j];
      }
      num %= MOD;
      if (num < 0) num += MOD;
      res += (long)i*(long)num;
      res %= MOD;
      nums[i] = num;
    }
    System.out.println(res);
    sc.close();
  }

  public static long modpow(long a, long n) {
    long res = 1;
    while (n > 0) { // nを2進数として扱う
      long tmp = n & 1; // 2進数nの現在の桁
      if (tmp > 0) res = res*a%MOD;
      a = a*a%MOD;
      n >>= 1;
    }
    return res;
  }
}

Measured memory_bytes: 36368
#include<stdio.h>
int main()
{
	int n;
	int a,v[20],r[20],max=0;
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%d %d",&a,&v[i]);
		r[a-1]=v[i];
	}
	for(int i=0;i<n;i++){
		if(r[i]>max){
			max=r[i];
		}
	}
	for(int i=0;i<n;i++){
		if(max==r[i]){
			printf("%d %d\n",i+1,r[i]);
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 2752
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstring>

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) v.erase(unique(v.begin(), v.end()), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
#define des_priority_queue priority_queue<int, vector<int>, greater<int> >
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;

#define MAX_V 1000000

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

	ll A, B, C;
	cin >> A >> B >> C;
	ll total = A * B * C;
	ll tmp1 = (A / 2) * B * C;
	ll rsl = abs((total - tmp1) - tmp1);
	tmp1 = A * (B / 2) * C;
	rsl = min(rsl, abs((total - tmp1) - tmp1));
	tmp1 = A * B * (C / 2);
	rsl = min(rsl, abs((total - tmp1) - tmp1));
	cout << rsl << endl;

}


Measured memory_bytes: 256
//84104971101048411497 - Can you guess what does this mean?
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef complex<double> point;
#define mapii map<int, int>
#define debug(a) cout << #a << ": " << a << endl
#define debuga1(a, l, r) fto(i, l, r) cout << a[i] << " "; cout << endl
#define fdto(i, r, l) for(int i = (r); i >= (l); --i)
#define fto(i, l, r) for(int i = (l); i <= (r); ++i)
#define forit(it, var) for(__typeof(var.begin()) it = var.begin(); it != var.end(); it++)
#define forrit(rit, var) for(__typeof(var.rbegin()) rit = var.rbegin(); rit != var.rend(); rit++)
#define ii pair<int, int>
#define iii pair<int, ii>
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define maxN 100005
#define oo 1000000007
#define sz(a) (int)a.size()

const double PI = acos(-1.0);

double fRand(double fMin, double fMax)
{
    double f = (double)rand() / RAND_MAX;
    return fMin + f * (fMax - fMin);
}

template <class T>
T min(T a, T b, T c) {
    return min(a, min(b, c));
}

template <class T>
T max(T a, T b, T c) {
    return max(a, max(b, c));
}

int n, f[maxN], dp[2][maxN];
vector<int> g[maxN];

void DFS1(int u, int p) {
    f[u] += (sz(g[u]) == 1);
    for(int v: g[u]) {
        if (v != p) {
            DFS1(v, u);
            f[u] += f[v];
        }
    }
}

void DFS2(int u, int p) {
    if (f[u] == 1) {
        dp[0][u] = 0;
        dp[1][u] = 1;
    } else {
        dp[0][u] = oo;

        int minD = 0;
        for(int v: g[u]) {
            if (v != p) {
                DFS2(v, u);
                dp[1][u] += dp[1][v];
                minD = min(minD, dp[0][v]-dp[1][v]);
            }
        }
        dp[1][u] += minD;
    }
}

int Solve() {
    fto(u, 0, n-1) {
        if (sz(g[u]) > 2) {
            DFS1(u, -1);
            DFS2(u, -1);
//            debug(u);
//            fto(u, 0, n-1) printf("%d %d %d\n", f[u], dp[0][u], dp[1][u]);
            return dp[1][u];
        }
    }
    return 1;
}

int main () {
    scanf("%d", &n);
    fto(i, 1, n-1) {
        int u, v;
        scanf("%d%d", &u, &v);
        g[u].pb(v); g[v].pb(u);
    }

    cout << Solve();

    return 0;
}


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

int cnt[1000005], oks[1000005];
int main() 
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    long int n,x,ans=0;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++)
    {
        cin>>x;
        cnt[x]++;
    }
    for (int i=1;i<=1000000;i++)
    {
        if (oks[i] == 0 && cnt[i] == 1) ans += cnt[i];
        if (cnt[i] > 0) for (int j = 2 * i; j <= 1000000; j += i) oks[j] = 1;
    }
    cout << ans;
	return 0;
}

Measured memory_bytes: 11376
AB = list(map(int, input().split()))
 
A = int(AB[0])
B = int(AB[1])
 
if A%2 == 0 and B%2 == 0:
    print(int((A+B)/2))
elif A%2 == 1 and B%2 == 1:
    print(int((A+B)/2))
else:
    print("IMPOSSIBLE")

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int dx[]={-1,1,0,0};
int dy[]={0,0,-1,1};
#define ull unsigned long long int
#define ll long long int
#define MAX 1000000007
//1e9+7
#define pll pair<ll,ll>
#define pii pair<int,int>
#define IO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define FO ifstream fin("a.in");ofstream fout("a.out");
#define TEST ll t;cin>>t;while(t--)
ll sizes[100001];
ll arr[100001];

bool ok=true;
ll A[100001];
pll B[100001];

ll root(ll i){
    while(i!=arr[i]) i=arr[i];
    return(i);
}
void Union(ll i,ll j){
    ll root_i=root(i),root_j=root(j);
    if(root_i==root_j) return;
    if(sizes[root_i]>sizes[root_j]) swap(root_i,root_j);
    sizes[root_j]+=sizes[root_i];
    arr[root_i]=arr[root_j];
    return;
}
bool prime[10000];
vector<ll> v;
void era(){
    memset(prime,true,sizeof prime);
    for(ll p=2;p*p<=10000;p++){
        if(prime[p]){

            for(ll q=p*p;q<=10000;q+=p){
                prime[q]=false;
            }
        }
    }

    return;
}

int main(){
    IO

    ll N,ans=0;
    char c;
    cin>>c;
    if(c=='A') cout<<'T';
    if(c=='T') cout<<'A';
    if(c=='C') cout<<'G';
    if(c=='G') cout<<'C';

    return(0);
}

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

string s[2005];
char ans[10005];
int len[2005];
bitset<10005> can[2005];
pair<int,int> rec[2][4005];

#define mp make_pair
#define fi first
#define se second

int main () {
        int n, k; cin >> n >> k;
        for (int i = 1; i <= n; ++i) cin >> s[i], len[i] = s[i].size();
        can[n+1][0] = 1;
        for (int i = n; i >= 1; --i) can[i] = can[i+1] | (can[i+1]<<len[i]);
        int cur = 0, nxt = cur ^ 1, cnt = 0;
        for (int i = 1; i <= n; ++i) if (can[i+1][k-len[i]]) rec[0][++cnt] = mp (i, 0);
        for (int i = 0; i < k; ++i) {
                char Min = 'z';
                for (int j = 1; j <= cnt; ++j) Min = min (Min, s[rec[cur][j].fi][rec[cur][j].se]);
                ans[i] = Min;
                int minID = 1e9, ccnt = 0;
                for (int j = 1; j <= cnt; ++j) {
                        int id = rec[cur][j].fi, pos = rec[cur][j].se;
                        if (s[id][pos] != Min) continue;
                        if (pos+1 == len[id]) minID = min(minID,id);
                        else rec[nxt][++ccnt] = mp (id,pos+1);
                }
                for (int j = minID+1; j <= n; ++j)
                        if (k-len[j]-i-1>=0 && can[j+1][k-len[j]-i-1])
                                rec[nxt][++ccnt] = mp (j,0);    
                cur ^= 1, nxt ^= 1;
                cnt = ccnt;
        }
        ans[k] = '\0';
        cout << ans << endl;
        return 0;
}

Measured memory_bytes: 4096
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <iterator>

using namespace std;

#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(v) reverse((v).begin(),(v).end())
#define ANS(ans) cout<<(ans)<<endl;
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
typedef vector<int> VI;

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

int main() {
	int n, h, w;
	cin >> n >> h >> w;

	int ans = 0;
	int a, b;
	REP(i, n) {
		cin >> a >> b;
		if (a >= h && b >= w) {
			ans++;
		}
	}

	ANS(ans);
	return 0;
}


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

int main(){
    int n;
    cin >> n;
    int R[n];
    for (int i = 0; i < n; i++)
    {
        cin >> R[i];
    }
    
    int minv = R[0];
    int maxv = -2*pow(10,9);
    for(int i =1;i<n;i++){
        maxv = max(maxv,R[i]-minv);
        minv = min(R[i],minv); 
    }
    cout << maxv << endl;
}


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

int main(){
  int N;
  cin >> N;
  vector<tuple<string,int,int>> Point(N);
  for(int i=0;i<N;i++){
    string s;
    int p;
    cin >> s >> p;
    Point[i]=make_tuple(s,100-p,i+1);
  }
  sort(Point.begin(),Point.end());
  for(int i=0;i<N;i++){
    cout << get<2>(Point[i]) << endl;
  }
}

Measured memory_bytes: 3548
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cerr << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cerr<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 500010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = (1 << 30) - 1;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
mt19937 rng; //use it by rng() % mod, shuffle(all(vec), rng)
///////////////////////////////////////////////////////////////////////////////////////////////////

int N;
string S, T;

void solve() {
	cin >> N;
	cin >> S;
	cin >> T;

	rep(i, 0, N) {
		bool found = false;
		rep(j, 0, N - i) {
			if(S[i + j] != T[j]) found = true;
		}
		if(!found) {
			cout << N + i << "\n";
			return;
		}
	}
	cout << 2 * N << "\n";
}

uint32_t rd() {
	uint32_t res;
#ifdef __MINGW32__
	asm volatile("rdrand %0" :"=a"(res) ::"cc");
#else
	res = std::random_device()();
#endif
	return res;
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
    cerr << fixed;
	cerr.precision(6);
	rng.seed(rd());
#ifdef LOCAL
	//freopen("in.txt", "wt", stdout); //for tester
	if(!freopen("in.txt", "rt", stdin)) return 1;
#endif	
	solve();
    cerr << "Time: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
	return 0;
}




Measured memory_bytes: 256
n, m = map(int, input().split())
a = list(map(int, input().split()))

from heapq import heappush, heappop

queue = []
for x in a:
    heappush(queue, -x)

for i in range(m):
    d = -heappop(queue)
    dd = d // 2
    heappush(queue, -dd)

print(int(-sum(queue)))

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

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

    vector<int> b(m);
    for (int i = 0; i < m; i++) cin >> b.at(i);

    int cnt = 0, a, sum;
    for (int i = 0; i < n; i++) {
        sum = 0;
        for (int j = 0; j < m; j++) {
            cin >> a;
            sum += a * b.at(j);
        }
        if (sum + c > 0) cnt++;
    }

    cout << cnt << endl;

    return 0;
}


Measured memory_bytes: 3600
/*
 ╔═══╦═══╦═══╗
 ║╔═╗║╔══╩╗╔╗║
 ║║░║║╚══╗║║║║
 ║║░║║╔══╝║║║║
 ║╚═╝║╚══╦╝╚╝║
 ╚══╗╠═══╩═══╝
 ░░░╚╝░░░░░░░░
 */

#include <bits/stdc++.h>
#define ll					long long
#define MOD					1000000007
#define MAX					1e9
#define MIN                 -1e9
#define PI					acos(-1.0)
#define vi					vector<int>
#define vii					vector<vi>
#define vll					vector<ll>
#define mid(s,e)			(s+(e-s)/2)
#define clz(n)				__builtin_clzll(n))

using namespace std;

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
template<typename T>
void printVec(const T &v, char sep=' ') {for (auto &i: v) cout << i << sep;}
template<typename T>
void printVecPair(const T &v, char sep=' ') {for (auto &i: v) cout << i.first <<" " << i.second<< sep;}


#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

int main() {
	ios::sync_with_stdio(false);
 	cin.tie(0);
	int n;
	cin>>n;
	vector<ll> m(n+1), h(n);
	for(int i=0;i<=n;i++) cin>>m[i];
	for(int i=0;i<n;i++) cin>>h[i];
	unsigned ll ans = 0;
	for(int i=0;i<n;i++) {
			ll l = min(m[i],h[i]);
			ans += l;
			h[i] -= l;
			ll r = min(m[i+1],h[i]); 
			ans += r;
			m[i+1] -= r;
	}
	cout<<ans;
	return 0;
}





Measured memory_bytes: 1792