akhauriyash/Code-Regression huggingface dataset:
n = int(input())
jisho = 'abcdefghijklmnopqrstuvwxyz'
moji = []
#print(moji)
for i in range(n):
    dic = {}
    for i in range(len(jisho)):
        dic.setdefault(jisho[i],0)
    s = str(input())
    for j in range(len(s)):
        dic.setdefault(s[j],0)
        dic[s[j]] += 1
    moji.append(dic)
dic = {}
for j in range(len(jisho)):
    tmp = 50
    for i in range(n):
        tmp = min(tmp,moji[i][jisho[j]])
    if tmp != 0:
        dic.setdefault(jisho[j],tmp)
#print(dic)
ans = ''
for item in dic.items():
    while dic[item[0]]>0:
        ans += item[0]
        dic[item[0]] -= 1
print(ans)

Measured memory_bytes: 9272
#pragma GCC optimize("Ofast")
#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 = 1001001001;

int main() {
    int a;

    cin >> a;

    cout << a+pow(a,2)+pow(a,3) << endl;

    return 0;
    
}

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

int main() {
    int a, b;
    cin >> a >> b;
    if(a>=13){
        cout << b << endl;
        return 0;
    }else if(a>=6){
        cout << b/2 << endl;
        return 0;
    }
    cout << 0 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=1;i<n;i++)
#define ll long long
int main(){
	int n;
	cin >> n;
	ll sum=0;
	rep(i,n+1){
		rep(j,n+1){
			rep(k,n+1){
				int gc = __gcd(i,j);
				int gd = __gcd(gc,k);
				sum+=gd;
			}
		}
	}
	cout << sum << endl;
}


Measured memory_bytes: 3624
#import numpy as np

N=int(input())
A=[int(c) for c in input().split()]

#A=np.array(A)






#大きい方から
for i in range(sorted(A)[1],1,-1):
#	if(np.sum(A%i==0)>=N-1):
	
	#check
	b=0
	j=0
	while(b<2):
		if(j==N):
			print(i)
			exit()
		if(A[j]%i!=0):
			b+=1
		j+=1
print(1)


Measured memory_bytes: 14052
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/STACK:256000000")
#define _USE_MATH_DEFINES
#include<iostream>
#include<vector>
#include<string>
#include<stack>
#include<algorithm>
#include<cmath>
#include<set>
#include<queue>
#include<sstream>
#include<utility>
#include<map>
#include<ctime>
#include<cstdio>
#include<cassert>
#include<functional>
#include<unordered_map>
#include<deque>
#include<cmath>





using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef pair<char, char> pcc;
typedef pair<double, double> pdd;

#define show(x) cerr << x
#define debug(x) show(#x << ": " << (x) << endl)

const long double PI = 3.14159265358979323846;
const long double eps = 1e-5;
const ll INF = numeric_limits<int>::max();
const ll LINF = numeric_limits<ll>::max();
//const ll mod = 1000 * 1000 * 1000 + 7;




void solve() {
    int a, b;
    string s;
    cin >> a >> s >> b;
    if (s[0] == '+')
        cout << a + b << endl;
    else 
        cout << a - b << endl;
}


//#define LOCAL

int main() {
    ios_base::sync_with_stdio(0);cin.tie(nullptr);cout.tie(nullptr);
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    solve();



#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif	
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <cmath>
#include <csignal>
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <string>
#include <vector>

using ll = long long;
using namespace std;

int main() {
    int n = 0;
    cin >> n;
    vector<int> a(n+1);
    for (int i=1; i<=n; i++) {
        cin >> a.at(i);
    }
    a.push_back(0);
    ll all = 0;
    for (int i=0; i<n+1; i++) {
        all += abs(a.at(i+1) - a.at(i));
    }
    for (int i=0; i<n; i++) {
        cout << all - abs(a.at(i) - a.at(i+1)) - abs(a.at(i+1) - a.at(i+2)) + abs(a.at(i) - a.at(i+2)) << endl;;
    }
    return 0;
}


Measured memory_bytes: 1656
import java.util.Scanner;
 
class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        if(a<b && b<c){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 26260
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<iomanip>
#include<queue>
#include<stack>
#include<time.h>
#define rep(i,n)for(int i=0;i<n;i++)
#define int long long
#define ggr getchar();getchar();return 0;
#define prique priority_queue
constexpr auto mod = 1000000007;
#define inf 1e15
#define key 1e9
using namespace std;
typedef pair<int, int>P;
void yes() { cout << "Yay!" << endl; }
void no() { cout << ":(" << endl; }
template<class T> inline void chmax(T& a, T b) {
	a = std::max(a, b);
}
template<class T> inline void chmin(T& a, T b) {
	a = std::min(a, b);
}
const int MAX = 330000;
int 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;
	}
}
int COMB(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;
}
bool prime(int n) {
	int cnt = 0;
	for (int i = 1; i <= sqrt(n); i++) {
		if (n % i == 0)cnt++;
	}
	if (cnt != 1)return false;
	else return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}
void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
	cerr << " " << to_string(H);
	debug_out(T...);
}

