akhauriyash/Code-Regression huggingface dataset:
// ※※※ 解答不能 ※※※
// LHiC氏.
// https://atcoder.jp/contests/caddi2018/submissions/3847395
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
#define repex(i, a, b, c) for(int i = a; i < b; i += c)
#define repx(i, a, b) repex(i, a, b, 1)
#define rep(i, n) repx(i, 0, n)
#define repr(i, a, b) for(int i = a; i >= b; i--)
#define pb push_back
const LL MOD = 998244353;

LL pw(LL a, LL b){
    LL ans = 1;
    while(b){
        while(!(b & 1)) b >>= 1, a = (a * a) % MOD;
        ans = (ans * a) % MOD, --b;
    }
    return ans;
}

map<pair<int, int>, int> mm;
const int MAXN = 120000;
LL dp[8], dp2[2];
vector<int> go[MAXN * 2];
int dd[MAXN * 2][3], pc[10];

int main(){
    LL n, m;
    scanf("%lld %lld", &n, &m);
    LL gg = n * n - n - 2 * (n - 1) - 2 * (n - 2);
    gg /= 2;
    rep(i, 2 * (LL)n) rep(j, 3) dd[i][j] = -1;
    rep(i, (LL)m){
        int a, b, c;
        scanf("%d %d %d", &a, &b, &c);
        --a, --b;
        if(mm.count({a, b})){
            if(mm[{a, b}] != c){
                puts("0");
                return 0;
            }
            continue;
        }
        if(abs(a - b) > 2){
            --gg;
            mm[{a, b}] = c;
            mm[{b, a}] = c;
        }else{
            if(abs(a - b) <= 1) go[a + b].pb(c);
            if(abs(a - b) % 2 == 0) dd[(a + b) / 2][1 + (a - b) / 2] = c;
        }
    }
    repx(i, 1, (LL)(n - 1)){
        int cc = 0;
        rep(j, 3) if(dd[i][j] != -1) ++cc;
        if(cc == 0){
            ++gg;
        }else if(cc == 1){
            if(dd[i][1] != -1) ++gg;
        }else if (cc == 2){
            if(dd[i][1] == -1){
                dd[i][1] = dd[i][0] ^ dd[i][2];
                go[i * 2].pb(dd[i][1]);
            }
        }else{
            if((dd[i][0] ^ dd[i][1] ^ dd[i][2]) != 0){
                puts("0");
                return 0;
            }
        }
    }
    rep(i, (LL)n) if(go[2 * i].empty()) go[2 * i].pb(-1);
    rep(i, (LL)(n - 1)) while(go[2 * i + 1].size() < 2) go[2 * i + 1].pb(-1);
    array<int, 3> a = {go[0][0], go[1][0], go[1][1]};
    rep(i, 8){
        int fl = 0;
        rep(j, 3) if(a[j] != -1 && a[j] != ((i >> j) & 1)) fl = 1;
        if(!fl) dp[i] = 1;
        else    dp[i] = 0;
    }
    rep(i, 8) pc[i] = __builtin_popcount(i) % 2;
    repx(i, 1, (LL)n){
        memset(dp2, 0, sizeof(dp2));
        rep(j, 8){
            int cur = pc[j];
            if(go[2 * i][0] != -1 && go[2 * i][0] != cur) continue;
            dp2[cur] = (dp2[cur] + dp[j]) % MOD;
        }
        if(i == n - 1) break;
        memset(dp, 0, sizeof(dp));
        array<int, 3> a = {-1, go[2 * i + 1][0], go[2 * i + 1][1]};
        rep(k, 2){
            a[0] = k;
            rep(i, 8){
                int fl = 0;
                rep(j, 3) if(a[j] != -1 && a[j] != ((i >> j) & 1)) fl = 1;
                if(!fl) dp[i] = dp2[k];
            }
        }
    }
    printf("%lld\n", (dp2[0] + dp2[1]) * pw(2, gg) % MOD);
    return 0;
}

Measured memory_bytes: 21120
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <utility>
#include <numeric>

using namespace std;

using ll = long long;
using ull = unsigned long long;

const ll inf = (ll)1e9;
const ll mod = (ll)1e9 + 7;

#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

#define print(s) cout << s;
#define println(s) cout << s << endl;
#define printd(s, f) cout << fixed << setprecision(f) << s << endl;


int main()
{
	int a, b, c;
	cin >> a >> b >> c;

	if (b >= a * c)
	{
		println(c);
	}
	else
	{
		println(b / a);
	}
}


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

const double PI = acos(-1);
using ll = long long;
using ull = unsigned long long;
const int inf = 2e9;
const ll INF = 2e18;
const ll MOD = 1e9+7;
typedef pair<int,int> P;

#define REP(i,n) for (int i = 0; i < (n); i++)
#define sz(s) (s).size()
#define pb push_back
#define fi first
#define se second
#define mp make_pair

const int d[] = {0, 1, 1, 0, -1, 1, -1, -1, 0};

int main(){
  int h, w;
  scanf("%d%d", &h, &w);
  static int cell[1123][1123], stat[1123][1123];
  REP(i, h) REP(j, w){
    while(isspace(cell[i][j] = getchar()));
    if(cell[i][j] == '.'){
      cell[i][j] = -1;
      stat[i][j] = -1;
    }else{
      cell[i][j] -= '0';
      stat[i][j] = 0;
    }
  }

  /*REP(i, h){
    REP(j, w) putchar(cell[i][j]);
    putchar('\n');
  }*/

  set<P> next;
  REP(i, h) REP(j, w) next.insert(mp(i, j));

  for(int t = 0;; ++t){
    set<P> next_;
    vector<P> ochita;
    for(auto i : next){
      if(stat[i.fi][i.se] != -1){
        int count = 0;
        REP(j, 8){
          if(stat[i.fi + d[j]][i.se + d[j + 1]] == -1) ++count;
        }
        if(count >= cell[i.fi][i.se]){
          //stat[i.fi][i.se] = -1;
          ochita.pb(mp(i.fi, i.se));
          REP(k, 8){
            next_.insert(mp(i.fi + d[k], i.se + d[k + 1]));
          }
        }
      }
    }
    for(auto i : ochita) stat[i.fi][i.se] = -1;


    if(next_.empty()){
      printf("%d\n", t);
      return 0;
    }else{
      next = next_;
    }

  }
}



