akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <cmath>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <set>

template<class T>
std::pair<std::vector<T>, std::vector<T> > getPrimeFactors(const T &N){
    const T zero = static_cast<T>(0);
    const T one = static_cast<T>(1);
    const T two = static_cast<T>(2);
    std::vector<T> F; //prime factors
    std::vector<T> E; //exponents
    T tmpN = N, tmpE;
    for(T i=two; i*i<=N; ++i){
        if(tmpN%i == zero){
            F.emplace_back(i);
            tmpE = zero;
            while(tmpN%i == zero){
                tmpN /= i;
                ++tmpE;
            }
            E.emplace_back(tmpE);
        }
    }
    if(tmpN > one){
        F.emplace_back(tmpN);
        E.emplace_back(one);
    }
    return std::make_pair(F,E);
}


int main(int argc, char *argv[]){
    int N;
    std::cin >> N;
    std::map<int,int> map;
    for(int i=2; i<=N; ++i){
        auto pf = getPrimeFactors(i);
        for(int j=0; j<pf.first.size(); ++j){
            map[pf.first[j]] += pf.second[j];
        }
    }
    std::vector<int> vector;
    for(auto &kv : map){
        vector.emplace_back(kv.second+1);        
    }
    std::sort(vector.begin(),vector.end());

    auto numGe = [&vector](int i){
        return vector.end() - std::lower_bound(vector.begin(),vector.end(),i);
    };

    long long num75 = 0LL;
    //75
    num75 += numGe(75);
    //25*3
    num75 += numGe(25)*(numGe(3)-1);
    //15*5
    num75 += numGe(15)*(numGe(5)-1);
    //5*5*3
    num75 += (numGe(5)*(numGe(5)-1))/2*(numGe(3)-2);

    std::cout << num75 << std::endl;

    return 0;
}


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

using namespace std;

int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  int left = a + b;
  int right = c + d;
  if (left == right) cout << "Balanced" << endl;
  if (left > right) cout << "Left" << endl;
  if (left < right) cout << "Right" << endl;
  return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
input = lambda: sys.stdin.readline()[:-1]
sys.setrecursionlimit(10**8)
inf = float('inf')
mod = 10**9+7


