akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

typedef long double ld;
typedef long long ll;

const int mod = 1e9 + 7;

int add(int x, int y) {
  x += y;
  if (x >= mod)
    x -= mod;
  return x;
}

int sub(int x, int y) {
  return add(x, mod - y);
}

int mul(ll x, ll y) {
  return x * y % mod;
}

int uul(int &x, int y) {
  return x = mul(x, y);
}

void udd(int &x, int y) {
  x = add(x, y);
}

int bin(int x, int to) {
  int y = 1;
  while (to) {
    if (to & 1)
      y = mul(x, y);
    x = mul(x, x);
    to >>= 1;
  }
  return y;
}

int inv(int x) {
  assert(x != 0);
  return bin(x, mod - 2);
}

const int M = 307;

bitset<M> c[M];

int n, k;
int d[M][M][M];
int pw[M];

void pre() {
  for (int i = 0; i < M; ++i)
    pw[i] = bin(2, i);

  for (int n = 0; n < M; ++n) {
    d[n][0][0] = 1;
    for (int k = 0; k + 1 < M; ++k)
      for (int r = 0; r + 1 < M; ++r) {
        int nx = pw[r];
        int ny = sub(pw[n], nx);
        int cur = d[n][k][r];
        udd(d[n][k + 1][r], mul(nx, cur));
        udd(d[n][k + 1][r + 1], mul(ny, cur));
      }
  }
}

void read() {
  cin >> n;
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < n; ++j) {
      int x;
      cin >> x;
      c[i][j] = x;
    }
}

void gaub() {
  int last = 0;
  for (int i = 0; i < n; ++i) {
    int x = -1;
    for (int j = last; j < n; ++j)
      if (c[j][i]) {
        x = j;
      }

    if (x == -1)
      continue;

    swap(c[last], c[x]);
    for (int j = last + 1; j < n; ++j)
      if (c[j][i])
        c[j] ^= c[last];

    ++last;
  }

  k = last;

  cerr << "k = " << k << endl;
}


void kill() {
  int ans = 0;

  for (int m = k; m <= n; ++m) {
    int cnt = mul(d[n][n][m], d[m][n][k]);
    uul(cnt, bin(2, (n - m) * n));
    udd(ans, cnt);
  }

  uul(ans, inv(d[n][n][k]));


  cout << ans << endl;
}


int main() {
#ifdef LOCAL
  assert(freopen("h.in", "r", stdin));
#endif

  ios_base::sync_with_stdio(false);

  pre();
  read();
  gaub();
  kill();
}



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

using namespace std;

struct Eins 
{
	vector<long long> st;
	int n;
	Eins(int n) : n(n) {st.resize(n + 1);}
	void update(int i,int val) 
	{
		for (;i <= n;i += i&-i) st[i] += val;
	}
	long long get(int i)
	{
		long long ans = 0;
		for (;i; i -= i &-i) ans += st[i];
		return ans;
	}
	long long get(int L,int R)
	{
		return get(R) - get(L-1);
	}
	void update(int L,int R,int val)
	{
		update(L,val);
		if (R < n) update(R + 1,-val);
	} 
};

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n,d,m;
	cin >> n >> d >> m;
	vector<pair<int,int>> a(n);
	vector<int> b;
	for (int i = 0;i < n;++i) cin >> a[i].first >> a[i].second;
	sort(a.begin(),a.end());
	for (int i = 0;i < n;++i) {
		b.emplace_back(a[i].first);
	}
	b.resize(unique(b.begin(),b.end()) - b.begin());
	b.emplace_back(1e9 + 1);
	Eins Tree(b.size());
	auto get = [&](int u) {return lower_bound(b.begin(),b.end(),u) - b.begin() + 1;};
	for(int i = 0;i < n;++i) {
		int add = a[i].second;
		if (i) add -= a[i-1].second;
		Tree.update(get(a[i].first),add);
	}
	long long ans = 0;
	for (int i = 0;i < n;++i) {
		long long h = Tree.get(get(a[i].first)) ;
		if (h <= 0) continue;
		int add = (h + m-1) / m;
		ans += add;
		Tree.update(i+1,upper_bound(b.begin(),b.end(),min(1ll * a.back().first,2ll * d + a[i].first )) - b.begin(),-m * add);		
	}
	cout << ans;
}

Measured memory_bytes: 4340
N = int(input())
T = [int(t) for t in input().split()]
M = int(input())
PX = [tuple(map(int, input().split())) for _ in range(M)]

total_time = sum(T)
for i in range(M):
    p, x = PX[i]
    print(total_time - T[p - 1] + x)


Measured memory_bytes: 3060
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

int main() {
	vector<int> kuku(0);
	for (int i = 1; i < 10; i++) {
		for (int j = 1; j < 10; j++) {
			kuku.push_back(i*j);
		}
	}
	int n;
	cin >> n;
	bool ans = false;
	for (int i : kuku) {
		if (i == n) ans = true;
	}
	if (ans) cout << "Yes";
	else cout << "No";
}

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

int main() {
	int N, a;
	cin >> N;
	int c1, c2, c4;
	c1 = c2 = c4 = 0;
	for (int i = 0;i < N;i++) {
		cin >> a;
		if (a % 2) c1++;
		else if (a % 4) c2 = 1;
		else c4++;
	}
	c1 += c2;
	if (c1 > c4 + 1)
		cout << "No" << endl;
	else
		cout << "Yes" << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		
		int a = stdIn.nextInt();
		int b = stdIn.nextInt();
		int c = stdIn.nextInt();
		int d = stdIn.nextInt();
		
		int e = a + b;
		int f = c + d;
		
		if (e == f) {
			System.out.println("Balanced");
		} else if (e < f) {
			System.out.println("Right");
		} else {
			System.out.println("Left");
		}
	}
}

Measured memory_bytes: 23252
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
#define pq_pair_tB priority_queue <pair<ll,ll>, vector<pair<ll,ll> > , greater<pair<ll,ll> > > 
#define pq_pair_ts priority_queue <pair<ll,ll> > //第二成分の大きさが関係ない
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}
ll gcd(ll a, ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a, ll b){return a/gcd(a,b)*b;}


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll N , H, W;
    cin >> N >> H >> W;
    
    cout << (N-H+1) * (N-W+1) << endl;
    
    
    //cout << fixed << setprecision(16) << ans << endl;
    return 0;
}