Measured memory_bytes: 58856
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bits/stdc++.h>
#include<cmath>
#include<bitset>
#include<queue>
#define ll long long
#define itn int
#define co(ans) cout<<ans<<endl;
#define COYE cout<<"YES"<<endl;
#define COYe cout<<"Yes"<<endl;
#define COye cout<<"yes"<<endl;
#define CONO cout<<"NO"<<endl;
#define CONo cout<<"No"<<endl;
#define COno cout<<"no"<<endl;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define INF ((1LL<<62)-(1LL<<31))
#define MOD 1000000007
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
using namespace std;


int main(){
  ll N;
  cin>>N;
  
  ll A[N];
  REP(i,N) cin>>A[i];
  
  ll t=1;
  for(int i=0; i<N; ++i){
    if(A[i]==t){
      t++;
    }
  }
  
  if(t<2){
    cout<<-1<<endl;
    return 0;
  }
  
  cout<<N-t+1<<endl;
  return 0;
}


Measured memory_bytes: 1920
#include<bits/stdc++.h>
#define rep(i,k,n) for(ll i= (ll) k;i< (ll) n;i++)
#define all(v) (v).begin(), (v).end()
#define SZ(v) (int)((v).size())
#define pb push_back
#define ft first
#define sd second
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const long long INF = 4e18L + 1;
const int IINF = 2e9 + 1;

using namespace std;

template<class TH> void _dbg(const char *sdbg, TH h){ cerr<<sdbg<<'='<<h<<endl; }
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',')cerr<<*sdbg++;
  cerr<<'='<<h<<','; _dbg(sdbg+1, a...);
}

#ifdef LOCAL
#define DBG(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define DBG(...)
#define cerr if(0)cout
#endif

int main()
{
#ifndef LOCAL
    ios_base::sync_with_stdio(0);
    cin.tie(0);
#endif
	ll k; cin >> k;
	vector<ll>quer(k);
    for(auto& q : quer){
		cin >> q;
	}
	ll st = 2, fn = 2;
	reverse(all(quer));
	for(auto& q : quer){
		if(st / q == fn / q and st % q){
			cout << "-1\n";
			return 0;
		}
		st = (st + q - 1) / q * q;
		fn = fn / q * q + q - 1;
	}
	cout << st << " " << fn << "\n";
	return 0;
}

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

ll g(ll a,ll b){
  ll n;
  while(a%b!=0){
    n=a%b;
    a=b;
    b=n;
  }
  return b;
}

ll h(ll a,ll b){
  return (a/g(a,b))*b;
}

int main(){
  int i,j;ll cnt=0;
  int n;
  cin>>n;
  ll t[n];
  for(i=0;i<n;i++)cin>>t[i];
  cnt=t[0];
  for(i=1;i<n;i++)cnt=h(cnt,t[i]);
  cout<<cnt;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define LL long long
#undef INT_MIN
#undef INT_MAX
#define INT_MIN -2147483648
#define INT_MAX 2147483647
#define LL_MIN -9223372036854775808
#define LL_MAX 9223372036854775807
#define segment_size 65536
int main(){
    string S;
    cin >> S;
    int ans = 700;
    if(S[0] == 'o') ans += 100;
    if(S[1] == 'o') ans += 100;
    if(S[2] == 'o') ans += 100;
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
N, K = map(int, input().split())
h = list(map(int, input().split()))
dp = [None] * N

for i in range(N):
    if i == 0:
        dp[0] = 0
    elif i == 1:
        dp[1] = abs(h[0]-h[1])
    else:
        ans = 10**10
        for j in range(1, K+1):
            if j > i:
                break
            ans = min(ans, dp[i-j] + abs(h[i-j]-h[i]))
        dp[i] = ans

print(dp[N-1])

Measured memory_bytes: 85456
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define io ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
int n, w;
void solve(){
	cin>>n>>w;
	int weight[n], value[n];
	ll dp[n + 1][w + 1];
	for(int i = 0; i < n; ++i){
		cin>>weight[i];
		cin>>value[i];
	}
	for(int i = 0; i < n + 1; i++) dp[i][0] = 0;
	for(int i = 0; i <= w; i++) dp[0][i] = 0;
	for(int i = 1; i < n + 1; i++){
		for(int j = 1; j <= w; j++){
			if(j - weight[i - 1] < 0) dp[i][j] = dp[i - 1][j];
			else{
				dp[i][j] = (ll)max(value[i - 1] + dp[i - 1][j - weight[i - 1]], dp[i - 1][j]);
			}
//			cout<<dp[i][j]<<" ";
		}
//		cout<<endl;
	}
//	cout<<endl;
	cout<<dp[n][w];
}
int main(){
	io;
	solve();
	return 0;
}


Measured memory_bytes: 82516
#include <bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef long long ll;
typedef pair<double, double> pdd;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef vector<pii> vii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
//const int mod = ;

int main() {
  std::ios::sync_with_stdio(false); std::cin.tie(0);
  int n, k;
  cin >> n >> k;
  vi a(n);
  for (int i = 0; i < n; ++i) cin >> a[i];
  int res = 1, cnt = 0;
  set<int> w;
  for (int i = 0; i < k; ++i) {
    w.insert(a[i]);
    if (i + 1 < k) cnt += a[i] < a[i + 1];
  }
  int was = cnt == k - 1;
  for (int i = k; i < n; ++i) {
    w.insert(a[i]);
    cnt += a[i - 1] < a[i];
    cnt -= a[i - k] < a[i - k + 1];
    auto it = w.end(); --it;
    if (*w.begin() != a[i - k] || *it != a[i]) {
      if (cnt == k - 1) {
        if (!was) ++res;
        was = 1;
      } else ++res;
    }
    w.erase(a[i - k]);
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 11264
#include<bits/stdc++.h>
#define rep(i,k,n) for(ll i= (ll) k;i< (ll) n;i++)
#define all(v) (v).begin(), (v).end()
#define SZ(v) (int)((v).size())
#define pb push_back
#define ft first
#define sd second
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const long long INF = 1e18L + 1;
const int IINF = 1e9 + 1;

using namespace std;

template<class TH> void _dbg(const char *sdbg, TH h){ cerr<<sdbg<<'='<<h<<endl; }
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',')cerr<<*sdbg++;cerr<<'='<<h<<','; _dbg(sdbg+1, a...);
}

#ifdef LOCAL
#define DBG(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define DBG(...) (__VA_ARGS__)
#define cerr if(0)cout
#endif

const int N = 1e5;

int n;
pair<int, int> segs[N + 1];

bool comp_right(int i, int j){ return segs[i].sd > segs[j].sd;}
bool comp_left(int i, int j){ return segs[i].ft < segs[j].ft;}

ll simul(priority_queue<int, vector<int>, function<bool(int, int)> > rights, 
		priority_queue<int, vector<int>, function<bool(int, int)> > lefts, bool cur){
	ll x = 0, res = 0;
	vector<bool>visited(n + 1, false);
	while(SZ(rights) or SZ(lefts)){
		auto& pq = (cur) ? lefts : rights;
		while(SZ(pq)){
			int i = pq.top(); pq.pop();
			if(!visited[i]){
				visited[i] = true;
				if(x > segs[i].sd){
					res += x - segs[i].sd;
					x = segs[i].sd;
				} else if(x < segs[i].ft){
					res += segs[i].ft - x;
					x = segs[i].ft;
				}
				break;
			}
		}
		cur ^= true;
	}
	return res + abs(x);
}

int main()
{
#ifndef LOCAL
	ios_base::sync_with_stdio(0);
    cin.tie(0);
#endif
	cin >> n;
	priority_queue<int, vector<int>, function<bool(int, int)> > rights(comp_right), lefts(comp_left);
	rep(i, 0, n){
		cin >> segs[i].ft >> segs[i].sd;
		lefts.push(i); rights.push(i);
	}
    cout << max(simul(rights, lefts, false), simul(rights, lefts, true)) << "\n";
	return 0;
}

Measured memory_bytes: 3572
import java.lang.reflect.Array;
import java.util.*;


public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        String s = sc.next();

        Character[] numbers = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9'};
        List<Character> numList = Arrays.asList(numbers);
        String ans = "Yes";
        for(int i = 0; i < s.length(); i++){
            char c = s.charAt(i);
            if(i == a){
                if(c != '-'){
                    ans = "No";
                    break;
                }
            }else if(!numList.contains(c)){
                ans = "No";
                break;
            }
        }

        System.out.println(ans);
    }
}

