akhauriyash/Code-Regression huggingface dataset:
def MAP(): return list(map(int,input().split()))
def INT(): return int(input())
def FLOAT(): return float(input())
MOD = 10**9+7

N = INT()

def dfs(s):
    if int(s) > N:
        return 0
    ret = 1 if all(s.count(c) > 0 for c in '753') else 0
    for c in '753':
        ret += dfs(s + c)
    return ret

print(dfs('0'))

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
using namespace std;

int main(void) {
    int n;
    vector<int> tri(3,0);
    cin >> n;
    for(int i=0; i<n; i++) {
        cin >> tri[0] >> tri[1] >> tri[2];
        sort(tri.begin(),tri.end(),greater<int>());
        if(tri[0]*tri[0] == tri[1]*tri[1] + tri[2]*tri[2]) {
            cout << "YES" << endl;
        }
        else cout << "NO" << endl;
    }
    return 0;
}

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

int main() {
  long N; cin >> N;
  if (N % 2 != 0) cout << 0 << endl;
  else {
    long res = 0, div = 2;
    for (int i = 0; i < 26; i++) {
      div *= 5;
      res += N / div;
    }
    cout << res << endl;
  }
}

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

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

long long MOD = 1000000000 + 7;

int main(){
  cout << setprecision(10);
  ll N;
  cin >> N;
  for(ll x = 1; x <= 3500; x++){
    for(ll y = 1; y <= 3500; y++){
      ll left = 4*x*y - N * y - N * x;
      ll right = N * x * y;
      ll z;
      if(left > 0 && right % left == 0){
        z = right / left;
        cout << x << " " << y << " " << z << endl;
        return 0;
      }
    }
  }
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    int n,s,k;
    cin>>n>>s;
    for(int i=0;i<=n;i++)
        for(int j=0;j<=n;j++){
            if(i+j>n) break;
            k=n-i-j;
            if(i*10000+j*5000+k*1000==s){
                cout<<i<<" "<<j<<" "<<k<<endl;
                return 0;
            }
            if(i*10000+j*5000+k*1000>s) break;
        }
    cout<<"-1 -1 -1"<<endl;
    return 0;
}

Measured memory_bytes: 256
while true do
  ans=0
  str=gets.chomp
  number=str.split
  num=Array.new(3)
  num[0]=number[0].to_i
  num[2]=number[2].to_i
  if number[1]=='+' then
    ans=num[0]+num[2]
  elsif number[1]=='-' then
    ans=num[0]-num[2]
  elsif number[1]=='*' then
    ans=num[0]*num[2]
  elsif number[1]=='/' then
    ans=num[0]/num[2]
  elsif number[1]=='?' then
    break
  end
  puts ans
end

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

#ifdef LOCAL
#include "../lib/dump.hpp"
#else
#define dump(...)
#define dumpv(...)
#endif

typedef long long ll;
typedef pair<int, int> P;
const int MOD = 1e9 + 7;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;

void solve()
{
  string s, t;
  cin >> s;
  cin >> t;
  vector<set<int>> p(26);
  for (int i = 0; i < s.size(); i++) {
    p[s[i] - 'a'].insert(i);
  }
  // dump(p);
  ll ans = 0;
  ll loop = 0;
  vector<int> c(26);
  for (int i = 0; i < t.size(); i++) {
    int j = t[i] - 'a';
    if (p[j].size() == 0) {
      // 見つからない
      cout << -1 << endl;
      return;
    } else {
      // 見つかった
      auto loc = p[j].lower_bound(ans);
      if (loc != p[j].end()) {
        // 先にある
        ans = *loc + 1;
      } else {
        // 手前にある
        ans = *p[j].begin() + 1;
        loop++;
      }
      dump(t[i], ans, loop);
    }
  }
  cout << loop * s.size() + ans << endl;
}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  // freopen("temp.1", "r", stdin);
  solve();
  return 0;
}

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

int main() {
  int N; cin >> N;
  int a[N]; rep(i,0,N) cin >> a[i];
  
  bool check[N]; rep(i,0,N) check[i] = false;
  bool right = false;
  int ans = -1,tmp =0,count =0;
  while (true) {
    if (check[tmp]) break;
    check[tmp] = true;
    if (check[1]) {
      right = true; break;
    }
    count++;
    tmp = a[tmp] - 1;
  }
    
  if (right) cout << count << endl;
  else cout << -1 << endl;
}

Measured memory_bytes: 4044
import java.util.*;

public class Main {
    public static void main(final String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        Set<Integer> set = new HashSet<>();
        for (int i = 0; i < m; i++) {
            set.add(sc.nextInt());
        }
        long[] dp = new long[n+1];
        dp[0] = 1;
        long mod = 1000000007;
        for (int i = 1; i <=n ; i++) {
            if (!set.contains(i)) {
                dp[i] = dp[i-1];
                if (i-2 >=0 ) dp[i] += dp[i-2];
                dp[i] %=  mod;
            }
        }

        System.out.println(dp[n]);
    }
}

Measured memory_bytes: 63556
import java.util.Scanner;

public class Main {
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		String str = sc.next();
		char a[] = new char[str.length()];
		for(int i = 0; i < str.length(); i++){
			a[i] = str.charAt(i);
		}
		for(int i = str.length() - 1; i >= 0; i--){
			System.out.print(a[i]);
		}
		System.out.println();
	}
}

