akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <set>
using ll = long long;
using graph = std::vector<std::vector<ll>>;
using wGraph = std::vector<std::vector<std::pair<ll,ll>>>;
#define rep(i,n) for (int i=0; i < int(n); i++)

using namespace std;
ll MOD7 = 1000000007;
ll MOD9 = 1000000009;
vector<ll> InputVec(ll N){
    vector<ll> A(N);
    for (int i = 0; i < N; ++i) {
        cin >> A[i];
    }
    return A;
}
void OutputVec(vector<ll> A){
    for (int i = 0; i < A.size(); ++i) {
        cout << A[i] << ",";
    }
    cout << endl;
}
vector<vector<ll>> InputVec2d(ll H,ll W){
    vector<vector<ll>> A(H);
    for (int yi = 0; yi < H; ++yi) {
        A[yi] = vector<ll>(W);
    }
    for (int yi = 0; yi < H; ++yi) {
        for (int xi = 0; xi < W; ++xi) {
            cin >> A[yi][xi];
        }
    }
}

void OutputVec2d(vector<vector<ll>> A){
    for (int yi = 0; yi < A.size(); ++yi) {
        for (int xi = 0; xi < A[yi].size(); ++xi) {
            cout << A[yi][xi] << ",";
        }
        cout << endl;
    }
}

