akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define mid ((l+r) >> 1)
#define lc(x) pt[x].lc
#define rc(x) pt[x].rc
#define sum(x) pt[x].sum
using namespace std;
const int MAXN=500010;
int n,m,tmp;
int a[MAXN];
map<int,int>pos;
struct PresidentTree
{
    int lc,rc,sum;
} pt[MAXN*100];
int num,rt[MAXN];
void build(int &k1,int l,int r)
{
    k1=++ num;
    sum(k1)=0;
    if(l==r)
        return;
    build(lc(k1),l,mid);
    build(rc(k1),mid+1,r);
}
void modify(int &k1,int pre,int l,int r,int p,int v)
{
    k1=++ num;
    pt[k1]=pt[pre];
    sum(k1)=sum(pre)+v;
    if(l==r)
        return;
    if(p<=mid)
        modify(lc(k1),lc(pre),l,mid,p,v);
    else
        modify(rc(k1),rc(pre),mid+1,r,p,v);
}
int query(int k1,int l,int r,int ql,int qr)
{
    if(ql<=l && r<=qr)
        return sum(k1);
    int ans=0;
    if(ql<=mid)
        ans+=query(lc(k1),l,mid,ql,qr);
    if(qr>mid)
        ans+=query(rc(k1),mid+1,r,ql,qr);
    return ans;
}
int main()
{
    scanf("%d%d",&n,&m);
    for(int i=1;i<=n;i++) scanf("%d",&a[i]);
    num=0;
    pos.clear();
    build(rt[0],1,n);
    for(int i=1; i<=n; i ++)
    {
        if(pos[a[i]])
        {
            modify(tmp,rt[i-1],1,n,pos[a[i]],-1);
            modify(rt[i],tmp,1,n,i,1);
        }
        else
        {
            modify(rt[i],rt[i-1],1,n,i,1);
        }
        pos[a[i]]=i;
    }
    while(m--)
    {
        int l,r;scanf("%d%d",&l,&r);
        tmp=query(rt[r],1,n,l,r);
        printf("%d\n",tmp);
    }
}


Measured memory_bytes: 252940
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdint>
#include <cstdio>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;

using i64 = int64_t;

int N, a[101010];

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

    int z = 0, m2 = 0, m4 = 0;
    for (int j = 0; j < N; ++j) {
        if (a[j]%4 == 0) m4++;
        else if (a[j]%2 == 0) m2++;
        else z++;
    }

    bool flg = false;
    if (m4 >= z) flg = true;
    if (z - m4 == 1 && m2 == 0) flg = true;
    cout << (flg ? "Yes" : "No") << endl;
    return 0;
}


Measured memory_bytes: 640
N, M = map(int, input().split())
from functools import reduce
from operator import mul

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

if N >= 2 and M >= 2:

    print(cmb(N, 2) + cmb(M, 2))
elif N >= 2 :
    print(cmb(N, 2))
elif M >= 2:
    print(cmb(M, 2))
else:
    print(0)

Measured memory_bytes: 38256
#include <iostream>
#include <unordered_map>
#include <vector>
#include <algorithm>

using namespace std;

void limit_add(long long& target, long long add) {
  target = (target + add) % 1000000007;
}

int main() {
  string s;
  cin >> s;
  
  long long dp[2][13];
  for (int i = 0; i < 2; i++) {
    for (int j = 0; j < 13; j++) {
      dp[i][j] = 0;
    }
  }
  
  dp[0][0] = 1;
  
  int s_size = s.size();
  for(int i = 0; i < s_size; i++) {
    for (int j = 0; j < 13; j++) {
      dp[(i+1)%2][j] = 0;
    }
    
    char c = s[i];
    int range_start = c == '?' ? 0 : (c-'0');
    int range_end = c == '?' ? 9 : (c-'0');

    for (int j = 0; j < 13; j++) {
      for (int k = range_start; k <= range_end; k++) {
        int x = (10*j + k) % 13;
        limit_add(dp[(i+1)%2][x], dp[i%2][j]);
      }
    }
  }
  
  cout << dp[s.size()%2][5] << endl;
    
  return 0;
}


Measured memory_bytes: 512
#[allow(unused_macros)]
macro_rules! dbg {
    ($val:expr) => {
        match $val {
            tmp => {
                eprintln!("[{}:{}] {} = {:#?}",
                          file!(), line!(), stringify!($val), &tmp);
                tmp
            }
        }
    }
}

#[allow(dead_code)]
pub struct Scanner<'a> {
    _buf: &'a str,
    iter: ::std::str::SplitWhitespace<'a>,
}

#[allow(dead_code)]
impl<'a> Scanner<'a> {
    pub fn new(buf: &'a str) -> Self {
        Scanner {
            _buf: buf,
            iter: buf.split_whitespace(),
        }
    }

    pub fn array<T>(&mut self, n: usize) -> Vec<T>
        where T: ::std::str::FromStr,
              T::Err: ::std::fmt::Debug,
    {
        let mut res = Vec::with_capacity(n);
        for _ in 0..n {
            res.push(self.value());
        }
        res
    }

    pub fn value<T>(&mut self) -> T
        where T: ::std::str::FromStr,
              T::Err: ::std::fmt::Debug,
    {
        self.next().parse().unwrap()
    }

    pub fn chars(&mut self) -> Vec<char> {
        self.next().chars().collect()
    }

    fn next(&mut self) -> &str {
        self.iter.next().unwrap()
    }
}

fn div_ceil(a: i64, b: i64) -> i64 {
    (a+b-1) / b
}

fn f(d: i64, mut g: i64, p: &[i64], c: &[i64], mask: i64) -> i64 {
    let mut res = 0;

    for i in 0..d {
        if mask & (1<<i) != 0 {
            g -= p[i as usize] * 100*(i+1);
            g -= c[i as usize];
            res += p[i as usize];
        }
    }
    if g <= 0 { return res; }

    for i in (0..d).rev() {
        if mask & (1<<i) != 0 { continue; }

        let q = div_ceil(g, 100*(i+1));
        if q <= p[i as usize] - 1 {
            g -= q * (100*(i+1));
            res += q;
            break;
        }
        else {
            g -= (p[i as usize] - 1) * (100*(i+1));
            res += p[i as usize] - 1;
        }
    }
    if g > 0 { return 10_i64.pow(18); }

    res
}