def make_divisors(n):
    re=inf
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            if i != n // i:
                re=min(re,i+(n//i))
            else:
                re=min(re,i+i)
    return re

n = int(input())
ans = 0
a = make_divisors(n)
print(a-2)


Measured memory_bytes: 3064
#include <iostream>
#include <math.h>
using namespace std;
typedef long long ll;

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

int main() {
  int x;
  cin >> x;
  if(x==2){cout << 2 << endl; return 0;}
  for(int i = x; i < 100004; i++){
    if(i%2 == 0)continue;
    if(sosu(i)){cout << i << endl; return 0;}
  }
}


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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define pb push_back
#define rep(i, a, n) for(int i = (a); i < (n); i++)
#define dep(i, a, n) for(int i = (a); i >= (n); i--)
#define mod (ll)(1e9+7)
#define int ll

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

struct T {
  int to, en, sn;
};

int enk[100001], snk[100001];

signed main() {
  int n, m, s, t;
  cin >> n >> m >> s >> t;

  vector<T> v[100001];

  rep(i, 0, n + 1) {
    enk[i] = 1000000000000000;
    snk[i] = 1000000000000000;
  }

  rep(i, 0, m) {
    int u, vv, a, b;
    cin >> u >> vv >> a >> b;
    v[u].pb({vv, a, b});
    v[vv].pb({u, a, b});
  }

  snk[t] = 0, enk[s] = 0;

  priority_queue<P, vector<P>, greater<P> > pq;
  pq.push({0, s});

  while(!pq.empty()) {
    P p = pq.top();
    pq.pop();
    if(enk[p.second] < p.first) continue;
    rep(i, 0, v[p.second].size()) {
      if(enk[v[p.second][i].to] > p.first + v[p.second][i].en) {
        enk[v[p.second][i].to] = p.first + v[p.second][i].en;
        pq.push({p.first + v[p.second][i].en, v[p.second][i].to});
      }
    }
  }
  priority_queue<P, vector<P>, greater<P> > pq2;
  pq2.push({0, t});

  while(!pq2.empty()) {
    P p = pq2.top();
    pq2.pop();
    if(snk[p.second] < p.first) continue;
    rep(i, 0, v[p.second].size()) {
      if(snk[v[p.second][i].to] > p.first + v[p.second][i].sn) {
        snk[v[p.second][i].to] = p.first + v[p.second][i].sn;
        pq2.push({p.first + v[p.second][i].sn, v[p.second][i].to});
      }
    }
  }

  int r[100001] = {};
  rep(i, 0, n + 1) r[i] = enk[i] + snk[i];
  dep(i, n - 1, 0) r[i] = min(r[i], r[i + 1]);
  rep(i, 1, n + 1) {
    cout << 1000000000000000 - r[i] << endl;
  }

}


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

#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <algorithm>

#include <bits/stdc++.h>
#include <cmath>
#include <limits>

using namespace std;
typedef long long LL;

LL GCD(LL x, LL y){
        LL r=0;
        if( x<y ) swap(x, y);
        r = x % y;
        while(r!=0){
                x = y;
                y = r;
                r = x % y;
        }
        return y;
}

long long A[100002] = {0};

int main(int argc, char* argv[]){
	cin.tie(0);
	ios::sync_with_stdio(false);

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

	if(N == 2){
		cout << max(A[1], A[2]) << endl;
		return 0;
	}

	long long d = A[1];
	vector<int> v;
	for(int i=2; i<=N; i++){
		long long u = GCD(d, A[i]);
		if(u < d){
			d = u;
			v.push_back(i);
		}
	}
    long long ans = 1;
	v.push_back(1);
	for(int k=0; k<v.size(); k++){
		long long d = 1;
		int index = v[k];
		int count = 0;
		for(int i=1; i<=N; i++){
			if(i == index) continue;
			count++;
			if(count == 1){
				d = A[i];
			}
			long long u = GCD(d, A[i]);
			if(count > 1) d = u;
		}
		if(ans < d) ans = d;
	}
	cout << ans << endl;
	return 0;
}

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

typedef long long ll;
using namespace std;

int main(){
	
	int n;
	cin >> n;
	vector< vector<int> > happ(n, vector<int>(3));
	int INF = 1<<30;
	
	for(int i=0;i<n;++i)
		for(int j=0;j<3;++j)
			cin >> happ[i][j];
	//dp[i][j] es la mayor felicidad del dia i con la actividad anterior j
	vector< vector<int> > dp(n, vector<int>(3,0));
	dp[0][0]=max(happ[0][1],happ[0][2]);
	dp[0][1]=max(happ[0][0],happ[0][2]);
	dp[0][2]=max(happ[0][1],happ[0][0]);
	for(int day=1;day<n;++day){
		for(int i=0;i<3;++i){
			for(int j=0;j<3;++j){
				if(i!=j){
					dp[day][j]=max(dp[day][j],dp[day-1][i]+happ[day][j] );
				}
			}
		}
	}
	
	int maxi = -INF;
	for(int i=0;i<3;++i){
		maxi = max(maxi,dp[n-1][i]);
	}
	cout << maxi;
			
	
	
	return 0;
}


Measured memory_bytes: 11136
def main ():
	N = int(input())
	A = list(map(int,input(). split ()))
	if 0 in A:
		print(0)
		return
	prod = 1
	for a in A:
		prod *= a
		if prod > 1000000000000000000:
			print(-1)
			return
	print(prod)
main ()

Measured memory_bytes: 21648
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)

int main()
{
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    while (1) {
        c -= b;
        if (c <= 0) {
            cout << "Yes" << endl;
            break;
        }
        a -= d;
        if (a <= 0) {
            cout << "No" << endl;
            break;
        }
    }
}

Measured memory_bytes: 3592
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<map>
#include<set>
#include<queue>
#include<cstdio>
#include<climits>
#include<cmath>
#include<cstring>
#include<string>
#include<sstream>
#include<cassert>

#define f first
#define s second
#define mp make_pair

#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin(); i!=(c).end(); i++)
#define ALL(c) (c).begin(), (c).end()

using namespace std;

typedef unsigned int uint;
typedef long long ll;

#define MAX 1000001

int main(){
  int num[34] = {1};
  REP(i,31){
    num[i+3] += num[i];
    num[i+2] += num[i];
    num[i+1] += num[i];
  }
  int n;
  while(scanf("%d",&n),n)
    printf("%d\n",(num[n]+3649)/3650);
  return 0;
}

Measured memory_bytes: 0
a,b=map(int,input().split())
y=[]
for i in range(a-1):
    v=list(map(int,input().split()))
    y.append(v)
y.sort(key=lambda n:n[0])
ans=[0]*a
for j in range(b):
    c,d=map(int,input().split())
    ans[c-1]=ans[c-1]+d
for k in range(a-1):
    ans[y[k][1]-1]=ans[y[k][1]-1]+ans[y[k][0]-1]
print(*ans,sep=" ")


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

h2=[]
for hh in h:
 h2.append(t-0.006*hh)

v=10**9
for i in range(n):
 if abs(v-a)>abs(h2[i]-a):
  v=h2[i]
  inx=i+1
print(inx)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define Rep(i, N) for(int i = 0; i < N; i++)

signed main()
{
  int N;
  int A, cnt = 0;

  cin >> N;

  Rep(i, N) {
    cin >> A;
    if(A % 2)cnt++;
  }

  if(cnt % 2) cout << "NO" << endl;
  else cout << "YES" << endl;
  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define dump(x) cout << (x) << endl
typedef long long ll;
typedef pair<int, int> pi;
typedef vector<int> V;

int main() {
  int n;
  cin >> n;
  vector<ll> t(n), a(n);
  for (int i = 0; i < n; i++) cin >> t[i] >> a[i];
  ll x, y;
  x = y = 1;
  for (int i = 0; i < n; i++) {
    ll n;
    ll p = x/t[i];
    if (x%t[i] != 0) p++;
    ll q = y/a[i];
    if (y%a[i] != 0) q++;
    n = p >= q ? p : q;
    if (n == 0) n = 1;
    x = t[i]*n;
    y = a[i]*n;
  }
  dump(x+y);
  return 0;
}


Measured memory_bytes: 256
import java.io.*;

class Main{
public static void main(String[] args) throws IOException {

 BufferedReader reader =new BufferedReader(new InputStreamReader(System.in));
 String[] line = reader.readLine().split(" ");
 int a = Integer.parseInt(line[0]);
 int b = Integer.parseInt(line[1]);
  
 int area = a * b;
 int areaLength = ( a + b ) * 2;
 System.out.println(area + " " + areaLength);

}

}

Measured memory_bytes: 24272
#include <bits/stdc++.h>
#include <math.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rrep(i, n) for(int i = 0; i <= (n); i++)
using namespace std;
typedef long long ll;
 
const ll INF = 1LL<<62;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// 多次元 vector 生成
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

const int MOD = 1000000007;

int ans = 100000000;

int main(){
    int A, B; cin >> A >> B;
    string S; cin >> S;
    int n = S.size();

    bool isOK = true;
    rep(i,n){
        if (i != A){
            if (!('0' <= S[i] && S[i] <= '9')){
                isOK = false;
                break;
            }
        }
        else{
            if (S[i] != '-'){
                isOK = false;
                break;
            }
        }
    }
    if (isOK) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 3628
n = int(input())
s = [input() for _ in range(n)]

name_cnt = {'M': 0, 'A': 0, 'R': 0, 'C': 0, 'H': 0}
for s_i in s:
    if s_i[0] in name_cnt.keys():
        name_cnt[s_i[0]] += 1

name_set = set()
name_chars = list(name_cnt.keys())

ans = 0
for i in range(0, 5):
    for j in range(i + 1, 5):
        for k in range(j + 1, 5):
            ans += name_cnt[name_chars[i]] * name_cnt[name_chars[j]] * name_cnt[name_chars[k]]
print(ans)


Measured memory_bytes: 16196
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Deque;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		int m = sc.nextInt();
		int k = sc.nextInt();
	    Deque<Integer> aq = new ArrayDeque<>();
	    Deque<Integer> bq = new ArrayDeque<>();
		
		int[] a = new int[n+1];
		long[] as = new long[n+1];
		for( int i=0 ; i<n ; i++ ) {
			a[i] = sc.nextInt();
			as[i+1] = as[i] + a[i];
		}
		int[] b = new int[m+1];
		long[] bs = new long[m+1];
		for( int i=0 ; i<m ; i++ ) {
			b[i] = sc.nextInt();
			bs[i+1] = bs[i] + b[i];
		}
		
		int c=0;
		
		int j=m;
		for( int i=0 ; i<n+1 ; i++ ) {
			if( as[i] > k) {
				break;
			}
			while( bs[j] > k - as[i] ) {
				j--;
			}
			c = Math.max(c, i+j);
		}
		
		System.out.println(c);
//		for( int in =0 ; in < n+1 ; in++ )
			System.err.println(Arrays.toString(as));
			System.err.println(Arrays.toString(bs));
		
	}

}


Measured memory_bytes: 73236
mod scanner {
    use std::io::StdinLock;
    use std::str::FromStr;
    use std::io::BufRead;
    pub struct Scanner<'a> {
        stdin: StdinLock<'a>,
        token: Vec<String>,
    }
    impl<'a> Scanner<'a> {
        pub fn new(stdin: StdinLock) -> Scanner {
            Scanner {
                stdin: stdin,
                token: vec![],
            }
        }
        pub fn read<T: FromStr>(&mut self) -> T {
            loop {
                if let Some(token) = self.token.pop() {
                    return token.parse().ok().unwrap();
                }
                let mut s = String::new();
                self.stdin.read_line(&mut s).unwrap();
                self.token = s.trim().split_whitespace().rev().map(String::from).collect();
            }
        }
    }
}