Measured memory_bytes: 25912
#include<bits/stdc++.h>
using namespace std;
map<char,int> m;
int main(){
	string s;
	cin>>s;
	for(int i=0;i<s.size();i++){
		m[s[i]]++;
	}
	for(char i='a';i<='z';i++){
		if(m[i]%2){
			puts("No");
			return 0;
		}
	}
	puts("Yes");
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <stack>
#include <set>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define all(v) v.begin(), v.end()

const int N = (int)3e5+3;

ll mpow(ll a, ll b){
	if(b==0) return 1;
	else if(b%2==0){ll memo = mpow(a,b/2); return memo*memo%MOD;}
	else return mpow(a,b-1) * a % MOD;
}
ll gcd(ll a, ll b){
	if(b==0) return a;
	else return gcd(b, a%b);
}
vector<ll> kaijo_memo;
ll kaijo(ll n){
	if(kaijo_memo.size() > n) return kaijo_memo[n];
	if(kaijo_memo.size() == 0) kaijo_memo.push_back(1);
	while(kaijo_memo.size() <= n) kaijo_memo.push_back(kaijo_memo[kaijo_memo.size()-1] * kaijo_memo.size() % MOD);
	return kaijo_memo[n];
}
ll nCr(ll n, ll r){
	if(n < r || r < 0) return 0;
	ll ret = 1;
	ret *= kaijo(n); ret %= MOD;
	ret *= mpow(kaijo(r), MOD-2); ret %= MOD;
	ret *= mpow(kaijo(n-r), MOD-2); ret %= MOD;
	return ret;
}

int main(void){
	int a,b,c;cin>>a>>b>>c;
	int maxa = max(a,max(b,c));
	int sum = a+b+c;
	if((maxa*3 - sum)%2 == 0){
		cout<<(maxa*3-sum)/2<<endl;
	}else{
		cout<<(maxa*3+3-sum)/2<<endl;
	}
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();

		if (A==B && B==C) {

			System.out.println("Yes");
		} else {
			System.out.println("No");

		}

	}

}

Measured memory_bytes: 21844
import sys

read = sys.stdin.read
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7


def main():
    N, D = map(int, readline().split())
    ans = 0
    for _ in range(N):
        X, Y = map(int, readline().split())
        if X**2+Y**2<=D**2:
            ans += 1
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 9120
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, i;
  int Rs = 0;
  int Bs = 0;
  char s;
  char R ='R';
  char B ='B';
  cin >> N;
 while(cin >> s){
   if(s == R){
   Rs++;
   }
   if(s == B){
   Bs++;
   //cout << s << endl;
   }
 }
 
  if (Rs > Bs){
  cout << "Yes" <<endl;
  }
  else{
  cout << "No" << endl;
  }
}



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

#ifdef LOCAL
#include "../dump.hpp"
#else
#define dump(...)
#endif

#define rep(i,n) for(ll i=0,i##_cond=(n);i<i##_cond;++i)
#define FOR(i,a,b) for(ll i=(a),i##_cond=(b);i<i##_cond;++i)
#define ROF(i,a,b) for(ll i=(a)-1,i##_cond=(b);i>=i##_cond;--i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend() //sortで大きい順
#define UNIQUE(v) v.erase(unique(all(v)),v.end())
#define SUM(a) accumulate(all(a),0)
#define sz(x) ((ll)(x).size())
#define pb push_back
#define fst first
#define snd second
#define mp make_pair

typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<ll,ll> pii;

const ll inf = 1ll<<62;
const ll mod = 1e9+7;

#define int ll

main(){
  while(1){
    int n; cin >> n; if(n == 0) break;
    vi p(26);
    bool fa = true;
    vector<char> c(n); rep(i,n) cin >> c[i];
    rep(i,n){
      p[int(c[i] - 'A')]++;
      int f = 0, s = 0, pos;
      rep(j,26){
	if(f <= p[j]){
	  s = f;
	  pos = j;
	  f = p[j];
	}else if(s < p[j] and p[j] < f){
	  s = p[j];
	}
      }
      if(f > s + (n - 1 - i)){
	//dump(f,s,n-1-i);
	cout << char(pos + 'A') << " " << i + 1 << endl;
	fa = false;
	break;
      }
    }
    if(fa) cout << "TIE" << endl;
  }
}


Measured memory_bytes: 3080
//https://atcoder.jp/contests/arc067/tasks/arc067_b
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
#ifdef BTK
#define DEBUG if(1)
#else
#define CIN_ONLY if(1)
struct cww {cww() {CIN_ONLY{ios::sync_with_stdio(false); cin.tie(0);}}}star;
#define DEBUG if(0)
#endif
#define ALL(v) (v).begin(),(v).end()
#define REC(ret, ...) std::function<ret (__VA_ARGS__)>
template <typename T>inline bool chmin(T &l, T r){bool a = l>r; if (a)l = r; return a;}
template <typename T>inline bool chmax(T &l, T r){bool a = l<r; if (a)l = r; return a;}
template <typename T>istream& operator>>(istream &is, vector<T> &v){for (auto &it : v)is >> it;return is;}
class range {private: struct I { int x; int operator*() { return x; }bool operator!=(I& lhs) { return x<lhs.x; }void operator++() { ++x; } }; I i, n;public:range(int n) :i({ 0 }), n({ n }) {}range(int i, int n) :i({ i }), n({ n }) {}I& begin() { return i; }I& end() { return n; }};


int main(){
    int N;
    LL A,B;
    cin>>N>>A>>B;
    LL ret=0;
    LL pre=0;
    for(int i:range(N)){
        LL x;
        cin>>x;
        if(i){
            ret+=min((x-pre)*A,B);
        }
        pre=x;
    }
    cout<<ret<<endl;
    return 0;
}

Measured memory_bytes: 256
S = input()

if S[0] == 'A':
    S = S[1:]
    if S[1: -1].count('C') == 1:
        i = S[1: -1].index('C') + 1
        S = S[: i] + S[i + 1:]
        if S.islower():
            print('AC')
            exit()
print('WA')

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

int a[100005];
int dp[100005][2];

int main(){
  ios::sync_with_stdio(0); cin.tie(0), cout.tie(0);
  int n; cin >> n;
  for(int i = 1 ; i <= n ; i++){
    cin >> a[i];
  }
  dp[1][0] = dp[1][1] = 1;
  for(int i = 2 ; i <= n ; i++ ){
    if(a[i-1]>=a[i]) dp[i][0] = dp[i-1][0] + 1;
    else dp[i][0] = 1;
    if(a[i-1]<=a[i]) dp[i][1] = dp[i-1][1] + 1;
    else dp[i][1] = 1;
  }
  int i = n;
  int cnt = 0;
  while(i){
    int mx = max(dp[i][0],dp[i][1]);
    i -= mx;
    cnt++;
  }
  cout << cnt;
}


Measured memory_bytes: 1408
#include<stdio.h>
int main(){
  double r;
  double m, e;
  scanf("%lf",&r);
  m=3.141592653589*(double)r*(double)r;
  e=2*(double)r*3.141592653589;
  printf("%.6f %.6f\n",m, e);
  return 0;
}
  

