akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int gu = 0;
    int ki = 0;
    for(int i = 0; i < n; i++) {
      int a = sc.nextInt();
      if(a % 2 == 0) {
        gu++;
      } else {
        ki++;
      }
    }
    long ans = (long)Math.pow(3, n) - (long)Math.pow(2, gu);
    System.out.println(ans);
  }
}

Measured memory_bytes: 21844
#include <stdio.h>

int main(){
  int x[10000], i;

  for(i=1;i<=10000;i++) {
    scanf("%d", &x[i]);
    if(x[i]==0) break;
  }

  for(i=1;i<=10000;i++) {
    if(x[i]==0) break;
    printf("Case %d: %d\n",i, x[i]);
  }


  return 0;
}



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

typedef long long int int64;

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))

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

int calc(int index,int *d,int *f){
  if(index>12){
    int min=24;
    int i,j;
    i=0;
    j=1;
    while(j<=24){
      if(f[j]>=2) return 0;
      if(f[j]==1){
	min=MIN(min,j-i);
	i=j;
	j=j+1;
      } else {
	j++;
      }
    }
    return min;
  }
  if(index==12){
    int t;
    if(d[12]>0){
      f[12]=1;
      t=calc(index+1,d,f);
      f[12]=0;
    } else {
      t=calc(index+1,d,f);
    }
    return t;
  }
  if(d[index]==0) return calc(index+1,d,f);
  if(d[index]==2){
    f[index]=1;
    f[24-index]=1;
    int t=calc(index+1,d,f);
    f[index]=0;
    f[24-index]=0;
    return t;
  }
  f[index]=1;
  int t=calc(index+1,d,f);
  f[index]=0;
  f[24-index]=1;
  t=MAX(t,calc(index+1,d,f));
  f[24-index]=0;
  return t;
}

void run(void){
  int n;
  scanf("%d",&n);
  if(n>=25){
    printf("0\n");
    return;
  }
  int d[13];
  int i;
  for(i=0;i<=12;i++) d[i]=0;
  for(i=0;i<n;i++){
    int t;
    scanf("%d",&t);
    d[t]++;
  }
  if(d[0]>0){
    printf("0\n");
    return;
  }
  for(i=1;i<12;i++){
    if(d[i]>2){
      printf("0\n");
      return;
    }
  }
  if(d[12]>=2){
    printf("0\n");
    return;
  }
  //d[0]=0, d[i]<=2, d[12]<=1

  int f[25];
  for(i=0;i<=24;i++) f[i]=0;
  f[0]=1;
  f[24]=1;
  int s=calc(0,d,f);
  printf("%d\n",s);
  return;
}

int main(void){
  run();
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define int long long
using ll=long long;
using vi=vector<int>;
using vl=vector<long long>;
using pii=pair<int,int>;
using pll=pair<long long,long long>;
#define ITR(i,c) for(auto i=begin(c);i!=end(c);++i)
#define FORE(x,c) for(auto &x:c)
#define REPF(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define REP(i,n) REPF(i,0,n)
#define REPR(i,n) for(int i=(int)(n);i>=0;--i)
#define REPW(i,n) for(i=0;i<(int)(n);++i)
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)   // c++14
#define SZ(c) ((int)c.size())
#define EXIST(c,x) (c.find(x)!=end(c))
#define OUTOFRANGE(y,x,h,w) (y<0||x<0||y>=h||x>=w)
#define dump(...)
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
#define INF (1001001001)
#define INFLL (1001001001001001001ll)
template<class T> ostream& operator << (ostream &os,const vector<T> &v) {
    ITR(i,v) os << *i << (i==end(v)-1 ? "" : " "); return os; }
template<class T> istream& operator >> (istream &is,vector<T> &v) {
    ITR(i,v) is >> * i; return is; }
template<class T> istream& operator >> (istream &is, pair<T,T> &p) {
        is >> p.first >> p.second; return is; }
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;}
//------------------------------------------------------------------------------
struct before_main_function {
    before_main_function() {
        #ifdef int
            #undef INF
            #define INF INFLL
            #define stoi stoll
        #endif
        cin.tie(0);ios::sync_with_stdio(false);
        cout<<setprecision(15)<<fixed;
    }
} before_main_function;
//------------------------------------------------------------------------------

