akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;

// template {{{  0 
// using {{{ 1
using ll = long long int;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vii = vector<pii>;
using vll = vector<pll>;
// }}} 1
// definition {{{ 1
// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)
#define Scll(x) scanf("%lld", &x)
#define Scll2(x,y) scanf("%lld%lld", &x, &y)
#define Scll3(x,y,z) scanf("%lld%lld%lld", &x, &y, &z)
#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2
// constants {{{ 2
#define EPS (1e-7)
#define INF (2e9)
#define PI (acos(-1))
// }}} 2
// systems {{{ 2
#define Repe(x,y,z) for(ll x = z; x < y; x++)
#define Rep(x,y) Repe(x,y,0)
#define RRepe(x,y,z) for(ll x = y-z-1; x >= 0; x--)
#define RRep(x,y) RRepe(x,y,0)
// }}} 2
// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n")
#define YESNO(a) (a)?printf("YES\n"):printf("NO\n")
// }}} 2
// }}} 1
// input {{{ 1
// }}} 1
// }}} 0

int main() {

	int N;
	Scd(N);

	vi a(N);
	vi b(N);
	Rep(i,N) Scd(a[i]), b[i] = a[i];

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

	int dis = 0;

	Rep(i,N){
		if(a[i]!=b[i]) dis++;
	}

	int Q;
	Scd(Q);

	int x,y;
	int ans = 0;

	while(Q--){
		if( dis == 0 ) {
			printf( "%d\n", ans );
			return 0;
		}
		Scd2(x,y);
		x--,y--;
		if( a[x] == b[x] ) dis++;
		if( a[y] == b[y] ) dis++;
		swap(a[x],a[y]);
		if( a[x] == b[x] ) dis--;
		if( a[y] == b[y] ) dis--;
		ans++;
	}

	printf( "%d\n", dis == 0 ? ans : -1 );
	return 0;
}




Measured memory_bytes: 5172
A=[]
for i in range(3):
    B=list(map(int,input().split()))
    A.append(B)

if A[0][0]-A[1][0]!=A[0][1]-A[1][1]:
    print('No')
    exit(0)

if A[0][0]-A[1][0]!=A[0][2]-A[1][2]:
    print('No')
    exit(0)

if A[1][0]-A[2][0]!=A[1][1]-A[2][1]:
    print('No')
    exit(0)

if A[1][0]-A[2][0]!=A[1][2]-A[2][2]:
    print('No')
    exit(0)

print('Yes')

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <queue>

using namespace std;

const int nmax = 1e9 + 7;
const long long INF = 1e16;
typedef long long ll;

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

  ll ans = N - 1;
  for (ll i = 2; i * i <= N; i++){
    if (N % i == 0){
      ans = min(ans, i + (N / i) - 2);
    }
  }
  cout << ans << endl;
    
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <ctime>
#include <iomanip>
#include <numeric>
using namespace std;
const int MAX = 2e5 + 4;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int n, m;
	cin >> n >> m;
	int p;
	string s;
	string AC = "AC";
	int correct = 0, penalty = 0;
	bool problem[MAX] = { false };
	vector<int> penalties(MAX);
	for (int i = 0; i < m; i++)
	{
		cin >> p >> s;
		if (!problem[p])
		{
			if (s == AC)
			{
				correct++;
				problem[p] = true;
				penalty += penalties[p];
			}
			else penalties[p]++;
		}
	}
	cout << correct << " " << penalty;
	return 0;
}

Measured memory_bytes: 1280
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000
#define MOD 10000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

int n, m;
int res=0;
vector<vector<int> > to;
vector<bool> seen;

void dfs(int u){
    bool can = true;
    REP(i,n){
        if( seen[i]==false && i!=u ) can = false;
    }

    if(can){
        res++;
        return;
    }

    //フラグを立てる
    seen[u] = true;
    for(auto x : to[u]){
        if(seen[x] != false) continue;
        dfs(x);
    }
    //フラグを下げる
    seen[u] = false;
}

int main() {
    cin >> n >> m;
    to.resize(n);
    seen.resize(n, false);
    REP(i,m){
        int a,b; cin >> a >> b;
        a--; b--;
        to[a].PB(b);
        to[b].PB(a);        
    }

    dfs(0);

    cout << res << endl;
}

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

int main() {

  int a,b;
  cin >> a >> b;
  
  int x = 2*b + 1;
  
  if(a%x == 0) cout << a/x << endl;
  else cout << a/x + 1 << endl;

}


Measured memory_bytes: 256
import java.util.*;

public class Main{
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int A = sc.nextInt();
    int B = sc.nextInt();
    int count =0;
    for (int i=A; i<=B; i++) {
      if (i % 100 == i / 10000 + (i / 1000 - i / 10000 * 10) * 10) count++;
    }
    System.out.println(count);
  }
}

Measured memory_bytes: 22612
#include <stdio.h>
#include <stdlib.h>
#include <string.h>


int main() {
  int A, B, C, result;
  int i;
  scanf ("%d %d %d", &A, &B, &C);
  
  result = (A-B>C) ? 0 : C-(A-B);
  
  
  printf("%d", result);
  return 0;
}




Measured memory_bytes: 128
#include <algorithm>
#include <bitset>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <utility>
using namespace std;

#define ABS(a) (((a) >= 0) ? (a) : -(a))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) > (b) ? (b) : (a))
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define RFOR(i, a, b) for (int i = a; i > b; --i)
#define REP(i, n) for (int i = 0; i < n; ++i)
#define int long long

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

const int kMaxN = 100000;

int n;
int a[kMaxN];
int ans, d;

