akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <vector>
#include <string>
#include <ctype.h>
#include <set>
#include <map>
#include<cstdio>
#include<queue>
#include<cstdlib>
#include<bitset>
#include<time.h>
#include<string>
#include<stack>
#include<cmath>
#include<iostream>
#include<cstring>
#include<complex>
#include<tr1/unordered_set>
#include<tr1/unordered_map>


#define FOR(i,j,k) for(int i=j;i<k;i++)
#define FORD(i,j,k) for(int i=j;i>=k;i--)
#define ll long long
//Make sure no overflow problems
//#define int long long
#define pii  pair<int, int>
#define vi vector<int >
#define pb push_back
#define mp make_pair
#define x first
#define y second
#define VAR(i,n) __typeof(n) i = (n)
#define FOREACH(i,c) for(VAR(i,(c).begin());i!=(c).end();i++)
#define FORDEACH(i,c) for( VAR(i,(c).rbegin()),i!=(c).rend();i++)
#define REP(i,n) FOR(i,0,n)
#define ld long double
const int INF = 1000000009;
const long long INFLL = (ll)INF * (ll)INF;
const ld EPS = 10e-9;


using namespace std;

#pragma GCC optimize ("Ofast")
static auto _ = [] { std::ios::sync_with_stdio(0); std::cin.tie(0); std::cout.tie(0); std::cerr.tie(0); return 0; } ();

int main() {
    int n;
    cin>>n;
    int INF = 1e9+5;
    vector<int> dp(3,0);
    vector<int> arr(3);
    
    for(int i=0;i<n;i++){
        for(int i=0;i<3;i++)
            cin>>arr[i];
        
        vector<int> ndp(3,0);
        
        for(int i=0;i<3;i++){
            for(int j=0;j<3;j++){
                if(i!=j){
                    // cout<<'F';
                    ndp[i]=max(ndp[i],dp[j]+arr[i]);
                }
            }
        }
        dp=ndp;
        
    }
    
    cout<<max({dp[0],dp[1],dp[2]});
    cerr<<"time taken : "<<(float)clock()/CLOCKS_PER_SEC<<" secs"<<endl; 
    return 0;
}



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

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	if (a + b == c || a + c == b || a == b + c) cout << "Yes";
	else cout << "No";
	return 0;
}
/*
31536000のコメント解説欄
ここテンプレで用意してるから、A問題とかだとこの先空欄の危険あり

3個を必ず2個と1個に分けるので3C2=3通りを検証すれば良い
ちなみに、これをN個を等しく分ける問題になると難易度が1個上がるよ
*/

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

using namespace std;

#define rep(i,m,n) for(int (i)=(int)(m);i<(int)(n);i++)
#define rep2(i,m,n) for(int (i)=(int)(n)-1;i>=(int)(m);i--)
#define REP(i,n) rep(i,0,n)
#define REP2(i,n) rep2(i,0,n)
#define FOR(i,c) for(decltype((c).begin())i=(c).begin();i!=(c).end();++i)
#define ll long long
#define ull unsigned long long
#define all(hoge) (hoge).begin(),(hoge).end()
#define en '\n'
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;
typedef pair<ll, ll> P;
constexpr long long INF = 1LL << 60;
constexpr int INF_INT = 1 << 25;
constexpr long long MOD = (ll) 1e9 + 7;
typedef vector<ll> Array;
typedef vector<Array> Matrix;
constexpr int loose = 0;
constexpr int tight = 1;


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