signed main() {
    string a,b,c;
    cin>>a>>b>>c;
    cout<<((*rbegin(a)==*begin(b) && *rbegin(b)==*begin(c)) ? "YES" : "NO")<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<cstring>
#include<cstdlib>
#include<cstdio>
#include<cmath>
#include<iostream>
#define N 1100000
using namespace std;
char s[N],t[N];
int p[N],head,tail,n,f[N],ans;
int main()
{
	scanf("%d",&n);
	scanf("%s",s+1);
	scanf("%s",t+1);
	bool bo=1;
	for(int i=1;i<=n;i++) if(s[i]!=t[i]) {bo=0;break;}
	if(bo) {printf("0\n");return 0;}
	int j=n;
	for(int i=n;i>=1;i--)
	{
		j=min(j,i);
		while(j && s[j]!=t[i]) j--;
		if(j==0) {printf("-1\n");return 0;}
		f[i]=j;
	}
	head=1;tail=0;
	for(int i=n;i>=1;i--)
	{
		while(head<=tail && p[head]-(tail-head)>i) head++;
		if(f[i]!=f[i+1]) p[++tail]=f[i];
		ans=max(ans,tail-head+1);
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 10880
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i=(a); i<(int)(b); i++)
#define PPC(x) __builtin_popcount(x)
#define pb push_back
#define ALL(x) (x).begin(), (x).end()
#define st first
#define nd second
using namespace std;
 
const int maxN = 1 << 19;
const long long INF = 5000000000000000000ll;

typedef pair <long long, long long> Irvl_t;

template <class T1, class T2> inline void remin(T1& a, T2 b)	{   a = min(a, (T1)b);  }
template <class T1, class T2> inline void remax(T1& a, T2 b)	{   a = max(a, (T1)b);  }

map <long long, set <Irvl_t> > M;

void mrg(Irvl_t& a, Irvl_t b)
{
	remin(a.st, b.st);
	remax(a.nd, b.nd);
}

bool check(Irvl_t& p, set<Irvl_t>& S)
{
	auto it = S.lower_bound({p.first, -INF});
	if (it != S.end() and it->first <= p.second)
	{
		mrg(p, *it);
		S.erase(it);
		return true;
	}
	
	if (it == S.begin())
		return false;
		
	it = prev(it);
	
	if (it->second >= p.first)
	{
		mrg(p, *it);
		S.erase(it);
		return true;
	}
	
	return false;
}

void solve()
{
	int n;
	long long x, d;
	scanf ("%d%lld%lld", &n, &x, &d);
		
	long long s0 = 0ll, s1 = 0ll, mod = llabs(d);
	M[0].insert({0ll, 0ll});
	
	if (mod == 0ll)
	{
		printf("%d\n", x == 0ll ? 1 : n+1);
		return;
	}
	
	FOR(m, 1, n+1)
	{
		s0 += m-1;
		s1 += n-m;
		long long a = d * s0 + x * m;
		long long b = d * s1 + x * m;
		if (b < a)
			swap(a, b);
		long long r = x * m;
		r %= mod;
		r += mod;
		r %= mod;
		set <Irvl_t>& S = M[r];

		pair <long long, long long> p = {a, b};
		while (check(p, S));
		S.insert(p);
	}
	
	long long res = 0ll;
	for (auto p : M)
	{
		auto S = p.second;
		for (auto it : S)
			res += (it.second - it.first) / mod + 1ll;
	}
	
	printf("%lld\n", res);
}
 
int main()
{
	int t;
	t=1;//scanf ("%d", &t);
	while (t--)
		solve();
	return 0;
}


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

a=[int(_) for _ in input().split()]
b=[int(_) for _ in input().split()]

m=sum(b)-sum(a)
l=0
for i in range(n):
  if a[i]<b[i]:
    l+= (b[i]-a[i]+1)//2
    
if l>m:
  print("No")
else:
  print("Yes")

Measured memory_bytes: 4600
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<cstring>
#include<vector>
#include<cmath>
#include<queue>
#include<stack>
using namespace std;
#define INT(x) int x; scanf("%d",&x)
#define LL(x) ll x; scanf("%lld",&x)
#define INPUT(x) cin >> x
#define REP1(x,n) for(int x = 0; x < n; x++)
#define REP2(x,s,e) for(int x = s; x <= e; x++)
#define RREP1(x,n) for(int x = n-1; x >= 0; x--)
#define RREP2(x,s,e) for(int x = s; x >= e; x--)
#define BR printf("\n")
#define INF_INT 2147483647
#define INF_LL 9223372036854775807

typedef long long ll;

bool flag(string s){
    string yaki = "YAKI";
    if (s.size() < 4) {
        return false;
    }
    REP1(i, 4){
        if(yaki[i] != s[i]) return false;
    }
    
    return true;
}

int main(){
    string s;
    
    cin >> s;
    
    if (flag(s)) {
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
	string s1;
	cin>>s1;
	int n=s1.size();
	int a1=0,a2=0;
	for(int i=0;i<n;i++)
	{
		if(s1[i]=='C')
		a1++;
		if(s1[i]=='F' and a1)
		a2++;
	}
	if(a1 and a2)
	cout<<"Yes\n";
	else
	cout<<"No\n";
	return 0;
}

Measured memory_bytes: 256
#[test]
fn test_solve() {
    assert_eq!(solve("3\n2 3\n1 1\n3 2\n"), "10\n");
    assert_eq!(solve("4\n1 1\n1 1\n1 5\n1 100\n"), "101\n");
    assert_eq!(solve("5\n3 10\n48 17\n31 199\n231 23\n3 2\n"), "6930\n");
}

fn solve(src: &str) -> String {
    let mut sc = Scanner::from_str(src);

    let n: usize = sc.read();
    let mut tk = 1;
    let mut ao = 1;
    for _ in 0..n {
        let t: usize = sc.read();
        let a: usize = sc.read();
        let tu = (tk + t - 1) / t;
        let au = (ao + a - 1) / a;
        let u = std::cmp::max(tu, au);
        tk = u * t;
        ao = u * a
    }

    format!("{}\n", tk + ao)
}

fn main() {
    let mut buf = String::new();
    use std::io;
    use std::io::{Read, Write};
    io::stdin().read_to_string(&mut buf).unwrap();
    io::stdout().write_all(solve(&buf).as_bytes()).unwrap();
}

struct Scanner<'a>(std::str::SplitWhitespace<'a>);
impl<'a> Scanner<'a> {
    fn from_str(src: &str) -> Scanner {
        Scanner(src.split_whitespace())
    }
    fn get(&mut self) -> &str {
        self.0.next().unwrap()
    }
    fn read<T: std::str::FromStr>(&mut self) -> T {
        self.get().parse().ok().unwrap()
    }
}

Measured memory_bytes: 4352
N = int(input())
X = [[i] + list(map(int, input().split())) for i in range(N)]

class UnionFind:
    def __init__(self, n):
        self.par = list(range(n))
        self.rank = [0] * n
        
    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]
        
    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)
        
        if x == y:
            return
        
        if self.rank[x] == self.rank[y]:
            self.rank[x] += 1
        elif self.rank[x] < self.rank[y]:
            x, y = y, x
        
        self.par[y] = x
                
    def is_same(self, x, y):
        return self.find(x) == self.find(y)

def kruskal():
    edges.sort(key=lambda x: x[2])
    t = UnionFind(N)
    ret = 0
    
    for u, v, c in edges:
        if not t.is_same(u, v):
            t.unite(u, v)
            ret += c
            
    return ret

edges = []

for k in range(1, 3):
    X.sort(key=lambda x: x[k])
    for i in range(N - 1):
        edges.append((X[i][0], X[i + 1][0], abs(X[i][k] - X[i + 1][k])))

print(kruskal())


Measured memory_bytes: 137124
N, M = map(int, input().split())
Hs = list(map(int, input().split()))
ans = [1 for _ in range(N)]
for _ in range(M):
    A, B = map(int, input().split())
    if Hs[A-1] > Hs[B-1]:
        ans[B-1] = 0
    elif Hs[A-1] == Hs[B-1]:
        ans[A-1] = 0
        ans[B-1] = 0
    else:
        ans[A-1] = 0
print(sum(ans))

Measured memory_bytes: 20000
#include<stdio.h>
#include<iostream>
#include<math.h>
#include<algorithm>
#include<string>
using namespace std;

