akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
int main(){
    int n;
    char a[101],b[101],c[101];
    scanf("%d",&n);
    scanf("%s%s%s",a,b,c);
    //int tmp=0;
    int ans=0;
    for(int i=0;i<n;i++){
        if(a[i]==b[i] && b[i]==c[i]);
        else if(a[i]==b[i] && b[i]!=c[i])ans++;
        else if(a[i]!=b[i] && b[i]==c[i])ans++;
        else if(a[i]!=b[i] && a[i]==c[i])ans++;
        else if(a[i]!=b[i] && b[i]!=c[i] && a[i]!=c[i])ans+=2;
    }
    
    printf("%d\n",ans);
}

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

#define Fast ios_base::sync_with_stdio(0);cin.tie(0),cout.tie(0)
#define FO freopen("in.txt", "r", stdin)
#define FC freopen("out.txt", "w", stdout)
#define aise cout<<"aise"<<endl
#define pb push_back
#define mp make_pair
#define ll long long
#define mset(v, a) memset(v, a, sizeof(v))
#define pll pair< ll, ll >
#define pdd pair< double, double >
#define ff first
#define ss second
#define pi acos(-1.0)
#define mxN 2097162
#define inf 1e9
#define MOD 1000000007

int main()
{

    ll n, a, b, c, d, e;
    cin >> n >> a>> b >> c >> d >> e;
    cout << max({ (n-1)/a, (n-1)/b, (n-1)/c,  (n-1)/d, (n-1)/e })+5;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef pair<ll,ll> ii;
typedef tree<ii,null_type,less<ii>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
// *st.find_by_order(index), 0-based
// order_of_key(e)

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int N; cin>>N;
	vector<int> A(N);
	for (int i=0; i<N; i++)
		cin>>A[i];
	ii init={1000,0};
	ii low=init;
	ii high=init;
	for (int i=0; i<N; i++) {
		ll cur=max(low.first+low.second*A[i],high.first+high.second*A[i]);
		low={cur,0};
		high={cur%A[i],cur/A[i]};
	}
	cout<<max(low.first+low.second*A.back(),high.first+high.second*A.back())<<"\n";
	return 0;
}

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

long long a, b, c, k, ans;

int main() {
	cin >> a >> b >> c >> k;

	if(k <= a){
		ans = k;
	}
	else if(k <= a + b){
		ans = a;
	}
	else{
		ans = a - (k-a-b);
	}

	cout << ans << endl;
}

Measured memory_bytes: 3616
macro_rules! get {
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
            get!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
            get!($($t),*)
        ).collect::<Vec<_>>()
    };
    ($t:ty ;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
    ($t:ty ;; $n:expr) => {
        (0..$n).map(|_| get!($t ;;)).collect::<Vec<_>>()
    };
}

fn main() {
    let (k, s) = get!(usize, usize);
    let r = (0..k+1).flat_map(|i|
        (0..k+1).map(|j|
            if i+j <= s && s-(i+j) <= k { 1 } else { 0 }
        ).collect::<Vec<_>>()
    ).fold(0, |a, n| a + n);
    println!("{}", r);
}

Measured memory_bytes: 4352
#include <iostream>
#include <utility>
#include <stdint.h>
#include <algorithm>
#include <vector>

using namespace std;

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

  vector<unsigned> D;
  
  for (int n=0; n<N; ++n) {
    unsigned d;
    cin >> d;
    D.push_back(d);
  }

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

  cout << D[N/2] - D[N/2-1] << endl;

  return 0;
}


Measured memory_bytes: 892
#include<cstdio>
using namespace std;
#define N 100005
#define LL long long
#define rep(i,j,k) for(i=j;i<=k;++i)
struct E{
	int to,nxt,flag;
}ed[N<<1];
int n,m,i,j,k,top,a,b;
int head[N],vis[N];
bool flag;
LL ans,s[5];
void read(int &p){
	p=0; char x=getchar();
	while(x<'0' || x>'9') x=getchar();
	while(x>='0'&&x<='9'){p=p*10+x-'0'; x=getchar();}
}
void add(int u,int v,int f){
	top++; ed[top]=(E){v,head[u],f}; head[u]=top;
}
void dfs(int x,int c){
	int i,v,nc[2];
	vis[x]=c; s[0]++; s[c]++; nc[1]=(c%3)+1; 
	if(c==1) nc[0]=3;
	else nc[0]=c-1;
	for(i=head[x];i;i=ed[i].nxt){
		v=ed[i].to;
		if(ed[i].flag) s[4]++;
		if(vis[v]){
			if(vis[v]!=nc[ed[i].flag]) flag=false;
		}else dfs(v,nc[ed[i].flag]);
	}
}
int main(){
	read(n); read(m);
	rep(i,1,m){
		read(a); read(b);
		add(a,b,1); add(b,a,0);
	}
	rep(i,1,n)
	if(!vis[i]){
		s[4]=s[0]=s[1]=s[2]=s[3]=0; flag=true;
		dfs(i,1);
		if(flag){
			if((!s[1])||(!s[2])||(!s[3])){
				ans+=(LL)s[4];
			}else{
				ans+=(LL)s[1]*1LL*s[2];
				ans+=(LL)s[2]*1LL*s[3];
				ans+=(LL)s[3]*1LL*s[1];
			}
		}else ans+=(LL)s[0]*1LL*s[0];
	}
	printf("%lld\n",ans);
	return 0;
}

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

int N;
int A[111111];

int sum[111111];
int sumabs[111111];

