akhauriyash/Code-Regression huggingface dataset:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy,copy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

def main():
    n,x = MAP()
    L = [1]*n
    P = [1]*n

    for  i in range(1,n):
        L[i] = 2* L[i-1] +3
        P[i] = 2* P[i-1] + 1

    def func(N, X):
        if N==0:
            return 0 if X <= 0 else 1

        elif X<= L[N-1] + 1:
            return func(N-1, X-1)

        else:
            return P[N-1] + 1 + func(N-1, X-L[N-1] -2)

    print(func(n,x))

if  __name__=='__main__':
    main()

Measured memory_bytes: 5148
#include <bits/stdc++.h>
#include <math.h>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1001001001;
const int mINF = -1001001001;


int main() {
int a,b,c;
cin >> a >> b;
char s[a];
cin >> s;
s[b-1] += 32;
cout << s << endl;
return 0;
}


Measured memory_bytes: 256
#include <cstdio>
const int N=1000000;
int p[N],pN[N];
main(){p[0]=0;p[1]=0;int i,k,n,c;
for(i=2;i<N;i++)p[i]=1;for(i=2;i*i<N;){for(k=2;i*k<N;k++)p[i*k]=0;do{i++;}while(!p[i]);}for(i=0,c=0;i<N;i++){p[i]&&c++;pN[i]=c;}for(;scanf("%d",&n)+1;printf("%d\n",pN[n]));}

Measured memory_bytes: 0
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<climits>
#include<string>
#include<vector>
#include<map>
#include<queue>
#include<set>
#include<algorithm>

#define ll long long
#define sz 205

using namespace std;

int main()
{
    ll sum=0,x;

    for(ll i=1;i<=3;i++)
    {
        scanf("%lld",&x);

        sum=(sum*10)+x;
    }

    if(sum%4==0)
        printf("YES\n");

    else
        printf("NO\n");

    return (0);
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define ll long long 
#define rep(i,a,b) for(signed i=a;i<(b);++i)
#define erep(i,a,b) for(signed i=a;i<=(b);++i)
#define per(i,a,b) for(signed i=(a);i>(b);--i)
#define eper(i,a,b) for(signed i=(a);i>=b;--i)
#define fore(i, x, a) for(auto &&x:a) 
#define ITR(i,b,e) for(auto i=(b);i!=(e);++i)
#define endl "\n";
#define pb push_back
#define mp make_pair
#define ALL(x) begin(x),end(x)
#define F first
#define S second
#define debug(x)  cout << #x << ": " << (x) << '\n';
const long long INF=1001001001001001001;
const int MOD=(int)1e9 + 7;
const double EPS=1e-9;
using namespace std;
using Pii = pair<int,int>;
using vii = vector<int>;
template<class T>using  PS_queue = priority_queue<T, vector<T>, greater<T> >;
template<class T>using vv = vector<T>;
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; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val){fill( (T*)array, (T*)(array+N), val );}
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) {
    ITR(i,begin(v),end(v))os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> ostream& operator<<(ostream &os,const vector<vector<T> > &v) {
    ITR(u,begin(v),end(v))ITR(w,begin(*u),end(*u))os<<*w<<(w==end(*u)-1?"\n":" ");return os;}
template<class T> istream& operator>>(istream &is,vector<T> &v) {
    ITR(i,begin(v),end(v)) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
    is>>p.first>>p.second;return is;}
template<class T>T gcd(T a, T b){ return b ? gcd(b, a % b) : a; }
template<class T>T lcm(T a, T b){ return a / gcd(a, b) * b; }
struct edge { int from, to, cost; };
int dy[]={0, 1, -1, 0}; int dx[]={1, 0, 0, -1};

int n;
signed main() {
 cin.tie(0);
 ios::sync_with_stdio(false);
  cin >> n; 
  vv<double> a(n);
  cin  >> a;
  double res = 0.0;
  rep(i, 0, n) {
    res += 1.0 / a[i];
  }
  cout << fixed << setprecision(20) << 1.0 / res << endl;
  return 0;
}



Measured memory_bytes: 256
#include<stdio.h>
int main(){
	int L,M,N,t=0,c=0,i;
	for(;;t=0,c=0){
		scanf("%d",&L);
		if(L==0)break;
		for(i=1;i<13;i++){
			scanf("%d%d", &M, &N);
			t+=M-N;
			if(t>=L&&c==0){
				c=i;
			}
		}
		if(c!=0)printf("%d\n",c);
		else puts("NA");
	}
	return 0;
}

Measured memory_bytes: 0
import java.util.*;
public class Main{
     public static void main(String []args){
         Scanner scan = new Scanner(System.in);
         int a = scan.nextInt();
         
         boolean flag = true;
         while ( a != 0 ){
            if ( a % 10 == 7 ){
                flag = false;
                break;
            }
            
            a/=10;
         }
         
         if ( !flag ){
             System.out.println("Yes");
         }else{
             System.out.println("No");
         }
     }
}

Measured memory_bytes: 35744
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String N = sc.next();
        String ans = N.substring(N.length() -1);
        if (ans.equals("3"))
            System.out.println("bon");
        else if(ans.equals("0") || ans.equals("1") || ans.equals("6") || ans.equals("8"))
            System.out.println("pon");
        else
            System.out.println("hon");
    }
}

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

int main(){
	int A[2],i;
	for(i=0;i<2;i++){
		cin >> A[i];
		if(A[i]==1) A[i]=14;
	}
	if(A[0]>A[1]) cout << "Alice" << endl;
	if(A[0]<A[1]) cout << "Bob" << endl;
	if(A[0]==A[1]) cout << "Draw" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}

