akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cassert>
#include <cmath>
#include <complex>
using namespace std;


typedef complex<double> P;

#define EPS			(1e-10)
#define PI			(3.14159265358979323846)


#define X(a)		( (a).real() )
#define Y(a)		( (a).imag() )
#define EQ(a,b)		( -EPS<(a)-(b) && (a)-(b)<EPS )
#define EQV(a,b)	( EQ(X(a),X(b)) && EQ(Y(a),Y(b)) )

#define unit(a)		( (a)/abs(a) )
#define normal(a)	( (a)*P(0,1) )
#define dot(a,b)	( X((a)*conj(b)) )
#define cross(a,b)	( Y(conj(a)*(b)) )

int ccw(P a, P b, P c)
{
	b -= a; c -= a;
	if(cross(b, c) > 0)   return +1;	// counter clockwise
	if(cross(b, c) < 0)   return -1;	// clockwise
	if(dot(b, c) < 0)     return +2;	// c--a--b on line
	if(norm(b) < norm(c)) return -2;	// a--b--c on line
	return 0;
}

int main()
{
	P p[4]; int a; double x,y; char c;
	while(cin >> x >> c >> y)
	{
		p[0]=P(x,y);

		for(int i=1; i<4; i++)
		{
			cin >> c >> x >> c >> y;
			p[i]=P(x,y);
		}

		a=0;
		for(int i=0; i<4; i++)
		{
			a+=ccw(p[i],p[(i+1)%4],p[(i+2)%4]);
		}

		cout << (a==4||a==-4 ? "YES":"NO") << endl;
	}

}

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

using namespace std;

typedef long long ll;
ll n, m, A[100050];
ll cycd(ll a, ll b){
	if(b<a) b+=m;
	return b-a;
}

struct node{
	ll s,e,m,v,lazy;
	node *l, *r;
	node(ll ss, ll ee){
		s = ss, e = ee;
		m = (s+e)/2;
		v = lazy = 0;
		if(s == e) return;
		l = new node(s,m);
		r = new node(m+1,e);
	}
	ll value(){
		v += lazy*(e-s+1);
		if(s != e){
			l->lazy += lazy;
			r->lazy += lazy;
		}
		lazy = 0;
		return v;
	}
	void add(ll x, ll y, ll val){
		value();
		if(s == x and e == y){
			lazy += val;
			return;
		}
		if(y <= m) l->add(x,y,val);
		else if(x > m) r->add(x,y,val);
		else l->add(x,m,val), r->add(m+1,y,val);
		v = l->value() + r->value();
	}
	ll sum(ll x, ll y){
		value();
		if(s == x and e == y) return value();
		if(y <= m) return l->sum(x,y);
		else if(x > m) return r->sum(x,y);
		else return l->sum(x,m) + r->sum(m+1,y);
	}
}*root;
void print(){
	for(ll i = 1; i<=m; i++) printf("%d ", root->sum(1,i)); printf("\n");
}
void add(ll s, ll e, ll val){
	if(s > m) s-=m;
	if(e > m) e-=m;
	if(s > e){
		root->add(s,m,val);
		root->add(1,1,(m-s+1)*val);
		root->add(1,e,val);
		root->add(e+1,e+1,-(m-s+1+e)*val);
	}else{
		root->add(s,e,val);
		if(e+1 <= m) root->add(e+1,e+1,-(e-s+1)*val);
	}
}
int main(){
//	freopen("mx0.txt","r",stdin);
	cin >> n >> m;
	root = new node(0,m);
	for(ll i = 0; i<n; i++){
		cin >> A[i];
		if(i > 0){
			root->add(1,1,cycd(A[i-1],A[i]));
			if(cycd(A[i-1],A[i]) >= 2) add(A[i-1]+2,A[i],-1);
		}
	}
	ll ans = 1000000000000;
	for(ll i = 1; i<=m; i++){
		ans = min(root->sum(1,i),ans);
	}
	cout << ans;
}


Measured memory_bytes: 13568
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector> 
#include<limits>
#include<numeric>
#include<type_traits>
#include<math.h>
#include<fstream>
#include<set>
#include<queue>
using namespace std;
typedef long long ll;

const ll MOD = 1e9 + 7; 

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
#define out(str) cout << str << endl
#define ALL(a) (a).begin(),(a).end()
#define INF_INT (1<<30)
#define INF_LL (1ll<<62)

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; }

int N,M;
char A[100][100],B[100][100];
bool match(int x, int y){
    rep(i,M){
        rep(j,M){
            if(A[x+i][y+j]!=B[i][j])return false;
        }
    }
    return true;
}

int main(){
    cin>>N>>M;
    rep(i,N){
        rep(j,N){
            cin>>A[i][j];
        }
    }
    rep(i,M){
        rep(j,M){
            cin>>B[i][j];
        }
    }
    rep(i,N-M+1){
        rep(j,N-M+1){
            if(match(i,j)){
                out("Yes");
                return 0;
            }
        }
    }
    out("No");
    
}

Measured memory_bytes: 256
def unique(list_to_unique) -> list:
    if len(list_to_unique) == 0:
        return []
    else:
        result = [list_to_unique[0]]
        for it in range(1, len(list_to_unique)):
            if list_to_unique[it] != list_to_unique[it - 1]:
                result.append(list_to_unique[it])
        return result


n = int(input())
a = list(map(int, input().split()))
a = unique(a)
while len(a) > 1 and a[0] >= a[1]:
    a.pop(0)
while len(a) > 1 and a[len(a) - 1] <= a[len(a) - 2]:
    a.pop(len(a) - 1)
b = []
na = []
for i in range(len(a)):
    if i == 0 or i == len(a) - 1:
        b.append(a[i])
    elif a[i] > a[i - 1] and a[i] > a[i + 1] or a[i] < a[i + 1] and a[i] < a[i - 1]:
        b.append(a[i])
a = b
if len(a) > 2:
    money = 1000
    stocks = 0
    for i in range(len(a)):
        if i % 2 == 1:
            money += stocks * a[i]
            stocks = 0
        else:
            stocks += money // a[i]
            money %= a[i]
    print(money)
