akhauriyash/Code-Regression huggingface dataset:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
from collections import deque

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

DR = [1, -1, 0, 0]
DC = [0, 0, 1, -1]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
     
def main():
    A = []
    for _ in range(3):
        A.extend(LI())
    N = I()
    for _ in range(N):
        b = I()
        for i, a in enumerate(A):
            if a == b:
                A[i] = -1
    nums = set()
    for i, a in enumerate(A):
        if a == -1:
            nums.add(i)
    bingo = False
    if 0 in nums and 1 in nums and 2 in nums:
        bingo = True
    if 3 in nums and 4 in nums and 5 in nums:
        bingo = True
    if 6 in nums and 7 in nums and 8 in nums:
        bingo = True
    if 0 in nums and 3 in nums and 6 in nums:
        bingo = True
    if 1 in nums and 4 in nums and 7 in nums:
        bingo = True
    if 2 in nums and 5 in nums and 8 in nums:
        bingo = True
    if 0 in nums and 4 in nums and 8 in nums:
        bingo = True
    if 2 in nums and 4 in nums and 6 in nums:
        bingo = True
    if bingo:
        print("Yes")
    else:
        print("No")


main()



Measured memory_bytes: 7876
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

int readint() {
    return readln.chomp.to!int;
}

int[] readints() {
    return readln.split.map!(to!int).array;
}

void main() {
    int r = readint;
    int g = readint;

    // (r + p) / 2 = g
    int p = 2 * g - r;
    writeln(p);
}


Measured memory_bytes: 256
#include <cstddef>
#include <complex>
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <vector>
#include <array>
#include <list>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <numeric>
#include <limits>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <bitset>
#include <valarray>
#include <utility>
#include <tuple>
#include <cmath>
#include <memory>
#include <random>
#include <fstream>
#include <locale>

using ll = long long;
using ull = unsigned long long;

//vector
template <class T>
using vec = std::vector<T>;

template <class T>
using vvec = vec<vec<T>>;

constexpr std::size_t operator""_sz(ull n) { return std::size_t(n); }