int main() {
	string str;
	cin >> str;
	for (int i = str.size() - 1; i >= 0; i--) {
		cout << str[i];
	}
        cout << endl;
	return 0;
}

Measured memory_bytes: 1172
#include <stdio.h>
int main(){
  int c=0;
  int k,s,l;
  scanf("%d %d",&k,&s);
  for(int i=0;i<=k;i++){
    for(int j=0;j<=k;j++){
      l=s-i-j;
      if(l>=0&&l<=k) c++;
    }
  }
  printf("%d",c);
  return 0;
}

Measured memory_bytes: 128
#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

using namespace std;

typedef long long ll;

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

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

typedef pair<int, int> match;

map<match, int> match_to_id;
map<int, match> id_to_match;

match new_match(const int a, const int b) {
    assert(a != b);
    return { min(a, b), max(a, b) };
}

int get_id(match &x) {
    static int counter = 0;
    if (match_to_id.find(x) == match_to_id.end()) {
        match_to_id[x] = counter;
        id_to_match[counter] = x;
        counter++;
    }
    return match_to_id[x];
}

match get_match(int id) {
    match res = id_to_match[id];
    assert(res.first != 0 && res.second != 0);
    return res;
}

vector<vector<int>> graph;
vector<int> deps;

int main(void) {
    int N;
    cin >> N;

    // nC2
    const int pair_num = N * (N - 1) / 2;
    graph.resize(pair_num);
    deps.resize(pair_num, 0);

    for (int i = 0; i < N; i++) {
        int prev = -1;
        int a = i + 1;
        for (int j = 0; j < N - 1; j++) {
            int b;
            cin >> b;
            auto match = new_match(a, b);
            auto id = get_id(match);
            if (prev != -1) {
                graph[prev].push_back(id);
                deps[id]++;
            }
            prev = id;
        }
    }

    // for (int i = 0; i < (int) graph.size(); i++) {
    //     match one = get_match(i);
    //     printf("(%d, %d): ", one.first, one.second);
    //     for (int j = 0; j < (int) graph[i].size(); j++) {
    //         match other = get_match(graph[i][j]);
    //         printf("(%d, %d) ", other.first, other.second);
    //     }
    //     printf("\n");
    // }
    // printf("\n");

    // for (int i = 0; i < N * (N - 1) / 2; i++) {
    //     printf("i: %d, deps[%d]: %d\n", i, i, deps[i]);
    // }
    // printf("\n");

    int ans = 0;
    int removed = 0;
    // {id, day}
    queue<pair<int, int>> q;

    for (int i = 0; i < pair_num; i++) {
        if (deps[i] == 0) {
            q.push({i, 1});
        }
    }

    while (!q.empty()) {
        auto id = q.front().first;
        auto day = q.front().second;
        q.pop();
        removed++;
        chmax(ans, day);

        for (auto other : graph[id]) {
            deps[other]--;
            if (deps[other] == 0) {
                q.push({other, day + 1});
            }
        }
    }

    if (removed == pair_num) {
        cout << ans << endl;
    } else {
        cout << "-1" << endl;
    }

    return 0;
}


Measured memory_bytes: 91920
using System;

namespace ABC099_A
{
    class Program
    {
        static string Solve()
        {
            int input = int.Parse(Console.ReadLine());
            if (input <= 999)
            {
                return "ABC";
            }
            return "ABD";
        }
        static void Main(string[] args)
        {
            Console.WriteLine(Solve());
        }
    }
}


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

#define int long long

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

	int d,t,s;
	cin>>d>>t>>s;

	double ans = (double)d/s;
	
	if(ans <= t){
		cout<<"Yes"<<endl;
	}
	else{
		cout<<"No"<<endl;
	}
	return 0;
}

Measured memory_bytes: 3608
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<limits.h>

int main(void){
    int N, K;
    scanf("%d%d", &N, &K);
    int i, j;
    int *l = (int*)malloc(N * sizeof(int));
    for(i=0; i<N; i++) {
       scanf("%d", &l[i]); 
    }

    for(i=0; i<N-1; i++) {
        for(j=i+1; j<N; j++) {
            int temp;
            if(l[i] < l[j]) {
                temp = l[i];
                l[i] = l[j];
                l[j] = temp;
            }
        }
    }
    int sum = 0;
    for(i=0; i<K; i++) {
        sum += l[i];
    }
    printf("%d\n", sum);
    free(l);


    return 0;
}

Measured memory_bytes: 128
#include <iostream>

using namespace std;

void rotate(int d[], int id1, int id2, int id3, int id4){
	int tmp = d[id1];
	d[id1] = d[id2];
	d[id2] = d[id3];
	d[id3] = d[id4];
	d[id4] = tmp;
}

