akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;

class Program
{
    static string InputPattern = "InputX";

    static List<string> GetInputList()
    {
        var WillReturn = new List<string>();

        if (InputPattern == "Input1") {
            WillReturn.Add("5");
            WillReturn.Add("3");
            WillReturn.Add("10000");
            WillReturn.Add("9000");
            //48000
        }
        else if (InputPattern == "Input2") {
            WillReturn.Add("2");
            WillReturn.Add("3");
            WillReturn.Add("10000");
            WillReturn.Add("9000");
            //20000
        }
        else {
            string wkStr;
            while ((wkStr = Console.ReadLine()) != null) WillReturn.Add(wkStr);
        }
        return WillReturn;
    }

    static void Main()
    {
        List<string> InputList = GetInputList();
        int N = int.Parse(InputList[0]);
        int K = int.Parse(InputList[1]);
        int X = int.Parse(InputList[2]);
        int Y = int.Parse(InputList[3]);

        int Answer=0;
        for (int I = 1; I <= N; I++) {
            if (I <= K) Answer += X;
            else Answer += Y;
        }
        Console.WriteLine(Answer);
    }
}


Measured memory_bytes: 2904
N, M, X, Y = map(int, input().split())
xs = list(map(int, input().split()))
ys = list(map(int, input().split()))

xs.append(X)
ys.append(Y)

if max(xs) >= min(ys):
  war = "War"
else:
  war = "No War"

print(war)

Measured memory_bytes: 3060
#pragma GCC optimize ("Ofast")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
using namespace std;

// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
// template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

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

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define all(x) begin(x), end(x)
#define sz(x) (int) x.size()

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)
#define trav(a,x) for (auto& a: x)

const int MOD = 1e9+7; // 998244353;
const int MX = 2e5+5;
const ll INF = 1e18;
const ld PI = acos((ld)-1);
const ld EPS = 1e-6;
const int dx[4] = {1,0,-1,0}, dy[4] = {0,1,0,-1};
const char nl = '\n';

template <typename T> inline T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template <typename T> inline T lcm(T a, T b) { return a / gcd(a, b) * b; }
template <class T> void ckmin(T& a, T b) { a = min(a, b); }
template <class T> void ckmax(T& a, T b) { a = max(a, b); }

// (Integer/Long).bitCount(x)
int pct(int x) { return __builtin_popcount(x); }
int pct(ll x) { return __builtin_popcountll(x); }

void DBG() { cerr << "]" << endl; }
template<class H, class... T> void DBG(H h, T... t) { cerr << h; if (sizeof...(t)) cerr << ", "; DBG(t...); }

void setIn(string s) { freopen(s.c_str(),"r",stdin); }
void setOut(string s) { freopen(s.c_str(),"w",stdout); }
void unsyncIO() { ios_base::sync_with_stdio(0); cin.tie(0); }
void setIO(string s = "") {
	unsyncIO();
	if (sz(s)) { setIn(s+".in"), setOut(s+".out"); }
}

// Binary Exponentiation
ll pow(ll b, ll e, ll m = 0LL, ll ans = 1LL) { while (e) { if (e & 1LL) { ans *= b; if (m) ans %= m; } b *= b, e >>= 1LL; if (m) b %= m; } return ans; }



void solve(int tcn) {
	int m;
	cin >> m;
	int c = 7 % m;
	FOR(i, 1, 1e7) {
		if (c == 0) {
			cout << i << nl;
			return;
		}
		c = c * 10 + 7;
		c %= m;
	}
	cout << -1 << nl;
}

int main() {
    setIO();

    int t = 1; //cin >> t;
	for (int i = 1; i <= t; ++i) {
		//cout << "Case #" << i << ": ";
		solve(i);
	}
	return 0;
}

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

#[allow(dead_code)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

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

#[allow(dead_code)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

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

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

fn main() {
    input!{
        x: usize,
        a: usize
    }
    let result = if x < a {
        0
    } else {
        10
    };
    println!("{}", result);
}


Measured memory_bytes: 4352
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees#, log2
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
A = [INT() for _ in range(N)]	

dic = defaultdict(int)

for a in A:
	dic[a] += 1

#print(dic)
print(len([1 for x in dic if dic[x]%2]))
	


Measured memory_bytes: 18360
import itertools
a, b, c, d = input()
ops = ("+", "-")
for op1, op2, op3 in itertools.product(ops, repeat=3):
    eq = a + op1 + b + op2 + c + op3 + d
    if eval(eq) == 7:
        print(eq + "=7")
        break

Measured memory_bytes: 3060
from bisect import bisect
from bisect import bisect_right
from bisect import bisect_left
 
N = int(input())
L = list(map(int, input().split()))
L.sort()
#print(L)
 
cnt = 0
for i in range(N):
  for j in range(i+1, N):
    s = L[i] + L[j]
    x = bisect_left(L, s)
    #print((L[i], L[j]), s, x)
    cnt += max(x - j - 1, 0)
print(cnt)

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

ll binpow(ll a,ll b)
{
	if(b==0)
		return 1;
	if(b%2==0)
	{
		return (binpow(a,b/2)*binpow(a,b/2))%modulo;
	}
	else
	{
		return (((binpow(a,b/2)*binpow(a,b/2))%modulo)*a)%modulo;
	}
}

ll moduloinverse(ll a)
{
	return binpow(a,modulo-2)%modulo;
}

ll factorial(ll n)
{
	long long temp=1;
	for(ll i=n;i>=1;--i)
	{
		temp=(temp*i)%modulo;
	}
	return temp%modulo;
}

ll factorial1(ll n,ll b)
{
	long long temp=1;
	for(ll i=n;i>=(b+1);--i)
	{
		temp=(temp*i)%modulo;
	}
	return temp%modulo;
}
ll com(ll n,ll r)
{
	if(r==0)
		return 1;
    ll temp=std::max(r,n-r);
    ll temp1=std::min(r,n-r);
	long long a=factorial1(n,temp);
	long long b=factorial(temp1);
	return (a*moduloinverse(b))%modulo;
}



