akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<algorithm>
int main(void)
{
	int k,n,a[10000000],b[10000000],i,p=0,l;
	scanf("%d%d",&k,&n);
	for(i=0;i<n;i++){
		scanf("%d",&a[i]);
		if(i!=0){
			b[i]=a[i]-a[i-1];
		}
	}
  b[0]=k-a[n-1]+a[0];
	std::sort(b,b+n);
	for(i=0;i<n-1;i++){
		p+=b[i];
	}
	printf("%d\n",p);
	return 0;
}


Measured memory_bytes: 7040
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
using namespace std;
int frq[101];
int main()
{
	long long x, y, z;
	cin >> x >> y >> z;
	long long a = x - y;
	long long b = z - a;
	if (b > 0)
		cout << b << "\n";
	else
		cout << 0 << "\n";
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, n) for (ll i = 0; i < (ll)n; i++)
#define all(x) (x).begin(), (x).end()
#define unique(x) x.erase(unique(x.begin(), x.end()), x.end());
//

int main() {
  string S;
  cin >> S;
  vector<int> abc(26);
  for (int i = 0; i < S.size(); i++) {
    // cout << S[i] << S[i] - 'a' << endl;
    abc.at(S[i] - 'a') += 1;
  }

  for (int i = 0; i < 26; i++) {
    if (abc[i] == 0) {
      cout << (char)('a' + i) << endl;
      return 0;
    }
  }
  cout << "None" << endl;
}

Measured memory_bytes: 512
#include<cstdio>
#include<iostream>
#include<cstdlib>

int main(){
	int a,b,c;scanf("%d%d%d",&a,&b,&c);
    if(a+b>=c) puts("No"),exit(0);
	__int128 d=c-a-b;
	puts(d*d>__int128(4)*a*b?"Yes":"No");
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <algorithm>
#define mem(i,a) memset(i,a,sizeof(i))
#define PI acos(-1.0)
#define DMAX 100005
#define MOD 20190823
#define eps 1e-8
#define mp make_pair
#define INF 1000000000+9
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
template<class T> inline void read(T &f){
	f=0;
    T x=1;
    char ch=getchar();
    while(ch<48 || ch>57) {
        if(ch=='-') {
            x=-1;
        }
        ch=getchar();
    }
    while(ch<=57 && ch>=48) {
        f=f*10+ch-'0';
        ch=getchar();
    }
    f*=x;
}
int main(){
	ll r;
	read(r);
	cout<<r*r<<endl;
	return 0;
}

Measured memory_bytes: 888
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

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

    int x = A+B;
     
    if(x - C >= 0){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}



Measured memory_bytes: 3600
s=gets.chop.bytes.map{|b|b-97};n=gets.to_i;s.size.times{|i|n>=(m=(26-s[i])%26)&&n-=m-s[i]=0};s[-1]=(s[-1]+n)%26;puts s.map{|e|(e+97).chr}*''

Measured memory_bytes: 7788
import java.util.Scanner;

public class Main {

    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] w = new int[N];
        w[0] = sc.nextInt();
        for (int i = 1; i < N; i++) {
            w[i] = w[i-1]+sc.nextInt();
        }
        int min = Integer.MAX_VALUE;
        for (int i = 0; i < N; i++) {
            int front = w[i];
            int back = w[N-1]-w[i];
            min = Math.min(min, Math.abs(back-front));
        }
        System.out.println(min);
    }
}

Measured memory_bytes: 35844
// Starting with the name of Allah

#include <bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<string>
using namespace std;
int main()
{
	int a,b,c,k,j;
	cin>>a>>b>>c>>k;
	if(a>=k){
		cout<<k<<endl;
	}
	else if((a+b)>=k){
		cout<<a<<endl;
	}
	else{
		j=a - (k - (a + b));
		cout<<j<<endl;
	}
	return 0;
}


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

#define N 1000000
#define M 100

long int cnt;
int A[N];

void insertionSort(int n, int g){
  int i, j;
  int v;
  
  for(i=g; i<n; i++){
    v=A[i];
    for(j=i-g; 0<=j && A[j]>v; j-=g){
      A[j+g]=A[j];
      cnt++;
    }
    A[j+g]=v;
  }
}

void shellSort(int n){
  int G[M], g_num;

  for(int i=1, j=0; ;j++){
    G[j]=i;
    i=3*i+1;
    if(i>n){
      g_num=j+1;
      break;
    }
  }

  for(int i=0; i<g_num/2; i++) swap(G[i], G[g_num-1-i]);
  
  printf("%d\n", g_num);
  for(int i=0; i<g_num; i++){
    if(i) printf(" %d",G[i]);
    else  printf("%d", G[i]);
  }
  printf("\n");
  
  for(int i=0; i<g_num; i++){
    insertionSort(n, G[i]);
  }
}

int main(void){

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

  for(int i=0; i<n; i++) scanf("%d", A+i);  
  shellSort(n);

  printf("%d\n", cnt);
  for(int i=0; i<n; i++) printf("%d\n",A[i]);
  
  return 0;
}



Measured memory_bytes: 7104
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskC solver = new TaskC();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskC {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int N = in.nextInt();
            long curT = 1;
            long curA = 1;

            for (int i = 0; i < N; i++) {
                long T = in.nextLong();
                long A = in.nextLong();

                long F = Math.max(div(curT, T), div(curA, A));

                curA = A * F;
                curT = T * F;
            }

            out.println(curA + curT);
        }

        private long div(long A, long B) {
            return (A + B - 1) / B;
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}


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