graph InputGraph(ll N,ll M){
    graph G(N);
    for (int i = 0; i < M; ++i) {
        ll a,b;
        cin >> a >> b;
        a--;b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    return G;
}
graph InputDGraph(ll N,ll M){
    graph G(N);
    for (int i = 0; i < M; ++i) {
        ll a,b;
        cin >> a >> b;
        a--;b--;
        G[a].push_back(b);
    }
    return G;
}

void OutputGraph(graph G){
    for (int i = 0; i < G.size(); ++i) {
        cout << i << ":";
        for (int j = 0; j < G[i].size(); ++j) {
            cout << G[i][j]<< ",";
        }
        cout << endl;
    }
}

int main() {
    ll N,K;
    cin >> N >> K;
    auto a = InputVec(N);
    vector<ll> sum(N + 1);
    sum[0] = 0;
    for (int i = 1; i < N + 1; ++i) {
        sum[i] += sum[i - 1] + a[i - 1];
    }
    //sum[i] = i-1までの総和
    ll res = 0;
    for (int i = 40; i >= 0; --i) {
        ll count = 0;
        //cout << (res + (1ll << i)) << endl;
        for (int j = 0; j < N; ++j) {
            //cout << ((res + (1ll << i)) & a[j]) << endl;

        }
        for (int si = 0; si < N; ++si) {
            for (int gi = si + 1; gi < N + 1; ++gi) {
                ll b = sum[gi] - sum[si];
                if(((res + (1ll << i)) & b) == (res + (1ll << i))){
                    count++;
                }
            }
        }
        if(count >= K){
            res += 1ll << i;
        }
    }
    cout << res << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int search(int A[],int n,int key) {
  int i = 0;
  A[n] = key;
  while (A[i] != key) i++;
  return i != n;
}

int main() {
  int i,n,A[10000+1],q,key,sum=0;

  scanf("%d",&n);
  for(i = 0;i < n;i++) scanf("%d",&A[i]);

  scanf("%d",&q);
  for(i = 0;i < q;i++) {
    scanf("%d",&key);
    if(search(A,n,key)) sum++;
  }
  printf("%d\n",sum);

  return 0;

}



Measured memory_bytes: 2108
# 解説を参考に作成
from collections import deque


def solve(K):
    lunlun = deque([i for i in range(1, 10)])

    ans = 0
    for _ in range(K):
        ans = lunlun.popleft()
        x = ans * 10 + ans % 10
        if x % 10 != 0:
            lunlun.append(x - 1)
        lunlun.append(x)
        if x % 10 != 9:
            lunlun.append(x + 1)

    print(ans)


if __name__ == '__main__':
    K = int(input())
    solve(K)


Measured memory_bytes: 18832
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
sufficient = sum(b)
# print(sufficient)
for i in range(n-1):
    if a[i]+1 == a[i+1]:
        # print(i, c[a[i]-1])
        sufficient += c[a[i]-1]
print(sufficient)


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

//#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()
#define dump(o) if(DEBUG){cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) if(DEBUG){cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
using ll = long long; using ull = unsigned long long; using pii = pair<int, int>;
static const int INF = 0x3f3f3f3f; static const long long INFL = 0x3f3f3f3f3f3f3f3fLL;
static const int MOD = 1e9 + 7;
static const bool DEBUG = false;

signed main() {
	ll N; cin >> N;
	ll K; cin >> K;
	ll X; cin >> X;
	ll Y; cin >> Y;
	ll ans = 0;
	ans += min(N, K)*X;
	ans += max(0LL, N - K)*Y;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#define REP(i, n) for(int i=0; i<(int)(n); i++)
using namespace std;
int main(void){
  int n, i, max;
  cin >> n;
  int a[100001] = {}, cnt[100001] = {};
  REP(i, n){
    cin >> a[i];
    cnt[a[i]  ]++;
    cnt[a[i]+1]++;
    cnt[a[i]+2]++;
  }
  max = *max_element(cnt,cnt+100001);
  cout << max << endl;
  return 0;
}

Measured memory_bytes: 1024
#include <cstdio>

int a[200050];
int main()
{
	int n;scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	if(n&1)
	{
		for(int i=n;i>=1;i-=2)
			printf("%d ",a[i]);
		for(int i=2;i<=n;i+=2)
			printf("%d ",a[i]);
	}
	else
	{
		for(int i=n;i>=1;i-=2)
			printf("%d ",a[i]);
		for(int i=1;i<=n;i+=2)
			printf("%d ",a[i]);
	}
}


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

#define all(v) (v).begin(), (v).end()
#define sortv(v) sort(all(v))
#define uniqv(v) (v).erase(unique(all(v)), (v).end())
#define pb push_back
#define FI first
#define SE second
#define lb lower_bound
#define ub upper_bound
#define mp make_pair
#define test 1
#define TEST if(test)

using namespace std;

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

const ll MOD = 1000000007; // 998244353
const int INF = 2e9;
const ll INFLL = 1e18;
const int MAX_N = 10000;
const int MAX_K = 1000000;

int N;
ll arr[MAX_N+1], A[MAX_N+1];

ll multi(ll x, ll y){
	if(y==1)	return x%MOD;
	if(y==0)	return 1;
	ll m = multi(x, y/2);
	if(y%2){
		return ((m*m%MOD)*x)%MOD;
	}
	return m*m%MOD;
}

ll ans=0;
ll M=1;

ll gcd(ll x, ll y){
	return(x==0)?y:gcd(y%x, x);
}

int cnt[MAX_K+1];


int main(){
	scanf("%d", &N);
	for(int i=1; i<=N; i++){
		scanf("%lld", &arr[i]);
		A[i] = arr[i];
		for(ll d=2; d*d<=arr[i]; d++){
			if(arr[i]%d==0){
				int num = 0;
				while(arr[i]%d==0){
					arr[i]/=d;
					num++;
				}
				cnt[d] = max(cnt[d], num);
			}
		}
		if(arr[i]!=1){
			cnt[arr[i]] = max(1, cnt[arr[i]]);
		}
	}
	for(int i=2; i<=MAX_K; i++){
		if(cnt[i]!=0){
			M = (M * multi((ll)i, (ll)cnt[i]))%MOD;
		}
	}
	//cout<<M<<endl;
	for(int i=1; i<=N; i++){
		//cout<<multi(A[i], MOD-2)<<endl;
		//cout<<M*multi(A[i], MOD-2)%MOD<<endl;
		//cout<<ans<<endl;
		ans = (ans + (M * multi(A[i], MOD-2) % MOD)) % MOD;
		//cout<<ans<<endl;
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 2944
#include <bits/stdc++.h>
using namespace std;
#define MAXN 3030
typedef long double ld;

ld pd[MAXN][MAXN];
ld p[MAXN];
int n;

ld solve(int i, int k){
	
	if(2*k > n)  return 0;
	if(i == n+1) return 1;
	if(pd[i][k] != -1) return pd[i][k];
	
	
	return pd[i][k] = solve(i+1, k)*p[i] + solve(i+1,k+1)*(1-p[i]);
}

int main(){
	cin >> n;
	
	int i, j;
	
	for(i = 1; i <= n; i++){
		cin >> p[i];
		for(j = 0; j <= n; j++){
			pd[i][j] = -1;
		}
	}
	
	printf("%.10Lf\n", solve(1,0));

}



Measured memory_bytes: 143744
N = int(input())
A = []
B = []
for i in range(N):
    a,b = map(int,input().split())
    A.append(a)
    B.append(b)
A.reverse()
B.reverse()
ans = 0
for a,b in zip(A,B):
    a += ans
    x = a % b
    if x != 0:
        ans += b - x
print(ans)

Measured memory_bytes: 11048
def good(i, s):
    if i % 2 == 1:
        return s in ["R", "U", "D"]
    else:
        return s in ["L", "U", "D"]


S = input()

if all(good(i, s) for i, s in enumerate(S, 1)):
    print("Yes")
else:
    print("No")


Measured memory_bytes: 2940
#include <algorithm>
#include <cmath>
#include <vector>
#include <functional>
#include <cstdlib>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <ctype.h>
#include <climits>
#include <queue>
#include <iomanip>
using namespace std;
typedef long long ll;
#define REP(i, n) for(ll i = 0; i < (ll)(n); ++i)
#define FOR(i, a, b) for(ll i=(a); i < (ll)(b); ++i)
template<class T> inline bool chmax(T& a, T b) { if(a < b){ a=b; return 1; } return 0;}
template<class T> inline bool chmin(T& a, T b) { if(a > b){ a=b; return 1; } return 0;}

bool rcomp(pair<int,int> l, pair<int,int> r){
	return l.second > r.second;
}

bool bcomp(pair<int,int> l, pair<int,int> r){
	return l.first < r.first;
}


int main(){
	int n;
	cin >> n;
	vector<pair<int,int>> red(n),blue(n);
	REP(i,n) cin >> red[i].first >> red[i].second;
	REP(i,n) cin >> blue[i].first >> blue[i].second;
	
	sort(red.begin(), red.end(), rcomp);
	sort(blue.begin(), blue.end(), bcomp);
	
	int ans = 0;
	vector<int> r(n,0);
	REP(i,n){
		REP(j,n){
			if(r[j]!=0) continue;
			if(red[j].first < blue[i].first && red[j].second < blue[i].second){
				ans++;
				r[j] = 1;
				break;
			}
		}
	}
	
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 3628
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <functional>
#include <ctime>
#include <cmath>
#include <limits>
#include <numeric>
#include <type_traits>
using namespace std;
using ll = long long;

unsigned euclidean_gcd(unsigned a, unsigned b) {
    if (a < b) return euclidean_gcd(b, a);
    unsigned r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}

class UnionFind {
public:
    vector <ll> par;
    vector <ll> siz;
    UnionFind(ll sz_) : par(sz_), siz(sz_, 1LL) {
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    void init(ll sz_) {
        par.resize(sz_);
        siz.assign(sz_, 1LL);
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    ll root(ll x) {
        while (par[x] != x) {
            x = par[x] = par[par[x]];
        }
        return x;
    }
    bool merge(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool issame(ll x, ll y) {
        return root(x) == root(y);
    }

    ll size(ll x) {
        return siz[root(x)];
    }
};

int main() {
    long long a,b;
    cin >> a >> b;
    vector<long long>c(a);
    for (long long i = 0; i < 2 * a-2; i++) {
        long long y;
        cin >> y;
        c.at(y - 1)++;
    }
    long long ans = 1;
    for (long long i = 0; i < a; i++) {
        for (long long j = 0; j < c.at(i) - 1; j++) {
            ans *= b - j - 2;
            ans %= 1000000007;
        }
    }
    ans *= b;
    ans %= 1000000007;
    ans *= b - 1;
    ans %= 1000000007;
    if (a == 1) { cout << b << endl; }
    else cout << ans << endl;
}

Measured memory_bytes: 1024
#include <stdio.h>

#define N 101

typedef struct{
  int u;
  int v[N];
  int k;
}Graph;

int main(){

  int n, i, j, u, l;
  int A[N][N];
  Graph Adj[N];

  scanf("%d", &n);

  for(i=1; i<=n; i++){
    for(j=1; j<=n; j++){
      A[i][j] = 0;
    }
  }
  
  for(i=1; i<=n; i++){
    scanf("%d%d", &Adj[i].u, &Adj[i].k);
    for(j=1; j<=Adj[i].k; j++){
      scanf("%d", &Adj[i].v[j]);
    }
  }

  for(i=1; i<=n; i++){
    for(l=1; l<=Adj[i].k; l++){
      for(j=1; j<=n; j++){
	if(Adj[i].v[l] == j) A[i][j] = 1;
      }
    }
  }

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

  return 0;
}

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

using namespace std;

class union_find {
    vector<int> parent;
    vector<int> rank;

public:
    union_find(int n) {
        parent = vector<int>(n);
        rank = vector<int>(n);

        for (int i = 0; i < n; i++) {
            parent[i] = i;
            rank[i] = 0;
        }
    }

    int root(int a) {
        if (parent[a] != a) {
            parent[a] = this->root(parent[a]);
        }

        return parent[a];
    }

    void unite(int a, int b) {
        int ra = this->root(a);
        int rb = this->root(b);

        if (ra == rb) {
            return;
        }

        if (rank[ra] < rank[rb]) {
            parent[ra] = rb;
        } else {
            parent[rb] = ra;

            if (rank[ra] == rank[rb]) {
                rank[ra]++;
            }
        }
    }
};

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

    vector<int> p(n);
    for (int i = 0; i < n; i++) {
        cin >> p[i];
        p[i]--;
    }

    union_find uf(n);
    for (int i = 0; i < m; i++) {
        int x, y;
        cin >> x >> y;
        uf.unite(x - 1, y - 1);
    }

    int res = 0;
    for (int i = 0; i < n; i++) {
        if (uf.root(i) == uf.root(p[i])) {
            res++;
        }
    }

    cout << res << endl;
}


Measured memory_bytes: 1408
import java.io.*;
 
 
class Main{
  public static void main(String[] args)throws IOException{
     
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String str = br.readLine();
 
    String[] strAry = str.split(" ");
     
    int x = Integer.parseInt(strAry[0]);
    int y = Integer.parseInt(strAry[1]);
 
    System.out.println(x*y +" "+ 2*(x+y));
  }
}

Measured memory_bytes: 24032
#include<iostream>
#include<algorithm>
#include<string>
#include<cmath>
#include<vector>
#include<functional>
#include<stack>

using namespace std;

int main() {
	int n, k, count = 0;
	while (cin >> n >> k) {
		count = 0;
		if (n == 0)break;
		for (int i = 1; i <= n - 2; i++) {
			for (int j = i + 1; j * 2 < k - i; j++) {
				if (k - i - j > 0 && k - i - j <= n)count++;
			}
		}
		cout << count << endl;
	}

	return 0;
}

Measured memory_bytes: 3060
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>

using namespace std;

#define rep(i, n) for (int64_t i = 0; i < (n); i++)
#define irep(i, n) for (int64_t i = 0; i <= (n); i++)
#define rrep(i, n) for (int64_t i = (n)-1; i >= 0; i--)
#define rirep(i, n) for (int64_t i = n; i >= 0; i--)

int main()
{
    string s;
    cin >> s;

    int64_t result = 0;
    int x = 0;
    rep(i, s.size())
    {
        if (s[i] == 'A') {
            if (i > 0 && s[i - 1] == 'B') {
                x = 0;
            }
            x++;
        } else if (s[i] == 'B') {
            if (i > 0 && s[i - 1] == 'B') {
                x = 0;
            }
        } else {
            if (i > 0 && s[i - 1] == 'B') {
                result += x;
            } else {
                x = 0;
            }
        }
    }
    cout << result << endl;
    return 0;
}

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

i=A
length = B-A+1
judge = 0

for _ in range(length):
    if(i%K==0):
        judge = 1
        break

    i += 1
    
if judge==1:
    print("OK")
else:
    print("NG")

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

ll n,k,l,ob1[200005],ob2[200005],br1=1,br2=1;
vector<ll> adj1[200005],adj2[200005];
map<pair<ll,ll>,ll> s;

void dfs1(ll tr)
{
    ob1[tr]=br1;
    for(auto u: adj1[tr])
        if(!ob1[u])
            dfs1(u);
}
void dfs2(ll tr)
{
    ob2[tr]=br2;
    for(auto u: adj2[tr])
        if(!ob2[u])
            dfs2(u);
}

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

    cin>>n>>k>>l;
    for(ll i=0;i<k;i++)
    {
        ll x,y;
        cin>>x>>y;
        adj1[x].push_back(y);
        adj1[y].push_back(x);
    }
    for(ll i=0;i<l;i++)
    {
        ll x,y;
        cin>>x>>y;
        adj2[x].push_back(y);
        adj2[y].push_back(x);
    }

    for(ll i=1;i<=n;i++)
    {
        if(ob1[i]==0)
        {
            dfs1(i);
            br1++;
        }
    }
    for(ll i=1;i<=n;i++)
    {
        if(ob2[i]==0)
        {
            dfs2(i);
            br2++;
        }
    }
    /*
    for(ll i=1;i<=n;i++)
        printf("%lld ",ob1[i]);
    */
    for(ll i=1;i<=n;i++)
        s[{ob1[i],ob2[i]}]++;

    for(ll i=1;i<=n;i++)
        cout<<s[{ob1[i],ob2[i]}]<<" ";
    cout<<endl;

    return 0;
}


Measured memory_bytes: 33252
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int h,w,i,j;
    while(1)
    {
        cin>>h>>w;
        if(h==0&&w==0)
            break;
        for(i=0;i<h;i++)
        {
            for(j=0;j<w;j++)
            {
                printf("#");
            }
            printf("\n");
        }
        printf("\n");
    }
}



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

int main(){
  
  int a,b,c;
  bool answer = false;
  cin >> a >> b;
  
  c = 2*a;
  
  vector<int> vec(a+1);
  for(int i=0;i<a;i++){
    
    c += 2;
  
  if( b == c ){
    
    answer = true;
    
  }
    
  else if( b == 2*a ){
    
    answer = true;
    
  }
    
  }
  
    
  if( answer ){
    
    cout << "Yes" << endl;
    
  }
    
  else{
    
    cout << "No" << endl;
    
  }
    
}

Measured memory_bytes: 3600
let cnt = ref 0
let g = ref []

let print_list l =
  List.iteri (fun i n -> Printf.printf (if i = 0 then "%d" else " %d") n) l;
  print_newline ()

let print_array = Array.iter (fun n -> Printf.printf "%d\n" n)

let insertion_sort a n g =
  let rec insert j v =
    if j < 0 || a.(j) <= v then a.(j + g) <- v
    else (a.(j + g) <- a.(j); incr cnt; insert (j - g) v)
  in
  let rec doit i =
    if i < n then (insert (i - g) a.(i); doit (i + 1))
  in
  doit g

let generate_g n =
  let rec doit i g lst =
    if g > n then lst
    else doit (i + 1) (int_of_float (4.**(float_of_int i) +. 3.*.2.**(float_of_int (i - 1)) +. 1.)) (g :: lst)
  in
  doit 1 1 []

let shell_sort a n =
  cnt := 0;
  g := generate_g n;
  let rec doit = function
    | [] -> ()
    | hd :: tl -> (insertion_sort a n hd; doit tl)
  in
  doit !g

let () =
  let n = read_int () in
  let a = Array.make n 0 in
  let rec doit i =
    if i < n then (a.(i) <- read_int (); doit (i + 1))
  in
  doit 0;
  shell_sort a n;
  Printf.printf "%d\n" (List.length !g);
  print_list !g;
  Printf.printf "%d\n" !cnt;
  print_array a

Measured memory_bytes: 12656
using namespace std;
#include<iostream>
#include<vector>
int N,M;
const int DIM=100010;
long X[DIM]; 
int ans=1;
const int base=1000000007; 


int FIB(int i){
    if (X[i] != 0) {return X[i];}
    X[i] = FIB(i-2);
    X[i] = (X[i] + FIB(i-1))% base; 
    return X[i]; 
}


int main(){
    int a,i,j,k,x,y,z;
    int c = 0; 
    long s; 

    cin >> N >> M; 
    // cout << N << " " << M << "\n"; 
    for(i=0;i<DIM;i++){X[i]=0;}
    X[0]=0;
    X[1]=1; 
    X[2]=1;
    for(i=0;i<M;i++){
        cin >> a; 
        if (c == a || a >= N){ 
            cout << 0 << endl; // Exit. Serial skip 
            exit(0);
        }
        s = FIB(a-c);
        ans=(int)(((long)ans * (long)s ) % (long) base);
        // cout << a << " " << s << " " << ans << endl;
        c = a + 1;
    }
    s = FIB(N-c+1);
    ans=(int)(((long)ans * (long)s ) % (long) base);
    // cout << M << " " << s << " " << ans << endl;
    cout << ans  << endl; // Exit. Serial skip 

}

Measured memory_bytes: 2560
/*************************************************\
                 MD.Faysal Hasan
                Comilla Univesity
\*************************************************/

#include<bits/stdc++.h>
using namespace std;

#define         ikarus_101     ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

#define         scl(x)         scanf("%lld",&x)
#define         scll(x,y)      scanf("%lld%lld",&x,&y)
#define         sclll(x,y,z)   scanf("%lld%lld%lld",&x,&y,&z)
#define         scc(x)         scanf("%c",&x)
#define         scs(x)         scanf("%s",&x)
#define         pfl(x)         printf("%lld\n",x)
#define         pfll(x,y)      printf("%lld %lld\n",x,y)
#define         pyes           puts("Yes")
#define         pno            puts("No")
#define         nel            printf("\n")
#define         spc            ' '
#define         nn             '\n'

#define         vcl            vector<ll>
#define         mpl            map<ll,ll>
#define         vpl            vector<pair<ll,ll>>
#define         pb             push_back
#define         mkp(x,y)       make_pair(x,y)
#define         F              first
#define         S              second
#define         vin(a)         for(auto &it : a) cin>>it
#define         vout(a)        for(auto it : a) cout<<it<<spc;cout<<nn
#define         yes            cout<<"YES"<<"\n"
#define         no             cout<<"NO"<<"\n"
#define         all(a)         a.begin(),a.end()
#define         sajo(str)      sort(str.begin(),str.end())
#define         rev(str)       reverse(str.begin(),str.end())
#define         usajo(str)     sort(str.rbegin(),str.rend())

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

#define         pi             2*acos(0.0)
#define         gcd(a,b)       __gcd(a,b)
#define         lcm(a,b)       (a/gcd(a,b))*b
#define         mem(a,b)       memset(a,b,sizeof (a))
#define         dec(x)         cout<<fixed<<setprecision(x)
#define         min3(a,b,c)    min(a,min(b,c))
#define         max3(a,b,c)    max(a,max(b,c))
#define         LIM            100005

typedef     unsigned long long      ull;
typedef     long long               ll;
typedef     long double             ld;

const   ll  N   =   2e5+7;
const   ll  M   =   1e9+7;
const   ll  lmx =   92233720368547758;

ll aa[1000];
int main() {ikarus_101

      ll n,m,a,b,c,d,x,y,i,j,k;

      scll(x,n);
      rep(i,n)
      {
          scl(k);
          aa[k]++;
      }
      if(aa[x] == 0) return pfl(x),0;
      for(i=1;i<=200;i++)
      {
            if(aa[x-i] == 0) return pfl(x-i),0;
            if(aa[x+i] == 0) return pfl(x+i),0;
      }

      return 0;
}



Measured memory_bytes: 3836
n = int(input())
s = [input() for i in range(n)]
m = int(input())
t = [input() for i in range(m)]

ans = 0

for i in set(s):
    a = sum(k == i for k in s) - sum(k == i for k in t)
    ans = max(a,ans)
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(), x.end()
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
using namespace std;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const ll inf = 1e9;
const int MAX_N = 500;

int main() {
    int d, g; cin >> d >> g;
    int ans;
    if (g == 100) ans = 101*pow(100,d);
    else ans = g*pow(100,d);
    printf("%7d\n",ans);
}

Measured memory_bytes: 256
N=int(input())
M=['',[],[],'']

for i in range(N):
    m=str(input())
    if m[0]!='B' and m[-1:]!='A':
        M[0]+=m
    elif m[0]!='B' and m[-1:]=='A':
        M[1].append(m)
    elif m[0]=='B' and m[-1:]!='A':
        M[2].append(m)
    else:
        M[3]+=m

if not M[1] and not M[2]:
    M[0]+=M[3]
elif not not M[1] and not M[2]:
    M[0]+=''.join(M[1])+M[3]
elif not M[1] and not not M[2]:
    M[0]+=M[3]+''.join(M[2])
else:
    M[0]+=M[1][0]+M[3]+M[2][0]
    M[1].pop(0)
    M[2].pop(0)
    for i in range(min(len(M[1]),len(M[2]))):
        M[0]+=M[1][i]+M[2][i]
    del M[1][0:i+1]
    del M[2][0:i+1]
    M[0]+=''.join(M[1])+''.join(M[2])
print(M[0].count('AB'))


Measured memory_bytes: 3828
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define sqr(x) ((x)*(x))
#define mp make_pair
#define int long long
#define PI pair<int,int>
inline char gc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
inline int read(){
    int x = 0; char ch = gc(); bool positive = 1;
    for (; !isdigit(ch); ch = gc())	if (ch == '-')	positive = 0;
    for (; isdigit(ch); ch = gc())	x = x * 10 + ch - '0';
    return positive ? x : -x;
}
inline void write(int a){
    if(a>=10)write(a/10);
    putchar('0'+a%10);
}
inline void writeln(int a){
    if(a<0){
    	a=-a; putchar('-');
    }
    write(a); puts("");
}
int n,m;
signed main(){
	n=read(); m=read();
	if(n>m)swap(n,m);
	if(n==1){
		cout<<(m==1?1:m-2)<<endl;
	}else{
		cout<<(n-2)*(m-2)<<endl;
	}
}

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

int main() {
    int n, q;
    std::cin >> n >> q;
    std::vector<bool> visited(n);
    std::vector<std::vector<int>> to(n, std::vector<int>(0));

    for (int i = 0; i < n - 1; i++) {
        int a, b;
        std::cin >> a >> b;
        a--;
        b--;
        to[a].push_back(b);
        to[b].push_back(a);
    }

    std::vector<int> ans(n);
    for (int i = 0; i < q; i++) {
        int p, x;
        std::cin >> p >> x;
        p--;
        ans[p] += x;
    }
    
    // ラムダ式で再帰ってどうやるんだっけ
    auto dfs = [&](auto&& dfs_, int pos) -> void {
        visited[pos] = true;
        for (int next: to[pos]) {
            if (visited[next] == false) {
                ans[next] += ans[pos];
                dfs_(dfs_, next);
            }
        }
    };
    dfs(dfs, 0);

    for (int i = 0; i < n; i++) {
        if (i > 0) {
            std::cout << " ";
        }
        std::cout << ans[i];
    }
    std::cout << std::endl;

    return 0;
}


Measured memory_bytes: 19712
import math
import itertools
import heapq
from sys import stdin, stdout, setrecursionlimit
from bisect import bisect, bisect_left, bisect_right
from collections import defaultdict, deque


# d = defaultdict(lambda: 0)
# setrecursionlimit(10**7)
# inf = float("inf")


##### stdin ####
def LM(t, r): return list(map(t, r))
def R(): return stdin.readline()
def RS(): return R().split()
def I(): return int(R())
def F(): return float(R())
def LI(): return LM(int,RS())
def LF(): return LM(float,RS())
def ONE_SL(): return list(input())
def ONE_IL(): return LM(int, ONE_SL())
def ALL_I(): return map(int, stdin)
def ALL_IL(): return LM(int,stdin)

##### tools #####
def ap(f): return f.append
def pll(li): print('\n'.join(LM(str,li)))
def pljoin(li, s): print(s.join(li))

##### main #####



def main():
	n,a,b = LI()
	ans = 0
	for i in range(1,n+1):
		s = sum([int(k) for k in str(i)])
		if a<=s<=b:
			ans += i
	print(ans)

	
if __name__ == '__main__':
	main()

Measured memory_bytes: 3444
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int n = 100;
		char[][] field = new char[n][n];
		for (int i = 0; i < n / 2; i++) {
		    Arrays.fill(field[i], '#');
		}
		for (int i = n / 2; i < n; i++) {
		    Arrays.fill(field[i], '.');
		}
		int wCount = 1;
		for (int i = 0; i < n / 2 && wCount < a; i += 2) {
		    for (int j = 0; j < n && wCount < a; j += 2) {
		        field[i][j] = '.';
		        wCount++;
		    }
		}
		int bCount = 1;
		for (int i = n - 1; i >= n / 2 && bCount < b; i -= 2) {
		    for (int j = 0; j < n && bCount < b; j += 2) {
		        field[i][j] = '#';
		        bCount++;
		    }
		}
		StringBuilder sb = new StringBuilder();
		sb.append("100 100\n");
		for (int i = 0; i < n; i++) {
		    sb.append(field[i]).append("\n");
		}
	    System.out.print(sb);
   }
}




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

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned __int128 HASH;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pullull;
typedef pair<ll,int> plli;
typedef pair<double, int> pdbi;
typedef pair<int,pii> pipii;
typedef pair<ll,pll> plpll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<pii> vpii;
typedef vector<vector<int>> mat;

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n);i>0;i--)
#define rrep2(i,a,b) for (int i=(a);i>b;i--)
#define pb push_back
#define fi first
#define se second
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()

const ll hmod1 = 999999937;
const ll hmod2 = 1000000000 + 9;
const int INF = 1<<30;
const ll mod = 1000000000 + 7;
const int dx4[4] = {1, 0, -1, 0};
const int dy4[4] = {0, 1, 0, -1};
const int dx8[8] = {1, 1, 1, 0, 0, -1, -1, -1};
const int dy8[8] = {0, 1, -1, 1, -1, 0, 1, -1};
const double pi = 3.141592653589793;

#define addm(X, Y) (X) = ((X) + ((Y) % mod) + mod) % mod

int N;

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N;
    rep2(h, 1, 3501) {
        rep2(n, 1, 3501) {
            if ((4 * h * n - N * n - N * h)  == 0) continue;
            if ((N * h * n) % (4 * h * n - N * n - N * h) == 0 && (N * h * n) / (4 * h * n - N * n - N * h) > 0) {
                int w = (N * h * n) / (4 * h * n - N * n - N * h);
                cout << h << " " << n << " " << w << endl;
                return 0;
            }
        }
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define ll long long
#define ld long double
#define all(a) (a).begin(),(a).end()
#define mk make_pair
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;
ll MOD=1000000007;
int main(){
  ll n,d;
  cin>>n>>d;
  ll count=0;
  rep(i,n){
    ll x,y;
    cin>>x>>y;
    if(x*x+y*y<=d*d) count++;
  }
  cout<<count;
return 0;
}

Measured memory_bytes: 3612
def main():
    N = int(input())
    a = sorted([int(x) for x in input().split(" ")], reverse=True)
    Alice = sum([x for i, x in enumerate(a) if i % 2 == 0])
    Bob = sum([x for i, x in enumerate(a) if i % 2 == 1])
    print(Alice-Bob)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9132
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int k = in.nextInt();
		String s = in.next();
		List<Integer> list = new ArrayList<>();
		char c = s.charAt(0);
		if(c=='0') list.add(0);
		int num = 0;
		for(int i=0;i<s.length();i++) {
			if(s.charAt(i)!=c) {
				list.add(num);
				c = s.charAt(i);
				num = 1;
			}else num++;
		}
		list.add(num);
		if(c=='0') list.add(0);
		
		if(2*k+1>=list.size()) {
			System.out.println(n);
		}else {
			int tmp = 0;
			int ans = 0;
			int i = 0;
			for(;i<2*k+1;i++) {
				tmp += list.get(i);
			}
			ans = tmp;
			for(;i<list.size();i+=2) {
				tmp = tmp + list.get(i) + list.get(i+1) - list.get(i-2*k-1) - list.get(i-2*k);
				ans = Math.max(ans, tmp);
			}
			System.out.println(ans);
		}
		in.close();
		
	}

}


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

int main(){
    int x[5];
    rep(i,5) cin >> x[i];

    rep(i,5){
        if(x[i]==0){
            cout << i+1 << endl;
            return 0;
        }
    }

    return 0;
}

Measured memory_bytes: 3644
// Template
#include <bits/stdc++.h>
#define rep_override(x, y, z, name, ...) name
#define rep2(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep3(i, l, r) for (int i = (int)(l); i < (int)(r); ++i)
#define rep(...) rep_override(__VA_ARGS__, rep3, rep2)(__VA_ARGS__)
#define per(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
constexpr int inf = 1001001001;
constexpr ll INF = 3003003003003003003;
template <typename T> inline bool chmin(T& x, const T& y) {if (x > y) {x = y; return 1;} return 0;}
template <typename T> inline bool chmax(T& x, const T& y) {if (x < y) {x = y; return 1;} return 0;}
struct IOSET {IOSET() {cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10);}} ioset;

