akhauriyash/Code-Regression huggingface dataset:
//#define DEBUG

#include <iostream>
#include <vector>
#include <string>
#include <cstdlib>
#include <numeric>
#ifdef DEBUG
#include <bitset>
#endif
using namespace std;
typedef long long ll;

vector<ll> split(string S, char separator = ' ');
ll sum(vector<ll> A);
string insertSeparator(string S, vector<ll> index, char separator = ' ');

template <class T>
void print(vector<T> A) {
    if (A.size() == 0) cout << "nil" << endl;
    else {
        for (T i : A) cout << i << " ";
        cout << endl;
    }
}

int main() {
    string S;
    cin >> S;
    ll ans = 0;
    for (ll i = 0; i < (1 << (S.size() - 1)); i++) {
        vector<ll> index;
        for (ll j = 0; j < S.size() - 1; j++) {
#ifdef DEBUG
            cout << bitset<4>(i) << ", " << bitset<4>(1<<j);
            cout << ": " << (i & (1<<j)) << endl;
#endif
            if ((i & (1 << j)) != 0) index.push_back(j);
        }
        string t = insertSeparator(S, index);
        ll u = sum(split(t));
#ifdef DEBUG
        cout << "index: ";
        print(index);
        cout << u << " / " << t << "\n\n";
#endif
        ans += u;
    }
    cout << ans << endl;
}

vector<ll> split(string S, char separator) {
    S += separator;
    vector<ll> ret;
    string tmp;
    ll index = 0;
    for (ll i = 0; i < S.size(); i++) {
        if (S[i] == separator) {
            tmp = S.substr(index, i - index);
            ret.push_back(atoll(tmp.c_str()));
            index = i + 1;
        }
    }
    return ret;
}

ll sum(vector<ll> A) {
    return accumulate(A.begin(), A.end(), 0LL);
}

string insertSeparator(string S, vector<ll> index, char separator) {
    string ret;
    for (ll i = 0; i < S.size(); i++) {
        ret += S[i];
        for (ll j : index) {
            if (i == j) {
                ret += separator;
                break;
            }
        }
    }
    return ret;
}

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


int main(){
  int64_t N,M,result=0;
  int64_t temp;
  int64_t max_val =0;
  priority_queue<int>price;

  cin>>N>>M;

  for (size_t i = 0; i < N; i++)
  {
    cin>>temp;
    price.push(temp);
  }

  for (size_t i = 0; i < M; i++)
  {
    max_val = price.top();
    price.pop();
    price.push(max_val/2);
  }

  for (size_t i = 0; i < N; i++)
  {
    result += price.top();
    price.pop();
  }
  
  cout<<result<<endl;
  
}

Measured memory_bytes: 892
# -*- coding: utf-8 -*-
import numpy as np
import sys
from collections import deque
from collections import defaultdict
import heapq
import collections
import itertools
import bisect
from scipy.special import comb
import copy
sys.setrecursionlimit(10**6)


def zz():
    return list(map(int, sys.stdin.readline().split()))


def z():
    return int(sys.stdin.readline())


def S():
    return sys.stdin.readline()[:-1]


def C(line):
    return [sys.stdin.readline() for _ in range(line)]


N = z()
C, S, F = [0]*(N-1), [0]*(N-1), [0]*(N-1)
for i in range(N-1):
    c, s, f = zz()
    C[i], S[i], F[i] = c, s, f

ans = [0]*N
ans[N-2] = C[N-2] + S[N-2]
C_sum = [0]*(N-1)
C_sum[N-2] = C[N-2]
for i in reversed(range(0, N-2)):
    C_sum[i] = C_sum[i+1] + C[i]

for i in range(0, N - 1):
    ans[i] = S[i] + C[i]
    for j in range(i+1, N - 1):
        if (ans[i] <= S[j]):
            wait_time = S[j] - ans[i]
        else:
            wait_time = (-ans[i] % F[j])
        ans[i] += (wait_time + C[j])

    # for i in reversed(range(0, N-2)):
    #     if(S[i] + C[i] <= S[i+1]):
    #         print("つける")
    #         ans[i] = S[i] + C[i] + ans[i+1]
    #     else:
    #         print("つけない")
    #         wait_time = F[i+1] - ((S[i] + C[i]) % F[i+1])
    #         print("wait_time", wait_time)
    #         ans[i] = S[i] + C[i] + ans[i+1] + wait_time

    # else:
    #     ans[i] = ans[i+1] + C[i] + F[i]*2

for ans_ in ans:
    print(ans_)


Measured memory_bytes: 42480
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  string S;
  long K;
  cin >> S >> K;
  char ans = '0';

  for (int i = 0; i < S.size(); ++i) {
    if (S[i] != '1') {
      ans = S[i];
      break;
    }

    --K;
    if (K == 0) {
      ans = S[i];
      break;
    }
  }

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

Measured memory_bytes: 256
#![allow(non_snake_case, unused)]
use std::cmp::*;
use std::collections::*;
use std::f64::consts::*;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

const MOD: usize = 1_000_000_000 + 7;
fn main() {
    input! {
        n: usize,
    }
    /*
    T:0, A:1, C:2, G:3
    AGC: 132
    ACG: 123
    GAC: 312
    A.GC: 1032
    AG.C: 1302
    */

    let mut dp = vec![vec![vec![vec![0; 4]; 4]; 4]; n + 1];
    dp[0][0][0][0] = 1;

    for i in 0..n {
        for c3 in 0..4 {
            for c2 in 0..4 {
                for c1 in 0..4 {
                    for c0 in 0..4 {
                        if c2 == 1 && c1 == 3 && c0 == 2
                            || c2 == 1 && c1 == 2 && c0 == 3
                            || c2 == 3 && c1 == 1 && c0 == 2
                            || c3 == 1 && c1 == 3 && c0 == 2
                            || c3 == 1 && c2 == 3 && c0 == 2
                        {
                            continue;
                        }
                        dp[i + 1][c2][c1][c0] += dp[i][c3][c2][c1];
                        dp[i + 1][c2][c1][c0] %= MOD;
                    }
                }
            }
        }
    }

    let mut ans = 0;
    for c3 in 0..4 {
        for c2 in 0..4 {
            for c1 in 0..4 {
                ans += dp[n][c3][c2][c1];
            }
        }
    }

    println!("{}", ans % MOD);
}


