akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
using namespace std; 
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)
inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; }
const int INF = 1<<29;
typedef long long int ll;
inline int two(int n) { return 1 << n; }
inline int test(int n, int b) { return (n>>b)&1; }
inline void set_bit(int & n, int b) { n |= two(b); }
inline void unset_bit(int & n, int b) { n &= ~two(b); }
inline int last_bit(int n) { return n & (-n); }
inline int ones(int n) { int res = 0; while(n && ++res) n-=n&(-n); return res; }
template<class T> void chmax(T & a, const T & b) { a = max(a, b); }
template<class T> void chmin(T & a, const T & b) { a = min(a, b); }
const int MOD=1000000007;

bool isPowerOfTwo (ll x)  
{  
    return x && (!(x&(x-1)));  
}
bool isPrime(int n) 
{ 
    if (n <= 1)  return false; 
    if (n <= 3)  return true; 
    if (n%2 == 0 || n%3 == 0) return false; 
  
    for (int i=5; i*i<=n; i=i+6) 
        if (n%i == 0 || n%(i+2) == 0) 
           return false; 
  
    return true; 
}
int highestPowerof2(unsigned int n) 
{ 
    // Invalid input 
    if (n < 1) 
        return 0; 
  
    int res = 1;
    for (int i=0; i<8*sizeof(unsigned int); i++) 
    { 
        int curr = 1 << i; 
        if (curr > n) 
           break; 
  
        res = curr; 
    } 
  
    return res; 
} 
long long binpow(long long a, long long b) {
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}       
////////////////////////////////////////////////////////////////////
int a[26];
int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);  
  cout.tie(NULL);
  int t=1;
  while(t--)
  {
    memset(a,0,sizeof(a));
    int n;string s;
    cin>>n>>s;
    if(n%2)
    return cout<<"No",0;
    string r=s.substr(0,n/2);
    /*cout<<r<<"\n";*/
    string t=s.substr(n/2,n/2);
    /*cout<<t<<"\n";*/
    if(r==t)cout<<"Yes";
    else
    {
        cout<<"No";
    }
    
  }
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<functional>
#include<string>
#include<cmath>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<cstdio>
#include<numeric>
using namespace std;
using ll = long long;
int main(){
  string s;
  int n;
  cin >> n >> s;
  vector<int> sume(n + 3, 0),sumw(n + 3, 0);
  for(int i = 0; i < n; i++){
    if(s[i] == 'W'){
      sumw[i + 1]++;
    }
    sumw[i + 2] = sumw[i + 1];
  }
  for(int i = n - 1; i >= 2; i--){
    if(s[i] == 'E'){
      sume[i - 1]++;
    }
    sume[i - 2] = sume[i - 1];
  }
  int mini = 1001001001;
  for(int i = 0; i < n; i++) {
    mini = min(mini, sumw[i] + sume[i]);
    //cout << sumw[i] << " " << sume[i] << '\n';
  }
  cout << mini << endl;
  return 0;
}

Measured memory_bytes: 3076
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <iterator>
#pragma warning(disable:4996)
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define MOD 1000000007
using namespace std;



int main(int argc, char* argv[])
{
    long n;
    scanf("%ld", &n);

    vector<long> d(n);
    long i;
    for(i=0; i<n; i++) {
        scanf("%ld", &d[i]);
    }
    sort(d.begin(), d.end());

    d.erase(unique(d.begin(), d.end()), d.end());

    printf("%ld\n", (long)d.size());

    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
	int N;

	cin >> N;

	cout << N << ':';

	while (true)
	{
		int i = 2;

		while (N >= i * i)
		{
			if (N % i == 0) { N /= i; cout << ' ' << i; goto Exit; }

			i++;
		}

		break;

	Exit:;
	}

	cout << ' ' << N << endl;

	return 0;
}

Measured memory_bytes: 3100
n=int(input())
d=[int(n) for n in input().split()]

sum=0
i=int(1)
t=int(0)
while t<=n-2:
    while i<=n-1:
        sum=sum+d[t]*d[i]
        i+=1
    t+=1
    i=t+1
print(sum)


Measured memory_bytes: 3060
def counting_sort(arr):
    max_value = max(arr) + 1
    counter = [0] * max_value

    # counter[i]にiの出現数を記録
    for i in range(len(arr)):
        counter[arr[i]] += 1

    # counter[i]にi以下の数の出現数を記録
    for i in range(1, max_value):
        counter[i] += counter[i-1]

    sorted_arr = [0] * len(arr)
    for i in range(len(arr)):
        sorted_arr[counter[arr[i]] - 1] = arr[i]
        counter[arr[i]] -= 1
    
    return sorted_arr

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

print(*counting_sort(arr))




Measured memory_bytes: 224600
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <clocale>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i, s, n) for(int i = (s), i##_len=(n); i < i##_len; ++i)
#define FORS(i, s, n) for(int i = (s), i##_len=(n); i <= i##_len; ++i)
#define VFOR(i, s, n) for(int i = (s); i < (n); ++i)
#define VFORS(i, s, n) for(int i = (s); i <= (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) FORS(i, 0, n)
#define VREP(i, n) VFOR(i, 0, n)
#define VREPS(i, n) VFORS(i, 0, n)
#define RFOR(i, s, n) for(int i = (s), i##_len=(n); i >= i##_len; --i)
#define RFORS(i, s, n) for(int i = (s), i##_len=(n); i > i##_len; --i)
#define RREP(i, n) RFOR(i, n, 0)
#define RREPS(i, n) RFORS(i, n, 0)
#define ALL(v) (v).begin(), (v).end()
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v), greater<decltype(v[0])>())
#define SZ(x) ((int)(x).size())
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define BIT(n) (1LL<<(n))
#define UNIQUE(v) v.erase(unique(ALL(v)), v.end())

using ll = long long;
using Pi_i = pair<int, int>;
using VI = vector<int>;
using VD = vector<double>;
using VLL = vector<ll>;
using VS = vector<string>;
using VC = vector<char>;
using VB = vector<bool>;

const int MOD = 1000000007;
const int INF = 1000000000;

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



int main(){
    int n; cin >> n;
    unordered_set<string> dictionary;
    REP(i, n){
        string com, str;
        cin >> com >> str;
        if(com == "insert")
            dictionary.insert(str);
        else{
            if(dictionary.find(str) == dictionary.end())
                cout << "no\n";
            else cout << "yes\n";
        }
    }
    return 0;
}