Measured memory_bytes: 764
#include<bits/stdc++.h>
using namespace std;
#define fo(i, k, n) for (int i = k; i <= n; ++ i)
#define fod(i, k, n) for (int i = k; i >= n; -- i)
template <typename T, typename U>
static inline void maxx (T &x, U y) {
  if (x < y) {
    x = y;
  }
}
template <typename T, typename U>
static inline void minn (T &x, U y) {
  if (x > y) {
    x = y;
  }
}
template<typename T>
void read (T &x) {
  x = 0;
  T neg = 1;
  register T c = getchar ();
  if (c == '-') {
    neg = -1;
  }
  while (c < 48 || c > 57) {
    c = getchar ();
  }
  for (; c < 48 || c > 57; c = getchar ());
  for (; c <= 57 && c >= 48; c = getchar ()) {
    x = (x << 3) + (x << 1) + (c & 15);
  }
  x *= neg;
}
template<typename T>
void write (T x) {
  bool neg = 0;
  if (x < 0) {
    x *= -1;
    neg = 1;
  }
  char snum[65];
  int i = 0;
  do {
    snum[++ i] = x % 10 + '0';
    x /= 10;
  }
  while (x);
  //-- i;
  if (neg) {
    putchar ('-');
  }
  while (i > 0) {
    putchar (snum[i --]);
  }
}
///declare
int main () {
  if (fopen ("test.inp", "r")) {
    freopen ("test.inp", "r", stdin);
  }
//  else {
//    freopen(".inp", "r", stdin);
//    freopen(".out", "w", stdout);
//  }
//  ios_base :: sync_with_stdio (0);
//  cin.tie (nullptr);
//  cout.tie (nullptr);
  string s;
  cin >> s;
  if (s == "Sunny") {
    cout << "Cloudy";
  }
  else if (s == "Cloudy") {
    cout << "Rainy";
  }
  else {
    cout << "Sunny";
  }
}


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

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

  int a_pos = str.find('A');
  int z_pos;
  for (int i = str.size() - 1; i >= 0; i--) {
    if (str.at(i) == 'Z') {
      z_pos = i;
      break;
    }
  }
  cout << z_pos - a_pos + 1 << endl;
}


Measured memory_bytes: 640
import java.io.*;

class Main{
 public static void main(String[] arg) throws IOException{
  BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
  String str = br.readLine();

  int x = Integer.parseInt(str), h=x/3600, m, s;
  x %= 3600;
  m = x/60;
  x %= 60;
  s = x;

  System.out.println(h + ":" + m + ":" + s);
 }
}

Measured memory_bytes: 24328
#! /usr/bin/env python
# coding: utf-8


def slove(n, a, b):
    if (b - a) % 2 != 0:
        return "Borys"
    else:
        return "Alice"


if __name__ == "__main__":
    m = input().split(" ")
    n = int(m[0])
    a = int(m[1])
    b = int(m[2])

    print(slove(n, a, b))

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


int main() {
    int  n,k;
    cin >> n >> k;

    vector <int> f(n,0);
    for (int i=0; i<n; i++){
        cin >> f[i];

    }

    sort(f.begin(), f.end());
    int ans = 0;
    for (int i=0; i<k; i++){
        ans += f[i];
    }

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

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

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

  string s; cin >> s;
  int K; cin >> K;

  set<string> st;
  for (int i = 0; i < s.size(); i++)
    for (int j = 0; j < min(5, (int)s.size()); j++)
      if (i+j < s.size()) st.insert(s.substr(i, j+1));
  int count = 0;
  for (string ans : st) {
    if (++count == K) {
      cout << ans << "\n";
      break;
    }
  }
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i < (int)(n); i++)
#define Sort(a) sort(a.begin(), a.end())
typedef long long int ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
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;}