#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
struct edge { int to, cost; };
class UnionFind {
protected:
	int* par, * rank, * size;
public:
	UnionFind(unsigned int size) {
		par = new int[size];
		rank = new int[size];
		this->size = new int[size];
		rep(i, size) {
			par[i] = i;
			rank[i] = 0;
			this->size[i] = 1;
		}
	}
	int find(int n) {
		if (par[n] == n)return n;
		return par[n] = find(par[n]);
	}
	void unite(int n, int m) {
		n = find(n);
		m = find(m);
		if (n == m)return;
		if (rank[n] < rank[m]) {
			par[n] = m;
			size[m] += size[n];
		}
		else {
			par[m] = n;
			size[n] += size[m];
			if (rank[n] == rank[m])rank[n]++;
		}
	}
	bool same(int n, int m) {
		return find(n) == find(m);
	}
	int getsize(int n) {
		return size[find(n)];
	}
};
string s;
signed main() {
	cin >> s;
	if (s.size() % 2 == 1)puts("No");
	else {
		for (int i = 0; i < s.size(); i += 2) {
			if (s[i] != 'h') {
				puts("No");
				ggr
			}
		}
		for (int i = 1; i < s.size(); i += 2) {
			if (s[i] != 'i') {
				puts("No");
				ggr
			}
		}
		puts("Yes");
	}
	ggr
}

Measured memory_bytes: 256
import java.io.IOException;
import java.util.Scanner;

public class Main {
    public static void Solver(int A,int B,int C)
    {
        int sevenCount = 0;
        int fiveCount = 0;
        if(A == 5)
            fiveCount++;
        if(B == 5)
            fiveCount++;
        if(C == 5)
            fiveCount++;
        if(A == 7)
            sevenCount++;
        if(B == 7)
            sevenCount++;
        if(C == 7)
            sevenCount++;

        if(fiveCount == 2 && sevenCount == 1)
            System.out.println("YES");
        else
            System.out.println("NO");

    }
    public static void main(String[] args) throws IOException {
        Scanner input = new Scanner(System.in);

        Solver(input.nextInt(),input.nextInt(),input.nextInt());
    }
}


Measured memory_bytes: 21972
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)*}
    };
}

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

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!{
        a:i32,
        b:i32,
        c:i32
    }
    if a <= c && c <= b{
        println!("Yes")
    }else{
        println!("No");
    }
}


Measured memory_bytes: 4352
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<cstdio>
#include<set>
using namespace std;

typedef long long ll;

int main() {
  int N; cin >> N;
  int X[200010];
  int X2[200010];
  for ( int i = 1; i <= N; i++ ) {
    cin >> X[i];
    X2[i] = X[i];
  }
  sort(X2+1,X2+N+1);
  int med1 = X2[N/2],med2 = X2[N/2+1];
  //cout << med1 << endl;
  //cout << med2 << endl;
  for ( int i = 1; i <= N; i++ ) {
    if( X[i] <= med1  ) cout << med2 << endl;
    else cout << med1 << endl;
  }
  return 0;
}


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

int main() {
	ios_base::sync_with_stdio( false );

	string s;
	getline( cin, s );

	for( auto& c: s ) {
		if( c >= 'a' && c <= 'z' ) {
			c += 'A' - 'a';
		}
	}

	cout << s << endl;
}



