akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define len(v) ll(v.size())
#define fi first
#define se second

template <class T>
void cout_vec(const vector<T> &vec){
  for(auto itr:vec) cout<<itr<<' ';
  cout<<endl;
}

template <class T>
void cout_vec2(const vector<vector<T>> &vec){
  rep(i,vec.size()){
    rep(j,vec[i].size()){
      cout<<vec[i][j]<<' ';
    }
    cout<<endl;
  }
}

typedef pair<ll,ll> P;
const ll mod=1e9+7;
const ll inf=1e15;

template <class T>
vector<P> divisor(T x){
	vector<P> res;
	for(T i=1;i*i<=x;i++){
		if(x%i==0){
			res.push_back(P(i,x/i));
		}
	}
	return res;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n;
  cin>>n;
  vector<P> ret=divisor(n);
  ll ans=1e18;
  for(auto itr:ret){
    //cout<<itr.fi<<' '<<itr.se<<endl;
    ans=min(ans,abs(itr.fi-1)+abs(itr.se-1));
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define forr(i, a, b) for(int i = (a); i < (int) (b); i++)
#define forn(i, n) forr(i, 0, n)
#define dforr(i, a, b) for(int i = (int)(b-1); i >= (a); i--)
#define dforn(i, n) dforr(i, 0, n)
#define db(v) cerr << #v << " = " << v << endl
#define pb push_back
#define sz(x) ((int)x.size())
#define ff first
#define ss second
typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
const int MAXN = 200500;

int n;
ll L, X[MAXN];

ll S[MAXN], AP[MAXN], D[MAXN];
ll I1[MAXN], P1[MAXN];
ll I2[MAXN], P2[MAXN];

void solve(ll I[], ll P[]){
    S[0] = 0; forr(i, 1, n+1)S[i] = S[i-1] + X[i-1], D[i] = X[i-1];
    I[0] = P[0] = AP[0] = 0;
    forr(i, 1, n+1){
        I[i] = I[i-1] + 2*S[i-1] + D[i];
        AP[i] = P[i] = AP[i-1] + 2*S[i-1] + 2*D[i];
    }
    forr(i, 1, n+1){
        if(i > n-i+1){
            int d = i-(n-i+1);
            I[i] -= AP[d];
        }
        if(i > n-i){
            int d = i-(n-i);
            P[i] -= AP[d];
        }
    }
//    printf("Para X:\n");
//    forn(i, n)printf("%lld ", X[i]); puts("");
//    printf("S:"); forn(i, n+1)printf(" %lld", S[i]); puts("");
//    printf("AP:"); forn(i, n+1)printf(" %lld", AP[i]); puts("");
//    printf("I:"); forn(i, n+1)printf(" %lld", I[i]); puts("");
//    printf("P:"); forn(i, n+1)printf(" %lld", P[i]); puts("");
}

int main(){
//	freopen("input.txt", "r", stdin);
	while(scanf("%lld %d", &L, &n) >= 1){
        forn(i, n)scanf("%lld", &X[i]); X[n] = L;
        dforr(i, 1, n+1)X[i] = X[i] - X[i-1];
        solve(I1, P1);
        reverse(X, X + (n+1));
        solve(I2, P2);
        ll ans = 0;
        forn(i, n){
            ans = max(ans, P1[i] + I2[n-i]);
            ans = max(ans, P2[i] + I1[n-i]);
        }
        printf("%lld\n", ans);
    }
	return 0;
}


Measured memory_bytes: 12800
import sys
class Node:
    __slots__ = ['key', 'left', 'right']
    def __init__(self, key):
        self.key = key
        self.left = self.right = None

root = None

def find(target):
    result = root
    while result and target != result.key:
        result = result.left if target < result.key else result.right
    if result is None:
        return False
    else:
        return True

def insert(key):
    global root
    y = None  # xの親
    x = root
    while x:
        y = x
        x = x.left if key < x.key else x.right
    if y is None:  # Tが空の場合
        root = Node(key)
    elif key < y.key:
        y.left = Node(key)
    else:
        y.right = Node(key)

def in_order(node):
    if node is None:
        return ''
    return in_order(node.left) + f' {node.key}' + in_order(node.right)
def pre_order(node):
    if node is None:
        return ''
    return f' {node.key}' + pre_order(node.left) + pre_order(node.right)
input()
for e in sys.stdin:
    if e[0] == 'i':
        insert(int(e[7:]))
    elif e[0] == 'f':
        print('yes' if find(int(e[5:])) else 'no')
    else:
        print(in_order(root))
        print(pre_order(root))


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define REP(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, a, b) for(int i=(a); i<(b); ++i)
#define FORR(i, a, b) for(int i=(b)-1; i>=(a); --i)

#define DEBUG(x) cout<<#x<<": "<<(x)<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

template<typename T> inline void CHMAX(T& a, const T b) {if(a<b) a=b;}
template<typename T> inline void CHMIN(T& a, const T b) {if(a>b) a=b;}

constexpr ll MOD=1000000007ll;
// constexpr ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-9;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

int numa[252521], numb[252521];
int rana[252521][2], ranb[252521][2];

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  // cout<<setprecision(10)<<fixed;
  int n, a[252521], b[252521];
  cin>>n;
  REP(i, n){
    cin>>a[i];
    ++numa[a[i]];
  }
  REP(i, n){
    cin>>b[i];
    ++numb[b[i]];
  }
  FOR(i, 1, n+1){
    if(numa[i]>n-numb[i]){
      cout<<"No"<<'\n';
      return 0;
    }
  }
  FOR(i, 1, n+1){
    rana[i][0]=rana[i][1]=-1;
    ranb[i][0]=ranb[i][1]=-1;
  }
  REP(i, n){
    if(rana[a[i]][0]==-1){
      rana[a[i]][0]=i;
      rana[a[i]][1]=i;
    }
    else{
      rana[a[i]][1]=i;
    }
  }
  REP(i, n){
    if(ranb[b[i]][0]==-1){
      ranb[b[i]][0]=i;
      ranb[b[i]][1]=i;
    }
    else{
      ranb[b[i]][1]=i;
    }
  }
  int ma=0;
  REP(i, n){
    if(!numb[a[i]]){
      continue;
    }
    if(ranb[a[i]][0]<=rana[a[i]][1]){
      CHMAX(ma, rana[a[i]][1]-ranb[a[i]][0]+1);
      // DEBUG(rana[a[i]][1]-ranb[a[i]][0]);
    }
  }
  rotate(b, b+n-ma, b+n);
  cout<<"Yes"<<'\n';
  REP(i, n){
    cout<<b[i]<<" \n"[i==n-1];
  }
  return 0;
}


Measured memory_bytes: 9884
e=input()
a=e[0]
b=e[1]
c=e[2]
d=e[3]
t=0

for x1 in ["+","-"]:
    for x2 in ["+","-"]:
        for x3 in ["+","-"]:
            if eval(a+x1+b+x2+c+x3+d)==7:
                t=1
            if t==1:
                break
        if t==1:
            break  
    if t==1:
        break
        
print(a+x1+b+x2+c+x3+d+"=7")

Measured memory_bytes: 3064
import math, string, itertools, fractions, heapq, collections, re, array, bisect, copy, functools, random
import sys
from collections import deque, defaultdict, Counter; from heapq import heappush, heappop
from itertools import permutations, combinations, product, accumulate, groupby
from bisect import bisect_left, bisect_right, insort_left, insort_right
from operator import itemgetter as ig
sys.setrecursionlimit(10 ** 7)
inf = 10 ** 20; INF = float("INF"); ans = 0; tmp = 0; ansli = []; tmpli = []; candili = []
eps = 1.0 / 10 ** 10; mod = 10 ** 9 + 7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]; ddn = dd + [(-1, 1), (1, 1), (1, -1), (-1, -1)]; ddn9 = ddn + [(0, 0)]
"""for dx, dy in dd:
        nx = j + dx; ny = i + dy
            if 0 <= nx < w and 0 <= ny < h:"""