elif len(a) == 2 and a[0] < a[1]:
    print(1000 // a[0] * a[1] + 1000 % a[0])
else:
    print(1000)


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

//#define int long long
#define reps(i,s,n) for(int (i)=(s);(i)<(n);++(i))
#define rep(i,n) reps(i,0,n)
#define rept(i,n) rep(i,(n)+1)
#define repst(i,s,n) reps(i,s,(n)+1)
#define reprt(i,n,t) for(int (i)=(n);(i)>=(t);--(i))
#define repr(i,n) reprt(i,n,0)
#define each(itr,v) for(auto &(itr):(v))
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define tmax(x,y,z) max(x,max(y,z))
#define tmin(x,y,z) min(x,min(y,z))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln '\n'
#define bln(i,n) (((i)==(n)-1)?'\n':' ')
#define dbg(x) cout<<#x" = "<<(x)<<ln<<flush
#define dbga(x,n) {cout<<#x" : ";for(int (i)=0;i<(n);++i){cout<<((x)[i])<<(i==((n)-1)?'\n':' ')<<flush;}}
#define zero(a) memset(a,0,sizeof(a))
#define unq(a) sort(all(a)),a.erase(unique(all(a)),a.end())

typedef complex<double> P;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vst;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vector<int> > mat;

const ll inf = (ll)1e9+10;
const ll linf = (ll)1e18+10;
const ll mod = (ll)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};
const double eps = 1e-10;

ll mop(ll a,ll b,ll m=mod) {ll r=1;a%=m;for(;b;b>>=1){if(b&1)r=r*a%m;a=a*a%m;}return r;}
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b) {return a*b/gcd(a,b);}
bool ool(int x,int y,int h,int w) {return((x<0)||(h<=x)||(y<0)||(w<=y));}
bool deq(double a,double b) {return abs(a-b)<eps;}

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;

// ━━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…
// .｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋
// ・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・

// 風船は同時に3個まで k個持ってると1動くのにk+1秒かかる
// dp[i][j]: i番目までを移動距離jで運びきって原点にいる状態になるのにかかる時間の最小値
int n, p[40], t[40], dp[44][8080];

void solve() {
	rept(i,n) rept(j,8000) dp[i][j] = inf;
	dp[0][0] = 0;
	rep(i,n) rept(j,8000) if (dp[i][j]!=inf) {
		// iを運ぶ
		if (dp[i][j]+p[i]<=t[i]) chmin(dp[i+1][j+p[i]*2], t[i]+p[i]*2);
		else continue;
		// i+1も同時に運ぶ
		if (i+1>=n) continue;
		int d = abs(p[i]-p[i+1]);
		if (t[i]+d*2<=t[i+1]) chmin(dp[i+2][j+p[i]+d+p[i+1]], t[i+1]+p[i+1]*3);
		else continue;
		// i+2も同時に運ぶ
		if (i+2>=n) continue;
		int e = abs(p[i+1]-p[i+2]);
		if (t[i+1]+e*3<=t[i+2]) chmin(dp[i+3][j+p[i]+d+e+p[i+2]], t[i+2]+p[i+2]*4);
	}
	int res = inf;
	rept(i,8000) if (dp[n][i]!=inf) chmin(res,i);
	if (res==inf) {
		repst(i,1,n) {
			bool ng = 1;
			rept(j,8000) if (dp[i][j]!=inf) ng = 0;
			if (ng) {
				cout << "NG " << i << ln;
				return;
			}
		}
	} else cout << "OK " << res << ln;
}

signed main() {
	while (1) {
		cin >> n;
		if (n==0) break;
		rep(i,n) cin >> p[i] >> t[i];
		solve();
	}
}


Measured memory_bytes: 4420
#include<bits/stdc++.h>
#define ll long long
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;
 
int main(){

    float r;
    cin >> r;
    

    cout << 2*r*3.14159;

    

	return 0;
}

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


def main():
    n = int(input())

    for i in range(0, 100 + 1):
        for j in range(0, 100 + 1):
            if (4 * i + 7 * j) == n:
                print('Yes')
                exit()

    print('No')


if __name__ == '__main__':
    main()


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

bool check(vector<int> und, int x){
    rep(i, und.size()){
        if(und[i]<x)return false;
    }
    return true;
}

int main(){
    int m, n, x;
    cin >> n >> m >> x;
    
    vector<vector<int>> a;
    vector<int> c;
    a.resize(n);
    c.resize(n);
    rep(i, n){
        cin >> c[i];
        a[i].resize(m);
        rep(j, m)cin >> a[i][j];
    }
    
    
    int ans = 1<<30;
    rep(i, (1<<n)){
        vector<int> und(m, 0);
        int cost=0;
        rep(j, n){
            if(i&(1<<j)){
                cost+=c[j];
                rep(k, m)und[k]+=a[j][k];
            }
        }
        if(check(und, x))ans = cost<ans? cost: ans;
    }
    
    if(ans == 1<<30)ans=-1;
    cout << ans << endl;
}

Measured memory_bytes: 3664
#include<iostream>
#include<climits>
#include<cassert>
#include<algorithm>
#include<cassert>
#include<map>
#include<vector>
using namespace std;
#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n)   REP(i,0,n)

const int N = 101;
const int mod = 10000;
int dp[N][3][3];
int solve(int n,int *in){
  rep(i,N)rep(j,3)rep(k,3)dp[i][j][k] = 0;
  rep(i,3){
    if (in[0] != -1 && i != in[0])continue;
    rep(j,3){
      if (in[1] != -1 && j != in[1])continue;
      dp[1][i][j] =1;
    }
  }
  REP(i,2,n){
    rep(j,3){//two day
      rep(k,3){//one day before
	rep(ii,3){//ii-th day
	  if (in[i] != -1 && in[i] != ii)continue;
	  if (j == k && j == ii)continue;//ï¼æ¥é£ç¶åã
	  dp[i][k][ii] += dp[i-1][j][k];
	  dp[i][k][ii] %= mod;
	}
      }
    }
  }
  int ret = 0;
  rep(i,3){
    rep(j,3){
      ret = (ret + dp[n-1][i][j])%mod;
    }
  }
  return ret;
}

main(){
  int n,k;
  while(cin>>n>>k && n){
    int in[n];rep(i,n)in[i] = -1;
    rep(i,k){
      int day,type;
      cin>>day>>type;
      in[day-1] = type-1;
    }
    cout << solve(n,in) << endl;
  }
}

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

#define endl '\n'
#define ll long long

