akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
int main(){
	int N;
	vector<int> X;
	cin >> N;
	for(int i = 0; i < N; i++){
		int tmp;
		cin >> tmp;
		X.push_back(tmp);
	}
	
	// 重心を計算
	double center = 0;
	for(int i = 0; i < N; i++){
		center += (double)X[i];
	}
	center = round(center/N);
	
	// 体力の総和を計算
	int result = 0;
	for(int i = 0; i < N; i++){
		result += (X[i] - (int)center) * (X[i] - (int)center);
	}
	
	cout << result << endl;
}

Measured memory_bytes: 512
# a, b, c, x = map(int, open(0))

A,B,C,X = [int(input()) for i in range(4)]

count = 0

for i in range(A+1):
    for j in range(B+1):
        for k in range(C+1):
            if 500*i+100*j+50*k==X:
                count+=1

print(count)

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

int main() {
int X;
cin>>X;
vector<int> p(X);
p.push_back(2);
for(int i=X;i<200000;i++){
  bool flg=true;
  for(int j=2;j<sqrt(i);j++){
    if(i%j==0) {
      flg=false;
      break;
  }
}
  if(flg) {
    cout<<i<<endl;
    return 0;
  }
}


}


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

int main(){
  int a,b,k,i;
  cin >> a >> b >> k;
  for(i=100; i>0; i--){
    if(a%i==0 && b%i==0){
      k--;
      if(k==0) break;
    }
  }
  cout << i;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;

class Main {


	private static long lcm(long a, long b) {
		return a / gcd(a, b) * b;
	}

	private static long gcd(long a, long b) {
		if (b == 0) return a;
		return gcd(b, a % b);
	}

	public static void main(String[] args) throws Exception {
		final Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long m = sc.nextLong();
		long[] a = new long[n];

		boolean ok = true;

		for (int i = 0; i < n; i++) {
			a[i] = sc.nextLong();
			if (a[i] % 2 == 1) ok = false;
			a[i] /= 2;

		}

		if (!ok) {
			System.out.println(0);
			return;
		}

		int b = f(a[0]);
		for (int i = 0; i < n; i++) {
			if (f(a[i]) != b) {
				ok = false;
				break;
			}
			a[i] >>= b;
		}

		if (!ok) {
			System.out.println(0);
			return;
		}

		m >>= b;

		long lcm = 1;
		for (int i = 0; i < n; i++) {
			lcm = lcm(lcm, a[i]);
			if (lcm > m) {
				System.out.println(0);
				return;
			}
		}

		m /= lcm;
		System.out.println((m + 1) / 2);
	}

	private static int f(long a) {
		int count = 0;
		while (a % 2 == 0) {
			a /= 2;
			count++;
		}

		return count;
	}
}


Measured memory_bytes: 48976
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>
#include <iomanip>
#include <ctype.h>

using namespace std;
using ll = long long;

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

ll GCD(ll x, ll y) {
    if (y == 0) return x;
    else return GCD(y, x % y);
}

int main()
{
    int A;
    cin >> A;

    if (A < 1200) { cout << "ABC" << endl; }
    else { cout << "ARC" << endl; }
}

Measured memory_bytes: 256
#![allow(unused_imports)]
use std::io::*;
use std::fmt::*;
use std::str::*;
use std::cmp::*;
use std::collections::*;

pub trait InputValue {
    fn parse(s: &str) -> Self;
}

pub fn read<T: InputValue>() -> T {
    let mut buf = String::new();
    let _ = stdin().read_line(&mut buf);
    T::parse(&buf.trim())
}

pub fn readn<T: InputValue>(n: usize) -> Vec<T> {
    let mut vec = vec![];
    for _ in 0..n {
        vec.push(read());
    }
    vec
}

pub fn readnc<T: InputValue>() -> Vec<T> {
    let mut vec = vec![];
    let line: String = read();
    for token in line.split_whitespace() {
        vec.push(T::parse(token));
    }
    vec
}

macro_rules! parse_single_value {
    ($($t:ty),*) => {
        $(
            impl InputValue for $t {
                fn parse(s: &str) -> $t { s.parse().unwrap() }
            }
        )*
	}
}
parse_single_value!(i32, i64, f32, f64, usize, String);

macro_rules! parse_tuple {
	($($t:ident),*) => {
		impl<$($t),*> InputValue for ($($t),*) where $($t: InputValue),* {
			fn parse(s: &str) -> ($($t),*) {
				let mut tokens = s.split_whitespace();
				let t = ($($t::parse(tokens.next().unwrap())),*);
				t
			}
		}
	}
}
parse_tuple!(A, B);
parse_tuple!(A, B, C);
parse_tuple!(A, B, C, D);
parse_tuple!(A, B, C, D, E);

// ===

fn main() {
    let s: String = read();
    let n = s.len();
    let x = s.into_bytes();
    let mut need = vec![n, n];
    for i in 0..n {
        let idx = if x[i] == b'0' { 0 } else { 1 };
        if i == n-1-i {
            need[idx] = min(need[idx], i+1);
        } else {
            need[idx] = min(need[idx], max(i, n-1-i));
        }
    }
    println!("{}", max(need[0], need[1]));
}


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

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pair<int, int> > vpii;
typedef vector<pair<ll, ll> > vpll;

#define pll pair<ll,ll>
#define pii pair<int, int>
#define all(x) x.begin(), x.end()
#define F first
#define S second
#define rep(i,n) for (int i = 0; i < n; ++i) 
#define REP(i,k,n) for (int i = k; i <= n; ++i) 
#define REPR(i,k,n) for (int i = k; i >= n; --i)
#define pb push_back
#define watch(x) cout << (#x) << " is " << (x) << endl
#define sz(a) int((a).size())
#define endl '\n' // remove for interactive

const int INF = 1e9;
const ll mod = 1e9 + 7;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}



