akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
using namespace std;

int main(){

  bool pn[246913]={};
  for(int i=2;i<=123456;i++){
    for(int j=2;i*j<=246912;j++){
      pn[i*j]=true;
    }
  }

  int n;
  while(cin>>n, n){
    int cnt=0;
    for(int i=n+1;i<=2*n;i++){
      if(pn[i]==false) cnt++;
    }

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

Measured memory_bytes: 3280
#include <bits/stdc++.h>
typedef long long ll;
int main(int argc, char const *argv[]) {
    ll N, M, X, Y;
    std::cin >> N >> M >> X >> Y;
    std::vector<ll> x;
    std::vector<ll> y;
    ll t;
    for (size_t i = 0; i < N; i++) {
        std::cin >> t;
        x.push_back(t);
    }
    for (size_t i = 0; i < M; i++) {
        std::cin >> t;
        y.push_back(t);
    }
    x.push_back(X);
    y.push_back(Y);
    if (*std::max_element(x.begin(), x.end()) <
        *std::min_element(y.begin(), y.end())) {
        std::cout << "No War" << '\n';
    } else {
        std::cout << "War" << '\n';
    }
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <utility>
#include <functional>
#include <string>
using namespace std;
int main() {
	string s;
	cin >> s;
	int mindif=10000;
	for (int i = 0; i < s.size() - 2; ++i) {
		string ss{ s[i],s[i + 1],s[i + 2] };
		int tmp=stoi(ss);
		int dif = abs(tmp - 753);
		if (dif < mindif)mindif = dif;
	}
	cout << mindif << endl;
	return 0;
}



Measured memory_bytes: 888
use proconio::input;
fn main() {
    input!{
        N:usize,
        H:[u64;N],
    }
  let mut dp = vec![0;N];
  for i in 0..N-1 {
      if H[N-1-i]<=H[N-2-i]{
          dp[N-2-i]=dp[N-1-i]+1;
      }
  }
  let mut max=0;
  for i in 0..N {
      if dp[i]>max {
          max=dp[i];
      }
  }
  print!("{}",max);
}

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

using namespace std;
typedef long long int ll;
typedef pair <ll,ll> P;
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define REPR(i, n) for(int i = n-1; i >= 0; i--)
#define FOR(i, n, m) for(int i = n; i < (int)(m); i++)
#define PRINT(x) cout << x << endl
#define ALL(v) v.begin(), v.end()
#define INF (ll)1e18

ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

ll MOD = 1000000007;

int main()
{
    ll N;
    cin >> N;
    vector<vector<P>> tree(N);
    REP(i, N-1) {
        ll u, v, w;
        cin >> u >> v >> w;
        u--; v--;
        tree[u].push_back(P(v, w));
        tree[v].push_back(P(u, w));
    }
    vector<bool> visited(N, false);
    vector<ll> dist(N, 0);
    queue<ll> sta;
    sta.push(0);
    visited[0] = true;
    while(!sta.empty()) {
        ll cur = sta.front();
        sta.pop();
        for (P t : tree[cur]) {
            if (!visited[t.first]) {
                sta.push(t.first);
                dist[t.first] = dist[cur] + t.second;
                visited[t.first] = true;
            }
        }
    }
    REP(i, N) {
        PRINT(dist[i] % 2);
    }
    return 0;
}


Measured memory_bytes: 8832
#include <iostream>
#include <sstream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <cstring>
#include <bitset>
#include <functional>
#include <random>
#define REP(i,a,n) for(int i=a;i<=n;++i)
#define PER(i,a,n) for(int i=n;i>=a;--i)
#define hr putchar(10)
#define pb push_back
#define lc (o<<1)
#define rc (lc|1)
#define mid ((l+r)>>1)
#define ls lc,l,mid
#define rs rc,mid+1,r
#define x first
#define y second
#define io std::ios::sync_with_stdio(false)
#define endl '\n'
#define DB(a) ({REP(__i,1,n) cout<<a[__i]<<',';hr;})
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int P = 1e9+7, INF = 0x3f3f3f3f;
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll qpow(ll a,ll n) {ll r=1%P;for (a%=P;n;a=a*a%P,n>>=1)if(n&1)r=r*a%P;return r;}
ll inv(ll x){return x<=1?1:inv(P%x)*(P-P/x)%P;}
inline int rd() {int x=0;char p=getchar();while(p<'0'||p>'9')p=getchar();while(p>='0'&&p<='9')x=x*10+p-'0',p=getchar();return x;}
//head



const int N = 1e6+50;
int k,a[N],n;
char s[N];

void solve1() {
	int ans = 0, now = 0;
	REP(i,1,n*k) if (a[i]==a[i-1]) ++ans,a[i]=--now;
	printf("%d\n",ans);
}

int f[N];
void solve2() {
	int ans = 0, now = 0;
	REP(i,1,100*n) {
		if (a[i]==a[i-1]) ++ans,a[i]=--now;
		if (i%n==0) f[i/n] = ans;
	}
	int d;
	if (k&1) d=f[51]-f[49],printf("%lld\n",f[51]+(k-51)/2ll*d);
	else d=f[50]-f[48],printf("%lld\n",f[50]+(k-50)/2ll*d);
}

int main() {
	scanf("%s%d",s+1,&k);
	n=strlen(s+1);
	REP(i,1,n) a[i]=s[i];
	REP(j,1,200) REP(i,1,n) a[i+n*j]=a[i];
	if (k<=200) solve1();
	else solve2();
}










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

int main() {
    int a, b, c, d, e;
    cin >> a >> b >> c >> d >> e;
    vector<int> nums = {a,b,c,d,e};
    vector<bool> last(5,0);
    int minim = 9;
    for (int i=0; i<5; i++) if (nums[i]%10>0 && nums[i]%10<minim) minim = nums[i]%10;
    for (int i=0; i<5; i++) if (nums[i]%10==minim) {
        last[i] = true;
        break;
    }
    int res = 0;
    for (int i=0; i<5; i++) if (!last[i] && nums[i]%10>0) nums[i] = nums[i]/10*10+10;
    for (auto i : nums) res+=i;
    cout << res;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define P 1000000007
using namespace std;
template <class T> inline void read(T &x) {
	x = 0; int c = getchar(), f = 1;
	for (; !isdigit(c); c = getchar()) if (c == 45) f = -1;
	for (; isdigit(c); c = getchar()) (x *= 10) += f*(c-'0');
}
int n, m, a[105], f[2][100005];
int main() {
	read(n), read(m), f[0][m] = 1;
	for (int i = 1; i <= n; i++) read(a[i]);
	for (int i = 1, c = 1; i <= n; i++, c ^= 1) {
		f[c][0] = f[c^1][a[i]];
		for (int j = 1; j <= m; j++)
			f[c][j] = (f[c^1][min(j+a[i],m)]-f[c^1][j-1]+P)%P;
		for (int j = 1; j <= m; j++) (f[c][j] += f[c][j-1]) %= P;
	}
	return printf("%d\n", f[n&1][0]), 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define rep(i,j,k) for(register int i = j; i <= k; i++)
#define dow(i,j,k) for(register int i = j; i >= k; i--)
#define ll long long
using namespace std;
int n, sv, v, l, r, mid;
char c[10];
inline int get() 
{ 
	scanf("%s",c+1);
	
	if( c[1] == 'V' ) exit(0);
	
	else if( c[1] == 'M' ) return 0;
	
	else return 1;
}

int main() 
{ 
	cin>>n;
	printf("%d",0);
	cout<<endl;
	sv = get();
	l=1;
	r=n-1;
	while(1) { 
		mid = (l + r) >> 1;
		cout<<mid<<endl;
		fflush(stdout);
		v=get();
		if(mid&1) 
		{ 
			if( v != sv ) 
			{ 
				l = mid + 1;
			} 
			else r = mid - 1;
		} 
		else 
		{ 
			if(v==sv) 
			{ 
				l=mid+1;
			} 
			else r=mid-1;
		}
	}	
	return 0;
}

Measured memory_bytes: 852
def read_values():
    return map(int, input().split())


def read_list():
    return list(read_values())


def g(a, b):
    if a > b:
        a, b = b, a
    while b % a:
        a, b = b % a, a
    return a


def main():
    mod = 10 ** 9 + 7
    N = int(input())
    A = read_list()

    B = 1
    for a in A:
        B *= a // g(B, a)
    
    print(sum(B // a for a in A) % mod)


if __name__ == "__main__":
    main()



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

int main() {
    int N, M;
    cin >> N >> M;
    set<int> fromStart;
    set<int> toEnd;
    rep(i, M) {
        int a, b;
        cin >> a >> b;
        if (a == 1) {
            fromStart.insert(b);
        } else if (b == 1) {
            fromStart.insert(a);
        } else if (a == N) {
            toEnd.insert(b);
        } else if (b == N) {
            toEnd.insert(a);
        }
    }
    set<int> ans;
    set_intersection(fromStart.begin(), fromStart.end(),
        toEnd.begin(), toEnd.end(),
        inserter(ans, ans.end())
    );
    string t = (ans.size() > 0) ? "POSSIBLE" : "IMPOSSIBLE";
    cout << t << endl;
    return 0;
}

Measured memory_bytes: 9600
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <functional>
#include <stack>
#include <queue>
#include <string>
#include <map>
#include <unordered_map>
#include <bitset>
#include <numeric>
#include <vector>
#include <set>
#include <unordered_set>
#include <bitset>
#include <limits>
#include <random>
#include <complex>
#include <numeric>


using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;

const ll mod=1000000007ll;
const ll inf=1000000000000000ll;

const ll nmax=50;


int main(){
    ll a,b,c,ans;
    ans=0;
    cin>>a>>b>>c;
    ans=max(ans,a*10+b+c);
    ans=max(ans,b*10+a+c);
    ans=max(ans,c*10+b+a);
    cout<<ans<<endl;
    return 0;
}


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

m = 10**10
for i in range(1, N):
  a, b = 0, 0
  for j in range(i):
    a += W[j]
  for j in range(i, N):
    b += W[j]
  m = min(m, abs(a-b))
print(m)

Measured memory_bytes: 9124
#include <iostream>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <limits>
#include <numeric>
#include <algorithm>
#include <functional>

#include <vector>

using namespace std;

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

	int N;
	cin >> N;

	vector<int> A(N, 0);

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

	sort(A.begin(), A.end(), greater<int>());

	long long result = A[0];
	for (int i = 2; i < N; i++)
	{
		result += A[i / 2];
	}

	cout << result;
	
	return 0;
}


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

int main()
{
    long long N, M;
    string S;
    cin >> N >> M >> S;

    reverse(S.begin(), S.end());
    vector<bool> over(S.size());
    for (int i = 0; i < over.size(); i++)
    {
        over[i] = S[i] == '0';
    }

    vector<long long> ans;
    long long current = 0;
    while (current < N)
    {
        long long next = current;
        for (long long i = 1; i <= M; i++)
        {
            if (over[current + i])
            {
                next = min(N, current + i);
            }
        }
        if (next == current)
        {
            cout << -1 << endl;
            return 0;
        }
        ans.push_back(next - current);
        current = next;
    }
    reverse(ans.begin(), ans.end());
    for (long long a : ans)
    {
        cout << a << " ";
    }
    cout << endl;
}


Measured memory_bytes: 1528
#include<iostream>
#include<cmath>
#include<string>
#include<algorithm>
using namespace std;

int main()
{
	int r, d, x2000,x200x;
	cin >> r >> d >> x2000;
	int n = 10;
	while (n--)
	{
		x200x = r*x2000 - d;
		cout << x200x << endl;
		x2000 = x200x;
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define vtpl(x,y,z) vector<tuple<x,y,z>>
#define at(x,i) get<i>(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
ll modfac(ll a){
    ll ans=1;
    while(a>1){
        ans*=a;
        ans%=1000000007;
        a--;
    }
    return ans;
}
ll modinv(ll a,ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m; 
    if (u < 0) u += m;
    return u;
}
struct UnionFind {
    vector<int> par;
    
    UnionFind(int n) : par(n, -1) {}

    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }
    
    bool same(int x, int y) {
        return root(x) == root(y);
    }
    
    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y);
        par[x] += par[y];
        par[y] = x;
        return true;
    }
    
    int size(int x) {
        return -par[root(x)];
    }
};
ll modpow(ll a, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
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;cin >> n;
    ll ans=0;
    ans+=n/500*1000;
    n%=500;
    ans+=n/5*5;
    cout <<ans <<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<vector>
#include<string>
#define rep(i,N) for(int i = 0; i<N,i++)
using namespace std;
typedef long long llong;
typedef unsigned long long ullong;

llong gcd(llong a, llong b) {
	if (a < b) swap(a, b);
	if (a % b == 0) return b;
	else return gcd(b, a % b);
}

llong lcm(llong a, llong b) {
	llong g = gcd(a, b);
	return a * b / g;
}

int N, K;
llong V[100];
llong ans = 0;

int main() {
	cin >> N >> K;
	for (int i = 0; i < N; i++) {
		cin >> V[i];
	}

	bool flag = true;

	for (int i = 0; i <= K; i++) {
		for (int j = -( (-i) / 2); j <= i && j <= N; j++) {
			for (int k = 0; k <= j; k++) {

				llong motimono[100];

				int l;

				for (l = 0; l < k; l++) {
					motimono[l] = V[l];
				}

				for (; l < j; l++) {
					motimono[l] = V[N - 1 - l + k];
				}

				sort(motimono, motimono + j, greater<llong>());

				llong SUM = 0;

				for (int m = 0; m < 2 * j - i; m++) {
					SUM += motimono[m];
				}

				ans = max(ans, SUM);
			}
		}
	}
	cout << ans;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdint.h>
#include <inttypes.h>
#include <stdlib.h>
#include <string.h>

typedef unsigned long long int uint64;
typedef long long int          int64;
 
#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))

void get_N (int64 *n)
{
  int cnt;
  
  cnt = scanf("%lld", n);

  return;
}

void get_NK (int64 *n, int64 *k)
{
  int cnt;
  
  cnt = scanf("%lld %lld", n, k);

  return;
}

void get_N1234 (int64 *n1, int64 *n2, int64 *n3, int64 *n4)
{
  int cnt;

  if (n2 == NULL) {
    cnt = scanf("%lld", n1);
    return;
  }
  if (n3 == NULL) {
    cnt = scanf("%lld %lld", n1, n2);
    return;
  }
  if (n4 == NULL) {
    cnt = scanf("%lld %lld %lld", n1, n2, n3);
    return;
  }
  cnt = scanf("%lld %lld %lld %lld", n1, n2, n3, n4);
  return;
}

void omit_LF (void)
{
  char c;
  int  cnt;
  
  cnt = scanf("%c", &c);
  return;
}

char *get_S (int64 n)
{
  char *buf;
  int  i;
  int  cnt;

  buf = (char *)malloc((size_t)(n * sizeof(char)));
  if (buf == NULL) {
    return NULL;
  }

  cnt = scanf("%s", buf);

  return buf;
}

char *get_SN (int64 max, int64 *size)
{
  char *buf;
  int  i;
  int  n;
  int  cnt;

  buf = (char *)malloc((size_t)(max * sizeof(char)));
  if (buf == NULL) {
    return NULL;
  }

  cnt = scanf("%s", buf);

  n = strlen(buf);

  *size = n;
  
  return buf;
}

int64 *get_NSeq (int64 n)
{
  int64 *buf;
  int64 i;

  buf = (int64 *)malloc((size_t)(n * sizeof(int64)));
  for (i=0; i<n; i++) {
    get_N(&buf[i]);
  }

  return buf;
}

typedef struct _tmp_t {
  int64    a;
  int64    b;
} tmp_t;

typedef int64 simple_t;

int compare_simple(const void *a, const void *b)
{
  simple_t *x;
  simple_t *y;

  x = (simple_t *)a;
  y = (simple_t *)b;

  if (x > y) return 1;
  if (y < x) return -1;

  return 0;
}
void qsort_simple (simple_t *array, int size)
{
  qsort(array, size, sizeof(simple_t), compare_simple);
}

int compare_a(const void *a, const void *b)
{
  tmp_t *x;
  tmp_t *y;

  x = (tmp_t *)a;
  y = (tmp_t *)b;

  if (x->a > y->a) return 1;
  if (x->a < y->a) return -1;

  return 0;
}

int compare_b(const void *a, const void *b)
{
  tmp_t *x;
  tmp_t *y;

  x = (tmp_t *)a;
  y = (tmp_t *)b;

  if (x->b > y->b) return 1;
  if (x->b < y->b) return -1;

  return 0;
}

void qsort_a (tmp_t *array, int size)
{
  qsort(array, size, sizeof(tmp_t), compare_a);
}

void qsort_b (tmp_t *array, int size)
{
  qsort(array, size, sizeof(tmp_t), compare_b);
}


int resolve1()
{
  int64 R;
  double pi=3.14159;
  double L;

  get_N(&R);

  L = pi*R*2;

  printf("%lf", L);
  return 0;
}

int resolve2()
{
  int64 N,M;
  int64 *A;
  int64 i;
  int64 total = 0;
  int64 play=0;
  
  get_NK(&N, &M);
  A = get_NSeq(M);

  for (i=0; i < M; i++) {
    total += A[i];
  }

  if (N >= total) {
    play = N - total;
  } else {
    printf("-1");
    return 0;
  }

  printf("%lld",play);
  return 0;
}


int main()
{
  int64 X;
  int64 i, total;

  get_N(&X);

  total = 0;

  total = 100;
  i = 0;
  
  while (1) {
    i++;
    total += (total/100);
    if (total >= X) {
      printf("%lld", i);
      return 0;
    }
  }

  printf("NG");

  return 0;
}



Measured memory_bytes: 1736
#include <stdio.h>
#include <vector> 
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;

int main(){
    int L;
    cin>>L;
    long double a;
    a=L/3.0;
    std::cout<<std::fixed<<std::setprecision(10);
    cout<<a*a*a<<endl;



}

Measured memory_bytes: 256
<?php

    $N =intval(trim(fgets(STDIN)));
    
    $P = array_map('intval',explode(" ",trim(fgets(STDIN))));
    
    $P_save = $P;
    
    $P_rev  = $P;
    sort($P_rev);
    
    if($P_rev== $P_save){
        echo "YES";
        exit;
    }
    
    for($i=0;$i<$N-1;$i++){
    
        for($j=$i+1;$j<$N;$j++){
            
            $P = $P_save;
            $X = $P[$i];
            $Y = $P[$j];
            
            $P[$i] = $Y;
            $P[$j] = $X;
            if($P_rev == $P){
                echo "YES";
                exit;
            }
        }
    }
    echo "NO";
?>

Measured memory_bytes: 16236
#include<iostream>
#include <cstdio>
#include <iostream>
#include <cstring>
#include <string>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <complex>
#include <algorithm>
#include <vector>

using namespace std;
typedef long long ll;
typedef long double db;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define de(x) cout << #x << "=" << x << endl
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
int main()
{
	int d25,d50,d100,d200;
	cin>>d25>>d50>>d100>>d200;
	ll n;
	cin>>n;
	n*=100;
	if(d50>2*d25)
	d50=2*d25;
	if(d100>d50*2)
	d100=2*d50;
	if(d200>2*d100)
	d200=2*d100;
	ll ans=0;
	if(n>=200)
	{
		ans+=(n/200)*d200;
		n%=200;
	}
	if(n>=100)
	{
		ans+=(n/100)*d100;
		n%=100;
	}
	if(n>=50)
	{
		ans+=(n/50)*d50;
		n%=50;
	}
	
	if(n>=25)
	{
		ans+=(n/25)*d50;
		n%=25;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int a[3],i,c,f=0;
  scanf("%d %d %d",&a[0],&a[1],&a[2]);
  for(i=0;i<3;i++){
    for(c=0;c<3;c++){
      if(a[i]<a[c]){
	f=a[i];
	a[i]=a[c];
	a[c]=f;
      }
    }
  }
  printf("%d %d %d\n",a[0],a[1],a[2]);
  return(0);
}

Measured memory_bytes: 1024
#include <stdio.h>

int main(void){
  int a,b,c;
  
  scanf("%d %d %d",&a,&b,&c);
  if(c-a+b>0){
    printf("%d\n",c-a+b);
  }else{
    printf("0\n");
  }
  
  return 0;
}

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

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

  string s;
  cin >> s;
  int ans1 = 0, ans2 = 0;
  rep(i, 0, s.size()) {
    if (i % 2) {
      if (s[i] == '0')
        ans1++;
      else
        ans2++;
    } else {
      if (s[i] == '0')
        ans2++;
      else
        ans1++;
    }
  }
  cout << min(ans1, ans2) << endl;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int main(){
    int n,cnt=0;
    vector<string> vec(0);
    string s;
    map<string,int> mp;
    vector<pair<int,string> > p;
    cin >> n;
    rep(i,n){
        cin >> s;
        if(!mp.count(s)){
            mp[s]=0;
            vec.push_back(s);
        }
        else mp[s]++;
    }
    rep(i,vec.size()){
        p.push_back(make_pair(mp[vec.at(i)],vec.at(i)));
    }
    sort(p.begin(),p.end());
    reverse(p.begin(),p.end());
    int mx=p.at(0).first;
    vector<string> drafts(0);
    rep(i,p.size()){
        if(p.at(i).first==mx)drafts.push_back(p.at(i).second);
        else break;
    }
    sort(drafts.begin(),drafts.end());
    rep(i,drafts.size()){
      cout << drafts.at(i) << endl;
    }
}

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

char s[10];

int main(){
    cin>>s;
    if(s[0]==s[1]&&s[1]==s[2]&&s[2]==s[3])
         cout<<"No"<<endl;
    else if((s[0]==s[1]&&s[2]==s[3])||(s[0]==s[2]&&s[1]==s[3]||s[0]==s[3]&&s[1]==s[2]))
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
}

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

main :: IO ()
main = do
    [a, b, c] <- fmap read . words <$> getLine :: IO [Int]
    let p1 = any ((== c) . (`mod` b)) $ fmap (a *) [1 .. b]
    if p1
        then putStrLn "YES"
        else putStrLn "NO"

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

using namespace std;

const int N=200005;

int n,K,num[N],fv[N];
char s[N];
bitset<N> V;

int main(){
	scanf("%d%d",&n,&K);
	scanf("%s",s+1);
	for(int i=1;i<=n;i++){
		V[i]=s[i]=='A';
		num[i]=num[i-1]+1;
		if(i&1)num[i]+=s[i]=='A';else num[i]+=s[i]=='B';
	}
	num[n+1]=K+1;
	for(int j=1;j<=n;j++)if(num[j]<=K&&num[j+1]>K){
		V>>=j;
		if(j&1)V=~V;
		for(int p=n,x=1;p>n-j;p--,x^=1)V[p]=x;
		K-=num[j];
	}
	if(K){
		if(V[1]==1)V[1]=0;else V=~(V>>1),V[n]=1;
		K--;
	}
	if(K&&(n&1))if(K&1)V[1]=!V[1];
	for(int i=1;i<=n;i++)if(V[i])putchar('A');else putchar('B');
	return 0;
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
long long dp[N] = {};
long long arr[N] = {};
long long per[N] = {};
long long DP(int x) {
    if (~dp[x]) return dp[x];
    if (x & 1)
        return dp[x] = max(arr[x] + DP(x - 2), arr[x - 1] + DP(x - 3));
    else
        return dp[x] = max(arr[x] + DP(x - 2), arr[x - 1] + per[x - 2]);
}
int main() {
    ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++)
        cin >> arr[i];
    for (int i = 1; i <= n; i++)
        per[i] = per[i - 1] + arr[i] * (i & 1);
    fill(dp, dp + n + 1, -1);
    dp[0] = 0;
    dp[1] = 0;
    cout << DP(n) << '\n';
    return 0;
}

Measured memory_bytes: 14592
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<ll> vl;
typedef pair<ll,ll> pll;
#define MOD 1000000007
#define INF 1000000000
#define mp make_pair
#define pb push_back
#define ss second
#define ff first
#define endl '\n'
#define pl cout<<endl;
# define PI  3.14159265358979323846
ll maxi=LLONG_MIN;
ll mini=LLONG_MAX;
int main() 
{
	
 	 ll n,k;cin>>n>>k;
 	 ll a[n],dp[k+1]={0};
 	 for (int i = 0; i < n; ++i)
 	 {
 	 	cin>>a[i];
 	 }
 	 for (int i = 0; i <= k ; ++i)
 	  {
 	  	for (int j = 0; j < n ; ++j)
 	  	{
 	  		if (i>=a[j]&&dp[i-a[j]]==0)
 	  		{
 	  			dp[i]=1;
 	  		}
 	  	}
 	  }
 	  if(dp[k]==1){cout<<"First";}
 	  else{cout<<"Second";} 
 	
 	return 0;
 }

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
const int MOD=1e9+7;
//const int MOD=998244353;
const int INF=1e9;
const long long LINF=1e18;
#define int long long
//template
template <typename T>
void fin(T a){
  cout<<a<<endl;
  exit(0);
}
//main
signed main(){
  int N;cin>>N;
  string s,t;
  cout<<0<<endl;cin>>s;if(s=="Vacant")return 0;
  cout<<N-1<<endl;cin>>t;if(t=="Vacant")return 0;
  int l=0,r=N-1;
  for(int i=0;i<25;i++){
    int m=(r+l)>>1;
    cout<<m<<endl;string u;cin>>u;if(u=="Vacant")return 0;
    if(((m-l)&1)^(s!=u))r=m,t=u;
    else l=m,s=u;
  }
}


Measured memory_bytes: 852
#include<bits/stdc++.h>            //  IT'S NEVER TOO LATE...
    	using namespace std;
        #include<math.h>
    	#define ll long long
    	#define fore(i, l, r) for(int i = int(l); i < int(r); ++i)
        #define forn(i, n) fore(i, 0, n)
        #define fori(i, l, r) fore(i, l, (r) + 1)
        #define sz(v) int((v).size())
        #define all(v) (v).begin(), (v).end()
        #define pb push_back
        #define mp make_pair
        #define ff first
        #define ss second

        const double PI = atan(1)*4;

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

    	
    	vector<int> ar[1000001];
        vector<pair<int,int>> path;
        int vis[1000001],dis[1000001];

        /*void dfs(int node)
        {
            vis[node]=1;

            for(int child : ar[node])
            {
                if(vis[child]==0)
                {
                    dis[child]=dis[node]+1;
                    dfs(child);
                }
            }
        }*/

    /*    void bfs(int i)
        {
            queue<int> q;
            q.push(i);
            vis[i]=1;
            dis[i]=0;

            while(!q.empty())
            {
                int curr=q.front();
                q.pop();

                for(int child : ar[curr])
                    if(vis[child]==0)
                    {
                        q.push(child);
                        dis[child]=dis[curr]+1;
                        vis[child]=1;
                    }
            }
        }*/

        bool isprime(int n)
        {
            for(int i=2;i*i<=n;i++)
                if(n%i==0)
                    return false;
            return true;
        }

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

        int modpow(int b,int p,int m)
        {
            if(p==0) return 1%m;
            if(p%2) return (b*modpow(b,p-1,m))%m;
            int u=modpow(b,p/2,m);
            return (u*u)%m;
        }

        int c[55] , dp[300];

        int fn(int n,int m)
        {
            //cout<<n<<" ";
            if(n==0)
                return 1;

            if(dp[n])
                return dp[n];
            int ans = 0;

            forn(i,m)
            {
                //cout<<c[i]<<"\n";
                if(c[i]<=n)
                ans+=fn(n-c[i] , m);
            }
            dp[n]=ans;
            return ans;
        }

    	int main()  
    	{

    		
    		int t=1;
    		//cin>>t;
    		
    		while(t--)
    		{
                ll a,c;
                long double b;
                
                cin>>a>>b;
                
                ll ans = floor((ll)a*b);
                cout<<(ll)ans;
            }
            return 0;
    	}

        //              NOW IT'S TIME TO WAKE UP...

Measured memory_bytes: 27176
N=int(input())
a_list = list(map(int, input().split()))
minus_a_list = list(filter(lambda x: x < 0, a_list))
# print(minus_a_list)
if (len(minus_a_list) % 2 == 0):
    print(sum(map(abs, a_list)))
else:
    abs_a_list = list(map(abs, a_list))
    print(sum(abs_a_list) - 2 * min(abs_a_list))


Measured memory_bytes: 14412
N = int(input())
alfa=["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]
name = ""

while N > 0:
    N -= 1
    name += alfa[N % 26]
    N //= 26

print(name[::-1])

Measured memory_bytes: 9196
#include <bits/stdc++.h>
#include <boost/foreach.hpp>
using namespace std;
#define pi 2*asin(1.0)
#define MAX 10000000
#define MOD 1000000007
#define _GLIBCXX_DEBUG
 
vector<long> fac(MAX);
vector<long> finv(MAX);
vector<long> inv(MAX);
 
//template functions
/////////////////////////
void Cominit(){
  fac.at(0)=fac.at(1)=1;
  finv.at(0)=finv.at(1)=1;
  inv.at(1)=1;
  for(long i=2;i<MAX;i++){
      fac.at(i)=(fac.at(i-1)*i)%MOD;
      inv.at(i)=MOD-inv.at(MOD%i)*(MOD/i)%MOD;
      finv.at(i)=finv.at(i-1)*inv.at(i)%MOD;
  }
}

long facComb(long N,long M){// nCm%
if(N<M) return 0;
if(N<0||M<0) return 0;
return fac.at(N)*(finv.at(M)*finv.at(N-M)%MOD)%MOD;
}

long Comb(long N,long M){// nCm
long ans=1;
for(long i=N;i>N-M;i--){
    ans=ans*i;
}
for(long i=M;i>0;i--){
    ans=ans/i;
}
return ans;
}

long Perm(long N,long M){// nPm
long ans=1;
for(long i=N;i>N-M;i--){
    ans=ans*i;
}
return ans;
}

long GCM(long A,long B){
            long W,r;
    if(A<B){

        W=B;
        B=A;
        A=W;
    }
    while(A%B!=0){
        r=A%B;
        A=B;
        B=r;
    }
    return B;
}
long LCM(long A,long B){
    return (A*B)/GCM(A,B);
}

long upDiv(long a,long b){
  return (a+b-1)/b;
}

long strtolong(string str){
istringstream ss;
ss=istringstream(str);
long num;
ss>>num;
return num;
}

long chartolong(char ch){
long num;
num=ch-'0';
return num;
}

string longtostr(long N){
    string str;
    str=to_string(N);
    return str;
}









/////////////////////////


//Answer


int main() {

long A,B,C;
cin>>A>>B>>C;
if(A+B+C<=21){
cout<<"win"<<endl;
}else{
cout<<"bust"<<endl;
}

}



Measured memory_bytes: 237456
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <cstdlib>
#define rep(i,x) for(int i=0;i<x;i++)
#define all(a) (a).begin(),(a).end()
using namespace std;
using ld = long double;
using ll = long long;
const ll INF = 10010010010;
typedef pair<ll, ll> P;
const ll mod = 1000000007;
ll gcd(ll a, ll b) {//a>b
	if (a < b)swap(a, b);
	if (a % b == 0) return b;
	else return gcd(b, a % b);
}
int main(){
  ll N;
  cin >> N;
  cout << (N * N + N)/2 << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep1(i,n) for(i=1;i<=n;i++)
int main(){
  int x[6];
  int i;
  
  rep1(i,5){
    cin >>x[i];
    if(x[i]==0){
      cout << i;
    }
  }
  
}

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

int main()
{
  int W, H, x, y, r;
  cin >> W >> H >> x >> y >> r;

  if (0 <= x - r && x + r <= W
   && 0 <= y - r && y + r <= H)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 1160
import sys

def resolve():
    N = int(input())
    for i in range(4, 100, 4):
        if N == i:
            print("Yes")
            return
        for j in range(7, 100, 7):
            if N == j:
                print("Yes")
                return
            if N == i + j:
                print("Yes")
                return
    print("No")

if '__main__' == __name__:
    resolve()

Measured memory_bytes: 40560
#include "bits/stdc++.h"
using namespace std;
#define rep(i,a,n) for(ll i=a;i<n;i++)
#define ALL(s) s.begin(),s.end()
#define P pair<ll,ll>
#define vl vector<ll>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vvl vector<vector<ll>>
#define print(n) cout<<n<<endl
const int M=100111;
const int inf=1000000007;
const long long INF=1000000000000000007;
using ll=long long;
int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};


int main(){
	int n,l,ans=0;
	cin>>n>>l;
	rep(i,1,n+1)ans+=(l+i-1);
	int tmp=inf;
	int c=0;
	rep(i,1,n+1){
		tmp=min(abs(tmp),abs((int)(l+i-1)));
		if(tmp==abs(l+i-1))c=i;
	}
	print(ans-(l+c-1));

		
}	

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

int main()
{
  ll h, w,a;
  cin >> h >> w;
  if(w==1||h==1) a=1;
  else if(w%2==0) a=  w*h/2;
  else w--,a= w*h/2+h/2+h%2;
  cout <<a <<endl;
}

Measured memory_bytes: 256
#include <iostream>
// #include <cassert>
#include <vector>
#include <algorithm>
#include <climits>


// #include <deque>
// #include <stack>
// #include <set>
// #include <map>
// #include <string>
// #include <unordered_set>
// #include <unordered_map>
// #include <queue>
// #include <tuple>

// #include <cmath>
// #include <numeric>

using namespace std;
typedef long long ll;
typedef long l;
typedef pair<long,long> pll;
typedef pair<int,int> pii;
typedef pair<int,long> pil;
typedef pair<long,int> pli;
const char el = '\n';

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

    ll n,p; string s;
    cin>>n>>p; cin.ignore();
    cin>>s;
    cin.ignore();

    if (p==2 || p==5) {
        ll ret=0;
        for (int i = 0; i<n; ++i) {
            int dig = (int)s[i]-'0';
            if (dig%p ==0) ret+=(i+1);
        }
        cout<<ret<<el;
        return 0;

    }

    vector<ll> modvals(p,0);
    ll cummodvalue = 0;



    ll ret = 0;
    ll tenpow = 1;
    cummodvalue=0;
    for (ll i =n-1; i>=0; --i) {
        char ch = s[i];

        ll dig = (ll)(ch-'0');
        cummodvalue += (tenpow)*dig;
        cummodvalue%=p;

        if (cummodvalue==0) {
            ++ret;
            // cout<<"found full suffix from index "<<i<<":  "<<s.substr(i)<<el;
        }

        // if (modvals[cummodvalue]>0) {
        //     cout<<"at index "<<i<<":  "<<s.substr(i)<<" ";
        //     cout<<"found "<<modvals[cummodvalue]<<" prior suffices with modvalue = "<<cummodvalue<<el;
        // }

        ret += modvals[cummodvalue];

        ++modvals[cummodvalue];

        tenpow *= (ll)10;
        tenpow %= p;
       
    }

    cout<<ret<<el;
    
    // long n, m;
    // cin>>n>>m; cin.ignore();

}



Measured memory_bytes: 720
#include<bits/stdc++.h>
using namespace std;
bool visited[100010];
vector<int> v[100010];
int n;
void dfs(int node)
{
    visited[node]=true;
    for(int i=0;i<v[node].size();i++)
    {
    	if(visited[v[node][i]]==false)
            dfs(v[node][i]);
    }
}
int main()
{
    int m,k,a,b;
    cin>>n>>m;
    for(int i=0;i<m;i++)
	{
        cin>>a>>b;
    	v[a].push_back(b);
    	v[b].push_back(a);
    }
    int block=0;
    for(int j=1;j<=n;j++)
	{
        if(visited[j]==false)
		{
            dfs(j);
            block++;
        }
    } 
    cout<<block-1<<endl; 
    return 0;
}


Measured memory_bytes: 9652
#include "bits/stdc++.h"
#define Rep(i,n) for(int i=0;i<(int)(n);i++)
#define For(i,n1,n2) for(int i=(int)(n1);i<(int)(n2);i++)
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i,n) for(ll i=((ll)(n)-1);i>=0;i--)
#define FOR(i,n1,n2) for(ll i=(ll)(n1);i<(ll)(n2);i++)
#define RFOR(i,n1,n2) for(ll i=((ll)(n1)-1);i>=(ll)(n2);i--)
#define all(a)  (a).begin(),(a).end()
#define IOS std::cin.tie(0),std::ios::sync_with_stdio(false)

namespace idaten {

	using namespace std;
	using ll = int_fast64_t;
	using ull = uint_fast64_t;
	using P = std::pair<int64_t, int64_t>;
	template<typename T1, typename T2> inline bool chmin(T1& a, T2 b) { if (a > b) { a = b; return 1; }return 0; }
	template<typename T1, typename T2> inline bool chmax(T1& a, T2 b) { if (a < b) { a = b; return 1; }return 0; }
	template<class T> inline std::istream& operator >> (std::istream& is, std::vector<T>& v) { for (T& x : v) { is >> x; }return is; }
	template<class T> inline std::ostream& operator << (std::ostream& os, const std::vector<T>& v) {
		for (auto itr = v.begin(); itr != v.end();) { os << (*itr) << ((++itr != v.end()) ? " " : ""); }
		return os;
	}
	template<class V, typename T>inline void fill(V& v, const T& val) { v = val; }
	template<class V, typename T>inline void fill(std::vector<V>& v, const T& val) { for (V& x : v) { fill(x, val); } }
	template<class V, typename H>inline void resize(std::vector<V>& v, const H h) { v.resize(h); }
	template<class V, typename H, typename... T>inline void resize(std::vector<V>& v, const H& h, const T& ... t) { v.resize(h); for (auto& x : v) { resize(x, t...); } }
	inline void put() {}
	template<class T> inline void put(const T& first) { std::cout << first << "\n"; }
	template<class T, class... N> inline void put(const T& first, const N& ... rest) { std::cout << first << " "; put(rest...); }

	void solve() {
		IOS;
		ll n;
		cin >> n;
		vector<ll> a(n);
		REP(i, n) {
			cin >> a[i];
		}
		unordered_map<ll, ll> mp1;
		ll res = 0;
		REP(i, n) {
			ll t2 = i + 1 - a[i];
			res += mp1[t2];
			ll t1 = a[i] + i + 1;
			mp1[t1]++;
		}
		put(res);
	}
} // namespace idaten

int main() {
	idaten::solve();
	return 0;
}


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

int main() {
	
  //初期宣言と型の設定
  int A, B, C;
  string op;
  
  //入力部
  cin >> A >> op >> B;
  
  if(op=="+"){
    C=A+B;
  }
  else if(op=="-"){
    C=A-B;
  }
  else{
    cout <<"error"<< endl;
  }
  cout << C << endl;
}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int INF = 1e9;
int MOD = 1e9+7;
main(){
    ll A,B;
    cin >> A >> B;
    if(llabs(A-B) <= 1LL){
        cout << "Brown" << endl;
    }else{
        cout << "Alice" << endl;
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<string>
using namespace std;
int serch(int n)
{
    if(n==1)return 1;
    else return n+serch(n-1);
}
int main()
{
    int n;
    while(cin>>n){
        n=serch(n)+1;
        cout<<n<<endl;
    }
}

Measured memory_bytes: 1160
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <fstream>
#include <numeric>
using namespace std;
typedef long long int ll;

#define EPS (1e-7)
#define INF 1e18
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define PI (acos(-1))

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

int main() {
    int K;
    string S;
    cin >> K;
    cin >> S;

    if (S.size() > K) S = S.substr(0, K) + "...";
    cout << S << endl;

    return 0;
}


Measured memory_bytes: 3108
#include <iostream>
#include <string>
#include <vector>
#include <utility>

using namespace std;

#define min(a,b) (a < b ? a : b)

int main(void){
    int n;
    string s;
    cin >> n;
    cin >> s;
    vector<pair<int,int>> res(n);
    res[0].first = 0;
    res[n-1].second = 0;
    for(int i=0;i<n-1;i++){
        if(s[i] == 'W')res[i+1].first = res[i].first + 1;
        else res[i+1].first = res[i].first;
    }
    for(int i=n-1;i>=1;i--){
        if(s[i] == 'E')res[i-1].second = res[i].second + 1;
        else res[i-1].second = res[i].second;
    }
    int min = 1e09;
    for(int i=0;i<n;i++){
        min = min(res[i].first + res[i].second,min);
    }
    cout << min << endl;
    return 0;
}

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

int main() {
  ll n; cin >> n;
  if(n == 0){
    cout << 0 << endl;
    return 0;
  }
  if(n % 2 == 1){
    cout << 0 << endl;
    return 0;
  }
  /*ll sum = 0;
  for(ll i = 0; i <= n; i++){
    ll x = i, cnt = 0;
    while(x > 0 && x % 10 == 0){
      cnt++;
      x /= 10;
    }
    sum += cnt;
  }
  cout << sum << endl;*/
  ll ans = 0;
  for(ll i = 10; i <= n; i *= 5){
    ans = ans + n / i;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3608
#include<stdio.h>
#include<string.h>
#define MAX 1000005
 typedef struct  d{
  char name[11];
  int time;
  char sname[11];
  int stime;
  char Ansname[11];
  int Anstime;
}date;

 
int main(){
  int n,q,i,str,tmp,tmp2,j,k=0;
  date tn[MAX];

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

  for(i=1;i<n+1;i++){
    scanf("%s ",tn[i].name);
     scanf("%d",&tn[i].time);
  }
  tmp2=n+1;
  i=1;
  while(1){
   
    tn[i].stime=(tn[i].time-q);
    if(tn[i].stime>0){
       
     
      tn[tmp2].time=tn[i].stime;
      strcpy(tn[i].sname,tn[i].name);
      strcpy(tn[tmp2].name,tn[i].sname);
      str+=q;
      if(tmp2==n+1){
	tmp2=1;
      }
      else{
	tmp2++;
      }
      if(i==n+1){
	i=1;
      }
      else{
	i++;
      }
      
    }
    else{
     
      str+=tn[i].time;
      tn[k].Anstime=str;
      tn[i].time=0;
      strcpy(tn[k].Ansname,tn[i].name);
      k++;
      strcpy ( tn[i].name," ");
      if(i==n+1){
	i=1;
      }
      else{
	i++;
      }
    }
    if(k==n){
      break;
    }

  }
  for(j=0;j<n;j++){
    printf("%s %d\n",tn[j].Ansname,tn[j].Anstime);
  }
  return 0;
}



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

int main() {
    string s1,s2,s3;cin>>s1>>s2>>s3;
    transform(s1.begin(), s1.end(),s1.begin(), ::toupper);
    transform(s2.begin(), s2.end(),s2.begin(), ::toupper);
    transform(s3.begin(), s3.end(),s3.begin(), ::toupper);
  
    cout<<s1[0]<<s2[0]<<s3[0]<<endl;
	return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <vector>


using ll = long long;
ll r_count, g_count, b_count;
char ch;
int n;
std::string s;

int main() {
    std::cin >> n >> s;
    for (int i = 0; i < n; i++) {
        ch = s[i];
        if (ch == 'R') {
            r_count++;
        }
        else if (ch == 'G') {
            g_count++;
        }
        else {
            b_count++;
        }
    }
    ll num = r_count * g_count * b_count;
    for (int i = 0; i < n; i++) {
        for (int j = i+1; j < n; j++) {
            int p = j - i;
            int k = j + p;
            if (i == j)
                continue;
            if (k >= n) {
                continue;
            }
            if (s[i] != s[j] && s[j] != s[k] && s[i] != s[k]) {
                num--;
            } 
        }
    }
    std::cout << num << std::endl;
}

Measured memory_bytes: 3612
N,K=map(int,input().split())
P=list(map(int,input().split()))
P=[i-1 for i in P]
C=list(map(int,input().split()))
import math
ans=-10**18
for i in range(N):
  x=i
  tot=0
  cycle=[]
  while True:
    x=P[x]
    cycle.append(C[x])
    tot+=C[x]
    if x==i:
      break
  L=len(cycle)
  t=0
  for i in range(L):
    t+=cycle[i]
    if i+1>K:
      break
    now=t
    if tot>0:
      e=(K-i-1)//L
      now+=tot*e
    ans=max(ans,now)

print(ans)

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

#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define vsort(v) sort(v.begin(), v.end());
#define rvisort(v) sort(v.begin(), v.end(), greater<int>());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define int long long
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())
#define pqasc priority_queue<long long, vector<long long>, greater<long long>>

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using ul = unsigned long;

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 GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { return a * b / GCD(a, b); }

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

inline bool inside(int y, int x, int H, int W) {
    return (y >= 0 && x >= 0 && y < H && x < W);
}

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

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  string s; cin>>s;
  int n=s.size();
  vi ans(n);
  int now=0;
  bool flg=false;
  rep(i,n){
    if(flg==false && s[i]=='L'){
      int cnt=i-now;
      ans[i-1]+=(cnt+1)/2;
      ans[i]+=cnt/2;
      flg=true;
    }
    if(flg){
      if(s[i]=='R'){
        now=i;
        flg=false;
      }
    }
  }
  
  flg=false;
  now=n-1;
  rrep(i,n){
    if(flg==false && s[i]=='R'){
      int cnt=now-i;
      ans[i+1]+=(cnt+1)/2;
      ans[i]+=cnt/2;
      flg=true;
    }
    if(flg){
      if(s[i]=='L'){
        now=i;
        flg=false;
      }
    }
  }
  
  rep(i,n) cout<<ans[i]<<endl;
}


Measured memory_bytes: 1488
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
using namespace std;

const int INF = INT_MAX / 2;

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

    vector<int> dp(10, -INF);
    dp[0] = 0;
    for(int i=0; i<n; ++i){
        int s;
        cin >> s;
        vector<int> nextDp = dp;
        for(int j=0; j<10; ++j){
            int k = (j + s) % 10;
            nextDp[k] = max(nextDp[k], dp[j] + s);
        }
        dp.swap(nextDp);
    }

    int ans = max(0, *max_element(dp.begin()+1, dp.end()));
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <iomanip>
#include <utility>
#include <map>
#include <algorithm>
#include <cmath>
#include <set>
#include <unordered_set>
using namespace std;
using int64 = long long;
using vint = vector<int>;
#define ForInt(i, n) for (int (i) = 0; (i) < (n); ++(i))
#define ForIntInit(i, begin, end) for (int i = (begin); i < (end); ++i)
#define ForItr(it, itBegin, itEnd) for (auto (it) = (itBegin); (it) != (itEnd); ++(it))


int main()
{
	int n;
	cin >> n;
	multiset<int> d;
	int tmp;
	ForInt(i, n)
	{
		cin >> tmp;
		d.insert(tmp);
	}

	auto it = d.begin();
	ForInt(i, n / 2)
	{
		++it;
	}
	int arcMin = *it;
	--it;
	int abcMax = *it;
	int kCount = arcMin - abcMax;
	if (kCount < 0)
	{
		kCount = 0;
	}
	cout << kCount << endl;

	return 0;
}


Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define si size()
#define bk back()
#define popb pop_back()
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define endl "\n"
#define lb lower_bound
#define ub upper_bound
#define emp empty()
#define beg begin()
#define en end()
#define ump unordered_map
#define forl(i,a,n) for(int i=a;i<n;i++)
#define rfor(i,n,a) for(int i=n;i>=a;i--)
#define fore(i,a,n) for(int i=a;i<=n;i++)
#define len length()
const int N=1e9+7;
int main()
{
   int n;
   cin>>n;
   int arr[n];
   forl(i,0,n) cin>>arr[i];
   int dp[n];
   //dp[i] means minimum cost to reach (0..i) from 0
   forl(i,0,n) dp[i]=N;
   dp[0]=0;
   forl(i,1,n)
   {
       fore(j,1,2)
       {
           if(i-j>=0) dp[i]=min(dp[i],dp[i-j]+abs(arr[i]-arr[i-j]));
       }
   }
   cout<<dp[n-1]<<endl;
}


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

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

int main() {
	int N, K, x[100000], i, l, r, a, b, min = 2000000000;

	scanf("%d %d", &N, &K);
	for (i = 0; i < N; i++) {
		scanf("%d", &x[i]);
	}


	for (l = 0; (r = l + K - 1) < N; l++) {
		a = abs(x[l]) + abs(x[l] - x[r]);
		b = abs(x[r]) + abs(x[r] - x[l]);
		min = mini(min, mini(a, b));
	}

	printf("%d", min);

	return 0;
}

Measured memory_bytes: 512