int main(){
	int n;
	while(cin >> n, n){
		int d[6]={1,2,3,4,5,6};
		int dir, rot=0, res = 1;
		for(int i=0;i<n;i++){
			char s[9]; cin >> s;
			if(s[0]=='L') rot+=3;
			else if(s[0]=='R') rot++;
			else {
				if(s[0]=='N') dir = 0;
				if(s[0]=='W') dir = 1;
				if(s[0]=='S') dir = 2;
				if(s[0]=='E') dir = 3;
				dir = (dir+rot)%4;
				if(dir == 0) rotate(d, 0, 1, 5, 4);
				if(dir == 1) rotate(d, 0, 2, 5, 3);
				if(dir == 2) rotate(d, 0, 4, 5, 1);
				if(dir == 3) rotate(d, 0, 3, 5, 2);
			}
			res += d[0];
		}
		cout << res << endl;
	}
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define debug(n) cout << "DEBUG1 " << n << "\n";
#define debug2(n, m) cout << "DEBUG2 " << n << ' ' << m << "\n";
#define debug3(n, m, x) cout << "DEBUG3 " << n << ' ' << m << ' ' << x << "\n";
#define ss_def stringstream ss // stringstream, do ss_def(str), then ss >> n (n is int)
#pragma GCC optimize("Ofast")
using namespace std;
ll int BtoPmodM(ll int b, ll int p, ll int m) { // (b ^ p) % m (Big Mod)
    b %= m;
    if (p == 0) return 1;
    else if (p % 2 == 0) return (BtoPmodM(b, p / 2, m) * BtoPmodM(b, p / 2, m)) % m; // a^(p/2) * a^(p/2) = a^p
    else if (p % 2 == 1) return (BtoPmodM(b, (p - 1) / 2, m) * BtoPmodM(b, (p - 1) / 2, m) * b) % m; // +1
    else return 0; // a function must return something
}
ll int euclidalgo(ll int a, ll int b) { // Euclidean Algorithm
    if (b == 0) {
        return a;
    } else {
        return euclidalgo(b,a % b);
    }
}
bool coprime(ll int a, ll int b) {
    if (euclidalgo(a, b) == 1) return true;
    else return false;
}
ll int factModP(ll int n, ll int p) {
    ll int fac[n - 1];
    fac[0] = 1;
    for (ll int i = 1;i <= n;i++) {
        fac[i] = fac[i - 1] * i % p;
    }
    return fac[n];
}
ll int power(ll int x, ll int y, ll int p) { // x ^ y % p
    ll int res = 1;
    x = x % p;
    while (y > 0) { 
        if (y & 1) res = (res * x) % p; 
        y /= 2; 
        x = (x * x) % p; 
    } 
    return res; 
}
ll int modInverse(ll int n, ll int p) {
    return power(n, p - 2, p); 
}
ll int nCrModPFermat(ll int n, ll int r, ll int p) {
    if (r == 0) return 1; 
    ll int fac[n + 1]; 
    fac[0] = 1; 
    for (ll int i = 1;i <= n;i++) {
        fac[i] = fac[i - 1] * i % p; 
    }
    return (fac[n] * modInverse(fac[r], p) % p * modInverse(fac[n - r], p) % p) % p; 
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    // implementation
    ll int k, n;
    cin >> k >> n;
    ll int a[n];
    for (int i = 0;i < n;i++) cin >> a[i];
    sort(a, a + n);
    ll int maxd = INT_MIN;
    ll int ptr = 0;
    for (int i = 1;i < n;i++) {
    	if (abs(a[i] - a[i - 1]) > maxd) {
    		maxd = abs(a[i] - a[i - 1]);
    		ptr = i;
		}
	}
	ll int x = k - (a[n - 1] - a[0]);
//	debug(x);
	if (x > maxd) {
		maxd = x;
	}
	cout << k - maxd << endl;
}

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

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = std::int64_t;
using P = std::tuple<int,int>;

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

    int R;
    std::cin >> R;

    int res = 3 * R * R;
    std::cout << res << std::endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, e) for (int i = (int)(s); i <= (int)(e); i++)
#define printYesNo(is_ok) puts(is_ok ? "Yes" : "No");
#define printVector(v) rep(i, v.size()) cout << v[i] << endl;

int main()
{
  int sx, sy, tx, ty;
  cin >> sx >> sy >> tx >> ty;
  int right = tx - sx;
  int up = ty - sy;
  array<char, 2> RL = {'R', 'L'};
  array<char, 2> UD = {'U', 'D'};
  if (right < 0)
  {
    swap(RL[0], RL[1]);
    right *= -1;
  }

  if (up < 0)
  {
    swap(UD[0], UD[1]);
    up *= -1;
  }

  string ans = string(right, RL[0]);
  ans += string(up, UD[0]);
  ans += RL[0];
  ans += string(up + 1, UD[1]);
  ans += string(right + 1, RL[1]);
  ans += UD[0];
  ans += string(up, UD[0]);
  ans += string(right, RL[0]);
  ans += UD[0];
  ans += string(right + 1, RL[1]);
  ans += string(up + 1, UD[1]);
  ans += RL[0];

  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#define   mod  998244353
#define   int  long long 
#define   ld   long double
#define   pb   push_back
#define   vi  vector<int> 
#define   dbg(x)  cerr << #x << " = " << x << '\n'
#define   sz(x)  (int)x.size()
#define   ff   first
#define   ss   second
#define   pii  pair<int,int>
using namespace std;

inline void solve(){
    int n; cin>>n; 
    vi a(n);
    for (int &i: a) cin>>i;
    int p=0,ne=0,s=0;
    for (int i=0;i<n;i++){
        s += a[i];
        if (i&1){
            if (s>=0){
                p += s+1;
                s = -1;
            }
        }
        else {
            if (s<=0){
                p += abs(s)+1;
                s=1;
            }
        }
    }
    s=0;
    for (int i=0;i<n;i++){
        s += a[i];
        if (i%2==0){
            if (s>=0){
                ne += s+1;
                s=-1;
            }
        }
        else {
            if (s<=0){
                ne += abs(s)+1;
                s=1;
            }
        }
    }
    cout << min(p,ne) << endl;
}

signed main()
{
    int n=1; // cin>>n;
    while (n--) solve();
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include <cassert>
#include <algorithm>
#include <math.h> 
#include <set>
#include <map>
#include <deque>


using namespace std;

#define ll long long int
#define rep(i, n) for(ll i = 0; i < n; i++)
#define repp(i, n) for(int i = 1; i <= n; i++)
#define sort(v) sort((v).begin(), (v).end())
#define riverse(v) reverse((v).begin(), (v).end())
using vi = vector<int>;
using vs = vector<string>;
using vll = vector<ll>;
using vvi = vector<vi>;
const ll MOD = 1e9 + 7;


int main() {
    int N;
    cin >> N;
    vll a(N);
    ll sum = 0;
    vll ans;
    rep(i, N) {
        cin >> a[i];
        sum += a[i];
    }
    ll x = 0;
    ll xminusy;
    for (int i = 1; i < N; i++) {
        x += a[i-1];
        xminusy = abs(sum - 2 * x);
        ans.push_back(xminusy);
    }
    sort(ans);
    cout << ans[0] << endl;
}

Measured memory_bytes: 3956
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <queue>

using namespace std;

//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 PB push_back
#define MP make_pair
#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())
#define SORT(c) sort((c).begin(),(c).end())

//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);

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

  int N; cin >> N;
  int p, q;
  while(N--){
	cin >> p >> q;
	int cnt = 0;
	for(int m=-200;m<200;++m){
	  for(int n=-200;n<200;++n){
		if(m == 0 && n == 0) continue;
		if((m*p+n*q) % (m*m+n*n) == 0 &&
		   (m*q-n*p) % (m*m+n*n) == 0)
		  ++cnt;
	  }
	}
	cout <<(cnt > 8? "C": "P") << endl;
  }
  
  return 0;
}

Measured memory_bytes: 1184
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int t = sc.nextInt();
		int cnt[] = new int[n];
		long ans = 0;
		for(int i = 0; i < n; i++) {
			cnt[i] = sc.nextInt();
		}
		for(int i = 1; i < cnt.length; i++) {
			ans += Math.min(cnt[i] - cnt[i-1], t);
		}
		ans += t;
		System.out.println(ans);
		sc.close();
	}
}