Measured memory_bytes: 31900
//In the name of God

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

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

const int N = 1e3+10 , mod = 1e9+7;

int a[N] , b[N] , whr[N * N] , whc[N * N] , cntr[N] , cntc[N];
bool mr[N] , mc[N];

int32_t main(){
   ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
   memset(whr , -1 , sizeof(whr));
   memset(whc , -1 , sizeof(whc));
   int n , m;
   cin >> n >> m;
   for(int i = 0 ; i < n ; i++){
      cin >> a[i];
      if(whr[a[i]] != -1)
         return cout << 0 , 0;
      whr[a[i]] = i;
   }
   for(int i = 0 ; i < m ; i++){
      cin >> b[i];
      if(whc[b[i]] != -1)
         return cout << 0 , 0;
      whc[b[i]] = i;
   }
   int ret = 1;
   int r = 0 , c = 0 , cnt = 0;
   for(int i = n * m ; i > 0 ; i--){
      int rr = whr[i] , cc = whc[i];
      if(rr == -1 && cc == -1){
         if(cnt >= r * c)
            return cout << 0 , 0;
         ret = 1ll * ret * (r * c - cnt) % mod;
         cnt++;
         continue;
      }
      if(rr == -1){
         if(mc[cc] || r == 0)
            return cout << 0 , 0;
         c++;
         cnt++;
         ret = 1ll * ret * r % mod;
         continue;
      }
      if(cc == -1){
         if(mr[rr] || c == 0)
            return cout << 0 , 0;
         r++;
         cnt++;
         ret = 1ll * ret * c % mod;
         continue;
      }
      if(mc[cc])
         return cout << 0 , 0;
      c++;
      if(mr[rr])
         return cout << 0 , 0;
      r++;
      cnt++;
   }
   cout << ret;
   return 0;
}


Measured memory_bytes: 8192
from functools import reduce

def main():
    # 初期値用:十分大きい数(100億)
    # 1e10

    # 初期値用:十分小さい数(-100億)
    # -1e10
    
    # 一文字のみを読み込み
    # s = input().rstrip().split(' ')
    
    # スペース区切りで標準入力を配列として読み込み
    # s = input().rstrip().split(' ')

    # 位置文字ずつ標準入力を配列として読み込み
    # s = list(input().rstrip())
    
    N = int(input().rstrip())
    a_list = input().rstrip().split(' ')
    cost = 0
    min_cost = 201 * 201 * 100
    for i in range(-100,101):
        cost = 0
        for a in a_list:
            a_num = int(a)
            cost = cost + (a_num - i) * (a_num-i)
            # print(i,a_num,cost)
        if(cost < min_cost):
            min_cost = cost
            # print('new ans',min_cost)
    print(min_cost)
    
if __name__ == '__main__':
    main()


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

int main(){
    int a,b;
    cin>>a>>b;
    vector<string>s(100);
    rep(i,100){
        if(i<50)s[i]=string(100,'.');
        else s[i]=string(100,'#');
    }
    int y=0,x=0;
    while(--b){
        s[y][x]='#';
        x+=2;
        if(x==100)x=0,y+=2;
    }
    y=51,x=0;
    while(--a){
        s[y][x]='.';
        x+=2;
        if(x==100)x=0,y+=2;
    }
    cout<<100<<" "<<100<<endl;
    rep(i,100){
        cout<<s[i]<<endl;
    }
}

Measured memory_bytes: 3648
def dfs(x):
    ans.append(x)
    if len(str(x))==10:
        return
    
    last=x%10
    
    for i in [last-1,last,last+1]:
        if 0<=i<=9:
            dfs(10*x+i)

k=int(input())
ans=[]
for i in range(1,10):
    dfs(i)
    
ans=sorted(ans)
print(ans[k-1])



Measured memory_bytes: 13884
N = int(input())
A = list(map(int,input().split()))

box = [0]*(N+1)
ans = []
for n in range(N,0,-1):
    c = 0
    for i in range(n,N+1,n):
        c += box[i]
    c %= 2
    if A[n-1] != c:
        box[n] = 1
        ans.append(n)
print(len(ans))
if ans:
    print(*ans)

Measured memory_bytes: 14056
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=200005;
int a[N],b[N],num[N];
int x[100][100];
ll n,m,k;
int main()
{
    scanf("%lld%lld",&n,&m);
 
    if(n%2019==0||m%2019==0) 
	{
		cout<<0<<endl;
		return 0;
	}
	int x1=n/2019;
    int y1=m/2019; 
    
    if(y1>x1)
	{
		cout<<0<<endl;
		return 0;
	}
	if(m-n>=2019)
    {
        printf("0\n");
        return 0;
    }

    if(n%2019>m%2019)
    {
        printf("0\n");
        return 0;
    }
	ll ans=2020;
	for(ll i=n;i<=m;i++)
	{
		for(ll j=i+1;j<=m;j++)
			ans=min((i%2019*j%2019)%2019,ans);
	}
	
   cout<<ans<<endl;
    return 0;
}


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

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

Measured memory_bytes: 256
let n = Scanf.scanf " %d" @@ (+) 0
let a_s = Array.init n @@ fun _ -> Scanf.scanf " %d" @@ (+) 0
let s = ref 0
let r = ref 0
let ans = ref 0
let _ =
  for l = 0 to n - 1 do
    while !r < n && !s lxor a_s.(!r) = !s + a_s.(!r) do s := !s + a_s.(!r); incr r done;
    if l = !r then incr r
    else (ans := !ans + !r - l; s := !s - a_s.(l)) done;
  Printf.printf "%d\n" !ans

Measured memory_bytes: 6272
#include <bits/stdc++.h>
using namespace std;
using ll =long long;
#define all(v) v.begin(),v.end()
 
int main() {
  ll A,B,C;
  cin>>A>>B>>C;
  if(A-B>=C) {
cout<<0<<endl;
  }
  else {
cout<<C-(A-B)<<endl;
  }
}
  

Measured memory_bytes: 3636
#include <cstdio>
#include <cstdlib>
#include <string>
#include <iostream>
using namespace std;

struct BINNODE {
	int key;
	BINNODE *parent;
	BINNODE *left;
	BINNODE *right;

