akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define sz(a) int((a).size())
#define pb push_back
#define all(c) c.begin(),c.end()
#define tr(c,i) for(i = c.begin(); i != c.end(); i++)
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define forstl(i,v) for(auto &i: v)
#define forn(i,e) for(int i = 0; i < e;++i)
#define forsn(i,s,e) for(int i = s; i < e;++i)
#define rforn(i,s) for(int i = s; i >= 0;--i)
#define rforsn(i,s,e) for(int i = s; i >= e;--i)
# define INF 0x3f3f3f3f 
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll,ll> p64;
typedef pair<int,int> p32;
typedef pair<int,p32> p96;
typedef vector<ll> v64;
typedef vector<int> v32; 
typedef vector<v32> vv32;
typedef vector<v64> vv64;
typedef vector<p32> vp32;
typedef vector<p64> vp64;
typedef vector<vp32> vvp32;
typedef map<int,int> m32;
const int LIM=1e5+5,MOD=1e9+7;

int main()
{
    ll i,j,k,m,n,wt;
    cin>>n>>wt;
    ll w[n],v[n];
    forn(i,n)
        cin>>w[i]>>v[i];
    ll dp[n+5][wt+5];
    for(i=0;i<n;i++)
    {
        for(j=0;j<=wt;j++)
        {
            dp[i][j]=0;
        }
    }
    for(i=0;i<n;i++)
    {
        for(j=1;j<=wt;j++)
        {
            if(i>0 && j>=w[i])
            {
                dp[i][j]=max(dp[i-1][j],v[i]+dp[i-1][j-w[i]]);
            }
            else if(i>0)
            {
                dp[i][j]=dp[i-1][j];
            }
            else if(i==0)
            {
                if(j>=w[i])
                    dp[i][j]=v[i];
                else
                    dp[i][j]=0;
            }
        }
    }
    cout<<dp[n-1][wt]<<"\n";
}

Measured memory_bytes: 81760
/*map,set,priority_queue,stack,queue*/
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define el "\n"
#define pb emplace_back
#define F first
#define S second
#define fo(i,n) for(int i=0;i<n;++i)
#define all(v) v.begin(),v.end()
#define fastio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); 
typedef vector<int> vi;
const int mod = (int)1e9 + 7;
//const int N = 500007;
/*int arr[N];
vector<int> adj[N];

void dfs(int x,int par)
{
    arr[x]+=par;
    arr[par] = 0;
    for(auto child:adj[x])
    {
        if(child==par)
            continue;
        dfs(child,x);
    }
}
*/
const int  N = 1e6+1;
vector<int> sieve(N+7,1);
void fun()
{
    sieve[0] =0;
    sieve[1] = 0;
    for(int i=2;i*i<=N;++i)
    {
        if(sieve[i])
        {
            for(int j=i*i;j<=N;j+=i)
            {
                sieve[j] = 0;
            }
        }
    }
}
int modExpo(int x,int y){
  int res = 1;
  while(y > 0){
    if(y&1)
      res = (res*x)%mod;
    y = y>>1;
    x = (x*x)%mod;
  }
  return res;
}
int32_t main() 
{
    fastio
    int n;
    cin>>n;
    if(n<=2)
    {
        cout<<0;
        return 0;
    }
    int ans = n/2;
    if(n%2==0)
        ans--;
    cout<<ans;
    return 0;
}



Measured memory_bytes: 8064
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INF INT_MAX // 2147483647
#define INFLL LLONG_MAX // 9223372036854775807
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define per(i, n) for(ll i=((ll)(n))-1; i>=0; i--)
#define perf(i, n) for(ll i=((ll)(n)); i>0; i--)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
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(){
    Init();
    ll a, b; cin >> a >> b;
    cout << ((a+b >= 24) ? a+b-24 : a+b) << endl;
}

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

std::string convert(long long x) {
  if (x == 0)
    return "0";

  std::string res = "";
  while (x != 0) {
    int r = x % (-2);
    x /= -2;

    if (r < 0) {
      r += -(-2);
      x += 1;
    }

    res = std::to_string(r) + res;
  }
  return res;
}

int main() {
  long long x;  std::cin>>x;

  std::cout<<convert(x)<<"\n";

  return 0;
}


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

typedef long long int ll;
ll n, a[200007];
map<ll, ll> occ;

int main() {
    cin >> n;
    for(ll i = 0; i < n; ++i) {
        cin >> a[i];
        occ[a[i]]++;
    }

    ll total = 0;
    for(ll i = 1; i <= n; ++i) {
        total += (occ[i] * (occ[i] - 1))/2;
    }

    for(ll i = 0; i < n; ++i) {
        cout << total - occ[a[i]] + 1 << endl;
    }

    return 0;
}

Measured memory_bytes: 17628
while True:
    n = int(input())
    if n==0: break
    count = 0
    while True:
        if n==1:
            print(count)
            break
        elif n % 2 ==0:
            n /= 2
            count +=1
        else:
            n*=3
            n+=1
            count += 1


Measured memory_bytes: 5596
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int N, K; cin >> N >> K;
    vector<int> A(N); for (int& a : A) cin >> a;
    vector<int> W(K + 1);
    for (int x = 1; x <= K; x++) {
        for (int a : A) {
            if (x - a >= 0 && !W[x - a]) {
                W[x] = true;
                break;
            }
        }
    }
    cout << (W[K] ? "First" : "Second") << endl;
    return 0;
}

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

int gcm(int a, int b) {
    int c;
    while (true) {
        c = a % b;
        if (c == 0) break;
        a = b;
        b = c;
    }
    return b;
}
int main(void) {
    int a, b; cin >> a >> b;
    int n = gcm(a, b);
    int k, count = 0; cin >> k;
    for (int i = n; i > 0; i--) {
        if (n % i == 0) count++;
        if (count == k) {
            cout << i << endl;
            break;
        }
    }
}

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

#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define ALL(x) x.begin(),x.end()
#define EPS (1e-8)
#define equals(a,b) (fabs((a)-(b))<EPS)

using namespace std;

typedef long long ll;
bool LTE(double a,double b) { return equals(a,b) || a < b; }
bool LT(double a,double b) { return !equals(a,b) && a < b; }

void compute() {

}

int main() {
  int A,B;
  cin >> A >> B;
  int cnt = 0;
  REP(i,A,B+1) {
    string s = to_string(i);
    string t = string(s.rbegin(),s.rend());
    if( s == t ) ++cnt;
  }
  cout << cnt << endl;
  compute();
  return 0;
}


