akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
// Custom Header {{{
#define ALL(x) x.begin(), x.end()
#define rep(i, s, n)      for(int i(s); i < int(n); ++i)
#define endl '\n'
#ifndef YDK
#define eprintf(...)
#endif
using namespace std;
using i64 = long long;
using pii = pair<i64, i64>;
template<class A, class B>inline bool chmax(A &a, const B &b){return b>a ? a=b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b<a ? a=b,1 : 0;}
constexpr const int INF  = 0x3f3f3f3f;
constexpr const i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr const int MOD  = int(1e9) + 7;
// }}}

// Library {{{
template<class Container, class InputIt>
Container countTable(InputIt first, InputIt last)
{
    Container cnt;
    for (; first != last; ++first) { ++cnt[*first]; }
    return cnt;
}
// }}}


signed main()
{
    int N;
    int a[200010];

    cin >> N;
    rep(i, 0, N) cin >> a[i];

    auto cnt = countTable<map<int,int>>(a, a+N);

    int ans = 0;
    for (auto e : cnt) {
        int v = e.first;
        int c = e.second;
        if (c > v) {
            ans += c - v;
        }
        else if (c < v) {
            ans += c;
        }
    }

    cout << (ans) << endl;

    return 0;
}


Measured memory_bytes: 5120
import java.util.*;

public class Main{
  public static void main(String[]args){
    Scanner sc = new Scanner(System.in);
    int N = Integer.parseInt(sc.next());
    
    float ans = 0;
    for(int i = 0; i < N; i++){
      double a = Double.parseDouble(sc.next());
      String s = sc.next();
      if(s.equals("BTC")){
        a *= 380000.0;
      }
      ans += a;
    }
    System.out.println(ans);
  }
}

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

int main(){
    int N, M; cin >> N >> M;
    vector<int> result(N, 0);
    int ac{0}, wa{0};
    for(int i=0; i<M; i++){
        int p; string s; cin >> p >> s;
        p--;
        if(s=="AC" && result[p] >= 0){
            ac++;
            wa += result[p];
            result[p] = -1;
        } else if(s=="WA" && result[p]>=0){
            result[p]++;
        }
    }

    cout << ac << " " << wa << endl;
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <unordered_map>

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

    std::vector<int> arr(N);
    std::unordered_map<int, long long int> map;

    for (int i = 0; i < N; i++) {
        std::cin >> arr[i];
        if (map.find(arr[i]) == map.end()) {
            map[arr[i]] = 0;
        }
        map[arr[i]]++;
    }

    std::unordered_map<int, long long int> counts_in;
    long long int count = 0;
    for (auto && m: map) {
        counts_in[m.first] = m.second - 1;
        count += m.second * (m.second - 1) / 2;
    }

    for (int i = 0; i < N; i++) {
        std::cout << count - map[arr[i]] + 1 << std::endl;
    }
}


Measured memory_bytes: 15304
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
//		String line = reader.readLine();
//		String[] str = reader.readLine().split(" ");
//		int[] ab = new int[str.length];
//		for (int i = 0; i < str.length; i++) {
//			ab[i] = Integer.parseInt(str[i]);
//		}
		
		int[] abc = new int[5];
		for (int i = 0; i < 5; i++) {
			String line = reader.readLine();
			abc[i] = Integer.parseInt(line);
		}
		String line = reader.readLine();
		int k = Integer.parseInt(line);
		
		if (abc[4]- abc[0] <= k) {
			System.out.println("Yay!");
		}
		else {
			System.out.println(":(");
		}
		
	}
}

Measured memory_bytes: 21972
#include <stdio.h>
#include <string.h>
int main(){
    char s[100];
    int n, AC = 0, WA = 0, TLE = 0, RE = 0;
    scanf("%d", &n);
    for (int i = 0; i < n; i++)
    {
        scanf("%s", s);
        if(strcmp(s, "AC") == 0){
            AC += 1;
        }
        else if (strcmp(s, "WA") == 0){
            WA += 1;
        }
        else if (strcmp(s, "TLE") == 0){
            TLE += 1;
        }
        else{
            RE += 1;
        }
    }
    printf("AC x %d\n", AC);
    printf("WA x %d\n", WA);
    printf("TLE x %d\n", TLE);
    printf("RE x %d\n", RE);
    return 0;
}

Measured memory_bytes: 1704
#include <iostream>

using namespace std;

int n;
int A[110][110];
int d[110];
int f[110];
string color[110];
int t = 0;

void dfs_visit(int u) {
  color[u] = "GRAY";
  d[u] = ++t;
  for (int v = 0; v < n; v++) {
    if (A[u][v] == 1 && color[v] == "WHITE") {
      dfs_visit(v);
    }
  }
  color[u] = "BLACK";
  f[u] = ++t;
}

void dfs() {
  // color 初期化
  for (int i = 0; i < n; i++) {
    color[i] = "WHITE";
  }
  for (int u = 0; u < n; u++) {
    if (color[u] == "WHITE") {
      dfs_visit(u);
    }
  }
}

int main() {
    cin >> n;
    int u, k, v;
    for (int i = 0; i < n; i++) {
      cin >> u >> k;
      for (int j = 0; j < k; j++) {
        cin >> v;
        A[u-1][v-1] = 1;
      }
    }
    dfs();

    // answer
    for (int i = 0; i < n; i++) {
      cout << i + 1 << " " << d[i] << " " << f[i] << endl;
    }
}



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

map<int, int> prime_factor(long long n) {
  map<int, int> res;
  for (int i = 2; i * i <= n; ++i) {
    while (n % i == 0) {
      ++res[i];
      n /= i;
    }
  }

  if (n != 1) res[n] = 1;
  return res;
}

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

  map<int, int> m = prime_factor(n);

  cout << n << ":";
  for (auto i : m) {
    for (int j = 0; j < i.second; ++j) {
      cout << " " << i.first;
    }
  }
  cout << endl;
}