Measured memory_bytes: 652
#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
void solve()
{
	string s;
	cin>>s;
	vector<ll> a(26,0);
	for(ll i=0;i<s.size();i++)
		a[s[i]-'a']++;
	for(ll i=0;i<26;i++)
	{
		if(a[i]==0)
		{
			cout<<char(i+'a');
			return;
		}
	}
	cout<<"None";
	return;
}


int main()
{
	fast;
	ll q;
	q=1;
	// cin>>q;
	while(q--)
	{
		solve();
	}
	return 0;
}


Measured memory_bytes: 3780
n = int(input())
ab = [[0] * 2 for _ in range(n)]
for i in range(n):
    a, b = map(int, input().split())
    ab[i][0], ab[i][1] = a, b
ab = sorted(ab, key=lambda x: x[1])
#print(ab)
time = 0
for task in ab:
    time += task[0]
    if time <= task[1]:
        #print(time, task[1])
        continue
    else:
        print('No')
        exit()
print('Yes')


Measured memory_bytes: 39704
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
const int inf = 1e9 + 7;
const ll INF = 1e18;
#define abs(x) (x >= 0 ? x : -(x))
#define lb(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define ub(v, x) (int)(upper_bound(all(v), x) - v.begin())
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template<typename T> T pow(T a, int b) { return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
const int mod = 1000000007;
ll modpow(ll a, int b) { return b ? modpow(a * a % mod, b / 2) * (b % 2 ? a : 1) % mod : 1; }
template<class T> ostream& operator<<(ostream& os, const vector<T>& vec) { for (auto &vi: vec) os << vi << " "; return os; }
template<class T, class U> ostream& operator<<(ostream& os, const pair<T, U>& p) { os << p.F << " " << p.S; return os; }
template<class T> inline void add(T &a, int b) { a += b; if (a >= mod) a -= mod; }



void solve();

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

    int T;
    // cin >> T;
    T = 1;

    while (T--) {
        solve();
    }
}

void solve() {
  int n;
  cin >> n;
  map<string, int> mp;
  rep(i, n) {
    string s;
    cin >> s;
    mp[s]++;
  }
  vector<string> v;
  int ma = 0;
  for (auto e : mp) if (chmax(ma, e.S));
  for (auto e : mp) if (e.S == ma) v.eb(e.F);
  sort(all(v));
  rep(i, sz(v)) cout << v[i] << endl;
}


Measured memory_bytes: 27120
#include <iostream>

using namespace std;