Measured memory_bytes: 4352
#include<iostream>
using namespace std;
long long a[10];
int main()
{
    int n,ans=0;
    cin>>n;
    for(int i=0; i<n; i++)
        cin>>a[i];
    for(int i=0; i<n; i++)
        for(int j=i+1; j<n; j++)
            for(int k=j+1; k<n; k++)
                if( (a[i]+a[j]>a[k]) && (a[i]+a[k] > a[j]) && (a[j] + a[k] > a[i]) &&( a[i]!=a[j]) && (a[i]!=a[k]) && (a[j]!=a[k]))
                    ans++;
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
int main() {
  int a,b;
  cin>>a>>b;
  vector<int> gezi(a);
  int renshu=0;
  for(int i=0;i<a;i++){
    int c;
    cin>>c;
    gezi.at(i)=c;
  }
  for(int i=0;i<a;i++){
    if(gezi.at(i)>=b)
      renshu++;
    else
      continue;
  }
  cout<<renshu<<endl;
}

Measured memory_bytes: 640
from collections import defaultdict
n,k = map(int,input().split())
a = list(map(int,input().split()))
for i in range(n):
    a[i] -= 1
    a[i] %= k

S = [0]
for i in range(n):
    S.append((S[-1]+a[i])%k)

ans = 0
dic = defaultdict(int)
dic[0] = 1
for i in range(1,n+1):
    if i >= k:
        dic[S[i-k]] -= 1
    ans += max(0,dic[S[i]])
    dic[(S[i])] += 1

print(ans)

Measured memory_bytes: 41352
#!/usr/bin/env python3
n=int(input())
uvw=[list(map(int,input().split())) for i in range(n-1)]
graph=[[] for i in range(n+1)]
color=[-1]*(n+1)
for u,v,w in uvw:
    graph[u].append((v,w))
    graph[v].append((u,w))

color[1]=1
ne=[1]
while ne:
    t=ne.pop()
    for v,w in graph[t]:
        if color[v]==-1:
            ne.append(v)
            color[v]=color[t] if w%2==0 else (color[t]+1)%2

for i in range(1,n+1):
    print(color[i])

Measured memory_bytes: 52268
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int a,b;
  cin>>a>>b;
  if(a>b)
  {
    for(int i=0;i<a;i++)
    {
      cout<<b;
    }
    cout<<endl;
  }
  else if(b>a)
  {
     for(int i=0;i<b;i++)
    {
      cout<<a;
    }
    cout<<endl;
  }
  else
  {
    for(int i=0;i<a;i++)
    {
      cout<<a;
    }
    cout<<endl;
  }
  return 0;
}

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

#define ll long long ;

using namespace std;


const int N=1e6+5;

vector<int> v;

int n,ans,tc,q,m,a[N],k;

char s1[N],s2[N];

int main(){
    scanf("%d",&n);
    n--;
    long long ans=1LL*n*(n+1)/2;
    printf("%lld\n",ans);
}

Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<string> 
#include<algorithm>
const int INF=0xfffff;
using namespace std;
int ans[30];
int num[30];
int main(){
	int n;
	string str;
	for(int i=0;i<30;i++)ans[i]=INF;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>str;
		memset(num,0,sizeof(num));
		int len=str.length();
		for(int j=0;j<len;j++){
			num[str[j]-'a']++;
		}
		for(int i=0;i<26;i++){
			ans[i]=min(ans[i],num[i]);
		}
	}
	int flag=0;
	for(int i=0;i<26;i++){
		if(ans[i]!=0){
			flag=1;
			for(int j=0;j<ans[i];j++){
				cout<<char('a'+i);
			}
		}
	}
	if(flag==0)cout<<endl;
	return 0;
} 

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

int main() {
    int n;
    cin >> n;
    int t, a;
    cin >> t >> a;
    double min_diff = INT_MAX;
    int index = 0;
    for (int i = 0; i < n; i++) {
        int h;
        cin >> h;
        double tmp = t - 0.006 * h;
        double diff = abs(tmp - a);
        if (diff < min_diff) {
            min_diff = diff;
            index = i;
        }
    }
    cout << index + 1 << endl;
    return 0;
}


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

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

using namespace std;

int main(){
  int n,x;
  cin>>n>>x;
  int l[n];
  REP(i,n){
    cin>>l[i];
  }

  int d=0;
  int count=1;
  REP(i,n){
    d=d+l[i];
    if(d>x){
      cout<<count<<endl;
      return 0;
    }else{
      count++;
    }
  }
  cout<<count<<endl;
}


Measured memory_bytes: 256
sx, sy, tx, ty = list(map(int, input().split()))
ans = "U"*(ty-sy)+"R"*(tx-sx)+"D"*(ty-sy)+"L"*(tx-sx)
ans += "L"+"U"*(ty-sy+1)+"R"*(tx-sx+1)+"D"
ans += "R"+"D"*(ty-sy+1)+"L"*(tx-sx+1)+"U"
print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <algorithm>
using namespace std; 
  
typedef long long LL; 
typedef pair<int, int> pii; 
typedef pair<LL, LL> pll; 
typedef pair<string, string> pss; 
typedef vector<int> vi; 
typedef vector<string> vs;
typedef vector<vi> vvi; 
typedef vector<pii> vii; 
typedef vector<LL> vl; 
typedef vector<vl> vvl; 
  
double EPS = 1e-9; 
int INF = 100005; 
long long int mod=1000000007;
long long TES=1000007;
long long INFF = 1000000000000000005LL; 
double PI = acos(-1); 
int dirx[8] = { -1, 0, 0, 1, -1, -1, 1, 1 }; 
int diry[8] = { 0, 1, -1, 0, -1, 1, -1, 1 }; 
  
#ifdef TESTING 
#define DEBUG fprintf(stderr, "====TESTING====\n") 
#define VALUE(x) cerr << "The value of " << #x << " is " << x << endl 
#define debug(...) fprintf(stderr, __VA_ARGS__) 
#else 
#define DEBUG 
#define VALUE(x) 
#define debug(...) 
#endif 
  