fn main() {
    let mut _input = String::new();
    {
        use ::std::io::Read;
        ::std::io::stdin().read_to_string(&mut _input).unwrap();
    }
    let mut sc = Scanner::new(&_input);

    let d = sc.value::<i64>();
    let g = sc.value::<i64>();
    let mut p = Vec::with_capacity(d as usize);
    let mut c = Vec::with_capacity(d as usize);
    for _ in 0..d {
        p.push(sc.value::<i64>());
        c.push(sc.value::<i64>());
    }

    let mut ans = 10_i64.pow(18);
    for i in 0..(1<<d) {
        let cur = f(d, g, &p, &c, i);
        if cur < ans {
            ans = cur;
        }
    }

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


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

int main(){
    int n, num;
    int card[4][13]={{}};
    char mark;
    cin >> n;
    
    for(int i=0; i<n; i++){
        cin >> mark >> num;
        if(mark=='S'){card[0][num-1]=1;
        }else if(mark=='H'){card[1][num-1]=1;
        }else if(mark=='C'){card[2][num-1]=1;
        }else if(mark=='D'){card[3][num-1]=1;
        }
    }

    for(int i=0; i<4; i++){
        for(int j=0; j<13; j++){         
            if(card[i][j]==0){    
                if(i==0){cout << "S " << j+1 << endl;
                }else if(i==1){cout << "H " << j+1 << endl;
                }else if(i==2){cout << "C " << j+1 << endl;
                }else if(i==3){cout << "D " << j+1 << endl;
                }      
            }
        }
    }

    return 0;
}


Measured memory_bytes: 3108
#include <bits/stdc++.h>
#define LL long long
#define P pair<int, int>
const LL N = 4e6 + 10;
const LL inf = 0x3f3f3f;
const LL mod = 998244353;
using namespace std;
template <typename tp>
inline void read(tp &x)
{
    x = 0; char c = getchar(); bool f = 0;
    for (; c < '0' || c > '9'; f |= (c == '-'), c = getchar()) ;
    for (; c >= '0' && c <= '9'; x = (x << 3) + (x << 1) + c - '0', c = getchar()) ;
    if (f) x = -x;
}
LL Ksm(LL a,LL b,LL ret=1)
{
    while(b)
    {
        if(b&1) ret=a*ret%mod;
        a=a*a%mod;
        b>>=1;
    }
    return ret;
}
LL n,m,ans;
LL inv[N],jc[N];
void init()
{
    inv[0]=jc[0]=jc[1]=1;
    for(int i=2;i<=4000000;i++) jc[i]=jc[i-1]*i%mod;
    inv[4000000]=Ksm(jc[4000000],mod-2);
    for(int i=3999999;i>=1;i--) inv[i]=inv[i+1]*(i+1)%mod;
}
LL C(LL x,LL y){return jc[y]*inv[y-x]%mod*inv[x]%mod;}
int main()
{
    read(n),read(m);
    init();
    for(int i=0;i<=m/2;i++)
    {
        LL ji=i*2+m%2,ou=m+(m-ji)/2;
        if(ji>n) break;
        ans+=C(ji,n)*C(n-1,ou+n-1)%mod;
        ans%=mod;
    }
    for(int i=m*2+1;i<=3*m;i++)
    {
        ans-=n*C(n-2,3*m-i+n-2)%mod;
        ans=(ans+mod)%mod;
    }
    printf("%lld\n",ans);
    return 0;
}

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

const int N = 1005, M = 5005;

int n, f[N], head[N], nxt[N], val[N];
void link(int x, int y) {nxt[y] = head[x], head[x] = y;}

int dfs(int x) {
	std::vector<int> q; int sum = 0, base = 0;
	for (int i = head[x]; i; i = nxt[i]) {
		int ret = dfs(i), d = std::abs(ret - val[i]);
		base += std::min(ret, val[i]), sum += ret + val[i];
		q.emplace_back(d);
	}
	std::bitset<5000> b; b.set(0);
	if (base > val[x]) {std::cout << "IMPOSSIBLE\n", std::exit(0);}
	for (int d : q) b |= b << d; int lst = -1;
	for (int i = b._Find_first(); i <= val[x] - base; i = b._Find_next(i)) lst = i;
	return sum - base - lst;
}

int main() {
	std::ios::sync_with_stdio(0), std::cin.tie(0);
	std::cin >> n;
	for (int i = 2, x; i <= n; ++i) std::cin >> x, link(x, i);
	for (int i = 1; i <= n; ++i) std::cin >> val[i];
	dfs(1), std::cout << "POSSIBLE\n";
	return 0;
}

Measured memory_bytes: 1152
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		int[] result=new int[n];
		for(int i=1;sc.hasNextInt();i++) {
			result[sc.nextInt()-1]=i;
		}
		StringBuilder sb=new StringBuilder();
		for(int i=0;i<n;i++) {
			sb.append(result[i]);
			if(i!=n) {
				sb.append(" ");
			}else {
				sb.append("\n");
			}
		}
		System.out.println(sb.toString());
	}
}

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

int main()
{ 
  int n; cin >> n;
  vector<int> fib = vector<int>(n+1);
  fib[0] = fib[1] = 1;
  for (int i = 2; i <= n; i++)
    fib[i] = fib[i-1] + fib[i-2];
  cout << fib[n] << endl;
  return EXIT_SUCCESS;
}



Measured memory_bytes: 3108
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i) 
#define rrep(i, a, b) for (int i = (a); i < (b); ++i)
#define PI acos(-1)
#define pcnt __builtin_popcountll
#define rng(a) a.begin(), a.end()
#define rrng(a) a.rbegin(), a.rend()
#define sz(x) (int)(x).size()
#define v(T) vector<T>
#define vv(T) v(v(T))
#define fi first
#define se second

using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using LP = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using tl = tuple<ll, ll, ll>;

template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
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; }

ll INF = 1001001001;
ll LINF = 1001001001001001001ll;

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

    char c; cin>>c;
    if (c == toupper(c)) cout<<"A"<<endl;
    else cout<<"a"<<endl;
}

Measured memory_bytes: 3644
#include<iostream>
#include<utility>
#include<tuple>
#include<set>
#include<list>
#include<vector>
#include<map>
#include<algorithm>
#include<queue>
#include<cmath>

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FUNCTION__ << endl;
#define int long long

const long long MAXN = 1e6;
const long long MOD = 1e9+7;
const long long INF = __LONG_LONG_MAX__ / 2;

using namespace std;