struct Edge {
	ll to, cap, rev;
	Edge(ll _to, ll _cap, ll _rev) {
	to = _to; cap = _cap; rev = _rev;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

void add_edge(Graph& G, ll from, ll to, ll cap, bool revFlag, ll revCap) {
	G[from].push_back(Edge(to, cap, (ll)G[to].size()));
	if (revFlag)G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}

void solve(){
	ll n;
	cin>>n;
	Matrix a(2,Array(n));
	REP(i,2) REP(j,n) cin>>a[i][j];
	Matrix sum(2,Array(n+1,0));
	REP(i,2) REP(j,n) sum[i][j+1] = sum[i][j]+a[i][j];
	
	ll ans=0;
	REP(i,n){
		chmax(ans,sum[0][i+1]+sum[1][n]-sum[1][i]);
	}
	cout<<ans<<en;
}

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

    solve();
	//ll t;cin>>t;REP(i,t) solve();

    return 0;
}


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

#define PI 3.141592653589793

using namespace std;

int main(){
    int d, a, ba=90;
    double x=0,y=0;
    while(scanf("%d,%d",&d,&a), d != 0 || a != 0){
        x += d * cos(ba * PI / 180.0);
        y += d * sin(ba * PI / 180.0);
        ba -= a;
    }
    cout << (x > 0 ? floor(x) : ceil(x)) << endl;
    cout << (y > 0 ? floor(y) : ceil(y)) << endl;

    return 0;
}


Measured memory_bytes: 3596
#include<iostream>
#include<sstream>
#include<fstream>
#include<vector>
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<bitset>
#include<algorithm>
#include<functional>
#include<climits>
#include<utility>
#include <iomanip>
#include<map>


using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;

#define max(a,b) (a>b?a:b)
#define min(a,b) (a<b?a:b)
#define FOR(i,s,e) for (int i = int(s); i < int(e); i++)
#define REP(i,x) FOR(i,0,x)
#define CLR(a) memset((a), 0 ,sizeof(a))

const ll MOD = 1e+9+7;
const double PI  = acos(-1.0);


int main(){
  int a,b;
  cin>>a>>b;
  a--,b--;
  char ret[100][100];
  REP(i,50)REP(j,100){
    ret[i][j]='.';
    ret[i+50][j]='#';
  }
  int ai=99,aj=0,bi=0,bj=0;
  while(a!=0){
    ret[ai][aj]='.';
    aj+=2;
    if(aj>=100){
      aj=0,ai-=2;
    }
    a--;
  }
  while(b!=0){
    ret[bi][bj]='#';
    bj+=2;
    if(bj>=100){
      bj=0,bi+=2;
    }
    b--;
  }
  cout<<"100 100\n";
  REP(i,100){
    REP(j,100) cout<<ret[i][j];
    cout<<"\n";
  }
}


Measured memory_bytes: 256
use proconio::input;

fn main() {
    input! {
        n: usize,
    }

    let mut divs = vec![];

    for i in 2..=(n as f64).sqrt().ceil() as usize {
        if n % i == 0 {
            divs.push(i-1);
            divs.push(n/i-1);
        }
    }
    divs.push(n-1);

    let mut sum = 0;

    for div in divs {
        if div == 0 {
            continue;
        }
        if n / div == n % div {
            sum += div;
        }
    }

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


Measured memory_bytes: 2648
B, W = list(map(int, input().split()))

MOD = 10**9+7

facts = [1,1] #階乗
invs = [1,1] #整数の逆元
invfacts = [1,1] #階乗の逆元
for ind in range(1, B+W):
    i = ind+1
    facts.append(facts[-1]*i % MOD)
    invs.append( -(MOD//i)*invs[MOD%i] % MOD )
    invfacts.append( invfacts[-1]*invs[i] % MOD )

def Comb(n, r, MOD=MOD):
    if n < r:
        return 0
    return facts[n]*invfacts[n-r]*invfacts[r] % MOD

y_pi = 0 #i回目までにBを食べ尽くした確率piの分子
y_qi = 0 #i回目までにWを食べ尽くした確率qiの分子
pow2 = 1
invxi = 1
inv2 = invs[2]
for i in range(B+W):
    #y_pi = 0 if i < B else 2*y_pi + ((facts[i-1]*invfacts[i-B] % MOD)*invfacts[B-1] % MOD)
    y_pi = (2*y_pi + Comb(i-1, B-1))%MOD
    #y_qi = 0 if i < W else 2*y_qi + ((facts[i-1]*invfacts[i-W] % MOD)*invfacts[W-1] % MOD)
    y_qi = (2*y_qi + Comb(i-1, W-1))%MOD
    invxi = invxi * inv2 % MOD
    yi = (pow2-y_pi+y_qi) % MOD
    z = yi*invxi % MOD
    print(z)
    pow2 = pow2*2 %MOD

Measured memory_bytes: 29040
using System;
using System.Linq;

class D
{
	static void Main()
	{
		var n = int.Parse(Console.ReadLine());
		var a = Console.ReadLine().Split().Select(int.Parse).ToArray();

		var d = a.GroupBy(x => x).ToDictionary(g => g.Key, g => g.LongCount());
		var M = d.Sum(p => p.Value * (p.Value - 1) / 2);
		Console.WriteLine(string.Join("\n", a.Select(x => M - d[x] + 1)));
	}
}


Measured memory_bytes: 81844
import           Control.Monad
import           Data.Array.ST
import           Data.Array.Unboxed    (UArray)
import qualified Data.Array.Unboxed    as U
import qualified Data.ByteString.Char8 as BS
import           Data.List

getAsCharArray1DWithLength :: IO (Int, UArray Int Char)
getAsCharArray1DWithLength = BS.getLine >>= \cs ->
  let n = BS.length cs
      ary = (U.listArray (1,n) $ unfoldr BS.uncons cs) :: UArray Int Char
  in return (n, ary)

main :: IO ()
main = do
  (n,sa) <- getAsCharArray1DWithLength
  (m,ta) <- getAsCharArray1DWithLength
  let result = solve (n,sa) (m,ta)
  putStrLn $ restore sa result n m

solve :: (Int, UArray Int Char) -> (Int, UArray Int Char) -> UArray (Int,Int) Int
solve (n',sa) (m',ta) = runSTUArray $ do
  dp <- newArray ((0,0),(n',m')) 0
  forM_ [(n_,m_) | n_ <- [1..n'], m_ <- [1..m']] $ \(n,m) -> do
    a <- readArray dp (n-1,m-1)
    b <- readArray dp (n,m-1)
    c <- readArray dp (n-1,m)
    if sa U.! n == ta U.! m
      then writeArray dp (n,m) $ maximum [a+1,b,c]
      else writeArray dp (n,m) $ maximum [b,c]
  return dp

restore :: UArray Int Char -> UArray (Int,Int) Int -> Int -> Int -> String
restore st ary n m = go n m ""
  where go 0 _ ss = ss
        go _ 0 ss = ss
        go i j ss
          | ary U.! (i,j) == ary U.! (i-1,j) = go (i-1) j ss
          | ary U.! (i,j) == ary U.! (i,j-1) = go i (j-1) ss
          | otherwise                        = go (i-1) (j-1) ((st U.! i):ss)


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

int main() {
	int a,b,c;
	cin>>a>>b>>c;
	if((a+b+c==17)&&(a*b*c==175)&&(a*a+b*b+c*c==99)){
		cout<<"YES";
	}
	else{cout<<"NO";}
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
	Scanner scan = new Scanner(System.in);

	int N = scan.nextInt();
	int T = scan.nextInt();
	int A = scan.nextInt();

	int[] H_ = new int[N];
	for(int i = 0; i < N; i++){
	    H_[i] = scan.nextInt();
	}

	double min_diff = 10000;
	int point = 0;

	for(int i = 0; i < N; i++){
	    double temp = T - H_[i]*0.006;
	    if(Math.abs(A-temp) < min_diff){
		min_diff = Math.abs(A-temp);
		point = i;
	    }
	}

	System.out.println(point+1);
    }
}


Measured memory_bytes: 24020
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(int i=0;i<N;++i)
typedef long long int LL;

LL N, K, ans;

int main()
{
	in >> N >> K;
	std::vector<LL>x(N), y(N);
	std::vector<char>c(N);
	std::vector<std::vector<LL>>imos(K * 3, std::vector<LL>(K * 3, 0));
	std::vector<std::vector<std::vector<LL>>>res(2, std::vector<std::vector<LL>>(K, std::vector<LL>(K, 0)));
	rep(i, N)
	{
		in >> x[i] >> y[i] >> c[i];
		if (c[i] == 'B') y[i] += K;
		x[i] %= K * 2;
		y[i] %= K * 2;
		++imos[x[i]][y[i]];
		--imos[x[i] + K][y[i]];
		--imos[x[i]][y[i] + K];
		++imos[x[i] + K][y[i] + K];
	}
	rep(i, imos.size()) rep(j, imos[i].size() - 1) imos[i][j + 1] += imos[i][j];
	rep(i, imos.size() - 1) rep(j, imos[i].size()) imos[i + 1][j] += imos[i][j];
	rep(i, imos.size()) rep(j, imos[i].size()) res[(i / K + j / K) % 2][i%K][j%K] += imos[i][j];
	rep(i, 2) rep(j, K) rep(k, K) ans = std::max(ans, res[i][j][k]);
	out << ans << std::endl;
	return 0;
}


Measured memory_bytes: 97920
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=NTL_1_D&lang=ja

#include <bits/stdc++.h>
using namespace std;

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

vector<pair<long long, long long> > prime_factorize(long long N) {
    vector<pair<long long, long long> > res;
    for (long long i = 2; i * i <= N; ++i) {
        if (N % i != 0) {
            continue; 
        }
        long long ex = 0; // 指数
        // 割れるだけ割る
        while (N % i == 0) {
            ++ex;
            N /= i;
        }
        // 結果を push
        res.push_back({i, ex});
    }

    // 残った数はそのまま push
    if (N != 1) {
        res.push_back({N, 1});
    }

    return res;
}

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

    const auto &res = prime_factorize(N); // 素因数分解
    long long ans = N;
    for (auto p : res) {
        // cout << p.first << ":" << (1 / p.first) << " "; 正しい答えにならない (1 / p.first) = 0 → 整数同士の徐算は小数点以下は切り捨てになる!!
        // cout << p.first << ":" << (1 + p.first) << " "; 正しい答えになる
        // cout << p.first << ":" << (1 * p.first) << " "; 正しい答えになる
        // cout << p.first << ":" << (1 - p.first) << " "; 正しい答えになる
        ans *= (p.first - 1);
        ans /= p.first;
    }
    cout << ans << endl;

    return 0;
}




Measured memory_bytes: 3092
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let n = read::<usize>();
    let b = read_vec::<i64>();
    let mut a = vec![b[0]];
    for i in 1..n - 1 {
        a.push(min(b[i], b[i - 1]));
    }
    a.push(b[n - 2]);
    println!("{}", a.iter().sum::<i64>());
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


Measured memory_bytes: 2148
import scala.io.StdIn

object Main {
  def main(args: Array[String]): Unit = {
    val length = StdIn.readInt
    val array = StdIn.readLine().split(" ").map(_.toInt)

    val result = selectionSort(array)
    println(array.mkString(" "))
    println(result)
  }

  def selectionSort(array: Array[Int]): Int = {
    var sw = 0
    for (i <- 0 to array.length - 1) {
      var min = i
      for (j <- i to array.length - 1) {
        if (array(j) < array(min)) min = j
      }
      if (min != i) {
        swap(array, i, min)
        sw += 1
      }
    }
    sw
  }

  def swap(array: Array[Int], a: Int, b: Int): Unit = {
    val tmpValue = array(a)
    array(a) = array(b)
    array(b) = tmpValue
  }
}

Measured memory_bytes: 43968
#include <bits/stdc++.h>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <iostream>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <iomanip>
#include <math.h>
#include <time.h>
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)n; i++)
#define repf(i, a, b) for (ll i = (ll)a; i < (ll)b; i++)
#define repr(i, a, b) for (ll i = (ll)a; i > (ll)b; i--)
#define all(v) (v).begin(), (v).end()
#define mp(a, b) make_pair(a, b)
#define pb(x) push_back(x)
#define eb(x) emplace_back(x)
#define F first
#define S second
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<int> vii;
typedef vector<vii> vvii;
const ll mod = 1e9 + 7;
const int infi = 1147483600;
const ll infl = 1e18 + 5;
const char ENDL = '\n';
//cout << fixed << setprecision(17) << res << endl;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    cin >> n;
    ld s = 0;
    rep(i,n){
        ld ai;
        cin >> ai;
        s += 1.0 / ai;
    }
    ld res = 1.0 / s;
    cout << fixed << setprecision(17) << res << endl;
}


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

