akhauriyash/Code-Regression huggingface dataset:
#pragma region cp-helper
#include <bits/stdc++.h>
using namespace std;
#define AC ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define int long long
#define ll long long
#define ull unsigned long long
#define ii pair<ll, ll>
#define lll pair<ll, ll>
#define vi vector<int>
#define vvi vector<vi>
#define vl vector<ll>
#define vll vector<lll>
#define vvl vector<vl>
#define vii vector<ii>
#define all(a) a.begin(), a.end()
#define qsort(a) sort(all(a))
#define qsortd(a) sort(all(a), greater<>())
#define qsortf(a, f) sort(all(a), f)
#define pb(n) push_back(n)
#define eb(n) emplace_back(n)
#define pp(a, b) emplace_back(a, b)
#define umap unordered_map
#define uset unordered_set
#define nl '\n'
#define fileio(in, out) freopen(in, "r", stdin); freopen(out, "w", stdout)
#define qmod %mod
#define pls signed
#define give main()
const int mod = 1000000007;
#pragma endregion

const int N = 100005;
int num_groups, p[N], grpsize[N], ans[N], n, m, k, a, b;
set<int> fr[N];
int par(int x) { return (p[x]==x)? x:par(p[x]); } //No compression
bool isSameGroup(int a, int b) { return par(a) == par(b); }
void merge(int a, int b) {
    a = par(a), b = par(b);
    num_groups -= (!isSameGroup(a, b));
    if (grpsize[a] < grpsize[b]) {
        p[a] = b;
        grpsize[b] += grpsize[a];
    }
    else {
        p[b] = a;
        grpsize[a] += grpsize[b];
    }
}

pls give {
    AC;
    for (int i = 0; i < N; ++i) p[i] = i, grpsize[i] = 1;
    cin >> n >> m >> k;
    for (int i=0; i<m; i++) {
        cin >> a >> b;
        if (!isSameGroup(a, b)) merge(a, b);
        fr[a].insert(b);
        fr[b].insert(a);
    }
    for (int i=1; i<=n; i++) {
        ans[i] = grpsize[par(i)];
    }
    for (int i=0; i<k; i++) {
        cin >> a >> b;
        if (isSameGroup(a, b)) {
            fr[a].insert(b);
            fr[b].insert(a);
        }
    }
    for (int i=1; i<=n; i++) cout << ans[i] - fr[i].size() - 1 << ' ';
    cout << nl;
 }

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

#include <atcoder/all>
typedef long long lint;
using namespace std;
using namespace atcoder;

int main() {
    int n, q;
    cin >> n >> q;
    dsu d(n);
    for (int i = 0; i < q; i++) {
        int t;
        cin >> t;
        if (t == 0) {
            int u, v;
            cin >> u >> v;
            d.merge(u, v);
        } else {
            int u, v;
            cin >> u >> v;
            int ans = d.same(u, v) ? 1 : 0;
            cout << ans << endl;
        }
    }
}

Measured memory_bytes: 3912
#include <bits/stdc++.h>
#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long
const int inf = 0x3f3f3f3f3f3f3f3LL;
const int mod = (int)1e9 + 7;
using namespace std;
#if LOCAL
#include "../../tr.h"
#else
#define tr(...)
#define endl '\n'
#endif
template<class T, class T2> void smin(T& a, T2 val) {if (a > val) a = val;}template<class T, class T2> void smax(T& a, T2 val) {if (a < val) a = val;}
const int N = 5*(int)1e5 + 10;

int n;

int32_t main(){_
   
   cin>>n;
   vector<int> a(n);

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

   int ans = 0;
   for (int i = 0; i < n; ++i)
   {
      int idx = a[i];
      if (idx - 1 >= 0){
         smax(dp[idx], dp[idx-1] + 1);
      }
      else{
         dp[idx] = 1;
      }
      smax(ans, dp[idx]);
   }
      
   cout<<n - ans;

   return 0;
}

Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pi 3.141592653589793238
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
ll MOD=1e9+7;

void solve()
{
	double n,d;
	cin>>n>>d;
	ll ans=0;
	for(double i=0;i<n;i++)
	{
		double x,y;
		cin>>x>>y;
		if(x*x+y*y<=d*d)
			ans++;
	}
	cout<<ans;
	return;
}
int main()
{
        fast;
        ll q;
        q=1;
        // cin>>q;
        while(q--)
        	solve();
        
        return 0;
}

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

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) (r).begin(),(r).end()
#define gsort(st,en) sort((st),(en),greater<int>())
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using dict = map<string,int>;
using pii = pair<int,int> ;

const int mod = 1000000007;
constexpr int imax = ((1<<30)-1)*2+1 ;
constexpr int inf = 100000000;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0};
const int dx[] = {0,-1,0,1};

inline bool value(int x,int y,int w,int h){
  return (x >= 0 && x < w && y >= 0 && y < h);
}

template<typename T>
void Unique(vector<T> &v){
  sort(all(v));
  v.erase(unique(all(v)),v.end());
}

template<typename T>
T ston(string& str, T n){
  istringstream sin(str) ;
  T num ;
  sin >> num ;
  return num ;
}

void Ans(bool f){
  if(f) cout << "YES"<<endl;
  else cout << "NO"<<endl;
}

int m, n;
bool check(vector<int> v,int mid){
  int h = 1;
  int w = 0;
  rep(i,n){
    if(v[i] > mid){
      return false;
    }
    if(w + v[i] <= mid){
      w += v[i];
    }
    else{
      w = v[i];
      ++h;
    }
  }
  if(h > m){
    return false;
  }
  return true;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  while(cin >> m >> n&&m&&n){
    vary(int,v,n,0);
    rep(i,n){
      cin >> v[i];
    }
    int lb = -1,ub = 1500001;
    while(1){
      int mid = (lb+ub)/2;
      if(mid == ub) break;
      if(check(v,mid)){
        ub = mid;
      }
      else{
        lb = mid+1;
      }
    }
    cout << ub << endl;
  }
  return 0;
}