int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n,a,b;
    cin>>n>>a>>b;
    //cout<<moduloinverse(n)<<endl;
    ll temp=binpow(2,n);
    temp--;
    temp=(temp-com(n,a)-com(n,b))%modulo;
    cout<<(temp+modulo)%modulo<<endl;
}


Measured memory_bytes: 256
fn read_line() -> String {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim_right().to_owned()
}

fn main() {
    read_line();
    let mut v: Vec<usize> = read_line().split_whitespace().map(|x| x.parse().unwrap()).collect();
    v.sort();

    let mid = v.len() / 2;
    println!("{}", v[mid] - v[mid - 1]);
}


Measured memory_bytes: 6396
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> P;
map <char,int> mp;
vector<int> V;
#define INF (1<<29)
#define INFLL (1ll<<58)
#define EPS (1e-10)
static const int MAX=1e5;
static const int MOD=1e9+7;
static const int NMAX=50;
static const int MMAX=50;
int dx[4]={0,1,0,-1},dy[4]={-1,0,1,0};
bool flag[30];
int cunt[101],cc[101];
string s;

void solve(){
    for(int i=0;i<s.size();i++){
        mp[s[i]]++;
    }
    for(int i=0;i<s.size();i++){
        
        if(mp[s[i]]==1&&!flag[s[i]-'a']){
            cc[i]=cc[i-1];
            continue;
        }
        mp[s[i]]--;
        if(mp[s[i]]>0&&!flag[s[i]-'a'])cunt[i]=1;
        else if(mp[s[i]]==0) cunt[i]=-1;
        flag[s[i]-'a']=true;
        if(i==0){
            cc[0]=cunt[0];
            continue;
        }
        cc[i]=cunt[i]+cc[i-1];
    }

    int max_n=-INF;
    for(int i=0;i<s.size();i++){
        max_n=max(max_n,cc[i]);
    }
    cout<<max_n<<"\n";
}
    
int main(){
    cin.tie(0);  ios::sync_with_stdio(false);
    int n;
    cin>>n>>s;
    
    solve();
    
    return 0;
}


Measured memory_bytes: 256
// 3_abc113_c
#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>// C++
#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>

using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
#define SZ(x) ((int)(x).size())
#define INF (1e16)
#define MOD (1000000007)
typedef long long ll;

void print_num(int x){
    if(x >= 100000){
        // do nothing
    }else if(x >= 10000) cout << "0";
    else if(x >= 1000) cout << "00";
    else if(x >= 100) cout << "000";
    else if(x >= 10) cout << "0000";
    else cout << "00000";

    cout << x;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    vector<pair<pair<int,int>, int>> v(m);
    rep(i, m){
        int p, y;
        cin >> p >> y;
        v[i].first = make_pair(p, y);
        v[i].second = i + 1;
    }
    sort(v.begin(), v.end());

    v[0].first.second = 1;
    for(int i = 1; i < m; i++){
        if(v[i].first.first == v[i - 1].first.first){
            v[i].first.second = v[i - 1].first.second + 1;
        }else{
            v[i].first.second = 1;
        }
    }

    vector<pair<int, pair<int, int>>> tmp(m);
    rep(i, m){
        tmp[i].first = v[i].second;
        tmp[i].second = v[i].first;
    }
    sort(tmp.begin(), tmp.end());

    rep(i, m){
        int p = tmp[i].second.first;
        int y = tmp[i].second.second;
        print_num(p);
        print_num(y);
        cout << endl;
    }

    return 0;
}


Measured memory_bytes: 3840
def main():
    n = int(input())
    v = input().split(" ")
    even = {}
    odd = {}
    for i in range(n):
        if i % 2 == 0:
            even.setdefault(v[i], 0)
            even[v[i]] += 1
        else:
            odd.setdefault(v[i], 0)
            odd[v[i]] += 1
    even = sorted(even.items(), key=lambda x: x[1], reverse=True)
    odd = sorted(odd.items(), key=lambda x: x[1], reverse=True)
    # print(even,odd)
    if even[0][0] == odd[0][0]:
        if len(even) > 1 and len(odd) > 1:
            print(n - int(even[0][1]) - max(even[1][1], odd[1][1]))
        elif len(even) > 1:
            print(n - odd[0][1] - even[1][1])
        elif len(odd) > 1:
            print(n - even[0][1] - odd[1][1])
        else:
            print(n // 2)
    else:
        print(n - int(even[0][1]) - int(odd[0][1]))


if __name__ == '__main__':
    main()

Measured memory_bytes: 20192
#include <stdio.h>


int Compare(int *A, int n, int *B, int m)
{
	int min;
	int i;

	if(m > n)
		min = n;
	else
		min = m;

	for(i = 0; i < min; i++){
		if(A[i] < B[i])
			return -1;
		else if(A[i] > B[i])
			return 1;
	}

	if(n < m)
		return -1;
	else if(m < n)
		return 1;

	return 0;
}


int main()
{
	int A[1000], B[1000];
	int judge;
	int n, m;
	int num;
	int i;

	scanf("%d", &n);
	for(i = 0; i < n; i++)
		scanf("%d", &A[i]);

	scanf("%d", &m);
	for(i = 0; i < m; i++)
		scanf("%d", &B[i]);

	judge = Compare(A, n, B, m);
	if(judge < 0)
		printf("1\n");
	else
		printf("0\n");


	return 0;
}


Measured memory_bytes: 2112
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pb push_back
#define mk make_pair
#define v_sort(x) sort(x.begin(),x.end())
#define v_gsort(x) sort(x.begin(),x.end(),greater<int>())
#define PI 3.14159265
#define MOD 998244353

using namespace std;

void Solve(){
   int n,m,k;
   cin>>n>>m>>k;
   for(int a=0;a<=m;a++){
     for(int b=0;b<=n;b++){
       if(k==a*n+b*m-2*a*b) {cout<<"Yes\n";return;}
     }
   }
   cout<<"No\n";
}

int main(){
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  int t=1;
//  cin>>t;
  while(t--){
      Solve();
  }
  return 0;
}


Measured memory_bytes: 3652
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		String[] strings = new String[Integer.parseInt(scanner.nextLine().split(" ")[0])];

		for(int i = 0; i < strings.length; i++) {
			strings[i] = scanner.nextLine();
		}

		System.out.println(Arrays.stream(strings).sorted().collect(
				StringBuilder::new, StringBuilder::append, StringBuilder::append).toString());
	}
}

