akhauriyash/Code-Regression huggingface dataset:
// Standard I/O
#include <iostream>
#include <sstream>
#include <cstdio>
// Standard Library
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
// Template Class
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
// Container Control
#include <algorithm>

using namespace std;

#define rep( i, n ) for( int i = 0; i < n; ++i )
#define irep( i, n ) for( int i = n-1; i >= 0; --i )
#define reep( i, s, n ) for ( int i = s; i < n; ++i )
#define ireep( i, n, s ) for ( int i = n-1; i >= s; --i )
#define foreach(itr, x) for( typeof(x.begin()) itr = x.begin(); itr != x.end(); ++itr)

#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
#define all( v ) v.begin(), v.end()
#define fs first
#define sc second
#define vc vector

// for visualizer.html
double SCALE = 1.0;
double OFFSET_X = 0.0;
double OFFSET_Y = 0.0;
#define LINE(x,y,a,b) cerr << "line(" << SCALE*(x) + OFFSET_X << ","	\
	<< SCALE*(y) + OFFSET_Y << ","										\
	<< SCALE*(a) + OFFSET_X << ","										\
	<< SCALE*(b) + OFFSET_Y << ")" << endl;
#define CIRCLE(x,y,r) cerr << "circle(" << SCALE*(x) + OFFSET_X << ","	\
	<< SCALE*(y) + OFFSET_Y << ","										\
	<< SCALE*(r) << ")" << endl;

typedef long long ll;
typedef complex<double> Point;

typedef pair<int, int> pii;
typedef pair<int, pii> ipii;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector< vector<int> > vii;
typedef vector< vector<double> > vdd;

typedef vector<int>::iterator vi_itr;

const int IINF = 1 << 28;
const int MOD = 1e9+7;
const double INF = 1e30;
const double EPS = 1e-10;
const double PI = acos(-1.0);

// Direction : L U R D
const int dx[] = { -1, 0, 1, 0};
const int dy[] = { 0, -1, 0, 1 };

int n, k;
int a[100000];

int main()
{
    cin >> n >> k;
    rep(i, n) cin >> a[i];

    cout << (n == k ? 1 : ceil((n - k) / (k - 1.0)) + 1) << endl;
}


Measured memory_bytes: 640
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

static class Program
{
    static int Solve(int N, int[] A)
    {
        int n = 0;
        foreach (int a in A)
        {
            if (a == n + 1) { ++n; }
        }
        return (n > 0) ? N - n : -1;
    }

    static void Main(string[] args)
    {
        int N = int.Parse(Console.ReadLine());
        int[] A = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
        Console.WriteLine(Solve(N, A));
    }
}


Measured memory_bytes: 33116
N = gets.chomp.to_i
str = gets.split
a = Array.new(N)
for i in 0...N do
    a[i] = str[i].to_f
end

b = 0.0
for i in 0...N do
    b += 1.0/a[i]
end

c = 1.0/b
puts c

Measured memory_bytes: 1788
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <stack>
#include <functional>

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
    #define eprintf(...) 42
#endif

#define rep_(i, a_, b_, a, b, ...) for (int i = (a), i##_len = (b); i < i##_len; ++i)
#define rep(i, ...) rep_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define reprev_(i, a_, b_, a, b, ...) for (int i = (b-1), i##_min = (a); i >= i##_min; --i)
#define reprev(i, ...) reprev_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define all(x) (x).begin(), (x).end()
template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template <class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
// template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair <int,int> P;
typedef long double ld;

int main (void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string n; int k; cin >> n >> k;
    int l = n.size();
    vector<vector<vector<int>>> dp(l + 1, vector<vector<int>>(2, vector<int>(5)));
    dp[0][0][0] = 1;
    rep (i, l) {
        int d = (int)n[i] - '0';
        rep (j, k + 1) {
            dp[i + 1][0][j + (d != 0)] += dp[i][0][j]; 
            dp[i + 1][1][j + 1] += max(0, d - 1) * dp[i][0][j];
            dp[i + 1][1][j] += (d != 0 ? dp[i][0][j] : 0);
            dp[i + 1][1][j + 1] += 9 * dp[i][1][j];
            dp[i + 1][1][j] += dp[i][1][j];
        }
    }
    cout << dp[l][0][k] + dp[l][1][k] << "\n";
    return 0;
}

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

using namespace std;
vector<int> left(vector<int> a,vector<int> l);
vector<int> right(vector<int> a,vector<int> r);
int n;