signed main() {
  cin >> n;
  REP(i, n) { cin >> a[i]; }

  int mx = 0;
  REP(i, n) { mx = MAX(a[i], mx); }

  d = 1000000000;
  if (mx%2 == 0) {
    REP(i, n) {
      if (a[i] == mx) { continue; }
      if (ABS(mx/2 - a[i]) < d) {
        d = ABS(mx/2 - a[i]);
        ans = a[i];
        if (d == 0) { break; }
      }
    }
  } else {
    REP(i, n) {
      if (a[i] == mx) { continue; }
      if (a[i] <= mx/2) {
        if (mx/2 - a[i] < d) {
          d = mx/2 - a[i];
          ans = a[i];
          if (d == 0) { break; }
        }
      } else {
        if (a[i] - (mx/2 + 1) < d) {
          d = a[i] - (mx/2 + 1) ;
          ans = a[i];
          if (d == 0) { break; }
        }
      }
    }
  }

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


Measured memory_bytes: 1024
import math


a,b,c = map(int,input().split())
sin = math.sin(math.radians(c))
y = a*b*sin
print(y/2)
cos = math.cos(math.radians(c))
x = a ** 2 + b ** 2 - 2*a*b*cos
x = math.sqrt(x)
print(a+b+x)
print(b*sin)


Measured memory_bytes: 5704
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <sstream>
#include <functional>
#include <map>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <list>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;
#define rep(i,n) for(int (i)=0;(i)<(ll)(n);++(i))
#define repd(i,n,d) for(ll (i)=0;(i)<(ll)(n);(i)+=(d))
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset((m),(v),sizeof(m))
#define chmin(X,Y) ((X)>(Y)?X=(Y),true:false)
#define chmax(X,Y) ((X)<(Y)?X=(Y),true:false)
#define fst first
#define snd second
#define UNIQUE(x) (x).erase(unique(all(x)),(x).end())
template<class T> ostream &operator<<(ostream &os, const vector<T> &v){int n=v.size();rep(i,n)os<<v[i]<<(i==n-1?"":" ");return os;}

int main(){
	int n;
	cin>>n;
	vector<int> a(n);
	int s = 0;
	rep(i, n){
		cin>>a[i];
		a[i] &= 1;
		s += a[i];
	}
	int res = 1, res2 = 1;
	rep(i, n) res *= 3;
	rep(i, n-s) res2 *= 2;
	cout<<res-res2<<endl;
	return 0;
}


Measured memory_bytes: 256
#import numpy as np
import sys
from collections import defaultdict
import math
import itertools
import bisect
read = sys.stdin.buffer.read
readline = sys.stdin.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10000)

N = int(readline())
A = list(map(int,input().split()))
#A = []  
#[bisect.insort_right(A, x) for x in tmp]
B = list(map(int,readline().rstrip().split()))
#B = []
#[bisect.insort_right(B,x) for x in tmp ]
C = list(map(int,readline().rstrip().split()))
#C = []
#[bisect.insort_right(C,x) for x in tmp]

A.sort()
B.sort()
C.sort()

listb = []
for i , b in enumerate(B[::-1]):
    if i == 0:
        listb.append(N - bisect.bisect_right(C,b))
    else:
        listb.append(N - bisect.bisect_right(C,b) + listb[i-1])

ans = 0
for a in A :
    indexb = bisect.bisect_right(B,a)
    if indexb == N :
        break
    ans += listb[N-1 - indexb]

print(ans)

Measured memory_bytes: 23520
import sys
input = sys.stdin.readline


def main():
    N = int(input())
    P = list(map(float, input().split()))
    dp = [[0]*(N+1) for _ in range(N+1)]  # i 枚目のコインを投げたとき j 枚が表の確率

    dp[1][0] = 1 - P[0]
    dp[1][1] = P[0]
    for i in range(2, N+1):
        for j in range(i+1):
            dp[i][j] = dp[i-1][j-1] * P[i-1] + dp[i-1][j] * (1 - P[i-1])

    ans = 0
    for i, p in enumerate(dp[N]):
        if i >= (N+1)//2:
            ans += p
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 276104
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int n, a[1005], res;

int main(){
cin >> n;
for(int i=1;i<=n;i++){
	cin >> a[i];
	if(a[i] == a[i - 1]){
		res++;
		a[i] = 0;
	}
}
cout << res;
return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef  long long ll;
using vll=vector<ll>;
using vvll=vector<vll>;
using vi=vector<int>;
using vvi=vector<vector<int>>;
using vb=vector<bool>;
using pii=pair<int,int>;
using vpii=vector<pair<int,int>>;
using plli=pair<ll,int>;
using vplli=vector<pair<ll,int>>;
using pllll=pair<ll,ll>;
using vpllll=vector<pair<ll,ll>>;

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

#define rep(i, begin_i, end_i) for (ll i = (ll)begin_i; i < (ll)end_i; i++)
//試験導入
#define irep(i, end_i, begin_i) for (ll i = (ll)begin_i-1; i >= (ll)end_i; i--)

long long INF = 1LL<<60;
int main( ){
    while(true){
        int H,W;
        cin>>W>>H;
        if(H==0&&W==0)
            break;
        string s[H];
        int si,sj;
        rep(i,0,H){
            cin>>s[i];
            rep(j,0,W){
                if(s[i][j]=='@')
                    si=i,sj=j;
            }
        }
        queue<pii> q;
        q.emplace(si,sj);
        vector<vb> is_v(H,vb(W,false));
        is_v[si][sj]=true;
        int cnt=1;
        while(!q.empty()){
            pii e=q.front();
            q.pop();
            int i=e.first,j=e.second;
            int di[]={1,-1,0,0};
            int dj[]={0,0,1,-1};
            rep(w,0,4){
                int ni=i+di[w],nj=j+dj[w];
                if((ni<0||ni>H-1)||(nj<0||nj>W-1))
                    continue;
                if(is_v[ni][nj])
                    continue;
                is_v[ni][nj]=true;
                if(s[ni][nj]=='.'){
                    cnt++;
                    q.emplace(ni,nj);
                }
            }
        }
        cout<<cnt<<endl;
    }
    return 0;
}





Measured memory_bytes: 3184
#include <cmath>
#include <string>
#include <iostream>
#include <algorithm>
using namespace std;
#define REP(i,n) for(int i = 0; i < n; i++)

int calcSumOfDigit(int num)
{
    int rem = 0;
    int sum = 0;
    while(num > 0)
    {
        rem = num % 10;
        num /= 10;

        sum += rem;
    }

    return sum;
}

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

    int c = calcSumOfDigit(N);
    if(N % c == 0)
        cout << "Yes" << endl;
    else   
        cout << "No" << endl;

    return 0;

}


Measured memory_bytes: 256
def bfs(row, col, maze)
  now = [row, col]
  dist = Hash.new
  dist[now] = 0
  q = [now]
  until q.empty?
    now = q.shift
    return -1 if maze[now[0]][now[1]] == '#'
    up = [now[0] - 1, now[1]]
    down = [now[0] + 1, now[1]]
    left = [now[0], now[1] - 1]
    right = [now[0], now[1] + 1]
    # 上
    if now[0] - 1 >=0 && maze[up[0]][up[1]] == '.' && !dist[up]
      q.push up
      dist[up] = dist[now] + 1
    end
    # した
    if now[0] + 1 <= maze.length - 1  && maze[down[0]][down[1]] == '.' && !dist[down]
      q.push down
      dist[down] = dist[now] + 1
    end
    # 左
    if now[1] - 1 >=0 && maze[left[0]][left[1]] == '.' && !dist[left]
      q.push left
      dist[left] = dist[now] + 1
    end
    # 右
    if now[1] + 1 <= maze[0].length - 1 && maze[right[0]][right[1]] == '.' && !dist[right]
      q.push right
      dist[right] = dist[now] + 1
    end
  end
  dist.values.max