Measured memory_bytes: 63216
#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++)
typedef vector<ll> vl;
typedef vector<string> vs;
typedef pair<ll,ll> pl;
typedef vector<pl> vp;
#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())
#define MOD 998244353 //1000000007

bool comp_output(pair<ll, pair<ll, pl>> a, pair<ll, pair<ll, pl>> b){
    return a.S.S.F < b.S.S.F;
}

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

    // solution comes here

    ll N, M;
    cin >> N >> M;
    vector<pair<ll, pair<ll, pl>>> t(M);//t<県, <YY, <out順, ansY>>>
    rep(i, M) {
        cin >> t[i].F >> t[i].S.F;
        t[i].S.S.F=i;
    }

    sortup(t);

    ll ansY=1;
    rep(i, M) {
        t[i].S.S.S = ansY;
        if(i<=M-2 and t[i].F==t[i+1].F) ansY++;
        else ansY = 1;
    }

    sort(t.begin(), t.end(), comp_output);

    rep(i, M) {
        cout << setfill('0') << right << setw(6) << t[i].F;//00000Pi
        cout << setfill('0') << right << setw(6) << t[i].S.S.S << nl;
    }
}

Measured memory_bytes: 4608
#import sys
MOD = 10 ** 9 + 7
INFI = 10**10
#input = sys.stdin.readline
import math
from collections import deque
import itertools
import heapq
#import bisect
from fractions import Fraction
import copy
from functools import lru_cache
from collections import defaultdict
import pprint


def sosuhante(n):
    for k in range(2, int(math.sqrt(n))+1):
        if n% k ==0:
            return False
    return True
def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

def kingaku(a,b,n):
    keta=len(str(n))
    return a*n+b*keta

def my_index(l, x, default=False):
    if x in l:
        return l.index(x)
    else:
        return default

#    h,w,a,b = map(int, input().split())
#    c = [[0 for j in range(n)] for i in range(n)]

def ret(a):
    c=[None]*(len(a)-1)
    if len(a)==1:
        return a[0]
    elif len(a)==0:
        return 0
    for i in range(1,len(a)):
        c[i-1]=abs(a[i]-a[i-1])
    return ret(c)

def soinsubunkai(n):
    a = []
    i = 1
    while i*i <= n:
        if n % i == 0 and i!=1:
            a.append(i)
            n=n//i

        if n% i !=0 or i==1:
            i += 1
    nokori=[n]
    return a + nokori

def main():
    n=list(map(int,input().split()))
    print(n.index(0)+1)






if __name__ == "__main__":

    main()

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

int n;
vector<int> adj[100005];
bool vis[100005]={false};
int m=0;
int ld[100005]={0};

int dist(int i){
    //m=0; 
    if(vis[i]==true) return ld[i];
    //m=0;
    vis[i]=true;
    for(auto it: adj[i]){
        
        ld[i]=max(ld[i], dist(it)+1);
    }
    //ld[i]=m;
    return ld[i];
}

int main(){
    int n, m;
    cin>>n>>m;
    
    while(m--){
        int x, y;
        cin>>x>>y;
        adj[y].push_back(x);
    }
    
    int yy=0;
    
    for(int i=1; i<=n; i++){
        if(vis[i]==false){
            yy=max(yy, dist(i));
        }
    }
    //int yy=0;
    /*for(int ff=1; ff<=n; ff++){
        cout<<ld[ff]<<"\n";
        //yy=max(yy, ld[ff]);
    }*/
    
    cout<<yy;
    return 0;
}


Measured memory_bytes: 9216
/*#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")*/
#include<bits/stdc++.h>
#define ll long long
#define inf 1000000005
#define mod 1000000007
#define put putchar('\n')
#define F(i,a,b) for (int i=(a);i<=(b);i++)
#define D(i,a,b) for (int i=(a);i>=(b);i--)
#define go(i,t) for (int i=head[t];i;i=Next[i])
#define sqr(x) ((x)*(x))
#define re register
#define mp make_pair
#define fi first
#define se second
#define pa pair<int,int>
#define pb push_back
#define be begin()
#define en end()
#define ret return puts("-1"),0;
#define N 500055
#define int ll
using namespace std;
inline char gc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
inline int read(){char c=getchar();int tot=1;while ((c<'0'|| c>'9')&&c!='-') c=getchar();if (c=='-'){tot=-1;c=getchar();}
int sum=0;while (c>='0'&&c<='9'){sum=sum*10+c-'0';c=getchar();}return sum*tot;}
inline void wr(int x){if (x<0) {putchar('-');wr(-x);return;}if(x>=10)wr(x/10);putchar(x%10+'0');}
inline void wrn(int x){wr(x);put;}inline void wri(int x){wr(x);putchar(' ');}
inline void wrn(int x,int y){wri(x);wrn(y);}inline void wrn(int a,int b,int c){wri(a);wrn(b,c);}
int n,m,a[N],sum[N],ans;
inline void add(int &x,int k){
	x+=k;x-=(x>=mod)?mod:0;
}
int ksm(int x,int k){
	int sum=1;
	while (k){
		if (k&1) sum=(ll)sum*x%mod;
		x=(ll)x*x%mod;
		k>>=1;
	}
	return sum;
}
int fac[N],inv[N];
int C(int n,int m){return (n<m||m<0)?0:1LL*fac[n]*inv[m]%mod*inv[n-m]%mod;}
void init_c(int x){
	fac[0]=1;F(i,1,x) fac[i]=1LL*fac[i-1]*i%mod;
	inv[x]=ksm(fac[x],mod-2);D(i,x-1,0) inv[i]=1LL*inv[i+1]*(i+1)%mod;
}
signed main(){
	n=read();init_c(n);
	F(i,1,n) a[i]=read();
	F(i,1,n){
		sum[i]=(sum[i-1]+a[i])%mod;	
		//suma[i]=(suma[i-1]+1LL*a[i]*i%mod)%mod;
	}
	//D(i,n,1) sumb[i]=(sumb[i+1]+1LL*a[i]*(n-i+1)%mod)%mod;
	F(i,0,n-1){
		//¼ÆËãxºÍx-iµÄ¹±Ï× 
		if (i==0) add(ans,1LL*(sum[n])%mod*fac[n-i-1]%mod*C(n,i+1)%mod*fac[i]%mod);
		else add(ans,1LL*(sum[n]+sum[n-i]-sum[i]+mod)%mod*fac[n-i-1]%mod*C(n,i+1)%mod*fac[i]%mod);
	}
	wrn(ans);
	return 0;
}