Measured memory_bytes: 23636
#include <bits/stdc++.h>
#define rep(i,n,m) for(int i=n;i<(int)(m);i++)
#define rrep(i,n,m) for(int i=((int)(n)-1);i>=m;i--)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
using namespace std;
int main(){
    int n;
    cin>>n;
    if(n%2==0){
        cout<<(n-2)*n/2<<endl;
        for(int i=1;i<=n;i++){
            for(int j=i+1;j<=n;j++){
                if(i+j==n+1) continue;
                cout<<i<<" "<<j<<endl;
            }
        }
    }
    else{
        cout<<((n-1)+(n-1)*(n-2))/2<<endl;
        for(int i=1;i<=n-1;i++){
            for(int j=i+1;j<=n;j++){
                if(i+j==n) continue;
                cout<<i<<" "<<j<<endl;
            }
        }
    }
}


Measured memory_bytes: 256
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

in_n = lambda: int(readline())
in_nn = lambda: map(int, readline().split())
in_s = lambda: readline().rstrip().decode('utf-8')
in_nl = lambda: list(map(int, readline().split()))
in_nl2 = lambda H: [in_nl() for _ in range(H)]
in_map = lambda: [s == ord('.') for s in readline() if s != ord('\n')]
in_map2 = lambda H: [in_map() for _ in range(H)]
in_all = lambda: map(int, read().split())


def main():

    S = in_s()
    T = in_s()

    ns = len(S)
    nt = len(T)

    ans = 10000
    for i in range(ns - nt + 1):

        cnt = 0
        for j in range(nt):
            if S[i + j] != T[j]:
                cnt += 1
        ans = min(ans, cnt)

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 67584
#include<iostream>
#include<vector>
#include<stdlib.h>
#include<time.h>
#include<math.h>
#include<string.h>
#include<algorithm>
#include<queue>
#include<map>
#include<iomanip>

using namespace std;
#define WHITE 0
#define GRAY 1
#define BLACK 2
#define RED 3
int cnt[1000];

bool isprime(int n){
 for (int i=2; i<=sqrt(n); i++){
  if(n%i==0)return false;
 }
 return true;
}