	BINNODE (int k) {
		key=k;
		parent=nullptr;
		left=nullptr;
		right=nullptr;
	}
};

void preorderwalk(BINNODE* root) {
	if(root==nullptr) return;
	printf(" %d",root->key);
	preorderwalk(root->left);
	preorderwalk(root->right);
	return;
}

void inorderwalk(BINNODE* root) {
	if(root==nullptr) return;
	inorderwalk(root->left);
	printf(" %d",root->key);
	inorderwalk(root->right);
	return;
}

int main() {
	int m,v;
	int i;
	string cmd;
	BINNODE* root=nullptr;
	BINNODE* x;
	BINNODE* y;
	BINNODE* z;
	cin >> m;
	for(i=0; i<m; ++i) {
		cin >> cmd;
		if(cmd=="insert") {
			cin >> v;
			z=new BINNODE(v);
			y=nullptr;
			x=root;
			while(x!=nullptr) {
				y=x;
				if (z->key < x->key) {
					x=x->left;
				} else {
					x=x->right;
				}
			}
			z->parent = y;

			if(y==nullptr) {
				root=z;
			} else if(z->key < y->key) {
				y->left = z;
			} else {
				y->right = z;
			}
		} else {
			inorderwalk(root);
			printf("\n");
			preorderwalk(root);
			printf("\n");
		}
	}
	return 0;
}

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