signed main(){
    cin>>N;
    cin>>A[0];
    for(int i=1;i<N;i++){
        char c;
        cin>>c>>A[i];
        if(c=='-')A[i]*=-1;
    }

    rep(i,N)sum[i+1]=sum[i]+A[i];
    rep(i,N)sumabs[i+1]=sumabs[i]+abs(A[i]);

    vint lis;
    rep(i,N)if(A[i]<0)lis.pb(i);

    int ans=sum[N];

    for(int i=0;i+1<lis.size();i++){
        int x=lis[i];
        int y=lis[i+1];
        int tmp=sum[x];
        tmp-=sumabs[y]-sumabs[x];
        tmp+=sumabs[N]-sumabs[y];
        chmax(ans,tmp);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3704
#include <iostream>
#include <vector>
#include <cstdio>
#include <cstring>
#include <cmath>
typedef long long int ll;
using namespace std;

#define MAXN (10000+5)
#define MAXA (1000000+5)

ll A[MAXN];

vector< pair<ll, ll> > factorize( int n ){
	vector< pair<ll,ll> > res;
	ll tmp;
	for( ll p = 2; p*p <= n; ++p ){
		if( n % p != 0 )	continue;

		tmp = 0;
		while( n % p == 0 ){
			++tmp;
			n /= p;
		}

		res.push_back( make_pair(p,tmp) );
	}

	if( n != 1 )
		res.push_back( make_pair(n,1) );

	return res;
}

void swap( ll &a, ll &b ){
	a = a^b;
	b = a^b;
	a = a^b;
}

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;
}

ll modpow( ll base, ll pow, ll m ){
	ll res = 1;
	while( pow ){
		if( pow & 1 )	res = res * base % m;
		base = base * base % m;
		pow >>= 1;
	}
	return res;
}

int main(){
	int n; cin >> n;
	ll const MOD = 1000000007L;

	vector< ll > num( MAXA, 0 );

	for( int i = 0; i < n; i++ ){
		cin >> A[i];
		auto pf = factorize(A[i]);

		for( auto p: pf ){
			num[p.first] = max( num[p.first], p.second );
		}
	}

	ll LCM = 1;
	for( int p = 2; p < MAXA; ++p ){
		if( num[p] == 0 )	continue;
		LCM = LCM * modpow( p, num[p], MOD ) % MOD;
	}
	
	// cout << "LCM = " << LCM << endl;
	
	ll res = 0;
	for( int i = 0; i < n; i++ ){
		ll t = LCM * modinv( A[i], MOD ) % MOD;
		res = (res + t) % MOD;
	}
	cout << res << endl;
}


Measured memory_bytes: 8192
/*
      author : nishi5451
      created: 11.08.2020 23:27:51
*/

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


int main(){
    int a;
    cin >> a;
    cout << a+a*a+a*a*a << endl;
    return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>

using namespace std;
typedef long long ll;

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

vector<vector<char>> mat;
int H, W;

int maxbfs(int i, int j) {
    int res = 0;

    deque<tuple<int, int, int>> q = {make_tuple(0, i, j)};
    set<pair<int,int>> seen;

    while (q.size() > 0) {
        int dist, i, j;
        tie(dist, i, j) = q.front(); q.pop_front();
        //printf("%d %d %d\n", dist, i, j);
        pair<int, int> v = {i, j};
        if (seen.count(v)) continue;
        seen.insert(v);
        res = max(res, dist);
        for (int a = 0; a < 4; a++) {
            int i2 = i+dx[a], j2 = j+dy[a];
            if (0 <= i2 and i2 < H and 0 <= j2 and j2 < W) {
                //printf("%d %d\n", i2, j2);
                // cout << mat[i2][j2] << endl;
                if (mat[i2][j2] == '.') {
                    q.push_back(make_tuple(dist+1, i2, j2));
                }
            }
        }
    }


    /*
    for (auto& row : mat) {
        for (auto& val : row) {
            cout << val;
        }
    }
    */

    return res;
}

int main() {
    cin >> H >> W;
    mat = vector<vector<char>>(H, vector<char>(W, ' '));
    for (auto& row : mat) {
        for (auto& val : row) {
            cin >> val;
        }
    }
    int best = 0;
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            if (mat[i][j] == '.') {
                int b = maxbfs(i,j);
                //printf("best %d\n", b);
                best = max(best, b);
            }
        }
    }
    cout << best << endl;
}


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

#define  optimize   ios::sync_with_stdio(0); cin.tie(0);
#define PI  acos(-1.0)
#define RESET(a, b) memset(a, b, sizeof(a))
#define pb push_back
int main()
{
     optimize
     ll n,k,x,y,ans=0;
     cin>>n>>k>>x>>y;
     if(n>=k){
        ans+=k*x;
        ans+=(n-k)*y;
        cout<<ans<<endl;
     }
     else{
        cout<<n*x<<endl;
     }
}


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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcountll

#define INF 1e16
#define mod 1000000007

ll n;
ll a[100010];

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

  cin>>n;
  rep(i,n)cin>>a[i];

  sort(a,a+n);
  ll idx=n-1;
  repl(i,1,n){
    if(a[i]>=0){
      idx=i;break;
    }
  }

  ll resa=0;
  rep(i,n){
    if(i<idx)resa-=a[i];
    else resa+=a[i];
  }

  vector<P> resb;
  repl(i,idx,n-1){
    resb.push_back(P(a[0],a[i]));
    a[0]-=a[i];
  }
  rep(i,idx){
    resb.push_back(P(a[n-1],a[i]));
    a[n-1]-=a[i];
  }
  cout<<resa<<endl;
  rep(i,resb.size())cout<<resb[i].fi<<" "<<resb[i].se<<endl;

  return 0;
}


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

void swap(int &x, int &y) {
    int temp;
    temp = x;
    x = y;
    y = temp;

    return;
}

void sectionSort(int *A, int N, int &count) {
    int i, j, minj;

    for(i=0; i<N; ++i) {
        minj = i;
        for(j=i; j<N; ++j) {
            if(A[j] < A[minj])
                minj = j;
        }
        if(minj != i) {
            swap(A[minj], A[i]);
            ++count;
        }
    }

    return;
}

int main() {
    int N;
    cin >> N;
    int A[N], i, count=0;
    for(i=0; i<N; ++i) cin >> A[i];

    sectionSort(A, N, count);
    cout << A[0];
    for(i=1; i<N; ++i) cout << ' ' << A[i];
    cout << endl;
    cout << count << endl;

    return 0;
}

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

int main()
{
    int a, b;
    string s;
    string t = "Yes";
    cin >> a >> b >> s;
    rep(i,a){
        if(s[i]=='-')
            t = "No";
    }
    if(s[a]!='-')
        t = "No";
    forx(i, a + 1, a + b+1) {
    if (s[i] == '-')
        t = "No";
}
cout << t << endl;
return 0;
}


Measured memory_bytes: 256
use std::io;
use std::cmp;
use std::collections::BinaryHeap;
use std::collections::HashMap;
use std::collections::HashSet;