void int_scan(int&);
void ll_scan(ll&);

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int x, y, a, b, c;
	int_scan(x);
	int_scan(y);
	int_scan(a);
	int_scan(b);
	int_scan(c);
	int p, q, r;
	priority_queue<int> p_queue;
	priority_queue<int> q_queue;
	priority_queue<int> r_queue;
	for (int i = 0; i < a; ++i) {
		int_scan(p);
		p_queue.push(p);
	}
	for (int i = 0; i < b; ++i) {
		int_scan(q);
		q_queue.push(q);
	}
	for (int i = 0; i < c; ++i) {
		int_scan(r);
		r_queue.push(r);
	}

	priority_queue<int> comb_queue;
	for (int i = 0; i < x; i++) {
		comb_queue.push(p_queue.top());
		p_queue.pop();
	}
	for (int i = 0; i < y; i++) {
		comb_queue.push(q_queue.top());
		q_queue.pop();
	}
	while (!r_queue.empty()) {
		comb_queue.push(r_queue.top());
		r_queue.pop();
	}

	ll sum = 0L;
	for (int i = 0; i < x + y; ++i) {
		sum += (ll)comb_queue.top();
		comb_queue.pop();
	}
	cout << sum << endl;
	return 0;
}

void int_scan(int& n)
{
	bool negative = false;
	char c;
	n = 0;

	c = getchar();
	if (c == '-')
	{
		negative = true;
		c = getchar();
	}
	for (; (c > 47 && c < 58); c = getchar())
		n = n * 10 + c - 48;

	if (negative)
		n *= -1;
}

void ll_scan(ll& n)
{
	bool negative = false;
	char c;
	n = 0;

	c = getchar();
	if (c == '-')
	{
		negative = true;
		c = getchar();
	}
	for (; (c > 47 && c < 58); c = getchar())
		n = n * 10 + c - 48;

	if (negative)
		n *= -1;
}

Measured memory_bytes: 3572
import sys
a, b, c = map(int, input().split())
if c <= a or c <= b:
    print("No")
    sys.exit()
if c <= a + b:
    print("No")
    sys.exit()
if (c - a - b) ** 2 > 4 * a * b:
    print("Yes")
else:
    print("No")


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

int main() {
  int N, x;
  cin >> N >> x;
  
  vector<int> a(N);
  for (int i = 0; i < N; ++i) cin >> a.at(i);
  
  sort(a.begin(), a.end());
  
  int count = 0;
  for (int i = 0; i < N; ++i) {
    if (x < a.at(i)) {
      break;
    }
    else {
      x -= a.at(i);
      ++count;
      if (i == N - 1 && x > 0) {
        --count;  
      }
    }
    
  }
  cout << count << endl;
}

Measured memory_bytes: 3612
import java.util.Scanner;

public class Main {

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

        final long N = sc.nextLong();

        long ans = Long.MAX_VALUE;

        for (int i = 1; i <= Math.sqrt(N); i++) {
            if ((i*(N/i)) == N) {
                ans = Math.min(ans, f(i, (int) (N/i)));
            }
        }

        System.out.println(ans);
    }

    private static int f(final int a, final int b) {
        return Math.max(String.valueOf(a).length(), String.valueOf(b).length());
    }
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using Graph = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Rep(i, k, n) for (int i = k; i < (int)(n); i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
long long dp[100010];
long long h[100010];
int dx[8] = {1, 0, -1, 0, 1, -1, 1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, -1, 1};


int main()
{
    int h, w; cin >> h >> w;
    vector<string> S;
    string s;
    rep(i, h)
    {
        cin >> s;
        S.push_back(s);
    }

    rep(i, h)
    {
        rep(j, w)
        {
            if (S[i][j] == '#') continue;

            int cnt = 0;
            rep(k, 8)
            {
                int x = j + dx[k];
                int y = i + dy[k];
                if (y < 0 || y >= h) continue;
                if (x < 0 || x >= w) continue;
                if (S[y][x] == '#') cnt++;
            }
            S[i][j] = char(cnt + '0');
        }
    }

    rep(i, h) cout << S[i] << endl;
}

Measured memory_bytes: 256
import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N, K, S = lr()
INF = 10 ** 9
if S < INF:
    answer = [S] * K + [S+1] * (N-K)
else:
    answer = [S] * K + [1] * (N-K)    

print(*answer)


Measured memory_bytes: 6500
import java.util.Scanner;

/**
 * Created by zzt on 17-1-16.
 */
public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String s = scanner.nextLine();

        s = s.replaceAll("eraser", "");
        s = s.replaceAll("erase", "");
        s = s.replaceAll("dreamer", "");
        s = s.replaceAll("dream", "");

        System.out.println(s.length()>0?"NO":"YES");
    }
}

Measured memory_bytes: 16196
/**************************************************************************
Coded by: Saba Karimi(_VINTAGE)
Institution: AIT PUNE
***************************************************************************/
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back 
#define all(a) a.begin(),a.end()
#define lb lower_bound
#define ub upper_bound
#define pii pair<int,int>
#define ld long double
#define int long long int 
/**************************************************************************/
signed main()
{
    fast;
    int n;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++)
        cin>>a[i];
    sort(a,a+n);
    int l = a[(n/2)-1];
    int r = a[n/2];
    cout<<r-l;
}

Measured memory_bytes: 1024
n = int(input())
nums = list(map(int, input().split()))

count = 0
for num in nums:
    if num < 0:
        count = count + 1

mode = count % 2 == 1
sumVal = 0
if mode == False:
    for num in nums:
        sumVal = sumVal + abs(num)
else:
    minVal = None
    for num in nums:
        sumVal = sumVal + abs(num)
        if minVal == None or minVal > abs(num):
            minVal = abs(num)
    sumVal = sumVal - (minVal * 2)
print(sumVal)

Measured memory_bytes: 14224
from collections import Counter


n = int(input())
S = list()
for i in range(n):
    S.append(input())

count = Counter(S)
v_max = max(count.values())
keys = list()
for key, value in count.items():
    if value == v_max:
        keys.append(key)

keys = sorted(keys)
for key in keys:
    print(key)


Measured memory_bytes: 35572
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<cmath>
#include<climits>
#include<queue>
#include<stack>
#include<numeric>
#include<tuple>
using namespace std;


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

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

ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}


int main(){
  ll a, b;
  cin >> a >> b;
  cout << lcm(a, b) << endl;
}

Measured memory_bytes: 256
#![allow(non_snake_case)]
#![allow(unused_variables)]
#![allow(dead_code)]