end

h, w = gets.split.map(&:to_i)
maze = []
for i in 0..h-1
  maze << gets.chomp.chars
end

ans = []
ans << bfs(0, 0, maze)
for i in 0..h-1
  for j in 0..w-1
    ans << bfs(i, j, maze)
  end
end
p ans.max


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

#define MIN(x, y) ((x) < (y) ? (x) : (y))
#define MAX(x, y) ((x) > (y) ? (x) : (y))

#define DIVUP(x, y) (((x) + ((y) - 1)) / (y))
#define DIVOFF(x, y) (((x) + ((y) / 2)) / (y))
#define REMAINDER(x, y) ((x) % (y))

char S[50][53];

int main() {
  int H, W; scanf("%d%d", &H, &W);
  for (int i{}; i < H; ++i) scanf("%s", &S[i]);

  for (int x{}; x < H; ++x) {
    for (int y{}; y < W; ++y) {
      if (S[x][y] == '#') continue;
      char count{};
      for (int i{x-1}; i <= x+1; ++i) {
        for (int j{y-1}; j <= y+1; ++j) {
          if (i == x && j == y) continue;
          if (i < 0 || j < 0) continue;
          if (S[i][j] == '#') ++count;
        }
      }
      S[x][y] = '0' + count;
    }
  }

  for (int i{}; i < H; ++i) printf("%s\n", S[i]);

  return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main{
    public static void main(String[] args)
    {
        Scanner sc = new Scanner(System.in);

        int a, b, answer;
        
        a = sc.nextInt();
        b = sc.nextInt();
        

        if(a>9||b>9)
            answer = -1;
        else
            answer = a*b;
        
        System.out.println(answer);
    }
}

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

using namespace std;

const int mod = 998244353;

int add() { return 0; }
template<typename... M> int add(int a, M... b) {
  int x = add(b...);
  return a + x - mod * (a + x >= mod);
}

int mul() { return 1; }
template<typename... M> int mul(int a, M... b) {
  return int(1ll * a * mul(b...) % mod);
}

int pwr(int a, long long x) {
  return (x ? mul(pwr(mul(a, a), x >> 1), (x & 1 ? a : 1)) : 1);
}

int dvd(int a, int b) {
  return mul(a, pwr(b, mod - 2));
}

int sub(int a, int b) {
  return a - b + mod * (a < b);
}

void inc(int& a, int b) {
  a = add(a, b);
}

void dec(int& a, int b) {
  a = sub(a, b);
}

const int N = 3030;
int dp[N][N];

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

  int n, s;
  cin >> n >> s;
  int ans = 0;
  for (int i = 0; i < n; ++i) {
    int x;
    cin >> x;
    dp[i][0] = i + 1;
    for (int j = 0; j <= s; ++j) {
      if (j > 0 and j < s) {
        inc(dp[i + 1][j], dp[i][j]);
      }
      if (j + x <= s) {
        inc(dp[i + 1][j + x], dp[i][j]);
      }
    }
    inc(ans, mul(dp[i + 1][s], n - i));
  }
  cout << ans;

  return 0;
}

Measured memory_bytes: 35840
#include<bits/stdc++.h>
//ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
//clock_t start=clock();clock_t end=clock();cout<<(double)(end-start)/CLOCKS_PER_SEC<<endl;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> ppll;
typedef pair<ll,pll> plpl;
typedef tuple<ll,ll,ll> tl;
typedef pair<double,double> pdd;
ll mod=1000000007;
ll mod2=998244353;
ll mod3=1000003;
ll mod4=998244853;
ll mod5=1000000009;
ll inf=1LL<<60;
double pi=3.141592653589793238462643383279L;
double eps=1e-9;
#define rep(i,m,n) for(ll i=m;i<n;i++)
#define rrep(i,n,m) for(ll i=n;i>=m;i--)
#define srep(itr,st) for(auto itr=st.begin();itr!=st.end();itr++)
#define Max(a,b) a=max(a,b)
#define Min(a,b) a=min(a,b)
int dh[4]={1,-1,0,0};
int dw[4]={0,0,1,-1};
int ddh[8]={-1,-1,-1,0,0,1,1,1};
int ddw[8]={-1,0,1,-1,1,-1,0,1};
ll gcd(ll a,ll b){
    if(a<b)swap(a,b);
    if(b==0)return a;
    if(a%b==0)return b;
    return gcd(b,a%b);
}
ll Pow(ll n,ll k){
    ll ret=1;
    ll now=n;
    while(k>0){
        if(k&1)ret*=now;
        now*=now;
        k/=2;
    }
    return ret;
}
ll beki(ll n,ll k,ll md){
  ll ret=1;
  ll now=n;
  while(k>0){
    if(k%2==1){
      ret*=now;
      ret%=md;
    }
    now*=now;
    now%=md;
    k/=2;
  }
  return ret;
}
ll gyaku(ll n,ll md){
  return beki(n,md-2,md);
}
ll popcount(ll n){
    ll ret=0;
    ll u=n;
    while(u>0){
        ret+=u%2;
        u/=2;
        
    }
    return ret;
}
int main(){
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    ll L,n;cin>>L>>n;
    ll x[n+2];
    rep(i,1,n+1)cin>>x[i];
    x[0]=0;
    x[n+1]=L;
    ll ans=x[1];
    ll l=1,r=n+1;
    for(;;){
        if(r-l==1)break;
        r--;
        ans+=x[l]+L-x[r];
        if(r-l==1)break;
        l++;
        ans+=L-x[r]+x[l];
    }
    ll sum=ans;
    rep(i,2,n+1){
        if(r==n+1)break;
        if(n%2==i%2){
            sum+=-(L-x[r]+x[i-1])+x[r]-x[i-1];
            r++;
        }
        else{
            sum+=-(L-x[r]+x[i-1])+x[r-1]-x[i-1];
        }
        Max(ans,sum);
        
    }
    rep(i,0,n+2){
        x[i]=L-x[i];
    }
    sort(x,x+n+2);
    ll anss=x[1];
    l=1;
    r=n+1;
    for(;;){
        if(r-l==1)break;
        r--;
        anss+=x[l]+L-x[r];
        if(r-l==1)break;
        l++;
        anss+=L-x[r]+x[l];
    }
    sum=anss;
    rep(i,2,n+1){
        if(r==n+1)break;
        if(n%2==i%2){
            sum+=-(L-x[r]+x[i-1])+x[r]-x[i-1];
            r++;
        }
        else{
            sum+=-(L-x[r]+x[i-1])+x[r-1]-x[i-1];
        }
        Max(ans,sum);
    }
    //cout<<ans<<" "<<anss<<endl;
    cout<<max(ans,anss)<<endl;
}