int main()
{
    using namespace std;
	
	char c;
	cin >> c;

	char ans = ' ';

	switch (c)
	{
	case 'A':
		ans = 'T';
		break;
	case 'T':
		ans = 'A';
		break;
	case 'C':
		ans = 'G';
		break;
	case 'G':
		ans = 'C';
		break;
	default:
		break;
	}

	cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
n = int(input())
cards = [list(map(str, input().split())) for i in range(n)]

taro, hanako = 0, 0
for match in cards:
    if match[0] > match[1]:
        taro += 3
    elif match[0] < match[1]:
        hanako += 3
    else:
        taro += 1
        hanako += 1

print(taro, hanako)



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

using namespace std;

int v[4] = {10, 50, 100, 500};

int main()
{
    bool sep = false;
    int n;
    while(cin >> n, n)
    {
        if(sep) cout << endl;
        sep = true;
        int cs[4], sum = 0;
        for(int i=0; i<4; i++)
        {
            cin >> cs[i];
            sum += v[i] * cs[i];
        }
        int diff = sum - n;
        int st[4];
        fill(st, st+4, 0);
        for(int i=3; i>=0; i--)
        {
            st[i] = diff / v[i];
            diff %= v[i];
        }
        for(int i=0; i<4; i++)
        {
            if(cs[i]>st[i])
            {
                cout << v[i] << " " << cs[i]-st[i] << endl;
            }
        }
    }
}

Measured memory_bytes: 3056
#include <bits/stdc++.h>
using namespace std;
long long dp[1010][1010], h, w, mod = 1e9 + 7;
char arr[1010][1010];

long long fun(long long x, long long y)
{
    // cout << x << " " << y << endl;
    if (x < 0 || y < 0)
        return 0;
    if (x == 0 && y == 0)
        return 1;
    if (dp[x][y] != -1)
        return dp[x][y];
    int flag1 = 1, flag2 = 1;
    if (arr[x - 1][y] == '#')
        flag1 = 0;
    if (arr[x][y - 1] == '#')
        flag2 = 0;
    return dp[x][y] = (flag1 * (fun(x - 1, y) % mod) + flag2 * (fun(x, y - 1) % mod)) % mod;
}

int main()
{
    cin >> h >> w;
    long long ans, x, y;
    for (x = 0; x < h; x++)
        for (y = 0; y < w; y++)
            cin >> arr[x][y];
    memset(dp, -1, sizeof(dp));
    ans = fun(h - 1, w - 1);
    cout << ans << endl;
}

Measured memory_bytes: 9344
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(k,i,n) for(ll i=k;i<n;++i)
int main(void){
    // Your code here!
    ll l,r,ans=2019;
    cin>>l>>r;
    if(r-l>2019){
        cout<<0;
        return 0;
    }
    rep(l,i,r+1){
        rep(i+1,j,r+1)ans=min(ans,i*j%2019);
    }
    cout<<ans;
}


Measured memory_bytes: 256
from collections import deque

def main():
    H,W=map(int,input().split())
    S=[]
    for i in range(H):
        s=input()
        S.append(s)

    G=[]
    for i in range(H):
        for j in range(W):
            tmp=[]
            if S[i][j]=="#":
                G.append(tmp)
                continue
            if i-1>=0:
                if S[i-1][j]==".":
                    tmp.append((i-1)*W+j)
            if i+1<=H-1:
                if S[i+1][j]==".":
                    tmp.append((i+1)*W+j)
            if j-1>=0:
                if S[i][j-1]==".":
                    tmp.append(i*W+j-1)
            if j+1<=W-1:
                if S[i][j+1]==".":
                    tmp.append(i*W+j+1)
            G.append(tmp)

    res=0

    for start in range(H*W):
        dist = 0
        v = [-1 for _ in range(H * W)]
        que=deque([])
        que.append(start)
        v[start]=dist
        while len(que)>0:
            next_index=que.popleft()
            next=G[next_index]
            for i in next:
                if v[i]==-1:
                    que.append(i)
                    v[i]=v[next_index]+1

        if max(v)>=res:
            res=max(v)

    print(res)


if __name__=="__main__":
    main()






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

using namespace std; 
const int MAX_N = 305; 
double dp[MAX_N][MAX_N][MAX_N]; 
int n; 
int b1, b2, b3; 

int main () {
  //freopen("input.txt", "r", stdin);
  //freopen("output.txt", "w", stdout);
  cin >> n;
  for (int i = 1; i <= n; i++) {
    int x; 
    cin >> x; 
    if (x == 1) {
      b1++;
    }
    else if (x == 2) {
      b2++;
    }
    else {
      b3++; 
    }
  }
  dp[0][0][0] = 0.0; 
  for (int a3 = 0; a3 <= n; a3++) {
    for (int a2 = 0; a2 <= n; a2++) {
      for (int a1 = 0; a1 <= n; a1++) {
        if (a1 + a2 + a3 == 0) {
          continue; 
        }
        if (a1 + a2 + a3 > n) {
          continue; 
        }                         
        double omega = 1.0 * (a1 + a2 + a3); 
        double prob = 1.0 * n / omega;
        if (a1 > 0) {
          dp[a1][a2][a3] += 1.0 * a1 / omega * dp[a1 - 1][a2][a3]; 
        }
        if (a2 > 0) {
          dp[a1][a2][a3] += 1.0 * a2 / omega * dp[a1 + 1][a2 - 1][a3];
        }
        if (a3 > 0) {
          dp[a1][a2][a3] += 1.0 * a3 / omega * dp[a1][a2 + 1][a3 - 1]; 
        }
        dp[a1][a2][a3] += prob;
      }
    }
  }
  cout << fixed << setprecision(12) << dp[b1][b2][b3]; 
  return 0; 
}

Measured memory_bytes: 219392
import java.util.Scanner;

public class Main{
  public static void main(String[] args){
    
    Scanner scanner = new Scanner(System.in);
      
    int A = scanner.nextInt();
    int B = scanner.nextInt();
    int C = scanner.nextInt();
    
    int sum = A + B + C;
    
    if(sum >= 22){
      System.out.println("bust");
    }else{
      System.out.println("win");
    }
  
  }
  
}

    
    


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

int main() {
  int N,M;
  cin >> N>>M;
  double C=0;
  int ans=0;
  vector<int>A(N);
  for(int i=0;i<N;i++){
    cin>>A[i];
    C+=A[i];
  }
  double all=C/(4*M);
  sort(A.begin(), A.end());
  reverse(A.begin(), A.end());
  for(int i=0;i<N;i++){
    if(A[i]>=all){
      ans++;
    }
  }
  if(ans>=M){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
using ll = long long;
int main(void){
   int N,M,X,Y;
   cin>>N>>M>>X>>Y;
   int x,y;
   bool war=true;
   int Mx=-200,My=200;
   rep(i,N){
       cin>>x;
       Mx=max(Mx,x);
   }
   rep(i,M){
       cin>>y;
       My=min(My,y);
   }
   rep(i,Y-X){
       if(X+i+1>Mx&&X+i+1<=My){
           war=false;
       }
       }
   if(war==true){
       cout<<"War"<<endl;
   }
   else{
       cout<<"No War"<<endl;
   }
   
}

Measured memory_bytes: 3640
#include <time.h>

#include <stdlib.h>
#include <cstdint>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <limits>
#include <cstdint>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <limits>
#include <vector>
#include <map>
#include <set>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <bitset>

using namespace std;
const int64_t INF=10000000000000000;

int main(){
	int64_t n,a,b;
	cin>>n>>a>>b;
	if(n==1){
		if(a==b){
			cout<<1<<endl;
		}else{
			cout<<0<<endl;
		}
	}else{
		int64_t max_num=(n-1)*b+a;
		int64_t min_num=(n-1)*a+b;
		cout<<max((int64_t)0,(max_num-min_num+1))<<endl;
	}
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Scanner;

class Main {

	public static void main(String[] args) throws IOException {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		Scanner scan = new Scanner(System.in);

		String str1 =scan.nextLine();

		String str2;

		int count =0;

		while (true) {

				str2 = scan.nextLine();

				/*System.out.print(str2);*/
				if (str2.equals("END_OF_TEXT")) {
					break;
				}
				Scanner sb = new Scanner(str2);
					while(sb.hasNext()){


/*					System.out.println(sb.next());
*/					if(sb.next().equalsIgnoreCase(str1)){
						count++;

					}
					}
		}

		System.out.println(count);
 }

}

Measured memory_bytes: 26148
#pragma GCC optimize(3, "Ofast", "inline")
#include <bits/stdc++.h>
#if __cplusplus >= 201103L
#include <chrono>
using namespace std::chrono;
#endif
using namespace std;
#define ll long long
#define ull unsigned long long
#define pii pair<int, int>
#define pb push_back
#define fi first
#define se second
#ifdef LOCAL
#define prln(x) (cout << #x << ' ' << x << endl)
#define pr(x) (cout << #x << ' ' << x << ' ' )
#define prv(x) (cout << x << ' ')
#else
#define prln(x) 
#define pr(x)
#define prv(x)
#endif
#define clr(x) memset((x), 0, sizeof((x)))
#define clr1(x) memset((x), -1, sizeof((x)))
#define endl "\n"
#define pi acos(-1)
#define rep(i, st, ed) for (int i = (st); i <= (ed); ++i)
#define rep0(i, st, ed) for (int i = (st); i < (ed); ++i)
#define per0(i, st, ed) for (int i = (st); i > ed; --i)
#define per(i, st, ed) for (int i = (st); i >= ed; --i)
#define chmin(a, b) (a = a > b ? b : a)
#define chmax(a, b) (a = a < b ? b : a)
template<class T> void _sf(T &x) {cin >> x;}
void _sf(int &x) {scanf("%d", &x);}
void _sf(ll &x) {scanf("%lld", &x);}
void _sf(double &x) {scanf("%lf", &x);}
void _sf(char &x) {scanf(" %c", &x);}
void _sf(char *x) {scanf("%s", x);}
void sf() {}
template <class T, class...U> void sf(T & head, U&... tail) { _sf(head); sf(tail...);}
template<class T> void _out(const T &x) { cout << x; }
void _out(const int &x) { printf("%d", x); }
void _out(const ll &x) { printf("%lld", x); }
void _out(const double &x) { printf("%.16f", x); }
void _out(const char &x) { putchar(x); }
void _out(const char *x) { printf("%s", x); }
template<class T,class U> void _out(const pair<T,U> &x) {_out(x.F); putchar(' '); _out(x.S);}
template<class T> void _out(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _out(*i++)) if (i != x.cbegin()) putchar(' '); }
void out() {}
template<class T, class... U> void out(const T &head, const U &... tail) { _out(head); putchar(sizeof...(tail) ? ' ' : '\n'); out(tail...); }
const int mod = 1e9 + 7;
const int INF = 0x3f3f3f3f;

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


int main(){
    #ifdef LOCAL
        freopen("in.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
    #endif
    int a, b;
    sf(a, b);
    if (a > b) swap(a, b);
    if (a == 1 && b == 2) out(3);
    else if (a == 2 && b == 3) out(1);
    else out(2);
    return 0;
}

Measured memory_bytes: 256
n = int(input())
grid = [[0 for i in range(9)] for j in range(9)]
ans = 0

for i in range(1, n+1):
    s = str(i)
    if int(s[0]) == 0 or int(s[-1]) == 0:
        continue
    grid[int(s[0])-1][int(s[-1])-1] += 1

for i in range(9):
    for j in range(i, 9):
        if i == j:
            ans += grid[i][j] * grid[j][i]
        else:
            ans += (grid[i][j] * grid[j][i])*2

print(ans)

Measured memory_bytes: 3064
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <unordered_map>
#include <vector>


#define INF 4000000000000000000LL
#define MOD 1000000007
#define ALL(x) std::begin(x), std::end(x)


int main(int argc, char** argv)
{
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(0);

  std::cout << std::fixed << std::setprecision(6);
  std::cerr << std::fixed << std::setprecision(6);

  long long H, W, A;

  std::cin >> H >> W;

  if (H == 1 || W == 1) {
    std::cout << 1 << std::endl;
  }
  else {
    long long c1 = (W + 1) / 2, c2 = W / 2;
    long long d1 = (H + 1) / 2, d2 = H / 2;

    std::cout << c1 * d1 + c2 * d2 << std::endl;
    }
  
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
static const int N = 105;
int main()
{
	int a[N];
	int n,v,j,k;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
	}
	for(int i=0;i<n;i++)
	{
		if(i<n-1)
		cout<<a[i]<<' ';
		else
		cout<<a[i]<<endl;
		
	}
	for(int i=1;i<n;i++)
	{
		v=a[i];
		j=i-1;
		while(j>=0&&a[j]>v)
		{
			a[j+1]=a[j];
			j--;
		}
		a[j+1]=v;
		for( j=0;j<n-1;j++)
		{
			cout<<a[j]<<' ';
		}
		cout<<a[j]<<endl;
		/*if(i<n-1)
		{
			cout<<a[j]<<endl;
		}
		else 
		cout<<a[j];*/
	}
	
}


Measured memory_bytes: 3120
#include<stdio.h>
#include<math.h>
#define N 10000
#define M 100000000

int isprime(int );
int main()
{

  int A[N];
  int n,status=0,l,y[N];
  
  scanf("%d",&l);
  for(n=0;n<l;n++) scanf("%d",&A[n]);

  for(n=0;n<l;n++)y[n] = isprime(A[n]);

  for(n = 0; n <l; n++){
    if(y[n]== 1) status++;
  }

  printf("%d\n",status);

  return 0;

}

int isprime(int k)
{
  int i =3;

  if(k==2) return 1;
  
  else if(k%2==0) return 0;
  while(i <=sqrt(k)){
      if(k%i==0) return 0;
      i+=2;
    }
    
      return 1;

}



Measured memory_bytes: 2044
import sys
# 再帰上限を引き上げる
sys.setrecursionlimit(10**6)

####
# DFS(深さ優先探索

count = 0
def dfs(graph, v, seen):
    #print(seen)
    # Falseがない、つまり頂点が1個しかない場合は、1を返す
    if not False in seen:
        global count
        count += 1
        return
    
    # 頂点Vから行ける頂点を全探索
    for i in graph[v]:
        # 行ける場所はTrueである。
        if seen[i]:
            continue
        
        # いったんTrueにして
        seen[i] = True
        # 探索したら
        dfs(graph, i, seen)
        # 戻す
        seen[i] = False
        
    return
        
        

####

N, M = map(int, input().split())

# グラフを作る
graph = [[] for i in range(N)]
#print(graph)

for i in range(M):
    a, b = map(int, input().split())
    # index番号にあわせたいので、1引く
    a -= 1
    b -= 1
    graph[a].append(b)
    graph[b].append(a)
    
seen = [False for i in range(N)]
seen[0] = True
dfs(graph, 0, seen)

# 全探索できた数を表示
print(count)

Measured memory_bytes: 3064
#include <stdio.h>
typedef long long ll;

ll n;
ll a[100005];
ll b[100005];


int main()
{
	ll ans = 0;

	scanf("%lld", &n);
	for (ll i = 0; i < n; i++) {
		scanf("%lld %lld", &a[i], &b[i]);
	}
	
	for (ll i = n - 1; i >= 0; i--) {
		a[i] = a[i] + ans;

		if (a[i] % b[i]) {
			ans = ans + (b[i] - a[i] % b[i]);
		}
	}

	printf("%lld\n", ans);
}


Measured memory_bytes: 1792
//! ----------------------------------------------
//! Framework <https://github.com/vain0x/procon>
//!
//! See the bottom of file for solution.
//! ----------------------------------------------

#![allow(unused_imports)]
#![allow(non_snake_case)]

use std::cell::RefCell;
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::fmt::{Debug, Display, Formatter, Write as FmtWrite};
use std::io::{stderr, stdin, BufRead, Write};
use std::mem::{replace, swap};
use std::ops::*;
use std::rc::Rc;

/// Print values to standard error if debug mode.
#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), stderr());
            writeln!(err, "\x1B[33m{}\x1B[0m = {:?}", e, $e).unwrap()
        })*
    };
}