fn main() {
    let N: usize = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        line.trim().parse().unwrap()
    };
    let D: Vec<usize> = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        line.split_whitespace()
            .map(|x| x.parse().unwrap())
            .collect()
    };
    let M: usize = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        line.trim().parse().unwrap()
    };
    let T: Vec<usize> = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        line.split_whitespace()
            .map(|x| x.parse().unwrap())
            .collect()
    };

    let mut cnt = std::collections::HashMap::new();
    for i in 0..N {
        *(cnt.entry(&D[i]).or_insert(0)) += 1;
    }
    for j in 0..M {
        *(cnt.entry(&T[j]).or_insert(0)) -= 1;
    }

    let ans = if cnt.iter().all(|(&k, &v)| v >= 0) {
        "YES"
    } else {
        "NO"
    };

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

Measured memory_bytes: 19228
S = input()

d = set(['A', 'T', 'C', 'G'])
len_ = 0
ans = 0
for s in S:
    if s in d:
        len_ += 1
    else:
        if len_ > ans:
            ans = len_
        len_ = 0
if len_ > ans:
    ans = len_
print(ans)


Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <string>
#include <map>
#define MAX_U   10
#define MIN_U   0
#define rep(i,n) for(int i=0;i<n;i++)
#define sz(x) ((int)(x).size())
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<string> vs;
typedef queue<int> qi;
const int INF=numeric_limits<int>::infinity();
void printa(){cout<<"\n";}
template<class T, class... A>void printa(const T&first,const A&... rest){cout<<first;printa(rest...);}
template<class... A>void printa(const A&... rest){printa(rest...);}
void prints(){cout<<" ";}
template<class T, class... A>void prints(const T&first,const A&... rest){cout<<first;prints(rest...);}
template<class... A>void prints(const A&... rest){prints(rest...);}
int factorial(int x){int f=1;for(int i=1;i<x+1;i++)f=f*i;return f;}
int sigma(int x){int s;for(int i=1;i<x+1;i++)s=s+i;return s;}
int middle(int x){if(x%2==0)return x/2;else return x/2+1;}
double heron(int a,int b,int c){double s;s=(a+b+c)/2;return sqrt(s*(s-a)*(s-b)*(s-c));}
double trapezium(int a,int b,int h){return (a+b)*h/2;}
double triangle(int a,int h){return a*h/2;}
int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b;
    cin >>a>>b;
    if(a+b>=10)printa("error");
    else printa(a+b);
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)

int main()
{
  int n;
  cin >> n;
  std::vector<int> p(n);
  REP(i,n) cin >> p[i];

  std::vector<int> p_good(n);
  REP(i,n) p_good[i] = p[i];
  sort(ALL(p_good));
  int cnt = 0;
  REP(i,n) if(p_good[i]-p[i] != 0) cnt++;
  if(cnt <= 2) cout << "YES" << endl;
  else cout << "NO" << endl;
  return 0;
}


Measured memory_bytes: 256
H, W, N = map(int, input().split())
y, x = map(int, input().split())
S = input()
T = input()

x1 = x

is_no = False
for s, t in zip(S, T):
    if s == 'R':
        x1 += 1
    if x1 == W + 1:
        is_no = True
        break
    if t == 'L':
        if x1 != 1:
            x1 -= 1

x1 = x
for s, t in zip(S, T):
    if s == 'L':
        x1 -= 1
    if x1 == 0:
        is_no = True
        break
    if t == 'R':
        if x1 != W:
            x1 += 1

y1 = y
for s, t in zip(S, T):
    if s == 'U':
        y1 -= 1
    if y1 == 0:
        is_no = True
        break
    if t == 'D':
        if y1 != H:
            y1 += 1

y1 = y
for s, t in zip(S, T):
    if s == 'D':
        y1 += 1
    if y1 == H + 1:
        is_no = True
        break
    if t == 'U':
        if y1 != 1:
            y1 -= 1

if is_no:
    print('NO')
else:
    print('YES')

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

using namespace std;
#define ll long long
#define pb push_back
#define vi vector<int>
#define vll vector<long long>
#define inf 1000000100
#define infll 1LL << 50

int main()
{
    int n;
    cin >> n;
    vi butt(n+1);
    for(int i = 1; i <= n; i++)
    {
        cin >> butt[i];
    }

    vector<bool> visited(n+1);
    queue<int> q;
    q.push(1);
    int ans = 0;
    bool solve = 0;
    while(!q.empty())
    {
        int t = q.front();
        q.pop();
        if(!visited[butt[t]])
        {
            ans++;
            visited[butt[t]] = 1;
            q.push(butt[t]);
        }
        if(butt[t] == 2)
        {
            solve = 1;
            break;
        }
    }
    if(solve)
    {
        cout << ans << endl;
    }
    else
    {
        cout << -1 << endl;
    }
}

Measured memory_bytes: 640
def solve():
    import sys
    f_i = sys.stdin
    q = f_i.readline()
    
    from collections import deque
    A = deque()
    
    ans = []
    
    for q in f_i:
        if q[0] == '0':
            if q[2] == '0':
                A.appendleft(q[4:])
            else:
                A.append(q[4:])
        elif q[0] == '1':
            ans.append(A[int(q[2:])])
        else:
            if q[2] == '0':
                A.popleft()
            else:
                A.pop()
    print(''.join(ans), end='')

solve()


Measured memory_bytes: 34552
#include <bits/stdc++.h>
using namespace std;
 
main(){
  int N, A, B;
  A = 0;
  B = 0;
  cin >> N;
  vector<int> vec(N);
  for(int i=0; i<N; i++){
    cin >> vec.at(i);
  }
  sort(vec.begin(),vec.end());
  reverse(vec.begin(),vec.end());
  for(int i=0; i<N; i+=2){
    A += vec.at(i);
  }
  for(int i=1; i<N; i+=2){
    B += vec.at(i);
  }
  cout << A-B << endl;    
}

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

#define rep(i, N) for (int i = 0; i < (N); i++)
#define all(a) (a).begin(), (a).end()
#define pb push_back

using ll = long long;
using i_i = tuple<int, int>;

int main() {
    int x, y, z;
    cin >> x >> y >> z;
    if (x == y && y == z) cout << "Yes" << endl;
    else cout << "No" << endl;
}


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

int main() {
    int N, M, C;
    cin >> N >> M >> C;

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

    int A[N][M];
    int count = 0;
    for (int i = 0; i < N; i++) {
        int sum = 0;
        for (int j = 0; j < M; j++) {
            cin >> A[i][j];
            sum += A[i][j] * B[j];
        }
        if (sum + C > 0) {
            count++;
        }
    }

    cout << count << endl;
    return 0;
}

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