fn main() {
    run();
}

fn run() {
    let stdin = std::io::stdin();
    let mut sc = scanner::Scanner::new(stdin.lock());
    let n: usize = sc.read();
    let m: usize = sc.read();
    let mut x = vec![false; n + 1];
    let mut y = vec![false; n + 1];
    for _ in 0..m {
        let a: usize = sc.read();
        let b: usize = sc.read();
        if a == 1 {
            x[b] = true;
        }
        if b == n {
            y[a] = true;
        }
    }
    if x.iter().zip(y.iter()).any(|(a, b)| *a && *b) {
        println!("POSSIBLE");
    } else {
        println!("IMPOSSIBLE");
    }
}


Measured memory_bytes: 4352
//----------------------------------------------------------------------
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
//----------------------------------------------------------------------

using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;

int main(void) {
    int a, b, c;
    cin >> a >> b >> c;
    cout << max(c - (a-b), 0) << endl;;
    return 0;
}


Measured memory_bytes: 256
n, m = map(int, input().split())
a = [list(input()) for _ in range(n)]
b = [list(input()) for _ in range(m)]
for i in range(n - m + 1):
    for j in range(n - m + 1):
        flag = True
        for k in range(m):
            if a[i + k][j:j + m] != b[k]:
                flag = False
                break
        if flag:
            print('Yes')
            exit()
print('No')


Measured memory_bytes: 3060
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
struct city
{
	int cs,bh;
	int px,sr;
}a[100010];
int n,m;
int cc[100010];
bool cmp1(city x,city y)
{
	if(x.cs!=y.cs)  return x.cs<y.cs;
	  else  return x.bh<y.bh;
}
bool cmp2(city x,city y)
{
	return x.sr<y.sr;
}
int main()
{
	cin>>n>>m;
	for(int i=1;i<=m;i++)
	  cin>>a[i].cs>>a[i].bh,a[i].sr=i;
	sort(a+1,a+m+1,cmp1);
	for(int i=1;i<=m;i++)
	  a[i].px=++cc[a[i].cs];
	sort(a+1,a+m+1,cmp2);
	for(int i=1;i<=m;i++)
	  {
	  	int dqc=a[i].cs,gs=0;
	  	while(dqc>0)  gs++,dqc/=10;
	  	for(int j=1;j<=6-gs;j++)  cout<<0;
	  	cout<<a[i].cs;
	  	dqc=a[i].px,gs=0;
	  	while(dqc>0)  gs++,dqc/=10;
	  	for(int j=1;j<=6-gs;j++)  cout<<0;
	  	cout<<a[i].px<<endl;
	  }
	return 0;
}

Measured memory_bytes: 3456
N,M = map(int,input().split())
maxl = 1
minr = N
for i in range(M):
    l,r = map(int,input().split())
    if l >= maxl:
        maxl = l
    if r <= minr:
        minr = r
if maxl > minr:
    print(0)
else:
    print(minr-maxl+1)

Measured memory_bytes: 45288
#include<iostream>
using namespace std;
int main(){
  int n;
  double num=100000.0;
  cin>>n;
  for(int i=0;i<n;i++){
    num=num*1.05;
    if((int)num%1000>0){
      num=(int)num-(int)num%1000;
      num+=1000.0;
    }
  }
  cout<<(int)num<<endl;
  return 0;
}


Measured memory_bytes: 3112
// Original macro is in https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = || -> String {
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}
 
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};
 
    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
    
    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}
 
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };
 
    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [$t:tt]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };
 
    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };
 
    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };
 
    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

// for adhoc read (ex. https://atcoder.jp/contests/abc112/tasks/abc112_a)
#[allow(dead_code)]
fn read_line() -> String {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}
use std::cmp;
fn main() {
    input!{ k: i32, s: i32 }
    let mut ret = 0;

    for x in 0..k+1 {
        for y in 0..(k+1) {
            let z = s - x - y;
            if 0 <= z && z <= k {
                // println!("x {} y {} z {}", x, y, z);
                ret += 1;
            }
        }
    }
    println!("{}", ret);
}