fn read_line() -> String {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).ok();
    buf
}

fn gcd(a: usize, b: usize) -> usize {
    let mut p = cmp::min(a,b);
    let mut q = cmp::max(a,b);

    while q%p > 0 {
        let r = q%p;
        q = p;
        p = r;
    }
    p
}


fn main() {
    let n: usize = read_line().trim().parse().unwrap();
    let A: Vec<usize> = read_line().split_whitespace().map(|s| s.parse().unwrap()).collect();

    let mut ls = vec![0; n];
    let mut rs = vec![0; n];

    ls[0] = A[0];
    for i in 0..n-1 {
        ls[i+1] = gcd(A[i+1], ls[i]);
        
    }

    rs[n-1] = A[n-1];   
    for i in (0..n-1).rev() {
        rs[i] = gcd(rs[i+1], A[i]);
    }

    let mut ans = cmp::max(rs[1], ls[n-2]);
    for i in 0..n - 2 {
        ans = cmp::max(ans, gcd(ls[i], rs[i+2]));
    }

    println!("{}", ans);
}


Measured memory_bytes: 8444
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<limits.h>

int max(int a, int b){
  return a >= b ? a : b;
}
int min(int a, int b){
  return b >= a ? a : b;
}
int sei(int a){
  return a>0 ? a : 0;
}
int factorial(int n) {
    if (n > 0) return n*factorial(n - 1);
		else return 1;
}
int compare_up_int(const void *a, const void *b){
   return *(int*)a - *(int*)b;
}
int compare_down_int(const void *a, const void *b){
   return *(int*)b - *(int*)a;
}
int euclid(int a, int b){
  if(a < b){int tmp = a;a = b;b = tmp;}
  int r = a % b;
  if(r < 0) r += b;
  while(r != 0){
    a = b;b = r;r = a % b;
    if(r < 0) r += b;
  }
  return b;
}

int main(){
  int A,B,K;
  scanf("%d %d %d",&A,&B,&K);
  if(B-A >= 2*K){
    for(int i=0;i<K;i++){
      printf("%d\n",A+i);
    }
    for(int i=K-1;i>=0;i--){
      printf("%d\n",B-i);
    }
    return 0;
  }
  else{
    for(int i=A;i<B+1;i++)printf("%d\n",i);
  }
  return 0;
}


Measured memory_bytes: 256
n,m=map(int,input().split())
q=[]
import heapq
for i in range(m):
    a,b=map(int,input().split())
    heapq.heappush(q,(b,a))

largest=-10
c=0
while q:
    b,a=heapq.heappop(q)
    if largest-1<a:
        largest=b
        c+=1
print(c)


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

int main() {
    int N; cin >> N;
    string s = to_string(N);
    int sum = 0;
    for (int i = 0; i < s.size(); i++) {
        sum += s[i] - '0';
    }
    if (N % sum == 0) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 3700
import sys
sys.setrecursionlimit(10000000)
N, M = map(int, input().split())
K = [0]*(N+1)
L = [[] for _ in range(N+1)]
graph = [[] for _ in range(N+M+1)]
for i in range(1, N+1):
    K[i], *L[i] = map(int, input().split())
    for lang in L[i]:
        graph[i].append(lang + N)
        graph[lang + N].append(i)

seen = [False] * (N+M+1)
person = [0] * (N+1)


def dfs(node, seen):
    here = node
    seen[here] = True
    #print(f"here: {here}")
    if here <= N:
        person[here] = 1
    for goto in graph[here]:
        if not seen[goto]:
            dfs(goto, seen)


dfs(1, seen)
print("YES" if sum(person) == N else "NO")


Measured memory_bytes: 49308
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
static const int fast_io = [](){ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);return 0;}();
static const int precise_doubles = [](){cout<<fixed<<setprecision(20);return 0;}();
typedef pair<int, int> PII;
typedef tree<PII, null_type, less<PII>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
// find_by_order(k) - iterator to k'th element (0-based), order_of_key(k) - #things < k
typedef long double LD;
typedef long long LL;
#define EVAL(x) x
#define NEWL EVAL({cout << '\n';})
#define SPA(x) EVAL({cout << #x" = " << x << ' ';})
#define SPAR(a, b) EVAL({cout<<#a" = ";for(auto it=a;it!=b;)cout<<*(it++)<<" ";cout<<'\n';})
#define SPAV(v) EVAL({cout<<#v" = ";for(auto it=v.begin();it!=v.end();)cout<<*(it++)<<" ";cout<<'\n';})
const int INF = 0x3f3f3f3f; // 1.0e9
const LL LINF = 0x3f3f3f3f3f3f3f3fll; // 4.5e18
const LD eps = 1e-20;
const int mod = 1e9 + 7;
inline int msum(int x, int y) {return (x+y<mod ? x+y : x+y-mod);}
inline int mdif(int x, int y) {return (x>=y ? x-y : x-y+mod);}
inline int mprod(int x, int y) { return (1ll*x*y) % mod; }
inline int mpow(int x, LL y) {LL r=1;while(y){if(y&1)r=mprod(r,x);x=mprod(x,x);y>>=1;}return r;}
inline int minv(int x) { return mpow(x, mod-2); }
//------------------------------------------------------------------------------------------------------

#define less xzvfhafdxc

const int N = 1e5 + 10;

int n;
int a[N];
int id = 0;

int main() {
    cin >> n;
    ordered_set S;
    S.insert({-1, id++});
    for (int i = 1; i <= n; i++) {
        int x; cin >> x;
        int less = S.order_of_key({x, -1});
        if (less > 0) {
            S.erase(S.find_by_order(less-1));
        }
        S.insert({x, id++});
    }
    cout << S.size() << '\n';
}






























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

int main()
{
    long double a;
    long double  b;
    
    cin >> a;
    cin >> b;
    //count << a; 
    //count << b; 
    long double rtn = 0;

    rtn = (long double)(a * b);

    long rtn2 =  rtn;
    cout << rtn2;

    return 0;
}