int main()
{
    int m, f, r;
    while (true) {
        std::cin >> m >> f >> r;
        if (m == -1 && f == -1 && r == -1) {
            break;
        }

        if (m == -1 || f == -1) {
            std::cout << "F" << std::endl;
        } else if (80 <= (m + f)) {
            std::cout << "A" << std::endl;
        } else if (65 <= (m + f)) {
            std::cout << "B" << std::endl;
        } else if (50 <= (m + f)) {
            std::cout << "C" << std::endl;
        } else if (30 <= (m + f)) {
            if (50 <= r) {
                std::cout << "C" << std::endl;
            } else {
                std::cout << "D" << std::endl;
            }
        } else {
            std::cout << "F" << std::endl;
        }
    }

    return 0;
}


Measured memory_bytes: 3084
#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
#include <algorithm>
using namespace std;
const int INFINITY_HAHA = 999999;

typedef struct status {
    int from, to, speed;
    double time;
    status(int x, int x2, double y, int z): from(x), to(x2), time(y), speed(z) {}
} CurrentStatus;


struct cmp_statue {
    bool operator() (const CurrentStatus &a, const CurrentStatus &b) {
        return a.time > b.time;
    }
};


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

    int ncities, nroads;
    while(scanf("%d%d", &ncities, &nroads) != EOF && !(ncities == 0 && nroads == 0)) {

        int visited[50][50][50];
        priority_queue< CurrentStatus, vector<CurrentStatus>, cmp_statue > Q;

        vector< vector<int> > path_cost(ncities + 1, vector<int>(ncities + 1, -1) );
        vector< vector<int> > path_limit(ncities + 1, vector<int>(ncities + 1, -1) );

        memset(visited, 0, sizeof(visited));

        // Input
        int start_index, end_index;
        scanf("%d%d" , &start_index, &end_index);

        for(int n = 0; n < nroads; ++n) {
            int x, y, d, c;
            scanf("%d%d%d%d", &x, &y, &d, &c);
            path_cost[x][y] = path_cost[y][x] = d;
            path_limit[x][y] = path_limit[y][x] = c;
        }

        double minimun_v = 0;
        Q.push(CurrentStatus(start_index, start_index, 0.0, 0));

        while(!Q.empty()) {
            CurrentStatus cs = Q.top();
            Q.pop();

            if(cs.to == end_index && cs.speed == 1) {
                minimun_v = cs.time;
                break;
            }

            if(visited[cs.from][cs.to][cs.speed]) continue;

            visited[cs.from][cs.to][cs.speed] = 1;

            for(int j = 1; j <= ncities; ++j) {
                if(path_cost[cs.to][j] == -1) continue;
                if(j == cs.from) continue;
                

                for(int z = -1; z <= 1; ++z) {
                    if(!visited[cs.to][j][cs.speed + z] && cs.speed + z >= 1 && cs.speed + z <= path_limit[cs.to][j]) {
                        Q.push(CurrentStatus(cs.to, j, cs.time + ((double)path_cost[cs.to][j])/(cs.speed + z), cs.speed + z));
                    }
                }
            }
        }

        if(minimun_v) {
            printf("%0.5lf\n", minimun_v);
        } else {
            printf("unreachable\n");
        }
    }

    return 0;
}

Measured memory_bytes: 15768
#include<bits/stdc++.h>
using namespace std;
#define int long long 
const int mxN=2e6+10,M=1e9+7;
int mod(int a,int M){int ret=a%M; if(ret<0)ret+=M;return ret;}
int exp(int a,int b,int M){
    if(b==0LL)return 1LL;
    if(b==1LL)return mod(a,M);
    int t=exp(a,b/2,M);
    if(b%2)return mod(a*mod(t*t,M),M);
    return mod(t*t,M);
}



int a,b;
int fat[mxN];
int x,y;
int32_t main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    fat[0]=1LL;
    for(int i=1;i<=mxN;i++){
        fat[i]=mod(fat[i-1]*mod(i,M),M);
    }
    cin>>x>>y;
    if((x+y)%3!=0){
        cout<<0;
        return 0;
    }
    //achar movimentos a e b
    a=(2*y-x)/3;
    b=(2*x-y)/3;
    if(a<0 || b<0){
        cout<<0;
        return 0;
    }
    //cout<<a<<" "<<b<<"\n";
    //cout<<fat[a+b]<<"\n";
    //cout<<fat[a]<<" "<<fat[b]<<"\n";
    int resp=mod(mod(fat[a+b]*exp(fat[a],M-2,M),M)*exp(fat[b],M-2,M),M);
    cout<<resp;



}

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

#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define endl '\n'

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

const int INF = 1e9;
const int MOD = 1e9 + 7;
const int MAXN = 2e5 + 5;

ll N, K, A[MAXN];

bool chk(ll x) {
	ll tot = 0;
	for(int i=1; i<=N; i++) {
		ll cnt = A[i] / x;
		if(A[i] % x) cnt++;
		tot += cnt-1;
	}
	return tot <= K;
}

int main() {
	ios::sync_with_stdio(0); cin.tie(0);
	cin >> N >> K;
	for(int i=1; i<=N; i++) cin >> A[i], A[i] *= 2;

	ll l = 1, r = 2e9, ans = 2e9;
	while(l <= r) {
		ll m = l + r >> 1;
		if(chk(m)) {
			ans = m;
			r = m - 1;
		}
		else l = m + 1;
	}
	if(ans % 2) ans++;
	cout << ans / 2;
}


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