int main()
{
    const static int64_t mod = 1000000007;
    int N;
    cin >> N;
    vector<int> A_vec(N);
    for (int i = 0; i < N; ++i)
        cin >> A_vec.at(i);
    vector<int> x_vec(N + 1, 0), y_vec(N + 1, 0), z_vec(N + 1, 0);
    for (int i = 0; i < N; ++i) {
        int A = A_vec.at(i);
        x_vec.at(i + 1) = x_vec.at(i);
        y_vec.at(i + 1) = y_vec.at(i);
        z_vec.at(i + 1) = z_vec.at(i);
        if (A == x_vec.at(i))
            ++x_vec.at(i + 1);
        else if (A == y_vec.at(i))
            ++y_vec.at(i + 1);
        else if (A == z_vec.at(i))
            ++z_vec.at(i + 1);
        else {
            cout << 0 << endl;
            return 0;
        }
    }
    int64_t cnt = 1;
    for (int i = 0; i < N; ++i) {
        int64_t tmp = 0;
        int A = A_vec.at(i);
        if (A == x_vec.at(i)) ++tmp;
        if (A == y_vec.at(i)) ++tmp;
        if (A == z_vec.at(i)) ++tmp;
        cnt = cnt * tmp % mod;
    }
    cout << cnt << endl;
}




Measured memory_bytes: 4828
#include <bits/stdc++.h>
#define re return
#define ll long long
#define ld long double
#define f first
#define s second
#define pi acos(-1)
#define oo (int)1e9
#define OO (ll)1e18
#define EPS 1e-7
#define FX(n) fixed<<setprecision(n)
#define mm(o,k) memset(o,k,sizeof o)
#define IO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
using namespace std;
const int maxn=105;

int main()
{
    IO;
    int n,cnt=0;
    cin >> n;
    vector<int> a(n+2,0);
    for(int i=1;i<=n;++i){
        cin >> a[i];
        cnt+=abs(a[i-1]-a[i]);
    }
    cnt+=abs(a[n]);
    for(int i=1;i<=n;++i)
        cout<<cnt-abs(a[i-1]-a[i])-abs(a[i]-a[i+1])+abs(a[i-1]-a[i+1])<<"\n";
    re 0;
}

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

typedef long long LL;
typedef long double ld;

#define debug printf("fuck %d\n", __LINE__);

inline LL read() {
	LL res = 0, bo = 1;
	char ch = getchar();
	while (ch < '0' || ch > '9') {
		if (ch == '-') bo = -1;
		ch = getchar();
	}
	while (ch >= '0' && ch <= '9') {
		res = (res << 1) + (res << 3) + ch - '0';
		ch = getchar();
	}
	return bo * res;
}

template <typename T>
void read(T &x) {
	x = read();
}

template <typename T, typename... Argv>
void read(T &a, Argv &... argv) {
	read(a);
	read(argv...);
}

const ld pi = 3.14159265358979323846;
const int N = 3005;
ld a[N], ansx, ansy;

int main() {
	int n = read(), L = read();
	for (int i = 1; i <= n; ++ i) std::cin >> a[i];
	for (int i = 1; i <= n; ++ i) {
		for (int j = i + 1; j <= n; ++ j) {
			int k = j - i - 1;
			ld tmp = pi * (a[i] + a[j]) / L;
			ansx += sin(tmp) * (n - 2 * k - 2), ansy += cos(tmp) *(n - 2 * k - 2);
		}
	}
	ansx /= 1.0 * n * (n - 1) * (n - 2) / 6;
	ansy /= 1.0 * n * (n - 1) * (n - 2) / 6;
	printf("%.12Lf %.12Lf\n", ansy, ansx);
	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <bitset>
#include <set>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define all(i,n) (i),(i+n)

int dx4[4]={1,0,-1,0};
int dy4[4]={0,-1,0,1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};

typedef pair<int, int> P;
typedef pair<string, int> SP;
typedef long long ll;

const int INF = 1e9;
const ll LLINF = 1e18;
const int MAX_V = 1e6+1;
const ll mod = 1000000007;

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

  cin >> n;

  int ma = -INF, mi = INF, mapos, mipos;
  bool m_f = false, p_f = false;
  REP(i, n) {
    int a;
    cin >> a;
    if(a > 0) p_f = true;
    if(a < 0) m_f = true;
    if(ma < a) {
      ma = a;
      mapos = i + 1;
    }
    if(mi > a) {
      mi = a;
      mipos = i + 1;
    }
  }

  if(m_f && p_f) {
    cout << (n - 1) + (n - 1) << endl;
    if(abs(ma) >= abs(mi)) {
      if(m_f && p_f) FOR(i, 1, n + 1) if(i != mapos) cout << mapos << " " << i << endl;
      FOR(i, 1, n) cout << i << " " << i + 1 << endl;
    } else {
      if(m_f && p_f) FOR(i, 1, n + 1) if(i != mipos) cout << mipos << " " << i << endl;
      for(int i=n; i>1; i--) cout << i  << " " << i - 1 << endl;
    }
  } else {
    cout << (n - 1) << endl;
    if(p_f) {
      FOR(i, 1, n) cout << i << " " << i + 1 << endl;
    } else {
      for(int i=n; i>1; i--) cout << i  << " " << i - 1 << endl;
    }
  }
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
    public static int gcd(int a,int b,int c){
        int smallest = Math.min(a,Math.min(b, c));
        for(int i = smallest;i > 0;i--){
            if(a%i == 0 && b%i == 0 && c%i == 0){
                return i;
            }
        }
        return -1;
    }
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int number = sc.nextInt();
        int total = 0;
        for(int i = 1;i < number+1;i++){
            for(int j = 1;j < number+1;j++){
                for(int k = 1;k < number+1;k++){
                    total += gcd(i,j,k);
                }
            }
        }
        System.out.println(total);
    }
}