void solve()
{
    string s; cin>>s;
    ll sm = 0;
    for(auto c: s) sm += c-'0';
    if(sm % 9 == 0) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

int main()
{
    // clock_t start, end;
    // start = clock();
    ios_base::sync_with_stdio(0); //cant use scanf, printf
    cin.tie(0);cout.tie(0); // no longer auto flush cout before each cin, remove for interactive
    int t = 1;
    // cin>>t;
    REP(i, 1, t)
    {
        solve();
        
    }
    // end = clock();
    // double time_taken = double(end - start) / double(CLOCKS_PER_SEC); 
    // watch(time_taken);
    ll x = INF; x++;
    return 0;
    
}



/*before sub
TEST: 0(1 by 1 too), 1, equal, -ve, bounds(random and ez)
ERR/WA: loop vars, out of bounds, endl, finish taking inputs, large doubles, larger INF, corr mod, t, early/late mod
RE: double dec, integer overflow(ll or 1LL mult)
*/





Measured memory_bytes: 3748
#[allow(unused_imports)]
use proconio::{input, fastout};
#[allow(unused_imports)]
use proconio::marker::{Chars};

#[fastout]
fn main() {
  input!{a:u128,b:Chars}
  let b:u128 = vec![b[0],b[2],b[3]].iter().collect::<String>().parse().unwrap();
  let mut b = (a*b).to_string();
  if b.len() > 2 {
    b.truncate(b.len() - 2);
  } else {
    b = "0".to_string();
  }
  println!("{}",b);
}


Measured memory_bytes: 2148
#include<bits/stdc++.h>
using namespace std;
int main()
{
      ios::sync_with_stdio(false);
      cin.tie(0);
   long long int i,n,x,k=0,input;
    cin>>n;
    x=n+1;
    for(i=0; i<n; i++){
        cin>>input;
        if(input<x){
            k++;
            x=input;
        }
    }
    cout<<k<<"\n";
    return 0;
}


Measured memory_bytes: 3652
s = input()

if s[len(s) - 1] == '2' or s[len(s) - 1] == '4' or s[len(s) - 1] == '5' or s[len(s) - 1] == '7' or s[len(s) - 1] == '9':
    print('hon')
elif s[len(s) - 1] == '0' or s[len(s) - 1] == '1' or s[len(s) - 1] == '6' or s[len(s) - 1] == '8':
    print('pon')
else:
    print('bon')

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

int main(void){
  int a,b,c,d; cin>>a>>b>>c>>d; 
  if(abs(a-c)<=d || (abs(a-b)<=d && abs(b-c)<=d)) puts("Yes"); 
  else puts("No");
  return 0;             
}


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

typedef pair<int, int> pii;
typedef long long ll;
typedef pair<ll, int> pli;
typedef vector<int> vi;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()

const ll MOD = 998244353;
const int MX = 300010;
ll inv[MX], fact[MX], ifact[MX];

void init(int MX)
{
    inv[1] = 1;
    for (int i = 2; i < MX; ++i) {
        inv[i] = inv[MOD % i] * (MOD - MOD / i) % MOD;
    }
    fact[0] = ifact[0] = 1;
    for (int i = 1; i < MX; ++i) {
        fact[i] = fact[i-1] * i % MOD;
        ifact[i] = ifact[i-1] * inv[i] % MOD;
    }
}

ll comb(int n, int r) {
    return fact[n] * ifact[r] % MOD * ifact[n - r] % MOD;
}

int N;
ll A, B, K;

int main() {
    init(MX);
    cin >> N >> A >> B >> K;
    ll ret = 0;
    for (int i = 0; i <= N; ++i) {
        ll za = (K - A * i);
        if (za < 0 || za % B != 0 || za / B > N) {
            continue;
        }
        ret = (ret + comb(N, i) * comb(N, za / B)) % MOD;
    }
    cout << ret << endl;

    return 0;
} 

Measured memory_bytes: 7296
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val a = listOf(0) + readLine()!!.split(" ").map { it.toInt() } + listOf(0)
    var total = 0
    for (i in 0 until n+1) total += Math.abs(a[i+1]-a[i])
    for (i in 1 until n+1) {
        var dif = Math.abs(a[i]-a[i-1]) + Math.abs(a[i+1]-a[i]) - Math.abs(a[i+1]-a[i-1])
        println(total-dif)
    }
}

Measured memory_bytes: 56564
#include <iostream>
#include <string.h>

using namespace std;

int main(void){
	char s[100100];
	int n,i,cnt=0;
	cin >> s;
	n = strlen(s);
	for(i=1; i<n; i++){
		if(s[i-1]!=s[i]){
			cnt++;
		}
	}
	cout << cnt << endl;
}

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <functional>
using namespace std;

typedef long long ll;

class max_flow { // Dinic O(E*V^2)
public:
	static const int MAX_V = 103;
	static const int INF = 2e9;
private:
	struct edge { int to, cap, rev; };
	vector<edge> edg[MAX_V];
	int level[MAX_V], iter[MAX_V];
public:
	void add_edge(int  from, int to, int cap) {
		edg[from].push_back({ to, cap, (int)edg[to].size() });
		edg[to].push_back({ from, 0, (int)edg[from].size() - 1 });
	}

	ll calc_max_flow(int s, int t) {
		ll flow = 0;
		while (true) {
			bfs(s);
			if (level[t] < 0) return flow;
			for (int i = 0; i < MAX_V; ++i) iter[i] = 0;
			int f;
			while ((f = dfs(s, t, INF)) > 0) {
				flow += (ll)f;
			}
		}
	}
private:
	void bfs(int s) {
		for (int i = 0; i < MAX_V; ++i) level[i] = -1;
		deque<int> que;
		level[s] = 0;
		que.push_back(s);
		while (!que.empty()) {
			int v = que.front(); que.pop_front();
			for (int i = 0; i < (int)edg[v].size(); ++i) {
				edge &e = edg[v][i];
				if (e.cap > 0 && level[e.to] < 0) {
					level[e.to] = level[v] + 1;
					que.push_back(e.to);
				}
			}
		}
	}

	int dfs(int v, int t, int f) {
		if (v == t) return f;
		for (int &i = iter[v]; i < (int)edg[v].size(); ++i) {
			edge &e = edg[v][i];
			if (e.cap <= 0 || level[v] >= level[e.to]) continue;
			int d = dfs(e.to, t, min(f, e.cap));
			if (d > 0) {
				e.cap -= d;
				edg[e.to][e.rev].cap += d;
				return d;
			}
		}
		return 0;
	}
};