Measured memory_bytes: 3100
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i = (int)(a); i <= (int)(b); i++)
#define NFOR(i,a,b) for(int i = (int)(a); i >= (int)(b); --i)
#define endl "\n"
#define mp make_pair
#define X first
#define Y second
#define inf 1e9
#define mod 1000000007
#define pb push_back
#define Case cout<<"Case #"<<++cas<<": ";
#define fastio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define all(v) v.begin(),v.end()
#define sz(x) int(x.size())
// #define lli int
typedef long long int lli;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<pii> vii;
typedef pair<lli,lli> pll;
typedef vector<lli> vl;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef complex <long double> complex_t;
const long double PI = acos((long double)-1.0);

#define pr(...) dbs(#__VA_ARGS__, __VA_ARGS__)
template <class T> void dbs(string str, T t) {cerr << str << " : " << t << "\n";}
template <class T, class... S> void dbs(string str, T t, S... s) {int idx = str.find(','); cerr << str.substr(0, idx) << " : " << t << ","; dbs(str.substr(idx + 1), s...);}
template <class S, class T>ostream& operator <<(ostream& os, const pair<S, T>& p) {return os << "(" << p.first << ", " << p.second << ")";}
template <class T>ostream& operator <<(ostream& os, const vector<T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class T>ostream& operator <<(ostream& os, const set<T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class S, class T>ostream& operator <<(ostream& os, const map<S, T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class T> void prc(T a, T b) {cerr << "["; for (T i = a; i != b; ++i) {if (i != a) cerr << ", "; cerr << *i;} cerr << "]\n";}

vector<pii> Adj[100010];
int dist[100010];

int main() {
    int k;
    cin >> k;
    FOR(i, 0, k-1) {
        dist[i] = 1e9;
    }
    FOR(i, 0, k-1) {
        Adj[i].pb(mp((i+1)%k, 1)), Adj[i].pb(mp((10*i)%k, 0));
    }
    priority_queue<pii, vector<pii>, greater<pii>> Q1;
    Q1.push(mp(0, 1));
    dist[1] = 0;

    while(!Q1.empty()) {
        pii u = Q1.top();
        Q1.pop();
        if (dist[u.second] == u.first) {
            // pr(u.second, u.first);
            for (auto v : Adj[u.second]) {
                if (dist[v.first] == 1e9 || dist[v.first] > dist[u.second] + v.second) {
                    dist[v.first] = dist[u.second] + v.second;
                    Q1.push(mp(dist[v.first], v.first));
                }
            }
        }
    }
    cout << dist[0] + 1 << endl;
return 0;}

Measured memory_bytes: 6780
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>

int main(int argc, char* argv[]){
  std::string s;
  int a, b;
  std::cin >> a >> b;
  int d = b - a;
  int n = d - 1;
  std::cout << n * (n + 1) / 2 - a << std::endl;
  return 0;  
}



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

int n, m;
char s[55][55];
bool used[55][55][55][55][4];
int dx[]{ -1,0,1,0 }, dy[]{ 0,1,0,-1 };
struct st {
	int x, y, px, py, id, cnt;
	bool vis[55][55];
};
bool ok(int x, int y, int px, int py, int i) {
	if (used[x][y][px][py][i])return false;
	used[x][y][px][py][i] = true;
	if (x + dx[i] == px&&y + dy[i] == py)return true;
	if (x + dx[i] + dx[(i + 1) % 4] == px&&y + dy[i] + dy[(i + 1) % 4] == py)return true;
	if (x + dx[(i + 1) % 4] == px&&y + dy[(i + 1) % 4] == py)return true;
	if (x - dx[i] + dx[(i + 1) % 4] == px&&y - dy[i] + dy[(i + 1) % 4] == py)return true;
	return false;
}
int main() {
	scanf("%d%d", &n, &m);
	st in; in.cnt = 1;
	memset(in.vis, 0, sizeof(in.vis));
	memset(s, '#', sizeof(s));
	for (int i = 1; i <= n; i++) {
		scanf("%s", s[i] + 1);
		s[i][m + 1] = '#';
		for (int j = 1; j <= m; j++) {
			if (s[i][j] == '^' || s[i][j] == 'v' || s[i][j] == '<' || s[i][j] == '>') {
				in.x = i; in.y = j;
				if (s[i][j] == '^')in.id = 0;
				if (s[i][j] == 'v')in.id = 2;
				if (s[i][j] == '<')in.id = 3;
				if (s[i][j] == '>')in.id = 1;
				in.px = i + dx[(in.id + 1) % 4]; in.py = j + dy[(in.id + 1) % 4];
			}
		}
	}
	in.vis[in.x][in.y] = true;
	queue<st>que; que.push(in);
	while (!que.empty()) {
		st p = que.front(); que.pop();
		if (s[p.x][p.y] == 'G') {
			printf("%d\n", p.cnt); return 0;
		}
		int nx, ny;
		nx = p.x + dx[p.id]; ny = p.y + dy[p.id];
		if (1 <= nx&&nx <= n && 1 <= ny&&ny <= m&&s[nx][ny] != '#'&&ok(nx, ny, p.px, p.py, p.id)) {
			int cnt = !p.vis[nx][ny];
			st u = p; u.vis[nx][ny] = true; u.x = nx; u.y = ny; u.cnt += cnt;
			que.push(u);
		}
		if (ok(p.x, p.y, p.px, p.py, (p.id + 1) % 4)) {
			st u = p; u.id = (u.id + 1) % 4;
			que.push(u);
		}
		if (ok(p.x, p.y, p.px, p.py, (p.id + 3) % 4)) {
			st u = p; u.id = (u.id + 3) % 4;
			que.push(u);
		}
		for (int i = -1; i <= 1; i++)for (int j = -1; j <= 1; j++) {
			nx = p.px + i; ny = p.py + j;
			if (nx<0 || nx>n + 1 || ny<0 || ny>m + 1)continue;
			if (s[nx][ny] == '#' && ok(p.x, p.y, nx, ny, p.id)) {
				st u = p; u.px = nx; u.py = ny;
				que.push(u);
			}
		}
	}
	puts("-1");
}

Measured memory_bytes: 9432
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

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

    vector<int> p,m;
    rep(i,n){
        int x;
        cin >>x;

        if(x>=0) p.pb(x);
        else m.pb(-x);
    }
    sort(all(p));
    sort(all(m));
    int P = p.size(), M = m.size();

    int ans = INT_MAX;
    rep(i,k+1){
        int j = k-i;
        if(i>P ||j>M) continue;

        int pd = 0;
        if(i) pd = p[i-1];

        int md = 0;
        if(j) md = m[j-1];

        ans = min(ans, 2*min(pd,md)+max(pd,md));
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1020
#include <stdio.h>
#include <stdlib.h>

int main(void){
	int N;
	scanf("%d\n",&N);
	int A[N];
	for(int i=0;i<N;i++){
		scanf("%d \n",&A[i]);
	}
	for(int i=0;i<N;i++){
			if((A[i]%2 == 0) && (A[i]%3 == 0 || A[i]%5 == 0))continue;
			else if(A[i]%2 == 1)continue;
			else {
				printf("DENIED");
				return 0;
			}
		}
	printf("APPROVED");
    return 0;
}


Measured memory_bytes: 128
S=list(input())
N=len(S)

A=[0]*(N+1)
L=[]
if S[0]=="<":
  r=1
  l=0
else:
  l=1
  r=0

for i in range(1,N):
  if S[i]=="<":
    r+=1
    if S[i]!=S[i-1]:
      L.append(-l)
      l=0
  else:
    l+=1
    if S[i]!=S[i-1]:
      L.append(r)
      r=0
if r>0:
  L.append(r)
elif l>0:
  L.append(-l)
      
m=max(abs(max(L)),abs(min(L)))
ans=0
if S[0]=="<":
  if len(L)%2==0:
    for i in range(len(L)//2):
      ma=max(L[2*i],-L[2*i+1])
      mi=min(L[2*i],-L[2*i+1])
      ans+=ma*(ma+1)//2+(mi-1)*mi//2
  else:
    for i in range(len(L)//2):
      ma=max(L[2*i],-L[2*i+1])
      mi=min(L[2*i],-L[2*i+1])
      ans+=ma*(ma+1)//2+(mi-1)*mi//2
    ans+=L[-1]*(L[-1]+1)//2
    
if S[0]==">":
  ans+=(-L[0])*(-L[0]+1)//2
  if len(L)%2==0:
    for i in range(len(L)//2-1):
      ma=max(L[2*i+1],-L[2*i+2])
      mi=min(L[2*i+1],-L[2*i+2])
      ans+=ma*(ma+1)//2+(mi-1)*mi//2
    ans+=L[-1]*(L[-1]+1)//2
  else:
    for i in range(len(L)//2):
      ma=max(L[2*i+1],-L[2*i+2])
      mi=min(L[2*i+1],-L[2*i+2])
      ans+=ma*(ma+1)//2+(mi-1)*mi//2

print(ans)  

Measured memory_bytes: 13872
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
#define INF 0x3f3f3f3f
#define MOD 1000000007
#define PI 4*atan(1.0)
typedef long long ll;
typedef long double ld;
using namespace std;
int dx[4]={0,0,-1,1};
int dy[4]={-1,1,0,0};
const int SIZE=200001;
//int arr[SIZE]={};
//ここまでテンプレ
int calc(long long int a,long long int b,long long int p){
	if(!b) return 1;
	else if(!(b%2)){
		long long int d=calc(a,b/2,p);
		return (d*d)%p;
	}else return (a*calc(a,b-1,p))%p;
}
int main(){
	char A[SIZE];
	scanf("%s",A);
	ll alpha[26]={};
	ll s=strlen(A);
	for(int i=0;i<s;i++){
		alpha[A[i]-'a']++;
	}
	ll w=s*(s-1)/2;
	w++;
	for(int i=0;i<26;i++){
		w-=alpha[i]*(alpha[i]-1)/2;
		//cout<<w<<endl;
	}
	cout<<w<<endl;
	return 0;
}

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

using namespace std;

using ll = long long;

constexpr char newl = '\n';
constexpr int MAXV = 1000000;

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

    int n;
    cin >> n;

    vector<int> a(n);
    vector<int> dp(MAXV + 1, 0);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        ++dp[a[i]];
    }

    for (int i = 1; i <= MAXV; ++i) {
        for (int j = i * 2; j <= MAXV; j += i) {
            dp[j] += dp[i];
        }
    }

    int ans = 0;
    for (int i = 0; i < n; i++) {
        //cerr << a[i] << " " << dp[a[i]] << newl;
        ans += (dp[a[i]] == 1);
    }
    cout << ans << newl;

    return 0;
}

Measured memory_bytes: 7952
using System;
using System.Linq;
using System.Collections.Generic;
using System.Text;

namespace Program
{
    public class ABC125D
    {
        static class Console_
        {
            private static Queue<string> param = new Queue<string>();
            public static int NextInt() => int.Parse(NextString());
            public static string NextString()
            {
                if (param.Count == 0) foreach (var item in Console.ReadLine().Split(' ')) param.Enqueue(item);
                return param.Dequeue();
            }
        }

        static public void Main(string[] args)
        {
            var N = Console_.NextInt();
            long sum = 0;
            long mini = 10000000000;
            bool odd = false;
            for (int i = 0; i < N; ++i)
            {
                var A = Console_.NextInt();
                if (A < 0) odd = !odd;
                var absA = Math.Abs(A);
                if (absA < mini) mini = absA;
                sum += absA;
            }

            Console.WriteLine(odd ? sum - mini * 2 : sum);
        }
    }
}


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

int main() {
  int n, m; cin >> n >> m;
  int s[m][n] = {};
  for (int i = 0; i < m; ++i) {
    int k; cin >> k;
    for (int j = 0; j < k; ++j) cin >> s[i][j];
  }
  int p[m]; for (int i = 0; i < m; ++i) cin >> p[i];
  
  int ans = 0;
  for (int bit = 0; bit < (1 << n); ++bit) {
    int switches[n] = {};
    bool ok = true;
    for (int rbit = 0; rbit < n; ++rbit) if (bit & (1 << rbit)) switches[rbit] = 1;
    
    for (int i = 0; i < m; ++i) {
      int on_switch_cnt = 0;
      for (int j = 0; j < n; ++j) if (switches[s[i][j] - 1] == 1) ++on_switch_cnt;
      
      if (on_switch_cnt % 2 != p[i]) ok = false;
    }
    
    if (ok) ++ans;
  }
  cout << ans << endl;
  return 0;
}

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

int main() {
  int r, g, b;
  cin >> r >> g >> b;
  int num = r*100 + g*10 + b;
  if(num%4==0) cout << "YES" << endl;
  else cout << "NO" << endl;
  return 0;
}


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

public class Prog
{
    public static void Main()
    {
        var input = Console.ReadLine().Split();
        int N = int.Parse(input[0]);
        int K = int.Parse(input[1]);
        Console.WriteLine(N - K + 1);
    }
}


Measured memory_bytes: 13140
N = int(input())
P = tuple(map(int, input().split()))
Q = tuple(map(int, input().split()))

import itertools

idx = 1
for l in itertools.permutations(range(1, N+1)):
    if l == P:
        a = idx
    if l == Q:
        b = idx

    idx += 1

print(abs(a-b))


Measured memory_bytes: 39280
#include <iostream>
#include <algorithm>

using namespace std; 
int n,total=0;;
int l[202];

int main(){
  cin >> n;
  for(int i=0;i<n*2;i++){
    cin >> l[i];
  }
  sort(l,l+n*2);
  for(int i=0;i<n*2;i+=2){
    total+=l[i];
  }
  cout << total << endl;
  return 0;
}

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

int main(){
	int n,cont = 0,res = 0;
	cin>>n;
	int vals[n];
	for (int k = 0; k <n;k++){
		cin >> vals[k];
		cont += vals[k];
	}
	//cout<<cont<<endl;
	cont = round((float)cont/(float)n);
	//cout<<cont<<endl;
	for (int k = 0; k <n;k++){
		res += (cont-vals[k])*(cont-vals[k]);
	}
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
void call(int n){
  for(int i = 1;i<=n;i++){
    int x = i;
    if ( x % 3 == 0 ){
        cout << " " << i;
        continue;
    }
    while(x){
      if ( x % 10 == 3 ){
        cout << " " << i;
        break;
      }
      x /= 10;
    }
  }
  cout << endl;
}
int main(){
    int N;
    cin>>N;
    call(N);
}


Measured memory_bytes: 3072
from collections import Counter
n=int(input())
l=map(int,input().split())
o=sorted(filter(lambda x:x[1]>=2,Counter(l).items()))

if len(o)<2:
  print(0)
else:
  if o[-1][1]>=4:
    print(o[-1][0]*o[-1][0])
  else:
    print(o[-1][0]*o[-2][0])

Measured memory_bytes: 24104
#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>;
const int INF = 1 << 30;
 
int main() {
	ll a, b, c;
	cin >> a >> b >> c;
	if (a%2==0 || b%2==0 || c%2==0) {
		cout << 0 << endl;
		return 0;
	}
	ll mi = min(a*b, min(b*c, c*a));
	cout << mi << endl;
	return 0;
}

Measured memory_bytes: 256
/**
 *   created: 01 June 2019  12:55:56
**/
#include<bits/stdc++.h>
using namespace std;

typedef vector<int> vi;
typedef pair<int , int> pii;
typedef vector< pair<int , int> > vii;
typedef long long ll;
typedef vector<long long> vl;
typedef pair<long long , long long> pll;
typedef vector< pair<long long , long long> > vll;

#define PB push_back
#define PPB pop_back
#define all(c) c.begin(),c.end()
#define rep(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
#define rrep(i,a,b) for(int i = (int)(a-1); i>=(int)(b); i--)
#define INFLL 2000000000000000007
#define INF 2000000007
#define MOD 1000000007


#define TRACE

#ifdef TRACE
#define trace1(x)                cerr << #x << ": " << x << endl;
#define trace2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
#define trace3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
#define trace4(a, b, c, d)       cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl;
#define trace5(a, b, c, d, e)    cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl;
#define trace6(a, b, c, d, e, f) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl;

#else

#define trace1(x)
#define trace2(x, y)
#define trace3(x, y, z)
#define trace4(a, b, c, d)
#define trace5(a, b, c, d, e)
#define trace6(a, b, c, d, e, f)

#endif


void optimizeIO()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
}

//                                        //AUTHOR: Kaushalesh Shukla

//=========================================================================================================

int main()
{
	optimizeIO();
	int tt=1;
	//cin>>tt;
	while(tt--){
		string s;
		cin>>s;
		stack<char> s1,s2;
		rep(i,0,s.size()){
			s1.push(s[i]);
		}
		int cnt=0;
		while(!s1.empty()){
			if(s2.empty()){
				s2.push(s1.top());
				s1.pop();
			}
			else{
				if(s1.top()!=s2.top()){
					cnt += 2;
					s1.pop();
					s2.pop();
				}
				else{
					s2.push(s1.top());
					s1.pop();
				}
			}
		}
		cout<<cnt;
	}
	return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
using namespace std;
int main()
{
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  
  map<int,bool> mp;
  rep(i,n){
    if(i&1) mp[a[i]] = true;
    else mp[a[i]] = false;
  }

  sort(a.begin(), a.end());
  int cnt = 0;
  rep(i,n){
    if(i&1){
      if(!mp[a[i]]) cnt++;
    }
    else{
      if(mp[a[i]]) cnt++;
    }
  }

  cout << cnt/2 << "\n";
  return 0;
}


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

using namespace std;

#define PI          3.1415926535897932384626433832795l

#define pb push_back
#define mp make_pair
#define lb lower_bound // First element which is not less than val
#define ub upper_bound // First element greater than val
#define f first
#define s second

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

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vd = vector<double>;
using vs = vector<string>;
using vpii = vector<pair<int,int>>;
using vpll = vector<pair<ll,ll>>;

using pii = pair<int,int>;
using pll = pair<ll,ll>;

#define endl '\n'
#define re return

#define rep(i,a,b) for (ll i = (a); i < (b); i++)
#define repz(i, a) for (ll i = 0; i < (a); i++)
#define repd(i,a,b) for (ll i = (a); i >= b; i--)
#define repdz(i,a) for (ll i = a; i >=0; i--)
#define trav(a, x) for (auto& a : x)

#define vecin(n,v) for(ll i = 0; i < n; i++) cin>>v[i];
#define llin(a) ll a; cin>>a;
#define llin2(a,b) ll a,b; cin >>a>>b;
#define llin3(a,b,c) ll a,b,c; cin>>a>>b>>c;
#define full(v) v.begin(),v.end()

void solve()
{
    int n;
    cin >> n;
    vi h(n);
    vecin(n,h);
    vi dp(n);
    dp[0]=0;
    dp[1]=abs(h[1]-h[0]);
    rep(i,2,n)
    {
        dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]));
    }
    cout << dp[n-1] << endl;
}
int main()
{
    ios_base::sync_with_stdio(false);
    //llin(t);
    //while (t--)
    //{
        solve();
    //}
}


Measured memory_bytes: 1024
//85DTG
//07082020
#include<bits/stdc++.h>
using namespace std;
#define bolt ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define F first
#define S second
#define pb push_back
#define endl "\n"
#define lb lower_bound
#define ub upper_bound
#define vi vector <int>
typedef long long ll;
typedef long double ld;
const ld pi=3.1415926535897932384626433;
const ll mod = 998244353;
const ll inf = 1e18;
int main ()
{
   bolt;
   ll n,d;
   cin>>n>>d;
   ll ans=0;
   for (ll i=0;i<n;i++)
   {
      ll x,y;
      ld a;
      cin>>x>>y;
      a=sqrt(x*x+y*y);
      if (a<=d)
         ans++;
   }

   cout<<ans;
}


Measured memory_bytes: 3632
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <map>
#include <iomanip>	
#include <deque>
#include <set>
#define rep(i,a,b) for(int i=a;i<b;++i)
#define rrep(i,a,b) for(int i=a;i>=b;--i)
#define fore(i,a) for(auto &i:a)
#define INF INT_MAX/2;
typedef long long ll;
using namespace std;
using vi = vector<int>;
using vll = vector<ll>;
ll mod = 1e9 + 7;
//ll llmax = 10000000000000000000ll;
using namespace std;
using Graph = vector<vector<int>>;


int cnt_digit(ll N)
{
	int digit = 0;

	while (N > 0)
	{
		N /= 10;
		digit++;
	}
	return digit;
}


 // 最大公約数計算
 
ll gcd(ll a, ll b)
{
	if (b == 0) {
		return a;
	}
	else {
		return gcd(b, a % b);
	}
}
// 最小公倍数の計算

ll lcm(ll a, ll b)
{
	ll g = gcd(a, b);

	return a / g * b;
}

struct union_find
{
	vector<int> par, r;
	union_find(int n)
	{
		par.resize(n);
		r.resize(n);
		init(n);
	}


	void init(int n)
	{
		for (int i = 0; i < n; i++) par[i] = i;
		for (int i = 0; i < n; i++) r[i] = 0;
	}

	int find(int x)
	{
		if (par[x] == x)return x;
		else return find(par[x]);
	}

	void unite(int x, int y)
	{
		x = find(x);
		y = find(y);

		if (r[x] < r[y])
		{
			par[x] = y;
		}
		else
		{
			par[y] = x;
			if (r[x] == r[y])
			{
				r[x]++;
			}
		}
	}
};



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

	string s;
	cin >> n >> s;
	vector<int> w(n + 1);
	vector<int> e(n + 1);
	w[0] = 0;
	e[0] = 0;
	rep(i, 0, n ) {
		if (s[i] == 'W') {
			w[i + 1] = w[i] + 1;
		}
		else
		{
			w[i + 1] = w[i];
		}

	}
	rep(i, 0, n) {
		if (s[i] == 'E') {
			e[i + 1] = e[i] + 1;
		}
		else
		{
			e[i + 1] = e[i];
		}

	}

	int ans = n;

	
	rep(i, 0, n) {
		int tmp = 0;
		tmp = w[i] + e[n] - e[i+1];

		ans = min(ans, tmp);
	}
		
		
	cout << ans << endl;
	
	
	
		
	
	
	
	
}
	

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

#define int long long
#define rep(x,y) for(int i=x;i<y;i++)
#define REP(x,y) for(int j=x;j<y;j++)
#define str string
#define vint vector<int>
#define vchar vector<char>
#define vool vector<bool>
#define pb() pushback
#define elif else if
#define all(x) x.begin(),x.end()

main(){
    int N,b,count=0,count2=0,H,W;
    double r,pai=3.141592653589;
    int C='A'-'a';
    char op;
    str S,T;
      while(1){
        cin>>H>>W;
        if(H>0&&W>0){
          vector<vchar> sharp(H,vchar(W));
          rep(0,H){
            REP(0,W){
            sharp[i][j]='#';
            cout<<sharp[i][j];
            }
            cout<<endl;
          }
          cout<<endl;
        }
        else break;
      }
}



Measured memory_bytes: 3148
# coding: utf-8
# Here your code !
import collections

p,q=map(int,input().split())
count =0

deq = collections.deque()
finished=[]

while 1:
    try:
        deq.append(input().split())
        
    except EOFError:
        break

while deq:
    d = deq.popleft()
    d[1]=int(d[1])
    if d[1]<=q:
        count+=d[1]
        d[1]=count
        finished.append(map(str,d))
    elif d[1]>q:
        d[1]-=q
        count+=q
        deq.append(d)
for f in finished:
    print(" ".join(f))

Measured memory_bytes: 30124
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

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

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

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

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

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

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

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

fn main() {
    input!{
        a: u64,
        b: u64,
    }
    println!(
        "{}",
        if a % 3 == 0 || b % 3 == 0 || (a + b) % 3 == 0 {
            "Possible"
        } else {
            "Impossible"
        }
    );
}


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

int main() {
	int A, B; cin >> A >> B;
	string S; cin >> S;
	
	bool flag = (S[A]=='-');
	for (int i = 0; i < S.size(); i++) {
		if (i == A)continue;

		if (S[i]<'0' || S[i]>'9')flag = false;
	}

	cout << (flag ? "Yes" : "No") << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
const ll maxn=2e5+1;
set<ll> elements;
bool flag;
ll N;
void create_set()
{
	for(ll j=0;j<=5;j++)
	{
		elements.insert(100+j);
	}
	for(ll i=1;i<=N;i++)
	{
		if(elements.find(i)!=elements.end())
		{
			for(ll j=0;j<=5;j++)
			{
				elements.insert(i+100+j);
			}
		}
	}
}
void solve()
{
	cin>>N;
	create_set();
	if(elements.find(N)!=elements.end())
	{
		flag=true;
	}
	else
	{
		flag=false;
	}
	if(flag==true)
	{
		cout<<1<<"\n";
	}
	else
	{
		cout<<0<<"\n";
	}
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll T=1,p=0;
	//cin>>T;
	do
	{
		solve();
		p++;
	}while(p<T);
	return 0;
}



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

int main(){
    double n,k;
    cin>>n>>k;
    
    int cnt=0,j=1;
    while(j<k){
        j*=2;
        cnt++;
    }
    
    double ans=0.0;
    
    for(int i=1;i<n+1;i++){
        int cnt=0,j=i;
            while(j<k){
                j*=2;
                cnt++;
            }
        ans+=1/(n*pow(2,cnt));
    }
    cout<<fixed<<setprecision(15)<<ans<<endl;
    return 0;
}

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

bool is_prime(int n){
  for(int i=2; i<n; i++){
    if(n % i == 0){
      return false;
    }
  }
  return true;
}


int main(){
  int64_t X;
  cin >> X;

  while(!is_prime(X)){
    X++;
  }

  cout << X << endl;
}


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

typedef long long ll;
typedef unsigned long long ull;
const int inf = 2e9;
const ll INF = 4e18;

int N, W;
ll w[110], v[110];
ll dp[110][100010];

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

  cin >> N >> W;
  for (int i = 1; i <= N; i++) {
    cin >> w[i] >> v[i];
  }
  for (int i = 0; i <= N; i++) {
    for (int j = 0; j <= 100000; j++) {
      dp[i][j] = INF;
    }
  }
  dp[0][0] = 0;
  for (int i = 1; i <= N; i++) {
    for (int j = 0; j <= 100000; j++) {
      dp[i][j] = min(dp[i][j], dp[i-1][j]);
      if (j+v[i] <= 100000)
	dp[i][j+v[i]] = min(dp[i][j+v[i]], dp[i-1][j] + w[i]);
    }
  }
  for (int j = 100000; j >= 0; j--) {
    if (dp[N][j] <= W) {
      cout << j << endl;
      return 0;
    }
  }
  return 0;
}


Measured memory_bytes: 80128
fun main(args : Array<String>) {
    val (n, m) = readLine()!!.split(" ").map { it.toInt() }
    val s = readLine()!!
    val t = readLine()!!

    val lcm = lcm(n.toLong(), m.toLong())
    if (lcm == n.toLong() * m.toLong()) {
        if (s[0] == t[0]) {
            println(lcm)
        } else {
            println("-1")
        }
        return
    }

    val stepN = lcm/n
    val stepM = lcm/m
    val stepC = lcm(stepN,  stepM)

    var idx = 0L

    while (idx < lcm) {
        if (s[(idx/stepN).toInt()] != t[(idx/stepM).toInt()]) {
            println("-1")
            return
        }
        idx += stepC
    }

    println(lcm)
}

fun gcd(a : Long, b : Long) : Long {
    return if (a % b == 0L) b else gcd(b, a % b)
}

fun lcm(a : Long, b : Long) : Long {
    return (a * b) / gcd(a, b)
}



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

#define for_(i,a,b) for(int i=(a);i<(b);++i)
typedef long long lint;
template< typename T > using Vec = vector< T >;

lint encode(lint v, lint c) { return (v << 32) | c; }

struct Edge {
	lint to;
	int dst;
	bool operator > (const Edge& o) const { return dst > o.dst; }
};

int N, M;
unordered_map< lint, Vec< Edge > > edges;
unordered_map< lint, int > dst;

void solve() {
	priority_queue< Edge, Vec< Edge >, greater< Edge > > que;
	que.push(Edge{0, 0});
	dst[0] = 0;
	
	while (!que.empty()) {
		Edge cur = que.top(); que.pop();
		
		if (dst[cur.to] < cur.dst) continue;
		
		for (const Edge& e : edges[cur.to]) {
			if (dst.count(e.to) == 0 || dst[e.to] > cur.dst + e.dst) {
				dst[e.to] = cur.dst + e.dst;
				que.push(Edge{e.to, dst[e.to]});
			}
		}
	}
	
	if (dst.count(encode(N-1, 0)) == 0) puts("-1");
	else cout << dst[encode(N-1, 0)] << endl;
}

int main() {
	cin >> N >> M;
	
	for_(i,0,M) {
		int u, v, c;
		cin >> u >> v >> c;
		--u; --v;
		
		edges[encode(u, c)].push_back(Edge{encode(v, c), 0});
		edges[encode(v, c)].push_back(Edge{encode(u, c), 0});
		
		edges[encode(u, 0)].push_back(Edge{encode(u, c), 1});
		edges[encode(v, 0)].push_back(Edge{encode(v, c), 1});
		
		edges[encode(u, c)].push_back(Edge{encode(u, 0), 0});
		edges[encode(v, c)].push_back(Edge{encode(v, 0), 0});
	}
	
	solve();
}

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

typedef struct _store {
	string name;
	int score;
	int order;
}Store;

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

	vector<Store> store(N);

	for (int i = 0; i < N; i++) {
		string S;
		int P;
		cin >> S >> P;
		store[i].name = S;
		store[i].score = P;
		store[i].order = i + 1;
	}

	for (int i = 0; i < N - 1; i++) {
		for (int j = N - 1; j > i; j--) {
			if (store[i].name > store[j].name) {
				//cout << i << j << endl;
				/*string temp_name = store[i].name;
				int temp_score = store[i].score;
				int temp_order = store[i].order;
				store[i].name = store[j].name;
				store[i].score = store[j].score;
				store[i].order = store[j].order;
				store[j].name = temp_name;
				store[j].score = temp_score;
				store[j].order = temp_order;*/
				swap(store[i], store[j]);
			}
			else if ((store[i].name == store[j].name) && (store[i].score < store[j].score)) {
				swap(store[i], store[j]);
			}
		}
	}

	for (int i = 0; i < N; i++) {
		cout << store[i].order << endl;
	}

	return 0;

}


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;
using P = pair<int,int>;
int main() {
    int n; cin >> n;
    ll sum = 0;
    map<int, int> mp;
    rep(i, n) {
        int a; cin >> a;
        mp[a]++;
        sum += a;
    }
    int q; cin >> q;
    rep(i, q) {
        int b, c; cin >> b >> c;
        int num = mp[b];
        sum -= num*b - num*c;
        cout << sum << endl;
        mp[c] += mp[b];
        mp[b] = 0;
    }
}


Measured memory_bytes: 7980
def Pair(K):
    n = 0
    even = []
    odd = []
    K = int(K)
    k = K + 1
    for p in range(1,k):
        if p%2 == 0:
            even.append(p)
        if p%2 == 1:
            odd.append(p)
    n = len(even) * len(odd)
    print (n)

Pair(input())


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,k;
  cin>>n>>k;
  vector<int> a(n);
  for(int i=0;i<n;i++)
    cin>>a.at(i);
  for(int i=k;i<n;i++)
    cout<<(a.at(i-k)<a.at(i)?"Yes":"No")<<endl;
}

Measured memory_bytes: 4048
#include <bits/stdc++.h>
 
using namespace std;
 
template <class T>inline T updmax(T& a, T b) {return a = max(a, b);}
template <class T>inline T updmin(T& a, T b) {return a = min(a, b);}
 
class Solution {
public:
	void solve() {
        long long n, a, b, c, d;
        cin >> n >> a >> b >> c >> d;
        b -= a;
        a = 0;
        b <<= 1;
        c <<= 1;
        d <<= 1;
        n--;
        long long w = ((d-c)/2)*n;
        for(int i=-n; i<=n; i+=2){
            long long ma, mi;
            ma = (c+d)/2 * i + w;
            mi = (c+d)/2 * i - w;
            if(mi <= b && b <=ma){
                cout << "YES" << endl;
                return;
            }
        }
        cout << "NO" << endl;
        
		return;
	};
};
 
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	Solution solution;
	solution.solve();
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll Maxn=2e5+10;
const ll INF=1e18;
ll f[Maxn],num[Maxn];
ll o_find(ll V){
    return f[V]==V?V:f[V]=o_find(f[V]);
}
void o_merge(ll p,ll q){
    ll u=o_find(p);
    ll v=o_find(q);
    if(u!=v){
        f[u]=o_find(v);
    }
}
int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    ll n,m;
    cin>>n>>m;
    for(ll i=1;i<=n;i++)    f[i]=i;
    for(ll i=1;i<=m;i++){
        ll u,v;
        cin>>u>>v;
        if(o_find(u)!=o_find(v)){
            o_merge(u,v);
        }
    }
    ll ans=-INF;
    for(ll i=1;i<=n;i++){
        o_find(i);
        num[f[i]]++;
    }
    for(ll i=1;i<=n;i++)    ans=max(ans,num[i]);
    cout<<ans;
    return 0;
}