Measured memory_bytes: 27092
#include<cstdio>

int main(){
    long long n;
    scanf("%lld",&n);
    long long ans = n-1;
    for(long long i = 2; i*i<=n; i++){
        if(n%i==0){
            long long j = n/i;
            if(i+j-2<ans) ans = i+j-2;
        }
    }
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define pvec(v) rep(i,v.size()){cout << v[i] << " ";};cout<<endl;
#define pb push_back
#define pf push_front
#define mod 1e9+7
#define m_p make_pair
 
typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<int,int> pr;
typedef vector<pr> vpr;
typedef vector<vector<int>> vvi;
const double pi = acos(-1.0);
 
ll gcd(ll x, ll y) { return (y == 0) ? x : gcd(y, x % y); }
ll lcm(ll x, ll y) { return x * y / gcd(x, y); }

bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false;

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return false;
        }
    }
    return true;
}

int main()
{
    ll n,m,l,r,ans=0;
    cin >> n >> m;
    ll x[100002];
    rep(i,100001) x[i]=0;
    rep(i,m){
        cin >> l >> r;
        x[l]++;
        x[r+1]--;
    }
    for(int i=2;i<100001;i++) x[i]=x[i]+x[i-1];
    for(int i=1;i<100001;i++){
        if(x[i]==m) ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include<algorithm>
#include <string>
#include <vector>
#include <queue>
using namespace std;
int h[25][2];

int main()
{
	int n;
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> h[i][0];
	}
	int ans = 0;
	for (int i = 1; i <= n; i++) {
		cin >> h[i][1];
		if (h[i][0] - h[i][1] > 0)ans += h[i][0] - h[i][1];
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define len(v) ll(v.size())

template <class T>
void cout_vec(const vector<T> &vec){
  for(auto itr:vec) cout<<itr<<' ';
  cout<<'\n';
}

typedef pair<ll,ll> P;
const ll mod=1e9+7;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,k;
    cin>>n>>k;
    double ans=0;
    FOR(i,1,n+1){
      ll now=i;
      ll cnt=0;
      while(now<k){
        now*=2;
        cnt++;
      }
      ll x=n*pow(2,cnt);
      ans+=(double)1/x;
      //cout<<i<<' '<<cnt<<endl;
    }
    cout<<setprecision(30)<<ans<<endl;
}

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

int main(){
    using namespace std;
    unsigned long N;
    cin >> N;
    unsigned long a{0}, n{1};
    for(unsigned long i{0}, A; i < N; ++i){
        cin >> A;
        if(A == n)++n;
        else ++a;
    }
    cout << static_cast<long>(a == N ? ~0UL : a) << endl;
    return 0;
}

Measured memory_bytes: 256
Imports System.Collections.Generic
Imports System.Console

Module Program
    Sub Main()
        Dim N As Integer = NextInt()
        Dim A As Integer = NextInt()
        Dim B As Integer = NextInt()
        Dim ans As Integer

        For i As Integer = 1 To N
            Dim SumOfDigits_i As Integer = SumOfDigits(i)
            If A <= SumOfDigits_i AndAlso SumOfDigits_i <= B Then
                ans += i
            End If
        Next

        WriteLine(ans)
    End Sub

    Function SumOfDigits(a As Integer) As Integer
        Dim result As Integer
        Do While a <> 0
            result += a Mod 10
            a \= 10
        Loop
        Return result
    End Function

    Function NextInt() As Integer
        Return CInt(NextString())
    End Function

    Function NextString() As String
        Dim result As New List(Of Char)
        Do
            Dim tmp As Integer = Read()
            If tmp < 0 Then Exit Do
            Dim nextChar As Char = Chr(tmp)

            If Not Char.IsWhiteSpace(nextChar) Then
                result.Add(nextChar)
            ElseIf nextChar <> vbCr Then
                Exit Do
            End If
        Loop
        Return New String(result.ToArray())
    End Function

End Module


Measured memory_bytes: 19920
/*
　　　  ∧＿∧　やあ
　　 （´・ω・｀)　　　　　/　　　　　ようこそ、バーボンハウスへ。
　　 ／∇y:::::＼　　　 [￣]　　　　　このテキーラはサービスだから、まず飲んで落ち着いて欲しい。
　　 |:⊃:|:::::|　　　|──|
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|　うん、「また」なんだ。済まない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|￣　  仏の顔もって言うしね、謝って許してもらおうとも思っていない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣／|
　　　　∇　∇　∇　∇　　　／.／|　　　でも、この提出を見たとき、君は、きっと言葉では言い表せない
　　　　┴　┴　┴　┴　／ ／　  |　　　「ときめき」みたいなものを感じてくれたと思う。
￣￣￣￣￣￣￣￣￣￣|／　　  |　　　殺伐としたコンテストの中で、そういう気持ちを忘れないで欲しい
￣￣￣￣￣￣￣￣￣￣　　　　 |　　　そう思って、この提出を投げたんだ。
　　　(⊆⊇)　(⊆⊇)　(⊆⊇)　　|
　    ||　　 ||　　||　　|　　　 じゃあ、判定を聞こうか。
　　.／|＼　／|＼ ／|＼
*/

#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <array>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
#define fst first
#define snd second
#define ALL(obj) (obj).begin(),(obj).end()
#define debug(x) cerr << #x << " -> " << x << " (line:" << __LINE__ << ")" << '\n';
#define debugpair(x, y) cerr << "(" << #x << ", " << #y << ") -> (" << x << ", " << y << ") (line:" << __LINE__ << ")" << '\n';
typedef long long lint;
typedef priority_queue<int> p_que;
typedef priority_queue<int, vector<int>, greater<int>()> p_que_rev;
const int INF = INT_MAX;
const lint LINF = LLONG_MAX;
const int MOD = 1000000000 + 7;
const double EPS = 1e-9;
const double PI = acos(-1);
const int di[]{0, -1, 0, 1, -1, -1, 1, 1};
const int dj[]{1, 0, -1, 0, 1, -1, -1, 1};


int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    int a, b, x;
    cin >> a >> b;
    x = 0;
    for (int i=1; i<=b-a; ++i){
        x += i;
    }
    x -= b;
    cout << x << "\n";
    return 0;
}

Measured memory_bytes: 256
using System;

class MainClass
{
	public static void Main ()
	{
	
	int i = 0;

		while (true) 
		{
			int x = int.Parse (Console.ReadLine ());
			i++;

			if (x == 0) {break;}
			Console.WriteLine ("Case " + i + ": " + x);

		}
	}
}

Measured memory_bytes: 9392
#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() {
    int n,z,w;cin>>n>>z>>w;
    int a[n];
    rep(i,n)cin>>a[i];

    int ans = abs(a[n-1]-a[n-2]);
    ans = max(ans,abs(a[n-1]-w));
    if(n==1)ans = abs(a[0]-w);
    cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 3640
#include <utility>
#include <tuple>
#include <queue>
#include <vector>
#include <iostream>
using namespace std;

bool in_range(int a, int b){
  return a >= 0 && a < b;
}

int bfs(const vector<string> &T, int sx, int sy){
  int H = T.size(), W = T[0].size();
  const int INF = 1e9;
  vector<vector<int>> D(H,vector<int>(W,INF));
  queue<pair<int,int>> Q;
  Q.emplace(sx,sy);
  D[sx][sy] = 0;
  int ret = 0;
  int dx[] = {1,0,-1,0}, dy[] = {0,1,0,-1};
  while(Q.size()){
    int x, y;
    tie(x,y) = Q.front();
    Q.pop();
    int d = D[x][y];
    for(int i = 0; i < 4; ++i){
      int x_ = x+dx[i], y_ = y+dy[i];
      if(!in_range(x_,H)) continue;
      if(!in_range(y_,W)) continue;
      if(T[x_][y_] != '.') continue;
      if(d+1 < D[x_][y_]){
        D[x_][y_] = d+1;
        Q.emplace(x_,y_);
        ret = max(ret,d+1);
      }
    }
  }
  return ret;
}

int main(){
  int H, W;
  cin >> H >> W;
  vector<string> T(H);
  for(int i = 0; i < H; ++i) cin >> T[i];
  int ans = 0;
  for(int i = 0; i < H; ++i){
    for(int j = 0; j < W; ++j){
      if(T[i][j] == '#') continue;
      ans = max(ans,bfs(T,i,j));
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repp(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define repm(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define INF (1ll<<60)
#define all(x) (x).begin(),(x).end()
typedef long long lint;
const lint MOD =1000000007;
const lint MAX = 10000000;
using Graph =vector<vector<lint>>;
typedef pair<lint,lint> P;
 
 
lint fac[MAX], finv[MAX], inv[MAX];
 
void COMinit() 
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (lint i = 2; i < MAX; i++)
    {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
long long COM(lint n, lint k)
{
    if (n < k)
        return 0;
    if (n < 0 || k < 0)
        return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
 
lint primary(lint num)
{
    if (num < 2) return 0;
    else if (num == 2) return 1;
    else if (num % 2 == 0) return 0;
 
    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return 0;
        }
    }
 
    return 1;
}
   long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
    lint lcm(lint a,lint b){
        return a/__gcd(a,b)*b;
    }
     lint gcd(lint a,lint b){
        return __gcd(a,b);
    }    
 
  int main(){
    lint n,k;
    cin>>n>>k;
    lint ma=(n-1)*(n-2)/2;
    if(k>ma){
        cout<<-1;
        return 0;
    }
    lint num=ma-k;
    cout<<num+n-1<<endl;

    rep(i,n-1){
        cout<<1<<" "<<i+2<<endl;
    }
    lint j=2;
    while(num>0){
        rep(i,min(num,n-j)){
            cout<<j<<" "<<i+j+1<<endl;
        }
        num-=(n-j);
        j++;
    }
  }
  
     


Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
#include <time.h>
#include <sys/timeb.h>
#include <cstdio>
#include <sys/time.h>

using namespace std;
#define ll long long
#define uint unsigned int
#define ulong unsigned long long int

int main(){
	
	string s;
	cin >> s;
	
	int ans = 0;
	for(auto c : s) if(c == '+') ans++; else ans--;
	cout << ans << endl;
	
	
	
    return 0;
}

Measured memory_bytes: 256
from math import ceil

# 定数
INF = float("inf")
MOD = int(1e9 + 7)

# エントリーポイント
def main():
    N, K = map(int, input().split())
    r = 0
    for n in range(1, N + 1):
        c = 0
        while n < K:
            n *= 2
            c += 1
        r += 0.5 ** c
    print(r / N)

main()


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int n,m,ans;
string a,b,str="OI";
int dp[2005][2005][2];
int main(){
  cin>>n>>m>>a>>b;
  a+='$',b+='$';  
  for(int i=n;i>=0;i--){
    for(int j=m;j>=0;j--){
      for(int k=0;k<2;k++){
        if(a[i]==str[k])dp[i][j][k]=max(dp[i][j][k],dp[i+1][j][1-k]+1);
        if(b[j]==str[k])dp[i][j][k]=max(dp[i][j][k],dp[i][j+1][1-k]+1);
      }
      dp[i][j][0]/=2;
      dp[i][j][0]*=2;
      ans=max(ans,dp[i][j][1]);
    }
  }
  cout<<ans<<endl;
  return 0;
}

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

typedef long long ll;
#define PI 3.1415926535897932384626433
#define MOD 1000000007

int main(){
    double w, h, x, y;
    cin >> w >> h >> x >> y;
    cout << w * h / 2 << " ";
    if(x == w / 2.0 && y == h / 2.0){
        cout << 1;
    }else{
        cout << 0;
    }
    cout << endl;
    return 0;
}

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

using namespace std;
typedef long long ll;
const int MAXN = 1000100;

int N;
string s;
int dig[MAXN];
int dp[MAXN][2];

int main()
{
    ios_base::sync_with_stdio(0);
    
    cin >> s;
    N = s.length();
    for (int i = 0; i < N; i++)
        dig[i+1] = s[i] - '0';
    dig[0] = 0;
    N++;
    dp[N-1][0] = dig[N-1];
    dp[N-1][1] = 10 - dig[N-1];

    for (int i = N - 2; i >= 0; i--)
    {
        dp[i][0] = min (dig[i] + dp[i+1][0], dig[i] + 1 + dp[i+1][1]);
        dp[i][1] = min (9 - dig[i] + dp[i+1][1], 10 - dig[i] + dp[i+1][0]);
    }
    cout << dp[0][0] << "\n";
}

Measured memory_bytes: 13084
#include "iostream"
#include "fstream"
#include "algorithm"
#include "iomanip"
#include "stack"
#include "queue"
#include "string"
#include "vector"
#include "map"
#include "set"
#include "list"
#include "deque"
#include "complex"
#include "bitset"
#include "cmath"
#include "unordered_set"
#include "unordered_map"
#include "iterator"
#include <ctime>
#include <cassert>
#include "numeric"
#include <cstdio>

using namespace std;

//#define f(i,n) for(int i=0; i<n;i++) 
//#define rf(i, n) for(int i=n-1;i>=0;i--)
//#define forn(i, j, n) for(int i=j; i<n; i++)
//#define ff(i, j, n) f(i, n)f(j, n)
#define pb push_back
#define maxi(a,b) a = max(a, b);
#define mini(a,b) a = min(a, b);
#define endl '\n'
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define sqr(x) ((x) * (x))
#define SZ(a) ((int)(a.size()))
#define watch(x) cout << (#x) << " = " << x << endl;
//typedef long long ll;
typedef long double ld;
#define int long long
#define double ld
typedef map<int, int> mii;
typedef pair<int, int> pii;
typedef pair<string, int> psi;
typedef pair<int, string> pis;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<pii> vpii;
typedef vector<char> vc;

template<class T>
void show(const vector<T> &a)
{
	for (T x : a)
		cout << x << " ";
	cout << endl;
}

const int sze = 3e5 + 50, oo = 1e18 + 500, mod = 1e9 + 7;
const double eps = 1e-9, PI = 2 * acos(0.0);
const int N = 1e6 + 10;
vi vertices[sze];
vi visit(sze, 0);
vc used(sze, false);
vi arr(sze, 0);
int n, m, k;
int cnt = 0;


signed main()
{
	ios::sync_with_stdio(0);
	cout.tie(0); cin.tie(0);
	/*freopen("stars.in", "r", stdin);
	freopen("stars.out", "w", stdout);*/

	string s;
	cin >> s;

	for (int i = 0; i < 3; i++)
	{
		if (s[i] == s[i + 1])
		{
			return cout << "Bad", 0;
		}
	}

	cout << "Good";
	return 0;
}

Measured memory_bytes: 12792
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define mp make_pair
#define pb push_back
#define ALL(A) A.begin(),A.end()
const long long mod=1000000007;
int gcd(int a,int b){
    if(a<b) gcd(b,a);
    while(a%b){
        int r=a%b;
        a=b;b=r;
    }
    return b;
}
int main(){
    int n;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++)
    cin>>a[i];
    int r=a[0];
    for(int i=1;i<n;i++)
    {
        r=gcd(r,a[i]);
    }
    cout<<r<<endl;
    return 0;
}

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

int main(){
    int typ, n;
    cin >> typ >> n;
    switch(typ){
        case 0:
            if (1868<=n && n<=1911) cout<<'M'<<n-1867<<endl;
            if (1912<=n && n<=1925) cout<<'T'<<n-1911<<endl;
            if (1926<=n && n<=1988) cout<<'S'<<n-1925<<endl;
            if (1989<=n && n<=2016) cout<<'H'<<n-1988<<endl;
            break;
        case 1:
            cout<<n+1867<<endl;
            break;
        case 2:
            cout<<n+1911<<endl;
            break;
        case 3:
            cout<<n+1925<<endl;
            break;
        case 4:
            cout<<n+1988<<endl;
    }
}


Measured memory_bytes: 3112
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (long long i = j; i < (long long)(n); i++)
#define _GLIBCXX_DEBUG
const ll MOD = 1000000007;
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; }
//(a+b-1)/b
//priority_queue<ll, vector<ll>, greater<ll>> q;

signed main(){
	//cout << fixed << setprecision(10);
	int n; cin>>n;
	vi a(n); rep(i,0,n)cin>>a[i];
	reverse(all(a));
	rep(i,0,n){
		cout<<a[i];
		if(i!=n-1)cout<<" ";
	}
	cout << endl;


	return 0;
}


Measured memory_bytes: 3128
n = gets.to_i
tree = Hash[(0..n-1).map {|i| [i, {}] }]
parent = Hash[(0..n-1).map {|i| [i, nil] }]
n.times do |i|
  k, *neighbours = gets.split.map(&:to_i)
  neighbours.each do |j|
    tree[i][j] = 0
    parent[j] = i
  end
end

subtree_size = Hash[(0..n-1).map {|i| [i, 1] }]
out_degree = (0..n-1).map {|i| tree[i].size }
queue = (0..n-1).select {|i| out_degree[i] == 0 }
paths = []
until queue.empty?
  i = queue.shift
  tree[i].each_key do |j|
    subtree_size[i] += subtree_size[j]
  end
  j = parent[i]
  if j
    out_degree[j] -= 1
    queue << j if out_degree[j] == 0
  end
end

# Heavy-Light Decomposition
queue = [0]
position = {}
ord = 0
until queue.empty?
  i = queue.shift
  path = [i]
  loop do
    heavy = true
    tree[i].each_key.sort_by {|j| -subtree_size[j]}.each do |j|
      if heavy
        path << j
        i = j
        heavy = false
      else
        queue << j
      end
    end
    break if heavy
  end
  path.unshift parent[path[0]] if parent[path[0]]
  (1..path.size - 1).each do |i|
    position[path[i]] = [path, i, ord]
  end
  paths << path
  ord += 1
end

position[0] = [paths[0], 0, 0]

q = gets.to_i
q.times do
  u, v = gets.split.map(&:to_i)
  path1, i, o1  = position[u]
  path2, j, o2  = position[v]
  until o1 == o2
    if o1 > o2
      path1, i, o1  = position[u = path1[0]]
    else
      path2, j, o2  = position[v = path2[0]]
    end
  end
  puts i < j ? path1[i] : path1[j]
end



Measured memory_bytes: 70000
# -*- coding: utf-8 -*-
#ARC078C
import sys
import math

n=int(input())

tmp = input().split()
hoge = list(map(lambda a: int(a), tmp))

total=0
for i in range(0,n):
	total+=hoge[i]
x=hoge[0]
y=total-x

res=abs(x-y)
#print("---")
#print(n)

for i in range(1,n-1):
	x+=hoge[i]
	y-=hoge[i]
	if(abs(x-y)<res):
		res=abs(x-y)
print(res)




Measured memory_bytes: 23800
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
typedef int64_t Int;
typedef pair<Int, Int> P;

vector<int> pow3 = {1};

int main(){
    int N; cin >> N;
    vector<Int> X(N), Y(N), P(N);
    rep(i,N) cin >> X[i] >> Y[i] >> P[i];

    rep(i,N) pow3.push_back(pow3.back() * 3);
    
    // 前処理：縦の路線・横の路線しか建てないときの各集落からの歩行距離
    vector<vector<Int>> V_only(1<<N, vector<Int>(N));
    vector<vector<Int>> H_only(1<<N, vector<Int>(N));
    rep(bit, 1<<N){
        rep(i,N){ // 集落 i からの歩行距離を計算
            Int dist_V = P[i] * abs(X[i]);
            Int dist_H = P[i] * abs(Y[i]);

            rep(j,N){
                if(bit>>j & 1){
                    dist_V = min(dist_V, P[i] * abs(X[i] - X[j]));
                    dist_H = min(dist_H, P[i] * abs(Y[i] - Y[j]));
                } 
            }

            V_only[bit][i] = dist_V;
            H_only[bit][i] = dist_H;
        }
    }

    // 全ての 3^N 通りの道路の建て方を試す．
    vector<Int> ans(N+1, 1e18);
    rep(trit, pow3[N]){
        int K = 0;

        int bitV = 0, bitH = 0;
        rep(i,N){
            if(trit / pow3[i] % 3 == 1){ 
                bitV += 1<<i; // X[i] 上に道を建てる
                K++;
            } else if (trit / pow3[i] % 3 == 2){
                bitH += 1<<i; // Y[i] 上に道を建てる
                K++;
            }
        }

        Int dist = 0;
        rep(i,N) dist += min(V_only[bitV][i], H_only[bitH][i]);
        
        ans[K] = min(ans[K], dist);
    }

    for(Int x : ans) cout << x << endl;
}


Measured memory_bytes: 13044
#include <bits/stdc++.h>
using namespace std;
 
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &vec){ os << "["; for (auto v : vec) os << v << ", "; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const deque<T> &vec){ os << "deq["; for (auto v : vec) os << v << ", "; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const set<T> &vec){ os << "{"; for (auto v : vec) os << v << ", "; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_set<T> &vec){ os << "{"; for (auto v : vec) os << v << ", "; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ", "; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ", "; os << "}"; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &pa){ os << "(" << pa.first << ", " << pa.second << ")"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << ": " << v.second << ", "; os << "}"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const unordered_map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << ": " << v.second << ", "; os << "}"; return os; }
template<typename T> void ndarray(vector<T> &vec, int len) { vec.resize(len); }
template<typename T, typename... Args> void ndarray(vector<T> &vec, int len, Args... args) { vec.resize(len); for (auto &v : vec) ndarray(v, args...); }
template<typename T> bool chmax(T &m, const T q) { if (m < q) {m = q; return true;} else return false; }
template<typename T> bool chmin(T &m, const T q) { if (q < m) {m = q; return true;} else return false; }
template<typename T1, typename T2> pair<T1, T2> operator+(const pair<T1, T2> &l, const pair<T1, T2> &r) { return make_pair(l.first + r.first, l.second + r.second); }
template<typename T1, typename T2> pair<T1, T2> operator-(const pair<T1, T2> &l, const pair<T1, T2> &r) { return make_pair(l.first - r.first, l.second - r.second); }
#define f first
#define s second
 
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int num, amount;
    cin >> num >> amount;
    amount = amount / 1000;
    for(int i = 0; i <= 2000; i++) {
        int a = i * 10;
        for(int j = 0; j <= 2000; j++) {
            int b = j * 5;
            if(a + b > amount)
                break;
            int c = amount - a - b;
            if(i + j + c == num) {
                cout << i << " " << j << " " << c;
                return 0;
            }
        }
    }
    cout << -1 << " " << -1 << " " << -1;
}

Measured memory_bytes: 3656
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+5;
int n,vis[2][N];
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
        int x;scanf("%d",&x);
        vis[i&1][x]++;
    }
    int mx1=0,p1=0,mx2=0,p2=0;
    for(int i=1;i<=100000;i++)
    {
        if(vis[0][i]>mx1) mx1=vis[0][i],p1=i;
        if(vis[1][i]>mx2) mx2=vis[1][i],p2=i;
    }
    int ans=0;
    if(p1==p2)
    {
        int m1=0,m2=0;
        for(int i=1;i<=100000;i++)
            if(i!=p1)
            m1=max(m1,vis[0][i]),m2=max(m2,vis[1][i]);
        ans=n-max(m1+mx2,m2+mx1);
    }
    else ans=n-mx1-mx2;
    printf("%d\n",ans);
}

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