#define FOR(a, b, c) for (int(a) = (b); (a) < (c); ++(a)) 
#define FORN(a, b, c) for (int(a) = (b); (a) <= (c); ++(a)) 
#define FORD(a, b, c) for (int(a) = (b); (a) >= (c); --(a)) 
#define FORSQ(a, b, c) for (int(a) = (b); (a) * (a) <= (c); ++(a)) 
#define FORC(a, b, c) for (char(a) = (b); (a) <= (c); ++(a)) 
#define FOREACH(a, b) for (auto&(a) : (b)) 
#define rep(i, n) FOR(i, 0, n) 
#define repn(i, n) FORN(i, 1, n) 
#define MAX(a, b) a = max(a, b) 
#define MIN(a, b) a = min(a, b) 
#define SQR(x) ((LL)(x) * (x)) 
#define RESET(a, b) memset(a, b, sizeof(a)) 
#define fi first 
#define se second 
#define mp make_pair 
#define pb push_back 
#define ALL(v) v.begin(), v.end() 
#define ALLA(arr, sz) arr, arr + sz 
#define SIZE(v) (int)v.size() 
#define SORT(v) sort(ALL(v)) 
#define REVERSE(v) reverse(ALL(v)) 
#define SORTA(arr, sz) sort(ALLA(arr, sz)) 
#define REVERSEA(arr, sz) reverse(ALLA(arr, sz)) 
#define PERMUTE next_permutation 
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#define TC(t) while (t--)

void solve()
{
  LL n,k;
  cin>>n;
  string str;
  while(n>0)
  {
      
      LL rem=n%26;
      if(rem==0)
      str+='z';
      else
      str+=char(96+rem);
      if(rem==0)
      n=(n/26)-1;
      else
      n=n/26;
 }
 reverse(str.begin(),str.end());
  cout<<str<<endl;
}
 
int main()
{
    IOS();
    solve();
    return 0;
}





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

using namespace std;

#define ll long long
#define pb push_back
#define fr first
#define sc second
#define ub upper_bound
#define lb lower_bound

const int mod=int(1e9+7),MAXN=int(2e5+1);

int main()
{

    int n ,k;
    cin >> n >> k;
    if (k <= n/2 + n%2) cout << "YES"<<endl;
    else cout << "NO" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n-1; i >= 0; i--)
#define ALL(x) x.begin(),x.end()
using ll = long long;
using pll = pair<ll, ll>;
using pii = pair<int, int>;
using vl = vector<ll>;
using vi = vector<int>;
const ll INF = 1e18;
const ll mod = 1e9+7;
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

// int dp[100100][100100];

ll power(int m, int n) { // m^n（繰り返し自乗法）
    if (n == 0) return 1;
    if (n % 2 == 1) return power(m, n-1) * m % mod;
    ll r = power(m, n/2);
    return r * r % mod;
}

// ll fact(int n) { // 階乗
//     return f[n];
// }

ll inv(ll a, ll b) { // 逆元を利用してa/bのmodを返す
    return a * power(b, mod-2) % mod;
}

ll f[101000];

ll comb(int n, int r) { // nCr
    if (n < r) return 0;
    // if (n == r || r == 0) return dp[n][r] = 1;
    // if (r == 1) return dp[n][r] = n;
    // if (dp[n][r] != 0) return dp[n][r];
    // return dp[n][r] = (comb(n-1, r-1) + comb(n-1, r)) % mod;
    if (n == r || r == 0) return 1;
    ll s = f[n-r] * f[r] % mod;
    return inv(f[n], s);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll p = 1;
    rep(i, 101000) {
        if (i == 0) f[i] = 1;
        else {
            p *= i;
            p %= mod;
            f[i] = p;
        }
    }
    int n, m;
    cin >> n >> m;
    ll r = 1;
    for (int i = 2; i <= m; i++) {
        int cnt = 0;
        if (m % i == 0) {
            while (m % i == 0) {
                m /= i;
                cnt++;
            }
            // cout << cnt << "\n";
            r *= comb(cnt+n-1, cnt);
            r %= mod;
        }
    }
    cout << r << "\n";
}

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

namespace
{
int D[ 200100 ];
int T[ 200100 ];
}

int main( int argc, char *argv[] )
{
int i;
int j;
int N;
int M;

	ios::sync_with_stdio( false );
	cin.tie( 0 );

	cin >> N;
	for( i = 0; i < N; i++ )
	{
		cin >> D[ i ];
	}

	cin >> M;
	for( i = 0; i < M; i++ )
	{
		cin >> T[ i ];
	}

	sort( D, D + N );
	sort( T, T + M );


	j = - 1;
	for( i = 0; i < M; i++ )
	{
		j++;
		if( j >= N )
		{
			cout << "NO" << endl;

			return 0;
		}

		while( D[ j ] < T[ i ] )
		{
			j++;
			if( j >= N )
			{
				cout << "NO" << endl;

				return 0;
			}
		}

		if( D[ j ] > T[ i ] )
		{
			cout << "NO" << endl;

			return 0;
		}
	}


	if( i == M )
		cout << "YES" << endl;
	else
		cout << "NO" << endl;

	return 0;
}




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

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
const int INF_N = 1e+9;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
//typedef vector<vector<ll>> mat;
typedef vector<int> vec;

//繰り返し二乗法
ll mod_pow(ll a, ll n, ll m) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * a%m;
		a = a * a%m; n >>= 1;
	}
	return res;
}

struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n%mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint &a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint &a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint &a, modint b) { a.n = ((ll)a.n*b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a*a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

//逆元(Eucledean algorithm)
ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }

const int max_n = 1 << 18;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}
using mP = pair<modint, modint>;

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




void solve() {
    int N; cin >> N;
    modint res = 0;
    vector<modint> s(N+1, 0), a(N);
    rep(i, N){
        cin >> a[i].n;
        s[i+1] = s[i] + a[i];
    }
    per(i, N){
        res += s[i]*a[i];
    }
    cout << res.n << endl;
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  //cout << fixed << setprecision(10);
  //init_f();
  //init();
  //int t; cin >> t; rep(i, t)solve();
  solve();
//   stop
    return 0;
}


Measured memory_bytes: 10304
#include<bits/stdc++.h>
#define PI 3.141592653589
using namespace std;
using ll = long long;

template<typename T_char>
T_char ToUpper(T_char cX){return toupper(cX);}

int f(int n){
  int tmp = 0;
  while(n>0){
    tmp += n%10;
    n = n/10;
  }
  return tmp;
}

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

  int s = f(n);

  if(n % s == 0) cout << "Yes";
  else cout << "No";

}