int main(){
    ll n;
    cin >> n;
    vll a(n);
    rep(i, n){
        cin >> a[i];
    }
    bool f[4] = {false, false, false};
    int ans = 1;
    REP(i, n){
        if(a[i-1] > a[i]){
            if(f[2]){
               f[2] = false; 
               ans++;
            }
            else {
                f[0] = true;
            }
        }
        else if(a[i-1] < a[i]){
            if(f[0]){
                f[0] = false;
                ans++;
            }
            else {
                f[2] = true;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

int main(){
	#ifdef EVAL
		freopen("input.txt", "r", stdin);
		//freopen("output.txt", "w", stdout);
	#endif
	int N;
	cin >> N;
	string S;
	cin >> S;
	if(N < 3200){
		cout << "red";
	}else{
		cout << S;
	}
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

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

			StringBuilder sb = new StringBuilder();
			sb.append(s.charAt(0));
			sb.append(s.length() - 2);
			sb.append(s.charAt(s.length() - 1));
			System.out.println(sb);
		}
	}
}


Measured memory_bytes: 21588
#include<iostream>
#include<utility>
#include<stack>
#include<string>
using namespace std;

char map[9][9];
int dx[12] = {1,2,3,0,0,0,-1,-2,-3,0,0,0};
int dy[12] = {0,0,0,1,2,3,0,0,0,-1,-2,-3};
		
int main()
{
	int n;
	cin >> n;
	for(int i=1; i<=n; i++){
		// mapの初期化
		for(int j=1; j<=8; j++){
			string s; cin >> s;
			for(int k=1; k<=8; k++){map[j][k]=s[k-1];}}
		// 初めに爆発する爆弾の座標
		pair<int, int> p;
		cin >> p.second >> p.first;
		stack< pair<int, int> > stk;
		stk.push(p);
		map[p.first][p.second] = '0';
		// 爆発の連鎖が終わるまでループを回る
		while(stk.size()){
			p = stk.top(); stk.pop();
			for(int i=0; i<12; i++){
				int nx = p.first+dx[i], ny = p.second+dy[i];
				if(0<nx && nx<=8 && 0<ny && ny<=8 && map[nx][ny]=='1'){
					pair<int,int> tp(p.first+dx[i], p.second+dy[i]);
					stk.push(tp);
					map[p.first+dx[i]][p.second+dy[i]] = '0';
				}
			}
		}
		// mapの出力
		cout << "Data " << i << ":\n";
		for(int j=1; j<=8; j++){
			for(int k=1; k<=8; k++){cout << map[j][k];}
			cout << endl;}
	}
	return 0;
}

Measured memory_bytes: 1212
int main(void)
{
    int a, b, c, n;
    int ans = 0;
    scanf("%d %d %d %d", &a, &b, &c, &n);
    for (int i = 0; i <= n/a; i++)
    {
        for (int j = 0; j <= (n-a*i)/b; j++)
        {
            int k = 0;
            if((n - a*i - b*j) % c == 0 && (k = (n - a*i - b*j)/c) >= 0)
            {
                ans++;
            }
        }
        
    }
    printf("%d\n", ans);
    
    
    return 0;
}

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

struct Problem {

	void Solve() {
		UL N, M; cin >> N >> M;
		UL C[3]; rep(i, N) C[i] = -1;
		rep(i, M) {
			UL s, c; cin >> s >> c;
			if (c == 0 && s == 1 && N != 1) { cout << -1 << endl; return; }
			s--;
			if(C[s] != -1 && C[s] != c) { cout << -1 << endl; return; }
			C[s] = c;
		}
		rep(i, N) {
			if (C[i] == -1) {
				if (N != 1 && i == 0) cout << 1;
				else cout << 0;
			}
			else cout << C[i];
		} cout << endl;
	}

	Problem();
};
int main() {
	unique_ptr<Problem> p(new Problem());
	p->Solve();
	return 0;
}
Problem::Problem() {
	cout << fixed << setprecision(10);
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

constexpr int P = 1000000007;

ll powmod(ll n, ll k) {
    ll r = 1, t = n % P;
    for (; k != 0; k /= 2) {
        if (k & 1) r = r * t % P;
        t = t * t % P;
    }
    return r;
}
ll inv(ll n) {
    return powmod(n, P - 2);
}

vector<int> f0, f1;
void init(int n) {
    f0.resize(n + 1);
    f0[0] = 1;
    for (int i = 1; i <= n; i++) {
        f0[i] = (ll)f0[i - 1] * i % P;
    }
    f1.resize(n + 1);
    f1[n] = inv(f0[n]);
    for (int i = n; i > 0; i--) {
        f1[i - 1] = (ll)f1[i] * i % P;
    }
}
ll fact(int k) {
    return f0[k];
}
ll comb(int n, int k) {
    if (n < k || k < 0) return 0;
    return (ll)f0[n] * f1[k] % P * f1[n - k] % P;
}

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

    init(n);

    ll r = 0;
    for (int k = (n + 1) / 2; k <= n - 1; k++) {
        ll a = comb(k - 1, n - 1 - k) * fact(k) % P * fact(n - 1 - k) % P;
        if (k < n - 1) {
            r += a;
        } else {
            r = a * k - r;
            r %= P; if (r < 0) r += P;
        }
    }

    cout << r << endl;

    return 0;
}

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

using namespace std;

int main()
{   
    int A,B,C,D,E,F;
    cin>>A>>B>>C>>D>>E>>F;
    
    A*=100; B*=100;

    int W=-1,S;
    for(int a=0;a<=F;a+=A) 
    for(int b=0;a+b<=F;b+=B) 
    for(int c=0;a+b+c<=F;c+=C)
    for(int d=0;a+b+c+d<=F;d+=D){
        int w=a+b;
        int s=c+d;
        if(w==0) continue;
        if(s>w/100*E) continue;
        if(W==-1 or s*(W+S)>S*(w+s)){
            W=w; S=s;
        }
    }
    cout<<W+S<<' '<<S<<endl;

}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#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; }

typedef long long ll;

using namespace std;


int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin>>n;
  int l=1<<n;
  vector<int>a(l+1);
  rep(i,l)cin>>a[i];
  vector<pair<int,int>>dp(l);
  rep(i,l)
  {
    int ti=i,used=0;
    dp[i]={i,l};
    vector<int>id;
    id.push_back(0);
    id.push_back(i);
    id.push_back(l);
    while(used!=i)
    {
      int ni=((ti-1-used)&i)|used;
      id.push_back(dp[ni].first);
      id.push_back(dp[ni].second);
      used|=i-ni;
    }
    sort(all(id));
    id.erase(unique(all(id)),id.end());
    sort(all(id),[&](int x,int y){return a[x]>a[y];});


    dp[i]={id[0],id[1]};

  }
  vector<int>res(l+1);
  //rep(i,l)cout<<dp[i].first<<dp[i].second<<endl;
  rep(i,l-1)res[i+1]=max(res[i],a[dp[i+1].first]+a[dp[i+1].second]);
  rep(i,l-1)cout<<res[i+1]<<"\n";
  cout<<endl;

  return 0;

}


Measured memory_bytes: 7168
#include <iostream>
#include <queue>
using namespace std;
 
int main()
{
    string s,t="";
    cin >> s;
    string words[] = {"dream","dreamer","erase","eraser"};
    bool result = false;
    queue<string> q;
    q.push(t);
    while(!q.empty() && !result)
    {
        string qt = q.front();
        q.pop();
        for(int i = 0; i < 4; ++i)
        {
            string tmp = qt+words[i];
            if(s == tmp)
            {
                result = true;
            }
            else if(s.length() >= tmp.length()
            && tmp == s.substr(0,tmp.length()))
            {
                q.push(tmp);
            }
        }
    }
    if(result)
    {
        cout << "YES" << endl;
    }
    else
    {
        cout << "NO" << endl;
    }
}

Measured memory_bytes: 1408
from math import floor
def gcd(a,b):
    if b == 0:
        return a
    else:
        return gcd(b,a%b)
T = int(input())
for i in range(T):
    A,B,C,D = map(int,input().split())
    if B > D or B > A:
        print("No")
    else:
        if A%B>C:
            print("No")
        else:
            d = gcd(B,D%B)
            r = (A%B)%d
            if B - d + r > C:
                print("No")
            else:
                print("Yes")

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <iomanip>
#include <cmath>
#include <vector>
#include <set>
#include <algorithm>

using namespace std;

int main()
{
    int N, K;
    cin >> N >> K;
    vector<long long> A(N);
    for (int i = 0; i < N; i++)
    {
        cin >> A[i];
        if (i + 1 > K)
        {
            if (A[i] > A[i-K])
            {
                cout << "Yes" << endl;
            }
            else
            {
                cout << "No" << endl;
            }
        }
    }
    return 0;
}


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

using namespace std;

typedef long long  ll;

#define SIZ 1000000000

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
		
	ll n, cnt = 0;
	cin >> n;
	
	vector<ll> v(n);
	for(ll i= 0; i < n ;i++) cin >> v[i];
	
	for(ll i = 0; i < n; i++){
		if((i + 1)%2 != 0 && v[i]%2 != 0){
			cnt++;
		}
	}
	
	cout << cnt << "\n";
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<ll,ll> P;

void Main() {
  ll a[3];
  rep(i,3) R a[i];
  sort(a,a+3);
  if(a[0]!=a[1]&&a[1]==a[2]) pr("Yes");
  else if(a[0]==a[1]&&a[1]!=a[2]) pr("Yes");
  else pr("No");
}

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


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ALDS1_2_C
{
    class Stablesort
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var input = Console.ReadLine().Split(' ');

            var bubbleArray = new string[N];
            var selectArray = new string[N];
            for (int i = 0; i < N; i++)
            {
                bubbleArray[i] = input[i];
                selectArray[i] = input[i];
            }

            bubbleArray = BubbleSort(bubbleArray, N);
            selectArray = SelectionSort(selectArray, N);

            Print(bubbleArray, N);
            Console.WriteLine("Stable");

            Print(selectArray, N);
            var isStable = IsStable(bubbleArray, selectArray, N);
            if (isStable)
            {
                Console.WriteLine("Stable");
            }
            else
            {
                Console.WriteLine("Not stable");
            }

        }

        public static string[] BubbleSort(string[] A, int N)
        {
            var flag = true;
            var count = 0;
            while (flag)
            {
                flag = false;
                for (int j = N - 1; j >= 1; j--)
                {
                    if (A[j][1] < A[j - 1][1])
                    {
                        var c = A[j];
                        A[j] = A[j - 1];
                        A[j - 1] = c;
                        flag = true;
                        count++;
                    }
                }
            }
            return A;
        }

        public static string[] SelectionSort(string[] A, int N)
        {
            for (int i = 0; i <= N - 1; i++)
            {
                var minj = i;
                for (int j = i; j <= N - 1; j++)
                {
                    if (A[j][1] < A[minj][1])
                    {
                        minj = j;
                    }
                }
                if (A[i][1] != A[minj][1])
                {
                    var c = A[i];
                    A[i] = A[minj];
                    A[minj] = c;
                }
            }
            return A;
        }

        public static void Print(string[] A, int N)
        {
            var prt = "";
            for (int i = 0; i < N; i++)
            {
                if (i == N - 1)
                {
                    prt += A[i];
                }
                else
                {
                    prt += A[i] + " ";
                }
            }
            Console.WriteLine(prt);
        }
        public static bool IsStable(string[] A,string[] B,int N)
        {
            bool stable = true;
            for (int i = 0; i < N; i++)
            {
                if (A[i][0] != B[i][0])
                {
                    stable = false;
                }
            }
            return stable;
        }
    }
}