int main(void){
  int n;
  int q1[4], q2[4];
  
  while (cin >> n, n){
    for (int i=0; i<n; i++){
      for (int j=0; j<4; j++) cin >> q1[j];
      for (int j=0; j<4; j++) cin >> q2[j];
      cout << (q1[0]*q2[0] - q1[1]*q2[1] - q1[2]*q2[2] - q1[3]*q2[3]) << " "
      << (q1[0]*q2[1] + q1[1]*q2[0] + q1[2]*q2[3] - q1[3]*q2[2]) << " "
      << (q1[0]*q2[2] - q1[1]*q2[3] + q1[2]*q2[0] + q1[3]*q2[1]) << " "
      << (q1[0]*q2[3] + q1[1]*q2[2] - q1[2]*q2[1] + q1[3]*q2[0]) << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 3020
h,w=map(int,input().split())
s=list(input() for _ in range(h))
flag=1
for i in range(h):
    for j in range(w):
        check=0
        if s[i][j]=="#":
            if i!=0 and s[i-1][j]=="#":check +=1
            if i!=h-1 and s[i+1][j]=="#":check += 1
            if j!=0 and s[i][j-1]=="#":check += 1
            if j!=w-1 and s[i][j+1]=="#":check += 1
            if check==0:flag=0
print("Yes" if flag else "No")

Measured memory_bytes: 3064
// Problem : D - Redistribution
// Contest : AtCoder - AtCoder Beginner Contest 178
// URL : https://atcoder.jp/contests/abc178/tasks/abc178_d
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
#define fastio                      \
  ios_base::sync_with_stdio(false); \
  cin.tie(0);                       \
  cout.tie(0);

typedef long long ll;

const ll MOD = 1e9 + 7;

ll modulo(ll a, ll b, ll n) {
  ll x = 1, y = a;
  while (b > 0) {
    if (b % 2 == 1) {
      x = (x * y) % n;  // multiplying with base
    }
    y = (y * y) % n;  // squaring the base
    b /= 2;
  }
  return x % n;
}

using namespace std;

ll factorial[50001];

void pre() {
  factorial[0] = 1;
  for (ll i = 1; i <= 50000; i++) {
    factorial[i] = (factorial[i - 1] * i) % MOD;
  }
}

ll mod_inv(ll x) { return modulo(x, MOD - 2, MOD) % MOD; }

ll nCr(ll n, ll r) {
  if (n < r) return 0;
  ll ans = factorial[n];
  ans = ans * mod_inv((factorial[r] * factorial[n - r]) % MOD);
  ans = ans % MOD;
  return ans;
}

int32_t main() {
  ll s;
  cin >> s;
  ll ans = 0;
  pre();
  for (ll len = 1; len <= s / 3; len++) {
    ll sum = s - 3 * len;
    if (sum >= 0) ans = (ans + nCr((sum + len - 1), (len - 1))) % MOD;
  }

  cout << ans << '\n';
  return 0;
}


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

using pii = pair<int,int>;
using ll = long long;
#define rep(i, j) for(int i=0; i < (int)(j); i++)
#define repeat(i, j, k) for(int i = (j); i < (int)(k); i++)
#define all(v) v.begin(),v.end()
#define debug(x) cerr << #x << " : " << x << endl

template<class T> bool set_min(T &a, const T &b) { return a > b  ? a = b, true : false; }
template<class T> bool set_max(T &a, const T &b) { return a < b  ? a = b, true : false; }
// vector
template<class T> istream&
operator >> (istream &is , vector<T> &v) { for(T &a : v) is >> a; return is; }
template<class T> ostream&
operator << (ostream &os , const vector<T> &v) { for(const T &t : v) os << "\t" << t; return os << endl; }
// pair
template<class T, class U> ostream&
operator << (ostream &os , const pair<T, U> &v) { return os << "<" << v.first << ", " << v.second << ">"; }

const int INF = 1 << 30;
const ll INFL = 1LL << 60;

vector<ll> generate_primes(ll N) {
    vector<int> is_prime(N, 1);
    vector<ll> primes;
    repeat(i, 2, N) {
        if(not is_prime[i]) continue;
        primes.push_back(i);
        for(ll j = i * 2; j < is_prime.size(); j += i) is_prime[j] = 0;        
    }
    return primes;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    auto primes = generate_primes(pow(1e10, 1.0/3.0)+10);
    set<ll> primes2;    
    for(ll p : generate_primes(sqrt(1e10) + 10)) primes2.insert(p*p);
    
    int N; cin >> N;
    vector<ll> S(N); cin >> S;

    map<ll, int> normalized_s;

    auto normalize = [&] (ll s) {
        for(ll p : primes) {
            ll ppp = p * p * p;
            while(s % ppp == 0) s /= ppp;            
            if(s == 1) break;
        }
        return s;
    };
    
    for(ll s : S) {
        normalized_s[normalize(s)]++;
    }
    
    int ans = 0;
    set<ll> used;
    for(auto s_ : normalized_s) {
        ll s = s_.first;
        if(used.count(s)) continue;
        
        ll t = normalize(s * s);
        used.insert(s);
        used.insert(t);
        
        int s_cnt = s_.second;
        int t_cnt = normalized_s.count(t) ? normalized_s[t] : 0;
        
        ans += s == t ? 1 : max(s_cnt, t_cnt);
    }
    cout << ans << endl;
    
    return 0;
}


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

using ll = long long;
using G = vector<vector<int>>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const ll MOD = 1000000007;

ll GCD(ll x, ll y){
	return y ? GCD(y, x%y) : x;	
}

int main() {
	int n, m, x, y; cin >> n >> m >> x >> y;
	int x_max = x;
	int y_min = y;
	for(int i=0;i<n;i++){
		int a; cin >> a;
		x_max = max(x_max, a);
	}
	for(int i=0;i<m;i++){
		 int b; cin >> b;
		 y_min = min(y_min, b);
	}
	if(x_max<y_min){
		cout << "No War" << endl;
		return 0;
	}
	cout << "War" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
typedef long long ll;
const ll inf = 1e10;
int main(){
    ll n, m, l;
    cin >> n >> m >> l;
    vector<vector<ll> > d(n, vector<ll>(n, inf)), td(n, vector<ll>(n, inf));
    rep(i,m){
        ll a, b, c;
        cin >> a >> b >> c;
        a--; b--;
        d[a][b] = d[b][a] = c;
    }
    rep(k,n)rep(i,n)rep(j,n)d[i][j] = min(d[i][j], d[k][j] + d[i][k]);
    
    rep(i,n)rep(j,n)if(d[i][j] <= l)td[i][j] = 1;
    rep(k,n)rep(i,n)rep(j,n)td[i][j] = min(td[i][j], td[k][j] + td[i][k]);
    ll q; cin >> q;
    rep(i,q){
        ll s, t;
        cin >> s >> t;
        s--; t--;
        cout << ((td[s][t] == inf)?-1:td[s][t]-1) << endl;
    }
    return 0;
}

Measured memory_bytes: 1920
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <sstream>
#include <iomanip>
#include <set>
#include <queue>
#include <stack>
#include <utility>
#include <stdio.h>
#include <unistd.h>
using namespace std;
typedef long long int ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define drep(i, n) for(int i = n - 1; i >= 0; i--)
#define itrep(itr, base) for (auto itr = base.begin(); itr != base.end(); itr++)
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define yes cout << "yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
#define no cout << "no" << endl
#define PI 3.14159265359

const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;
const int mod = 1000000007;

void P(int x) {cout << x << endl;}
void P(long x) {cout << x << endl;}
void P(double x) {cout << x << endl;}
void P(ll x) {cout << x << endl;}
void P(string x) {cout << x << endl;}
void P(char x) {cout << x << endl;}

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

int main() {
  int h[2], m[2], k;
  cin >>  h[0] >> m[0] >> h[1] >> m[1] >> k;
  int up   = h[0] * 60 + m[0];
  int down = h[1] * 60 + m[1];
  if (down - up - k < 0) {
    P(0);
  } else {
    P(down - up - k);
  }
  return 0;
}


Measured memory_bytes: 3648
#include <iostream>
#include <algorithm>
int A[210000];
using namespace std;

int main(){
   int N;
   //scanf("%d",&N);
   cin >> N;
   for(int i=0;i<N;i++)cin >> A[i];
   sort(A,A+N);
   for(int i=0;i<N-1;i++){
     if(A[i]==A[i+1]){
       printf("NO\n");return 0;
     }
   }

   printf("YES\n");

  return 0;
}


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

int key[7];

void N(){
	int change = key[1];
	key[1] = key[2];
	key[2] = key[6];
	key[6] = key[5];
	key[5] = change;
}

void S(){
	int change = key[1];
	key[1] = key[5];
	key[5] = key[6];
	key[6] = key[2];
	key[2] = change;
}

void W(){
	int change = key[1];
	key[1] = key[3];
	key[3] = key[6];
	key[6] = key[4];
	key[4] = change;
}

void E(){
	int change = key[1];
	key[1] = key[4];
	key[4] = key[6];
	key[6] = key[3];
	key[3] = change;
}

int main(void){
	int i;
	char str[105];
	
	for(i=0;i<6;i++){
		scanf("%d", &key[i+1]);
	}
	
	scanf("%s", str);
	
	for(i=0;i<strlen(str);i++){
		if(str[i] == 'N'){
			N();
		}else if(str[i] == 'S'){
			S();
		}else if(str[i] == 'W'){
			W();
		}else if(str[i] == 'E'){
			E();
		}
	}
	
	printf("%d\n", key[1]);
	
	return 0;
	
}


Measured memory_bytes: 2124
import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;

class Main {
	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner(System.in);
		String S = sc.next();

		String reversed = new StringBuilder(S).reverse().toString();
		String[] values = new String[] { "remaerd", "maerd", "resare", "esare", };

		int position = 0;
		while (position < S.length()) {
			String current = reversed.substring(position, Math.min(position + 7, S.length()));

			boolean matched = false;
			for (String value : values) {
				if (current.startsWith(value)) {
					matched = true;
					position += value.length();
					break;
				}
			}

			if (!matched) {
				// debug(current);
				System.out.println("NO");
				return;
			}
		}

		System.out.println("YES");
	}

	private static boolean isDebug = System.getProperty("sun.desktop") != null;

	private static void debug(Object... o) {
		if (isDebug) {
			System.err.println(Arrays.deepToString(o));
		}
	}

	public static class Scanner {
		private BufferedInputStream inputStream;

		public Scanner(InputStream in) {
			inputStream = new BufferedInputStream(in);
		}

		public int nextInt() throws IOException {
			int num = 0;

			int read = skip();
			do {
				num = num * 10 + (read - 0x30);
			} while ((read = inputStream.read()) > 0x20);

			return num;
		}

		public void fill(int[] a) throws IOException {
			for (int i = 0; i < a.length; i++) {
				a[i] = nextInt();
			}
		}

		public void fill(int[] a, int[] b) throws IOException {
			if (a.length != b.length) {
				throw new IllegalArgumentException();
			}

			for (int i = 0; i < a.length; i++) {
				a[i] = nextInt();
				b[i] = nextInt();
			}
		}

		public long nextLong() throws IOException {
			long num = 0;

			int read = skip();
			do {
				num = num * 10 + (read - 0x30);
			} while ((read = inputStream.read()) > 0x20);

			return num;
		}

		public void fill(long[] a) throws IOException {
			for (int i = 0; i < a.length; i++) {
				a[i] = nextLong();
			}
		}

		public void fill(long[] a, long[] b) throws IOException {
			if (a.length != b.length) {
				throw new IllegalArgumentException();
			}

			for (int i = 0; i < a.length; i++) {
				a[i] = nextLong();
				b[i] = nextLong();
			}
		}

		public long[] nextLong(int n) throws IOException {
			long[] array = new long[n];
			for (int i = 0; i < n; i++) {
				array[i] = nextLong();
			}

			return array;
		}

		public String next() throws IOException {
			StringBuilder builder = new StringBuilder();

			int read = skip();
			do {
				builder.append((char) read);
			} while ((read = inputStream.read()) > 0x20);

			return builder.toString();
		}

		private int skip() throws IOException {
			int read;
			while ((read = inputStream.read()) <= 0x20)
				;

			return read;
		}
	}
}


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

int main(){
	string a, b;
	int x, i = 0;
	cin >> a >> b;
	while((x = a.find(b, i)) != -1){
		cout << x << '\n';
		i = x + 1;
	}
	return 0;
}

Measured memory_bytes: 3916
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    divisors.sort(reverse=True)
    return divisors

def main():
    N, M = map(int, input().split())
    d = make_divisors(M)
    for i in d:
        if M // i >= N:
            return i
print(main())


Measured memory_bytes: 3060
import java.util.Scanner;
public class Main {
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        while(sc.hasNext()){
            double x1=sc.nextDouble();
            double y1=sc.nextDouble();
            double x2=sc.nextDouble();
            double y2=sc.nextDouble();
            double x3=sc.nextDouble();
            double y3=sc.nextDouble();
            double x4=sc.nextDouble();
            double y4=sc.nextDouble();  
            System.out.println(Math.abs((x2-x1)*(x4-x3)+(y2-y1)*(y4-y3))<1e-10?"YES":"NO");
        }
    }
}

Measured memory_bytes: 30444
N, X = map(int, input().split())

a = [1]  # レベルiバーガーの長さ
p = [1]  # レベルiバーガーに含まれるパティの数
for i in range(N):
    a.append(2 * a[-1] + 3)
    p.append(2 * p[-1] + 1)


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

    elif X <= 1 + a[N - 1]:
        return f(N - 1, X - 1)

    else:
        return p[N - 1] + 1 + f(N - 1, X - 2 - a[N - 1])


print(f(N, X))


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <math.h>

#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define repP(i, a, b) for(int i = a; i < b; i++)
#define repM(i, a, b) for(int i = a - 1; i >= b; i--)

using namespace std;

int main()
{
  long a = 0 , b = 0, c = 0, d = 0, e = 0, f = 0, i = 0, j = 0;
  long sum = 1, num = 1, count = 0, ans = 0, min = 0, max = 0;
  double d1 = 0, d2 = 0, d3 = 0, d4 = 0, d5 = 0, d6 = 0;
  int a1[999999], a2[999999], a3[999999];
  //char s1[200000], s2[200000], s3[200000];
  //string s1, s2, s3;
  cin>>a;
  for(i=0;i<a;i++){
    cin>>a1[i];
    if(a1[i] != sum){
      count++;
    }else{
      sum++;
    }
  }
  if(count == a){
    cout<<-1<<endl;
  }else{
    cout<<count<<endl;
  }
}

Measured memory_bytes: 3072
def gcd(a,b):
    if b==0:
        return a
    return gcd(b,a%b)

A,B = map(int,input().split())

def count_(upper_num):
    data = [2] + list(range(3,upper_num+1,2))
    idx = 0
    length = len(data)
    while idx < length:
        prime = data[idx]
        data = [d for d in data if (d==prime or d % prime != 0)]
        idx += 1
        length = len(data)
    
    return data

def make_divisors(n):
    divisors = [1]
    i = 2 
    max_int = int(n**0.5)+1
    while n >1:
#         print(n)
        if i >= max_int:
#             print("max")
            divisors.append(n)
            break
        # nを合う数字で割り切れたら、その割った数と商をリストに追加する。
        # nが平方数のとき、同じ数字が2回追加されてしまうので3行したのif文がある
        if n % i == 0:
            divisors.append(i)
            max_int = int((n//i)**0.5)+1
            while n%i == 0:
                n = n//i
                
        i += 1

    divisors = list(set(divisors))
#     divisors.sort()
    return divisors

print(len(make_divisors(gcd(A,B))))

Measured memory_bytes: 38640
import java.util.Scanner;
 
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        
        int N = sc.nextInt();
        
        if(N < 15){
            System.out.println(N*800);
        }else if(N >= 15){
            System.out.println(N*800 - (N/15)*200);
        }
    }
}


Measured memory_bytes: 21844
#include<iostream>
#include<set>
#include <bitset>
#include<queue>
#include<vector>
#include<map>
#include<stack>
#include <cstdio>
#include<algorithm>
#include <sstream>
#include<string>
#include<string.h>
#include <cmath>
#include <iomanip>
#include <string>
#include<list>
#include <limits>
#include <numeric>
#include <type_traits>
#define int long long
#define ll long long
#define mod  1000000007
#define inf 1e17
#define rep(i,j,n) for(int i=j;i<n;i++)
double pi = 3.141592653589793;
using namespace std;
//ここから始めよう
signed main(){
    string s,t;cin>>s>>t;
    int n=s.size();
    s+=s;
    bool ans=0;
    rep(i,0,n){
        bool c=1;
        rep(j,0,n){
            if(s[i+j]!=t[j])c=0;
        }
        if(c)ans=1;
    }
    if(ans)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>

using namespace std;
int main()
{
    int n;
    cin >> n;
    if(n>=65&&n<=90){
        cout << "1" << endl;
    }else if(n>=97&&n<=122){
        cout << "2" << endl;
    }else{
        cout << "0" << endl;
    }
    return 0;
}



Measured memory_bytes: 3100
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<unordered_map>
#include<array>
#include<map>
#include<iomanip>
//<< setprecision(5)
using namespace std;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
#define dme cout<<-1<<endl;return 0
const int mod=1000000007;
const int big=1e9;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-7;
template <class T,class U>void mineq(T& a,U b){if(a>b){a=b;}}
template <class T,class U>void maxeq(T& a,U b){if(a<b){a=b;}}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){return a/gcd(a,b)*b;}
int main(void){
	int ans=1,ue=1,st=1,mae,ima,n;
	cin>>n>>mae;
	for(int i=0;i<n-1;i++){
		cin>>ima;
		if(mae==ima){continue;}
		if(mae<ima){//???
			ue++;
			st=1;
			maxeq(ans,ue);
		}else{
			st++;
			ue=1;
			maxeq(ans,st);
		}
		mae=ima;
	}
	cout<<ans<<endl;
	return 0;
}

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

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

  vector<int> a(100001);
  vector<int> p6(6);
  vector<int> p9(5);
  for(int i=0;i<6;i++) p6[i]=int(pow(6,i+1));
  for(int i=0;i<5;i++) p9[i]=int(pow(9,i+1));

  for(int i=0;i<=N;i++) a[i]=i;
  for(int i=1;i<=N;i++){
    for(int j=0;j<6;j++){
      if(i>=p6[j]) a[i]=min(a[i-p6[j]]+1,a[i]);
    }
    for(int j=0;j<5;j++){
      if(i>=p9[j]) a[i]=min(a[i-p9[j]]+1,a[i]);
    }

  }
  cout<<a[N]<<endl;
}


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

int main() {
  int A[3];
  rep(i,3) cin >> A[i];
  if (A[0] + A[1] + A[2] >= 22) {
    cout << "bust";
  } else {
    cout << "win";
  }
}


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

#define int long long
#define REP(i, l, r) for (int i=(l); i<(r); ++i)
#define RREP(i, r, l) for (int i=(r); i>(l); --i)
#define vi vector<int>
#define vb vector<bool>
#define pii pair<int,int>
#define tiii tuple<int,int,int>
#define tiiii tuple<int,int,int,int>
#define popcount __builtin_popcountll

const int INF = 1LL<<60;
const int MOD = 1000000007;

template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
string to_string(string s) {return s;}
template <typename A, typename B>
string to_string(pair<A, B> p) {return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";}
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> t) {return "(" + to_string(get<0>(t)) + ", " + to_string(get<1>(t)) + ", " + to_string(get<2>(t)) + ")";}
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> t) { return "(" + to_string(get<0>(t)) + ", " + to_string(get<1>(t)) + ", " + to_string(get<2>(t)) + ", " + to_string(get<3>(t)) + ")";}
template <typename A>
string to_string(vector<A> v) {
    bool first = true;
    string result = "[";
    for (A i : v) {
        if (!first) result += ", ";
        first = false;
        result += to_string(i); 
    }
    return result + "]";
}

