akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cassert>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
#include <list>
#include <limits>
#include <numeric>
#include <utility>
#include <deque>
#include <valarray>
#include <unordered_set>
#include <unordered_map>
#include <regex>
#include <array>
#include <bitset>
#include <complex>
#include <string>
#include <tuple>

using namespace std;
using ll = long long;
const int INF = 1e9;
const ll MOD = 1e9 + 7;

int main()
{
  int n, k;
  cin >> n >> k;
  string s;
  cin >> s;
  s[k - 1] = tolower(s[k - 1]);
  cout << s << endl;

  return 0;
}


Measured memory_bytes: 256
X,K,D = map(int, input().split())
absX = abs(X)
ans = 0
if absX//D > K:
  ans = absX - D*K
else:
  if (absX//D)%2 == (K%2):
    ans = absX%D
  else:
    posX = absX%D+D
    negX = abs(absX%D-D)
    if posX < negX:
      ans = posX
    else:
      ans = negX
print(ans)
    

Measured memory_bytes: 9180
#include <bits/stdc++.h>
 #include <math.h>
using namespace std;
#define ll long long
#define pi 3.14159265359


int main(){
  int n,m;
  cin>>n>>m;
  vector<int>a(n);
  for(int i=0;i<n;i++)cin>>a[i];
  priority_queue<int>pq;
  for(int i=0;i<n;i++)pq.push(a[i]);
  for(int i=0;i<m;i++){
    int x=pq.top();
    pq.pop();
    pq.push(x/2);
  }
  ll sum=0;
  for(int i=0;i<n;i++){
    sum+=pq.top();
    pq.pop();
  }
  cout<<sum<<endl;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

#define DEBUG(x) cout<<#x<<": "<<x<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

#define CHMIN(a, b) a=min((a), (b))
#define CHMAX(a, b) a=max((a), (b))

const ll MOD=1000000007ll;
// const ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-11;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

const ll INF=1e18;
const int MAX_V=114514;

struct edge{
	int to;
	int cost[2];
};

int V;
vector<edge> g[MAX_V];
// 頂点sからの最短距離
ll d[2][MAX_V];

void dijkstra(int s, int k){
	// piiのfirstは最短距離、secondは頂点の番号
	priority_queue<pll, vector<pll>, greater<pll>> que;
	fill(d[k], d[k]+V, INF);
	d[k][s]=0;
	que.push(pii(0, s));
	while(!que.empty()){
		pii p=que.top();
		que.pop();
		ll v=p.second;
		if(d[k][v]<p.first){
			continue;
		}
		REP(i, g[v].size()){
			edge e=g[v][i];
			if(d[k][e.to]>d[k][v]+e.cost[k]){
				d[k][e.to]=d[k][v]+e.cost[k];
				que.push(pll(d[k][e.to], e.to));
			}
		}
	}
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, m, s, t, u, v, a, b;
	cin>>n>>m>>s>>t;
	--s;
	--t;
	V=n;
	REP(i, m){
		cin>>u>>v>>a>>b;
		--u;
		--v;
		edge e;
		e.to=v;
		e.cost[0]=a;
		e.cost[1]=b;
		g[u].push_back(e);
		edge e2;
		e2.to=u;
		e2.cost[0]=a;
		e2.cost[1]=b;
		g[v].push_back(e2);
	}
	dijkstra(s, 0);
	dijkstra(t, 1);
	pll sum[MAX_V];
	REP(i, n){
		sum[i]=pll(d[0][i]+d[1][i], i);
	}
	sort(sum, sum+n);
	int cnt=0;
	REP(i, n){
		while(sum[cnt++].second<i){}
		--cnt;
		cnt=min(cnt, n-1);
		cout<<ll(1e15)-sum[cnt].first<<'\n';
	}
	return 0;
}


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

int main() {
	int n;
	cin>>n;
	int dig =0;
	int x =n;
	while(x!=0)
	{
		dig++;
		x=x/10;
	}
	if(dig==1)
	cout<<n;
	else if(dig==2)
	cout<<"9";
	else if(dig==3)
	cout<<9+n-100+1;
	else if(dig==4)
	cout<<"909";
	else if(dig==5)
	cout<<909+n-10000+1;
	else 
	cout<<90909;
	
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; i++)
#define repo(i, n) for(int i=1; i<=n; i++)
#define INF 1001001001
#define INFll 100100100100100
// debug用
#define PrintVec(x) for (auto elementPrintVec: x) { cout << elementPrintVec << " "; } cout << endl;

using namespace std;
using ull = unsigned long long;
using ll = long long;
using P = pair<int, int>;
const int mod = 1000000007;

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, n){
    cin >> a[i];
  }
  sort(a.begin(), a.end());
  ll ans=0;
  int c=n-2, ap=n-2;
  ans+=a[n-1];
  while(c>0){
    ans+=a[ap];
    c--;
    if(c==0){
      break;
    }
    ans+=a[ap];
    c--;
    ap--;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 4028
n,m = gets.chomp.split(" ").map(&:to_i)
account = 0
wacount = 0
acmemo = {}
wamemo = {}

m.times do
  problem,result = gets.chomp.split(" ")
  if (result == 'AC')
    unless (acmemo[problem])
      acmemo[problem] = true
      wacount += wamemo[problem] ? wamemo[problem] : 0
      account += 1
    end
  else
    wamemo[problem] ? wamemo[problem]+=1 : wamemo[problem]=1
  end
end

puts "#{account} #{wacount}"


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


using namespace std;


typedef long long int lli;
typedef long double ld;


const int MAXN = 302;
const lli INF = (lli)(1e16);


lli H[MAXN];
lli memo[MAXN][MAXN];


int main() {

  int N, K;

  cin >> N >> K;
  for (int i = 1 ; i <= N ; i++) {
    cin >> H[i];
  }

  
  for (int i = 1 ; i <= N ; i++) {
    memo[i][1] = H[i];
    for (int k = 2 ; k <= N ; k++) {
      memo[i][k] = INF;
    }
  }

  for (int k = 2 ; k <= N-K ; k++) {
    for (int i = 1 ; i <= N ; i++) {
      for (int j = i-1 ; j >= 1 ; j--) {
        memo[i][k] = min(memo[i][k], memo[j][k-1] + max((lli)0, H[i]-H[j]));
      }
      //cerr << "memo[" << i << "]" << k << "] = " << memo[i][k] << "\n";
    }
  }

  lli ans = INF;
  for (int i = 1 ; i <= N ; i++) {
    ans = min(ans, memo[i][N-K]);
  }
  
  cout << ans;


  return 0;
}


Measured memory_bytes: 896
N, M = map(int, input().split())
graph = [[] for _ in range(N)]
for _ in range(M):
    a, b = map(int, input().split())
    graph[a-1].append(b-1)
    graph[b-1].append(a-1)

ans = 'IMPOSSIBLE'
qs = [0]
for _ in range(2):
    qqs = []
    for q in qs:
        for n in graph[q]:
            if n == N-1:
                ans = 'POSSIBLE'
                break
            qqs.append(n)
    qs = qqs

print(ans)

Measured memory_bytes: 39344
def main():
    a, b, c, d = map(int,input().strip().split())
    player = [ a, c, b, d ]

    i = 1
    j = 0

    while True:
        j = i%2
        k = j + 3 - ((j+1)*j)
        player[j] = player[j] - player[k]
        if( player[j] <= 0 ):
            break
        i = i + 1

    if(j!=0):
        print('Yes')
    else:
        print('No')
        
main()


Measured memory_bytes: 9008
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<sstream>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<utility>
#include<numeric>
#include<algorithm>
#include<bitset>
#include<complex>

using namespace std;

typedef long long Int;
typedef vector<int> vint;
typedef pair<int,int> pint;
#define mp make_pair

template<class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; }
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }
int in() { int x; scanf("%d", &x); return x; }