Measured memory_bytes: 15952
#include<iostream>

using namespace std;

int main (){
  
  int x,m,n;
  
  cin>>x>>m>>n;
  
  if(x*m > n) cout<<n<<endl;
  else if(n > x*m) cout<<x*m<<endl;
  else if(x*m == n) cout<<n<<endl;
  
  return 0;
  
}
  

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

using namespace std;

vector<int> pre, in;
int n;

void solve(int l, int r) {
	if (r - l == 1) {
		cout << in[l];
		if (in[l] != pre[0]) {
			cout << " ";
		}
	}
	else {
		for (int i = 0; i < n; i++) {
			for (int j = l; j < r; j++) {
				if (pre[i] == in[j]) {
					solve(l, j);
					solve(j + 1, r);
					cout << in[j];
					if (in[j] != pre[0]) {
						cout << " ";
					}
					return;
				}
			}
		}
	}
}

int main() {
	cin >> n;
	pre.resize(n);
	in.resize(n);
	for (int i = 0; i < n; i++) {
		cin >> pre[i];	
	}
	for (int i = 0; i < n; i++) {
		cin >> in[i];
	}

	solve(0, n);
	cout << endl;

	return 0;
}

Measured memory_bytes: 3088
N = int(input())

x = []
y = []
h = []
for i in range(N):
    x_, y_, h_ = map(int, input().split())
    x.append(x_)
    y.append(y_)
    h.append(h_)

for i in range(0,101):
    for j in range(0,101):
        for n, hn in enumerate(h):
            if hn > 0:
                tmph = hn + abs(i-x[n]) + abs(j-y[n])
                break
        count = 0
        for n in range(N):
            count += 1
            if h[n] != max(tmph - abs(i-x[n]) - abs(j-y[n]), 0):
                break
            if count == N:
                print(str(i) + ' ' + str(j) + ' ' + str(tmph))


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

signed main(void)
{
	map<char, int> mp;
	string s;
	cin >> s;
	rep(i, s.size())
	{
		mp[s[i]]++;
	}
	cout << mp['1'] << endl;
	return 0;
}


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

int main() {
  int q; cin >> q;
  set<int> st;
  for (int i = 0; i < q; i++) {
    int cmd; cin >> cmd;
    if (cmd == 0) {
      int x; cin >> x;
      st.insert(x);
      cout << st.size() << endl;
    }
    if (cmd == 1) {
      int x; cin >> x;
      cout << st.count(x) << endl;
    }
    if (cmd == 2) {
      int x; cin >> x;
      st.erase(x);
    }
    if (cmd == 3) {
      int l, r; cin >> l >> r;
      for (auto itr = st.lower_bound(l), end = st.upper_bound(r); itr != end; itr++) {
        cout << *itr << endl;
      }
    }
  }
}



Measured memory_bytes: 12356
use proconio::input;
use proconio::marker::Chars;

fn main() {
    input! {
        mut s: Chars,
    };
    s.reverse();
    loop {
        if s.len() == 0 {
            println!("YES");
            return;
        }
        if s[0..5].iter().zip("maerd".chars()).all(|(x,y)| *x == y) {
            s.drain(0..5);
            continue;
        }
        if s[0..5].iter().zip("esare".chars()).all(|(x,y)| *x == y) {
            s.drain(0..5);
            continue;
        }
        if s[0..6].iter().zip("resare".chars()).all(|(x,y)| *x == y) {
            s.drain(0..6);
            continue;
        }
        if s[0..7].iter().zip("remaerd".chars()).all(|(x,y)| *x == y) {
            s.drain(0..7);
            continue;
        }
        break;
    }
    println!("NO");
}


Measured memory_bytes: 2504
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define  fo(i,n) for(ll i=0;i<n;i++)
#define rfo(i,n) for(ll i=n;i>=0;i--)
#define fori(it, x) for (__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define pb push_back
#define deb(x) cout<< #x << " = "<<x<<endl;
#define F first
#define S second
#define MP make_pair
#define all(x) (x).begin(), (x).end()