string bin_string(int x) {
    const int d = 32;
    string result(d, ' ');
    RREP(i, d-1, -1) result[d-1-i] = '0'+((x&1LL<<i)!=0);
    return result;
}

int powa(int base, int exp) {
    int res = 1;
    while (exp) {
        if (exp&1) res = res*base % MOD;
        base = base*base % MOD;
        exp >>= 1;
    }
    return res;
}

vector<vi> nodes;
void dfs(vi &arr, vi &par, int u, int p=-1, int cnt=0) {
    arr[u] = cnt;
    par[u] = p;
    for (int v : nodes[u]) if (v != p) {
        dfs(arr, par, v, u, cnt+1);
    }
}

main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    
    int n, u, v;
    cin >> n >> u >> v;
    --u; --v;
    nodes.resize(n);
    REP(i, 0, n-1) {
        int a,b;
        cin >> a >> b;
        --a; --b;
        nodes[a].push_back(b);
        nodes[b].push_back(a);
    }

    vi fu(n), fv(n), pu(n), pv(n);
    dfs(fu, pu, u);
    dfs(fv, pv, v);
    if (fv[u]==1) cout << 0;
    else {
        int res = 0;
        while (pu[v] != u && pu[v] != pv[u]) {
            u=pv[u];
            v=pu[v];
            ++res;
        }
        if (pu[v] != u) ++res;
        fu.assign(n, 0);
        dfs(fu, pu, u, pv[u]);
        int best = 0;
        REP(i, 0, n) best = max(best, fu[i]);
        res += best;
        cout << res;
    }
}