int main() {
	int n; cin >> n;
	ll sum = 0;
	max_flow mf;
	for (int i = 1; i <= n; ++i) {
		int a; cin >> a;
		if (a > 0) sum += (ll)a;
		if (a > 0) mf.add_edge(i, n + 1, a);
		else mf.add_edge(0, i, -a);
	}
	for (int i = 1; i <= n; ++i) {
		for (int j = i + i; j <= n; j += i) {
			mf.add_edge(i, j, mf.INF);
		} 
	}
	cout << sum - mf.calc_max_flow(0, n + 1) << endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		double w = sc.nextDouble();
		double h = sc.nextDouble();
		double x = sc.nextDouble();
		double y = sc.nextDouble();
		double area = w * h / 2;
		int mult = 0;
		if(x * 2 == w && y * 2 == h) mult++;
		System.out.println(area + " " + mult);
	}
}


Measured memory_bytes: 23252
#include "bits/stdc++.h"

#define rep(i,n) for(int i = 0;i<n;i++)
#define cint(a) int a; cin >> a;
#define cstr(str) string str; cin >> str;


using namespace std;
using ll = long long;

const ll mod = 1e9 + 7;

int main(void) {
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	cint(n);
	n %= 1000;

	if (n == 0) cout << 0 << endl;
	else cout << 1000 - n    <<endl;











	return 0;
}


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

//降順
int s_dsort(const void *a, const void *b) {
  return *(int *)b - *(int *)a;
}

int main(void) {

	int  H;
	int  N,A[100000];
	int  i;

//入力
    scanf("%d %d",&H,&N);
    for(i=0;i<N;i++)
	    scanf("%d",&A[i]);

//降順に並べる
	qsort((void*)A,N,sizeof(int),s_dsort);

//やっつける！
	for(i=0;i<N;i++) {
		if(H<=0) break;
		H-=A[i];
	}
	if(H>0) printf("No\n");
	else    printf("Yes\n");
	return 0;
}




Measured memory_bytes: 892
#include <iostream>

using namespace std;

int main(){
  int h,w;
  cin >> h >> w;
  int r[h+1][w+1];
  int n; cin >> n;
  int a[n+1];
  int color=1;
  for(int i=1;i<=n;i++) cin >> a[i];
  for(int i=1;i<=h;i++){
    for(int j=1;j<=w;j++){
      if(i%2==1) r[i][j]=color;
      else r[i][w-j+1]=color;
      a[color]--;
      if(a[color]<=0){
        color++;
      }
    }
  }
  for(int i=1;i<=h;i++){
    for(int j=1;j<=w;j++){
      if(j==1) cout << r[i][j];
      else cout << " " << r[i][j];
    }
    cout << endl;
  }
}


Measured memory_bytes: 384
#!/usr/bin/env python3

import sys, math, copy
# import fractions, itertools
# import numpy as np
# import scipy

HUGE = 2147483647
HUGEL = 9223372036854775807
ABC = "abcdefghijklmnopqrstuvwxyz"

def fact(i):
    res = 1
    for j in range(1, i + 1):
        res *= j
    return res

def combi(n, i):
    assert 0 <= i <= n
    return fact(n) // (fact(i) * fact(n - i))

def main():
    n, p = map(int, input().split())
    ai = list(map(int, input().split()))
    assert len(ai) == n

    evens = 0
    odds = 0
    for a in ai:
        if a % 2 == 0:
            evens += 1
        else:
            odds += 1
    way_evens = 2 ** evens
    way_odds = 0
    for no in range(p, odds + 1, 2):
        way_odds += combi(odds, no)

    print(way_evens * way_odds)

main()


Measured memory_bytes: 3444
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e16;
const ll mod = 1000000007;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

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;
}
int ctoi(char c) {
  if (c >= '0' && c <= '9') {
    return c - '0';
  }
  return 0;
}
ll factorial(ll n) {
  if (n == 1) {
    return 1;
  }
  ll ans = factorial(n-1);
  return ans*n;
}
ll gcd(ll a, ll b) {
  if (b == 0) return a;
  return gcd(b, a%b);
}
ll lcm(ll a, ll b) {
  return (a/gcd(a, b))*b;
}
bool is_prime(ll n) {
  for (ll i = 2; i*i <= n; i++) {
    if (n%i == 0) return false;
  }
  return n != 1;
}
ll mod_pow(ll x, ll n, ll mod) {
  if (n == 0) return 1;
  ll res = mod_pow(x*x%mod, n/2, mod);
  if (n & 1) res = res * x % mod;
  return res;
}

int main() {
  ll n, m;
  cin >> n >> m;
  cout << n*(n-1)/2 + m*(m-1)/2 << endl;
}

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

const int N = 1e5 + 5 , INF = 2e9;

int n;
int h[N];
int mem[N];

int dp(int i){
    if(i == n)return 0;

    if(mem[i] != -1)return mem[i];
    int ans = INF;

    ans = min(ans , abs(h[i+1] - h[i]) + dp(i+1));
    if(i <= n-2){
        ans = min(ans , abs(h[i+2] - h[i]) + dp(i + 2));
    }

    return mem[i] = ans;
}

main(){
    scanf("%d" , &n);

    for(int i = 0 ; i < n ; i ++){
        scanf("%d" , &h[i]);
    }
    n --;
    memset(mem , -1 , sizeof mem);
    printf("%d\n" , dp(0));
}


Measured memory_bytes: 4096
var input: string = require('fs').readFileSync('/dev/stdin', 'utf8');
var inputLines: string[] = input.trim().split("\n");
var parts = inputLines[0].split(" ");

var X = parseInt(parts[0]);
var Y = parseInt(parts[1]);
var same: boolean = new Date(2018, X, 0).getDate() == new Date(2018, Y, 0).getDate();
console.log(same ? "Yes" : "No");

Measured memory_bytes: 7368
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPS(I, a, b) for (int i = (a); i < (b); ++i)
using namespace std;
using ll = long long;

int main() {
  int n,m,c,ans = 0;
  cin >> n >> m >> c;
  vector<int> b(m);
  REP(i,m) cin >> b[i];
  REP(i,n){
	vector<int> a(m);
    REP(i,m) cin >> a[i];
    int sum = 0;
    REP(i,m){
      sum += a[i] * b[i];
    }
    if(sum > -(c)) ans++;
  }
      
  cout << ans << endl;
}