Measured memory_bytes: 3024
import math
def fac(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr
def com(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
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
ans = 1
a,b = map(int,input().split())
l = fac(b)
for i in l:
  ans *= cmb(i[1]+a-1,a-1)
  ans = ans % (10**9 + 7)
if b == 1:
  print(1)
else:
  print(ans)

  
  

Measured memory_bytes: 9912
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    N = I()
    G = [[] for _ in range(N)]
    for _ in range(N - 1):
        a, b = LI_()
        G[a].append(b)
        G[b].append(a)
    c = LI()
    c.sort()

    # 最大の数は使われない、2番目に大きい数は、最大の数の隣のときだけ使われる
    # 深くなるほど小さくなるように置けば良い
    # DFSで置いていく
    ans = [0] * N
    def dfs(cur):
        ans[cur] = c.pop()
        for nxt in G[cur]:
            if ans[nxt] == 0:
                dfs(nxt)

    dfs(0)

    print(sum(ans[1:]))
    print(*ans)

if __name__ == '__main__':
    resolve()


Measured memory_bytes: 23160
S = list(input())

def way1():
    ans = 0
    for i in range(len(S)):
        if i % 2 == 0 and S[i] == "1":
            ans += 1
        elif i % 2 == 1 and S[i] == "0":
            ans += 1
    return ans

def way2():
    ans = 0
    for i in range(len(S)):
        if i % 2 == 0 and S[i] == "0":
            ans += 1
        elif i % 2 == 1 and S[i] == "1":
            ans += 1
    return ans


print(min(way1(), way2()))



Measured memory_bytes: 3956
/* ****revpro**** */

#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define endl	   '\n'
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll)x.size()
#define hell        1000000007
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define repr(i,a,b) for(ll i=b-1;i>=a;i--)    
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define mii	    map<ll,ll>
using namespace std;

#define N  100005
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int TESTS=1;
//	cin>>TESTS;
	while(TESTS--)
	{
		string s1,s2;
		cin>>s1>>s2;
		ll ans=0;
		rep(i,0,3) if(s1[i]==s2[i]) ans++;
		cout<<ans; 
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
 
int main()
{
	const long long MOD = 1000000007;
    long long n,f=1;
    cin >> n;
    for(long long i = 2; i <= n; i++)
	{
        f *= i;
        f %= MOD;
    }
    cout << f << endl;
	
    return 0;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template<class T,class U> using P = pair<T,U>;
template<class T> using vec = vector<T>;
template<class T> using vvec = vector<vec<T>>;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N,U,V;
    cin >> N >> U >> V;
    U--; V--;
    vvec<int> g(N);
    for(int i=0;i<N-1;i++){
        int a,b;
        cin >> a >> b;
        a--; b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    vec<int> distU(N,0),distV(N,0);
    auto dfs = [&](auto& self,int cur,int par,vec<int>& dist)-> void{
        for(auto& e:g[cur]) if(e!=par){
            dist[e] = dist[cur]+1;
            self(self,e,cur,dist);
        }
    }; 

    int ans = 0;
    dfs(dfs,V,-1,distV);
    dfs(dfs,U,-1,distU);
    for(int i=0;i<N;i++) if(distU[i]<distV[i]) ans = max(ans,distV[i]-1);
    cout << ans << endl;
}


Measured memory_bytes: 9216
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static void Main(string[] args)
    {
        var inputs = Console.ReadLine().Split(' ');
        var N = int.Parse(inputs[0]);
        var K = int.Parse(inputs[1]);

        var nums = Console.ReadLine().Split(' ');

        var list = new List<int>();

        foreach(var n in nums)
        {
            list.Add(int.Parse(n));
        }

        list.Sort();

        var ans = 0;
        for(var i = 0; i < K; i++)
        {
            ans += list[i];
        }

        Console.WriteLine(ans);

        Console.Read();
    }
}

Measured memory_bytes: 18580
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>
#include <iomanip>

#define intt long long
#define PI 3.14159265358979323846

using Graph = std::vector<std::vector<intt>>;
Graph G;

int main() {
    intt A, B, C, K; std::cin >> A >> B >> C >> K;
    for (int i = 0; i < K; ++i) {
        for (int j = 0; j < K - i; ++j) {
            if (A * std::pow(2, i) < B * std::pow(2, j) && B * std::pow(2, j) < C * std::pow(2, K-j)) {
                std::cout << "Yes" << std::endl;
                return 0;
            }
        }
    }
    std::cout << "No" << std::endl;
    return 0;
}

Measured memory_bytes: 3884
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int h = sc.nextInt();
		int w = sc.nextInt();
		sc.close();

		if (h % 3 == 0 || w % 3 == 0) {
			System.out.println(0);
			return;
		}

		long[] ans = new long[4];

		// 横2本
		ans[0] = w;

		// 縦2本
		ans[1] = h;

		// 縦＋横半分
		ans[2] = Long.MAX_VALUE;
		int end = w / 2;
		for (int i = w / 4; i <= end; i++) {
			long a = (long) h * i;
			long b = (long) h / 2 * (w - i);
			long max = Math.abs(a - b);
			if (h % 2 == 1) {
				long c = b + w - i;
				max = Math.max(max, Math.abs(a - c));
				max = Math.max(max, Math.abs(b - c));
			}
			ans[2] = Math.min(ans[2], max);
		}

		// 横＋縦半分
		ans[3] = Long.MAX_VALUE;
		end = h / 2;
		for (int i = h / 4; i <= end; i++) {
			long a = (long) w * i;
			long b = (long) w / 2 * (h - i);
			long max = Math.abs(a - b);
			if (w % 2 == 1) {
				long c = b + h - i;
				max = Math.max(max, Math.abs(a - c));
				max = Math.max(max, Math.abs(b - c));
			}
			ans[3] = Math.min(ans[3], max);
		}

		long ansM = ans[0];
		for (int i = 1; i < ans.length; i++) {
			ansM = Math.min(ansM, ans[i]);
		}
		System.out.println(ansM);
	}
}


Measured memory_bytes: 23380
#include <bits/stdc++.h>
//#include <ext/numeric>
//#include <ext/pb_ds/assoc_container.hpp> // Common file
//#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#define oo 0x3f3f3f3f
#define OO 0x3f3f3f3f3f3f3f3f
#define popcount(n) __builtin_popcount(n)
#define popcountll(n) __builtin_popcountll(n)
#define long long long

using namespace std;
//using namespace __gnu_cxx;
//using namespace __gnu_pbds;
//template<typename T>
//using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

const double PI = acos(-1.0);

const int MAXN = 3003;
int n, T;
pair<int, int> arr[MAXN];
int memo[MAXN][MAXN];

int solve(int idx, int t) {
//    cout << idx << ' ' << t  << endl;
    if (idx == n || t >= T)
        return 0;
    int &ret = memo[idx][t];
    if (~ret)
        return ret;
    ret = solve(idx + 1, t);
    ret = max(ret, solve(idx + 1, t + arr[idx].first) + arr[idx].second);
    return ret;
}


int main() {
#ifndef ONLINE_JUDGE
//    freopen("input.txt", "rt", stdin);
//    freopen("friday.out", "w", stdout);
#endif
    ios::sync_with_stdio(false), cin.tie(0), cout.tie(0), cout.precision(10), cout
            << fixed;

    int r;
    cin >> r;
    cout << r * r << '\n';



    return 0;
}

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

void printVector(vector<int> v) {
    for (auto x : v) {
        cout << x << ' ';
    }
    cout << '\n';
}

void printArray(ll A[], int size) {
    for (int i = 0; i <= size - 1; i++) cout << A[i] << ' ';
}

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

    int n, q;
    cin >> n >> q;
    string s;
    cin >> s;
    vector<int> v;
    int tot = 0;
    for (int i = 0; i <= n - 1; i++) {
        if (i + 1 <= n - 1 && s[i] == 'A' && s[i + 1] == 'C') tot++;
        v.push_back(tot);
    }
    for (int i = n - 1; i >= 1; i--) {
        //cout << 'h' << '\n';
        v[i] = v[i - 1];
    }
    v[0] = 0;
    //printVector(v);
    while (q--) {
        int l, r;
        cin >> l >> r;
        l--;
        r--;
        cout << v[r] - v[l] << '\n';
    }
    return 0;
}