Measured memory_bytes: 11288
#キューとdictionaryを利用したBFS
from collections import deque

n = int(input())

ab = [list(map(int,input().split())) for i in range(n-1)]

ver = [[] for i in range(n)]

for i in range(n-1):
    a,b = ab[i][0],ab[i][1]
    ver[a-1].append(b-1)
    ver[b-1].append(a-1)

#print(ver)

color = [dict() for i in range(n)]
q = deque()
i = 1
for v in ver[0]:
    color[0][v] = i
    color[v][0] = i
    q.append((0,v))
    i += 1

#print(q)

while q:
    f,t = q.popleft()
    i = 1
    for v in ver[t]:
        if v == f:
            continue
        if i == color[f][t]:
            i += 1
        color[t][v] = i
        color[v][t] = i
        q.append((t,v))
        i += 1

#print(color)
#辞書のリストで辺の色を管理している
k = 0
for i in range(n):
    k = max(k,len(ver[i]))
print(k)
for i in range(n-1):
    a,b = ab[i][0],ab[i][1]
    print(color[a-1][b-1])


Measured memory_bytes: 74912
import java.util.Scanner;
     
public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
 
        double N = sc.nextDouble();

        if (N % 2 == 0) {
            System.out.println((N / 2)/N);
        } else {
            System.out.println((int)(N / 2 + 1)/N);
        }
    }
}

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