Measured memory_bytes: 3536
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
using Graph = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Rep(i, k, n) for (int i = k; i < (int)(n); i++)
#define RRep(i, k, n) for (int i = k; i > (int)(n); i--)
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define ALL(a)  (a).begin(),(a).end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
const int MOD = 1000000007;
const double PI = acos(-1); //3.14~
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int main()
{
    int n; cin >> n;
    vector<int> v(n), c(n);
    rep(i, n) cin >> v[i];
    rep(i, n) cin >> c[i];

    int ans = 0;
    rep(i, n)
    {
        if (v[i] - c[i] > 0) ans+= v[i] - c[i];
    }
    cout << ans << endl;
}

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

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

#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

struct Sushi
{
    ll t;
    ll d;
    bool e;
};

Sushi S[100005];
bool V[100005];
bool U[100005];

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

    ll mv = 0;
    REP(i, N)
    {
        cin >> S[i].t >> S[i].d;
        if (!V[S[i].t])
        {
            mv++;
            V[S[i].t] = true;
        }
    }

    sort(S, S + N, [](Sushi a, Sushi b) { return a.d > b.d; });

    mv = std::min(K, mv); //! 食べられる最大の種類数
    int v = 0;            //! 被っているものを食べた数

    ll sum = 0;
    int i = 0, j = 0;
    REP(k, K)
    {
        for (; i < N; ++i)
        {
            if (!S[i].e)
                break;
        }
        for (; j < N; ++j)
        {
            if (!S[j].e && !U[S[j].t])
                break;
        }

        if (v + mv + 1 <= K)
        {
            //! mvを減らさずiを食べる
            sum += S[i].d;
            if (U[S[i].t])
                v++;
            S[i].e = U[S[i].t] = true;
            continue;
        }

        if (j >= N || 2 * mv - 1 + S[j].d < S[i].d)
        {
            //! mvを減らしてiを食べる
            sum += S[i].d;
            if (U[S[i].t])
                v++;
            S[i].e = U[S[i].t] = true;
            mv--;
            continue;
        }
        //! jを食べる
        sum += S[j].d;
        S[j].e = U[S[j].t] = true;
    }
    cout << sum + mv * mv << endl;
    return 0;
}

Measured memory_bytes: 2816
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		String line = sc.nextLine();
		String[] lines = line.split(" ");
		int N = Integer.parseInt(lines[0]);
		int M = Integer.parseInt(lines[1]);
		int[] L = new int[M];
		int[] R = new int[M];

		for(int i = 0 ; i < M ; i++) {
			line = sc.nextLine();
			lines = line.split(" ");
			L[i] = Integer.parseInt(lines[0]);
			R[i] = Integer.parseInt(lines[1]);
		}

		int Left = L[0];
		int Right = R[0];
		for(int i = 0; i < M; i++) {
			if(Left < L[i]) {
				Left = L[i];
			}
			if(Right > R[i]) {
				Right = R[i];
			}
		}

		if(Right- Left < 0) {
			System.out.println(0);
		}else {
			System.out.println(Right - Left + 1);
		}

	}

}


Measured memory_bytes: 61868
il = lambda: list(map(int, input().split()))
ils = lambda n, s="int(input())": [eval(s) for _ in range(n)]
mod = int(1e9+7)

n = int(input())
a = il()
dic = dict()
for i in a:
    if i in dic:
        dic[i] += 1
    else:
        dic[i] = 1
flag = 1
for i, j in dic.items():
    if i == 0:
        if j != 1:
            flag = 0
    else:
        if j != 2:
            flag = 0