signed main(){
    int N;
    vector<int> As, Bs, Cs;
    cin >> N;

    int n = (int)sqrt(N);
    cout << n * n << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("avx2")
#define l first
#define r second
#define int long long

const int maxn = 1e7 + 1, maxk = 1500101;

using namespace std;

int a[maxn], cnt[maxn];

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    int n, x, y;
    cin >> n >> x >> y; --x; --y;
    for (int i = 0; i < n; i++) {
        for (int j = i + 1; j < n; j++) {
            if (j <= x || i >= y) {
                ++cnt[j - i];
                continue;
            }
            if (i <= x && j >= y) {
               ++cnt[x - i + j - y + 1];
               continue;
            }
            if (i >= x && j <= y) {
                ++cnt[min(j - i, i - x + y - j + 1)];
                continue;
            }
            if (i <= x) ++cnt[x - i + min(y - j + 1, j - x)];
            else ++cnt[j - y + min(i - x + 1, y - i)];
        }
    }
    for (int k = 1; k <= n - 1; k++)
        cout << cnt[k] << '\n';
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int cnt[26];

int main(void){
	string s;
	cin >> s;
	int a=0;
	for(int i=0;i<4;i++){
		cnt[(s[i]-'A')]++;
		if(cnt[(s[i]-'A')]==2)a++;
	}
	printf("%s\n",a==2?"Yes":"No");
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<utility>
#include<algorithm>
#include<cmath>
using namespace std;


#define ll long long
#define fr(m) for(int i=0; i<m; i++)
#define frj(m) for(int j=0; j<m; j++)
#define frr(n) for(int i=n; i>=0; i--)
#define pb push_back
#define orr ||
#define nl \n
#define sci(n) scanf("%lld ", &n)
#define pri(n) printf("%d", n)
#define prl(n) printf("%lld", n)
#define yes cout<<"YES"<<endl
#define no cout<<"NO"<<endl

bool compare(string a, string b){
  return(a+b<b+a);
}

int main()
{

    ll n,l;
    cin>>n>>l;
    string arr[n];
    fr(n) cin>>arr[i];
    sort(arr,arr+n, compare);
    fr(n) cout<<arr[i];
    cout<<endl;
    return 0;
}


Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.FilterInputStream;
import java.io.BufferedInputStream;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Jenish
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        ScanReader in = new ScanReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Atcoder solver = new Atcoder();
        solver.solve(1, in, out);
        out.close();
    }

    static class Atcoder {
        public void solve(int testNumber, ScanReader in, PrintWriter out) {
            long A = in.scanLong();
            long B = in.scanLong();
            out.println((A * B) - (A + B) + 1);
        }

    }

    static class ScanReader {
        private byte[] buf = new byte[4 * 1024];
        private int INDEX;
        private BufferedInputStream in;
        private int TOTAL;

        public ScanReader(InputStream inputStream) {
            in = new BufferedInputStream(inputStream);
        }

        private int scan() {
            if (INDEX >= TOTAL) {
                INDEX = 0;
                try {
                    TOTAL = in.read(buf);
                } catch (Exception e) {
                    e.printStackTrace();
                }
                if (TOTAL <= 0) return -1;
            }
            return buf[INDEX++];
        }

        private boolean isWhiteSpace(int n) {
            if (n == ' ' || n == '\n' || n == '\r' || n == '\t' || n == -1) return true;
            else return false;
        }

        public long scanLong() {
            long I = 0;
            int n = scan();
            while (isWhiteSpace(n)) n = scan();
            int neg = 1;
            if (n == '-') {
                neg = -1;
                n = scan();
            }
            while (!isWhiteSpace(n)) {
                if (n >= '0' && n <= '9') {
                    I *= 10;
                    I += n - '0';
                    n = scan();
                }
            }
            return neg * I;
        }

    }
}



Measured memory_bytes: 21332
#![allow(unused_imports)]

use proconio::{input, fastout};
use proconio::marker::*;
use nalgebra::{min, max};

const MAX_LENGTH: usize = 1005;