using namespace std;

typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vii;
typedef vector<ll> vll;
typedef pair<ll,ll> pii;

#define pb push_back
#define odd(x) ((x)&1)
#define even(x) (!odd(x))
#define ff it->first
#define ss it->second
#define all(v) (v).begin(),(v).end()
#define rep(i,n) for(auto i=0;i<n;++i)
#define LOOP_IT(it,s) for(auto it=(s).begin();it!=(s).end();++it)
#define FASTIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);


#ifdef LOCAL
#define cerr cout
#else
#endif

#define TRACE

#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif


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...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif


const ll N = 1e6;
vll v(N);
ll now=1;

void solve(ll n,ll cur,string s)
{
    if(cur==n)
    {
        stringstream str(s);
        ll num = 0;
        str>>num;
        v[now] = num;
        ++now;
        if(now>N-1)
            return;
    }
    else
    {
        ll l = max(0,(s[cur-1]-'0')-1);
        ll r = min(9,(s[cur-1]-'0')+1);
        for(ll i=l;i<=r;++i)
        {
            s[cur] = i+'0';
            solve(n,cur+1,s);
            if(now>N-1)
                return;
        }
    }
}
int main(int argv, char* argc[])
{
    FASTIO


    for(ll i=1;i<=10;++i)
    {
        string s;
        s.resize(i);
        for(ll j=1;j<=9;++j){
        s[0] = j+'0';
        solve(i,1,s);
        }
    }
    ll k;
    cin>>k;
    cout<<v[k];

    return 0;
}