Measured memory_bytes: 3628
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<string>
#include<utility>
#include<vector>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll MOD = 1000000007;
#define rep(i,n) for(int i=0;i<n;i++)
#define repl(i,s,e) for(int i=s;i<e;i++)
#define reple(i,s,e) for(int i=s;i<=e;i++)
#define revrep(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()

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


int H, W;


class Item
{
public:
	int x;
	int y;
	int depth;

	Item(int x, int y, int depth)
	{
		this->x = x;
		this->y = y;
		this->depth = depth;
	}
};


int main()
{
	//方針
	//少なくとも最短経路分の白マスは必要。
	//逆に最短経路を確保できれば、残りの白マスは黒く塗ることができるので
	//その時スコアが最大になる。
	cin >> H >> W;

	vector<string> s(H);
	rep(i, H) cin >> s[i];


	//白マスの個数をカウントアップ
	int c = 0;
	rep(i, H)
	{
		rep(j, W)
		{
			if (s[i][j] == '.') c++;
		}
	}


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

	queue<Item> q;
	q.emplace(0, 0, 0);
	s[0][0] = 'x';

	int depth = 0;

	//幅優先探索
	while (!q.empty())
	{
		auto p = q.front(); q.pop();

		if (p.x == H - 1 && p.y == W - 1)
		{
			depth = p.depth;
			break;
		}

		rep(i, 4)
		{
			int x = p.x + dx[i];
			int y = p.y + dy[i];

			if (!(x >= 0 && x < H)) continue;
			if (!(y >= 0 && y < W)) continue;
			if (s[x][y] != '.') continue;

			s[x][y] = 'x';
			q.emplace(x, y, p.depth + 1);
		}
	}

	if (depth == 0)
	{
		cout << -1 << endl;
	}
	else
	{
		//スタートとゴールを除く
		cout << (c - 2) - (depth - 1);
	}

	return 0;
}

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

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
#include <string>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cmath>
#include <climits>
#include <bitset>
#include <array>
#include <deque>
#include <queue>
#include <map>
#define all(x) (x).begin(),(x).end()

void solve(){

}
int main(){
    int sx,sy,tx,ty;
    cin >> sx >> sy >> tx >> ty;

    string ans;
    int dx = tx-sx,dy = ty-sy;
    for (int i = 0; i < dy; i++){
        ans += 'U';
    }

    for (int i = 0; i < dx; i++){
        ans += 'R';
    }

    for (int i = 0; i < dy; i++){
        ans += 'D';
    }

    for (int i = 0; i < dx; i++){
        ans += 'L';
    }

    ans += 'L';

    for (int i = 0; i < dy+1; i++){
        ans += 'U';
    }

    for (int i = 0; i < dx+1; i++){
        ans += 'R';
    }

    ans += 'D';
    ans += 'R';

    for (int i = 0; i < dy+1; i++){
        ans += 'D';
    }

    for (int i = 0; i < dx+1; i++){
        ans += 'L';
    }

    ans += 'U';
    cout << ans << endl;





    return 0;
}


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

int main() {
    int X;
    cin >> X;

   	X = X % 1000;
  	if(X != 0){
    	cout << 1000 - (X % 1000) << endl;
    }else{
      cout << 0 << endl;
    }
    return 0;
}

Measured memory_bytes: 3616
import java.io.*;
import java.util.StringTokenizer;

public class Main {

    public static class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        public FastScanner(String s) {
            try {
                br = new BufferedReader(new FileReader(s));
            } catch (FileNotFoundException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }

        public FastScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String nextToken() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(nextToken());
        }

        long nextLong() {
            return Long.parseLong(nextToken());
        }

        double nextDouble() {
            return Double.parseDouble(nextToken());
        }
    }

    public static void main(String[] args) {
        FastScanner fs = new FastScanner();
        int A = fs.nextInt();
        int B = fs.nextInt();
        int C = fs.nextInt();
        int K = fs.nextInt();

        int sum = 0;


        sum = Math.min(K, A);
        K -= Math.min(K, A);

        K -= Math.min(K, B);

        sum -= Math.min(K, C);

        System.out.println(sum);

    }
}


Measured memory_bytes: 32760
import java.lang.reflect.Array;
import java.net.Inet4Address;
import java.util.Arrays;
import java.util.OptionalInt;
import java.util.Scanner;
import java.util.ArrayList;
import java.util.Collections;
import java.util.stream.Collectors;
import java.util.HashSet;
import java.util.HashMap;

public class Main {

    static long gcd(long p, long q) { if(q == 0) return p; return gcd(q, p % q);}
    static Scanner sc = new Scanner(System.in);
    /////////

    static long N, K;
    static ArrayList<Long> A = new ArrayList<>();
    static ArrayList<Long> F = new ArrayList<>();

    static boolean check(long mid) {
        long needs = 0;

        for(int i = 0; i < N; i++) {
            if(A.get(i) * F.get(i) <= mid) continue;
            needs += (long)Math.ceil(A.get(i) - (double)mid / F.get(i));
        }

        if(needs <= K) return true;
        else return false;

    }

    static long parametric_search(long l, long r) {
        if(r < l) return Long.MAX_VALUE;
        long mid = l + (r - l) / 2;

        if(check(mid)) {
            return Math.min(mid, parametric_search(l, mid - 1));
        } else {
            return parametric_search(mid + 1, r);
        }
    }


    public static void main(String[] args) {
        N = sc.nextLong(); K = sc.nextLong();

        for(int i = 0; i < N; i++) {
            A.add(sc.nextLong());
        }

        for(int i = 0; i < N; i++) {
            F.add(sc.nextLong());
        }

        A = A.stream().sorted().collect(Collectors.toCollection(ArrayList::new));
        F = F.stream().sorted(Collections.reverseOrder()).collect(Collectors.toCollection(ArrayList::new));

        System.out.println(parametric_search(0, Long.MAX_VALUE));
        //System.out.println(parametric_search(12, 12));

    }
}
//[B@25618e91
//[B@326de728
//

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

int main(){
    int n ;
    cin >> n ;
    double ans = 0 ;
    if (n % 2 == 0)
    {
        ans = 1.0/2.0 ;
        cout << ans << endl ;
    }else
    {
        ans = (n/2+1.0)/n ;
        cout << ans <<endl ;
    }
    
    
}

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

using namespace std;
#define int long long
#define MOD 1000000007
#define maxn 500010
#define endl '\n'
const int E = -1e14;
int n;
vector<pair<pair<int, int>, int>> queries;
int ans[maxn];
int a[maxn], t[maxn];