def wi(): return list(map(int, sys.stdin.readline().split()))
def wip(): return [int(x) - 1 for x in sys.stdin.readline().split()]#WideIntPoint
def ws(): return sys.stdin.readline().split()
def i(): return int(sys.stdin.readline())
def s(): return input()
def hi(n): return [i() for _ in range(n)]
def hs(n): return [s() for _ in range(n)]#HeightString
def mi(n): return [wi() for _ in range(n)]#MatrixInt
def mip(n): return [wip() for _ in range(n)]
def ms(n): return [ws() for _ in range(n)]

n, m = wi()
lr = mi(m)

gali = [0] * (n + 1)

for i in range(m):
    gali[lr[i][0] - 1] += 1
    gali[lr[i][1]] += -1
gali = list(accumulate(gali))
for i in range(n):
    if gali[i] == m:
        ans += 1
print(ans)

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

int main(){
	int E,Y;
	cin>>E>>Y;
	int y=0;
	if(E==0){
		if(Y>=1868 && Y<=1911){
			y=Y-1867;
			cout<<'M'<<y<<endl;
		}else if(Y>=1912 && Y<=1925){
			y=Y-1911;
			cout<<'T'<<y<<endl;
		}else if(Y>=1926 && Y<=1988){
			y=Y-1925;
			cout<<'S'<<y<<endl;
		}else if(Y>=1989 && Y<=2016){
			y=Y-1988;
			cout<<'H'<<y<<endl;
		}
	}else if(E==1){
				cout<<1867+Y<<endl;
	}else if(E==2){
				cout<<1911+Y<<endl;
	}else if(E==3){
				cout<<1925+Y<<endl;
	}else if(E==4){
				cout<<1988+Y<<endl;
	}

	return 0;
}

Measured memory_bytes: 3064
n, k, s = map(int, input().split())
result =[]

if s < 1000:
    result = [s for i in range(k)] + [s + 10 for i in range(n-k)]
else:
    result = [s for i in range(k)] + [s - 10 for i in range(n-k)]

print(' '.join(map(str, result)))

Measured memory_bytes: 15748
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include<algorithm>
#include<string>
#include <map>
#include <queue>
#include <stack>
#include<set>

#define DIV 1000000007

using namespace std;
using ll = long long;
using ldb = long double;

int main() {
	int h1, m1, h2, m2,k;
	cin >> h1 >> m1 >> h2 >> m2 >> k;
	int tm = (h2 - h1) * 60 + (m2 - m1);
	cout << tm - k << endl;
}

Measured memory_bytes: 3620
def resolve():
    n = int(input())
    a = list(map(int, input().split()))
    OK = True
    ans = 0
    while OK:
        for i in range(n):
            if a[i] % 2 == 0:
                a[i] //= 2
            else:
                OK = False
                break
        if OK:
            ans += 1
    print(ans)
resolve()

Measured memory_bytes: 38512
import sys
from bisect import *
from collections import *
from copy import deepcopy
from datetime import *
from heapq import *
from itertools import *
# from math import *
from operator import *
from pprint import *

sys.setrecursionlimit(10**8)

input = sys.stdin.readline

def main():
    """ main """
    N = int(input())
    HS = list(map(int, input().split()))
    max_h = max(HS)
    ans = 0
    for i in range(1, max_h+1):
        tmp = 0
        state = False
        for j in range(N):
            if HS[j] >= i and not state:
                tmp += 1
                state = True
            elif HS[j] < i and state:
                state = False
        ans += tmp
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 3952
fun main(args : Array<String> ) { 
  val (a, b) = readLine()!!.split(" ").map { x ->
    val t = x.toInt()
    if( t == 1 ) { 
      t + 13
    } else { 
      t 
    }
  }
  if ( a > b ) { 
    println("Alice")
  } else if ( a == b ) {
    println("Draw")
  } else if ( a < b ) {
    println("Bob")
  }
}

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

int main() {
  int q;
  string s;
  cin >> s >> q;
  
  
  deque<string> d;
  string t;
  for(int i = 0; i< s.size();i++){
    t = s[i];
    d.push_back(t);
  }
  
  int flg = 0;
  int tmp;
  int f;

  for (int i=0; i<q; i++){
    cin >> tmp;
    if(tmp == 1){
      flg = (flg+1)%2; 
    }else{
      cin >> f >> s;
      if((flg == 0 && f == 1) || (flg == 1 && f == 2)){
        d.push_front(s);
      }else{
        d.push_back(s);
      }
    }
  }
  if(flg == 0){
    while(!d.empty()){
      cout << d.front();
      d.pop_front();
    }
  }else{
    while(!d.empty()){
      cout << d.back();
      d.pop_back();
    }
  } 
}

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

