akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <cstring>

int main() {
    int n;
    int a[3][3];
    int b[3][3];
    int i,j,k;
    for(i = 0; i < 3; i++){
        for (j = 0; j < 3; j++){
            scanf("%d", &a[i][j]);
        }
    }
    memset(b, 0, sizeof(b));

    scanf("%d", &n);

    for(i = 0; i < n; i++) {
        int t;
        scanf("%d", &t);
        for(j = 0; j < 3; j++) {
            for(k = 0; k < 3; k++){
                if(t == a[j][k]) {
                    b[j][k] = 1;
                }
            }
        }
    }

    int flag = 0;
    for(j = 0; j < 3; j++) {
        if(b[j][0] == b[j][1] && b[j][1] == b[j][2] && b[j][0] == 1) {
            flag = 1;
        }
    }

    for(j = 0; j < 3; j++) {
        if(b[0][j] == b[1][j] && b[1][j] == b[2][j] && b[2][j] == 1) {
            flag = 1;
        }
    }

    if(b[0][0] == b[1][1] && b[1][1] == b[2][2] && b[2][2] == 1) flag = 1;
    if(b[0][2] == b[1][1] && b[1][1] == b[2][0] && b[2][0] == 1) flag = 1;

    if(flag == 1) printf("Yes");
    else printf("No");
    return 0;
}

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


int main(){
  int n, sum = 0;
  cin >> n;
  
  int d[n];
  rep(i,n) cin >> d[i];
  
  rep(i,n){
    for(int j = i+1; j < n; j++){
      sum += d[i]*d[j];
    }
  }
  cout << sum << endl;
  }

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

using namespace std;
using ll = long long;

#define let auto
#define conr auto const&

int const N = 200 * 1000 + 16;
int const M = 1000 * 1000 * 1000 + 7;

int n, m;

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

  cin >> n;
  deque<int> a;
  for(int i = 0; i < n; ++i) {
    int x;
    cin >> x;
    if(i&1)
      a.emplace_front(x);
    else
      a.emplace_back(x);
  }

  if(n&1)
    reverse(a.begin(), a.end());

  for(int x : a)
    cout << x << " ";
  cout << flush;
}

Measured memory_bytes: 3072
/*
START BY THE NAME OF ALMIGHTY ALLAH
THIS WONT BE ACCEPTED
STOP_GIVING_UP

██╗███████╗████████╗██╗ █████╗ ██╗  ██╗
██║██╔════╝╚══██╔══╝██║██╔══██╗██║ ██╔╝
██║███████╗   ██║   ██║███████║█████╔╝
██║╚════██║   ██║   ██║██╔══██║██╔═██╗
██║███████║   ██║   ██║██║  ██║██║  ██╗
╚═╝╚══════╝   ╚═╝   ╚═╝╚═╝  ╚═╝╚═╝  ╚═╝

*/
#include<bits/stdc++.h>
#define l(i,a,n)for(int i=a;i<n;i++)
#define pb push_back
#define in insert
#define mp make_pair
#define lw(v) sort(v.begin(),v.end());
#define hi(v) sort(v.begin(),v.end(),greater<long long>());
#define all(v) v.begin(),v.end()
#define filein freopen ("input.txt", "r", stdin)
#define fileout freopen ("output.txt", "w", stdout)
using namespace std;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    long long t,r=1,r1=0,r2=0,k=0,a,b,c=1,m,d=0,n,e,f,x=0,g,p=0,q=0,y=0,z=0;
    vector<long long>v;
    vector<long long>u;
    set<char>s;
    std::vector<int>::iterator it;
    string  s1,s2,s3,s4;
   cin>>n>>m;

cout<<(n*m)/__gcd(m,n)<<endl;

}


Measured memory_bytes: 3568
#include <bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
#define base 31
#define MOD 1e9+7
#define FOR(i, a, b) for(int i = a; i <= b; i++)
#define FORs(i, a, b) for(int i = a; i >= b; i--)
#define REP(i, a, b) for(int i = a; i < b; i++)
#define __FOR(i, a, b, k) for(int i = a; i <= b; i+= k)
#define __REP(i, a, b, k) for(int i = a; i < b; i+= k)
#define pb push_back
#define _io ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
using namespace std;
typedef pair <int, int> ii;
typedef vector <ii> vii;
#define fi first
#define se second
#define mp make_pair
#define N  200
int t, n,x;

int main(){
    _io;

    cin>>n>>x>>t;
    if ((int(n/x))*x<n) cout<<((n/x)+1)*t; else cout<<n/x*t;
}



Measured memory_bytes: 3684
m, d = gets.split.map(&:to_i)
ans = 0

for cntm in 1 .. m
  for cntd in 22 .. d
    if cntd >= 22 && cntd % 10 >= 2
      d1  = cntd % 10
      d10 = cntd / 10
      if d1 * d10 == cntm
        ans += 1
      end
    end
  end
end

puts ans


Measured memory_bytes: 1788
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);
		int A = scan.nextInt();
		int B = scan.nextInt();
		int ans = 0;
		
		if(A > B) {
			ans = A + (A - 1);
		}else if(B > A) {
			ans = B + (B - 1);
		}else {
			ans = A + B;
		}
		
		System.out.println(ans);
	}
}

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

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

    if(s=="hi"||s=="hihi"||s=="hihihi"||s=="hihihihi"||s=="hihihihihi"){
        cout<<"Yes"<<endl;

  


}
    else{cout<<"No"<<endl;}
}




Measured memory_bytes: 256
#
# abc082 b
#
import unittest
from io import StringIO
import sys


def input():
    return sys.stdin.readline().rstrip()


def resolve():
    s = list(input())
    t = list(input())

    flag = False
    s = sorted(s)
    t = sorted(t, reverse=True)

    if s < t:
        print("Yes")
    else:
        print("No")


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """yx
axy"""
        output = """Yes"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """ratcode
atlas"""
        output = """Yes"""
        self.assertIO(input, output)

    def test_入力例_3(self):
        input = """cd
abc"""
        output = """No"""
        self.assertIO(input, output)

    def test_入力例_4(self):
        input = """w
ww"""
        output = """Yes"""
        self.assertIO(input, output)

    def test_入力例_5(self):
        input = """zzz