int seat[17];
int res[200];

int main() {
	int i;
	int j;
	int k=-1;
	for(i=0;i<600;i++){
//cout<<i<<endl;
		for(j=0;j<17;j++){
			if(seat[j])seat[j]--;
//cout<<" "<<j<<" "<<seat[j]<<endl;
		}
		if(k==-1){
			if(i%5==0){
				k=i/5;
			}
		}
		while(1){
			int l;
			if(k==-1)break;
			if(k%5==1){
				for(l=0;l<=17-5;l++){
					if(seat[l]+seat[l+1]+seat[l+2]+seat[l+3]+seat[l+4]==0){
						seat[l]=seat[l+1]=seat[l+2]=seat[l+3]=seat[l+4]=17*(k%2)+3*(k%3)+19;
						res[k]=i-k*5;
						k++;
						if(k>i/5)k=-1;
						goto a;
					}
				}
			}else{
				for(l=0;l<=17-2;l++){
					if(seat[l]+seat[l+1]==0){
						seat[l]=seat[l+1]=17*(k%2)+3*(k%3)+19;
						res[k]=i-k*5;
						k++;
						if(k>i/5)k=-1;
						goto a;
					}
				}
			}
			break;
			a:;
		}
//cout<<i<<endl;
//for(j=0;j<17;j++){
//	cout<<" "<<j<<" "<<seat[j]<<endl;
//}
//cout<<"  "<<k<<endl;
	}
	int n;
//for(n=0;n<200;n++){
//	cout<<n<<" "<<res[n]<<endl;
//}
	while(cin>>n){
		cout<<res[n]<<endl;
	}
	return 0;
}

//WA

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

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

typedef long long ll;

const int INF = 1 << 30;
const ll LLINF = 1LL << 62;

int mod = 1000000007;


struct edge{
    int to;
    ll cost;
    edge(int t, ll c){
        to = t; cost = c;
    }
};

vector<edge> nodes[100000];
ll dist[100000] = {};

void dfs(int p, int s, ll acc){
    dist[s] = acc;
    rep(i, nodes[s].size()){
        int to = nodes[s][i].to;
        ll cost = nodes[s][i].cost;
        if(to == p) continue;
        dfs(s, to, acc + cost);
    }
}

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N; cin >> N;
    rep(i, N-1){
        int a, b; cin >> a >> b;
        a--; b--;
        ll c; cin >> c;
        nodes[a].push_back(edge(b, c));
        nodes[b].push_back(edge(a, c));
    }
    int Q, K; cin >> Q >> K;
    dfs(-1, K-1, 0);
    rep(i, Q){
        int x, y; cin >> x >> y;
        cout << dist[x-1] + dist[y-1] << endl;
    }
    return 0;
}

Measured memory_bytes: 15872
class Card:
    def __init__(self, s):
        self.color = s[0]
        self.val = int(s[1])

    def __str__(self):
        return "%s%d" % (self.color, self.val)


if __name__ == '__main__':
    n = int(raw_input())
    A = map(Card, raw_input().split())
    B = A[:]

    # bubble sort
    for i in range(0, n):
        for j in range(n - 1, i, -1):
            if A[j].val < A[j - 1].val:
                A[j], A[j - 1] = A[j - 1], A[j]

    # select sort
    for i in range(0, n):
        minj = i
        for j in range(i, n):
            if B[j].val < B[minj].val:
                minj = j
        if minj != i:
            B[minj], B[i] = B[i], B[minj]

    for c in A:
        print c,
    print
    print "Stable"
    for c in B:
        print c,
    print
    flag = True
    for i in range(n):
        if A[i] != B[i]:
            flag = False
            break
    print "Stable" if flag else "Not stable"


Measured memory_bytes: 4696
#include <iostream>
using namespace std;
int main(){
 int a, b;
 cin >> a >> b;
 int c;
 c = a * b;
 if (c % 2 == 0){
   cout << "Even" << endl;
 }else{
   cout << "Odd" << endl;
 }
 return 0;
}


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