using namespace std;
using ll = long long;


int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(0);
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    int ans = 0;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        if (a[i] >= k) {
            ans++;
        }
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int a[500000];
int main(){
  int n,x,y;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>x>>y;
    a[x+y]++;
  }
  for(int i=0;i<500000;i++){
    if(a[i]>1){
      a[i+1]+=a[i]/2;
      if(a[i]%2)a[i]=1;
      else a[i]=0;
    }
  }
  for(int i=0;i<500000;i++){
    if(a[i])cout<<i<<' '<<0<<endl;
  }
}

Measured memory_bytes: 3820
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0;i < (n);i++)
#define rrep(i,n) for (int i = (n - 1);i >= 0;i--)
#define all(v) v.begin(),v.end()
using namespace std;
using ll = long long;
using P = pair<int,int>;
using vi = vector<int>;
using vvi = vector<vi>;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    cout << n*n*n << endl;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=998244353
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

N,K=map(int,input().split())
L,R=[0]*K,[0]*K
for i in range(K):
    L[i],R[i]=map(int,input().split())
    R[i]+=1

class RangeBIT:
    def __init__(self,n):
        self.p=self.BIT(n+1)
        self.q=self.BIT(n+1)
    
    def add(self,s,t,x):
        self.p.add(s,-x*s)
        self.p.add(t,x*t)
        self.q.add(s,x)
        self.q.add(t,-x)
    
    def sum(self,s,t):
        return self.p.sum(t)+self.q.sum(t)*t-self.p.sum(s)-self.q.sum(s)*s
    
    class BIT:
        def __init__(self,n):
            self.num=n
            self.dat=[0]*(self.num+1)
        
        def add(self,i,x):
            i+=1
            while i<=self.num:
                self.dat[i]+=x
                i+=i&-i
        
        def sum(self,i):
            i+=1
            s=0
            while i>0:
                s+=self.dat[i]
                i-=i&-i
            return s

b=RangeBIT(N)
b.add(0,1,1)
for i in range(N):
    res=b.sum(i,i+1)%MOD
    for l,r in zip(L,R):
        if i+l<N:
            b.add(i+l,min(i+r,N),res)
print(b.sum(N-1,N)%MOD)

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

int ri() {
	int n;
	scanf("%d", &n);
	return n;
}

int main() {
	int n = ri();
	int64_t a[n];
	for (auto &i : a) std::cin >> i;
	int64_t res = 0;
	for (int i = 0; i < 60; i++) {
		int cnt = 0;
		for (auto j : a) if (j >> i & 1) cnt++;
		res += (1LL << i) % 1000000007 * cnt % 1000000007 * (n - cnt) % 1000000007;
	}
	std::cout << res % 1000000007 << std::endl;
	return 0;
}


Measured memory_bytes: 2560
def yumiri(L, n):
  for i in range(len(L)):
    if L[i] > n:
      return i - 1

def parunyasu(a, b, p, q):
  reans = ans
  rd1, rq1, d1, nd1, nq1, q1, _ = naobou(a, q)
  rd2, rq2, d2, nd2, nq2, q2, newans = naobou(b, p)

  if reans <= newans:
    t[d1 - 1] = q1
    t[d2 - 1] = q2
    return newans
  else:
    ayaneru(rd2, rq2, d2, nd2, nq2)
    ayaneru(rd1, rq1, d1, nd1, nq1)
    return reans

def ayaneru(rd, rq, d, nd, nq):
  ZL[rd].insert(rq, d)
  del ZL[nd][nq + 1]