Measured memory_bytes: 4100
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for(int i=0;i<(int)n;i++)
ll mod=1e9+7;
#define PI acos(-1)
struct edge{int from, to;};

int main(){
    int n;
    cin>>n;
    vector<int> a(n);
    rep(i,n) cin>>a[i];
    bool flag=true;

    rep(i,n){
        if(a[i]%2==0){
            if(a[i]%3==0 || a[i]%5==0){}
            else{
                cout<<"DENIED"<<endl;
                return 0;
            }
        }
    }
    cout<<"APPROVED"<<endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long int
using namespace __gnu_pbds;
typedef tree<pair<ll,pair<ll,ll> >, null_type, less<pair<ll,pair<ll,ll> > >, rb_tree_tag, tree_order_statistics_node_update>ordered_set;
#define me BOSS
#define bug() cout<<"AIkahne aise"<<endl
#define PI acos(-1)
/* Precode Start Here *\
     Sieve
void sieve()
{
    for(ll i=3; i<=2000; i+=2)
    {
        for(ll j=i*i; j<=4000000; j+=i)
            A[j]=1;
    }
    v.push_back(2);
    for(ll i=3; i<=4000000; i+=2)
        if(A[i]==0)
            v.push_back(i);
}

     Power Function Modulo P

ll modPow(ll a, ll x, ll p) {
    //calculates a^x mod p in logarithmic time.
    long res = 1;
    while(x > 0) {
        if( x % 2 != 0) {
            res = (res * a) % p;
        }
        a = (a * a) % p;
        x /= 2;
    }
    return res;
}


   factorial

ll fact(ll n)
{
    ll ans=1;
    for(ll i=1;i<=n;i++)
    {
        ans=(ans*i)%mod;
    }
    return ans;
}
     Calculating nCr using Fermats law Theorem

ll modInverse(ll a, ll p) {
    //calculates the modular multiplicative of a mod m.
    //(assuming p is prime).
    return modPow(a, p-2, p);
}


ll modBinomial(ll n, ll k, ll p) {
// calculates C(n,k) mod p (assuming p is prime).

    ll numerator = 1; // n * (n-1) * ... * (n-k+1)
    for (ll i=0; i<k; i++) {
        numerator = (numerator * (n-i) ) % p;
    }

    ll denominator = 1; // k!
    for (ll i=1; i<=k; i++) {
        denominator = (denominator * i) % p;
    }

    // numerator / denominator mod p.
    return ( numerator* modInverse(denominator,p) ) % p;
}
     num of divisor and euler totient

ll phi[1000001],mark[1000001],divi[1000001];;
void divisorPhi(ll n)
{
    for(int i=1;i<=n;i++)
        phi[i]=i;
    for(int i=2;i<=n;i++)
    {
        if(!mark[i])
        {
            for(int j=i;j<=n;j+=i)
            {
                mark[j]=1;
                phi[j]*=(1-1/(double)i);
            }
        }
    }
    for(ll i=1;i<=n;i++)
    {
        for(ll j=i;j<=n;j+=i)
            divi[j]++;
    }
}
/* Precode Ends */
#define mod 1000000007
ll A[5000001],B[5000001];
vector<ll>v;
map<ll,ll>myMap;
set<ll>mySet;
vector<pair<ll,ll> >vp;
priority_queue<ll> pq;
priority_queue<ll, vector<ll>, std::greater<ll> > first;
ll po(ll a,ll n)
{
  ll ans=1;
  for(int i=1;i<=n;i++)
       ans*=a;
    return ans;
}

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

ll ans=0;
string s;
cin>>s;
for(int i=0;i<s.size();i++)
{
    if(s[i]=='?')
        s[i]='D';
}
cout<<s<<endl;

return 0;
}



Measured memory_bytes: 3748
from itertools import product

N = int(input())
S = input()
pins = list(product([i for i in range(10)], repeat=3))
ans = 0
for pin in pins:
  i = 0
  for s in S:
    if pin[i] == int(s):
      i += 1
    if i == 3:
      ans += 1
      break
print(ans)

Measured memory_bytes: 68212
#include<cstdio>
#include<bits/stdc++.h>
typedef long long int ll;
#define REP(i, n) for(int i = 0; i < (n); i++)
#define FOR_IN(i, a, b) for(int i = (a); i < (b); i++)
#define BETWEEN(x, a, b) ((x) >= (a) && (x) <= (b))
#define BIT(b, i) (((b) >> (i)) & 1)
#define LOG_F 1
#define LOG(...) if(LOG_F) fprintf(stderr, __VA_ARGS__)

using namespace std;

ll pow(int x, int n){
  return n == 0 ? 1 : x * pow(x, n - 1);
}


/*
n
a1 b1
...
an bn

n 10^5
ai bi 10^9
 */
ll n;
ll c[1000000];