if flag:
    print(pow(2, n//2)%mod)
else:
    print(0)

Measured memory_bytes: 14244
#include<stdio.h>
int main(void)
{
int x,y,tmp;
while(1){
scanf("%d %d",&x,&y);
if (x == 0 && y == 0)break;
if (y < x){
tmp=y;
y=x;
x=tmp;
}
printf("%d %d\n",x,y);
}
return 0;
}

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

using namespace std;

const int MAX_N = 1e3;

int N, D1, D2, color1[MAX_N][MAX_N], color2[MAX_N][MAX_N];
vector<pair<int, int>> delta1, delta2;
vector<pair<int, int>> cp[2][2];

vector<pair<int, int>> get_delta(int x) {
    vector<pair<int, int>> res;
    for (int i = -2 * N; i <= 2 * N; i++)
        for (int j = -2 * N; j <= 2 * N; j++)
            if (i * i + j * j == x) res.emplace_back(i, j);
    return res;
}

void color_dfs(int res[MAX_N][MAX_N], vector<pair<int, int>> &delta, int x, int y, int c) {
    res[x][y] = c;
    for (auto i : delta) {
        int nx = x + i.first, ny = y + i.second;
        if (nx < 0 || nx >= 2 * N || ny < 0 || ny >= 2 * N) continue;
        if (res[nx][ny] != -1) continue;
        color_dfs(res, delta, nx, ny, c ^ 1);
    }
}

void color(int res[MAX_N][MAX_N], vector<pair<int, int>> &delta) {
    for (int i = 0; i < 2 * N; i++)
        for (int j = 0; j < 2 * N; j++)
            if (res[i][j] == -1) {
                color_dfs(res, delta, i, j, 0);
            }
}

int main() {
    scanf("%d%d%d", &N, &D1, &D2);
    delta1 = get_delta(D1);
    delta2 = get_delta(D2);
    memset(color1, -1, sizeof(color1));
    memset(color2, -1, sizeof(color2));
    color(color1, delta1);
    color(color2, delta2);
    for (int i = 0; i < 2 * N; i++)
        for (int j = 0; j < 2 * N; j++)
            cp[color1[i][j]][color2[i][j]].emplace_back(i, j);
    for (int i = 0; i < 2; i++) {
        for (int j = 0; j < 2; j++) {
            if (cp[i][j].size() >= N * N) {
                cp[i][j].resize(N * N);
                for (auto p : cp[i][j])
                    printf("%d %d\n", p.first, p.second);
            }
            return 0;
        }
    }
}


Measured memory_bytes: 39796
#include<bits/stdc++.h>
using namespace std;
int  main (){
  int a,b;
  cin>>a>>b;
  if(a%3==0){
    cout<<"Possible"<<"\n";
    return(0);
  }
  if(b%3==0){
    cout<<"Possible"<<"\n";
    return(0);
  }    
  if((a+b)%3==0){
    cout<<"Possible"<<"\n";
    return(0);
  }
  cout<<"Impossible"<<"\n";
  return(0);
}


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

int main(){
    while(1){
        int n;
        cin >> n;
        if(n == 0) break;
        vector<int> s(n);//得点
        for(int i = 0; i < n; i++) cin >> s[i];
        double ave = 0;//平均
        for(int i = 0; i < n; i++) ave += s[i];
        ave /= n;
        
        double v = 0;//分散
        for(int i = 0; i < n; i++) v += pow(s[i] - ave, 2);
        v /= n;
        
        cout << sqrt(v) << endl;
    }
    return 0;
}


Measured memory_bytes: 3292
fn run() {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    let mut it = s.trim().split_whitespace();
    let a: u32 = it.next().unwrap().parse().unwrap();
    let b: u32 = it.next().unwrap().parse().unwrap();
    for i in 1..100000 {
        if i * 8 / 100 == a && i * 10 / 100 == b {
            println!("{}", i);
            return;
        }
    }
    println!("-1");
}

fn main() {
    run();
}

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

int main(){
    for(int i = 0; i < 3; i++){
        int h, m, s, a, b;
        cin >> h >> m >> s;
        a = 3600*h+60*m+s;
        cin >> h >> m >> s;
        b = 3600*h+60*m+s;
        int stay = b-a;
        cout << stay/3600 << " "
            << stay%3600/60 << " " 
            << stay%60 << endl;
    }
    return 0;
}


Measured memory_bytes: 3076
#pragma region include
#include <stdio.h>
#include <string>
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <map>
#include <set>
#pragma endregion
using namespace std;

#pragma region 定数
#define INF_VAL (2147483647 - 1)
#define INF_VAL_MINUS -INFVAL
#pragma endregion

#pragma region マクロ
// 配列の長さを取得する(ただし関数内ではポインタサイズに注意)
#define SIZE_OF_ARRAY(array) sizeof(array) / sizeof(*array)

// for文
#define forn(i, size) for (long long(i) = 0; (i) < (size); (i)++)
#define for0(size) for (long(i) = 0; (i) < (size); (i)++)

// ソート
#define Sort(array, length) sort(array, array + length)
#define SortDESC(array, length, type_name) sort(array, array + length, std::greater<type_name>())

// 配列の最大値、最小値取得
#define MAX_OF_ARRAY(array, length) *max_element(array, array + length)
#define MIN_OF_ARRAY(array, length) *min_element(array, array + length)

// 結果出力系
#define YES                    \
    {                          \
        cout << "YES" << endl; \
        return 0;              \
    }
#define NO                    \
    {                         \
        cout << "NO" << endl; \
        return 0;             \
    }
#define Yes                    \
    {                          \
        cout << "Yes" << endl; \
        return 0;              \
    }
#define No                    \
    {                         \
        cout << "No" << endl; \
        return 0;             \
    }
#pragma endregion

#pragma region Utility
#pragma region 配列要素の合計値を取得
template <typename T>
T getSum(T array[], int length)
{
    T sum = 0;
    for (int i = 0; i < length; i++)
    {
        sum += array[i];
    }
    return sum;
}
#pragma endregion

#pragma region ToString(int)
string ToString(int i)
{
    char buffer[1000];
    sprintf(buffer, "%d", i);
    return string(buffer);
}
#pragma endregion

#pragma region 10進数からN進数(<= 10) へ変換
string convertToN(long n, int base)
{
    string ans = "";
    while (n != 0)
    {
        int temp = n % base; // 1桁取得
        ans = ToString(temp) + ans;
        n /= base;
    }
    return ans;
}
#pragma endregion
#pragma endregion

int main()
{
    // 標準入力から値を取得
    int N, M;
    cin >> N >> M;

    int i = 0;
    string result[N];
    int WA_count_array[N];
    int AC_count = 0;
    int WA_count = 0;

    forn(i, N)
    {
        WA_count_array[i] = 0;
    }

    forn(i, M)
    {
        int p_i;
        string s_i;
        cin >> p_i >> s_i;

        string status = result[p_i - 1];

        // まだACではない場合
        if (status != "AC")
        {
            if (s_i == "AC")
            {
                AC_count++;
                result[p_i - 1] = "AC";

                // 今までのWA回数を加算する
                WA_count += WA_count_array[p_i - 1];
                //printf("%d\n", WA_count_array[p_i - 1]);
            }
            else if (s_i == "WA")
            {
                //printf("%d\n", WA_count_array[p_i - 1]);
                WA_count_array[p_i - 1]++;
                result[p_i - 1] = "WA";
            }
        }
    }

    // 結果出力
    printf("%d %d\n", AC_count, WA_count);
}


Measured memory_bytes: 6144
#include <bits/stdc++.h>
using namespace std;
#define LONGLONGMAX 9223372036854775807
#define LONGLONGMIN -9223372036854775807
#define INTMAX 32767
#define INTMIN -32767
#define ROUNDUP(divisor,dividend) (divisor + (dividend - 1)) / dividend
string s;
int ans=0,ansm=0;
int main(){
  cin >> s;
  for (int i = 0; i < s.length(); i++) {
    if(s[i] == 'A' || s[i] == 'C' || s[i] == 'G' || s[i] == 'T'){
      for (int l = 0; l < s.length()-i; l++) {
        if(s[i+l] == 'A' || s[i+l] == 'C' || s[i+l] == 'G' || s[i+l] == 'T'){
          ans++;
        }else{
          break;
        }
      }
    }
    ansm=max(ans,ansm);
    ans = 0;
  }
  cout << ansm;
}


Measured memory_bytes: 256
#include <bits/stdc++.h> 
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define size_of_array(array) (sizeof(array)/sizeof(array[0]))
#define MAX 100005
#define DEBUG 0 
#define LIMIT (LONG_MAX / 10)
#define POSITIVE_LAST_D (LONG_MAX % 10)
using ll =long long;
using namespace std;
using Graph=vector<vector<int>>;

int main(){
    int n,r;
    cin>>n>>r;
    if(n>=10){
        cout<<r<<endl;
    }else{
        cout<<r+100*(10-n)<<endl;
    }
    return 0;
}

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

int main(){
    long long n,k;
    cin >> n >> k;
    if(k%2!=0){
        long long a=n/k;
        cout << a*a*a << endl;
    }else{
        long long a=n/k;
        long long b=(n+(k/2))/k;
        cout << a*a*a+b*b*b << endl;
    }
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
  
  int n;
  scanf("%d",&n);
  int flag = 0;
  int count = 0;

  int a[n];
  for(int i=0; i<n; i++){
    scanf("%d",&a[i]);
  }

  while(1){
    for(int i=0; i<n; i++){
      if(a[i] % 2 !=0){
        printf("%d",count);
        return 0;
      }else{
        a[i] = a[i] / 2;
      }
    }
    count ++;
  }
}

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

int main()
{
    int N, M, C;
    cin >> N >> M >> C;
    
    vector<int> B(M);
    for (int i = 0; i < M; i++){
        cin >> B[i];
    }
    
    vector<vector<int>> A(N, vector<int>(M));
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < M; j++) {
            cin >> A[i][j];
        }
    }
    
    int result = 0;
    for (int i = 0; i < N; i++) {
        int sum = 0;
        for (int j = 0; j < M; j++) {
            sum += A[i][j] * B[j];
        }
        sum += C;
        if (sum > 0) {
            result++;
        }
    }
    cout << result << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		if ((a * b) % 2 == 0) {
			System.out.println("Even");
		} else {
			System.out.println("Odd");
		}
		scan.close();
	}

}