/// Read from standard input and parse each word.
/// - `read!(T, U, ..)` parses a line as a tuple of words.
/// - `read![[T]]` parses a line as an array of words.
/// - `read![..; N]` parses `N` lines, using `read!(..)` repeatedly.
#[allow(unused_macros)]
macro_rules! read {
    ([$t:ty] ; $n:expr) =>
        ((0..$n).map(|_| read!([$t])).collect::<Vec<_>>());
    ($($t:ty),+ ; $n:expr) =>
        ((0..$n).map(|_| read!($($t),+)).collect::<Vec<_>>());
    ([$t:ty]) =>
        (rl().split_whitespace().map(|w| w.parse().unwrap()).collect::<Vec<$t>>());
    ($($t:ty),*) => {{
        let buf = rl();
        let mut w = buf.split_whitespace();
        ($(w.next().unwrap().parse::<$t>().unwrap()),*)
    }};
}

/// Read a line from standard input.
#[allow(dead_code)]
fn rl() -> String {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();

    #[allow(deprecated)]
    buf.trim_right().to_owned()
}

// -----------------------------------------------
// Solution
// -----------------------------------------------

fn is_asc(A: &[usize]) -> bool {
    A.windows(2).all(|w| w[0] < w[1])
}

fn main() {
    let N = read!(usize);
    let mut P = read![[usize]];

    let mut ok = is_asc(&P);
    for i in 0..N {
        for j in i + 1..N {
            P.swap(i, j);
            ok = ok || is_asc(&P);
            P.swap(i, j);
        }
    }

    println!("{}", if ok { "YES" } else { "NO" })
}