Measured memory_bytes: 10944
# -*- coding: utf-8 -*-
"""
Created on Sun Jul 21 19:31:27 2019

@author: yama
"""

n = int(input())
l = list(map(int, input().split()))

x = 0
for i in l:
    x ^= i
    
if x == 0:
    print("Yes")
    
else:
    print("No")


Measured memory_bytes: 14212
/*COMPETITIVE PROGRAMMING C++ TEMPLATE */

#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <string>
#include <cmath>
#include <iostream>
#include <stack>
#include <queue>
#include <climits>
#include <iomanip>
#include <iterator>

#define all(x) x.begin(), x.end()
#define MOD 998244353
const unsigned int M = 1000000007;
const long double PI = 3.141592653589793236L;

typedef long long int ll;
typedef long double ld;
#define MAX 50
using namespace std;
void printString(ll n)
{
    ll arr[10000];
    ll i = 0;


    while (n) {
        arr[i] = n % 26;
        n = n / 26;
        i++;
    }


    for (ll j = 0; j < i - 1; j++) {
        if (arr[j] <= 0) {
            arr[j] += 26;
            arr[j + 1] = arr[j + 1] - 1;
        }
    }

    for (ll j = i; j >= 0; j--) {
        if (arr[j] > 0)
            cout << char('A' + arr[j] - 1+32);
    }


}
void solve(){
   ll n;
   cin>>n;
   ll a[n];
   map<ll,ll> values;
   map<ll, ll>::iterator it;
   ll sum=0;
   for(ll i=0;i<n;i++){
       cin>>a[i];
        if(values.find(a[i])==values.end())values.insert(pair<ll,ll>(a[i],1));
        else{
            it=values.find(a[i]);
            it->second++;
        }
        sum+=a[i];
    }
   ll q;
   cin>>q;
   ll query[q][2];
   for(ll i=0;i<q;i++){
    cin>>query[i][0]>>query[i][1];
   }
   for(ll i=0;i<q;i++){
       ll b=query[i][0];
       ll c=query[i][1];
       it= values.find(b);
       if(it==values.end()){cout<<sum<<endl;continue;}
       ll subt=it->second;
       ll tosubt=it->first;
       sum-=subt*tosubt;
       values.erase(it);
       it=values.find(c);
       if(it==values.end()){
           values.insert(pair<ll,ll>(c,subt));
       }
       else{
           it->second+=subt;
       }
       sum+=c*subt;
       cout<<sum<<endl;
   }

}


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

    int T = 1;
    solve();

    return 0;
}