char s[100001];

int main() {
	int n;
	scanf("%s", s);
	n = strlen(s);
	f(i, 1, n)if (s[i] == s[i - 1]) {
		printf("%d %d", i, i + 1);
		return 0;
	}
	f(i, 2, n)if (s[i] == s[i - 2]) {
		printf("%d %d", i - 1, i + 1);
		return 0;
	}
	printf("-1 -1");
}

Measured memory_bytes: 384
n = int(input())
a = list(map(int, input().split()))
ans = 1
cnt = [3] + [0] * n
for i in a:
    ans *= cnt[i]
    ans %= 10 ** 9 + 7
    if ans == 0:
        break
    cnt[i] -= 1
    cnt[i + 1] += 1
print(ans)

Measured memory_bytes: 14008
//In the name of Allah :)
#include <bits/stdc++.h>
using namespace std;

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

int main()
{
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	long long a, b, v, w, t;
	cin >> a >> v >> b >> w >> t;
	if(w >= v){
		cout  << "NO\n";
		return 0;
	}	
	if(abs(a - b) <= (v - w) * t){
		cout << "YES\n";
		return 0;
	}

	cout << "NO\n";
}


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

vector<ll> a(51);

ll f(ll N, ll X) {
    if (N == 0) return 1;  // はじめにパティは１枚。

    if (X == 1) return 0;  // 一番下はバン。
    if (X <= 1 + a[N-1]) return f(N-1, X-1);
    if (X <= 2 + a[N-1]) return f(N-1, a[N-1]) + 1;
    if (X <= 2 + 2 * a[N-1]) return f(N-1, a[N-1]) + 1 + f(N-1, X-a[N-1]-2);
    else return 2 * f(N-1, a[N-1]) + 1;
    // return ret;
}

