akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define fi first
#define se second
#define pb push_back
#define mp make_pair
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 int INF = 1<<30;
const ll LINF = 1LL<<58;
const ll mod = 1000000007;

struct edge{
    int from, to, cost;
};
vector<edge> G;

int main(){
    int n;
    string s;
    cin >> n >> s;
    int r = 0, l = 0, rk = 0, lk = 0;
    for(int i = 0; i < s.size(); i++){
        if(s[i] == ')' && !l) lk++;
        else if(s[i] == ')') l--;
        else if(s[i] == '(') l++;
    }
    for(int i = s.size()-1; i > -1; i--){
        if(s[i] == '(' && !r) rk++;
        else if(s[i] == '(') r--;
        else if(s[i] == ')') r++;
    }
    for(int i = 0; i < lk; i++){
        s = '(' + s;
    }
    for(int i = 0; i < rk; i++){
        s += ')';
    }
    cout << s << endl;
    return 0;
}

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

int main() {
  int N,a,b,aa,bb,o;
  a = 0;
  b = 0;
  aa = 0;
  bb = 0;
  o  = 0;                        
  cin >> N;
  vector<int> c(N);
  for(int i = 0; i < N; i++) {
    cin >> c.at(i);
  }
  for(int i = 0; i < N; i++) {
    for(int j = 0; j < N; j++) {
      if(c.at(j) >= a) {
        a = c.at(j);
        o = j;
      }
    }
    aa = aa + a;
    c.at(o) = 0;
    a = 0;
    for(int t = 0; t < N; t++) {
      if(c.at(t) >= b) {
        b = c.at(t);
        o = t;
      }
    }
    bb = bb + b;
    c.at(o) = 0;
    b = 0;
  }
  aa = aa - bb;
  cout << aa << endl;
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
#define ALL(A) (A).begin(),(A).end()
#define ll long long
const ll mod = 1e9+7;
const ll INF = 2*1e18;
const int inf = 1e9+7;

int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int H,W,K;
	cin >> H >> W >> K;
	//i行j列塗る場合
	for(int i=0;i<=H;i++){
		for(int j=0;j<=W;j++){
			int tmp;
			if(i==0 || j==0){
				tmp = i*W + j*H;
			}else{
				tmp = i*(W) + j*(H-i-i);
			}
			if(tmp == K){
				cout <<"Yes"<<endl;
				return 0;
			}
		}
	}
	cout << "No" << endl;
}

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

#define rep(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define each(it,v) for(auto &it : v)
#define all(v) (v).begin(),(v).end()
#define mod 1e9+7

using namespace std;
using vi = vector<int>;
using vl = vector<long>;
using P = pair<int,int>;

main()
{
        vi v(3);
        rep(i,3)cin>>v[i];
        int k; cin>>k;
        rep(i,k)
        {
                sort(all(v));
                v[2]*=2;
        }
        int sum=0;
        each(it,v)sum+=it;
        cout<<sum<<endl;
}

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

const int MAX = 100010;
bool isNotPrime[MAX] = {0};

void setPrime(){
    isNotPrime[0] = 1;
    isNotPrime[1] = 1;
    for(int i = 2; i <= MAX/2; i++){
        if(isNotPrime[i])continue;
        for(int k = 2; k*i <= MAX; k++){
            isNotPrime[k*i] = 1;
        }
    }
}

int main(){
    setPrime();
    int accumulation[MAX] = {0};
    for(int i = 1; i < MAX; i++){
        if(i%2 && !isNotPrime[i] && !isNotPrime[(i + 1)/2]) accumulation[i] = accumulation[i - 1] + 1;
        else accumulation[i] = accumulation[i - 1];
    }
    int Q;
    cin >> Q;
    for(int i = 0; i < Q; i++){
        int l,r;
        cin >> l >> r ;
        cout << accumulation[r] - accumulation[l-1] << endl;
    }
}

Measured memory_bytes: 4048
#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <numeric>
#define ll long long int
#define pb push_back
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
int mx4[] = {0,1,0,-1};
int my4[] = {1,0,-1,0};
int INF = 2e6;
ll MOD = 1e9 + 7;

int main(){
    ll n,N; cin >> n;
    N = n;
    int sum = 0;
    for(int i = 9;i >= 0;i--){
        ll di = pow(10,i);
        sum += n / di;
        n %= di;
    }
    if(N % sum == 0) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

int main() {
    int N;
    cin >> N;
    int cnt = 0;
    int ans = 0;
    // for(int i = 1; i <= N; i *=10){
    //     while(i != 0){
    //     i /= 10;
    //     cnt++;
    // }
    // if(cnt % 2 ==1){
    //     ans += 10*i - 1 -i;
    // }
    // }

    if(1 <= N && N <10){
        cout << N << endl;
    }else if(10 <= N && N <100){
        cout << 9 << endl;
    }else if(100 <= N && N <1000){
        cout << 9 + (N-100)+1 << endl;
    }else if(1000 <= N && N <10000){
        cout << 909 << endl;
    }else if(10000 <= N && N <100000){
        cout << 909 + (N-10000) +1 << endl;
    } else {
        cout << 90909 << endl;
    }

}

Measured memory_bytes: 256
x,y = map(int,input().split())
if 0 <= x < y or x < y <= 0:
    print(abs(y-x))
elif 0 < y < x or y < x < 0:
    print(abs(x-y) + 2)
elif x < y:
    if y < abs(x):
        print(abs(x)-y + 1)
    else:
        print(y-abs(x) + 1)
else:
    if x < abs(y):
        print(abs(y)-x + 1)
    else:
        print(x-abs(y) + 1)

Measured memory_bytes: 9112
#include<stdio.h>
int main(void) {
	long long int a, b, k;
	scanf("%lld %lld %lld", &a, &b, &k);
	if (a <= k && b >= (k-a)) {
		b = b - (k - a);
		a = 0;
	}
	else if(a<k && b<(k-a)) {
		a = 0;
		b = 0;
			}
	else {
		a -= k;

	}
	printf("%lld %lld", a, b);
}

Measured memory_bytes: 128
#include <iostream>
#include <fstream>
#include <string> 
#include <cmath>  
#include <cstdlib>
#include <ctime>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <functional>

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

using namespace std;
using ll = long long;


int main() {
	string S1, S2;
	cin >> S1;
	cin >> S2;
	if ((S1[0] == S2[2]) && (S1[1] == S2[1]) && (S1[2] == S2[0])) cout << "YES" << endl;
	else cout << "NO" << endl;
	return 0;
}

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

using namespace std;
using ll = long long;

#define ALL(x) begin(x), end(x)

void solve(ll N, ll X, vector<ll> m) {
  ll s = accumulate(ALL(m),0);
  ll mi = *min_element(ALL(m));
  cout << N+(X-s)/mi << endl;
}

int main() {
  ll N;
  cin >> N;
  ll X;
  cin >> X;
  vector<ll> m(N);
  for (int i = 0; i < N; i++) {
    cin >> m[i];
  }
  solve(N, X, move(m));
  return 0;
}


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

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

    vector<long> X(N);
    vector<long> L(N);

    rep(i, N) cin >> X.at(i) >> L.at(i);

    vector<pair<long, long>> P(N);
    rep(i, N) P.at(i) = pair<long, long>(X.at(i) - L.at(i), X.at(i) + L.at(i));
    sort(P.begin(), P.end());

    int remove_cnt = 0;

    pair<long, long> p = P.at(0);
    for (int i = 1; i < N; i++)
    {
        if (P.at(i).first < p.second)
        {
            remove_cnt++;
            if (P.at(i).second <=p.second)
            {
                p = P.at(i);
            }
        }
        else
        {
            p = P.at(i);
        }
    }

    cout << N - remove_cnt << endl;
}


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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