int main(void){
 int N,k;
 int ans=0;
 vector<int> A;
 int p,q,r;

 for(int i=2; i<=100; i++)if(isprime(i))A.push_back(i);
 cin>>N;

 for(int i=0; i<=100; i++)cnt[i]=0;
 
 for(int i=2; i<=N; i++){
   k=i;
   for(int j=0; j<A.size();j++){
     while(k%A[j]==0){
      cnt[A[j]]++;
      k/=A[j];
     }
   }
 }

 for(int i=0; i<A.size(); i++){
  for(int j=i+1;j<A.size();j++){
   for(int k=j+1; k<A.size();k++){
    if(cnt[A[i]]>=2 && cnt[A[j]]>=4 && cnt[A[k]]>=4)ans++;
    if(cnt[A[i]]>=4 && cnt[A[j]]>=2 && cnt[A[k]]>=4)ans++;
    if(cnt[A[i]]>=4 && cnt[A[j]]>=4 && cnt[A[k]]>=2)ans++;
   }
   if(cnt[A[i]]>=24 && cnt[A[j]]>=2)ans++;
   if(cnt[A[i]]>=2 && cnt[A[j]]>=24)ans++;
   if(cnt[A[i]]>=14 && cnt[A[j]]>=4)ans++;
   if(cnt[A[i]]>=4 && cnt[A[j]]>=14)ans++;
  }
  if(cnt[A[i]]>=74)ans++;
 }

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
#define pi acos(-1);
ll strtoint(string str);
int main(){
	fast;
	ll n; cin>>n;
	if(n%10==2||n%10==7||n%10==5||n%10==4||n%10==9)cout<<"hon\n";
	else
		if(n%10==8||n%10==6||n%10==1||n%10==0)cout<<"pon\n";
		else
			if(n%10==3)cout<<"bon\n";
	return 0;
}
ll strtoint(string str){
	ll x=0;
	stringstream ss;
	ss<<str;
	ss>>x;
	return x;
}

Measured memory_bytes: 3644
#include <iostream>
#include <stdexcept>
#include <cassert>
#include <cmath>
#include <vector>
#include <string>
using namespace std;


int main() {
  int D, T, S;
  cin >> D >> T >> S;

  if ((float) D / S <= T) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 3628
///============================================================================
/// Name        : Faisal.cpp
/// Author      : Faisal Ahmed
/// Version     :
/// Copyright   : Your copyright notice
/// Description : C++, Ansi-style
///============================================================================

#include <bits/stdc++.h>

using namespace std;

typedef long long int ll;
typedef long double ld;

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

	ll n, x, y;
	ll a = 1LL, b = 1LL;

	cin >> n;

	for(int i = 0; i < n; i++){
		cin >> x >> y;
		ll m = max((a + x - 1) / x, (b + y - 1) / y);
		a = m * x, b = m * y;
	}

	cout << a + b << endl;

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long arr[1000000];
int main()
{
	long long i;
	string a,b;
	b="";
	cin>>a;
	for (i=0;i<a.length();i++)
	{
		b=b+'x';
	}
	cout<<b<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <map>
#include <deque>
#include <string.h>
using namespace std;

#define REP(i,n) for(int i = 0; i < n; i++)
#define ALL(v) v.begin(),v.end()
typedef long long ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;
typedef pair<string,string> pss;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pi> vpi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

double EPS = 1e-9;
int INFi = 1000000005;
long long INFll = 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};
ll MOD = 1000000007;

ll A, B, C, K;

int main(){
  cin >> A >> B >> C >> K;
  if(K % 2 == 0) {
    cout << A - B << endl;
  } else {
    cout << B - A << endl;
  }

  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
int n,x,a[200002],sum;
signed main(){
  cin>>n>>x;
  for(int i=0;i<n;i++) cin>>a[i];
  sort(a,a+n);
  for(int i=0;i<n;i++){
    if(x>=a[i]){
      x-=a[i];
      sum++;
    }
  }
  if(x&&sum==n) sum--;
  cout<<sum<<endl;
}

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

using namespace std;

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

int main() {
	bool path[20][20] = {};
	int m, n;
	cin >> m >> n;
	REP(i, n) {
		int a, b;
		scanf("%d %d", &a, &b);
		a--; b--;
		path[a][b] = true;
	}
	
	
	bool s[20] = {};
	s[1] = true;
	REP(i, m - 1) {
		int ans;
		
		REP(j, m) if (!s[j]) {
			bool f = true;
			REP(k, m) if (path[k][j]) f = false;
			if (f) {
				ans = j;
				REP(k, m) path[j][k] = false;
				s[ans] = true;
				break;
			}
		}
		printf("%d\n", ans + 1);
	}
	puts("2");
	
	return 0;
}

Measured memory_bytes: 1232
#include<bits/stdc++.h>
using namespace std;
constexpr int64_t mod=1e9+7;

int main()
{
  int n;
  cin>>n;
  vector<int> a(n);
  for(auto&& e: a) 
  {
    cin>>e;
  }
  int ans=0;
  int cnt=1;
  for (int i = 0; i < n; ++i)
  {
    if(a[i]!=cnt)
    {
      ans++;
      continue;
    }
    cnt++;
  }
  if(n==ans) cout<<-1<<endl;
  else  cout<<ans<<endl;
}

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

int main() {
	string s,t,u;
	int a,b;
	cin >> s >> t >> a >> b >> u;
	if(s == u)
	{
		a--;
	}
	else
	{
		b--;
	}
	cout << a << ' ' << b <<endl;
	return 0;
}


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

class UnionFind{
public:
    //親の番号を格納する。親だった場合はー（その集合のサイズ）
    vector<int> parents;

    //作る時はparentsを-1で初期化する
    //こうすることで全部ばらばらになる
    UnionFind(int n){
        parents = vector<int>(n, -1);
    }

    //Aがどのグループにいるか調べる
    int root(int A){
        if(parents[A]<0) return A;
        return parents[A] = root(parents[A]);
    }

    //自分のいるグループの大きさを調べる
    int size(int A){
        return -parents[root(A)];
    }

    //AとBをくっつける
    bool connect(int A, int B){
        //AとBを直接ではなく親同士をくっつける
        A=root(A);
        B=root(B);
        if(A==B){
            return false;
        }

        //大きい方（A)に小さい方（B)をくっつけたい
        if(size(A)<size(B)) swap(A, B);

        parents[A] += parents[B];
        parents[B] = A;

        return true;
    }
};

int main(){
    int N, K, L; cin >> N >> K >> L;
    UnionFind road(N), rail(N);

    for(int i=0; i<K; i++){
        int p, q; cin >> p >> q;
        p--, q--;
        road.connect(p, q);
    }

    for(int i=0; i<L; i++){
        int r, s; cin >> r >> s;
        r--; s--;
        rail.connect(r, s);
    }

    map<pair<int, int>, int> mp;
    for(int i=0; i<N; i++){
        mp[make_pair(road.root(i), rail.root(i))]++;
    }

    for(int i=0; i<N; i++){
        if(i) cout << " ";
        cout << mp[make_pair(road.root(i), rail.root(i))];
    }
    cout << endl;
}

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

int main() {
    int N;
    cin >> N;
    map<ll, ll> A;
    int a;
    for(int i = 0; i < N; i++) {
        cin >> a;
        A[a]++;
    }
    int Q;
    cin >> Q;
    vector<ll> S(Q);
    ll b, c;
    ll changed = 0;
    for(int i = 0; i < Q; i++) {
        cin >> b >> c;
        if(A.count(b)) {
            A[c] += A[b];
            changed = (c - b) * A[b];
            A.erase(b);
        } else {
            changed = 0;
        }
        if(i == 0) {
            ll s = 0;
            for(pair<ll, ll> kv : A) {
                s += kv.first * kv.second;
            }
            S.at(i) = s;
        } else {
            S.at(i) = S.at(i - 1) + changed;
        }
    }

    for(int i = 0; i < Q; i++) {
        cout << S.at(i) << endl;
    }

    return 0;
}

Measured memory_bytes: 8000
s = str(input())
 
if s == "SUN":
  print("7")
elif s == "MON":
  print("6")
elif s == "TUE":
  print("5")
elif s == "WED":
  print("4")
elif s == "THU":
  print("3")
elif s == "FRI":
  print("2")
elif s == "SAT":
  print("1")

Measured memory_bytes: 2940
#include<cstdio>

class Graph{
    int n;
    int **G;
    int *seen;
    int *time_d;
    int *time_f;
    
    public: Graph(int _n){
        n = _n;
        G = new int*[n+1];
        seen = new int[n+1];
        time_d = new int[n+1];
        time_f = new int[n+1];
        for(int i = 0;i <=n;++i){
            G[i] = new int[n+1];
            time_d[i] = 0;
            time_f[i] = 0;
        }
        for(int i = 0;i <= n;++i){
            for(int j = 0;j <= n;++j){
                G[i][j] = 0;
            }
        }
    }
    
    public: void BuildMatrix(){
        int u,k,v;
        for(int i = 0;i < n;++i){
            scanf("%d %d",&u,&k);
            for(int j = 0;j < k;++j){
                scanf("%d",&v);
                G[u][v] = 1;
            }
        }
    }
    
    public: void PrintMatrix(){
        for(int i = 1;i <= n;++i){
            for(int j = 1;j <n;++j){
                printf("%d ",G[i][j]);
            }
            printf("%d\n",G[i][n]);
        }
    }
    
    public :void DoDFS(){
        int c = 0;
        for(int i = 0;i <= n;++i) seen[i] = 0;
        DFS(1,c);
        for(int i = 1;i <= n;++i){
            if(seen[i] != 1) DFS(i,c);
        }
        for(int i = 1;i <= n;++i){
            printf("%d %d %d\n",i,time_d[i],time_f[i]);
        }
    }
    
    void DFS(int s,int& cnt){
        cnt++;
        seen[s] = true;
        time_d[s] = cnt;
        for(int j = 1;j <= n;++j){
            if(G[s][j] == 1 && seen[j] == 0){
                DFS(j,cnt);
            }
        }
        cnt++;
        time_f[s] = cnt;
    }
    
};

int main(){
    int n;
    scanf("%d",&n);
    Graph G(n);
    G.BuildMatrix();
    G.DoDFS();
}




Measured memory_bytes: 2768
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;

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

    string s[3];
    cin >> s[0] >> s[1] >> s[2];

    int turn = 0;
    // 0はA, 1はB, 2はC

    while(s[turn] != ""){
        int prev = turn;
        turn = s[prev][0] - 'a';
        s[prev] = s[prev].substr(1);
    }

    cout << char(turn + 'A') << endl;

	return 0;
}

Measured memory_bytes: 256
// Package main provides
//
// File:  d.go
// Author: ymiyamoto
//
// Created on Sat Dec  8 21:19:54 2018
//
package main

import "fmt"

func mid(n int64) int64 {
	var ret int64 = 1
	for i := int64(0); i < n; i++ {
		ret = 2*ret + 1
	}
	return ret
}

func num(n int64) int64 {
	if n == 0 {
		return 1
	}

	return 2*num(n-1) + 1
}

func calc(n, x int64) int64 {
	if x == 0 {
		return 0
	}

	if n == 0 {
		return 1
	}

	m := mid(n)
	if x >= m {
		return 1 + num(n-1) + calc(n-1, x-m)
	}

	return calc(n-1, x-1)
}

func main() {
	var N, X int64
	fmt.Scan(&N, &X)

	fmt.Println(calc(N, X))
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> iint;
typedef pair<ll,ll> llll;
#define ALL(x) (x).begin(),(x).end()
const ll zero = 0;
const ll INF = 3000000000000000000; //10^18
const int inINF = 1000000000; //10^9
const ll MOD = 1000000007; //10^9+7
const ll MOD2 = 998244353;

int main(){
    int H, W;
    cin >> H >> W;
    vector<vector<int>> a(H, vector<int> (W));
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            cin >> a[i][j];
        }
    }

    vector<pair<iint,iint>> ans;

    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W-1; j++) {
            if(a[i][j] % 2 == 1){
                ans.push_back(make_pair(make_pair(i+1, j+1), make_pair(i+1, j+2)));
                a[i][j]--;
                a[i][j+1]++;
            }
        }
    }
    for (int i = 0; i < H-1; i++) {
        if(a[i][W-1] % 2 == 1){
            ans.push_back(make_pair(make_pair(i+1, W), make_pair(i+2, W)));
            a[i][W-1]--;
            a[i+1][W-1]++;
        }
    }

    int M;
    M = ans.size();
    printf("%d\n", M);

    for (int i = 0; i < M; i++) {
        printf("%d %d %d %d\n", ans[i].first.first, ans[i].first.second, ans[i].second.first, ans[i].second.second);
    }

}