Measured memory_bytes: 3728
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
typedef pair<int,int> P; typedef priority_queue<int> Pr; typedef vector<int> V; typedef vector<P> Vp; typedef map<int,int> MP;
const int mod = 1000000007; const Int INF = 1145141919810893931;
#define END {cout<<ans<<'\n'; return 0;}
template<class T> inline bool cmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool cmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

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

    Int n; cin>>n; Int a[n];
    for (int i = 0; i < n; i++)cin>>a[i];
    Int ma=*max_element(a,a+n),use=-1;
    double b=ma/2;
    for (int i = 0; i < n; i++){
        if(a[i]!=ma&&abs(b-a[i])<abs(b-use))use=a[i];
    }
    cout<<ma<<' '<<use<<'\n';
}

Measured memory_bytes: 1024
fun main(args: Array<String>) {
    val m1 = readLine()!!.split(" ").map(String::toInt)[0]
    val m2 = readLine()!!.split(" ").map(String::toInt)[0]
    solver5(m1, m2)
}

fun solver5(m1: Int,m2: Int) {
    var result = if( m1 == m2) 0 else 1
    print(result)
}

Measured memory_bytes: 37784
#include <bits/stdc++.h>
 
#define endl '\n'
#define fi first
#define se second
#define MOD(n,k) ( ( ((n) % (k)) + (k) ) % (k))
#define forn(i,n) for (int i = 0; i < n; i++)
#define forr(i,a,b) for (int i = a; i <= b; i++)
#define all(v) v.begin(), v.end()
#define pb(x) push_back(x)
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ii> vii;

const int MX = 100005;
int n, m, a[MX], b[MX], res[MX], vis[MX];
vii adj[MX];

bool dfs (int u, int p) {
	int cn = 0;
	vis[u] = 1;

	for (ii &v : adj[u])
		if (v.fi != p && vis[v.fi] != 2) {
			if (vis[v.fi] == 1) {
				res[v.se] = u;
				cn++;
			} else if (dfs(v.fi, u)) {
				res[v.se] = v.fi;
			} else {
				res[v.se] = u;
				cn++;
			}
		}

	vis[u] = 2;
	return cn & 1;
}

int main () {
	ios_base::sync_with_stdio(0); cin.tie(0);
	
	cin >> n >> m;

	forn (i, m) {
		cin >> a[i] >> b[i];
		adj[a[i]].emplace_back(b[i], i);
		adj[b[i]].emplace_back(a[i], i);
	}

	if (dfs(1, 1)) {
		cout << -1 << endl;
		return 0;
	}

	forn (i, m) {
		if (res[i] == a[i]) cout << a[i] << " " << b[i] << endl;
		else cout << b[i] << " " << a[i] << endl;
	}

	return 0;
}


Measured memory_bytes: 14720
///
// File:  b.go
// Author: ymiyamoto
//
// Created on Sun May  6 12:41:16 2018
//
package main

import (
	"fmt"
)

var N, x int64
var arr []int64

func min(a, b int64) int64 {
	if a < b {
		return a
	}
	return b
}

func main() {
	fmt.Scan(&N, &x)
	arr = make([]int64, N)
	for i := range arr {
		fmt.Scan(&arr[i])
	}

	dp := make([][]int64, N)
	for i := range dp {
		dp[i] = make([]int64, N)
	}
	for i := range dp[0] {
		dp[0][i] = arr[i]
	}

	var ans int64
	ans = 1 << 60
	for k := int64(0); k < N; k++ {
		costs := int64(0)
		for i := int64(0); i < N; i++ {
			if k > 0 {
				dp[k][i] = min(dp[k-1][i], arr[(i-k+N)%N])
			}
			costs += dp[k][i]
		}
		ans = min(ans, x*k+costs)
	}

	fmt.Println(ans)
}


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

int main(){
  string s;
  cin >> s;
  int input = stoi(s);
  int first = input / 100;
  int last = input % 100;
  if(0 < first && first < 13){
    if(0 < last && last < 13){
      cout << "AMBIGUOUS" << endl;
    }else{
      cout << "MMYY" << endl;
    }
  }else{
    if(0 < last && last < 13){
      cout << "YYMM" << endl;
    }else{
      cout << "NA" << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 256
val MOD = 1000000007L

fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val t = readLine()!!.split(' ').map(String::toInt)
    val a = readLine()!!.split(' ').map(String::toInt)
    val amx = IntArray(n)
    val ans = IntArray(n)
    for (i in t.indices) {
        if (i != 0 && t[i - 1] > t[i]) {
            println(0)
            return
        }
        if (i == 0 || t[i - 1] < t[i]) {
            ans[i] = t[i]
        } else {
            amx[i] = t[i]
        }
    }
    for (i in t.indices.reversed()) {
        if (i != n - 1 && a[i + 1] > a[i]) {
            println(0)
            return
        }
        if (i == n - 1 || a[i + 1] < a[i]) {
            if (ans[i] != 0 && ans[i] != a[i] || amx[i] != 0 && amx[i] < a[i]) {
                println(0)
                return
            }
            ans[i] = a[i]
        } else {
            if (ans[i] != 0 && ans[i] > a[i]) {
                println(0)
                return
            }
            amx[i] = Math.min(amx[i], a[i])
        }
    }
    var res = 1L
    for (i in t.indices) {
        if (ans[i] == 0) res = (res * amx[i]) % MOD
    }
    println(res)
}

Measured memory_bytes: 57992
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define debug(x) cout << #x << ": " << x << endl
#define repn(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, a) for(int i = 0; i < (int)(a); i++)
#define all(v) v.begin(), v.end() 
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define endl '\n'

int gcd(int a, int b){ return ((b == 0) ? a : gcd(b, a % b)); }

vi s[15];

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	//freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
	int n, m;
	cin >> n >> m;
	//the constraints are small so we bruteforce every possible option
	//use bit representation of sets
	int a, b;
	rep(i, m){
		cin >> a;
		rep(j, a){
			cin >> b;
			b--;
			s[i].pb(b);
		}
	}
	vi p(m);
	rep(i, m) cin >> p[i];
	int ans = 0;
	rep(i, (1 << n)){
		int f = 1;
		rep(j, m){
			int cnt = 0;
			for(int u : s[j]){
				if(i & (1 << u)) cnt++;
			}
			if(cnt % 2 != p[j]) f = 0;
		}
		if(f) ans++;
	}
	cout << ans << endl;
	return 0;
}
/*
Things to look out for:
	- Integer overflows
	- Array bounds
	- Special cases
Be careful!
*/


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

ll rec(ll h){
	if(h <= 1) return h;
	return 1 + 2 * rec(h / 2);
}

int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	
	ll h; cin >> h;
	cout << rec(h) << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	int a[100010]={0};
	for(int i=1;i<=n;i++){
		int x;
		cin>>x;
		if(x){
			a[x]++;
			a[x-1]++;
			a[x+1]++;
		}else{
			a[x]++;
			a[x+1]++;
		}
	}
	int ma=-1;
	for(int i=1;i<=100002;i++){
		ma=max(a[i],ma);
		//cout<<ma<<endl;
	}
	cout<<ma<<endl;
	return 0;
}