//-------------------------------------------------
//--Enum various numbers
//-------------------------------------------------
namespace Enum
{
    using fint = ::std::int_fast64_t;
    //素因数分解(素因数列挙)
    ::std::map<fint,int> factor(fint n)
    {
        ::std::map<fint,int> ret;
        for(fint i=2; i*i<=n; i++){
            while(n%i==0){
                ret[i]++;
                n/=i;
            }
        }
        if (n!=1) ret[n]++;
        return ret;
    }
    //約数列挙
    ::std::vector<fint> divisor(fint n)
    {
        ::std::vector<fint> ret;
        for(fint i=1; i*i<=n; i++){
            if (n%i==0){
                ret.push_back(i);
                if (i*i!=n) ret.push_back(n/i);
            }
        }
        return ret;
    }
    //商列挙(割る最小の数と商のペア)
    ::std::vector<::std::pair<fint,fint> > quotient(fint n)
    {
        ::std::vector<::std::pair<fint,fint> > ret;
        fint i=0;
        for(i=1; i*i<=n; i++){
            ret.emplace_back(i,n/i);
        }
        for(; i<=n; i++){
            fint d = n/i;
            ret.emplace_back(i,d);
            i+=(n-d*i)/d;
        }
        return ret;
    }
    //素数判定(おまけ)
    bool isprime(fint n)
    {
        for(fint i=2; i*i<=n; i++){
            if (n%i==0) return false;
        }
        return true;
    }
}

//-------------------------------------------------

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N; cin>>N;
    auto fac = Enum::factor(N);
    int ans=0;
    for(auto e:fac){
        int now=1;
        while(e.se>=0) e.se-=now, now++, ans++;
        ans--;
    }
    cout<<ans<<"\n";
    return 0;
}


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

ll nCr(ll n, ll r){
    ll x=1, y=1;
    for(ll i = 1; i <= r; ++i){
        x = x * (n-i+1);
        y = y * i;
    }
    return x / y;
}

int main(){
    ll ans = 0;
    int n;
    cin >> n;
    vector<string> s(n);
    rep(i,n) cin >> s[i];
    rep(i,n) sort(s[i].begin(),s[i].end());
    unordered_map<string,int> mp;
    rep(i,n) ++mp[s[i]];

    for(auto a : mp){
        if(a.second > 1){
            ans += nCr(a.second,2);
        }
    }
    
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 17700
#include <stdio.h>

int main(void)
{

    int x, y;
    int t;

    while(1){
        scanf("%d %d", &x, &y);

        if(x != 0 || y != 0){
            if(x > y){
                t = x;
                x = y;
                y = t;
            }
            printf("%d %d\n", x, y);
        }
        else{break;}
    }
    return 0;
}    

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

cut=0
if n==0:
  print(1)
else:
  status=2 # 0:plus 1:minus 2:other
  for i in range(n-1):
    if status==2:
      if a[i]<a[i+1]:
        status=0
      elif a[i]>a[i+1]:
        status=1
    elif status==0:
      if a[i]>a[i+1]:
        cut+=1
        status=2
    elif status==1:
      if a[i]<a[i+1]:
        cut+=1
        status=2
print(cut+1)        


Measured memory_bytes: 14252
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
// #define main int main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
#define stlice(from, to) substr(from, (to) - (from) + 1)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
using namespace std;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef vector<pii> vpii;
typedef vector<vi> vvi;
typedef vector<vb> vvb;
typedef vector<vpii> vvpii;
const int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
const int MOD = 1000000007;
const double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
bool odd(const int &n) { return n & 1; }
bool even(const int &n) { return !odd(n); }
void solve();
main { solve(); return 0; }
// clang-format on

void solve() {
  int n;
  cin >> n;
  for (int i = 0, x = 1;; i++, x *= 3) {
    if (n <= x) {
      cout << i << endl;
      break;
    }
  }
}

Measured memory_bytes: 3120
#include <iostream>

using namespace std;

int main() {
    int n, m, l;
    cin >> n >> m >> l;
    int A[n][m];
    int B[m][l];
    //入力
    for(int i = 0;  i < n; i++) {
        for(int j = 0; j < m; j++) {
            cin >> A[i][j];
        }
    }
    for(int i = 0;  i < m; i++) {
        for(int j = 0; j < l; j++) {
            cin >> B[i][j];
        }
    }

    //処理
    long long int C[n][l];
    for(int i = 0; i < n; i++) {
        for(int j = 0; j < l; j++) {
            C[i][j] = 0; 
        }
    }

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < l; j++) {
            for (int k = 0; k < m; k++) {
                C[i][j] += A[i][k] * B[k][j];
            }
        }
    }

    //表示
    for(int i = 0;  i < n; i++) {
        for(int j = 0; j < l; j++) {
            if (j != l-1) cout << C[i][j] << ' ';
            else cout << C[i][j];
        }
        cout << endl;
    }

    return 0;
}


Measured memory_bytes: 3236
n, t = map(int, input().split())
a = list(map(int, input().split()))
m = float('inf')
l = []
max_s = 0
ans = 0
for i in range(n):
    m = min(m, a[i])
    max_s =max(a[i]-m, max_s)
    l.append(max(a[i] - m, 0))