Measured memory_bytes: 36200
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    ll n, m;
    cin >> n >> m;
    priority_queue<pair<ll, ll>> ab;
    rep(i, n) {
        ll a, b;
        cin >> a >> b;
        if (a > m) continue;
        ab.push(make_pair(m - a, b));
    }
    priority_queue<ll> pq;
    ll ans = 0;
    rrep(i, m) {
        while((sz(ab) > 0) && (ab.top().first == i)) {
            pq.push(ab.top().second);
            ab.pop();
        }
        if (!pq.empty()) {
            ans += pq.top();
            pq.pop();
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3696
N = int(input())
S = []
for _ in range(N):
    S.append(input())
    
print("AC x " + str(S.count("AC")))
print("WA x " + str(S.count("WA")))
print("TLE x " + str(S.count("TLE")))
print("RE x " + str(S.count("RE")))

Measured memory_bytes: 16252
#include<stdio.h>
#include<string.h>
#define LEN 100005

typedef struct pp{
	char name[100];
	int t;
}P;

P Q[LEN];
int head,tail,n;

void enqueue(P x){
	Q[tail]=x;
	tail=(tail+1)%LEN;
}

P dequeue(){
	P x=Q[head];
	head=(head+1)%LEN;
	return x;
}

int min(int a,int b){ return a<b ? a:b;}

int main(){
	int elaps=0,c;
	int i,q;
	P u;
	
	scanf("%d %d",&n,&q);
	
	for(i=1;i<=n;i++){
		scanf("%s",Q[i].name);
		scanf("%d",&Q[i].t);
	}
	head=1; tail=n+1;
	
	while(head!=tail){
		u=dequeue();
		c=min(q,u.t);
		u.t-=c;
		elaps+=c;
		if(u.t>0)enqueue(u);
		else{
			printf("%s %d\n",u.name,elaps);
		}
	}
	return 0;
}

Measured memory_bytes: 10752
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef tuple<ll, ll, ll> T;

int x;

int main(void){
    
    scanf("%d", &x);
    
    vector<int> v; v.push_back(0);
    int sum = 0;
    while(v.back() <= x){
        ++sum;
        v.push_back(v.back() + sum);
    }
    
    for(int i = 0; i < v.size(); ++i) if(x <= v[i]){ printf("%d\n", i); return 0; }
    
    return 0;
}

Measured memory_bytes: 640
import numpy as np

H, W, K = map(int, input().split())
c = np.array([sum([2 ** i if s == "#" else 0 for i, s in enumerate(input())]) for _ in range(H)])

ans = 0
for h in range(2 ** H):
  h_idx = np.array([bool(h & 2 ** i) for i in range(H)])
  for w in range(2 ** W):
    cnt = 0
    for a in c[h_idx]:
      cnt += bin(a & w).count("1")
    if cnt == K:
      ans += 1
      
print(ans)

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

def seconds_to_hms_format(seconds):
    m, s = divmod(int(seconds), 60)
    h, m = divmod(m, 60)
    return "%d:%d:%d" % (h, m, s)

def main():
    seconds = input()
    print(seconds_to_hms_format(seconds))

if __name__ == '__main__':
    main()

Measured memory_bytes: 7740
#include <iostream>
#include <cmath>

using namespace std;

int main()
{
    int N, count, ans = 0;

    cin >> N;

    for (int i = 1; i <= N; i+=2) {
        count = 1;
        for (int j = 1; j <= i/2; j++) {
            if (i % j == 0) {
                count++;
            }
        }
        if (count == 8) {
            ans++;
        }
    }
    
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define f(a,b) for( long long int i= a; i <= b; i++)
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define ll  long long
using namespace std;
int main()
{
    ll t,q,a,b,n;
    cin>>n;
a=n/1000;
if(n%1000)
{
    a+=1;
}
cout<<a*1000-n;
             return 0;
}
















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

int main() {
  int n;
  cin >> n;
  deque<int> d;
  int f, b;
  if (n%2) {
    cin >> f;
    d.push_front(f);
    --n;
  }
  rep(i,n/2) {
    cin >> b >> f;
    d.push_back(b);
    d.push_front(f);
  }
  while (!d.empty()) {
    cout << d.front();
    d.pop_front();
    if (d.empty()) cout << endl;
    else cout << " ";
  }
  return 0;
}


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

typedef long long llint;

int n, m;

//distは根元からの差分
int par[110000];
int dist[110000];

int root(int x) {
    if (x == par[x]) return x;
    int npar = root(par[x]);
    dist[x] += dist[par[x]];
    return par[x] = npar;
}

bool same(int x, int y) {
    return root(x) == root(y);
}

int rootDist(int x) {
    root(x);
    return dist[x];
}

int diff(int x, int y) {
    return rootDist(y) - rootDist(x);
}

void marge(int x, int y, int d) {
    d += rootDist(x) - rootDist(y);
    x = root(x);
    y = root(y);
    par[y] = x;
    dist[y] = d;
}

bool solve() {
    cin >> n >> m;
    for (int i = 1; i <= n; i++) {
        par[i] = i;
        dist[i] = 0;
    }
    
    while (m--) {
        int l, r, d;
        cin >> l >> r >> d;
        if (same(l, r)) {
            if (diff(l, r) != d) return false;
        } else {
            marge(l, r, d);
        }
    }

    return true;
}

int main() {
    if (solve()) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

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

using namespace std;

void hawawa()
{
	int d, n;
	int num = 1;
	cin >> d >> n;
	for(int i = 0; i < d; i++){
		num *= 100;
	}
	if (n < 100) {
		num *= n;
	}
	else {
		num *= n + 1;
	}
	cout << num << "\n";
}

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


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	in := bufio.NewReader(os.Stdin)
	var n, k int
	fmt.Fscan(in, &n, &k)
	A := append(make([]int, 0, n+1), 0)
	for i := 0; i < n; i++ {
		var p int
		fmt.Fscan(in, &p)
		A = append(A, A[i]+p)
	}
	var max int
	for i := 0; i <= n-k; i++ {
		sum := A[i+k] - A[i]
		if max < sum {
			max = sum
		}
	}
	fmt.Println((float64)(max + k) / 2)
}


Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
#define int long long
#define endl '\n'

int32_t main()
{
    string s;
    cin>>s;
    int sum=0;
    for(int i=0;i<s.length();i++)
    {
    	sum+=(s[i]-'0');
    	sum%=9;
    }
    if(sum==0)
    	cout<<"Yes";
    else
    	cout<<"No";
}   

Measured memory_bytes: 3716
#include <bits/stdc++.h>
using namespace std;
const int N = 109;

int h, w, n, m;
int c[N][N];

int main() {
    cin >> h >> w >> n;
    int x = 1, y = 1;
    for (int i = 1; i <= n; i++) {
        cin >> m;
        while (m--) {
            c[x][y] = i;
            if (y == w && x % 2 == 1) x++, y = w;
            else 
                if (y == 1 && x % 2 == 0) x++, y = 1;
                else y += ((x % 2 == 1) ? 1 : -1);
        }
    }
    for (int i = 1; i <= h; i++) {
        for (int j = 1; j <= w; j++) {
            cout << c[i][j] << ((j < w) ? " " : "\n");
        }
    }
    return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef pair<int,int> ii;
typedef tree<ii,null_type,less<ii>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int a,b; cin>>a>>b;
	if (b%a==0) cout<<(a+b);
	else cout<<(b-a)<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <queue>
#include <cmath>
using namespace std;

int main() {        
    string s;
    cin >> s;
    cout << count(s.begin(), s.end(), 'o') * 100 + 700 << endl;
}


Measured memory_bytes: 3648
#![allow(non_snake_case, unused)]
use std::cmp::*;
use std::collections::*;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

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

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

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

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

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

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

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

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

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

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

fn main() {
    input! {
        n: usize,
        d: [usize; n],
    }
    let d_sum = d.iter().sum::<usize>();
    let mut res = 0;
    for i in 0..n {
        res += d[i] * (d_sum - d[i])
    }
    println!("{}", res / 2);
}


Measured memory_bytes: 4352
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<bitset>
#include<vector>
#include<deque>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cmath>
#include<iomanip>
#include <functional>
using namespace std;
typedef long long ll;
const int mod = 1000000007;
const int INF = 1 << 28;
const double EPS = 1e-10;
//cout << fixed << std::setprecision(9)
//memset(a, 0, sizeof(a));
//--------------------------

vector<int> nums[10];
int N;

bool check(int n) 
{
	int a[10];
	memset(a, 0, sizeof a);

	while (n) {
		int dig = n % 10;
		n /= 10;
		if (dig == 3 || dig == 5 || dig == 7) {
			a[dig]++;
		}
		else {
			return false;
		}
	}

	if (a[3] * a[5] * a[7] == 0) {
		return false;
	}

	return true;
}

void find(int n)
{
	int dig = 0;
	while (n) {
		dig++;
		n /= 10;
	}

	nums[1].push_back(3);
	nums[1].push_back(5);
	nums[1].push_back(7);

	for (int i = 2;i <= dig;i++) {
		int len = nums[i-1].size();
		for (int j = 0;j < len;j++) {
			nums[i].push_back(10 * nums[i-1][j] + 3);
			nums[i].push_back(10 * nums[i-1][j] + 5);
			nums[i].push_back(10 * nums[i-1][j] + 7);
		}
	}

	int count = 0;
	for (int i = 0;i <=dig; i++) {
		for (int j = 0;j < nums[i].size();j++) {
			if (check(nums[i][j]) && nums[i][j] <= N) {
				count++;
			}
		}
	}

	cout << count << endl;
	return;
}

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

	return 0;
}


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




int main(){ 
      int n,m;
      cin >>n >>m;
      vector<int> l(m),r(m);
      int maxl=0,minr=1000000;
      for(int i=0;i<m;i++){
            cin>>l[i]>>r[i];
            if(l[i]>maxl) maxl = l[i];
            if(r[i]<minr) minr = r[i];
      }
      int ans = 0;
      if(minr-maxl>=0) ans = minr-maxl+1;
      cout << ans << endl;
}

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

int main(void) {
    int k,s, count = 0;
    scanf("%d%d", &k, &s);
    for(int x = 0; x <= k; x++) {
        for(int y = 0; y <= k; y++) {
            int z = s-x-y;
            if(z >= 0 && z <= k) {
                count++;
            }
        }
    }
    printf("%d\n", count);
    return 0;
}


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

Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>

using namespace std;

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = n;i >= m;i--)
#define REPO(i, n) for(int i = 1;i <= n;i++)
#define ll long long
#define INF 1999999999
#define MINF -1999999999
#define ALL(n) n.begin(),n.end()

int main() {
	int a;
	cin >> a;
	cout << a / 3 << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    double n;
    cin>>n;
    double a=n/3;
    int b=n/3;
    int c=n-2*b;
    if((a*a*a)>(b*b*c))
        cout<<fixed<<setprecision(8)<<a*a*a<<endl;
    else
        cout<<(b*b*c)<<endl;
}


Measured memory_bytes: 3720
n = gets.to_i
$a = [0] + gets.split.map(&:to_i)

$road = Array.new(n+1) {[]}
(n-1).times do
    u, v = gets.split.map(&:to_i)
    $road[u] << v
    $road[v] << u
end

$dp = Array.new(n+1, 10**10)
$ans = Array.new(n+1)

def dfs(i, pre)
    j = $dp.bsearch_index {|e| $a[i] <= e}
    x, $dp[j] = $dp[j], $a[i]
    $ans[i] = $dp.bsearch_index {|e| e >= 10**10}

    $road[i].each do |k|
        next if k == pre
        dfs(k, i)
    end

    $dp[j] = x
end

dfs(1, 0)
puts $ans[1..-1]

Measured memory_bytes: 260652
import java.util.Scanner;


public class Main {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        String str = sc.next();
        if(str.charAt(str.length()-1)=='3'){
            System.out.println("bon");
        }if(str.charAt(str.length()-1)=='0' ||  str.charAt(str.length()-1)=='1' ||  str.charAt(str.length()-1)=='6' || str.charAt(str.length()-1)=='8'){
            System.out.println("pon");
        }if(str.charAt(str.length()-1)=='2' || str.charAt(str.length()-1)=='4' || str.charAt(str.length()-1)=='5' || str.charAt(str.length()-1)=='7' || str.charAt(str.length()-1)=='9'){
            System.out.println("hon");
        }
    }
}



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

using namespace std;
typedef long long LL;
static const double EPS = 1e-9;

#define FOR(i,k,n) for (int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n) 
class Mem{
  public:
  int name;
  int point;
  
  bool operator <(const Mem& b) const
  {
    if(point>b.point) return true;
    if(point<b.point) return false;
    if(name<b.name) return true;
    return false;
  };
  
};
int main(void){ 
  int n;
  while(cin>>n){
    if(!n) break;
    Mem m[40];
    REP(i,n){
      cin>>m[i].name;
      int p[10][3]={0};
      REP(j,9){
        cin>>p[j][0];
        if(p[j][0]!=10)
          cin>>p[j][1];
      }
      cin>>p[9][0];
      cin>>p[9][1];
      if(p[9][0]+p[9][1]>=10) cin>>p[9][2];
      m[i].point = 0;
      REP(j,9){
        REP(k,2)
          m[i].point += p[j][k];
        if(p[j][0]==10){
          m[i].point += p[j+1][0];
          if(j!=8&&p[j+1][0]==10)
            m[i].point+=p[j+2][0];
          else
            m[i].point+=p[j+1][1];
        }
        else if(p[j][0]+p[j][1]==10){
          m[i].point+=p[j+1][0];
        }
      }
      m[i].point+=p[9][0]+p[9][1]+p[9][2];
    }
    sort(m,m+n);
    REP(i,n){
      cout << m[i].name << " " <<m[i].point << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 0
import std.stdio, std.string, std.conv, std.range, std.array, std.algorithm;
import std.uni, std.math, std.container, std.typecons, std.typetuple;
import core.bitop, std.datetime;

immutable int inf = 1<<20;

void main(){
    int N, M, a, b, c;
    readVars(N, M);

    auto cost = new int[][](N, N);

    foreach(i ; 0 .. N){
        foreach(j ; i + 1 .. N){
            cost[i][j] = inf;
            cost[j][i] = inf;
        }
    }

    foreach (i ; 0 .. M){
        readVars(a, b, c);
        cost[a - 1][b - 1] = c;
        cost[b - 1][a - 1] = c;
    }

    //writefln("%(%s\n%)", cost);

    auto dist = new int[][](N, N);

    foreach (i ; 0 .. N){
        foreach (j ; i + 1 .. N){
            dist[i][j] = cost[i][j];
            dist[j][i] = dist[i][j];
        }
    }

    //writefln("%(%s\n%)", dist);

    foreach(k ; 0 .. N){
        foreach(i ; 0 .. N){
            foreach(j ; i + 1 .. N){
                dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
                dist[j][i] = dist[i][j];
            }
        }
    }

    int ans;

    foreach(i ; 0 .. N){
        foreach(j ; i + 1 .. N){
            if(cost[i][j] < inf && dist[i][j] != cost[i][j]){
                ans++;
            }
        }
    }

    writeln(ans);
}

void readVars(T...)(auto ref T args){
    auto line = readln.split;
    foreach(ref arg ; args){
        arg = line.front.to!(typeof(arg));
        line.popFront;
    }
    if(!line.empty){
        throw new Exception("args num < input num");
    }
}

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

int main(void){
  int N, i;
  long long int t, ans=1, n, m, r;

  scanf("%d",&N);
  for(i=0;i<N;i++){
    scanf("%lld",&t);
    if(ans<t){ n=ans;  m=t;}
    else{ n=t;  m=ans;}
    while(n!=0){r=m%n;  m=n;  n=r;}
    ans = ans/m*t;
  }  
  printf("%lld\n",ans);
  return 0;
}


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

using ll = long long;
#define repi(n) for (int i = 0; i < n; i++)
#define repj(n) for (int j = 0; j < n; j++)
#define repk(n) for (int k = 0; j < n; k++)
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, a, b) for (auto i = a; i < b; i++)
#define repv(itr) for (auto&& v : itr)
const int dx[] = {-1, 0, 0, 1, -1, -1, 1, 1};
const int dy[] = {0, -1, 1, 0, -1, 1, -1, 1};
template <typename T>
T minptr(T begin, T end) {
  T re = begin;
  for (T i = begin + 1; i != end; i++) {
    if (*i < *re) re = i;
  }
  return re;
}
template <typename T>
T maxptr(T begin, T end) {
  T re = begin;
  for (T i = begin + 1; i != end; i++) {
    if (*i > *re) re = i;
  }
  return re;
}
int __vmax(int x) {
  return INT_MAX;
}
double __vmax(double x) {
  return 1e+300;
}
ll __vmax(ll x) {
  return LLONG_MAX;
}
int __vmin(int x) {
  return INT_MIN;
}
double __vmin(double x) {
  return -1e+300;
}
ll __vmin(ll x) {
  return LLONG_MIN;
}
template <typename T>
vector<T> lis(T begin, T end, bool allowequal = false, bool lds = false) {
  using V = typename iterator_traits<T>::value_type;
  int n = end - begin;
  vector<V> a(n, lds ? __vmin(*begin) : __vmax(*begin));
  vector<int> id(n);
  if (lds && allowequal) {
    for (int i = 0; i < n; i++) {
      id[i] = n - 1 -
              (lower_bound(a.rbegin(), a.rend(), begin[i]) - 1 - a.rbegin());
      a[id[i]] = begin[i];
    }
  } else if (lds) {
    for (int i = 0; i < n; i++) {
      id[i] = n - 1 -
              (upper_bound(a.rbegin(), a.rend(), begin[i]) - 1 - a.rbegin());
      a[id[i]] = begin[i];
    }
  } else if (allowequal) {
    for (int i = 0; i < n; i++) {
      id[i] = upper_bound(a.begin(), a.end(), begin[i]) - a.begin();
      a[id[i]] = begin[i];
    }
  } else {
    for (int i = 0; i < n; i++) {
      id[i] = lower_bound(a.begin(), a.end(), begin[i]) - a.begin();
      a[id[i]] = begin[i];
    }
  }
  int m = *maxptr(id.begin(), id.end());
  vector<T> re(m + 1);
  for (int i = n - 1; i >= 0; i--) {
    if (id[i] == m) re[m--] = begin + i;
  }
  return re;
}
template <typename T>
T gcd(T a, T b) {
  return b ? gcd(b, a % b) : a;
}

ll a[500];
ll minmv(int n, ll t) {
  vector<ll> v(n);
  repi(n) v[i] = (a[i] % t + t) % t;
  sort(v.begin(), v.end());
  if (v[n - 1] == 0) return 0;
  vector<ll> psum(n + 1), nsum(n + 1);
  psum[0] = 0;
  repi(n) psum[i + 1] = psum[i] + v[i];
  nsum[n] = 0;
  repi(n) nsum[n - i - 1] = nsum[n - i] + (t - v[n - i - 1]);
  // cout << t << endl;
  // repv(psum) cout << v << " ";
  // cout << endl;
  // repv(nsum) cout << v << " ";
  // cout << endl;
  repi(n + 1) if (psum[i] == nsum[i]) return psum[i];
  return LLONG_MAX;
}
int main() {
  int n;
  ll k;
  cin >> n >> k;
  repi(n) cin >> a[i];
  ll sum = 0;
  repi(n) sum += a[i];
  auto sqrtsum = floor(sqrt(sum));
  ll re = 1;
  for (ll i = 1; i <= sqrtsum; i++) {
    if (sum % i == 0) {
      if (sum / i > re && minmv(n, sum / i) <= k) re = sum / i;
      if (i > re && minmv(n, i) <= k) re = i;
    }
  }
  cout << re << endl;
}


Measured memory_bytes: 256
import java.util.*;

class Main{
	public static void main(String[] $){
		//入力
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		sc.close();

		//処理
		int ans = s.lastIndexOf('Z') - s.indexOf('A') + 1;

		//出力
		System.out.println(ans);
	}
}


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

#ifndef M_PI
#define M_PI 3.14159265358979
#endif
#define deg_to_rad(deg) (((deg) / 360) * 2 * M_PI)
#define rad_to_deg(rad) (((rad) / 2 / M_PI) * 360)

using namespace std;

typedef long long ll;
typedef vector<long long> vll;
typedef pair<long long, long long> pll;
typedef long double ld;

const ll INF = 1e15;
const ll MOD = 1e9 + 7;

int main() {
    ll i, j, k;
    ll N;
    cin >> N;
    ll ac = 0, wa = 0, tle = 0, re = 0;
    for(i = 0; i < N; i++) {
        string s;
        cin >> s;
        if(s == "AC")
            ac++;
        if(s == "WA")
            wa++;
        if(s == "TLE")
            tle++;
        if(s == "RE")
            re++;
    }
    cout << "AC x " << ac << endl;
    cout << "WA x " << wa << endl;
    cout << "TLE x " << tle << endl;
    cout << "RE x " << re << endl;

    return 0;
}


Measured memory_bytes: 3628
#include <iostream>

int main(int argc, char **argv)
{
    int N, A, B;
    std::cin >> N >> A >> B;

    if((A - B) % 2 == 0){
        std::cout << "Alice" << std::endl;
    }else{
        std::cout << "Borys" << std::endl;
    }
}


Measured memory_bytes: 256
N = int(input())
M = input().split(' ')
A = [int(x) for x in M]

M = int(1e9+7)

s = 0
for a in A:
    s += a

ans = 0
for a in A:
    ans += a * (s-a)

ans //= 2
print(int(ans % M))


Measured memory_bytes: 31440
use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).ok();
    let mut it = buf.split_whitespace();
    let n = it.next().unwrap().parse::<usize>().unwrap();
    let ng = if n%2 == 0 { n+1 } else { n };
    let mut res = Vec::new();
    for i in 1..n {
        for j in i+1..n+1 {
            if i+j == ng { continue }
            res.push((i, j));
        }
    }
    println!("{}", res.len());
    for &p in &res {
        println!("{} {}", p.0, p.1);
    }
}


Measured memory_bytes: 4352
#include <stdio.h>

int main()
{
  int a;
  scanf("%d",&a);
  int i;
  i = 0;
  int t;
  int sum;
  while (i < a)
  {
    t = i + 1;
    while (i < a && i < t * 10 - 1)
    {
      sum++;
      i++;
      //printf("i:%d sum:%d\n",i,sum);
    }
    //printf("%d\n",i);
    i  = (i + 1)*10;
    i -= 1;
  }
  printf("%d",sum);
}

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

int main() {
    int n, result = 0;
    cin >> n;
    array<int, 3> points[n + n];
    for (int i = 0; i < n; i++) {
        cin >> points[i][0] >> points[i][1];
        points[i][2] = 0;
    }
    for (int i = 0; i < n; i++) {
        cin >> points[i + n][0] >> points[i + n][1];
        points[i + n][2] = 1;
    }
    sort(points, points + n + n);
    set<int> red;
    for (int i = 0; i < n + n; i++) {
        if (points[i][2] == 1) {
            if (!red.empty()) {
                auto it = red.lower_bound(points[i][1]);
                if (it != begin(red)) {
                    red.erase(prev(it));
                    result++;
                }
            }
        } else {
            red.emplace(points[i][1]);
        }
    }
    cout << result;
    return 0;
}


Measured memory_bytes: 256
#pが素数の時、p未満の数の積xについてx^(p-1)=1(mod p) <=> x^(p-2)=1/x(mod p) (オイラの小定理)
#ここでpは素数なので、p以下の数a,b,nにおいてcmb(n,a)≡n!/((n-a)!*a!)≡((n-a+1)*…*n)/(a!)≡((n-a+1)*…*n)(a!)^(p-2) (mod p)
#あとは((n-a+1)*…*n)(a!)^(p-2) (mod p)を繰り返し2乗法でO(log(p))で求められる…らしいが普通にpow(n,r,mod)つよそう
#ちゃんと実装します



def modpow(a,n,mod):
    if n==0:
        return 1
    x=modpow(a,n//2,mod)
    x=(x*x)%mod
    if ((n%2)==1):
        x=(x*a)%mod
    return x%mod

def cmb(n,r,mod):
    x=1
    y=1
    for i in range(0,r,1):
        x=(x*(n-i))%mod
        y=(y*(i+1))%mod
    x=x%mod
    y2=modpow(y,mod-2,mod)
    return (x*y2)%mod

n,a,b=map(int,input().split())
p = 10 ** 9 + 7


#print(modpow(2,n,p),cmb(n,a,p),cmb(n,b,p))
print((modpow(2,n,p)-1-cmb(n,a,p)-cmb(n,b,p))%p)

Measured memory_bytes: 38512
#include<stdio.h>

int main()
{
	int h1, m1, h2, m2, k, ans;
	
	scanf("%d %d %d %d %d", &h1, &m1, &h2, &m2, &k);
	
	int sum1 = (h1 * 60) + m1;
	int sum2 = (h2 * 60) + m2;
	
	if(sum1 > sum2){
		ans = sum1 - sum2 - k;
	}else{
		ans = sum2 - sum1 - k;
	}
	printf("%d\n", ans);
}

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

int main(void) {
	int a, b, c,d;
	cin >> a >> b >> c>>d;
	if (a <= b) {
		cout << (a * c) << endl;
	}
	else {
		cout << (b * c) + ((a - b) * d) << endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define r1(i, n) for (int i=0;i<n;i++)
#define r2(i, n) for (int i=0;i<n;i+=2)
#define ll long long
#define llc(n) ll n; cin >> n;
using namespace std;
int main() {
  int n,m,x;
  cin >> n >> m;
  if(n%m==0) x=n/m;
  else x=n/m+1;
  cout << x << endl;
}

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

#include <map>

#include <algorithm>

using namespace std;

typedef pair<int, int> P;

int x, y, z, n, a, e;

int v[4];

P event[55];

 double dp[55][5050][2];

//double dp[55][5050];
int main() {

    while (scanf("%d%d%d",&x,&y,&z)) {

        if (!x&&!y&&!z) break;

        fill(event, event+55, P(0,0));

        memset(dp, 0, sizeof(dp));
        for (int i=0; i<x; i++) scanf("%d",&v[i]);

        for (int i=0; i<z; i++) {

            scanf("%d%d%d",&n,&a,&e);

            event[n]=P(a,e);
//            event[n]=P((a==1),a==3?-e:e);

        }
        dp[0][0][0]=1.0;
//        dp[0][0]=1.0;
        for (int i=0; i<y; i++) {
            if (event[i].first==1) {
                int next=min(y,i+event[i].second);
                for (int j=0; j<5050; j++) {
                    dp[next][j][1]+=dp[i][j][0];
                    for (int k=0; k<x; k++) {
                        int next2=min(y,i+v[k]);
                        dp[next2][j][0]+=dp[i][j][1]/x;
                    }
                }
            } else {
                for (int j=0; j<5050; j++) {
                    if (dp[i][j][0]==0.0&&dp[i][j][1]==0.0) continue;
                    for (int k=0; k<x; k++) {
                        int next=min(y,i+v[k]);
                        if (event[i].first==2) {
                            dp[next][j+event[i].second][0]+=dp[i][j][0]/x;
                            dp[next][j][0]+=dp[i][j][1]/x;
                        } else if (event[i].first==3) {
                            dp[next][max(0,j-event[i].second)][0]+=dp[i][j][0]/x;
                            dp[next][j][0]+=dp[i][j][1]/x;
                        } else {
                            dp[next][j][0]+=(dp[i][j][0]+dp[i][j][1])/x;
                        }
                    }
                }
            }
/*            for (int j=0; j<5050; j++) {
                if (dp[i][j]==0.0) continue;
                for (int k=0; k<x; k++) {
                    int nv=min(y,i+v[k]);
                    int np=j;
                    if (nv<y) {
                        if (event[nv].first) nv+=event[nv].second;
                        else np+=event[nv].second;
                    }
                    dp[min(y,nv)][max(0,np)]+=dp[i][j]/x;
                }
            }
*/        }
        double res=0.0;
        for (int k=0; k<5050; k++) res+=(dp[y][k][0]+dp[y][k][1])*k;
//        for (int k=0; k<5050; k++) res+=dp[y][k]*k;
//        printf("%.0f\n",res);
        printf("%d\n",(int)res);

    }

}

Measured memory_bytes: 5104
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, n) for(ll i=0; i<(ll)n; i++)
#define REPR(i, n) for(ll i=(ll)n-1; i>=0; i--)
#define FOR(i, m, n) for(ll i=(ll)m; i<(ll)n; i++)
#define FORR(i, m, n) for(ll i=(ll)m-1; i>=(ll)n; i--)
#define ALL(x) (x).begin(), (x).end()
#define ASC(v) sort(ALL(v));
#define DESC(v) sort(ALL(v), greater<int>());
#define UNIQ(a) sort(ALL(a));(a).resize(unique(ALL(a)) - a.begin());
#define PRINTD(x, d) cout << fixed << setprecision(d) << x << "\n";
#define DEBUG(x) cout<<#x<<": "<<x<<"\n"
const double PI = acos(-1);
ll lcm(ll a, ll b) { return a / __gcd(a, b) * b; }
bool isprime(int x){ int i; if(x<2)return 0; else if(x==2) return 1; if(x%2==0) return 0; for(i=3; i*i<=x; i+=2) if(x%i==0) return 0; return 1; }
int digsum(int n) { int r=0; while(n>0) { r+=n%10; n/=10; } return r; }
vector<string> split(string s, char p){vector<string>v;stringstream m(s);string b;while(getline(m,b,p))v.push_back(b);return v;}
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 (a>b) { a = b; return 1; } return 0; }
struct nya{ nya(){ cin.tie(0); ios::sync_with_stdio(false); } }nyan;

int main(){
    ll A, B, C, K; cin >> A >> B >> C >> K;
    REP(k, K) {
        if (A >= B) B *= 2;
        else if (B >= C) C *= 2;
        if (A < B && B < C) {
            cout << "Yes\n";
            return 0;
        }
    }
    cout << "No\n";
}


Measured memory_bytes: 3644
//int a = stoi(c); 文字列をintへ
//小文字から大文字
//transform(a.begin(), a.end(), a.begin(), ::toupper);
//数値計算 個数以外はdouble
//map 全探索
//auto begin = p.begin(), end = p.end();
//for (auto it = begin; it != end; it++) {}
//mapのキー：it->first mapのバリュー：it->second
//大文字判定 isupper(文字) 小文字判定 islower(文字)
//do{}while(next_permutation(ALL(配列)))
//小文字に対応する文字コード：S[i] - 'a'
//文字コード→小文字：(char)(数字+'a')
//グラフの距離:隣接行列で扱う
//bool型　初期値はTrue
//島渡りの問題：中間ノードに着目
//数が大きい時の比較はstring型で行う
//全て0になったか調べたい->0になるたびにcntする
//例外処理は最初にする
//x = p^m + q^n...の約数の個数:(n+1)*(m+1)....
//N!のどの素因数で何回割れるか
//⇔1~Nまでの数がそれぞれどの素因数で何回割り切れるかの和
//パズルの問題->一般化して全探索
//stack<ll> s;
//s.push(要素);s.top();s.pop();
//queue<ll> q;
//q.push(要素);q.front();q.pop();
//同じ作業繰り返す系の問題：収束先を見つける
//過半数：N/2.0で判定
//優先度付きキュー
//priority_queue<
//ll,
//vector<ll>
//> q;
#include <bits/stdc++.h>
#define rep(i,N) for(int i = 0; i < N;i++)
#define ALL(a) (a).begin(),(a).end()
#define ll long long int
#define PI 3.14159265358979323846264338327950L
using namespace std;


//割るやつ
const ll MOD = (pow(10, 9) + 7);

// K進数でのNの桁数
ll dig(ll N, ll K) {
	ll dig = 0;
	while (N) {
		dig++;
		N /= K;
	}
	return dig;
}
// a,bの最大公約数
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a%b);
}