int main(){
    cin>>n;
    vector<int> a(n);
    vector<int> l(n+1);
    vector<int> r(n+1);
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    int ans=0;
    l=left(a,l);
    r=right(a,r);
    for(int i=1;i<n-1;i++){
        ans=max(ans,__gcd(l[i-1],r[i+1]));
    }
    ans=max(ans,r[1]);
    ans=max(ans,l[n-2]);
    cout<<ans<<endl;
    return 0;
}
vector<int> left(vector<int> a,vector<int> l){
    l[0]=a[0];
    for(int j=1;j<n;j++){
        l[j]=__gcd(l[j-1],a[j]);
    }
    return l;
}
vector<int> right(vector<int> a,vector<int> r){
    r[n]=a[n-1];
    for(int j=n-1;j>=0;j--){
        r[j]=__gcd(r[j+1],a[j]);
    }
    return r;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i, a, b) for(ll i = (a); i < (ll)b; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF (1ll << 60)
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
using vl = vector<ll>;
using vvl = vector<vl>;
typedef double db;
typedef string str;
typedef pair<ll, ll> p;
constexpr int MOD = 1000000007;
using ll = long long;
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

void print(const std::vector<int> &v) {
    std::for_each(v.begin(), v.end(), [](int x) { std::cout << x << " "; });
    std::cout << std::endl;
}

ll modpow(ll a, ll p) {
    if(p == 0)
        return 1;
    if(p % 2 == 0) {
        ll halfp = p / 2;
        ll half = modpow(a, halfp);
        return half * half % MOD;
    } else {
        return a * modpow(a, p - 1) % MOD;
    }
}

int main() {
    ll N;
    cin >> N;
    vector<int> A(N);
    map<int, int> inp;
    REP(i, N) {
        cin >> A[i];
        inp[A[i]]++;
    }
    if(N % 2 == 1) {
        if(inp[0] != 1) {
            cout << 0 << endl;
            return 0;
        }
        for(int i = 2; i < N; i += 2) {
            if(inp[i] != 2) {
                cout << 0 << endl;
                return 0;
            }
        }
    } else {
        for(int i = 1; i < N; i += 2) {
            if(inp[i] != 2) {
                cout << 0 << endl;
                return 0;
            }
        }
    }
    cout << modpow(2, N / 2) << endl;
    return 0;
}

Measured memory_bytes: 3584
#include<iostream>
#include<string>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<queue>
#include<stack>
#include<list>
#include<map>
#include<deque>
#include<math.h>
using namespace std;
#define ll long long
int main(){
    ll n;
    cin >> n;
    ll d[n];
    ll i;
    for(i=0;i<n;i++){
        cin >> d[i];
    }
    sort(d,d+n);
    cout<<d[n/2]-d[n/2-1];
    return 0;
}

Measured memory_bytes: 1024
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;

inline int index(const vector<int> &xs, int x){
	return lower_bound(xs.begin(), xs.end(), x) - xs.begin();
}

int main(){
	int n, m;
	scanf("%d%d", &n, &m);

	vector<int> tx(n + 1), ty(n + 1);
	for(int i = 0; i < n; ++i){
		scanf("%d%d", &tx[i], &ty[i]);
	}
	tx[n] = ty[n] = (int)-2e9;
	
	vector<int> xs = tx, ys = ty;
	sort(xs.begin(), xs.end());
	xs.erase( unique(xs.begin(), xs.end()), xs.end() );
	sort(ys.begin(), ys.end());
	ys.erase( unique(ys.begin(), ys.end()), ys.end() );

	vector<vector<int> > s(xs.size() + 1, vector<int>(ys.size() + 1) );
	for(int i = 0; i < n; ++i){
		int ix = index(xs, tx[i]);
		int iy = index(ys, ty[i]);
		++s[ix][iy];
	}
	
	for(int i = 0; i <= xs.size(); ++i){
		for(int j = 1; j <= ys.size(); ++j){
			s[i][j] += s[i][j - 1];
		}
	}
	for(int j = 0; j <= ys.size(); ++j){
		for(int i = 1; i <= xs.size(); ++i){
			s[i][j] += s[i - 1][j];
		}
	}
	
	int x1, x2, y1, y2;
	for(int i = 0; i < m; ++i){
		scanf("%d%d%d%d", &x1, &y1, &x2, &y2);
		
		int ix1 = index(xs, x1);
		int iy1 = index(ys, y1);
		int ix2 = upper_bound(xs.begin(), xs.end(), x2) - xs.begin() - 1;
		int iy2 = upper_bound(ys.begin(), ys.end(), y2) - ys.begin() - 1;
		
		int c = s[ix2][iy2] - s[ix1-1][iy2] - s[ix2][iy1-1] + s[ix1-1][iy1-1];
		printf("%d\n", c);
	}
}

Measured memory_bytes: 98948
import java.util.Scanner;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;

public class Main {

    public static void swap(int x, int y) {
        int tmp = x;
        x = y;
        y = tmp;
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

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

        int cnt = 0;

        for (int i = 0; i < n; i++) {
            int mn = i;
            for (int j = i; j < n; j++) {
                if (a[j] < a[mn]) {
                    mn = j;
                }
            }
            if (mn != i) {
                int tmp = a[i];
                a[i] = a[mn];
                a[mn] = tmp;
                cnt++;
            }
        }

        for (int i = 0; i < n - 1; i++) {
            System.out.printf("%d ", a[i]);
        }
        System.out.println(a[n - 1]);
        System.out.println(cnt);

        sc.close();
    }
}


Measured memory_bytes: 26448
n, k = map(int, input().split())
x = list(map(int, input().split()))
p = n
for i in range(n):
  if x[i] > 0:
    p = i
    break
result = float('inf')
for i in range(k + 1):
  if p - i < 0 or p + k - i > n:
    continue
  if i == 0:
    result = min(result, x[p + k - 1])
  elif i == k:
    result = min(result, -x[p - k])
  else:
    l = x[p - i]
    r = x[p + (k - i) - 1]
    result = min(result, r - 2 * l, r * 2 - l)
print(result)


Measured memory_bytes: 14564
import java.util.Scanner;
public class Main {


    public static void main(String[] args) {


        Scanner scan = new Scanner(System.in);
        int N=scan.nextInt();

        String M=scan.next();

      if(M.length()<=N){System.out.println(M);}
      else{
          String Ns=M.substring(0,N);
          System.out.println(Ns+"...");
      }
    }

}



Measured memory_bytes: 27084
MOD = 10**9 + 7

N, K = map(int, input().split())
As = list(map(int, input().split()))

numInvs = [0] * N
for i, Ai in enumerate(As):
    for Aj in As[i+1:]:
        if Ai > Aj:
            numInvs[i] += 1

nums = [0] * N
for i, Ai in enumerate(As):
    for Aj in As:
        if Ai > Aj:
            nums[i] += 1

ans = 0
for numInv, num in zip(numInvs, nums):
    ans += numInv*K % MOD
    ans += num*K*(K-1)//2 % MOD
    ans %= MOD

print(ans)


Measured memory_bytes: 42588
#include <iostream>
 
using namespace std;
 
int juju(int n, int s, int v, int t)
{
    if(n == 0 && v == s){
        return 1;
    }
    if(v > s || n < 0){
        return 0;
    }
    int c = 0;
    for(int i = t+1; i <= 9; i++){
        c += juju(n-1, s, i+v, i);
    }
     
    return c;
}
 
int main()
{
    int n, s, c;
     
    while(1){
        cin >> n >> s;
        if(n == 0 && s == 0){
            break;
        }
 
        c = 0;
        for(int i = 0; i <= 9; i++){
            c += juju(n-1, s, i, i);
        }
         
        cout << c << endl;
    }
     
    return 0;
}

Measured memory_bytes: 1160
from itertools import product
from collections import Counter
N=int(input())
D=list(map(int, input().split()))
res=0
c=Counter(D)
if c[0]>0 or max(c.values())>2:print(0);exit()
if N>13:print(1);exit()
for b in product(*((d,24-d) for d in D)):
    d0, m= 0,1<<30
    for d in sorted(b):
        m=min((d-d0),24-(d-d0),m)
        d0=d
    m=min(d0,24-d0,m)
    res = max(res,m)
print(res)

Measured memory_bytes: 73752
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
#define rep(i, n) for(ll i = 0;i < n;i++)
#define all(i) i.begin(), i.end()
template<class T, class U> bool cmax(T& a, U b) { if (a<b) {a = b; return true;} else return false; }
template<class T, class U> bool cmin(T& a, U b) { if (a>b) {a = b; return true;} else return false; }

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

  ll n, k;
  cin >> n >> k;
  vl h(n);
  rep(i, n) {
    cin >> h[i];
  }

  sort(all(h));

  ll ans = 0;
  rep(i, max(n-k, 0LL)) {
    ans += h[i];
  }
  cout << ans << endl;
}