for i in l:
    if i == max_s:
        ans += 1
# print(l)
print(ans)


Measured memory_bytes: 64236
#include <cstdio>

int main(){
	int c[6] = { 1, 5, 10, 50, 100, 500};
	int n;
	int sum = 0;
	for(int i = 0; i < 6; i++){
		scanf("%d", &n);
		sum += n * c[i];
	}
	
	if(sum >= 1000) printf("1\n");
	else printf("0\n");
	
	return 0;
}

Measured memory_bytes: 1016
#include <iostream>
#include <cmath>
#include <iomanip>
#include <limits>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
using namespace std;

bool isPrime(long long n){
    for(long long i=2;i*i<=n;i++){
        if(n%i == 0){
            return 0;
        }
    }
    return 1;
}

int factors(long long n){
    long long m=n;
    cout << n << ':';
    while(n>1){
        for(long long i=2;i*i<=m;i++){
            if(n % i == 0){
                n /= i;
                cout << ' ' << i;
                break;
            }
        }
        if(isPrime(n)){
            cout << ' ' << n;
            break;
        }
    }
    cout << endl;
    return 0;
}

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


Measured memory_bytes: 3116
import sys
from heapq import *
H=[]
O=[]
for e in sys.stdin:
 if'end'==e:break
 if'i'==e[0]:heappush(H,-int(e[7:]))
 elif't'==e[2]:O+=[-heappop(H)]
print('\n'.join(map(str,O)))


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

int main() {
  int A,B,C,D;
  cin >> A >> B >> C >> D;

  if ( A + B > C + D ) {
  cout << "Left" << endl;
  }
  else if ( A + B < C + D ) {
  cout << "Right" << endl;
  }
  else {
  cout << "Balanced" << endl;
  }  
}

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

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

typedef long long ll;

int GetLeftIndex(vector<int> &nodes, const int &i) {
  if (2 * i + 1 < nodes.size()) return 2 * i + 1;
  return -1;
}

int GetRightIndex(vector<int> &nodes, const int &i) {
  if (2 * i + 2 < nodes.size()) return 2 * i + 2;
  return -1;
}

void MaxHeepify(vector<int> &nodes, const int &index) {
  int left_index = GetLeftIndex(nodes, index);
  int right_index = GetRightIndex(nodes, index);
  int largest_index;
  if (left_index != -1 && nodes[left_index] > nodes[index]) {
    largest_index = left_index;
  } else {
    largest_index = index;
  }
  if (right_index != -1 && nodes[right_index] > nodes[largest_index]) {
    largest_index = right_index;
  }
  if (largest_index != index) {
    swap(nodes[index], nodes[largest_index]);
    MaxHeepify(nodes, largest_index);
  }
}

void BuildMaxHeap(vector<int> &nodes) {
  for (int i = (nodes.size() - 1) / 2; i >= 0; i--) {
    MaxHeepify(nodes, i);
  }
}

int main() {
  int n;
  cin >> n;
  vector<int> nodes(n);
  FOR(i, 0, n) { cin >> nodes[i]; }
  BuildMaxHeap(nodes);
  FOR(i, 0, n) { cout << " " << nodes[i]; }
  cout << endl;
  return 0;
}


Measured memory_bytes: 4604
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
static const int N=1000;

int lcs(string X, string Y){
  int c[N+1][N+1];
  int m=X.size();
  int n=Y.size();
  int maxl=0;
  X=' '+X;
  Y=' '+Y;
  for(int i=0;i<=m;i++) c[i][0]=0;
  for(int j=1;j<=n;j++) c[0][j]=0;

  for(int i=1;i<=m;i++){
    for(int j=1;j<=n;j++){
      if(X[i]==Y[j]){
	c[i][j]=c[i-1][j-1]+1;
      }else{
	c[i][j]=max(c[i-1][j],c[i][j-1]);
      }
      maxl=max(maxl,c[i][j]);
    }
  }
  return maxl;
}

int main(){
  string s1,s2;
  int n;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>s1>>s2;
    cout<<lcs(s1,s2)<<endl;
  }
  return 0;
}



Measured memory_bytes: 7072
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
//const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;
//const ll MOD = ;
ll mod(ll A, ll M) {return (A % M + M) % M;}
const ll INF = 1LL << 60;
template<class T> bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
ll divceil(ll A, ll B) {return (A + (B - 1)) / B;}
ll myctoi(char C) {return C - '0';}
char myitoc(ll N) {return '0' + N;}
#define FINALANS(A) {cout << (A) << '\n'; exit(0);}

int main()
{
  ll N;
  cin >> N;
  ll A, B;
  cin >> A >> B;

  ll ans = INF;
  if ((B - A) % 2 == 0)
    chmin(ans, (B - A) / 2);
  else
  {
    chmin(ans, A + ((B - A) - 1) / 2);
    chmin(ans, (N - B + 1) + (N - (A + (N - B + 1))) / 2);
  }
  chmin(ans, min(max(N - A, N - B), max(A - 1, B - 1)));

  cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        @SuppressWarnings("resource")
        Scanner sc = new Scanner(System.in);
        char[] s = sc.next().toCharArray();
        int l = 0;
        int r = 0;
        for (int i = 0 ; i < s.length ; i++) {
            if (s[i] == 'A') {
                l = i;
                break;
            }
        }
        for (int i = s.length - 1 ; i >= 0 ; i--) {
            if (s[i] == 'Z') {
                r = i;
                break;
            }
        }

//        for (int i = l ; i <= r ; i++) {
//            System.out.print(s[i]);
//        }
        System.out.print(r - l + 1);

    }

}

Measured memory_bytes: 28080
alp = ["a","b","c","d","e","f","g","h","i","j"]
N = int(input())
ans_list = []
for i in range(N):
    ans_list.append([])
for i in range(N):
    if i == 0:
        ans_list[i].append(["a",1])
    else:
        for j in range(len(ans_list[i-1])):
            for l in range(ans_list[i-1][j][1]+1):
                temp = ans_list[i-1][j][0] + alp[l]
                if l == ans_list[i-1][j][1]:
                    chk = ans_list[i-1][j][1]+1
                else:
                    chk = ans_list[i-1][j][1]
                ans_list[i].append([temp,chk])
for i in range(len(ans_list[N-1])):
    print(ans_list[N-1][i][0])

Measured memory_bytes: 73308
#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;