int main() {
    ll N, X;
    cin >> N >> X;
    a[0] = 1;
    rep(i, 50) a[i+1] = a[i] * 2 + 3;
    cout << f(N, X) << endl;
    return 0;
}

Measured memory_bytes: 3608
n=int(input())
T=[]
for i in range(n):
    T.append(int(input()))
    
def gcd(a,b):
    while b:
        a,b=b, a%b
    return a

def lcm(a,b):
    return a*b//gcd(a,b)

T=list(set(T))
cnt=0
x=1
while True:
    x=lcm(x,T[cnt])
    cnt+=1
    if cnt==len(T):
        break

print(x)

Measured memory_bytes: 3060
/*
    Mbak Sana Dong
    Mbak Chaeyoung Dong
*/
#include <bits/stdc++.h>
#define ll long long int
using namespace std;
struct angka
{
    int o,c;
    string s;
};
struct angka node[1000010];
int chaeng;
bool desc(struct angka a, struct angka b)
{
    return a.o + a.c > b.o + b.c;
}
int main()
{
	int n,i,j,k,x,y,ans,curr,temp,m;
	int tc;
	cin >> n;
    string s;
    chaeng = 0;
    int cnt = 1;
    int sum = 0;
    int suff = 0;
    for(i=1;i<=n;i++) {
        cin >> s;
        int bal = 0;
        int mini = 0;
        int o = 0, c = 0;
        for(auto x : s) {
            if(x == '(') {
                bal++;
                o++;
            }
            else {
                bal--;
                c--;
            }
            mini = min(mini, bal);
        }
        chaeng += bal;
        if(bal == s.size()) {
            sum += bal;
        } else if(-bal == s.size()) {
            suff += bal;
        } else {
            node[cnt].o = o;
            node[cnt].c = c;
            node[cnt].s = s;
            cnt++;
        }
    }
    if(chaeng != 0) {
        cout << "No" << endl;
        return 0;
    }
    sort(node+1, node+cnt, desc);
    for(i=1;i<cnt;i++) {
        string s = node[i].s;
        for(auto x : s) {
            if(x == '(') sum++;
            else sum--;
            if(sum < 0) {
                cout << "No" << endl;
                return 0;
            }
        }
    }
    if(sum + suff == 0) {
        printf("Yes\n");
    } else {
        printf("No\n");
    }
	return 0;
}


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