Measured memory_bytes: 21844
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<stack>
#include<queue>
#include<vector>
#include<set>
#include<map>
#include<string>
#define ls k<<1,l,mid
#define rs k<<1|1,mid+1,r
#define mp(x,y) make_pair(x,y)
#define r(x) read(x)
#define rr(x,y) read(x);read(y)
#define rrr(x,y,z) read(x);read(y);read(z)
#define FOR(i,l,r) for(int i=l;i<=r;i++)
#define pb(x) push_back(x)
#define sss(str) scanf("%s",str+1)
#define ssf(x) scanf("%lf",&x)
#define aLL(x) x.begin(),x.end()
#define fi first
#define se second
using namespace std;
typedef long long LL;
typedef double dd;
typedef pair<LL,LL> pt;
const int N=2e5+5;
const int M=2e2+5;
const int INF=0x7fffffff;
const int mod=1e9+7;
const int sz=18;
const double eps=1e-10;
const double pi=acos(-1);
//***********************
int n,m;
int dad[N];
int num[N];
vector<int> v[N];
//***********************
template<class T>
inline void read(T &x)
{
    char c; x=1;
    while((c=getchar())<'0'||c>'9') if(c=='-') x=-1;
    T res=c-'0';
    while((c=getchar())>='0'&&c<='9') res=res*10+c-'0';
    x*=res;
}
int seek(int k)
{
    return dad[k]==k?k:dad[k]=seek(dad[k]);
}
int main()
{
    int k;
    rrr(n,m,k);
    FOR(i,1,n){
        dad[i]=i;
        num[i]=1;
    }
    FOR(i,1,m){
        int a,b;
        rr(a,b);
        v[a].pb(b);
        v[b].pb(a);
        int fa=seek(a);
        int fb=seek(b);
        if(fa!=fb){
            dad[fa]=fb;
            num[fb]+=num[fa];
        }
    }
    FOR(i,1,k){
        int a,b;
        rr(a,b);
        v[a].pb(b);
        v[b].pb(a);
    }
    FOR(i,1,n){
        int x=seek(i);
        int ans=num[x];
        for(int j:v[i]){
            int y=seek(j);
            if(x==y) ans--;
        }
        cout<<ans-1<<' ';
    }
    cout<<endl;
}


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

static int N = 0;
static vector<int> v;

int solve(vector<int> &v)
{
	for (int i = 0; i < N; ++i)
		if (v[i] % 2 == 1) return 0;

	int counter = 0;
	while (true)
	{
		for (int i = 0; i < N; ++i)
		{
			if (v[i] % 2 == 0)
			{
				v[i] /= 2;
			}
			else
			{
				goto exit;
			}
		}
		counter++;
	}
		
	exit:
	return counter;
}

int main(int argc, char **argv)
{
	cin >> N;
	v.resize(N);

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

	std::cout << solve(v) << std::endl;
}


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

void solve(long long N, std::vector<long long> L) {
    ll ans = 0;
    for (ll i = 0; i < N; i++) {
        for (ll j = i + 1; j < N; j++) {
            for (ll k = j + 1; k < N; k++) {
                if ((L[i] != L[j]) && (L[j] != L[k]) && (L[k] != L[i]) && (L[i] + L[j] > L[k]) &&
                    (L[j] + L[k] > L[i]) && (L[k] + L[i] > L[j])) {
                    ans++;
                }
            }
        }
    }
    cout << ans << endl;
}

int main() {
    long long N;
    scanf("%lld", &N);
    std::vector<long long> L(N);
    for (int i = 0; i < N; i++) {
        scanf("%lld", &L[i]);
    }
    solve(N, std::move(L));
    return 0;
}


Measured memory_bytes: 3664
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>
using namespace std;
#define int long long
int MOD = 1000000007;
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N,M;
	cin >> N >> M;
	vector<int> A(N);
	int res = 0;
	int mn = -1;
	int mx = 10000000;
	int L, R;
	for (int i = 0; i < M; i++) {
		cin >> L >> R;
		mn = max(mn, L);
		mx = min(mx, R);
	}
	
	res = max((int)0, mx - mn + 1);
	cout << res << endl;
}

Measured memory_bytes: 1024
import java.io.File;
import java.io.FileNotFoundException;
import java.lang.management.ManagementFactory;
import java.lang.management.ThreadMXBean;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws FileNotFoundException {

		ThreadMXBean threadMXBean = ManagementFactory.getThreadMXBean();
		long startCpuTime = threadMXBean.getCurrentThreadCpuTime(), stopCpuTime = 0;

		Scanner scan = new Scanner(System.in);
		// Scanner scan = new Scanner(new
		// File("D:\\UserArea\\J0124567\\Downloads\\0542-input.txt"));

		while (scan.hasNext()) {

			int t = scan.nextInt();
			if (t == 0)
				break;
			for (int f = 0; f < 9; f++) {
				t -= scan.nextInt();

			}
			// stopCpuTime = threadMXBean.getCurrentThreadCpuTime();

			System.out.println(t);
		}

		scan.close();
		// stopCpuTime = threadMXBean.getCurrentThreadCpuTime();
		// System.out.println("CPU=" + (stopCpuTime - startCpuTime) / 1000000);

		System.exit(0);
	}
}