ll dp[105][100005];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N, K;
    cin >> N >> K;
    vector<ll> v0, v1;
    for (ll i = 1; i * i <= N; ++i) {
        v0.push_back(i);
    }
    ll last = N;
    REP(i, v0.size()) {
        if (last <= v0.size())
            break;
        ll n = v0[i];
        ll m = std::max((N / (n + 1)) + 1, (ll) v0.size());

        v1.push_back(std::max(0LL, last - m + 1));
        last = m - 1;
    }
    reverse(v0.begin(), v0.end());
    memset(dp, 0, sizeof(dp));
    REP(i, v1.size()) {
        dp[1][i] = v1[i];
    }
    REP(i, v0.size()) {
        dp[1][v1.size() + i] = 1;
    }

    FOR(i, K, 1) {
        ll s = 0;
        ll index = v1.size() + v0.size() - 1;
        REP(j, v1.size()) {
            s = (s + dp[i][index--]) % MOD;
            dp[i + 1][j] = (s * v1[j]) % MOD;
        }
        REP(j, v0.size()) {
            s = (s + dp[i][index--]) % MOD;
            dp[i + 1][j + v1.size()] = s;
        }
    }

    ll ans = 0;
    REP(i, v0.size() + v1.size()) {
        ans = (dp[K][i] + ans) % MOD;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 82940
n,x=map(int,input().split())
a=list(map(int,input().split()))
a.sort()
count=0

for i in range(n-1):
    if x>=a[i]:
        x-=a[i]
        count+=1
    else:
        break

if x==a[-1]:
    count+=1
print(count)

Measured memory_bytes: 3060
#include <stdio.h>
#include <assert.h>
#include <complex>
#include <vector>
#include <algorithm>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef complex<double> P;
#define EPS (1e-12)
#define e (1e-6)

P readP() {
    double x, y;
    scanf("%lf%lf", &x, &y);
    return P(x, y);
}

double radius(const vector<P>& ps) {
    P p = P(0, 0);
    for (double cur = 1.0; cur > EPS; cur *= 0.5) {
        rep (_, 100) {
            double mx = norm(ps[0]-p);
            int ix = 0;
            rep (i, ps.size()) {
                double d = norm(ps[i]-p);
                if (mx < d) mx = d, ix = i;
            }
            p += cur*(ps[ix]-p);
        }
    }
    double ans = 0;
    rep (i, ps.size()) ans = max(ans, abs(ps[i]-p));
    return ans;
}

int n, m;
double rs[128], ts[128];
bool used[128];

bool can(int k) {
    vector<double> a, b;
    rep (i, n) if (!used[i]) a.push_back(rs[i]);
    rep (i, m) if (i >= k) b.push_back(ts[i]);
    sort(a.begin(), a.end());
    reverse(a.begin(), a.end());
    sort(b.begin(), b.end());
    reverse(b.begin(), b.end());
    rep (i, b.size()) if (b[i] > a[i]+e) return false;
    return true;
}

int main() {
    scanf("%d%d", &n, &m);
    rep (i, n) scanf("%lf", rs+i);
    rep (i, m) {
        int K;
        scanf("%d", &K);
        vector<P> ps;
        rep (_, K) ps.push_back(readP());
        ts[i] = radius(ps);
    }
    if (!can(0)) puts("NG");
    else {
        int c = 0;
        rep (k, m) {
            rep (i, n) if (!used[i] && ts[k] <= rs[i]+e) {
                used[i] = 1;
                if (can(k+1)) {
                    c++;
                    printf("%d\n", i+1);
                    break;
                }
                used[i] = 0;
            }
        }
        assert(c == m);
    }
    return 0;
}

Measured memory_bytes: 1120
#![allow(unused_parens)]
#![allow(unused_imports)]
#![allow(non_upper_case_globals)]
#![allow(non_snake_case)]
#![allow(unused_mut)]
#![allow(unused_variables)]
#![allow(dead_code)]

use itertools::Itertools;
use proconio::input;
use proconio::marker::{Chars, Usize1};

#[allow(unused_macros)]
#[cfg(debug_assertions)]
macro_rules! mydbg {
    //($arg:expr) => (dbg!($arg))
    //($arg:expr) => (println!("{:?}",$arg));
      ($($a:expr),*) => {
          eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
      }
}
#[cfg(not(debug_assertions))]
macro_rules! mydbg {
    ($($arg:expr),*) => {};
}

macro_rules! echo {
    ($($a:expr),*) => {
          $(println!("{}",$a))*
      }
}

use std::cmp::*;
use std::collections::*;
use std::ops::{Add, Div, Mul, Sub};

#[allow(dead_code)]
static INF_I64: i64 = 92233720368547758;
#[allow(dead_code)]
static INF_I32: i32 = 21474836;
#[allow(dead_code)]
static INF_USIZE: usize = 18446744073709551;
#[allow(dead_code)]
static M_O_D: usize = 1000000007;
#[allow(dead_code)]
static PAI: f64 = 3.1415926535897932;

trait IteratorExt: Iterator {
    fn toVec(self) -> Vec<Self::Item>;
}

impl<T: Iterator> IteratorExt for T {
    fn toVec(self) -> Vec<Self::Item> {
        self.collect()
    }
}

trait CharExt {
    fn toNum(&self) -> usize;
    fn toAlphabetIndex(&self) -> usize;
    fn toNumIndex(&self) -> usize;
}
impl CharExt for char {
    fn toNum(&self) -> usize {
        return *self as usize;
    }
    fn toAlphabetIndex(&self) -> usize {
        return self.toNum() - 'a' as usize;
    }
    fn toNumIndex(&self) -> usize {
        return self.toNum() - '0' as usize;
    }
}

trait VectorExt {
    fn joinToString(&self, s: &str) -> String;
}
impl<T: ToString> VectorExt for Vec<T> {
    fn joinToString(&self, s: &str) -> String {
        return self
            .iter()
            .map(|x| x.to_string())
            .collect::<Vec<_>>()
            .join(s);
    }
}

trait StringExt {
    fn get_reverse(&self) -> String;
}
impl StringExt for String {
    fn get_reverse(&self) -> String {
        self.chars().rev().collect::<String>()
    }
}

trait UsizeExt {
    fn pow(&self, n: usize) -> usize;
}
impl UsizeExt for usize {
    fn pow(&self, n: usize) -> usize {
        return ((*self as u64).pow(n as u32)) as usize;
    }
}

fn main() {
    input! {
       s: Chars,
       t:Chars,
    }

    let mut ans: usize = 0;
    for i in 0..s.len() {
        if s[i] != t[i] {
            ans += 1;
        }
    }

    echo!(ans);
}


Measured memory_bytes: 3988
import numpy as np

N, W = map(int, input().split())
wv = [[0, 0]] + [[int(_) for _ in input().split()] for _ in range(N)]
dp = np.zeros([N+1, W+1], dtype=int)

for i in range(1, N+1):
    key = wv[i][0]
    dp[i][:key] = dp[i-1][:key]
    dp[i][key:] = np.maximum(dp[i-1][key:], dp[i-1][:-key] + wv[i][1])

print(dp[N][W])

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

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

        string res = "NO COLOR";
        for(auto p : m) if(p.second > n/2)  res = to_string(p.first);
        printf("%s\n", res.c_str());
    }
    return 0;
}