Measured memory_bytes: 13312
#include<bits/stdc++.h>
using namespace std;
typedef int64_t ll;
typedef long double ld;
const ll MOD=1000000007;
#define loop(i,n) for(ll i=0;i<(ll)(n);i++)
#define change(a,b) do{ll c=a; a=b; b=c;}while(0)
long long gcd(long long a,long long b){
    ll gcdmax=max(a,b);
    ll gcdmin=min(a,b);
    while(true){
        if(gcdmax%gcdmin==0)break;
        else gcdmax%=gcdmin;
        change(gcdmin,gcdmax);
    }
    return gcdmin;
}
ll powerup(ll N,ll P,ll M){
    if(P==0)return 1;
    else if(P%2==0){
        ll t=powerup(N,P/2,M);
        return t*t%M;
    }
    else return N*powerup(N,P-1,M)%M;
}
int main()
{
  ll N,M;
  cin>>N>>M;
  ll A[5]={0};
  ll tf=1;
  ll n,m;
  loop(i,M){
    cin>>n;
    cin>>m;
    if(A[n]==0){
      A[n]=m;
      if(n==1&&A[n]==0){
        if(N!=1)tf=0;
      }
    }
    else if(m!=A[n]){
      cin>>A[n];
      tf=0;
    }
  }
  if(tf==0)cout<<-1<<endl;
  else{
    loop(i,N){
      if(i==0&&A[1]==0&&N!=1)cout<<1;
      else cout<<A[i+1];
    }
  }
}

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

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

int main() {
    int N, Q;
    cin >> N >> Q;
    string S;
    cin >> S;

    // 累積和の前処理
    vector<int> sum(N + 1, 0);
    for (int i = 1; i < N; ++i) {
        sum[i+1] = sum[i];
        if (S[i-1] == 'A' && S[i] == 'C')
            sum[i+1]++;
    }

    int l, r;
    int ans;
    rep(q, Q) {
        cin >> l >> r;
        ans = sum[r] - sum[l];
        cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 3404
N, M, X, Y = map(int, input().split())
x = list(map(int, input().split()))
y = list(map(int, input().split()))
if max(x) < min(y):
    for i in range(max(x) + 1, min(y) + 1):
        if X < i <= Y:
            print("No War")
            break
        if i == min(y):
            print("War")
else:
    print("War")

    

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define iii tuple<int, int, int>
#define ii pair<int, int>
#define fi first
#define se second

using namespace std;
using namespace __gnu_pbds;

template <typename T>
using ordered_set =
    tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

void solve() {
    int n, M = 1e9 + 7;
    cin >> n;

    vector<vector<int>> a(n, vector<int>(n));

    for (auto& i : a)
        for (auto& j : i) cin >> j;

    vector<int> dp(1 << n), cnt(1 << n);
    dp[0] = 1;

    queue<int> q;
    q.push(0);

    while (!q.empty()) {
        int msk = q.front(), i = cnt[msk];
        q.pop();

        if (i == n) break;
        if (!dp[msk]) continue;

        for (int j = 0; j < n; ++j) {
            if (a[i][j] && !(msk & (1 << j))) {
                q.push(msk | (1 << j));
                cnt[msk | (1 << j)] = cnt[msk] + 1;
                dp[msk | (1 << j)] = (dp[msk | (1 << j)] + dp[msk]) % M;
            }
        }
        dp[msk] = 0;
    }
    cout << dp[(1 << n) - 1] << '\n';
}

int main() {
    ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
    // freopen("in", "r", stdin);

    int t = 1;
    // cin >> t;
    while (t--) solve();

    return 0;
}

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

int main() {
  int N, D;
  cin >> N >> D;
  vector<double> V(N);
  for (int i = 0; i < N; i++) {
    int x, y;
    cin >> x >> y;
    V.at(i) = sqrt(pow(x, 2) + pow(y, 2));
  }
  
  int C = 0;
  for (int i = 0; i < N; i++) {
    if (V.at(i) <= D) {
      C++;
    }
  }
  cout << C << endl;
}


Measured memory_bytes: 4828
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
  int n,k,i,sum;
  sum = 0;
  cin >> n >> k;
  vector<int>s(n);
  
  for(i=0;i<n;i++) cin >> s.at(i);
  
  sort(s.begin(),s.end());
  
  for(i=0;i<k;i++) sum+=s.at(i);
  
  cout << sum << endl;
}


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

using ll = long long;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)

#define rng(a) a.begin(), a.end()
#define rrng(a) a.rbegin(), a.rend()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

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

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
    os << "(" << p.first << "," << p.second << ")";
    return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
    os << "{";
    rep(i, (int)v.size()) {
        if (i)
            os << ",";
        os << v[i];
    }
    os << "}";
    return os;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
    for (auto val : array)
        std::cout << val << ", ";
    std::cout << "\n";
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << std::setprecision(10);

    string s; std::cin >> s;
    int slen = s.size();
    int bc = 0, wc = 0;
    int i = 0;
    while(i < slen) {
        if (s[i] == 'B') bc++;
        while (i < slen && s[i] == 'B') i++;
        if (s[i] == 'W') wc++;
        while (i < slen && s[i] == 'W') i++;
    }
    std::cout << max(0, bc+wc-1) << "\n";
}


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

using std::cin;
using std::cout;
using std::endl;
using std::setprecision;
using std::fixed;
using std::pair;
using std::make_pair;
using std::string;
using std::vector;
using std::list;
using std::map;
using std::set; // insert erase find count
using std::queue;
using std::priority_queue;
using std::stack;