Measured memory_bytes: 9916
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <queue>
#include <sstream>
#include <stack>
#include <time.h>
#include <vector>
#include <complex>
#include <map>
#include <set>
#include <iomanip>
#include <math.h>
#include <stdlib.h>
#include <list>
#include <utility>
#include <memory>
#include <cstring>
#include <fstream>
#include <numeric>
#include <assert.h>
#include <bitset>
#include <ios> 
#include <cctype>
#include <bits/stdc++.h>
using namespace std;
int main(){
	int a,b,c;
	cin>>a>>b>>c;
	cout<<min(b/a,c);
}

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

using namespace std;
using ll = long long;
constexpr int mo = 1e9+7;
constexpr int  mod = mo;
constexpr int inf = 1<<30;
int main(){
    ll n,k;
    cin>>n>>k;
    if(n> k) swap(n,k);
    ll ret = 0ll;
    if(n == 1 and k == 1)ret = 1;
    else if(n == 1){
        ret = k-2;
    }else{
        ret = 1ll*(n-2)*(k-2);
    }
    cout << ret << endl;
    return 0;
}



Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
int main(int argc, char const *argv[])
{
  int n;
  scanf("%d",&n);
  int x[n];
  int y[n];
  int i,j;
  double sum=0.0;
  double c;
  for(i=0;i<n;i++){
    scanf("%d",&x[i]);
    scanf("%d",&y[i]);
  }
  double k[n][n];
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      k[i][j]=sqrt(pow(x[i]-x[j],2)+pow(y[i]-y[j],2));
      sum+=k[i][j];
    }
  }
  c=sum/n;
  printf("%lf",c);
  return (0);
}


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