int main(){
    int H, N;
    cin >> H >> N;
    int i, A, sum=0;
    for(i = 0; i < N; i++){
        cin >> A;
        sum += A;
        if(sum >= H){
            cout << "Yes" << endl;
            exit(0);
        }
    }
    if(i == N){
        cout << "No" << 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 ll long long int
ll lcm(ll a, ll b)
{
  ll g=__gcd(a,b);
  return a / g*b;
}

int main()
{
  int n;
  cin >> n;
  ll t[n];
  rep(i, n)
  {
    cin >> t[i];
  }

  ll ans = lcm(t[0], t[1]);
 // cout << ans << endl;
  for (int i = 2; i < n; i++)
  {
    ans = lcm(ans, t[i]);
    //cout << ans << endl;
  }
  if(n==1){
    cout<<t[0]<<endl;
  }else
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
url = "https://atcoder.jp//contests/abc061/tasks/abc061_b"

def main():
    t = list(map(int, input().split()))
    rode = [0] * t[0]
    for i in range(t[1]):
        r = list(map(int, input().split()))
        rode[r[0]-1] += 1
        rode[r[1]-1] += 1
    for v in rode:
        print(v)



if __name__ == '__main__':
    main()


Measured memory_bytes: 9096
import sys
N, M = map(int, input().split())
MOD = 10 ** 9 + 7

NG = [False for _ in range(N+1)]
for _ in range(M):
    NG[int(input())] = True

dp = [None for _ in range(N+1)]
dp[0] = 1
dp[1] = 0 if NG[1] else 1
for i in range(2, N+1):
    if NG[i]:
        dp[i] = 0
    else:
        dp[i] = (dp[i-2] + dp[i-1]) % MOD

print(dp[-1])


Measured memory_bytes: 7836
import sys
# import re
import math
import collections
# import decimal
import bisect
import itertools
import fractions
# import functools
import copy
# import heapq
import decimal
# import statistics
import queue

# import numpy as np

sys.setrecursionlimit(10000001)
INF = 10 ** 16
MOD = 10 ** 9 + 7
# MOD = 998244353

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))


# ===CODE===
def main():
    # nCrの左項にはn以外も来るバージョン、1!～(n-1)!を保持
    def prepare(n, MOD):
        # 1! - n! の計算
        f = 1
        factorials = [1]  # 0!の分
        for m in range(1, n + 1):
            f *= m
            f %= MOD
            factorials.append(f)
        # n!^-1 の計算
        inv = pow(f, MOD - 2, MOD)
        # n!^-1 - 1!^-1 の計算
        invs = [1] * (n + 1)
        invs[n] = inv
        for m in range(n, 1, -1):
            inv *= m
            inv %= MOD
            invs[m - 1] = inv

        return factorials, invs

    n, k = ns()
    facts, invs = prepare(n, MOD)

    ans = 0
    for ki in range(min(n, k + 1)):
        zero_comb = facts[n] * invs[ki] * invs[n - ki] % MOD
        nonzero_comb = facts[n - 1] * invs[ki] * invs[n - 1 - ki] % MOD
        ans += zero_comb * nonzero_comb % MOD
        ans %= MOD

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 26272
n = int(input())
aList = list(map(int, input().split()))
bList = list(map(int , input().split()))

deathSum = 0

for index in range(len(aList)-1):
    if(aList[index] < bList[index]):
        # a < bなら討伐数にaを加算する
        # さらに次のindexのaListを調査する
        deathSum += aList[index]
        bList[index] = bList[index] - aList[index]
        if(aList[index+1] > bList[index]):
            deathSum += bList[index]
            aList[index+1] -= bList[index]
        else:
            # a+1 < b
            deathSum += aList[index+1]
            aList[index+1] = 0
    else:
        # a >= bなら討伐数にbを加算する
        deathSum += bList[index]

print(deathSum)


Measured memory_bytes: 18624
#include <iostream>
#include <vector>
#include <queue>
#include <unordered_set>

using namespace std;


int N, M;
unordered_set<int> flg;
vector<vector<int>> tbl;

int main()
{
	int ans = 0;
	cin >> N;
	cin >> M;

	flg = unordered_set<int>();
	tbl = vector<vector<int>>(N+1);

	for (int i = 1; i <= N; i++) {
		flg.insert(i);
	}
	for (int i = 1; i <= M; i++) {
		int x, y, z;
		cin >> x;
		cin >> y;
		cin >> z;

		tbl.at(x).push_back(y);
		tbl.at(y).push_back(x);
	}

	while (!flg.empty()) {
		ans++;

		int tgt = *flg.begin();
		flg.erase(tgt);

		queue<int> q;
		q.push(tgt);
		while (!q.empty()) {
			int ind = q.front();
			q.pop();
			for (int i : tbl.at(ind)) {
				if (flg.find(i) != flg.end()) {
					flg.erase(i);
					q.push(i);
				}
			}
		}
	}

	cout << ans << endl;

	return 0;
}



Measured memory_bytes: 10660
#include <cstdio>

int main() {
	int a, b;
	scanf("%d%d", &a, &b);
	if(a>0&&b>0) {
		puts("Positive");
	}
	else if(a<=0&&b>=0) {
		puts("Zero");
	}
	else if(a<=0&&b==0) {
		puts("Zero");
	}
	else {
		if((b-a)%2==1) {
			puts("Positive");
		}
		else {
			puts("Negative");
		}
	}
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
#include<string>
#include<math.h>
#include<vector>
#include<numeric>
//#include <bits/stdc++.h>
#include<cstring>
#include<iostream>
#include<functional>
using namespace std;

int main() {
	int A, B, C, X;
	cin >> A >> B >> C >> X;
	int cnt = 0;
	for(int i=0;i<=A;i++)
		for(int j=0;j<=B;j++)
			for (int k = 0; k <= C; k++) {
				if (i * 500 + j * 100 + k * 50 == X)
					cnt++;
			}
	cout << cnt << endl;
	//cin >> N;
	return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES 
#include<iomanip> 
#include<cmath>  
#include<iostream>
#include<fstream>
#include<vector>
#include<algorithm>
#include<numeric>
#include<bitset>
#include<map>
// #include<unordered_map>
#include<set>
// #include<unordered_set>
#include<queue>
#include<deque>
#include<stack>
#include<functional>
using namespace std;
typedef long long ll;
#define repi(i,a,b) for(ll i = (ll)(a) ; i < (ll)(b) ; i++)
#define repd(i,a,b) for(ll i = (ll)(a) ; i > (ll)(b) ; i--)
#define rd(x) cin >> x
#define wr(x)  cout << x
#define wrln(x) cout << x << endl
#define wl() cout << endl
const ll MAX_10p5 = 100010;
const ll MAX_10p9 = 1000000010;
const ll MAX_10p18 = 1000000000000000010;
const ll MOD = 1000000007;
const ll m4x[4] = { 1,0,-1,0 };
const ll m4y[4] = { 0,1,0,-1 };
const ll m8x[8] = { 1,1,0,-1,-1,-1,0,1 };
const ll m8y[8] = { 0,1,1,1,0,-1,-1,-1 };
const ll m9x[9] = { 1,1,0,-1,-1,-1,0,1,0 };
const ll m9y[9] = { 0,1,1,1,0,-1,-1,-1,0 };

struct edge {
	ll from, to, cost;
	bool operator<(const edge& right) const {
		return cost < right.cost;
	}
};
struct point {
	ll x, y, idx;
	bool operator<(const point& right) const {
		return x == right.x ? y < right.y : x < right.x;
	}
};

template<typename T>
T minT(T a, T b) {
	if (a < b) return a;
	else return b;
}

template<typename T>
T maxT(T a, T b) {
	if (a > b) return a;
	else return b;
}

template<typename T>
T absT(T a) {
	if (a < 0) a *= -1;
	return a;
}

template<typename T>
T powT(T a, T x) {
	T res = 1;
	while (x > 0) {
		if (x & 1) res = res*a;
		a = a*a;
		x >>= 1;
	}
	return res;
}

ll StoLL(string str) {
	ll ret = 0, ini = 0;
	if (str[0] == '-') ini = 1;
	repi(i, ini, str.length()) {
		ret *= 10;
		ret += (ll)(str[i] - '0');
	}
	if (ini) ret *= -1;
	return ret;
}

///////////////////////////////////////////////////////////////////////////////////////

char grid[100][100];

int main() {
	char cs[2] = { '.','#' };
	ll a, b, c, s, l;
	cin >> a >> b;
	if (a < b) {
		c = 0, s = a, l = b;
	}
	else {
		c = 1, s = b, l = a;
	}

	repi(i, 0, 100) repi(j, 0, 100) grid[i][j] = cs[c];
	c = (c + 1) % 2;

	repi(i, 0, l) {
		ll tx = 1 + (i / 24) * 4, ty = 1 + (i % 24) * 4;
		repi(j, 0, 9) {
			grid[tx + m9x[j]][ty + m9y[j]] = cs[c];
		}
	}
	c = (c + 1) % 2;
	
	repi(i, 0, s - 1) {
		ll tx = 1 + (i / 24) * 4, ty = 1 + (i % 24) * 4;
		grid[tx][ty] = cs[c];
	}

	wrln("100 100");
	repi(i, 0, 100) {
		repi(j, 0, 100) {
			wr(grid[i][j]);
		}
		cout << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
*/


int N;
bool graph[10][10], visited[10];

int dfs(int v){
    visited[v] = true;

    bool all_visited = true;
    for(int i=1; i<=N; i++) if(visited[i] == false) all_visited = false;
    if(all_visited){
        visited[v] = false;
        return 1;
    }

    int ret = 0;
    for(int i=1; i<=N; i++){
        if(graph[v][i] == true && visited[i] == false){
            ret += dfs(i);
        }
    }


    visited[v] = false;
    return ret;
}


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

    vector<int> a(M), b(M);
    for(int i=0; i<M; i++){
        cin >> a[i] >> b[i];
        graph[a[i]][b[i]] = graph[b[i]][a[i]] = true;
    }

    cout << dfs(1) << endl;

}

Measured memory_bytes: 256
/*
    to amy
*/

#include <bits/stdc++.h>
#define MAX 100010
#define pb push_back
using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int x,a;
    while(cin>>x>>a){
        if(x<a)cout<<0<<endl;
        else cout<<10<<endl;
    }
    return 0;
}

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

using namespace std;

bool ps[4][4];

bool f(vector<int>& path, int i, int n){
    if(i>=n){
        int src=path[0];
        for(int j=1; j<n; ++j){
            int dst=path[j];
            if(!ps[src][dst]) return false;
            src=dst;
        }
        return true;
    }
    for(int j=0; j<n; ++j){
        if(find(path.begin(), path.end(), j)!=path.end()) continue;
        path[i]=j;
        if(f(path, i+1, n)) return true;
        path[i]=-1;
    }
    return false;
}

int main(){
    for(int i=0; i<3; ++i){
        int a, b; cin >> a >> b;
        --a; --b;
        ps[a][b]=ps[b][a]=true;
    }
    vector<int> path(4, -1);
    if(f(path, 0, 4)) cout << "YES\n";
    else cout << "NO\n";
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

namespace ConsoleApp
{
    class Program
    {
        static void Main(string[] args)
        {
            var ss = Console.ReadLine().Split();
            var N = int.Parse(ss[0]);
            var X = int.Parse(ss[1]);

            ss = Console.ReadLine().Split();
            var L = new int[N];
            for (int i = 0; i < N; i++)
            {
                L[i] = int.Parse(ss[i]);
            }

            var count = 1;
            var d = 0;
            for (int i = 0; i < N; i++)
            {
                d += L[i];

                if (d <= X)
                {
                    count++;
                }
                else
                {
                    break;
                }
            }

            Console.WriteLine(count);
        }
    }
}

Measured memory_bytes: 13140
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>

using namespace std;
#define ll long long
#define ld long double
#define mp make_pair

void print(auto &a)
{
    for (auto s: a) cout<<s<<' ';
    cout<<endl;
}

void get(vector<auto> &a)
{
    for (int i = 0; i<a.size(); i++) cin>>a[i];
}

const int p = 1e9 + 7;


int mul(int a, int b) {
    return (1LL * a%p * b%p) % p;
}

int add(int a, int b) {
    ll s = (a+b);
    s = s%p;
    if (s<0) s+=p; 
    return s;
}

int po(int a, int deg)
{
    if (deg==0) return 1;
    if (deg%2==1) return mul(a, po(a, deg-1));
    int t = po(a, deg/2);
    return mul(t, t);
}

int inv(int n)
{
    return po(n, p-2);
}

vector<int> Z(string s)
{
int n = s.length();
vector<int> z(n);
int L = 0, R = 0;
for (int i = 1; i < n; i++) {
  if (i > R) {
    L = R = i;
    while (R < n && s[R-L] == s[R]) R++;
    z[i] = R-L; R--;
  } else {
    int k = i-L;
    if (z[k] < R-i+1) z[i] = z[k];
    else {
      L = i;
      while (R < n && s[R-L] == s[R]) R++;
      z[i] = R-L; R--;
    }
  }
}
return z;
}


int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(nullptr);
    
    int n;
    cin>>n;
    string s;
    cin>>s;
    vector<int> cnt(n+1);
    cnt[0] = 0;
    for (int i = 0; i<n; i++)
    {
        cnt[i+1] = cnt[i];
        if (s[i]=='.') cnt[i+1]++;
    }
    
    int minn = n;
    for (int i = 0; i<=n; i++)
    {
        minn = min(minn, i-cnt[i] + (cnt[n]-cnt[i]));
    }
    cout<<minn;

    
}

Measured memory_bytes: 1300
import sys
input=sys.stdin.readline
sys.setrecursionlimit(10 ** 8)
from itertools import accumulate
from itertools import permutations
from itertools import combinations
from collections import defaultdict
from collections import Counter
import fractions
import math
from collections import deque
from bisect import bisect_left
from bisect import insort_left
import itertools
from heapq import heapify
from heapq import heappop
from heapq import heappush
import heapq
from copy import deepcopy
alf = list("abcdefghijklmnopqrstuvwxyz")
ALF = list("ABCDEFGHIJKLMNOPQRSTUVWXYZ")
#import numpy as np
INF = float("inf")
#d = defaultdict(int)
#d = defaultdict(list)
#N = int(input())
#A = list(map(int,input().split()))
#S = list(input())[:-1]
#S.remove("\n")
#N,M = map(int,input().split())
#S,T = map(str,input().split())
#A = [int(input()) for _ in range(N)]
#S = [list(input())[:-1] for _ in range(N)]
#A = [list(map(int,input().split())) for _ in range(N)]
import numpy as np
N,S = map(int,input().split())
MOD = 998244353
A = list(map(int,input().split()))
dp = np.zeros(3003,dtype = np.int64)
dp[0] = 2
if A[0] <= S:
    dp[A[0]] = 1
for i in range(1,N):
    a = A[i]
    p = dp*2
    p[a:] += dp[:-a]
    p %= MOD
    dp = p
print(dp[S])

    





Measured memory_bytes: 27384
#include<bits/stdc++.h>
#define ls ch[x][0]
#define rs ch[x][1]
#define ll long long
using namespace std;

inline ll read(){
	ll num=0,neg=1;char c=getchar();
	while(!isdigit(c)){if(c=='-')neg=-1;c=getchar();}
	while(isdigit(c)){num=(num<<3)+(num<<1)+c-'0';c=getchar();}
	return num*neg;
}

int cnt[200010],scnt[200010],tot[200010];
int n,a[200010],ans[200010];

struct node{
	int x;
	bool operator <(const node &y)const{
		if(scnt[x]!=scnt[y.x]) return scnt[x]<scnt[y.x];
		return cnt[x]<cnt[y.x];
	}
};


int main(){
	n=read();priority_queue<node>line;
	for(int i=1;i<=n;i++) a[i]=read(),tot[a[i]]++;
	for(int i=1;i<=n;i++) cnt[read()]++;
	for(int i=1;i<=n;i++) scnt[i]=min(tot[i],cnt[i]);
	for(int i=1;i<=n;i++) if(cnt[i]) line.push((node){i});
	
	for(int i=1;i<=n;i++){
		
		int u=(line.top()).x;line.pop();
		if(u==a[i]){
			if(line.empty()){
				printf("No\n");return 0;
			}
			int v=(line.top()).x;line.pop();
			if(scnt[a[i]]) scnt[a[i]]--;
			ans[i]=v;line.push((node){u});
			if(--cnt[v])line.push((node){v});
		}
		else {
			ans[i]=u;if(scnt[a[i]])scnt[a[i]]--;
			if(--cnt[u])line.push((node){u});
		}
	}
	printf("Yes\n");
	for(int i=1;i<=n;i++) printf("%d ",ans[i]);
	return 0;
}


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

const int N = 1e5 + 105;
int steps = 2;
ll dp[N];
ll h[N];
int n;


ll solve(int idx) {
    if (idx >= n)
        return 1e9;
    if (idx == n - 1)
        return 0;
    if (dp[idx] != -1)
        return dp[idx];
    ll res = 1e9;
    for (int i = 1; i <= steps; i++)
        res = min(res, solve(idx + i) + abs(h[idx] - h[idx + i]));
    return dp[idx] = res;
}

int main() {
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    cin >> n;
    for (int i = 0; i < n; i++)
        cin >> h[i];
    memset(dp, -1, sizeof dp);
    cout << solve(0);
    return 0;
}


Measured memory_bytes: 6528
import sys
import os
import math
import bisect
import itertools
import collections
import heapq
import queue
import array

# 時々使う
# from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall
# from decimal import Decimal
# from collections import defaultdict, deque

# 再帰の制限設定
sys.setrecursionlimit(10000000)


def ii(): return int(sys.stdin.buffer.readline().rstrip())
def il(): return list(map(int, sys.stdin.buffer.readline().split()))
def fl(): return list(map(float, sys.stdin.buffer.readline().split()))
def iln(n): return [int(sys.stdin.buffer.readline().rstrip())
                    for _ in range(n)]


def iss(): return sys.stdin.buffer.readline().decode().rstrip()
def sl(): return list(map(str, sys.stdin.buffer.readline().decode().split()))
def isn(n): return [sys.stdin.buffer.readline().decode().rstrip()
                    for _ in range(n)]


def lcm(x, y): return (x * y) // math.gcd(x, y)


# MOD = 10 ** 9 + 7
MOD = 998244353
INF = float('inf')


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N = ii()
    xyh = [il() for _ in range(N)]

    for cx in range(0, 101):
        for cy in range(0, 101):
            tmp_x, tmp_y, tmp_h = -1, -1, -1
            for x, y, h in xyh:
                # 高さが1以上の調査点から
                # ピラミッドの中心を求める
                if h == 0:
                    continue
                tmp_x, tmp_y = cx, cy
                tmp_h = h + abs(x - cx) + abs(y - cy)
                break

            if tmp_h != -1:
                # 求めた中心が全ての調査点の条件と
                # 一致するか否かを確かめる
                for x, y, h in xyh:
                    if h != max(tmp_h - abs(x - tmp_x) - abs(y - tmp_y), 0):
                        break
                else:
                    print(tmp_x, tmp_y, tmp_h)
                    exit()


if __name__ == '__main__':
    main()


Measured memory_bytes: 9604
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<functional>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
using namespace std;
#define MOD 1000000007
#define f(i,n) for(long long i=0;i<(long long)(n);i++)
#define N 200010






int main() {
	long long a[N];
	long long b[N];
	long long n, k;
	queue<long long>q;
	long long x, y, z;
	long long xx, yy, zz;
	long long s, ans;
	bool v = true;
	ans = 0;
	scanf("%lld", &n);
	f(i, n) {
		scanf("%lld", &a[i]);
	}
	f(i, n) {
		scanf("%lld", &b[i]);
	}
	f(i, n) {
		x = (i + n - 1) % n;
		y = i;
		z = (i + 1) % n;
		if (b[y] < a[y]) {
			printf("-1\n");
			return 0;
		}
		if (((b[x] + b[z]) < b[y])&&(b[y]>a[y]))q.push(y);
	}
	while (!q.empty()) {
		y = q.front();
		x = (y + n - 1) % n;
		z = (y + 1) % n;
		q.pop();
		xx = b[y] % (b[x] + b[z]);
		if (xx <= a[y]) {
			yy = b[y] - a[y];
			if ((yy % (b[x] + b[z])) == 0) {
				ans += (yy / (b[x] + b[z]));
				b[y] = a[y];
			}
			else {
				printf("-1\n");
				return 0;
			}
		}
		else {
			ans += (b[y] / (b[x] + b[z]));
			b[y] = xx;
		}
		x = (x + n - 1) % n;
		y = (y + n - 1) % n;
		z = (z + n - 1) % n;
		if (((b[x] + b[z]) < b[y]) && (b[y] > a[y]))q.push(y);

		x = (x + 2) % n;
		y = (y + 2) % n;
		z = (z + 2) % n;
		if (((b[x] + b[z]) < b[y]) && (b[y] > a[y]))q.push(y);
}
	f(i, n) {
		if (a[i] != b[i]) {
			printf("-1\n");
			return 0;
		}
	}

	printf("%lld\n", ans);


	return 0;
}

Measured memory_bytes: 4224
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <iomanip>
#include <bitset>
#include <set>
#include <map>
#include <stdio.h>
#include <numeric>
#include <cstring>

#define rep(i,n) for (int i = 0; i < (n); i++)
#define rep1(i,n) for (int i = 1; i < (n); i++)
#define FOR(i,a,b) for (int i=(a); i < (b); i++)
#define MOD 1000000007 //10^9+7
using namespace std;
using ll = long long;
using PII = pair<int, int>;
using PLL = pair<ll, ll>;
const int INF = numeric_limits<int>::max();
const ll INFL = numeric_limits<ll>::max();


// 負の数にも対応した % 演算
long long mod(long long val, long long m) {
    long long res = val % m;
    if (res < 0) res += m;
    return res;
}

//greatest common divisor
long long gcd(ll a, ll b) 
{
    if (a % b == 0) {
        return b;
    } else {
        return gcd(b, a % b);
    }
}

//least common multiple
long long lcm(ll a, ll b)
{
    return a / gcd(a, b) * b ;
}

ll factorial(ll n) {
    ll res = 1;
    for (ll i = 1; i <= n; i++) {
        res *= i;
    }
    return res;
}

int main()
{
    long long n, a, b , c, d, e; cin >> n >> a >> b >> c>>d>>e;
    cout << max({ (n - 1) / a, (n - 1) / b, (n - 1) / c, (n - 1) / d, (n - 1) / e }) + 5 << endl;
    return 0;
}


Measured memory_bytes: 3596
#include <iostream>
#include <algorithm>
#include <bitset>
#include <cmath>

using namespace std;

int main()
{
    int n,m;
    cin >> n >> m;
    //cout << n << " " << m << endl;
    int k[m];
    int s[m][n];
    int p[m];
    
    for(int i=0; i<m; i++){
        cin >> k[i];
        //cout << k[i] << " ";
        for(int j=0; j<k[i]; j++){
            cin >> s[i][j];
            //cout << s[i][j] << " ";
        }
        //cout << endl;
    }
    for(int i=0; i<m; i++){
        cin >> p[i];
        //cout << p[i] << " ";
    }
    //cout << endl << "-----" << endl;


    int loop = std::pow(2, n);
    int cnt = 0;
    int total = 0;
    for(int i=0; i<loop; i++){
        //cout << "-> " << i << endl;
        bool ok = true;
        for(int j=0; j<m; j++){
            total = 0;
            for(int jj=0; jj<k[j]; jj++){
                if((i & (1<<(s[j][jj]-1))) != 0) total++;
                //cout << total << "&" << (1<<(s[j][jj]-1)) << s[j][jj]-1 << " ";
            }
            //cout << total << ":" << p[j] << endl;
            if(total%2 != p[j]){
                ok = false;
                break;
            }
        }
        //cout << ok << endl;
        if(ok == true) cnt++;
    }
    
    cout << cnt << endl; 
    return 0;
}


Measured memory_bytes: 256
import math
n,d=map(int,input().split())
plot=[list(map(int,input().split())) for i in range(n)]
res=0
for i in range(n-1):
  for j in range(i+1,n):
    dist=0
    for k in range(d):
      dist += (plot[j][k]-plot[i][k])**2
    temp = int(math.sqrt(dist))
    if temp ** 2 == dist:
        res += 1
    
print(res)

Measured memory_bytes: 9168
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <string>
#include <iomanip>
using namespace std;
int main(){
	int n;
	int a[200002];
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>a[i];
	}
	int b[200002]={};
	int c[200002]={};
	for(int i=n;i>=1;i--){
		if(b[i]%2==a[i]){
			c[i]=0;
		}else{
			c[i]=1;
			vector<int> hoge;
			for(int j=1;j*j<=i;j++){
				if(i%j==0){
					hoge.push_back(j);
					if(j*j!=i){
						hoge.push_back(i/j);
					}
				}
			}
			for(int j=0;j<hoge.size();j++){
				if(i%hoge[j]==0){
					b[hoge[j]]++;
				}
			}
		}
	}
	int cnt=0;
	vector<int> ans;
	for(int i=1;i<=n;i++){
		if(c[i]){
			cnt++;
			ans.push_back(i);
		}
	}
	cout<<cnt<<endl;
	for(int i=0;i<cnt;i++){
		cout<<ans[i]<<endl;
	}
	return 0;
}


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

using namespace std;


int main()
{
string n,a,b,c;
set<int> s;
cin >> n;
for(int i=0;i<n.size();i++)
{
    s.insert(n[i]);
}
if(s.size()==n.size())
    cout<<"yes";
else cout<<"no";


}


Measured memory_bytes: 256
//g++  5.4.0

#include <bits/stdc++.h>
using namespace std;


int main()
{
  
    long int n,i,si;
    cin>>n;
    vector<pair<long int,long int>>s(n);
    for(i=0;i<n;i++){
         cin>>si;  
         s[i].first = si;
         s[i].second = i+1;
    }
    sort(s.begin(),s.end());
    for(auto p:s) cout<<p.second<<" ";
}

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

int main(){
    int N, A, count, ans=1000000;
    cin >> N;
    for (int i = 0; i < N; i++) {
        count = 0;
        cin >> A;
        for(int j = 0;; j++) {
            if(A % 2 == 0) {
                A /= 2;
                count++;
            }
            else break;
        }
        if(ans > count) ans = count;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3528
#define _GLIBCXX_DEBUG
#include <iostream>
#include <vector>
#include <string>
using namespace std;
using vi = vector<int>;
using vc = vector<char>;

int main(void){
    int n, m;
    cin >> n >>m;
    vi S(m);
    vc C(m);
    for(int i=0; i<m; i++) cin >> S[i] >> C[i];
    int begin, end;
    switch(n){
        case 1: begin = 0; end = 10; break;
        case 2: begin = 10; end = 100; break;
        case 3: begin = 100; end = 1000; break;
    }
    for(int i=begin; i<end; i++){
        string str = to_string(i);
        bool ok = true;
        for(int j=0; j<m; j++)if(str[S[j]-1] != C[j]) ok = false;
        if(ok){ cout << i << '\n'; return 0; }
    }
    cout << -1 << '\n';
    return 0;
}

Measured memory_bytes: 3724
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <iterator>
#pragma warning(disable:4996)

typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define MOD 1000000007
using namespace std;

int main(int argc, char* argv[])
{
    long n;
    scanf("%ld", &n);

    vector<long> a(n);

    long max=0;
    long imax=0;
    long i;
    for(i=0; i<n; i++) {
        scanf("%ld", &(a[i]));
        if(max<a[i]) {
            max=a[i];
            imax=i;
        }
    }

    ll val=2*max;
    ll ans=-1;
    for(i=0; i<n; i++) {
        if(i==imax) continue;
        if(val > abs((ll)2*a[i]-max)) {
            val = abs((ll)2*a[i]-max);
            ans=a[i];
        }
    }

    printf("%lld %lld\n", MAX(max,ans), MIN(max,ans));


    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>

using namespace std;
typedef long long ll;
ll fexp(ll x, ll y, ll m) {
  ll ans = 1;
  while (y) {
    if (y & 1)
      ans = ans * x % m;
    x = x * x % m;
    y >>= 1;
  }
  return ans;
}
int main() {
  int n;
  string x;
  cin >> n >> x;
  ll curr = 0;
  int tot = 0;
  for (char c : x)
    tot += c == '1';
  vector<ll> l(n), m(n), r(n);
  ll lt = 0, mt = 0, rt = 0;
  if (tot > 1) {
    l[0] = 1 % (tot - 1);
    for (int i = 1; i < n; ++i)
      l[i] = l[i - 1] * 2 % (tot - 1);
    for (int i = 0; i < n; ++i)
      if (x[i] == '1')
        lt = (lt + l[n - i - 1]) % (tot - 1);
  }
  if (tot > 0) {
    m[0] = 1 % tot;
    for (int i = 1; i < n; ++i)
      m[i] = m[i - 1] * 2 % tot;
    for (int i = 0; i < n; ++i)
      if (x[i] == '1')
        mt = (mt + m[n - i - 1]) % tot;
  }
  r[0] = 1 % (tot + 1);
  for (int i = 1; i < n; ++i)
    r[i] = r[i - 1] * 2 % (tot + 1);
  for (int i = 0; i < n; ++i)
    if (x[i] == '1')
      rt = (rt + r[n - i - 1]) % (tot + 1);
  string ans;
  for (int i = 0; i < n; ++i) {
    int curr = tot + (x[i] == '1' ? -1 : 1);
    if (curr <= 1) {
      ans += to_string(curr) + "\n";
      continue;
    }
    int t = 1;
    ll now;
    if (curr == tot + 1) {
      now = (rt + r[n - i - 1]) % (tot + 1);
    } else {
      now = (lt - l[n - i - 1]) % (tot - 1);
      if (now < 0)
        now += tot - 1;
    }
    while (now) {
      now %= __builtin_popcount(now);
      t++;
    }
    ans += to_string(t) + "\n";
  }
  cout << ans;
}

Measured memory_bytes: 8812
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
const int MOD=(int)1e9+7;
using namespace std;
int main(){
    int a,b,c;
    cin>>a>>b>>c;
    if(a+b>=c) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 256
M, D = map(int, input().split())

ans = 0
for i in range(4, M+1):
    for j in range(22, D+1):
        d1 = j % 10
        d2 = j // 10
        if d1 >= 2 and d2 >= 2 and i == d1 * d2:
            ans += 1

print(ans)



Measured memory_bytes: 2940
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.*;

public class Main {

    static int N;
    static int[] A;

    public static void main(String[] args) {
        FastScanner sc = new FastScanner(System.in);
        N = sc.nextInt();
        A = sc.nextIntArray(N*3);

        System.out.println( solve() );
    }

    private static long solve() {
        long[] ls = new long[N+1];
        PriorityQueue<Integer> lq = new PriorityQueue<>(N);
        long curr = 0;
        for (int i = 0; i < N; i++) {
            lq.add(A[i]);
            curr += A[i];
        }
        ls[0] = curr;
        for (int i = 0; i < N; i++) {
            int a = A[N+i];
            lq.add(a);
            int b = lq.poll();
            curr += (a-b);
            ls[i+1] = curr;
        }

        long[] rs = new long[N+1];
        Comparator<Integer> c = Comparator.naturalOrder();
        PriorityQueue<Integer> rq = new PriorityQueue<>(N, c.reversed());
        curr = 0;
        for (int i = 3*N-1; i >= 2*N; i--) {
            int a = A[i];
            rq.add(a);
            curr += a;
        }
        rs[N] = curr;
        for (int i = 0; i < N; i++) {
            int a = A[2*N-1-i];
            rq.add(a);
            int b = rq.poll();
            curr += (a-b);
            rs[N-i-1] = curr;
        }

        long max = Long.MIN_VALUE;
        for (int i = 0; i < N+1; i++) {
            max = Math.max(ls[i] - rs[i], max);
        }
        return max;
    }

    static class FastScanner {

        private BufferedReader reader;
        private StringTokenizer tokenizer;

        FastScanner(InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
            tokenizer = null;
        }

        String next() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        String nextLine() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    return reader.readLine();
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }

            return tokenizer.nextToken("\n");
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        int[] nextIntArray(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++)
                a[i] = nextInt();
            return a;
        }

        long[] nextLongArray(int n) {
            long[] a = new long[n];
            for (int i = 0; i < n; i++)
                a[i] = nextLong();
            return a;
        }
    }
}



Measured memory_bytes: 62452
def factorial(n):
  if n in [0, 1]:
    return 1
  else:
    return factorial(n - 1) * n

def rank_of_list(A):
  rank = 0
  for i in range(len(A)):
    rank += (A[i] - 1) * factorial(len(A) - i - 1)
    A = list(map(lambda a: a - 1 if a > A[i] else a, A))
  return rank

def main():
  N = int(input())
  P = list(map(lambda p: int(p), input().split(" ")))
  Q = list(map(lambda q: int(q), input().split(" ")))
  print(abs(rank_of_list(P) - rank_of_list(Q)))

main()

Measured memory_bytes: 9160
#include<bits/stdc++.h>
using namespace std;
int gcd(int x,int y)
{
	if(x==0)return y;
	else if(y==0)return x;
	else
	return gcd(y%x,x);
}
int main()
{
   int n;cin>>n;
   int sum=0;
   for(int i=1;i<=n;i++)
   {
   	for(int j=1;j<=n;j++)
   	{
   		for(int k=1;k<=n;k++)
   		{
   			int num=gcd(i,j);
   			num=gcd(num,k);
   			sum+=num;
		   }
	   }
   }
   cout<<sum<<endl;
	return 0;
 } 

Measured memory_bytes: 3592
#include <iostream>
using namespace std;
const int maxn = 30;

int number , n , max_number , cnt;

int main ( void )
{
	cin >> n;
	for ( int i = 1 ; i <= n ; i++ ) {
		cin >> number;
		if ( number >= max_number ) {
			cnt++;
			max_number = number;
		}
	}	
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 3624
from collections import Counter

N = int(input())
V = list(map(int,input().split()))

c1 = Counter(V[::2]).most_common(2)
c2 = Counter(V[1::2]).most_common(2)

c1 = dict(list(c1))
c2 = dict(list(c2))
c1[-1] = 0
c2[-2] = 0

MAX = 0
for k,v in c1.items():
    for k2,v2 in c2.items():
        if k != k2:
            MAX = max(v+v2,MAX)

print(N - MAX)

Measured memory_bytes: 15588
#include<bits/stdc++.h>
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

const ll MOD=(ll)1e9+7LL;

ll s, pref[2099];
int main() {
    IOS; cin >> s;
    pref[0]=pref[1]=pref[2]=0LL;
    pref[3]=1LL;
    pref[4]=2LL;
    pref[5]=3LL;
    for(ll i=6; i<=s; ++i) {
        pref[i]=pref[i-3]+pref[i-1]+1;
        pref[i]%=MOD;
    }
    cout << (pref[s]-pref[s-1]+MOD)%MOD;
}


Measured memory_bytes: 3648
#include <iostream>
#include <vector>
#include <algorithm>
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define REP(i, n) for(int i = 1; i < (int)(n); ++i)
using namespace std;

struct UnionFind {
    vector<int> par;
    
    UnionFind(int N) : par(N) {
        rep(i, N) par[i] = -1;
    }
    
    int root(int x) {
        if (par[x] < 0) return x;
        return par[x] = root(par[x]);
    }
    
    void unite(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        if (rx == ry) return;
        if (par[rx] > par[ry]) swap(rx, ry);
        par[rx] += par[ry];
        par[ry] = rx;
        return;
    }
    
    bool same(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
    
    int size(int x) {
        return -par[root(x)];
    }
};

int main() {
    int N, M, K;
    cin >> N >> M >> K;
    UnionFind UF(N);
    
    vector<int> friends(N, 0);
    rep(i, M) {
        int A, B;
        cin >> A >> B;
        ++friends[A - 1];
        ++friends[B - 1];
        UF.unite(A - 1, B - 1);
    }
    
    vector<vector<int>> brock(N);
    rep(i, K) {
        int C, D;
        cin >> C >> D;
        brock[C - 1].push_back(D - 1);
        brock[D - 1].push_back(C - 1);
    }
    
    rep(i, N) {
        int ans = UF.size(i);
        ans -= 1;
        ans -= friends[i];
        for (int x : brock[i]) {
            if (UF.same(i, x)) --ans;
        }
        if (i != N - 1) cout << ans << " ";
        else cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 6784
#include <iostream>
#include <algorithm>
#include <string>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <vector>
#include <queue>
#include <stack>
using namespace std;

#define rep(i, s) for (int i = 0; i < s; ++i)
#define all(v) (v.begin(), v.end())
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define VEC(a, n) vector<int>a(n)

typedef long long  ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main() {
    int n,k;
    cin>>n>>k;
    double ans=0;
    for(int i=0;i<n;i++){
        int tmp=i+1;
        int cnt=0;

        while(tmp<k){
            tmp*=2;
            cnt++;
        }
        ans+=pow(2,-cnt);
    }
    printf("%.12f\n", ans/n);




    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		new Main().solve();
	}
	
	int N,M;
	
	void solve(){
		Scanner sc=new Scanner(System.in);
		N=sc.nextInt();
		M=sc.nextInt();
		
		int[]a=new int[N];
		int[]b=new int[N];
		int[]c=new int[M];
		int[]d=new int[M];
		
		for(int i=0;i<N;i++){
			a[i]=sc.nextInt();
			b[i]=sc.nextInt();
		}
		for(int i=0;i<M;i++){
			c[i]=sc.nextInt();
			d[i]=sc.nextInt();
		}
		
		for(int i=0;i<N;i++){
			int dis=Integer.MAX_VALUE/2;
			int min=0;
			
			for(int j=0;j<M;j++){
				int man_dis=Math.abs(a[i]-c[j])+Math.abs(b[i]-d[j]);
				if(man_dis<dis){
					dis=man_dis;
					min=j;
				}
			}
			System.out.println(min+1);
		}
	}
}

Measured memory_bytes: 23508
use proconio::input;

fn main() {
    input! {
        n: usize,
        k: usize,
        a: [u128; n],
    }

    for num in 0..n - k{
        if a[num] < a[num + k] {
            println!("Yes");
        } else {
            println!("No");
        }
    }
}

Measured memory_bytes: 7228