Measured memory_bytes: 4352
def draw(h,w):
	t = "#." * (w/2)
	if w%2 == 0:
		s = t
		k = t.strip("#") + "#"
	else:
		s = t + "#"
		k = "." + t

	for i in range(0,h/2):
		print s
		print k
	if h%2==1:
		print s
	print

if __name__ == "__main__":
	while True:
		h,w = map(int, raw_input().split())
		if h==0 and w==0:
			break
		else:
			draw(h,w)

Measured memory_bytes: 6304
#include "stdio.h"

int main(void)
{
	int a,b,c,t;
	scanf("%d%d%d",&a,&b,&c);
	if(a>b)
	{
		t=a;
		a=b;
		b=t;
	}
	if(b>c)
	{
		t=b;
		b=c;
		c=t;
	}
	if(a>b)
	{
		t=a;
		a=b;
		b=t;
	}
	printf("%d %d %d\n",a,b,c);
	return 0;
}

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

int main() {
  int A, B, C, X;
  cin >> A >> B >> C >> X;
  int res = 0;
  for (int a = 0; a <= A; ++a) {
    for (int b = 0; b <= B; ++b) {
      for (int c = 0; c <= C; ++c) {
        int total = 500*a + 100*b + 50*c;
        if (total == X) ++res;
      }
    }
  }
  cout << res << endl;
}


Measured memory_bytes: 256
import java.awt.*;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.*;

public class Main {

    static String br = System.getProperty("line.separator");
    static Scanner sc = new Scanner(System.in);
    static PrintWriter out = new PrintWriter(System.out);

    public static void main(String[] args) {
        int H = nextInt();
        int W = nextInt();

        char[][] c = new char[H][W];
        int sum = 0;
        for(int i=0; i<H; i++){
            char[] list = next().toCharArray();
            for(int j=0; j<W; j++){
                c[i][j] = list[j];
                if(list[j] == '.') sum++;
            }
        }

        Deque<Point> deque = new ArrayDeque<>();
        deque.add(new Point(0, 0));

        Point goal = new Point(W-1, H-1);
        int count = 0;

        boolean reached = false;
        int[] dx = {-1, 0, 0, 1}, dy = {0, -1, 1, 0};
        outer:for(;!deque.isEmpty(); count++){
            for(int i=deque.size(); i>0; i--){
                Point poll = deque.poll();
                if(poll.equals(goal)){
                    reached = true;
                    break outer;
                }
                c[poll.y][poll.x] = '#';
                for(int j=0; j<4; j++){
                    int x = poll.x + dx[j];
                    int y = poll.y + dy[j];
                    if(x < 0 || x >= W || y < 0 || y >= H) continue;
                    if(c[y][x] == '.'){
                        c[y][x] = '#';
                        deque.add(new Point(x, y));
                    }
                }
            }
        }
        println(!reached ? -1 : sum-count-1);
    }

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

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

    static String next() {
        return sc.next();
    }

    static String nextLine(){
        return sc.nextLine();
    }

    static void println(Object o) {
        out.println(o);
        out.flush();
    }

    static void print(Object o) {
        PrintWriter out = new PrintWriter(System.out);
        out.print(o);
        out.flush();
    }
}


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

const int Mod = 998244353;
const int Max_N = 500005;

int fexp(int base, int exp) {
	int ret = 1;
	while (exp) {
		if (exp & 1)
			ret = 1LL * ret * base % Mod;
		base = 1LL * base * base % Mod;
		exp >>= 1;
	}
	return ret;
}

inline int get_inv(int x) {
	return fexp(x, Mod - 2);
}

int N, M, Ans;
int pwN[Max_N], pwM[Max_N], fac[Max_N], inv[Max_N];

inline int binom(int x, int y) {
	return 1LL * fac[x] * inv[y] % Mod * inv[x - y] % Mod;
}

int main() {
	scanf("%d%d", &N, &M);
	pwN[0] = pwM[0] = 1;
	for (int i = 1; i < Max_N; i++) {
		pwN[i] = 1LL * pwN[i - 1] * (N + 1) % Mod;
		pwM[i] = 1LL * pwM[i - 1] * (M + 1) % Mod;
	}
	fac[0] = 1;
	for (int i = 1; i < Max_N; i++)
		fac[i] = 1LL * fac[i - 1] * i % Mod;
	inv[Max_N - 1] = get_inv(fac[Max_N - 1]);
	for (int i = Max_N - 2; i >= 0; i--)
		inv[i] = 1LL * inv[i + 1] * (i + 1) % Mod;
	
	for (int d = 1, i = 0; i <= min(N, M); i++, d *= -1) {
		Ans = (Ans + 1LL * d * (1LL * binom(N, i) * binom(M, i) % Mod * fac[i] % Mod) * (1LL * pwM[N - i] * pwN[M - i] % Mod) % Mod) % Mod;
	}
	if (Ans < 0)
		Ans = (Ans + Mod) % Mod;
	printf("%d\n", Ans);
	
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef long double ld;

const int MOD = (int) 1e9 + 7;

int add(int a, int b)
{
    a += b;
    if (a >= MOD)
    {
        return a - MOD;
    }
    if (a < 0)
    {
        return a + MOD;
    }
    return a;
}

int mul(int a, int b)
{
    return a * (ll) b % MOD;
}

int pw(int a, int b)
{
    int r = 1;
    while (b)
    {
        if (b & 1)
        {
            r = mul(r, a);
        }
        a = mul(a, a);
        b /= 2;
    }
    return r;
}

const int N = (int) 3e6 + 7;
int fact[N];

int comb(int n, int k)
{
    int x = fact[n];
    int y = mul(fact[k], fact[n - k]);
    return mul(x, pw(y, MOD - 2));
}

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

    fact[0] = 1;
    for (int i = 1; i < N; i++)
    {
        fact[i] = mul(fact[i - 1], i);
    }
    int x, y;
    cin >> x >> y;
    int t = x + y;
    if (t % 3)
    {
        cout << "0\n";
        return 0;
    }
    t /= 3;
    x -= t;
    y -= t;
    if (x < 0 || y < 0)
    {
        cout << "0\n";
        return 0;
    }
    cout << comb(x + y, y) << "\n";
}


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

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