using namespace std;
typedef long long ll;

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

    vector<int> x(n);
    for(int i=0;i<n;i++){
        cin >> x[i];
    }
    int max_x = *max_element(x.begin(),x.end());
    int X = max(max_x,a);
    vector<vector<vector<ll>>> dp;
    dp = vector<vector<vector<ll>>>(n+1, vector<vector<ll>>(n+1, vector<ll>((n+1)*X, 0)));
    ll ans = 0;
    dp[0][0][0] = 1;

    for(int j=1;j<n+1;j++) {
        for(int k=0;k<n+1;k++){
            for(int s=0;s<(n+1)*X;s++){
                if(j>=1 && s<x[j-1]){
                    dp[j][k][s] = dp[j-1][k][s];
                }else if(j>=1 && k>=1 && s>=x[j-1]){
                    dp[j][k][s] = dp[j-1][k][s] + dp[j-1][k-1][s-x[j-1]];
                }
            }
        }
    }
    for(int k=1;k<n+1;k++){
        ans += dp[n][k][k*a];
    }
    cout << ans << "\n";
}


Measured memory_bytes: 53248
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)

using namespace std;

int Ha, Hb, Hc, Hx, Hy, Hz, Hmax, Hmin;
int ans;
int a,b;
int n;
char s[100], t[100];
char num[200];
int main() {
	cin >> n;
	rep(i, n){
		cin >> s[i];
	}
	rep(i, n){
		cin >> t[i];
	}
	rep(i, n){
		cout << s[i] << t[i];
	}
	return 0;
}