typedef long long int lli;
typedef vector<lli> VI;
typedef vector<vector<lli> > VII;
typedef vector<string> VS;
typedef pair<lli, lli> PII;

int string_to_int(string str) {
    int length = str.length();
    int number = 0;
    for (int i = 0; i < length; i++) {
        number += (int)(str[i] - '0');
        number *= 10;
    }
    number /= 10;
    return number;
}

int main(void) {
    lli n;
    string d = "";
    char input;
    cin >> n;
    for (lli loop = 0; loop < n; loop++) {
        cin >> input;
        d += input;
    }
    int digit = 0;
    int num = 1;
    bool cont = true;
    while (cont) {
        digit++;
        num *= 10;
        set<lli> st;
        int length = d.length();
        for (int i = 0; i <= length - digit; i++) {
            string temp = d.substr(i, digit);
            int element = string_to_int(temp);
            st.insert(element);
        }
        if (digit == 1 && st.count(0) == 0) {
           cout << 0 << endl; 
           break;
        }
        for (int i = num / 10; i < num; i++) {
           if (st.count(i) == 0) {
                cout << i << endl; 
                cont = false;
                break;
           }
        }
    }

    return 0;
}

Measured memory_bytes: 3232
#include <bits/stdc++.h>
#define ALL(v) v.begin(), v.end()
#define MAX 510000
#define rrep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep(i, n) for(ll i = 1; i <= (ll)(n); i++)
#define dcout cout<<fixed<<setprecision(15);

using namespace std;
typedef long long int  ll;
typedef pair<ll, ll> P;

constexpr int MOD = 1e9 + 7;
constexpr ll inf = 1LL << 60;

//lcm//
ll gcd(ll x, ll y) {
	if (x == 0) return y;
	return gcd(y%x, x);
}
ll lcm(ll x, ll y) { return x * y / gcd(x, y); }

//a^n mod p//
ll modpow(ll a, ll n, ll p) {
  if (n == 1) return a % p;
  if (n % 2 == 1) return (a * modpow(a, n - 1, p)) % p;
  ll t = modpow(a, n / 2, p);
  return (t * t) % p;
}

//inversemod//
long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

//Cmonp//
ll 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;
	}
}