def naobou(d, q):
  newans = ans

  rd = t[d - 1] - 1
  rq = yumiri(ZL[rd], d)
  newans += SUMD[ZL[rd][rq] - ZL[rd][rq - 1] - 1] * c[rd]
  newans += SUMD[ZL[rd][rq + 1] - ZL[rd][rq] - 1] * c[rd]
  newans -= SUMD[ZL[rd][rq + 1] - ZL[rd][rq - 1] - 1] * c[rd] 
  del ZL[rd][rq]

  nd = q - 1
  nq = yumiri(ZL[nd], d)
  newans += SUMD[ZL[nd][nq + 1] - ZL[nd][nq] - 1] * c[nd]
  newans -= SUMD[d - ZL[nd][nq] - 1] * c[nd]
  newans -= SUMD[ZL[nd][nq + 1] - d - 1] * c[nd]
  ZL[nd].insert(nq + 1, d)

  newans -= s[d - 1][rd]
  newans += s[d - 1][nd]

  return rd, rq, d, nd, nq, q, newans

def rieshon():
  ans = 0
  for i in range(D):
    ans += s[i][t[i] - 1]
    for j in range(26):
      if t[i] - 1 == j:
        L[j] = 0
        ZL[j].append(i + 1)
      else:
        L[j] += 1
        ans -= L[j] * c[j]
  for i in range(26):
    ZL[i].append(D + 1)
  return ans

import time
import random
startTime = time.time()

D = int(input())
c = list(map(int, input().split()))
s = [list(map(int, input().split())) for _ in range(D)]

L = [0] * 26
ZL = [[0] for _ in range(26)]
SUMD = [0] * (D + 1)
for i in range(1, D + 1):
  SUMD[i] = SUMD[i - 1] + i

RD = [0] * 26
t = [0] * D
for i in range(D):
  RD[0] += 1
  ma = s[i][0] + RD[0] * c[0]
  man = 0
  for j in range(1, 26):
    RD[j] += 1
    k = s[i][j] + RD[j] * c[j]
    if k > ma:
      ma = k
      man = j
  t[i] = man + 1
  RD[man] = 0

ans = rieshon()
while time.time() - startTime < 1.8:
  l = random.randrange(min(D - 1, 26)) + 1
  d = random.randrange(D - l) + 1
  p = t[d - 1]
  q = t[d + l - 1]
  if p == q: continue
  ans = parunyasu(d, d + l, p, q)

for i in range(D):
  print(t[i])


Measured memory_bytes: 87352
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <queue>
#include <bitset>
#define MOD (1000000007l)
#define rep(i, n) for(long i = 0; i < (n); i++)

using namespace std;

void solve() {
  string S;
  cin >> S;
  reverse(S.begin(), S.end());

  unordered_map<long, long> result;
  result[0] = 1;
  long current_one = 1;

  for (auto c: S) {
    unordered_map<long, long> next;
    for (char xxx = '0'; xxx <= '9'; xxx++) {
      long diff = ((xxx - '0') * current_one) % 13;
      // cout << "--- diff: " << diff << ", xxx: " << xxx << endl;
      if (c == xxx or c == '?') {
        for (auto it: result) next[(diff + it.first) % 13] += it.second;
      }
    }
    for (auto it: next) next[it.first] %= MOD;
    result = next;
    current_one = (current_one * 10) % 13;
  }

  cout << result[5] << endl;
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout.precision(12);
  solve();
  return 0;
}


Measured memory_bytes: 512
#include<cstdio>
#include<math.h>
#include<algorithm>
using namespace std;
int a[100],b[100],x[100],y[100],lon[100],ans[100];

int main(){
    int n,m,i,j;
    scanf("%d %d",&n,&m);
    for(i=0;i<n;i++){
        scanf("%d %d",&a[i],&b[i]);             
    }
    for(i=0;i<m;i++){
        scanf("%d %d",&x[i],&y[i]);             
    }
    for(i=0;i<n;i++){
        for(j=0;j<m;j++){
             if(lon[i]>abs(a[i]-x[j])+abs(b[i]-y[j])){
                  ans[i]=j;
                  lon[i]=abs(a[i]-x[j])+abs(b[i]-y[j]);                               
             }
             if(j==0){
                  ans[i]=j;
                  lon[i]=abs(a[i]-x[j])+abs(b[i]-y[j]);  
             }
        }             
    }
    for(i=0;i<n;i++){
        printf("%d\n",ans[i]+1);  
    }
    return 0;
}


Measured memory_bytes: 128
import Control.Applicative
import Control.Monad

main :: IO ()
main = do
  [r0, w0, c, r] <- f
  unless (r0 == 0 && w0 == 0 && c == 0 && r == 0) $ do
    print $ solve r0 w0 c r
    main
  where
    f = map read <$> words <$> getLine

solve :: Int -> Int -> Int -> Int -> Int
solve r0 w0 c r
  | r0 >= w0 * c = 0
  | otherwise = ceil (c * w0 - r0) r
  where
    ceil x y = (x + y - 1) `div` y



Measured memory_bytes: 3916
def getN():
    return int(input())

def getMN():
    a = input().split()
    b = [int(i) for i in a]
    return b[0],b[1]

def getlist():
    a = input().split()
    b = [int(i) for i in a]
    return b

n = getN()

price = []
for i in range(n):
    price.append(getN())

wari = max(price) // 2
print(sum(price) - wari)

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