Measured memory_bytes: 4660
import copy as cp
import sys
from collections import deque


def func(s,i,j):
  dot = 0
  for c in s:
    dot += len(c.replace('#',''))
    
  d = deque()
  d.append((i,j,0))
  h = len(s)
  w = len(s[0])
  m = [[-1 for i in range(w)] for j in range(h)]
  
  count = 0
  while True:
    i,j,n = d.popleft()
    if i < 0 or j < 0 or i >= h or j >= w or s[i][j] == '#' or m[i][j] != -1:
      continue
    
    m[i][j] = n
    
    d.append((i+1,j,n+1))
    d.append((i,j+1,n+1))
    d.append((i-1,j,n+1))
    d.append((i,j-1,n+1))
    count += 1
    
    if count == dot:
      break
      
  
  ans = 0
  for i in range(len(m)):
    ans = max(ans,max(m[i]))

  return ans

h,w = map(int,input().split())
s = []
for i in range(h):
  s.append(input())

ans = 0
for i in range(h):
  for j in range(w):
    if s[i][j] == '#':
      continue
      
    tmp = func(s,i,j)
    ans = max(ans, func(s,i,j))

print(ans)

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

int main(){
    int64_t n,m;
    cin >>n>>m;
    
    int flag=0;
    //int ans=0;

    //cout <<fixed<<setprecision(16)<< << endl;
    cout << abs((m-2)*(n-2)) << endl;

    //if(flag==1)cout << "Yes" <<endl;
    //else cout << "No" <<endl;
    
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<string>
using namespace std;
long long int n,a[100005],x,y,sum;
int main(){
	cin>>n;
	for(long long int i=1;i<=n;i++)cin>>a[i];
	x=1;y=a[1];
	long long int j=0;
	while(y!=2){
		x=y;
		y=a[x];
		j++;
		if(j>n){ printf("-1");return 0;};
     };
	printf("%lld",j+1);
	return 0;}

Measured memory_bytes: 1152
s=input()
K=int(input())
ans=[]

for c in s:
  if c=="a":
    ans.append(c)
    continue
  if ord("z")+1- ord(c)<=K:
    K-=ord("z")+1-ord(c)
    ans.append("a")
    continue
    
  ans.append(c)
    
if K:
  ans[-1]=chr( (ord(ans[-1])+K%26 -ord("a"))%26+ord("a") )
print("".join(ans))

Measured memory_bytes: 46448
a, b = map(int, input().split())
import math


def _gcd(x, y):
    if y == 0:
        return x
    return _gcd(y, x % y)


gcd = _gcd(a, b)
i, cnt = 2, 1
while i * i <= gcd:
    flag = 0
    while gcd % i == 0:
        flag = 1
        gcd //= i
    if flag:
        cnt += 1
    i += 1
if gcd != 1:
    cnt += 1
print(cnt)


Measured memory_bytes: 40044
N = int(input())
A = list(map(int, input().split()))

cnt = 0
f = 0

for i in range(N):
    if A[i] < 0:
        cnt += 1
        A[i] *= -1
    elif A[i] == 0:
        f = 1

# print(cnt)
# print(min(A))
# print(sum(A))
if cnt%2 == 0 or f:
    print(sum(A))
else:
    print(sum(A) - min(A)*2)

Measured memory_bytes: 14332
using System;
class Program {
  
  private static int[] data = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  
  static void Main(string[] args) {
    int a,b,c;
    a = int.Parse(Console.ReadLine()); //標準入力
    //string[] str = Console.ReadLine().Split(' ');//2つ以上のスペース区切り入力の取得
    //b = int.Parse(str[0]);  //数値で受け取りたい場合は変換
    
    Console.Write(data[a-1]);//改行なし出力
    //Console.WriteLine("改行あり a = {0} b = {1} c = {2}", a, b, c);//改行付き出力
  }
 }

Measured memory_bytes: 13140
while True:
    n,x = map(int,input().split())
    if n == 0 and x == 0:
        break
    count = 0
    for i in range(1,n+1):
        for j in range(i+1,n+1):
            for k in range(j+1,n+1):
                if i + j + k == x:
                    count += 1
    print(count)
                


Measured memory_bytes: 5596
N, A, B, C = map(int, input().split())
l = [int(input()) for i in range(N)]
INF = 1E9

def dfs(cur, a, b, c):
    if(cur == N):
        return abs(a-A) + abs(b-B) + abs(c-C) - 30 if min(a, b, c)>0 else INF
    ret0 = dfs(cur + 1, a, b, c)
    ret1 = dfs(cur + 1, a + l[cur], b, c) + 10
    ret2 = dfs(cur + 1, a, b + l[cur], c) + 10
    ret3 = dfs(cur + 1, a, b, c + l[cur]) + 10
    return min(ret0, ret1, ret2, ret3)

print(dfs(0, 0, 0, 0))

Measured memory_bytes: 3064
# -*- coding: utf-8 -*-

n = int(input())
v = [int]*n
c = [int]*n
v = input().split()
c = input().split()

sum = 0

for i in range(n):
	xy = int(v[i]) - int(c[i])
	if xy > 0:
		sum += xy
		
print(sum)


Measured memory_bytes: 3060
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

s = readline().rstrip().decode('utf-8')
t = readline().rstrip().decode('utf-8')

#できる限りTを後ろの方に詰めるというのが大前提
#全て？かもしくは、SとTを照らし合わせた時に？以外が全て合っている場合、それが正解。
#他の？は全てaで埋めればよい
flag = 0
for i in range(len(s)-len(t),-1,-1):
    for j in range(len(t)):
        if s[i+j] == t[j] or s[i+j] == "?":
            if j == len(t)-1:
                flag = 1
                break
        else:
            flag = 0
            break
    if flag:
        ans = ["a" for k in range(len(s))]
        
        for k in range(len(s)):
            if s[k] != "?":
                ans[k] = s[k]
        for k in range(len(t)):
            ans[i+k] = t[k]
        print("".join(ans))
        exit()

print("UNRESTORABLE")


Measured memory_bytes: 38384
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define double long double
#define endl '\n'
#define vi vector<int>
#define vvi vector<vi>
#define vpii vector<pii>
#define vpipii vector<pipii>
#define vpiipi vector<piipi>
#define pb push_back
#define pob pop_back
#define pii pair<int,int>
#define pipii pair<int,pii>
#define piipi pair<pii,int>
#define pld pair<long double,long double>
#define mod 1000000007
// #define mod 163577857 
// #define mod 998244353
#define rep(i,n) for (int i = 0; i < n; i++)
#define repp(i,a,b) for(int i = a ; i<b ; i++)
#define reppr(i,a,b) for(int i = a-1 ; i>=b ; i--)
#define repr(i,n) for (int i = n - 1; i >= 0; i--)
#define ff first
#define ss second
#define pc putchar_unlocked
#define gc getchar_unlocked
#define inf 9223372036854775807
#define infn -9223372036854775807
#define pi 3.14159265358979323846
#define eps 0.0000000001
#define sp << " " <<
#define setprec(x) cout << fixed << setprecision(x);
#define REVERSE(a) reverse(all(a));
#define SORT(a) sort(all(a));
#define all(n) n.begin(),n.end()
 
//GCD and LCM
    int gcd (int a, int b) { return b ? gcd (b, a % b) : a; }
    int lcm (int a, int b) { return a / gcd(a, b) * b; }
 
//Modular Exponentiation
    int powmod(int x,int y) 
    { 
        if (y == 0) return 1; 
        int p = powmod(x, y/2) % mod; 
        p = (p * p) % mod;   
        return (y%2 == 0)? p : (x * p) % mod; 
    }
 
//Modular Inverse
    int inverse(int a) 
    { 
       return powmod(a,mod-2); 
    }

//Binomial Coefficients
    int fact[200010], factinv[200010] , coefficientflag = 0;
    void Util_nCr()
    {
        fact[0] = 1 , factinv[0] = 1;
        repp(i,1,200010)
        {
            fact[i] = (fact[i-1] * i)%mod;
            factinv[i] = (factinv[i-1] * inverse(i))%mod;
        }
    }
    int nCr(int n , int r)
    {
        if(!coefficientflag) coefficientflag = 1 , Util_nCr();             
        return ((fact[n] * inverse(fact[n-r]) % mod * inverse(fact[r]))%mod) ;
    }

void solve();
signed main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    int t = 1;
    // cin >> t; 
    while(t--)
        solve();
} 