Measured memory_bytes: 640
#include <stdio.h>
int main()
{
    int n,m,i,a[3]={1,2,3};
    scanf("%d%d",&n,&m);
    for(i=0;i<3;i++)
    {
        if(a[i]==n||a[i]==m)
           a[i]=0;

    }
    for(i=0;i<3;i++)
    {
        if(a[i]!=0)
            printf("%d\n",a[i]);
    }
}


Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <vector>
#include <ctype.h>
#include <cmath>
#include <iomanip>
#include <ios>
using namespace std;
int main(void){
    
    int a,b,c;
    cin>>a>>b>>c;
    cout<<a*b/2<<endl;
    
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define lln long long int
#define llu unsigned lln
#define sc(n) scanf("%d",&n);
#define scl(n) scanf("%lld",&n);
#define scd(n) scanf("%lf",&n);
#define pf(res) printf("%d\n",res);
#define pfl(res) printf("%lld\n",res);
#define pfd(res) printf("%lf\n",res);
#define pb(n) push_back(n);
#define maxii 100005
using namespace std;
typedef pair<int,int> pii;
typedef pair<lln,lln> pll;
vector<int> vi;
vector<lln> vl;
vector<pii> vii;
vector<pll> vll;


int arr[maxii];
int arr2[maxii];
bool check[maxii];
bool check2[1000][1000];
int n,m;
int x[]={1,-1,0,0};
int y[]={0,0,-1,1};
int x2[]={1,-1,0,0,1,-1,1,-1};
int y2[]={0,0,-1,1,1,-1,-1,1};
int bx[]={0,0,1,-1,-1,1,1,-1};
int by[]={1,-1,0,0,-1,-1,1,1};
int kx[] = {1,1,2,2,-1,-1,-2,-2};
int ky[] = {2,-2,1,-1,2,-2,1,-1};

bool isvisited(int x,int y)
{
    if(x<1 || y<1 || x>n ||y>m)
    {
        return false;
    }
    else if(check2[x][y]==true)
    {
        return false;
    }
    else return true;
}
int gcd(int a,int b)
{
    if(b==0){
      return a;
     }
    return gcd(b,a%b);
}
int lcm(int a,int b)
{
    int res=(a*b)/gcd(a,b);
    return res;
}
int po(int a,int b)
{
    int res=1;
    while(b)
    {
        if(b%2!=0)
        {
            res*=a;
            b--;
        }
        else
        {
            a*=a;
            b/=2;
        }
    }
    return res;
}

lln modMul(lln  a, lln b,lln mod){
    lln ans = 0;
    a = a % mod;
    while (b > 0){
        if ( b % 2 )ans = (ans%mod+ a%mod) % mod;
        a = (a%mod * 2%mod) % mod;
        b /= 2;
    }
    return ans % mod;
}
lln powerMod(lln a,lln b,lln mod){
	if(b==0)return 1LL%mod;
	lln x=powerMod( a,b/2,mod );
	x = ( x%mod * x%mod ) % mod;
	if( b%2==1 )x = ( x%mod * a%mod ) % mod;
	return x%mod;
}

int main()
{
   string a;
   cin>>a;
   int sum=0;
   for(int i=0;i<a.size();i++)
   {
       int p=a[i]-'0';
       sum+=p;
   }
   if(sum%9==0)
   {
       cout<<"Yes\n";
   }
   else cout<<"No";

}






Measured memory_bytes: 3760
#include <bits/stdc++.h>
using namespace std;
using pii=pair<int,int>;
using ll=long long;

#define fi first
#define se second
#define pb push_back
#define rep(i,n) for(int i=0; i<(int)(n); i++)

int main() {

	int n;
	string s;
	cin >> n >> s;
	int l = s.length();
	
	rep(i,l) {
		int t = s[i] - 'A';
		t = (t + n) % 26;
		char c = t + 'A';
		putchar(c);
	}
	cout << endl;
  return 0;
}


Measured memory_bytes: 256
i,a[1<<17],b[1<<17];c;
main(s){
	for(;~(c=getchar());)c>10?a[i]=a[i]*10+c-48:i++;
	for(b[i=s]=1;!b[s=a[s]]++&&s-2;i++);
	printf("%d",s==2?i:-1);
}

Measured memory_bytes: 896
/*
 *       ~ AtCoder  Botay ~
 *        code by kazalika
 */

#include <bits/stdc++.h>

using namespace std;



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

  string s, t;
  cin >> s >> t;
  if (t.substr(0, (int) s.size()) == s)
    cout << "Yes";
  else 
    cout << "No";

}

Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std ;
int main()
{
    int joi = 0 ;
    int ioi = 0 ;
    char str[10001] = {0} ;
    while( cin >> str )
    {
        joi = ioi = 0 ;
        for ( int i = 0 ; i < strlen(str) ; i++ )
        {
            if ( str[i+1] == 'O' && str[i+2] == 'I' )
            {
                if ( str[i] == 'J' ) joi++ ;
                if ( str[i] == 'I' ) ioi++ ;
            }
        }
        cout << joi << endl << ioi << endl ;
    }
    return 0 ;
}