// Mod-Int
constexpr int MOD = 998244353;
struct ModInt {
    ll val;
    ModInt() = default;
    ModInt(ll x) : val(x % MOD + (x < 0 ? MOD : 0)) {}
    ModInt &operator+= (const ModInt &x) {if ((val += x.val) >= MOD) val -= MOD; return *this;}
    ModInt &operator-= (const ModInt &x) {if ((val -= x.val) < 0) val += MOD; return *this;}
    ModInt &operator*= (const ModInt &x) {(val *= x.val) %= MOD; return *this;}
    ModInt operator+ (const ModInt &x) const {return ModInt(*this) += x;}
    ModInt operator- (const ModInt &x) const {return ModInt(*this) -= x;}
    ModInt operator* (const ModInt &x) const {return ModInt(*this) *= x;}
    ModInt pow(ll t) const {
        if (!t) return ModInt(1);
        ModInt m = pow(t / 2);
        m *= m;
        if (t & 1) m *= *this;
        return m;
    }
    ModInt inv() const {return pow(MOD - 2);}
    ModInt &operator/= (const ModInt &x) {return *this *= x.inv();}
    ModInt operator/ (const ModInt &x) const {return ModInt(*this) /= x;}
    friend istream &operator>> (istream &is, ModInt &x) {is >> x.val; return is;}
    friend ostream &operator<< (ostream &os, const ModInt &x) {os << x.val; return os;}
};