Measured memory_bytes: 256
//#include "pch.h"
#include <iostream>
#include <algorithm>
#include <numeric>
#include <string>
#include <vector>
using namespace std;

#define FOR(i, s, e) for(int i=s; i<e; i++)
#define REF(i, s, e) for(int i=s; i>e; i--)
typedef long long ll;
const ll INF = 1LL << 40;

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

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

	int n;
	cin >> n;

	vector<int> h(n);
	FOR(i, 0, n) cin >> h[i];

	int section = 0;
	while (*max_element(h.begin(), h.end()) != 0) {
		
		//区間分割
		int i = 0;
		while (i < n) {
			
			//h[i] == 0なら次へ
			if (h[i] == 0) i++;
			else {
				//cout << "i:" << i;
				int i_s = i;
				
				//区間の終わりまで
				int min1 = 1000;
				while (i < n && h[i] > 0) { min1 = min(min1, h[i]); i++; }
				//cout << " - " << i-1;
				int i_e = i - 1;
				
				//区間最小値をhから引く
				FOR(i, i_s, i_e + 1) h[i] -= min1;

				//区間に追加
				section += min1;
				//cout << " hmin:" << min1 << endl;
			}

		}
		//cout << "h:" << endl;
		//FOR(i, 0, n) cout << h[i] << endl;
		//cout << endl;
	}

	cout << section << endl;

}