Measured memory_bytes: 3140
#include <stdio.h>
long long int ncr(long long int n,long long int r){
    static long long int memo[1000][1000];
    if(r<0 || r>n)
        return -1;
    if(r==0 || n==r)
        return 1;
    if(memo[n][r])
        return memo[n][r];
    else
        return memo[n][r]=ncr(n-1,r)+ncr(n-1,r-1);
}
main(){
    int N,P;
    scanf("%d %d",&N,&P);
    int k=0,g=0;
    int i,j,t;
    for(i=0;i<N;i++){
        scanf("%d",&t);
        if(t%2)
            k++;
        else
            g++;
    }
    long long r1=0,r2=0;
    for(i=0;i<=g;i++)
        r1+=ncr(g,i);
    for(i=P;i<=k;i+=2)
        r2+=ncr(k,i);
    printf("%lld\n",r1*r2);
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
 
using namespace std;
 
#define INF 1001000100010001000
#define MOD 1000000007
#define EPS 1e-10
#define int long long
#define rep(i, N) for (int i = 0; i < N; i++)
#define Rep(i, N) for (int i = 1; i < N; i++)
#define For(i, a, b) for (int i = (a); i < (b); i++)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define i_i pair<int, int>
#define vi vector<int>
#define vvi vector<vi >
#define vb vector<bool>
#define vvb vector<vb >
#define vp vector< i_i >
#define all(a) (a).begin(), (a).end()
#define Int(x) int x; scanf("%lld", &x);
#define int2(x, y) int x, y; scanf("%lld %lld", &x, &y);
 
//int dxy[5] = {0, 1, 0, -1, 0};
// assign
 
signed main()
{
    Int(n);
    int ans = INF;
    vi data(n);
    rep(i, n) cin >> data[i];

    for (int i = -100; i < 101; i++) {
        int tmp = 0;
        rep(j, n) {
            tmp += (i - data[j]) * (i - data[j]);
        }
        ans = min(ans, tmp);
    }
    cout << ans << endl;


    return 0;
}



Measured memory_bytes: 256
#pragma GCC optimize("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target ("avx")
#include <bits/stdc++.h>
constexpr int INF = 2147483647;
constexpr long long int INF_LL = 9223372036854775807;
constexpr int MOD = 1000000007;
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

int main() {
	int D, G;
	cin >> D >> G;
	vector<int> p(D), c(D);
	for (int i = 0; i < D; i++) {
		cin >> p[i] >> c[i];
	}

	int ans = INF;
	for (int i = 0; i < (1 << D); i++) {
		vector<bool> solve(D);
		for (int j = 0; j < D; j++) {
			if (i & (1 << j))solve[j] = true;
		}
		int score = 0, solvedprob = 0;
		for (int j = 0; j < D; j++) {
			if (solve[j]) {
				score += p[j] * (j + 1) * 100 + c[j];
				solvedprob += p[j];
			}
		}

		if (score < G) {
			for (int j = D - 1; j >= 0; j--) {
				if (!solve[j]) {
					for (int k = 0; k < p[j]; k++) {
						score += (j + 1) * 100;
						solvedprob++;
						if (score >= G)goto aa;
					}
				}
			}
		}
		; aa:
		ans = min(solvedprob, ans);
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
#define int64 long long int
int64 merge(int64 A,int64 B,int64 C,int64 D){
	if(B < C)return B - A + 1 + D - C + 1;
	return D - A + 1;
}
int64 to(int64 E,int L){
	bool flag = false;
	int64 res = E;
	for(int i=L-1; i>=0; i--){
		if(E & (1LL<<i))flag = true;
		if(flag)res |= 1LL<<i;
	}
	return res;
}
int64 calc(int64 S,int64 E){
	if(E <= 1)return E - S + 1;
	
	int L = 0;
	while((1LL << L) <= E) L++; --L;
	if(S & (1LL << L))
		return calc(S - (1LL<<L), E - (1LL << L));

	return merge(S,to(E,L),(1LL<<L) + S, (1LL << (L+1))-1);
}
int main(){
	int64 A, B;
	cin >> A >> B;
	cout << calc(A,B) << endl;
	return 0;
}

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

#define ll long long
#define vl vector<ll>
#define vvl vector<vl >
#define pl pair<ll,ll>
#define vpl vector<pl >
#define vvpl vector<vp >
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define wt ll tc; cin>>tc; while(tc--)
#define ft ll tc,ti; cin>>tc; for(ti=1;ti<=tc;ti++)
#define fd(c,element) ((c).find(element)!=(c).end())
#define fdv(c,element) (find(all(c),element)!=(c).end())
#define fio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define pb push_back
#define mp make_pair

int main() {
    fio;
    ll i,j,n,c=0;
    cin>>n;
    ll a[n],m[n-1];
    for(i=0;i<n;i++) cin>>a[i];
    m[0]=a[0];
    for(i=1;i<n-1;i++) m[i]=max(m[i-1],a[i]);
    for(i=1;i<n;i++) {
    	if(m[i-1]<=a[i]) c++;
    }
    cout<<c+1;
}

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

typedef struct _Node {
    int x;
    struct _Node *prev;
    struct _Node *next;
} Node;

Node *head = NULL, *tail = NULL;

/* Print all elements to stdin */
void dump() {
    int hoge = 0;
    Node *p = head;
    while (p != NULL) {
        if (hoge == 0)  printf("%d",  p->x);
        else            printf(" %d", p->x);
        ++hoge;
        p = p->next;
    }
    printf("\n");
}

void insert(int x) {
    Node *nod = malloc(sizeof(Node));;
    nod->x = x;
    nod->prev = NULL;
    nod->next = NULL;

    if (head == NULL) {
        head = nod;
        tail = nod;
    } else {
        nod->next = head;
        head->prev = nod;
        head = nod;
    }
    //dump();

}

void delete(int x) {
    Node *p = head;
    int flg = 0;
    
    while (flg == 0 && p != NULL) {
        //printf("x = %d\n", p->x);
        if (p->x == x) {
            Node *c = p;
            if (c->prev != NULL) {
                p->prev->next = c->next;
            } else {    /* if delete head */
                head = c->next;
            }
            
            if (c->next != NULL) {
                p->next->prev = c->prev;
            } else {    /* if delete tail */
                tail = c->prev;
            }
            flg = 1;
        } else {
            p = p->next;
        }
    }
}

void deleteFirst() {
    if (head == tail) {
        head = NULL;
        tail = NULL;
    } else if (head != NULL) {
        if (head->next != NULL) head->next->prev = NULL;
        head = head->next;
    }
}

void deleteLast() {
    if (head == tail) {
        head = NULL;
        tail = NULL;
    } else if (tail != NULL) {
        if (tail->prev != NULL) tail->prev->next = NULL;
        tail = tail->prev;
    }
}

int main(int argc, char **argv) {

    int n;
    scanf("%d\n", &n);

    int i;
    int x;
    char buf[256];
    char tmp[256];
    for (i = 0; i < n; ++i) {
        fgets(buf, 256, stdin);
        
        if (buf[0] == 'i' || buf[6] == ' ') {
            /* read x */
            sscanf(buf, "%s %d", tmp, &x);

            if (buf[0] == 'i') insert(x);
            else               delete(x);     
        } else if (buf[6] == 'F') {
            deleteFirst();
        } else if (buf[6] == 'L') {
            deleteLast();
        }
    }

    dump();
    
    return 0;
}

Measured memory_bytes: 36112
#include<stdio.h>
int main(void){
	int n,q;
	scanf("%d %d\n",&n,&q);
	char s[n];
	scanf("%s",s);
	int i=0;
	int h[n];
	h[0]=0;
	for(i=0;i<n-1;i++){
		if(s[i]=='A'&&s[i+1]=='C') h[i+1] = 1+h[i];
		else h[i+1]=h[i];
	}
	int k[2][q];
	for(i=0;i<q;i++)scanf("%d %d\n",&k[0][i],&k[1][i]);
	for(i=0;i<q;i++){
		printf("%d\n",h[k[1][i]-1]-h[k[0][i]-1]);
	}
	return 0;
}

Measured memory_bytes: 2048
#include <iostream>
#include <cstdio>
#include <algorithm>
#define N 100005
using namespace std;

typedef long long ll;
ll n, s, a[3 * N];
int main()
{
	ll i;
	cin >> n;
	for (i = 0; i < 3 * n; i++) scanf("%lld", &a[i]);
	sort(a, a + 3 * n);
	for (i = 3 * n - 2; i >= n; i -= 2) s += a[i];
    cout << s << endl;
    return 0;
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std ;
#define ll long long int 
#define pb push_back 
#define mp make_pair 
#define pii pair <int , int > 
#define pll pair < ll , ll >
int main(){
	ios_base::sync_with_stdio(false) ;
	cin.tie(NULL) ;
	ll r ;
  cin >> r ;
  cout << 3*r*r ;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, e) for (int i = (int)(s); i <= (int)(e); i++)
#define printYesNo(is_ok) puts(is_ok ? "Yes" : "No");
#define SORT(v) sort(v.begin(), v.end());
#define RSORT(v) sort(v.rbegin(), v.rend());
#define REVERSE(v) reverse(v.begin(), v.end());

template <typename T>
void printlnVector(T v)
{
  rep(i, v.size())
  {
    cout << v[i] << endl;
  }
}

template <typename T>
void printVector(T v)
{
  rep(i, v.size())
  {
    cout << v[i] << " ";
  }
  cout << endl;
}

int main()
{
  string N;
  cin >> N;
  bool is_ok = false;
  if (N[0] == '7' || N[1] == '7' || N[2] == '7')
    is_ok = true;
  printYesNo(is_ok);
  return 0;
}

Measured memory_bytes: 3592
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		if(a==b && a==c && b==c){
			System.out.println("Yes");
			return;
		}
		System.out.println("No");
	}
}


Measured memory_bytes: 23764
#include <algorithm>
#include <iostream>
#include <vector>
#include <set>

using namespace std;

int main() {
  int N, x, y, ans{};
  cin >> N;
  using pii = pair<int,int>;
  auto f = [](const pii &p1, const pii &p2){return p1.second > p2.second;};
  set<pii, decltype(f)> r(f);
  set<pii> b;
  for (int i = 0; i != N; ++i) {
    cin >> x >> y;
    r.insert({x,y});
  }
  for (int i = 0; i != N; ++i) {
    cin >> x >> y;
    b.insert({x,y});
  }

  for (auto &p: b) {
    for (auto &q: r) {
      if (q.first < p.first && q.second < p.second) {
        r.erase(q);
        ++ans;
        break;
      }
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 3644
#!/usr/bin/env python3
import collections
import itertools as it
import math
#import numpy as np
 
s  = input()
#  = int(input())
#  = map(int, input().split())
#  = list(map(int, input().split()))
#  = [int(input()) for i in range(N)]
#
c = collections.Counter(s)

v = [v_ for v_ in c.values() if v_ != 0]

if len(s) == 1:
    print('YES')
    exit()

if len(s) == 2: 
    print('YES' if len(v) == 2 else 'NO')
    exit()

if len(v) <= 2:
    print('NO')
else:
    print('YES' if max(v) - min(v) <= 1 else 'NO')


Measured memory_bytes: 3572
#include <bits/stdc++.h>
#define f(i,n) for(int i=0;i<(n);i++)
#define P pair<int,int>
#define LONG LLONG_MAX/3;
#define INT INT_MAX/3;
#define mod 1000000007
#define S second
#define F first
typedef long long ll;
using namespace std;
map<string,bool> m;
int main(){
	int n;
	cin>>n;
	char c;
	f(i,n){
		string s;
		cin>>s;
		if(m[s]||(s[0]!=c&&i)){
			puts("No");
			return 0;
		}
		c=s[s.size()-1];
		m[s]=true;
	}
	puts("Yes");
	return 0;
}


Measured memory_bytes: 256
// https://qiita.com/tubo28/items/e6076e9040da57368845

use std::io::*;
use std::str::FromStr;
use std::collections::HashMap;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n: u32 = read();
    let _: u32 = read();

    let mut d = HashMap::new();
    for _ in 0..n {
        let k: u32 = read();
        let xs: Vec<_> = (0..k).map(|_| read::<u32>()).collect();
        for x in xs {
            (*d.entry(x).or_insert(0)) += 1;
        }
    }
    let ans = d.iter().filter(|&(_, &v)| v == n).count();
    println!("{}", ans);
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
char a[11], b[11], c[11];
int main()
{
	
	scanf("%s%s%s", a, b, c);
	int x = strlen(a), y = strlen(b), z = strlen(c);
	if (a[x - 1] == b[0] && b[y - 1] == c[0]) {
		puts("YES");
	} else {
		puts("NO");
	}
}

Measured memory_bytes: 256
#ifdef _MSC_VER
#define _CRT_SECURE_NO_WARNINGS
#endif

#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <cassert>
#include <string.h>
#include <unordered_set>
#include <unordered_map>

using namespace std;

typedef long long int64;
typedef unsigned long long uint64;
#define two(X) (1<<(X))
#define twoL(X) (((int64)(1))<<(X))
#define contain(S,X) (((S)&two(X))!=0)
#define containL(S,X) (((S)&twoL(X))!=0)
const double pi=acos(-1.0);
const double eps=1e-11;
template<class T> inline void ckmin(T &a,T b){if(b<a) a=b;}
template<class T> inline void ckmax(T &a,T b){if(b>a) a=b;}
template<class T> inline T sqr(T x){return x*x;}
typedef pair<int,int> ipair;
#define SIZE(A) ((int)A.size())
#define LENGTH(A) ((int)A.length())
#define MP(A,B) make_pair(A,B)
#define PB(X) push_back(X)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,a) for(int i=0;i<(a);++i)
#define ALL(A) A.begin(),A.end()

const int maxnode=2000000+16;

int n,h;
vector<int> g[maxnode];
bool v[maxnode];
int d[maxnode];
int q[maxnode];
bool ww;

void bfs(int p)
{
	if (v[p]) return;
	v[p]=true;
	int sizeq=0;
	q[sizeq++]=p;
	REP(cl,sizeq)
	{
		int x=q[cl];
		for (int y:g[x]) if (!v[y]) v[y]=true,q[sizeq++]=y;
	}
}
void dfs2(int p)
{
	if (v[p]) return;
	v[p]=true;
	if (p<h && d[p]<0) ww=true;
	for (int x:g[p]) dfs2(x);
}
int main()
{
#ifdef _MSC_VER
	freopen("input.txt","r",stdin);
#endif
	std::ios::sync_with_stdio(false);
	while (cin>>n>>h && n>0)
	{
		h+=2;
		vector<ipair> edges;
		REP(i,n)
		{
			int a,b,c,d;
			cin>>a>>b>>c>>d;
			int s=((c==0)?(a+h):c);
			int t=((d==0)?b:(d+h));
			edges.emplace_back(s,t);
		}
		bool ok=true;
		REP(i,h+h) g[i].clear();
		REP(i,h+h) v[i]=false;
		for (auto e:edges) g[e.first].push_back(e.second);
		FOR(i,h,h+h) bfs(i);
		for (auto e:edges) if (!v[e.first]) ok=false;

		REP(i,h+h) g[i].clear();
		REP(i,h+h) v[i]=false;
		for (auto e:edges) g[e.second].push_back(e.first);
		REP(i,h) bfs(i);
		for (auto e:edges) if (!v[e.second]) ok=false;

		REP(i,h+h) d[i]=0;
		for (auto e:edges) ++d[e.first],--d[e.second];
		REP(i,h) if (d[i]>0) ok=false;
		FOR(i,h,h+h) if (d[i]<0) ok=false;

		REP(i,h+h) g[i].clear();
		REP(i,h+h) v[i]=false;
		for (auto e:edges) g[e.second].push_back(e.first);
		for (auto e:edges) g[e.first].push_back(e.second);
		REP(i,h+h) if (!v[i] && SIZE(g[i])>0)
		{
			ww=false;
			dfs2(i);
			if (!ww) ok=false;
		}

		if (ok)
			printf("YES\n");
		else
			printf("NO\n");
		fflush(stdout);
#ifndef _MSC_VER
		break;
#endif
	}
	return 0;
}



Measured memory_bytes: 54772
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 99999999999999999
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;




int grundy(ll x,ll MAX){

	ll left = MAX/2+1,right = MAX;

	int this_even,this_odd,pre_even,pre_odd;

	while(true){

		if(left == MAX/2+1){ //最初の区間

			if(right%2 == 0){

				this_even = 0; //右端は手詰まりなのでgrundyが0
				this_odd = 1;

			}else{ //right%2 == 1

				this_even = 1;
				this_odd = 0;
			}

		}else{

			bool check[3];
			for(int i = 0; i < 3; i++){

				check[i] = false;
			}

			//まずは区間右端のgrundy数を求める
			int right_grundy;

			if(right%2 == 0){

				check[pre_odd] = true; //+1
				check[pre_even] = true;  //*2

			}else{ //right%2 == 1

				check[pre_even] = true;  //+1および*2
			}

			for(int i = 0; i < 3; i++){

				if(!check[i]){

					right_grundy = i;
					break;
				}
			}

			int another_grundy;

			//右端の1つ左のgrundy数を求める
			for(int i = 0; i < 3; i++){

				check[i] = false;
			}

			check[right_grundy] = true; //+1
			check[pre_even] = true; //*2

			for(int i = 0; i < 3; i++){

				if(!check[i]){

					another_grundy = i;
					break;
				}
			}

			if(right%2 == 0){

				this_even = right_grundy;
				this_odd = another_grundy;

			}else{

				this_even = another_grundy;
				this_odd = right_grundy;
			}
		}

		if(x >= left && x <= right){

			if(x%2 == 0){

				return this_even;
			}else{

				return this_odd;
			}
		}

		right = left-1;
		left = right/2+1;

		pre_even = this_even;
		pre_odd = this_odd;
	}
}

int main(){

	int K;

	scanf("%d",&K);

	ll x,MAX;
	ll XOR = 0;

	for(int i = 0; i < K; i++){

		scanf("%lld %lld",&x,&MAX);

		XOR ^= grundy(x,MAX);
 	}

	if(XOR == 0){

		printf("tubuann\n");

	}else{

		printf("mo3tthi\n");
	}

	return 0;
}



Measured memory_bytes: 3148
import java.util.*;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int H = sc.nextInt();
		int A = sc.nextInt();
		int ans = 0;
		
		if (0 != H%A) {
			ans = H/A + 1;
		} else {
			ans = H/A;
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 21844
using System;
using System.Collections.Generic;

class Myon

{
    public Myon() { }
    public static int Main()
    {
        cin = new Scanner();
        new Myon().calc();
        return 0;
    }
    static Scanner cin;

    void calc()
    {
        int N = cin.nextInt();
        int K = cin.nextInt();
        int[] A = cin.ArrayInt(N);
        long sum = 0;
        for (int i = 0; i < N; i++)
        {
            sum += A[i];
        }
        List<int> l = new List<int>();
        for (int i = 1; i * i <= sum; i++)
        {
            if(sum % i == 0)
            {
                l.Add(i);
                l.Add((int)sum / i);
            }
        }
        l.Sort();
        l.Reverse();

        int ans = 1;
        foreach (int i in l)
        {
            if (sum % i != 0) continue;
            int[] B = new int[N];
            for (int j = 0; j < N; j++)
            {
                B[j] = A[j] % i;
            }
            Array.Sort(B);

            int left = 0;
            int right = N - 1;
            long need = 0;
            while (left < right)
            {
                int move = B[left];
                move = Math.Min(move, i - B[right]);
                B[left] -= move;
                B[right] += move;
                if (B[left] == 0) left++;
                if (B[right] == i) right--;
                need += move;
                if (need > K) break;
            }
            if(need <= K)
            {
                ans = i;
                break;
            }
        }
        Console.WriteLine(ans);

    }

}


class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextLong() + add;
        }
        return Array;
    }
        
    public double nextDouble()
    {
        return double.Parse(next());
    }


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}





Measured memory_bytes: 15280
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
const int oo = 1e9;
const int MOD = 1000000007;
const int BASE = 26;
const int N = 402010;
#define x first
#define y second
#define pb push_back
#define mp make_pair

int h , w, num[101][101][2], cnt = 0, SINK, SOURCE, last[N], sx, sy, tx, ty;
char g[102][102];
struct edge {
	int from , to , cap, nxt;
	edge() {
		from = to = cap = nxt = -1;
	}
};
vector<edge> E;
void addEdge(int u , int v,  int cap) {
	E.pb(edge());
	E.back().from = u;
	E.back().to = v;
	E.back().cap = cap;
	E.back().nxt = last[u];
	last[E.back().from] = E.size() - 1;
}
void add(int u , int v , int cap) {

	addEdge(u, v, cap);
	addEdge(v, u, 0);
}

int cost[N], p[N];
bool getPath() {
	for (int i = 0; i <= 300; ++i) {
		cost[i] = oo;
		p[i] = -1;
	}
	cost[SOURCE] = 0;
	queue<int> q;
	q.push(SOURCE);
	while (q.size()) {
		int src = q.front();
		q.pop();
		if (src == SINK)break;

		for (int i = last[src]; i != -1; i = E[i].nxt) {
			int newCost = cost[src] + 1;
			if (E[i].cap && newCost < cost[E[i].to]) {
				cost[E[i].to] = newCost;
				p[E[i].to] = i;
				q.push(E[i].to);
			}
		}
	}
	return cost[SINK] != oo;
}


int main() {
	memset(last, -1, sizeof last);
	memset(num, -1, sizeof num);
	cin >> h >> w;
	SOURCE = cnt++;
	SINK = cnt++;
	for (int i = 0; i < h; ++i) {
		scanf("%s", g[i]);
		for (int j = 0 ; j < w ; ++j) {
			if (g[i][j] == 'o') {
				add(i + 2, h + j + 2, 1);
				add(h + j + 2, i + 2, 1);
			}
			if (g[i][j] == 'S') {
				add(SOURCE, i + 2, oo);
				add(SOURCE, h + j + 2, oo);
				sx = i;
				sy = j;
			}
			if (g[i][j] == 'T') {
				add(i + 2, SINK, oo);
				add(h + j + 2, SINK, oo);
				tx = i;
				ty = j;
			}
		}
	}
	if (tx == sx || ty == sy) {
		puts("-1");
		return 0;
	}

	int mxFlow = 0;

	while (getPath()) {
		int mn = oo;
		int cur = p[SINK];
		while (cur != -1) {
			mn = min(mn, E[cur].cap);
			cur = p[E[cur].from];
		}
		mxFlow += mn;
		cur = p[SINK];
		while (cur != -1) {
			E[cur].cap -= mn;
			E[cur ^ 1].cap += mn;
			cur = p[E[cur].from];
		}
	}
	cout << mxFlow << endl;
	return 0;
}


Measured memory_bytes: 4216
<?php 

$n = trim(fgets(STDIN));
$count=0;
for($a=1;$a<$n;$a++){
    for($b=1; $b<$n ;$b++){
        $c = $n - ( $a * $b);
        if($c >= 1){
            $count++;
        }
        if($c <= 0){
            break;
        }
    }
}
echo $count;

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

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

	int  X, A, B;
	cin >> X >> A >> B;
	if (A - B >= 0) {
		cout << "delicious";
	}
	else if (B - A <= X) {
		cout << "safe";
	}
	else cout << "dangerous";
}


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

int main(void){
    int N;
    cin >> N;
    vector<double> A(N);
    double tmp = 0;
    for (int i=0; i < N; i++){
        cin >> A.at(i);
    }
    for (int i=0; i < N; i++){
        tmp  += (1 / A.at(i));
    }
    cout << 1 / tmp << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep1(i, n) for(int i = 1; i < n+1; i++)
#define sort(A) sort(A.begin(),A.end())
#define reverse(A) reverse(A.begin(),A.end());
#define vecmin(A) *min_element(A.begin(),A.end());
#define vecmax(A) *max_element(A.begin(),A.end());
typedef long long ll;
typedef vector<int> vec;

ll gcd(ll a,ll b){
  if(b == 0) return a;
  return gcd(b,a%b);
}

ll lcm(ll a,ll b){
  return a/gcd(a,b)*b;
}

int main(){
  int n;
  cin >> n;
  vec a(n);
  rep(i,n) cin >> a[i];
  int l = 1;
  rep(i,n) l = lcm(l,a[i]);
  int ans = 0;
  rep(i,n) ans = ans + a[i] - 1;
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>

using namespace std;
typedef long long ll;

const ll inf = 100000000000000LL;

int a[101];
bool flag[101];

int cc = 0;

ll dfs(int n, int k){
  ll ret = inf;

  if(n+1 == k) return 0;
    
  if(!flag[k] && a[k] < 0){
    bool memo[100] = {};
    ll sum = 0;
    int counter = 0, ncounter = 0;
    
    for(int i=1;i*k<=n;i++){
      if(!flag[i*k]){
	memo[i*k] = true;
	flag[i*k] = true;
	sum += a[i*k];
	counter++;
	ncounter += a[i*k] < 0;
      }
    }
    
    if(counter != 1 || a[k] < 0){
      ret = min(ret, dfs(n, k+1) + sum);
    }

    for(int i=1;i*k<=n;i++){
      if(memo[i*k]){
	memo[i*k] = false;
	flag[i*k] = false;
      }
    }
    
    if((counter == 1 && a[k] < 0) || counter == ncounter)
	return ret;
  }
    
  ret = min(ret, dfs(n, k+1));

  //printf("%d\n",cc++);
  
  return ret;
}

int main() {
  int n;
  ll sum = 0;
  
  scanf("%d",&n);

  for(int i=1;i<=n;i++){
    scanf("%d",a+i);
    sum += a[i];
  }
  
  printf("%lld\n", sum - dfs(n,1));

  return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<vector>
using namespace std;
using ll = long long;

int main() {
  int N,W,i,j;
  cin>>N>>W;
  vector<int> w(N+1),v(N+1);
  for (i=1;i<=N;i++) {
    cin>>w[i]>>v[i];
  }
  vector<vector<ll> > dp(N+1, vector<ll>(W+1, 0));
  for (i=1;i<=N;i++) {
    for (j=0;j<=W;j++) {
      if (j<w[i]) {
        dp[i][j] = dp[i-1][j];
      } else {
        dp[i][j] = max(dp[i-1][j-w[i]] + v[i], dp[i-1][j]);
      }
    }
  }
  cout<<dp[N][W]<<endl;
  return 0;
}


Measured memory_bytes: 82708
#include <cstdio>
#include <iostream>
#include <set>
#include <cmath>
#include <string>
#include <algorithm>

using namespace std;

const int CMax = 102;

int n, m, C[CMax], D[CMax];
string S[CMax];
long long sum;

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

    for (int i = 0; i < n; i++) {
        cin >> S[i];
        for (int j = 0; j < m; j++) {
            if (S[i][j] == '#') {
                C[i]++;
                D[j]++;
            }
        }
    }

    bool tik = false;

    for (int i = 0; i < n; i++) {
        tik = false;
        for (int j = 0; j < m; j++) {
            if (C[i] > 0 && D[j] > 0) {
                cout << S[i][j];
                tik = true;
            }
        }
        if (tik) cout << endl;
    }
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

static void D_WeLikeAGC();	// https://atcoder.jp/contests/abc122/tasks/abc122_d

int main()
{
	D_WeLikeAGC();

	fflush(stdout);
	return 0;
}

enum CharKinds
{
	charA = 0,
	charC,
	charG,
	charT,

	charKind,
};

class RecordedPattern {
public:
	std::vector<std::string> vStrPtns;
	std::vector<unsigned long long> vPtnCnt;

	RecordedPattern() {}
	~RecordedPattern() {}
	

	void set(const char* szPtn, unsigned long long ptnCnt)
	{
		if (!match(szPtn, ptnCnt)) {
			vStrPtns.push_back(szPtn);
			vPtnCnt.push_back(ptnCnt);
		}
	}

	bool match(const char* szPtn, unsigned long long & ptnCnt)
	{
		bool isMatch = false;
		int strCnt = vStrPtns.size();

		for (int i = 0; i < strCnt; i++) {
			if (vStrPtns[i] == szPtn) {
				isMatch = true;
				ptnCnt = vPtnCnt[i];
				break;
			}
		}
		return isMatch;
	}
};

static RecordedPattern vRecords[100];

bool isAvailable(const std::string & targ)
{
	bool avail = true;
	int len = targ.length();
	const char* cmp = targ.c_str();

	if ((strstr(cmp, "AGC")) ||
		(strstr(cmp, "GAC")) ||
		(strstr(cmp, "ACG"))) {
		avail = false;
	}
	else if ((len > 3) && (cmp[0] == 'A') && (cmp[3] == 'C')) {
		if ((cmp[1] == 'G') || (cmp[2] == 'G')) {
			avail = false;
		}
	}
	return avail;
}

unsigned long long decideChar(int maxN, int szIdx, const char * szBfr)
{
	static const char available[] = { 'A', 'C', 'G', 'T' };
	static const int TmpSzLen = 4;

	int chkCnt = (TmpSzLen > szIdx) ? szIdx : TmpSzLen;
	char mkStr[TmpSzLen + 1] = { 0 };
	unsigned long long patternCnt = 0;

	if (szIdx >= maxN) {
		return 1;
	}


	if (vRecords[szIdx - 1].match(szBfr, patternCnt)) {
		return patternCnt;
	}

	int cpyOfs = 0;
	if (chkCnt >= TmpSzLen) {
		cpyOfs = 1;
	}
	
	for (int j = 0; j < (chkCnt - cpyOfs); j++) {
		mkStr[j] = szBfr[j + cpyOfs];
	}

	std::string chk = "";
	unsigned long long tmpRet = 0;
	for (int i = 0; i < charKind; i++) {
		tmpRet = 0;
		mkStr[chkCnt - cpyOfs] = available[i];
		
		chk = mkStr;
		if (isAvailable(chk)) {
			tmpRet = decideChar(maxN, szIdx + 1, mkStr);
		}
		patternCnt += tmpRet;
	}
	patternCnt = patternCnt % ((unsigned long long)(1e9) + 7);
	vRecords[szIdx - 1].set(szBfr, patternCnt);

	return patternCnt;
}

static void D_WeLikeAGC()
{
	const char addable[] = { 'A', 'C', 'G', 'T' };
	int N = 0;

	scanf(" %d", &N);

	char buff[4] = { 0 };
	unsigned long long pattern = 0;

	for (int i = 0; i < charKind; i++) {
		buff[0] = addable[i];
		pattern += decideChar(N, 1, buff);
	}
	
	printf("%llu\n",  (unsigned long long)(pattern % (unsigned long long)(1e9 + 7)));
}



Measured memory_bytes: 1664
#include<cstdio>
#include<cctype>
#include<cstring>
#include<set>
#include<algorithm>
#define reg register
typedef long long ll;
template<typename T>inline T read(){
    reg T x=0;reg short f=1;reg char c=getchar();
    for(;!isdigit(c);f=c=='-'?-1:1,c=getchar());
    for(;isdigit(c);x=x*10+(c^48),c=getchar());
    return x*f;
}
const int MN=1e5+5;
const int U=1<<16;
const int inf=0x7f7f7f7f;
int n,ans,s[MN],f[U],sum[17];
using std::min;
inline int dfs(int S){
	if(f[S]<inf)return f[S];
	for(reg int i=1;i<16;i++)
	    if((S>>i)&1)for(reg int j=1;j<16;j++)
			    if((i^j)&&((S>>j)&1)){
					reg int t=i^j,s=S^(1<<i)^(1<<j)^(1<<t);
					f[S]=min(f[S],dfs(s)+1+((S>>t)&1));
				}
	return f[S];
}
int main(){
	n=read<int>();memset(f,0x7f,sizeof(f));
	for(reg int i=1,x,y,c;i<n;i++){
		x=read<int>(),y=read<int>(),c=read<int>();
		s[x]^=c;s[y]^=c;
	}
	for(reg int i=0;i<n;i++)sum[s[i]]++;
	reg int S=0;f[0]=0;
	for(reg int i=1;i<16;i++)ans+=(sum[i]>>1),S+=(1<<i)*(sum[i]&1);
	printf("%d\n",ans+dfs(S));
	return 0;
}

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



int main() {

	vector<char> s(3);
    for(int i=0;i<3;i++){
        cin>>s.at(i);
    }

    sort(s.begin(),s.end());

    if(s.at(0)=='a'&&s.at(1)=='b'&&s.at(2)=='c')
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;


	return 0;
}

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

#define F first
#define S second
#define prev azaza
#define MP make_pair
#define PB push_back

using namespace std;
typedef long long ll;
typedef long double ld;

const int max_n = 1011, inf = 1000111222;

char f[max_n][max_n];
int d[max_n][max_n];

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

bool onf(int i, int j) {
    return i >= 0 && i < n && j >= 0 && j < m;
}

int main()
{
    //freopen("input.txt", "r", stdin);
    cin >> n >> m;
    queue<pair<int, int>> q;
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < m ;++j) {
            d[i][j] = inf;
        }
    }
    for (int i = 0; i < n; ++i) {
        scanf("%s", f[i]);
        for (int j = 0; j<m; ++j) {
            if (f[i][j] == '#') {
                d[i][j] = 0;
                q.push(MP(i, j));
            }
        }
    }
    int ans = 0;
    while (!q.empty()) {
        pair<int, int> cur = q.front();
        q.pop();
        int i = cur.F, j = cur.S;
        ans = max(ans, d[i][j]);
        for (int k = 0; k < 4; ++k) {
            int ni = i + di[k];
            int nj = j + dj[k];
            if (onf(ni, nj) && d[ni][nj] == inf) {
                d[ni][nj] = d[i][j] + 1;
                q.push(MP(ni, nj));
            }
        }
    }
    cout << ans << endl;
    return 0;
}



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

int main()
{
	int n;
	cin >> n;
	long double p = (long double)n / 3;
	//cout << p << "\n";
	long double a1, a2, a3;
	a1 = p;
	a2 = p;
	a3 = p;
	long double ans;

	ans=  a1 * a2 * a3;
	printf("%.10LF",ans);
	//cout << ans;

	return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << endl
typedef int64_t Int;

using namespace std;
using Graph = vector<vector<Int>>;

const double pi = M_PI;
const Int MOD = 1000000007;

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    cout << max({a, b, c}) - min({a, b, c}) << endl;

    return 0;
}


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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    LL a,b,c,d;cin>>a>>b>>c>>d;

    LL ans= max(a*c,max(a*d,max(b*c,b*d)));
    cout<<ans;
}

Measured memory_bytes: 3648
#ABC124 C
S = input()
ans = 10000000000000
gl = ["",""]
for i in range(2):
    for j in range(len(S)):
        if j % 2 == i:
            gl[i] += "0"
        else:
             gl[i] += "1"

for i in range(2):
    tmp = 0
    for j in range(len(S)):
        if S[j] != gl[i][j]:
            tmp += 1
    ans = min(ans,tmp)
print(ans)     


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

const int MOD = 1000000007;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define copy(from, to) copy(from.begin(), from.end(), back_inserter(to))
#define sort(a) sort(a.begin(), a.end())
#define reverse(s) reverse(s.begin(), s.end())
#define p(s) cout << (s) << endl

typedef long long ll;
using namespace std;

template<class T>
void load(vector<T> &v, int n) {
  for (int i = 0; i < n; ++i) {
    T t;
    cin >> t;
    v.push_back(t);
  }
}

template<class T>
T max(vector<T> &v) {
  return *max_element(v.begin(), v.end());
}

template<class T>
T min(vector<T> &v) {
  return *min_element(v.begin(), v.end());
}

void py(bool isUpper = false) {
  if (isUpper) {
    p("YES");
  } else {
    p("Yes");
  }
}

void pn(bool isUpper = false) {
  if (isUpper) {
    p("NO");
  } else {
    p("No");
  }
}

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

  int r = 1;
  while (true) {
    if (r * 2 > n) {
      p(r);
      return 0;
    } else {
      r *= 2;
    }
  }
}

Measured memory_bytes: 256
#include <stdio.h>

struct dice {
	int up;
	int front;
	int right;
	int left;
	int back;
	int down;
};

void mov_order(struct dice *d, char order)
{
	int wk;
	
	switch(order){
		case 'N':
			wk       = d->up;
			d->up    = d->front;
			d->front = d->down;
			d->down  = d->back;
			d->back  = wk;
			break;
		case 'E':
			wk       = d->left;
			d->left  = d->down;
			d->down  = d->right;
			d->right = d->up;
			d->up    = wk;
			break;
		case 'W':
			wk       = d->right;
			d->right = d->down;
			d->down  = d->left;
			d->left  = d->up;
			d->up    = wk;
			break;
		case 'S':
			wk       = d->back;
			d->back  = d->down;
			d->down  = d->front;
			d->front = d->up;
			d->up    = wk;
			break;
	}
}

void set_up(struct dice *d1, struct dice *d2, char *order)
{
	d2->up    = d1->up;
	d2->front = d1->front;
	d2->right = d1->right;
	d2->left  = d1->left;
	d2->back  = d1->back;
	d2->down  = d1->down;
	
	while(*order != 0x00){
		mov_order(d2, *order);
		order++;
	}
}

int main(void)
{
	int x, i, j, k, l, wk, flg = 0;
	struct dice da[100], d1, d2, d3;
	
	scanf("%d", &x);
	for(i = 0; i < x; i++){
		scanf("%d%d%d%d%d%d", &da[i].up, &da[i].front, &da[i].right, &da[i].left, &da[i].back, &da[i].down);
	}
	
	for(i = 0; i < x - 1; i++){
		for(j = i + 1; j < x; j++){
			d1 = da[i];
			d2 = da[j];
			for(k = 0; k < 6; k++){
				l = 4;
				switch(k){
					case 0: if(d1.up == d2.up)   {set_up(&d2, &d3, "");  l = 0; break;}
					case 1: if(d1.up == d2.front){set_up(&d2, &d3, "N"); l = 0; break;}
					case 2: if(d1.up == d2.right){set_up(&d2, &d3, "W"); l = 0; break;}
					case 3: if(d1.up == d2.left) {set_up(&d2, &d3, "E"); l = 0; break;}
					case 4: if(d1.up == d2.back) {set_up(&d2, &d3, "S"); l = 0; break;}
					case 5: if(d1.up == d2.down) {set_up(&d2, &d3, "NN");l = 0; break;}
				}
				
				for(; l < 4 && d1.front != d3.front; l++){
					wk       = d3.front;
					d3.front = d3.right;
					d3.right = d3.back;
					d3.back  = d3.left;
					d3.left  = wk;
				}
				if((l < 4) &&
				   (d1.right == d3.right) &&
				   (d1.left  == d3.left) &&
				   (d1.back  == d3.back) &&
				   (d1.down  == d3.down)){
					flg = 1;
					break;
				}
			}
			if(flg == 1) break;
		}
		if(flg == 1) break;
	}
	if(flg == 0) printf("Yes\n");
	else         printf("No\n");
	
	return(0);
}



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

int main() {
  int N;
  cin >> N;
  char c;
  vector<int> v1(N);
  for(int i = 0; i < N; i++) {
      cin >> c;
      if(c == 'R') {
          v1[i] = 0;
      } else {
          v1[i] = 1;
      }
  }
  vector<int> v2 = v1;
  sort(v2.begin(), v2.end());
  int count = 0;
  for(int i = 0; i < N; i++) {
      if(v1[i] != v2[i]) {
          count++;
      }
  }
  cout << count/2;
}

Measured memory_bytes: 4840
#include <bits/stdc++.h>
using namespace std;
#define INF 0x7fffffff
#define mem0(x) memset(x, 0, sizeof(x))
#define mem1(x) memset(x, -1, sizeof(x))
#define all(x) x.begin(), x.end()
#define sz(x) x.size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define de(x) cout << #x << " = " << x << endl;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define per(i, a, b) for (int i = a; i > b; i--)
#define setI freopen("input.txt", "r", stdin);
#define setIO freopen("input.txt", "r", stdin); freopen("output.txt","w", stdout);
typedef long long LL;
typedef pair<int, int> pii;
typedef vector<int> vi;
//---------------------------------------------------------//
const int N = 1e5 + 5;

int n, a[N];

int main()
{
	#ifdef M1saki
//		setI;
	#endif
//	ios::sync_with_stdio(false);
	scanf("%d", &n);
	rep(i, 1, n + 1)  scanf("%d", &a[i]);
	int ans = 0;
	rep(i, 1, n + 1)
	{
		if (a[i] != i)  continue;
		if (i + 1 <= n && a[i + 1] == i + 1)
		{
			swap(a[i], a[i + 1]);
			ans++;
			continue;
		}
		if (i - 1 >= 1)
		{
			if (a[i - 1] != i && a[i] != i - 1)
			{
				swap(a[i - 1], a[i]);
				ans++;
				continue;
			}
		}
		if (i + 1 <= n)
		{
			if (a[i] != i + 1 && a[i + 1] != i)
			{
				swap(a[i], a[i + 1]);
				ans++;
				continue;
			}
		}
	}
	printf("%d\n", ans);

	return 0;
}

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

using namespace std;

int main(void){

    int n;
    cin >> n;

    vector<int> a1(n);
    vector<int> a2(n);
    
    for(int i=0; i<n; i++) cin >> a1[i];
    for(int i=0; i<n; i++) cin >> a2[i];
    
    vector<int> rev_sum_a1(n);
    vector<int> rev_sum_a2(n);
    
    for(int i=n-1; i>=0; i--) {
        if(i==n-1) {
            rev_sum_a1[i] = a1[i];
            rev_sum_a2[i] = a2[i];
        }
        else {
            rev_sum_a1[i] = a1[i] + rev_sum_a1[i+1];
            rev_sum_a2[i] = a2[i] + rev_sum_a2[i+1];
        }
    }
    
//    bool isa1 = true;
    int max = 0;
    int index = -1;
    int sum = 0;
    for(int i=0; i<n; i++) {
        sum += a1[i];

        if(rev_sum_a2[i]>rev_sum_a1[i+1]) {
            if(max<sum+rev_sum_a2[i]) {
                index = i;
                max = sum+rev_sum_a2[i];
            }
        }
    }
  
    int result = 0;
    bool isa1 = true;
    for(int i=0; i<n; i++) {
        if(index == -1) {
            result += a1[i];
            continue;
        }
        
        if(isa1) result += a1[i];
        if(index == i) isa1 = false;
        if(!isa1) result += a2[i];
        
    }

    cout << result << endl;

    return 0;
    
}


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

#define watch(x) cerr << (#x) << ": " << (x) << endl
#define int long long

const int mod = 1000000007;

int subs(map<char, int>& freq, char last) {
    int ret = 1;
    for(pair<char, int> f : freq) {
        if(f.first != last)
            ret = ret*(f.second+1)%mod;
    }
    return ret;
}

int32_t main() {

    int n; cin >> n;
    string s; cin >> s;

    map<char, int> freq;

    int ans = 0;
    for(char c : s) {
        ans = (ans+subs(freq, c))%mod;
        freq[c]++;
    }

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


Measured memory_bytes: 512
#include <iostream>
#include <iterator>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <cstring>
#include <stack>
#include <vector>
#include <list>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <limits>
#include <utility>
#define EPS (1e-10)
#define REP(i,n) for(int i=0;i<n;i++)
#define equals(a,b) (fabs((a) - (b)) < EPS)
#define ll long long
using namespace std;

//typedef pair<int,int> P;
//const ll MOD = 1000000007;
//const ll INF = 100000000;

string S, T;

//stack<int> stack;
//queue<int> que;
//priority_queue<int> pque;
//set<int> s; set<int>::iterator ite;
//multiset<int> ms; multiset<int>::iterator ite;
//map<int, int> m; map<int, int>::iterator ite;
//multimap<int, int> mm; multimap<int, int>::iterator ite;

//int dp[][];
//int dx[4] = {1, 0, -1, 0}; int dy[4] = {0, -1, 0, 1};
//int dx[8] = {1, 1, 1, 0, -1, -1, -1, 0};
//int dy[8] = {0, -1, -1, -1, 0, 1, 1, 1};

void solve() {
  if(S.size() + 1 != T.size()) {
    printf("No\n");
    return;
  }
  if(T.erase(S.size()) == S) {
    printf("Yes\n");
  } else {
    printf("No\n");
  }
  return;
}

int main(int argc, char const *argv[]) {

  cin >> S;
  cin >> T;

  solve();
  return 0;
}



Measured memory_bytes: 3636
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) {
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		try {
			String line = reader.readLine();
			int day = Integer.parseInt(line);
			String strs = "Christmas";
			String eves = " Eve";
			
			for (int i = 0; i < 25 - day; i++) {
				strs = strs + eves;
			}
			
			System.out.println(strs);
			
		} catch (IOException e) {
			System.out.println(e);
		} catch (NumberFormatException e) {
			System.out.println("wrong");
		}
	}
}

Measured memory_bytes: 21204
#include<iostream>
#include<string>
using namespace std;
int main()
{
	string s;
	int n;
	cin>>s>>n;
	for(int i=0;i<n;i++)
	{
		if(s[i]=='1') continue;
		else {
			cout<<s[i]<<endl;
			return 0;
		}	
	}
	cout<<"1"<<endl;
	return 0;
		
}

Measured memory_bytes: 256