int arr[n];
ll sum=0;
for(int i=0;i<n;i++){
  cin>>arr[i];
  sum+=arr[i];
}
ll x=4*m;

ll  y=sum/x;
int cnt=0;
for(int i=0;i<n;i++){
     if(sum<=arr[i]*4*m){
         cnt++;
     }
}

 if(cnt<m){
     cout<<"No"<<endl;
 }
 else cout<<"Yes"<<endl;

return 0;
}


Measured memory_bytes: 256
n, m  = map(int, input().split())
import numpy as np
import heapq
import math
a = [-1*int(i) for i in input().split()]
heapq.heapify(a)

if n > 1:
  for i in range(m):
    x = heapq.heappop(a)
    heapq.heappush(a,math.ceil(x/2))
  a = np.array(a)
  print(-1*a.sum())
else:
  print(-1*a[0]//(2**m))

Measured memory_bytes: 23160
using System;
using System.IO;
using System.Collections;
using System.Collections.Generic;
using System.Linq;

class  CompetitiveProgrammingProgram
{
    static void Main(string[] args)
    {
        int n = int.Parse(Console.ReadLine());
        string s=Console.ReadLine();
        char[] c=s.ToCharArray();
        for(int i=0;i< s.Length;i++){
            c[i]=(char)(((int)(c[i]-'A')+n)%26+(int)('A'));
        }
        s=new string(c);
        Console.WriteLine(s);
    }
}

Measured memory_bytes: 11152
import math
A,B,H,M = map(int,input().split())

theta_A = (H*60+M)*2*math.pi/(12*60)
theta_B = M*2*math.pi/60

theta = abs(theta_A - theta_B)
if theta > math.pi:
    theta = 2*math.pi - theta

length = math.sqrt(A**2+B**2-2*A*B*math.cos(theta))
print(length)


Measured memory_bytes: 9500
#include<iostream>
using namespace std;
int main()
{
 while(true){

      int n;

     
	  cin >> n ;
	  
      if(n==0)
         break;

	  double a, h , w;
      double BMI = 0;
      double H = 0;
      double max = 0;
	  double z ;
      int y=0;

      for(int i=0 ;i<n ;i++){
		     
            cin >> a >> h >> w;
            H = h / 100;
		
            BMI = w / H / H;

	
			z = 22 - BMI; 
            if(z < 0){
                z = z * (-1);
            }
		
			if(i == 0){
				max = z;
				y = a;
			}
			
			else if(max > z){
               
                 max = z;
				  y = a;
			}
	  }

			cout << y << endl;

 }
    
 return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <string>
using namespace std;
 
int main()
{
  string s;
  cin>>s;
  int ans=0;
  int i=0;
  while(i<s.size())
  {
    if(i%2==0)
    {
      if(s[i]!='h')
      {
        ans=1;
      }
    }
    if(i%2==1)
    {
      if(s[i]!='i')
      {
        ans=1;
      }
    }
    i++;
  }
  if(i%2==1)
  {
    ans=1;
  }
  if(ans==0)
  {
    cout<<"Yes"<<endl;
  }
  else
  {
    cout<<"No"<<endl;
  }
	return 0;
}

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

r = S.count('R')
w = len(S)-r

if r == 0 or w == 0:
    print(0)
    exit()

ans = 0
for i in range(len(S)):
    if S[i] == "R":
        r -= 1
    else:
        r -= 1
        w -= 1
        ans += 1
    if r == 0 or w == 0:
        break
print(ans+r)

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

#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = (n)-1; i >= 0; i--)
#define rep1(i,n) for(int i = 1; i <= (n); i++)
#define rrep1(i,n) for(int i = (n); i > 0; i--)

#define ll long long
#define pi pair<int, int>
#define pll pair<ll, ll>

#define MOD 1000000007
#define INF 1000000000000000LL

using namespace std;

int main(){
  int m,k;cin>>m>>k;
  if(k>=pow(2, m) || k==1&m==1){ cout<<-1<<endl; return 0; }

  if(k==0){
    rep(i, pow(2,m))cout<<i<<' '<<i<<' ';
    return 0;
  }

  rep(i, pow(2, m))if(i!=k)cout<<i<<' ';
  cout<<k<<' ';
  rrep(i, pow(2, m))if(i!=k)cout<<i<<' ';
  cout<<k<<' ';
  cout<<endl;

//  int t = 0;rep1(i, 120){t^=i; cout<<i<<' '<<t<<endl;}

  return 0;
}

Measured memory_bytes: 4036
from math import * 
from collections import *

N, D, A = list(map(int, input().split()))
ans = 0
t = 0
q = deque()

XH = sorted([list(map(int, input().split())) for i in range(N)])

for x, h in XH:
    if q:
        while q and q[0][0] < (x-D):
            _, c = q.popleft()
            t -= c
    
    h = h - t * A
    if h <= 0: continue
    
    x += D
    c = ceil(h/A)
    t += c
    ans += c
    q.append((x, c))
    
print(ans)

Measured memory_bytes: 65616
def main():
    from collections import Counter
    import sys

    input()
    a = list(map(int, sys.stdin.readline().split()))

    d = Counter(a)

    base = sum(v * (v - 1) // 2 for v in d.values())
    e = [str(base - (d[v] - 1)) for v in a]
    print('\n'.join(e))


if __name__ == '__main__':
    main()


Measured memory_bytes: 34152
w = int(input())
n = int(input())
lst = [i + 1 for i in range(w)]
def swap(t):
  a,b = t
  temp = lst[a-1]
  lst[a-1] = lst[b-1]
  lst[b-1] = temp
for i in range(n):
  swap(tuple(map(int,input().split(","))))
for i in range(w):
  print(lst[i])


Measured memory_bytes: 5608
using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.AccessControl;
using System.Security.Cryptography;
using System.Text;
using System.Threading.Tasks;

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = ReadLineInt();
            var s = ReadLine();

            var re = "";
            var alpha = GetAlphaUpperArray().ToList();

            for (int i = 0; i < s.Length; i++) {

                var index = (alpha.IndexOf(s[i].ToString()) + n) % 26;
                re += alpha[index];
            }

            Console.WriteLine(re);
            ReadLine();
        }

        //メモ

        //配列
            //降順
            //var sort = array.OrderBy(x => -x).ToArray();

            //合計値
            //array.Sum();

        //kのn乗
        //(int) Math.Pow(k, n);

        //for文の逆
        //for(int i = array.Length - 1; i >= 0; i--) { }


        //最大公約数
        static int gcd(int a, int b)
        {
            if (a > b) {
                return gcd(b, a);
            }

            while (b != 0) {
                var remainder = a % b;
                a = b;
                b = remainder;
            }

            return a;
        }

        //最小公倍数
        static int lcm(int a, int b) => a * b / gcd(a, b);

        /// <summary>
        /// コンビネーション
        /// </summary>
        static int nCm(int n, int m)
        {
            if (m == 0) return 1;
            if (n == 0) return 0;
            return n * nCm(n - 1, m - 1) / m;
        }

        public static string ReadLine() => Console.ReadLine();
        public static int ReadLineInt() => int.Parse(Console.ReadLine());
        public static long ReadLineLongInt() => long.Parse(Console.ReadLine());
        public static string[] ReadLineStringSplit(char a = ' ') => ReadLine().Split(a).ToArray();
        public static int[] ReadLineIntSpilit(char a = ' ') => ReadLine().Split(a).Select(x => int.Parse(x)).ToArray();
        public static long[] ReadLineLongSpilit(char a = ' ') => ReadLine().Split(a).Select(x => long.Parse(x)).ToArray();
        static string[] GetAlphaLowerArray() => new string[] { "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z" };
        static string[] GetAlphaUpperArray() => new string[] { "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z" };
    }
}