//a,bの最小公倍数
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}

//階乗計算
ll f(ll n) {
	if (n == 0 || n == 1) return 1;
	else return (n * f(n - 1));
}

//Nのd桁目の数
ll dignum(ll N, ll d) {
	ll x = pow(10, d);
	N %= x;
	ll y = pow(10, d - 1);
	N /= y;
	return N;
}

//Nをdで何回割れるか
ll divcnt(ll N, ll d) {
	ll ans = 0;
	while (1) {
		if (N%d == 0) {
			ans++;
			N /= d;
		}
		else break;
	}

	return ans;
}

//素数判定
bool prime(ll num) {
	if (num < 2) return false;
	else if (num == 2) return true;
	else if (num % 2 == 0) return false;
	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2) {
		if (num % i == 0) return false;
	}
	return true;
}

//フィボナッチ数列
vector<ll> memo(pow(10, 6) + 1);
ll fibo(ll n) {
	if (n == 1) return 1;
	else if (n == 2) return 1;
	else if (memo[n] != 0) return memo[n];
	else return memo[n] = fibo(n - 1) + f(n - 2);
}

ll RS(ll N, ll P, ll M) {
	if (P == 0) return 1;
	if (P % 2 == 0) {
		ll t = RS(N, P / 2, M);
		return t * t % M;
	}
	return N * RS(N, P - 1, M);
}

int main() {
	ll N;cin >> N;
	vector<ll> L(N);rep(i,N)cin >> L[i];

	ll cnt = 0;
	for(int i = 0; i <= N - 3; i++){
		for(int j = i+1; j <= N -2; j++){
			for(int k = j + 1; k<=N-1;k++){
				if(L[i] != L[j] && L[j] != L[k] && L[i] != L[k]){
					if(max(L[i],max(L[j],L[k])) < L[i] + L[j] + L[k] - max(L[i],max(L[j],L[k]))){
						cnt++;
					}
				}
			}
		}
	}

	cout << cnt << endl;
}	

Measured memory_bytes: 11020
#include <bits/stdc++.h>
using namespace std;
int main()
{
    string a,b; cin >> a; b = a; int s = a.size();
    reverse(b.begin(),b.end());
    int cnt = 0;
    for(int i = 0; i < s ;i++)
    {
        if(a[i] != b[i])
        {
            cnt++;
        }
    }
   if(cnt == 0 ) cout << 0 << '\n';
   else cout << cnt / 2 << '\n';
}


Measured memory_bytes: 256