Measured memory_bytes: 256
from math import factorial as f

N, M = map(int, input().split())
if abs(N - M) > 1:
    ans = 0
else:
    if N == M:
        ans = 2 * f(N) * f(M)
    else:
        ans = f(N) * f(M)
print(ans % (int(10**9 + 7 )))

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

typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pl;

const int INT_INF = 2147483646;
const ll LL_INF = 9223372036854775807;
const double PI=3.1415926535897932;

bool SecondCompare(const pair<int,int> &a,const pair<int,int> &b)
{
       return a.second<b.second;
}
 
bool SecondCompareDes(const pair<int,int> &a,const pair<int,int> &b)
{
       return a.second>b.second;
}

ll minll(ll a, ll b){
    if(a >= b)  return b;
    else    return a;
}

ll maxll(ll a, ll b){
    if(a >= b)  return a;
    else    return b;
}

ll a,b,c;

int main(){
    cin >> a >> b >> c;
    ll ans = min(b/a,c);
    cout << ans << endl;
}

Measured memory_bytes: 256
//02
#include<iostream>
#include<string>
#include<cstdio>

using namespace std;

typedef  int ia[1000];

ia lx,ty,rx,by,d,c;
string tn[1000];
int p;
char s[1001];
char *sp;

int exp(int dp){
  if(*sp!='<'||sp[1]=='/')return 0;
  char t[1000];
  int cp=p;
  p++;
  d[cp]=dp;
  sscanf(sp,"<%[^>]>%d,%d,%d,%d",t,lx+cp,ty+cp,rx+cp,by+cp);
  sp++;
  while(*sp!='<'){
    sp++;
  }
  tn[cp]=t;
  int nc;
  for(nc=0;exp(dp+1);nc++);
  c[cp]=nc;
  int nr;
  sscanf(sp,"</%*[^>]>%n",&nr);
  sp+=nr;
  return 1;
}

  

int main(){
  for(int n;cin>>n,n;){
    cin.ignore().getline(s,1001);
    lx[0]=ty[0]=-1;
    rx[0]=by[0]=10001;
    d[0]=0;
    c[0]=1;
    tn[0]="OUT OF MAIN PANEL";
    p=1;
    sp=s;
    exp(1);
    while(n--){
      int md=-1;
      int id;
      int x,y;
      cin>>x>>y;
      for(int i=0;i<p;i++){
	if(lx[i]<=x&&x<=rx[i]&&ty[i]<=y&&y<=by[i]&&md<d[i]){
	  md=d[i];
	  id=i;
	}
      }
      cout<<tn[id]<<' '<<c[id]<<endl;
    }
  }
  return 0;
}

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

using namespace std;

#define int long long

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

#ifdef DBG
#define log(item) cout << #item << " " << item << endl
#define loga(array, val) cout << #array << #val << " " << array[val] << endl
#else
#define log(item)
#define loga(array, val)
#endif

typedef vector<int> VI;
typedef pair<int, int> PII;

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

int N, M;

signed main(){
    cin >> N >> M;

    int l = 0;
    int r = 10000000;
    REP(i, M){
        int a,b;
        cin >> a >> b;
        l = max(l, a);
        r = min(r, b);
    }

    if(l > r){
        cout << 0 << endl;
    }else{
        cout << r - l + 1 << endl;
    }
    return 0;
}


Measured memory_bytes: 256
s=input()
n=len(s)
ans1=0
ans2=0
for i in range(0,n,2):
        if s[i]=="0":
                ans1+=1
        else:
                ans2+=1
for i in range(1,n,2):
        if s[i]=="0":
                ans2+=1
        else:
                ans1+=1
print(min(ans1,ans2))
        
  

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

void solve()
{
	int n;
	cin>>n;
	if(n>=30)
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;
}

int main()
{
	ll t =1 ;
	// cin>>t;
	while(t--)
	{
		solve();
	}
}

Measured memory_bytes: 3620
#include <iostream>