Measured memory_bytes: 4352
S=list(input())
N=len(S)

S1=S[:int((N-1)/2)]
S2=S[int((N+3)/2)-1:]
S1r=[i for i in S1[::-1]]
S2r=[i for i in S2[::-1]]
Sr=[i for i in S[::-1]]
if S1==S1r and S2==S2r and S==Sr:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 38384
#include <bits/stdc++.h>
#define in_arr(n,A)                     for(int i=0;i<n;i++)cin>>A[i];
#define IOS                             ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define vi                              vector <int>
#define vl                              vector <ll>
#define out_arr(n,A)                    for(int i=0;i<n;i++)cout<<A[i]<<" ";
#define LINE                            cout << endl
#define SPACE                           cout << " "
#define pb                              push_back
#define Fr                              first
#define Sc                              second
#define YES                             cout << "YES"
#define NO                              cout << "NO"
#define wrong                           cout << -1
#define pll                             pair <ll, ll>
#define pii                             pair <int, int>
#define OO                              INT_MAX
#define SMALL                           INT_MIN
#define BIGx2                           LONG_LONG_MAX
#define sz                              size()
//BIT_OP
#define isOn(s, j)                      (s & (1<<j))
#define setBit(s, j)                    (s |= ( 1<< j))
#define clearBit(s, j)                  (s &= ~( 1 << j ))
#define lowBit(s)                       (s & (-s))
#define setAll(s, n)                    ( s = ( 1 << n ) - 1)
#define modulo(s, n)                    ((s) & ( n - 1 ))
#define isPowerOfTwo(s)                 (!(s & (s - 1)))
#define nearestPowerOfTwo(s)            ((int)pow(2.0, (int)((log((double)s) / log(2.0)) + 50. )))
#define nextnearestPowerOfTwo(s)        (1<<(32 - __builtin_clz(s)))
#define turnoffLastBit(s)               ((s) & (s - 1))
#define turnonLastZero(s)               ((S) | (s + 1))
#define turnoffLastConsecutiveBits(s)   ((s) & (s + 1))
typedef long long ll;
using namespace std;
ll n;
int A[200200];

int main()
{
    IOS
    cin >> n;
    ll Bla = n * (n + 1);
    Bla = Bla >> 1;
    cout << Bla - n << endl;;
}


Measured memory_bytes: 256
# ABC066C - pushpush (ARC077)
from collections import deque

n = int(input())
lst = list(map(int, input().rstrip().split()))
b = deque()
parity = n % 2
for i, j in enumerate(lst, start=1):
    if i % 2 == parity:
        b.appendleft(j)
    else:
        b.append(j)
print(*b)

Measured memory_bytes: 25412
#include <iostream>
#include <cstdio>
#include <vector>
#define N 100000
using namespace std;
typedef long long ll;

ll n, k, en, M=1e9+7, d[N], s[N];
vector<int> c;
int main() {
	ll i, t;
	cin >> n >> k;
	c.push_back(0);
	for(i=1; i<=n; ) {
		t =	n / (n / i);
		c.push_back(t);
		i = t + 1;
	}
	en = c.size() - 1;
	for(i=en; i; i--) {
		c[i] -= c[i-1];
		s[i] = 1;
	}
	while(k--) {
		for(i=1; i<=en; i++) d[i] = s[en-i+1] * c[i] % M;
		for(i=1; i<=en; i++) s[i] = (s[i-1] + d[i]) % M;
	}
	cout << s[en];
	return 0;
}

Measured memory_bytes: 1660
# -*- coding: utf-8 -*-

"""
・速攻自力AC
"""

import sys, re
from collections import deque, defaultdict, Counter
from math import sqrt, hypot, factorial, pi, sin, cos, radians
if sys.version_info.minor >= 5: from math import gcd
else: from fractions import gcd 
from heapq import heappop, heappush, heapify, heappushpop
from bisect import bisect_left, bisect_right
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from functools import reduce, partial
from fractions import Fraction
from string import ascii_lowercase, ascii_uppercase, digits