void update(int idx, int val) {
    while (idx <= n) {
        t[idx] += val;
        idx += idx & -idx;
    }
}

int pre(int idx) {
    int ans = 0;

    while (idx > 0) {
        ans += t[idx];
        idx -= idx & -idx;
    }
    return ans;
}

int query(int l, int r) {
    return pre(r) - pre(l - 1);
}

bool comp(pair<pair<int, int>, int> a, pair<pair<int, int>, int> b) {
    return a.first.second < b.first.second;
}

void solve() {
    sort(queries.begin(), queries.end(), comp);
    map<int, int> last;

    int counter = 0;
    for (int i = 0; i < n; i++) {
        if (last.count(a[i])) {
            update(last[a[i]], -1);
        }
        last[a[i]] = i + 1;
        update(i + 1, 1);
        while (counter < queries.size() and queries[counter].first.second == i + 1) {
            ans[queries[counter].second] = query(queries[counter].first.first, i + 1);
            counter++;
        }
    }
}

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

    cin >> n;

    int q;
    cin >> q;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }

    for (int j = 0; j < q; ++j) {
        int u, v;
        cin >> u >> v;

        queries.push_back({{u, v}, j});
    }
    solve();

    for (int i = 0; i < queries.size(); i++)
        cout << ans[i] << endl;
}


Measured memory_bytes: 58564
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<cmath>
#include<string>
#include<bitset>
#include <sstream>
#include<queue>
#include<set>
#define rep(i,n) for(ll i=0;i<(n);++i)
using namespace std;
typedef long long ll;
typedef pair<int,ll>P;

const ll mod = 1e9+7;
const ll INF = ll(1e18)+1;
const ll MAXN = 1e6;

int main()
{
    ll n,k;
    cin>>n>>k;
    ll a[n];
    rep(i,n)cin>>a[i];
    sort(a,a+n);
    ll Ll=-INF;
    ll Lr=INF;
    while(Ll+1<Lr)
    {
        ll Lc=(Ll+Lr)/2;
        bool ok = [&]{
            ll total=0;
            rep(i,n)
            {
                if(a[i]<0)
                {
                    int l=-1,r=n;
                    while(l+1<r)
                    {
                        int c=(l+r)/2;
                        if(a[i]*a[c]<Lc)r=c;else l=c;
                    }
                    total+=n-r;

                }
                else
                {
                    int l=-1,r=n;
                    while(l+1<r)
                    {
                        int c=(l+r)/2;
                        if(a[i]*a[c]<Lc)l=c;else r=c;
                    }
                    total+=r;

                }
                if(a[i]*a[i]<Lc)total--;


            }
            total/=2;

            return total<k;
        }();
        if(ok)Ll=Lc;else Lr=Lc;

    }
    cout<<Ll<<endl;
    
}

Measured memory_bytes: 1792
/*My CSP has exploded*/
/*CF868F Yet Another Minimization Problem*/
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<stack>
#include<vector>
#include<queue>
using namespace std;

#define LL long long
#define DB double
#define MOD 59393
#define Pr pair<int,int>
#define X first
#define Y second
#define MAXN 5000
#define MAXM 200
#define MAXK 13
#define INF 10000000000000000
#define mem(x,p) memset(x,p,sizeof(x))

LL read(){
  LL x=0,F=1;char c=getchar();
  while(c<'0'||c>'9'){if(c=='-')F=-1;c=getchar();}
  while(c>='0'&&c<='9'){x=(x<<3)+(x<<1)+c-'0';c=getchar();}
  return x*F;
}
int n,m,a[MAXN+5],b[MAXM+5][MAXN+5];
int st[MAXM+5][MAXN+5][MAXK+5];
LL sum[MAXN+5],ans[MAXN+5],nlg[MAXN+5];

int getst(int d,int l,int r){
    int k=nlg[r-l+1];
    return max(st[d][l][k],st[d][r-(1<<k)+1][k]);
}
void solve(int l,int r,int pl,int pr){
    if(l>r)return ;
    int mid=l+r>>1,p=0;
    for(int i=pl;i<=min(mid,pr);i++){
        LL res=sum[i]-sum[mid];
        for(int j=1;j<=m;j++)
        res+=getst(j,i,mid);
        if(res>ans[mid])
        ans[mid]=res,p=i;
    }
    solve(l,mid-1,pl,p);
    solve(mid+1,r,p,pr);
}
int main(){
    n=read(),m=read();
    for(int i=2;i<=n;i++)
    sum[i]=sum[i-1]+(a[i]=read());
    for(int i=1;i<=n;i++)
        for(int j=1;j<=m;j++)
        b[j][i]=read();
    for(int i=2;i<=n;i++)
    nlg[i]=nlg[i>>1]+1;
    for(int i=1;i<=m;i++){
        for(int j=1;j<=n;j++)
        st[i][j][0]=b[i][j];
        for(int k=1;k<=MAXK;k++){
            int L=1<<k;
            for(int j=1;j+L<=n+1;j++)
            st[i][j][k]=max(st[i][j][k-1],st[i][j+(L>>1)][k-1]);
        }
    }
    solve(1,n,1,n);
    LL res=0;
    for(int i=1;i<=n;i++)
    res=max(res,ans[i]);
    printf("%lld",res);
}


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

int max(int a, int b){
  if(a > b) return a;
  else return b;
}

long long int min(long long int a, long long int b){
  if(a < b) return a;
  else return b;
}

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

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

int main(){

  int n,x;
  scanf("%d %d",&n,&x);

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

  city[n] = x;
  qsort(city, n+1, sizeof(int), sort);

  int difference[n];
  for(int i = 0; i < n; ++i){
    difference[i] = city[i+1] -city[i];
  }

  qsort(difference, n, sizeof(int), sort);

  int ans = difference[0];
  for(int i = 1; i < n; ++i){
    ans = gcd(ans,difference[i]);
  }

  printf("%d",ans);

  return 0;

}


