akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define int long long
#define ALL(obj) (obj).begin(), (obj).end()
#define fi first
#define se second
#define NIL -1
using ll = long long;
const ll MOD = 1000000007;
#define REP(i,n) for (ll i=0; i < (n); ++i)
#define FOR(i,a,b) for (ll i=(a); i < (b); ++i)
using namespace std;

int get_gcd(int a, int b) {
  while(1) {
    if (a < b) swap(a, b);
    if (b == 0) return a;
    a %= b;
  }
}
int get_lcm(int a, int b){return a * b / get_gcd(a, b);}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

signed main () {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

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

  int l, r, sum0, ans;
  l = r = sum0 = ans = 0;
  // 尺取り法
  while (1) {
    // [l, r]の中で0の部分列がk以下となる最大のrを求める
    while (r+1 < n) {
      if (s[r] == '1' && s[r+1] == '0' && sum0 == k) break;
      else if (s[r] == '0' && s[r+1] == '1') sum0++;
      r++;
    }

    if (r-l+1 > ans) ans = r-l+1;

    // lを次の区間に進める
    int prev_l = s[l];
    while(s[l] == prev_l) {
      l++;
      if (l == n) goto FINISH;
    }
    if(prev_l == '0') sum0--;
  }

FINISH:
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 512
#include<stdio.h>
int main(void)
{
	int a, b, c;
	scanf("%d", &a);
	scanf("%d", &b);
	scanf("%d", &c);

	if (a > b) {
		if (b < c&&a>=c) {
			printf("Yes\n");
		}
		else {
			printf("No\n");
		}
	}
	else if (a < b) {
		if (b > c&&a<=c) {
			printf("Yes\n");
		}
		else {
			printf("No\n");
		}
	}
	return 0;
}

Measured memory_bytes: 128
import java.util.Scanner

fun main(args: Array<String>) {
  val cin = Scanner(System.`in`)
  val s = cin.next()

  var res = 0

  for (i in s) {
    if (i == '+') {
      res++
    } else {
      res--
    }
  }

  println(res)
  cin.close()
}

Measured memory_bytes: 29580
#[allow(unused_imports)]
use std::cmp::{Ordering};

#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};

#[allow(unused_imports)]
use std::io::{stdin, stdout, BufWriter, Write};

#[allow(unused_imports)]
use std::iter::FromIterator;

#[allow(unused_macros)]
macro_rules! min {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        std::cmp::min($x, min!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! max {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        std::cmp::max($x, max!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! get { 
    ([$t: ty]) => { 
        { 
            let mut line = String::new(); 
            stdin().read_line(&mut line).unwrap(); 
            line.split_whitespace().map(|t|t.parse::<$t>().unwrap()).collect::<Vec<_>>()
        }
    };
    ([$t: ty];$n: expr) => {
        (0..$n).map(|_|get!([$t])).collect::<Vec<_>>()
    };
    ($t: ty) => {
        {
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t: ty),*) => {
        { 
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            ($(iter.next().unwrap().parse::<$t>().unwrap(),)*)
        }
    };
    ($t: ty; $n: expr) => {
        (0..$n).map(|_|get!($t)).collect::<Vec<_>>()
    };
    ($($t: ty),*; $n: expr) => {
        (0..$n).map(|_|get!($($t),*)).collect::<Vec<_>>()
    };
}

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

const BIG_STACK_SIZE: bool = true;

#[allow(dead_code)]
fn main() {
    use std::thread;
    if BIG_STACK_SIZE {
        thread::Builder::new()
            .stack_size(32 * 1024 * 1024)
            .name("solve".into())
            .spawn(solve)
            .unwrap()
            .join()
            .unwrap();
    } else {
        solve();
    }
}

fn gcd(a: usize, b: usize) -> usize {
    if a == usize::default() {
        b
    } else {
        gcd(b % a, a)
    }
}

fn solve() {
    let t = get!(usize);
    let abcd = get!([usize]; t).into_iter().map(|e| (e[0],e[1],e[2],e[3]));
    for (a,b,c,d) in abcd {
        if a < b || b > d {
            println!("No");
            continue;
        }
        if b <= c {
            println!("Yes");
            continue;
        }
        if c < a % b {
            println!("No");
            continue;
        }
        let g = gcd(b,d);
        if b-g+a%g > c {
            println!("No");
        } else {
            println!("Yes");
        }
    }
}


Measured memory_bytes: 8572
X = input()

S_start_index = 0
for i in range(int(len(X)/2)):
    if X[i] == "S":
        S_start_index = i
        break

T_stop_index = 0
#print(len(X)-1 > int(len(X)/2)-1)
for i in range(len(X)-1, int(len(X)/2)-1, -1):
#    print("i=", i)
    if X[i] == "T":
        T_stop_index = i + 1
        break


#print(S_start_index, T_stop_index)

count = 0
delate_count = 0
max_count = 0
for i in range(S_start_index ,T_stop_index):
    if X[i] == "S":
        count += 1
    else:
        if count == 0:
            pass
        else:
            count -= 1
            delate_count += 1


#print(delate_count)
output = len(X) - delate_count*2

print(output)

        

Measured memory_bytes: 3500
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<queue>
#include<vector>
#include<ctime>
#include<map>
#include<bitset>
#include<set>
#define LL long long
#define mp(x,y) make_pair(x,y)
#define pll pair<long long,long long>
#define pii pair<int,int>
using namespace std;
inline int read()
{
	int f=1,x=0;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
int stack[20];
template<typename T>inline void write(T x)
{
	if(x<0){putchar('-');x=-x;}
    if(!x){putchar('0');return;}
    int top=0;
    while(x)stack[++top]=x%10,x/=10;
    while(top)putchar(stack[top--]+'0');
}
template<typename T>inline void pr1(T x){write(x);putchar(' ');}
template<typename T>inline void pr2(T x){write(x);putchar('\n');}
const int MAXN=505;
int a[MAXN],b[MAXN],n,T;
int ans,sum;
void work(int k)
{
	int g=sum/k,t=0;
	for(int i=1;i<=n;i++)b[i]=a[i]%k,t+=a[i]/k;
	sort(b+1,b+1+n);g-=t;
	int s=0;
	for(int i=n;i>=1;i--)
	{
		if(g)s+=k-b[i],g--;
		else s+=b[i];
	}
	if(s<=2*T)ans=max(ans,k);
}
int main()
{
	n=read();T=read();
	for(int i=1;i<=n;i++)a[i]=read(),sum+=a[i];
	for(int i=1;1LL*i*i<=sum;i++)if(!(sum%i))
	{
		work(i);
		work(sum/i);
	}
	pr2(ans);
	return 0;
}


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

int main(){
    int n,x;    cin >> n >> x;
    vector<int> l(n+1),d(n+2);
    d[1] = 0;
    for(int i=1;i<=n;i++)  {
         cin >> l.at(i);
    }
    for(int i=2;i<=n+1;i++){
        d[i] = d[i-1] + l[i-1];
        if(d[i]<=x)cnt++;
        else break;
    }
    cout << cnt << endl;
    
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <math.h>
#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;
int main()
{
    vector<string> s1,s2;
    int n;
    cin >> n;
    for(int i = 0;i < n;i++)
    {
        string s;
        cin >> s;
        s1.push_back(s);
    }
    int m;
    cin >> m;
    for(int i = 0;i < m;i++)
    {
        string s;
        cin >> s;
        s2.push_back(s);
    }
    int ans = 0;
    for(int i = 0;i < n;i++)
    {
        int temp = count(s1.begin(),s1.end(),s1[i]) - count(s2.begin(),s2.end(),s1[i]);
        if(temp > ans)
        {
            ans = temp;
        }
    }
    cout << ans << "\n";

    return 0;
}

Measured memory_bytes: 256
n,k=map(int,input().split())


if n>k:
    large=(n-(k*(n//k-1)))-k
    small=k-(n-k*(n//k))
    #print(large,small)
    print(min(large,small))
elif n==k:
    print(0)
else:
    print(min(n,abs(n-k)))





Measured memory_bytes: 38256
#include<stdio.h>
#define MAX (1000000-1)

int tcomp[MAX+1];	// 各自然数を構成するために必要な正四面体数の数
int otcomp[MAX+1];	// 各自然数を構成するために必要な奇数の正四面体数の数

int min(int a,int b){
	return a<b?a:b;
}
int main(){
	int i,n,m;
	int in;
	for(i=0;i<=MAX;i++){
		tcomp[i]=otcomp[i]=MAX;
	}
	tcomp[0]=otcomp[0]=0;
	for(i=0;i<=MAX;i++){
		for(n=1;;n++){
			m = n*(n+1)*(n+2)/6;
			if(MAX < i+m)break;
			tcomp[i+m] = min(tcomp[i+m],tcomp[i]+1);
			if(m&1)
				otcomp[i+m] = min(otcomp[i+m],otcomp[i]+1);
		}
	}
	while(scanf("%d",&in)==1&&in){
		printf("%d %d\n",tcomp[in],otcomp[in]);
	}
}

Measured memory_bytes: 8412
n, m = gets.split(" ").map(&:to_i)
matrix = []
n.times do
  matrix << gets.split(" ").map(&:to_i)
end
vector = []
m.times do
  vector << gets.to_i
end
result = []
n.times do |i|
  item = matrix[i]
  temp = 0
  m.times do |j|
    temp += item[j] * vector[j]
  end
  result << temp
end
puts result


Measured memory_bytes: 6976
n = int(input())
a = list(map(int, input().split()))
a.insert(0, 0)
dp = [0] * (n+1)

# 前からその時の最大を更新していく

dp[0] = 1000
dp[1] = 1000
for start in range(1, n):
    for end in range(start+1, n+1):
        if a[end] - a[start] > 0:
            cnt = dp[start] // a[start]
            money = dp[start] + (a[end] - a[start]) * cnt
            dp[end] = max(dp[end], money)
        else:
            dp[end] = max(dp[end], dp[start])
print(dp[-1])

Measured memory_bytes: 67696
#include <bits/stdc++.h>
using namespace std;
#define int long long
int n, m, v, p, a[100010];
int tmp[100010];
inline bool check(int x)
{
	int cnt = 0;
	priority_queue <int> q;
	long long ret = (v - 1) * m;
	for (register int i = 1;i <= n;i ++)
	{
		tmp[i] = a[i];
	}
	tmp[x] += m;
	for (register int i = 1;i <= n;i ++)
	{
		if(i == x) continue;
		int num = tmp[x] - tmp[i];
		if(num < 0)
		{
			cnt ++;
			ret -= m;
			if(ret < 0) ret = 0;
		}
		else
		{
			if(num < m)
			{
				q.push(m - num);
				ret -= num;
			}
			else
			{
				ret -= m;
			}
			if(ret < 0)	ret = 0;
		}
	}
	while(!q.empty())
	{
		if(ret <= 0) break;
		cnt ++;
		int tp = q.top();
		q.pop();
		ret -= tp;
	}
	return cnt < p;
}

inline int find()
{
	int l = 1, r = n;
	while(r - l >= 3)
	{
		int mid = (l + r) >> 1;
		if(check(mid))
		{
			r = mid;
		}
		else
		{
			l = mid + 1;
		}
	}
	for (register int i = l;i <= r;i ++)
	{
		if(check(i)) return i;
	}
	return n + 1;
}

signed main() {
	scanf("%lld%lld%lld%lld", &n, &m, &v, &p);
	for (register int i = 1;i <= n;i ++)
	{
		scanf("%lld", &a[i]);
	}
	sort(a + 1, a + n + 1);
	printf("%lld\n", n - find() + 1);
	return 0;
}


Measured memory_bytes: 6688
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);++i)
#define sayyes cout<<"Yes"<<endl;
#define sayno cout<<"No"<<endl;
using namespace std;
typedef long long ll;
const double PI=acos(-1);
typedef pair<int,int>P;
const int mod =1e9+7;

int main()
{
    int n;
    cin>>n;
    vector<int> a(1e5+5,0);
    ll amount=0;
    rep(i,n)
    {
        int t;
        cin>>t;
        a[t]++;
        amount+=t;
    }

    int q;
    cin>>q;
    vector<P> bc(q);
    rep(i,q)
    {
        cin>>bc[i].first>>bc[i].second;
    }
    rep(i,q)
    {
        int dif=bc[i].second-bc[i].first;
        amount+=dif*a[bc[i].first];
        cout<<amount<<endl;
        a[bc[i].second]+=a[bc[i].first];
        a[bc[i].first]=0;
    }
}


Measured memory_bytes: 4532
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  short int N,sum=1;
  cin >> N;
  vector<short int> d(N);
  short int i;
  for(i=0;i<N;++i)
    cin >> d.at(i);
  sort(d.begin(), d.end());
  reverse(d.begin(), d.end());
  for(i=0;i<(N-1);++i){
    if(d.at(i)>d.at(i+1))
      ++sum;
  }
  cout << sum << endl;
}


Measured memory_bytes: 3616
using System;

class ITP1_5_C
{
    public static void Main()
    {
        while (true)
        {
            string[] Input = Console.ReadLine().Split(' ');
            int H = int.Parse(Input[0]);
            int W = int.Parse(Input[1]);

            if (H == 0 && W == 0)
                break;

            for (int i = 0; i < H; i++)
            {
                for (int j = 0; j < W; j++)
                {
                    if ((i + j) % 2 == 0)
                        Console.Write("#");
                    else
                        Console.Write(".");
                }
                Console.WriteLine();
            }
            Console.WriteLine();
        }
    }
}

Measured memory_bytes: 8848
#include <bits/stdc++.h>
#define ll long long
#define INIT(a, b) memset(a, b, sizeof(a))
using namespace std;
const int maxn = 100 + 7;

ll K, A, B;
ll ans;

int main()
{
    ios::sync_with_stdio(false);
    cin >> K >> A >> B;
    if (A >= B - 2 || K <= A)/*1.A==B+2时两种情况相等*/
    {                        /*2.K<=A时打开K次最优*/
        ans = K + 1;
    }
    else
    {
        K -= (A - 1);
        ans = A + (B - A) * (K / 2);
        if (K % 2 == 1)
            ans++;
    }
    cout << ans << endl;
    return 0;
}

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

int main(){
    int A,B,C,X,Y;
    cin >> A >> B >> C >> X >> Y;
    int res = 1<< 30; //求める最小値
    for(int c =0; c<= max(2*X, 2*Y); c++){
        int a = max(0, X - c/2);
        int b = max(0, Y - c/2);
        int price = A*a + B*b + C*c;
        if(price < res) res = price;
    }
    cout << res << endl;
}

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

int main() {
    int n, k;
    cin >> n >> k;
    int l[n];
    rep(i, n) cin >> l[i];
    sort(l, l + n, greater<int>());

    int ans = 0;
    rep(i, k) ans += l[i];

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


Measured memory_bytes: 3600
#include <bits/stdc++.h>
#define ll long long
#define inf 0x3f3f3f3f
#define PII pair<int,int>
#define ls x<<1
#define rs x<<1|1
#define fi first
#define se second
#define pb push_back
#define cwk freopen("D:\\c++\\in.txt","r",stdin),freopen("D:\\c++\\out.txt","w",stdout)
using namespace std;
const int N=1e6+10;
int a[N];
int dis[N];
int k,n;
int main()
{
	//cwk;
	scanf("%d%d",&k,&n);
	for(int i=0;i<n;i++) {
		scanf("%d",&a[i]);
	}
	ll ans=0;
	for(int i=0;i<n;i++) {
		if(i<n-1) dis[i]=(a[i+1]-a[i]);
		else dis[i]=k-a[i]+a[0];
	}
	sort(dis,dis+n);
	for(int i=0;i<n-1;i++) {
		ans+=dis[i];
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 5120
#include <bits/stdc++.h>
#define fi first
#define se second
#define REP(i, a, b) for (int i = (a); i <= (b); ++i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define FORD(i, a, b) for(int i = (a); i > (b); --i)
#define REPD(i, a, b) for(int i = (a); i >=(b); --i)
#define TR(it, a) for(__typeof(a.begin()) it = a.begin(); it != a.end(); ++it)
#define endl '\n'
#define mp make_pair
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define ins insert
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define unmap unordered_map
#define pq priority_queue
#define minEle min_element
#define maxEle max_element
#define lb lower_bound //first pos >= val
#define ub upper_bound // first pos > val
#define bp __builtin_popcount
#define debug(a) cout << a << endl
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair <ll, ll> pll;
typedef pair <int, int> pii;
typedef pair <pii, int> ppi;
typedef pair <int, pii> pip;
typedef pair <ll, ld> pld;
typedef pair <ll, pll> pllp;
typedef pair <pll, ll> ppll;
typedef vector <int> vi;
typedef vector <ll> vll;
typedef vector <pll> vpll;
typedef vector <pii> vpii;
typedef map <int, int> mii;
typedef map <ll, ll> mll;
typedef string BigNum;

const ll maxN = 1e18;
const ll minN = -1e18;
const ll MOD = 1e9 + 7;
const ll MOD1 = 998244353;
const int baseHash = 331;
const int bigNumLength = 5000;
const ld PI = acos(-1);

//Remember limit for IT, etc..., and +1 in limit of any array
const ll limit = 2e5 + 5;
const ll limit1 = 1e6 + 5;
const ll limit2 = 1e3 + 5;
//If TLE let's use int instead of ll because it's as slow as your WPM :)))

/*----IMPORTANT THINGS----*/
pii dir[] = {{0, 1}, {1, 0}, {0, -1}, {-1, 0}, {1, 1}, {1, -1}, {-1, 1}, {-1, -1}};
//right down left up rightdown leftdown rightup leftup
pii NON = {-1, -1};
/*------------------------*/

int n;
int a[limit];
ll sum[limit];
ll f[405][405];

ll cal(int l, int r) {
    if (r - l == 1) return f[l][r] = a[l] + a[r];
    if (r - l == 0) return f[l][r] = 0;
    if (f[l][r] != -1) return f[l][r];

    ll ans = maxN;
    REP(i, l, r - 1) {
        ans = min(ans, cal(l, i) + cal(i + 1, r) + sum[r] - sum[l - 1]);
    }

    return f[l][r] = ans;
}

void solveProblem() {
    REP(i, 1, n) {
        REP(j, i, n) f[i][j] = -1;
    }

    REP(i, 1, n) sum[i] = sum[i - 1] + a[i];

    cout << cal(1, n) << endl;
}

void fastInput() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}

void readInput() {
    cin >> n;
    REP(i, 1, n) cin >> a[i];
}

int main() {
    fastInput();
    readInput();
    solveProblem();
}



Measured memory_bytes: 4940
#include <cstdio>
#include <climits>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <string>
#include <cstdio>
#include <climits>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <utility>
#include <queue>
#include <cstring>
#include <set>
#include <map>
#include <complex>
#include <tuple>

#define rep(i, n) for (int i = 0; i < int(n); i++)
using namespace std;
long long MOD = 1000000007;
long long INF = 1000000000000000000; //10^18
typedef long long ll;
typedef unsigned long long ull;


ll powMod(ll x, ll n, ll mod) {
  if (n == 0) return 1;
  ll t = powMod(x, n/2, mod);
  t = t * t % mod;
  if (n & 1) return t * x % mod;
  return t;
}

ll gcd(ll a, ll b) {
  if (a == 0 || b == 0) return a + b;
  if (b > a) return gcd(b, a);
  return gcd(b, a % b);
}



int main(void) {

  int n, ans = 0;
  ll d, x, y;

  cin >> n >> d;
  rep(i, n) {
    cin >> x >> y;
    if (x*x + y*y <= d*d) ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3596
def start_process(length, num):

    print(ans)

def main():
    ans = 0
    data = [int(input()) for i in range(5)]
    min_data = 10
    for i in range(5):
        if 0 < data[i] % 10 < min_data:
            min_data = data[i] % 10

    for i in range(5):
        ans = ans + (data[i] // 10)
        if data[i] % 10 > 0:
            ans += 1
    #     print(ans)
    # print(min_data)
    print((ans - 1) * 10 + min_data)

def kari():
    a = list(map(int, input().split()))
    a, b = map(int, input().split())

if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
import heapq

N, M = map(int, input().split())
A = list(map(int, input().split()))
BC = sorted([list(map(int, input().split())) for i in range(M)], key=lambda x: x[1], reverse=True)

if N == 1:
    print(max(A[0], BC[0][1]))
    quit()

heapq.heapify(A)
for b, c in BC:
    a = A[0]
    if a >= c:
        continue
    else:
        curPopped = 0
        while curPopped < b:
            a = heapq.heappop(A)
            if a >= c:
                heapq.heappush(A, a)
                break
            curPopped += 1
        for i in range(curPopped):
            heapq.heappush(A, c)

print(sum(A))


Measured memory_bytes: 33784
#include <bits/stdc++.h>
using namespace std;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
#define VL vector<ll>
#define INF 100000000
typedef long long ll;

int main(){
    string S;
    cin>>S;
    sort(S.begin(),S.end());
    if(S=="abc")cout<<"Yes";
    else cout<<"No";
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb push_back 
 #define fo(i,n) for(int i=0;i<n;i++)
#define ll long long
#define Mod 1000000009 
#define MAX 4294967296  // 2^32
const int M=1e9+7;
    long long mod(long long x){
        return ((x%M + M)%M);
    }
    long long add(long long a, long long b){
        return mod(mod(a)+mod(b));
    }
    long long mul(long long a, long long b){
        return mod(mod(a)*mod(b));
    }
using namespace std;

long long gcd(int x,int y){
    if(y==0)return x;
    return gcd(y,x%y);
}


long long power(int x,int y){
if(y==0)return 1;
long long t=power(x,y/2);
if(y%2==1)return x*t*t;
return t*t;



}
double findMod(double a, double b) 
{ 
    double mod; 
    // Handling negative values 
    if (a < 0) 
        mod = -a; 
    else
        mod =  a; 
    if (b < 0) 
        b = -b; 
  
    // Finding mod by repeated subtraction 
      
    while (mod >= b) 
        mod = mod - b; 
  
    // Sign of result typically depends 
    // on sign of a. 
    if (a < 0) 
        return -mod; 
  
    return mod; 
} 

ll power(ll x, ll y, ll p)
{
    ll res = 1;      // Initialize result
 
    x = x % p;  // Update x if it is more than or
                // equal to p
 
    while (y > 0)
    {
        // If y is odd, multiply x with result
        if (y & 1)
            res = (res*x) % p;
 
        // y must be even now
        y = y>>1; // y = y/2
        x = (x*x) % p;
    }
    return res;
}
 
// Returns n^(-1) mod p
ll modInverse(ll n, ll p)
{
    return power(n, p-2, p);
}
ll ans=INT_MIN;
void dfs(vector<int>adj[],vector<int>&vis,int i,int &f){
    vis[i]=1;

    for(auto it=adj[i].begin();it!=adj[i].end();it++){
        if(!vis[*it]){
            f++;
            dfs(adj,vis,*it,f);
        }
    }
}

int main(){



    // std::string binary = std::bitset<8>(n).to_string();
    ios::sync_with_stdio(0);
    cin.tie(0);
    ll n,x,t;
cin>>n>>x>>t;
ll a=n/x;
if(n%x!=0)a++;
cout<<t*a<<endl;

}

Measured memory_bytes: 3652
#include <iostream>
#include <vector>
#include <tuple>

using namespace std;

int main()
{
	for(int n,q;cin>>n>>q,n|q;){
		vector<tuple<string,int,int>> ys;
		for(int i=0;i<n;i++){
			string name; int year,ad;
			cin>>name>>year>>ad;
			ys.emplace_back(name,ad-year+1,ad);
		}
		
		while(q--){
			int y; cin>>y;
			int i=-1;
			for(int j=0;j<n;j++)
				if(get<1>(ys[j])<=y && y<=get<2>(ys[j])){
					i=j;
					break;
				}
			if(i==-1)
				cout<<"Unknown"<<endl;
			else
				cout<<get<0>(ys[i])<<' '<<y-get<1>(ys[i])+1<<endl;
		}
	}
	
	return 0;
}

Measured memory_bytes: 1284
typedef long long ll;
#include <bits/stdc++.h>
using namespace std;
int facctorialMethod(int k){
    int sum = 1;
    for (int i = 1; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;
}
int main() {
    ll n;
    std::cin >> n;
    vector<ll> a(n);
    
    vector<ll> b(n);
    for (int i = 0; i < n; i++) {
        std::cin >> a[i];
        b[i] = a[i];
    }
    sort(b.begin(),b.end());
    ll maxc = 1;
    ll vvv = b[n-1];
    for (int i = n-2;i  >= 0; i--) {
        if(b[i]==vvv){
            maxc++;
        }
    }
    ll num = 0;
    for (int i = 0; i < min(n,(ll)3); i++) {
        if(b[i]==0)num++;
    }
    
    if(maxc>3){
        std::cout << 0 << std::endl;
        return 0;
    }
    
    ll cure = -1;
    
    ll ren = 0;
    for (int i = 0; i < n; i++) {
        if(cure != b[i]){
            cure = b[i];
            ren=1;
        }else{
            ren++;
            if(ren>3){
                std::cout << 0 << std::endl;
                return 0;
            }
        }
    }
    
    
    vector<ll> cnt(n+100,0);
    
    ll res = 1;
    for (int i = 0; i < n;  i++) {
        cnt[a[i]]++;
        if(a[i]>0){
            if(cnt[a[i]-1]>3){
                std::cout << 0 << std::endl;
                return 0;
            }
            res *= (cnt[a[i]-1]);
            cnt[a[i]-1]--;
            res %= 1000000007;
        }
    }
    // for (int i = 0; i < vvv; i++) {
    //     if(cnt[i]>0){
    //         std::cout << 0 << std::endl;
    //         return 0;
    //     }
    // }

    res *=  facctorialMethod(3)/facctorialMethod(3-num);
    res %= 1000000007;
    std::cout << res << std::endl;
}


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

int main() {
	int x,y;cin >>x >>y;
	set<int> a{1,3,5,7,8,10,12};
	set<int> b{4,6,9,11};
	if(a.find(x) != a.end() && a.find(y) != a.end() ) {
		cout << "Yes" << endl;
	} else if(b.find(x) != b.end() && b.find(y) != b.end() ) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))
def do(): 
    s,w=INTM()
    if s<=w:
        print('unsafe')
    else:
        print('safe')
if __name__ == '__main__':
    do()

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

int main() {
    int n, r;
    int diff = -1000000000;
    cin >> n;
    cin >> r;
    int minValue = r;
    for (int i = 1; i< n; i++) {
        cin >> r;
        diff = max(diff, r-minValue);
        minValue = min(minValue, r);
    }
    cout << diff << endl;
    return 0;
}


Measured memory_bytes: 3116
#include<iostream>
#include<algorithm>
#include<vector>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;

int main()
{
    int whole,key,be,af;
    cin >> whole;
    cin >> key;
    cin >> be;
    cin >> af;
    if(whole >= key)
    {
        cout << (key) * be + (whole - key) * af << endl;
    }
    else
    {
        cout << whole * be << endl;
    }
}

Measured memory_bytes: 256
fun main() {
    val n = readInt()
    var pairs = 0L
    var rem = 0
    repeat(n) {
        val a = readInt() + rem
        pairs += a/2
        rem = if (a % 2 == 1 && (a > 1 || rem == 0)) 1 else 0
//        println("$a $rem")
    }
    println(pairs)
}

// Input Reader
private fun readLn() = readLine()!!

private fun readInt() = readLn().toInt()

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

ll modpower(ll a, ll r, ll mod){ //a^r
    ll x = 1;
    a %= mod;
    while (r > 0) {
        if (r & 1) x = x * a % mod;
        r >>= 1;
        a = a * a % mod;
    }
    return x;
}

ll modinv(ll a, ll mod){
    return modpower(a, mod-2, mod);
}

int main() {
    ll mod = 1e9+7;
    ll N, K;
    cin >> N >> K;
    
    vector<ll> dp(K+1, 0);
    for (ll i = 1; i <= K; i++) dp[i] = modpower(K/i, N, mod);
    
    vector<bool> era(K+1, true);
    vector<int> moe(K+1, 1);
    for (ll i = 2; i <= K; i++) {
        if (!era[i]) continue;
        for (int j = i*2; j <= K; j += i) {
            era[j] = false;
        }
        for (int j = i; j <= K; j += i) {
            moe[j] *= -1;
        }
        for (ll j = i*i; j <= K; j += i*i) {
            moe[j] = 0;
        }
    }
    
    for (ll i = 1; i <= K; i++) {
        for (ll j = 2; j <= K/i; j++) {
            dp[i] += dp[j*i]*moe[j];
            dp[i] %= mod;
            if (dp[i] < 0) dp[i] += mod;
        }
    }
    
    ll ans = 0;
    for (ll i = 1; i <= K; i++) {
        ans += i * dp[i] % mod;
        ans %= mod;
        //cout << i << " " << moe[i] << endl;
    }
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 4584
import java.util.Scanner;
public class Main{
    public static void main(String args[]){
        Scanner scan=new Scanner(System.in);
        int N=scan.nextInt();
        int i;
        int ans=1;
        for(i=1;i<(int)Math.sqrt(N);i++){
        }
        ans=i*i;
        System.out.println(ans);

    }
}

Measured memory_bytes: 23124
arr = list(map(int, input().split()))


def canSpeak(a, b):
    return abs(a - b) <= arr[3]


if canSpeak(arr[0], arr[2]) or (canSpeak(arr[0], arr[1]) and canSpeak(arr[1], arr[2])):
    print("Yes")
else:
    print("No")


Measured memory_bytes: 2940
#include<bits/stdc++.h>
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int mod = 1000000007;
const int INF = 1001001001;

int main() {
  int k, a, b;
  cin >> k >> a >> b;
  // 最初にmin(a, k)枚分叩いておく
  ++k;
  ll ans = min(a, k);
  k -= a;
  ll diff = b - a;
  if (diff >= 2 && k >= 0) {
    ans += (diff) * (k / 2) + k % 2;
  } else {
    ans += max(0, k);
  }

  cout << ans << endl;
}

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

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cout.precision(12);
  cout << fixed;
  int n;
  double s = 0.0, o = 1.0;
  cin >> n;
  for(int i = 0; i < n; i++){
    int k;
    cin >> k;
    s += o / k;
  }
  cout << o / s;
  return 0;
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0;i < (n);i++)
using ll = long long;
const ll MOD=1000000007;
const long long INF = 1LL << 60;
const double pi=acos(-1.0);

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



int main() 
{
  ll N,M; cin>>N>>M;
  vector<string> A(N);
  vector<string> B(M);
  rep(i,N)
  {
    cin>>A.at(i);
  }
  rep(i,M)
  {
    cin>>B.at(i);
  }
  bool judge=false;
  rep(i,N-M+1)
  {
    rep(j,N-M+1)
    {
      rep(i2,M)
      {
        rep(j2,M)
        {
          if(A.at(i+i2).at(j+j2)!=B.at(i2).at(j2)) goto OUT;
        }
      }
      judge=true;
      OUT:;
    }
  }
  if(judge) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}


Measured memory_bytes: 3632
n = int(input())
h = [int(i) for i in input().split()]
ans = 0
a = 0
for i in range(n-1):
    if h[i] >= h[i+1]:
        a += 1
    else:
        ans = max(ans, a)
        a = 0
ans = max(ans, a)
print(ans)

Measured memory_bytes: 14252
#include <iostream>
using namespace std;
int main(void){
    int x ,y;
    while(true){
        cin >> x;
        cin >> y;
        if(x == 0 && y==0){
            break;
        }
        if(x < y){
            cout << x << " " << y << endl;
        }
        else{
            cout << y << " " << x << endl;
        }
    }
    
}



Measured memory_bytes: 3080
s=input()
l=len(s)
k=int(input())
z=''
for i in range(l):
  t=123-ord(s[i])
  if s[i]=='a':
    z+='a'
  elif t<=k:
    z+='a'
    k-=t
  else:
    z+=s[i]
v=ord(z[l-1])-97+k
z=z[:l-1]+chr(v%26+97)
print(z)

Measured memory_bytes: 3444
from collections import defaultdict

def getlist():
	return list(map(int, input().split()))

#処理内容
def main():
	N, A, B, C = getlist()
	ans = []
	Q = []
	cnt = 0
	for i in range(N):
		s = input()
		Q.append(s)

	#s1シミュレーﾄ
	if A + B + C == 1:
		for i in range(N):
			if Q[i] == "AB":
				if A == 1:
					ans.append("B")
					A -= 1; B += 1
				elif B == 1:
					ans.append("A")
					B -= 1; A += 1
				else:
					print("No")
					return
			elif Q[i] == "AC":
				if A == 1:
					ans.append("C")
					A -= 1; C += 1
				elif C == 1:
					ans.append("A")
					C -= 1; A += 1
				else:
					print("No")
					return
			else:
				if B == 1:
					ans.append("C")
					B -= 1; C += 1
				elif C == 1:
					ans.append("B")
					C -= 1; B += 1
				else:
					print("No")
					return
		print("Yes")
		for i in range(N):
			print(ans[i])
		return

	#初期化事故
	if Q[0] == "AB" and A == 0 and B == 0:
		print("No")
		return
	if Q[0] == "AC" and A == 0 and C == 0:
		print("No")
		return
	if Q[0] == "BC" and B == 0 and C == 0:
		print("No")
		return

	for i in range(N - 1):
		if Q[i] == "AB":
			if A == 1 and B == 0:
				ans.append("B")
				A -= 1; B += 1
			elif A == 0 and B == 1:
				ans.append("A")
				A += 1; B -= 1

			elif A >= 2:
				ans.append("B")
				A -= 1; B += 1
			elif B >= 2:
				ans.append("A")
				A += 1; B -= 1
			else:
				if Q[i + 1] == "AC":
					ans.append("A")
					A += 1; B -= 1
				else:
					ans.append("B")
					A -= 1; B += 1

		elif Q[i] == "AC":
			if A == 1 and C == 0:
				ans.append("C")
				A -= 1; C += 1
			elif A == 0 and C == 1:
				ans.append("A")
				A += 1; C -= 1

			elif A >= 2:
				ans.append("C")
				A -= 1; C += 1
			elif C >= 2:
				ans.append("A")
				A += 1; C -= 1
			else:
				if Q[i + 1] == "AB":
					ans.append("A")
					A += 1; C -= 1
				else:
					ans.append("C")
					A -= 1; C += 1

		else:
			if B == 1 and C == 0:
				ans.append("C")
				B -= 1; C += 1
			elif B == 0 and C == 1:
				ans.append("B")
				B += 1; C -= 1

			elif B >= 2:
				ans.append("C")
				B -= 1; C += 1
			elif C >= 2:
				ans.append("B")
				B += 1; C -= 1
			else:
				if Q[i + 1] == "AB":
					ans.append("B")
					B += 1; C -= 1
				else:
					ans.append("C")
					B -= 1; C += 1

	#最後
	if Q[N - 1] == "AB":
		if A >= 1:
			ans.append("B")
		else:
			ans.append("A")
	elif Q[N - 1] == "AC":
		if A >= 1:
			ans.append("C")
		else:
			ans.append("A")
	else:
		if B >= 1:
			ans.append("C")
		else:
			ans.append("B")

	print("Yes")
	for i in range(N):
		print(ans[i])


if __name__ == '__main__':
	main()

Measured memory_bytes: 85544
//
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define MODU 1000000007
// ll modpow (ll a, ll b, ll m){
//   if(b==0) return 1;
//   else{
//     ll z = modpow(a, b/2, m);
//     z = (z*z)%m;
//     if(b%2==0) return z;
//     else return (z*a)%m;
//   }
// }
// ll gcd(ll a, ll b){
//   if(b==0) return a;
//   else return gcd(b, a%b);
// }


int main(){
  ll n, x, y, t, ot(0), ox(0), oy(0), tempt(0);
  bool flag = true;
  cin >> n;
  while(n--){
    cin >> t >> x >> y;
    if(abs(t-ot)!=abs(x-ox)+abs(y-oy)){
      if(abs(t-ot)<abs(x-ox)+abs(y-oy)) {flag = false;}
      else{
        tempt = abs(t-ot)-(abs(x-ox)+abs(y-oy));
        if(tempt%2==1){
          flag = false;
        }
      }
    }
    // cout << flag << endl;
    ot = t; ox = x; oy = y;
  }
  cout << (flag?"Yes":"No");
  return 0;
}
// notes
//


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
using namespace std;
int main() {
	int N, P, mn = 1000000, ans = 0;
	scanf("%d", &N);
	for (int i = 0; i < N; ++i) {
		scanf("%d", &P);
		if (P < mn) ++ans, mn = P;
	}
	printf("%d", ans);
	return 0;
}

Measured memory_bytes: 128
def msb(x) # returns 0-32
	return 0 if x == 0
	x |= x>>1
	x |= x>>2
	x |= x>>4
	x |= x>>8
	x |= x>>16
	x += 1
	return [
		31,  0, 22,  1, 28, 23, 18,  2, 29, 26, 24, 10, 19,  7,  3, 12,
		30, 21, 27, 17, 25,  9,  6, 11, 20, 16,  8,  5, 15,  4, 14, 13
	][((x*0x076be629)&0xFFFFFFFF) >> 27] + 1
end

N, M = gets.split.map(&:to_i)
A = gets.split.map(&:to_i)

B = A.sort.reverse

MSB = [nil] * N
bottom = 0
ticket = 0
(0...N).each{|i|
	MSB[i] = msb(B[i])
	break if MSB[i] < bottom
	ticket += MSB[i] - bottom
	if M < ticket
		bottom += (ticket-M+i)/(i+1)
		ticket -= (ticket-M+i)/(i+1)*(i+1)
	end
}
C = B.map.with_index{|b, i|
	(MSB[i]||0) <= bottom ? b : b>>(MSB[i]-bottom)
}
(0...(MSB.index(nil)||N)).sort_by{|i| -C[i] }.take(M-ticket).each{|i|
	C[i] >>= 1
} if ticket < M

p C.inject(&:+)


Measured memory_bytes: 30600
#if 1
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>
#include <assert.h>
#include <bitset>
#include <list>
#include <cmath>

auto& in = std::cin;
auto& out = std::cout;
#define all_range(C) std::begin(C), std::end(C)
const double PI = 3.141592653589793238462643383279502884197169399375105820974944;

int32_t N;
int64_t A[300000];

int main()
{
    using std::endl;
    in.sync_with_stdio(false);
    out.sync_with_stdio(false);
    in.tie(nullptr);
    out.tie(nullptr);

	int64_t K;
    in >> N >> K;
    for (int i = 0; i < N; i++)
    {
        in >> A[i];
    }
    std::sort(A, A + N);

	using BS_INT = int64_t;
	BS_INT ok_range = 1100000000000000000 + 1, ng_range =  -1100000000000000000;
	while (std::abs(ok_range - ng_range) > 1) {
		BS_INT mid = (ok_range + ng_range) / 2;

		//ここに書く
		int64_t count = 0;
		for (size_t i = 0; i < N; i++)
		{
			if (A[i] >= 0) {
				count += std::upper_bound(A, A + N, mid, [i](auto& mid, auto& a) {return !(a * A[i] <= mid); }) - A;
			}
			else {
				count += A + N - std::lower_bound(A, A + N, mid, [i](auto& a, auto& mid) {return !(a * A[i] <= mid); });
			}
			if (A[i] * A[i] <= mid) {
				--count;
			}
		}
		count /= 2;

		if (count >= K) {
			ok_range = mid;
		}
		else {
			ng_range = mid;
		}
	}
	out << ok_range << endl;

    return 0;
}
#endif


Measured memory_bytes: 1792
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {

	public static void main(String[] args) throws Exception {
		// TODO 自動生成されたメソッド・スタブ
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		String W = in.readLine();
		int N = Integer.parseInt(W);

		W = in.readLine();
		String[] D = W.split(" ");

		int[] d = new int[D.length];
		for(int i=0;i<d.length;i++){
			d[i]=Integer.parseInt(D[i]);
		}
		Arrays.sort(d);

		int l = N/2 -1 ;
		int r = N/2;

		int ans = d[r] - d[l] ;

		if(ans <= 0){
			ans =0;
		}
		System.out.println(ans);

	}


}


Measured memory_bytes: 39048
import java.util.Scanner;

//6/9コンテスト

public class Main {
	public static void main(String[]args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		//List<Integer> list= new ArrayList<Integer>();
		int nokori=n-k;
		if(k==1) {
			System.out.println("0");
		}
		else{
			System.out.println(nokori);
		}




	}

}


Measured memory_bytes: 22228
#include <iostream>
#include <vector>
#include <cmath>

using namespace std;

int main(){
    int x;
    cin >> x;
    vector<bool> expo(x+1);

    expo[1] = 1;

    //オーバーフローを起こさないため
    for(int b = 2; b <= x; b++){
        int v = b*b;
        while(v<=x){
            expo[v] = 1;
            v *= b;
        }
    }
    for(int i = x; i >= 1; i--){
        if(expo[i]){
            cout << i << endl;
            return 0;
        }
    }

}


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


int main (){
    int m,n;
    cin >> n>> m;
    vector<int> a(m),b(m);
    int l,r;
    rep(i,m){
        cin >> a[i] >> b[i];
    }
    l = *max_element(a.begin(),a.end());
    r = *min_element(b.begin(),b.end());
    if(l <= r)cout << r-l+1<< endl;
    else cout << 0 << endl;
    return 0;

}

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

#define lp(i,n) for(int i=0;i<n;i++)
int main(){
  int a,b,c,d,e,f;
  cin>>a>>b>>c>>d>>e>>f;
  a+=b*5+c*10+d*50+e*100+f*500;
  if(a>=1000) cout<<1<<endl;
  else cout<<0<<endl;
  return 0;
}



Measured memory_bytes: 3100
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long ll;
#define chmin(a,b) a=min(a,b)
#define chmax(a,b) a=max(a,b)
#define rep(i,n) for(int i=0;i<n;i++)
#define mod 1000000007
#define mad(a,b) a=(a+b)%mod
#define N 5010
ll K,D[N];
void solve(){
	ll n,m,x;
	cin>>n>>x>>m; n--;
	ll d[N];
	rep(i,K)d[i]=D[i]%m;
	ll vl=x/m;
	ll dsum=0; rep(i,K)dsum+=d[i];
	ll pnt=x+dsum*(n/K);
	rep(i,n%K)pnt+=d[i];
	ll vr=pnt/m;
	//cout<<"#"<<vl<<" "<<vr<<" "<<pnt<<endl;
	//cout<<"D=";rep(i,K)cout<<d[i]<<" "; cout<<endl;
	ll ans=n-(vr-vl);
	rep(i,K)if(d[i]==0)ans-=(n/K+(i<n%K));
	cout<<ans<<endl;
}
int main(){
	ll Q;
	cin>>K>>Q;
	rep(i,K)cin>>D[i];
	while(Q--)solve();
}




Measured memory_bytes: 384
from statistics import median

n = int(input())
a = []
b = []
for i in range(n):
    A, B = map(int, input().split())
    a.append(A)
    b.append(B)

if n % 2 == 1:
    print(abs(median(b) - median(a)) + 1)
else:
    print(int(abs(median(b) - median(a)) * 2) + 1)

Measured memory_bytes: 28840
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1001001001LL;
constexpr long long LINF = 1001001001001001001;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define rept(i, j, n) for(int i=(j); i<(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 main(){
    int n; cin >> n;
    ll sum = 0;
    rept(i, 1, n+1){
        if(i%3!=0 && i%5!=0) sum += i;
    }
    cout << sum << ln;
}

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

int count = 0;

int divide_two(int num) {
    if (num % 2 == 0) {
        count += 1;
        return num / 2;
    } else {
        return num;
    }
}

int main() {
    int N, a;
    cin >> N;

    for (int i = 0; i < N; i++) {
        cin >> a;

         while(a % 2 == 0) {
            a = divide_two(a);
        }
    }
    cout << count << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,i,j,k,l,m;
    int a[100000];
    scanf("%d",&n);
    for(i=0;i<2*n;i++)
        scanf("%d",&a[i]);
    sort(a,a+(2*n));
    int total = 0;
    for(i=0;i<2*n;i+=2)
    {
        total+=a[i];
    }
    printf("%d\n",total);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define MAX 1e9
#define MOD 1e9+7
using namespace std;
void file()
{
//#ifndef ONLINE_JUDGE
    //freopen("input.txt", "r", stdin);
    //	freopen("output.txt", "w", stdout);
//#endif  !ONLINEJUDGE
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}
int n,b;
vector<pair<ll,ll> >v;
ll dp[105][100005];
ll solve(ll i,ll rem){
    if(i==n)return 0;
    ll &ret=dp[i][rem];
    if(~ret)return ret;
    ret=max(ret,solve(i+1,rem));
    if(v[i].first<=rem)ret=max(ret,solve(i+1,rem-v[i].first)+v[i].second);
    return ret;
}
int main()
{
    cin>>n>>b;
    v.resize(n);
    memset(dp,-1,sizeof(dp));
    for(int i=0;i<n;++i)cin>>v[i].first>>v[i].second;
    cout<<solve(0,b)<<endl;
    return 0;
}


Measured memory_bytes: 82304
/*input
10000000
*/

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

int main() {
    int n;
    cin >> n;
    ll ans = 0;
    for (int i = 1; i <= n; i++) {
        int a = n/i;
        ans += (ll)i*a*(a+1)/2;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
#define ll long long
using namespace std;
string s;
int cnt=0;
int main() {
	cin>>s;
	for(int i=0;i<s.size();i++) {
		cnt+=s[i]-'0';
		cnt%=9;
	}
	if(cnt==0) printf("Yes");
	else printf("No");
	return 0;
}

Measured memory_bytes: 3928
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const ll MOD=1000000007;


char Game(queue<char> x,queue<char> y,queue<char> z,char c){
  if(c=='a'){
    if(x.empty()){
      return c;
    }
    else{
      c=x.front();
      x.pop();
      return Game(x,y,z,c);
    }
  }
  if(c=='b'){
    if(y.empty()){
      return c;
    }
    else{
      c=y.front();
      y.pop();
      return Game(x,y,z,c);
    }
  }
  if(c=='c'){
    if(z.empty()){
      return c;
    }
    else{
      c=z.front();
      z.pop();
      return Game(x,y,z,c);
    }
  }
}

int main() {
  string a,b,c;
  cin>>a>>b>>c;
  queue<char> A,B,C;
  for(int i=0;i<a.size();i++){
    A.push(a[i]);
  }
  for(int i=0;i<b.size();i++){
    B.push(b[i]);
  }
  for(int i=0;i<c.size();i++){
    C.push(c[i]);
  }
  cout<<(char)(Game(A,B,C,'a')+('A'-'a'));
  
}

Measured memory_bytes: 896
<?php
$n=trim(fgets(STDIN));
$ans=array_fill(1,$n,0);
$x=1;
while($x<100){
  $y=1;
  while($y<100){
    $z=1;
    while($z<100){
      $p=$x*$x+$y*$y+$z*$z+$x*$y+$y*$z+$z*$x;
      if($p<=$n){
        ++$ans[$p];
      }else{
        $z=100;
      }
      ++$z;
    }
    ++$y;
  }
  ++$x;
}
echo join("\n",$ans);

Measured memory_bytes: 16532
<?php

$N = intval(trim(fgets(STDIN)));
$A = new SplDoublyLinkedList();
for($i=0;$i<$N;$i++) {
  $arr = explode(' ', trim(fgets(STDIN)));
  $c = $arr[0];
  $v = count($arr) > 1 ? $arr[1] : '';
  switch ($c) {
    case 'insert':
      $A->unshift($v);
      break;
    case 'delete':
      $index = 0;
      for($A->rewind();$A->valid();$A->next()){
        if($A->current() == $v) {
          $A->offsetUnset($index);
          break;
        }
        $index++;
      }
      break;
    case 'deleteFirst':
      $A->shift();
      break;
    case 'deleteLast':
      $A->pop();
      break;
    default:
      # code...
      break;
  }
}

$need = false;
for($A->rewind();$A->valid();$A->next()){
    if ($need) {
        echo " ";
    } else {
        $need = true;
    }
    echo $A->current();
}

?>



Measured memory_bytes: 136116
#include <iostream>

using namespace std;

int main()
{
    long long n,W;
    cin >> n >> W;
    long long w[n+1];
    long long v[n+1];
    for(long long i=1;i<=n;i++)
    {
        cin >> w[i] >> v[i];
    }
    long long f[W+1][n+1];
    for(long long i=0;i<=n;i++)
    {
        f[0][i]=0;
    }
    for(long long i=0;i<=W;i++)
    {
        f[i][0]=0;
    }
    for(long long i=1;i<=W;i++)
    {
        for(long long j=1;j<=n;j++)
        {
            f[i][j]=f[i][j-1];
            if(i-w[j]>=0)f[i][j]=max(f[i][j],f[i-w[j]][j-1]+v[j]);
        }
    }
    cout << f[W][n];
    return 0;
}


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

using namespace std;

int main()

{
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

    int a, b;

    cin >> a >> b;

    if (a >= 13) cout << b;
    else if (a <= 12 && a >= 6) cout << b/2;
    else cout << "0";

    return 0;
}


Measured memory_bytes: 256
import bisect

A,B,Q=map(int,input().split())
slist = []
for i in range(A):
  slist.append(int(input()))
#print(slist)

tlist = []
for i in range(B):
  tlist.append(int(input()))
#print(tlist)

for i in range(Q):
  x = int(input())
  min_dist = 10**11
  
  # x->s->t
  if x < slist[0]:
    si = [0]
  elif slist[-1] < x:
    si = [len(slist)-1]
  else:
    sl = bisect.bisect(slist,x)
    si = [sl-1,sl]
    
  for index in si:
    s = slist[index]
    dist = abs(x-s)

    if s < tlist[0]:
      dist += tlist[0]-s
    elif tlist[-1] < s:
      dist += s-tlist[-1]
    else:
      tl = bisect.bisect(tlist,s)  
      dist += min(s-tlist[tl-1],tlist[tl]-s)
    
    if dist < min_dist:
      min_dist = dist

  # x->t->s
  if x < tlist[0]:
    ti = [0]
  elif tlist[-1] < x:
    ti = [len(tlist)-1]
  else:
    tl = bisect.bisect(tlist,x)
    ti = [tl-1,tl]
    
  for index in ti:
    t = tlist[index]
    dist = abs(x-t)

    if t < slist[0]:
      dist += slist[0]-t
    elif slist[-1] < t:
      dist += t-slist[-1]
    else:
      sl = bisect.bisect(slist,t)
      dist += min(t-slist[sl-1],slist[sl]-t)
    
    if dist < min_dist:
      min_dist = dist

  print(min_dist)


Measured memory_bytes: 12080