int main(){
  cin>>n;
  ll b_sum = 0;
  for(ll i=0; i<n; i++){
    ll a,b;
    cin>>a>>b;
    c[i]=a+b;
    b_sum+=b;
  }
  sort(c,c+n,greater<ll>());

  ll ans = -b_sum;
  for(ll i=0; i<n; i+=2){
    ans+=c[i];
  }

  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 1024
# import sys
# input = sys.stdin.readline

n = int(input())
C = [list(input().split()) for i in range(n)]
s = input()

ans = 0
a=0
for i in range(n):
    if a==1:
        ans += int(C[i][1])
    if s == C[i][0]:
        a = 1
print(ans)

Measured memory_bytes: 38384
#include <iostream>
#include <vector>
#include <algorithm>
#define ll long long 
using namespace std;

vector<ll> divisor(ll n) 
{
vector<ll> res;
for (int i = 1; i * i <= n; i++) {
if (n % i == 0) {
res.push_back(i);
if (i != n / i) res.push_back(n / i);
}
}
return res;
}


int main()
{
    ll x;
    cin>>x;
    vector <ll>y=divisor(x);
    sort(y.begin(),y.end());
ll v,w;
ll a,b;
for(int i=0;i<y.size();i++)
{v=0;w=-y[i];
    while(w<=1 || v*v*v*v*v-w*w*w*w*w<=x)
    {if(v*v*v*v*v-w*w*w*w*w==x)break;
     else{v++;w++;}
    }if(w<=1 || v*v*v*v*v-w*w*w*w*w<=x)break;
}
cout <<v<<" "<<w;

}



Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
int A,B,K;
int main(){
  cin >> K >> A >> B;
  if(A%K == 0){
    cout << "OK" << endl;
  }
  else{
    if(((A/K)+1)*K <= B){
      cout << "OK" << endl;
    }
    else{
      cout << "NG" << endl;
    }
  }
}

Measured memory_bytes: 3632
def mapint_inp():
    return map(int, input().split())

def intinp():
    return int(input())

# 学びたいアルゴリズムの数 M
# 参考書の数 N
# i番目の参考書はC_i円
# j番目のアルゴリズムの理解度がA_i,j上昇
# 理解度の目標値 X
# -> 全てをX以上にしたい
# 可能な場合金額の最小値、不可能な場合 -1

N, M, X = mapint_inp()
CA = [list(mapint_inp()) for _ in range(N)]

total_value_and_understanding_value = []

def add_each_element_in_list(l1, l2):
    return [a + b for a, b in zip(l1, l2)]


totals = []
for i in range(2**N):
    t = []
    for j in range(N):
        if ((i >> j) & 1):
            if t:
                t = add_each_element_in_list(t, CA[j])
                continue
            t = CA[j]
    if t:
        totals.append(t)

def check_X(l):
    for i in range(M+1):
        if i == 0:
            continue
        if l[i] < X:
            return False
    return True

import math
ans = math.inf
f = False
for total in totals:
    if check_X(total):
        ans = min(total[0], ans)

if ans == math.inf:
    print(-1)
else:
    print(ans)
    


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

int main() {
    int x;
    cin >> x;
    int g=x/100;
    int h=x-g*100;
    int ans=0;
    while (h>5){
        h -= 5;
        ans+=1;
    }
    if(h==0 && ans<=g){
        cout << 1 << endl;
    }
    else if(ans+1<=g){
        cout << 1 << endl;
    }
    else
    {
        cout << 0 <<endl;
    }
    
    
}

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

int main(){
    priority_queue<int,vector<int>,greater<int>> a;
    int l , m , n;
    cin >> l >> m >> n;
    a.push(l);
    a.push(m);
    a.push(n);
    cout << a.top() << " ";
    a.pop();
    a.pop();
    cout << a.top() << endl;
    return 0;
}


Measured memory_bytes: 3172
/*
Author: Vishesh Gupta
E mail: visheshguptavgr@gmail.com
*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define newline ("\n")
#define deb(n) cerr << #n << " = " << (n) << '\n'
#define FOR(i, n) for (int(i) = 0; (i) < n; (i)++)
#define PI (3.141592653589)

#define ordered_set tree<int, null_type, std::less<int>, rb_tree_tag, tree_order_statistics_node_update>

#define MOD 1000000007

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed;
    cout.precision(1);
    //start coding here

    float d, t, s, s1;
    cin >> d >> t >> s;
    s1 = d/t;
    if(s>=s1)
        cout << "Yes" << newline;
    else
    {
        cout << "No" << newline;
    }
    
    return 0;
}


Measured memory_bytes: 3684
/*The woods are lovely, dark and deep,
But I have promises to keep,
And miles to go before I sleep,
And miles to go before I sleep.*/

//PRABHJOT SINGH A.K.A. PRABHI
//~~~~~conquizztador~~~~~


#include<bits/stdc++.h>
using namespace std;
using lli = long long int;
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
const int MOD = 1000000007;
const int MOD1 = 998244353;
const int maxn = 100010;
const int lim = (int)1e9;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n = 0, a = 0, b = 0;
	cin >> n >> a >> b;
	cout << min(n * a, b) << endl;
}

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

int main(void){
    int n,m,q;cin >> n >> m >> q;
    vector<vector<int>> s(n+2,vector<int>(n+2,0));
    
    int num[575][770] = {};
    rep(i,m){
        int l,r;cin >> l >> r;
        num[max(l,r)-1][min(r,l)-1]++;
    }
    for(int i = 1;i < n+1;i++){
        for(int j = 1;j < n+1;j++){
            s[i][j] = s[i][j-1] + s[i-1][j] - s[i-1][j-1] + num[i-1][j-1];
        }
    }
    
    rep(i,q){
        int alina,gray;cin >> alina >> gray;
        int l = max(alina,gray),r = min(alina,gray);
        
        int sum = s[l][l] - s[r-1][l] - s[l][r-1] + s[r-1][r-1];
        
        cout << sum << endl;
    }
}

Measured memory_bytes: 6344
#[allow(unused_imports)]
use std::char::*;
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;