Measured memory_bytes: 26368
#include <cstdio>
#include <iostream>
#include <cstring>
#include <string>
#include <cstdlib>
#include <utility>
#include <cctype>
#include <algorithm>
#include <bitset>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <cmath>
#define LL long long
#define LB long double
#define x first
#define y second
#define Pair pair<int,int>
#define pb push_back
#define pf push_front
#define mp make_pair
#define LOWBIT(x) x & (-x)
using namespace std;

const int MOD=998244353;
const LL LINF=2e16;
const int INF=1e9;
const int magic=348;
const double eps=1e-10;
const double pi=3.14159265;
const int G=3;

inline int getint()
{
    char ch;int res;bool f;
    while (!isdigit(ch=getchar()) && ch!='-') {}
    if (ch=='-') f=false,res=0; else f=true,res=ch-'0';
    while (isdigit(ch=getchar())) res=res*10+ch-'0';
    return f?res:-res;
}

int inv[200048];
LL finv[200048],fac[200048];
int n;
char s1[100048],s2[100048];
int e,m;

inline void init_inv()
{
	int i;
	fac[0]=fac[1]=inv[0]=inv[1]=finv[0]=finv[1]=1;
	for (i=2;i<=100000;i++)
	{
		fac[i]=(fac[i-1]*i)%MOD;
		inv[i]=MOD-((long long)(MOD/i)*inv[MOD%i])%MOD;
		finv[i]=(finv[i-1]*inv[i])%MOD;
	}
} 

inline LL quick_pow(LL x,LL y)
{
	x%=MOD;LL res=1;
	while (y)
	{
		if (y&1) res=(res*x)%MOD,y--;
		x=(x*x)%MOD;y>>=1;
	}
	return res;
}

int len;
LL wn_pos[100048],wn_neg[100048];
inline void init_wn()
{
	for (register int clen=2;clen<=len;clen<<=1)
	{
		wn_pos[clen]=quick_pow(G,(MOD-1)/clen);
		wn_neg[clen]=quick_pow(G,(MOD-1)-(MOD-1)/clen);
	}
}

LL a[100048],b[100048];

inline void NTT(LL c[],int fl)
{
	int i,j,k,clen;
	for (i=(len>>1),j=1;j<len;j++)
	{
		if (i<j) swap(c[i],c[j]);
		for (k=(len>>1);i&k;k>>=1) i^=k;
		i^=k;
	}
	for (clen=2;clen<=len;clen<<=1)
	{
		LL wn=(fl==1?wn_pos[clen]:wn_neg[clen]);
		for (j=0;j<len;j+=clen)
		{
			LL w=1;
			for (k=j;k<j+(clen>>1);k++)
			{
				LL tmp1=c[k],tmp2=(c[k+(clen>>1)]*w)%MOD;
				c[k]=(tmp1+tmp2)%MOD;c[k+(clen>>1)]=((tmp1-tmp2)%MOD+MOD)%MOD;
				w=(w*wn)%MOD;
			}
		}
	}
	if (fl==-1)
		for (i=0;i<len;i++) c[i]=(c[i]*inv[len])%MOD;
}

inline void calc_NTT()
{
	NTT(a,1);NTT(b,1);
	for (register int i=0;i<len;i++) a[i]=(a[i]*b[i])%MOD;
	NTT(a,-1);
}

struct poly
{
	LL A[100048];
	inline poly operator * (const poly B) const
	{
		int i;poly res;
		memset(a,0,sizeof(a));memset(b,0,sizeof(b));
		for (i=0;i<=m;i++) a[i]=A[i],b[i]=B.A[i];
		calc_NTT();
		for (i=0;i<=m;i++) res.A[i]=a[i];
		return res;
	}
};

inline poly Quick_pow(poly x,LL y)
{
	int i;poly res;
	for (i=0;i<=m;i++) x.A[i]%=MOD;
	res.A[0]=1;
	while (y)
	{
		if (y&1) res=res*x,y--;
		x=x*x;y>>=1;
	}
	return res;
}

int main ()
{
	int i,j,k;
	scanf("%s%s",s1+1,s2+1);n=strlen(s1+1);
	init_inv();
	e=m=0;
	for (i=1;i<=n;i++)
	{
		if (s1[i]=='1' && s2[i]=='0') e++;
		if (s1[i]=='1' && s2[i]=='1') m++;
	}
	len=1;while (len<=m*2) len<<=1;
	init_wn();
	poly ans;for (i=0;i<=m;i++) ans.A[i]=finv[i+1];
	ans=Quick_pow(ans,e);
	LL fans=0;
	for (i=0;i<=m;i++) fans=(fans+ans.A[i])%MOD;
	fans=fans*fac[e]%MOD*fac[m]%MOD*fac[e+m]%MOD;
	printf("%lld\n",fans);
	return 0;
}


Measured memory_bytes: 11520
#include <bits/stdc++.h>
 
#define forn(i, n) for (llong i = 0ll; i < (llong) n; ++i)
#define fornn(i, l, r) for (llong i = (llong) l; i < (llong) r; ++i)
#define size(x) ((int) (x.size()))
 
using namespace std;
 
typedef long long llong;
const llong inf = (llong) 1e+9 + 7ll;
const llong linf = (llong) 1e+18 + 7ll;
const long double eps = (long double) 1e-9;
const long double pi = acosl((long double) -1.0);
const int alph = 26;

mt19937 mrand(random_device{} ()); 

template<typename T, typename U> inline llong umin(const T& a, const U& b) { return a < b ? a : b; }
template<typename T, typename U> inline llong umax(const T& a, const U& b) { return a > b ? a : b; }
 
static char buff[(int) 2e6 + 17]; // reads std::string
const int maxn = (int) 3e5 + 17;

int n;
string s;
vector<int> p[maxn];
int pt[maxn];
int dp[maxn];

bool read()
{
	if (scanf("%s", buff) != 1)
		return false;

	return true;
}