Measured memory_bytes: 1396
#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 yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define MAX_N 1002
#define i197 1000000007

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P1;
typedef pair<int,int> Pi;
typedef pair<double,Pi> Pdi;
typedef pair<ll,int>Pli;
typedef pair<P1,ll> P2;
typedef pair<string,string> Ps;
const ll INF=1000000000000000001;
struct edge{int to,cost;};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
struct Road{double cost;int a,b;};
struct pos{
	// 1 変数を入れる;
	int x,y,sx,sy,cost;
};
int main() {

	ll k;
	ll n,h[200002];
	cin>>n>>k;
	ll t=0;
	rep(i,n){
		cin>>h[i];
		t+=h[i];
	}
	sort(h,h+n,greater<ll>());
	rep(i,k){
		t-=h[i];
	}
	ll r=0;
	cout<<max(t,r)<<endl;
	return 0;
}


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

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(), (x).end()

using namespace std;

template <typename T> T &chmin(T &a, const T &b) {return a = min(a, b);}
template <typename T> T &chmax(T &a, const T &b) {return a = max(a, b);}

using ll = long long;
using ld = long double;

const int INF = 1e9;
const ld eps = 1e-9, pi = acos(-1.0);

int main(){
  int n;
  cin >> n;
  int place[8];
  int fixed[8];
  REP(i, 8){ place[i] = i; fixed[i]=-1; }
  REP(i, n) {
    int tx, ty;
    cin >> tx >> ty;
    fixed[tx] = ty;
  }
  do {
    bool valid = true;
    REP(i, 8) if(fixed[i] != -1 && fixed[i] != place[i]) { valid = false; break; }
    REP(i, 8) REP(j, i) if(abs(place[i]-place[j]) == i-j) { valid = false; break; }
    if(valid) break;
  } while(next_permutation(place, place+8));
  REP(i, 8) {
    REP(j, 8) cout << (place[i]==j ? "Q" : ".");
    cout << endl;
  }
  return 0;
}


Measured memory_bytes: 3088
#include<iostream>
#include<stdio.h>
#include <vector>
#include <algorithm>
using namespace std;

int main(){
  const double PI=3.14159265358979323846;
  //整数の時はint
  int a,b,m;
  double c;
  //文字の時はstring
  //string a;
 
  cin>>a>>b;

  if(a<=b)
  cout<<"unsafe"<<endl;
  else
    cout<<"safe"<<endl; 

 
  return 0;
}

Measured memory_bytes: 3676
import Control.Monad
import Control.Applicative
import Data.List

main :: IO()
main = getLine >>= main' . map read . words
    where 
        main' [0, 0, 0, 0] = return ()
        main' as = do
            print $ solve as 0
            main

solve :: [Int] -> Int -> Int
solve [r0, w0, c, r] n = if div r0 w0 >= c
                             then n
                             else solve [r0+r, w0, c, r] n+1

Measured memory_bytes: 4796
#include <stdio.h>
#include <stdlib.h>

int n;
int a[100001] = {0};

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

int main(void){
    int i, j, s = 0;
    scanf("%d", &n);
    for ( i = 0; i < n; i++)
        scanf("%d", &a[i]);
    qsort(a, n, sizeof(int), cmp);
    i = 0; j = 1;
    while( 1 ){
        if(n <= j){
            if(n == j) s++;
            break;
        }
        if(a[i] == a[j]){
            i = j + 1;
            j = j + 2;
        } else {
            s++;
            i = j;
            j = j + 1;
        }
    }
    printf("%d\n", s);
    return 0;
}


Measured memory_bytes: 892
import numpy as np
N,K=map(int,input().split())
p=list(map(int,input().split()))
p=np.array(list(map(lambda x: (1+x)/2, p)))
mx_0 = np.sum(p[:K])
mx=0
#print(p)
if N!=K:
  for i in range(1,N-K+1):
    s = mx_0-p[i-1]+p[i+K-1]
    mx_0=s
    #print(s)
    mx = max(s,mx)
else:
  mx=np.sum(p)
  
print(mx)

Measured memory_bytes: 33856
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define int long long
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e18;

bool f[110][110];

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n, k;
    cin >> n >> k;
    int MAX = (n - 1) * (n - 2) / 2;
    if(k > MAX){
        cout << -1 << endl;
        return 0;
    }
    rep(i, 1, n){
        f[0][i] = true;
        f[i][0] = true;
    }
    rep(i, 1, n){
        rep(j, i + 1, n){
            if(k == MAX){
                i = n;
                break;
            }
            if(f[i][j]) continue;
            f[i][j] = true;
            f[j][i] = true;
            k++; 
        }
    }
    vector<P> ans;
    rep(i, 0, n){
        rep(j, i + 1, n){
            if(f[i][j]){
                ans.push_back({i, j});
            }
        }
    }
    cout << ans.size() << endl;
    for(int ii = 0; ii < ans.size(); ii++){
        cout << ans[ii].first + 1 << ' ' << ans[ii].second + 1 << endl;
    }
}

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

int main()
{
    char a[4],b[4],c[4];
    while(cin>>a[0])
    {
        for(int i=1;i<3;i++)
          {cin>>a[i];}
          cout<<a[0];
          for(int i=0;i<3;i++)
          {
              cin>>b[i];
          }
         cout<<b[1];
          for(int i=0;i<3;i++)
          cin>>c[i];
          // cout<<a[0];
          // cout<<b[1];
            cout<<c[2]<<endl;
    }return 0;
}


Measured memory_bytes: 256
//agc015_a.cpp
//Sat Nov  3 10:55:49 2018

#include <iostream>
#include <string>
#include <queue>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#define INTINF 2147483647
#define LLINF 9223372036854775807
using namespace std;
using ll=long long;
typedef pair<int,int> P;