int main(){
    ll a,b;
    cin>>a>>b;
    for(ll i=1;i<=1000;i++){
        if(floor(i*0.08) == a && floor(i*0.1) == b){
            cout<<i<<endl;
            return 0;
        }
    }
    cout<<"-1";
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//template <typename T, typename cmp=less<T>> using oset =tree<T, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
#define inf 100000000000000000
#define ll long long 
#define pb push_back
#define f first
#define s second
#define mod 1000000007
#define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define test ll t ; cin>>t; while(t--)
void mahakal(){
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	freopen("error.txt","w",stderr);
	#endif
}
int main(){
	//mahakal(),fast;

	ll n , m ;
	cin>> n >> m ;

	vector<pair<ll,ll>>vec;
	for(ll i=0, a ;i< n ;i++)cin>>a , vec.pb({a , 1});
	for(ll i=0, a, b;i< m ;i++)cin>>a>> b , vec.pb({b , a});
	sort(vec.begin(),vec.end());
	reverse(vec.begin(), vec.end());	
	ll cnt=0, i=0,sum=0;;
	while(cnt<n ){
		while(cnt<n && vec[i].s>0){
			sum+=vec[i].f;
			vec[i].s--;
			cnt++;
		}
		i++;
	}
	cout<<sum<<endl;

	return 0;
}

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

using namespace std;

char S[200001];

int main()
{
	int N, A, B, C, D;
	cin >> N >> A >> B >> C >> D;
	A--;
	B--;
	C--;
	D--;

	cin >> S;

	int s1 = A;
	int s2 = B;
	int e1 = min(C, D);
	int e2 = max(C, D);

	bool oinuki = false;
	bool flag = true;

	for (int i = s1+1; i < e2; i++)
	{
		if (S[i - 1] == '#' && S[i] == '#')
		{
			flag = false;
			break;
		}

		if (s2 <= i && i <= e1)
		{
			if (S[i - 1] == '.' && S[i] == '.' && S[i + 1] == '.')
			{
				oinuki = true;
			}
		}
	}

	if (flag)
	{
		if (D < C)
		{
			if (oinuki)
			{
				cout << "Yes" << endl;
			}
			else
			{
				cout << "No" << endl;
			}
		}
		else
		{
			cout << "Yes" << endl;
		}
	}
	else
	{
		cout << "No" << endl;
	}

	return 0;
}




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

#define ll long long
#define F first
#define S second
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define endl '\n'
#define ull unsigned long long
#define vi vector<int>
#define pii pair<int,int>
#define INF 1e+9

using namespace std;

int main()
{
    ios_base::sync_with_stdio( 0 ) ;
    cin.tie( 0 ) ;  cout.tie( 0 ) ;
    
    int t ;
    cin >> t ;
    vector < int > v( 3 , 0 ) ;
    int a[3] ; int b[3]; 
    while(t--){
        cin >> a[0] >> a[1] >> a[2] ; 

        for(int i = 0 ; i < 3 ; i++){
            int res = 0 ; 
            for(int j = 0 ; j < 3 ; j++){
                if(i != j)
                    res = max(res , v[j] + a[i]) ; 
            }

            b[i] = res ; 
        }

        for(int i = 0 ; i < 3 ; i++){
            v[i] = b[i] ; 
        }

    }

    auto y = *max_element(all(v)) ;

    cout << y << endl ;
}



Measured memory_bytes: 256
import java.util.*;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] n = new int[N];
		int count = 0;
		boolean even = true;
		for(int i = 0;i < N;i++) {
			n[i] = sc.nextInt();
		}
		while(even) {
			for(int k = 0;k < N;k++) {
				if(n[k] % 2 == 0) {
					n[k] /= 2; 
				}
				else even = false;
			}
			if(even) {
				count++;
			}
		}
		System.out.println(count);
	}

}


Measured memory_bytes: 23124
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    from operator import itemgetter

    N = int(readline())
    mat = []

    l_max = 0
    r0 = 0
    l_idx = -1
    r_min = INF
    l1 = 0
    r_idx = -1

    for i in range(N):
        l, r = map(int, readline().split())
        r += 1
        mat.append([l, r])
        if l > l_max:
            l_max = l
            r0 = r
            l_idx = i
        if r < r_min:
            l1 = l
            r_min = r
            r_idx = i

    if N == 2:
        ans = 0
        for l, r in mat:
            ans += r - l
    elif l_idx == r_idx:
        ans = 0
        h = max(0, r_min - l_max)
        for i in range(N):
            l, r = mat[i]
            ans = max(ans, h + r - l)
    else:
        mat2 = []
        for i in range(N):
            l, r = mat[i]
            mat2.append([max(r - l_max, 0), max(r_min - l, 0)])

        mat2.sort(key=itemgetter(1), reverse=True)
        mat2.sort(key=itemgetter(0))

        l_acc = []

        ans = 0
        h = max(0, r_min - l_max)
        for i in range(N):
            l, r = mat[i]
            ans = max(ans, h + r - l)

        a, b = mat2[0][0], r_min - l1
        ans = max(ans, a + b)

        for i in range(N - 1):
            a = max(a, mat2[i + 1][0])
            b = min(b, mat2[i][1])
            ans = max(ans, a + b)

        a, b = r0 - l_max, mat2[N - 1][1]
        ans = max(ans, a + b)

        ans = max(ans, (r0 - l_max))

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 102748
'use strict'
function Main(input){
  input=input.trim().split(/\s+/);
  var N=input[0]-0;
  var s=input[1].split('');
  var R=0;
  while(s.length>0)
    if(s.pop()==='R')R++;
  var result=(R>N-R)?'Yes':'No';
  console.log(result);
}

Main(require('fs').readFileSync('/dev/stdin','utf8'));

Measured memory_bytes: 7372
#include<iostream>
#include <algorithm>
#include <vector>
#include <string>
using namespace std;
string seireki[2] = {"Heisei", "TBD"};
int main(){
   string S;
   cin >> S;
   
   
  int year = atoi(S.substr(0, 4).c_str());
  int month = atoi(S.substr(5, 7).c_str());
  int day = atoi(S.substr(8, 10).c_str());


/* cout << year  <<endl;
  cout << month <<endl;
  cout << day <<endl; */

  int hantei = year*10000 + month*100 + day;
  if(hantei <= 2019*10000 + 4*100 + 30){
    cout << seireki[0] <<endl;
  }else{
    cout << seireki[1] <<endl;
  }



  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <stack>
#include <string>
#include <vector>
#include <utility>

using namespace std;

int main() {
    char buf[1<<15];
    scanf("%s", buf);
    string s(buf);

    stack<size_t> q;
    vector<pair<size_t, int>> L;
    int A=0;
    for (size_t i=0; i<s.length(); ++i) {
        if (s[i] == '\\') {
            q.push(i);
        } else if (s[i] == '/') {
            if (q.empty()) continue;

            int l=i-q.top();
            A += l;
            while (!L.empty()) {
                if (L.back().first < q.top()) break;

                l += L.back().second;
                L.pop_back();
            }
            L.push_back(make_pair(q.top(), l));
            q.pop();
        }
    }

    printf("%d\n", A);

    size_t k=L.size();
    printf("%zu", k);
    for (size_t i=0; i<k; ++i)
        printf(" %d", L[i].second);

    printf("\n");
    return 0;
}

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

   typedef long long ll;
   typedef pair<ll, ll> Pii;
   typedef vector<ll> Vi;
   typedef vector<Vi> VVi;

   const double EPS = (1e-7);
   const ll INF =(1e13);
   const double PI = (acos(-1));
   const ll MOD = ll(1e9) + 7;

   #define REP(i, n) for(ll i = 0; i < (ll)(n); i++)
   #define REPR(i, n) for(ll i = n; i > -1; i--)
   #define FOR(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
   #define ALL(x) (x).begin(),(x).end()
   #define SORT(x) sort((x).begin(), (x).end())
   #define RSORT(x) sort((x).rbegin(), (x).rend())
   #define REVERSE(x) reverse((x).begin(), (x).end())
   #define SZ(x) ((ll)(x).size())
   #define pb push_back
   #define mp make_pair

   //chmax(a, b): a>bならaをbで更新　更新したときにtrueを返す
   //chmin(a, b): a<bならaをbで更新　更新したときにtrueを返す
   template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
   template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

   #define dump(x) cerr<< #x << "= " << (x) << endl;

   ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
   ll pow(ll a, ll b){if (b == 0) return 1; else if (b % 2 == 0) return pow(a * a, b / 2); else return pow(a * a, b / 2) * a;}
   ll pow(ll a, ll b, ll m){if (b == 0) return 1; else if (a == 0) return 0; else if (b % 2 == 0) return (pow((a * a) % m, b / 2, m) % m); else return (pow((a * a) % m, b / 2, m) * a) % m;}
   ll residue(ll a, ll m){return ((a % m) + m) % m;};

   ll dx[4]={1,0,-1,0};
   ll dy[4]={0,1,0,-1};

Vi divisor(ll n){
   Vi div = {};
   for(ll i = 1; i * i <= n; i++){
      if(n % i == 0){
         div.pb(i); 
         if(i * i == n) break;
         div.pb(n / i);
      }
   }
   RSORT(div);
   return div;
}
int main(){
   ll n; cin >> n;
   Vi a(n); REP(i, n) cin >> a[i];

   ll ans = 0;
   FOR(i, 1, n) ans = gcd(a[i], ans);

   Vi d0 = divisor(a[0]);
   for(auto &d : d0){
      ll cnt = 0;
      FOR(i, 1, n){
         if(a[i] % d != 0) cnt++;
      }
      if(cnt <= 1 && chmax(ans, d)) break;
   }
   cout << ans << endl;
}


Measured memory_bytes: 1152
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define OUT(s) cout << s << "\n";
using namespace std;

char A;


void Main()
{


    if (isupper(A))
    {
        OUT("A");
    }
    else
    {
        OUT("a");
    }
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    // cout << fixed << setprecision(15);
    cin >> A;
    Main();
    return 0;
}

Measured memory_bytes: 3608
//https://atcoder.jp/contests/abc161/tasks/abc161_a

import java.io.PrintWriter;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        // write your code here

        Scanner in = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);


        int x = in.nextInt();
        int y = in.nextInt();
        int z = in.nextInt();

        int temp1 = x;
        x = y; y =temp1;

        int temp2 = x;
        x = z; z = temp2;
        out.println(x + " " + y + " " + z);
        out.close();

    }


}