def input(): return sys.stdin.readline().strip()
def ceil(a, b=1): return int(-(-a // b))
def round(x): return int((x*2+1) // 2)
def fermat(x, y, MOD): return x * pow(y, MOD-2, MOD) % MOD
def lcm(x, y): return (x * y) // gcd(x, y)
def lcm_list(nums): return reduce(lcm, nums, initial=1)
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

q, h, s, d = MAP()
n = INT()

best1L = min(q*4, h*2, s)
best2L = min(d, best1L*2)

if n % 2 == 0:
    print(best2L * (n//2))
else:
    print(best2L * (n//2) + best1L)


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

using namespace std;

int main() {
	int a, b, ans = 0;
	cin >> a >> b;
	ans = max(ans, 2 * a - 1);
	ans = max(ans, 2 * b - 1);
	ans = max(ans, a + b);
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

n, t = na()

mincost = 99999999999999
for i in range(n):
    c, u = na()
    if u <= t:
        mincost = min(mincost, c)

if mincost == 99999999999999:
    print("TLE")
else:
    print(mincost)


Measured memory_bytes: 3060
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    int a[100010];
    rep(i, N) cin >> a[i];
    int cnt4 = 0, cnt2 = 0, cnt1 = 0;
    rep(i, N) {
        if(a[i] % 4 == 0) cnt4++;
        else if (a[i] % 2 == 0) cnt2++;
        else cnt1++;
    }
    if(cnt2 > 0) cnt1++;
    if(cnt1 <= cnt4 + (cnt1 + cnt4) % 2) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    
    return 0;
}

Measured memory_bytes: 640
#include <cstdio>
int n;
int ans = 50;
int main()
{
	scanf("%d", &n);
	while (n--)
	{
		int x;
		scanf("%d", &x);
		int c = 0;
		while (x % 2 == 0)
		{
			x /= 2;
			c++;
		}
		if (c < ans)
			ans = c;
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
const double PI = acos(-1);
#define rep(i, n) for (int i = 0; i < (int)(n); i++ )
using namespace std;
int findSumOfDigits(int n) {
  int sum = 0;
  while (n > 0) { // n が 0 になるまで
    sum += n % 10;
    n /= 10;
  }
  return sum;
}
int main(){
  long long n;
  cin >> n;
  vector<long long> r(n);
  rep(i,n){
    cin >> r.at(i);
  }
  int minv,maxv;
  maxv = r.at(1) - r.at(0);
  minv = r.at(0);
  for(int i = 1; i < n; i++){
    if(maxv < r.at(i)-minv) maxv = r.at(i) - minv;
    if(minv > r.at(i)) minv = r.at(i);
  }
  cout << maxv << endl;
}


Measured memory_bytes: 4408
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <climits>
#include <cstdlib>
#include <vector>
#include <unordered_map> 
#include <iomanip>
using namespace std;
#define ALL(a) (a).begin(),(a).end()
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define INF (INT_MAX/3)
#define PSB push_back
#define PN 1000000007
typedef long long LL;
//#define int long long


//booooooooooooost
//#include <boost/multiprecision/cpp_int.hpp>
//#include <boost/multiprecision/cpp_dec_float.hpp>
//namespace mp = boost::multiprecision;	//多倍長整数(mp::cpp_int), 多倍長小数(mp::cpp_dec_float_100)



int inv_mod(int a, int m)
{
	int b, x, u, q, tmp;

	b = m; x = 1; u = 0;
	while (b > 0) {
		q = a / b;
		tmp = u; u = x - q * u; x = tmp;
		tmp = b; b = a - q * b; a = tmp;
	}

	return (x < 0) ? m + x : x;
}



signed main() {

	int N, K, X, Y;
	cin >> N >> K >> X >> Y;

	if(N - K >= 0) cout << K * X + (N - K) * Y << endl;
	else cout << N * X << endl;

	/*string w;
	cin >> w;
	vector<int> f;
	f.assign(26, 0);*/



	
	return 0;
}

Measured memory_bytes: 764
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
ll calc(ll a, ll b, ll c) {
    return max({a, b, c}) - min({a, b, c});
}
ll H, W;
ll solve() {
    ll res = H * W;
    for (ll i = 1; i < W; i++) {
        ll a = i * H;
        ll b = H * W - a;
        
        ll p = (b / H) / 2 * H;
        ll q = (b / (W - i)) / 2 * (W - i);
        res = min(res, calc(a, p, b-p));
        res = min(res, calc(a, q, b-q));
    }
    return res;
}
int main () {
    cin >> H >> W;
    ll ans = solve();
    swap(H, W);
    ans = min(ans, solve());
    cout << ans << endl;
}

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

int main()
{
	string s;
	cin >> s;
	int i;
	int cnt = 0;
	string ss[7]={"MON","TUE","WED","THU","FRI","SAT","SUN"};
	for(i = 0; i < 6; i++){
		if(!(s.compare(ss[i])))
			break;
	}
	for (int j = i; j < 6; j++)
	{
		cnt++;
		/* code */
	}
	
	if(!s.compare("SUN")) cnt +=7;
	cout << cnt << endl;
	return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;

int main(void) {
    cin.tie(0); ios::sync_with_stdio(false);
    
    ll A,B,C,X,Y; cin >> A >> B >> C >> X >> Y;
    ll ans = LINF;
    for(ll i = 0; i <= 200000;i+=2){
        ans = min(ans,C*i + A*max(X-i/2,0LL) + B*max(Y-i/2,0LL));
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;


int main(){
    int a,b,c;
    int ans = 0;
    cin >> a >> b >> c;
    for(int i = 1; i < b+2; i++){
        ans = ((a % b) * (i%b)) % b;
        if(ans == c){
            cout << "YES" << endl;
            return 0;
        }
    }

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, z, n) for(int i = z; i < n; i++)
#define all(v) v.begin(), v.end()
typedef long long ll;
//const int INF = 1<<29;
//const int MODINF = 1000000007;
using namespace std;

int main(){
    int64_t X;
    cin >> X;
    int64_t count = 0, Z = 100;
    while(Z < X){
        int64_t y = Z / 100;
        Z += y;
        count++;
    }
    cout << count << endl;
}

Measured memory_bytes: 3652
#include<iostream>
using namespace std;
int main(){
     
     
    int n;
     
    cin>>n;
    int a[105];
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    for(int i=n-1;i>=0;i--){
        if(i!=0)cout<<a[i]<<" ";
        if(i==0)cout<<a[i];
    }
    cout<<endl;
    return 0;
}


Measured memory_bytes: 3096
#include <bits/stdc++.h>
using namespace std;
char maz[10010];
int n,k;
int main(){
  	scanf("%d%d",&n,&k);
  	scanf("%s",maz);
  	maz[k-1] -= 'A';
  	maz[k-1] += 'a';
  	printf("%s\n",maz);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    int n,k,ans=0;
    cin >> n >> k >> s;
    for(int i=0;i<n-1;i++){
        if(s[i]==s[i+1])ans++;
    }
    ans = min(ans+2*k,n-1);
    cout << ans << endl;

}


Measured memory_bytes: 512
#include <iostream>
#include <string>
using namespace std;
int main(void){
	string str;
	cin>>str;
	for (int a=0;a<str.size();a++){
		if (str[a]>='D') str[a]=str[a]-3;
		else str[a]=str[a]+23;
	}
	for (int a=0;a<str.size();a++){
		cout<<str[a];
	}
	cout<<endl;
	return 0;
}

Measured memory_bytes: 3152
#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() {
	ios::sync_with_stdio(false);
	cin.tie(0);

	int			n;
	/* int			max; */
	/* int			second_max; */
	cin >> n;
	vector<int>	A(n);
	vector<int>	B;

	/* rep(i, n) */
	/* 	cin >> A.at(i); */
	for (int &a : A)
		cin >> a;
	B = A;
	sort(B.rbegin(), B.rend());
	/* max = B.at(0); */
	/* second_max = B.at(1); */
	for (int a : A)
	/* { */
		cout << (a != B.at(0) ? B.at(0) : B.at(1)) << endl;
		/* if (a != B.at(0)) */
		/* 	cout << B.at(0) << endl; */
		/* else */
		/* 	cout << B.at(1) << endl; */
	/* } */
}


Measured memory_bytes: 3200
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <complex>

#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

#include <stdexcept>

using namespace std;

// type alias
using ll = long long;
using ull = unsigned long long;
using comp = complex<double>;

const ll MOD = 1000000007LL;
const double PI = 3.14159265358979323846;

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

// for loop
#define REP(i, n) for ((i) = 0;(i) < (ll)(n);(i)++)

//debug
#define DUMP(x)  cerr << #x << " = " << (x) << endl
#define DEBUG(x) cerr << #x << " = " << (x) << " (l" << __line__ << ")" << " " << __file__ << endl

int solve() {
	ll n;
	cin >> n;

	vector<ll> quots(n + 1);
	for (ll i = 1; i <= n; ++i) {
		quots[i] = i;
	}

	vector<ll> tortients(n + 1, 1);
	for (ll p = 2; p <= ll(sqrt(n)) + 1LL; ++p) {
		if (tortients[p] != 1) continue;
		for (ll i = 1; p * i <= n; ++i) {
			ll count = 1;
			while (quots[p * i] % p == 0) {
				quots[p * i] /= p;
				++count;
			}
			tortients[p * i] *= count;
		}
	}

	ll res = 1;
	for (ll i = 2; i <= n; ++i) {
		res += i * tortients[i] * (quots[i] == 1 ? 1 : 2);
	}

	cout << res << endl;

	return 0;
}

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

	solve();

	return 0;
}


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




int main(void){
int n,x;
int ok=0;
for(;;){
    scanf("%d %d",&n,&x);
    if(n==x&&n==0){break;}
    for(int i=1;i<=n;i++){
        for(int j=i+1;j<=n;j++){
            for(int k=j+1;k<=n;k++){
                if(i==k||i==j||j==k){continue;}
                if(i+j+k==x){ok++;}
            }
        }
    }
    printf("%d\n",ok);
    ok=0;
}
}



Measured memory_bytes: 2064
#include<iostream>
#include<string>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<queue>
#include<stack>
#include<map>
using namespace std;
#define ll long long
int main(){
    int a,b,c;
    cin >> a >> b >> c;
    int max=a;
    if(max<b)max=b;
    if(max<c)max=c;
    cout << a+b+c-max;
    return 0;
}


Measured memory_bytes: 256
let rec f()=Scanf.scanf"%d %d
"(fun n x->if n>0||x>0then let z=ref 0in for a=1to n do for b=a+1to n do if b<x-a-b&&x-a-b<=n then z:=!z+1done done;f(Printf.printf"%d
"!z));;f()

Measured memory_bytes: 2412
#include <iostream>
#include <cstring>
#include <map>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <set>
#include <vector>
#include <queue>
#include <list>
#include <numeric>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <math.h>
#include <stack>
#include <climits>
#include <bitset>
#include <utility>


using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// const ll INF = 1LL <<60;
const int INF = 10000;

//最小公倍数
ll gcd(ll x, ll y) {
  ll tmp = 0;
  if (x < y){
    tmp=x;
    x=y;
    y=tmp;
  }
  while (y > 0) {
    ll r = x % y;
    x = y;
    y = r;
  }
  return x;
}

//最大公倍数
ll lcm(ll x,ll y){
  return x/gcd(x,y)*y;
}

const int MAX = 510000;
const int MOD = 1000000007;

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

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


//階乗
ll kaijo(ll k){
    ll sum = 1;
    for (ll i = 1; i <= k; ++i)
    {
        sum *= i;
        sum%=1000000000+7;
    }
    return sum;
}

//for(int i = ; i < ; i++){}

ll lmax(ll s,ll t){
  if(s>t){
    return s;
  }
  else{
    return t;
  }
}

ll lmin(ll s,ll t){
  if(s<t){
    return s;
  }
  else{
    return t;
  }
}
// ここから開始
int main(){
  int n;
  cin>>n;
  int l[n];
  int a[3];
  set <pair<int,pair<int,int> > > v;
  for(int i = 0; i < n; i++) cin>>l[i];
  sort(l,l+n);
  ll sum = 0;
  for(int i = 0; i < n; i++){
    for(int j = i+1; j < n; j++){
      for(int k = j+1; k < n; k++){
        if(l[i]+l[j]<=l[k]) {
          break;
        }
        else{
          sum++;
        } 
      }
    }
  }
  cout<<sum<<endl;
  return 0;
}


Measured memory_bytes: 256
H, W = map(int, input().split())
G = [list(input()) for _ in range(H)]
que = [[0,0]]
dist = [[-1]*W for _ in range(H)]
direction = [[0,1], [0,-1], [1,0], [-1,0]]

dist[0][0] = 0
while que:
  h, w = que.pop(0) 
  for dh, dw in direction:
    if h+dh <0 or h+dh >= H or w+dw <0 or w+dw >= W:
      continue
    if G[h+dh][w+dw] == '#':
      continue
    if dist[h+dh][w+dw] != -1:
      continue
    dist[h+dh][w+dw] = dist[h][w] +1 
    que.append([h+dh, w+dw])

if dist[H-1][W-1] == -1:
  print(-1)
else:
  num = 0
  for i in range(H):
    num += G[i].count('#')
  print(H*W-num-dist[H-1][W-1]-1)


Measured memory_bytes: 3064
# -*- coding: utf-8 -*-
import fractions

N = int(input())
A = list(map(int, input().split()))


gcd = fractions.gcd


left = [0] * N
right = [0] * N
for i in range(N):
    if i == 0:
        left[0] = A[0]
        right[N-1] = A[-1]
        continue

    left[i] = gcd(left[i-1], A[i])
    right[N-i-1] = gcd(right[N-i], A[N-i-1])

max_gcd = right[1]
for i in range(N):
    if i == 0:
        continue
    elif i == N - 1:
        if max_gcd < left[-2]:
            max_gcd = left[-2]
    else:
        target = gcd(left[i-1], right[i+1])
        if max_gcd < target:
            max_gcd = target

print(max_gcd)


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


int main(){
  int n;
  cin >> n;
  string a,b,c;
  cin >> a >> b >> c;
  int ans=0;
  for(int i=0;i<n;++i){
    if(a[i]!=b[i] && a[i]!=c[i] && b[i]!=c[i]) ans+=2;
    else if(a[i]==b[i] && a[i]==c[i] && b[i]==c[i])continue;
    else ans+=1;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3576
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
#define REP(i,n) for(int i = 1; i<=n; ++i)
#define all(x) begin(x),end(x)
#define show(obj) {for(auto x:obj)cout<<x<<' ';cout<<endl;}
#define line "----------"
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> LP;
const int inf = 1001001000;
const ll INF = 1LL<<60;
const int MOD = (int)1e9 + 7;

int d4x[4] = {0,1,0,-1};
int d4y[4] = {1,0,-1,0};

priority_queue<pair<int, P>, vector<pair<int,P>>, greater<pair<int,P>>> pq;

int H, W, Ch, Cw, Dh, Dw;
vector<vector<char>> nap(1010, vector<char>(1010));
vector<vector<int>> dist(1010, vector<int>(1010, inf));

void dfs(int y, int x){
	rep(i,4){
		int dy = y + d4y[i], dx = x + d4x[i];
		if(nap[dy][dx] == '.' && dist[dy][dx] == inf){
			dist[dy][dx] = dist[y][x];
			dfs(dy, dx);
		}
	}
	for(int i = -2; i < 3; ++i){
		for(int j = -2; j < 3; ++j){
			int dy = y + i, dx = x + j;
			if(nap[dy][dx] == '.' && dist[dy][dx] == inf){
				pq.emplace(dist[y][x], make_pair(dy, dx));
			}
		}
	}
}

int main(){
	cin >> H >> W;
	cin >> Ch >> Cw >> Dh >> Dw;
	++Ch; ++Cw; ++Dh; ++Dw;
	for(int i = 2; i <= H + 1; ++i)for(int j = 2; j <= W+1; ++j)cin >> nap[i][j];

	pq.emplace(-1, make_pair(Ch, Cw));
	while(!pq.empty()){
		int y = pq.top().second.first;
		int x = pq.top().second.second;
		int bf_cost = pq.top().first;
		pq.pop();
		if(dist[y][x] == inf){
			dist[y][x] = bf_cost + 1;
			dfs(y,x);
		}
	}
	int ans = dist[Dh][Dw];

	//cout << line << endl;
	//for(int i = 2; i <= H+1; ++i){
	//	for(int j = 2; j <= W+1; ++j){
	//		printf("%2d ", ((dist[i][j] != inf) ? dist[i][j] : -1));
	//	}
	//	cout << endl;
	//}
	//cout << line << endl;

	if(ans == inf)cout << -1 << endl;
	else cout << ans << endl;
	return 0;
}


Measured memory_bytes: 8968
#include <iostream>
#include <stdio.h>
#include <fstream>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <limits.h>
#include <math.h>
#include <functional>

#define repeat(i,n) for (long long i = 0; (i) < (n); ++ (i))
#define debug(x) cerr << #x << ": " << x << '\n'
#define debugArray(x,n) for(long long i = 0; (i) < (n); ++ (i)) cerr << #x << "[" << i << "]: " << x[i] << '\n'

using namespace std;

typedef long long ll;
typedef pair<int,int> Pii;
typedef vector<int> vint;
typedef vector<ll> vll;
const ll INF = LLONG_MAX;
const ll MOD = 998244353;

int main() {
  int H,W;cin >> H >> W;
  vector<vector<string> > ans(2,vector<string>(H,string(W,'.')));
  repeat(i,H){
    repeat(j,W){
      char c;cin >> c;
      if(c=='#'){
        ans[0][i][j] = '#';
        ans[1][i][j] = '#';
      }
    }
  }
  repeat(i,H){
    for(int j=1;j<W-1;j++){
      ans[i&1][i][j] = '#';
    }
  }
  repeat(i,H){
    ans[0][i][0] = '#';
    ans[1][i][W-1] = '#';
  }
  repeat(c,2){
    repeat(i,H){
      cout << ans[c][i] << endl;
    }
    if(c==0) cout << endl;
  }
  return 0;
}


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

int main(){
  long long n, sum = 0;

  cin >> n;
  while(n--){
    int a,b;
    char c;

    cin >> a >> c >> b;
    if(c == '(') sum += b;
    else sum -= b;
 
    if(sum == 0) cout << "Yes" << endl;
    else cout << "No" << endl;
  }

  return 0;
}

Measured memory_bytes: 1164
// reference: https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

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

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

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

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

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

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

fn main() {
    input! {
        n: usize,
        a: [usize; 5]
    }

    let min = a.into_iter().min().unwrap();
    let ans = (n as f64 / min as f64).ceil() as i64 + 4;
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <stdio.h>

int main(void) {
	// your code goes here
	int a,b,c;
	scanf("%d%d%d",&a,&b,&c);
	if(a==b&&b==c)
		printf("No");
	else if((a==b&&a!=c)||(a==c&&b!=c)||(c==b&&a!=c))
		printf("Yes");
	else
		printf("No");
	return 0;
}


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

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

    long death_count = 0;
    if(A[0] > B[0])
    {
        death_count += B[0];
        B[0] = 0;
    }
    else
    {
        death_count += A[0];
        B[0] -= A[0];
    }

    for(int i = 1 ;i < N; i++)
    {
        long live_count;
        live_count = A[i] - B[i - 1];
        if(live_count < 0)
        {
            death_count += A[i];
            continue;
        }
        
        if(live_count > B[i])
        {
            death_count += B[i] + B[i - 1];
            B[i] = 0;
        }
        else
        {
            death_count += A[i];
            B[i] -= live_count;
        }
    }

    if(A[N] > B[N - 1])
    {
        death_count += B[N - 1];
        B[N - 1] = 0;
    }
    else
    {
        death_count += A[N];
        B[N - 1] -= A[N];
    }

    cout << death_count << endl;
}



Measured memory_bytes: 1792
#include<iostream>
#include<algorithm>
#include<queue>
#include<vector>
#include<string>
#include<unordered_map>
using namespace std;
using ll = long long;
int main(){
    int N;
    cin >> N;
    if(N % 2 == 0)cout << N / 2 - 1;
    else cout << N / 2;
    
}

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

using namespace std;

int h, n;
int heal[20010];
int aa, bb;
int minn = 987654321;

int main(void)
{
	scanf("%d %d", &h, &n);
	
	for(int i = 1 ; i < 20010 ; i++)
		heal[i] = 987654321;
	
	for(int i = 0 ; i < n ; i++)
	{
		scanf("%d %d", &aa, &bb);
		
		for(int j = 0 ; j < 20010 - aa ; j++)
		{
			if(heal[j] != 987654321)
			{
				heal[j + aa] = min(heal[j + aa], heal[j] + bb);
			}
		}
	}
	
	for(int i = h ; i < 20010 ; i++)
	{
		minn = min(minn, heal[i]);
	}
	
	printf("%d", minn);
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <math.h>
using namespace std;

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

    auto m = S.length() / 2;
    int ret = 0;
    for (auto i = 0; i < m; i ++) {
        if (S[i] != S[S.length() - 1 - i]) {
            ret ++;
        }
    }

    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define all(v) v.begin(), v.end()
const int MOD = 1e9 + 7;
const int INF = 1e9;
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main() {
    int h, w, d;
    cin >> h >> w >> d;
    int a[h][w];
    pair<int, int> pr[h * w + 1];
    rep(i, 0, h) {
        rep(j, 0, w) {
            cin >> a[i][j];
            pr[a[i][j]] = make_pair(i + 1, j + 1);
        }
    }

    int sum[h * w + 1] = {};
    rep(i, 1, d + 1) {
        int j = i;
        while (j + d <= h * w) {
            int x = pr[j].first;
            int y = pr[j].second;
            int nx = pr[j + d].first;
            int ny = pr[j + d].second;
            sum[j + d] = sum[j] + abs(x - nx) + abs(y - ny);
            j++;
        }
    }
    int q;
    cin >> q;
    rep(i, 0, q) {
        int s, g;
        cin >> s >> g;
        cout << sum[g] - sum[s] << endl;
    }

    return 0;
}


Measured memory_bytes: 2560
#include <iostream>
using namespace std;
     
int main() {
    int gcd[2];
    cin >> gcd[0] >> gcd[1];
    while (gcd[0] != 0 && gcd[1] != 0) {
        if(gcd[0] < gcd[1]) {
            gcd[1] = gcd[1] % gcd[0];
        } else {
            gcd[0] = gcd[0] % gcd[1];
        }
    }
    
    if(gcd[0] == 0) {
        cout << gcd[1] << endl;
    } else {
        cout << gcd[0] << endl;
    }
}


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

bool tri(ll x,ll y,ll z){
  if(x+y>z&&x+z>y&&z+y>x)return true;
  else return false;
}

int main(){
  ll N;
  cin>>N;
  ll L[N+1];
  for(int i=0;i<N;i++)cin>>L[i];
  
  ll memo=0;
  for(ll i=0;i<N;i++)
    for(ll k=i+1;k<N;k++)
      for(ll j=k+1;j<N;j++)
        if(L[i]!=L[j] && L[j]!=L[k] && L[i]!=L[k] && tri(L[i],L[j],L[k])==1){
          memo++;
        }
  
  cout<<memo<<endl;
}

Measured memory_bytes: 3620
bs = Array.new(4) { Array.new(3) { Array.new 10, 0 } }
gets.to_i.times do
  b, f, r, v = gets.split.map(&:to_i)
  bs[b-1][f-1][r-1] += v
end
bs.each_with_index do |fs, b|
  fs.each do |rs|
    rs.each do |v|
      print " #{v}"
    end
    puts
  end
  puts ?# * 20 if b < 3
end

Measured memory_bytes: 8736
def resolve():
    a, b = map(int, input().split())
    if b == 1:
        print(0)
    elif b < a:
        print(int(1))
    elif b == a:
        print(int(1))
    else:
        print(int((b-a) / (a - 1))+1 if (b - a) % (a - 1) == 0 else int(b // a + 1))


resolve()

Measured memory_bytes: 3060
stack = []
line = gets.chomp.split
line.each{|str|
    case str
    when "+"
        stack << stack.pop + stack.pop
    when "-"
        stack << -1 * stack.pop + stack.pop
    when "*"
        stack << stack.pop * stack.pop
    else
        stack << str.to_i
    end
}
puts stack.pop



Measured memory_bytes: 6860
from math import factorial
from collections import Counter

def cmb(n,r):
    return factorial(n)//(factorial(n-r)*factorial(r))

N,A,B=map(int,input().split())
v=list(map(int,input().split()))
v.sort(reverse=True)
l=Counter(v)

avg=0
cnt=0
for i in range(A,B+1):
    tmp=sum(v[:i])/i
    if tmp>avg:
        avg=tmp
        cnt=cmb(l[v[A-1]],v[:i].count(v[i-1]))
    elif tmp==avg:
        cnt+=cmb(l[v[A-1]],v[:i].count(v[i-1]))
print(avg)
print(cnt)

Measured memory_bytes: 9428