fn main() {
    input! {
    n: usize,
    a: usize,
    b: usize,
    c: usize,
    l: [usize; n]
   }
    let mut dp = vec![vec![std::usize::MAX; MAX_LENGTH]; 1 << n];
    for i in 0..1 << n {
        for j in 0..n {
            if i & 1 << j > 0 {
                for k in (l[j] + 1..MAX_LENGTH).rev() {
                    dp[i][k] = min(dp[i][k],
                                          dp[i][k - l[j]].saturating_add(10))
                }
                for k in 1..MAX_LENGTH {
                    dp[i][k] = min(dp[i][k], max(k, l[j]) - min(k, l[j]));
                }
            }
        }
    }
    let mut ans = std::usize::MAX;
    for i in 1..1 << n {
        for j in 1..1 << n {
            for k in 1..1 << n {
                if i & j == 0 && j & k == 0 && k & i == 0 {
                    ans = min(ans, dp[i][a] + dp[j][b] + dp[k][c]);
                }
            }
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 4140
N, M = map(int,input().split())
p = []
pad = p.append
for i in range(M):
    s = list(map(int,input().split()))
    pad(s + [i])
p.sort()
cur = p[0][0]
cnt = 1
for i in range(M):
    if p[i][0] > cur:
        cur = p[i][0]
        cnt = 1
    p[i][1] = cnt
    cnt += 1
p.sort(key=lambda x: x[2])
for i in range(M):
    print("0" * (6 - len(str(p[i][0]))) + str(p[i][0]) + "0" * (6 - len(str(p[i][1]))) + str(p[i][1]))

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

int main() {
  int m1, d1, m2, d2;
  cin >> m1 >> d1 >> m2 >> d2;
  if (d2 == 1) cout << 1 << endl;
  else cout << 0 << endl;
  return 0;
}

Measured memory_bytes: 3624
A,V = map(int,input().split())
B,W = map(int,input().split())
T=int(input())

place_A=A+(T*V)
place_B=B+(T*W)

place_A_1=A-(T*V)
place_B_1=B-(T*W)

if A<B:
    if place_A>=place_B:
        print("YES")

    else:
        print("NO")

else:
    if place_A_1<=place_B_1:
        print("YES")
    else:
        print("NO")


Measured memory_bytes: 9216
#include<bits/stdc++.h>
using namespace std;
typedef long long int LL;

int main()
{
   int n,i,j;
   cin>>n;
   int arr[n];
   int cnt=0;
   int cntt=0;
   for(int i=0;i<n;i++)
   {
       cin>>arr[i];

       if(arr[i]%2==0)
       {
           cnt++;
          if(arr[i]%3==0 || arr[i]%5==0)
          {
              cntt++;
             // break;
          }
       }
   }
   if(cnt==cntt)
   {
       cout<<"APPROVED"<<endl;
   }
   else

    cout<<"DENIED"<<endl;
   return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
 
using namespace std;
 
struct TRAMP{
    char mark;
    int number;
};
 
int main(){
    int n,min;
    char buf[3];
    scanf("%d",&n);
 
    TRAMP selectArray[n],bubbleArray[n];
 
    for(int i = 0; i < n; i++){
        scanf("%s",buf);
        selectArray[i].mark = buf[0];
        selectArray[i].number = buf[1] - '0';
        bubbleArray[i] = selectArray[i];
    }
 
    for(int i = n-1; i >= 0; i--){
        for(int j = 0; j < i; j++){
            if(bubbleArray[j].number > bubbleArray[j+1].number) swap(bubbleArray[j], bubbleArray[j+1]);
        }
    }
 
    for(int i = 0; i < n-1; i++){
        min = i;
        for(int j = i+1; j < n; j++){
            if(selectArray[j].number < selectArray[min].number){
                min = j;
            }
        }
        if(i != min){
            swap(selectArray[i],selectArray[min]);
        }
    }
 
    for(int i = 0; i < n-1; i++) printf("%c%d ",bubbleArray[i].mark,bubbleArray[i].number);
    printf("%c%d\n",bubbleArray[n-1].mark,bubbleArray[n-1].number);
    printf("Stable\n");
    for(int i = 0; i < n-1; i++) printf("%c%d ",selectArray[i].mark,selectArray[i].number);
    printf("%c%d\n",selectArray[n-1].mark,selectArray[n-1].number);
 
    int p;
    for(p=0; p < n; p++){
        if(selectArray[p].number != bubbleArray[p].number || selectArray[p].mark != bubbleArray[p].mark)
            break;
    }
    if(p == n){
        printf("Stable\n");
    }else{
        printf("Not stable\n");
    }
 
    return 0;
}


Measured memory_bytes: 2740
#include<iostream>
#include <cstdio>
#include<cstring>
#include<string>
#include <cstdlib>  
#include<cmath>   
#include <cctype>
#include<string>
#include<set>
#include <iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include<list>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility>
#define LEN 100005
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,n) for(ll i=0;i<n;i++)
#define For(i,m,n) for(int i=m;i<n;i++)
#define FOR(i,m,n) for(ll i=m;i<n;i++)
using namespace std;
using ll = long long;
double pi() { return 3.14; }
int sum(int a, int b) { return a + b; }
int mul(int a, int b) { return a * b; }
ll LGCD(ll x, ll y) { if (x % y == 0) return y;else return LGCD(y, x % y); }
ll LLCM(ll x, ll y) { return x * y / LGCD(x, y); }

int GCD(int x, int y) { if (x % y == 0) return y;else return GCD(y, x % y); }
int LCM(int x, int y) { return x * y / GCD(x, y); }
ll dpc[10000][10000];

//void nCr(ll n, ll r) {
//	ll ans = 1;
//	for (int i = n; i > n - r; --i) {
//		ans = ans * i;
//	}
//	for (int i = 1; i < r + 1; ++i) {
//		ans = ans / i;
//	}
//	printf("%d",ans);
//}

ll combination(ll n, ll r) {
	if (n == r) { return dpc[n][n] = 1; }
	else if (r == 0) { return dpc[n][0] = 1; }
	else if (r == 1) { return dpc[n][1] = n; }
	else if (dpc[n][r]) { return dpc[n][r]; }
	else { return dpc[n][r] = combination(n - 1, r - 1) + combination(n - 1, r); }
}

//cout << fixed << setprecision(10);
int searchint(string s, int suuji, int k, int n) {
	int t = 0;
	for (int i = k;i < n;i++) {
		if (s[i] - '0' == suuji) {
			t = 1;
			return i;
		}

	}if (t == 0)return -1;

}

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

	int fir[10], sec[10], thi[10];
	int ans=0;

	for (int j1 = 0;j1 < 10;j1++) {

		fir[j1] = searchint(s, j1, 0, n);
		sec[j1] = fir[j1];
		thi[j1] = fir[j1];
	}
	int seca, thia;

	for (int j1 = 0;j1 < 10;j1++) {
		if (fir[j1] == -1)continue;
		else {
			for (int j2 = 0; j2 < 10;j2++) {
				if (sec[j1] == -1)continue;
				else if (sec[j2] > fir[j1]) {
					for (int j3 = 0; j3 < 10;j3++) {
						if (thi[j3] == -1)continue;
						else if (thi[j3] > sec[j2]) { ans++; }
						else {
							thia = searchint(s, j3, sec[j2] + 1, n);
							if (thia == -1)continue;
							else { ans++; }
						}
					}
				}
				else {
					seca = searchint(s, j2, fir[j1] + 1, n);
					if (seca == -1)continue;
					else {
						for (int j3 = 0; j3 < 10;j3++) {
							if (thi[j3] == -1)continue;
							else if (thi[j3] > seca) { ans++; }
							else {
								thia = searchint(s, j3, seca + 1, n);
								if (thia == -1)continue;
								else { ans++; }
							}
						}
					}
				}
			}
		}
	}

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

Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <vector>
#include <stack>
#include <map>
#include <set>
#include <cmath>
#include <cctype>
#include <ctime>
#include <cassert>

using namespace std;

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define eps 1e-9

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

const int INF = 0x7fffffff;
int A, B, C, t1, t2, t3;

int main() {
#ifdef __AiR_H
    freopen("in.txt", "r", stdin);
//    freopen("out.txt", "w", stdout);
#endif // __AiR_H
    scanf("%d %d %d", &A, &B, &C);
    if ((A % 2) || (B % 2) || (C % 2)) { printf("0\n"); return 0; }
    if (A == B && B == C) { printf("-1\n"); return 0; }
    int ans = 0;
    while (A % 2 == 0 && B % 2 == 0 && C % 2 == 0) {
        t1 = A / 2; t2 = B / 2; t3 = C / 2;
        A = t2 + t3; B = t1 + t3; C = t1 + t2; ++ans;
    }
    printf("%d\n", ans);
#ifdef __AiR_H
    printf("Time used = %.2fs\n", (double)clock() / CLOCKS_PER_SEC);
#endif // __AiR_H
    return 0;
}


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

int main(void){
    double h, w;
    cin >> h >> w;
    if (h == 1 || w ==  1) cout << 1 << endl;
    else cout << (long long int)ceil(h*w/2) << endl;
    return 0;
}


Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

tmp = -10
res = 0
for i in range(N):
  res += B[A[i]-1]
  
  if A[i] == tmp + 1:
    res += C[tmp-1]
    
  tmp = A[i]
  
print(res)

Measured memory_bytes: 3064
#include <algorithm>
#include <bits/stdc++.h>
#include<iostream>
#include<string>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
int main(){
    string st;
    cin>>st;
    int n=st.size();
    cout<<st[0]<<n-2<<st[n-1]<<endl;
}

Measured memory_bytes: 256
N=int(input())
A=list(map(int,input().split()))
cnt=[0,0,0,0]
for a in A:
    cnt[a]+=1
aaa=cnt[1]
bbb=cnt[2]
ccc=cnt[3]

dp=[[[0]*(N+1) for j in range(bbb+ccc+1)] for i in range(ccc+1)]

for k in range(ccc+1):
    for j in range(bbb+ccc-k+1):
        for i in range(N-k-j+1):
            tmp=i+j+k
            if tmp==0:
                continue
            else:
                dp[k][j][i]=N/tmp
                if i>0:
                    dp[k][j][i]+=i*dp[k][j][i-1]/tmp
                if j>0:
                    dp[k][j][i]+=j*dp[k][j-1][i+1]/tmp
                if k>0:
                    dp[k][j][i]+=k*dp[k-1][j+1][i]/tmp
                
print(dp[ccc][bbb][aaa])

Measured memory_bytes: 495244
#include<stdio.h>

int main(void){

  int a=0,b=0,c=0;
  int d=0;
  int dca=0,dba=0,dcb=0;

  scanf("%d %d %d %d", &a, &b, &c, &d);

if(c-a>=0){
  dca=c-a;
}else{
  dca=a-c;
}
if(b-a>=0){
  dba=b-a;
}else{
  dba=a-b;
}
if(c-b>=0){
  dcb=c-b;
}else{
  dcb=b-c;
}


  if(dca<=d){
    printf("Yes\n");
    return 0;
  }else{
    if(dba<=d && dcb<=d){
      printf("Yes\n");
    }else{
      printf("No\n");
    }
  }

  return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<vector>
using namespace std;
int main(){
	int n, k;
	cin >> n >> k;
	vector<int> h(n);
	for (int i = 0; i < n; i++){
		cin >> h.at(i);
	}
	int ans = 0;
	for (int i = 0; i < n; i++){
		if (h.at(i) >= k){
			ans++;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 640
while True:
    H,W=map(int,input().split())
    if H==0 and W==0:
        break
    for h in range(H):
        for w in range(W):
            if (h+w)%2==0:
                print("#",end="")
            else:
                print(".",end="")
        print()
    print()
            
        


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

int main() {
    string s;
    int n;
    cin >> n >> s;
    for (int i = 0; i < s.size();i++) {
        s[i] = (s[i] + n  - 'A') % 26 + 'A';
    }
    cout << s << endl;
    return 0;
}

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

typedef long long ll;
const ll INF = 1e9, MOD = 1e9 + 7;
const double EPS = 1e-9, PI = 3.141592653589793;
#define REP(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
#define REPR(i,a,b) for(ll i=b;i>=a;i--)
#define repr(i,n) REPR(i,0,n)
#define all(v) (v).begin(), (v).end()
#define pb push_back

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

    string s,t;
    cin >> s >> t;
    if(s[0]==t[2] && s[1]==t[1] && s[2]==t[0]) cout << "YES" << "\n";
    else cout << "NO" << "\n";
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(n); ++i)
using namespace std;
using ll = long long;
int main(void){
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    sort(a.rbegin(), a.rend());
    ll ans = 0;
    int t = n-1;
    rep(i, n){
        int lim = 2;
        if (i==0) lim=1;
        rep(j, lim){
            if (t > 0){
                ans += a[i];
                t--;
            }
        }
    }
    cout << ans << endl;
    return 0;
    
}


Measured memory_bytes: 4036
#include <iostream>
#include <utility>
#include <vector>
#include <algorithm>

using namespace std;

typedef vector<int> Cards;

int main() {
  Cards ss, hs, cs, ds;
  int n;

  cin >> n;
  for(int i=0; i<n; i++) {
    char s;
    int m;
    cin >> s >> m;
    switch(s) {
    case 'S':
      ss.push_back(m);
      break;
    case 'H':
      hs.push_back(m);
      break;
    case 'C':
      cs.push_back(m);
      break;
    case 'D':
      ds.push_back(m);
      break;
    }
  }

  sort(ss.begin(), ss.end());
  sort(hs.begin(), hs.end());
  sort(cs.begin(), cs.end());
  sort(ds.begin(), ds.end());

  int idx = 0;
  for(auto itr = ss.begin(); itr != ss.end(); itr++) {
    if(*itr > idx+1) {
      for(int i=0; i<*itr-idx-1; i++) {
	cout << "S " << idx+1 + i << endl;
      }
    }
    idx = *itr;
  }
  if(idx != 13) {
    for(int i=idx+1; i<=13; i++) {
      cout << "S " << i << endl;
    }
  }
  
  idx = 0;
  for(auto itr = hs.begin(); itr != hs.end(); itr++) {
    if(*itr > idx+1) {
      for(int i=0; i<*itr-idx-1; i++) {
	cout << "H " << idx+1 + i << endl;
      }
    }
    idx = *itr;
  }
  if(idx != 13) {
    for(int i=idx+1; i<=13; i++) {
      cout << "H " << i << endl;
    }
  }
  
  idx = 0;
  for(auto itr = cs.begin(); itr != cs.end(); itr++) {
    if(*itr > idx+1) {
      for(int i=0; i<*itr-idx-1; i++) {
	cout << "C " << idx+1 + i << endl;
      }
    }
    idx = *itr;
  }
  if(idx != 13) {
    for(int i=idx+1; i<=13; i++) {
      cout << "C " << i << endl;
    }
  }
  
  idx = 0;
  for(auto itr = ds.begin(); itr != ds.end(); itr++) {
    if(*itr > idx+1) {
      for(int i=0; i<*itr-idx-1; i++) {
	cout << "D " << idx+1 + i << endl;
      }
    }
    idx = *itr;
  }
  if(idx != 13) {
    for(int i=idx+1; i<=13; i++) {
      cout << "D " << i << endl;
    }
  }
  
  return 0;
}



Measured memory_bytes: 3100
#include <stdio.h>
#include <math.h>

int main(void){
	long long  x;
	double cnt;
	
	scanf("%lld", &x);
	
	cnt = (double)x/11.0*2.0;
	
	cnt = ceil(cnt);
	
	if (cnt*11.0/2.0-5.0 >= x) cnt--;
	
	printf("%lld\n", (long long)cnt);
	
	return 0;
}

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

int main(){
  string w; cin >> w;
  int al[26]={};
  for(int i=0; i<w.size(); i++){
    al[w[i]-'a']++;
  }
  bool beau=true;
  for(int i=0; i<26; i++){
    if(al[i]%2==1){
      beau=false; break;
    }
  }
  cout << (beau?"Yes":"No") << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#define IO(i, o) freopen(i, "r", stdin), freopen(o, "w", stdout)

using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
mt19937 rng((uint32_t)chrono::steady_clock::now().time_since_epoch().count());

int h1, w1, h2, w2;

int main(){
	//IO("input.txt", "output.txt");
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> h1 >> w1 >> h2 >> w2;
	cout << (h1 * w1 - h2 * w1 - w2 * h1 + w2 * h2) << "\n";
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <cstring>
#include <bitset>
#include <cmath>
#include <iomanip>
#include <stack>
#include <set>
#include <queue>
#include <algorithm>
#include <deque>
#include <map>
#include <cmath>
using namespace std;

#define INF 1e18
#define int long long

signed main() {
    int n; cin >> n;
    vector<int> v(n);
    for(int i = 0; i < n; i++) cin >> v[i];

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

    double ans = v[0];
    for(int i = 1; i < n; i++) {
        ans += v[i];
        ans /= 2;
    }

    cout << setprecision(10) << ans << endl;
    return 0;
}


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

// Loops
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
#define _rrep(i, n) rrepi(i, n, 0)
#define rrepi(i, a, b) for (int i = int(a) - 1; i >= int(b); --i)

#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define rrep(...) _overload3(__VA_ARGS__, rrepi, _rrep, )(__VA_ARGS__)
#define each(xi, x) for (auto &&xi : x)
// Note: we can use rep(i,N) or rep(i,from,to)

// typedef
template <class T> using vec = vector<T>;
using ll = long long;
using vi = vec<ll>;
using vvi = vec<vi>;
using vvvi = vec<vvi>;
using pii = pair<ll, ll>;

// Constants

// Shorter repr for frequently used terms
#define pb push_back
#define mp make_pair

// Algorithms
#define all(x) (x).begin(), (x).end()
#define uniq(v) v.erase(unique(all(v)), v.end())
#define perm(c)                                                                \
  sort(all(c));                                                                \
  for (bool c##p = 1; c##p; c##p = next_permutation(all(c)))

template <class T> pair<T, size_t> max(vector<T> &x) {
  auto it = max_element(all(x));
  return mp(*it, it - x.begin());
}
template <class T> pair<T, size_t> min(vector<T> &x) {
  auto it = min_element(all(x));
  return mp(*it, it - x.begin());
}

template <class T> inline bool chmax(T &maxval, const T &newval) {
  if (maxval < newval) {
    maxval = newval;
    return 1;
  }
  return 0;
}
template <class T> inline bool chmin(T &minval, const T &newval) {
  if (minval > newval) {
    minval = newval;
    return 1;
  }
  return 0;
}

// Utilities
// Grid world utilities
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};
#define inside(H, W, y, x) 0 <= (x) && (x) < (W) && 0 <= (y) && (y) < (H)

// Debug
#ifdef LOCAL
#include "dump.hpp"
#define debug(x) cerr << #x << ": " << x << '\n'
#else
#define dump(...)
#define debug(x)
#endif

// Paste snippets here!!

//

void solve(long long N) {
  ll ret = 0;
  rep(i,1,N+1){
    if(i%3==0 || i%5==0) continue;
    ret += i;
  }
  cout << ret << endl;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false); // Magic for faster cin
  cout.precision(12);
  long long N;
  std::cin >> N;
  solve(N);
  return 0;
}


Measured memory_bytes: 3604
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    int n,flag=0,result=0;
    cin>>s;
    for(long int i=s.size()-1;i>=0;i--){
        n=s[i]-'0'+flag;
        if(n<(10-n) || (n==5 && s[i-1]<'5')){
            flag=0;
            result+=n;
        }
        else{
            flag=1;
            result+=(10-n);
        }
    }
    result+=flag;
    cout<<result;
}



Measured memory_bytes: 5320
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcountll
#define INF 1e16
#define mod 1000000007
int main(){
    ll x;
    cin>>x;
    if(x/100 >= (double)(x%100) / 5) cout<<1<<endl;
    else cout<<0<<endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
    	
		Scanner sc = new Scanner(System.in);
		// 文字列整数の入力
		int N = sc.nextInt();
		String S = sc.next();
		int  len = N;
		
		if(len % 2 != 0) {
			System.out.println("No");
	   		sc.close();
	        return ;
		}
		
		int hanbun = len / 2;
		
		String a = S.substring(0, hanbun);
		String b = S.substring(hanbun, len);
		
		if(a.equals(b)) {
			System.out.println("Yes");
			
		}else {
			System.out.println("No");
		}

   		sc.close();
        return ;

    }
    
}



Measured memory_bytes: 22612
// /Code by : Harry_Singh/
#include<bits/stdc++.h>
#define int long long 
#define io ios_base::sync_with_stdio(false),cin.tie(nullptr);
#define ipair pair<int,int>
#define pb push_back
#define f(i,n) for(int i=0;i<n;i++)
#define fo(i,n) for(int i=n;i>=0;i--)
#define F(i,n) for(int i=1;i<=n;i++)
#define FO(i,n) for(int i=n;i>=1;i--)
#define mod 1000000007
using namespace std;
#define inf 100000000000000009
#define tr cout<<"\n" 
#define br break
#define N 100005
// directions
vector<int> G[N];

void we_have_choices()
{


int n;
cin>>n;
int a[n+1];
F(i,n)cin>>a[i];
int sum=0;
for(int i=2;i<=n;i++)
{
  if(a[i]<a[i-1])sum+=(a[i-1]-a[i]),a[i]=a[i-1];
}
cout<<sum;tr;


}


int32_t main()
{
#ifndef ONLINE_JUDGE
 freopen("input.txt","r",stdin);
 freopen("output.txt","w",stdout);
#endif
    io;
    int t=1;
    while (t--)we_have_choices();
    return 0;
}

Measured memory_bytes: 7560
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=5e18;

ll gcd(ll a,ll b) {
  if(b==0) {
    return a;
  }
  else {
    return gcd(b,a%b);
  }
}

int main() {
  ll t;
  cin >> t;
  while(t--) {
    ll a,b,c,d;
    cin >> a >> b >> c >> d;
    if(b>a) {
      cout << "No" << endl;
      continue;
    }
    if(b<=a&&b>d) {
      cout << "No" << endl;
      continue;
    }
    if(b<=a&&d>=b&&c>=b) {
      cout << "Yes" << endl;
      continue;
    }
    ll g=gcd(b,d);
    if(a-(a-c-1)/g*g<b) cout << "No" << endl;
    else cout << "Yes" << endl;
  }
}

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

int main() {
  ll n;
  cin >> n;
  vector<ll> a(n), b(n);
  for (int i = 0; i < n; i++) cin >> a[i] >> b[i];

  ll ans = 0;
  for (int i = n - 1; i >= 0; i--) {
    ll mod = (a[i] + ans) % b[i];
    if (mod == 0) continue;
    ll cnt = b[i] - mod;
    ans += cnt;
  }
  cout << ans << endl;
}


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

int main(){
  int l, r, d;
  cin >> l >> r >> d;
  int ans = 0;
  for (int i=l; i<r+1; i++){
    if (i%d == 0) ans ++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3588
n= int(input())
ac=0
wa=0
tle=0
re=0

for i in range(0,n):
  a = input()
  if (a == 'AC'): ac+=1
  if (a == 'WA'): wa+=1
  if (a == 'TLE'): tle+=1
  if (a == 'RE'): re+=1

print ('AC x',ac)
print ('WA x',wa)
print ('TLE x',tle)
print ('RE x',re)
  

Measured memory_bytes: 9144
#include <bits/stdc++.h>
using namespace std;
 
 
long long dp[101][1<<17] = {0};
 
int main() {
  ios_base::sync_with_stdio(false); cin.tie(0);
  int n, W; cin >> n >> W;
  fill(dp[0] + 1, dp[0] + W + 1, -(1ll<<60));
  for (int i = 1; i <= n; ++i) {
    int w, v; cin >> w >> v;
    copy(dp[i - 1], dp[i - 1] + w, dp[i]);
    for (int j = w; j <= W; ++j) {
      dp[i][j] = max(dp[i - 1][j], dp[i - 1][j - w] + v);
    }
  }
  cout << *max_element(dp[n], dp[n] + W + 1) << '\n';
}


Measured memory_bytes: 102912
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define all(vec) vec.begin(), vec.end()
#define mp(a, b) make_pair(a, b)
typedef long long ll;
const ll INF = 1LL << 60;
const ll MOD = (1e9 + 7);
using namespace std;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
ll dp[100010];
ll gcd(ll x, ll y){
  return y == 0 ? x : gcd(y, x % y);
}
ll lcg(ll x, ll y){
  return x * y / gcd(x, y);
}
ll digits(ll x){
  ll length = 0;
  while (x > 0){
    x /= 10;
    length++;
  }
  return length;
  if (x == 0) return 0;
}
map<ll, ll> factor(ll n){
  map<ll, ll> ans;
  ll a = 2;
  while (n >= a * a){
    if (n % a == 0){
      ans[a]++;
      n /= a;
    }
    else a++;
  }
  ans[n]++;
  return ans;
}
template<class T> inline bool chmin(T& a, T b){
  if (a > b){
    a = b;
    return true;
  }
  return false;
}
template<class T> inline bool chmax(T& a, T b){
  if (a < b){
    a = b;
    return true;
  }
  return false;
}

int main(){
  cout << fixed << setprecision(15);

  int n; cin >> n;
  string s, t; cin >> s >> t;

  //ll ans;
  string ans;

  rep(i, n){
    ans.push_back(s[i]);
    ans.push_back(t[i]);
  }

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

Measured memory_bytes: 256
import sys, math
from itertools import permutations, combinations
from collections import defaultdict, Counter, deque
from math import factorial, gcd
from bisect import bisect_left #bisect_left(list, value)
sys.setrecursionlimit(10**7)
enu = enumerate
MOD = 10**9+7
def input(): return sys.stdin.readline()[:-1]
def pri(x): print('\n'.join(map(str, x)))

N, K = map(int, input().split())

if N<=K:
    print('unsafe')
else:
    print('safe')





Measured memory_bytes: 9480
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define repa(i, s, n) for(int i = s; i < (int)n; i++)
using namespace std;
using ll = long long;
typedef vector<int> vi;

int main(){
	int h, w;
	cin >> h >> w;
	string c;

	rep(i, h){
		cin >> c;
		cout << c << endl << c << endl;
	}

	return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <string>
#include <vector>

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;

int
main()
{
  int H, W;
  cin >> H >> W;
  vector<char> v(H * W);
  vector<int> up(H * W);
  vector<int> down(H * W);
  vector<int> left(H * W);
  vector<int> right(H * W);
  char *data = &v[0];
  for (int h = 0; h < H; h++)
  {
    string s;
    cin >> s;
    char *base = data + W * h;
    for (int w = 0; w < W; w++)
    {
      base[w] = s[w];
    }
  }
  for (int x = 0; x < W; x++)
  {
    up[x] = (v[x] == '.' ? 1 : 0);
  }
  for (int y = 1; y < H; y++)
  {
    int base = W * y;
    for (int x = 0; x < W; x++)
    {
      int i = base + x;
      up[i] = (v[i] == '.' ? up[i - W] + 1 : 0);
    }
  }
  for (int x = 0; x < W; x++)
  {
    int i = W * (H - 1) + x;
    down[i] = (v[i] == '.' ? 1 : 0);
  }
  for (int y = H - 2; 0 <= y; y--)
  {
    int base = W * y;
    for (int x = 0; x < W; x++)
    {
      int i = base + x;
      down[i] = (v[i] == '.' ? down[i + W] + 1 : 0);
    }
  }
  for (int y = 0; y < H; y++)
  {
    int i = W * y;
    left[i] = (v[i] == '.' ? 1 : 0);
  }
  for (int x = 1; x < W; x++)
  {
    for (int y = 0; y < H; y++)
    {
      int i = W * y + x;
      left[i] = (v[i] == '.' ? left[i - 1] + 1 : 0);
    }
  }
  for (int y = 0; y < H; y++)
  {
    int i = W * y + W - 1;
    right[i] = (v[i] == '.' ? 1 : 0);
  }
  for (int x = W - 2; 0 <= x; x--)
  {
    for (int y = 0; y < H; y++)
    {
      int i = W * y + x;
      right[i] = (v[i] == '.' ? right[i + 1] + 1 : 0);
    }
  }

  int best = 0;
  for (int y = 0; y < H; y++)
  {
    int base = W * y;
    for (int x = 0; x < W; x++)
    {
      int i = base + x;
      if (v[i] == '.')
      {
        int count = up[i] + down[i] + left[i] + right[i] - 3;
        if (best < count)
        {
          best = count;
        }
      }
    }
  }
  cout << best << endl;
  return 0;
}


Measured memory_bytes: 66688
#include<bits/stdc++.h>
using namespace std;
int main(){
    int H, W;
    cin >> H >> W;
    char grid[H + 3][W + 3];
    long long dp[H + 3][W + 3];
    for(int i = 1; i <= H; i++){
        for(int j = 1; j <= W; j++){
            cin >> grid[i][j];
            dp[i][j] = 0;
        }
    }
    long long mod = 1e9 + 7;
    dp[1][1] = 1;
    for(int i = 1; i <= H; i++){
        for(int j = 1; j <= W; j++){
            if(grid[i][j] == '.'){
                if(i - 1 >= 1){
                    dp[i][j] = (dp[i][j] + dp[i - 1][j]) % mod;
                }
                if(j - 1 >= 1){
                    dp[i][j] = (dp[i][j] + dp[i][j - 1]) % mod;
                }
            }
        }
    }
    cout << dp[H][W];
    return 0;
}

Measured memory_bytes: 9088
#include <stdio.h>

int main(void)
{
  while(1)
    {
      int a,b[100],i,max,min,sum;
      scanf("%d",&a);
      if(a==0)
	break;
      scanf("%d",&b[0]);
      min=b[0];max=b[0];sum=b[0];
      for(i=1;i<a;i++)
	{
	  scanf("%d",&b[i]);
	  if(max<b[i])
	    max=b[i];
	  if(min>b[i])
	    min=b[i];
	  sum+=b[i];
	}
      printf("%d\n",(sum-max-min)/(a-2));
    }
  return 0;
}

Measured memory_bytes: 600
#include<stdio.h>
#include <algorithm>

int Partition(int A[], int p, int r) {
    int x = A[r];
    int j = p;
    for (int i = p; i < r; ++i) {
        if (A[i] <= x) {
            std::swap(A[j], A[i]);
            ++j;
        }
    }
    std::swap(A[j], A[r]);
    return j;
}

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

    int pivot = Partition(A, 0, n - 1);

    for (int i = 0; i < n; ++i) {
        if (i > 0) {
            printf(" ");
        }
        if (i == pivot) {
            printf("[%d]", A[i]);
        }
        else {
            printf("%d", A[i]);
        }
    }
    printf("\n");
    return 0;
}

Measured memory_bytes: 2980
import std.stdio;
import std.string;
import std.conv;
import std.typecons;
import std.algorithm;
import std.functional;
import std.bigint;
import std.numeric;
import std.array;
import std.math;
import std.range;
import std.container;

char[] str;
void main() {
    int N = readln.chomp.to!int;
    str = readln.chomp.to!(char[]);
    int cnt = 0;
    foreach(i; 0..N) {
        char[] s = readln.chomp.to!(char[]);
        if (rec(0, 0, s, [])) cnt++;
    }
    cnt.writeln;
}
bool rec(int depth, int index, char[] s, int[] ary) {
    if (ary.length == str.length) {
        return true;
    } else if (depth<s.length){
        if (s[depth] == str[index]) {
            if (ary.length<2 || depth-ary[$-1]==ary[$-1]-ary[$-2]) {
                int[] _ary = ary.dup;
                if (rec(depth+1, index+1, s, _ary~depth)) return true;
            }
        }
        if (rec(depth+1, index, s, ary)) return true;
    }
    return false;
}

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

int N,M;
int A[200010],B[200010];

int main()
{
    scanf("%d",&N);
    for(int i = 0; i < N; i++)scanf("%d",A + i);
    scanf("%d",&M);
    for(int i = 0; i < M; i++)scanf("%d",B + i);

    sort(A,A + N);
    sort(B,B + M);

    int l = 0;

    for(int i = 0; i < M; i++)
    {
        while(l < N && B[i] != A[l])l++;
        l++;
        if(l > N)
        {
            printf("NO\n");
            return 0;
        }
    }
    printf("YES\n");
    return 0;
}


Measured memory_bytes: 1792
sub u1{my$i=pop;
	$p[$i]=$p[$i]&&$p[$i]!=$i?u1($p[$i]):$i+0
}
sub u2{my$i=pop;
	$q[$i]=$q[$i]&&$q[$i]!=$i?u2($q[$i]):$i+0
}
($N,$K,$L)=split$",<>;
for(1..$K){
	($a,$b)=split$",<>;
	$a=u1($a+0);
	$b=u1($b+0);
	if($a!=$b){
		$p[$a]=$b
	}
}
for(1..$L){
	($a,$b)=split$",<>;
	$a=u2($a+0);
	$b=u2($b+0);
	if($a!=$b){
		$q[$a]=$b
	}
}
@s=map[u1($_),u2($_),$_],1..$N;
@s=sort{@$a[0]cmp@$b[0]||@$a[1]cmp@$b[1]}@s;
for($i=0;$i<$N;){
	$j=$i+1,$t=1;
	($a,$b)=@{$s[$i]};
	for(;($c,$d)=@{$s[$j]},$j<$N&&$a==$c&&$b==$d;++$j){
		++$t
	}
	for(;$i<$j;++$i){
		$ans[@{$s[$i]}[2]]=$t
	}
}
print$_,$"for@ans


Measured memory_bytes: 88184
n=int(input())
m={}
s=0
for i in input().split():
    i=int(i)
    x=m.get(i,0)
    m[i]=x+1
    s+=i
q=int(input())
for i in range(q):
    b,c=[int(i) for i in input().split()]
    x=m.get(b,0)
    y=m.get(c,0)
    m[b]=0
    m[c]=x+y
    s=s-(b*x)+(c*x)
    print(s)


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

int main() {
    long long int n, ans = (long long int)1e18;
    cin >> n;
    int a[n];
    long long int L = 0;
    long long int cut[n+1] = {0};
    for(int i = 0 ; i < n; ++i) {
        cin >> a[i];
        L += a[i];
        cut[i+1] = L;
    }
    for(int i = 0; i < n; ++i) {
        ans = min(ans, abs(cut[i] - (L - cut[i])));
    }

    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 2560
li=list(input())

def Calc(a,b,s):
  if s=='+':
    return a+b
  else:
    return a-b

for i in range(2**3):
    b=['+','+','+']
    for j in range(3):
        if (i >> j) & 1:
            b[j]='-'
    aplusb=Calc(int(li[0]),int(li[1]),b[0])
    abplusc=Calc(aplusb,int(li[2]),b[1])
    calc=Calc(abplusc,int(li[3]),b[2])
    
    if calc==7:
      print(str(li[0])+b[0]+str(li[1])+b[1]+str(li[2])+b[2]+str(li[3])+'=7')
      break
      
     

Measured memory_bytes: 9080