Measured memory_bytes: 1792
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef pair<int,int> pii;
typedef double db;

#define fi first
#define se second
#define mp make_pair
#define fastIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define TEST freopen("in.txt","r",stdin);
#define ab(a) ((a < 0) ? (-(a)) : (a))
#define all(a) a.begin(), a.end()
#define ones(a) __builtin_popcount(a)

const int N = (int)2e5 + 9;
int zero[N];

int main(){
  fastIO;
  int n;
  cin >> n;
  int arr[n];
  for(int i = 1;i <= n;i ++ ){
    cin >> arr[i];
    if(arr[i] == 0){
      zero[i] = 1;
    }
  }
  for(int j = n-1;j >= 1; j -- ){
    if(arr[j] == 0){
      zero[j] += zero[j + 1];
    }
  }
  ll ans = 0;
  int sum = 0;
  int xor_sum = 0;
  for(int i = 1;i <= n;i ++ ){
    sum = 0;
    xor_sum = 0;
    for(int j = i;j <= n;){
      ans += zero[j];
      j += zero[j];
      if(j > n)
        break;
      sum += arr[j];
      xor_sum ^= arr[j];
      if(sum == xor_sum){
        ans ++ ;
      }
      else{
        break;
      }
      j ++ ;
    }
  }
  cout << ans << "\n";
  return 0;
}


Measured memory_bytes: 1792
import Control.Applicative ((<$>), (<*>))
import Control.Monad
import Data.List

main :: IO ()
main = do
  [h,w] <- getl $ wrds toInt
  solve <$> replicateM h getLine >>= mapM_ (putStrLn . unwords . map show)

solve :: [String] -> [[Int]]
solve xs = map (f (-1)) xs
  where
    f _ [] = []
    f p (y:ys)
      | y == 'c' = 0 : f 0 ys
      | otherwise = let q = if p == (-1) then (-1) else (p+1) in q : f q ys

toInt :: String -> Int
toInt = read

wrds :: (String -> a) -> String -> [a]
wrds f = map f . words

getl :: (String -> a) -> IO a
getl f = f <$> getLine

Measured memory_bytes: 4576
read = input 
rn = lambda :list(map(int, read().split()))
def reverse_range(r):return range(r-1, -1, -1)
import math

def sol(a):
    best = a + 1
    N = math.sqrt(a)
    N = int(N)
    for i in range(1, N+1):
        if a % i == 0:
            j = a // i
            best = min(best, i+j)
    
    return best
    
a = rn()[0]
print(sol(a)-2)

Measured memory_bytes: 3064
r, g, b, n = gets.split(" ").map(&:to_i)

numbers = []

numbers.push(r)
numbers.push(g)
numbers.push(b)

numbers.sort!

number_0_max = n / numbers[0]
number_1_max = 0
number_2_max = 0

count = 0

sum0 = 0
sum1 = 0
sum2 = 0

number_0_max.downto(0) do |index|
  sum0 = numbers[0] * index
  
  if sum0 < n
    number_1_max = (n - sum0) / numbers[1]
  elsif sum0 == n
    count += 1
    next
  else
    next
  end
  
  # if sum0 > n
  #   next
  # elsif sum0 == n
  #   count += 1
  #   next
  # else
  #   number_1_max = (n - sum0) / numbers[1] + 1
  # end

  number_1_max.downto(0) do |index2|
    sum1 = numbers[1] * index2
  
    if sum0 + sum1 < n
      number_2_max = (n - sum0 - sum1) / numbers[2]
    elsif sum0 + sum1 == n
      count += 1
      next
    else
      next
    end

    # if sum0 + sum1 > n
    #   next
    # elsif sum0 + sum1 == n
    #   count += 1
    #   next
    # else
    #   number_2_max = (n - sum0 - sum1) / numbers[2] + 1
    # end
  
    number_2_max.downto(0) do |index3|
      sum2 = numbers[2] * index3
      if sum0 + sum1 + sum2 < n
        break
      elsif sum0 + sum1 + sum2 == n
        count += 1
        break
      else
        next
      end
      
      # if sum0 + sum1 + sum2 > n
      #   next
      # elsif sum0 + sum1 + sum2 == n
      #   count += 1
      #   break
      # else
      #   break
      # end

    end
  end
end

puts count

Measured memory_bytes: 1788
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long ll;
ll num[500005];
ll red[100005];
ll gre[100005];
ll whi[100005];
vector<ll>vec;
int main()
{
	int R = 0, G = 0, W = 0;
	int x, y, a, b, c;
	cin >> x >> y >> a >> b >> c;
	for (int i = 0; i < a; i++)scanf("%lld", &red[i]);
	for (int i = 0; i < b; i++)scanf("%lld", &gre[i]);
	for (int i = 0; i < c; i++)scanf("%lld", &whi[i]);
	sort(red, red + a, greater<ll>());
	sort(gre, gre + b, greater<ll>());
	sort(whi, whi + c, greater<ll>());
	for (int i = 0; i < x; i++)vec.push_back(red[i]);
	for (int i = 0; i < y; i++)vec.push_back(gre[i]);
	for (int i = 0; i < c; i++)vec.push_back(whi[i]);
	sort(vec.begin(), vec.end(), greater<ll>());
	ll ans = 0;
	for (int i = 0; i < x + y; i++)ans += vec[i];
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 9968
#include "bits/stdc++.h"

using namespace std;

#define COUNTOF(array) (sizeof(array) / sizeof(array[0]))
#define OUT(P) cout << (P) << endl
#define OUT2(P1, P2) cout << (P1) << " " << (P2) << endl
#define PRINT_ARRAY(P) for(int i=0; i<P.size(); i++) cout << P[i] << endl;
#define PRINT_ARRAY_INLINE(P) do { for(int i=0; i<P.size(); i++) cout << P[i] << " "; cout << endl; } while(0)
#define PRINT_ARRAY_WITH_LABEL(L, P) do { cout << L << ": "; PRINT_ARRAY_INLINE(P); cout << endl; } while(0)

int sum_digits(int num);
template <class T>
vector<T> copy_vector(vector<T> vec);

int main() {
    int a, b, c, d, e, k; 
    string YES = "Yay!";
    string NO = ":(";
    cin >> a >> b >> c >> d >> e >> k;
    
    if(abs(b-a)<=k && abs(c-a)<=k && abs(d-a) <=k && abs(e-a) <= k && abs(c-b) <=k
        && abs(d-b) <=k && abs(e-b)<=k && abs(d-c)<=k && abs(e-c) <= k && abs(e-d)<=k) 
        cout << YES << endl;
    else 
        cout << NO << endl;
    return 0;
}

/******************************/
/***** DECRARED FUNCTIONS *****/
/******************************/

int sum_digits(int num) {
    int rtn = 0;
    while(num != 0) {
        int tmp = num % 10; 
        rtn += tmp;
        num /= 10; 
    }   
    return rtn;
}
//int sum_digits(int num) {
//    int rtn = 0;
//    string num_str = to_string(num);
//    for(int i=0; i<num_str.size(); i++) {
//        rtn += num_str[i] - '0';
//    }   
//    return rtn;
//}

// vectorのコピー
template <class T>
vector<T> copy_vector(vector<T> vec) {
    vector<T> rtn;
    rtn.reserve(vec.size());
    copy(vec.begin(), vec.end(), back_inserter(rtn));
    return rtn;
}



Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
    int n,m;
    int a[55],b[55];
    cin >> n >> m;
    for(int i = 0; i < m; i++){
        cin >> a[i] >> b[i];
        a[i] -= 1;
        b[i] -= 1;
    }

    int ans[55];
    for(int i =0; i < n; i++){
        ans[i] = 0;
    }

    for(int i = 0; i < n; i++){
        for(int j = 0; j < m; j++){
            if(a[j] == i || b[j] == i){
                ans[i] += 1;
         }
    }
}
for(int i=0; i < n; i++){
    cout << ans[i] << endl;
}
}