Measured memory_bytes: 37076
#include "bits/stdc++.h" 
using namespace std; 
  
  typedef long long ll;
#define MAXN   1000001 
int spf[MAXN]; 

void sieve() 
{ 
    spf[1] = 1; 
    for (int i=2; i<MAXN; i++) 
  
        
        spf[i] = i; 
  
    for (int i=4; i<MAXN; i+=2) 
        spf[i] = 2; 
  
    for (int i=3; i*i<MAXN; i++) 
    { 
        if (spf[i] == i) 
        { 
            for (int j=i*i; j<MAXN; j+=i) 
                if (spf[j]==j) 
                    spf[j] = i; 
        } 
    } 
} 
  vector<ll> ret; 
void getFactorization(ll x) 
{ 
    
    while (x != 1) 
    { 
        ret.push_back(spf[x]); 
        x = x / spf[x]; 
    } 
    
} 
int gcd(int a, int b) 
{ 
    if (b == 0) 
        return a; 
    return gcd(b, a % b); 
} 
  
// Returns LCM of array elements 
ll findlcm(int arr[], int n) 
{ 
    // Initialize result 
    ll ans = arr[0]; 
  
    // ans contains LCM of arr[0], ..arr[i] 
    // after i'th iteration, 
    for (int i = 1; i < n; i++) 
        ans = (((arr[i] * ans)) / 
                (gcd(arr[i], ans))); 
  
    return ans; 
} 

int main() 
{ 
    ll x,y,z;
  cin>>x>>y>>z;
  cout<<z<<" "<<x<<" "<<y;
    return 0; 
} 

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

bool is_uruu(int y){
	if(y % 400 == 0){
		return true;
	}else if(y % 100 == 0){
		return false;
	}else if(y % 4 == 0){
		return true;
	}
	return false;
}

int main(){
	int a, b;
	int n = 0;
	while(cin >> a >> b){
		if(a == 0 && b == 0) break;
		if(n != 0) cout << endl;
		else n++;
		int uru[1000];
		int count = 0;
		for(int i = a; i <= b; i++){
			if(is_uruu(i)){
				uru[count++] = i;
			}
		}
		if(count == 0){
			cout << "NA" << endl;
		} else {
			for(int j = 0; j < count; j++)
				cout << uru[j] << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 0
<?php
# C - Green Bin

fscanf(STDIN, "%d", $N);
$array = [];
for ($i=0;$i<$N;$i++) {
    $str = str_split(trim(fgets(STDIN)));
    sort($str, SORT_STRING);
    $array[] = implode($str);
}
$array_count = array_count_values($array);
$count = 0;
foreach ($array_count as $value) {
    if ($value > 1) {
        $count += intdiv($value * ($value - 1), 2);
    }
}

echo $count . PHP_EOL;


Measured memory_bytes: 19188
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) begin(v),end(v)
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
using ll = long long;
using pii = pair<int, int>;
constexpr ll INF = 1ll<<30;
constexpr ll longINF = 1ll<<60;
constexpr ll MOD = 1000000007;
constexpr bool debug = 0;
//---------------------------------//

int main() {
	int H, W, K;
	cin >> H >> W >> K;
	int stx, sty, edx, edy;
	cin >> sty >> stx >> edy >> edx;
	--sty; --stx; --edy; --edx;
	vector<string> maps(H);
	REP(i, H) cin >> maps[i];
	
	vector<vector<int>> d[4], kmax[4], done[4]; // 直前の移動方向
	REP(i, 4) {
		d[i] = vector<vector<int>>(H, vector<int>(W, INF));
		kmax[i] = vector<vector<int>>(H, vector<int>(W, 0));
		done[i] = vector<vector<int>>(H, vector<int>(W, 0));
	}
	
	struct Data {
		int y, x, pdir, res;
	};
	
	int dx[] = {1,0,-1,0}, dy[] = {0,-1,0,1};
	
	deque<Data> deq;
	REP(dir, 4) {
		d[dir][sty][stx] = 0;
		deq.emplace_back(Data{sty, stx, dir, 0});
	}
	
	auto ok = [&](int y, int x) {
		return y >= 0 && y < H && x >= 0 && x < W && maps[y][x] == '.';
	};
	
	while (!deq.empty()) {
		Data cur = deq.front(); deq.pop_front();
		if (!chmax(done[cur.pdir][cur.y][cur.x], 1)) continue;
		chmax(cur.res, kmax[cur.pdir][cur.y][cur.x]);
		
		REP(dir, 4) {
			int ny = cur.y + dy[dir], nx = cur.x + dx[dir];
			if (!ok(ny, nx)) continue;
			
			int &to = d[dir][ny][nx], &from = d[cur.pdir][cur.y][cur.x];
			
			if (dir != cur.pdir || cur.res == 0) {
				// コストが発生
				if (chmin(to, from + 1)) deq.emplace_back(Data{ny, nx, dir, K - 1});
			}
			else {
				if (to >= from) {
					if (chmin(to, from)) deq.emplace_front(Data{ny, nx, dir, cur.res - 1});
					chmax(kmax[dir][ny][nx], cur.res - 1);
				}
			}
		}
	}
	
	int ans = INF;
	REP(dir, 4) chmin(ans, d[dir][edy][edx]);
	if (ans == INF) puts("-1");
	else cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 55736
using System;
using System.Collections.Generic;
using System.Linq;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            //[summary]C - Big Array
            var line = ReadLine();
            int n = (int)line[0];
            long k = line[1];

            var a = new int[n];
            var b = new long[n];

            for (int i = 0; i < n; i++)
            {
                line = ReadLine();
                a[i] = (int)line[0];
                b[i] = line[1];
            }

            Array.Sort(a, b);

            long sum = 0;

            for (int i = 0; i < n; i++)
            {
                if (sum + b[i] < k)
                {
                    sum += b[i];
                }
                else
                {
                    Console.WriteLine(a[i]);
                    break;
                }
            }
        }

        static List<long> ReadLine()
        {
            var line = Console.ReadLine();
            var array = line.Split(' ');

            return array.Select(x => long.Parse(x)).ToList();
        }
    }
}