Measured memory_bytes: 3076
#include<iostream>
#include<vector>
#include <cmath>
#include <map>
#include <set>
#include <algorithm>
#include <string>
#define rep(i,n) for (int i= 0;i<(n);++i)
using namespace std;
typedef long long ll;
const ll maxSum = 50*50+1;
int main() {
    ll N ;
    cin >> N ;
    if(N >= 30){
        cout << "Yes" << endl;

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

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

int main(){
  int X;
  int N;
  int Y[110];
  cin >> X >> N;
  if(N==0){
    cout << X <<endl;
    return 0;
  }
  for(int i=0; i<N ;i++){
    cin >> Y[i];
  }
  bool flag = false;
  //逐次検索
  for(int i=0; i<N ;i++){
    if(X==Y[i]) {
      flag = false;
      break;
    }
    flag = true;
  }
  if(flag){
    cout << X <<endl;
    return 0;
  }
  for(int delta=1;delta<=50;delta++){
    for(int i=0; i<N ;i++){
      if(X-delta==Y[i]){
        flag = false;
      break;
      }
      flag = true;
    }
    if(flag){
    cout << X-delta <<endl;
    return 0;
  }
    for(int i=0; i<N ;i++){
      if(X+delta==Y[i]){
        flag = false;
      break;
      }
      flag = true;
    }
    if(flag){
    cout << X+delta <<endl;
    return 0;
  }
  }
  return 1;
}

Measured memory_bytes: 3156
#include "bits/stdc++.h"
    
using namespace std;
int nummer;
vector<long long >dp(100001,900000000000000);
vector<long long>num;
long long  erg(int n){
	if(dp[n]!=900000000000000){
		return dp[n];
	}
	if(n<0){
		return 900000000000000;
	}
	if(n==0){
		return 0;
	}
	for(int i=1;i<=nummer;i++){
		if(n-i<0){
			break;
		}
		dp[n]=min(dp[n],erg(n-i)+(max(num[n],num[n-i])-min(num[n],num[n-i])));
	}
	return dp[n];
}
int main() {
	int menge,numm;
	cin>>menge>>nummer;
	for(int i=0;i<menge;i++){
		cin>>numm;
		num.push_back(numm);
	}
cout<<erg(menge-1);
    return 0;
}

Measured memory_bytes: 6644
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<ctype.h>
#include<string.h>

#define size 100005

int main()
{
    int n, m, x, arr[size], tol[size], pos, i, a=0, b=0, min;
    scanf("%d%d%d", &n, &m, &x);

    for(i=0; i<=n; i++)
        tol[i]=0;

    for(i=1; i<=m; i++)
    {
        scanf("%d", &arr[i]);
        pos = arr[i];
        tol[pos]=1;
    }

    for(i=x+1; i<=n-1; i++)
    {
        if(tol[i]==1)
            a++;
    }
    for(i=x-1; i>=1; i--)
    {
        if(tol[i]==1)
            b++;
    }
    min = a<b ? a : b;
    printf("%d\n", min);

    return 0;
}


Measured memory_bytes: 1720
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,p[105],m[105][105];
  cin >> n;
  for(int i=1;i<=n;i++){
    cin >> p[i-1] >> p[i];
  }
  for(int i=1;i<=n;i++)m[i][i]=0;
  for(int l=2;l<=n;l++){
    for(int i=1;i<=n-l+1;i++){
      int j=i+l-1;
      m[i][j]=(1 << 21);
      for(int k=i;k<=j-1;k++){
	m[i][j]=min(m[i][j],m[i][k]+m[k+1][j]+p[i-1]*p[k]*p[j]);
      }
    }
  }
  cout << m[1][n] << endl;
}

Measured memory_bytes: 3104
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <cstdlib>
#include <cassert>
#include <cstdio>
#include <cmath>
#include <string>
#include <unordered_map>
#include <iomanip>
#include <deque>
using namespace std;
#define int long long

signed main() {
#ifndef ONLINE_JUDGE
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
#endif
	string s;
	cin >> s;
	if (s.size() >= 4 && s.substr(0, 4) == "YAKI") {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

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

#define rep(i,n) for(ll i = 0; i < n; i++)
#define Rep(i,n) for(ll i = 0; i <= n; i++)
#define REp(i,n) for(ll i = 1; i < n; i++)
#define REP(i,n) for(ll i = 1; i <= n; i++)
#define sz(x) int(x.size())
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define endl '\n'
#define fi first
#define se second
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
template<class T> using V = vector<T>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll &a, const ll &b){return ((a)+(b)-1)/b;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }



int main(){
  int x;
  cin >> x;
  YesorNo(x >= 30);
}

Measured memory_bytes: 3756
//https://atcoder.jp/contests/tenka1-2018-beginner/tasks/tenka1_2018_d
//D - Crossing
#include <bits/stdc++.h>
#if LOCAL
#include "dump.hpp"
#else
#define dump(...)
#endif
using namespace std;
using ll=long long;
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
template<class T>bool chmax(T &a, const T &b) {if (a<b) { a=b; return 1; } return 0;}
template<class T>bool chmin(T &a, const T &b) {if (b<a) { a=b; return 1; } return 0;}
int main() {
#if LOCAL&0
    std::ifstream in("./test/sample-1.in");
    //std::ifstream in("./input.txt");
    std::cin.rdbuf(in.rdbuf());
#else
    cin.tie(0);
    ios::sync_with_stdio(false);
#endif
    ll N; cin>>N;
    bool yn=false;
    ll num=-1;
    FOR(i,1,1e+5){
        ll tmp = (i+1)*i/2;
        if(tmp==N) {
            num=i;
            break;
        }
        if(N<tmp){
            break;
        }
    }
    if(num<=0){
        cout<<"No"<<endl;
        return 0;
    }
    cout<<"Yes"<<endl;

    vector<vector<ll>> ans(num+1);
    ll cnt=1;
    FOR(no,1,num+1){
        ll pos = no-1;
		FOR(i, no-1, num) {
			// ans.at(pos).push_back(no + i);
		    // ans.at(i+1).push_back(no + i);
			ans.at(pos).push_back(cnt);
		    ans.at(i+1).push_back(cnt);
            ++cnt;
		}
	}
    dump(ans);
    cout<<ans.size()<<endl;
    for(const auto& s:ans){
        cout<<s.size();
        for(const auto& v:s){
            cout<<" "<<v;
        }
        cout<<endl;
    }

	return 0;
}

Measured memory_bytes: 3200
#include<bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
#define F first
#define S second
#define pb push_back
#define INF 1e18
#define MOD 1000000007
#define N 1000005
#define BB(V) V[V.size()-2]
#define ex(V) return printf(V),0
using namespace std;
int a[100005];
int main(){
	int n;
	scanf("%d",&n);
	int mx=0;
	for(int i=0;i<n;i++){
		scanf("%d",a+i);
		mx=max(mx,a[i]);
	}
	int t=a[0]==mx?1:0;
	for(int i=0;i<n;i++){
		if(abs(a[t]-mx/2)>abs(a[i]-mx/2))t=i;
	}
	printf("%d %d",mx,a[t]);
}

Measured memory_bytes: 640
#include <stdio.h>
#define swap(type,m,n) do{type t=m; m=n; n=t;}while(0)

int main(void) {
	int a, b, c;
	scanf("%d %d %d", &a, &b, &c);

	if (a > b)swap(int, a, b);
	if (b > c)swap(int, b, c);
	if (a > b)swap(int, a, b);
	printf("%d %d %d\n", a, b, c);
	return 0;
}

Measured memory_bytes: 1808
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long
int N, X; 
int a[51], b[51];

int f(int N, int X) {
    if (X == 0) return 0;
    if (N == 0) return 1;
    int ret = 0;
    X--;
    if (X >= a[N - 1]) {
        ret += b[N - 1];
        X -= a[N - 1];
        if (X <= 0) return ret;
        X--;
        ret++;
        if (X >= a[N - 1]) {
            ret += b[N - 1];
            X -= a[N - 1];
            X--;
            return ret;
        } else {
            return f(N - 1, X) + ret;
        }
    } else {
        return f(N - 1, X);
    }
    

    
}

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N >> X;
    
    a[0] = 1;
    b[0] = 1;
    rep(i, N) a[i + 1] = a[i] * 2 + 3;
    rep(i, N) b[i + 1] = b[i] * 2 + 1;
    cout << f(N, X) << endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<iomanip>
typedef long long int ll;
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define REP(i,n) for (int i=0;i<(n);i++)
#define EREP(i,n) for (int i=1;i<=(n);i++)
#define ALL(a) (a).begin(),(a).end()
//#define EVEL 1

#ifdef EVEL
#define DEB(X) cout << #X << ":" <<X<<" " ;
#define TF(f) f ? cout<<"true  " : cout<<"false ";
#define END cout<<"\n";
#else
#define DEB(X) {}
#define TF(f) {}
#define END {}
#endif
const int MOD =  1000000007 ;
const int INF = 2000000000;


    int A,B;

int main(){
    cin>>A>>B;


    cout<<(A-1)*(B-1);
    return 0;

}


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

int main() {
  int A, B, tmp;
  int o1,o2,o3,o4,o5;
  int sum = 0;
  cin >> A >> B ;
  
  for(int i=A;i<=B;i++){
    tmp = i;

    o1 = tmp / 10000;
    tmp %= 10000;
    
    o2 = tmp / 1000;
    tmp %= 1000;
    
    o3 = tmp / 100;
    tmp %= 100;
    
    o4 = tmp / 10;
    tmp %= 10;

    o5 = tmp;
    
    if(o1==o5&&o2==o4){
        sum++;
//        cout << i << endl;
    }

  }
  cout << sum << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ull unsigned long long
# define ll long long
# define mod 1000000007LL 
using namespace std;
int main()
{
     ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t;
    cin>>t;
    unordered_map<string,ll>ans;
    while(t--)
    {
        string s;
        cin>>s;
        ans[s]++;
    }
    cout<<"AC"<<" "<<"x"<<" "<<ans["AC"]<<"\n";
    cout<<"WA"<<" "<<"x"<<" "<<ans["WA"]<<"\n";
    cout<<"TLE"<<" "<<"x"<<" "<<ans["TLE"]<<"\n";
    cout<<"RE"<<" "<<"x"<<" "<<ans["RE"]<<"\n";



    
    return 0;
}

Measured memory_bytes: 3668
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <cmath>
using namespace std;
typedef long long unsigned int ll;
 
int main() {
 
  int a,b,c;
  cin >> a;
  cin >> b;
  cin >> c;
  cout << (a*b)/2 <<endl;
  
   return 0;
}


Measured memory_bytes: 256
from fractions import gcd
t = int(raw_input())
for _ in xrange(t):
    a, b, c, d = map(int, raw_input().split())
    if a < b or b > d:
        print 'No'
        continue
    a -= b
    if a > c:
        a -= (a - c + b - 1) / b * b
    if a < 0:
        print 'No'
    elif d % b == 0 or c >= b:
        print 'Yes'
    else:
        d = gcd(b, d)
        a += (c - a + d) / d * d
        print 'No' if a < b else 'Yes'


Measured memory_bytes: 4392
A, B, K = map(int,input().split())
ansList = []
for i in range(K):
    if A + i > B:
        break
    ansList.append(A + i)
for i in range(K - 1,-1,-1):
    if B - i < A or B - i in ansList:
        continue
    ansList.append(B - i)
for c in ansList:
    print(c)

Measured memory_bytes: 3060
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
	int x,y;
	while(true){
		cin>>x>>y;
		if(x==0&&y==0)
			break;
		int best=1000000000;
		int a[4];
		for(int f=1;f*f<=x;f++){
			if(x%f==0){
				for(int g=1;g*g<=y;g++){
					if(y%g==0){
						a[0]=f,a[1]=x/f;
						a[2]=g,a[3]=y/g;
						sort(a,a+4);
						int count=0;
						for(int i=0;i<3;i++){
							count+=(a[i+1]-a[i])*(a[i+1]-a[i]);
						}
						best=min(best,count);
					}
				}
			}
		}
		cout<<best<<endl;
	}
	return 0;
}

Measured memory_bytes: 1172
#include <cstdio>
#include <algorithm>
#define MAXN 1005
#define INF 999999

int d[MAXN][MAXN], be[MAXN][MAXN];
int V, E;
void floyd() {
    for(int k = 1; k <= V; k++)
        for(int i = 1; i <= V; i++)
            for(int j = 1; j <= V; j++)
                d[i][j] = std::min(d[i][j], d[i][k] + d[k][j]);
}

int main() {
    int a, b, c, cnt = 0;
    scanf("%d %d", &V, &E);
    for(int i = 1; i <= V; i++) {
        for(int j = 1; j <= V; j++) {
            if(i == j) {
                d[i][j] = 0;
                be[i][j] = 0;
            }else {
            	d[i][j] = INF;
            	be[i][j] = INF;
			} 
        }
    }

    for(int i = 0; i < E; i++) {
        scanf("%d %d %d", &a, &b, &c);
        d[a][b] = c;
        d[b][a] = c;
        be[a][b] = c;
        be[b][a] = c;
    }

    floyd();
    for(int i = 1; i <= V; i++)
        for(int j = i+1; j <= V; j++)
            if(be[i][j] != INF && d[i][j] != be[i][j])
                cnt++;
    printf("%d\n", cnt);
    return 0;
}


Measured memory_bytes: 4608
#include<cmath>
#include<math.h>
#include<ctype.h>
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<cwchar>
#include<cwctype>
#include<deque>
#include<exception>
#include<fstream>
#include<functional>
#include<iomanip>
#include<ios>
#include<iosfwd>
#include<iostream>
#include<istream>
#include<iterator>
#include<limits>
#include<list>
#include<locale>
#include<map>
#include<memory>
#include<new>
#include<numeric>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<stdexcept>
#include<streambuf>
#include<string>
#include<typeinfo>
#include<utility>
#include<valarray>
#include<vector>
#include<string.h>
#include<stdlib.h>
#include<stdio.h>
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b;
	cin>>a>>b;
	cout<<((a-1)*(b-1));
	return 0;
}

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

typedef long long int ll;


ll n;ll a,b,c,d;
string s;

int main(){

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


    cin>>n;
    cin>>a>>b>>c>>d;
    cin>>s;

    s = 'a'+s;

    if(c<d)
    {
        ll flg = 0;
        for(ll i=b;i<=d;i++)
        {
            if(i==d)
            {
                flg = 1;break;
            }

            if(i+2<=d)
            {
                if(s[i+2]=='.')
                {
                    i++;continue;
                }
            }
            if(s[i+1]!='.'){
                break;
            }
        }
        if(flg==0)
        {
            cout<<"No"<<endl;return 0;
        }

        flg = 0;

        for(ll i=a;i<=c;i++)
        {
            if(i==c)
            {
                flg = 1;break;
            }

            if(i+2 <= c)
            {
                if(s[i+2]=='.'){
                    i++;continue;
                }
            }
            if(s[i+1]=='#')
            {
                break;
            }

        }
        if(flg==0){
            cout<<"No"<<endl;return 0;
        }
        else{
            cout<<"Yes"<<endl;return 0;
        }

    }
    else{
            ll flg = 0;
            ll i = 0;
        for( i=b;i<=d;i++)
        {
            if(s[i-1]=='.' and s[i+1]=='.'){
                flg = 1;
                break;
            }
            if(s[i+1]=='#')
            {
                if(i+2 <= d)
                {
                    if(s[i+2]=='.'){
                        i++;continue;
                    }
                }
                break;
            }

        }
        //cout<<flg<<endl;
        if(flg==0){
            cout<<"No"<<endl;return 0;
        }
        flg = 0;
        for(ll i=a;i<=c;i++)
        {
            if(i==c){
                flg = 1;
                break;
            }

            if(s[i+1]=='#')
            {
                if(i+2<=c)
                {
                    if(s[i+2]=='.'){
                        i++;continue;
                    }
                }
                break;
            }


        }
        //cout<<flg<<endl;
        if(flg==0){
            cout<<"No"<<endl;return 0;
        }

        flg = 0;
        for(ll i=b;i<=d;i++)
        {
            if(i==d){
                flg = 1;
                break;
            }

            if(s[i+1]=='#')
            {
                if(i+2<=d)
                {
                    if(s[i+2]=='.'){
                        i++;continue;
                    }
                }
                break;
            }


        }
        if(flg==0){
            cout<<"No"<<endl;return 0;
        }
        cout<<"Yes"<<endl;return 0;

    }






}


Measured memory_bytes: 720
N=input()
N=int(N)

a = [0 for i in range(N+1)]

#aの入力
for i in range(1,N+1):
    a[i]=input()
    a[i]=int(a[i])

#ボタン処理
#ボタン1からスタート
count=0
num=1
while True:
    #2のボタンに到達したか？
    if num==2:
        #最終出力、パターン1
        print(count)
        break
    else:
        if a[num]==0:
            #ゼロならループに入るので、whileを外れる
            #最終出力、パターン1
            print(-1)
            break
        else:
            #カウントを1増
            count+=1
            #numを一度退避
            temp=num
            #numを次のボタンへ
            num=a[num]
            #既に使った印として、今使ったボタンの中身を0に
            a[temp]=0

Measured memory_bytes: 7080
n,k=map(int,input().split())
li=[list(map(int,input().split())) for i in range(n)]
gr=[0]*(n+1) #各グループの出現回数をメモする配列

from operator import itemgetter
li=sorted(li, key=itemgetter(1), reverse=True)

A=[] #大きい方からK個以内の配列で、2個以上あるやつの2番目以降のやつの大きさを記録

for i in range(k):
  if gr[li[i][0]]>=1:
    A.append(li[i][1])
  gr[li[i][0]]+=1

A.reverse()

B=[] #既に同じグループが登場してしまってない子の大きさを記録
for i in range(k,n):
  if gr[li[i][0]]==0:
    B.append(li[i][1])
  gr[li[i][0]]+=1

#現時点での種類数とポイントを測定
sp=set()
ans=0
for i in range(k):
  ans+=li[i][1]
  sp.add(li[i][0])
sp=len(sp)
ans+=sp*sp

koukan=[] #その交換で、累積でどの程度増減するか
zouka=0
for a,b in zip(A,B):
  zouka+=(sp+1)**2-sp**2-(a-b)
  #print(a,b,sp,zouka)
  koukan.append(zouka)
  sp+=1

#koukanの中で最大の増加を探して、ansに+する。
# print(A,B)
# print(koukan)
if koukan:
  ans+=max(0,max(koukan))

print(ans)

Measured memory_bytes: 31316
import collections
N,K=map(int,input().split())
A=list(map(int,input().split()))


c=collections.Counter(A)

a=(c.most_common()[K:])

ans=0
if a==[]:
  print(ans)
else:
  for i in range(len(a)):
    ans+=a[i][1]
  print(ans)

Measured memory_bytes: 39320