Measured memory_bytes: 15488
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
using namespace std;

typedef long long ll;

int main() {
  int N,K; cin >> N >> K;
  vector<int> h(N);
  for ( int i = 0; i < N; i++ ) cin >> h[i];
  sort(h.begin(),h.end());
  int ans = 1000000000;
  for ( int i = 0; i+K-1 < N; i++ ) {
    ans = min(h[i+K-1] - h[i],ans);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 640
#include <algorithm>
#include <string>
#include <iostream>
#include <sstream>

using namespace std;

int main()
{
	const int SIZE = 3;
	int numbers[SIZE];
	
	for(auto& i : numbers)
		cin >> i;

	sort(numbers, numbers+SIZE);

	stringstream formatter;
	for(auto i : numbers)
		formatter << i << " ";
	
	string result = formatter.str();
	result.erase(result.length() - 1);

	cout << result << endl;

	return 0;
}

Measured memory_bytes: 1232
#include<bits/stdc++.h>
#include<cmath>
#define SZ(x) ((int)x.size())
#include<vector>
#include<set>
#include<map>
#define ll long long
#define REP(i,a,b) for(ll i=a;i<b;i++)
#define pb push_back
#include<string>
#include<cctype>
#include<queue>
#define ii pair<int,int>
#include <sstream>
#define lli long long int
#define pairs pair<int,int>
#define mod 1000000007
const double PI = 3.141592653589793238460;
typedef std::complex<double> Complex;
typedef std::valarray<Complex> CArray;
using namespace std;
ll pows(ll a,ll n,ll m)
{
	ll res=1;
	while(n)
	{
	if(n%2!=0)
	{
		res=(res*a)%m;
		n--;
		}
		else
		{
			a=(a*a)%m;
			n=n/2;
			}	
	}
	return res%m;
}
ll  gcd(ll a,ll b)
{
	if(b==0)
	return a;
	else 
	return gcd(b,a%b);
}
bool isprime(ll n)
{
	if(n==1)
	{
		return false;
	}
	for(ll i=2;i*i<=n;i++)
	{
		if(n%i==0)
		{
			return false;
		}
	}
	return true;
}
bool istrue(string s)
{
	int i=0;
	int j=s.size()-1;
	while(i<j)
	{
	if(s[i]==s[j])
	{
		i++;
		j--;
		}
		else
		{
			return false;
			}	
	}
	return true;
}
int main()
{
   ios::sync_with_stdio(false);
	 cin.tie(0);
    cout.tie(0);
 ll a;
    double b;
    cin >> a >> b;
 
    ll tmp = b * 100 + 0.5;
 
    ll ans = (a * tmp) / 100;
 
    cout << ans << endl;
 
}
 


Measured memory_bytes: 3648
#!/usr/bin/env python3
import bisect
import collections
import sys

sys.setrecursionlimit(1000000)
ACMOD = 1000000007
INF = 1 << 62


def solve(N: int, A: "List[int]"):
    if N == 0:
        if A[0] == 1:
            print(1)
        else:
            print(-1)
        return
        
    ans = 2 ** (N + 1) - 1
    len_list = []
    current_len = 1
    for depth, leafs in enumerate(A):
        ans -= leafs * (2 ** (N - depth + 1) - 2)
        len_list.append(current_len - leafs)
        current_len = (current_len - leafs) * 2
    last_leaf = len_list[-1]
    if last_leaf < 0:
        print(-1)
        return
    must_delete = last_leaf
    # print(must_delete)
    for _depth, x in enumerate(len_list[::-1]):
        depth = N - _depth
        leaf = A[depth]
        if must_delete <= (x + leaf) // 2:
            ans -= must_delete
            if ans > 0:
                print(ans)
            else:
                print(-1)
            return
        ans -= must_delete
        must_delete -= (x + leaf) // 2
    print(-1)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word

    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N - 0 + 1)]  # type: "List[int]"
    solve(N, A)