Measured memory_bytes: 256
#include<stdio.h>

int main()
{
    int i, n, A[100005], cnt, k;

    while(scanf("%d%d", &n, &k) == 2)
    {
        for(i = 0; i < n; i++) {
            scanf("%d", &A[i]);
        }
        cnt = 0;
        for(i = 1; i <= n; i++) {

            if(i == n || i > n) break;
            i = i + k;
            cnt++;
            i = i - 2;
        }
        printf("%d\n", cnt);
    }

    return 0;
}


Measured memory_bytes: 512
N=int(input())
H=list(map(int,input().split()))

result = True
if len(H)==1:
  result = True
else:
  before = H[0] - 1
  for i in range(1,N):
    if H[i] > before:
      before = H[i] - 1
    elif H[i] < before:
      result = False
      before = H[i] - 1
    else:
      before = H[i]
      continue
    
print("Yes" if result else "No")      
      
  


  

Measured memory_bytes: 14252
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ldb = long double;
using pa = pair < ll, ll >;
using vec = vector < ll >;
#define pb push_back
#define po pop_back
#define mp make_pair
#define mt make_tuple
#define F  first
#define S  second
#define f(i,x,n) for(ll i=x;i<n;i++) 
#define unique_sort(x) sort(all(x)), x.resize(distance(x.begin(), unique(all(x))))
#define all(c) c.begin(),c.end()
#define str string
#define edl "\n"
#define add insert
#define cot continue
#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL)
const int MOD = 1e9 + 7, INF = INT_MAX, N = 1e5 + 10;
const double PI = acos(-1);
const ll LINF = LLONG_MAX;




int main() 
{

 fast();

  
  ll a,s;

  cin>>a>>s;
  ll x;
  ll c=0;
  ll s1=1;
  f(i,0,a)
  {
    cin>>x;
    c+=x;
    if(c>s)
      {
        break;
      }
    else    
    s1++;

  }
cout<<s1;

  


    




    
    return 0;
}
 

Measured memory_bytes: 256
#include<algorithm>     //sort,二分探索,など
#include<bitset>        //固定長bit集合
#include<cmath>         //pow,logなど
#include<complex>       //複素数
#include<deque>         //両端アクセスのキュー
#include<fstream>       //ファイルストリーム（標準入力変更用）
#include<functional>    //sortのgreater
#include<iomanip>       //setprecision(浮動小数点の出力の誤差)
#include<iostream>      //入出力
#include<iterator>      //集合演算(積集合,和集合,差集合など)
#include<map>           //map(辞書)
#include<numeric>       //iota(整数列の生成),gcdとlcm(c++17)
#include<queue>         //キュー
#include<set>           //集合
#include<stack>         //スタック
#include<string>        //文字列
#include<unordered_map> //イテレータあるけど順序保持しないmap
#include<unordered_set> //イテレータあるけど順序保持しないset
#include<utility>       //pair
#include<vector>        //可変長配列

//名前
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef map<string, int> msi;
typedef map<string, ll> msll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pllll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
typedef vector<vector<string>> vvs;
typedef vector<vector<bool>> vvb;

//定数
const ll MOD = 1000000007;
const ll INF = 1000000000000000000;

//マクロ
#define rep(i,n) for(int i=0;i<n;i++)
#define reps(i,s,e) for(int i=s;i<e;i++)
#define repse(i,s,e) for(int i=s;i<=e;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define in1(x1) cin >> x1
#define in2(x1, x2) cin >> x1 >> x2
#define in3(x1, x2, x3) cin >> x1 >> x2 >> x3
#define inN(x, N) rep(i, N) in1(x[i])
#define outl(x) cout << x << endl
#define out2l(x, y) cout << x << " " << y << endl 

//よく使う関数
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

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

    //標準入力をファイルに変更
    //std::ifstream in("input.txt");
    //std::cin.rdbuf(in.rdbuf());

    int x;
    in1(x);

    if (x == 0)
        outl(1);
    else
        outl(0);

    return 0;
}


Measured memory_bytes: 3616