int main() {
    int n, s;
    cin >> n >> s;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    
    vector<ModInt> now(s + 1, ModInt(0));
    ModInt ans(0);
    rep(i, n) {
        now[0] += ModInt(1);
        vector<ModInt> vec(s + 1, ModInt(0));
        rep(j, s + 1) {
            vec[j] += now[j];
            if (j + a[i] <= s) vec[j + a[i]] += now[j];
        }
        rep(j, s + 1) now[j] = vec[j];
        ans += now[s];
    }
    
    cout << ans << "\n";
}


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

typedef long long ll;

int main() {
	ll n, z, w; cin >> n >> z >> w;
	vector<ll>a(n); for (auto&& x : a)cin >> x;
	ll ans = 0;
	if (n == 1) {
		ans = abs(a[0] - w);
	}
	else {
		ans = max(abs(a[n - 1] - w), abs(a[n - 2] - a[n - 1]));
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  string s; cin >> s;
  cout << (count(begin(s), end(s), 'x') < 8 ? "YES" : "NO") << '\n';
}

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

int main() {
	u32 K;
	cin >> K;
	
	u32 A[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51}; 
	cout << A[K-1];
	return 0;
}

Measured memory_bytes: 256
use std::io::stdin;

fn main(){
    let mut input = String::new();
    stdin().read_line(&mut input).unwrap();
    let mut x :Vec<i32> = input.trim().split_whitespace().map(|x| x.parse().ok().unwrap()).collect();
    x.sort();
    println!("{}",x[0] + x[1]);
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> pii;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pb push_back
#define fastIO ios_base::sync_with_stdio(false); cin.tie(nullptr);
#define endl '\n'
#define deb(x) cout << #x << " "<< x << endl;
#define fo(i, n) for(int i=0; i<n; i++)
#define Fo(i, k, n) for(int i=k; i<n; i++)
#define all(x) x.begin(),x.end()
#define int long long

/* 
ll exp(ll x,ll n)
{
    ll result=1;
    while(n>0)
    {
        if(n % 2 ==1)
            result=result * x;
        x=x*x;
        n=n/2;
    }
    return result;
}



int nCrModPFermat(int n, int r, int p)
{
   if (r==0)
      return 1;
    int fac[n+1];
    fac[0] = 1;
    for (int i=1 ; i<=n; i++)
        fac[i] = fac[i-1]*i%p;
 
    return (fac[n]* modInverse(fac[r], p) % p *
            modInverse(fac[n-r], p) % p) % p;
}
*/
/*struct greaterr
{
    template<class T>
    bool operator()(T const &a, T const &b) const { return a > b; }
};
 
*/
 
/*vector<bool> sieve(100007,true);
 
void help(){
     sieve[0] = false;
     sieve[1] = false;
 
     for(int i=2;i*i<100007;++i){
        if(sieve[i]){
            for(int j=i*i;j<100007;j+=i)
                sieve[j] = false;
 
        }
     }
 
}*/
/*
ll expo(ll a,ll b){ll r=1;a=a%mod;while(b){if(b%2)r=(r*a)%mod;a=(a*a)%mod;b=b/2;}
return r;}
 
 
 */
 int n,s;
 const int mod = 1000000007;
  const int N = 200009;
  int arr[N];
  int sum ; 
  bool check(int mid)
  {
      
     int v[n];
     

      fo(i,n)
        v[i] = arr[i] + (i+1)*mid; 

      sort(v,v+n);
     int sum = 0;
      for(int i=0;i<mid;++i)
        sum+= v[i];
      
     return sum>s;
  }
  
  

    int32_t main() {
     fastIO
     
      int a,b;
      cin>>a>>b;

      if(b==1)
      {
        cout<<"0";
        return 0;
      }
       int ct = 1;
    int ct1 = 0;
       for(int i=1;i<500000;++i)
       {
          ct+=a-1;
          ct1++;
          if(ct>=b)
            break;
       } 
       cout<<ct1<<endl;
    
     return 0;
      }
// always test the corner cases ALWAYS;

Measured memory_bytes: 256
M, D = [int(x) for x in input().split()]
ret = 0
for m in range(1, M+1):
  for d10 in range(2, 10):
    for d1 in range(2, 10):
      d = 10 * d10 + d1
      if d > D:
        break
      if d1 * d10 == m:
        ret += 1
    if d10 > D:
      break
print(ret)

Measured memory_bytes: 3060
n = gets.strip.to_i
s = gets.strip.split('')

# 数字を入れる配列を用意する
r = []
l = []
r_c = (1..n+1).map{|i| i = 0 }
l_c = (1..n+1).map{|i| i = 0 }

# 数字と累積和の配列を生成
(1..n).each do |i|
  if s[i-1] == "E"
    r[i-1] = 1
    l[i-1] = 0
  else
    r[i-1] = 0
    l[i-1] = 1
  end
  r_c[i] = r_c[i-1] + r[i-1]
  l_c[i] = l_c[i-1] + l[i-1]
end

# 最小の回数を計算する
min = n
(1..n).each do |i|
  count = ( l_c[i] - l_c[0] ) + ( r_c[n] - r_c[i-1] ) - 1
  min = count if count < min
end
puts min 

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

using namespace std;
using ll = long long;

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

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

  ll x, y;
  for (ll i = 1; i * i <= n; ++i) {
    if (n % i == 0) {
      x = i;
      y = n / i;
    }
  }

  cout << x + y - 2 << endl;
  return 0;
}


Measured memory_bytes: 256
import math

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

def bunbo(N):
    return 1/N

def n_calc(n, K):
    A = math.log10(K/n)/math.log10(2)
    A = A + 0.9999999999
    A = int(A)
    return A

def calc(N, K):
    result = 0
    const = 1/N
    for i in range(1, N+1):
      c = n_calc(i, K)
      if c < 0:
        c = 0
      result += (const * ((1/2)**c))
    return result
  
print(calc(N, K))



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

using namespace std;
const int maxn = 3005;
const int MOD = 1e9 + 7;
int dp[maxn][maxn];
int pref[maxn];
string s;
int n;
int main()
{
    ios_base::sync_with_stdio(false);
    cin >> n >> s;
    dp[1][1] = 1;
    for(int at = 2; at <= n; at ++){
        int sum = 0;
        for(int last = 1; last <= at; last ++){
            sum += dp[at - 1][last];
            sum %= MOD;
            pref[last] = sum;
        }
        for(int last = 1; last <= at; last ++){
            int L, R;
            if(s[at - 2] == '<'){
                L = 1;
                R = last - 1;
            }
            else{
                L = last;
                R = at - 1;
            }
            if(L <= R){
                dp[at][last] += ((pref[R] - pref[L - 1]) + MOD) % MOD;

            }
        }
    }
    int ret = 0;
    for(int i = 1; i <= n; i ++){
        ret += dp[n][i];
        ret %= MOD;
    }
    cout << ret << endl;
    return 0;
}


Measured memory_bytes: 34176
N, W = map(int, input().split())
w_v = [list(map(int, input().split())) for i in range(N)]

memo = {}

def  nap(i, j):
    if i == N:
        return 0

    if (i, j) in memo:
        return memo[i, j]
    elif w_v[i][0] > j:
        temp = nap(i+1, j)
    else:
        temp = max(nap(i+1, j), nap(i+1, j-w_v[i][0]) + w_v[i][1])
    memo[i, j] = temp

    return memo[i, j]

print(nap(0, W))

Measured memory_bytes: 20684
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort(ALL(x))
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
const int INF = 1001001001;
const ll LINF = 100100100100100100;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;

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

	vector<ll> A;
	rep(i,n){
		ll a; cin >> a;
		A.PB(a);
	}
	ll ans = A[0];
	reps(i,n-1){
		ans ^= A[i];
	}
	// cout << ans << endl;
	if(ans==0){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}


	return 0;
}


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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
//const ull mod = 1e9 + 7;
const ll mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

// debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

// conversion number to bit
string num2bit(ll num, ll len){
  string bit = "";
  REP(i, len){
    bit += char('0'+(num>>i & 1));
  }
  return bit;
}

ll G[10][10] = {};
ll N, M;

int solve(vector<ll> &perm){
	if(perm[0] != 0) return 0;
	bool ok = true;
	REP(i, N-1){
		if(G[perm[i]][perm[i+1]]!=1) ok = false;
	}
	return (ok ? 1 : 0);
}

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

    cin >> N >> M;

    REP(i, M){
	    ll a, b;
	    cin >> a >> b;
	    a--, b--;
	    G[a][b] = 1;
	    G[b][a] = 1;
	}

    vector<ll> perm(N);
    REP(i, N) perm[i] = i;
	bool flag = true;
	ll res = 0;
	while(flag){
		//vprint(perm2);
		res += solve(perm);
		flag = next_permutation(perm.begin(), perm.end());
	}
	cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define LINF (ll)INF*INF
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef vector<pii> vp;

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

signed main(void) {
    string s;
    cin >> s;
    vi a(26);
    rep(i,s.size())a[s[i]-'a']++;
    int ans = 0;
    rep(i,26)ans += a[i]%2;
    if(ans > 0)ans--;
    cout << (ans+1)/2 << endl;
}