int main(){
	int n, x, m;
	int min = INT_MAX;
	cin >> n >> x;
	for(int i=0; i<n; i++){
		cin >> m;
		x -= m;
		if(m < min) min = m;
	}
	cout << n + x / min;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <string>
#include <algorithm>
#include <deque>

using namespace std;

int main()
{
    int N;
    cin >> N;
    vector< pair<int,int> > A(N);
    for (int i=0;i<N;++i) {
        int a;
        cin >> a;
        A[i] = {a, i};
    }

    sort(A.begin(), A.end());

    for (auto a: A) {
        cout << (a.second+1) << " ";
    }

    cout << endl;
}


Measured memory_bytes: 1664
from collections import Counter
from operator import mul
from functools import reduce

def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under


N = int(input())

s = [ list(input()) for _ in range(N)]
for i in range(N):
    s[i].sort()
    s[i]=''.join(s[i])

s.sort()
s.append('0')
ans_tmp = 0
ans = 0
for i in range(N):
    if(s[i]== s[i+1]):
        ans_tmp += 1
    elif(ans_tmp>=1):
        ans+= cmb(ans_tmp+1, 2)
        ans_tmp=0


print(ans)


Measured memory_bytes: 112452
def solve(string):
    ans = 0
    i = 0
    while i < len(string):
        j = 0
        while i + j < len(string) and string[i + j] in "ATGC":
            j += 1
        ans = max(ans, j)
        i += j + 1
    return str(ans)
 
 
if __name__ == '__main__':
    print(solve(input()))

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=1e9+7;
const int INF=1e9;
const ll LINF=(ll)1e18;

int main(){
    int cnt[10]={};
    for(int i=0;i<4;i++){
        int n;
        cin>>n;
        cnt[n]++;
    }
    if(cnt[1]&&cnt[9]&&cnt[7]&&cnt[4]){
        cout<<"YES"<<endl;
    }
    else{
        cout<<"NO"<<endl;
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>

#define ll long long int
#define mod 1000000007

using namespace std;


int main()
{
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    
        string s;
        cin >> s;
        if(s[0] == 'R' & s[1] == 'R' && s[2] == 'R')
        cout << 3;
        else if(s[0] == 'R' && s[1] == 'R' || s[1] == 'R' && s[2] == 'R')
        cout << 2;
        else if(s[0] == 'R' || s[1] == 'R' || s[2] == 'R')
        cout << 1;
        else
        cout << 0;
    
}









Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define INF 100000000
#define EPS 1e-10
#define MOD 1000000007
using namespace std;
typedef pair<int,int> P;

int n, m;
P x[10000];

void solve(){
	rep(i,n) cin >> x[i].second >> x[i].first;
	sort(x,x+n,greater<P>());
	int ans = 0;
	rep(i,n){
		if(m >= x[i].second){
			m -= x[i].second;
		} else{
			x[i].second -= m;
			m = 0;
			ans += x[i].second*x[i].first;
		}
	}
	cout << ans << endl;
}

int main(){
	while(cin >> n >> m){
		if(n == 0 && m == 0) break;
		solve();
	}
}

Measured memory_bytes: 1240
import numpy as np

def gcd(a,b):
    if(a>b):
        a,b=b,a
    if(a==0):return b
    return gcd(b%a,a)

t=int(input())
ans=1
for _ in range(t):
    k=int(input())
    ans=ans*k//gcd(ans,k)
print(ans)

Measured memory_bytes: 14532
fn main(){
  let n = getline().trim().parse::<i64>().unwrap();
  let h:Vec<_> = getline().trim().split(' ').map(|e| e.parse::<i64>().unwrap()).collect();
  
  let mut highest = h[0];
  let mut ans = 0;
  for i in 0..n as usize {
    if highest <= h[i] {
      ans += 1;
      highest = h[i];
    }
  }
  println!("{}", ans);
}

fn getline() -> String{
  let mut __ret=String::new();
  std::io::stdin().read_line(&mut __ret).ok();
  return __ret;
}


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

ll modPow(ll a, ll n) {
  if (n == 0) return 1; // 0乗にも対応する場合
  if (n == 1) return a % MOD;
  if (n % 2 == 1) return (a * modPow(a, n - 1)) % MOD;
  ll t = modPow(a, n / 2);
  return (t * t) % MOD;
}
ll modComb(ll n,ll a){
  ll x=1,y=1;
  rep(i,a){
    x*=n-i;
    x%=MOD;
    y*=i+1;
    y%=MOD;
  }
  y=modPow(y,MOD-2);
  return (x*y)%MOD;
}


int main(){
  ll n,a,b,ans;
  cin >> n >> a >> b;
  ans=modPow(2,n);
  ans+=2*MOD;
  ans--;
  
  ans-=modComb(n,a);
  ans-=modComb(n,b);
  ans%=MOD;
  cout << ans << endl;
}


Measured memory_bytes: 384
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <ctype.h>

int main(void) {
      int a[6], ans = 0, kari = 4, max = 9, taihi;

      for(int i = 0; i < 5; i++) {
        if(scanf("%d", &a[i]) == 1);
      }

        for(int i = 0; i < 5; i++) {
          if(max > (a[i] % 10) && a[i] % 10 != 0) {
            max = a[i] % 10;
            kari = i;
          }
        }

        if(kari != 4) {
          taihi = a[kari];
          a[kari] = a[4];
          a[4] = taihi;
        }


      for(int i = 0; i < 5; i++) {
        while(ans % 10 != 0) {
          ans++;
        }
        ans += a[i];
      }

      printf("%d", ans);

      return 0;
}


Measured memory_bytes: 128
#!/usr/bin/env python3
import sys


def solve(N: int):
    ret = 180 * (N - 2)
    print(ret)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    solve(N)

if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <memory.h>
#include <stdlib.h>


int main(void)
{	
	char s[11];
	scanf("%s",s);
	
	if(s[0]=='Y' && s[1]=='A' && s[2]=='K' && s[3]=='I'){
		printf("Yes\n");
	} else{
		printf("No\n");
	}
	return 0;
}


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

#define ll long long
#define ld long double
#define xx first
#define yy second
#define vl vector<ll>
#define pll pair<ll,ll>
#define all(v) v.begin(),v.end()

#define MAX 400005

vector<ll> g[MAX];
vector<ll> a(MAX);

ll kth[MAX];

multiset<ll> haha;

void dfs(ll node, ll par)
{
    haha.insert(a[node]);
    
    auto it = haha.lower_bound(a[node]);

    ll xd= -1;
    
    it++;
    
    if(it != haha.end())
        xd = *it, haha.erase(it);

    kth[node] = haha.size();

    for(ll x: g[node])
    {
        if(x!=par)
        {
            dfs(x,node);
        }
    }

    if(xd!=-1) haha.insert(xd);

    auto lol = haha.find(a[node]);
    if(lol!=haha.end())
        haha.erase(lol);
}

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

    ll n, u, v;
    cin >> n;

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

    for(int i=0;i<n-1;i++)
    {
        cin >> u >> v;

        g[u].push_back(v);
        g[v].push_back(u);
    }

    dfs(1,0);

    for(int i=1;i<=n;i++) cout << kth[i] << endl;

    return 0;
}


Measured memory_bytes: 37964
import java.util.Scanner;
/** 参考: https://beta.atcoder.jp/contests/abc103/submissions/2877427 */
public class Main {
	public static void main(String[] args) {
		// ここは Scanner in のほうがわかりやすいだろうか？
		Scanner sc = new Scanner(System.in);
		String s = sc.nextLine();
		String t = sc.nextLine();
		for (int i = 0; i < t.length(); i++) {
			// tmpでもよかったけどSの途中経過ってことがわかるようにs_tmpにした
			String s_tmp = s.substring(i) + s.substring(0, i);
			if (s_tmp.equals(t)) {
				System.out.println("Yes");
				return;
			}
		}
		System.out.println("No");
	}
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define REP(i, n) for(int i=0; i<(int)(n); ++i)
#define FOR(i, s, n) for(int i=(int)(s); i<(int)(n); ++i)
#define ALL(n) (n).begin(), (n).end()
#define pb push_back

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> mat;

const ll MAX_V = 100000;
const ll INF = 1e9;
const ll MOD = 998244353;

int main(){
    string s, t; cin >> s >> t;
    string tmp;
    bool fg = false;
    REP(i, s.size()){
        tmp = t.substr(i, t.size()) + t.substr(0, i);
        if (tmp == s){
            fg = true;
            cout << "Yes" << endl;
            break;
        }
    }
    if (!fg) cout << "No" << endl;
}

Measured memory_bytes: 256
#include <cstdio>
using namespace std;
int main(){
	int r, g, b;
	scanf("%d %d %d", &r, &g, &b);
	if ((100 * r + 10 * g + b) % 4 == 0) {
		puts("YES");
	} else {
		puts("NO");
	}
}

Measured memory_bytes: 128
#include <cstdio>
#include <algorithm>
#include <vector>

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

  std::vector<int> X(N);
  for (size_t i=0; i<N; ++i)
    scanf("%d", &X[i]);

  std::vector<int> Y=X;
  std::sort(Y.begin(), Y.end());
  int a=Y[N/2-1], b=Y[N/2];

  for (int x: X) {
    if (x <= a) {
      printf("%d\n", b);
    } else {
      printf("%d\n", a);
    }
  }
}


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

int main()
{
    int N;
    cin >> N;
    int P[N];
    for (int i = 0; i < N; i++) cin >> P[i];

    int min = P[0];
    int ans = 0;
    for (int i = 0; i < N; i++) {
        if (min >= P[i]) {
            ans++;
            min = P[i];
        }
    }
    cout << ans << endl;
    return 0;
}

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

int main(){
    int64_t N, a, b, c, d, e, x;

    cin >> N >> a >> b >> c >> d >> e;

    double min_person = min({a, b, c, d, e});

    x = ceil(N / min_person) + 4;
    
    cout << x << endl;
}

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

using namespace std;
typedef long long int LL;
typedef long long int ll;
typedef pair<long long int, long long int> pii;
typedef pair<double, double> pdd;

#define SORT(c) sort((c).begin(),(c).end())
#define BACKSORT(c) sort((c).begin(),(c).end(),std::greater<LL>())
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SP << " " <<

LL mod = 998244353;

LL modpow(LL a, LL n, LL mod) {
    LL res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

const LL MAX = 10010000;
const LL MOD = 998244353;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int 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(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

long long pow2[MAX];

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

  COMinit();

  pow2[0] = 1;

  FOR(i,1,MAX){
    pow2[i] = (pow2[i - 1] * 2) % mod;
  }

  LL N;
  cin >> N;

  LL sum = 0;
  
  FOR(i,N/2+1,N+1){
    sum += (COM(N, i) * pow2[N - i + 1])%mod;
    sum %= mod;
  }

  LL ans = modpow(3, N, mod) - sum;
  ans = ((ans % mod) + mod) % mod;

  cout << ans << endl;
}


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

using namespace std;

int main(){
    int r, g, b, n;
    cin >> r >> g >> b >> n;
    int ans = 0;
    for(int i = 0; i < n + 1; i++){
        for(int j = 0; j < n + 1; j++){
            int tmp = n - i * r - j * g;
            if(tmp >= 0 && tmp % b == 0){
                ans++;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template <typename T> void read(T &t) {
	t=0; char ch=getchar(); int f=1;
	while (ch<'0'||ch>'9') { if (ch=='-') f=-1; ch=getchar(); }
	do { (t*=10)+=ch-'0'; ch=getchar(); } while ('0'<=ch&&ch<='9'); t*=f;
}
int x,y,ans;
int main() {
	//freopen("1.txt","r",stdin);
	read(x); read(y);
	if (x==1&&y==1) ans+=400000;
	if (x<=3) ans+=(4-x)*100000;
	if (y<=3) ans+=(4-y)*100000;
	printf("%d\n",ans);
	return 0;
}
/*
  REMEMBER:
  1. Think TWICE, Code ONCE!
  Are there any counterexamples to your algo?
    
  2. Be careful about the BOUNDARIES!
  N=1? P=1? Something about 0?
    
  3. Do not make STUPID MISTAKES!
  Array size? Integer overflow? Time complexity? Memory usage? Precision error?
*/

Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define all(v) v.begin(), v.end()
#define MOD 1000000007
const int INF = 1LL<<30;

int main(){
    int n;
    string s;
    cin>>n>>s;
    int ans=0,l=0,r=n-1;
    while(l<r){
        if(s[l]=='W' && s[r]=='R'){
            ans++;
            l++,r--;
        }
        else if(s[l]=='W' && s[r]=='W') r--;
        else if(s[l]=='R' && s[r]=='W') l++,r--;
        else if(s[l]=='R' && s[r]=='R') l++;
    }

    cout<<ans<<endl;
}

Measured memory_bytes: 3756
let inputString = "";
let currentLine = 0;
process.stdin.on("data", (data) => {
  inputString += data;
});
process.stdin.on("end", function () {
  inputString = inputString
    .trim()
    .split("\n")
    .map((str) => str.trim());
  main();
});
function readLine() {
  return inputString[currentLine++];
}
function main() {
  const src = readLine();
  const target = readLine();
  let max = Number.MIN_SAFE_INTEGER;

  for (let i = 0; i <= src.length - target.length; i++) {
    let count = 0;
    for (let j = 0; j < target.length; j++) {
      const srcChar = src[i + j];
      const targetChar = target[j];
      if (srcChar === targetChar) count++;
    }
    max = Math.max(max, count);
  }

  console.log(target.length - max);
}


Measured memory_bytes: 32716
#include<cstdio>
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>

using namespace std;

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

int main(){
	int a,b,c;
	cin>>a>>b>>c;
	
	if(a<b && b<c)puts("Yes");
	else puts("No");
}

Measured memory_bytes: 1116
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
const int N=100005;
int Head[N],Next[N],Adj[N],tot=0;
inline void addedge(int u,int v){
	Next[++tot]=Head[u];
	Head[u]=tot;
	Adj[tot]=v;
}
int fa[N];
int n,k,ans=0;
int dis[N],dep[N];
inline void dfs(int x,int las) {
	dis[x]=dep[x];
	for (int e=Head[x];e;e=Next[e]) {
		dep[Adj[e]]=dep[x]+1,dfs(Adj[e],x);
		dis[x]=max(dis[x],dis[Adj[e]]);
	}
	if(las!=1&&x!=1&&dis[x]-dep[x]==k-1) ++ans,dis[x]=0;
}
int main (){
	scanf ("%d%d",&n,&k);
	for (int i=1;i<=n;i++) scanf ("%d",&fa[i]);
	if (fa[1]!=1) ans=fa[1]=1;
	for (int i=2;i<=n;i++) addedge(fa[i],i);
	dfs(1,0);
	printf ("%d",ans);
	return 0;
}


Measured memory_bytes: 7296
use std::io::Read;
use std::f64::consts::PI;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

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

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let r: usize = iterator.next().unwrap().parse().unwrap();

    let ans: f64 = 2_f64 * (r as f64) * PI;

    return ans.to_string();
}


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

int main() {
	int N, T;
	cin >> N >> T;
	vector<int> A(N), B(N);
	int maxa = 0;
	for(int i=0;i<N;i++) {
		cin >> A[i] >> B[i];
	}

	vector<vector<int>> dp(N + 1, vector<int>(T + 1, 0)), pd(N + 2, vector<int>(T + 1, 0));
	// dp[i][j] : 1~i番目の料理でj分以内に完食できる美味しさの合計
	// pd[i][j] : i~N番目の料理でj分以内で完食できる美味しさの合計
	
	for(int i=1;i<=N;i++) {
		for(int j=1;j<=T;j++) {
			dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
			if(j >= A[i-1]) dp[i][j] = max(dp[i][j], dp[i-1][j - A[i-1]] + B[i-1]);
		}
	}

	for(int i=N;i>=1;i--) {
		for(int j=1;j<=T;j++) {
			pd[i][j] = max(pd[i+1][j], pd[i][j-1]);
			if(j >= A[i-1]) pd[i][j] = max(pd[i][j], pd[i+1][j - A[i-1]] + B[i-1]);
		}
	}

	vector<int> ans(N+1, 0);
	// i番目以外の料理でT - 1分以内で食べる最大値
	for(int i=1;i<=N;i++) {
		for(int j=0;j<T;j++) {
			ans[i] = max( ans[i], dp[i-1][j] + pd[i+1][T-1-j]);
		}
		ans[i] += B[i-1];
	}
	cout << *max_element(ans.begin(), ans.end()) << endl;
}

Measured memory_bytes: 70912
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<string>
#include<cmath>
#include<vector>
#include<stack>
#include<queue>
#include<time.h>
#include<tuple>
#include<set>
#include<map>
#include<cctype>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define vint vector<int> 
#define vvint vector<vint>
#define ct(a) cout<<a<<endl
#define tget(a,b) get<a>(b)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const int MOD = 1e9 + 7;
int a,b,h;
int ans[100005];

int main(void) {
	cin >> a >> b >> h;
	ct((a + b)*h / 2);
	system("pause");
	return 0;
}

Measured memory_bytes: 504
#include "bits/stdc++.h"
using namespace std;
const int MOD = 1e9 + 7;
typedef long long lint;
const int INF =1e7;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repi(i, k, n) for (int i = (k); i < (int)(n); ++i)
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define all(x) (x).begin(),(x).end()
#define pb push_back
int main(){
    int a, b;
    cin >> a >> b;
    vi v(4);
    v.pb(a);
    v.pb(a - 1);
    v.pb(b);
    v.pb(b - 1);
    sort(v.rbegin(), v.rend());
    cout<<v[0]+v[1]<<endl;
    return 0;
}

Measured memory_bytes: 256
//header{{{
//#define _GLIBCXX_DEBUG
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
//#include<boost/multiprecision/cpp_int.hpp>
//#include<boost/math/common_factor_rt.hpp>
  
using namespace std;
//using namespace boost::multiprecision;  
//using namespace boost::math;

#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define Fixed fixed << setprecision(12)
#define int int_fast64_t
using pii = pair<int,int>;
constexpr int INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod1 = 1e9+7; 
constexpr int mod2 = 998244353;

template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

template <class T> using min_heap = priority_queue<T,vector<T>,greater<T> >;
template <class T> using max_heap = priority_queue<T>;
template <class A, class B> using umap = unordered_map<A,B>;
  
inline int square(int a){ return a * a;}
inline int updiv(int a,int b){ return (a + b - 1) / b; }

constexpr int dx[] = {1,0,-1,0,1,1,-1,-1};
constexpr int dy[] = {0,-1,0,1,1,-1,-1,1};
//}}}

int n, m, q;
vector<int> a, b, c, d;

int dfs(vector<int> &v){
    if(v.size() == n){
        int sum = 0;
        for(int i = 0; i < q; ++i){
            if(v[b[i] - 1] - v[a[i] - 1] == c[i]){
                sum += d[i];
            }
        }
        return (sum);
    }

    int ret = 0;
    for(int i = (v.empty() ? 1 : v.back()); i <= m; ++i){
        v.push_back(i);
        chmax(ret, dfs(v));
        v.pop_back();
    }

    return (ret);
}

signed main(){
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout.setf(ios_base::fixed);
    cout.precision(10);

    cin >> n >> m >> q;

    a.resize(q);
    b.resize(q);
    c.resize(q);
    d.resize(q);

    rep(i,q){
        cin >> a[i] >> b[i] >> c[i] >> d[i];
    }

    vector<int> v;

    cout << dfs(v) << '\n';

    return 0;
}


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


void solve(long long K, long long N, std::vector<long long> A){
    ll ans = K;
    ll ma = 0;
    for(int i = 0;i < N-1;i++){
        ma = max(ma, A[i+1] - A[i]);
    }
    ma = max(ma, K - A[N-1] + A[0]);
    //cout<<1<<endl;
    cout<<ans - ma<<endl;
}

int main(){
    long long K;
    scanf("%lld",&K);
    long long N;
    scanf("%lld",&N);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    solve(K, N, std::move(A));
    return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <cmath>

using namespace std;

typedef long long ll;

int main()
{
    string s;
    getline(cin, s);

    if ((s.size() % 2 == 1) ^ (s.front() == s.back()))
    {
        cout << "First" << endl;
    }
    else
    {
        cout << "Second" << endl;
    }
}

Measured memory_bytes: 512
def main():
    N, M = map(int, input().split())
    *A, = map(int, input().split())

    d = {0: 1}

    ans = 0

    t = 0
    for x in A:
        t = (t + x) % M
        ans += (cnt := d.get(t, 0))
        d[t] = cnt + 1
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 20768
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using intpair=pair<int,int>;
using llpair=pair<ll,ll>;
using llvec=vector<ll>;
using llmat=vector<vector<ll>>;
#define llmattp(name,a,b,num) name(a,vector<ll>(b,num))
#define INTINF 1<<30
#define LLINF 1LL<<60
#define ABS(x) ( (x)>0 ? (x) : -(x) )

template<class T> inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}

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

ll gcd(ll a, ll b) {
	if(a==0||b==0) return 0;
	if(a<b) swap(a,b);
	ll tmp = a%b;
	while(tmp!=0) {
		a = b;
		b = tmp;
		tmp = a%b;
	}
	return b;
}

ll factorial(ll x) {
	ll f=1;
	for(ll i=2; i<x; i++) {
		f*=i;
	}
	return f;
}

ll nPr(ll n, ll r) {
	ll result=1;
	for(ll i=r+1; i<=n; i++) result*=i;
	return result;
}

ll nCr(ll n, ll r) {
	if (n == r) { return 1; }
	if (r > n) { return 0; }

	if (r > n / 2) { r = n - r; }

	if (n == 0) { return 0; }
	if (r == 0) { return 1; }
	if (r == 1) { return n; }

	double result = 1;
	for (double i = 1; i <= r; i++) {
		result *= (n - i + 1) / i;
	}

	return (ll)result;
}

bool IsPrime(ll num) {
	if (num < 2) return false;
	else if (num == 2) return true;
	else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

	double sqrtNum = sqrt(num);
	for (ll i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			// 素数ではない
			return false;
		}
	}

	// 素数である
	return true;
}

ll GreaterBinarySearch(ll *array, ll key, ll max, ll min) {
	if(array[max]<array[min]) {
		return NULL;
	} else {
		ll mid = max + (min-max)/2;
		if(array[mid]<key) {
			return GreaterBinarySearch(array,key,max,mid-1);
		} if(array[mid]>key) {
			return GreaterBinarySearch(array,key,mid+1,min);
		} else {
			return mid;
		}
	}
}

void PrimeFact(ll x) { // 素因数分解 出力部を適切に書き換え
	int i=2;
	while(x%2&&i*i<=x) {
		cout<<2<<endl;
		x/=2;
	}
	i++;
	while(i*i<=x) {
		if(x%i) {
			i+=2;
			continue;
		}
		cout<<i<<endl;
		x/=i;
	}
}

bool Palind(string s) {
	return s == string(s.rbegin(), s.rend());
}

int main() {
	int N,M; cin>>N>>M;
	int A[N]; for(int i=0; i<N; i++) cin>>A[i];
	intpair CB[M]; for(int i=0; i<M; i++) cin>>CB[i].second>>CB[i].first;
	sort(A,A+N);
	sort(CB,CB+M,greater<intpair>());

	int k=0;
	for(int i=0; k<N&&i<M; i++) {
		for(int j=0; A[k]<CB[i].first&&j<CB[i].second&&k<N; j++) {
			A[k]=CB[i].first;
			k++;
		}
		if(A[k]>=CB[i].first) k=N;
	}

	ll result=0LL;
	for(int i=0; i<N; i++) result+=A[i];

	cout<<result<<endl;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define F first
#define S second
using namespace std;
using ll = long long;
typedef pair<int, int> P;
ll Mod = 1000000007;
int main() {
  int N,K;
  cin >> N >> K;
  string S;
  cin >> S;
  S[K-1] += 32;
  cout << S << endl;
  return 0;
}

Measured memory_bytes: 3588
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

int compare_int(const void *a, const void *b)
{
  return *(int*)a - *(int*)b;
}

int main() {
  int n,k;
  scanf("%d %d", &n, &k);
  int p[n];
  for(int i=0;i<n;i++) {
    scanf("%d", &p[i]);
  }

  qsort(p, n, sizeof(int), compare_int);
  int ans=0;
  for(int i=0;i<k;i++){
    ans+=p[i];
  }
  
  printf("%d", ans);
  return 0;
}

Measured memory_bytes: 2212
n,q = map(int, input().split())
que=[list(map(int,input().split())) for i in range(q)]

ide_ele = 2000000000
def segfunc(x, y):
    return min(x,y)
class SegTree:
    def __init__(self, init_val, segfunc, ide_ele):
        n = len(init_val)
        self.segfunc = segfunc
        self.ide_ele = ide_ele
        self.num = 1 << (n - 1).bit_length()
        self.tree = [ide_ele] * 2 * self.num
        for i in range(n):
            self.tree[self.num + i] = init_val[i]
        for i in range(self.num - 1, 0, -1):
            self.tree[i] = self.segfunc(self.tree[2 * i], self.tree[2 * i + 1])

    def update(self, k, x):
        # param k: index(0-index)
        # param x: update value
        k += self.num
        self.tree[k] = x
        while k > 1:
            self.tree[k >> 1] = self.segfunc(self.tree[k], self.tree[k ^ 1])
            k >>= 1

    def query(self, l, r): #[l, r) 0-index
        res = self.ide_ele
        l += self.num
        r += self.num
        while l < r:
            if l & 1:
                res = self.segfunc(res, self.tree[l])
                l += 1
            if r & 1:
                res = self.segfunc(res, self.tree[r - 1])
            l >>= 1
            r >>= 1
        return res
al = [n for i in range(n)]
seg1 = SegTree(al, segfunc, ide_ele)
seg2 = SegTree(al, segfunc, ide_ele)
sm = 0
for q in que:
    x=q[1]
    if q[0]==1:
        num = seg1.query(x,n+1)
        sm+=num-2
        if x < seg2.query(num, num+1):
            seg2.update(num,x)
    else:
        num = seg2.query(x,n+1)
        sm+=num-2
        if x < seg1.query(num, num+1):
            seg1.update(num,x)

print((n-2)*(n-2) - sm)

Measured memory_bytes: 139268
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

typedef long long ll;
typedef uint64_t ull;
typedef pair<int, int> P;
constexpr double PI = 3.1415926535897932;   // acos(-1)
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)

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

    int n, m;
    cin >> n >> m;
    ll sum = 0;
    for(int i = 0; i < m; ++i){
        int a;
        cin >> a;
        sum += a;
    }

    if(sum > n){
        cout << -1 << endl;
        return 0;
    }

    ll ans = n - sum;
    cout << ans << endl;
}


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

int main() {
  int n,min = 100;
  cin >> n;
  vector<long long>data(n);
  for(int i = 0;i < n;i++){
    int mini = 0;
    cin >> data.at(i);
    while(data.at(i)%2 == 0){
      data.at(i) = data.at(i)/2;
      mini++;
    }
    if(mini < min){
      min = mini;
    }
  }
  cout << min << endl;
}


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

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<bool> VB;
typedef vector<double> VD;
typedef vector<string> VS;
typedef vector<char> VC;
typedef pair<int, int> PII;
typedef long long LL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SQ(a) ((a)*(a))
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define LB lower_bound
#define UB upper_bound

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

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL INF = 1e9;
const LL MOD = 1e9+7;

//other
//-------------------------------------------
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define FI first
#define SE second

//memo
// setprecision()


LL Gcd(LL a, LL b) {
  if (a < b) {
    return Gcd(b,a);
  }
  if (b == 0) {
    return a;
  }
  else {
    return Gcd(b,a%b);
  }
}

LL Lcm(LL a, LL b) {
  LL abd = Gcd(a,b);
  LL x = a / abd, y = b / abd;
  
  return x*y*abd;
}

int main() {
  int A, B;
  cin >> A >> B;
  cout << Lcm(A,B) << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
#define int long long
#define pii pair<int,int>
#define pb push_back
#define cases int t;cin>>t;while(t--)
#define N 300003
#define inf LLONG_MAX
//int mod=1e9+7;
//int mod=998244353;

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

	int n,ans=0,i;
	cin>>n;
	for(i=1;i*i<n;++i)
		if(n%i==0 and (n-i)/i and n%((n-i)/i)==n/((n-i)/i))
			ans+=(n-i)/i;
	cout<<((n<=2)?0:ans);


    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;

template<unsigned P> struct ModInt {
  using M = ModInt;
  unsigned v;
  ModInt() : v(0) {}
  template<class Z> ModInt(Z x) : v(x >= 0 ? x % P : (P - -x % P) % P) {}
  constexpr ModInt(unsigned v, int) : v(v) {}
  static constexpr unsigned p() { return P; }
  M operator+() const { return *this; }
  M operator-() const { return {v ? P - v : 0, 0}; }
  explicit operator bool() const noexcept { return v; }
  bool operator!() const noexcept { return !(bool) *this; }
  M operator*(M r) const { return M(*this) *= r; }
  M operator/(M r) const { return M(*this) /= r; }
  M operator+(M r) const { return M(*this) += r; }
  M operator-(M r) const { return M(*this) -= r; }
  bool operator==(M r) const { return v == r.v; }
  bool operator!=(M r) const { return !(*this == r); }
  M& operator*=(M r) { v = (uint64_t) v * r.v % P; return *this; }
  M& operator/=(M r) { return *this *= r.inv(); }
  M& operator+=(M r) { if ((v += r.v) >= P) v -= P; return *this; }
  M& operator-=(M r) { if ((v += P - r.v) >= P) v -= P; return *this; }
  M inv() const {
    int a = v, b = P, x = 1, u = 0;
    while (b) {
      int q = a / b;
      swap(a -= q * b, b);
      swap(x -= q * u, u);
    }
    assert(a == 1);
    return x;
  }
  template<class Z> M pow(Z n) const {
    if (n < 0) return pow(-n).inv();
    M res = 1;
    for (M a = *this; n; a *= a, n >>= 1) if (n & 1) res *= a;
    return res;
  }
  template<class Z> friend M operator*(Z l, M r) { return M(l) *= r; }
  template<class Z> friend M operator/(Z l, M r) { return M(l) /= r; }
  template<class Z> friend M operator+(Z l, M r) { return M(l) += r; }
  template<class Z> friend M operator-(Z l, M r) { return M(l) -= r; }
  friend ostream& operator<<(ostream& os, M r) { return os << r.v; }
  friend istream& operator>>(istream& is, M& r) { lint x; is >> x; r = x; return is; }
  template<class Z> friend bool operator==(Z l, M r) { return M(l) == r; }
  template<class Z> friend bool operator!=(Z l, M r) { return !(l == r); }
};
using Mint = ModInt<(unsigned) 1e9 + 7>;

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  lint n; cin >> n;
  V<Mint> dp(n + 1);
  dp[1] = n, dp[2] = n * n;
  Mint sum = dp[1];
  for (int i = 2; i < n; ++i) {
    sum += dp[i];
    dp[i + 1] = sum - dp[i - 1] + max(i - 2, 0) * (n - 1) + (n - i + 1) * n;
  }
  cout << dp[n] << '\n';
  // cerr << "dp(" << dp.size() << ") = {"; for (const auto& e : dp) cerr << e << ", "; cerr << "} (l." << __LINE__ << ")\n";
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define rep(i,N) for(ll i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1

ll mod_add(ll a, ll b) { return (a + b) % MOD; }
ll mod_sub(ll a, ll b) { return (a - b + MOD) % MOD; }
ll mod_mul(ll a, ll b) { return a*b % MOD; }

ll n;

priority_queue<ll,vector<ll>,greater<ll>> p;
priority_queue<ll> q;

int main(){
    cin >> n;
    vector<ll> a(3*n);
    rep(i,3*n)cin >> a[i];
    ll sum = 0;
    vector<ll> c1;
    rep(i,n){
        sum += a[i];
        p.push(a[i]);
    }
    c1.push_back(sum);
    FOR(i,n,2*n){
        p.push(a[i]);
        sum -= p.top();
        sum += a[i];
        c1.push_back(sum);
        p.pop();
    }
    // rep(i,c1.size()){
    //     cout << c1[i] << " ";
    // }
    // cout << endl;
    sum = 0;
    vector<ll> c2;
    FOR(i,2*n,3*n){
        sum += a[i];
        q.push(a[i]);
    }
    c2.push_back(sum);
    for(int i = 2*n-1;i >= n;i--){
        q.push(a[i]);
        sum -= q.top();
        sum += a[i];
        c2.push_back(sum);
        q.pop();
    }
    reverse(ALL(c2));
    ll ans = -INF;
    rep(i,c1.size()){
        // cout << c1[i] << " " << c2[i] << endl;
        ans = max(ans,c1[i] - c2[i]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 6516
from copy import deepcopy
n = int(input())
X = []
As = []
Bs = []
for i in range(n):
    A, B = list(map(int, input().split()))
    As.append(A)
    Bs.append(B)
As.sort()
Bs.sort()

if n % 2 == 1:
    m = (n-1) // 2
    print(Bs[m] - As[m] + 1)
else:
    b_m = n // 2 - 1
    a_m = b_m + 1
    min_mid =  (As[b_m] + As[a_m])
    max_mid =  Bs[b_m] + Bs[a_m]
    print(max_mid - min_mid + 1)

Measured memory_bytes: 25784
#include<stdio.h>
typedef long long ll;
ll gcd(ll a,ll b){return a%b==0?b:gcd(b,a%b);}
ll adj(ll a,ll b,ll m){
	if((a%m+m)%m>b)b+=m;
	return a+b-(a%m+m)%m;
}
bool work(){
	ll a,b,c,d,g;
	scanf("%lld%lld%lld%lld",&a,&b,&c,&d);
	if(b>a||b>d)return 0;
	g=gcd(b,d);
	return adj(c-b+1,a%g,g)>=0;
}
int main(){
	int T;
	scanf("%d",&T);
	while(T--)puts(work()?"Yes":"No");
}

Measured memory_bytes: 128
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>

//using ll = long long int;
#define PI 3.141592653589793
//141167095653376;

int main(void) {
	
	int a;
	scanf("%d", &a);
	printf("%d\n",a+a*a+a*a*a);
	return 0;
}

Measured memory_bytes: 1728
import heapq

def main():
    n, m = map(int, input().split())
    data = {}
    priorityQ = []
    for _ in range(n):
        a, b = map(int, input().split())
        if a <= m:
            if a in data:
                data[a].append(b)
            else:
                data[a] = [b]
    ans = 0
    for i in range(1, m+1):
        if i in data.keys():
            for k in data[i]:
                heapq.heappush(priorityQ, -k)
        if priorityQ:
            ans -= heapq.heappop(priorityQ)
    print(ans)
    return

if __name__ == "__main__":
    main()

Measured memory_bytes: 28916
#include<iostream>
 using namespace std ;
 int main()
{
short int c=0,price;
char s[3];

cin>>s;

if(s[0]=='o') ++c;
if(s[1]=='o') ++c;
if(s[2]=='o') ++c;

price=700+c*100;

cout<<price;

}

Measured memory_bytes: 3540
# include <bits/stdc++.h>
using namespace std;
int	n, K, a[100005];
int CC(int x) {
	return x < 0 ? 0 : (x + K - 1) / K;
}
int main() {
	// freopen("C.in", "r", stdin);
	scanf("%d %d", & n, & K), K --;
	for (int i = 1; i <= n; i ++)
		scanf("%d", a + i);
	int id = min_element(a + 1, a + n + 1) - a, 
		L = id - 1, 
		R = n - id, 
		ans = ~ 0u >> 2;
	for (int i = 0; i <= K; i ++)
		ans = min(ans, 	+ 1
						+ CC(L - i)
						+ CC(R - (K - i))	);
	printf("%d\n", ans);
	return 0;
}

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

using namespace std;

#define debug(n) cerr << #n << ':' << n << endl;
#define dline    cerr << __LINE__ << endl;

using ll = long long;
using ull = unsigned long long;
template<class T, class U> using P = pair<T,U>;
template<class T> using Heap = priority_queue<T>;
template<class T> using heaP = priority_queue<T,vector<T>,greater<T>>;
template<class T,class U> using umap = unordered_map<T,U>;
template<class T> using uset = unordered_set<T>;

template<class T>
bool ChangeMax(T&a,const T&b){
  if(a >= b) return false;
  a = b;    return true;
}

template<class T>
bool ChangeMin(T&a,const T&b){
  if(a <= b) return false;
  a = b;    return true;  
}

template<class T, size_t N, class U>
void Fill(T (&a)[N], const U&v){
    fill((U*)a,(U*)(a+N),v);
}

template<class T>
istream& operator >> (istream&is, vector<T>&v){
  for(auto&e:v)is >> e;
  return is;
}

int gcd(int x, int y){
  if(y==0)return x;
  return gcd(y,x%y);
}


int main(){
  int n; cin >> n;
  vector<int> v(n);cin >> v;
  sort(v.begin(), v.end());
  cout << v.back() - v.front() << endl;
}

 


Measured memory_bytes: 3628