using namespace std;

int n, k, i, x, pos, rez;

int main()
{
    scanf("%d%d", &n, &k);

    for(i = 1; i <= n; i ++)
    {
        scanf("%d", &x);
        if(x == 1)
            pos = i;
    }

    if(n == k)
    {
        printf("1");
        return 0;
    }
    if(k == 2)
    {
        printf("%d", n-1);
        return 0;
    }

    if(pos > n-k+1)
    {
        rez = 0;
        pos = n - k + 1;
        rez = pos / (k-1) + ((pos % (k-1) == 0 || pos % (k-1) == 1) ? 0 : 1);
        printf("%d", rez+1);
        return 0;
    }
    if(pos < k)
    {
        pos = n - k + 1;
        rez = pos / (k-1) + ((pos % (k-1) == 0 || pos % (k-1) == 1) ? 0 : 1);
        printf("%d", rez+1);
        return 0;
    }

    rez = 0;
    rez = pos / (k-1) + ((pos % (k-1) == 0 || pos % (k-1) == 1) ? 0 : 1);
    int x = 0;
    while(x+1 < pos)
    {
        x += k-1;
    }
    pos = n - (pos + ((x+1)-pos)) + 1;
    rez += pos / (k-1) + ((pos % (k-1) == 0 || pos % (k-1) == 1) ? 0 : 1);
    printf("%d", rez);

    return 0;
}


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