void solve()
{
	s = buff;
	s = "#" + s;
	n = size(s) - 1;

	forn (i, n)
		p[s[i + 1] - 'a'].push_back(i + 1);

	forn (i, 26)
		p[i].push_back(inf);

	for (int i = n; i >= 0; --i)
	{
		dp[i] = inf;

		for (int j = 0; j < 26; ++j)
		{
			int k = *upper_bound(p[j].begin(), p[j].end(), i);

			if (k == inf)
				dp[i] = 0;
			else
				dp[i] = min(dp[i], dp[k] + 1);
		}
	}

	string ans = "";

	for (int i = 0; i <= n; )
	{
		for (int j = 0; j < 26; ++j)
		{
			int k = *upper_bound(p[j].begin(), p[j].end(), i);

			if (k == inf)
			{
				ans.push_back(char('a' + j));
				i = n + 1;
				break;
			}
			
			if (dp[i] == dp[k] + 1)
			{
				ans.push_back(char('a' + j));
				i = k;
				break;
			}
		}
	}

	printf("%s\n", ans.c_str());
}

int main()
{
#if SEREZHKA
	freopen("file.in", "r", stdin);
#endif

	while (read())
		solve();

	return 0;
}


Measured memory_bytes: 10428
import sys
L = int(sys.stdin.readline().rstrip())
 
h = list(map(int, sys.stdin.readline().rstrip().split()))
 
if L == 0:
  ans = 0
elif L == 1:
  ans = h[0]
elif L == 2:
  ans = max(h)
  
else:
  grad1 = h[0] > h[1]
  p= 0
  v= 0
  if grad1:
    p += h[0]
 
  for n in range(2, L):
    grad2 = h[n-1] > h[n] 
    if grad1 == grad2:
      continue
    elif grad2:
      p += h[n-1]
    else:
      v += h[n-1]
    grad1 = grad2
               
  if not grad1:
    p += h[n]
 
  ans = p - v
print(ans)

Measured memory_bytes: 3064
import kotlin.math.*
import java.util.*

const val MOD = 1_000_000_007L

fun readI() = readLine()!!.toInt()
fun readL() = readLine()!!.toLong()
fun readD() = readLine()!!.toDouble()
fun readIs() = readLine()!!.split(' ').map(String::toInt)
fun readLs() = readLine()!!.split(' ').map(String::toLong)
fun readDs() = readLine()!!.split(' ').map(String::toDouble)

fun main(args: Array<String>) {
  val k = readI()
  val s = readLine()!!
  if (s.length <= k) {
    println(s)
  } else {
    println(s.substring(0, k) + "...")
  }
}


Measured memory_bytes: 34384
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
using namespace std;
int main(void){
    int n,l;
    cin >> n >> l;
    vector<string> s(n);
    for(int i = 0;i < n;i++){
          cin >> s[i];
    }
    
    sort(s.begin(),s.end());
    for(int i = 0;i < n;i++){
          cout << s[i];
    }
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main (void) {
    int sx, sy;
    int tx, ty;

    cin >> sx >> sy >> tx >> ty;

    int dx = tx - sx;
    int dy = ty - sy;
    for (int i = 0; i < dy; i++) cout << 'U';
    for (int i = 0; i < dx; i++) cout << 'R';
    for (int i = 0; i < dy; i++) cout << 'D';
    for (int i = 0; i < dx + 1; i++) cout << 'L';
    for (int i = 0; i < dy + 1; i++) cout << 'U';
    for (int i = 0; i < dx + 1; i++) cout << 'R';
    cout << 'D';
    cout << 'R';
    for (int i = 0; i < dy + 1; i++) cout << 'D';
    for (int i = 0; i < dx + 1; i++) cout << 'L';
    cout << 'U' << endl;

    return 0;
}

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

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

    long long l0 = 2;
    long long l1 = 1;
    
    if (n == 1) {
        cout << l1 << endl;
        return 0;
    }

    for (int i = 0; i < n - 1; i++) {
        l0 += l1;
        swap(l0, l1);
    }
    cout << l1 << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        
        char[] input_text = sc.nextLine().toCharArray();
        
        for (int i = 0; i < input_text.length; i++) {
            switch (input_text[i]){
                case '1':
                    input_text[i] = '9';
                    break;
                case '9':
                    input_text[i] = '1';
                    break;
            }
        }
        
        String output_text = new String(input_text);
        System.out.println(output_text);
    }
}


Measured memory_bytes: 21460
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#define DIVCEIL(A,B) ((A+(B-1))/B)
using namespace std;

long long count(bool is_pos, std::vector<long long> A){
    long long acc=0, ans=0;
    for(auto a: A){
        acc += a;
        if(is_pos && acc<=0){
            ans+=(abs(acc)+1);
            acc=1;
        }else if(!is_pos && acc>=0){
            ans+=(acc+1);
            acc=-1;
        }
        is_pos = !is_pos;
    }
    return ans;
}

void solve(long long n, std::vector<long long> A){
    cout << min(count(true, A), count(false, A)) << endl;
}

int main(){
    long long n;
    scanf("%lld",&n);
    std::vector<long long> a(n);
    for(int i = 0 ; i < n ; i++){
        scanf("%lld",&a[i]);
    }
    solve(n, std::move(a));
    return 0;
}


Measured memory_bytes: 2560
#include<iostream>
#include <algorithm>
#include<cstdlib>
#include <string>
#include <sstream>
using namespace std;

int main()
{
	int a[5];
	for(int i=0;i<5;++i) cin >> a[i]; 
	int k;
	cin >> k;
	
	bool flag=false;
	for(int i=0;i<5;++i){
	for(int j=0;j<5;++j){
		if(abs(a[i]-a[j])>k){
			flag = true;
			break;
		}
	}
	}

	if(flag) cout << ":(" << endl;
	else cout << "Yay!" << endl;

}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
q = int(input())

s = sum(a)

arr = [0] * (10**5 + 1)
for i in range(n):
    arr[a[i]] += 1

ans = []
for i in range(q):
    b, c = map(int, input().split())
    nb = arr[b]
    bc = arr[c]
    s -= b * nb
    s += c * nb
    arr[b] = 0
    arr[c] += nb
    ans.append(s)

for i in range(q):
    print(ans[i])

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

int main(void) {
  ll N;
  cin >> N;
  vector<ll> A(N), B(N);
  REP(i, 0, N) cin >> A[i] >> B[i];

  vector<ll> ord(N);
  REP(i, 0, N) ord[i] = i;

  sort(ord.begin(), ord.end(), [&](const ll i, const ll j) { return A[i] + B[i] < A[j] + B[j]; });
  reverse(ord.begin(), ord.end());

  ll ans = 0;
  REP(i, 0, N) {
    ll k = ord[i];
    if (i % 2 == 0) {
      ans += A[k];
    } else {
      ans -= B[k];
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 2560