Measured memory_bytes: 17540
#include <stdio.h>
#include <stdlib.h>
#define MAX 200000

int main(){
    char *s = (char*)calloc(sizeof(char), MAX+3);
    char *t = (char*)calloc(sizeof(char), MAX+3);
    int i=0,count =0;
    fgets(s, MAX+2, stdin);
    fgets(t, MAX+2, stdin);
    while(s[i]!='\n' && i < MAX){
        if(s[i] != t[i]){
            count++;
        }
        i++;
    }
    printf("%d\n",count);
    return 0;
}


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

using ll = long long;

using namespace std;

using P = pair<int, int>;
#define fi first
#define se second

vector<P> G[51]; // 行先, id
bool visited[51] = {0};
int edges[51] = {0};

bool dfs(int i, int to, int id) {
    visited[i] = true;
    if (i == to) 
        return true;
    for (auto &g:G[i]) {
        if (visited[g.fi]) continue;
        int d = dfs(g.fi, to, id);
        if (d) {
            edges[g.se] |= (1 << id); // 辺g.seによって条件idが成立する
            return true;
        }
    }
    return false;
}

ll dp[51][(1 << 20) + 1];

int main() {
    int n, m;
    cin >> n;
    for (int i=0, ai, bi; i<n-1; i++) {
        cin >> ai >> bi;
        ai--; bi--;
        G[ai].push_back({bi, i});
        G[bi].push_back({ai, i});
    }
    cin >> m;
    for (int i=0, ui, vi; i<m; i++) {
        cin >> ui >> vi;
        ui--; vi--;
        fill(visited, visited+n, false);
        dfs(ui, vi, i);
    }
    fill(dp[0], dp[n], 0);
    dp[0][0] = 1;
    for (int i=0; i<n-1; i++) {
        for (int j=0; j<(1<<m); j++)
            dp[i+1][j] = dp[i][j];
        for (int j=0; j<(1 << m); j++) {
            dp[i+1][j | edges[i]] += dp[i][j];
        }
    }
    cout << dp[n-1][(1 << m) - 1] << '\n';
    return 0;
}

Measured memory_bytes: 411904
#include<bits/stdc++.h>
using namespace std;
#define ll long long
typedef pair<ll,ll>P;
vector<P>vec;

int main(){
  int n;
  ll a[200009],b[200009];
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>a[i]>>b[i];
    vec.push_back(P(b[i],i));
  }
  sort(vec.begin(),vec.end());

  ll now=0;
  for(int i=0;i<n;i++){
    ll idx=vec[i].second;
    now+=a[idx];
    if(now>b[idx]){
      cout<<"No"<<endl;
      return(0);
    }
  }

  cout<<"Yes"<<endl;
  return(0);
}


Measured memory_bytes: 8816
#include<iostream>
#include<vector>

using namespace std;

int main() {

	int table[3][10][4];

	for (int i = 0; i < 3; i++) {
		for (int j = 0; j < 10; j++) {
			for (int k = 0; k < 4; k++) {

				table[i][j][k] = 0;
			}
		}
	}

	int n;

	cin >> n;

	int b, f, r, v;

	for (int m = 0; m < n; m++) {
		cin >> b >> f >> r >> v;

		table[f-1][r-1][b-1] += v;

	}
	
	for (int k = 0; k < 3; k++) {
		for (int i = 0; i < 3; i++) {
			for (int j = 0; j < 10; j++) {
				cout <<" "<< table[i][j][k];
			}
			cout << endl;
			}

		cout << "####################" << endl;
		}

	for (int i = 0; i < 3; i++) {
		for (int j = 0; j < 10; j++) {
			cout << " " << table[i][j][3] ;
		}
		cout << endl;
	}

	return 0;
}

Measured memory_bytes: 3088
from itertools import combinations

N = int(input())
v_list = list(map(int, input().split()))
c_list = list(map(int, input().split()))

max_diff = -10000000
for n_selection in range(0, N+1):
    v_selected = list(combinations(v_list, n_selection))
    c_selected = list(combinations(c_list, n_selection))
    if n_selection == 0:
        max_diff = max(max_diff, 0)
    for i in range(len(v_selected)):
        X = sum(v_selected[i])
        Y = sum(c_selected[i])
        max_diff = max(max_diff, X - Y)

print(max_diff)

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

//using namespace boost::multiprecision;
using namespace std;
typedef long long ll;
//typedef unsigned long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define sz(x) ll(x.size())
typedef pair<int, int> P;
//typedef pair<ll, int> P;
//typedef pair<ll, ll> P;
//const double INF = 1e10;
//const ll INF = LONG_LONG_MAX / 100;
//const ll INF = (1ll << 31) - 1;
const ll INF = 1e15;
const ll MINF = LONG_LONG_MIN;
//const int INF = INT_MAX / 10;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
//typedef pair<int, int> P;
//typedef pair<double, double> P;

bool contain(set<ll> &s, ll a) { return s.find(a) != s.end(); }

//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
const int mod = 1000000007;
typedef priority_queue<long long, vector<long long>, greater<long long> > PQ_ASK;


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

    set<ll> numbers;
    rep(i, n) {

        ll a;
        cin >> a;
        if (contain(numbers, a)) {
            numbers.erase(a);
        } else {
            numbers.insert(a);
        }

    }


    cout << numbers.size() << endl;

}



Measured memory_bytes: 4864
m, k = map(int, input().split())
if m == 0:
    if k == 0:
        print(0, 0)
    else:
        print(-1)
elif m == 1:
    if k == 0:
        print(0, 0, 1, 1)
    else:
        print(-1)