int main(){
    
    ll N, K, mx, g;
    cin >> N >> K;
    for(int i = 0; i < N; i++){
        ll A;
        cin >> A;
        if(i == 0){
            mx = A;
            g = A;
        }
        else{
            mx = max(mx, A);
            g = gcd(g, A);
        }
    }
    if(mx < K || K % g)cout << "IMPOSSIBLE" << endl;
    else cout << "POSSIBLE" << endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.util.stream.Collectors;
import java.io.*;
import java.nio.charset.StandardCharsets;

public class Main {
	static class Tuple {
		long X, L;

		Tuple(long X, long L) {
			this.X = X;
			this.L = L;
		}

		long min() {
			return X - L;
		}

		long max() {
			return X + L;
		}
	}

	int range = 2000000000;
	List<Tuple> list;
	int N;
	int removeNum = 0;

	public static void main(String[] args) throws IOException {
		InputStreamReader reader = new InputStreamReader(System.in, StandardCharsets.UTF_8);
		BufferedReader in = new BufferedReader(reader);
		Main ins = new Main(in);
		ins.calc();
		ins.showResult();
	}

	Main(BufferedReader in) throws IOException {
		this.N = Integer.parseInt(in.readLine());
		this.list = new ArrayList<>(N);
		for (int i = 0; i < N; ++i) {
			String[] tokens = in.readLine().split(" ");
			list.add(new Tuple(Long.parseLong(tokens[0]), Long.parseLong(tokens[1])));
		}

	}

	boolean fillMap(Tuple tuple, boolean[] map) {
		boolean enable = true;
		int min = (int) Math.max(0, tuple.min());
		int max = (int) Math.min(range - 1, tuple.max());
		System.out.println(min + ", " + max);
		for (int i = min; i <= max; ++i) {
			if (map[i]) {
				enable = false;
				break;
			}
		}
		if (!enable) {
			return false;
		} else {
			Arrays.fill(map, min, max + 1, true);
			return true;
		}
	}

	void calc() {
		// まずLの大きさ順にソートする
		Collections.sort(list, new Comparator<Tuple>() {
			@Override
			public int compare(Tuple o1, Tuple o2) {
				return Long.compare(o1.max(), o2.max());
			}
		});

		long min = list.get(0).max();
		for(int i = 1; i < N; ++i) {
			Tuple tuple = list.get(i);
			if(min <= tuple.min()) {
				// 入れられる
				min = tuple.max();
			}else {
				// 入れられない
				++this.removeNum;
			}
		}
	}

	void showResult() {
		System.out.println((N-removeNum));
	}
}


Measured memory_bytes: 49816
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <cmath>
#define rep(i,cc,n) for(int i=cc;i<=n;++i)
#define drep(i,cc,n) for(int i=cc;i>=n;--i)
typedef long long ll;
using namespace std;
int main(){
    int n;
    cin>>n;
    string s;
    cin>>s;
    int cnt = 0;
    rep(i,0,n-3){
        if(s[i]=='A'&&s[i+1]=='B'&&s[i+2]=='C') cnt++;
    }
    cout<<cnt<<endl;
    return 0;
}

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

int main() {
	int n;
	cin >> n;
	// if(n != 0 && ((n % 7) % 4 == 0 || (n % 4) % 7 == 0)) cout << "Yes";
	// else cout << "No";
	bool flag = false;
	for(int i = 0; i < (n / 4) + 1; i++) {
		for(int j = 0; j < (n / 7) + 1; j++) {
			if(n == 4 * i + 7 * j) {
				flag = true;
				break;
			}
		}
		if(flag) break;
	}
	if(flag) cout << "Yes";
	else cout << "No";
	cout << endl;
	return 0;
}


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

#define MOD 1000000007

main(){
	int n,k;
	long long a[2010],ori[2010],afr[2010];
	long long ans,l;
	
	memset(ori,0,sizeof(ori));
	memset(afr,0,sizeof(afr));
	ans = 0;
	cin>>n>>k;
	for(int i=1;i<=n;i++)
		cin>>a[i];
	
	for(int i=1;i<n;i++)
		for(int j=i+1;j<=n;j++)
			if(a[j] < a[i])
				ori[i]++;
	
	for(int i=1;i<=n;i++)
		for(int j=1;j<=n;j++)
			if(a[j] < a[i])
				afr[i]++;
		
	for(int i=1;i<=n;i++){
		ans += ori[i];
		ans %= MOD;
		l = afr[i]*(k-1);
		l %= MOD;
		l *= 500000004;
		ans += l;
		ans %= MOD;
	}
	cout<<(ans*k)%MOD;
	
} 

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <functional>
#include <cmath>
#include <complex>
#include <cctype>
#include <cassert>
#include <sstream>
#include <ctime>
 
using namespace std;
 
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
 
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
 
typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, pii> P;
 
const ll INF = 1ll<<29;
const ll MOD = 1000000007;
const double EPS  = 1e-10;
 
int n, m;
int cnt[50];
 
int main() {
	cin >> n >> m;
	REP(i, m) {
		int a, b;
		scanf("%d %d", &a, &b);
		a--; b--;
		
		cnt[a]++;
		cnt[b]++;
	}
	
	REP(i, n) printf("%d\n", cnt[i]);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <bitset>
#include <iomanip>
#include <stack>
#include <list>
#include <map>
#include <unordered_map>
#include <chrono>
#include <numeric>
using namespace std;
using ll = long long;
const ll INF = (ll)1e18+1;
const ll DIV = 1000000007;
//#define TEST
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
#ifdef TEST
    chrono::system_clock::time_point start, end;
    start = chrono::system_clock::now();
#endif
    long D;
    cin >> D;
    cout << "Christmas ";
    for(int i=0;i<25-D;i++)
    {
        cout << "Eve ";
    }
    cout << endl;
#ifdef TEST
    end = chrono::system_clock::now();
    cerr << static_cast<double>(chrono::duration_cast<chrono::microseconds>(end - start).count() / 1000.0) << "[ms]" << endl;
#endif
    return 0;
}

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

#define rep(i,n) for(ll i=0;i<n;i++)
#define ll long long

int main(){
    int a[120],n;
    cin>>n;
    rep(i,n) cin>>a[i];
    int m=1000000000,M=0;
    rep(i,n){
        M=max(M,a[i]);
        m=min(m,a[i]);
    }
    cout<<M-m<<endl;
}

Measured memory_bytes: 256
#include <cstdio>

using namespace std;

int main(){
    char op;
    int a, b;
    
    while(scanf("%d %c %d", &a, &op, &b), op != '?'){
        
        switch(op){
        case '+':
            printf("%d\n", a + b);
            break;
        
        case '-':
            printf("%d\n", a - b);
            break;
        
        case '*':
            printf("%d\n", a * b);
            break;
        
        case '/':
            printf("%d\n", a / b);
            break;
        }
    }
    
    return 0;
}


Measured memory_bytes: 2764
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cctype>
#include<algorithm>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<cstring>
//#include<windows.h>
//#include<time.h>
#define pb push_back
#define ppb pop_back
#define fi first
#define se second
#define mer make_pair
#define mme memset
using namespace std;

const double pie1=3.1415926;//π1
const double pie2=3.14159265358979;//π2
const double pie3=3.14159265358979323846;//π3
const int vbi=999999999;
const int vli=-vbi;
const long long vbl=999999999999999999;
const long long vll=-vbl;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<pii,int> piii;
typedef pair<pii,pii> pi4;
typedef pair<pll,ll> plll;
typedef pair<int,pii> ipii;
typedef pair<ll,pll> lpll;
typedef pair<pll,pll> pl4;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pii> vpi;
typedef vector<pll> vpl;
typedef set<int> sti;
typedef set<ll> stl;
typedef set<pii> spi;
typedef set<pll> spl;
priority_queue<int> pqi;
priority_queue<ll> pql;
queue<int> qi;
queue<ll> ql;

/*void bin_v(){
	char bin[1000];
	gets(bin);
}*/

bool pss(int a){
	for(int i=2;i<=sqrt(a);i++)
		if(a%i==0)
			return false;
	return true;
}
/////////////////////////////////////////////////////////////////////////////////////////

int main(){
	//my name is Veex_WCY
	ios::sync_with_stdio(false);
	int n;
	string str;
	cin>>n>>str;
	int sum=0,l=0,r=0,ok=0;
	for(int i=0;i<n;i++)
		if(str[i]=='(')
			l++;
		else if(l>0){
			l--;
			ok++;
			r++;
		}
		else
			r++;
	r-=ok;
	for(int i=1;i<=r;i++)
		str="("+str;
	for(int i=1;i<=l;i++)
		str=str+")";
	cout<<str;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>

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

  unsigned N = 0;
  std::cin >> N;
  std::vector<std::vector<int> > dp(N);
  for (unsigned i = 0; i < N; ++i)
  {
    int a, b, c;
    dp[i].resize(3);
    std::cin >> a >> b >> c;
    if (i == 0)
    {   
      dp[0][0] = a;
      dp[0][1] = b;
      dp[0][2] = c;
      continue;
    }   
    dp[i][0] = a + std::max(dp[i-1][1], dp[i-1][2]);
    dp[i][1] = b + std::max(dp[i-1][0], dp[i-1][2]);
    dp[i][2] = c + std::max(dp[i-1][0], dp[i-1][1]);
  }

  std::cout << std::max({dp[N-1][0], dp[N-1][1], dp[N-1][2]});

  return 0;
}

Measured memory_bytes: 5760
#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define cool ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	#define int  long long int
	#define pb push_back
	#define fe first
    #define lb lower_bound 
    #define ub upper_bound
    #define pii pair<pair<int,int>,pair<int,int> >
	#define se second
	#define endl "\n"
	#define pi pair<int, int>
	#define vi vector<int> 
	#define vvi vector<vi>
    #define bs   binary_search
	#define rep(i,a,b) for(int i=a;i<b;i++)
	#define rep1(i,a,b) for(int i=a;i<=b;i++)	
    #define all(c) (c).begin(),(c).end()
    #define sz(x)       (int)x.size() 
	#define PI 3.14159265358979323846
    
	 const int N =1e5+5;
    
     int mod= 1e9+7,INF=1e17;
     
     int dx[4]={0,0,+1,-1};
     int dy[4]={+1,-1,0,0};
 
     int a[N][(int)26],lst[(int)26];
     
     void solve(){
          string  s,p;
          cin>>s>>p;
          int len=sz(s);
          rep(i,0,26)
            lst[i]=-1;
          rep(i,0,26)
            a[len][i]=-1;
		
		for(int i=len-1;i>=0;i--){
			 lst[s[i]-'a']=i+1;
			 
			 rep(j,0,26)
			   a[i][j]=lst[j];
		}
		
		
		//~ rep(i,0,len){
			 //~ rep(j,0,26)
			   //~ cout<<a[i][j]<<" ";
			   //~ cout<<endl;
		//~ }
		
		
		int ind=0,tt=0;
		
		rep(i,0,sz(p)){
		  if(a[ind][p[i]-'a']!=-1)
		    ind=a[ind][p[i]-'a'];
		    
		  else{
			   tt++;
			  ind =0;
			  if(a[ind][p[i]-'a']!=-1)
			    ind=a[ind][p[i]-'a'];
			    
			  else {				  
				  cout<<-1<<endl;
				  return;			  
			  }  
		   } 
		  }
		 // cout<<tt<<endl;
		  
		  int tot=tt*len+ind;
		  cout<<tot<<endl;
		  
		  
		                    
	    }
	 

     

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


Measured memory_bytes: 20944
import math
S = input()
K = int(input())
s = list(S)
c1 = 0
for i in range(len(s)-1):
    if s[i+1] == s[i]:
        c1 += 1
        s[i+1] = 0
s = list(S*2)
c2 = 0
for i in range(len(s)-1):
    if s[i+1] == s[i]:
        c2 += 1
        s[i+1] = 0
c = S[0]
for s in S:
    if s != c:
        print(c1+(c2-c1)*(K-1))
        exit()
print(math.floor(len(S)*K/2))


Measured memory_bytes: 62000
#include <iostream>
#include <utility>
#include <vector>
#include <algorithm>

int main() {
  int n, t;
  std::cin >> n >> t;
  std::vector<std::pair<int, int>> p(n);
  for (int i = 0; i < n; i++) {
    int a, b;
    std::cin >> a >> b;
    p[i] = {a, b};
  }
  std::sort(p.begin(), p.end());
  int ans = 0;
  for(auto x : p) {
      if (x.second <= t) {
        ans = x.first;
        break;
      }
  }
  if (ans == 0) {
      std::cout << "TLE" << std::endl;
  } else {
      std::cout << ans << std::endl;
  }
  
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cctype>
#include <iostream>
#include <map>
#include <string>
#include <set>
#include <algorithm>
#define ll long long
#define il inline
#define rgi register ll

using namespace std;

const int N = 100000 + 10;

ll n, cnt, ans;

set <string> s;

map <string, ll> vis;

il ll read()
{
	rgi x = 0, f = 0, ch;
	while(!isdigit(ch = getchar())) f |= ch == '-';
	while(isdigit(ch)) x = (x << 1) + (x << 3) + (ch ^ 48), ch = getchar();
	return f ? -x : x;
}

int main()
{
	n = read();
	for(rgi i = 1; i <= n; ++i)
	{
		string str;
		cin >> str;
		sort(str.begin(), str.end());
		s.insert(str);
		vis[str]++;
	}
	for(set <string> :: iterator it = s.begin(); it != s.end(); ++it)
		ans += vis[*it] * (vis[*it] - 1) / 2;
	printf("%lld", ans);
	return 0;
}

Measured memory_bytes: 20608
#include<bits/stdc++.h>
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define MOD	1000000007
#define int	long long
#define pii pair<int,int> 
#define vi vector<int>
using namespace std;

vector<int> truth[200], liar[200];


int32_t main(){
	int n;
	cin >> n;
	for(int i = 1; i <= n; i++){
		int x;
		cin >> x;
		for(int j = 0; j < x; j++){
			int y, z;
			cin >> y >> z;
			if(z == 0)
				liar[i].PB(y);
			else
				truth[i].PB(y);
		}
	}
	int ans = 0;
	for(int i = 0; i < (1<<n); i++){
		vector<int> v;
		for(int j = 0; j < n; j++)
			if(i&(1<<j))
				v.push_back(j);
		set<int> l, t;
		
		for(auto x : v){
			t.insert(x);
			for(auto y : truth[x+1]){
				t.insert(y-1);
			}
		}
		
		if(t.size() != v.size())
			continue;
		
		for(auto x : v){
			for(auto y : liar[x+1]){
				l.insert(y-1);
			}
		}
		bool flag = 1;
		for(auto x : v){
			if(l.find(x) != l.end()){
				flag = 0;
			}
		}
		if(flag){
			ans = max(ans,(int)v.size());
		}
	}
	
	cout << ans << endl;
	
	return 0;
}



Measured memory_bytes: 256
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>

#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define repi(i,a,b) for(int i = (a); i < (b); i++)

using namespace std;

typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;

const int INF=1<<29;
const double EPS=1e-9;

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

int main(){
	string str;
	getline(cin, str);
	int cnt = 0;
	string tmp ="";
	bool flag =true;
	for(int i =0; i<str.length();i++){
		if(str[i]==','||str[i]==' '||str[i]=='.'){
			//cout <<cnt<<endl;
			if(cnt>=3&&cnt<=6){
				if(flag){
					cout <<tmp;
					flag =false;
				}else{
					cout <<" "<<tmp;
				}
			}
			cnt=0;
			tmp ="";
		}else{
			tmp +=str[i];
			cnt++;
		}
	}
	cout <<endl;
	return 0;
}

Measured memory_bytes: 1176
S = input()

B_index_sum = 0
for i in range(len(S)):
    if S[i] == "B":
        B_index_sum += i+1

B_count = S.count("B")
destination_B_index_sum = (len(S)*B_count) - sum(range(B_count))

print(max(0, destination_B_index_sum - B_index_sum))

Measured memory_bytes: 9176
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    long long int n,a,b,c;
    cin>>n;
    if(n==1){
        cout<<"Hello World"<<endl;
    }
    if(n==2){
        cin>>a>>b;
        c=a+b;
        cout<<c<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(n) begin(n), end(n)
using ll = long long;
using namespace std;

int main(){
	int n;
	cin >> n;
	vector<tuple<int, int, int>> c(n);
	rep(i, n){
		int a, b;
		cin >> a >> b;
		c.at(i) = make_tuple(a+b, a, b);
	}
	sort(c.rbegin(), c.rend());
	ll ta = 0, ao = 0;
	rep(i, n){
		if(i % 2 == 0) ta += get<1>(c.at(i));
		else ao += get<2>(c.at(i));
	}
	cout << ta - ao << endl;
	return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n, a[100100], i, tmp=0, cnt=1;
    cin >> n;
    for(i=0;i<n;i++){
        cin >> a[i];
        a[i]--;
    }
    if(a[0]==1){
        cout << 1 <<endl;
        return 0;
    }
    for(i=0;i<n;i++){
        if(a[tmp]==1){
            cout << cnt <<endl;
            return 0;
        }
        tmp=a[tmp];
        cnt++;
    }
    cout << -1 <<endl;
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define ll long long
#define endl '\n'
using namespace std;
const ll mod = (ll)1e9+7;
const ll INF = 0x3f3f3f3f;

void add(ll &x, ll y)
{
    x+=y;
    if(x>=mod)
    {
        x-=mod;
    }
}

ll countn(int x)
{
    ll ret=0;
    while(x)
    {
        x/=10;
        ret++;
    }
    return ret;
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    #ifndef ONLINE_JUDGE
    //freopen("A.txt", "r", stdin);
    #endif
    ll n, ans=mod;
    cin >> n;
    for(ll i=1; i<=sqrt(n); i++)
    {
        if(n%i!=0) continue;
        ans = min(ans, countn(max(i, n/i)));
    }
    cout << ans;
}

Measured memory_bytes: 256
N, M, Q = map(int, input().split())
LR = [list(map(int, input().split())) for _ in range(M)]
PQ = [list(map(int, input().split())) for _ in range(Q)]

T = [[0 for _ in range(N + 2)] for _ in range(N + 2)]
for L, R in LR:
  T[L][R] += 1
#print("T:", T)

S = [[0 for _ in range(N + 2)] for _ in range(N + 2)]
for i in range(N + 2):
  for j in range(N + 2):
    S[i][j] = S[i][j - 1] + T[i][j]
for j in range(N + 2):
  for i in range(N + 2):
    S[i][j] += S[i - 1][j]
#print("S:", S)

for P, Q in PQ:
  print(S[Q][Q] - S[P - 1][Q] + S[Q][P - 1] - S[P - 1][P - 1])

Measured memory_bytes: 112600
/*                        _
                       _oo0oo_
                      o8888888o
                      88" . "88
                      (| -_- |)
                      0\  =  /0
                   ____/`---'\____
                  /  \\|     |//  \
                 / \\||| /:\ |||// \
                / _||||| -:- |||||- \
               |   | \\\ \-/ /// |   |
               | \_|  ''\---/''  |_/ |
               \  .-\__  '-'  ___/-. /
            ____'. .'  /--.--\  `. .'_____
          /"" '<  `.___\_<|>_/___.' >' "" \
         | | :  `- \`.;`\ _ /`;.`/ - ` : | |
         \  \ `_.   \_ __\ /__ _/   .-` / _/
          `-.____`.___ \_____/___.-`___.-'

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 JENISH MONPARA S.    IIT PATNA    I_LOVE_ADITI_GOEL
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
#include <bits/stdc++.h>
using namespace std;
const long double PI = 3.141592653589793;
const long double DEL = 1e-12;
const int mod =  1000000007;
const int LIM = 100005;


#define fio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define mpq priority_queue<int,vector<int>,greater<int>>
#define deb(a) cerr << #a << ": " << a << endl
#define ftt cin>>t;for(int tt=1;tt<=t;++tt)
#define forr(i,n) for((i)=1;(i)<=(n);(i)++)
#define Rev(v) reverse(v.begin(),v.end())
#define Sort(v) sort(v.begin(),v.end())
#define mem(a,b) memset(a,b,sizeof(a))
#define umii unordered_map<int,int>
#define all(a) a.begin() , a.end()
#define vvi vector<vector<int>>
#define pq priority_queue<int>
#define sqr(a) (((a) * (a)))
#define double long double
#define dbg cout<<"\nhi\n"
#define pii pair<int,int>
#define mii map<int,int>
#define vb vector<bool>
#define eb emplace_back
#define vi vector<int>
#define nl cout<<"\n"
#define pb push_back
#define int long long
#define sp <<" "<<
#define ss second
#define ff first
 
int fpow(int x, int n){
    int res = 1;
    while(n){
          if(n&1){
                res = res * x % mod;
          }
          x = x * x % mod;
          n>>=1;
    }
    return res;
}
int gcd(int a,int b){
    if(b == 0)return a;
    return gcd(b,a % b);
}
void sieve(int n){
     bool prime[5*LIM];
     memset(prime, true, sizeof(prime));
      int rootn = (int)sqrt(n);
     for (int p = 2; p <= rootn; p++)
          if (prime[p] == true)
               for (int i = p*p; i <= n; i += p)
                    prime[i] = false;
     prime[1] = 0;

}

int cnt, sum, mid, mx = -1e17, mn = 1e17, a[2*LIM];
int n, m, d, t, i, j, k, l, r, x, y, z;
bool f, f1, f2;
string s;

//******************************************* CHECK CONSTRAINTS **************************************************


int32_t main()
{     fio;
      cin>>x;
      if(x%1000==0){
            cout<<0;
      }else
      cout<<1000-(x%1000);
     
}


Measured memory_bytes: 3660
import java.util.*;

class Main{
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        int sum = 0;
        int temp = 0;
        int i = 0;
        int e = 0;
        //余りが一番小さいものを最後に注文する。
        int r[] = new int[5];
        int s = 11;
        int t = 11;
        for(int k = 0; k<5; k++){
          r[k] = sc.nextInt();
        }

        for(i = 0; i < 5; i++){
          s = Math.min(t,r[i]%10);
          if(t != s && r[i]%10 !=0){
          e = i;
          t = s; 
          }
        }
        temp = r[4];
        r[4] = r[e];
        r[e] = temp;

        for(int j = 0; j < 4; j++){
          if(r[j] % 10 != 0){
            sum = 10 - (r[j] % 10) + r[j] +sum;
          }else{
            sum += r[j];
          }
        }
        sum += r[4];
        System.out.println(sum);
    }
}


Measured memory_bytes: 22736
#include<iostream>
#include<vector>
#include<algorithm>

int main(){
	long long n;
	std::vector<long long> aList;

	std::cin>>n;
	aList.resize(n);

	for(int i=0; i<n; i++)
		std::cin>>aList[i];

	std::vector<long long> log2List(31, 0);
	std::vector<long long> pow2List(31, 1);

	std::vector<std::vector<long long>> log2ind(n);
	for(int i=0; i< n; i++)
		log2ind[i].resize(31, 0);


	for(int i=1; i< 31; i++)
		pow2List[i]= pow2List[i-1]*2;

	for(int i=0; i<n; i++){
		long long tmp= aList[i];
		int idx=0;
		while(tmp> 0){
			log2ind[i][idx]= tmp%2;
			log2List[idx]+= tmp%2;
			tmp/=2;
			idx++;
		}
	}

	for(int i=0; i<n; i++){
		long long tmp= aList[i];

		long long ans=0;

		for(int j=0; j< 31; j++){
			if((log2List[j] - log2ind[i][j])%2 ==1)
				ans+= pow2List[j];			
		}

		std::cout<<ans<<" ";
	}

	std::cout<<std::endl;

	return 0;
}

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

#define MOD 1000000007

int main()
{
    int N;
    string S1, S2;

    cin >> N;
    cin >> S1 >> S2;

    long long ans = 1;
    for (int i = 0; i < N; i++)
    {
        if (S1[i] == S2[i])
        {
            if (i > 0)
            {
                if (S1[i - 1] == S2[i - 1])
                {
                    // ab
                    // ab
                    ans *= 2;
                }
                else
                {
                    // aac
                    // bbc
                    ans *= 1;
                }
            }
            else
            {
                // a
                // a
                ans *= 3;
            }
        }
        else
        {
            if (i > 0)
            {
                if (S1[i - 1] == S2[i - 1])
                {
                    // abb
                    // acc
                    ans *= 2 * 1;
                }
                else
                {
                    // aacc
                    // bbdd
                    ans *= 1 * 2 + 1 * 1;
                }
            }
            else
            {
                // aa
                // bb
                ans *= 3 * 2;
            }
            i++;
        }
        ans %= MOD;
    }
    cout << ans << endl;
}


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


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i,n) cin >> a[i];

  map<int,int> nmap;
  rep(i,n){
    nmap[i+a[i]]++;
  }
  ll ans =0;
  rep(i,n){
    ans += nmap[i-a[i]];
  }
  cout << ans << endl;

  return 0;
    

}


Measured memory_bytes: 21084
#include <iostream>

using namespace std;

int main() {
    int x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;

    int x3, y3, x4, y4;
    x3 = y3 = x4 = y4 = 0;

    int diffX, diffY;
    diffX = diffY = 0;
    
    diffX = x2 - x1;
    diffY = y2 - y1;

    x3 = x2 - diffY;
    y3 = y2 + diffX;

    diffX = x3 - x2;
    diffY = y3 - y2;

    x4 = x3 - diffY;
    y4 = y3 + diffX;

    cout << x3 << " " << y3 << " " << x4 << " " << y4 << endl; 

    return 0;
}

Measured memory_bytes: 888
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <queue>
#include <numeric>
#include <string>
#include <string.h>
#include <map>
#include <set>
#include <functional>
#include <complex>
#include <stack>
#include <tuple>

#define ll long long int

using namespace std;

const int INF = (1<<30) - 1;

bool infield(int h, int w){
    return 0<=h && h<8 && 0<=w && w<8;
}

int turn_field(vector<string> &field, bool flip, int h, int w, char myc, char opc){
    if(field[h][w] != '.')
        return 0;
    
    int count = 0;
    for(int i=-1; i<=1; i++){
        for(int j=-1; j<=1; j++){
            if(i==0 && j==0) continue;
            
            int l = 0;
            int nh = h, nw = w;
            do{
                l++;
                nh = h + i*l;
                nw = w + j*l;
            }while(infield(nh, nw) && field[nh][nw] == opc);
            
            if(infield(nh, nw) && field[nh][nw] == myc){
                count += l - 1;
                if(flip)
                    for(int k=0; k<l; k++)
                        field[h+k*i][w+k*j] = myc;
            }
        }
    }
    return count;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    char turnc[] = {'o', 'x'};
    
    vector<string> field(8);
    for(string &s: field)
        cin >> s;
    
    int pass = 0;
    int turn = 0;
    while (pass < 2) {
        bool update = false;
        char myc = turnc[turn];
        char opc = turnc[turn^1];
        
        int count = 0;
        int th, tw;
        
        if(turn == 0){
            for(int h=0; h<8; h++){
                for(int w=0; w<8; w++){
                    int tcount = turn_field(field, false, h, w, myc, opc);
                    if(count < tcount){
                        count = tcount;
                        th = h;
                        tw = w;
                        update = true;
                    }
                }
            }
        }else{
            for(int h=7; 0<=h; h--){
                for(int w=7; 0<=w; w--){
                    int tcount = turn_field(field, false, h, w, myc, opc);
                    if(count < tcount){
                        count = tcount;
                        th = h;
                        tw = w;
                        update = true;
                    }
                }
            }
        }
        
        if(update){
            turn_field(field, true, th, tw, myc, opc);
            pass = 0;
        }else{
            pass++;
        }
        
        turn ^= 1;
    }
    
    for(string s: field)
        cout << s << endl;
    
    return 0;
}

Measured memory_bytes: 1184
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;
import java.util.HashMap;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        FactorsFactorial solver = new FactorsFactorial();
        solver.solve(1, in, out);
        out.close();
    }

    static class FactorsFactorial {
        public static long MOD = 1_000_000_007;

        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            long result = 1;
            HashMap<Long, Long> map = new HashMap<>();
            for (int i = 2; i <= n; i++) {
                HashMap<Long, Long> p = primeFactorize(i);
                for (long key : p.keySet()) {
                    map.put(key, map.getOrDefault(key, 0L) + p.get(key));
                }
            }
            for (long key : map.keySet()) {
                result *= (map.get(key) + 1);
                result %= MOD;
            }
            out.println(result);
        }

        static HashMap<Long, Long> primeFactorize(long x) {
            HashMap<Long, Long> result = new HashMap<>();
            for (long i = 2; i * i <= x; i++) {
                if (x % i != 0) {
                    continue;
                }
                long ex = 0;
                while (x % i == 0) {
                    ex++;
                    x /= i;
                }
                result.put(i, ex);
            }
            if (x != 1) {
                result.put(x, 1L);
            }
            return result;
        }

    }
}



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

using namespace std;

class Solution {
public:
	void solve() {
		int a, b, c, d;
		cin >> a >> b >> c >> d;
		while (a > 0 || c > 0) {
			c -= b;
			if (c <= 0) {
				cout << "Yes\n";
				return;
			}
			a -= d;
			if (a <= 0) {
				cout << "No\n";
				return;
			}
		}
		return;
	};
};

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	Solution solution;
	solution.solve();
	return 0;
}

Measured memory_bytes: 3624
#pragma region template 2.4
#include <bits/stdc++.h>
using namespace std;
template <typename T>
using pq_asc = priority_queue<T, vector<T>, greater<T>>;
typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> ii;
typedef vector<ii> vii;
typedef vector<string> vs;
#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define REP1(i, n) for (ll i = 1; i <= (n); ++i)
#define FOR(i, a) for (auto &i : a)
#define CH(f, x, y) x = f(x, y)
#define IN(T, x) \
    T x;         \
    cin >> x;
#define AIN(T, a, n) \
    vector<T> a(n);  \
    FOR(i, a)        \
    cin >> i;
#define A2IN(T1, a, T2, b, n) \
    vector<T1> a(n);          \
    vector<T2> b(n);          \
    REP(i, n)                 \
    cin >> a[i] >> b[i];
#define OUT(x) cout << (x) << endl;
#define FOUT(x) cout << fixed << setprecision(15) << (x) << endl;
#define ALL(a) (a).begin(), (a).end()
#define SORT(a) sort(ALL(a))
#define RSORT(a) \
    SORT(a);     \
    reverse(ALL(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define DUMPA(a)          \
    cout << #a << " = {"; \
    JOUT(ALL(a), cout, ", ") << "}" << endl;

template <typename T>
ostream &JOUT(T s, T e, ostream &os = cout, string sep = " ")
{
    if (s != e)
    {
        os << *s;
        ++s;
    }
    while (s != e)
    {
        os << sep << *s;
        ++s;
    }
    return os;
}

ostream &YES(bool cond, string yes = "Yes", string no = "No", ostream &os = cout)
{
    if (cond)
    {
        os << yes << endl;
    }
    else
    {
        os << no << endl;
    }
    return os;
}

template <typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p)
{
    os << '(' << p.first << ", " << p.second << ')';
    return os;
}

template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v)
{
    os << '[';
    JOUT(ALL(v), os, ", ") << ']';
    return os;
}

const ll INF = 1e18;
const ll MOD = 1e9 + 7;
#pragma endregion template

int main()
{
    IN(string, S);
    YES(S[0] != S[1] or S[1] != S[2]);
}

Measured memory_bytes: 256
#include<set>
#include<map>
#include<cmath>
#include<queue>
#include<bitset>
#include<string>
#include<cstdio>
#include<cctype>
#include<cassert>
#include<cstdlib>
#include<cstring>
#include<sstream>
#include<iostream>
#include<algorithm>

#define For(i,x,y) for (int i=x;i<y;i++)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define lf else if

#define dprintf(...) fprintf(stderr,__VA_ARGS__)
using namespace std;

typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
typedef vector<int> Vi;

int IN(){
	int c,f,x;
	while (!isdigit(c=getchar())&&c!='-');c=='-'?(f=1,x=0):(f=0,x=c-'0');
	while (isdigit(c=getchar())) x=(x<<1)+(x<<3)+c-'0';return !f?x:-x;
}

const int N=200000+19;
const int p=1e9+7;

int Pow(int a,int b){
	int res=1;
	for (;b;b>>=1,a=1ll*a*a%p) if (b&1) res=1ll*res*a%p;
	return res;
}

struct Edge{
	int y,nxt;
} E[N*2];

Vi V[N],P;
int fac[N],inv[N],las[N],vis[N],chk[N],nxt[N],sz[N],deg[N];
int n,num,tmp,ans,cnt,v,e,a,b,v2,num2,tmp2,alb,x,y;

int C(int n,int m){
	return 1ll*fac[n]*inv[m]%p*inv[n-m]%p;
}
void Link(int x,int y){
	E[cnt]=(Edge){y,las[x]};las[x]=cnt++;
	E[cnt]=(Edge){x,las[y]};las[y]=cnt++;
}
void dfs(int x){
	vis[x]=1;
	v++;
	for (int i=las[x],y;~i;i=E[i].nxt){
		e++;
		if (!vis[y=E[i].y]) dfs(y);
	}
}
void dfs(int x,int fa){
	P.pb(x);
	chk[x]=1;
	for (int i=las[x],y;~i;i=E[i].nxt)
		if (i!=fa){
			if (!chk[y=E[i].y]){
				dfs(y,i^1);
			} else{
				a=x,b=y;
			}
		}
}
void gao(int x,int fa){
	for (int i=las[x],y;~i;i=E[i].nxt)
		if ((y=E[i].y)!=fa){
			if (x==a&&y==b) continue;
			if (x==b&&y==a) continue;
			nxt[y]=x;
			gao(y,x);
		}
}
int bao(int x){
	chk[x]=2;
	int ans=1;
	sz[x]=0;
	for (int y:V[x]){
		ans=1ll*ans*bao(y)%p*C(sz[x]+sz[y],sz[y])%p;
		sz[x]+=sz[y];
	}
	sz[x]++;
	return ans;
}
void Work(int x){
	P.clear();
	tmp=0;
	dfs(x,-1);
	
	alb=1;
	gao(a,-1);
	nxt[a]=b;
	for (int i:P) if (i<nxt[nxt[i]]){
		V[nxt[i]].pb(i);
		deg[i]++;
	}
	num2=0;
	for (int i:P) if (deg[i]==0&&chk[i]!=2){
		alb=1ll*alb*bao(i)%p*C(num2+sz[i],sz[i])%p;
		num2+=sz[i];
	}
	for (int i:P){
		V[i].clear();
		deg[i]=0;
		chk[i]=0;
	}
	//printf("%d\n",alb);
	tmp=(tmp+alb)%p;
	
	alb=1;
	gao(b,-1);
	nxt[b]=a;
	for (int i:P) if (i<nxt[nxt[i]]){
		V[nxt[i]].pb(i);
		deg[i]++;
	}
	num2=0;
	for (int i:P) if (deg[i]==0&&chk[i]!=2){
		alb=1ll*alb*bao(i)%p*C(num2+sz[i],sz[i])%p;
		num2+=sz[i];
	}
	//printf("%d\n",alb);
	tmp=(tmp+alb)%p;
}

int main(){
	memset(las,-1,sizeof(las));
	fac[0]=1;
	For(i,1,N) fac[i]=1ll*fac[i-1]*i%p;
	inv[N-1]=Pow(fac[N-1],p-2);
	for (int i=N-1;i;i--) inv[i-1]=1ll*inv[i]*i%p;
	n=IN()*2;
	For(i,1,n+1){
		x=IN(),y=IN();
		Link(x,y+n/2);
	}
	ans=1;
	For(i,1,n+1) if (!vis[i]){
		v=0,e=0;
		dfs(i);
		if (v!=e/2){
			puts("0");
			return 0;
		}
		Work(i);
		ans=1ll*ans*tmp%p*C(num+v,v)%p;
		num+=v;
	}
	printf("%d\n",ans);
}

Measured memory_bytes: 20468
import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

A, B, M = lr()
R = lr()
D = lr()
answer = min(R) + min(D)
for _ in range(M):
    x, y, c = lr()
    x -= 1; y -= 1
    temp = R[x] + D[y] - c
    if temp < answer:
        answer = temp

print(answer)


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

static const int MAX_V = 210;
const int INF = 1e9;

int d[MAX_V][MAX_V];
int V;

void warshall_floyde(){
    for(int k = 0; k < V; k++){
        for(int i = 0; i < V; i++){
            for(int j = 0; j < V; j++) d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
        }
    }
}

int R;
bool visited[210];
vector<int> r;

int dfs(int v, int p = -1, int length = 0, int depth = 1){
    //if(length == 2 && depth == R - 1) cout << "closest!" << v << endl; 
    if(depth == R) return length;
    //cout << v << endl;
    int ans = INF;
    rep(i, R){
        int nv = r[i];
        if(visited[nv] || nv == p) continue;
        visited[nv] = true;
        ans = min(ans, dfs(nv, v, length + d[v][nv], depth + 1));
        // if(ans == 2) cout << "closest!" << v << endl;
        visited[nv] = false;
    }
    //cout << ans << endl;
    return ans;
}

int main(){
    int M; cin >> V >> M >> R;
    r.resize(R);
    rep(i,R) {cin >> r[i]; r[i]--;}
    rep(i, V) rep(j, V){
        if(i != j) d[i][j] = INF;
        else d[i][j] = 0;
    }
    rep(i, M){
        int a, b, c; cin >> a >> b >> c;
        a--, b--;
        d[a][b] = c;
        d[b][a] = c;
    }
    warshall_floyde();
    int ans = INF;
    rep(j, 205) visited[j] = 0;
    rep(i, R){
        visited[r[i]] = true;
        ans = min(ans, dfs(r[i]));
        visited[r[i]] = false;
    }
    cout << ans << endl;
}

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

int main() {
  int N;
  cin >>N;
  vector<string> S(N);

  for(int i=0;i<N;i++){
    cin >> S.at(i);
  }

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

  decltype(S)::iterator result = unique(S.begin(), S.end());
  S.erase(result, S.end());
  cout << S.size() <<endl;
}

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


int main(){
 int l; 
 string s;
  cin>>s;
  l=s.length();
  
  if(s[l-1]=='s') {
  
    s[l]='e';
    s[l+1]='s';
    
    for(int i=0;i<l+2;i++)cout<<s[i];
  
  }
    
    else {
    
     s[l]='s';
    for(int i=0;i<l+1;i++)cout<<s[i];
    
    }
  
}

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

using namespace std;

int main(void) {
  string S, T, U; int A, B;
  cin >> S >> T >> A >> B >> U;

  map<string, int> ball;
  ball.insert(make_pair(S, A));
  ball.insert(make_pair(T, B));
  ball[U]--;

  cout << ball[S] << " " << ball[T] << endl;

  return 0;
}

Measured memory_bytes: 256
use std::io;
use std::str::FromStr;

fn input_char_vec() -> Vec<char> {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    line.trim().chars().collect()
}

fn input<T:FromStr>() -> T {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    line.trim().parse().ok().unwrap()
}

fn main() {
    let s = input_char_vec();
    let mut k: u64 = input();
    for c in s {
        if k == 1 || c != '1' {
            println!("{}", c);
            return;
        } else {
            k -= 1;
        }
    }
}


Measured memory_bytes: 2080
//#define _USE_MATH_DEFINES
//#include <math.h>
#include <iostream>
//#include <iomanip>
//#include <bits/stdc++.h>

using namespace std;

int main() {
    
    int H,W;
    while(cin >> H >> W){
        if(H == 0 && W == 0) break;
        for(int i = 0; i < H; i++){
            for(int j = 0; j < W; j++){
                if(i == 0 || i == H - 1){
                    cout << "#";
                }else{
                    if(j == 0 || j == W - 1) cout << "#";
                    else cout << ".";
                }
            }
            cout << endl;
        }
        cout << endl;
    }
    return 0;
}



Measured memory_bytes: 3016
import java.util.Scanner;
public class Main {
 public static void main(String[] args) {
  Scanner sc=new Scanner(System.in);
  int N=sc.nextInt();
  int hm [][]=new int[200][5];
  for(int i=0;i<N;i++){
   for(int k=0;k<3;k++){
    hm[i][k]=sc.nextInt();
   }
   hm[i][3]=0;
  }
  for(int j=0;j<3;j++){
   for(int a=0;a<N;a++){
    hm[a][4]=0;
    for(int b=0;b<N;b++){
     if(a!=b && hm[a][j]==hm[b][j]){
      hm[a][4]=1;
     }
    }
    if(hm[a][4]==0){
     hm[a][3]=hm[a][3]+hm[a][j];
    }
   }
  }
  for(int d=0;d<N;d++){
  System.out.println(hm[d][3]);
  }
 }
}

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

using namespace std;
typedef long long ll;
ll mod = 1e9+7;

int main(void)
{
  ll A,B;cin>>A>>B;
  if(A==B){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }

  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <iterator>
#include <cmath>
#include <set>
#include <deque> 
#include <string>


using namespace std;

int n;
char s[10010];

int main()
{
	scanf("%d\n", &n);
	scanf("%s", s);
	
	if (n % 2 != 0)
	{
		printf("No\n");
		return 0;
	}
	
	bool isSame = true;
	
	int step = n / 2;
	
	for (int i = 0 ; i < step ; i++)
	{
		if (s[i] != s[i + step])
		{
			isSame = false;
			break;
		}
	}
	
	if (isSame)
	{
		printf("Yes\n");
	}
	else
	{
		printf("No\n");
	}
	
			
	return 0;
}


Measured memory_bytes: 128
#include <stdio.h>
#include <string.h>

struct Rev
{
    char name[10];
    int point;
    int rank;
};

int main(void){
    int N = 0;
    scanf("%d", &N);

    struct Rev rev[N];

    for(int i = 0; i < N; i++){
        scanf("%s", rev[i].name);
        scanf("%d", &rev[i].point);
        rev[i].rank = i+1;
    }
    
    for(int i = 0; i < N; i++){
        for(int j = i + 1; j < N; j++){
            int value = strcmp((rev[i].name), (rev[j].name));
            struct Rev tem;
            if(value > 0){
                tem = rev[i];
                rev[i] = rev[j];
                rev[j] = tem;
            }else if(value == 0){
                struct Rev temp;
                
                if(rev[i].point < rev[j].point){
                    temp = rev[i];
                    rev[i] = rev[j];
                    rev[j] = temp;                 
                }
            }
        }
    }

    for(int i = 0; i < N; i++){
        printf("%d\n", rev[i].rank);
    }

    return 0;
}

Measured memory_bytes: 128