typedef pair<int, int> pii;
typedef long long ll;
typedef vector<int> vi;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()
#define dump(x) cout << #x << " = " << (x) << endl

int main() {
	ll A,B,C;
	cin>>A>>B>>C;
	cout<<min(C,A+B+1)+B<<endl;
	return 0;
}

Measured memory_bytes: 256
import math

a, b, h, m = map(int, input().split())
angule_h = 30 * h + 0.5 * m
angule_m = 6 * m
angule_diff = min(360 - abs(angule_h - angule_m),abs(angule_h - angule_m))
c_2 = (a ** 2 + b ** 2) - (2 * a * b * math.cos(math.radians(angule_diff)))
print(math.sqrt(c_2))

Measured memory_bytes: 9572
#include <iostream>

using namespace std;

int main()
{
    int x, y;
    cin >> x >> y;
    while (x != 0 || y != 0)
    {
        if (x > y)
            swap(x, y);
        cout << x << " " << y << endl;
        cin >> x >> y;
    }
}


Measured memory_bytes: 3000
n = int(input())
l = list(map(int, input().split()))
l_div = [x for x in l if x % 2 == 0]
for x in l_div:
    if x % 3 == 0 or x % 5 == 0:
      pass
    else:
        print("DENIED")
        exit(0)
print("APPROVED")
exit(0)

Measured memory_bytes: 2940