else:
    if k>=2**m:
        print(-1)
    else:
        L = [i for i in range(2 ** m) if i != k]
        ans = L + [k] + L[::-1] + [k]
        print(*ans, sep=' ')
    

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

int main() {
    int N; cin >> N;
    int H[N];
    int ans = 0;
    H[0] = 0;
    for (int i = 1; i <= N; i++) {
        cin >> H[i];
    }
    for (int i = 1; i <= N; i++) {
        bool canSeeSea = true;
        for (int j = 0; j < i; j++) {
            if (H[i] < H[j]) {
                canSeeSea = false;
            }
        }
        if (canSeeSea) {
            ans++;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3564
#include <iostream>
#include <array>
#include <vector>
#include <iomanip>
#include <string>
#include <cmath>
#include <algorithm>
#include <queue>
#include <map>
#include <set>
using namespace std;

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

const LL  INF=1<<31;
const LL MOD=1000000007;



int main(){
     LL x;
     cin>>x;
     LL ans=(x+10)/11*2;
     if(ans!=(x+4)/11*2)ans--;
     cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define eps 1e-7
#define PI acos(-1)
#define de(x) cout<<#x<<'='<<x<<" , "
#define dee(x) cout<<#x<<'='<<x<<endl
#define sz(x) x.size()
#define mp make_pair
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define mset(a,b) memset(a,b,sizeof(a))
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define pb push_back
typedef long long LL;
typedef pair<int,int> pii;
typedef vector<int> vi;
const int MAXN=55,MAXE=55*55;

struct Edge{
    int nx,v,w;
}e[MAXE];
int Fi[MAXN],sz;
void E_add(int u,int v,int w){
    e[sz].v=v,e[sz].w=w,e[sz].nx=Fi[u],Fi[u]=sz++;
}

int dfn[MAXN],low[MAXN];
int clockcnt,bridgecnt,cutcnt;
void tarjan(int u,int fa){
    dfn[u]=low[u]=++clockcnt;
    int child=0,tag=0;
    for(int i=Fi[u];i!=-1;i=e[i].nx){
        int v=e[i].v;
        if(v==fa) continue;
        if(!dfn[v]){
            child++;
            tarjan(v,u);
            low[u]=min(low[u],low[v]);
            if(low[v]>=dfn[u]) tag=1;
            if(low[v]>dfn[u]) bridgecnt++;
        }
        else if(dfn[v]<dfn[u]) low[u]=min(low[u],dfn[v]);
    }
    if(tag&&!(fa==-1&&child==1)) cutcnt++;
}
int N,M;

int main(){
    scanf("%d %d",&N,&M);
    mset(Fi,-1);
    rep(i,0,M){
        int x,y;
        scanf("%d %d",&x,&y);
        E_add(x,y,1),E_add(y,x,1);
    }
    tarjan(1,-1);
    cout<<bridgecnt<<endl;
}


















/*
struct Edge{
    int nx,v,w;
}e[MAXE];
int Fi[MAXN],sz;
void E_add(int u,int v,int w){
    e[sz].v=v,e[sz].w=w,e[sz].nx=Fi[u],Fi[u]=sz++;
}
void SPFA(int st){
    mset(dis,0x3f);
    mset(vis,0); dis[st]=0;
    queue<int> q;
    q.push(st);
    while(!q.empty()){
        int u=q.front(); q.pop();
        vis[u]=0;
        for(int i=Fi[u];i!=-1;i=e[i].nx){
            int v=e[i].v;
            if(dis[v]>dis[u]+e[i].w){
                dis[v]=dis[u]+e[i].w;
                if(!vis[v]){ vis[v]=1; q.push(v); }
            }
        }
    }
}
*/


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

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

int main(){
  string a,b;
  cin >> a >> b;
  int la = a.size(), lb = b.size();
  string ans = "EQUAL";
  if(la<lb)ans="LESS";
  else if(la>lb)ans="GREATER";
  else{
    rep(i,la){
      if(a.at(i)<b.at(i)){
        ans="LESS";
        break;
      }else if(a.at(i)>b.at(i)){
        ans="GREATER";
        break;
      }
    }
  }
  cout<<ans<<endl;
  return 0;
}


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

int main() {
  int n, m;
  bool key = 1;
  cin >> n;
  string A[n];
  rep(i, n) cin >> A[i];
  cin >> m;
  rep(i, m) {
    string S;
    cin >> S;
    rep(i, n) if (A[i] == S) {
      cout << (key ? "Opened" : "Closed") << " by " << S << endl;
      if (key)
        key = 0;
      else
        key = 1;
      goto end;
    }
    cout << "Unknown " << S << endl;
  end:;
  }
  return 0;
}

Measured memory_bytes: 3208
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int count =0;
		for (int i=1;i<=N;i++) {
			String s =String.valueOf(i);
			if (s.length()%2==1)  {
				count ++;
			}
		}
		System.out.println(count);
	}
}

Measured memory_bytes: 41256
import java.util.*;
 
class Main {
    static int N,X,L;
    static int[][] Robot;
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        N = scan.nextInt();
        Robot = new int[N][2];
        for(int i=0;i<N;i++){
            Robot[i][0] = scan.nextInt();
            Robot[i][1] = scan.nextInt();
        }
       Arrays.sort(Robot,(o1,o2)->{ //sort
        if(o1[0]==o2[0])
            return Integer.compare(o1[1], o2[1]);
        else
            return Integer.compare(o1[0], o2[0]);
       });
       int remove_cnt = 0;
       for(int i=1;i<N;i++){
            if((Robot[i-1][0]+Robot[i-1][1]) > (Robot[i][0]-Robot[i][1]) ){
                if((Robot[i-1][0]+Robot[i-1][1]) > (Robot[i][0]+Robot[i][1])){ 
                    Robot[i-1][0] = -1; Robot[i-1][1] = -1;
                }
                else{
                    Robot[i][0] = Robot[i-1][0]; Robot[i][1] = Robot[i-1][1]; 
                    Robot[i-1][0] = -1; Robot[i-1][1] = -1;
                }
                remove_cnt++;
            }
       }
       System.out.print(N-remove_cnt);
    }
}

Measured memory_bytes: 94584
#include<iostream>
using namespace std;
int main()
{
	ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	long long a, b, n,k;
	cin >> n >> a >> b;
	k = n % (a + b);
	if (k <= a) cout << (n / (a + b) * a) + k << '\n';
	else cout << (n / (a + b) * a) + a << '\n';
}

Measured memory_bytes: 256