void solve()
{
	ll n,x,t;
	cin>>n>>x>>t;
	if(n%x == 0)
	{
		cout<<(n/x)*t;
	}
	else
	{
		cout<<((n/x)+1)*t;
	}
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    solve();
    return 0;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h> 
    using namespace std;
    typedef long long ll;
    typedef pair<ll,ll> p;
    const int inf=(1<<30);
    #define rep(i,a,n)	for(int i=a;i<n;i++)
    #define rrep(i,a,n) for(int i=(a-1);i>=n;i--)
    	
    bool pairComparesecond(const p& firstElof, const p& secondElof)
    {
        return firstElof.second > secondElof.second;
    }
     
    ll bit[60];
     
    int main(){
    	ll n,k;
    	cin>>n>>k;	
    	ll a[100010];
    	rep(i,0,n){
    		cin>>a[i];
    	}
    	rep(i,0,n)rep(j,0,40){
    		ll d=1ll<<j;
    		if(d&a[i])bit[j]++;
    	}
    	ll dp[60][2];
    	rep(i,0,60)rep(j,0,2)dp[i][j]=-1;
    	dp[59][0]=0;
    	rrep(i,59,0){
    		ll d=1ll<<i;
    		if(dp[i+1][1]>=0)dp[i][1]=max(dp[i][1],dp[i+1][1]+d*max(bit[i],n-bit[i]));
    		if(dp[i+1][0]>=0){
    			if(d&k){
    				dp[i][0]=max(dp[i][0],dp[i+1][0]+d*(n-bit[i]));
    				dp[i][1]=max(dp[i][1],dp[i+1][0]+d*(bit[i]));
    			}
    			else dp[i][0]=max(dp[i][0],dp[i+1][0]+d*bit[i]);
    		}
    	}
    	cout<<max(dp[0][0],dp[0][1])<<endl;
     
    }

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i = a; i < b; i++)
#define REP(i, n) FOR(i, 0, n)
#define INF 999999999
typedef long long ll;
using namespace std;
int main() {
    int N, K;
    cin >> N >> K;
    int x[N];
    int dis = 0;
    REP(i, N) {
        cin >> x[i];
        if(x[i] > (K - x[i])) {
            dis += (K-x[i])*2;
        }else{
            dis += x[i]*2;
        }
    }
    cout << dis << endl;
}

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

cnt = [1 for i in range(N+1)]
flag = [0 for i in range(N+1)]
flag[1] = 1

for _ in range(M):
    x, y = map(int,input().split())
    if flag[x]:
        flag[y] = 1
    if cnt[x] == 1 and flag[x]:
        flag[x] = 0
    cnt[x] -= 1
    cnt[y] += 1

print(sum(flag))

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

namespace ProblemSet
{
    class ProblemSet
    {
        static void Main(string[] args)
        {
            string strN = Console.ReadLine();

            string[] strD = Console.ReadLine().Split(' ');

            var intD = new List<int>();

            for (int i = 0; i < strD.Length; i++)
            {
                intD.Add(int.Parse(strD[i]));
            }

            string strM = Console.ReadLine();

            string[] strT = Console.ReadLine().Split(' ');

            var intM = new List<int>();

            for (int i = 0; i < strT.Length; i++)
            {
                intM.Add(int.Parse(strT[i]));
            }

            int intIdx = 0;
            var intDSorted = intD.OrderBy(x => x).ToList();
            var intMSorted = intM.OrderBy(x => x).ToList();
            for (int i =0; i < intM.Count; i++)
            {
                //intIdx = intD.IndexOf(intM[i],intIdx);

                intIdx = intDSorted.IndexOf(intMSorted[i],intIdx);

                if (intIdx == -1)
                {
                    Console.WriteLine("NO");
                    return;
                }
                else
                {
                    intDSorted[intIdx] = 0;
                    intIdx += 1;
                }
            }

            Console.WriteLine("YES");
            return;

        }
    }
}


Measured memory_bytes: 51812
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<queue>
#define F first
#define S second
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define all(n) n.begin(),n.end()
using namespace std;
bool used[2010][2010];
static const short dy[] = {0,1,0,-1};
static const short dx[] = {1,0,-1,0};
int h,w;
typedef pair<int,int> P;
 
int main(){
  int n;
  while(true){
    cin >> w >> h;
    if(w+h == 0)break;
    cin >> n;
    int x1[n],x2[n],y1[n],y2[n];
    vector<int> x,y;
    for(int i=0;i<n;i++){
      cin >> x1[i] >> y1[i] >> x2[i] >> y2[i];
      x.pb(x1[i]);y.pb(y1[i]);x.pb(x2[i]);y.pb(y2[i]);
    }
    x.pb(0); x.pb(w); y.pb(0); y.pb(h);
     
    sort(all(x)); sort(all(y));
    x.erase(unique(all(x)),x.end()); y.erase(unique(all(y)),y.end());
    
    int limx = x.size(),limy = y.size();
    rep(i,2010)rep(j,2010)used[i][j] = false;
    rep(i,limy)rep(j,limx)used[i][j] = i==limy-1||j==limx-1;        
    rep(i,n){
      x1[i] = find(all(x),x1[i])-x.begin();
      //cout << "x1[i] = " << x1[i];
      y1[i] = find(all(y),y1[i])-y.begin();
      //cout << ", y1[i] = " << y1[i];
      x2[i] = find(all(x),x2[i])-x.begin();
      //cout << ", x2[i] = " << x2[i];
      y2[i] = find(all(y),y2[i])-y.begin();
      //cout << ", y2[i] = " << y2[i] << endl;
  for(int k=x1[i];k<x2[i];k++){
    for(int j=y1[i];j<y2[i];j++)used[j][k] = true;
      }
    }
    int cnt = 0;

    queue<P> que;
  
   
     
    rep(i,limy){
      rep(j,limx){
    if(!used[i][j]){
      que.push(P(j,i));
      cnt++;
      used[i][j] = true;
      while(!que.empty()){
        P p = que.front(); que.pop();
        rep(k,4){
          int nx = p.F+dx[k],ny = p.S+dy[k];
          if(0<=nx && nx <limx-1 && 0<= ny && ny <limy-1 && !used[ny][nx]){
        used[ny][nx] = true;
        que.push(P(nx,ny));
          }
        }
 
      }
    }
      }
    }
   
 
 
    cout << cnt << endl;
 
 
 
 
 
  }
  return 0;
}