Measured memory_bytes: 6312
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
  private static class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;

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

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

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

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

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

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

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

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

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

  public static void main(String[] args) {
    FastScanner sc = new FastScanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    if ((a + b) % 2 != 0) System.out.println("IMPOSSIBLE");
    else System.out.println((a + b) / 2);
  }
}

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

int main(int argc, char *argv[]){
  int num;
  cin >> num;
  long long int p, n;
  char c;
  long long int count = 0;
  for (int i = 0; i < num; i++) {
    cin >> p >> c >> n;
    if(c == '('){
      count += n;
    }else{
      count -= n;
    }
    if(count == 0){
      std::cout << "Yes" << std::endl;
    }else{
      std::cout << "No" << std::endl;      
    }
  }
  return 0;
}

Measured memory_bytes: 1164
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#define TEST cout << "test" << endl;
using namespace std;

int main(void){
	int n,d;
	cin >> n >> d;
	int answer = n / (d * 2 + 1);
	if(n % (d * 2 + 1) != 0)answer++;
	cout << answer << endl;
	return 0;
}

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

using namespace std;

int main() {
	int n;
	while (cin >> n) {
		if (n == 0) {
			break;
		}
		priority_queue<int> pq;
		for (int i = 1; i < n; i++) {
			pq.push((i*i)%n);
		}
		int counter = 0;
		vector<int> hyou;
		while (!pq.empty()) {
			hyou.push_back(pq.top());
			pq.pop();
			counter++;
			while (!pq.empty()) {
				if (pq.top() == hyou[counter-1]) {
					pq.pop();
				} else {
					break;
				}
			}
		}
		vector<int> data(n+1, 0);
		int a;
		for (int i = 0; i < counter; i++) {
			for (int j = 0; j < counter; j++) {
				if (i == j) {
				} else {
					a = hyou[i]-hyou[j];
					if (a < 0) {
						a += n;
					}
					if (a > (n-1)/2) {
						a = n - a;
					}
					data[a]++;
				}
			}
		}
		for (int i = 1; i <= (n-1)/2; i++) {
			cout << data[i] << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1352
#include <stdio.h>

int main()
{
    int a, b;
    scanf("%d %d", &a, &b);
    if((a+b>a-b)&&(a+b>a*b)){
        printf("%d\n",a+b);
    }else if ((a-b>a+b)&&(a-b>a*b))
    {
        printf("%d\n",a-b);
    }else if ((a*b>a+b)&&(a*b>a-b))
    {
        printf("%d\n",a*b);
    }else if(a==0){
        printf("%d\n",b);
    }else if(b==0){
        printf("%d\n",a);
    }
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
long long x,i,n;
int main(){
	ios::sync_with_stdio(false);
	cin>>n;x=1;
	for(i=2;i<=n;++i){
		x=x*i;
		x=x%1000000007;
	}
	cout<<x<<endl;
	return 0;
}

Measured memory_bytes: 256
n=gets.to_i
arr=[0,0,0,0,0]
n.times{
    aa=gets.chomp.split("")[0]
    
    if aa=="M"
     arr[0]+=1
    end
    
    if aa=="A"
     arr[1]+=1
    end
    
    if aa=="R"
     arr[2]+=1
    end
    
    if aa=="C"
     arr[3]+=1
    end
    
    if aa=="H"
     arr[4]+=1
    end
    
    
    
}


cc=arr.count(0)


if cc>=3 
    puts 0
    exit
end



if cc==1
    arr.delete(0)
    a=arr[0]
b=arr[1]
c=arr[2]
d=arr[3]

 puts a*b*c+a*b*d+a*c*d+b*c*d
 exit
 end
 
 if cc==2
     arr.delete(0)
 a=arr[0]
b=arr[1]
c=arr[2]
puts a*b*c
exit
end


if cc==0
    a=arr[0]
b=arr[1]
c=arr[2]
d=arr[3]
e=arr[4]
    
 puts a*b*c+a*b*d+a*b*e+a*c*d+a*c*e+a*d*e+b*c*d+b*c*e+c*d*e+b*d*e

end

Measured memory_bytes: 2044
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <typeinfo>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

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

    switch (n % 10)
    {
    case 2:
    case 4:
    case 5:
    case 7:
    case 9:
        s = "hon";
        break;
    case 0:
    case 1:
    case 6:
    case 8:
        s = "pon";
        break;
    case 3:
        s = "bon";
        break;
    }

    cout << s << endl;
}

Measured memory_bytes: 3624
// inputに入力データ全体が入る
function Main(input) {
	// 1行目がinput[0], 2行目がinput[1], …に入る
	input = input.split("\n");
	const w = parseInt(input[0].split(" ")[0], 10);
	const h = parseInt(input[0].split(" ")[1], 10);
	const x = parseInt(input[0].split(" ")[2], 10);
	const y = parseInt(input[0].split(" ")[3], 10);
	// 処理
  	let flg = 0;
  	if(x === w/2 && y === h/2) flg =1;
  	console.log(`${w*h/2} ${flg}`);
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7628
#include<stdio.h>

int main(void)
{
  int i, n, max = -1000000, min = 1000000;
  long sum = 0;

  scanf("%d", &n);

  int a;

  for(i = 0; i < n; i++) {
    scanf("%d", &a);
    sum += a;
    if(max <= a) {
      max = a;
    }
    if(min >= a) {
      min = a;
    }
  }

  printf("%d %d %ld\n", min, max, sum);

  return 0;
}

Measured memory_bytes: 600
unittest
{
//	assert( [ "3 3 1 1" ].parse.expand.solve == "100\n010\n001" );
	assert( [ "3 3 1 1" ].parse.expand.solve == "011\n100\n100" );
//	assert( [ "1 5 2 0" ].parse.expand.solve == "01010" );
	assert( [ "1 5 2 0" ].parse.expand.solve == "11000" );
	
	assert( [ "4 3 1 2" ].parse.expand.solve == "011\n011\n100\n100" );					// 追加ケース
	assert( [ "4 4 1 2" ].parse.expand.solve == "0111\n0111\n1000\n1000" );				// 追加ケース
	assert( [ "5 4 1 1" ].parse.expand.solve == "0111\n1000\n1000\n1000\n1000" );		// 追加ケース
}

import std.conv;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto hwab = input.front.split.to!( long[] );
	return tuple( hwab[ 0 ], hwab[ 1 ], hwab[ 2 ], hwab[ 3 ] );
}

auto solve( long h, long w, long a, long b )
{
	const CS = [ '0', '1' ];
	auto mss = new char[][]( h, w );
	foreach( y, ref ms; mss )
	{
		foreach( x, ref m; ms )
		{
			m = CS[ ( y < b ) ^ ( x < a ) ];
		}
	}
	return mss.join( "\n" );
}


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




int main()
{
    int N,K;
    cin >> N >> K;
    if (N%K == 0) {
        cout << 0 << endl;
    }else{
        cout << 1 << endl;
        
    }
    
    return 0;
}



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

typedef long long int ll;

ll dp[105][55][55];
ll n,k;
ll arr[105+1];

ll solve(ll i,ll st,ll en)
{
    if(i>k)return INT_MIN;
    //cout<<i<<" "<<st<<" "<<en<<endl;
    if(i==k || st>en)
    {
        return 0;
    }

    if(dp[i][st][en]==-1)
    {

        ll c = 0;
        ll d = 0;
        ll v1 = 0;
        ll v2 = 0;
        if(arr[st]<0){
            c+=1;
        }
        if(arr[en]<0){
            d+=1;
        }
        if(arr[st]>=0){
            v1 = arr[st];
        }
        if(arr[en]>=0){
            v2 = arr[en];
        }

        dp[i][st][en] = max(v1+solve(i+1+c,st+1,en), v2+solve(i+1+d,st,en-1));

        dp[i][st][en] = max(dp[i][st][en],max(arr[st]+solve(i+1,st+1,en), arr[en]+solve(i+1,st,en-1)));
        dp[i][st][en] = max(0LL,dp[i][st][en]);
    }
    return dp[i][st][en];

}

int main()
{
    memset(dp,-1,sizeof(dp));

    cin>>n>>k;


    ll s = 0;
    for(ll i=0;i<n;i++){
        cin>>arr[i];
    }



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





}


Measured memory_bytes: 2688
x, y, z, k = map(int, input().split())
A = sorted(list(map(int, input().split())), reverse=True)
B = sorted(list(map(int, input().split())), reverse=True)
C = sorted(list(map(int, input().split())), reverse=True)

ABC = []
for i in range(x):
    for j in range(y):
        if (i + 1) * (j + 1)  <= k:
            for h in range(z):
                if (i + 1) * (j + 1) * (h + 1) <= k:
                    ABC.append(A[i] + B[j] + C[h])
                else:
                    break    
        else:
            break


ABC.sort(reverse=True)

for i in range(k):
    print(ABC[i])


Measured memory_bytes: 8732
N = int(input())
a = list(map(int,input().split()))
def count_2(num):
    cnt = 0
    while(num>0 and num%2 == 0):
        cnt += 1
        num /= 2
    return cnt
ans = 0
for n in a:
    ans += count_2(n)
print(ans)

Measured memory_bytes: 4148
#include<cstdio>
#include<cstring>
#include<algorithm>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const double PI = acos(-1.0);
const double eps = 1e-6;
const int INF = 0x3f3f3f3f;

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

const int MAXN = 500 + 10;
int a[MAXN][MAXN];
int b[MAXN][MAXN];
int ans[MAXN][MAXN];

void init() {
	memset(a, 0, sizeof(a));
	memset(b, 0, sizeof(b));
	memset(ans, 0, sizeof(ans));
}
int main() {
	int n, m, q;
	scanf("%d %d %d", &n, &m, &q);
	init();
	for (int i = 0; i < m; i++) {
		int l, r;
		scanf("%d %d", &l, &r);
		a[l][r]++;
	}

	for (int j = 1; j <= n; j++) {
		b[j][j] = a[j][j];
		for (int i = j - 1; i >= 1; i--) {
			b[i][j] = b[i + 1][j] + a[i][j];
		}
	}

	for (int i = 1; i <= n; i++) {
		ans[i][i] = a[i][i];
		for (int j = i + 1; j <= n; j++) {
			ans[i][j] = ans[i][j - 1] + b[i][j];
		}
	}
	while (q--) {
		int li, ri;
		scanf("%d %d", &li, &ri);
		printf("%d\n", ans[li][ri]);
	}
	return 0;
}


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

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<pair<int, int>, int> PP;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;

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

int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int main(void) {
    int N, Q;
    string S;
    cin >> N >> Q >> S;
    vector<int> cnt(N + 1);
    for (int i = 1; i <= N; i++) {
        cnt[i] = cnt[i - 1];
        if (S[i - 1] == 'A' && S[i] == 'C') cnt[i]++;
    }
    for(int i = 0; i < Q; i++) {
        int l, r;
        cin >> l >> r;
        cout << cnt[r - 1] - cnt[l - 1] << endl;
    }
}


Measured memory_bytes: 1408
d, g = map(int, input().split())
g //= 100
problems = []
for i in range(d):
    p, c = map(int, input().split())
    problems.append((i + 1, p, c // 100))

min_c = float('inf')
for i in range(2**d):
    cnt = 0
    score = 0
    for j in range(d):
        if 1 << j & i:
            cnt += problems[j][1]
            score += problems[j][0] * problems[j][1] + problems[j][2]
    if score >= g:
        min_c = min(min_c, cnt)
    for j in range(d):
        if not (1 << j & i):
            need = max(0, (g - score + problems[j][0] - 1) // problems[j][0])
            if problems[j][1] >= need:
                min_c = min(min_c, cnt + need)
print(min_c)


Measured memory_bytes: 3064
def gcd(a,b):
    r=a%b
    while r!=0:
        a=b
        b=r
        r=a%b
    return b

def lcm(a,b):
    return  a*b//gcd(a,b)
    
n=int(input())
t=[int(input()) for i in range(n)]

anser=1
for i in t:
    anser=lcm(anser,i)
print(anser)

Measured memory_bytes: 38384
k, a, b = list(map(int, input().split()))

if a > k-2 +1:
    ans = k +1
elif b-a <= 2:
    ans = k + 1
else:
    if (k-a+1)%2 ==0:
        k2 = (k-a+1)//2
        ans = k2*(b-a) + a
    else:
        k2 = (k-a+1)//2
        ans = k2*(b-a) +a +1
print(ans)


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

using namespace std;
 
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl;
#define DEBUG_MAT(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}
typedef long long ll;
#define int ll
 
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(int)(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const long double pi = 3.1415926535897932384626433832795028841971L;
#define Sp(p) cout<<setprecision(25)<< fixed<<p<<endl;
// int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
// int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
// vi dx = {1, 0, -1, 0}, dy = {0, 1, 0, -1};
// vi dx2 = { 1,1,0,-1,-1,-1,0,1 }, dy2 = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
// const ll MOD = 1000000007;
const ll MOD = 998244353;
// #define mp make_pair
//#define endl '\n'


signed main() {
    fio();
    int a;
    cin >> a;
    cout << a + a * a + a * a * a << endl;
}

Measured memory_bytes: 3652
#include <stdio.h>

int main(void) {
	long long h, w, num=0;
	scanf("%lld %lld", &h, &w);
	if(h==1 or w==1){
		printf("1");
		return 0;
	}
	
	if(h%2==0)
		printf("%lld", h*w/2);
	else
		printf("%lld", (h-1)*w/2+(w+1)/2);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,a,n) for(int i=a;i<n;i++)
#define repb(i,a,b) for(int i=a;i>=b;i--)
#define all(a) a.begin(),a.end()
#define o(a) cout<<a<<endl
#define int long long
#define fi first
#define se second
using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

int num[10];
int dp[11][331];
int fact[11];

signed main(){
	rep(i,0,10) num[i]=i;
	do{
		int t=0;
		rep(i,0,10){
			t+=num[i]*(i+1);
			dp[i+1][t]++;
		}
	}while(next_permutation(num,num+10));

	fact[0]=1;
	rep(i,1,10) fact[i]=fact[i-1]*i;

	int n,s;
	while(cin>>n>>s){
		if(s>331||n>10){
			o(0); continue;
		}
		o(dp[n][s]/fact[10-n]);
	}
}

Measured memory_bytes: 1188
#include <stdio.h>

int N;
int A[1000000]={0};

int main(){
  scanf("%d",&N);
  int x;
  for(int i=0;i<N-1;i++){
    scanf("%d",&x);
    A[x-1]+=1;
  }

  for(int i=0;i<N;i++)
    printf("%d\n",A[i]);
}

Measured memory_bytes: 2512
n = int(input())
b = list(map(int,input().split()))
a = []
for i in b:
    if i == 1:
        a.insert(0,1)
    else:
        if len(a)+1 < i:
            print(-1)
            exit()
        a.insert(i-1,i)
    
for i in a:
    print(i)

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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<int> A(N);
    for (int i = 0; i < N; ++i) cin >> A[i];
    for (int i = N - 1; i > 0; i--) {
        if (A[i] < A[i - 1]) {
            A[i - 1]--;
        }
        if (A[i] < A[i - 1]) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 640
n,x=map(int,input().split())
a=sorted(list(map(int,input().split())))
count=0
for i in range(n):
    if i==n-1:
        if x==a[i]:
            count+=1
        break
    if x<a[i]:
        break
    x-=a[i]
    count+=1
print(count)

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

int main() {
	string s, t; cin >> s >> t;
	int ans;
	for (int i = 0; i < s.size(); i++) {
		if (s[i] == t[i])ans++;
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef vector<int> vi;
typedef pair<int,int> ii;
#define inf 1e9
#define F first
#define S second
#define dbg(x) cout<<#x<<" value : "<<x<<"\n";
#define rep(i,j,k) for(int i = (j); i <= (k); i++)
#define rep__(i,j,k) for(int i = (j); i < (k); i++)
#define per(i,j,k) for(int i = (j); i >= (k); i--)
#define per__(i,j,k) for(int i = (j); i > (k); i--)
#define mst(a,b) memset(a,b,sizeof(a))
#define sf(n) scanf("%d",&n)
#define stf(n,m) scanf("%d%d",&n,&m)
#define pf(n) printf("%d\n",n)
#define slf(n) scanf("%lld",&n)
#define plf(n) printf("%lld\n",n)
priority_queue<int,vector<int>,less<int> > q;
const int N=2e5+10;
const int mod=1e9+7;
LL n;
inline LL mn(LL c,LL d){return c>d?d:c;}
bool isprime(LL x){
	if(x<=1)return 0;
	if(x==2||x==3)return 1;
	else if(x%6!=1&&x%6!=5)return 0;
	for(LL i=5;i<=sqrt(x);i+=6){
		if(x%i==0||x%(i+2)==0)return 0;
	}
	return 1;
}
int main()
{
	LL h;
	cin>>n;
	if(isprime(n))cout<<n-1<<endl;
	else {
		for(LL i=LL(sqrt(n)+1);i>=2;i--){
			if(n%i==0){
				h=n/i+i;
				break;
			}
		}
		cout<<h-2<<endl;
	}
	return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
s = input()
ans = 0
for i in range(2**(len(s)-1)):
	k = i
	current_index = 0
	cnt_div = 0 # 2で割った回数 つまり+が計算されるのは何桁か
	while True:
		cnt_div += 1
		if k % 2: 
			ans += int(s[current_index:current_index+cnt_div])
			current_index = current_index+cnt_div
			cnt_div = 0 #もっと効率化できる？
		k = k //2
		if k == 0:
			ans += int(s[current_index:]) 
			break
print(ans)
		

Measured memory_bytes: 2940
'use strict'
function Main(input) {

  let tmp = input.split('\n');
  let Num = parseInt(tmp[0]);
  let Vle = tmp[1].split(' ').map(Number);
  let Cst = tmp[2].split(' ').map(Number);

  let maxVle = 0;
  for (let i = 0; i < Num; i++) {
    if (Vle[i] - Cst[i] > 0) {
      maxVle += Vle[i] - Cst[i];
    }
  }
  console.log(maxVle);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
#[allow(unused_macros)]
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)*}
    };
}
 
#[allow(unused_macros)]
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)*}
    };
}
 
#[allow(unused_macros)]
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, 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")
    };
}
 


fn main() {
    input!{
        _n: u64,
        m: u64,
        mut array: [[u64; 2]; m]
    }

    let mut x = 0;
    let mut count = 0;
    array.sort_by_key(|a| a[1]);
/*
    for a in array.iter() {
        println!("{:?}", a);
    }
*/
    for a in array.iter() {
        if x < a[0] {
            count = count + 1;
            x = a[1]-1;
        }
    }

    println!("{}", count);
    
}


Measured memory_bytes: 10492