zzz"""
        output = """No"""
        self.assertIO(input, output)


if __name__ == "__main__":
    # unittest.main()
    resolve()


Measured memory_bytes: 6244
#include<stdio.h>
#include<math.h>
#define N 10000
int isPrime(int);
main(){
  int a[N],n,x,i,count=0;
  
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&a[i]);
  }
  
  for(i=0;i<n;i++){
    x = isPrime(a[i]);
      if(x==1)
	count++;
  }
  printf("%d\n",count);
  
  return 0;
}
int isPrime( int x ){
  int i=3;
  if(x==2)
    return 1;
  if(x<2 || x%2==0)
    return 0;
  while(i*i<=x){
    if(x%i==0){
      return 0;
    }
    i=i+2;
  }
  return 1;
}

Measured memory_bytes: 632
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
typedef long double ld;

using namespace std;

const int N = 105;

struct Pt {
  ld x, y, ang;
  Pt(ld _x=0, ld _y=0): x(_x), y(_y), ang(atan2(_y, _x)){
    if(ang < 0) ang += 2 * M_PI;
  };
  Pt operator+(const Pt &a) const {
    return Pt(x+a.x, y+a.y);
  }
  Pt operator-(const Pt &a) const {
    return Pt(x-a.x, y-a.y);
  }
  Pt operator*(const ld &a) const {
    return Pt(x*a, y*a);
  }
  Pt operator/(const ld &a) const {
    return Pt(x/a, y/a);
  }
  ld operator*(const Pt &a) const {
    return x*a.x + y*a.y;
  }
  ld operator^(const Pt &a) const {
    return x*a.y - y*a.x;
  }
  bool operator<(const Pt& ret) const {
    return ang < ret.ang;
  }
};
ld norm2(const Pt &a) {
  return a*a;
}
ld norm(const Pt &a) {
  return sqrt(norm2(a));
}

int n;
Pt dp[N];
vector<Pt> v;

void init() {
  cin >> n;
  for(int i = 0 ; i < n ; ++i) {
    ld x, y; cin >> x >> y;
    v.push_back(Pt(x, y));
  }
}
void solve() {
  sort(v.begin(), v.end());
  dp[0] = {0, 0};
  Pt ans = {0, 0};
  for(int i = 1 ; i <= n ; ++i) {
    dp[i] = {0, 0};
    for(int j = 0 ; j < i ; ++j) {
      Pt x = dp[j] + v[i - 1];
      if(norm(x) > norm(dp[i])) dp[i] = x;
    }
    if(norm(dp[i]) > norm(ans)) ans = dp[i];
  }
  reverse(v.begin(), v.end());
  for(int i = 1 ; i <= n ; ++i) {
    dp[i] = {0, 0};
    for(int j = 0 ; j < i ; ++j) {
      Pt x = dp[j] + v[i - 1];
      if(norm(x) > norm(dp[i])) dp[i] = x;
    }
    if(norm(dp[i]) > norm(ans)) ans = dp[i];
  }
  int cnt = 5000;
  while(cnt--) {
    random_shuffle(v.begin(), v.end());
    for(int i = 1 ; i <= n ; ++i) {
      dp[i] = {0, 0};
      for(int j = 0 ; j < i ; ++j) {
        Pt x = dp[j] + v[i - 1];
        if(norm(x) > norm(dp[i])) dp[i] = x;
      }
      if(norm(dp[i]) > norm(ans)) ans = dp[i];
    }
  }
  cout << fixed << setprecision(15) << norm(ans) << '\n';
}

int32_t main() {
  ios_base::sync_with_stdio(0), cin.tie(0);
  init();
  solve();
}


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

match = [[0 for i in range(10)] for i in range(10)]

for i in range(n+1):
    if i % 10 == 0:
        continue
    s = str(i)
    match[int(s[0])][int(s[len(s)-1])] += 1

ans = 0
for i in range(1, 10):
    for j in range(1, 10):
        ans += match[i][j] * match[j][i]

print(ans)


Measured memory_bytes: 40812
//bismillahir rahmanir rahim            //Author:Fayed Anik
 
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
//using namespace __gnu_pbds;
 
//#define         ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define         ll                          long  long
#define         lf                          double
#define         pb(x)                       push_back(x)
#define         ull                         unsigned long long
#define         sfl(a)                      scanf("%lld",&a)
#define         sf(a)                       scanf("%d",&a)
#define         pf(a)                       printf("%d\n",a)
#define         pfl(a)                      printf("%lld\n",a)
#define         FOR(x,n)                    for(ll x=1;x<=n;++x)
#define         pii                         pair< ll , ll >
#define         mp(a,b)                     make_pair(a,b)
#define         UNIQUE(v)                   v.resize(distance(v.begin(),unique(v.begin(),v.end())))
#define         mod                         1000000007
#define         INF                         2e18
#define         EPS                         1e-15
#define         f1                          first
#define         f2                          second
#define         all(v)                      v.begin(),v.end()
#define         PI                          acos(-1)
#define         printminusone               printf("-1\n")
#define         bug                         printf("bug")
#define         FILEIN                      freopen("in.txt","r",stdin)
#define         FILEOUT                     freopen("out.txt","w",stdout)
 
//ll SET(ll mask,ll pos){ return mask = (mask | (1ll<<pos)); }
//ll RESET(ll mask,ll pos){ return mask = mask & ~(1ll<<pos); }
//bool CHECK(ll mask,ll pos) { return (bool) (mask & (1ll<<pos)); }
//priority_queue <ll, vector<ll>, greater<ll> > pq;
//int dx[]={0,0,1,-1,1,1,-1,-1};
//int dy[]={1,-1,0,0,1,-1,1,-1};


int main(){
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);   
    string s,t;
    cin>>s>>t;
    ll n = s.size(),cnt=0;
    for(ll i=0;i<n;i++){
        if(s[i]!=t[i]) cnt++;
    }
    pfl(cnt);
    return 0;
}


Measured memory_bytes: 3856
import java.util.Scanner;

public class Main {
	void run() {
		Scanner scan = new Scanner(System.in);
		while (true) {
			int m = scan.nextInt();
			int f = scan.nextInt();
			int r = scan.nextInt();
			if (m == -1 && f == -1 && r == -1) break;
			if (m == -1 || f == -1) {
				System.out.println("F");
			} else if (m + f >= 80) {
				System.out.println("A");
			} else if (f + m >= 65) {
				System.out.println("B");
			} else if (f + m >= 50) {
				System.out.println("C");
			} else if (f + m >= 30) {
				if (r >= 50) {
					System.out.println("C");
				} else {
					System.out.println("D");
				}
			} else {
				System.out.println("F");
			}
		}
	}
	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 26096
import sys
from sys import stdin
input = stdin.readline

mod = 10**9 + 7
class mint:
  def __init__(self, x):
    self.x = x % mod
  def __str__(self): return str(self.x)
  __repr__ = __str__
  def __add__(self, other):
    return(
      mint(self.x + other.x) if isinstance(other, mint) else
      mint(self.x + other)
    )
  def __sub__(self, other):
    return(
      mint(self.x - other.x) if isinstance(other, mint) else
      mint(self.x - other)
    )
  def __mul__(self, other):
    return(
      mint(self.x * other.x) if isinstance(other, mint) else
      mint(self.x * other)
    )
  def __truediv__(self,  other):
    return (
      mint(
        self.x * pow(other.x, mod - 2, mod)
      ) if isinstance(other, mint) else
      mint(self.x * pow(other, mod - 2, mod))
    )
  def __pow__(self, other):
    return (
      mint(pow(self.x, other.x, mod)) if isinstance(other, mint) else
      mint(pow(self.x, other, mod))
    )
  __radd__ = __add__
  def __rsub__(self, other):
    return(
      mint(other.x - self.x) if isinstance(other, mint) else
      mint(other - self.x)
    )
  __rmul__ = __mul__
  def __rtruediv__(self, other):
    return (
      mint(
        other.x * pow(self.x, mod - 2, mod)
      )if isinstance(other, mint) else
      mint(other * pow(self.x, mod - 2, mod))
    )
  def __rpow__(self, other):
    return (
      mint(pow(other.x, self.x, mod)) if isinstance(other, mint) else
      mint(pow(other, self.x, mod))
    )

n = int(input())
a = list(map(int, input().split()))
sum = [0] * n
sum[0] = a[0]
for i in range(n): 
  if (i==0): continue
  sum[i] += a[i] + sum[i-1]
ans = 0
for i in range(n-1):
  ans += mint(a[i] * (sum[n-1] - sum[i]))
print(ans)

Measured memory_bytes: 31140
#include<bits/stdc++.h>
using namespace std;
const int maxn=2e5+5;
#define f(x,y,z) for(int x=(y),__=(z);x<=__;++x)
typedef long long ll;
#define v64 vector<ll>
//dp[i][j]：到第i个，j==1：选择此个，j==0：不选择此个，到此共选择了i/2个，得到的最大值。
/* 转移方程：
 
i为奇数时
选择(i-1)/2个 
dp[i][1]= arr[i]+max{dp[i-2][0],dp[i-2][1],dp[i-3][1],dp[i-3][0]}

dp[i][0]= max{dp[i-2][0]+arr[i-1],dp[i-3][1]+arr[i-1],dp[i-3][0]+arr[i-2],dp[i-3][0]+arr[i-1]} 
i为偶数时

*/ 
ll dp[maxn][2];
int main(){
	int n;
	scanf("%d",&n);
	v64 arr(n+1,0);
	f(i,1,n)
		cin >> arr[i];
	dp[2][1]=arr[2];
	dp[2][0]=arr[1];
	f(i,3,n){
		if(i&1){
			dp[i][1]=arr[i]+max(dp[i-2][0],dp[i-2][1]);
			dp[i][0]=max(dp[i-1][0],dp[i-1][1]);
		}
		else{
			dp[i][1]=arr[i]+dp[i-1][0];
			dp[i][0]=arr[i-1]+dp[i-2][0];
		}
	}
	printf("%lld\n",max(dp[n][1],dp[n][0]));
}

Measured memory_bytes: 8072
1.step do
  input_list = gets.chop.split(' ')
  a = input_list.fetch(0).to_i
  b = input_list.fetch(2).to_i
  op = input_list.fetch(1)

  case op
  when '+'
    puts a + b
  when '-'
    puts a - b
  when '*'
    puts a * b
  when '/'
    puts a / b
  when '?'
    break
  end
end



Measured memory_bytes: 6884
#include <stdio.h>
#include <math.h>

int M[101][101];
int p[101];

void matrixChainOrder (int n) {
	int i,j,k,l,q;
	for (i=1;i<=n;i++) M[i][i] = 0;
	for (l=2;l<=n;l++) {
		for (i=1;i<=n-l+1;i++) {
			j = i+l-1;
			M[i][j] = INFINITY;
			for (k=i;k<=j-1;k++) {
				q = M[i][k] + M[k+1][j] + p[i-1]*p[k]*p[j];
				if (M[i][j] >= q) M[i][j] = q;
			}
		}
	}
	printf("%d\n", M[1][n]);
}

int main() {
	int n,i,k;

	scanf("%d", &n);

	for (i=0; i<n; i++) {
		scanf("%d",&p[i]);
		scanf("%d", &k);
	}
	p[i] = k;
	matrixChainOrder(n);

	return 0;
}

Measured memory_bytes: 636
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <functional>
#include <climits>
#include <cmath>
#include <utility>

using namespace std;



int main(int argc, char *argv[])
{
	long long int N, M;
	//input
	cin >> N >> M;

	vector<pair<long long int,long long int> > ab;
	for (int i = 0; i < N; i++){
		long long int a, b;
		cin >> a >> b;
		ab.push_back(make_pair(a,b));
	}

	//calc
	long long int ans = 0;
	sort(ab.begin(), ab.end());

	long long int remaining = M;
	for (int i = 0; i < N; i++){
		pair<long long int, long long int> p = ab[i];
		long long int a = p.first;
		long long int b = p.second;;

		if (remaining - b >= 0){
			ans += a * b;
			remaining -= b;
		}
		else{
			ans += a * remaining;
			remaining = 0;
		}

		if (remaining == 0){
			break;
		}
	}

	//ans
	cout << ans << endl;


	return 0;
}


Measured memory_bytes: 2420
inp = list(map(lambda x: int(x), input().split(" ")))
N = inp[0]
M = inp[1]
inp = list(map(lambda x: int(x), input().split(" ")))

count_all = sum(inp)
check = count_all/(4*M)

inp.sort()
inp.reverse()

flag = True
for i in range(M):
    if(inp[i]<check):
        print("No")
        flag = False
        break
if (flag):
    print("Yes")


Measured memory_bytes: 38256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i < (n); i++)
#define lower(s) transform(s.begin(), s.end(), s.begin(), ::tolower)
using namespace std;
using ll = long long;

int main() {
  string s;
  cin >> s;
  cout << ((s[0] == s[1] && s[1] == s[2] && s[0] == s[2]) ? "No" : "Yes") << endl;
  return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
                
#define speedio ios_base::sync_with_stdio(false); cin.tie(NULL);
#define pretime float(clock()-clk)/CLOCKS_PER_SEC
#define max2(a,b) ((a)>(b) ? (a) : (b))   
#define min2(a,b) ((a)<(b) ? (a) : (b)) 
#define rep(i,a,b) for(i=a;i<=b;++i)
#define rev(i,a,b) for(i=a;i>=b;--i) 
#define all(x) x.begin(),x.end()
#define sz(x) (int)x.size()
#define ll long long int 
#define ins insert
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define PI 3.14159265
#define mod 1000000007
#define inf 1000000000000000
#define bug(x) cerr<<#x<<" = "<<(x)<<'\n'

using namespace std;
typedef vector<ll>   vll;
typedef vector<int>   vi;
typedef set<ll>      sll;
typedef set<int>      si;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
clock_t clk=clock();       

ll i,j;
void solve(void);

int main()
{
  speedio;
   int t=1;  
  // cin>>t;
   while(t--)
     solve();

  return 0;
}
ll gcd(ll a,ll b)
{
  a=abs(a); b=abs(b);
     while(a>0 && b>0)
        (a > b ? a%=b : b%=a );

  return (a==0?b:a);
}

// #define cerr if(0)cerr
void solve()
{
	ll a,b,c,d; cin>>a>>b>>c>>d;
    ll k1=a/c+(a%c!=0) ,k2=b/c;
    ll ans=k2-k1+1;
    k1=a/d+(a%d!=0); k2=b/d;
    ans+=k2-k1+1;

    ll lcm=c*d/gcd(c,d);
    k1=(a/lcm) + (a%lcm!=0); k2=(b/lcm);
    ans-=k2-k1+1;

    cout<<b-a+1-ans<<'\n';
    
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

void makePrimeNumber(int N, vector<bool>& prime) // 0ツ暗按湘」Nツ暗按可コツづ個青ョツ青板つゥツづァツ素ツ青板づーツ探ツつキ
{
    prime.assign(N+1, true);
    prime [0] = prime[1] = false;
    for(int i=2; i*i<=N; i++){
        if(prime[i]){
            for(int j=i; i*j<=N; j++){
                prime[i*j] = false;
            }
        }
    }
}

int main()
{
    vector<bool> prime;
    makePrimeNumber(1000000, prime);

    for(;;){
        int n, x;
        cin >> n >> x;
        if(n == 0)
            return 0;

        vector<bool> value(x+1, false);
        value[0] = true;
        for(int i=0; i<n; ++i){
            int a;
            cin >> a;
            for(int j=0; j+a<=x; ++j){
                if(value[j])
                    value[j+a] = true;
            }
        }

        int i = x;
        while(i > 0 && (!value[i] || !prime[i]))
            -- i;
        if(i == 0)
            cout << "NA" << endl;
        else
            cout << i << endl;
    }
}

Measured memory_bytes: 1152
from collections import deque
n , k = map(int,input().split())
kouho = []
for i in range(n-1):
    for j in range(i+1,n):
        kouho.append((i,j))
s = len(kouho)
now = 0
ke = []
for i in range(n-2):
    for j in range(i+1,n-1):
        ke.append((i,j))
if len(ke) < k:
    print(-1)
    exit()
kesu = set()    
for i in range(k):
    kesu.add(ke[i])

route = [[] for i in range(n)]
m = 0
for i in range(s):
    if not kouho[i] in kesu:
        m += 1
        u , v = kouho[i]
        route[u].append(v)
        route[v].append(u)

d = deque()
d.append(0)
cou = 1
visit = [False for i in range(n)]
visit[0] = True
while d:
    now = d.popleft()
    for i in route[now]:
        if not visit[i]:
            cou += 1
            visit[i] = True
            d.append(i)

if cou != n:
    print(-1)
    exit()

print(m)
for i in range(s):
    if not kouho[i] in kesu:
        x , y = kouho[i]
        print(str(x+1) + " " + str(y+1))

Measured memory_bytes: 74756
using System;
using System.IO;
using System.Linq;

namespace Sort_II
{
    class AOJ_Partition
    {
        static void Main(string[] args)
        {
            Console.ReadLine();
            var A = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
            var p = 0;
            var r = A.Length - 1;

            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            var index = Partition(A, p, r);

            for (int i = 0; i < A.Length - 1; i++)
                if (i == index) Console.Write("[" + A[i] + "] ");
                else Console.Write(A[i] + " ");
            if (index == r) Console.WriteLine("[" + A.Last() + "]");
            else Console.WriteLine(A.Last());

            Console.Out.Flush();
        }

        static public int Partition(int[] A, int p, int r)
        {
            var x = A[r];
            var i = p - 1;
            for (int j = p; j < r; j++)
                if (A[j] <= x)
                {
                    i++;
                    var temp = A[i];
                    A[i] = A[j];
                    A[j] = temp;
                }
            var tmp = A[i + 1];
            A[i + 1] = A[r];
            A[r] = tmp;

            return i + 1;
        }
    }
}

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

using ll = long long;

using namespace std;

int main() {
    int n;
    cin >> n;
    ll a[n+1];
    for (auto &ai:a) cin >> ai;
    if (a[n] == 0) {
        cout << -1 << '\n';
        return 0;
    }
    ll rui[n+2];
    rui[n+1] = 0;
    for (int i=n; i>=0; i--) {
        rui[i] = rui[i+1] + a[i];
    }
    ll ans = 0, now = 1;
    for (int i=0; i<=n; i++) {
        ans += now;
        if (now < a[i]) {
            cout << -1 << '\n';
            return 0;
        }
        now -= a[i];
        now = min(now * 2, rui[i+1]);
    }
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 5160
N, A, B = [int(_) for _ in input().split()]
S = input()
student = 0
abroad = 0
for i in range(N):
    if (student < A + B and S[i] == 'a') or (student < A + B and abroad < B
                                             and S[i] == 'b'):
        student += 1
        abroad += (S[i] == 'b')
        print('Yes')
    else:
        print('No')


Measured memory_bytes: 4016
#include <bits/stdc++.h>
#define rep(i, N) for (int i = 0; i < (N); i++)
#define swap(a, b) (a += b, b = a - b, a -= b)
using namespace std;
int main()

{
    string S;
    cin >> S;
    int ans = S.size() - 1;
    for (int i = 0; i < S.size() - 1; i++)
    {
        if (S[i] == S[i + 1])
        {
            ans--;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define rep(i, a, b) for(int i=(a); i<(b); i++)
#define sz(a) (int)a.size()
//---------------

const int N=200005;
vector<int> G[N];
int n;
int d[2][N],son[N];

void dfs(int ty,int u,int dis) {
	d[ty][u]=dis;
	rep(i,0,sz(G[u])) {
		int v=G[u][i];
		if(d[ty][v]!=-1) continue;
		dfs(ty,v,dis+1);
	}
}
void dfs2(int u,int fa) {
	son[u]=1;
	rep(i,0,sz(G[u])) {
		int v=G[u][i];
		if(v==fa) continue;
		dfs2(v,u);
		son[u]+=son[v];
	}
}
void print(int x) {
//	cout<<x<<endl;
	int a=son[x],b=n-a;
//	cout<<a<<" "<<b<<endl;
	if(b<a) puts("Fennec");
	else puts("Snuke");
}
int main() {
	while(~scanf("%d",&n)) {
		///init
		rep(i,0,n) G[i].clear();
		memset(d,-1,sizeof(d));
		///read
		rep(i,1,n) {
			int u,v;scanf("%d%d",&u,&v);
			--u;--v;
			G[u].pb(v);
			G[v].pb(u);
		}
		///get d
		dfs(0,0,0);dfs(1,n-1,0);
		///get son
		dfs2(n-1,n-1);
		///solve
		int dis=d[0][n-1];
		rep(i,0,n) {
			if(d[0][i]==dis/2&&d[1][i]==dis-dis/2) {
				print(i);
				break;
			}
		}

	}
	return 0;
}

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

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;

ll N,M;
char dp_c[20000];
ll dp_l[20000];
ll dp_b[20000];
ll A[10];
ll n[10] = {0,2,5,5,4,5,6,3,7,6};

int main(){
    cin >> N >> M;
    for(int i=0;i<M;i++) cin >> A[i];
    dp_c[0] = '\n';
    for(int i=0;i<N;i++){
        if(dp_c[i] == 0) continue;
        for(int m=0;m<M;m++){
            if(dp_c[i+n[A[m]]]==0){
                dp_c[i+n[A[m]]] = '0' + A[m];
                dp_b[i+n[A[m]]] = i;
                dp_l[i+n[A[m]]] = dp_l[i] + 1;
                continue;
            }
            if(dp_l[i] + 1 > dp_l[i+n[A[m]]]){
                dp_c[i+n[A[m]]] = '0' + A[m];
                dp_b[i+n[A[m]]] = i;
                dp_l[i+n[A[m]]] = dp_l[i] + 1;
                continue;
            }
            if(dp_l[i] + 1 == dp_l[i+n[A[m]]] && A[m] > dp_c[i+n[A[m]]]-'0'){
                dp_c[i+n[A[m]]] = '0' + A[m];
                dp_b[i+n[A[m]]] = i;
                dp_l[i+n[A[m]]] = dp_l[i] + 1;
            }
        }
    }
    vector<char> v;
    ll p = N;
    while(p > 0){
        v.push_back(dp_c[p]);
        p = dp_b[p];
    }
    for(auto &e : v) cout << e;
    cout << endl;
    return 0;
}

Measured memory_bytes: 3808
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, n, P, sum;
  cin >> N;
  n = N;
  
  for(int i = 8; i > -1; i--){
  P = pow(10,i);
  sum += N / P;
  N = N % P;
  }
  
  if(n % sum == 0){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 384
import numpy as np
import sys

A = np.zeros(5)
for i in range(5):
    A[i] = int(input())

A2 = np.ceil(A/10.0).astype(np.int)*10
A3=(A-1)%10+1
print((A3.min()+A2.sum()-10).astype(np.int))


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

using namespace std; 



int main () {
long double a, b, h, m; 
cin >> a >> b >> h >> m; 

long double num = m / 5.0; 
long double num2 = h + (m / 60.0);
long double angle = (num2 - num) * 30.0; 
long double pi = 3.141592653589793238462643383279; 
long double  x = angle*pi/180; 

long double answer = (a * a) + (b * b) - 2.0*a*b * cos(x); 
answer = sqrt(answer); 

cout << setprecision(100) << answer; 






}

Measured memory_bytes: 4120
#include <cstdint>
#include <cstdio>
#include <iostream>
#include <vector>

static const uint32_t kVeryLargeNumber = 0xffffffff;

uint32_t cmp_counter = 0;

void merge(std::vector<uint32_t>& data, int begin1, int begin2, int end2)
{
    int j = 0;
    int k = 0;
    std::vector<uint32_t> subdata1(begin2 - begin1 + 1);
    std::vector<uint32_t> subdata2(end2 - begin2 + 1);

    for(int i = 0; i < subdata1.size() - 1; i++) {
        subdata1[i] = data[begin1 + i];
    }
    subdata1[subdata1.size() - 1] = kVeryLargeNumber;

    for(int i = 0; i < subdata2.size() - 1; i++) {
        subdata2[i] = data[begin2 + i];
    }
    subdata2[subdata2.size() - 1] = kVeryLargeNumber;

    for(int i = begin1; i < end2; i++) {
        cmp_counter++;
        if(subdata1[j] < subdata2[k]) {
            data[i] = subdata1[j];
            j++;
        } else {
            data[i] = subdata2[k];
            k++;
        }
    }
}

void merge_sort(std::vector<uint32_t>& data, int vector_1_begin, int vector_2_end)
{
    if(vector_2_end - vector_1_begin <= 1) {
        return;
    }

    int vector_2_begin = (vector_1_begin + vector_2_end) / 2;
    merge_sort(data, vector_1_begin, vector_2_begin);
    merge_sort(data, vector_2_begin, vector_2_end);
    merge(data, vector_1_begin, vector_2_begin, vector_2_end);
}

int main()
{
    int input_size;
    std::cin >> input_size;
    std::vector<uint32_t> data(input_size);
    for(int i = 0; i < data.size(); i++) {
        std::cin >> data[i];
    }

    merge_sort(data, 0, data.size());

    printf("%u", data[0]);
    for(int i = 1; i < data.size(); i++) {
        printf(" %u", data[i]);
    }
    putchar('\n');
    printf("%u\n", cmp_counter);

    return 0;
}

Measured memory_bytes: 6760
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,ssw,sum=0,min=0x7ffffff;
	cin>>n>>ssw;
	int m[n];
	for(int i=0;i<n;i++)
	{
		cin>>m[i];
		ssw-=m[i];
		if(m[i]<min) min=m[i];
	}
	cout<<ssw/min+n<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
int a,aaa,bbb, b, aa[100], bb[100], r,kazu,m;
kazu = 0;
while (cin >> aaa >> bbb) {
	kazu++;
	m = aaa * bbb;
	a = aaa;
	b = bbb;
	if (a <= b) {
		r = a;
		a = b;
		b = r;
	}
	while (b != 0) {
		r = a % b;
		a = b;
		b = r;
	}
	aa[kazu] = a;
	if (m > 0) {
		bb[kazu] = m / aa[kazu];
	}
	else {
		m = aaa / aa[kazu];
		bb[kazu] = m * bbb;
	}
}
for (int i = 1; i <= kazu; i++) {
	cout << aa[i] << " " << bb[i] << endl;
}
}


Measured memory_bytes: 2996
/* *
 *
 * Author: Hamkor
 *
 * */

#include <bits/stdc++.h>

using namespace std;

/* * * *   * * *   	* * * */
typedef long long ll;
const int oo = 1e9;
const ll mod = 100000000;
typedef complex<ll> P;
#define X real()
#define Y imag()
/* * * *   * * *   	* * * */

int main(){
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int n, m, x, y, a = -1e9, b = 1e9; cin>>n>>m>>x>>y;
    for (int i=0; i<n; i++){
        int d; cin>>d;
        a = max(a, d);
    }
    for (int i=0; i<m; i++){
        int d; cin>>d;
        b = min(b, d);
    }
    if (a >= b || a >= y || b <= x) cout<<"War";
    else cout<<"No War";
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#define repu(i,x,y) for (int i=x; i<=y; ++i)
#define repd(i,x,y) for (int i=x; i>=y; --i)
using namespace std;

int n,ans,a[500100],sum;
char str[500100];

void add(int p,int w)
{
    for (a[p]+=w,sum+=w; a[p]>9; ++p)
    {
        int x=a[p]/10,y=a[p]-x*10;
        sum=sum-a[p]+x+y,a[p]=y,a[p+1]+=x;
    }
}

int main()
{
    scanf("%s",str+1),n=strlen(str+1);
    repu(i,1,n)
        add(n-i,9*(str[i]-'0'));
    repu(i,1,n)
    {
        add(0,9);
        if (sum<=9*i)
        {
            printf("%d\n",i);
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 2560
#include<cstdio>
#include<iostream>
#include<unordered_set>
#include<string>

using namespace std;
int main(){
	int n;
	cin>>n;
	unordered_set<string> res;
	for(int i=0;i<n;i++){
		string x; 
		cin>>x;
		res.insert(x);
	}
	cout<<res.size();
	return 0;
} 

Measured memory_bytes: 17616
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <utility>

using namespace std;

#define int long long

typedef pair<int, int> pii;

#define fst first
#define scd second
#define rep(i,x) for(int i=0;i<(x);++i)

template<typename T>bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}

const int inf = 1e9;

int k[150];
vector<pii> stone[150];
int N, M;

int memo[150][150][10];

int rec(int n, int m, int i)
{
	if (n >= N - 1) return 0;

	if (~memo[n][m][i]) return memo[n][m][i];

	int res = inf;

	rep(j, k[n + 1]) {
		int dist = (stone[n][i].scd + stone[n + 1][j].scd) * abs(stone[n][i].fst - stone[n + 1][j].fst);
		chmin(res, dist + rec(n + 1, m, j));
	}

	if (m < M) {
		if (n + 2 >= N) return 0;
		rep(j, k[n + 2]) {
			int dist = (stone[n][i].scd + stone[n + 2][j].scd) * abs(stone[n][i].fst - stone[n + 2][j].fst);
			chmin(res, dist + rec(n + 2, m + 1, j));
		}
	}

	return memo[n][m][i] = res;
}

signed main()
{
	while (scanf("%lld %lld", &N, &M), N || M) {
		rep(i, N) {
			scanf("%lld", &k[i]);

			stone[i].resize(k[i]);

			rep(j, k[i]) {
				int x, d; scanf("%lld %lld", &x, &d);
				stone[i][j].fst = x, stone[i][j].scd = d;
			}
		}

		int ans = inf;

		rep(i, k[0]) {
			memset(memo, -1, sizeof(memo));
			chmin(ans, rec(0, 0, i));
		}

		if (M > 0) {
			rep(i, k[1]) {
				memset(memo, -1, sizeof(memo));
				chmin(ans, rec(1, 1, i));
			}
		}

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

Measured memory_bytes: 2844
#include<bits/stdc++.h>
using namespace std;
    
int main()
{
  long long N; 
  cin >> N;
  vector<long long> arr(N);
  for(long long i = 0 ; i < N ; i++)
  cin >> arr[i];

    long long sumprod = 0;

    long long sum = 0;
    for(long long i = 0 ; i < N ; i++)
    sum += arr[i];

    vector<long long> sumTillN = arr;
    for(long long i = 1 ; i < N ; i++)
    {
        sumTillN[i] += sumTillN[i-1]; 
    }


  for(long long i = 0 ; i < N ; i++)
  {

      sumprod += ( (arr[i] % 1000000007) * ((sum-sumTillN[i])%1000000007) ) %1000000007;
  
  }

    cout << sumprod % 1000000007;
}

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

// {U}{INT,LONG,LLONG}_{MAX,MIN}
#define INF         INT_MAX/3
#define LLINF       LLONG_MAX/3
#define MOD         (1000000007LL)
#define MODA(a, b)  a=((a)+(b))%MOD
#define MODP(a, b)  a=((a)*(b))%MOD
#define inc(i, l, r)   for(int i=(l);i<(r);i++)
#define dec(i, l, r)   for(int i=(r)-1;i>=(l);i--)
#define pb          push_back
#define se          second
#define fi          first
#define mset(a, b)  memset(a, b, sizeof(a))

using LL  = long long;
using G   = vector<vector<int>>;

int di[] = {0, -1, 0, 1};
int dj[] = {1, 0, -1, 0};
// }}}

int main() {
    cin.tie(0);ios::sync_with_stdio(false);
    int n, m;cin >> n >> m;
    vector<int> a(n), b(n), c(m), d(m);
    inc(i, 0, n) cin >> a[i] >> b[i];
    inc(i, 0, m) cin >> c[i] >> d[i];

    inc(i, 0, n){
        int min = INT_MAX;
        int ans = 0;
        inc(j, 0, m){
            if(abs(a[i]-c[j])+abs(b[i]-d[j]) < min){
                ans = j;
                min = abs(a[i]-c[j])+abs(b[i]-d[j]);
            }
        }
        cout << ans+1 << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int maxn = 110;
int dp[maxn][4][2];
char N[maxn];
string s;
int k, len;

inline int dfs (int idx, int c0, int flag) {
  if (c0 > k) return 0; // hit max number of 0s
  if (idx > len) return c0 == k; // out of bounds, return 1 if capacity is met
  if (dp[idx][c0][flag] != -1) return dp[idx][c0][flag];
  int ans = 0;
  int bound = (flag == 1) ? N[idx] - '0' : 9;
  for (int i = 0; i <= bound; i++) {
    ans += dfs(idx + 1, c0 + (i != 0), flag && (i == bound));
  }
  return dp[idx][c0][flag] = ans;
}

signed main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  memset(dp, 255, sizeof(dp));

  // index the number N (string) from 1
  cin >> s;
  len = s.size();
  for (int i = 0; i < len; i++) N[i + 1] = s[i];
  len = strlen(N + 1);
  cin >> k;

  // start at 1st char, count of 0s is 0, flag set (bounded)
  cout << dfs(1, 0, 1) << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
  int n, m, l, r, lmax=0, rmin;
  cin >> n >> m;
  rmin=n;
  for(int i=0; i<m; i++){
    cin >> l >> r;
    if(l>lmax) lmax =l;
    if(r<rmin) rmin = r;
  }
  cout << max(rmin-lmax+1, 0);
  return 0;
}


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

int main() {
  int A, B;
  cin >> A >> B;
  int sum = 0;
  
  for ( int cnt = A; cnt <= B; ++cnt ) {
    int tmp = cnt; 
    int x = 0;
    x += (tmp % 10) * 10000; tmp /= 10;
    x += (tmp % 10) * 1000;  tmp /= 10;
    x += (tmp % 10) * 100;   tmp /= 10;
    x += (tmp % 10) * 10;    tmp /= 10;
    x += (tmp % 10) * 1;     tmp /= 10;
    
    if ( x == cnt ) sum++;
  }
  
  cout << sum << endl;
}

Measured memory_bytes: 3588
#include<bits/stdc++.h>
using namespace std;
int n,f,t,i,r;
vector<int> g[1<<18];
int dfs(int v, int p) {
	int c0 = 0, a = 0;
	for(int i : g[v]) if(i != p) {
		t = dfs(i, v);
		t ? a += t : ++c0;
	}
	return a + c0 - (c0>0);
}
int main() {
	for(i=(cin>>n,n);--i;) {
		cin>>f>>t;
		g[f].push_back(t);
		g[t].push_back(f);
	}
	while(r < n && g[r].size()<3) r++;
	cout << (r==n?1:dfs(r, r));
	return 0;
}


Measured memory_bytes: 16232
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<iostream>
#include<vector>
#include<queue>
#include<cstdlib>
#define ll long long
#define lowbit(x) (x&(-x))
using namespace std;

struct Info{
    ll x,h;
}M[200007];

ll ans,n,d,a,Modify,tag[200007],Next[200007];

bool cmp(Info a,Info b){
    return a.x>b.x;
}

int main(){
    scanf("%lld%lld%lld",&n,&d,&a);
    for (int i=1;i<=n;++i) scanf("%lld%lld",&M[i].x,&M[i].h);
    sort(M+1,M+n+1,cmp);
    for (int i=1;i<=n;++i){
        Next[i]=max(Next[i-1],1ll*i);
        while (Next[i]<n&&M[i].x-M[Next[i]+1].x<=1ll*2*d) ++Next[i];
        Modify+=tag[i];
        if (Modify<M[i].h){
            ll Num=(M[i].h-Modify)/a+(((M[i].h-Modify)%a)!=0);
            ans+=Num;
            Modify+=Num*a;
            tag[Next[i]+1]-=Num*a;
        }
    }
    printf("%lld\n",ans);
    return 0;
}

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

typedef long long ll;
typedef pair<int, int> Pair;

const int N = 100005;
const ll INF = 1000000000000;

int n, m, u, v, dp[N];
vector<int> node[N];

int go(int u){
  if(dp[u] != -1) return dp[u];
  int ans = 0;
  for(auto& v: node[u]) ans = max(ans, 1 + go(v));
  return dp[u] = ans;
}

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

  cin >> n >> m;
  while(m--){
    cin >> u >> v;
    node[u].push_back(v);
  }
  memset(dp, -1, sizeof dp);
  int ans = 0;
  for(int i = 1; i <= n; i++) ans = max(ans, go(i));
  cout << ans << endl;
}


Measured memory_bytes: 8192
from collections import deque, Counter

def main():
    with open(0) as f:
        H, W = map(int, f.readline().split())
        maze = [list(line) for line in f.readlines()]

    rank = [[None]*W for _ in range(H)]
    rank[0][0] = 0
    #bfs
    reserved = deque([(0,0)])
    while len(reserved) > 0:
        x, y = reserved.popleft()
        for u,v in [(s,t) for s,t in [(x-1,y), (x+1,y), (x,y-1), (x,y+1)] if 0<=s<H and 0<=t<W]:
            if rank[u][v] is not None:
                continue
            if maze[u][v] == '.':
                rank[u][v] = rank[x][y] + 1
                reserved.append((u,v))

    if rank[H-1][W-1] is None:
        print(-1)
    else:
        counter = Counter()
        for line in maze:
            counter.update(line)
        print(counter['.'] - rank[H-1][W-1]-1)

main()

Measured memory_bytes: 9536
S = input()
T = input()
dp = [[0 for j in range(len(T)+1)] for i in range(len(S)+1)]

for i in range(len(S)) :
    for j in range(len(T)) :
        if S[i] == T[j] :
            dp[i+1][j+1] = dp[i][j] + 1
        else :
            dp[i+1][j+1] = max(dp[i+1][j], dp[i][j+1])

ans = ""

i = len(S)
j = len(T)

while i * j :
    if S[i-1] == T[j-1] :
        ans = S[i-1] + ans
        i -= 1
        j -= 1
    elif dp[i][j] == dp[i-1][j] :
        i -= 1
    else :
        j -= 1
    
print(ans)


Measured memory_bytes: 120028
#include<iostream>
#include<string>
#include<math.h>
#include<algorithm>
#define rep(i,n)for(int i=0;i<n;i++)
using namespace std;

int main(){
	int a, b, c;
	cin >> a >> b >> c;
	if (a*c <= b){
		cout << c << endl;
	}
	else{
		cout << b / a << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>
#include <cstring>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define all(c) begin(c),end(c)

template<typename T1, typename T2>
inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }

template<typename T1, typename T2>
inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

//改造
typedef long long int ll;
using ll = long long int;
using ull = long long unsigned int;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007


//ここから編集する
class Solve {
public:
    void solve() {
        int N;
        cin >> N;
        vector<int> v(N);
        for (int i = 0; i < N; ++i) {
            cin >> v[i];
        }

        if (N % 3) {
            sort(all(v));
            if (v[0] == v.back()) {
                cout << "Yes" << endl;
            } else {
                cout << "No" << endl;
            }
            return;
        }


        sort(all(v));
        int x = 0;
        for (int i = 0; i < 3; ++i) {
            int f = i * N / 3;
            int t = (i + 1) * N / 3 - 1;
            cerr << f << " " << t << endl;
            if (v[f] != v[t]) {
                cout << "No" << endl;
                return;
            }
            x = x ^ v[f];
        }

        if (x == 0)
            cout << "Yes" << endl;
        else
            cout << "No" << endl;


    }
};


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    Solve().solve();


    return 0;
}


Measured memory_bytes: 888
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<map>
#include<stack>
#include<cmath>
#include<iomanip>
#include<set>
#include<numeric>
#include<sstream>
#include<random>
#include<cassert>
#include<complex>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rrep(i, st, n) for (int i = st; i < n; ++i)
using pii = pair<int, int>;
const int inf = 1e9 + 7;
int dy[] = {0, 0, -1, 1, -1, 1, -1, 1};
int dx[] = {1, -1, 0, 0, -1, 1, 1, -1};
#define ceil(a, b) a / b + !!(a % b)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)

string random_string( size_t length )
{
    auto randchar = []() -> char
    {
        const char charset[] =
        "NEWS";
        const size_t max_index = (sizeof(charset) - 1);
        return charset[ rand() % max_index ];
    };
    string str(length,0);
    generate_n( str.begin(), length, randchar );
    return str;
}

int init_face[7];
int face[7];
void roll(int tmp, int a, int b, int c) {
    face[1] = face[a];
    face[a] = face[b];
    face[b] = face[c];
    face[c] = tmp;
}
int main() {
    rrep(i, 1, 6 + 1) cin >> init_face[i];
    int n; cin >> n;
    while (n--) {
        rrep(i, 1, 7) face[i] = init_face[i];
        int top, front; cin >> top >> front;
        while (1) {
            string ch = random_string(1);
            int tmp = face[1];
            if (ch == "N") {
                roll(tmp, 2, 6, 5);
            } else if (ch == "E") {
                roll(tmp, 4, 6, 3);
            } else if (ch == "W") {
                roll(tmp, 3, 6, 4);
            } else {
                roll(tmp, 5, 6, 2);
            }
            if (face[1] == top && face[2] == front) {
                break;
            }
            //rrep(i, 1, 6 + 1) cout << face[i] << " "; cout << endl;
        }
        cout << face[3] << endl;
    }
}



Measured memory_bytes: 3136
N = gets.to_i
adj = Array.new(N).map{Array.new}
(N-1).times do
  a,b,c = gets.chomp.split(" ").map(&:to_i)
  adj[a-1] << [b-1,c]
  adj[b-1] << [a-1,c]
end
Q,K = gets.chomp.split(" ").map(&:to_i)
path = Array.new(N).map{Array.new([false,10**15])}
path[K-1] = [true,0]
temp0 = []
temp1 = [[K-1,0]]
while !(temp1.empty?)
  temp0 = Marshal.load(Marshal.dump(temp1))
  temp1 = []
  temp0.each do |i,j|
    adj[i].each do |k,l|
      if path[k][0] == false
        path[k] = [true,l+j]
        temp1 << [k,l+j]
      end
    end
  end
end
Q.times do
  x,y = gets.chomp.split(" ").map{|i|i.to_i-1}
  puts path[x][1]+path[y][1]
end

Measured memory_bytes: 61932
#include <algorithm>
#include <bits/stdc++.h>
#include <cstdlib>
#include <cmath>
using namespace std;

int main(){
    int a,b;
    cin >> a >> b;
    if(a<10 && b <10){
      cout << a*b << endl;
    }else{
      cout << -1 << endl;
    }
}


Measured memory_bytes: 256
import java.util.Scanner;

class Main{
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		String a=sc.next();
		int[] DREAMS=new int[6];
		for(int i=0; i<6; i++) {
			DREAMS[i]=0;
		}

		for(int i=0; i<a.length(); i++) {
			if(a.charAt(i)=='d') {
				DREAMS[0]++;
			}
			else if(a.charAt(i)=='r') {
				DREAMS[1]++;
			}
			else if(a.charAt(i)=='e') {
				DREAMS[2]++;
			}
			else if(a.charAt(i)=='a') {
				DREAMS[3]++;
			}
			else if(a.charAt(i)=='m') {
				DREAMS[4]++;
			}
			else if(a.charAt(i)=='s') {
				DREAMS[5]++;
			}
		}

		int x=0,y=0,z=0,w=0;

		x=2*DREAMS[3]-DREAMS[2];
		y=DREAMS[2]-DREAMS[5]*2-DREAMS[4];
		z=DREAMS[1]+DREAMS[5]-DREAMS[2];
		w=DREAMS[2]-DREAMS[1];

		//System.out.println(x+" "+y+" "+z+" "+w);

		if(a.length()==x*5+y*7+6*z+5*w) {
			if(x+y==DREAMS[0]) {
				if(x+2*y+2*z+w==DREAMS[1]) {
					if(x+2*y+z*2+w*2==DREAMS[2]) {
						if(x+y+z+w==DREAMS[3]) {
							if(x+y==DREAMS[4]) {
								if(z+w==DREAMS[5]) {
									if(x>=0) {
										if(y>=0) {
											if(z>=0) {
												if(w>=0) {
													System.out.println("YES");
													System.exit(0);
												}
											}
										}
									}
								}
							}
						}
					}
				}
			}
		}
		System.out.println("NO");
	}
}

Measured memory_bytes: 25556
#include <stdio.h>
int main(){
    int A[1000];
    int n;
    int i,j,v;
    int max,min;
    
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d",&A[i]);
        printf("%d",A[i]);
        if(i<n-1)printf(" ");
    }
    printf("\n");
    for(i=1;i<n;i++){
        v=A[i];
        j=i-1;
        while(j>=0 && A[j]>v){
            A[j+1]=A[j];
            j--;
        }
        A[j+1]=v;
        
        for(j=0;j<n;j++){
            printf("%d",A[j]);
            if(j<n-1)printf(" ");
        }
        printf("\n");

    }
    return 0;
}



Measured memory_bytes: 1924
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int>i_i;
int main() {
int N,point,round;
cin>>N>>point>>round;

vector<int>A(round);
vector<int>score(N);
for(int i=0;i<round;i++) cin>>A.at(i);
for(int i=0;i<N;i++) score.at(i)=point-round;

for(int i=0;i<round;i++){
	score.at(A.at(i)-1)++;
}
for(int i=0;i<N;i++){
	if(score.at(i)>0) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}
	return 0;
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define read(x) scanf("%d",&x)
typedef long long ll;
typedef double dl;
using namespace std;

const int N=2e5+7;
const int M=1e9+7;
const int INF=0x3f3f3f3f;

int n,m,k;

int cnt[N];
int d,a;

void solve(){
	cin>>n>>k;
	fo(i,1,k){
		cin>>d;
		fo(i,1,d){
			cin>>a;
			cnt[a]++;
		}
		
	}
	int ans=0;
	fo(i,1,n){
		if (cnt[i]==0) ans++;
	}
	cout<<ans;
}

int main(){
//	ios::sync_with_stdio(0);
//  cin.tie(0),cout.tie(0);
//	int T;read(T);
//	for(int i=1;i<=T;i++)
		solve();
}


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

int main() {
  ll n; cin>>n;
  
  vector<ll> p(n), q(n);
  rep(i, n) cin>>p.at(i);
  rep(i, n) cin>>q.at(i);
  
  vector<ll> a(n);
  rep(i, n) a.at(i)=i+1;
  
  ll s=0;
  ll t=0;
  bool pd=false;
  bool qd=false;
  
  while(pd==false||qd==false) {
    if(pd==false) {
      s++;
      pd=true;
      rep(i, n) if(a.at(i)!=p.at(i)) pd=false;
    }
    if(qd==false){
      t++;
      qd=true;
      rep(i, n) if(a.at(i)!=q.at(i)) qd=false;
    }
    next_permutation(a.begin(), a.end());
  }
  cout << max(s, t)-min(s, t);
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		String a = sc.next();
		String b = sc.next();
		
		byte[] b1 = a.getBytes();
		byte[] b2 = b.getBytes();
		
//		System.out.println(b1[0]);
//		System.out.println(b2[0]);
		
		if (b1[0] > b2[0]){
			System.out.println(">");
		}
		else if (b1[0] < b2[0]){
			System.out.println("<");
		}
		else {
			System.out.println("=");
		}
	}

}


Measured memory_bytes: 23764