Measured memory_bytes: 25300
import java.util.*;

public class Main {
    public static void main(String args[]) {
        
        Scanner sc = new Scanner(System.in);
        
        int n = Integer.parseInt(sc.next());
        int k = Integer.parseInt(sc.next());
        
        int counter = 0;
        int tmp = n;
        while(tmp > 0) {
            tmp = tmp / k;
            ++counter;
        }
        
        System.out.println(counter);
        
    }
}

Measured memory_bytes: 21844
n,q = map(int,input().split())
s = input()
l = [0,0]
for i in range(0,n-1):
    l.append(l[i+1]+(s[i]+s[i+1]=="AC"))
for i in range(q):
    x,y = map(int,input().split())
    if l[x-1]+1==l[x]:
        print(l[y] - l[x - 1]-1)
    else:
        print(l[y] - l[x - 1])

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

int main(){
    int N; cin >> N;
    vector<pair<int, int>> p(N);
    for (int i = 0; i < N; i++) cin >> p[i].first >> p[i].second;
    sort(p.begin(),p.end());
    long cnt = 0;
    double len = 0;
    do{
        for (int i = 0; i < N-1; i++)
        {
            len += sqrt(pow(p[i].first-p[i+1].first, 2) + pow(p[i].second-p[i+1].second, 2));
        }
        cnt++;
    } while(next_permutation(p.begin(),p.end()));
    cout << setprecision(10) << len / cnt << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define F first
#define S second
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int,int>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
ll gcd(ll a, ll b) { return b?gcd(b, a%b):a;}
ll lcm(ll a, ll b) { return a*b/gcd(a,b);}
ll MOD=1000000007;

int main(){
  int a,b;cin>>a>>b;
  if(a>=b){
    rep(i,a){
    cout<<b;
    }
    cout<<endl;
  }else if(a<b){
    rep(i,b){
    cout<<a;
    }
    cout<<endl;
  }
}

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

using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define ll long long int
#define INF 1000000007
#define llINF 1000000000000000007
#define v(i) vector<i>
#define vv(i) vector<vector<i>>
// cin.eof() 入力個数の問題
// int num = atoi(string.c_str()); 文字列の整数変換
int keta(ll n){int ans=0;while(n>0){n /= 10; ans++;}return ans;}
ll _pow(ll a,ll b){ll ans = 1;rep(i,b){ ans *= a;}return ans;}

int main() {
    int n,k;cin>>n>>k;
    ll s; cin>>s;
    rep(i,k){
        cout<<s<<" ";
    }if(s != 99999){
    rep(i,n-k){
        cout<<99999<<" ";
    }}else
    {
         rep(i,n-k){
        cout<<100000<<" ";}
    }
    
    return 0;
}


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

#define rep(i,n) for(int i=0; i<(int)n; i++)
#define ll long long
#define all(x) (x).begin(), (x).end()

const int INF = 100000000;

int kaijo(int k){
    int sum = 1;
    for (int i = 1; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;
}

int main(){
    int n;
    cin >> n;
    vector<int> p(n),q(n),r(n);
    rep(i,n) cin >> p.at(i);
    rep(i,n) cin >> q.at(i);
    int a,b;
    r=p;
    sort(all(r));
    int counter=0;
    do{
        counter++;
        if(r==p) a=counter;
        if(r==q) b=counter;
    }while(next_permutation(all(r)));

    cout << abs(a-b) << endl;
}

Measured memory_bytes: 256
def cross(a,b):return a[0]*b[1] - a[1]*b[0]

q = range(int(input()))
for i in q:
    a,b,c,d,e,f,g,h = [int(x) for x in input().split()]
    A = [c-a,d-b]; B = [e-a,f-b]; C = [g-a,h-b];
    D = [g-e,h-f]; E = [a-e,b-f]; F = [c-e,d-f];
    if max(a,c) < min(e,g) or max(e,g) < min(a,c) or max(b,d) < min(f,h) or max(f,h) < min(b,d):
        print("0")
    elif cross(A,B) * cross(A,C) <= 0 and cross(D,E) * cross(D,F) <= 0:
        print("1")
    else:
        print("0")

Measured memory_bytes: 7708
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPLL(i, n) for (ll i = 0; i < (ll)(n); i++)
using namespace std;
template<class T>inline bool chmax(T &a, const T &b){if(a < b){a = b; return 1;}return 0;}
template<class T>inline bool chmin(T &a, const T &b){if(a > b){a = b; return 1;}return 0;}
typedef long long ll;

//AtCoder Petrozavodsk Contest 001 A - Two Integers

ll gcd(ll n, ll m){
  if(m == 0) return n;
  return gcd(m, n%m);
}

ll lcm(ll n, ll m){
  return n / gcd(n, m) * m;
}

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll X, Y; cin >> X >> Y;
  ll tmp = lcm(X, Y);
  if(tmp == X){
    cout << -1 << endl;
  }else{
    cout << X*(tmp/X-1) << endl;
  }

}

Measured memory_bytes: 3644
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
int main(void){
    // Your code here!
    
    vector<int> a(3);
    for(int i=0; i<3; i++){
        cin>>a[i];
    }
    
    sort(a.begin(), a.end());
    
    if(a[0]+a[1]==a[2]){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
    
    
}


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

A.sort(reverse=True)

if A[N-1] == 0:
    print(0)
else:
    ans = 1
    for i in range(N):
        ans *= A[i]
        if ans > 10**18:
            ans = -1
            break
    print(ans)


Measured memory_bytes: 21580
#define _USE_MATH_DEFINES

#include <cstdio>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>

using namespace std;

long long int P[31][200000] = {};

int main(){
	
	int N, C;
	cin >> N >> C;
	
	for(int i = 0; i < N; i++){
		int s, t, c;
		cin >> s >> t >> c;
		P[c - 1][s]++;
		P[c - 1][t]--;
	}
	
	int ans = 0;
	int cur = 0;
	
	for(int i = 0; i <= 100000; i++){
		for(int j = 0; j < 30; j++){
			if(P[j][i] == 1){
				cur++;
			}
		}
		ans = max(ans, cur);
		for(int j = 0; j < 30; j++){
			if(P[j][i] == -1){
				cur--;
			}
		}
	}
	
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 46592
#include <vector>
#include <algorithm>
#include <iostream>
#include <chrono>
#include<bitset>
#include<deque>
#include <map>
#define vint vector<int>
#define vint2 vector<vint>
#define vchar vector<char>
#define vchar2 vector<vchar> 
#define vchar3 vector<vchar2> 
#define pr pair<int,int>
#define vpr vector<pr>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
typedef  long long int ll;
using namespace std;
//CHAR_BIT	ビット フィールドではない最小変数のビット数。	8
//SCHAR_MIN	signed char 型変数の最小値。	–128
//SCHAR_MAX	signed char 型変数の最大値。	127
//UCHAR_MAX	unsigned char 型変数の最大値。	255 (0xff)
//CHAR_MIN	char 型変数の最小値。 - 128、 / J オプション使用時は 0
//CHAR_MAX	char 型変数の最大値。	127、 / J オプション使用時は 255
//MB_LEN_MAX	多文字定数の最大バイト数。	5
//SHRT_MIN	short 型変数の最小値。	–32768
//SHRT_MAX	short 型変数の最大値。	32767
//USHRT_MAX	unsigned short 型変数の最大値。	65535 (0xffff)
//INT_MIN	int 型変数の最小値。	–2147483647 – 1
//INT_MAX	int 型変数の最大値。	2147483647
//UINT_MAX	unsigned int 型変数の最大値。	4294967295 (0xffffffff)
//LONG_MIN	long 型変数の最小値。	–2147483647 – 1
//LONG_MAX	long 型変数の最大値。	2147483647
//ULONG_MAX	unsigned long 型変数の最大値。	4294967295 (0xffffffff)




int  main() {
	int A, B, K;
	cin >> A >> B >> K;
	
	int c[2] = { A,B };
	int ban = 0;

	REP (i,K) {
		ban = i % 2;
		if (c[ban] % 2 == 1) {
			c[ban]--;
		}
		c[ban] /= 2;
		c[(ban + 1) % 2] += c[ban];
	}


	cout << c[0]<<" "<<c[1] << endl;
	//while (true) {}

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pint = pair<int, int>;
ll N;
vector<ll> A;
vector<ll> B;
const ll INF = 1e12;

int main()
{
    cin >> N;
    A.resize(N + 1);
    B.resize(N);

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

    ll res = 0;
    for (int i = N - 1; i >= 0; --i)
    {
        ll temp = A[i + 1] - B[i];
        if (temp >= 0)
        {
            res += B[i];
            continue;
        }
        else
        {
            res += A[i + 1];
            B[i] -= A[i + 1];
            ll temp_2 = A[i] - B[i];
            if (temp_2 >= 0)
            {
                res += B[i];
                A[i] -= B[i];
            }
            else
            {
                res += A[i];
                A[i] = 0;
            }
        }
    }
    cout << res << endl;
}

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

int main()
{
	long int N, W;
	cin >> N >> W;
	
	long int wV[110][2];
	for(int i = 0; i < N; i++){
		cin >> wV[i][0] >> wV[i][1];
	}
	
	long int dp[110][100010] = {0};
	
	for(int i = 0; i < N; i++){
		for(int j = 0; j <= W; j++){
			if(j + wV[i][0] <= W){
				dp[i + 1][j + wV[i][0]] = dp[i][j] + wV[i][1];
			}
			
			dp[i + 1][j] = max(dp[i + 1][j], dp[i][j]);
		}
	}
	
	cout << dp[N][W] << endl;
}

Measured memory_bytes: 86144
#pragma GCC optimize(2)
#include<bits/stdc++.h>
#define ll long long
#define maxn 1000005
#define inf 1e9
#define pb push_back
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define per(i,a,b) for(int i=a;i>=b;i--)
using namespace std;

inline int read()
{
	int x=0,w=1; char c=getchar();
	while(c<'0'||c>'9') {if(c=='-') w=-1; c=getchar();}
	while(c<='9'&&c>='0') {x=(x<<1)+(x<<3)+c-'0'; c=getchar();}
	return w==1?x:-x;
}

int main()
{
	ll x; cin>>x;
	ll nw=100,cnt=0;
	while(1)
	{
		nw=nw*(1.01); cnt++;
		if(nw>=x) break;
	}
	cout<<cnt<<endl;
	return 0;
}

Measured memory_bytes: 3584
/* ex 9_2
   kohei_suzuki */

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define SIZE 100001

//リストのノード（スタック内の各データ）の定義
typedef struct node{
    char elem;
    struct node *next;
} node;

//スタックにデータを追加
void push(node **first, char elem){
    //追加する分の領域を確保
    node *new = calloc(1, sizeof(node));
    if(new == NULL) exit(1);
    new->elem = elem;
    new->next = *first;
    *first = new;
}

//スタックからデータを取り出す
char pop(node **first){
    char elem;
    node *tmp = *first;
    if(tmp == NULL) exit(1);
    elem = tmp->elem;
    *first = tmp->next;
    //取り出したノードのメモリを解放
    free(tmp);
    return elem;
}

int main(void){
    char cube[SIZE];
    int count = 0;
    node *first = NULL;//最初のノードの指す先
    
    scanf("%s", cube);//入力受取

    for(int i=0; i<strlen(cube); i++){
        if(first != NULL){
            if(cube[i] == first->elem){//前の要素(キューブ)と異なるときはスタックにノードを追加する
                push(&first, cube[i]);
            }
            else{//前の要素(キューブ)と異なるときにスタックからノードを取り出す
                pop(&first);
                count += 2;//一回取り出すごとに２つのキューブをとりだしている。
            }
        }
        else{//初期状態のノードにデータを追加
            push(&first, cube[i]);
        }
    }
    printf("%d", count);
    return 0;
}

Measured memory_bytes: 4864
let input = readLine()!.split(separator: " ").map { Int($0)! }
let N = input[0]
let M = input[1]
let X = readLine()!.split(separator: " ").map { Int($0)! }.sorted()

if N >= X.count {
    print(0)
} else {
    var distances = [Int]()
    for i in stride(from: 0, to: X.count - 1, by: 1) {
        distances.append(abs(X[i] - X[i + 1]))
    }
    print(distances.sorted()[0 ..< distances.count - N + 1].reduce(0, +))
}


Measured memory_bytes: 13208
def counter(n, x):
    count = 0
    for i in range(1, n-1):
        for j in range(i+1, n):
            for k in range(j+1, n+1):
                if i + j + k == x:
                    count += 1
    return count

while True:
    n, x = map(int, input().split())
    if n == x == 0:
        break
    print(counter(n, x))

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

int main(){
	int x,y,xx,yy;
	cin>>x>>y>>xx>>yy;
	xx-=x;
	yy-=y;
	vector<char>path;
	for(int i=0; i<xx; i++) path.push_back('R');
	for(int i=0; i<yy; i++) path.push_back('U');
	for(int i=0; i<xx; i++) path.push_back('L');
	for(int i=0; i<yy; i++) path.push_back('D');
	path.push_back('D');
	for(int i=0; i<xx+1; i++) path.push_back('R');
	for(int i=0; i<yy+1; i++) path.push_back('U');
	path.push_back('L');
	
	path.push_back('U');
	for(int i=0; i<xx+1; i++) path.push_back('L');
	for(int i=0; i<yy+1; i++) path.push_back('D');
	path.push_back('R');
	for(int i=0; i<path.size(); i++) cout<<path[i];
}

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

int main(){
    int n,i,array[100];
    
    cin >> n;
    for(i = 0; i < n; i++){
        cin >> array[i];
    }
    for(i = n-1; i >= 0; i--){
        cout << array[i];
        if(i != 0) cout << " ";
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 3032
m[9][9];x[9][9];z[10];
main(n,i,j){for(scanf("%d",&n);n--;n?puts(""):1,memset(x,0,324)){
for(i=0;i<9;i++)for(j=0;j<9;j++)scanf("%d",m[i]+j);
for(i=0;i<9;i++){
	memset(z,0,40);
	for(j=0;j<9;j++)z[m[i][j]]++;
	for(j=0;j<9;j++)if(z[m[i][j]]>1)x[i][j]=1;
}
for(i=0;i<9;i++){
	memset(z,0,40);
	for(j=0;j<9;j++)z[m[j][i]]++;
	for(j=0;j<9;j++)if(z[m[j][i]]>1)x[j][i]=1;
}
for(i=0;i<9;i++){
	memset(z,0,40);
	for(j=0;j<9;j++)z[m[i%3*3+j/3][i/3*3+j%3]]++;
	for(j=0;j<9;j++)if(z[m[i%3*3+j/3][i/3*3+j%3]]>1)x[i%3*3+j/3][i/3*3+j%3]=1;
}
for(i=0;i<9;puts(""),i++)for(j=0;j<9;j++)printf(x[i][j]?"*%d":" %d",m[i][j]);
}exit(0);}

Measured memory_bytes: 604
#include <bits/stdc++.h>
using namespace std;
int main() {
    int N;
    std::cin >> N;
    int Amin = N;
    
    for (int i = 0; i <= N; i++) {
        int res=0;
        int first=i;
        int rem=N-i;
        for (int j = 8; j >=0; j--) {
            int a=(int)pow(6,j);
            res+=first/a;
            first-=(first/a)*a;
        }
        for (int j = 6; j >=0; j--) {
            int a=(int)pow(9,j);
            res+=rem/a;
            rem-=(rem/a)*a;
        }
        
        Amin=min(Amin,res);
    }
    
    std::cout <<Amin  << std::endl;
}



Measured memory_bytes: 256
#include <iostream>
#include <iomanip> //! for setprecision(10)
#include <math.h>
#include <algorithm>
#include <functional> 
#include <string>
#include <vector>

#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <utility>

using namespace std;

typedef long long LL;

#define dump(c) { for (auto it = c.begin(); it != c.end(); ++it) if (it == c.begin()) cout << *it; else cout << ' ' << *it; cout << endl; } 
#define rep(i,n) for (int i = 0; i < (n); ++i)

const int MOD = 1000000007;

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

    int N;
    cin >> N;
    vector<int> x(N);
    vector<int> y(N);
    rep(i, N) {
        cin >> x[i] >> y[i];
    }

    double sum = 0;
    int count = 0;
    for (int i = 0; i < N-1; ++i) {
        for (int j = i + 1; j < N; ++j) {
            double dx = x[i] - x[j];
            double dy = y[i] - y[j];
            sum += sqrt(dx * dx + dy * dy);
            ++count;
        }
    }
    double avg = sum / count;
    double ans = avg * (N-1);

    cout << setprecision(10) << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = int_fast64_t;
const int mod = 1e9 + 7;
const int inf = (1 << 30) - 1;
const ll infll = (1LL << 61) - 1;
#define fast() ios::sync_with_stdio(false), cin.tie(nullptr)
#pragma GCC target("avx2")
#pragma GCC optimize("O3")

ll N, ans;

int main()
{
	fast();
	cin >> N;
	for (ll i = 2, M = N, z = 2; i * i <= M && N != 1; z = ++i)
	{
		while (N % z == 0)
			ans++, N /= z, z *= i;
		while (N % i == 0)
			N /= i;
	}

	cout << ans + (N != 1) << "\n";
}


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

int main(){
  int c1,c2,c3,c4,c5,c6,c7,c8,c9;
  cin>>c1>>c2>>c3>>c4>>c5>>c6>>c7>>c8>>c9;
  bool ans=1;
  if(c1!=c2+c4-c5)ans=0;
  if(c1!=c3+c7-c9)ans=0;
  if(c5!=c6+c8-c9)ans=0;
  if(ans)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}



Measured memory_bytes: 3672