void solve()            
{
    int k;
    cin >> k;
    string s;
    cin >> s;
    if(s.length()<=k)
        cout << s;
    else
        cout << s.substr(0,k) << "...";
}

Measured memory_bytes: 3536
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi vector<vector<int> >
#define vvl vector<vector<ll> >
#define vll vector<ll>
#define rep(a, b, c) for(ll c=a;c<b;c++)
#define re(b, c) for(ll c=0;c<b;c++)
typedef long long int ll;
typedef long double ld;
using namespace std;

//-------------------------------------------------------------------
#define P 1000000007
#define N_MAX 2000000
typedef long long int ll;
ll fac[N_MAX+1];
ll inv[N_MAX+1];
ll finv[N_MAX+1];

ll comb(ll n, ll k){
    if(n<k) return 0;
    return (((fac[n]*finv[n-k])%P)*finv[k])%P;
}

void init(){
    fac[0] = finv[0] = fac[1] = finv[1] = inv[1] = 1;
    for(int i = 2; i <= N_MAX; i++){
        fac[i] = (fac[i-1]*i)%P;
        inv[i] = ((-(P/i)*inv[P%i])%P+P)%P;
        finv[i] = (finv[i-1]*inv[i])%P;
    }
}
//-------------------------------------------------------------------
//-------------------------------------------------------------------
#include <sstream>
#include <fstream>
ifstream ifs;
void initr(string s){ifs.open(s);}
vector<string> split(const string &str, char sep){
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while(getline(ss, buffer, sep)) v.push_back(buffer);
    return v;
}
ll read(){
  string str;
  getline(ifs, str);
  return stoll(str);
}
string read_str(){
  string str;
  getline(ifs, str);
  return str;
}
vector<ll> read_vec(){
  string str;
  getline(ifs, str);
  std::vector<ll> num;
  vector<string> data = split(str, ' ');
  for(int i=0;i<data.size();i++) num.push_back(stoll(data[i]));
  return num;
}
vvl read_mat(ll h){
  string str;
  vvl num = vv(h, 0, 0, ll);
  for(int i=0;i<h;i++){
    getline(ifs, str);
    vector<string> data = split(str, ' ');
    for(int j=0;j<data.size();j++) num[i].push_back(stoll(data[j]));
  }
  return num;
}
//-------------------------------------------------------------------

int main(int argc, char const *argv[]) {
  ll n;
  std::cin >> n;
  //initr("rnd_0.in");
  //n = read();
  vll num(n+1, -1), a(n+1);
  ll sa = 0;
  init();
  //a = read_vec();
  re(n+1, i) std::cin >> a[i];
  re(n+1, i) {
    if(num[a[i]]!=-1) sa = i - num[a[i]] - 1;
    num[a[i]] = i;
  }
  for(int i=1;i<=n+1;i++){
    ll a = comb(n-1,i);
    ll b = (2*comb(n-1,i-1)-comb(n-1-sa,i-1) + P)%P;
    ll c = comb(n-1, i-2);
    std::cout << (a+b+c)%P << '\n';
  }
  return 0;
}


Measured memory_bytes: 49664
#include <iostream>
#include <string>
#define REP(val,times) for(int val = 0;val < times;val++)
using namespace std;