int main() {
  int n, k, q;
  cin>>n>>k>>q;
  int a[n];
  for (int i=0; i<n; i++) cin>>a[i];
  int b[n];
  for (int i=0; i<n; i++) b[i] = a[i];
  sort(b, b + n);
  set<int> sa;
  for (int i=0; i<n; i++) sa.insert(a[i]);
  int ans = b[q-1] - b[0];
  bool can_select[n];
  for (int i=0; i<n; i++) can_select[i] = true;
  for (int v: sa) {
    for (int i=0; i<n; i++) {
      if (a[i] == v) {
        can_select[i] = false;
      }
    }
    vector<int> nums;
    for (int i=0; i<n; i++) {
      if (!can_select[i]) {
        continue;
      }
      int start = i;
      while (i < n && can_select[i]) {
        ++i;
      }
      if (i - start + 1 < k) {
        continue;
      }
      vector<int> list;
      for (int j=start; j<i; j++) {
        list.push_back(a[j]);
      }
      sort(list.begin(), list.end());
      for (int j=0; j<i-start-(k-1); j++) {
        nums.push_back(list[j]);
      }
    }
    if (nums.size() < q) {
      break;
    }
    sort(nums.begin(), nums.end());
    ans = min(nums[q-1] - nums[0], ans);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 384
#include<cstdio>
#include<cstring>
#include<vector>
#include<stack>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<map>
#define maxn 200100
using namespace std;
int main()
{
	int a,b;
	scanf("%d%d",&a,&b);
	int x1=a+b,x2=a-b,x3=a*b;
	int Max=x1;
	Max=max(Max,x2);
	Max=max(Max,x3);
	printf("%d\n",Max);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(), a.end()
#define maxs(x, y) (x = max(x, y))
#define mins(x, y) (x = min(x, y))
#define pb push_back
#define sz(x) (int)(x).size()
#define PQ(T) priority_queue<T, v(T), greater<T>>
#define bn(x) ((1 << x) - 1)
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int mod = 1000000007;

struct mint{
    ll x;
    mint(ll x = 0):x((x%mod+mod)%mod){};
    mint operator-() const{
        return mint(-x);
    }
    mint& operator+=(const mint a){
        if((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a){
        if((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a){
        (x *= a.x) %= mod;
        return *this;
    }

    mint operator+(const mint a) const{
        mint res(*this);
        return res += a;
    }
    mint operator-(const mint a) const{
        mint res(*this);
        return res -= a;
    }
    mint operator*(const mint a) const{
        mint res(*this);
        return res *= a;
    }
    mint pow(ll t) const{
        //愚直にt回書けるとO(t)かかるが，
        //以下の方法でやるとO(log(t))
        //二進数で考えて，一番上の桁から再帰的に計算
        if(!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if(t&1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const{
        return pow(mod-2);
    }
    mint& operator/=(const mint a){
        return (*this) *= a.inv();
    }
    mint operator/(const mint a) const{
        mint res(*this);
        return res/=a;
    }
};

struct combination{
    vector<mint> fact, ifact;
    combination(int n):fact(n+1), ifact(n+1){
        //n < mod という条件を想定しているのだぞ！という主張
        assert(n < mod);
        fact[0] = 1;
        for(int i=1; i<= n; i++) fact[i] = fact[i-1]*i;
        ifact[n] = fact[n].inv();
        for(int i=n; i>=1; i--) ifact[i-1] = ifact[i]*i;
    }
    mint operator()(int n, int k){
        if(k<0 || k>n) return 0;
        return fact[n]*ifact[k]*ifact[n-k];
    }
};

int main(){
    mint n;
    int k;
    cin >> n.x >> k;

    mint ans=0;

    for(int i=k;i<=n.x+1;i++){
        ans = ans + (1 + (n.x+1 - i) * i);
    }

    cout << ans.x << endl;


    return 0;
}

Measured memory_bytes: 3632
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<string>
#include<iostream>
#include<cctype>
#include<cstdio>
#include<vector>
#include<stack>
#include<queue>
#include <algorithm>
#include<math.h>
#include<set>
#include<map>
#include<iomanip>

//#include<bits/stdc++.h>

using namespace std;



int main() {

	long long int a, b;
	cin >> a >> b;

	if (abs(a - b) > 1) {
		cout << 0 << endl;
		return 0;
	}
	long long int x = 1, y = 1;
	for (int i = 1; i <= a; i++) {
		x *= i;
		x %= 1000000007;
	}

	for (int i = 1; i <= b; i++) {
		y *= i;
		y %= 1000000007;
	}

	x *= y;
	x %= 1000000007;

	if (a == b)x *= 2;
	x %= 1000000007;
	cout << x << endl;

	

	return 0;
	
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define PI 3.14159265358979323846
#define MOD 1000000007
#define INF (int)1e9

using namespace std;
using namespace __gnu_pbds;
//typedef tree<TYPE, null_type, less<TYPE>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
//typedef tree<TYPE, null_type, less_equal<TYPE>, rb_tree_tag, tree_order_statistics_node_update> indexed_multiset;

int N, W;
long long A[101], B[101], dp[101][100001];

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> N >> W;
	for(int i = 1; i <= N; i++) cin >> B[i] >> A[i];
	for(int i = 1; i <= 100000; i++) dp[0][i] = -1;
	for(int i = 1; i <= N; i++)
		for(int j = 1; j <= 100000; j++){
			if(j < A[i]) dp[i][j] = dp[i - 1][j];
			else if(dp[i - 1][j] == -1 && dp[i - 1][j - A[i]] == -1) dp[i][j] = -1;
			else if(dp[i - 1][j] == -1) dp[i][j] = dp[i - 1][j - A[i]] + B[i];
			else if(dp[i - 1][j - A[i]] == -1) dp[i][j] = dp[i - 1][j];
			else dp[i][j] = min(dp[i - 1][j], dp[i - 1][j - A[i]] + B[i]);
			if(dp[i][j] > W) dp[i][j] = -1;
		}
	long long mx = 0;
	for(int i = 1; i <= 100000; i++)
		if(dp[N][i] != -1) mx = i;
	cout << mx << "\n";
	return 0;
}


Measured memory_bytes: 79232
#include <bits/stdc++.h>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <vector>
#define LL long long
#define mp make_pair
#define pb push_back
#define INF (1<<29)
using namespace std;
typedef pair<int,int>pii;
int main(){
	int a,b,c;
	cin>>a>>b>>c;
	int t1=abs(b-a)+abs(c-b);//a-b-c
	int t2=abs(b-a)+abs(c-a);
	int t3=abs(b-c)+abs(c-a);
	int t4=abs(b-c)+abs(a-b);
	int t5=abs(c-a)+abs(a-b);
	int t6=abs(c-a)+abs(c-b);
	cout<<min(min(t1,min(t2,t3)),min(t4,min(t5,t6)))<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
 
using namespace std;
typedef long long int ll;
 
int main() {
	ios::sync_with_stdio(0); 
	cin.tie(0);
 
ll n;
cin>>n;
string s;
map<string,ll>m;
m["AC"]=0;
m["WA"]=0;
m["TLE"]=0;

m["RE"]=0;

while(n--)
{
	cin>>s;
	m[s]++;
	}
	
	
	for(auto y: {"AC","WA","TLE","RE"})
	{
	cout<<y<<" x "<<m[y]<<"\n";
			}


	
}
 

Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define all(v) v.begin(),v.end()
#define SZ(v) ((int)v.size())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)
#define bit(n) (1LL<<(n))
#define bit_exist(x, n) ((x >> n) & 1)
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) cout << #v << "=" << endl; REP(i_debug, v.size()){ cout << v[i_debug] << ","; } cout << endl;
#define mdebug(m) cout << #m << "=" << endl; REP(i_debug, m.size()){ REP(j_debug, m[i_debug].size()){ cout << m[i_debug][j_debug] << ","; } cout << endl;}
#define pb push_back
#define f first
#define s second
#define int long long
#define INF 1000000000000000000
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream &operator<<(ostream &os, vector<T> &v){ for(int i = 0; i < v.size(); i++) { cout << v[i]; if(i != v.size() - 1) cout << endl; }; return os; }
template<typename T> void Out(T x) { cout << x << endl; }
template<typename T1, typename T2> void Ans(bool f, T1 y, T2 n) { if(f) Out(y); else Out(n); }

using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using PiP = pair<int, Pii>;
using PPi = pair<Pii, int>;
using bools = vector<bool>;
using pairs = vector<Pii>;

//int dx[4] = {1,0,-1,0};
//int dy[4] = {0,1,0,-1};
//char d[4] = {'D','R','U','L'};

const int mod = 1000000007;
//const int mod = 998244353;
#define Add(x, y) x = (x + (y)) % mod
#define Mult(x, y) x = (x * (y)) % mod



signed main(){
    string N; cin>>N;
    int ans1=0, ans2=0;
    REP(i,N.size()){
        ans1 +=(int)(N[i]-'0');
    }
    ans2 = (int)(N[0]-'0')-1;
    ans2 += 9*(N.size()-1);
    cout<<max(ans1,ans2)<<endl;
}

Measured memory_bytes: 256
# 1<=a,b<=10000
# a,bは整数

#number = input('整数を入力してね > ')
#print (number)
a, b = map(int, input().split())
#print(a, b)
c = a * b
#print(c)
d=c%2
if d==0:
    print('Even')
if d==1:
    print('Odd')

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

int main(){
    vector<int> v(3);
    for(int i=0;i<3;i++) cin>>v[i];
    sort(v.begin(),v.end());
    cout<<v[0]+v[1]<<endl;
}

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

signed main() {
  int N, K;
  cin >> N >> K;
  
  string ng = "";
  string D;
  for( int i = 0; i < K; i++ ){
    cin >> D;
    ng += D;
  }
  
  int ans = N;
  string A;
  bool fg = true;
  while( true ){
    A = to_string(ans);
    fg = true;
    for( int i = 0; i < A.size(); i++ ){
      for( int j = 0; j < ng.size(); j++ ){
        if( A.at(i) == ng.at(j) ) fg = false;
      }
    }
    if( fg == true ){
      cout << ans << endl;
      return 0;
    }
    ans++;
  }
}


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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
string char_to_string(char val) {
    return string(1, val);
}

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

    for(int i = 0; i < s.size(); ++i) {
        if(i == 5 || i == 13) {
            cout << " ";
            continue;
        }
        cout << s[i];
    }
    cout << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <string>
#include <iostream>
#include <queue>
#include <cstring>
using namespace std;
typedef pair<int,int> P;
bool field[101][101]={};
char a[101][101];
int main(){
	int n,m;
	while(scanf("%d %d",&n,&m) && n){
		for(int i=0;i<n;i++){
			scanf("%s",a[i]);
		}
		memset(field,0,sizeof(field));
		queue<P>que;
		que.push(make_pair(0,0));
		while(!que.empty()){
			P p=que.front();
			int x=p.first;
			int y=p.second;
			que.pop();
			if(field[x][y]){
				puts("LOOP");
			}else if(a[x][y]=='>'){
				que.push(make_pair(x,y+1));
			}else if(a[x][y]=='v'){
				que.push(make_pair(x+1,y));
			}else if(a[x][y]=='<'){
				que.push(make_pair(x,y-1));
			}else if(a[x][y]=='^'){
				que.push(make_pair(x-1,y));
			}else{
				printf("%d %d\n",y,x);
			}
			field[x][y]=true;
		}
	}
}

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

int main() {

    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    long long n = 0;
    cin >> n;
    vector<int> v(n, 0);
    for(int i = 0; i < n; i++) cin >> v[i]; 
    vector<int> dp(n, 0);
    long long ans = 0;
    dp[0] = 0;
    dp[1] = abs(v[1] - v[0]);
    for(int i = 2; i < n; i++) {
        dp[i] = std::min(dp[i - 1] + abs(v[i] - v[i - 1]), dp[i - 2] + abs(v[i] - v[i - 2]));
    }
    cout << dp[n - 1] << endl;
    return 0;
}

Measured memory_bytes: 1024
//
// Created by 伊東麻沙美 on 2019/10/22.
//

#include<iostream>
#include<algorithm>
using namespace std;


int main(){

    int A,B;
    cin>>A>>B;

    if(A>(2*B)){
        cout<<A-(2*B)<<endl;
    }else{
        cout<<0<<endl;
    }


    //cin>>a>>b>>x;
    //scanf("%d%s%d",&i,&x,&j);


       // printf("%d",i+j);
       //cout<<i+j<<endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0; i<(n); i++)
#define REPR(i,n) for(int i=n; i>=0; i--)
#define FOR(i,m,n) for(int i=m; i<(n); i++)
#define ALL(v) v.begin(),v.end()
#define INF 2e9
using namespace std;
typedef long long ll;
 
 
int main()
{
    
    int A, B;
    cin >> A >> B;

    if(A*B % 2 == 1){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
counter = [0] * 26
BASE = ?A.ord

$<.each_line do |line|
	line.scan(/[a-z]/i) do |c|
		counter[c.upcase.ord - BASE] += 1
	end
end

('a'..'z').each_with_index do |c, i|
	puts "#{c} : #{counter[i]}"
end

Measured memory_bytes: 6120
p = list(map(int,input().split()))
N = p[0]
K = p[1]
A = list(map(int,input().split()))
A.sort()
variety = 1
series = []
row = 1
for i in range(N-1):
    if A[i] == A[i+1]:
        row += 1
    else:
        series.append(row)
        row = 1
        variety += 1
series.append(row)
series.sort()

ans = 0
for i in range(variety - K):
    ans += series[i]
print(str(ans))

Measured memory_bytes: 24996
n = int(input())
listL = list(map(int, input().split()))

count = 0
for l1 in listL:
    for l2 in listL:
        for l3 in listL:
            if l2 > l1 and l3 > l2 and l1+l2 > l3:
                count+=1
print(count)

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

int main(void){
    
    int seisu;
    cin>>seisu;
    if (seisu % 2 == 0) { //偶数の場合
        int ans=seisu*seisu/4;
        cout<<ans<<endl;
    } else {//奇数の場合
        int ans=(seisu*seisu-1)/4;
        cout<<ans<<endl;
        
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<deque>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;

int A[100010];
bool F[100010];
int main()
{
	int N;
	cin >> N;
	for (int i = 0; i < N; i++) {
		int a;
		cin >> a;
		A[i + 1] = a;
	}
	int ans = 0;
	int b = 1;
	while (b != 2) {
		if (F[b]) {
			cout << -1 << endl;
			return 0;
		}
		F[b] = true;
		ans++;
		b = A[b];
	}
	cout << ans << endl;
}


Measured memory_bytes: 4052
using System;
using System.Linq;
using static System.Console;
class Program
{
    static void Main(string[] args)
    {
        int N = int.Parse(ReadLine());
        string[] strp = ReadLine().Split(' ');
        int[] p = strp.Select(int.Parse).ToArray();
        int count = 0;
        for(int i = 0; i < N; i++)
        {
            if(p[i] != i + 1)
            {
                count++;
            }
        }
        if(count == 2 || count == 0)
        {
            WriteLine("YES");
        }
        else
        {
            WriteLine("NO");
        }

    }
}

Measured memory_bytes: 13396
#include <iostream>
#include <algorithm>
using namespace std;
 
int main() {
	int n;
	int map[2][100];
	int ans = 0;
 
	cin >> n;
	for (int i=0; i<2; i++) {
		for (int j=0; j<n; j++) {
			cin >> map[i][j];
		}
	}
 
	for (int x=0; x<n; x++) {
	    int cnt = 0;
		for (int i=0; i<=x; i++) cnt += map[0][i];
		for (int i=x; i<n; i++) cnt += map[1][i];
		ans = max(cnt, ans);
	}
 
	cout << ans << endl;
 
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <string>
#include <algorithm>
#include <vector>
#include <cstring>

using namespace std;

int a[128], e[128], r[128];
int memo[128][128];
int D, N;

int getMin(int left, int exp)
{
	if (left <= 0) return (0);
	if (memo[left][exp] >= 0) return (memo[left][exp]);
	
	int ans = 99999;
	
	for (int i = 0; i < N; i++){
		if (exp == 100 && a[i] == 0) continue;
		if (r[i] <= exp && !(a[i] == 0 && e[i] == 0))
			ans = min(ans, getMin(left - a[i], min(100, exp + e[i])) + 1);
	}
	
	return (memo[left][exp] = ans);
}

int main()
{
	
	while (scanf("%d %d", &D, &N) && N){
		bool e0 = false;
		for (int i = 0; i < N; i++){
			scanf("%d %d %d", a + i, e + i, r + i);
			if (r[i] == 0) e0 = true;
		}
		
		memset(memo, -1, sizeof(memo));
		int ans = getMin(D, 0);
		
		if (ans >= 99999) printf("NA\n");
		else printf("%d\n", ans);
	}
	
	return (0);
}

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

int number = 1000000007;

int main() {
  int64_t n,a = 1, b = 1, c = 1, ans;
  cin >> n;
  for(int i = 0; i < n; i++) {
    a = (a*10)%number;
    b = (b*9)%number;
    c = (c*8)%number;
  }
  b= (b*2)%number;
  ans = (a-b+c)%number;
  if(ans<0)
    ans+=number;
  cout << ans << endl;
}

Measured memory_bytes: 3624
#include<stdio.h>
#define MAX 250

int main()
{
  int H,A[MAX+1],i;
  
  scanf("%d",&H);
  for(i=1;i<=H;i++)
    {
      scanf("%d",&A[i]);
    }

  for(i=1;i<=H;i++)
    {
      printf("node %d: key = %d, ",i,A[i]);
      if(i>1) printf("parent key = %d, ",A[i/2]);
      if(H>=2*i) printf("left key = %d, ",A[2*i]);
      if(H>=(2*i+1)) printf("right key = %d, ",A[2*i+1]);
      printf("\n");
    }
  return 0;
}



Measured memory_bytes: 2052
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(ll i = n;i >= 0;--i)
#define FOR(i,m,n) for(ll i = m, i##_len=(n);i <i##_len; ++i)
#define all(x) (x).begin(),(x).end()
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; }
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
const int INF = 1e9;
const ll LLINF = 1e16;
 
ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}


int main(void)
{
    ll n;
    cin >> n;
    vector<ll> p(n);
    REP(i,n){
        cin >> p[i];
    }

    ll cnt = 0;
    ll icnt = 0;
    for (int i = 0; i < n; i++)
    {
        if(p[i] == i+1){
            icnt++;
        }
        else{
            cnt += icnt / 2 + icnt % 2;
            icnt = 0;
        }
    }

    if(icnt != 0){
        cnt += icnt / 2 + icnt % 2;
    }

    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#define int long long
using namespace std;

signed main() {
    int N, A, B;
    cin >> N >> A >> B;
    if ((B - A) % 2 == 0) {
        cout << (B - A) / 2 << endl;
        return 0;
    }
    
    int a = A + (B - A - 1) / 2;
    int b = N - B + 1 + (B - A - 1) / 2;
    if (a < b) cout << a << endl;
    else cout << b << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scn  = new Scanner(System.in);
        strong_palindrome(scn.next());
    }
    static  void  strong_palindrome(String word){

        if(palindrome(word) != word){
            System.out.println("No");
            return;
        }
        String fp = word.substring(0, (word.length()-1)/2);
        String sp = word.substring((word.length()-1)/2+1);
        if(palindrome(fp) != fp || palindrome(sp) != sp){
            System.out.println("No");
            return;
        }
        System.out.println("Yes");

    }
    static String palindrome(String word){
        for(int i = word.length()-1; i >= 0; i--){
            if(word.charAt(i) != word.charAt(word.length()-1-i)){
                return "";
            }
        }
        return  word;
    }

}


Measured memory_bytes: 23760
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
#include <array>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <utility>
#include <functional>

using namespace std;
using lli = long long int;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0) 
{ v = vector<T>(n+o); for (lli i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> void read_n(T a[], size_t n, size_t o = 0)
{ for (lli i=o; i<n+o; ++i) cin >> a[i]; }
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs

lli n, a[100001], ia[100001];
int main() {
  cin >> n;
  read_n(a, n);

  iota(&ia[0], &ia[n], 0);
  sort(&ia[0], &ia[n], [&](lli i, lli j) { return a[i] < a[j]; });

  lli ans = 0;
  for (lli i=0; i<n; i+=2) {
    if (ia[i]%2 != 0) ++ans;
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 1792
#include <iostream>

using namespace std;

int N;


int main()
{
	long long ans = 0;

	cin >> N;

	int min_abs = 1000000001;
	bool minus_odd = false;
	int tmp;

	for (int i = 0;i<N; i++) {
		cin >> tmp;
		if (tmp < 0) {
			minus_odd = !minus_odd;
			tmp *= -1;
		}
		min_abs = min(min_abs,tmp);
		ans += tmp;
	}

	if (minus_odd) {
		ans -= min_abs * 2;
	}


	cout << ans << endl;

	return 0;
}


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

typedef long long ll;
#define rep(i,n) for(i=0;i<n;++i)
#define each(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); itr++)
#define mp make_pair
#define pb push_back
#define fi first
#define sc second

char f[1000][1000];
int dp[1000][1000];

int main(int argc, char const *argv[]) {
  int i,j;
  while(1){
    int n;
    cin >>n;
    if(n==0) break;

    rep(i,n)rep(j,n) scanf(" %c", &f[i][j]);
    memset(dp,0,sizeof(dp));

    rep(i,n){
      if(f[0][i]!='*') dp[0][i]=1;
      if(f[i][0]!='*') dp[i][0]=1;
    }

    for(i=1; i<n; ++i){
      for(j=1; j<n; ++j){
        if(f[i][j]=='*') dp[i][j]=0;
        else dp[i][j]=min( dp[i][j-1], min(dp[i-1][j-1],dp[i-1][j]) )+1;
      }
    }

    /*
    rep(i,n){
      rep(j,n) printf("%2d ",dp[i][j]);
      printf("\n");
    }
    */
    
    int ans=0;
    rep(i,n)rep(j,n) ans=max(ans,dp[i][j]);

    std::cout << ans << std::endl;
  }
  return 0;
}

Measured memory_bytes: 6084
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
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; }
const ll INF = 1LL << 60;
const int MAX = 1000000010;
const ll MOD = 1000000007;
const double PI = acos(-1);

int main () {
    int x, n; cin >> x >> n;
    vector<bool> P(101, true);
    for (int i = 0; i < n; i++) {
        int p; cin >> p;
        P[p] = false;
    }

    int MIN = 101;
    int ans;
    if (chmin(MIN, x)) ans = 0;
    for (int i = 1; i <= 100; i++) {
        if (P[i]) {
            if (chmin(MIN, abs(x - i))) ans = i;
        }
    }
    if (chmin(MIN, abs(x - 101))) ans = 101;

    cout << ans << endl;
    return 0;
}

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

#define LOCAL 0

#define lli long long int
#define llu unsigned long long int
#define ld long double
#define all(v) v.begin(),v.end()
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define si(n) scanf("%d",&n)
#define slli(n) scanf("%lld",&n);
#define ss(n) scanf("%s",n);

const long double EPS = 1e-10;
const int MOD = 1000000007ll;
const int mod1 = 1000000009ll;
const int mod2 = 1100000009ll;
int INF = (int)1e9;
lli INFINF = (lli)1e18;
int debug = 0;
long double PI = acos(-1.0);

using namespace std;

int bit_count(lli _x){lli _ret=0;while(_x){if(_x%2==1)_ret++;_x/=2;}return _ret;}
int bit(lli _mask,int _i){return (_mask&(1ll<<_i))==0?0:1;}
int add(int a,int b,int m=MOD){int x=a+b;while(x>=m)x-=m;while(x<0)x+=m;return x;}
int sub(int a,int b,int m=MOD){int x=a-b;while(x<0)x+=m;while(x>=m)x-=m;return x;}
int mul(int a,int b,int m=MOD){lli x=a*1ll*b;x%=m;while(x<0)x+=m;return (int)x;}
int ldtoint(ld x){return (int)(x+0.5);}lli ldtolli(ld x){return (lli)(x+0.5);}
int powermod(lli _a,lli _b,int _m=MOD){lli _r=1;while(_b){if(_b%2==1)_r=mul(_r,_a,_m);_b>>=1;_a=mul(_a,_a,_m);}return _r;}

template<class T1,class T2>ostream&operator<<(ostream& os,const pair<T1,T2>&p){os<<"["<<p.first<<","<<p.second<<"]";return os;}
template<class T>ostream&operator<<(ostream& os,const vector<T>&v){os << "[";bool first=true;for (T it:v){if (!first)os<<", ";first = false;os<<it;}os<<"]";return os;}
template<class T>ostream&operator<<(ostream& os,set<T>&v){os<<"[";bool first=true;for (T it:v){if(!first)os<<", ";first=false;os<<it;}os<<"]";return os;}
template<class T1,class T2>ostream&operator<<(ostream& os,map<T1,T2>&v){os<<"[";bool first=true;for(pair<T1,T2> it:v){if(!first)os<<", ";first=false;os<<"("<<it.F<<","<<it.S<<")";}os<<"]";return os;}
template<class T>void parr(T a[],int s,int e){cout<<"[";for(int i=s;i<e;i++)cout<<a[i]<<", ";cout<<a[e]<<"]\n";}

lli N;
lli A[100010];

int main()
{
if(LOCAL){
    freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    debug = 1;
}
    srand (time(NULL));

    vector<lli> odd,even;
    cin>>N;
    for(int i=1;i<=N;i++){
        lli x;
        cin>>x;
        if(x&1)
            odd.pb(x);
        else
            even.pb(x);
    }
    while(odd.size()>=2 || even.size()>=2){
        if(odd.size()>=2){
            int x = odd.back();
            odd.pop_back();
            x += odd.back();
            odd.pop_back();
            even.pb(x);
            continue;
        }
        else{
            int x = even.back();
            even.pop_back();
            x += even.back();
            even.pop_back();
            even.pb(x);
            continue;
        }
    }
    if(odd.size() + even.size() == 1){
        cout<<"YES\n";
    }
    else
        cout<<"NO\n";

    return 0;
}


Measured memory_bytes: 1908
#include <cstdio>
#define max(x, y) ((x) < (y) ? (y) : (x))

int main() {
  int n, k, x, y;
  scanf("%d %d %d %d", &n, &k, &x, &y);
  printf("%d\n", x * n + (y - x) * max(n - k, 0));
}

Measured memory_bytes: 128
first = True
while True:
    n = input()
    res = []
    if n==0:
        break
    if not first:
        print
    for i in xrange(n):
        res.append((lambda s: (s[0], 3*int(s[1])+int(s[3])))(raw_input().split()))
    res.sort(cmp=lambda x, y: y[1]-x[1])
    for e in res:
        print "%s,%d" % (e[0], e[1])
    first = False

Measured memory_bytes: 4228
#define DEBUG 0

/**
 * File    : E.cpp
 * Author  : Kazune Takahashi
 * Created : 2019-6-1 23:15:51
 * Powered by Visual Studio Code
 */

#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <string>
#include <complex>
#include <tuple>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <random>
#include <chrono>
#include <cctype>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
using namespace std;

typedef long long ll;

/*
void Yes()
{
  cout << "Yes" << endl;
  exit(0);
}

void No()
{
  cout << "No" << endl;
  exit(0);
}
*/

/*
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
*/

// const ll MOD = 1000000007;

const int MAX_SIZE = 1000010;
const long long MOD = 1e6 + 3;

long long inv[MAX_SIZE];
long long fact[MAX_SIZE];
long long factinv[MAX_SIZE];

void init()
{
  inv[1] = 1;
  for (int i = 2; i < MAX_SIZE; i++)
  {
    inv[i] = ((MOD - inv[MOD % i]) * (MOD / i)) % MOD;
  }
  fact[0] = factinv[0] = 1;
  for (int i = 1; i < MAX_SIZE; i++)
  {
    fact[i] = (i * fact[i - 1]) % MOD;
    factinv[i] = (inv[i] * factinv[i - 1]) % MOD;
  }
}

long long C(int n, int k)
{
  if (n >= 0 && k >= 0 && n - k >= 0)
  {
    return ((fact[n] * factinv[k]) % MOD * factinv[n - k]) % MOD;
  }
  return 0;
}

long long power(long long x, long long n)
{
  if (n == 0)
  {
    return 1;
  }
  else if (n % 2 == 1)
  {
    return (x * power(x, n - 1)) % MOD;
  }
  else
  {
    long long half = power(x, n / 2);
    return (half * half) % MOD;
  }
}

long long gcd(long long x, long long y)
{
  return y ? gcd(y, x % y) : x;
}

int main()
{
  init();
  int Q;
  cin >> Q;
  while (Q--)
  {
    ll x, d, n;
    cin >> x >> d >> n;
    if (d == 0)
    {
      cout << power(x, n) << endl;
      continue;
    }
    else
    {
      x = (x * inv[d]) % MOD;
      if (x + n - 1 >= MOD)
      {
        cout << 0 << endl;
        continue;
      }
      ll ans = power(d, n);
      ans *= (fact[x + n - 1] * factinv[x - 1]) % MOD;
      ans %= MOD;
      cout << ans << endl;
    }
  }
}

Measured memory_bytes: 24320
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main()
{
    ll n,no=0,i,q;
    cin>>n;
   if(n<8){
    if(n==2)
        cout<<"2"<<endl;
    else if(n==3)
        cout<<"3"<<endl;
    else if(n==4 || n==5)
        cout<<"5"<<endl;
    else if(n==6 || n==7)
        cout<<"7"<<endl;
   }
   else{
    while(1){
        //cout<<n;
        q = sqrt(n);
        for(i=2;i<=q;i++){
            if(n%i==0){
                no= 1;
                break;}
        }
      //  cout<<"\tno = "<<no<<endl;
        if(no==0){
        cout<<n<<endl;
        break;}
        no = 0;
        n++;
    }
   }
}


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

using namespace std;
#define ll long long

ll INF = 1e18;

int getVal( ll &N, ll a)
{
    int num = 0;
    while((N %a == 0))
    {
        num++;
        N = N/a;
    }

    int ans = 0;
    int val = 0;
    for(int i =1; i<=num;i++)
    {
        val += i;
        if(val > num)
            break;
        ans = i;
    }
    return ans;
}

bool isPrime( ll n)
{
    if( n < 2)
        return false;
    
    for(ll i = 2; i*i <=n;i++)
    {
        if(n%i == 0)
            return false;
    }
    return true;
}

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

    if(isPrime(N))
    {
        cout<<1<<endl;
        return 0;
    }

    ll st = sqrt(N);
    vector<ll> prime;
    for(ll i=2;i*i<=N;i++)
    {
        if(isPrime(i))
        {
            prime.push_back(i);
        }
    }

    int ans = 0;
    for(int i=0;i<prime.size();i++)
    {
        if(N%prime[i] == 0)
        {
            int val = getVal( N,prime[i]);
            ans += val;
            //cout<<prime[i]<<" "<<ans<<endl;
            if(N <2)
                break;
            if(isPrime(N))
                {
                    ans++;
                    break;
                }
        }
    }

    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 4264
#include<iostream>
#include<string>
#include<queue>
#include<vector>
using namespace std;
const int INF=1000000000;
typedef pair<int,int> Q;
typedef pair<int,Q> P;
struct eage{int d;int cost;};
int main(){
	int D[1<<9][205],ans=INF;
	for(int i=0;i<257;++i){
		for(int j=0;j<205;++j){
			D[i][j]=INF;
		}
	}
	int R,r[8];
	int N,M,A,B,C,s=1;
	cin>>N>>M>>R;
	vector<eage> v[205];
	priority_queue<P,vector<P>,greater<P> >que;

	for(int i=0;i<R;++i){
		cin>>r[i];
		que.push(P(0,Q(s,r[i])));
		s=s<<1;
	}
	for(int i=0;i<M;++i){
		cin>>A>>B>>C;
		v[A].push_back(eage{B,C});
		v[B].push_back(eage{A,C});
	}

	while(!que.empty()){
		P p=que.top();que.pop();
		int c1=p.first,s1=p.second.first,v1=p.second.second;
//		cout<<c1<<" "<<s1<<" "<<v1<<endl;
		if(D[s1][v1]<c1)continue;
		D[s1][v1]=c1;
		if(s1==(1<<R)-1)continue;
		for(int i=0;i<v[v1].size();++i){
			int s2=s1;
			for(int j=0;j<R;++j) if(v[v1][i].d==r[j]) s2=s2|1<<j;
			if(D[s2][v[v1][i].d]>c1+v[v1][i].cost){
				que.push(P(c1+v[v1][i].cost,Q(s2,v[v1][i].d)));
				D[s2][v[v1][i].d]=c1+v[v1][i].cost;
			}
		}
	}
	for(int i=0;i<R;++i)ans=min(ans,D[(1<<R)-1][r[i]]);
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 4088
nums = input()


for i in range(8):
    operands = []
    sum_num = int(nums[0])
    for j in range(3):
        if i >> j & 1:
            sum_num += int(nums[j+1])
            operands.append("+")
        else:
            sum_num -= int(nums[j+1])
            operands.append("-")
    if sum_num == 7:
        result = []
        operands.append("")
        for num, operand in zip(nums, operands):
            result.append(num)
            result.append(operand)
        print("".join(result) + "=7")
        break


Measured memory_bytes: 3064
import math
import sys


def Knight():
    def check(d):
        if (d[0] + d[1]) % 3 or d[0] < 0 or d[1] < 0:
            print(0)
            sys.exit()
    d = list(map(int, input().split()))
    check(d)

    x = d[0]
    y = d[1]
    diff = x - y if x > y else y - x  # aとbの回数の差
    d2 = [x - diff, y - diff * 2] if x < y else [x - diff * 2, y - diff]
    r = d2[0] // 3

    def cmb(n, r, mod):
        if (r < 0 or r > n):
            return 0
        r = min(r, n-r)
        return g1[n] * g2[r] * g2[n-r] % mod

    mod = 10**9+7  # 出力の制限
    N = x if x > y else y
    g1 = [1, 1]  # 元テーブル
    g2 = [1, 1]  # 逆元テーブル
    inverse = [0, 1]  # 逆元テーブル計算用テーブル

    for i in range(2, N + 1):
        g1.append((g1[-1] * i) % mod)
        inverse.append((-inverse[mod % i] * (mod//i)) % mod)
        g2.append((g2[-1] * inverse[-1]) % mod)

    a = cmb(r*2+diff, r, mod)

    print(a)


Knight()


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

#define F first
#define S second
#define PB push_back
#define MP make_pair
#define mod 1000000007;

typedef long long ll; 
typedef pair<int, int> ii; 
typedef vector<ii> vii;
typedef vector<int> vi;
typedef vector<ll> vll;

// Print fn to print array

int main(){
	int n,m;
	cin >> n >> m;
	if(n<=9 && m<=9){
		cout << n*m << endl;
	}
	else cout << -1 << endl;
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<map>
#include<set>
#include<vector>
#include<cstring>
#include<cassert>
#include<sstream>
#include<cmath>
#include<algorithm>
#include<queue>
#include<limits>
#include<ctime>
#include<stack>
#include<bits/stdc++.h>
#include<string>
#include<stdlib.h>
#include<stdio.h>
#define long long

using namespace std;
int main() {
	int n,l;
	cin>>n>>l;
	string a[n];
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	sort(a,a+n);
	for(int i=0;i<n;i++){
		cout<<a[i];
	}
	
}


Measured memory_bytes: 3612
package main

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

var sc = bufio.NewScanner(os.Stdin)

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

func main(){
  s := nextInt()
  sc.Scan()
  var t string = sc.Text()
  if s >= len(t){
    fmt.Println(t)
  }else{
     fmt.Println(t[0:s] + "...")
  }
 
  
}

Measured memory_bytes: 1760