Measured memory_bytes: 3208
n = int(input())
mod = 1000000007
a = list(map(int,input().split()))
a.sort()
if n %2 ==1:
  if a[0] != 0:
    print(0)
    exit()
  for i in range(1,n//2+1):
    if a[2*i] != 2*i or a[2*i-1] != 2*i:
      print(0)
      exit()
  print(pow(2,n//2,mod))
else:
  for i in range(n//2):
    if a[2*i] != 2*i+1 or a[2*i+1] != 2*i+1:
      print(0)
      exit()
  print(pow(2,n//2,mod))

Measured memory_bytes: 14008
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define rrep(i,n) for(ll i##_len=(n) ,i=i##_len-1;i>=0;--i)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define fe(vec,lambda) std::for_each(vec.begin(), vec.end(), lambda );
#define printd(val) std::cout<< #val" = " <<val<<"\n";
#define printv(val) std::for_each(val.begin(),val.end(),[](auto x){cout<<x<<"\n";});
#define lim 1000000007ll
#include<bits/stdc++.h>
using ll = long long;
using pii = std::pair<ll,ll>;
using namespace std;
template<class T>T chmin(T& a,T b){if(a>b){a^=b;b^=a;a^=b;return 1;}return 0;}
template<class T>T chmax(T& b,T a){if(a>b){a^=b;b^=a;a^=b;return 1;}return 0;}
template <class T> T gcd(T a, T b){if (a < b) {a ^= b;b ^= a;a ^= b;} return b ? gcd(b, a % b) : a;}
template <class T> T lcm(T a, T b){return a * b / gcd(a, b);}
inline bool operator<(const pii &lhs,const pii &rhs){return(lhs.second<rhs.second);}
template<class T> vector<pair<T,T>> duplicator(const vector<T>& input){vector<pair<T,T>> out(input.size()-1);rep(i,input.size()-1){out[i].first =input[i  ];out[i].second=input[i+1];}return(out);}
vector<char> String_to_vector_char(const string& input){vector<char> out(input.size());rep(i,input.size()){out[i]=input[i];}return out;}


ll a,b,c;
vector<ll>v;
map<ll,ll>m;
string s,s2;
void input(){
    cin>>s;
}
void src(){
    replace(s.begin(),s.end(),',',' ');
    cout<<s;
}

int main(int argc,char* argv[]){
    ios::sync_with_stdio(false);
    //ifstream in( argv[1] ); cin.rdbuf(in.rdbuf());
    input();
    src();    
    return 0;
}

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

using namespace std;

int main(){
    int N;
    while(cin >> N){
        vector<int> a(N);
        for(auto& t : a) cin >> t;
        int mIdx = distance(a.begin(), min_element(a.begin(), a.end()));
        int MIdx = distance(a.begin(), max_element(a.begin(), a.end()));
        vector<pair<int,int>> res;
        if(-a[mIdx] < a[MIdx]){
            res.emplace_back(MIdx+1, 1);
            for(int i=1;i+1<=N;i++) res.emplace_back(i, i+1);
        } else {
            res.emplace_back(mIdx+1, N);
            for(int i=N;i-1>=1;i--) res.emplace_back(i, i-1);
        }
        cout << 2*res.size() << endl;
        for(auto& p : res){
            for(int i=0;i<2;i++) cout << p.first << " " << p.second << endl;
        }
    }
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

long long table[10000001];

int main() {
	int n; cin >> n;
    for (int i = 2; i <= n; ++i)
        for (int j = i + i; j <= n; j += i) ++table[j];
    long long ans = 1;
    for (int i = 2; i <= n; ++i) ans += i * (table[i] + 2);
    cout << ans << endl;

	return 0;
}

Measured memory_bytes: 81748