int main(){
	ll n,a,b;
	cin >> n >> a >> b;

	ll mintotal = b+a*(n-1);
	ll maxtotal = a+b*(n-1);
	if (b<a || (n==1 && a!=b)){
		cout << 0 << endl;
	}else {
		cout << maxtotal-mintotal+1 << endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define INF 99999999999
#define rep(i,m,n) for(lli i = m;i < n;i++)
#define rrep(i,m,n) for(lli i=m-1;i>=n;i--)
#define pb(n) push_back(n)
#define UE(N) N.erase(unique(N.begin(),N.end()),N.end());
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(),n.end())
#define Out(S) cout << S << endl
#define NeOut(S) cout << S
#define HpOut(S) cout << setprecision(20) << S << endl
#define Vecpr(K,L1,L2,N) vector<pair<L1,L2>> K(N)
#define Vec(K,L,N,S) vector<L> K(N,S)
#define DV(K,L,N,M,R) vector<vector<L>> K(N, vector<L>(M,R))
#define pint pair<lli,lli>
#define Lower(v,X) lower_bound(v.begin(),v.end(),X)-v.begin();
#define mod 1000000007
#define MAX 5100000
#define ceili(x,y) (x+y-1)/y  
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
int main(){
  lli A,B,C,D,E,L,R,X,Y,W,H,N,M,K,sum=0,num=0,flag=0;string S,T;
  cin >> N >> M;
  if(abs(N-M)>1)Out(0);
  else{
    sum++;
    rep(i,2,N+1)sum=(sum%mod*i)%mod;
    rep(i,2,M+1)sum=(sum%mod*i)%mod;
    if(N==M)sum=(sum%mod*2)%mod;
    Out(sum);
  }
}
  

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<functional>
using namespace std;
int n, m, k, p, dist[6007][2017], c[3000]; bool u[3000];
vector<string>v; string a[3000], b[3000], s1, s2; vector<pair<int, int>>x[7000];
int s(string Y) { return lower_bound(v.begin(), v.end(), Y) - v.begin(); }
int main() {
	while (true) {
		cin >> m >> k >> p; p *= 10; if (m + k + p == 0)return 0; v.clear(); cin >> s1 >> s2;
		for (int i = 0; i < m; i++) { cin >> a[i] >> b[i] >> c[i]; v.push_back(a[i]); v.push_back(b[i]); }
		sort(v.begin(), v.end()); v.erase(unique(v.begin(), v.end()), v.end()); n = v.size();
		for (int i = 0; i < n; i++) { x[i].clear(); u[i] = false; for (int j = 0; j <= p; j++)dist[i][j] = 1e9; }
		for (int i = 0; i < m; i++) { int pos1 = s(a[i]), pos2 = s(b[i]); x[pos1].push_back(make_pair(pos2, c[i])); x[pos2].push_back(make_pair(pos1, c[i])); }
		priority_queue<tuple<short, short, short>, vector<tuple<short, short, short>>, greater<tuple<short, short, short>>>Q;
		for (int i = 0; i < k; i++) { string U; cin >> U; u[s(U)] = true; }
		
		Q.push(make_tuple(0, s(s1), p)); dist[s(s1)][p] = 0;
		while (!Q.empty()) {
			int a1 = get<0>(Q.top()), a2 = get<1>(Q.top()), a3 = get<2>(Q.top()); Q.pop();
			for (pair<int, int>i : x[a2]) {
				int cap = a3 - i.second; if (cap < 0)continue; if (u[i.first] == true)cap = p;
				if (dist[i.first][cap] > dist[a2][a3] + i.second) {
					dist[i.first][cap] = dist[a2][a3] + i.second; Q.push(make_tuple(dist[i.first][cap], i.first, cap));
				}
			}
		}
		int maxn = 1e9; for (int i = 0; i <= p; i++)maxn = min(maxn, (int)dist[s(s2)][i]); if (maxn > 1e8)maxn = -1;
		cout << maxn << endl;
	}
	return 0;
}

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

int main() {
	// your code goes here
	int n, arr[1000],cnt=0;
	cin>>n;
	for(int i=0;i<n;++i)
	cin>>arr[i];
	for(int i=1;i<n-1;++i)
	{
	    if((arr[i]<arr[i-1]&&arr[i]>arr[i+1])||(arr[i]>arr[i-1]&&arr[i]<arr[i+1]))
	    cnt++;
	}
	cout<<cnt;
	return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        
		// 1行、2つ(複数)数字
		String[] ss0 = br.readLine().trim().split(" ", 0);
		int W = Integer.parseInt(ss0[0]);
		int a = Integer.parseInt(ss0[1]);
		int b = Integer.parseInt(ss0[2]);


		if ((a<=b)&&(b<=a+W)) { System.out.println(0); return; }
		if ((a<=b+W)&&(b+W<=a+W)) { System.out.println(0); return; }
		if ((b<=a)&&(a<=b+W)) { System.out.println(0); return; }
		if ((b<=a+W)&&(a+W<=b+W)) { System.out.println(0); return; }

		int x = Math.abs( b-(a+W) );
		int y = Math.abs( a-(b+W) );
		
		x = (x < y) ? x : y;  //Max

        System.out.println(x);
        return;
    }
    //-----------------------------------------------------------------
    // Debug.Print
    static void dp(String s) {
		System.out.println(s);
	}
    static void dp(StringBuilder s) { dp(s.toString()); }
    static void dp(int i) { dp(String.valueOf(i)); }
    static void dp(long i) { dp(String.valueOf(i)); }


	//-----------------------------------------------------------------
	// 入力値確認
	static void checkInput(int[][] i2) {
		StringBuilder sb = new StringBuilder();
		for(int[] i1: i2){
			for(int i: i1) sb.append("[" + i + "]");
			sb.append(System.getProperty("line.separator"));
		}
		System.out.println(sb);
	}

}

Measured memory_bytes: 21076
#include <iostream>
#include <algorithm>
#include <complex>
#include <utility>
#include <vector>
#include <string>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#include <set>
#include <map>
#include <numeric>
#include <functional>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
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; }
inline void Yes(bool condition){ if(condition) PRINT("Yes"); else PRINT("No"); }
template<class itr> void cins(itr first,itr last){
    for (auto i = first;i != last;i++){
        cin >> (*i);
    }
}
template<class itr> void array_output(itr start,itr goal){
    string ans = "",k = " ";
    for (auto i = start;i != goal;i++) ans += to_string(*i)+k;
    if (!ans.empty()) ans.pop_back();
    PRINT(ans);
}
ll gcd(ll a, ll b) {
    return a ? gcd(b%a,a) : b;
}
const ll INF = 1e18;
const ll MOD = 1000000007;
typedef pair<ll,ll> P;
const ll MAX = 20000;
constexpr ll nx[8] = {1,0,-1,0,-1,-1,1,1};
constexpr ll ny[8] = {0,1,0,-1,-1,1,-1,1};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,c = 0;
    cin >> n;
    rep(i,1,n+1){
        if (i%3 == 0 || i%5 == 0) continue;
        else c += i;
    }
    PRINT(c);
}