Measured memory_bytes: 5180
#include <stdio.h>
#include <string>
#include <iostream>
#include <iomanip>
#include <map>
#include <algorithm>
#include <vector>
#include <math.h>
#include <queue>
#include <set>
#define MOD (long long)1000000007
#define INF (long long)998244353
using namespace std;

int main(void){
    int n;
    string s;
    cin >> n >> s;
    vector<int> first(11,INF),last(11,-1);
    for(int i=0; i<n; i++){
        for(int j=0; j<=9; j++)if(first[j]==INF && s[i]=='0'+j)first[j]=i;
        
        for(int j=0; j<=9; j++)if(s[i]=='0'+j)last[j]=i;
    }
    long long ans=0;
    set<int> keys;
    for(int i=0; i<n; i++){
        for(int j=0; j<=9; j++){
            for(int k=0; k<=9; k++){
                if(first[j]<i && i<last[k]){
                    keys.insert(100*j+10*(s[i]-'0')+k);
                }
            }
        }
    }
    cout << keys.size() << endl;
    return 0;
}

Measured memory_bytes: 384
import sys
sys.setrecursionlimit(10**9)
N,M=map(int,input().split())

def find_negative_loop(n,w,es):
  dist=[float("inf")]*n
  #この始点はどこでもよい
  dist[1]=0
  
  for i in range(n):
    for j in range(w):
      e=es[j]
      if dist[e[1]]>dist[e[0]]+e[2]:
        dist[e[1]]=dist[e[0]]+e[2]
        if i==n-1:
          return True
  return False

def shortest_path(s,n,w,es):
  #s→iの最短距離
  #s:始点, n:頂点数, w:辺の数, es[i]:[辺の始点,辺の終点,辺のコスト]
  dist=[float("inf")]*n
  #d[i]: s→iの最短距離
  dist[s]=0

  while True:
    update=False
    for p,q,r in es:
      # e: 辺iについて [from,to,cost]
      if dist[p]!=float("inf") and dist[q]>dist[p]+r:
        dist[q]=dist[p]+r
        update=True
    if not update:
      break
      
  return dist

graph=[[] for _ in range(N+1)]
elist=[]
for _ in range(M):
  a,b,c=map(int,input().split())
  graph[a].append(b)
  elist.append((a,b,-c))
  
#remove unnecessary vertex and edge
visited=[None]*(N+1)
def check_reachable(u):
  visited[u]=True
  if u==N:
    reachable[u]=True
    return True
  elif reachable[u]!=None:
    return reachable[u]  

  cnt=0
  for v in graph[u]:
    if not visited[v]:
      ret=check_reachable(v)
      if ret:
        cnt+=1
        
  if cnt>0:
    reachable[u]=True
    return True
  else:
    return False

reachable=[None]*(N+1)
for i in range(1,N+1):
  if reachable[i]==None:
    visited=[False]*(N+1)
    check_reachable(i)
#print(reachable)
  
elist2=[]
for a,b,nc in elist:
  if reachable[b]:
    elist2.append((a,b,nc))
  
M2=len(elist2)
res1=find_negative_loop(N+1,M2,elist2)

if res1:
  print("inf")
else:
  res2=shortest_path(1,N+1,M2,elist2)
  print(-res2[N])

Measured memory_bytes: 4340
S = input()
L1 = "".join(["1" if i % 2 == 0 else "0" for i in range(len(S))])
L2 = "".join(["0" if i % 2 == 0 else "1" for i in range(len(S))])
num1 = sum([1 if s != l else 0 for s, l in zip(S, L1)])
num2 = sum([1 if s != l else 0 for s, l in zip(S, L2)])
print(min(num1, num2))


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

using namespace std;
typedef vector<int> vi;
#define loop(i,a,b) for(int i=(a); i<int(b); i++)
#define rep(i,b) loop(i,0,b)

vi riffle(vi const& v){
    int n = v.size();
    vi res(n);
    rep(i,n){
        if(i&1) res[i]=v[i/2+n/2];
        else res[i]=v[i/2];
    }
    return res;
}

vi cut(vi const& v, int k){
    int n = v.size();
    vi res(n);
    rep(i,n) res[i] = v[(i+k)%n];
    return res;
}

int main(){
    int n; cin >> n;
    n*=2;
    vi v(n);
    rep(i,n) v[i] = i+1;
    int m; cin>>m;
    rep(i,m){
        int op; cin>>op;
        if(op) v = cut(v,op);
        else v = riffle(v);
    }
    rep(i,n) cout << v[i] << "\n";
}

Measured memory_bytes: 1192
#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 1000000000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll, ll> p;
constexpr int MOD = 1000000007;
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;
}

int main() {
    string S;
    cin >> S;
    map<char, int> m;
    for(int i = 0; i < 4; i++) {
        m[S[i]]++;
    }
    for(map<char, int>::iterator it = m.begin(); it != m.end(); ++it) {
        if(it->second != 2) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.lang.*;

/**
 * ReversingNumbers
 */
public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int array[] = new int[n];

        for (int i = 0; i < n; i++) {
            array[i] = sc.nextInt();
        }
        System.out.print(array[n - 1]);

        for (int i = 1; i < n; i++) {
            System.out.print(" " + array[n - i - 1]);
        }
        System.out.println();
    }
}