if __name__ == '__main__':
    main()


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

#define pb push_back

using ll=long long;
using vll=vector<ll>;
using vvll=vector<vll>;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int,int>;
using vpii=vector<pii>;
using vvpii=vector<vpii>;


bool dfs(const vvi& g, int par, int v, vi& vis, vi& outdeg, vvi& dg) {
    //cerr << "DBG vis " << v << endl;
    vis[v] = 1;
    for (int w: g[v]) {
        if (w == par || vis[w] == 2)
            continue;
        if (vis[w] == 1) {
            ++outdeg[v];
            dg[v].pb(w);
        }
        else {
            bool tmp = dfs(g, v, w, vis, outdeg, dg);
            assert(tmp);
        }
    }
    if (outdeg[v]%2 == 1) {
        if (par < 0)
            return false;
        ++outdeg[v];
        dg[v].pb(par);
    }
    else if (par >= 0) {
        ++outdeg[par];
        dg[par].pb(v);
    }
    vis[v] = 2;
    return true;
}

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

    int n, m;
    cin >> n >> m;
    vvi g(n);
    for (int i=0; i<m; ++i) {
        int a, b;
        cin >> a >> b;
        --a; --b;
        g[a].pb(b);
        g[b].pb(a);
    }

    vi outdeg(n,0);
    vvi dg(n);
    vi vis(n,0);
    int res = dfs(g, -1, 0, vis, outdeg, dg);
    int arccnt = 0;
    for (int i=0; i<n; ++i) {
        assert(outdeg[i] == dg[i].size());
        if (res)
            assert(outdeg[i]%2 == 0);
        arccnt += outdeg[i];
    }
    assert(arccnt == m);
    if (!res)
        cout << "-1\n";
    else {
        for (int i=0; i<n; ++i) {
            for (int v: dg[i])
                cout << i+1 << " " << v+1 << "\n";
        }
    }
}


Measured memory_bytes: 20992
import math

N = int(input())

input_line = input()
Line1 = input_line.split()
Line1 = [int(s) for s in Line1]

input_line = input()
Line2 = input_line.split()
Line2 = [int(s) for s in Line2]

Line1_count = 1
Line2_count = 1

Line1_base = []
Line2_base = []

for z in range(N):
    Line1_base.append(z+1)
    Line2_base.append(z+1)

# print (Line1_base)

for i in range(N):
    q = i+1
    # print("s",i,q)
    # print(Line1[i])
    # print(Line1_base.index(Line1[i]),math.factorial(N-q))

    Line1_count += math.factorial(N-q)*Line1_base.index(Line1[i])
    Line2_count += math.factorial(N-q)*Line2_base.index(Line2[i])
    Line1_base.remove(Line1[i])
    Line2_base.remove(Line2[i])
    # print(Line1_base)
    
    # print(Line1_count)
    # print(Line2_count)