int main() {

    int h,w;

    cin >> h >> w;

    string s[h];

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

    for(int i=0; i<h*2; i++){
        cout << s[i/2] << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int MAXN=105;
char maze[MAXN][MAXN];
int r[MAXN],c[MAXN];
int h,w;
int main(){
	scanf("%d%d",&h,&w);
	getchar(); 
	for(int i=1;i<=h;i++){
		for(int j=1;j<=w;j++){
			scanf("%c",&maze[i][j]);
			if(maze[i][j]=='.'){
				r[i]++;c[j]++;				
			}
		}
		getchar();
	} 
	for(int i=1;i<=h;i++){
		if(r[i]==w) continue;
		for(int j=1;j<=w;j++){
			if(c[j]==h) continue;
			printf("%c",maze[i][j]);
		}
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 256
// inputに入力データ全体が入る
function Main(input) {
	
	var Input = input.split("\n");
	
  	var N = parseInt(Input[0],10);
  
    var arr = Input[1].split("")
    
    var cnt = 1
    
  	for(var i in arr){
        
      if(i == 0){
      }else{
        
      	var a = arr[parseInt(i,10)-1];
        var b = arr[i]
        if(a != b){
          cnt = cnt + 1
        }
      }
    }
  
	//出力
	console.log(cnt);
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 27052
#include <iostream>
#include<stdio.h>
#include<ctype.h>
#include<string.h>
#include <algorithm>
#include <cstring>
#include<queue>
#include <stack>
using namespace std;


int main(){
    long long a;
    cin >> a;
    if(a % 2 == 1 || a<1){
        cout << 0 << endl;
    }else{
        a/=2;
        long long sum = 0;
        while(a > 0){
            sum+=a/5;
            a/=5;
        }
        cout << sum << endl;
           }
    return 0;
}


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

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

using namespace std;

struct Node{
	Node *l,*r;
	int d,s,mn;
};

using NP=Node*;

const int poolSize=1000000;
Node buf[poolSize];
stack<NP> pool;
void InitPool(){
	REP(i,poolSize)
		pool.push(buf+i);
}

int Depth(NP x){
	return x?x->d:0;
}

int Size(NP x){
	return x?x->s:0;
}

const int inf=1145141919;

int Mini(NP x){
	return x?x->mn:inf;
}

void delNode(NP x){
	pool.push(x);
}

NP newNode(NP l,NP r,int v=inf){
	NP x=pool.top();
	pool.pop();
	*x=Node{l,r,max(Depth(l),Depth(r))+1,Size(l)+Size(r),min({v,Mini(l),Mini(r)})};
	return x;
}

Node Merge1(NP a,NP b,NP c){
	if(abs(max(Depth(a),Depth(b))+1-Depth(c))<=1)
		return Node{newNode(a,b),c};
	else if(abs(max(Depth(b),Depth(c))+1-Depth(a))<=1)
		return Node{a,newNode(b,c)};
	Node ret=Node{newNode(a,b->l),newNode(b->r,c)};
	delNode(b);
	return ret;
}

Node Merge2(NP a,NP b){
	if(Depth(a)==Depth(b))
		return Node{a,b};
	else if(Depth(a)>Depth(b)){
		Node m=Merge2(a->r,b);
		Node ret=Merge1(a->l,m.l,m.r);
		delNode(a);
		return ret;
	}else{
		Node m=Merge2(a,b->l);
		Node ret=Merge1(m.l,m.r,b->r);
		delNode(b);
		return ret;
	}
}

NP Merge(NP a,NP b){
	if(!a)
		return b;
	if(!b)
		return a;
	Node m=Merge2(a,b);
	return newNode(m.l,m.r);
}

Node Split(NP x,int k){
	if(k<=0)
		return Node{NULL,x};
	if(Size(x)<=k)
		return Node{x,NULL};
	if(k<=Size(x->l)){
		Node s=Split(x->l,k);
		Node ret=Node{s.l,Merge(s.r,x->r)};
		delNode(x);
		return ret;
	}else{
		Node s=Split(x->r,k-Size(x->l));
		Node ret=Node{Merge(x->l,s.l),s.r};
		delNode(x);
		return ret;
	}
}

void Update(NP x,int k,int v){
	if(Size(x)==1){
		x->mn=v;
		return;
	}
	if(k<Size(x->l))
		Update(x->l,k,v);
	else
		Update(x->r,k-Size(x->l),v);
	x->mn=min(Mini(x->l),Mini(x->r));
}

int read(){
	int i;
	scanf("%d",&i);
	return i;
}

NP t[200000];

int main(){
	InitPool();
	int n=read(),q=read();
	REP(i,n){
		t[i]=newNode(NULL,NULL,read());
		t[i]->s=1;
	}
	while(n>1){
		int k=n/2;
		REP(i,k)
			t[i]=Merge(t[i*2],t[i*2+1]);
		if(k*2<n)
			t[k]=t[k*2];
		n=(n+1)/2;
	}
	NP root=t[0];
	REP(_,q){
		int x=read(),y=read(),z=read();
		if(x==0){
			Node s1=Split(root,y);
			Node s2=Split(s1.r,z+1-y-1);
			Node s3=Split(s2.r,1);
			root=Merge(Merge(s1.l,s3.l),Merge(s2.l,s3.r));
		}else if(x==1){
			Node s1=Split(root,y);
			Node s2=Split(s1.r,z+1-y);
			printf("%d\n",Mini(s2.l));
			root=Merge(s1.l,Merge(s2.l,s2.r));
		}else if(x==2){
			Update(root,y,z);
		}
	}
}

Measured memory_bytes: 22284
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        String S = sc.next();
        int max = 0;
        //区切るところを変えて探す
        for (int i=1;i<N;i++){
            String str1 = S.substring(0,i);
            String str2 = S.substring(i);
            int count = 0;
            //アルファベットあるかな
            boolean[] ar1 = new boolean[26];
            boolean[] ar2 = new boolean[26];
            for (int j=0;j<str1.length();j++){//前半
                ar1[str1.charAt(j)-'a']=true;
            }
            for (int j=0;j<str2.length();j++){//後半
                ar2[str2.charAt(j)-'a']=true;
            }
            for (int j=0;j<26;j++){//両方にあるか
                if (ar1[j]&&ar2[j]){
                  count++;
                }
            }
            max = Math.max(max,count);
        }
        System.out.println(max);
    }
}

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

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

using namespace std;

int main(){
	int n,x; scanf("%d%d",&n,&x);
	if(x==1 || x==2*n-1) puts("No");
	else{
		puts("Yes");
		vector<int> sign(2*n-1);
		if(x<=n){
			fill(sign.begin(),sign.end(),1);
			rep(i,x-1) sign[n+i]=-1;
		}
		else{
			fill(sign.begin(),sign.end(),-1);
			rep(i,(2*n-1)-x) sign[n+i]=1;
		}
		sign[n-1]=0;

		int large=x+1,small=x-1;
		rep(i,2*n-1){
			if     (sign[i]>0) printf("%d\n",large), large++;
			else if(sign[i]<0) printf("%d\n",small), small--;
			else               printf("%d\n",x);
		}
	}

	return 0;
}


Measured memory_bytes: 2304
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, n) for(int i=0; i<int(n); i++)
#define RNG(i, f, t) for(int i=int(f); i<=int(t); i++)
#define REV(i, f, t) for(int i=int(f); i>=int(t); --i)
#define ALL(v) (v).begin(), (v).end()
bool RELAXED = false;
template<int,typename T> struct MINMAX{ T val; MINMAX(T val) : val(val) {} };
template<typename T> MINMAX<1,T> MAX(T val) { return MINMAX<1,T>(val); };
template<typename T> MINMAX<2,T> MIN(T val) { return MINMAX<2,T>(val); };
template<typename T, typename U> inline T& operator|=(T &lhs, MINMAX<1,U> rhs) { return lhs = (rhs.val > lhs ? (RELAXED=true,rhs.val) : (RELAXED=false,lhs)); }
template<typename T, typename U> inline T& operator|=(T &lhs, MINMAX<2,U> rhs) { return lhs = (rhs.val < lhs ? (RELAXED=true,rhs.val) : (RELAXED=false,lhs)); }
template<typename T> inline vector<T> readVector(int n) { vector<T> vec(n); FOR(i,n) cin>>vec[i]; return vec; }
template<typename T> void EXIT(T answer) { cout<<answer<<endl; exit(0); }
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pii> vpii;
typedef signed long long int ll;

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

    int n; cin>>n;
    vector<ll> a = readVector<ll>(n);
    ll sum = accumulate(ALL(a), 0LL);
    ll best=sum;
    ll cur=0;
    FOR(i,n) {
        cur += a[i];
        sum -= a[i];
        best |= MIN(abs(sum-cur));
    }
    cout<<best<<endl;
    return 0;
}



Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#define FOR(i,b,e) for(int i=b;i<e;i++)
#define REP(i,n) FOR(i,0,n)
using namespace std;

int dp[1001][1001];
string s1, s2;

int lcs(int n1, int n2) {
  if (dp[n1][n2] != -1) return dp[n1][n2];
  
  dp[n1][n2] = (s1[n1-1] == s2[n2-1]) ? (1 + lcs(n1 - 1, n2 - 1)) : max(lcs(n1 - 1, n2), lcs(n1, n2 - 1));
  return dp[n1][n2];
}

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


  int q; cin >> q;
  REP(i, q) {
    REP(i, 1001) {
      REP(j, 1001) {
        dp[i][j] = -1;
      }
    }
    REP(i, 1001) dp[i][0] = 0;
    REP(i, 1001) dp[0][i] = 0;

    cin >> s1;
    cin >> s2;

    cout << lcs(s1.length(), s2.length()) << endl;
  }
}