Measured memory_bytes: 3652
from collections import defaultdict
from scipy.sparse.csgraph import floyd_warshall
H, W = map(int, input().split())
C = []
for i in range(10):
    ci = [int(cij) for cij in input().split()]
    C.append(ci)

A = defaultdict(int)
for i in range(H):
    for Aij in input().split():
        A[int(Aij)] += 1
if -1 in A:
    del A[-1]

D = floyd_warshall(C)
cost = 0
for k, v in A.items():
    cost += D[k][1] * v
print(int(cost))


Measured memory_bytes: 19124
#include<iostream>
#include<bits/stdc++.h>
#include<string>
using namespace std;
int main()
{
  int n ;
  cin >> n  ;
  vector<int> h(n) ;
  for(int i=0;i<n;i++){
    cin >> h[i] ;
  }
  int cnd = h[0] ;
  int cnt = 1 ;
  
  for(int i=1;i<n;i++){
    if(h[i]>=cnd){
      cnt++ ;
      cnd = h[i] ;
    }
  }

  cout << cnt << endl ;
  return 0 ;
}

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

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

  vector<char> ans;
  for(int i=0; i<s.size(); i++){
    if(s[i]=='0')ans.push_back('0');
    else if(s[i]=='1')ans.push_back('1');
    else if(ans.size()!=0)ans.pop_back();
  }

  for(int i=0; i<ans.size(); i++)cout<<ans.at(i);
}

Measured memory_bytes: 256
using System;
using static System.Console;
using static System.Math;
using System.IO;
using System.Collections.Generic;
namespace I_am_the_green_coder{
    class Inonoa{
        // なんか入力用の関数作ったけどまだテストしてないので使う前に確かめて
        static void Main(){
            long n = long.Parse(Console.ReadLine());
            long[] a = ILongs();
            long xor = a[0];
            for(int i=1;i<n;i++){
                xor ^= a[i];
            }
            Console.WriteLine(xor==0?"Yes":"No");
        }

        static readonly long MOD = 1000000007;

        ///<summary>a_1, a_2, a_3, ...みたいなの</summary>
        static long[] ILongs(){
            string[] s = ReadLine().Split();
            long[] re = new long[s.Length];
            for(long i=0;i<s.Length;i++){
                re[i] = long.Parse(s[i]);
            }
            return re;
        }

        ///<summary>xooxoxoxxoxo...みたいなの</summary>
        static char[] IChars(){
            return ReadLine().ToCharArray();
        }

        ///<summary>n m とかをちょっとはやくかくだけ</summary>
        static string[] IStrings(){
            return ReadLine().Split();
        }

        ///<summary>n行の入力を取ったり</summary>
        static long[][] ILongLongs(long n){
            long[][] re = new long[n][];
            for(long i=0;i<n;i++){
                string[] s = ReadLine().Split();
                re[i] = new long[s.Length];
                for(long j=0;j<s.Length;j++){
                    re[i][j] = long.Parse(s[j]);
                }
            }
            return re;
        }

        ///<summary>n行の文字列を取ったり</summary>
        static char[][] ICharsChars(long n){
            char[][] re = new char[n][];
            for(long i=0;i<n;i++){
                re[i] = ReadLine().ToCharArray();
            }
            return re;
        }
    }
}

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

int main(){
    int n, x, cnt;

    while (true) {
        cin >> n >> x;

        if (n == 0 && x == 0) {
            break;
        } else {
            cnt = 0;
            for (int i = 1; i <= n; i++) {
                for (int j = i + 1; j <= n; j++) {
                    for (int k = j + 1; k <= n; k++) {
                        if (i + k + j == x) {
                            cnt += 1;
                        }
                    }
                }
            }

            cout << cnt << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 3108
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		new Main().run();
	}

	void run() {
		Scanner sc = new Scanner(System.in);
		int H = sc.nextInt();
		int W = sc.nextInt();
		int[][] c = new int[10][10];
		for (int i = 0; i < 10; ++i) {
			for (int j = 0; j < 10; ++j) {
				c[i][j] = sc.nextInt();
			}
		}
		int[][] A = new int[H][W];
		for (int i = 0; i < H; ++i) {
			for (int j = 0; j < W; ++j) {
				A[i][j] = sc.nextInt();
			}
		}

		for (int i = 0; i < 10; ++i) {
			for (int j = 0; j < 10; ++j) {
				for (int k = 0; k < 10; ++k) {
					c[j][k] = Math.min(c[j][k], c[j][i] + c[i][k]);
				}
			}
		}

		long ans = 0;
		for (int i = 0; i < H; ++i) {
			for (int j = 0; j < W; ++j) {
				if (A[i][j] == -1)
					continue;
				ans += c[A[i][j]][1];
			}
		}
		System.out.println(ans);
	}

	void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}
}


Measured memory_bytes: 48708
#include <iostream> 
#include <vector>
#include <cmath>
#include <string>
#include <sstream>
#include <algorithm>
#include <queue>
#include <stack>
#include <unordered_set>
#include <set>
#include <unordered_map>
#include <map>
#include <iomanip>
#include <cctype>
#include <climits>

using namespace std;

using ii = pair<int, int>;
using vi = vector<int>;
using vii = vector<ii>;
using vvi = vector<vi>;

using ll = long long int;

#define mp(a,b) make_pair(a,b)

const int MOD = 1000 * 1000 * 1000 + 7;

bool res() {
	int n;
	cin >> n;
	if (!cin) return false;

	return true;
}

int main() {
	cin.tie(NULL);
	ios_base::sync_with_stdio(false);
	int n;
	cin >> n;

	string s;
	cin >> s;

	int r = 0, w = 0;

	for (int i = 0; i < n; ++i) {
		if (s[i] == 'R') ++r;
		else ++w;
	}

	int sol = 0;
	for (int i = 0; i < r; ++i) {
		if (s[i] == 'W') ++sol;
	}

	cout << sol << '\n';


	return 0;
}

Measured memory_bytes: 3764
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
int main() {
 int A,B,K,j=0;
  cin>>A>>B>>K;
  
  for(int i=max(A,B);i>=1;i--){
    if(A%i==0&&B%i==0){
      j++;
      if(j==K){
        cout<<i<<endl;
        break;
      }
    }
  }
}	


Measured memory_bytes: 256