Measured memory_bytes: 1792
#include<stdio.h>
int main(void) {
  int a = 0, b = 0, c = 0, d = 0;
  int i;
  for(i = 0; i < 10; i++) {
    scanf("%d", &d);
    if(a <= d) {
      c = b;
      b = a;
      a = d;
    } else if(b <= d) {
      c = b;
      b = d;
    } else if(c <= d) {
      c = d;
    }
  }

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

Measured memory_bytes: 600
//ヘッダー
#include<bits/stdc++.h>
using namespace std;

//型定義
typedef long long ll;

//定数
const int INF=1e+9;
const int MOD=1e+9+7;

//REPマクロ
#define REP(i,n) for(int i=0;i<(ll)(n);i++)
#define REPD(i,n) for(int i=n-1;i>=0;i--)
#define REP2(i,a,b) for(int i=a;i<(ll)(b);i++)
#define REPD2(i,a,b) for(int i=a;i>(ll)(b);i--)

//vectorの扱い
#define ALL(x) (x).begin(),(x).end() //sortなどの引数省略
#define SIZE(x) ((ll)(x).size()) //size
#define MAX(x) *max_element(ALL(x)) //最大値
#define MIN(x) *min_element(ALL(x)) //最小値

//グローバル変数


//ライブラリ挿入

const int H_MAX=80;
const int W_MAX=80;
const int A_MAX=80;
const int B_MAX=80;

vector<vector<vector<bool>>> dp(H_MAX+1,vector<vector<bool>>(W_MAX+1,vector<bool>(1+A_MAX*(H_MAX+W_MAX),false)));

int main(){
    int H,W;
    cin>>H>>W;
    vector<vector<int>> A(H,vector<int>(W)),B(H,vector<int>(W));
    REP(i,H){
        REP(j,W){
            cin>>A[i][j];
        }
    }

    REP(i,H){
        REP(j,W){
            cin>>B[i][j];
        }
    }
    dp[0][0][0]=true;
    dp[1][0][0]=true;
    dp[0][1][0]=true;
    
    REP(i,H){
        REP(j,W){
            REP(v,1+A_MAX*(H_MAX+W_MAX)){
                if(abs(v-abs(A[i][j]-B[i][j]))<=A_MAX*(H_MAX+W_MAX)){
                    dp[i+1][j+1][v]=dp[i+1][j+1][v]||dp[i][j+1][abs(v-abs(A[i][j]-B[i][j]))];
                    dp[i+1][j+1][v]=dp[i+1][j+1][v]||dp[i+1][j][abs(v-abs(A[i][j]-B[i][j]))];
                }
                if(v+abs(A[i][j]-B[i][j])<=A_MAX*(H_MAX+W_MAX)){
                    dp[i+1][j+1][v]=dp[i+1][j+1][v]||dp[i][j+1][v+abs(A[i][j]-B[i][j])];
                    dp[i+1][j+1][v]=dp[i+1][j+1][v]||dp[i+1][j][v+abs(A[i][j]-B[i][j])];
                }
            }
        }
    }
    REP(v,1+A_MAX*(H_MAX+W_MAX)){
        if(!dp[H][W][v]) continue;
        cout << v <<endl;
        return 0;
    }
}

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

int N, K;
vector<ll> h;
ll dp[100005];

ll f (int i)
{
	if (i >= N-1) return 0;

	if (dp[i] != -1) return dp[i];

	ll ans = 1e9;
	for (int j = i+1; j <= i+K && j < N; ++j)
		ans = min(ans, abs(h[i]-h[j]) + f(j));

	return dp[i] = ans;
}

int main()
{
	ios::sync_with_stdio(false);
	memset(dp, -1, sizeof(dp));

	cin >> N >> K;
	h.resize(N);

	for (int i = 0; i < N; ++i)
		cin >> h[i];

	cout << f(0) << endl;

	return 0;
}

Measured memory_bytes: 9600
#include <ctype.h>
#include <stdio.h>

int main(int argc, const char * argv[]) {
    int i=0;
    char str[1210];
    
    //scanf?????????
    gets(str);
    
    while(str[i]){
        //?°????????????£??????
        if(islower(str[i]))  str[i]=toupper(str[i]);
        //??§???????????£??????
        else if(isupper(str[i]))  str[i]=tolower(str[i]);
        i++;
    }
    
    printf("%s\n",str);
    
    return 0;
}

Measured memory_bytes: 524
import java.util.*;
class Main{
	Scanner sc=new Scanner(System.in);
	int[] su=new int[100];
	int sum;
	void go(){
		int n=sc.nextInt();
		
		for(int i=0; i<n; i++){
			su[i]=sc.nextInt();
		}
		for(int i=n-1; i>0; i--){
			for(int j=0; j<i; j++){
				if(su[j]>su[j+1]){
					sum++;
					int a=su[j+1];
					su[j+1]=su[j];
	  			  	su[j]=a;
				}
			}
		}
		for(int i=0; i<n; i++){
			if(i<n-1){
				System.out.print(su[i]+" ");
			}else{
				System.out.println(su[i]);
			}
		}
		System.out.println(sum);
	}
	public static void main(String[]agrs){
		new Main().go();
	}
}

Measured memory_bytes: 26416
#include <iostream>
#include <cstring>
#include <cstdio>
using namespace std;

int fri[100010];

int find(int x){
  if( fri[x] == x ) return x;
  else return fri[x] = find(fri[x]);
}

void uf_union(int x, int y){
  x = find(x);
  y = find(y);
  fri[x] = y;
}

int main(){

  int n,m,q;
  cin >> n >> m;

  // init
  for(int i=0; i<n; i++) fri[i] = i;

  //
  for(int i=0; i<m; i++){
    int u,v; scanf("%d %d",&u,&v);
    uf_union(u,v);
  }

  cin >> q;
  for(int i=0; i<q; i++){
    int u,v; scanf("%d %d",&u,&v);
    if( find(u) == find(v) ) printf("yes\n");
    else printf("no\n");
  }


}

Measured memory_bytes: 2204
#include <stdio.h>

int main()
{
    int N,M,C;
    int B[21];
    int A[100][21];

    scanf("%d %d %d", &N, &M, &C);
    for(int i=0;i<M;i++){
        scanf("%d",&B[i]);
    }

    for(int i=0;i<N;i++){
        for(int j=0;j<M;j++){
            scanf("%d",&A[i][j]);
        }
    }
    int AC=0;
    int judge=0;
    for(int i=0;i<N;i++){
        for(int j=0;j<M;j++){
            judge+= A[i][j]*B[j];
        }
        if(judge+C >0){
            AC++;
        }
        judge=0;
    }
    printf("%d",AC);
    return 0;
}

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

int main() {
  string s;
  vector<int> a;
  cin >> s;
  
  for(int i=0;i<=s.size()-3;i++) {
    a.push_back(abs(stoi(s.substr(i,3)) - 753));
  }
  
  cout << *min_element(a.begin(),a.end()) << "\n";
  return 0;
}

Measured memory_bytes: 256
N = int(input())
A=[]
for i in range(N):
    A.append(int(input()))
max_A=max(A)
ind_max = A.index(max_A)
A2=A
del A2[ind_max]
max2_A=max(A2)
for i in range(N):
    if i==ind_max:
        print(max2_A)
    else:
        print(max_A)

Measured memory_bytes: 12532
n = int(input())
a = dict()

for i in range(n):
    s = input()
    a.setdefault(s, 0)
    a[s] += 1

ans = []
mx = 0
for key, value in a.items():
    if mx < value:
        mx = value
        ans = [key]
    elif mx == value: ans.append(key)

ans.sort()
for i in ans: print(i)


Measured memory_bytes: 32096
# -*- coding:utf-8 -*-
import copy

def solve():
    N, M = list(map(int, input().split()))
    A, B = [], []
    edge = {}  # edge[v] := 頂点vの隣接リスト

    """方針
    Nは高々8なので全探索してみる
    """
    for i in range(M):
        a, b = list(map(int, input().split()))
        # 始点は0とする
        if not a-1 in edge:
            edge[a-1] = []
        edge[a-1].append(b-1)
        if not b-1 in edge:
            edge[b-1] = []
        edge[b-1].append(a-1)

    rest_list = [i for i in range(N)]  # まだ到達してない残りの頂点のリスト
    rest_list.remove(0)  # 0が始点なので除外しておく
    now_v = 0  # 現在の頂点

    def dfs(now_v, rest_list):
        if len(rest_list) == 0:
            # 残りの頂点が存在しない（すべての頂点に到達成功した）
            return 1
        ans = 0  # パスの数
        for u in rest_list:
            if not u in edge[now_v]: continue  # 現在の頂点now_vから、次の頂点uに辺が存在しないならスキップ
            tmp_rest_list = copy.deepcopy(rest_list)
            tmp_rest_list.remove(u)
            ans += dfs(u, tmp_rest_list)
        return ans

    ans = dfs(0, rest_list)
    print(ans)


if __name__ == "__main__":
    solve()


Measured memory_bytes: 3444
#include <iostream>
#include <cstdlib>

using namespace std;
#define ll long long

long long N,K;
long long prev1,next1;
int debug=0;

int main(){
    cin >> N >> K;
    long long  i=0;

    if(N>K){
        long long tmp;
        tmp = N/K;
        N = N - tmp* K;
        if(debug){
            cout << "new N=" << N << endl;
        }
    }

    prev1=N;
    while(true){
        next1 = abs(prev1-K);

        if(debug){
            cout << i << "..." << "prev,next=" << prev1 <<"," <<next1 <<endl;
        }

        if(next1 > prev1)
            break;
        prev1 = next1; 
        i++;
    }

    cout << prev1 << endl;
    return 0;


}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(int i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(int i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(int i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define uniq(x) (x).erase(unique((x).begin(), (x).end()), (x).end())

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n;
    cin >> n;
    map<int, int> a;
    vector<pair<int, int>> b;
    int ans = 0;
    
    rep(i, n) {
        int ta;
        cin >> ta;
        a[ta]++;
    }
    
    for (auto x : a) {
        a[x.first] = x.second - (x.second - 1) / 2 * 2;
    }
    
    for (auto x : a) {
        if (x.second == 2) {
            int t = -1;
            
            for (auto y : a) {
                if (x.first >= y.first) {
                    continue;
                }
                
                if (y.second == 2) {
                    t = y.first;
                    break;
                }
            }
            
            if (t == -1) {
                ans--;
                a[x.first] = 1;
                continue;
            }
            
            a[x.first] = 1;
            a[t] = 1;
        }
    }
    
    for (auto x : a) {
        ans += x.second;
    }
    
    cout << max(0, ans) << endl;
    return 0;
}

Measured memory_bytes: 4992
#include <iostream>
#include <algorithm>
#include <vector>
 
#define FAST_IO ios_base::sync_with_stdio(false), cin.tie(nullptr)
using namespace std;
const int INF = 1e9 + 5;
 
signed main() {
    FAST_IO;
 
    int n, k;
    cin >> n >> k;
    vector<int> stones(n);
    for (int i = 0; i < n; i++) cin >> stones[i];
 
    vector<int> dp(n, INF); // dp[i] : Minimum cost to reach stone i.
    dp[0] = 0; // Base case, we start on the first stone so cost to reach it is 0.
 
    for (int i = 0; i < n; i++) { // i represents the stone the frog is currently at.
        for (int j = i + 1; j <= i + k; j++) { // j represents a potential stone for the frog to jump to.
            if (j < n)
                // Storing the total minimum cost to reach stone j from stone i.
                dp[j] = min(dp[j], dp[i] + abs(stones[j] - stones[i]));
        }
    }
    cout << dp[n - 1];
    return 0;
}

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

UL C[1000001] = {};
UL N;
UL A[200000];

int main() {
	scanf("%u", &N);
	rep(i, N) scanf("%u", A + i);
	sort(A, A + N);
	UL ans = 0;
	rep(i, N) {
		C[A[i]]++;
		if (C[A[i]] > 1) continue;
		for (UL j = A[i] + A[i]; j <= 1000000; j += A[i]) C[j]++;
	}
	rep(i, N) if (C[A[i]] <= 1) ans++;
	printf("%u", ans);

	return 0;
}


Measured memory_bytes: 8508
// Problem Code: abc162_d

#include <iostream>
#include <string>
#include <unordered_map>

using namespace std;

long long triplets(int N, string& S) {
	long long cnt = 1;
	unordered_map<char, int> freq;

	for (char& c: S)
		freq[c]++;
	cnt *= 1LL * freq['R'] * freq['G'] * freq['B'];
	
	for (int i = 0; i < N; i++)
		for (int j = i + 1; j < N; j++) {
			// remove triplets where j - i == k - j
			int k = 2 * j - i;
			if (k < N && S[i] != S[j] && S[j] != S[k] && S[k] != S[i])
				cnt--;
		}
	
	return cnt;
}

int main() {
	int N;
	string S;
	cin >> N >> S;
	cout << triplets(N, S);
	return 0;
}

Measured memory_bytes: 3644
import java.util.*;

public class Main{
	
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
  	int[] a=new int[3];
    for(int i=0;i<3;i++){
      a[i]=sc.nextInt();
    }
    Arrays.sort(a);
    System.out.println(a[0]+a[1]);
  }
}


Measured memory_bytes: 21200
#include <iostream>
#include <vector>
#include <math.h>
#include <string>
#include <algorithm>
#include <functional>
#include <queue>

using namespace std;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

int main() {
  int n;
  int ac = 0;
  int wa = 0;
  int tle = 0;
  int re = 0;
  cin >> n;

  for (int i = 0; i < n; i++)
  {
    string s = "";
    cin >> s;
    if (s == "AC") {
      ac++;
    } else if (s == "WA")
    {
      wa++;
    } else if (s == "TLE")
    {
      tle++;
    } else
    {
      re++;
    }
  }

  cout << "AC x " << ac << endl;
  cout << "WA x " << wa << endl;
  cout << "TLE x " << tle << endl;
  cout << "RE x " << re << endl;  
  
  return 0;
}


Measured memory_bytes: 3220
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <assert.h>
#include <numeric>
#include <time.h>

using namespace std;

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

int main()
{
  int n, m;
  cin >> n >> m;
  vector<int> h(n), a(m), b(m);
  for (int i = 0; i < n; i++)
  {
    cin >> h[i];
  }
  for (int i = 0; i < m; i++)
  {
    cin >> a[i] >> b[i];
    a[i]--;
    b[i]--;
  }

  vector<vector<int>> graph(n);
  for (int i = 0; i < m; i++)
  {
    graph[a[i]].push_back(b[i]);
    graph[b[i]].push_back(a[i]);
  }

  vector<bool> good(n, true);
  for (int i = 0; i < n; i++)
  {
    for (int j : graph[i])
    {
      if (h[i] <= h[j])
      {
        good[i] = false;
        continue;
      }
    }
  }

  int ans = 0;
  for (bool higher : good)
  {
    if (higher)
    {
      ans++;
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 9596
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef pair<string , int> s_i;
typedef vector<ll> vel;
typedef vector<int> vei;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> ve_vel;
typedef vector<vector<int>> ve_vei;
typedef vector<vector<char>> ve_vec;
typedef vector<vector<bool>> ve_veb;
typedef vector<vector<string>> ve_ves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pub push_back
#define puf push_front
#define pob pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
//#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
const int64 INF = 1LL << 58;
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 (a>b) { a=b; return 1; } return 0; }
template<typename T> void remove(T & vector, unsigned int index){vector.erase(vector.begin() + index);}

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

    ll S; cin >> S;
    ll a = 1000000000;
    ll x1 = 0, y1 = 0, x2 = a, y2 = 1, x3, y3; 
    x3 = (a - S % a) % a; y3 = (S + x3) / a;
    cout << x1 << " " << y1 << " " << x2 <<  " " << y2 << " " << x3 << " " << y3 << endl;

    return 0;

}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main()
{
     short a{0};
     int b{0};
    cin>>a;
    vector<double>vec(0);
    for(int j{0};j<a;j++){cin>>b;
vec.push_back(b);
    }
    double alttoplam{0};
    for(auto er:vec){
        alttoplam+=1/er;
    }
    cout<<1/alttoplam;
}

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


int main() {
int long long N;
int long long Ans=0;
  cin >> N;
  for(int i=1;i<=N;i++){
    Ans=Ans+(N/i*i+i)*(N/i)/2;
  }
  cout << Ans;

}

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

int main(){
    long long h,w,m,ans(0);
    cin >> h >> w;

    m = h*w;

    if(h==1||w==1){
        puts("1");
        return 0;
    }

    if(m%2==0){
        cout << m/2 << endl;
        return 0;
    }else{
        cout << m/2+1 << endl;
        return 0;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define iterator IT
#define SIZ(V) V.size()
#define FS(a) fixed<<setprecision(a)
using namespace std;
namespace STARTER {
    int MAX(int a,int b){return a>b?a:b;}
    int MIN(int a,int b){return a<b?a:b;}
    int ABS(int a){return a<0?-a:a;}
    int GCD(int a,int b){return !b?a:GCD(b,a%b);}
    int LCM(int a,int b){return a/GCD(a,b)*b;}
    int QSM(int a,int b,int p){int ret=1;while(b)(b&1)&&(ret=ret*a%p),a=a*a%p,b>>=1;return ret;}
    int ROUND(double a){return a+0.5;}
}
using STARTER::MAX;
using STARTER::MIN;
using STARTER::ABS;
using STARTER::GCD;
using STARTER::LCM;
using STARTER::QSM;
using STARTER::ROUND;
const int maxN=2005;int n,x,y,s[maxN][maxN],ans[maxN],t[maxN*maxN];
int main() {
    cin>>n>>x>>y;
    for(int i=1;i<n;i++)for(int j=i+1;j<=n;j++)s[i][j]=min(j-i,ABS(x-i)+1+ABS(y-j));
    for(int i=1;i<n;i++)for(int j=i+1;j<=n;j++)t[s[i][j]]++;
    for(int k=1;k<n;k++)cout<<t[k]<<'\n';
    return 0;
}

Measured memory_bytes: 17024
#ABC133-E Virus Tree 2
"""
問題：
n頂点の木(辺の情報が与えられる)に対して、k色で頂点を塗り分ける時、距離が2以下の頂点に対して同じ色
を塗ってはいけないという制約下で、何通りの塗り分け方が存在するか。

解法：
ある頂点xに対して、その親が既に塗られている場合、xの子の数をcとして、xの子の塗り方の総数は
(k-2)Pc
なお、木の頂点の塗り方をk通りとした場合、それ以降は子の塗り方さえ考えれば良いので、x自体の塗り方の総数は
既に考慮されている。
"""
import sys
readline = sys.stdin.buffer.readline
def even(n): return 1 if n%2==0 else 0
mod = 10**9+7

#順列modあり
def factrial_memo(n=10**5+1,mod=10**9+7): # [1,n)までの階乗と逆元の階乗
    fact = [1, 1]  # fact[n] = (n! mod mod)
    factinv = [1, 1]  # factinv[n] = ((n!)^(-1) mod mod)
    inv = [0, 1]  # factinv 計算用
    for i in range(2, n + 1):
        fact.append((fact[-1] * i) % mod)
        inv.append((-inv[mod % i] * (mod // i)) % mod)
        factinv.append((factinv[-1] * inv[-1]) % mod)
    return fact,factinv # warning:1-indexed list

#そのまま使う
fact,factinv = factrial_memo()

def permutation(n,m,mod=10**9+7): #nPm
    return fact[n]*factinv[n-m]%mod

n,k = map(int,readline().split())

g = [[] for _ in range(n)] #隣接リスト
for i in range(n-1):
    a,b = map(int,readline().split())
    a,b = a-1,b-1
    g[a].append(b)
    g[b].append(a)

#親のノードに子を入れてくdfs
root = 0 #根
stack = [0]
parent = [0]*n
order = []
while stack:
    x = stack.pop()
    order.append(x)
    for i in g[x]:
        if i == parent[x]:
            continue
        parent[i] = x
        stack.append(i)

ans = 1

for x in order: #親
    if len(g[x]) == 1 and x != root:
        continue
    if len(g[x]) >= k: #条件を満たす彩色ができない
        print(0)
        exit()
    if x == root:
        ans *= permutation(k,len(g[x])+1)
        ans %= mod
    else:
        ans *= permutation(k-2,len(g[x])-1)
        ans %= mod

print(ans)

Measured memory_bytes: 66548
#include <bits/stdc++.h>
using namespace std;
 
long long gcd(long x,long y){
    if(y==0)return x;

    return gcd(y,x%y);
}
long long lcm(long x,long y){
    return x*y/gcd(x,y);
}

int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}


int main()
{
    long long x,ans=0;
    cin>>x;

    ans=x/11;
    ans*=2;

    if(x%11!=0){
        if(x%11<=6){
            ans+=1;
        }else{
            ans+=2;
        }
    }

    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
ll n;
int main(){
    int a,b,c;
    cin>>a>>b>>c;
    cout<<c<<" "<<a<<" "<<b<<endl;
    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
n = int(input())
h = list(map(int, input().split()))
cnt = 0
while h and not h[-1]:
    h.pop()
while h:
    for l in reversed(range(len(h))):
        if not h[l]:
            l += 1
            break
    for i in range(l, len(h)):
        h[i] -= 1
    while h and not h[-1]:
        h.pop()
    cnt += 1
print(cnt)


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

int main(){
    string s; cin >> s;

    if(s == "ARC") cout << "ABC" << endl;
    else cout << "ARC" << endl;

    return 0;
}

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

#define ASC(vec) vec.begin(), vec.end() 
#define DESC(vec) vec.rbegin(), vec.rend()
#define rep(i, n) for(int i = 0; i < n; i++)
#define Rep(i, n) for(int i = 1; i < n; i++)
#define In(vec) rep(i, n) cin>>vec[i]; 
#define ANS(s) cout << s << endl;
#define inc(a, b) cin >> a >> b;

int main(){
	map<string,string> tamesi;
	vector<string> tamesi2 = {"Sunny","Cloudy","Rainy"};
	tamesi[tamesi2[0]] = tamesi2[1];
	tamesi[tamesi2[1]] = tamesi2[2];
	tamesi[tamesi2[2]] = tamesi2[0];

	string a;

	cin>>a;
	cout<<tamesi[a];
	return 0;
}


Measured memory_bytes: 3604
#include <iostream>
#include <iomanip>
#include <complex>
#include <vector>
#include <cassert>
#include <algorithm>
#include <cmath>
#include <queue>
#include <utility>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)

const double EPS = 1e-10;
const double INF = 1e12;
#define X real();
#define Y imag();
#define LE(n,m) ((n)<(m)+EPS)
#define GE(n,m) ((n)+EPS < (m))
#define EQ(n,m) (abs((n)-(m)) < EPS)

typedef complex<double> P;
typedef vector<P> VP;
struct L : vector<P> {
  L(P a, P b){push_back(a); push_back(b);}
};
struct C{
  P p;
  double r;
  C(const P& p, const double& r) : p(p), r(r){}
};

double dot(P a, P b){
  return (conj(a)*b).X;
}
double cross(P a, P b){
  return (conj(a)*b).Y;
}

int ccw(P a, P b, P c){
  b -= a;
  c -= a;
  if(cross(b,c)>EPS) return +1;
  if(cross(b,c)<-EPS) return -1;
  if(dot(b,c)<EPS) return +2;
  if(norm(b) < norm(c)) return -2;
  return 0;
}

VP crosspointCC(const C& a, const C& b){
  VP ps;
  P ab = b.p-a.p;
  double dist = abs(ab);
  double l = ((a.r*a.r-b.r*b.r)/dist + dist)/2;
  double n= sqrt(a.r*a.r - l*l);
  P mid = a.p + (ab)*(l/dist);
  P hei = ab * (n/dist) * P(0,1);
  ps.push_back(mid+hei);
  ps.push_back(mid-hei);
  return ps;
}

int main(){
  while(1){
    int n;
    cin >> n;
    if(n==0) break;

    vector<C> c;
    for(int i=0; i<n; i++){
      double x,y,r;
      cin >> x >> y >> r;
      c.push_back(C(P(x,y), r));
    }

    VP ps;
    ps.push_back(c[0].p);
    for(int i=0; i<n-1; i++){
      VP cp = crosspointCC(c[i], c[i+1]);
      ps.push_back(cp[0]);
      ps.push_back(cp[1]);
    }
    ps.push_back(c[n-1].p);

    int numpoints = ps.size();
    vector<vector<double> > adj((int)ps.size(), vector<double>(ps.size(), INF));
    for(int i=0; i<numpoints; i++){
      for(int j=i; j<numpoints; j++){
        bool flag = true;
        for(int k=i+1; k<j; k++){
          if(k%2==0 && ccw(ps[i], ps[j], ps[k])==1){
            flag = false;
          }
          if(k%2!=0 && ccw(ps[i], ps[j], ps[k])==-1){
            flag = false;
          }
        }
        if(flag){
          adj[i][j] = abs(ps[i]-ps[j]);
        }
      }
    }

    for(int k=0; k < numpoints; k++){
      for(int i=0; i<numpoints; i++){
        for(int j=0; j<numpoints; j++){
          adj[i][j] = min(adj[i][j], adj[i][k]+adj[k][j]);
        }
      }
    }

    cout << fixed;
    cout << setprecision(10);
    cout << adj[0][numpoints-1] << endl;
  }
  return 0;
}

Measured memory_bytes: 3344
#include"bits/stdc++.h"
using namespace std;
using ll = int64_t;

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

    ll ans = N;
    for (ll i = 1; i * i <= N; i++) {
        if (N % i != 0) {
            continue;
        }

        //(i, N / i)が候補
        ans = min(ans, (i - 1) + (N / i - 1));
    }

    cout << ans << endl;
}

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

int main() {
  long int h;
  long int n = 0;
  long int ac = 1;
  cin >> h ;
  while (h > 1) {
    n++;
    h = ceil( h / 2 );
    ac = ac + pow(2,n) ;
  }
  cout << ac << endl;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
using namespace std;
typedef long long ll;
#define ALL(v) (v).begin(), (v).end()
const int mod = 1e9+7;

int main() {
    string S;
    cin >> S;
    int g_cnt = 0, p_cnt = 0;
    int win = 0, lose = 0;
    for (int i = 0; i < S.size(); i++) {
        if (g_cnt == p_cnt) {
            g_cnt++;
            if (S[i] == 'p') lose++;
        } else {
            p_cnt++;
            if (S[i] == 'g') win++;
        }
    }

    cout << win - lose << endl;
    return 0;
}


Measured memory_bytes: 512
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int n,a=0,m;
    cin>>n;
    m=n;
    while(n!=0){
        a+=n%10;
        n/=10;
    }
    if(m%a==0)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


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


#define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl '\n'
// User defined sizeof macro
# define my_sizeof(type) ((char *)(&type+1)-(char*)(&type))


int main()

{
    optimize();
    int a,b;
    cin>>a>>b;

    string s1=to_string(a);
    string cpa;
    string s2=to_string(b);
    string cpb;
    for(int i=0;i<b ;i++) cpa+=s1;
//    cout<<cpa;
//    cout<<endl;
    for(int i=0;i<a ;i++) cpb+=s2;
//    cout<<cpb;
//     cout<<endl;
     if(cpa>cpb)
        cout<<cpb;
     else cout<<cpa;















    return 0;
}





Measured memory_bytes: 3724
//yabei... yutaka1999 ga Digit wo Accept shiteiru...
#include<iostream>
#include<cmath>
using namespace std;
int n,m,c,d,p,Q,R,e,f;
int main(){
	while(true){
		cin>>n>>m>>c;if(!n){break;}
		p=0;Q=100000000;R=100000000;
		while(true){
			d=(p*n-c)/m;
			if(p*n==d*m+c){
				if(Q+R>abs(p)+abs(d)){
					Q=abs(p);
					R=abs(d);
				}
				if(Q+R==abs(p)+abs(d)){
					e=abs(p)*n+abs(d)*m;
					f=Q*n+R*m;
					if(f>e){
						Q=abs(p);
						R=abs(d);
					}
				}
			}
			d=(p*n+c)/m;
			if(p*n+c==d*m){
				if(Q+R>abs(p)+abs(d)){
					Q=abs(p);
					R=abs(d);
				}
				if(Q+R==abs(p)+abs(d)){
					e=abs(p)*n+abs(d)*m;
					f=Q*n+R*m;
					if(f>e){
						Q=abs(p);
						R=abs(d);
					}
				}
			}
			p++;
			if(p>100000){break;}
		}
		cout<<Q<<' '<<R<<endl;
	}
}

Measured memory_bytes: 1160
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <math.h>
#include <complex>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <functional>
#include <assert.h>
#define int long
#define ll long long
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define SZ(x) x.size()
#define fi first
#define se second
const int INF = 1e9;
using namespace std;

template<class t> using vc=vector<t>;
template<class t> using vvc=vc<vc<t>>;

using pi=pair<int,int>;
using vi=vc<int>;

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

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout<<fixed<<setprecision(20);

    int N,M; cin >> N >> M;
    if(N==M) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

#define mod (int)1e9+7
#define yes cout<<"YES"<<endl
#define no cout<<"NO"<<endl
#define pb push_back
#define make_pair mp
#define pi acos(-1)


int main()
{
    int m1,m2,d1,d2;

    scanf("%d%d%d%d",&m1,&d1,&m2,&d2);
    if (m1<m2)
    {
        printf("1");
    }
    else if (m1>m2)
    {
        printf("1");
    }
    else
    {
        printf("0");
    }




    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字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    ごちゃごちゃ場合分けを考える前に全探索は考えましたか？
*/

int main(){
    int N; cin >> N;
    vector<ll> a(N);
    for(int i=0; i<N; i++) cin >> a[i];

    sort(a.begin(), a.end(), greater<ll>());
    vector<ll> ans;

    for(int i=0; i<N-1; i++){
        if(a[i] == a[i+1]){
            ans.push_back(a[i]);
            i++;
            if(ans.size() == 2) break;
        }
    }

    if(ans.size() != 2) cout << 0 << endl;
    else cout << ans[0]*ans[1] << endl;
}

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

long long f(long long x){
	if(x <= 1) return 1;
	else return x * f(x-2);
}

int main(){
	//freopen("i.txt","r",stdin);
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	long long n;
	
	cin >> n;
	if(n % 2 == 1){
		cout << 0;
		return 0;
	}
	
	long long ans = 0LL;
	long long ten = 10LL;
	while(ten <= n){
		ans += (n / ten);
		ten *= 5LL;
	}
	cout << ans;
	
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import deque

MOD = 10 ** 9 + 7

N = int(input())
graph = [[] for _ in range(N+1)]
for i,x in enumerate(input().rstrip().split(),1):
    x = int(x)
    graph[i].append(x)
    graph[x].append(i)

# 各深さから来ている (0個、1個、2個以上) の分布を 確率 mod MODで持つ。

half = (MOD + 1) // 2

def merge(dp,dp1):
    L = len(dp1)
    for i in range(L):
        # 0個,1個,2個以上
        a,b,c = dp[i]
        d,e,f = dp1[i]
        a,b,c = a*d, a*e + b*d, a*f + b*e + b*f + c*d + c*e + c*f
        a %= MOD
        b %= MOD
        c %= MOD
        dp[i] = (a,b,c)
    return

def dfs(v,parent = None):
    dp = None
    L = 0
    for u in graph[v]:
        if u == parent:
            continue
        dp1 = dfs(u,v)
        if dp is None:
            dp = dp1
        else:
            if len(dp) < len(dp1):
                dp,dp1 = dp1,dp
            # 2個以上が入っているインデックス
            if L < len(dp1):
                L = len(dp1)
            merge(dp,dp1)
    if dp is None:
        dp = deque()
    else:
        # 2個以上あるときに、0個化する
        for i in range(L):
            a,b,c = dp[i]
            dp[i] = (a+c,b,0)
    dp.appendleft((half,half,0))
    return dp

dp = dfs(0)

answer = sum(b for a,b,c in dp)
answer *= pow(2,N+1,MOD)
answer %= MOD
print(answer)

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

int A,B;

void DFS(queue<char> array,char c,int Acount,int Bcount){


  array.push(c);
  /*queue<char> tmp = array;
  cout << number << " " << A << " " << B << " " << Acount << " " << Bcount;
  for(int i=0;!tmp.empty();i++){
    cout << tmp.front();
    tmp.pop();
  }
  cout << endl;*/

  if(A == Acount && B == Bcount){
    for(int i=0;i<A+B;i++){
      cout << array.front();
      array.pop();
    }
    cout << endl;
    return;
  }

if( (Acount == 5 && Bcount <= 3) || (Bcount == 5 && Acount <= 3) ){ //???????????????????????¶????????????????????????????????¶?????¨?????´??????????????????
  return;
}





  if(A>Acount){
    DFS(array,'A',Acount+1,Bcount);
  }
  if(B>Bcount){
    DFS(array,'B',Acount,Bcount+1);
  }
}

int main(){

  cin >> A >> B;
  queue<char> s;
  DFS(s,'A',1,0);
  DFS(s,'B',0,1);
  return 0;
}

Measured memory_bytes: 3096
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;

int main() {
  int N;
  double xy[8][2];
  int num[] = {0, 1, 2, 3, 4, 5, 6, 7};
  cin >> N;
  for (int i = 0;i < N;i++) {
    cin >> xy[i][0] >> xy[i][1];
  }
  double sum = 0;
  int nnn = 0;
  do {
    for (int i = 0;i < N;i++) {
      if (i != N - 1) {
        sum += sqrt(pow((xy[num[i]][0] - xy[num[i + 1]][0]), 2) + pow((xy[num[i]][1] - xy[num[i + 1]][1]), 2));
      }
    }
    nnn++;
  } while (next_permutation(num, num + N));
  cout << std::setprecision(12) << sum / nnn << endl;
  return 0;
}


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

using namespace std;

int main()
{
	string str1,str2;

	char alphabet[27];
	char replace1[27],replace2[27];

	for(int i=0;i<26;i++)
	{
		alphabet[i] = '-';
		replace1[i] = '-';
		replace2[i] = '-';
	}

	cin >> str1 >> str2;

	for(int i=0;i<str1.size();i++)
	{
		if(str1[i] != str2[i])
		{
			char index1 = str1[i] - 'a';
			char index2 = str2[i] - 'a';
			//未登録 or 対応する文字が登録済みの文字の場合は真
			if(replace1[index1] == '-')
			{
				replace1[index1] = str2[i];
				replace2[index2] = str1[i];
			}
		}
	}

	for(int i=0;i<str1.size();i++)
	{	
		char index = str1[i] - 'a';
		if(replace1[index] != '-' && replace1[index] != str2[i])
		{
			cout << "No" << endl;
			return 0;
		}
		
		index = str2[i] - 'a';
		if(replace2[index] != '-' && replace2[index] != str1[i])
		{
			cout << "No" << endl;
			return 0;
		}

	}

	cout << "Yes" << endl; 

	return 0;
}

Measured memory_bytes: 776
#include <iostream>
#include <string>
#include <cctype>
#include <fstream>

using namespace std;

void my_reverse(string *s){
    char temp;
    int first =0,last = (*s).size()-1;
    while(first < last){
        temp = (*s)[first];
        (*s)[first] = (*s)[last];
        (*s)[last] = temp;
        first++;last--;
    }

    return;
}

int main(){
    
    int n,ra,rb,rlen;
    string str,op,rstr;

    cin >> str >> n;
    for(int i=0;i<n;i++){
        cin >> op >> ra >> rb;
        rlen = rb - ra +1;
        if(op == "replace"){cin >> rstr;}
        if(op == "print"){
            cout << str.substr(ra,rlen) << endl;
        }else{
            if(op == "reverse"){
                rstr = str.substr(ra,rlen);
                my_reverse(&rstr);
            }
            str.replace(ra,rlen,rstr);
        }
    }
    return 0;
}


Measured memory_bytes: 3192
// nb_9960
  #include <bits/stdc++.h> 
  using namespace std; 
  #define fi(i,a,n) for (ll i=a; i < n; i++) 
  #define ll long long
  #define pb push_back 
  #define mp make_pair 
  #define F first 
  #define S second 
  #define all(x) x.begin(), x.end() 
  #define clr(x) memset(x, 0, sizeof(x)) 
  #define sortall(x) sort(all(x)) 
  typedef pair<ll, ll> pl; 
  typedef vector<ll> vl; 
  typedef vector<pl> vpii; 
  #define sz(a) int((a).size())
  #define tr(c,i) for(typeof(c).begin() i = c.begin(); i != c.end(); i++)
  #define present(c,x) (c.find(x) != c.end())
  #define cpresent(c,x) (find(all(c),x) != c.end())

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

    ll t = 1; 
    // cin >> t;

    while (t--) { 
      ll n;
      cin>>n;
      if(n==1){
        cout<<0<<endl;
      }else{
        cout<<1<<endl;
      }
    } 
    return 0; 
  } 


Measured memory_bytes: 3616