#[allow(unused_macros)]
macro_rules! debug {($($a:expr),*) => {println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);}}
#[allow(unused_macros)]
macro_rules! input { ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; let mut next = || { iter . next ( ) . unwrap ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; ( $ ( $ r : tt ) * ) => { let stdin = std :: io :: stdin ( ) ; let mut bytes = std :: io :: Read :: bytes ( std :: io :: BufReader :: new ( stdin . lock ( ) ) ) ; let mut next = move || -> String { bytes . by_ref ( ) . map ( | r | r . unwrap ( ) as char ) . skip_while ( | c | c . is_whitespace ( ) ) . take_while ( | c |! c . is_whitespace ( ) ) . collect ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules! input_inner { ( $ next : expr ) => { } ; ( $ next : expr , ) => { } ; ( $ next : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules! read_value { ( $ next : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ next , $ t ) ) ,* ) } ; ( $ next : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ next , $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ next : expr , chars ) => { read_value ! ( $ next , String ) . chars ( ) . collect ::< Vec < char >> ( ) } ; ( $ next : expr , usize1 ) => { read_value ! ( $ next , usize ) - 1 } ; ( $ next : expr , $ t : ty ) => { $ next ( ) . parse ::<$ t > ( ) . expect ( "Parse error" ) } ; }

#[derive(PartialEq, PartialOrd)]
pub struct Total<T>(pub T);
impl<T: PartialEq> Eq for Total<T> {}
impl<T: PartialOrd> Ord for Total<T> { fn cmp(&self, other: &Total<T>) -> std::cmp::Ordering { self.0.partial_cmp(&other.0).unwrap() }}

#[allow(dead_code)]
const MAX:usize = 100006;
#[allow(dead_code)]
const INF_U32:u32 = 1 << 31;
#[allow(dead_code)]
const INF_I32:i32 = 1 << 30;
#[allow(dead_code)]
const INF_U64:u64 = 1 << 63;
#[allow(dead_code)]
const INF_I64:i64 = 1 << 62;
#[allow(dead_code)]
const MOD:i64 = 1e9 as i64 + 7;


fn main() {
    input!{s:chars};
    let mut map = HashMap::new();

    for ch in s {
        let mut count = map.entry(ch).or_insert(0);
        *count += 1;
    }
    println!("{}", if map.iter().filter(|&(_ch, x)| *x%2!=0).count() > 0 {"No"} else {"Yes"});
}

Measured memory_bytes: 4352
#include<iostream>
using namespace std;
int main(){
  int a,b,k;
  cin>>a>>b>>k;
  for(int i=min(a,b);i>=1;i--){
    if(a%i==0&&b%i==0){
      k--;
    }
    if(k==0){
      cout<<i<<endl;
      break;
    }
  }
return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define nl "\n"
#define rep(i,n) for(ll i=0; i<(n); i++)
#define INF ((1LL<<62)-(1LL<<31))
#define MOD 1000000007 //998244353
typedef vector<ll> vl;
typedef vector<vector<ll>> matrix;//matrix A(n, vl(m)); //n*m行列
typedef vector<string> vs;
typedef pair<ll,ll> pl;
typedef vector<pl> vp;
typedef vector<bool> vb;
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define sortup(V) sort(V.begin(), V.end())
#define sortdown(V) sort(V.rbegin(), V.rend())
template<class T>bool chmax(T &a, const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a, const T &b){if(b<a){a=b;return 1;}return 0;}
void CumuSum(vl &A){rep(i,A.size())if(i)A[i]+=A[i-1];}
ll llpow(ll e,ll x){ll res=1LL;while(x){if(x&1)res*=e;e*=e;x/=2;}return res;}
ll llpowMOD(ll e,ll x){ll res=1LL;while(x){if(x&1)res*=e;e*=e;x/=2;res%=MOD;e%=MOD;}return res;}

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

    // solution comes here

    ll X, Y, ans=0;
    cin >> X >> Y;

    while(X <= Y) {
        ans++;
        X *= 2;
    }

    cout << ans << nl;
}

Measured memory_bytes: 256
H, W = map(int, input().split())
sharp = "#"

a = []
for i in range(H):
    A = input()
    A = "#" + str(A) + "#"
    a.append(A)
print(str(sharp*(W+2)))
for i in range(H):
    print(a[i])
print(str(sharp*(W+2)))


Measured memory_bytes: 3060
//include
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>

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

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

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

template <class T>
inline T nCr(T n, T r)
{
    T num = 1;
    for (int i = 1; i <= r; ++i)
    {
        num *= (n - i + 1) / i;
    }
    return num;
}
template <class T>
inline T nPr(T n, T r)
{
    r = n - r;
    T sum = 1;
    int i;
    for (i = n; i >= r + 1; --i)
        sum *= i;
    return sum;
}

template <class T>
inline T facctorial(T k)
{
    T sum = 1;
    for (int i = 1; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;
}

//numeric
template <class T>
inline T gcd(T a, T b)
{
    if (a < b)
    {
        a ^= b;
        b ^= a;
        a ^= b;
    }

    return b ? gcd(b, a % b) : a;
}

template <class T>
inline T lcm(T a, T b)
{
    return a * b / gcd(a, b);
}

//typedef
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) int((a).size())
#define EACH(i, c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())

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

//constant
constexpr double EPS = 1e-10;
const double PI = acos(-1.0);
constexpr LL INF = 1e10;

//clear memory
#define CLR(a) memset((a), 0, sizeof(a))

//debug
#define dump(x) cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
                      << " " << __FILE__ << endl;

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


Measured memory_bytes: 256
n,k = map(int,input().split())
lst = [int(input()) for i in range(n)]
lst.sort()
for i in range(n-k+1):
    if i==0:
        m = lst[k-1]-lst[i]
    else:
        if lst[k+i-1]-lst[i] < m:
            m = lst[i+k-1]-lst[i]
print(m)

Measured memory_bytes: 7384
#include<stdio.h>
int main()
{
	int i,j,n,a[200001],m,l=0;
scanf("%d",&n);
for(m=0;m<n;m++)
scanf("%d",&a[m]);
for(i=0;i<n-1;i++)
   {
    for(j=i+1;j<n;j++)
    l=l+(a[i]*a[j]);
   }
   
   printf("%d",l);
   return 0;
   }

Measured memory_bytes: 128
#include<cstdio>
#include<cstring>
#include<vector>
using namespace std;
#define MN 300
#define MOD 1000000007
int f[2][MN+5][MN+5];
vector< pair<int,int> > v[MN+5];
inline void rw(int&a,int b){if((a+=b)>=MOD)a-=MOD;}
int main()
{
	int n,m,l,r,i,j,k,ans=0;
	scanf("%d%d",&n,&m);
	while(m--)scanf("%d%d%d",&l,&r,&i),v[r].push_back(make_pair(l,i));
	f[0][0][0]=1;
	for(i=0;i<n;++i)
	{
		memset(f[~i&1],0,sizeof(f[~i&1]));
		for(j=0;j<=i;++j)for(k=0;k<=j;++k)if(f[i&1][j][k])
			rw(f[~i&1][j][k],f[i&1][j][k]),
			rw(f[~i&1][i][k],f[i&1][j][k]),
			rw(f[~i&1][i][j],f[i&1][j][k]);
		for(l=0;l<v[i+1].size();++l)for(j=0;j<=i;++j)for(k=0;k<=j;++k)
			if(1+(j>=v[i+1][l].first)+(k>=v[i+1][l].first)!=v[i+1][l].second)f[~i&1][j][k]=0;
		if(i+1==n)for(j=0;j<=i;++j)for(k=0;k<=j;++k)rw(ans,f[~i&1][j][k]);
	}
	printf("%d",ans);
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std ;
#define ll long long
inline int D(){
    int t ;
    scanf( "%d" , &t ) ;
    return t ;
}
inline ll LLD(){
    ll t ;
    scanf( "%lld" , &t ) ;
    return t ;
}


//#########################################

int main() {

int n=D();
int y= n/15;
cout<<(n*800)-(y*200);




}




Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<stdio.h>
#include<string.h>
using namespace std;
typedef  long long ll;
int A,B,C,D;
int main(){
    int ans=0;
    scanf("%d%d%d%d",&A,&B,&C,&D);
     ans+=(min(A,B)+min(C,D));
    printf("%d",ans);
    return 0;
}


Measured memory_bytes: 256
import numpy as np
h, w = list(map(int, input().split()))
ss = []
for _ in range(h):
    s = input()
    s = s.replace(".", "0").replace("#", "1")
    s = list(map(int, list(s)))
    ss.append(s)
ss = np.array(ss)
    

dp = np.zeros((h, w)).astype(np.int32)
if ss[0,0] == 1:
    dp[0,0] = 1
    

for kh in range(h):
    for kw in range(w):
#         print(kh, kw)
#         print(dp)
        if kh == 0 and kw == 0:
            continue
        if kh == 0:
            a = 9999
        else:
            if ss[kh - 1, kw] == 0 and ss[kh, kw] == 1:
                a = dp[kh - 1, kw] + 1
            else:
                a = dp[kh - 1, kw]

        if kw == 0:
            b = 9999
        else:
            if ss[kh, kw - 1] == 0 and ss[kh, kw] == 1:
                b = dp[kh, kw - 1] + 1
            else:
                b = dp[kh, kw - 1]

        dp[kh, kw] = min([a, b])

print(dp[-1, -1])

Measured memory_bytes: 22160
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int max_n=200005;
const int mod=1e9+7;
int n;
char s[max_n];
int a[max_n];
int main(){
    scanf("%d %s",&n,s+1);
    for(int i=1;i<=n*2;i++)a[i]=s[i]!='W';
    int ans=1,c=0;
    for(int i=1;i<=n*2;i++){
        if(a[i]!=c%2)c++;
        else{
            ans=1ll*ans*c%mod;
            c--;
            if(c<0){
                printf("0\n");
                return 0;
            }
        }
    }
    if(c!=0)ans=0;
    for(int i=1;i<=n;i++)ans=1ll*ans*i%mod;
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 1280
h,w = map(int,input().split())
n = int(input())
a = list(map(int,input().split()))

ret = []
iv = 0
for i in range(h):
    s = ""
    for j in range(w):
        v = str(iv+1)
        a[iv] -= 1
        if a[iv] == 0: iv += 1
        if i%2 == 0:
            s = s+" "+v if s != "" else v
        else:
            s = v + " " + s
    print(s)

Measured memory_bytes: 3188
//NEVER LOSE HOPE 
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")
#define fastio ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#include <bits/stdc++.h>
#define int long long int
#define vi vector<int>
#define pi pair<int,int>
#define si set<int>
#define mi map<int,int>
#define ff first
#define ss second
#define pb push_back
#define all(v) v.begin(),v.end()
#define gi greater<int>()
#define mp make_pair
#define endl "\n"

//to count no of digits //floor(log10(n) + 1)

#define lb lower_bound //a,a+n,4 -a==index of 4  // returns pointer to the "first position of num" if number is present in the container. Returns pointer to the "position of next higher number greater than num" if num is not present.   
#define ub upper_bound // returns pointer to the "first position of the next higher number than last occurence of num" if num is present in the container. Returns pointer to the position of next higher number than num if container does not contain occurence of num.
#define REP(i,n) for(int i=0;i<n;i++)
#define REPE(i,n) for(int i=n-1;i>=0;i--)
#define REPA(i,a,n) for(int i=a;i<=n;i++)
 
//next_permutation(s.begin(),s.end())
//*max_element(a,a+n)
#define mod 1000000007
int N=INT_MAX;
using namespace std;

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

int gcd(int a,int b)
{
    if(b==0)return a;
    return gcd(b,a%b);
}
int lcm(int a,int b)
{
    return a/gcd(a,b)*b;
 
}

  
 //JAI SHREE RAM  //JAI SHREE RAM //JAI SHREE RAM  //JAI SHREE RAM
///////////////// MAIN FUNCTION ////////////////////////

 void CSK()
 {
  int a,b,c;
  cin>>a>>b>>c;
  if(b>=a){
    cout<<c<<endl;
  }
  else{
    if(a%b==0)
    {
      cout<<(a/b)*c<<endl;
    }
    else{
      cout<<((a/b)+1)*c<<endl;
    }
  }
 
    

  





   



    




  




    

















}
///////////////////////// END //////////////////////////////////////  
  
 

 
 
 
int32_t main()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif 
    fastio;
    cout<<fixed;
    cout.precision(10);
    int __TESTCASES=1;
    //cin>>__TESTCASES;
    while(__TESTCASES--){
    CSK();  
}
 
}

Measured memory_bytes: 3644
#include<iostream>
#include<climits>
#include<math.h>
#include<vector>
#include<algorithm>
#include<cstdio>
#include <string>
#include <complex>
#include <functional>
using namespace std;
typedef pair<int,int> P;
double dat[100][100];
int dp[1000001];//動的計画法
int prime[1000001];

long long gcd(long long a,long long b){
    return b?gcd(b,a%b):a;
}

int main(){
   long a,b,c,d;
   int n;
   cin>>n;
   for(int i=0;i<n;i++){
       cin>>a>>b>>c>>d;
       if(a<b){
           cout<<"No"<<endl;
           continue;
       }
       if(b>d){
           cout<<"No"<<endl;
           continue;
       }
       if(c>=b){
           cout<<"Yes"<<endl;
           continue;
        }
        long long g=gcd(b,d);
        a=a%b;
        long long k=(b-a)/g;
        if((b-a)%g==0) k--;
        if(a+k*g>c){
            cout<<"No"<<endl;
            continue;
        }
        else cout<<"Yes"<<endl;
   }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define pb push_back
#define pf push_front
#define ft first
#define sc second
#define all(v) v.begin(), v.end()
using namespace std;
const int maxn = 10000010, mod = 998244353;
int dl[maxn];
int nm[maxn];
int cnt[maxn];
int bg[maxn];
signed main() {
    ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    int n;
    cin >> n;
    ll sum = 0;
    cnt[1] = 1;
    dl[1] = 1;
    bg[1] = 1;
    for (int d = 2; d < maxn; d++) {
        if (dl[d] == 0) {
            dl[d] = d;
            nm[d] = 1;
            bg[d] = 1;
            ll g = d;
            g = g * g;
            if (g < maxn) {
                for (int i = g; i < maxn; i+=d) {
                    if (dl[i] == 0) {
                        dl[i] = d;
                    }
                }
            }
        }
    }
    sum = 1;
    for (int d = 2; d <= n; d++) {
        if (dl[d / dl[d]] != dl[d]) {
            cnt[d] = cnt[d / dl[d]] * 2;
            nm[d] = 1;
            bg[d] = d / dl[d];
        } else {
            nm[d] = nm[d / dl[d]] + 1;
            bg[d] = bg[d / dl[d]];
            cnt[d] = cnt[bg[d]] * (nm[d] + 1);
        }
        sum += (ll)d * cnt[d];
        //cout << d << " " << cnt[d] << "\n";
    }
    cout << sum;
}


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

int main(){
	int i,j,k,n,m,l,f,x,y,z; string s;
	cin >> n >> l;
	string t[105];
	rep(i, n) cin >> t[i];
	sort(t, t+n);
	rep(i, n){
		cout << t[i];
	}
	cout << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <sstream>
#include <utility>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <cmath>
#include <functional>
#include <chrono>
#include <cstring>
#include <limits.h>

using namespace std;
typedef long long lint;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef vector<lint> vl;
typedef pair<lint,lint> pll;

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

    int n; cin>>n;
    vi a(n);
    bool one = false;
    string s; cin>>s;
    for (int i=0; i<n; ++i){
        int &v = a[i];
        v = s[i]-'1';
        //cin>>v; v--;
        if (v==1) one=true;
    }

    auto last = [](vi a){
        int n = a.size();
        int res = 0;
        for (int i = 0; i<n; ++i){
            int cn_1i = (((n-1)|i) == (n-1))?1:0;
            if (cn_1i) res = res^a[i];
        }
        return res;
    };

    if (!one){
        cout<<last(a);
    } else {
        for (int &v: a) if (v==2) v=0;
        cout<<last(a);
    }


}


Measured memory_bytes: 9116
use proconio::*;

fn main() {
    input!{
        a: f64,
        b: f64,
        h: f64,
        m: f64,
    }

    let hrad = 360f64 * (h / 12f64) + (360f64 / 12f64) * (m / 60f64);
    let mrad = 360f64 * (m / 60f64);

    let rad_diff_pi = (hrad - mrad).abs().min((360f64 - (hrad - mrad)).abs());
    let rad_diff_pi = rad_diff_pi / 180f64 * std::f64::consts::PI;

    let ans = (a*a + b*b - 2f64 * a * b * rad_diff_pi.cos()).sqrt();

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


Measured memory_bytes: 3044