Measured memory_bytes: 256
for x in range(input()):
    x=raw_input()
    x=x[::-1]
    y=raw_input()
    y=y[::-1]
    z=[0]*81
    if len(x)>80 or len(y) >80:
        print 'overflow'
    else:
        for i in xrange(len(x)):
            z[i]=int(x[i])
        for j in xrange(len(y)):
            z[j]=z[j]+int(y[j])
        for k in xrange(max(len(x),len(y))):
            sum=z[k]
            z[k]=sum%10
            z[k+1]+=sum/10
        z.reverse()
        if z[0]!=0:
            print 'overflow'
        else:
            for j in xrange(len(z)):
                if z[0]==0:
                    z.pop(0)
                else:
                    break
            if len(z)==0:
                print 0
            else:
                print ''.join(map(str,z))

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

int main() {
  char c;
  cin >> c;
  
  if(c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u'){
    cout << "vowel" << endl;
  }  else {
    cout << "consonant" << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define all(x) (x).begin(),(x).end()
#define INF 10000000
using ll = long long ;
ll gcd(ll a, ll b) {
  if(b == 0) return a;
  return gcd(b, a % b);
}
template< int id > struct CompTupleBy
{
  template<class T> 
  bool operator()( const T& a, const T& b ) const {
    return std::get<id>(a) < std::get<id>(b);
  }
};

using namespace std;

int main(){
    string s;
    cin >> s;
    int flag = 0;
        for(int i=0;i<s.size();i+=2){
            if (s[i]=='L') flag += 1;
        }
        for(int j=1;j<s.size();j+=2){
            if (s[j]=='R') flag += 1;
        }
    if (flag == 0) cout << "Yes" << endl;
    else cout << "No" << endl;
   
    
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip> //! for setprecision(10)
#include <math.h>
#include <algorithm>
#include <functional> 
#include <string>
#include <vector>

#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <utility>

using namespace std;

typedef long long LL;

#define dump(c) { for (auto it = c.begin(); it != c.end(); ++it) if (it == c.begin()) cout << *it; else cout << ' ' << *it; cout << endl; } 
#define rep(i,n) for (int i = 0; i < (n); ++i)

const int MOD = 1000000007;


inline char maxChar(const string& str)
{
    char c = 'a';
    rep(i, str.length()) {
        c = max(c, str[i]);
    }
    return c;
}


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

    set<string> ans[11];

    int N;
    cin >> N;
    ans[1].insert("a");
    for (int i=2; i <= N; ++i) {
        for (string s: ans[i-1]) {
            char mc = maxChar(s);
            for (char c = 'a'; c <= mc+1; ++c) {
                ans[i].insert(s+c);
            }
        }
    }

    for (string s: ans[N]) {
        cout << s << '\n';
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 15232
use proconio::input;

#[proconio::fastout]
fn main() {
    input! {
    A:u64,B:u64,C:u64,X:u64,
    }
    let mut ans: u64 = 0;
    for a in 0..=A {
        for b in 0..=B {
            for c in 0..=C {
                if 500 * a + 100 * b + 50 * c == X {
                    ans += 1;
                } else if 500 * a + 100 * b + 50 * c > X {
                    break;
                }
            }
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 2168
#include "iostream"
#include "algorithm"
#include "string"
#include "vector"
#include "cmath"
#define INT_MAX 2147483647
#define LLINT_MAX 9223372036854775807
#define mod 1000000007
using namespace std;

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	for(int i=0;i<b;i++)
		if (a*i%b == c) {
			cout << "YES" << endl;
			return 0;
		}
	cout << "NO" << endl;
	return 0;
}

Measured memory_bytes: 256
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    s=input()
    t=input()
    s_lis=[[] for _ in range(32)]
    t_lis=[[] for _ in range(32)]
    for i,ss in enumerate(s):
        s_lis[ord(ss)-ord('a')].append(i)
    for i,tt in enumerate(t):
        t_lis[ord(tt)-ord('a')].append(i)
    ss_lis=[sl for sl in s_lis if len(sl)>0]
    tt_lis=[tl for tl in t_lis if len(tl)>0] 
    ss_lis.sort()
    tt_lis.sort()
    if all([True if x==y else False for x,y in zip(ss_lis,tt_lis)]):
        print("Yes")
    else:
        print("No")

if __name__=='__main__':
    main()

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

int main() {
	// your code goes here
	int m, d;
	int ans=0;
	cin >> m >> d;
	for(int i=1;i<m+1;i++){
		for(int j=1;j<d+1;j++){
			if(j<22) continue;
			if(j%10==1) continue;
			if((j/10)*(j%10)==i) ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

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

#define INX(x) (cin >> x)
#define OUTX(x) (cout << x << endl)

#define ADD emplace_back
#define MP make_pair
#define VVEC(type) vector<vector<type>>


int main()
{
    ll L, R, d;
    cin >> L >> R >> d;

    ll result = 0;
    for(ll i = L; i <= R; i++)
    {
        if(i % d == 0)
        {
            result++;
        }
    }
    cout << result << endl;


    return 0;
}


Measured memory_bytes: 3620
#include <stdio.h>

using namespace std;


int main(){
	int debt = 100000,n;
	scanf("%d",&n);

	for(int i=0;i<n;i++){
		debt=(debt/100)*105;
		if((debt%1000)>0){
			debt+=(1000-(debt%1000));
		}
	}

	printf("%d\n",debt);

    return 0;
}

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

int A[3];

int main() {
	cin >> A[0] >> A[1] >> A[2];
	sort(A, A + 3);
	if (A[0] == 5 && A[1] == 5 && A[2] == 7)
		puts("YES");
	else puts("NO");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int N;cin>>N;
    vector<int>vec(N);for(int i=0;i<N;i++)cin>>vec[i];
    vector<int>ans(N);
    ans[0]=0;ans[1]=abs(vec[1]-vec[0]);
    if(N<3)cout<<ans[1]<<endl;
    else{
        for(int i=2;i<N;i++){
            int x=ans[i-2]+abs(vec[i]-vec[i-2]);
            int y=ans[i-1]+abs(vec[i]-vec[i-1]);
            ans[i]=min(x,y);
        }
        cout<<ans[N-1]<<endl;
    }
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
 
#define int         long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        1000000007
#define rep(i,a,b)  for(int i=a;i<b;i++)
using namespace std;
const int maxn = 200001;
int n, m,x,y,z;
long double a[301], dp[301][301][301];
long double sol(int x, int y, int z)
{
    if(dp[x][y][z]!=-1)return dp[x][y][z];
    long double q = 0;
    if(x+y+z == 0)return q;
    if(x > 0) q+=sol(x-1, y, z)*x;
    if(y > 0) q+=sol(x+1, y-1, z)*y;
    if(z > 0) q+=sol(x, y+1, z-1)*z;

    q /= (long double)(x+y+z);
    q += n/(long double)(x+y+z);
    dp[x][y][z] = q;
    return q;
}
void solve()
{
    cin>>n;
    rep(i, 0, n)
    {
        cin>>a[i];
        if(a[i]==1)x++;
        else if(a[i]==2)y++;
        else z++;
    }
    rep(i, 0, 301)rep(j, 0, 301)rep(k, 0, 301)dp[i][j][k] = -1;
    cout<<setprecision(15)<<sol(x, y, z);






















    

}
signed main(){
   
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t=1;
    //cin>>t;
    while(t--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 426496
#include <bits/stdc++.h>
#define FOR(i, n) for(ll i = 0; i < n; i++)
#define FORR(i, n) for(ll i = n; i >= 0; i--)
#define FORS(i, m, n) for(int i = m;i < n;i++)
#define ALL(v) accumulate(v.begin(),v.end(),0)
#define SORT(v) sort(v.begin(),v.end())
#define OUT(n) (cout << n << endl)
#define IN1(a) (cin >> a)
#define IN2(a,b) (cin >> a >> b)
#define IN3(a,b,c) (cin >> a >> b >> c)
#define IN4(a,b,c,d) (cin >> a >> b >> c >> d)
#define REVS(v) reverse(v.begin(),v.end())
using namespace std;
typedef long long ll;
int gcd(int a,int b){return b?gcd(b,a%b):a;}

int main(){
  int k;
  string s;
  IN1(k);
  IN1(s);
  if (s.size() <= k){
    OUT(s);
  }
  else
  {
    s = s.substr(0,k) + "...";
    OUT(s);
  }
  

}


Measured memory_bytes: 3604
'use strict'
// import bigInt from 'big-integer'

const getBitPatterns = (num) => {
    const row = []
    for (let bit = 0; bit < (1 << num); bit++) {
        const newRow = []
        for (let i = 0; i < num; i++) {
            if (bit & (1 << i)) newRow.push(1)
            else newRow.push(0)
        }
        row.push(newRow)
    }

    return row
}


const main = (input) => {
    input = input.trim()
    const nums = input.split("")
    const plusNum = nums.length - 1
    const bitPatterns = getBitPatterns(plusNum)

    let answer = 0
    for (let i = 0; i < bitPatterns.length; i++) {
        const bitPattern = bitPatterns[i]
        let tmpStrs = [nums[0]]
        for (let j = 0; j < bitPattern.length; j++) {
            const num = nums[j + 1]
            if (bitPattern[j]) {
                tmpStrs.push(num)
            } else {
                tmpStrs[tmpStrs.length - 1] += num
            }
        }
        answer += tmpStrs.reduce((acc, cur) => acc + parseInt(cur, 10), 0)
    }

    console.log(answer)
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));

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

#define debug(x) cout<<#x<<"="<<x<<endl
#define pii pair<int,int>
#define PQ priority_queue
#define ll long long
#define pb push_back
#define mp make_pair

int g[202][202],ans=2147483647,n,m,K,a[10],now;

int main(){
	int t1,t2,t3;
	cin>>n>>m>>K;
	for (int i=0;i<K;i++) cin>>a[i];
	sort(a,a+K);
	for (int i=1;i<=n;i++){
		for (int j=1;j<=n;j++){
			g[i][j]=2147483647;
		}
	}
	for (int i=0;i<m;i++){
		cin>>t1>>t2>>t3;
		g[t1][t2]=t3;
		g[t2][t1]=t3;
	}
	for (int k=1;k<=n;k++){
		for (int i=1;i<=n;i++){
			for (int j=1;j<=n;j++){
				if (i==j || j==k || i==k) continue;
				if (g[i][k]==2147483647 || g[k][j]==2147483647) continue;
				if (g[i][j]>g[i][k]+g[k][j]){
					g[i][j]=g[i][k]+g[k][j];
					g[j][i]=g[i][k]+g[k][j];
				}
			}
		}
	}
	do{
		now=0;
		for (int i=0;i<K-1;i++){
			now+=g[a[i]][a[i+1]];
		}
		ans=min(ans,now);
	}while(next_permutation(a,a+K));
	cout<<ans;
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));
//priority_queue<int,vector<int>, greater<int> > q2;



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

	int N;
	cin >> N;
	int ans = 0, asum = 0, bsum = 0, absum = 0;
	REP(i, N) {
		string S;
		cin >> S;
		REP(j, S.size() - 1) {
			if (S[j] == 'A' && S[j + 1] == 'B') ans++;
		}
		if (S[0] == 'B' && S[S.size() - 1] == 'A')absum++;
		else if (S[0] == 'B')bsum++;
		else if (S[S.size() - 1] == 'A')asum++;
	}
	if (asum == 0 && bsum == 0 && absum!=0) {
		absum--;
	}
	cout << ans + min(asum + absum, bsum + absum) << endl;

	return 0;
}



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

using namespace std;


int main(void){

  int h,w,k,ans=0;
  cin>>h>>w>>k;
  char arr[h][w];

  for(int i=0;i<h;i++)
      for(int j=0;j<w;j++)
        cin>>arr[i][j];

  for(int i=0;i<(1<<h);i++)
  {
      for(int j=0;j<(1<<w);j++)
      {
          int bl=0;
          for(int a=0;a<h;a++)
          {
              for(int b=0;b<w;b++)
              {
                  if( (i&(1<<a))==0 && (j&(1<<b))==0 && arr[a][b]=='#')
                   bl++;
              }
          }
          if(bl==k)
            ans++;
      }
  }
  cout<<ans<<"\n";
  return 0;
}


Measured memory_bytes: 3632
#include<cstdio>
#include<cstring>
#include<algorithm>
#define cl(x,y) memset(x,y,sizeof(x))
using namespace std;
inline char nc(){
	static char buf[100000],*l=buf,*r=buf;
	return l==r&&(r=(l=buf)+fread(buf,1,100000,stdin),l==r)?EOF:*l++;
}
inline int red(){
	int res=0,f=1;char ch=nc();
	while (ch<'0'||'9'<ch) {if (ch=='-') f=-f;ch=nc();}
	while ('0'<=ch&&ch<='9') res=res*10+ch-48,ch=nc();
	return res*f;
}

const int maxn=100005,maxe=200005;
int tst,n,e,f[maxn],dep[maxn];
bool vis[maxn],ans[maxn],suc;
int tot,son[maxe],lnk[maxn],nxt[maxe],ID[maxe],X[maxn],Y[maxn];
inline void add(int x,int y,int id){
	son[++tot]=y;nxt[tot]=lnk[x];lnk[x]=tot;ID[tot]=id;
}
void dfs(int x,int fa){
	vis[x]=1;
	int F=0;
	for (int j=lnk[x];j;j=nxt[j])
	 if (ID[j]!=fa){
	 	if (!vis[son[j]]){
	 		dep[son[j]]=dep[x]+1;dfs(son[j],ID[j]);
		}else{
			if (dep[son[j]]<dep[x]) f[x]++,ans[ID[j]]=(x!=Y[ID[j]]);
		}
	 }else F=son[j];
	if ((f[x]&1)&&fa==0) suc=0;
	if (f[x]&1) ans[fa]=(x!=Y[fa]),f[x]++;
	else ans[fa]=(x!=X[fa]),f[F]++;
}
int main(){
	//kisyutu
	tst=1;
	while (tst--){
		n=red(),e=red();
		tot=1;cl(lnk,0);cl(f,0);cl(ans,0);
		for (int i=1,x,y;i<=e;i++) x=X[i]=red(),y=Y[i]=red(),add(x,y,i),add(y,x,i);
		suc=1;cl(vis,0);cl(dep,0);
		for (int i=1;i<=n;i++)
		 if (!vis[i]) dfs(i,0);
		if (!suc) printf("-1");else
		for (int i=1;i<=e;i++){
			printf("%d %d\n",ans[i]?X[i]:Y[i],ans[i]?Y[i]:X[i]);
		}
		putchar('\n');
	}
	return 0;
} 

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

int main() {
    string s, t;
    cin >> s >> t;
    map<char, int> s_map, t_map;
    bool flg = true;
    for (int i = 0; i < s.size(); i++) {
        auto s_itr = s_map.find(s[i]);
        auto t_itr = t_map.find(t[i]);
        if (s_itr == s_map.end() && t_itr != t_map.end()) {
            flg = false;
            break;
        } else if (s_itr != s_map.end() && t_itr == t_map.end()) {
            flg = false;
            break;
        } else if (s_itr->second != t_itr->second) {
            flg = false;
            break;
        }
        if (s_itr == s_map.end() && t_itr == t_map.end()) {
            s_map[s[i]] = i;
            t_map[t[i]] = i;
        }
    }
    if (flg) printf("Yes\n");
    else printf("No\n");
    return 0;
}

Measured memory_bytes: 776
/*
    Author : Nishant Gupta 2.0
*/
#include<bits/stdc++.h>
using namespace std;

#define LL long long int
#define getcx getchar_unlocked
#define X first
#define Y second
#define PB push_back
#define MP make_pair
#define MAX 1000005
#define LOG_MAX 20
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL (LL(1e18))
#define chk(a) cerr << endl << #a << " : " << a << endl
#define chk2(a,b) cerr << endl << #a << " : " << a << "\t" << #b << " : " << b << endl
#define chk3(a,b,c) cerr << endl << #a << " : " << a << "\t" << #b << " : " << b << "\t" << #c << " : " << c << endl
#define chk4(a,b,c,d) cerr << endl << #a << " : " << a << "\t" << #b << " : " << b << "\t" << #c << " : " << c << "\t" << #d << " : " << d << endl
#define rep(i, a, n) for(i=a;i<n;i++)
#define rev(i, a, n) for(i=a;i>=n;i--)
#define in(x) scanf("%d", &x)
#define inl(x) scanf("%lld", &x)
#define in2(x, y) scanf("%d %d", &x, &y)
#define inl2(x, y) scanf("%lld %lld", &x, &y)
#define MSV(A,a) memset(A, a, sizeof(A))
#define rep_itr(itr, c) for(itr = (c).begin(); itr != (c).end(); itr++)
typedef pair<int, int> pi;
typedef pair<LL, LL> pl;
const char en = '\n';

int p[MAX];
bool f[MAX];
void solve() {
	int n;
	in(n);
	int a[n];
	for(int i=0;i<n;i++) {in(a[i]); p[a[i]]++;}
	
	for(int i=2;i*i<MAX;i++) {
		for(int j=2*i;j<MAX;j+=i) {
			int q = j/i;
			if(p[i] || p[q]) f[j] = true;
		}
	}
	
	int cnt = 0;
	for(int i=0;i<n;i++) {
		if(p[a[i]] > 1 || (p[1] >= 1 && a[i] != 1) || f[a[i]]) continue;
		cnt++;
	}
	cout<<cnt<<en;
}

int main() {
	int t = 1;
	
	//~cin>>t;
	while(t--) {
		solve();
	}
    return 0;
}


Measured memory_bytes: 9172
//#pragma GCC optimize(3)
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cctype>
#include<cassert>
#include<cstdlib>
#include<utility>
#include<iterator>
#include<iomanip>
using namespace std;
#define lowbit(x) x&(-x)
typedef long long ll;
typedef long double lb;
typedef unsigned long long ull;
const double PI = acos(-1.0);
const int maxn = 1000000;
int read();
int A[maxn];
int main()
{
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    string s;
    cin>>s;
    for(int i = 0;i<(int)s.length();i++)
    {
    	A[i] = 1;
    }
    for(int i = 0;i<(int)s.length();i++)
    {
    	int pos = 0 ;
    	if(s[i]=='R')
    {while(s[i+1]!='L')
    	{
    		A[i]--;
    		i++;
    		pos++;
    	}
    	if(pos%2!=0)
    	{  A[i]+=pos/2;
           A[i+1]+=pos/2+1;
    		
    	}else
    	{
    		A[i]+=pos/2;
    		A[i+1]+=pos/2;
           
    	}
    }else
    continue;
    }
   
    for(int i = (int)s.length()-1;i>0;i--)
    {
         
         int pos = 0;
         if(s[i]=='L')
         {
         while(s[i-1]!='R')
         {
         	A[i]--;
         	i--;
         	pos++;
         }
         if(pos%2!=0)
         {
         	 A[i]+=pos/2;
           A[i-1]+=pos/2+1;
         }
         else
    	{
    		A[i]+=pos/2;
    		A[i-1]+=pos/2;
          
    	}
    }else
    continue;
    }
    for(int i = 0;i<(int)s.length();i++)
    {
    	cout<<A[i]<<" ";
    }
    return 0;
}
inline int read()
{
	int x = 0,w = 0;
	char ch = 0;
	while(!isdigit(ch)){
		w |= (ch == '-');
		ch = getchar();
	}
	while(isdigit(ch)){
		x = (x<<3)+(x<<1)+(ch^48);
		ch = getchar();
	}
	return w?-x:x;
}


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

int main(){
  uint32_t N, K;
  cin >> N >> K;

  vector<bool> hasTreat(N,false);

  for( uint32_t i = 0; i < K; ++i ){
    uint32_t di;
    cin >> di;
    for( uint32_t j = 0; j < di; ++j ){
      uint32_t tmp;
      cin >> tmp;
      hasTreat.at(tmp-1) = true;
    }
  }
  uint32_t result = 0;
  for( uint32_t i = 0; i < N; ++i ){
    if( hasTreat.at(i) == false){
      ++result;
    }
  }

  cout <<result << endl;
}

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

int main() {
  int N, K;
  cin >> N >> K;
  vector<ll> V(N);
  rep(i, N) cin >> V[i];
  int pic = min(N, K);
  ll ans = 0;
  for (int i = 0; i <= pic; i++) {
    for (int j = 0; j <= pic - i; j++) {
      vector<ll> A(0);
      vector<ll> B(0);
      for (int k = 0; k < i; k++) {
        if (V[k] >= 0) A.push_back(V[k]);
        else B.push_back(V[k]);
      }
      for (int k = 0; k < j; k++) {
        if (V[N-1-k] >= 0) A.push_back(V[N-1-k]);
        else B.push_back(V[N-1-k]);
      }
      sort(B.begin(), B.end());
      reverse(B.begin(), B.end());
      int pop = K - i - j;
      while (pop > 0) {
        if (!B.empty()) {
          B.pop_back();
        }
        pop--;
      }
      ll sum = 0;
      for (auto a : A) sum += a;
      for (auto b : B) sum += b;
      ans = max(ans, sum);
    }
  }
  cout << ans << endl;
}

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

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007

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


int main(){
	cin.tie(0);ios::sync_with_stdio(false);
	ll a, b, k;cin >> a >> b >> k;
	REP(i, k){
		if(i % 2){
			if(b%2)b--;
			b /= 2;
			a += b;
		}
		else {
			if(a%2)a--;
			a /= 2;
			b += a;
		}
	}
	cout << a << " " << b << endl;
		
	return 0;
}


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

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

  //int a, b, h, m;
  double a, b, h, m;
  //scanf("%d %d %d %d", &a, &b, &h, &m);
  scanf("%lf %lf %lf %lf", &a, &b, &h, &m);
  //printf("%d %d %d %d\n", a, b, h, m);

  //int angle;
  double angle;
  //int angle_h = (h * 30) + (m / 2);
  double angle_h = (h * 30) + (m / 2);
  //int angle_m = m * 6;
  double angle_m = m * 6;
  if(angle_h>angle_m){
    angle = angle_h - angle_m;
  }else{
    angle = angle_m - angle_h;
  }
  //if(angle > 180) angle = 360 - angle;
  if(angle > 180.0L) angle = 360 - angle;
  //printf("angle_h=%d, angle_m=%d, angle=%d\n", angle_h, angle_m, angle);

  //double p = 3.141592653589793238462643383279;
  double p = 3.141592653589793238462643383279L;
  double c = sqrt((a * a) + (b * b) - 2 * (a * b *cos(angle * p / 180.0)));
  printf("%5.20lf\n", c);

  return 0;
}

Measured memory_bytes: 2596
#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)
#define MOD 1000000007
int main(){
	fast;
	ll x;
	cin>>x;
	if(x<1200)
		cout<<"ABC";
	else
		cout<<"ARC";
	return 0;
}



Measured memory_bytes: 3648
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
const int MAXS = 1 << 16;
const int MAXN = 1e5 + 5;
int dp[MAXS] , n , S , a[MAXN];
int DP(int now) {
	if(now == 0) return 0;
	if(dp[now] != -1) return dp[now];
	dp[now] = 1e9;
	for (int i = 0; i < 15; ++i) {
		if(!(now & (1 << i))) continue;
		for (int j = i + 1; j < 15; ++j) {
			if(!(now & (1 << j))) continue;
			int nnow = now ^ (1 << i) ^ (1 << j) ^ (1 << (((i+1) ^ (j+1)) - 1));
			int f;
			if(((now ^ (1 << i) ^ (1 << j)) & (1 << (((i+1) ^ (j+1)) - 1)))) f = 1;
			else f = 0;
			dp[now] = min(dp[now] , DP(nnow) + 1 + f);
		}
	}
	return dp[now];	
}
int main() {
	scanf("%d" , &n);
	for (int i = 1; i < n; ++i) {
		int u , v , w;
		scanf("%d %d %d" , &u , &v , &w);
		a[u] ^= w;
		a[v] ^= w;
	}
	int ans = 0;
	for (int i = 0; i < n; ++i) {
		if(!a[i]) continue;
		if(S & (1 << (a[i] - 1))) ans ++;
		S ^= (1 << (a[i] - 1));
	} 
	memset(dp , -1 , sizeof dp);
	dp[0] = 0;
	ans += DP(S);
	printf("%d" , ans);
	return 0;
}

Measured memory_bytes: 2380