struct Dice{
    int s[6];
    void roll(char ope){
        int b;
        if(ope == 'E'){
            swap(s[0],s[2]);
            swap(s[0],s[5]);
            swap(s[0],s[3]);
        }
        if(ope == 'W'){
            swap(s[0],s[3]);
            swap(s[0],s[5]);
            swap(s[0],s[2]);
        }
        if(ope == 'S'){
            swap(s[0],s[1]);
            swap(s[0],s[5]);
            swap(s[0],s[4]);
        }
        if(ope == 'N'){
            swap(s[0],s[4]);
            swap(s[0],s[5]);
            swap(s[0],s[1]);
        }
        if(ope == 'R'){
            swap(s[1],s[2]);
            swap(s[1],s[4]);
            swap(s[1],s[3]);
        }
    }
    int top(){
        return s[0];
    }
    int right(){
        return s[2];
    }
    int left(){
        return s[3];
    }
    int front(){
        return s[1];
    }
};

bool same(Dice a,Dice b){
    REP(i,6)
     if(a.s[i] != b.s[i])   
         return false;
    return true;
}

int main(){
    Dice Dice[2];
    REP(i,2)
        REP(j,6)
            cin >> Dice[i].s[j];
    bool flag = false;
    
    REP(i,4){
        Dice[1].roll('R');
        REP(j,4){
            Dice[1].roll('N');
            if(same(Dice[0],Dice[1]))
                flag = true;
        }
    }
    Dice[1].roll('E');
    REP(i,4){
        Dice[1].roll('N');
        if(same(Dice[0],Dice[1]))
            flag = true;
    }
    Dice[1].roll('W');
    Dice[1].roll('W');
    REP(i,4){
        Dice[1].roll('N');
        if(same(Dice[0],Dice[1]))
            flag = true;
    }
    cout << (flag ? "Yes" : "No") << endl;

    return 0;
}