using namespace std;
#define int long long
#define All(v) (v).begin(),(v).end()
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    if(a!=c){
        cout << 1 << endl;
    }else{
        cout << 0 << endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define len(val) static_cast<long long>(val.size())
#define rep(i, n) for(int i=0; i<(n); i++)
typedef long long ll;
typedef pair<int, int> P;


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

    int N;
    cin >> N;
    int L[N];
    rep(i, N) cin >> L[i];
    sort(L, L+N);
    int s = 0;
    for(int i=0; i<N-1; i++){
        s+=L[i];
    }
    if(L[N-1] < s){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
"use strict";
var input=require("fs").readFileSync("/dev/stdin","utf8");
var cin=input.split(/ |\n/),cid=0;
function next(){return +cin[cid++];}
function nextstr(){return cin[cid++];}
function nextbig(){return BigInt(cin[cid++]);}
function nexts(n,a){return a?cin.slice(cid,cid+=n):cin.slice(cid,cid+=n).map(a=>+a);}
function nextm(h,w,a){var r=[],i=0;if(a)for(;i<h;i++)r.push(cin.slice(cid,cid+=w));else for(;i<h;i++)r.push(cin.slice(cid,cid+=w).map(a=>+a));return r;}
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill().map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill().map(x=>"+r+")";return eval(r);}
var mod = 1e9+7;
function mul(){for(var a=arguments,r=a[0],i=a.length;--i;)r=((r>>16)*a[i]%mod*65536+(r&65535)*a[i])%mod;return r;}
var fac=[],finv=[],invs=[],pow2=[];
function fset(n){
  fac.length=n+1,fac[0]=fac[1]=1;
  for(var i=2;i<=n;)fac[i]=mul(fac[i-1],i++);
  finv.length=n+1,finv[0]=finv[1]=1,finv[n]=inv(fac[n]);
  for(i=n;2<i;)finv[i-1]=mul(finv[i],i--);
  //invs.length=n+1,invs[0]=invs[1]=1;
  //for(i=2;i<=n;)invs[i]=mul(fac[i-1],finv[i++]);
  //pow2.length=n+1,pow2[0]=1;
  //for(i=1;i<=n;i++)pow2[i]=pow2[i-1]*2%mod;
}
function inv(b){for(var a=mod,u=0,v=1,t;b;v=t)t=a/b|0,a-=t*b,u-=t*v,t=a,a=b,b=t,t=u,u=v;u%=mod;return u<0?u+mod:u;}
function pow(a,n){for(var r=1;n;a=mul(a,a),n>>=1)if(n&1)r=mul(a,r);return r;}
function ncr(n,r){return mul(fac[n],finv[r],finv[n-r]);}
function npr(n,r){return mul(fac[n],finv[n-r]);}
function mput(n){return (n%mod+mod)%mod;}

var myOut = main();
if(myOut !== undefined)console.log(String(myOut));

function main(){
  var n = next(), a = next(), b = next(), c = next(), d = next();
  var dp = xArray(0,n+1);
  var dp2 = Array(n+1);
  dp[0] = 1;
  fset(n);
  for(var i = a; i <= b; i++){
    for(var j = 0; j <= n; j++)dp2[j] = dp[j];
    for(var j = c; j <= d; j++){
      var m = j * i;
      if(m > n)break;
      var p = mul(pow(finv[i],j),finv[j]);
      for(var k = n-m; k >= 0; k--){
        if(dp[k] === 0)continue;
        dp2[k+m] += mul(dp[k],npr(n-k,m),p);
        dp2[k+m] %= mod;
      }
    }
    var t = dp;
    dp = dp2;
    dp2 = t;
  }
  return dp[n];
}

Measured memory_bytes: 20680
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <queue>
#include <stack>

using namespace std;

typedef int itn;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef map<int, int> M;
typedef pair<int, int> P;
typedef stack<int> S;
typedef queue<int> Q;

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    for (int i = 0; i < (int)s.size(); ++i)
    {
        if (s[i] == '1') cout << '9';
        else if (s[i] == '9') cout << '1';
    }
    cout << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
using namespace std;
int n;
string s;
string o;

int solve(int i,int j,int m){
  if(i == (int)s.size()) return 1;
  if(j >= (int)o.size() || s[i] != o[j]) return 0;
  return solve(i+1,j+m,m);
}

int main(void){
  cin >> n >> s;
  int res = 0;
  for(int i = 0; i < n; i++){
    cin >> o;
    bool f = false;
    for(int j = 0; j < (int)o.size(); j++){
      if(o[j] == s[0]){
	for(int k = j+1; k < (int)o.size(); k++){
	  if(o[k] == s[1] && solve(1,k,k-j)){
	    res++;
	    //cout << i << endl;
	    f = true;
	    break;
	  }
	}
      }
      if(f) break;
    }
  }
  cout << res << endl;
}

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

int main()
{
    ll A, B;
    cin >> A >> B;
    ll s = abs(A + B);
    if (s % 2 == 0)
        cout << s / 2 << endl;
    else
        cout << "IMPOSSIBLE" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>

using namespace std;

int main() {
  int N;
  cin >> N;
  long long int a[N];
  for(int i = 0; i < N; i++) {
    cin >> a[i];
  }
  bool ok = true;
  long long int ans = 1;
  if(N % 2 == 0) {
    int cou[N];
    for(int i = 0; i < N; i++) {
      cou[i] = 0;
    }
    for(int i = 0; i < N; i++) {
      if(a[i] % 2 == 0) ok = false;
      cou[a[i]]++;
    }
    for(int i = 0; i < N; i++) {
      if(cou[i] != 2 && cou[i] != 0) ok = false;
    }
    for(int i = 0; i < N/2; i++) {
      ans = (ans * 2) % 1000000007;
    }
    if(!ok) ans = 0;
  } else {
    int cou[N];
    for(int i = 0; i < N; i++) {
      cou[i] = 0;
    }
    for(int i = 0; i < N; i++) {
      if(a[i] % 2 == 1) ok = false;
      cou[a[i]]++;
    }
    for(int i = 1; i < N; i++) {
      if(cou[i] != 2 && cou[i] != 0) ok = false;
    }
    if(cou[0] != 1) ok = false;
    for(int i = 0; i < N/2; i++) {
      ans = (ans * 2) % 1000000007;
    }
    if(!ok) ans = 0;
  }
  cout << ans << endl;

}


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

int main() {
  /* Aから順番に引いていく。 */
  long long int A = 0, B = 0, C = 0, K = 0;
  long long int sum = 0;
  cin >> A >> B >> C >> K;
  
  /* 4 3 6 10 のとき、
     まず 4を引けるだけ引くので、残りは 10 - 4 = 6
     次に 3を引けるだけ引くので、残りは 6 - 3 = 3
     ここで、3 < 6だから、残りは 3 - (6 - 3) = 0
  */
  if (K > A) {
    K -= A;
    sum += A;
  } else {
    /* 残り引ける枚数より実際の残り枚数が多い場合、残り引ける枚数は0になる */
    sum += K;
    K = 0;
  }
  
  if (K > B) {
    K -= B;
  } else {
    K = 0;
  }
  
  if (K > C) {
    K -= C;
    sum += C * -1;
  } else {
    sum += K * -1;
    K = 0;
  }
  
  cout << sum << endl;
  return 0;
}

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

typedef long long ll;

const ll MOD = 998244353;

const int ARR_SIZE = 2e5+5;

int N = 0;

struct Node {
    int lazy;
    ll val, coeff;
};

Node arr[ARR_SIZE<<2];

ll coefficients[ARR_SIZE];

void FillCoeff() {
    coefficients[N] = 1;
    for (int i = N-1; i > 0; --i) {
        coefficients[i] = coefficients[i+1] * 10 % MOD;
    }
    coefficients[0] = 0;

    // presum
    for (int i = 1; i <= N; ++i) {
        coefficients[i] = coefficients[i]+coefficients[i-1] % MOD;
    }
}



void Pushup(int root) {
    arr[root].val = (arr[root<<1].val + arr[root<<1|1].val) % MOD;
}

void Pushdown(int root) {
    if (arr[root].lazy) {
        // pushdown lazy
        arr[root<<1].lazy = arr[root].lazy;
        arr[root<<1|1].lazy = arr[root].lazy;

        // update
        arr[root<<1].val = arr[root].lazy * arr[root<<1].coeff % MOD;
        arr[root<<1|1].val = arr[root].lazy * arr[root<<1|1].coeff % MOD;

        // clear lazy
        arr[root].lazy = 0;
    }
}

void Build(int root, int rl, int rr) {
    // return point
    if (rl == rr) {
        arr[root].lazy = 1;
        arr[root].coeff = (coefficients[rr] + MOD - coefficients[rl-1]) % MOD;
        arr[root].val = arr[root].lazy * arr[root].coeff % MOD;
        return;
    }

    // split
    int mid = (rl+rr)>>1;
    if (mid >= rl) {
        Build(root<<1, rl, mid);
    }
    if (mid < rr) {
        Build(root<<1|1, mid+1, rr);
    }

    // pushup
    arr[root].coeff = (arr[root<<1].coeff + arr[root<<1|1].coeff) % MOD;
    Pushup(root);
}

void Update(int root, int rl, int rr, int vl, int vr, int val) {
    // return point
    if (vl <= rl && rr <= vr) {
        arr[root].lazy = val;
        arr[root].val = (arr[root].coeff * val) % MOD;
        return;
    }

    // split
    int mid = (rl+rr)>>1;
    Pushdown(root);

    if (mid >= vl) {
        Update(root<<1, rl, mid, vl, vr, val);
    }
    if (mid < vr) {
        Update(root<<1|1, mid+1, rr, vl, vr, val);
    }

    // pushup
    Pushup(root);
}


ll Query(int root, int rl, int rr, int ql, int qr) {
    // return point
    if (ql <= rl && rr <= qr) {
        return arr[root].val;
    }

    // split query
    ll val = 0;

    int mid = (rl+rr)>>1;
    Pushdown(root);

    if (mid >= ql) {
        ll l = Query(root<<1, rl, mid, ql, qr);
        val = l % MOD;
    }
    if (mid < qr) {
        ll r = Query(root<<1|1, mid+1, rr, ql, qr);
        val = (val + r) % MOD;
    }

    return val;
}


int main(int argc, char const *argv[])
{
    int nCases = 1;
    //scanf("%d", &nCases);

    for (int iCase = 1; iCase <= nCases; ++iCase) {
        int Q;
        scanf("%d%d", &N, &Q);

        FillCoeff();
        Build(1, 1, N);

        for (int i = 0; i < Q; ++i) {
            int l, r, d;
            scanf("%d%d%d", &l, &r, &d);


            Update(1, 1, N, l, r, d);
            ll ans = Query(1, 1, N, 1, N);
            printf("%lld\n", ans);
        }
    }

    return 0;
}


Measured memory_bytes: 17616
#include <stdio.h>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<queue>
using namespace std;
typedef long long ll;
const ll M = 200013;
int main()
{
    ll i,m,n;
    scanf("%lld%lld",&n, &m);
    if(n<=m)
    {
        for(i=1; i<=m; i++)
        {
            printf("%lld",n);
        }
    }
    else
    {
        for(i=1; i<=n; i++)
        {
            printf("%lld",m);
        }
    }
    return 0;
}


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

inline int read(){
  int x = 0; char c = getchar();
  while(!isdigit(c)) c = getchar();
  while(isdigit(c)) x = x * 10 + c - '0', c = getchar();
  return x;
}

int main(){
  int n = read(), maxl = 0, suml = 0;
  for(int i = 0, l; i < n; i++)
    l = read(), maxl = max(maxl, l), suml += l;
  printf("%s", maxl < suml - maxl? "Yes": "No");
  return 0;
}


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

int main() {
    ll H, W;
    cin >> H >> W;
    string S;
    vector<vector<bool>> path(H, vector<bool>(W, false));
    rep(y, H) {
        cin >> S;
        rep(x, W) { path[y][x] = S[x] == '.'; }
    }

    vector<vector<ll>> d(H * W, vector<ll>(H * W, 1e9));
    rep(i, H * W) d[i][i] = 0;
    auto cvt = [&](ll y, ll x) { return y * W + x; };
    auto setd = [&](ll y1, ll x1, ll y2, ll x2) {
        ll p1 = cvt(y1, x1);
        ll p2 = cvt(y2, x2);
        d[p1][p2] = 1;
        d[p2][p1] = 1;
    };

    rep(y, H) {
        rep(x, W) {
            if (!path[y][x]) continue;
            if (y > 0) {
                if (path[y - 1][x]) setd(y, x, y - 1, x);
            } else if (y < H - 1) {
                if (path[y + 1][x]) setd(y, x, y + 1, x);
            }
            if (x > 0) {
                if (path[y][x - 1]) setd(y, x, y, x - 1);
            } else if (x < W - 1) {
                if (path[y][x + 1]) setd(y, x, y, x + 1);
            }
        }
    }

    rep(k, H * W) {
        rep(i, H * W) {
            rep(j, H * W) { d[i][j] = min(d[i][j], d[i][k] + d[k][j]); }
        }
    }

    ll ans = -1;
    rep(i, H * W) {
        rep(j, H * W) {
            if (d[i][j] < 1e9) ans = max(ans, d[i][j]);
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1536
#include<bits/stdc++.h>
using namespace std;
namespace io {
	const int SIZE = (1 << 21) + 1;
	char ibuf[SIZE], *iS, *iT, obuf[SIZE], *oS = obuf, *oT = oS + SIZE - 1, c, qu[55]; int f, qr;
	// getchar
	#define gc() (iS == iT ? (iT = (iS = ibuf) + fread (ibuf, 1, SIZE, stdin), (iS == iT ? EOF : *iS ++)) : *iS ++)
	// print the remaining part
	inline void flush () {
		fwrite (obuf, 1, oS - obuf, stdout);
		oS = obuf;
	}
	// putchar
	inline void putc (char x) {
		*oS ++ = x;
		if (oS == oT) flush ();
	}
	// input a signed integer
	template <class I>
	inline void gi (I &x) {
		for (f = 1, c = gc(); c < '0' || c > '9'; c = gc()) if (c == '-') f = -1;
		for (x = 0; c <= '9' && c >= '0'; c = gc()) x = x * 10 + (c & 15); x *= f;
	}
	// print a signed integer
	template <class I>
	inline void print (I &x) {
		if (!x) putc ('0'); if (x < 0) putc ('-'), x = -x;
		while (x) qu[++ qr] = x % 10 + '0',  x /= 10;
		while (qr) putc (qu[qr --]);
	}
	//no need to call flush at the end manually!
	struct Flusher_ {~Flusher_(){flush();}}io_flusher_;
}
using io :: gi;
using io :: putc;
using io :: print;
#define rep(i,j,k) for(int i = j;i <= k;++i)
#define repp(i,j,k) for(int i = j;i >= k;--i)
#define ll long long
void gi(int &sum){
    sum = 0;char c = getchar();bool flag = true;
    while(c < '0' || c > '9') {if(c == '-') flag = false;c = getchar();}
    while(c >= '0' && c <= '9') sum = sum * 10 + c - 48,c = getchar();
    if(!flag) sum = -sum;
}
const int p = 1e9+7;
int n,a[201000],f[201000],la[201000];
int main(){
	gi(n); rep(i,1,n) gi(a[i]);
	f[0] = 1;
	rep(i,1,n) f[i] = ( f[i-1] + (la[a[i]]!=0&&la[a[i]]!=i-1 ? f[la[a[i]]] : 0) )%p,la[a[i]] = i;
	printf("%d\n",f[n]);
    return 0;
}

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

typedef long long ll;

const int mod = 924844033;
const int Maxn = 2005;

int fac[Maxn];
int n, k;
int gdp[Maxn];
int dp[Maxn][2];
int res;

int main()
{
    fac[0] = 1;
    for (int i = 1; i < Maxn; i++)
        fac[i] = ll(i) * fac[i - 1] % mod;
    gdp[0] = 1;
    scanf("%d %d", &n, &k);
    for (int i = 1; i <= n && i <= 2 * k; i++) {
        fill((int*)dp, (int*)dp + Maxn * 2, 0);
        dp[0][0] = 1;
        int cnt = n / (2 * k) + 1;
        for (int j = i; j <= n; j += 2 * k)
            for (int z = cnt; z >= 0; z--) {
                int zer = dp[z][0], one = dp[z][1]; dp[z][0] = dp[z][1] = 0;
                // back
                if (j - k >= 1)
                    dp[z + 1][0] = (dp[z + 1][0] + zer) % mod;
                // same
                dp[z][0] = (ll(dp[z][0]) + ll(zer) + ll(one)) % mod;
                // forw
                if (j + k <= n)
                    dp[z + 1][1] = (ll(dp[z + 1][1]) + ll(zer) + ll(one)) % mod;
            }
        for (int j = n; j >= 0; j--) if (gdp[j] != 0) {
            int ways = gdp[j]; gdp[j] = 0;
            for (int z = 0; z <= cnt; z++) {
                int my = (dp[z][0] + dp[z][1]) % mod;
                if (my) gdp[j + z] = (gdp[j + z] + ll(ways) * my) % mod;
            }
        }
    }
    for (int i = 0; i <= n; i++) {
        int add = ll(gdp[i]) * fac[n - i] % mod;
        if (i % 2) res = (res - add + mod) % mod;
        else res = (res + add) % mod;
    }
    printf("%d\n", res);
    return 0;
}


Measured memory_bytes: 256
n,m,x=input().split()
n,m,x=int(n),int(m),int(x)

a1=input().split()
a2=[]
for i in range(n+1):
    if str(i) in a1:
        a2.append(1)
    else:
        a2.append(0)

print(min([sum(a2[:x]),sum(a2[x+1:])]))


Measured memory_bytes: 3060
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <functional>
#include <numeric>
#include <math.h>
#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(void) {
	int X, N;
	cin >> X >> N;
	if (N == 0) {
		cout << X << endl;
		return 0;
	}
	priority_queue<int> que;
	//vector<int> vec(N);
	int tmp;
	for (int i = 0; i < N; i++) {
		cin >> tmp;
		que.push(tmp);
	}
	int ans = 0;
	for (int i = 101; i >= 0; i--) {
		if (que.empty()) {
			if (abs(X - ans) >= abs(X - i)) {
				ans = i;
			}
		} else {
			if (i == que.top()) {
				que.pop();
			} else {
				if (abs(X - ans) >= abs(X - i)) {
					ans = i;
				}
			}
		}
	}
	cout << ans << endl;
	return 0;
}

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

using namespace std;

char *p1, *p2, buf[100000];

#define nc() (p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 100000, stdin), p1 == p2) ? EOF : *p1 ++ )

int rd() {
	int x = 0;
	char c = nc();
	while (c < 48) {
		c = nc();
	}
	while (c > 47) {
		x = (((x << 2) + x) << 1) + (c ^ 48), c = nc();
	}
	return x;
}

int b[1000010];

long long ans = 0;

int main() {
	int n = rd();
	for (int i = 1; i < n; i ++ ) {
		b[i] = rd();
	}
	b[0] = b[n] = 0x7f7f7f7f;
	for (int i = 1; i <= n; i ++ ) {
		ans += min(b[i - 1], b[i]);
	}
	cout << ans << endl ;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define SORT(a) sort(a.begin(), a.end())
#define RSORT(a) sort(a.rbegin(), a.rend())
#define REP(i, n) for (int i = 0; i < n; i++)
#define RREP(i, n) for (int i = n; 0 <= i; i--)
#define FOR(i, start, end) for (int i = start; i < end; i++)
#define RFOR(i, start, end) for (int i = start; end <= i; i--)
#define ALL(a) a.begin(), a.end()
#define MOD(a) a %= 1000000007
using ll = long long;
using namespace std;
template <class T> inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

struct G {
    int to, cost;
};

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

    int N, M;
    cin >> N >> M;
    vector<vector<G>> graph(N);
    REP(i, M) {
        int L, R, D;
        cin >> L >> R >> D;
        L--;
        R--;
        graph[L].push_back({R, D});
        graph[R].push_back({L, -D});
    }
    vector<bool> visited(N, false);
    vector<int> dist(N);

    auto dfs = [&](auto f, auto i, auto d) -> bool {
        if (visited[i] && d != dist[i])
            return false;
        if (visited[i] && d == dist[i])
            return true;
        visited[i] = true;
        dist[i]    = d;
        REP(j, graph[i].size()) {
            if (!f(f, graph[i][j].to, d + graph[i][j].cost))
                return false;
        }
        return true;
    };

    REP(i, N) {
        if (!visited[i]) {
            if (!dfs(dfs, i, 0)) {
                std::cout << "No" << '\n';
                return 0;
            }
        }
    }

    std::cout << "Yes" << '\n';

    return 0;
}

Measured memory_bytes: 11264
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<iostream>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<cmath>
#include<string>

#define ls (t<<1)
#define rs ((t<<1)+1)
#define mid ((l+r)>>1)
#define fi first
#define se second
#define mk make_pair
#define pb push_back

#define N 305
#define M 200005
#define seed 23333
#define Mo 1000000007

using namespace std;
int i,j,m,n,p,k;
int f[N][N][N];
void jia(int &x,int y)
{
		x+=y; if (x>=Mo) x-=Mo;
}
int main()
{
		scanf("%d%d",&n,&m);
		f[0][1][0]=1;
		for (i=0;i<m;++i)
			for (j=1;j<=n;++j)
				for (k=0;k<=i;++k)
					if (f[i][j][k])
					{
						if (j<n)
						jia(f[i+1][j+1][k+1],1ll*f[i][j][k]*(n-j)%Mo); 
						jia(f[i+1][j][0],1ll*f[i][j][k]*(j-k)%Mo);
						jia(f[i+1][j][k],1ll*f[i][j][k]*k%Mo); 
					}
		printf("%d\n",f[m][n][0]);
}


Measured memory_bytes: 55424
#include<bits/stdc++.h>
#define fatafat ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define int long long
#define MOD ((long long)(1e9)+7)
#define excl(i,a,b) for(int i=a;i<b;i++)
#define incl(i,a,b) for(int i=a;i<=b;i++)
#define mp(a,b) make_pair(a,b)
#define ff first
#define ss second
#define PII pair<int,int>

using namespace std;

int binexp(int a,int b)
{
    if(b)
    {
        if(b%2)
            return a*binexp(a*a,b/2);
        return binexp(a*a,b/2);
    }
    return 1;
}

int modexp(int a,int b,int m)
{
    if(b)
    {
        if(b%2)
            return (a*modexp((a*a)%m,b/2,m))%m;
        return modexp((a*a)%m,b/2,m);
    }
    return 1;
}

int mygcd(int a,int b)
{
    if(b==0)
        return a;
    return mygcd(b,a%b);
}

int euclidgcd,euclidx,euclidy;

void exteuclid(int a,int b)
{
    if(b==0)
    {
        euclidgcd=a;
        euclidx=1;
        euclidy=0;
    }
    else
    {
        exteuclid(b,a%b);
        int temp=euclidx;
        euclidx=euclidy;
        euclidy=temp-euclidy*(a/b);
    }
}

int modinv(int a,int m)
{
    exteuclid(a,m);
    return (euclidx%m + m)%m;
}

int pmodinv(int a,int m)
{
    return modexp(a,m-2,m);
}

bool checkprime(int a)
{
    for(int i=2;i*i<=a;i++)
        if(a%i==0)
            return false;
    return true;
}

vector<bool> seive(int n)
{
    vector<bool> ret(n+1,true);
    ret[0]=ret[1]=false;
    for(int i=2;i*i<=n;i++)
        if(ret[i])
            for(int j=i*i;j<=n;j+=i)
                ret[j]=false;
    return ret;
}

vector<bool> seivelims(int l,int r)
{
    vector<bool> ret(r-l+1,true);
    for(int i=2;i*i<=r;i++)
    {
        for(int j=max(i*i,((l+i-1)/i)*i);j<=r;j+=i)
        {
            ret[j-l]=false;
        }
    }
    return ret;
}

vector<int> rootnfact(int n)
{
    vector<int> ret;
    for(long i=2;i*i<=n;i++)
        while(n%i==0)
        {
            ret.push_back(i);
            n/=i;
        }
    if(n!=1)
        ret.push_back(n);
    return ret;
}

vector<int> prelognfact(int n)
{
    vector<int> minprime(n+1,0);
    minprime[0]=minprime[1]=0;
    for(int i=2;i*i<=n;i++)
    {
        if(minprime[i]==0)
        {
            for(int j=i*i;j<=n;j+=i)
            {
                if(minprime[j]==0)
                    minprime[j]=i;
            }
        }
    }
    for(int i=2;i<=n;i++)
        if(minprime[i]==0)
            minprime[i]=i;
    return minprime;
}

vector<int> lognfact(int n,vector<int> minprime)
{
    vector<int> ret;
    while(n!=1)
    {
        ret.push_back(minprime[n]);
        n/=minprime[n];
    }
    return ret;
}

signed main()
{
    fatafat;
    int n;
    cin>>n;
    int arr[n],sum=0,cnt=0,min=10000000000;
    bool found=false;
    for(int i=0;i<n;i++){
        cin>>arr[i];
        if(arr[i]==0)
            found=true;
        if(arr[i]>0){
            if(arr[i]<min)
                min=arr[i];
            sum+=arr[i];
        }
        else{
            cnt++;
            if(-arr[i]<min)
                min=-arr[i];
            sum-=arr[i];
        }
    }
    if(found || !(cnt%2))
        cout<<sum;
    else
        cout<<sum-2*min;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define all(v) v.begin(), v.end()
    
int main(){
    int h,w,k;
    cin >> h >> w >> k;

    vector <string> S(h);

    for(int i=0; i<h; i++){
        cin >> S[i];
    }

    int ans = 0;

    for(int i=0; i < (1<<h); i++){
        for(int j=0; j< (1<<w); j++){
            int cntij = 0;
            bitset <6> hei(i);
            bitset <6> lin(j);
            for(int m=0; m<h; m++){
                for(int n=0; n<w; n++){
                    if( (hei.test(m)) && (lin.test(n)) && (S.at(m).at(n) == '#') ){
                        cntij ++;
                    }
                }
            }

            if(cntij == k){
                ans ++;
            }

        }
    }

    cout << ans << endl;

}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;
 
static const double EPS = 1e-8;
static const double PI = 4.0 * atan(1.0);
static const ll INF = 1023456789;
 
#define REP(i,n)	for(int i=0;i<n;++i)
#define REPR(i,n)	for(int i=n-1;i>=0;--i)
#define FOR(i,s,n)	for(int i=s;i<n;++i)
#define FORR(i,s,n)	for(int i=n-1;i>=s;--i)
#define ALL(c)		(c).begin(),(c).end()
#define CLEAR(v)	memset(v,0,sizeof(v))
#define MP(a,b)		make_pair((a),(b))
#define ABS(a)		((a)>0?(a):-(a))
#define F			first
#define S			second
 
int main(int argc, char **argv) {
	int m;
	cin >> m;
	cout << (48 - m) << endl;
	return 0;
}
 

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <cctype>
#include <algorithm>

#define ll long long

using namespace std;

inline int read(){
	int x=0,f=1;
	char ch=getchar();
	while (!isdigit(ch)){if (ch=='-') f=-1;ch=getchar();}
	while (isdigit(ch)) x=x*10+ch-'0',ch=getchar();
	return x*f;
}

int main(){
	string s;
	getline(cin,s);
	for (int i=0;i<s.length();i++){
		if (s[i]>='a'&&s[i]<='z'){
			cout<<"x";
		}
		else if (s[i]>='A'&&s[i]<='Z') cout<<"x";
		else cout<<s[i];
	}
	cout<<endl;
	return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<random>
#include<array>
#include<cassert>
using namespace std;
#define INF (1<<29)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define uniq(v) v.erase(unique(all(v)),v.end())


int a[3];
int b[3];

bool f(int p, int x,int y,int z) {
	if (a[x] != p && b[x] != p)return false;
	p = a[x] + b[x] - p;

	if (a[y] != p && b[y] != p)return false;
	p = a[y] + b[y] - p;

	if (a[z] != p && b[z] != p)return false;
	p = a[z] + b[z] - p;


	return true;
}

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

	rep(i,3) {
		cin >> a[i] >> b[i];
		a[i]--;
		b[i]--;
	}

	bool ok = false;
	rep(i,4) {
		ok = ok || f(i,0, 1, 2) || f(i,0, 2, 1) || f(i,1, 0, 2) || f(i,1, 2, 0) || f(i,2, 0, 1) || f(i,2, 1, 0);
	}


	cout << (ok ? "YES" : "NO") << endl;




	return 0;
}

Measured memory_bytes: 256
//
//  main.cpp
//  atcoder-matching
//
//  Created by r on 6/1/19.
//  Copyright © 2019 r. All rights reserved.
//

#include <iostream>
#include <algorithm>
#include <cstring>
#include <iomanip>
#include <fstream>
#include <cmath>
#include <vector>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <map>
#include <stack>
#include <queue>
#include <assert.h>
#include <limits>
#include <cstdio>
using namespace std;

//#define RDEBUG 1
#ifdef RDEBUG
#define D(x) x
#else
#define D(x)
#endif
#define inf 0x7fffffff
#define MOD 1000000007

long long N;
long long c[22][22];
long long dp[2097153][22];

long long f(long long mask, long long i) {
    if (mask == (1 << N)-1) {
        return 1;
    }
    if (dp[mask][i] != -1) {
        return dp[mask][i];
    }
    dp[mask][i] = 0;
    for (long long j = 0; j<N; j++) {
        if (c[i][j] && (mask & (1 << j)) == 0) {
            long long newmask = mask;
            newmask |= 1 << j;
            dp[mask][i]=(dp[mask][i]+f(newmask, i+1))%MOD;
        }
    }
    return dp[mask][i];
}

int main() {
    ios_base :: sync_with_stdio(false);
    cin.tie(nullptr);
    memset(dp, -1, sizeof(dp));
    cin >> N;
    for (long long i = 0; i<N; i++) {
        for (long long j = 0; j<N; j++) {
            cin >> c[i][j];
        }
    }
    cout << f(0,0) << endl;
    return 0;
}





Measured memory_bytes: 360704
n,m=map(int,input().split())
#各数字の個数をカウントするlist
cnt=[0]*(m+1)
for i in range(n):
    for j in list(map(int,input().split()))[1:]:
        cnt[j]+=1
res = 0
#もし数字の個数が人数に一致したならカウント
for i in range(1,m+1):
    if cnt[i] == n:
      res += 1
print(res)


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

#define rep(i,n) for(long long int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(long long int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(long long int i=(a);i>(b);i--)
#define all(v) (v).begin(), (v).end()
#define pb(q) push_back(q)
#define P pair<int,int>
#define Abs(a,b) max(a,b)-min(a,b)
#define YES(condition) if(condition){cout << "YES" << endl;}else{cout << "NO" << endl;}
#define Yes(condition) if(condition){cout << "Yes" << endl;}else{cout << "No" << endl;}
#define Cout(x) cout<<(x)<<endl

typedef long long ll;

using namespace std;

const int INF = 1e9,MOD = 1e9 + 7;
const ll LINF = 1e18;

//while(x!=0){
            //sum+=x%10;
           // x/=10;
        //}
        //各桁の和

//pair<int,int> p[100000];
//P r[100000];
//cin >> tmp;
//p[i]=make_pair(tmp,i);
//cout << p[i].second+1 << endl;//ペアの右側つまりiを出力

//s.find(w[i])==string::npos
//findの使い方

//for(int i=0;i<n;i++){
   // b[i]=x%2;
    //x/=2;
  //}二進数

long long int n=1,cnt=0,ans=1,a[100000],b[100000],cmp,data,m,h,x,y,xcmp=0,ycmp=0,sum=0,q=0;

string s,w;

vector<int> z;



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

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

int main(void){
       cin.tie(0);
    ios::sync_with_stdio(false);
    
   cin >> n;
   rep(i,n){
       cin >> h;
       ans = lcm(ans,h);
   }
     Cout(ans);
return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <assert.h>
#include <vector>
#include <unordered_map>
#include <queue>
#include <climits>
#include <cmath>
#include <algorithm>
using namespace std;
constexpr int64_t MOD = 1e9 + 7;
const double PI=3.141592;
int main(){
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);

  int S, W;
  cin >> S >> W;
  if (S <= W) cout << "unsafe" << endl;
  else cout << "safe" << endl;
  return 0;
}



Measured memory_bytes: 3640
s = input()
n = len(s)
alset = set()
mojiretsu = s
chuumoku = ""
cnt = 0
ans = float("INF")
for i in range(n):
    if s[i] not in alset:
        chuumoku = s[i]
        alset.add(chuumoku)
        while len(set(mojiretsu)) != 1:
            cpmojiretsu = mojiretsu
            mojiretsu = ""
            for j in range(len(cpmojiretsu) - 1):
                if cpmojiretsu[j] == chuumoku or cpmojiretsu[j + 1] == chuumoku:
                    mojiretsu += chuumoku
                else:
                    mojiretsu += s[j]
            cnt += 1
        if ans > cnt:
            ans = cnt
        cnt = 0
        mojiretsu = s
print(ans)

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

const int dx[] = {-1, 1, 0, 0};
const int dy[] = {0, 0, 1, -1};
char land[20][20];

void dfs(int y, int x) {
   land[y][x] = '0';
   for (int i = 0; i < 4; i++) {
      int ny = y+dy[i], nx = x+dx[i];
      if (ny >= 0 && ny < 12 && nx >= 0 && nx < 12 && land[ny][nx] == '1') {
         dfs(ny, nx);
      }
   }
   return;
}

int main() {
   while (cin >> land[0]) {
      for (int i = 1; i < 12; i++) {
         cin >> land[i];
      }

      int cnt = 0;
      for (int i = 0; i < 12; i++) {
         for (int j = 0; j < 12; j++) {
            if (land[i][j] == '1') {
               cnt++;
               dfs(i, j);
            }
         }
      }
      cout << cnt << endl;
   }

   return 0;
}


Measured memory_bytes: 3092
[N,Y] = list(map(int,input().split(' ')))

t = int(Y/1000 - N)
x = -1
y = -1
z = -1
for i in range(N+1):
  if ((t - 9*i)/4 < 0):
    break
  elif (int((t - 9*i)/4) == (t - 9*i)/4) and (N - i - int((t - 9*i)/4) >= 0) and (t - 9*i)/4 >= 0:
    x = i
    y = int((t - 9*i)/4)
    z = int(N - x - y)
    break
  else:
    continue
    
print('{0} {1} {2}'.format(x,y,z))

Measured memory_bytes: 3188
#include <stdio.h>
#include <string.h>
 
int main() {
 
  char str[1050] = {0};
  char ch[1050] = {0};
  char mei[30] = {0};
  char pl[1050]={0};
  int i,j,k,l,m,n,o,p;
 
  
  scanf("%s",str);
  scanf("%d",&n);
    
  for(i=0; i<7 ;i++) {
    ch[i] = str[i];
  }
 
  j=0;
  o=0;
  k=l=0;
 
  for ( i = 0; i < n; i++ ){
    scanf("%s", mei);
    scanf("%d %d", &k, &l);
    // printf("mei= %s",mei);
   
     
    if(mei[2] =='p') {
      
      scanf("%s", pl);
 
      for(m=0;m<l-k+1;m++) {
 
    //  printf("str[%d]%c = pl[%d]%c\n",m+k,str[m+k] ,m,pl[m]);
    str[m+k] = pl[m];   
      }
    }
 
    else if(mei[2] == 'v') {
       
      for(m=0; m<strlen(str);m++) {
    ch[m] = str[m];
      }
       
      for(m=0;m<l-k+1;m++) {
    //  printf("str[%d]%c = ch[%d]%c\n",k+m,str[k+m],l-m,ch[l-m]);
    str[k+m] = ch[l-m];
      }
     
    }
 
    else if(mei[0] = 'p') {   
       
      for(m=k; m<=l;m++) {
    printf("%c" ,str[m]);
      }
      printf("\n");
    }
     
  }
 
    
  return 0;
 
}


Measured memory_bytes: 2128
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cstring>
#include<cmath>
#include <numeric>
#include<queue>
#include<climits>
#include<cstdio>


#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
//#define INF ((LLONG_MAX) / (2))
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
typedef long long int ll;
typedef pair<ll,int> LL_IP;
#define INF 1e9+7


ll a[10000001];

int main(){

    ll n;
    cin >> n;
    vector<ll> arr;

    REP(i,1e7+1){
        a[i] = i+1;
    }
    REP(i,1e7){
        a[i+1] += a[i];
    }
    REP(i,n){
        if(a[i] >= n){
            ll tmp = a[i] - n;
            REP(j,i+1){
                if((j+1) != tmp){
                    arr.push_back(j+1);
                }
            }
            break;
        }
    }
    REP(i,arr.size()){
        cout << arr[i] << endl;
    }

    return 0;
}

Measured memory_bytes: 78464
#include <stdio.h>

int main() {
char a;
char ch[120];
char c[120];
char b[120];
int i,j,k,l,m,n,o;
m = 0;
n = 0;
i=0;
l=0;

while(1) {
scanf("%c",&a);

if(a == '\n') {
 break;
}

ch[i] = a;
i=i+1;

}

j=0;
while(1) {
scanf("%c",&a);
if(a == '\n') {
break;
}
c[j] = a;
j +=1;
}
/*??????????????§??\??????*/

for(k=0;k<i;k++) {

if(c[0] == ch[k] ) {       /*???????????????????????¨?????????????????? */
 l = k;
n = 0;                         /* ??????????????´???????????????*/
for(m=0;m<i-k;m++) {         /* c[k]????????????????§????????????? */
n = n +1;
l  +=1;
b[m] = ch[l-1];
}
l=0;
for(m=n;m<n+1+k;m++) {
l +=1;
b[m] = ch[l-1];            
}
o=0;
for(n=0;n<j;n++) {
/*printf("b[%d] = %c\n c[%d] = %c\n",n,b[n],n,c[n]); */
if(b[n] == c[n]){
o +=1;
}
}
}

/* printf("i = %d\nj = %d\n",i,j); */


if(o == j) {
printf("Yes\n");
break;
} else if(k==i-1) {
printf("No\n");
}
}
 
return 0;

}



Measured memory_bytes: 2148
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();//, b = sc.nextInt();
		//int x=sc.nextInt();//,k=sc.nextInt();
		long sum=0,count=0,flag=0,max=-999999,min=99999;
		long[] array=new long[a];
		//String s=sc.next();//,t=sc.next();
		String buff;
		//String[] arrays = new String[a];
		for(int i=0;i<a;i++) {
			buff=sc.next();
			if(buff.equals("P")) {
				array[0]++;
			}else if(buff.equals("G")) {
				array[1]++;
			}else if(buff.equals("Y")) {
				array[2]++;
			}else {
				array[3]++;
			}
		}
		for(int i=0;i<a;i++) {
			if(array[i]!=0)count++;
		}

		if(count==3)System.out.println("Three");
		if(count==4)System.out.println("Four");
	}
	public static int sample(int n) {
		return n;
	}

}


Measured memory_bytes: 22996
#include <bits/stdc++.h>
using namespace std;
int main(void){
    string S;
    cin >> S;
    reverse(S.begin(),S.end());
    for(int i = 0; i < S.size(); i++){
        if(S.substr(i,5) == "esare" || S.substr(i,5) == "maerd") i += 4;
        else if(S.substr(i,6) == "resare") i += 5;
        else if(S.substr(i,7) == "remaerd") i += 6;
        else{
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
}


Measured memory_bytes: 512
#include <algorithm>
#define _USE_MATH_DEFINES
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include<list>
#include<map>
#include<utility>
#include<tuple>
#include<numeric>
#include<set>

#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(a) (a).begin(),a.end()
using namespace std;

int main()
{
	int n;
	cin >> n;
	vector <char> a;
	rep(i, n) {
		char x;
		cin >> x;
		a.push_back(x);
	}
	sort(all(a));
	if (binary_search(all(a),'Y'))cout << "Four" << endl;
	else cout << "Three" << endl;
}



Measured memory_bytes: 256