print(abs(Line2_count - Line1_count))

Measured memory_bytes: 3064
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bits/stdc++.h>
#include<cmath>
#include<bitset>
#define ll long long
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,0,n)
#define SORT(V) sort((V).begin(),(V).end())
#define INF ((1LL<<62)-(1LL<<31))
#define MOD 1000000007
using namespace std;

int main(){
  int N;
  cin>>N;
  ll L[87];
  L[0]=2;
  L[1]=1;
  for(int i=2; i<87; ++i){
    L[i]=L[i-1]+L[i-2];
  }
  cout<<L[N]<<endl;
}

Measured memory_bytes: 256
//In the Name of ̲A̲l̲l̲a̲h̲

#include <bits/stdc++.h>

using namespace std;

int n, u, v, m;
vector <int> adj[100001] ;
bool mark[100001] ;
int mxPath[100001] , mxDepth[100001] ;
void DFS(int v)
{
    mark[v] = 1 ;
    if (!adj[v].size())
        return;
    int mx1 = 0;
    int mx3 = 0;
    int mx2 = 0;
    for (int u:adj[v])
    {
        if (!mark[u])
        {
            DFS(u);
        }
        if ( mx1 < mxDepth[u]+1)
        {
            mx1 = mxDepth[u]+1 ;
        }
        if (mx3 < mxPath[u])
        {
            mx3 = mxPath[u] ;
        }

    }
    if (adj[v].size() == 0)
        return ;
    mxPath[v] = max(mx1, mx3) ;
    mxDepth[v] = mx1 ;
}
int main()
{
	ios_base::sync_with_stdio(0);
	cin >> n >> m;
	for (int i = 0 ; i < m ; i++)
    {
        cin >> u >> v;
        adj[u].push_back(v) ;
    }
    int ans = 0;
    for (int i = 1; i <= n; i++)
    {
        if (!mark[i])
        {
            DFS(i);
        }
        if (mxPath[i] > ans)
            ans = mxPath[i];
    }
    cout << ans ;
}


/*𝐻𝒶𝒹𝒾*/


Measured memory_bytes: 9344
import java.util.*

fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val aList = readLine()!!.split(' ').map(String::toLong).sorted().toMutableList()

    val pat = aList.toSet().size
    if (pat == 1) {
        println(aList[0] * (n - 2))
        while (true) {
            if (aList.size != 2) {
                println("${aList[aList.size - 1]} ${aList[aList.size - 2]}")
                val diff = aList[aList.size - 1] - aList[aList.size - 2]
                aList.removeAt(aList.size - 1)
                aList.removeAt(aList.size - 1)
                aList.add(diff)
            } else {
                println("${aList[aList.size - 2]} ${aList[aList.size - 1]}")
                return
            }
        }
    }

    val allP = aList.all { it >= 0 }
    val allM = aList.all { it <= 0 }
    val pQueue = PriorityQueue<Long>()
    val mQueue = PriorityQueue<Long>()
    var l = 0L
    var r = 0L
    if (allP) {
        val temp = aList.first() - aList.last()
        l = aList.removeAt(0)
        r = aList.removeAt(aList.size - 1)
        aList.add(temp)
    }
    if (allM) {
        val temp = aList.last() - aList.first()
        l = aList.removeAt(aList.size - 1)
        r = aList.removeAt(0)
        aList.add(temp)
    }

    println(aList.map { Math.abs(it) }.sum())
    if(allP || allM)println("$l $r")
    aList.forEach {
        if (it > 0) pQueue.add(it)
        else if (it <= 0) mQueue.add(it)
    }
    while (true) {
        if (pQueue.size == 1 && mQueue.size == 1) {
            println("${pQueue.poll()} ${mQueue.poll()}")
            return
        } else {
            val p = pQueue.poll()
            val m = mQueue.poll()
            if (pQueue.size == 0) {
                println("$p $m")
                pQueue.add(p - m)
            } else {
                println("$m $p")
                mQueue.add(m - p)
            }
        }
    }
}

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

const int mod = 998244353;
long long int fac[5000001],inv[5000001],cnt[5000001];

long long int C(int n,int k){
	return fac[n]*inv[k]%mod*inv[n-k]%mod;
}

long long int solve(int n,int m,int k){
	long long int res = 0;
	for(int i=0;i<=k;i++)
		if(n-i>=0&&(n-i)%2==0&&m>=i)
			res += C((n-i)/2+m-1,m-1) * C(m,i) % mod;
	return res % mod;
}

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	fac[0]=fac[1]=inv[0]=inv[1]=1;
	for(int i=2;i<=5000000;i++){
		fac[i]=fac[i-1]*i%mod;
		inv[i]=mod-mod/i*inv[mod%i]%mod;
	}
	for(int i=2;i<=1000000;i++)
		inv[i]=inv[i-1]*inv[i]%mod;
	int n,m;
	cin>>n>>m;
	long long int ans = solve(3*m,n,m) - (solve(m,n,m) - solve(m,n-1,m)) * n;
	cout<<(ans%mod+mod)%mod<<endl;
}


Measured memory_bytes: 78592
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define fi first
#define se second
long long mo = 1e9 + 7;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<class A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}cout << "\n";}
ld PI=3.14159265358979323846;

int main(){
    ll N;
    cin >> N;
    vector<ll> A(N);
    rep(i,N){
        cin >> A[i];
    }
    ll sum = 0;
    ll ans = 0;
    for(ll l=0, r=0;l<N;l++){
        if(l>r)r=l;
        while(r<N && sum + A[r] == (sum ^ A[r])){
            sum += A[r];
            r++;
        }
        //cout << ans << endl;
        ans += (r-l);
        if(l<r){
            sum -= A[l];
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 4808
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INF INT_MAX // 2147483647
#define INFLL LLONG_MAX // 9223372036854775807
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define per(i, n) for(ll i=((ll)(n))-1; i>=0; i--)
#define perf(i, n) for(ll i=((ll)(n)); i>0; i--)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
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; }
using namespace std;

int main(){
    Init();
    ll n; cin >> n;
    ll cnt = 0;

    rep(i, n){
        ll a; cin >> a;
        while(a%2 == 0){
            cnt++;
            a /= 2;
        }
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256