akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define F first
#define S second
#define ll long long
#define ld long double
#define pb push_back

using namespace std;

int n;

string s,t,ans;

int main()
{
    cin >> n >> s >> t;
    for (int i=0;i<n;i++)
    {
        ans+=s[i];ans+=t[i];
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
// statics
using namespace std;
using int64 = int_fast64_t;
using PAIR = pair<int64, int64>;
constexpr int INF = 1 << 30;
constexpr int64 LINF = 1LL << 60;
constexpr int MOD = 1e9 + 7;
constexpr int MAX_N = 3e5 + 1;

// init/input
#define int int64
#define INIT ios::sync_with_stdio(false);cin.tie(0);
#define VAR(type, ...) type __VA_ARGS__;MACRO_VAR_Scan(__VA_ARGS__);
template<typename T> void MACRO_VAR_Scan(T &t) {cin>>t;}
template<typename First, typename...Rest> void MACRO_VAR_Scan(First &first, Rest&...rest) {cin>>first;MACRO_VAR_Scan(rest...);}
#define VEC(type, c, n) vector<type> c(n);for(auto &&i:c)cin>>i;

// out
#define OUT(dist) cout<<(dist);
#define FOUT(n, dist) cout<<fixed<<setprecision(n)<<(dist);
#define SP cout<<" ";
#define BR cout<<endl;
#define zero(n) cout<<setfill('0')<<right<<setw(n)
#define debug(x) cerr<<#x<<":"<< (x);BR;

// utility
#define ALL(a) (a).begin(), (a).end()
#define EACH(i, a) for(auto &&i:(a))
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define RFOR(i, a, b) for(int i=(b)-1;i>=0;--i)
#define REP(i, n) for(int i=0;i<(n);++i)
#define RREP(i, n) for(int i=(n)-1;i>=0;--i)

signed main() {
  INIT;
	VAR(int,h,w);
	VEC(string,s,h);

	bool ok=true;
	REP(hi,h){
		REP(wi,w){
			if(s[hi][wi]=='.') continue;
			if(0<=hi+1&&hi+1<h&&0<=wi-1&&wi-1<w)ok &= s[hi+1][wi-1]!='#';
			if(0<=hi-1&&hi-1<h&&0<=wi+1&&wi+1<w)ok &= s[hi-1][wi+1]!='#';
		}
	}
	OUT(ok?"Possible":"Impossible")BR;
	
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
 
#define sl(x) scanf("%ld", &x)
#define ss(x) scanf("%s", x)
#define pl(x) printf("%ld\n", x)
#define pd(x) printf("%lf\n", x)
#define ps(x) printf("%s\n", x)
 
#define INF 1000000000000000000
#define MOD 1000000007

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

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

int main() {
  long N, C;
  long i, j;
  long tans = 0;
  char buf[201];
  long len;
  
  ss(buf);
  len = strlen(buf);
  for(i=0;i<len-8;i++) {
    printf("%c", buf[i]);
  }
  printf("\n");
  
  
  return 0;
}

Measured memory_bytes: 128
/*
    アリナ・グレイはかわいい
*/

#include<bits/stdc++.h>
using namespace std;
#define itn int
#define endl "\n"

int main(void){
    long long int a,b,c;
    cin >> a >> b >> c;
    
    if(a == b && b == c && a % 2 == 0)cout << -1 << endl;
    else {
        for(long int i = 0;;i++){
            if(a % 2 == 1 || b % 2 == 1 || c % 2 == 1){
                cout << i << endl;
                break;
            }
            long long int a2 = (b+c)/2, b2 = (a+c)/2, c2 = (a+b)/2;
            a = a2,b = b2,c = c2;
        }
    }
 
}


Measured memory_bytes: 256
import sys
stdin = sys.stdin

def li(): return [int(x) for x in stdin.readline().split()]
def li_(): return [int(x)-1 for x in stdin.readline().split()]
def lf(): return [float(x) for x in stdin.readline().split()]
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(ns())
def nf(): return float(ns())

from itertools import accumulate

n = ni()
a = li()

a.sort()
a_cum = list(accumulate(a))[::-1]
a.sort(reverse=True)

ans = n

for i in range(n-1):
    if a[i] <= 2*a_cum[i+1]:
        continue
    else:
        ans = i+1
        break
        
print(ans)

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

#define NREP() for(ll i = 0; i < n; i++)
#define REP(i, n) for(ll i = 0; i < n; i++)
#define ALL(x) (x).begin(), (x).end()
#define MSG(x) cout << x << endl;
#define IPT(t, x) t ipt; cin >> ipt; x.push_back(ipt);
#define YN(x) x ? cout << "YES" << endl : cout << "NO" << endl;
#define Yn(x) x ? cout << "Yes" << endl : cout << "No" << endl;
#define yn(x) x ? cout << "yes" << endl : cout << "no" << endl;

using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;

const static ll MOD = 1e9 + 7;
ll n, cnt, ans, tmp, sum, a, b, c, d, k, m, h, w, q, x, y;
string s, t;

int main() {
    cin >> a >> b;
    if (a == 1) a = 14;
    if (b == 1) b = 14;

    if (a > b) {
        MSG("Alice")
    } else if (a < b) {
        MSG("Bob")
    } else {
        MSG("Draw")
    };
}


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

int main(){
    string S;
    cin >> S;
    sort(S.begin(), S.end());
    if((S.at(0) == S.at(1)) 
    && (S.at(2) == S.at(3))
    && (S.at(1) != S.at(2))){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}

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;
#define MOD ll(1e9+7)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cerr<<#x<<": "<<x<<endl

int main(){
    ll x;
    cin >> x;
    for(int i = 1; i < 10000; i++){
        if(100*i<= x && x <= 105*i){
            cout << 1 << endl;
            return 0;
        }
    }

    cout << 0 << endl;

    return 0;

}


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

int main() {
    int A, B;
    cin >> A >> B;
    bool flag = false;
    if (A % 3 == 0){
        flag = true;
    }
    if (B % 3 == 0){
        flag = true;
    }
    if ((A + B) % 3 == 0){
        flag = true;
    }

    if(flag){
        cout << "Possible" << endl;
    }
    else{
        cout << "Impossible" << endl;
    }
}

Measured memory_bytes: 256
s = input()
n = len(s)


for i in range(n):
    if (i+1)%2 == 0 and s[i] == 'R':
        print('No')
        break
    elif (i+1)%2 == 1 and s[i] == 'L':
        print('No')
        break
else:
    print('Yes')

Measured memory_bytes: 61928
#!/usr/bin/env python3
import sys
import string

def solve(C: str):
    for i, s in enumerate(string.ascii_lowercase):
        if s == C:
            print(string.ascii_lowercase[i+1])


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    C = next(tokens)  # type: str
    solve(C)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3764
from collections import deque
words=deque(input())

order_amount=int(input())
flg=True
for _ in range(order_amount):
    orders=input()
    if orders[0]=='1':
        flg=not flg
    else:
        _,f,c=orders.split()
        if (f=='1' and flg) or (f=='2' and not flg):
            words.appendleft(c)
        elif (f=='2' and flg) or (f=='1' and not flg):
            words.append(c)
if not flg:
    words.reverse()
word=''.join(words)
print(word)

Measured memory_bytes: 8436
#include<bits/stdc++.h>
using lint=long long;
using real=long double;
int main(){
    std::cin.tie(nullptr);std::ios_base::sync_with_stdio(false);
    std::cout.setf(std::ios_base::fixed);std::cout.precision(15);
    lint x,y;std::cin>>x>>y;
    lint ans=1;
    while(2*x<=y)ans++,x*=2;
    std::cout<<ans<<'\n';
}


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

int main() {
  
  int s;
  cin >> s;
  
  int x = s / 100;
  int y = s % 100;
  
  if(x <= 12 && y <= 12 && x != 0 && y != 0) {
    cout << "AMBIGUOUS" << endl;
  } else if (y <= 12 && y != 0) {
    cout << "YYMM" << endl;
  } else if (x <= 12 && x != 0) {
    cout << "MMYY" << endl;
  } else {
    cout << "NA" << endl;
  }
  
}


Measured memory_bytes: 256
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()
}

fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
  (0..n).map(|_| read_vec()).collect()
}

fn main() {
  let n: f64 = read();
  let ans: f64 = {
    if &n%2.0 == 0.0 {
      (&n/2.0)/&n
    } else {
      (&n+1.0)/2.0/&n
    }
  };

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

Measured memory_bytes: 4352
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

func nextInt(sc *bufio.Scanner) int { sc.Scan(); t, _ := strconv.Atoi(sc.Text()); return t }

func max(a, b int) int {
	if a >= b {
		return a
	}
	return b
}

type job struct {
	t, d int // t => 所要時間、d => 締め切り時間
}
type jobs []job

func (j jobs) Len() int {
	return len(j)
}
func (j jobs) Less(p, q int) bool {
	return j[p].d < j[q].d
}
func (j jobs) Swap(p, q int) {
	j[p], j[q] = j[q], j[p]
}

func main() {
	var n int
	fmt.Scan(&n)
	js := make([]job, n)
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	for i := 0; i < n; i++ {
		js[i].t = nextInt(sc)
		js[i].d = nextInt(sc)
	}
	sort.Sort(jobs(js))
	var tot int
	ok := true
	for i := range js {
		tot += js[i].t
		if tot > js[i].d {
			ok = false
			break
		}
	}
	if ok {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 6272
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main(){
    let n = read();
    let mut v: Vec<(i32, i32, i32)> = (0..n).map(|_| (read(), read(), read())).collect();
    v.insert(0, (0,0,0));
    let yes = v[..].windows(2).all(|w| {
        let (t, x, y) = w[0];
        let (nt, nx, ny) = w[1];
        let time = nt - t;
        let dist = (nx-x).abs() + (ny-y).abs();
        dist <= time && time % 2 == dist % 2
    });
    println!("{}", if yes {"Yes"} else {"No"});
}

Measured memory_bytes: 6396
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <fstream>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <stack>
#include <vector>
#include <set>
#include <tuple>
#include <utility>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef tuple<int,int,int> T3;
const int INF = 1000000000;

const double PI = 3.1415926535;
int main(){
	double r;
	cin >> r;
	printf("%.14lf\n",2*r*PI);
}


Measured memory_bytes: 3748
#include<iostream>
#include<vector>
#include<queue>
using namespace std;
int N_MAX = 100001;
struct edge{int from,to,cost;};
int main()
{
  int n,i,t;
  int res[N_MAX];
  edge e;
  vector<edge> g[N_MAX];
  queue<edge> q;
  cin >> n;
  if(n==1){
    cout << "0" << endl;
    return 0;
  }
  fill(res+1,res+n+1,-1);
  for(i=0;i<n-1;i++){
    cin >> e.from >> e.to >> e.cost;
    g[e.from].push_back(e);
    t=e.from;
    e.from=e.to;
    e.to=t;
    g[e.from].push_back(e);
  }
  res[1]=0;
  for(i=0;i<g[1].size();i++)
    q.push(g[1][i]);
  while(!q.empty()){
    e=q.front(); q.pop();
    if(res[e.to]>=0) continue;
    if(e.cost%2==1){
      res[e.to]=1-res[e.from];
    }else{
      res[e.to]=res[e.from];
    }
    for(i=0;i<g[e.to].size();i++)
      q.push(g[e.to][i]);
  }
  for(i=1;i<=n;i++)
    cout << res[i] << endl;
  return 0;
}

Measured memory_bytes: 7296
#include <cstdio>
#include <cstring>

typedef long long LL;
const int MN = 105;

char S[MN];
int N, K;
int A[MN], C;
LL Ans;

int main() {
	scanf("%s%d", S + 1, &K), N = strlen(S + 1);
	for (int i = 1, j = 1; i <= N; ++i) if (i == N || S[i] != S[i + 1]) A[++C] = i - j + 1, j = i + 1;
	if (C == 1) return printf("%lld\n", (LL)N * K / 2), 0;
	if (S[1] == S[N]) {
		for (int i = 2; i < C; ++i) Ans += (LL)A[i] / 2 * K;
		Ans += (LL)(A[1] + A[C]) / 2 * (K - 1);
		Ans += (LL)A[1] / 2;
		Ans += (LL)A[C] / 2;
		return printf("%lld\n", Ans), 0;
	}
	for (int i = 1; i <= C; ++i) Ans += (LL)A[i] / 2 * K;
	printf("%lld\n", Ans);
	return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		String str = sc.next();
		if(str.length() <= n){
			System.out.println(str);
		} else {
			System.out.println(str.substring(0, n)+"...");
		}
	}
}


Measured memory_bytes: 38528
#include<bits/stdc++.h>
#define fo(i,a,b)for(int i=a,_e=b;i<=_e;++i)
#define P pair<int,int>
#define fi first
#define se second
#define ll long long
using namespace std;
const int N=2005,mo=1e9+7;
int n,m,f[N],eq,up,vi[N],vs;
struct edge{int x,y,w;}e[N];
ll X;
vector<P>b[N];
bool us[N];
int F(int x){return x==f[x]?x:f[x]=F(f[x]);}
void link(int x,int y,int w){
	b[x].push_back(P(y,w));
	b[y].push_back(P(x,w));
}
int ksm(int x,int y){
	int t=1;
	for(;y;y>>=1,x=(ll)x*x%mo)if(y&1)t=(ll)t*x%mo;
	return t;
}
P find(int x,int y){
	if(x==y)return P(0,1);
	vi[x]=vs;
	for(P i:b[x])if(vi[i.fi]<vs){
		P j=find(i.fi,y);
		if(j.se)
			return P(max(i.se,j.fi),1);
	}
	return P(0,0);
}
bool cmp(edge x,edge y){return x.w<y.w;}
int main(){
	cin>>n>>m>>X;
	fo(i,1,m)cin>>e[i].x>>e[i].y>>e[i].w;
	sort(e+1,e+m+1,cmp);
	fo(i,1,n)f[i]=i;
	fo(i,1,m){
		int x=F(e[i].x),y=F(e[i].y);
		if(x==y)continue;
		us[i]=1;
		X-=e[i].w;
		f[x]=y;
		link(e[i].x,e[i].y,e[i].w);
	}
	if(X<0)return printf("0"),0;
	fo(i,1,m)if(!us[i]){
		int x=e[i].x,y=e[i].y;
		++vs;
		P k=find(x,y);
		if(e[i].w-k.fi==X)++eq;
		if(e[i].w-k.fi>X)++up;
	}
	if(X==0)
		printf("%d",(((ll)ksm(2,n-1)+mo-2)*ksm(2,m-(n-1))+(ll)2*(ksm(2,eq)-1)*ksm(2,up))%mo);
	else 
		printf("%d",(ll)2*(ksm(2,eq)-1)*ksm(2,up)%mo);
}

Measured memory_bytes: 384
#include <iostream>
#include<deque>
using namespace std;
int main()
{
  string s,z;
  cin>>s>>z;
  char n;
  n=s.size()-1;
  deque<char>dq;
  deque<char>x;
  int count=0;
  for(int i=0;i<s.size();i++){
    dq.push_back(s[i]);
  }
  for(int i=0;i<z.size();i++){
    x.push_back(z[i]);
  }
  for(int i=0;i<s.size();i++){
    if(dq!=x){
      dq.push_front(dq.back());
      dq.pop_back();
    }
    else{
      count++;
      break;
    }
  }
  if(count==1){
    cout<<"Yes";
  }
  else{
    cout<<"No";
  }

  return 0;
}


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

#define rep(i,n) for(long long int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(long long int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(long long int i=(a);i>(b);i--)
#define all(v) (v).begin(), (v).end()
#define pb(q) push_back(q)
#define P pair<int,int>
#define Abs(a,b) max(a,b)-min(a,b)
#define YES(condition) if(condition){cout << "YES" << endl;}else{cout << "NO" << endl;}
#define Yes(condition) if(condition){cout << "Yes" << endl;}else{cout << "No" << endl;}
#define Cout(x) cout<<(x)<<endl

typedef long long ll;

using namespace std;

const int INF = 1e9,MOD = 1e9 + 7;
const ll LINF = 1e18;

//while(x!=0){
            //sum+=x%10;
           // x/=10;
        //}
        //各桁の和

//pair<int,int> p[100000];
//P r[100000];
//cin >> tmp;
//p[i]=make_pair(tmp,i);
//cout << p[i].second+1 << endl;//ペアの右側つまりiを出力

//s.find(w[i])==string::npos
//findの使い方

//for(int i=0;i<n;i++){
   // b[i]=x%2;
    //x/=2;
  //}二進数

long long int n=1,cnt=0,ans=0,a,b,c,cmp,data,m,h,w,x,y,xcmp=0,ycmp=0,sum=0;

string s;

vector<int> z;

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

       cin >> a >> b;
       if(a%3!=0){
           if(b%3!=0){
               if((a+b)%3!=0){
                   Cout("Impossible");
                   return 0;
               }
           }
       }
       Cout("Possible");
return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <math.h>
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <algorithm>

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

using namespace std;
typedef long long ll;

int main() {

    ll N,D;
    cin >> N >> D;
    ll out = N/(D*2+1);
    if(N%(D*2+1)!=0) out++;
    cout << out << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){
    int x, y;
    while(1){
        scanf("%d %d", &x, &y);
        if(x==0 && y==0)break;
        if(x<y){
            printf("%d %d\n", x, y);
        }else{
            printf("%d %d\n", y, x);
        }
    }
    return 0;
}


Measured memory_bytes: 2052
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for(ll i=0; i<n; i++)
#define repr(i, s, e) for(ll i=s; i>=e; i--)
#define reps(i, s, e) for(ll i=s; i<=e; i++)
#define inf 1e18
#define all(v) v.begin(),v.end()
#define vsort(v) sort(v.begin(), v.end())
#define vsortr(v) sort(v.begin(), v.end(), greater<ll>())
#define ceil(a, b) (a+b-1)/b
#define ok cout << "ok" << endl;
#define sp << " " <<
template<typename T> inline bool chmax(T &a, T b){ if(a<b) a=b; return a<b; }
template<typename T> inline bool chmin(T &a, T b){ if(b<a) a=b; return b<a; }
template<typename T> void vdeb(vector<T> v){
    cout << "#vdebug" << endl;
    for(auto vv : v) cout << vv << " ";
    cout << endl;
}
template<typename T1, typename T2> void adeb(T1 arr[], T2 n){
    cout << "#adebug" << endl;
    for(int i=0; i<=n; i++) cout << arr[i] << " ";
    cout << endl;
}
template<typename T1> void mdeb(T1 mp){
    cout << "#map pair debug" << endl;
    for(auto const& m : mp) cout << m.first sp m.second << endl;
}
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){ fill((T*)array, (T*)(array+N), val); }
void ans(bool b){ cout << (b ? "Yes" : "No") << endl; }
void ans2(bool b){ cout << (b ? "YES" : "NO") << endl; }
int dx[] = {1, -1, 0, 0, 1, -1, 1, -1};
int dy[] = {0, 0, 1, -1, 1, -1, -1, 1};


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

    int n, m, a, b;
    vector<int> g[100];
    vector<pair<int, int>> edges;
    set<int> visit;
    ll cnt = 0;
    int start;

    cin >> n >> m;
    rep(i, m){
        cin >> a >> b;
        if(i == 0) start = a;
        g[a].push_back(b);
        g[b].push_back(a);
        edges.push_back(make_pair(a, b));
    }

    int check1, check2;

    function<void(int)> dfs = [&](int s){
        visit.insert(s);
        for(auto const& e : g[s]){
            if(visit.find(e) != visit.end()) continue;
            if(e == check1 && s == check2) continue;
            if(e == check2 && s == check1) continue;
            dfs(e);
        }
    };

    rep(i, m){
        visit.clear();
        check1 = edges[i].first;
        check2 = edges[i].second;
        dfs(start);
        if(visit.size() < n) cnt++;
    }

    cout << cnt << endl;

    return 0;
}


Measured memory_bytes: 256
import sys

stdin = sys.stdin

sn = lambda : stdin.readline().rstrip()
an = lambda : map(int, stdin.readline().split())
ni = lambda : int(sn())

def f(n):
    return n*(n+1)//2

def main():
  n, k = an()
  a = list(an())

  mod = int(1e9)+7
  ans = 0
  x = a[:] 
  for i, ai in enumerate(x):
    cnt = 0
    for j in range(i+1, n):
      if ai > x[j]:
        cnt += 1
    tcnt = 0
    for j in range(i+1):
      if ai > x[j]:
        tcnt += 1

    ans += f(k) * cnt
    ans %= mod
    ans += f(k - 1) * tcnt
    ans %= mod

  print(ans)

main()

Measured memory_bytes: 3188
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf = 1e9 + 7;

int main() {
	ll n1, k,n2;
	cin >> n1 >> k;
	while (1) {
		if (n1 > k)n2 = n1 % k;
		else n2 = abs(n1 - k);
		if (n2 >= n1)break;
		else n1 = n2;
	}
	cout << n1 << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<stack>
#include<list>
#include<cstdio>

using namespace std;

class Ans{
  int minimam;
  int target;
  list<int> st;
  stack<string> ans;
  const char *str;
  void prl(){
    for(list<int>::iterator it=st.begin();it!=st.end();it++){
      printf("%d ",*it);
    }
    printf("\n");
  }

  void check(int n){
    if(n<0){
      return;
    }else if(n<=minimam){
      char buff[10];
      string s;
      sprintf(buff,"%d ",target-n);
      s=buff;
      for(list<int>::iterator it=st.begin();it!=st.end();++it){
        sprintf(buff,"%d ",*it);
        s+=buff;
      }
      if(n<minimam){
        ans=stack<string>();
      }
      ans.push(s);
      minimam=n;
    }
  }
  void answer(const char *str,int now,int dist){
    if(*str == '\0' && now!=-1) {
      st.push_back(now);
      check(dist-now);
      st.pop_back();
      return;
    }
    if(now!=-1){
      st.push_back(now);
      //cout << now << endl;
      //prl();
      answer(str,-1,dist-now);
      st.pop_back();
    }
    {
      if(now==-1) now=0;
      now=now*10+(*str - '0');
      if(now > dist) return;
      answer(str+1,now,dist);
    }
  }
public:
  Ans(int target,const char *str){
    this->target = target;
    this->str = str;
    this->minimam = 0x7FFFFFFF;
    answer(this->str,-1,this->target);
  }
  void print(){
    if(ans.size()==1){
      string s = ans.top();
      while(s[s.size()-1] == ' ') s = s.substr(0, s.size()-1);
      cout << s << endl;
    }else if(ans.size()>1){
      cout << "rejected" << endl;
    }else{
      cout << "error" << endl;
    }
  }
};

int main(){
  int n;
  string m;
  while(cin >> n >> m , !(n==0&&m=="0")){
    Ans a(n,m.c_str());
    //cout << endl;
    a.print();
    //cout << endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include <stdio.h>
#include <bits/stdc++.h>
int main(){
  int n;
  int i;
  int j,k,l;
  scanf("%d", &n);
  for (i = 0; i < n; i++) {
    int y,m,d;
    int ans = 0;
    scanf("%d%d%d", &y, &m, &d);

    for (j = 1; j < y; j++) { // year_calc
      // printf("year\n");
      if (j%3 == 0) {
        ans += 200;
      }
      else {
        ans += 195;
      }
    }

    for (k = 1; k < m; k++) { // month_calc
      if (j%3 == 0) {
        ans += 20;
      }
      else {
        if (k%2 == 0) {
          ans += 19;
        }
        else {
          ans += 20;
        }
      }
    }
    ans += d;
    
    int minus = 0;
    for (j = 1; j < 999; j++) {
      if (j%3 == 0) {
        minus += 200;
      }
      else {
        minus += 195;
      }
    }
    for (k = 1; k <= 10; k++) { // month_calc
      //printf("j = %d\n",j);
      if (j%3 == 0) {
        minus += 20;
      }
      else {
        if (k%2 == 0) {
          minus += 19;
        }
        else {
          minus += 20;
        }
      }
    }
    
    printf("%d\n", minus - ans + 1);
  }
  return 0;
}

Measured memory_bytes: 1188
import heapq


def main():
    n = int(input())
    As = list(map(int, input().split()))
    As_sort = sorted(As, reverse=True)
    ans = 0
    q = []
    heapq.heappush(q, -As_sort[0])
    for i in range(1, n):
        tmp = heapq.heappop(q)
        tmp *= -1
        ans += tmp
        heapq.heappush(q, -As_sort[i])
        heapq.heappush(q, -As_sort[i])
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 31460
#include <iostream>
#include <utility>
#include <string>
#include <sstream>
#include <cstring>
#include <algorithm>
#include <vector>
using namespace std;

typedef pair<int, int> P;

bool fff(P a,P b){
	return a.first == b.first ? a.second < b.second : a.first > b.first;
}

int main(){
	int n,a,psum,c,take,f;
	string str,out;
	P tmp,array[40];
	vector<P> plist;
	vector<int> point;
	while(cin >> n,n){
		plist.clear();
		getline(cin,str);
		for(int i = 0;i < n;++i){
			psum = c = take = 0;
			getline(cin,str);
			stringstream buf(str);
			point.clear();
			f = 1;
			while(buf >> out){
				a = atoi(out.c_str());
				if(f) {
					tmp.second = a;
					f = 0;
				}
				else{
					point.push_back(a);
				}
			}
			point.push_back(0);
			point.push_back(0);
			int k = 0;
			for(int j = 0;j < 10;++j){
				if(point[k] == 10){
					psum += point[k] + point[k + 1] + point[k + 2];
					++k;
				}
				else if(point[k] + point[k + 1] == 10){
					psum += point[k] + point[k + 1] + point[k + 2];
					k += 2;
				}
				else {
					psum += point[k] + point[k + 1];
					k += 2;	
				}
			}
			tmp.first = psum;
			plist.push_back(tmp);
			buf.clear();
		}
		sort(plist.begin(),plist.end(),fff);
		for(int i = 0;i < plist.size();++i){
			cout << plist[i].second << " " << plist[i].first << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1256
#include <iostream>
//#include <string>
using namespace std;

int main() {
	unsigned long long n;
	unsigned long long ans = 0uLL;
	cin >> n;
	for (unsigned long long i = 0uLL; i < n ; i++) {
		ans += i;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
import numpy as np
import itertools

def calc_sum(nums):
    if len(nums) == 1: return nums[0]
    idxs = np.arange(1, len(nums))
    masks = list(itertools.product([False, True], repeat=len(idxs)))

    ret = 0 
    for mask in masks:
        selected_idxs = [0] +list( idxs[ np.array(mask)]) + [len(nums)]
        for i in range(len(selected_idxs) - 1):
            ret += (int(''.join(nums[selected_idxs[i]: selected_idxs[i+1]])))
    return ret


S = input()
nums = [s for s in S]

print(calc_sum(nums))

Measured memory_bytes: 12440
import java.util.Scanner;

public class Main{
	public static int divisble(int n) {
		if(n/100==0) {
			return 0;
		}
		return 1+divisble(n/100);
	}
	public static void main(String [] args){
		Scanner input = new Scanner(System.in);
		String temp = input.nextLine();
		int toReturn=0;
		int d=Integer.parseInt(temp.substring(0, temp.indexOf(" ")));
		int num=Integer.parseInt(temp.substring(temp.indexOf(" ")+1));
		int count=0;
		int tempe=1;
		while(count!=d) {
			tempe*=10;
			count=divisble(tempe);
		}
		for(int x=0;x<num;x++) {
			toReturn+=tempe;
		}
		if(num==100) {
			toReturn+=tempe;
		}
		System.out.println(toReturn);
		input.close();
		
	}
	

}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
  int N, K, x;
  cin >> N >> K;
  
  int D = 0;//Dは移動距離の総和
  
  for(int i = 0; i < N; i++)
  {
    cin >> x;
    if(x <= K - x){D += 2 * x;}
    else{D += 2 * (K - x);}
  }
  
  cout << D << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <ctype.h>

int main(void)
{
    char c;
    while (1)
    {
        scanf("%c", &c);
        if(c=='\n')break;
        if (isalpha(c))
        {
            if (islower(c))
                c = toupper(c);
            else if (isupper(c))
                c = tolower(c);
        }
        printf("%c",c);
    }
    printf("\n");
    return 0;
}


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

#include <math.h>
#include <stdlib.h>


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

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



ll mod = 1e9+7;

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    ll n; cin >> n;
    vector<ll> a(n);
    ll ans = 0;
    for(int i = 0; i < n; i++) cin >> a[i];


    for(int i = 60; i >= 0; i--){
        ll cnt = 0;
        for(int j = 0; j < n; j++){
            if((a[j] >> i) & 1) cnt++;
        }
        ll pnum = cnt * (n-cnt);
        pnum %= mod;
        ll m = (1LL<< i);
        m %= mod;
        ans += (pnum * m)%mod;
        ans %= mod;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 2560
a,b = map(int,input().split())
s = list(input())
if s[a] != '-':
    print('No')
else:
    s.pop(a)
    s = ''.join(s) 
    if len(s) == a+b and s.isdecimal() == 1:
        print('Yes')
    else:
        print('No')


Measured memory_bytes: 2940
import java.util.Scanner;
    public class Main{
  public static void main(String[] args){
          Scanner scan = new Scanner(System.in);
          int num1 = scan.nextInt();
          int num2 = scan.nextInt();
          int num3 = scan.nextInt();
          if(num1<num2&&num2<num3){
            System.out.println("Yes");
          }else{
            System.out.println("No");
          }
          scan.close();
}
}



Measured memory_bytes: 26200
N = int(input())
s = []
t = []
for _ in range(N):
  tmp = int(input())
  s.append(tmp)
  if tmp % 10 != 0:
    t.append(tmp)

ans = sum(s)

if ans % 10 != 0:
  print(ans)
else:
  if not t:
    print(0)
  else:
  	print(ans - min(t))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <cstdio>
using namespace std;
int main() {
    string s;
    cin >> s;
    int bexp[100010];
    for (int i = 0; i < s.length() ; i++) {
        if (s[i] == '1') bexp[i] = 1;
        else bexp[i] = 0;
    }

    int res = 0;
    for (int i = 1; i< s.length(); i++) {
        if (bexp[i] ^ bexp[i-1] == 0) {
            res++;
            bexp[i] = bexp[i] ^ 1;
        }
    }
    cout << res << "\n";
}

Measured memory_bytes: 896
#include <iostream>
#include <string>
#include <cstring>
#include <vector>
#include <algorithm>
#include <set>
#include <stack>
#include <deque>
#include <cmath>
#include <map>
using namespace std;
using ll = long long;
#define rep(i, n) for (ll i = 0; i < n; i++)
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

int main() {
    ll n;
    cin >> n;
    double ans = 0;
    rep(i, n) {
        double x;
        string u;
        cin >> x >> u;
        if (u == "JPY") ans += x;
        else ans += x * 380000.0;
    }
    cout.precision(20);
    cout << ans << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize("O2")
#include <bits/stdc++.h>
using namespace std;
#define FASTIO ios_base::sync_with_stdio(false), cin.tie(0)
//#define MULTI_TEST
//#define GOOGLE
#ifdef LOCAL
#include "debugger.h"
#else
#define db(...)
#endif
#define ll long long
#define v32 vector<int>
#define v64 vector<ll>
#define s32 set<int>
#define s64 set<ll>
#define p32 pair<int, int>
#define p64 pair<ll, ll>
#define sz(v) (ll)(v).size()
#define fi first
#define se second
#define ln '\n'
const ll MOD = 1e9 + 7;
inline ll add(ll a, ll b, ll m) { return (((a % m + b % m) % m + m) % m); }
inline ll mul(ll a, ll b, ll m) { return (((a % m * b % m) % m + m) % m); }

void solve(int tc)
{
	int n;
	cin >> n;
	v32 arr(n, 0);
	for (int i = 0; i < n; i++)
		cin >> arr[i];
	int x = 0;
	for (int i = 0; i < n; i += 2)
		x ^= (arr[i] ^ arr[i + 1]);
	for (int i = 0; i < n; i++)
		cout << (x ^ arr[i]) << " ";
	cout << ln;
	return;
}

int main()
{
#ifndef LOCAL
	FASTIO;
#endif
	int t = 1;
#ifdef LOCAL
	clock_t start, stop;
	start = clock();
#endif
#ifdef MULTI_TEST
	cin >> t;
#endif
	for (int tc = 1; tc < t + 1; tc++)
	{
#ifdef GOOGLE
		cout << "Case #" << tc << ": ";
#endif
		solve(tc);
	}
#ifdef LOCAL
	stop = clock();
	cerr << "Time :" << fixed << setprecision(5) << double(stop - start) / double(CLOCKS_PER_SEC) << "s" << ln;
#endif
	return 0;
}


Measured memory_bytes: 3928
from collections import defaultdict
import sys
import math
from datetime import datetime

def sol(a, b, c):
    big = max(a, b)
    if c % big == 0: return c // big
    else: return (c // big) + 1
    #return 1 + 2 + 3 - a - b
    #if a + b + c <= 21: return 'win'
    #else: return 'bust'



do_submit = True
#do_submit = False

def input_parse(input_str):
    lines = [x.strip() for x in input_str.split("\n") if x.strip()]
    parsed_lines = [list(map(str, line.split())) for line in lines]
    print(parsed_lines)
    n = int(parsed_lines[0][0])
    k = int(parsed_lines[0][1])
    S = parsed_lines[1][0]
    return n, k, S


if not do_submit:
    a, b, c = input_parse("""
    3 1
    ABC
    """)
    print(sol(a, b, c))

    a, b, c = input_parse("""
    4 3
    CABA
    """)
    print(sol(a, b, c))

else:
    #a, b, c = list(map(int, input().split()))
    # S = input().split()
    a = int(input())
    b = int(input())
    c = int(input())
    # T = input()
    print(sol(a, b, c))
    # S = input().strip()
    # print(sol(S))

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

int main(){
    int n,ans=0;cin>>n;vector<int> v(n),c(n);
    for(int i=0;i<n;i++) cin>>v.at(i);
    for(int i=0;i<n;i++){
        cin>>c.at(i);
        if(v.at(i)>c.at(i)) ans+=v.at(i)-c.at(i);
    }
    cout<<ans<<endl;
}

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


int main() {
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  int s,e;
  s = max(a,c);
  e = min(b,d);
  if (s >= e) cout << 0 << endl;
  else cout << e - s << endl;
  
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>

using namespace std;

long long int N, K, ans;
long long int MOD=1000000007;

int main(){
  cin >> N >> K;
  ans = 0;
  for (long long int i=K; i<=N+1; i++) {
    long long int min = 0;
    long long int max = 0;
    // for (int j=0; j<i; j++) {
    //   min += j;
    //   max += N-j;
    // }
    long long int a;
    min = (((i-1) * i) / 2) % MOD;
    max = (i * (N + 1 - i)) % MOD;
    max += min % MOD;
    ans += max - min + 1;
    ans %= MOD;
    // printf ("%lld: ans:%lld min:%lld max:%lld N+1:%lld N-i:%lld\n",i, ans, min, max, N+1, N+1-i);
  }

  cout << ans << endl;
}


Measured memory_bytes: 3640
import sys

sys.setrecursionlimit(10**7)
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))  #空白あり
def LI2(): return list(map(int,sys.stdin.readline().rstrip()))  #空白なし
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())  #空白あり
def LS2(): return list(sys.stdin.readline().rstrip())  #空白なし

s = S()

if s == s.upper():
    print('A')
else:
    print('a')

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

#define ten(n) ((int)1e##n)
// dump macro{{{
// http://www.creativ.xyz/dump-cpp-652
#define DUMPOUT cerr // 変数ダンプ先。coutかcerr

#ifdef PCM
// 引数はいくつでもどんな型でも可（ストリーム出力演算子があればOK）
#define dump(...) DUMPOUT<<"  "; \
  DUMPOUT<<#__VA_ARGS__; \
  DUMPOUT<<":=> "; \
  dump_func(__VA_ARGS__); DUMPOUT<<"in ["<<__LINE__<<":"<<__FUNCTION__<<"]"<<endl;
#define dump_1d(x,n) DUMPOUT <<"  " \
  <<#x<<"["<<#n<<"]"<<":=> {"; \
  rep(i,n){ DUMPOUT << x[i] << (((i)==(n-1))?"}":", "); } DUMPOUT <<" in [" << __LINE__ << "]" << endl;

#define dump_2d(x,n,m) DUMPOUT <<"  " \
    <<#x<<"["<<#n<<"]"<<"["<<#m<<"]"<<":=> \n"; \
    rep(i,n)rep(j,m){ DUMPOUT << ((j==0)?"     |":" ") << x[i][j] << (((j)==(m-1))?"|\n":" "); } \
    DUMPOUT <<"  in [" << __LINE__ << "]" << endl;
#else
#define dump(...) 42
#define dump_1d(...) 42
#define dump_2d(...) 42
#endif

// デバッグ用変数ダンプ関数
void dump_func() {
}
template <class Head, class... Tail>
void dump_func(Head&& head, Tail&&... tail)
{
    DUMPOUT << head;
    if (sizeof...(Tail) == 0) {
        DUMPOUT << " ";
    }
    else {
        DUMPOUT << ", ";
    }
    dump_func(std::move(tail)...);
}

// vector出力
template<typename T>
ostream& operator << (ostream& os, vector<T>& vec) {
    os << "{";
    for (int i = 0; i<vec.size(); i++) {
        os << vec[i] << (i + 1 == vec.size() ? "" : ", ");
    }
    os << "}";
    return os;
}/*}}}*/

#define rep(i, x) for(int i = 0; i < (int)(x); i++)/*{{{*/
#define reps(i,x) for(int i = 1; i <= (int)(x); i++)
#define rrep(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define rreps(i,x) for(int i=((int)(x));i>0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define RFOR(i, m, n) for(int i = m;i >= n;i--)
#define foreach(x,a) for(auto& (x) : (a) )
#define all(x) (x).begin(),(x).end()
#define sum(v) accumulate(all(v), 0)
#define sz(x) ((int)(x).size())
#define fill(x,y) memset(x,y,sizeof(x))
#define pb(a) push_back(a)
#define INF 2147483647
#define INFLL 1000000000000000000LL
#define MOD 1000000007/*}}}*/

struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);}} fast;/*{{{*/
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long long> vll;
typedef vector<vll> vvll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<pii> vii;
typedef vector<vii> vvii;
typedef tuple<int,int,int> iii;
typedef set<int> si;
typedef complex<double> pnt;
typedef vector<pnt> vpnt;
typedef priority_queue<pii,vii,greater<pii> > spq;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

/*}}}*/


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

  vector<string> x;

  reps(l,k){
    if (s.size()-l+1>0){
      rep(st, s.size()-l+1){
        x.pb(s.substr(st, l));
      }
    }
  }

  sort(all(x));
  x.erase(unique(all(x)), x.end());

  cout << x[k-1] << endl;

  return 0;
}


Measured memory_bytes: 1660
#include<iostream>
#include<string.h>
#include<ctype.h>
#include<string>
#include<math.h>
#define pi 3.141592653589
#include<iomanip>
using namespace std;

int main(){
     
    int a,b,c;
    
    cin>>a>>b>>c;
    if(a>=b&&a>=c&&a==b+c)cout<<"Yes"<<endl;
    else if(b>=a&&b>=c&&b==a+c)cout<<"Yes"<<endl;
    else if(c>=b&&c>=a&&c==a+b)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}
 

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<map>
#include<tuple>
#include<cmath>


#define MOD 1000000007
#define rep(i,k,N) for(ll i=k;i<N;i++)
#define MP make_pair
#define MT make_tuple //tie,make_tuple は別物
#define PB push_back

typedef long long ll;

using namespace std;

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

int main(){
    int N,M;
    cin>>N>>M;
    vector <ll> dp(8193,1000000000);
    dp[0]=0;
    ll a,b;
    queue<int> q;
    q.push(0);
    q.push(-1);
    rep(i,0,M){
        cin>>a>>b;
        vector<int> c(b);
        int x=0;
        rep(j,0,b){
            cin>>c[j];
            x+=pow(2,c[j]-1);
        }
        rep(s,0,pow(2,12)){
            dp[s|x]=min(dp[s|x],dp[s]+a);
        }

    }
    if(dp[pow(2,N)-1]==1000000000)cout<<-1;
    else cout<<dp[pow(2,N)-1];
    return 0;
}

Measured memory_bytes: 512
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <string>
#include <utility>

using namespace std;

int main() {
  string a,s,c;
  cin >> a >> s >> c;
  cout << "A" << s[0] << "C" << endl;

  return 0;
}


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

using namespace std;

int main(){
  string s;
  cin >> s;
  if (s.substr(0,4) == "YAKI") {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleTest
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());

            var dic = new Dictionary<string, bool>();

            for(var i = 0; i < n; ++i)
            {
                var arr = Console.ReadLine().Split(' ');
                switch(arr[0])
                {
                    case "insert":
                        if(!dic.ContainsKey(arr[1])) dic.Add(arr[1], true);
                        break;
                    case "find":
                        Console.WriteLine(dic.ContainsKey(arr[1]) ? "yes" : "no");
                        break;
                }
            }
        }
    }
}



Measured memory_bytes: 44600
fun main() {
    val int = rint()
    function(int)
}

fun function(K: Int) {
    var sum = 0L
    for (a in 1..K) {
        for (b in 1..K) {
            for (c in 1..K) {
                sum += gcd(a, gcd(b, c))
            }
        }
    }
    println(sum)
}

tailrec fun gcd(a: Int, b: Int): Int = if (b == 0) {
    a
} else {
    gcd(b, a % b)
}

fun rl() = readLine()!!
fun rsp() = readLine()!!.split(" ")
fun rint() = readLine()!!.toInt()
fun rspint() = readLine()!!.split(" ").map { it.toInt() }

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

int main() {
  int N;
  cin >> N;
  vector<long> a(N);
  vector<long> b(N);
  long sum=0;
  for(int i=0;i<N;i++){
    cin >> a[i];
    sum-=a[i];
  }
  for(int i=0;i<N;i++){
    cin >> b[i];
    sum+=b[i];
  }
  long an=0,bn=0;
  for(int i=0;i<N;i++){
    if(a[i]>b[i])bn+=a[i]-b[i];
    else an+=(b[i]-a[i]+1)/2;
  }
  if(an>sum || bn>sum)cout << "No";
  else cout << "Yes";
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
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;
}
using ll = long long;

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define endl "\n"
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
const double PI = acos(-1);
constexpr int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//-------------------------------------

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    bool isReverse = 0;
    string fr = "", ba = "";
    int q;
    cin >> q;
    while(q--) {
        int t;
        cin >> t;
        if(t == 1) {
            isReverse = !isReverse;
        } else {
            int f;
            char c;
            cin >> f >> c;
            if(f == 1) {
                if(isReverse) {
                    ba += c;
                } else {
                    fr += c;
                }
            } else {
                if(isReverse) {
                    fr += c;
                } else {
                    ba += c;
                }
            }
        }
    }
    reverse(ALL(fr));
    s = fr + s + ba;
    if(isReverse) {
        reverse(ALL(s));
    }
    cout << s << endl;
}

Measured memory_bytes: 1200
#include <iostream>
#include <string>
typedef long long LL;
using namespace std;

int main(){
    LL a;
    LL b;
    LL c;
    LL d;
    LL e;
    LL tmp;
    LL diff;
    LL sum = 0;   
    cin >> a >> b >> c >> d;
    if(c<d){
        tmp = c;
        c = d;
        d = tmp;
    }

    if(a%c==0){
        diff = b - a;
    }else{
        diff = b - ((a/c) + 1) * c;
    }
    if(diff>=0){
        sum += (diff/c) + 1;
    }

    if(a%d==0){
        diff = b - a;
    }else{
        diff = b - ((a/d) + 1) * d;
    }
    if(diff>=0){
        sum += (diff/d) + 1;
    }

    e = c * d;
    tmp = c%d;
    while(tmp!=0){
        c = d;
        d = tmp;
        tmp = c%d;
    }
    e = e / d;
    if(a%e==0){
        diff = b - a;
    }else{
        diff = b - ((a/e) + 1) * e;
    }
    if(diff>=0){
        sum -= (diff/e) + 1;
    }
    sum = b - a + 1 - sum;    
    cout << sum << endl;
}

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

using namespace std;

void trace(int n, vector<int> &a){
    for (int k = 0; k < n; k++){
        if (k != n-1) cout << a[k] << " ";
        else cout << a[n-1] << endl;
    }
}


void insertionSort(int n, vector<int> & a){
    for (int i = 1; i < n; i++){
        int j = i - 1;
        int temp = a[i];
        
        while(j >= 0 && a[j] > temp){
            a[j+1] = a[j];
            j--;
        }
        
        a[j+1] = temp;
        
        trace(n, a);
    }
    
}


int main(void){
    int n;
    cin >> n;
    
    vector<int> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    
    for (int i = 0; i < n; i++){
        if (i != n-1) cout << a[i] << " ";
        else cout << a[i] << endl;
    }
    
    insertionSort(n, a);
}



Measured memory_bytes: 3096
#include<bits/stdc++.h>
#define N 10000
using namespace std;
int a;
int x,y;
bool p=0,q=0;

int main(){
    cin >> a;
    x=a/100;
    y=a%100;
    if(x>0&&x<=12) p=1;
    if(y>0&&y<=12) q=1;
    if(p==1&&q==1) printf("AMBIGUOUS\n");
    else if(p==1) printf("MMYY\n");
    else if(q==1) printf("YYMM\n");
    else printf("NA\n");

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main() {
	int i, j, r, c, sum=0, rc_array[101][101];

	for (i = 0; i < 101; i++) {
		for (j = 0; j < 101; j++) {
			rc_array[i][j] = 0;
		}
	}

	scanf("%d %d", &r, &c);

	for (i = 0; i < r; i++) {
		for (j = 0; j < c; j++) {
			scanf("%d", &rc_array[i][j]);
		}
	}
	for ( i = 0; i <=r ; i++){
		for ( j = 0; j <= c-1; j++){
			 rc_array[i][c]+= rc_array[i][j];

		}
	}
	for (i = 0; i < r; i++) {
		for (j = 0; j <=c; j++) {
			rc_array[r][j] += rc_array[i][j];

		}
	}
	for (i = 0; i <= r; i++) {
		for (j = 0; j <= c; j++) {
			printf("%d", rc_array[i][j]);
			if (j != c) {
				printf(" ");
			}
		}
		printf("\n");
	}

}

Measured memory_bytes: 1816
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define MOD 1000000007
#define all(ppp) ppp.begin(),ppp.end()
#define out(ppp) cout<<(ppp)<<endl
#define out1(ppp) cout<<(ppp) 
#define MAX_CHAR 256

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
#define pb push_back

typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
typedef vector<vpi> vvpi;

typedef set<pi> spi;

const int INF=INT_MAX;
ll inv[10000100];
ll FactorialInv[10000100];
ll Factorial[10000100];

ll mymod(ll a,ll b){
    a%=MOD;
    ll result=1;
    while(b>0){
        if(b&1){
            result=(result*a)%MOD;
        }
        a=(a*a)%MOD;
        b>>=1;
    }
    return result;
    
}
ll modInverse(ll n){
    return mymod(n,MOD-2);
}

void init_combination(){
    const int MAX = 10000002;   //1e6+2
    Factorial[0]=1;
    inv[0]=1;
    for(int i=1;i<=MAX;i++){
        Factorial[i]=(Factorial[i-1]*i)%MOD;
    }
    FactorialInv[MAX]=modInverse(Factorial[MAX]);
    for(int i=MAX-1;i>=0;i--){
        FactorialInv[i]=FactorialInv[i+1]*(i+1)%MOD;
    }
    for(int i=1;i<=MAX;i++){
        inv[i]=(FactorialInv[i]*FactorialInv[i-1])%MOD;
    }
}

ll combination(ll n,ll k){
    if(n==k||k==0){
        return 1;
    }
    if(n<k){
        return 0;
    }
    ll ans=(Factorial[n]*FactorialInv[k])%MOD;
    ans=(ans*FactorialInv[n-k])%MOD;
    return ans;
}

int main(){
    ll N,K;
    cin>>N>>K;
    init_combination();
    for(ll i=1;i<=K;i++){
        ll t1=combination(K-1,i-1);
        ll t2=combination(N-K+1,i);
        ll ans=(t1*t2)%MOD;
        out(ans);
    }

}


Measured memory_bytes: 234624
import sys
sys.setrecursionlimit(10**8)

MOD = 10**9 + 7
def power_mod(a,b,p):
    if b==0:
        return 1
    if b%2==0:
        d=power_mod(a,b//2,p)
        return (d*d)%p
    else:
        return(a*power_mod(a,b-1,p)%p)

def inverse(a,p):
    return power_mod(a,p-2,p)

def combination(n, r, p): # nCrを求める
    r = min(n-r, r)
    result = 1
    for i in range(n, n-r, -1):
        result *= i
        result %=p
    for i in range(1, r+1):
        result *= inverse(i,p)
        result %= p
    return result

n,m,k = map(int,input().split())

ans = 0
for i in range(n):
    ans +=(n-i)*(m**2)*i
    ans %=MOD
for i in range(m):
    ans +=(m-i)*(n**2)*i
    ans %=MOD

ans *= combination(n*m-2,k-2,MOD)
ans %= MOD

print(ans)


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

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << setprecision(20);

  ll n;
  cin >> n;
  if (n%2 == 0) {
    cout << n << endl;
  } else {
    cout << 2 * n << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define repit(it, li) for(auto it=li.begin(); it!=li.end(); it++)
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main(){
   int n;
   cin>>n;
   bool ye=true;
   map<int, bool> deta;
   rep(i, n){
      int a;
      cin>>a;
      if(deta[a]) ye=false;
      deta[a]=true;
   }

   if(ye) cout<<"YES"<<endl;
   else cout<<"NO"<<endl;
   return 0;
}


Measured memory_bytes: 12960