// 
ll COM(ll n, ll k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

//LARGE n
ll com(ll n,ll m){
    if(n<m || n<=0 ||m<0){
		return 0;
	}
	if( m==0 || n==m){
		return 1;
	}
	ll k=1;
	for(ll i=1;i<=m;i++){
       k*=(n-i+1); 
	   k%=MOD;
	   k*=modinv(i,MOD);
	   k%=MOD;
	}
	return k;
}

//radP
ll rad(ll u, ll p){
ll cnt=0;
	while(u%p==0){
		u/=p;
		cnt++;
	}
	return cnt;
}


////////////////////////////////////////////////////////////////////

int main() {
string s,t;
cin>>s>>t;

int n=t.size();
s+=t[n-1];

if(s==t)cout<<"Yes"<<endl;
else cout<<"No"<<endl;


}



Measured memory_bytes: 3628
#include <stdio.h>

int main(void) {
	// your code goes here
	int n, d, x;
	scanf("%d", &n);
	int a;
	scanf("%d %d", &d, &x);
	for(int i=0;i<n;i++)
	{
		scanf("%d", &a);
		if(a==1)
		{
			x += d / a;
		}
		else
		{
			x += ((d - 1) / a) + 1;
		}
		//printf("%d\n", x);
	}
	printf("%d\n", x);
	return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <stack>
#include <complex>
#include <stdlib.h>
#include <stdio.h>
#include <functional>


#define fs first
#define sc second

using namespace std;

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

const ll mod = 1000000007;
ll fact[200200];
ll invfact[200200];

inline ll take_mod(ll a){
    return (a % mod + mod) % mod;
}

inline ll add(ll a, ll b){
    return take_mod(a+b);
}

inline ll sub(ll a, ll b){
    return take_mod(a-b);
}


inline ll mul(ll a, ll b){
    return take_mod(a * b);
}

inline ll pow(ll x, ll n){
    ll res = 1LL;
    while(n > 0){
        if(n & 1) res = mul(res, x);
        x = mul(x, x);
        n >>= 1;
    }
    return res;
}

ll mod_inv(ll x){
    return pow(x, mod-2);
}

// nは上限
void make_fact(ll n){
    fact[0] = 1;
    ll res = 1;
    for(int i = 1; i <= n; i++){
        fact[i] = res;
        res = mul(res, i+1);
    }
}

// nは上限
void make_invfact(ll n){
    invfact[0] = 1;
    invfact[n] = mod_inv(fact[n]);
    for(int i = n-1; i >= 1; i--){
        invfact[i] = mul(invfact[i + 1], i + 1);
    }
}

ll perm(ll n, ll k){
    return mul(fact[n], invfact[n-k]);
}

ll comb(ll n, ll k){
    return mul(mul(fact[n], invfact[n-k]), invfact[k]);
}

int main(){
    string s;
    cin >> s;

    ll len = s.length();

    ll dp[101000][4];

    dp[0][0] = 1;
    dp[0][1] = 0;
    dp[0][2] = 0;
    dp[0][3] = 0;
    for(int i = 1; i <= len; i++){
        dp[i][0] = dp[i-1][0];
        dp[i][1] = dp[i-1][1];
        dp[i][2] = dp[i-1][2];
        dp[i][3] = dp[i-1][3];
        if(s[i-1] == 'A'){
            dp[i][1] = add(dp[i-1][0], dp[i-1][1]);
        }
        else if(s[i-1] == 'B'){
            dp[i][2] = add(dp[i-1][1], dp[i-1][2]);
        }
        else if(s[i-1] == 'C'){
            dp[i][3] = add(dp[i-1][2], dp[i-1][3]);
        }
        else{
            dp[i][0] = mul(dp[i-1][0], 3);
            dp[i][1] = add(mul(dp[i-1][1], 3), dp[i-1][0]);
            dp[i][2] = add(mul(dp[i-1][2], 3), dp[i-1][1]);
            dp[i][3] = add(mul(dp[i-1][3], 3), dp[i-1][2]);
        }
    }

    cout << dp[len][3] << endl;


    return 0;

}


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

using namespace std;
using Int = long long;

int n, k;
const int nax = 100010;
int dp[nax], ar[101];

int rec(int s) {
  if(s == 0) {
    return false;
  }
  if(dp[s] != -1) {
    return dp[s];
  }
  bool ok = false;
  for(int i = 0; i < n; ++i) {
    if(s - ar[i] < 0) {
      break;
    }
    ok |= !(rec(s - ar[i]));
  }
  return dp[s] = (int) ok;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cin >> n >> k;
  for(int i = 0; i < n; ++i) {
    cin >> ar[i];
  }
  memset(dp, -1, sizeof dp);
  cout << (rec(k) ? "First" : "Second") << '\n';
  return 0;
}


Measured memory_bytes: 5376
from itertools import product


def main():
    abcd = input()

    for op in product(["+", "-"], repeat=3):
        op = list(op)
        op.append("")
        expr = ''.join(a + b for a, b in zip(abcd, op))
        if eval(expr) == 7:
            print(expr, '=7', sep='')
            break


if __name__ == '__main__':
    main()


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

int main(){
    int x,y;
    for(int i=0; i < 3000;i++){
        cin >> x >> y;
        if( (x == 0)&&(y == 0) ) break;
        else if( x <= y ) cout << x << " " << y << endl;
        else cout << y << " " << x << endl;
    }
}


Measured memory_bytes: 3000
#include <bits/stdc++.h>
#define int long long
#define CLK clock_t clk = clock();//Start of main
#define OCLK cerr << "Time (in ms): " << (double)(clock() - clk) * 1000.0 / CLOCKS_PER_SEC << '\n';//End of main
#define MOD 1000000007
/* DEFINE cout */
#define pln cout << "===============================\n"
#define on cout<<"\n"
#define os cout<<" "
#define o2(a,b) cout<<a<<" "<<b
#define o(a) cout << a
#define bitcount __builtin_popcount
/* DEFINE cout */
#define endl "\n"
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);//fastio
using namespace std;
struct hash_pair { // use pair as key in unordered_map<pair<int,int>,int,hash_pair>;
    template <class T1, class T2>
    size_t operator()(const pair<T1, T2>& p) const
    {
        auto hash1 = hash<T1>{}(p.first);
        auto hash2 = hash<T2>{}(p.second);
        return hash1 ^ hash2;
    }
};
bool prime[10000001];
int P=MOD-2;
int factorial[10000001]={0};
int powerFunction(int x,int y){
    int res = 1;
    int p = MOD;
    x = x % p;
    while (y > 0){
        if (y & 1)
            res = (res*x) % p;
        y = y>>1;
        x = (x*x) % p;
    }
    return res;
}
void sieveFunction(int maxLimit){
    memset(prime, true, sizeof(prime));
    prime[0] = prime[1]=false;
    for(int i=2; maxLimit >= i ; i++){
        if(prime[i]){
            for(int j=2*i ; maxLimit >= j ; j+=i)
                prime[j]=false;
        }
    }
}
void factorialFunction(int maxLimit){
    factorial[0]=1;
    for(int i=1 ; i <= maxLimit ; i++)
        factorial[i]=(factorial[i-1]*i)%MOD;
    return;
}
int gcd(int a, int b){
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
int n;
double arr[3000];
double dp[3000][3000];
double fun(int idx, int heads){
    if(dp[idx][heads] != -1){
        return dp[idx][heads];
    }
    if(idx == n){
        if(heads > n - heads){
            return 1;
        }
        return 0;
    }
    dp[idx][heads] = (1 - arr[idx]) * fun(idx + 1, heads) + arr[idx] * fun(idx + 1, heads + 1);
    return dp[idx][heads];
}
signed main(){
    for(int i=0; 3000>i; i++){
        for(int j=0; 3000>j; j++){
            dp[i][j] = -1;
        }
    }
    cout << setprecision(10);
    cin >> n;
    for(int i=0; n>i; i++){
        cin >> arr[i];
    }
    cout << fun(0, 0) << endl;
}


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

int main(void){
    char x,y;
    cin >> x>>y;
    if (x==y)
    {
        cout << '=' << endl;
        return 0;
    }else
    {
        cout << (x<y?'<':'>') << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#define N 150000
using namespace std;
int main(){
  int n,p,sosu[N],i,j,result,data[N],l,flag,temp;
  for(i=0;i<N;i++) sosu[i]=1;
  sosu[0]=0;
  sosu[1]=0;
  for(i=2;i<N/2;i++){
    if(sosu[i]==1){
      for(j=i*2;j<N;j+=i){
        sosu[j]=0;
      }
    }
  }
  while(1){
    flag=0;
    l=0;
    cin >> n >> p;
    if(n==-1&&p==-1) break;
    for(i=n+1;i<N;i++){
      if(sosu[i]==1){
	for(j=n+1;j<=i;j++){
          if(sosu[j]==1){
            data[l]=i+j;
	    l++;
	    if(l==p+300){
	      flag=1;
	      break;
	    }
	  }
	}
	if(flag==1) break;
      }
    }
    for(i=1;i<p+300;i++){
      for(j=1;j<p+300;j++){
	if(data[j]<=data[j-1]){
	  temp=data[j];
	  data[j]=data[j-1];
	  data[j-1]=temp;
	}
      }
    }
    cout << data[p-1] << endl;
  }
  return 0;
}

Measured memory_bytes: 1752
'use strict'

function main(s) {

  const x = Number(s);
  const nums = [...Array(31)].map((x, i) => i + 1);
  nums.shift();
  const max_ary = [1];

  for (let i = 0; i < nums.length; i++) {
    let j = 2;
    let n = nums[i];
    let max = Math.pow(n, j);
    if (max > x) continue;
    while (max <= x) {
      j += 1;
      max = Math.pow(n, j);
    }
    max = Math.pow(n, j - 1);
    max_ary.push(max);
  }

  const ans = Math.max(...max_ary);
  console.log(ans);
}

main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7372
from collections import defaultdict
from decimal import Decimal


def ceil(a, b):
    return (a + b - 1) // b


def main():
    N = int(input())
    t, a = map(int, input().split())
    for _ in range(N - 1):
        T, A = map(Decimal, map(int, input().split()))
        p = max(ceil(t, T), ceil(a, A))
        t, a = T * p, A * p
    print(t + a)


if __name__ == '__main__':
    main()


Measured memory_bytes: 5076