Measured memory_bytes: 26556
#include<bits/stdc++.h>
using namespace std;
bitset<4000010>f;
int n, x, s;
int main(){
    ios::sync_with_stdio(false);
    cin >> n;
    f[0] = 1;
    for(int i = 1; i <= n; ++i){
        cin >> x;
        f |= f << x;
        s += x;
    }
    for(int i = (s + 1) / 2; i <=s; ++i){
        if(f[i]){
            cout << i << (char)10;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 1792
L = int(input())
v = list(map(int,bin(L)[:2:-1]))
N = len(v)+1
edges = []
unit = 1
for i in range(N-1):
    L -= unit*v[i]
    edges.append((i+1, i+2, 0))
    edges.append((i+1, i+2, unit))
    if v[i]:
        edges.append((i+1, N, L))
    unit *= 2

print(N, len(edges))
for a, b, c in edges:
    print(a, b, c)

Measured memory_bytes: 38384
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define rep(i,n) for (int i=0;i<(int)(n);i++)
#define codefor int test;scanf("%d",&test);while(test--)
#define yn(ans) if(ans)printf("Yes\n");else printf("No\n")
#define YN(ans) if(ans)printf("YES\n");else printf("NO\n")
#define umap unordered_map
#define uset unordered_set
using namespace std;
using ll = long long;
const int MOD=1000000007;
//入力系
void scan(int& a){scanf("%d",&a);}
void scan(long long& a){scanf("%lld",&a);}
template<class T> void scan(T& a){cin>>a;}
template<class T> void scan(vector<T>& vec){for(auto&& it:vec)scan(it);}
void in(){}
template <class Head, class... Tail> void in(Head& head, Tail&... tail){scan(head);in(tail...);}
//出力系
void print(const int& a){printf("%d",a);}
void print(const long long& a){printf("%lld",a);}
void print(const double& a){printf("%.15lf",a);}
template<class T> void print(const T& a){cout<<a;}
template<class T> void print(const vector<T>& vec){if(vec.empty())return;print(vec[0]);for(auto it=vec.begin();++it!= vec.end();){putchar(' ');print(*it);}}
void out(){putchar('\n');}
template<class T> void out(const T& t){print(t);putchar('\n');}
template <class Head, class... Tail> void out(const Head& head,const Tail&... tail){print(head);putchar(' ');out(tail...);}
//デバッグ系
template<class T> void dprint(const T& a){cerr<<a;}
template<class T> void dprint(const vector<T>& vec){if(vec.empty())return;cerr<<vec[0];for(auto it=vec.begin();++it!= vec.end();){cerr<<" "<<*it;}}
void debug(){cerr<<endl;}
template<class T> void debug(const T& t){dprint(t);cerr<<endl;}
template <class Head, class... Tail> void debug(const Head& head, const Tail&... tail){dprint(head);cerr<<" ";debug(tail...);}

int main(){
    int n,x;
    while(scanf("%d %d",&n,&x)!=EOF){
        if(n==0&&x==0)break;
        int ans=0;
        for(int i=1;i<n-1;i++){
            //if(i>x)break;
            for(int j=i+1;j<n;j++){
                //if(i+j>x)break;
                for(int k=j+1;k<n+1;k++){
                    //if(i+j+k>x)break;
                    if(i+j+k==x)ans++;
                }
            }
        }
        out(ans);
    }
}



Measured memory_bytes: 3208
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cassert>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
const int mod = 1000000007;
const int inf = 1ll << 61;
typedef pair<int, int> P;
typedef pair<int, P>PP;
int a[100005];
signed main() {
	int n; cin >> n;
	rep(i, n)cin >> a[i];
	int cnt = 0;
	rep(i, n - 1)if (a[i] < a[i + 1])cnt++; cout << cnt << endl;
}


Measured memory_bytes: 3880
from itertools import combinations, permutations

N = int(input())
xy = [list(map(int, input().split())) for _ in range(N)]


dists = {i: {j: 0 for j in range(N)} for i in range(N)}
for i,j in combinations(range(N), 2):
    x1, y1 = xy[i]
    x2, y2 = xy[j]
    dists[i][j] = dists[j][i] = ((x1 - x2)**2 + (y1 - y2)**2)**(0.5)

factorial_of_N = 0
total_dist = 0.0
for route in permutations(range(N)):
    prev_i = route[0]
    factorial_of_N += 1
    for i in route[1:]:
        total_dist += dists[prev_i][i]
        prev_i = i

print(total_dist / factorial_of_N)

Measured memory_bytes: 9336
#include <bits/stdc++.h>
 
#define pb push_back
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define ll long long
 
const int N=3e5+5,MAX=3e7,MOD=1e9+7;
 
using namespace std;
 
 
int n;
bool ate[60];
int main()
{
   	
 	
 
    	cin>>n;
    	std::vector<int> a(n),b(n),c(n);
    	for(int i=0;i<n;i++)cin>>a[i],a[i]--;
    	for(int i=0;i<n;i++)cin>>b[i];
    	for(int i=1;i<n;i++)cin>>c[i];
    	int ans = 0;
    	for(int i=0;i<n;i++){
    		ans+=b[a[i]];
    		if(i && a[i-1]==a[i]-1)ans+=c[a[i]];
    		

    	}	

    	

    	cout<<ans<<endl;


}

Measured memory_bytes: 256
from itertools import combinations_with_replacement
n,m,q = map(int, input().split())
abcd = [list(map(int, input().split())) for _ in range(q)]

ans = 0
for a in combinations_with_replacement(range(1,m+1), n):
  t = 0
  for i in abcd:
    if a[i[1]-1] - a[i[0]-1] == i[2]: t += i[3]
  if ans < t: ans = t
print(ans)

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

int main(){
	int N;
	cin >> N;
	vector<int> a(N);
	vector<int> b(N);
	for(auto &i:a)cin >> i;
	for(auto &i:b)cin >> i;
	
	int ans=0;
	for(int k=0;k<30;k++){
		int t=1<<k;
		vector<int> aa=a;
		vector<int> bb=b;
		for(auto &i:aa)i%=(t*2);
		for(auto &i:bb)i%=(t*2);
		
		sort(bb.begin(),bb.end());
		long long c=0;
		for(auto i:aa){
			c+=(int)(lower_bound(bb.begin(),bb.end(),2*t-i)-lower_bound(bb.begin(),bb.end(),t-i));
			c+=(int)(lower_bound(bb.begin(),bb.end(),4*t-i)-lower_bound(bb.begin(),bb.end(),3*t-i));
		}
		if(c%2==1)ans+=t;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3432
N, M, K = gets.chomp.split(" ").map(&:to_i)
F = Hash.new{|h, k| h[k] = []}
B = Hash.new{|h, k| h[k] = []}
M.times{
  a, b = gets.chomp.split(" ").map(&:to_i)
  F[a] << b
  F[b] << a
}
K.times{
  c, d = gets.chomp.split(" ").map(&:to_i)
  B[c] << d
  B[d] << c
}

root = Array.new(N+1)
c = Array.new(N+1, 0)
(0..N).each{|n|
  next if not root[n].nil?
  bef = [n]
  root[n] = n
  c[n] += 1
  until bef.empty? do
    nxt = []
    bef.each{|b|
      F[b].each{|f|
        next if not root[f].nil?
        root[f] = n
        c[n] += 1
        nxt << f
      }
    }
    bef = nxt
  end
}

ans = Array.new(N+1, 0)
(1..N).each{|n|
  root_n = root[n]
  ans[n] = c[root[n]] - F[n].size - B[n].count{|b| root[b] == root_n} - 1
}

ans.shift
puts ans.join(' ')


Measured memory_bytes: 36348
#include<iostream>
#include<cstring>
#include<cmath>
#include<queue>
#include<stack>
#include<list>
#include<map>
#include<set>
#include<sstream>
#include<string>
#include<vector>
#include<cstdio>
#include<ctime>
#include<bitset>
#include<algorithm>
#include<string>
#include<unordered_map>
using namespace std;
typedef long long ll;
#define lson l , mid , rt << 1
#define rson mid + 1 , r , rt << 1 | 1

int read() {
	int ans = 0, flag = 1;
	char ch = getchar();
	while ((ch > '9' || ch < '0') && ch != '-') ch = getchar();
	if (ch == '-') flag = -1, ch = getchar();
	while (ch >= '0' && ch <= '9') ans = ans * 10 + ch - '0', ch = getchar();
	return ans * flag;
}


int main()
{
	int a = read();
	int b = read();
	for (int i = 1; i <= 3; i++)
	{
		if (a == i || b == i)
		{
			continue;
		}
		else
		{
			printf("%d\n", i);
		}
	}
	return 0;
}













Measured memory_bytes: 256
#include <stdio.h>

int main()
{
    int n,d,x,a,Ans=0,i;

    scanf("%d %d %d",&n,&d,&x);
    for(i=0; i<n; i++)
    {
        scanf("%d",&a);
       // printf("d=%d a=%d\n",d,a);
        Ans+=(d-1)/a;
        //printf("Ans1=%d\n",Ans);
        Ans++;
        //printf("Ans2=%d\n",Ans);
    }
    printf("%d\n",Ans+x);

    return 0;
}


Measured memory_bytes: 128
import math
a,b = map(int, input().split())
a1 = a*12.5
a2 = (a+1)*12.5
b1 = b*10
b2 = (b+1)*10
if max(a1,b1) >= min(a2,b2):
  print(-1)
else:
  print(math.ceil(max(a1,b1)))

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<iomanip>
#include<ctime>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<bitset>
#define sqr(x) ((x)*(x))
#define fz1(i,n) for ((i)=1;(i)<=(n);(i)++)
#define fd1(i,n) for ((i)=(n);(i)>=1;(i)--)
#define fz0g(i,n) for ((i)=0;(i)<=(n);(i)++)
#define fd0g(i,n) for ((i)=(n);(i)>=0;(i)--)
#define fz0k(i,n) for ((i)=0;(i)<(n);(i)++)
#define fd0k(i,n) for ((i)=(long long)((n)-1);(i)>=0;(i)--)
#define fz(i,x,y) for ((i)=(x);(i)<=(y);(i)++)
#define fd(i,y,x) for ((i)=(y);(i)>=(x);(i)--)
#define fzin fz1(i,n)
#define fzim fz1(i,m)
#define fzjn fz1(j,n)
#define fzjm fz1(j,m)
#define ff(c,itr) for (__typeof((c).begin()) itr=(c).begin();itr!=(c).end();++itr)
#define rdst(st,len){static char ss[len];scanf(" %s",ss);(st)=ss;}
#define inc(x,y) {x+=(y);if(x>=mod)x-=mod;}
#define dec(x,y) {x-=(y);if(x<0)x+=mod;}
#define spln(i,n) (i==n?'\n':' ')
#define fac_init(n){fac[0]=fac[1]=inv[1]=fi[0]=fi[1]=1;fz(i,2,n){fac[i]=1ll*fac[i-1]*i%mod;inv[i]=1ll*(mod-mod/i)*inv[mod%i]%mod;fi[i]=1ll*fi[i-1]*inv[i]%mod;}}
using namespace std;
inline void read(int &x)
{
	char c;int f=1;
	while(!isdigit(c=getchar()))if(c=='-')f=-1;
	x=(c&15);while(isdigit(c=getchar()))x=(x<<1)+(x<<3)+(c&15);
	x*=f;
}
int n,m,i,j,cnt[65];
string st;
priority_queue<pair<int,string> > pq;
int query(string x)
{
	printf("? %s\n",x.c_str());
	fflush(stdout);
	int t;scanf("%d",&t);
	return t;
}
char chr(int x)
{
	if(x<=10){
		return x-1+'0';
	}
	if(x<=36){
		return x-11+'a';
	}
	return x-37+'A';
}
string merge(string x,string y)
{
	int i=0,j=0;
	string ans;
	while(i<x.size()||j<y.size()){
		if(i<x.size()&&(j>=y.size()||query(x.substr(0,i+1)+y.substr(j))+i+1+(y.size()-j)==n)){
			ans.push_back(x[i++]);
		}
		else{
			ans.push_back(y[j++]);
		}
	}
	cerr<<ans<<endl;
	return ans;
}
int main()
{
	fz1(i,62){
		st="";
		fz1(j,128){
			st.push_back(chr(i));
		}
		cnt[i]=128-query(st);
		n+=cnt[i];
	}
	fz1(i,62)if(cnt[i]){
		st="";
		fz1(j,cnt[i]) st.push_back(chr(i));
		pq.push(make_pair(-cnt[i],st));
	}
	while(pq.size()>1){
		pair<int,string> x=pq.top();pq.pop();
		pair<int,string> y=pq.top();pq.pop();
		pq.push(make_pair(x.first+y.first,merge(x.second,y.second)));
	}
	printf("! %s\n",pq.top().second.c_str());
	fflush(stdout);
	return 0;
}

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

using namespace std;

#define ll long long

const int maxN = 100005;

int main() {
	//freopen("in.in", "r", stdin);

	ios_base::sync_with_stdio(0);
	cin.tie(0);

	string s;
	cin >> s;

	int ok = 1;
	for (int i = 0; i < s.size(); i++) {
			if (i % 2 == 0 && s[i] != 'h') ok = 0;
			if (i % 2 == 1 && s[i] != 'i') ok = 0;
	}
	if (s.size() % 2 != 0) ok = 0;

	cout << (ok ? "Yes" : "No") << endl;

	return 0;
}

Measured memory_bytes: 256
N, M = (int(i) for i in input().split())  
e = sorted([[int(i) for i in input().split()] for i in range(N)])

result = 0
for x in e:
    if M > x[1]:
        M -= x[1]
        result += x[0] * x[1]
    else:
        result += x[0] * M
        break

print(result)




Measured memory_bytes: 22376
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e16;
const ll mod = 1000000007;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)

int main() {
  ll n; cin >> n;
  ll res = 0;
  rep(i, n) {
    ll tmp = i+1;
    res += tmp*(n/tmp)*(n/tmp+1)/2;
  }
  cout << res << endl;
}

Measured memory_bytes: 3640