Measured memory_bytes: 3116
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll c[15],a[15][15];
int main(){
	ll n,m,x;
	cin>>n>>m>>x;
	for(int i=0;i<n;i++){
		cin>>c[i];
		for(int j=0;j<m;j++)cin>>a[i][j];
	}
	ll ans=1e9;
	for(int i=0;i<(1ll<<n);i++){
		ll sum[15]={},num=0;
		for(int j=0;j<n;j++){
			if(i&(1<<j)){
				num+=c[j];
				for(int k=0;k<m;k++)sum[k]+=a[j][k];
			}
		}
		bool f=1;
		for(int j=0;j<m;j++)if(sum[j]<x)f=0;
		if(f)ans=min(ans,num);
	}
	if(ans==1e9)cout<<-1;
	else cout<<ans;
	return 0;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
#define INF 1e+9

struct edge {
    int to;
    int cost;
};
using P = pair<int, int>;	// <最短距離, 頂点の番号>

void dijkstra(vector<vector<edge>> &g, vector<int> &d, int s) {
    priority_queue<P, vector<P>, greater<P> > que;
    d.assign(d.size(), INF);
    d[s] = 0;
    que.push(P(0, s));

    while (!que.empty()) {
        P p = que.top();
        que.pop();
        int v = p.second;
        if (d[v] < p.first) continue;

        for (int i=0; i<g[v].size(); ++i) {
            edge e = g[v][i];
            if (d[e.to] > d[v] + e.cost) {
                d[e.to] = d[v] + e.cost;
                que.push(P(d[e.to], e.to));
            }
        }
    }
}

int main() {
	int n, x, y;
	cin >> n >> x >> y;
	x--; y--;
	vector<vector<edge>> g(n);
	rep(i, n-1) {
		edge e = {i+1, 1};
		edge f = {i, 1};
		g[i].push_back(e);
		g[i+1].push_back(f);
	}
	{
		edge e = {y, 1};
		edge f = {x, 1};
		g[x].push_back(e);
		g[y].push_back(f);
	}
	vector<vector<int>> dis(n, vector<int>(n));
	rep(i, n) {
		vector<int> dist(n);
		dijkstra(g, dist, i);
		dis[i] = dist;
	}
	
	
	vector<int> ans(n-1);
	rep(i, n) {
		for(int j = i+1; j < n; j++) {
			ans[dis[i][j]-1]++;
		}
	}
	rep(i, n-1) {
		cout << ans[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 16128
function main(input) {
  const array = input.trim().split("\n");
  const NK = array[0].trim().split(" ");
  let N = parseInt(NK[0]);
  let K = parseInt(NK[1]);
  let p = array[1].trim().split(" ");
  p.sort(function (a, b) {
    if (parseInt(a) < parseInt(b)) return -1;
    if (parseInt(a) > parseInt(a)) return 1;
    return 0;
  });
  let counter = 0;
  for (let i = 0; i < K; i++) {
    counter += parseInt(p[i]);
  }
  console.log(counter);
}
main(require("fs").readFileSync("/dev/stdin", "utf8"));
// main("5 3\n50 100 80 120 80");
// main("1 1\n1000");


Measured memory_bytes: 31316
#include <stdio.h>

long long int gcd(long long int a, long long int b){
  	long long int tmp;
    if(a<b){tmp=a;a=b;b=tmp;}
    if(b == 0)return a;
    return gcd(b, a%b);
}

long long int lcm(long long int a, long long int b){
    return a * b / gcd(a, b);
}

int main(){
  long long int A,B;
  scanf("%lld %lld",&A,&B);
  printf("%lld\n",lcm(A,B));
}

Measured memory_bytes: 128
#include <cstdio>

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

  int oc = 0;
  for(; N--; ){
    int x; scanf("%d", &x); oc += x % 2;
  }

  puts(oc % 2 == 1 ? "NO" : "YES");
  return 0;
}


Measured memory_bytes: 128
#include<stdio.h>
#include<math.h>
int main(void)
{
    int a,b;
    int c;
    while(scanf("%d %d",&a,&b) != EOF){
        c = a + b;
        c = log10(c);
        printf("%d\n",c+1);
    }
    return 0;
}

Measured memory_bytes: 644
//
//  main.cpp
//  앳코
//
//  Created by 김도훈 on 2020/09/13.
//  Copyright © 2020 김도훈. All rights reserved.
//

#include <iostream>
using namespace std;

int main() {
    int N;
    long long a = 1, b = 2, c = 1, ans;
    cin >> N;
    for (int i = 1; i <= N; i++) {
        a *= 10; b *= 9; c *= 8;
        a %= 1000000007; b %= 1000000007; c %= 1000000007;
    }
    ans = (a-b+c+2000000014)%1000000007;
    cout << ans;
    return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(a)  (a).begin(),(a).end()
#define PI 3.14159265358979
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll mod = 1e9+7LL;

int main() {
    ll N, M; cin >> N >> M;
    map<int, int> d;
    rep(i, M){
        ll a, b; cin >> a >> b;
        d[a]++;
        d[b]++;
    }

    bool flag = true;

    rep(i, N){
        if(d.count(i)){
            if(d.at(i)%2!=0) flag = false;
        }
    }

    if(flag) cout << "YES" << endl;
    else cout << "NO" << endl;
}

Measured memory_bytes: 4352
import sys
n=int(input())
A=sorted(list(map(int,input().split())))
ans=1
mod=1000000007
if n%2==1:
    if A[0]==0:
        for i in range(1,n//2+1):
            if A[i*2-1]==A[i*2]==i*2:
                ans*=2
                ans%=mod
            else:
                print(0)
                sys.exit()
    else:
        print(0)
        sys.exit()
else:
    for i in range(n//2):
        if A[i*2]==A[i*2+1]==i*2+1:
            ans*=2
            ans%=mod
        else:
            print(0)
            sys.exit()

print(ans)

Measured memory_bytes: 14008
#include<iostream>
#include<math.h>
using namespace std;

int main()
{
    long long int n;
    cin>>n;
    long long int best=n-1;
    int i;
    for(i=1;i<=sqrt(n);i++)
    {
        if(n%i==0)
        {
            if(best>((n/i)+i-2))
                best=(n/i)+i-2;
        }
    }
    cout<<best;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<cmath>
using namespace std;
int N,L,minn,maxx;
int main()
{
	scanf("%d%d",&N,&L);
	minn=L;maxx=L+N-1;
	if(minn<=0&&maxx>=0)printf("%d",(minn+maxx)*N/2);
	if(minn>0)printf("%d",(minn+maxx)*N/2-minn);
	if(maxx<0)printf("%d",(minn+maxx)*N/2-maxx);
}

Measured memory_bytes: 256
// 2017-02-03
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
using namespace std;

int main() {
	int n;
	while (cin >> n, n) {
		vector<string> v;
		int l = 0;
		for (int i = 0; i < n; i++) {
			string s, t;
			cin >> s;
			t.push_back(s[0]);
			for (int j = 1; j < s.length(); j++) {
				switch (s[j - 1]) {
					case 'a': case 'i': case 'u': case 'e': case 'o': t.push_back(s[j]);
				}
			}
			v.push_back(t);
			l = max(l, (int)t.length());
		}
		sort(begin(v), end(v));
		for (int i = 0; i < n; i++) {
			while (v[i].length() < l) v[i].push_back('.');
		}
		int d = -1;
		bool b[50] = {};
		for (int i = 0; i < l; i++) {
			bool a = true;
			for (int j = 1; j < n; j++) {
				if (v[j][i] != v[j - 1][i]) b[j] = true;
				a &= b[j];
			}
			if (a) {
				d = i + 1;
				break;
			}
		}
		cout << d << endl;
	}
	return 0;
}

Measured memory_bytes: 3100
#include <stdio.h>

int main() {
    int a;
    printf("\n");
    
    if(scanf("%d", &a)==1)
    {
        if(100<=a&&a<=999)
        {
        int b= (a-70)/10;
        
        if(0<=a-700&&a-700<=99)
        {
            printf("Yes");
        }
        else if((a-7)%10==0)
        {
            printf("Yes");
        }
        else if(b%10==0)
        {
            printf("Yes");
        }
        else
        {
            printf("No");
        }
        }
        else
        {
            printf("Error");
        }
    
    }
    
        return 0;
}


Measured memory_bytes: 1736
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <climits>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
#include <random>
#include <complex>
#include <regex>

using namespace std;

#define SHOW_VECTOR(v) {std::cerr << #v << "\t:";for(const auto& xxx : v){std::cerr << xxx << " ";}std::cerr << "\n";}
#define SHOW_MAP(v){std::cerr << #v << endl; for(const auto& xxx: v){std::cerr << xxx.first << " " << xxx.second << "\n";}}


int main() {

    long long x;
    cin >> x;

    long long d = x / 11;
    x -= d * 11;
    long long ans = d * 2;

    if(x == 0) cout << ans;
    else if (x <= 6) cout <<  1 + ans ;
    else if (x <= 11) cout << 2 + ans;

}


























































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

int main() {
  int n;
  cin >> n;
  string s, ans;
  ans = "Three";
  
  for (int i = 0; i < n; i++) {
    string m;
    cin >> m;
    s += m;
  }
  
  for (int i = 0; i < n; i++) {
    if (s.at(i) == 'Y') {
      ans = "Four";
      break;
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int color[100050],fath[100050],n,ans[2];
vector <int> V[100050];
void build(int now,int f)
{
	fath[now]=f;
	for(int i=0;i<V[now].size();i++)
		if(V[now][i]!=f)build(V[now][i],now);
	return;
}
void dfs(bool flag,int now)
{
	color[now]=flag;
	ans[flag]++;
	for(int i=0;i<V[now].size();i++)
		if(color[V[now][i]]==-1)dfs(flag,V[now][i]);
}
int main()
{
	cin>>n;
	for(int i=1;i<n;i++)
	{
		int x,y;
		cin>>x>>y;
		V[x].push_back(y);
		V[y].push_back(x);
	}
	build(1,1);
	for(int i=1;i<=n;i++)color[i]=-1;
	int z=n,sum=0;
	while(z!=fath[z])
	{
		sum++;
		z=fath[z];
	}
	z=n;
	for(int i=1;i<=(sum-1)/2;i++)z=fath[z];
	color[z]=1;
	color[fath[z]]=0;
	dfs(1,z);
	dfs(0,fath[z]);
	if(ans[0]>ans[1])cout<<"Fennec";
	else cout<<"Snuke";
	return 0;
}

Measured memory_bytes: 11136
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>
#include <numeric>
#include <queue>
#include <stack>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9) + 7;

vector<int> Divisors(int n) {
	vector<int> res;

	for(int i = 1; i * i <= n; ++i) {
		if( n % i == 0 ) {
			res.push_back(i);
			
			if( i < n / i ) res.push_back(n / i);
		}
	}
	
	sort(res.begin(), res.end(), greater<int>());
	
	return res;
}

int gcd(int a, int b) {
	if( a < b ) swap(a, b);
	
	int r;
	while( r = a % b ) {
		a = b;
		b = r;
	}
	
	return b;
}

int main(void) {
	int a, b, k;
	cin >> a >> b >> k;
	
	vector<int> div = Divisors(gcd(a, b));
	
	cout << div[k - 1] << endl;
	
	return 0;
}


Measured memory_bytes: 256