Measured memory_bytes: 7244
import java.util.*;
public class Main {
  public static void main(String[] args){

    Scanner sc = new Scanner(System.in);
    int A = sc.nextInt();
    String op = sc.next();
    int B = sc.nextInt();


    if (op.equals("+")) {
      System.out.println(A + B);
    } else {
      System.out.println(A - B);
    }

  }
}

Measured memory_bytes: 22608
#include <iostream>
#include <set>

using namespace std;
int main(){
  int n,m;cin>>n>>m;
  bool ok = false;
  set<int> s;
  for(int i = 0; m > i; i++){
    int a,b;cin>>a>>b;
    if(a == 1 || a == n){
      if(s.count(b) == 1)ok = true;
      s.insert(b);
    }
    if(b == 1 || b == n){
      if(s.count(a) == 1)ok = true;
      s.insert(a);
    }
  }
  cout << (ok ? "POSSIBLE" : "IMPOSSIBLE") << endl;
}

Measured memory_bytes: 9600
import java.io.*;
import java.util.*;


class Main {
    public static void main(String[] args) {
        MyScanner sc = new MyScanner();
        out = new PrintWriter(new BufferedOutputStream(System.out));
        double a=sc.nextDouble();
        double b=sc.nextDouble();
        out.println(a*b/(a+b));
        out.close();
    }
    // http://codeforces.com/blog/entry/7018
    //-----------PrintWriter for faster output---------------------------------
    public static PrintWriter out;
    //-----------MyScanner class for faster input----------
    public static class MyScanner {
        BufferedReader br;
        StringTokenizer st;
        public MyScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }
        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
        int nextInt() {
            return Integer.parseInt(next());
        }
        long nextLong() {
            return Long.parseLong(next());
        }
        double nextDouble() {
            return Double.parseDouble(next());
        }
        String nextLine(){
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
}


Measured memory_bytes: 21460
# ==================================================-
# 最大公約数n個
def euclid(a, b):
    if b == 0:
        return a
    else:
        return euclid(b, a % b)


def multiple(a, b):
    return a * b // euclid(a, b)


import functools


# ------メイン関数-------
# numsは整数のリスト
def lcm(nums):
    return functools.reduce(multiple, nums)

a=[]

n=int(input())
for i in range(n):
    a.append(int(input()))

print(lcm(a))

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

int main()
{
    int n,i,c=0,d=0;
    string s;

    cin>>n>>s;

    for(i=0;i<n;i++){
        if(s[i]=='R'){
            c++;
        }
    }
    d=c;
    for(i=0;i<c;i++){
        if(s[i]=='R'){
            d--;
        }
    }
    cout<<d<<endl;

    return 0;
}




Measured memory_bytes: 3692
n = int(input())

A = [0]*(n+1)
for i in range(1,n+1):
  for j in range(1,n+1):
    if i*j > n:
      break
    A[i*j]+=1
    
ans = 0
for i in range(1,n+1):
  ans += i*A[i]
  
print(ans)  

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

using namespace std;
using ll = long long;

int main() {
    ll n,k;
    cin>>n>>k;
    if(n<=k) {
        cout<<min(n,k-n)<<endl;
    }
    else {
        ll b=n%k;
        cout<<min(b,k-b)<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast","unroll-loops","omit-frame-pointer","inline") //Optimization flags
#pragma GCC option("arch=native","tune=native","no-zero-upper") //Enable AVX
#pragma GCC target("avx2") //Enable AVX

#include <bits/stdc++.h>
#define db(x) cout << (x) << '\n';
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define f first
#define s second
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pii;
typedef pair<double,ll> pdi;
typedef pair<ld,ld> pdd;
typedef pair<double,ll> pdi;
typedef pair<double,pii> pdp;
typedef pair<string,ll> psi;
typedef pair<ll,string> pls;
typedef pair<string,string> pss;
typedef pair<ll,pii> pip;
typedef pair<pii,pii> ppp;
typedef complex<ld> point;
#define mod (ll)(998244353)
#define eps (1e-9)
#define oo (ll)(0x3f3f3f3f)
#define pi acos(-1)
#define MAXN (ll)(6e2+5)

ll dp[MAXN/2][MAXN/2][MAXN];
ll ac[2][MAXN/2][2*MAXN];
ll aci[2][MAXN/2][2*MAXN];
ll sz[MAXN];

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

    string s;
    int k;
    cin >> s >> k;
    k=min(k,300);
//    k=2*k;
    int n=s.size();
    int ty=0,cant=0,pos=0;
    for(int i=0;i<n;i++)
    {
        if(s[i]=='0')
        {
            if(ty==0)
                sz[pos]=0;
            else
                sz[pos]=cant;
            pos++;
            cant=-1;
        }
        cant++;
        ty=(s[i]-'0');
    }
    if(ty==1)
    {
        sz[pos]=cant;
        pos++;
    }

//    for(int i=0;i<pos;i++)
//        cout << sz[i] << '\n';

    dp[0][0][0]=1;
    ac[0][1][0]=1; ///i+j
    aci[0][1][600]=1; ///i-j
    for(int i=1;i<MAXN/2;i++)
    {
        aci[0][i][600]=1;
        ac[0][i][0]=1;
    }
    for(int i=1;i<=pos;i++)
    {
        int act=(i-1)&1;
        int tar=1-act;
//        db("")
//        db(i)
        for(int j=0;j<=k;j++)
            for(int u=j;u<=2*k;u++)
            {
                ll s1=(ac[act][min(j+sz[i-1]+1,(ll)k+2)][j+u]-ac[act][j][j+u]+mod)%mod;
                ll s2=(aci[act][j+1][j-u+600]-aci[act][0][j-u+600]+mod)%mod;
//                cout << j << ' ' << u << '\n';
//                cout << s1 << ' ' << s2 << '\n';
//                db("")
                dp[i][j][u]=(s1+s2-dp[i-1][j][u]+mod)%mod;
                ac[tar][j+1][j+u]=dp[i][j][u];
                aci[tar][j+1][j-u+600]=dp[i][j][u];
            }
        for(int j=0;j<MAXN/2;j++)
            for(int u=0;u<2*MAXN;u++)
                aci[act][j][u]=ac[act][j][u]=0;
        for(int u=0;u<2*MAXN;u++)
            for(int j=1;j<MAXN/2;j++)
            {
                aci[tar][j][u]=(aci[tar][j-1][u]+aci[tar][j][u])%mod;
                ac[tar][j][u]=(ac[tar][j-1][u]+ac[tar][j][u])%mod;
            }
    }

//    for(int i=0;i<=pos;i++)
//    {
//        db("")
//        db(i)
//        for(int j=0;j<=k;j++)
//        {
//            for(int u=0;u<=2*k;u++)
//                cout << dp[i][j][u] << ' ';
//            cout << '\n';
//        }
//    }

    ll res=0;
    for(int i=0;i<=2*k;i+=2)
        res=(res+dp[pos][0][i])%mod;
    db(res)

    return 0;
}
/**
0101 1
**/


Measured memory_bytes: 230392
#include <stdio.h>

int main(void){
	int k,s,res=0;
	int x,y,z;
	scanf("%d %d",&k,&s);
	for(x=0;x<=k;x++){
		for(y=0;y<=k;y++){
			z = s - x - y;
			if(0<=z && z<=k)res++;
		}
	}
	printf("%d\n",res);	
}

Measured memory_bytes: 128
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#define rep(i,a,n) for(ll i =(a);i<(n);i++)
#define urep(i,a,n) for(ll i = (a);i>=(n);i--)
#define all(x) (x).begin(),(x).end()
#define INF 1e30
const int mod = 1e9 + 7;
typedef long long ll;
using namespace std;
ll dx[4] = { 1,-1,0,0 };
ll dy[4] = { 0,0,1,-1 };
ll N, M, Q, H, W, D, L, R, K, X, A, B, C, Z;
ll ans;
string S;
ll x[100000000];
ll y[100000000];
ll nowcost = 1;
ll gcd(ll a, ll b) {
	if (b == 0)return a;
	else return gcd(b, a%b);
}
ll DP[1000001];
int main() {
	cin >> N >> K;
	ans = INF;
	rep(i, 0, N) {
		cin >> x[i] >> y[i];
	}
	rep(i, 0, N) {
		rep(j, 0, N) {
			rep(k, 0, N) {
				rep(l, 0, N) {
					ll count = 0;
					rep(m, 0, N) {
						if (x[m] <= max(x[i], x[j]) && min(x[i], x[j]) <= x[m] && y[m] <= max(y[k], y[l]) && min(y[k], y[l]) <= y[m]) {
							count++;
						}
					}
					if (K <= count) {
						ans = min(ans, abs(x[i] - x[j])*abs(y[k] - y[l]));
					}
				}
			}
		}
	}
	cout << ans << endl;
	cin >> ans;
	return 0;
}

Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;
//巡回セールスマン問題
int main(){
	int v,e;cin>>v>>e;
	vector<vector<int>> d(v,vector<int>(v,INF));
	for(int i = 0; i < e; i++) {
		int s,t,D;cin>>s>>t>>D;
		d[s][t] = D;
	}

	vector<vector<ll>> dp(1 << v,vector<ll>(v + 1,INF));
	dp[(1 << v) - 1][0] = 0;
	for(int s = (1 << v) - 2; s >= 0; s--) {
		for(int j = 0; j < v; j++) {
			for(int k = 0; k < v; k++) {
				if (!((s >> k) & 1)){
					dp[s][j] = min(dp[s][j], dp[s|(1 << k)][k] + d[j][k]);
				}
			}
		}
	}
	if (dp[0][0] == INF){
		cout << -1 << endl;
	}
	else{
		cout << dp[0][0] << endl;
	}

	// for(int i = 0; i < (1 << v); i++) {
	// 	for(int j = 0; j < v; j++) {
	// 		cout << dp[i][j] << " ";
	// 	}
	// 	cout << endl;
	// }
	// for(int i = 0; i < v; i++) {
	// 	for(int j = 0; j < v; j++) {
	// 		cout << d[i][j] << " ";
	// 	}
	// 	cout << endl;
	// }
	return 0;
}


Measured memory_bytes: 8092