akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int compare_string(const void *a, const void *b)
{
  return strcmp(*(const char **)a, *(const char **)b);
}

int main(int argc, char const *argv[])
{
  unsigned int N;
  scanf("%u", &N);

  char **S = malloc(sizeof(char *) * N);
  for (unsigned int i = 0; i < N; i++)
  {
    S[i] = malloc(sizeof(char) * 10);
  }

  for (unsigned int i = 0; i < N; i++)
  {
    scanf("%s", S[i]);
  }

  qsort(S, N, sizeof(char *), compare_string);

  unsigned int get_num = N;
  unsigned int base = 0;
  for (int i = 1; i < N; i++)
  {
    if (strcmp(S[base], S[i]) == 0)
    {
      get_num--;
    }
    else
    {
      base = i;
    }
  }
  printf("%d", get_num);
  return 0;
}

Measured memory_bytes: 10760
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     @hamayanhamayan0
　　　　／　　　＼　 　  |　|
　　　 /　　 /￣￣￣￣/　　|
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿
　 　　　＼/＿＿＿＿/　（u　⊃
---------------------------------------------------------------------------------------------------*/














string S, T;
//---------------------------------------------------------------------------------------------------
void _main() {
	cin >> S >> T;
	int N = S.length();

	int ans = 0;
	rep(i, 0, N) if (S[i] != T[i]) ans++;
	cout << ans << endl;
}







Measured memory_bytes: 3744
#include <algorithm>
#include <iostream>
#include <queue>
#include <stack>
#include <string>
#include <vector>
#define FOR(i, a, b) for (int i = a; i < b; i++)
#define REP(i, n) for (int i = 0; i < n; i++)
using namespace std;

int main() {
    int a, b;
    stack<int> st;
    string s;
    while (cin >> s) {
        if (s == "+") {
            a = st.top();
            st.pop();
            b = st.top();
            st.pop();
            st.push(a + b);
        } else if (s == "-") {
            a = st.top();
            st.pop();
            b = st.top();
            st.pop();
            st.push(b - a);
        } else if (s == "*") {
            a = st.top();
            st.pop();
            b = st.top();
            st.pop();
            st.push(a * b);
        } else {
            st.push(stoi(s));
        }
    }

    std::cout << st.top() << endl;
}


Measured memory_bytes: 3224
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <vector>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using ll = long long;
using namespace std;

int main() {
    int x[5];
    rep(i, 5) { cin >> x[i]; }

    rep(i, 5) {
        if(x[i] == 0) {
            cout << i + 1 << endl;
            break;
        }
    }
}

Measured memory_bytes: 3636
#include <stdio.h>
 
int main(void) {
  int m, f, r;
 
  for (; scanf("%d %d %d", &m, &f, &r) != EOF && !(m == f && f == r && m == -1);) {
    if (m == -1 || f == -1 || (m + f) < 30) { puts("F"); continue; }
    if ((m + f) >= 80) { puts("A"); continue; }
    if ((m + f) >= 65) { puts("B"); continue; }
    if ((m + f) >= 50 || r >= 50) { puts("C"); continue; }
    if ((m + f) >= 30) { puts("D"); continue; }
  }
 
  return 0;
}

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

int main(int argc, char const *argv[])
{
	int n,m;
	cin>>n>>m;
	int a,b,cnt[n]={},memo[n]={};
	set<int> edge[n],tree[n];
	for (int i = 0; i < m; ++i)
	{
		cin>>a>>b,--a,--b;
		edge[a].insert(b);
		edge[b].insert(a);
	}
	if (m%2==1)
	{
		cout<<"-1\n";
		return 0;
	}
	memo[0]=-1;
	queue<int> que;
	que.push(0);
	while (que.size()>0)
	{
		int now=que.front();
		que.pop();
		for (auto i = edge[now].begin(); i != edge[now].end(); ++i)
		{
			if (memo[*i]!=0)
			{
				cout<<now+1<<" "<<(*i)+1<<endl;
				++cnt[now];
				edge[*i].erase(now);
			}
			else
			{
				memo[*i]=memo[now]-1;
				tree[now].insert(*i);
				tree[*i].insert(now);
				edge[*i].erase(now);
				que.push(*i);
			}
		}
	}
	set<pair<int,int>> pri;
	for (int i = 0; i < n; ++i)
	{
		pri.insert(make_pair(memo[i],i));
	}
	for (auto i = pri.begin(); i != pri.end(); ++i)
	{
		auto p=*i;
		for (auto j = tree[p.second].begin(); j != tree[p.second].end(); ++j)
		{
			if (cnt[p.second]%2==0)
			{
				cout<<(*j)+1<<" "<<p.second+1<<endl;
				++cnt[*j];
			}
			else
			{
				cout<<p.second+1<<" "<<(*j)+1<<endl;
			}
			tree[*j].erase(p.second);
		}
	}
	return 0;
}


Measured memory_bytes: 30336
/***********************
*  Author: xuziyuan    * 
***********************/

#include <bits/stdc++.h>

#define rt0 return 0
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define replet(c) for(char c='a';c<='z';c++) 
#define LL long long
#define pii pair <int,int>
#define pb push_back
#define fi first
#define se second
#define mpr make_pair
#define sqr(a) ((a)*(a))

using namespace std;

const LL MOD=1e9+7;

LL n,b,a,h[100010],lb=0,ub=1e9,mid;

bool check()
{
	LL ss=b*mid,ret=0;
	rep(i,n)
	{
		if(h[i]-ss>0) ret+=(h[i]-ss+a-b-1)/(a-b);
	}
	return ret<=mid;
}

int main()
{
	cin>>n>>a>>b;
	rep(i,n) scanf("%lld",&h[i]);
	while(lb<ub)
	{
		mid=(lb+ub)/2;
		if(check()) ub=mid;
		else lb=mid+1;
	}
	cout<<lb<<endl;
	rt0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
typedef vector <ll> vll;
typedef pair <ll, ll> pll;
#define pb push_back
#define mp make_pair
#define MAX 1000000
#define mod 1000000007
#define all(_) _.begin(), _.end()
#define F first
#define S second

int main()
{
    ios_base :: sync_with_stdio(false);
    cin.tie(NULL), cout.tie(NULL);
    ll h, w, i, j;
    cin >> h >> w;
    ll dp[h][w];
    vector <string> s(h);
    for(i = 0; i < h; i++)
        cin >> s[i];
    dp[h - 1][w - 1] = 1;
    for(i = w - 2; i >= 0; i--)
    {
        if(s[h - 1][i] == '#')
            dp[h - 1][i] = 0;
        else
            dp[h - 1][i] = dp[h - 1][i + 1];
    }
    for(i = h - 2; i >= 0; i--)
    {
        if(s[i][w - 1] == '#')
            dp[i][w - 1] = 0;
        else
            dp[i][w - 1] = dp[i + 1][w - 1];
    }
    for(i = h - 2; i >= 0; i--)
    {
        for(j = w - 2; j >= 0; j--)
        {
            if(s[i][j] == '.')
                dp[i][j] = (dp[i + 1][j] + dp[i][j + 1]) % mod;
            else
                dp[i][j] = 0;
        }
    }
    cout << dp[0][0] << endl;
    return 0;
}

Measured memory_bytes: 9088
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
const ll INF = 1e16;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

#ifdef DEBUG
template <class T, class N> void verr(const T& a, const N& n) { rep(i, n) cout << a[i] << " "; cout << "\n"; }
template<class T> void verr(const vector<T>& v){ for(auto& a : v) cout << a << " "; cout << "\n"; }
ll dbgt = 1; void err() { cout << "passed " << dbgt++ << "\n"; }
template<class H, class... T> void err(H&& h,T&&... t){ cout<< h << (sizeof...(t)?" ":"\n"); if(sizeof...(t)>0) err(forward<T>(t)...); }
#endif

void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}
//--------------------------------------------------------------------------------//

int main() {
    init();
    ll N;
    cin >> N;
    vl A(5);
    rep(i, 5) cin >> A[i];

    ll ans = 5;
    ll m = *min_element(all(A));

    ans += (N + m - 1) / m - 1;
    cout << ans << endl;
}

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

int main()
{
    int n,k;cin>>n>>k;
    vector<int> v(n);
    for(int &i:v)cin>>i;
    for(int i=k;i<n;i++){
        if(v[i]>v[i-k])cout<<"Yes\n";
        else cout<<"No\n";
    }
    
}


Measured memory_bytes: 4016
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <cctype>
#include <cassert>
#include <limits>
#include <functional>
#include <iomanip>
#include <complex>
#include <bitset>
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#if defined(_MSC_VER) || __cplusplus > 199711L
#define aut(r,v) auto r = (v)
#else
#define aut(r,v) __typeof(v) r = (v)
#endif
#define each(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it)
#define all(o) (o).begin(), (o).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset(m,v,sizeof(m))
#define INF 0x3f3f3f3f3f3f3f3fLL
#define SIZE 100005

using namespace std;
typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
typedef pair<int,ll> pill; typedef pair<ll,int> plli; 
typedef pair<double, int> pdi;
template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }
typedef complex<double> P;
long long int MOD = 1000000007;

int N;
ll A[SIZE];
vi hen[SIZE];
bool ans=true;
ll dfs(int a,int fr){
	ll score=A[a];
	if(hen[a].size()>1)score*=(ll)2;//2*score-sum 
	for(int i=0;i<hen[a].size();i++){
		if(hen[a][i]==fr)continue;//skip
		ll hoge=dfs(hen[a][i],a);
		if(hoge>A[a])ans=false;
		score-=hoge;
	}
	if(score>A[a])ans=false;
	if(score<0)ans=false;
	if(fr==-1&&score!=0)ans=false;
	return score;
}
int main()
{

 
	//ios_base::sync_with_stdio(0);
	//cin.tie(0);
	cin>>N;
	for(int i=0;i<N;i++){
		cin>>A[i];
	}
	for(int i=0;i<N-1;i++){
		int a,b;
		cin>>a>>b;a--;b--;
		hen[a].pb(b);
		hen[b].pb(a);
	}
	if(N==2){
		if(A[0]==A[1])cout<<"YES"<<endl;
		else cout<<"NO"<<endl;
		return 0;
	}
	int from=-1;
	for(int i=0;i<N;i++){
		if(hen[i].size()>1){
			from=i;
			break;
		}
	}
	dfs(from,-1);
	if(ans)cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
}

Measured memory_bytes: 13184
/*Ph@n^0m Dec0d3r*/
/*----------------*/
/* 	^_HAR HAR MAHADEV_^
   	|Om namah shivaya|
*/
#include<bits/stdc++.h>
//#include<boost/multiprecision/cpp_int.hpp>
#define f(i,a,b) for(int i=a;i<b;i++)
#define ll long long int
#define fast std::ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define pb(temp) push_back(temp)
#define mp make_pair
#define mod (ll)1000000007
//using namespace boost::multiprecision;
using namespace std ;
typedef unsigned long long int ulli;

ulli gcd(ulli x,ulli y)
{
    if(x==0) return y;
    return gcd(y%x,x);
}
ulli factorial(ulli n)
{
    if (n == 0)
    return 1;
    return n * factorial(n - 1);
}
ll findS(ll s)
{
	return (sqrtl(8*s + 1) - 1)/2;
}
ll prime(ll a){
    if(a==1)return 0;
    if(a==2 || a==3)return true;
    if(a%2==0 ||a%3==0)return 0;
    for(ll i=5;i<=sqrt(a);i+=6)
        if(a%i==0 || a%(i+2)==0)
            return 0;

    return 1;
}
ll power(ll x,ll y)
{
    if (y == 0)
        return 1;
    ll p = power(x, y/2) % mod;
    p = (p * p) % mod;

    return (y%2 == 0)? p : (x * p) % mod;
}
ll powermod(ll x,ll y)
{
    ll res = 1;
    x = x % mod;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % mod;
        y = y>>1;
        x = (x*x) % mod;
    }
    return res;
}
ll nCr(ll n,ll k)
{
    ll C[k+1];
    //memset(C, 0, sizeof(C));

    C[0] = 1;

    for (ll i = 1; i <= n; i++)
    {
        for (ll j = min(i, k); j > 0; j--)
            C[j] = (C[j] + C[j-1])%(ll)(1e9 + 7);
    }
    return C[k];
}
ll LOGN(ll n , ll r){
	return (n > r-1) ? (1 + LOGN(n / r , r)) : 0 ;
}
void dfs(vector<ll> v[], bool visited[], ll current_node){
	visited[current_node]=true;
	for(ll nxt_node : v[current_node]){
		if(visited[nxt_node]==false){
			dfs(v , visited, nxt_node);
		}
	}
	return;
}

void bfs(vector<ll> v[], bool visited[], ll root){

    int current_node;
    queue<int> q;

    q.push(root);

    while(!q.empty()){

        current_node=q.front();

        visited[current_node]=true;

        for(int x:v[current_node])
            if(!visited[x])
                q.push(x);
    }
}
ll computeXOR(ll n)
{
    switch(n & 3)
    {
    case 0: return n;     
    case 1: return 1;     
    case 2: return n + 1;
    case 3: return 0;    
    }
}
int maxSubArraySum(int a[], int size)
{
   int max_so_far = a[0];
   int curr_max = a[0];
   for (int i = 1; i < size; i++)
   {
        curr_max = max(a[i], curr_max+a[i]);
        max_so_far = max(max_so_far, curr_max);
   }
   return max_so_far;
}
int main(){
	fast;
	string s , t ;
  cin >> s >> t ;
  string m = t + s ;
  cout << m ;
}


Measured memory_bytes: 256
s = input()
x = len(s) - 1
m = 0
n = 1
c = 0
while m <= x:
  if s[m] == 'L':
    c += 1
  m += 2
while n <= x:
  if s[n] == 'R':
    c += 1
  n += 2
if c == 0:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 3064
#include <bits/stdc++.h>
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>*/
 
#define pll              pair <long long,long long>
#define pb               push_back
#define ll               long long
#define ff               first
#define ss               second
#define D(x)             cerr<<#x " = "<<(x)<<endl
#define vll              vector <ll>
#define IOS              ios_base::sync_with_stdio(0); cin.tie(NULL);
#define endl             '\n'   
using namespace std;

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

int main()
{
    IOS
 	// freopen("input.txt","r",stdin);
 	// freopen("output.txt","w",stdout);
 	// freopen("error.txt","w",stderr);
	ll n;
	cin>>n;
	ll a[n];
	bool f[1000001]={0};
	bool vis[1000001]={0};
	ll gc=0;
	bool hmo=false;
	for(ll& x:a)
	{
		cin>>x;
		if(!f[x])
			f[x]=true;
		else if(x>1)
			hmo=true;
		gc=gcd(gc,x);
	}
	for(ll i=2;i<1000001;i++){
		if(vis[i])
			continue;
		ll cnt=f[i];
		for(ll j=2*i;j<1000001;j+=i){
			vis[j]=true;
			if(f[j])
				cnt++;
		}	
		if(cnt>=2 || hmo){
			if(gc==1)
			{
				cout<<"setwise coprime"<<endl;
				return 0;
			}
			else
			{
				cout<<"not coprime"<<endl;
				return 0;
			}
		}
	}
	cout<<"pairwise coprime"<<endl;
    return 0;
}

Measured memory_bytes: 13328
import sys
from collections import defaultdict, Counter, namedtuple, deque
import itertools
import functools
import bisect
import heapq
# import math
from fractions import gcd

MOD = 10 ** 9 + 7
# MOD = 998244353
# sys.setrecursionlimit(10**8)

a, v = map(int, input().split())
b, w = map(int, input().split())
t = int(input())
if v <= w:
    print("NO")
    exit()

dis = t*(v-w)
if dis >= abs(a-b):
    print("YES")
else:
    print("NO")


Measured memory_bytes: 72508
#include <bits/stdc++.h>
using namespace std;
int main(void){
   int N;
   cin >> N;
   int64_t sum=0;
   for(int i=1;i<N+1;i++) {
       if (i%3 != 0 && i%5 != 0) {
           sum+=i;
       }
   }
   cout << sum << endl;
   
} 


Measured memory_bytes: 3628
#include <iostream>
#include <vector>
#include <string>
#include <cstdlib>
#include<algorithm> 
#include <iomanip>
#include <math.h>
#include <cctype>
//小文字を大文字 c-0x20;


#define db double
#define vi vector<int>
#define pb push_back
#define fi first
#define se second
#define ll long long
#define ld long double
#define maxn 5005
#define mod 998244353
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vll vector<ll>
#define vpi vector<pii>
#define vpll vector<pll>
#define vv(z,a,b) vector<vector<int>>z(a,vector<int>(b))
#define vvll(z,a,b) vector<vector<ll>>z(a,vector<ll>(b))
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(c) c.begin(),c.end()
#define fix(k) fixed<<setprecision(k)
#define PI 3.141592653589793
#define sizestr(i,x)  size_t i=x.length();
using namespace std;



int main(){
ll a,v;cin>>a>>v;
ll b,w;cin>>b>>w;
ll t;cin>>t;

if(w>=v){
    cout<<"NO"<<endl;
    return 0;
}
ll sd=abs(a-b);
ll spd=abs(v-w);
ll sum=t*spd;
if(sum<sd){
    cout<<"NO"<<endl;
return 0;}
cout<<"YES"<<endl;

}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
     
int main() {
	long int N;
    cin >> N;
      
    long int count = 0;
    for(long int i=1; i<= N; i++){
    	if(i%15!=0){
    		if(i%3!=0){
    			if(i%5!=0){
    				count = count + i;
    			}
    		}
      	}
    }
    cout << count << endl;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a), i##_max = (b); i < i##_max; ++i)
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()

using namespace std;

constexpr int INF = 1 << 30;
constexpr int MOD = 1000000007;

int selection_sort(vector<int> &A) {
  int cnt = 0;
  REP(i, A.size()) {
    auto minj = i;
    FOR(j, i, A.size()) {
      if (A[j] < A[minj]) minj = j;
    }
    swap(A[i], A[minj]);
    if (i != minj) ++cnt;
  }
  return cnt;
}

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  REP(i, N) cin >> A[i];
  auto cnt = selection_sort(A);
  REP(i, N) {
    if (i) cout << " ";
    cout << A[i];
  }
  cout << endl << cnt << endl;
}



Measured memory_bytes: 3076
#include <iostream>
#include <algorithm>
using namespace std;
int main() 
{
	int n;
	int a[205];
	while(cin >> n)
	 {
		for(int i = 0; i < 2 * n; i ++)         
		   cin >> a[i];
		sort(a , a + 2 * n);
		int ans = 0;
		for(int i = 2 * n - 1; i >= 0 ; i -= 2)          
		  ans += a[i - 1];
		cout << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
const int MAX = 700000;
const int MOD = 1000000007;

long long  fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
/*第二引数で第一引数を割ったときの切り上げの計算*/
long long int maxtime(long long int x, long long int y){
	return(x + y - 1) / y;

}
/*最大公約数*/
long long int lcm(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;

	if (number2 > number1) {
		m = number2;
		n = number1;
	}
	long long int s = -1;
	while (s != 0) {
		s = m % n;
		m = n;
		n = s;
	}
	return m;
}
/*最大公倍数*/
long long int gcd(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;
	return m / lcm(m, n) * n;
}
/*逆元計算*/
long long int  modinv(long long a, long long m) {
	long long int b = m, u = 1, v = 0;
	while (b) {
		long long int t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
// index が条件を満たすかどうか
vector<long long int >meguru;
bool isOK(int index, int key) {
	if (meguru[index] >= key) return true;
	else return false;
}
// 汎用的な二分探索のテンプレ
int binary_search(int key) {
	int left = -1; //「index = 0」が条件を満たすこともあるので、初期値は -1
	int right = (int)meguru.size(); // 「index = a.size()-1」が条件を満たさないこともあるので、初期値は a.size()
	/* どんな二分探索でもここの書き方を変えずにできる！ */
	while (right - left > 1) {
		int mid = left + (right - left) / 2;

		if (isOK(mid, key)) right = mid;
		else left = mid;
	}
	/* left は条件を満たさない最大の値、right は条件を満たす最小の値になっている */
	return right;
}
long long modpow(long long a, long long n, long long mod) {
	long long res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}

int main() {
	long long int n, k;
	cin >> n >> k;
	if (n <= k) {
		cout << min(k - n, n);
		return 0;
	}
	else {
		long long int c = n;
		n = n % k;
		cout << min(n, k - n);
	}
}

Measured memory_bytes: 256
import sys

input = sys.stdin.readline
N = int(input())
D = [list(map(int, input().split())) for _ in range(N)]
cnt = 0
for d1, d2 in D:
    if d1 == d2:
        cnt += 1
    else:
        cnt = 0
    if cnt == 3:
        print('Yes')
        sys.exit(0)

print('No')


Measured memory_bytes: 61928
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repe(i,n) for (int i = 0; i <= (n); ++i)
#define repe1(i,n) for (int i = 0; i <= (n); ++i)
#define all(x) (x).begin(),(x).end()
#define pb(x) push_back(x)
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef long long ll;
const int INF = 1e9;
const ll mod = 1000000007;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a * b / gcd(a, b);}

ll pow_kai(ll a, ll n) {
    ll x = 1;
    while(n > 0) {
        if(n&1) {
            x = x*a;
        }
        a = a*a;
        n >>= 1;
    }
    return x;
}

int main() {
    int n,a,b;
    cin >> n >> a >>b;
    int res = 0;
    for(int i=1; i<=n; ++i) {
        int sum = 0;
        string num = to_string(i);
        rep(j,num.size()){
            int numm = num[j]-'0';
            sum += numm;
        }
        if (sum >= a && sum<=b) {
            res += i;
        }
    }
    cout << res << "\n";
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		boolean[] isNotPrimes = new boolean[100001];
		isNotPrimes[0] = true;
		isNotPrimes[1] = true;
		for (int i = 2; i < isNotPrimes.length; i++) {
		    if (!isNotPrimes[i]) {
		        for (int j = 2; i * j < isNotPrimes.length; j++) {
		            isNotPrimes[i * j] = true;
		        }
		    }
		}
		int[] counts = new int[100001];
		for (int i = 1; i < counts.length; i++) {
		    counts[i] = counts[i - 1];
		    if (!isNotPrimes[i] && !isNotPrimes[(i + 1) / 2]) {
		        counts[i]++;
		    }
		}
		int q = sc.nextInt();
		StringBuilder sb = new StringBuilder();
		for (int i = 0; i < q; i++) {
		    sb.append(- counts[sc.nextInt() - 1] + counts[sc.nextInt()]).append("\n");
		}
        System.out.print(sb);
    }
}



Measured memory_bytes: 68768
#include<bits/stdc++.h>
using namespace std;
 
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long
#define ull unsigned long long
#define db double
#define rep(i,a,b)    for(ll i=a;i<b;i++)
#define repn(i,a,b)   for(ll i=a;i>=b;i--)
#define F first
#define S second
#define qi queue<ll>
#define pii pair<ll,ll>
#define vi vector<ll>
#define si set<ll>
#define vii vector<pii>
#define mi multiset<ll>
#define mii multiset<pii>
#define MI map<ll,ll>
#define pb push_back
#define mp  make_pair
#define all(v) (v).begin(), (v).end()
#define allr(v) (v).rbegin(), (v).rend()
#define mod 998244353
#define mod2 998244353

const ll N=1e12;

int fexp(int a, int b){int ans = 1;while(b){if(b&1) ans = ans*a%mod2; b/=2;a=a*a%mod2;}return ans;}
int inverse(int a, int p){return fexp(a, p-2);}

ll solve(){
    ll a;
    cin>>a;
    vi v(2*a,0);
    rep(i,0,2*a) cin>>v[i];
    sort(all(v));
    cout<<v[a+1]-v[a]<<"\n";
    return 0;
}

signed main(){
    IOS
// 	#ifndef ONLINE_JUDGE
//     	freopen("input.txt", "r", stdin);
// 		freopen("output.txt", "w", stdout);
// 	#endif
    ll n;
    cin>>n;
    if(n>=30) cout<<"Yes";
  	else cout<<"No";
    return 0;
}
// size_t f= str.find(string s,0); find s in str from start
// if found then (f != string::npos)
// m.insert({x,y}); m[x]=y;

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

using namespace std;

const int NMAX = 1e5;

int ans = 0;
int n;
int v[NMAX + 5];
int sgn[NMAX + 5];

int main() {

    cin >> n;
    for(int i = 1;i <= n;i++){
        cin >> v[i];
    }
    
    sort(v + 1,v + 1 + n);
    swap(v[1],v[n]);
    swap(v[2],v[n]);
    
    for(int i = 1;i <= n;i++){
        if(i == 1){
            ans += v[i];
            sgn[i] = 1;
        }
        else if(i == 2){
            ans -= v[i];
            sgn[i] = - 1;
        }
        else{
            ans += (v[i] < 0 ? -v[i]:v[i]);
            sgn[i] = (v[i] < 0 ? -1:1);
        }
    }

    cout << ans << "\n";

    int fst = 1;
    int snd = 2;

    for(int i = 1;i < n - 1;i++){
        if(sgn[snd + 1] == 1){
            cout << v[snd] << " " << v[snd + 1] << "\n";
            v[snd + 1] = v[snd] - v[snd + 1];
            snd++;
        }
        else{
           cout << v[fst] << " " << v[snd] << "\n";
           v[snd] = v[fst] - v[snd];
           fst = snd;
           snd++;
        }
    }

    cout << v[fst] << " " << v[snd] << "\n";

    v[fst] -= v[snd];

    cerr << v[fst] << "\n";
    return 0;
}


Measured memory_bytes: 2688
#include<queue>
#include<stack>
#include<math.h>
#include<cmath>
#include<bitset>
#include<stdio.h>
#include<string>
#include<map>
#include<algorithm>
#include<vector>
#include<iostream>
#include<utility>
#include<functional>
#include<deque>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int main(){
  int i,n,a,b,p,x=0,y=0,z=0;
  cin >> n >> a >> b;
  for(i=0;i<n;i++){
    cin >> p;
    if(p<=a){
      x++;
    }
    else if(p<=b){
      y++;
    }
    else{
      z++;
    }
  }
  cout << min(x,min(y,z)) << endl;;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>

int main()
{
    std::string S, T;
    std::cin >> S;
    std::cin >> T;

    int ans = 0;

    for(int i=0; i<S.size(); i++){
        if(S[i] != T[i]){
            ans++;
        }
    }

    std::cout << ans << std::endl;

    //int end;
    //std::cin >> end;
    return 0;
}

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

#include<cstdio>
#define r(i,n) for(int i=0;i<n;i++)


int main(void){
    string s;
    cin>>s;
    string b=s;
    reverse(s.begin(),s.end());
    if(b==s)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;



return 0;

}


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

int main() {
    int N;
    cin>>N;
    string S;
    int endA = 0, startB = 0, ABnum = 0, BAnum = 0;
    for(int i=0;i<N;++i){
        cin>>S;
        for(int j=0;j<S.size()-1;++j){
            if(S[j] == 'A' & S[j+1] == 'B') ABnum++;
        }
        if(S[0]=='B' & S[S.size()-1]!='A') startB++;
        if(S[S.size()-1]=='A' & S[0]!='B') endA++;
        if(S[0]=='B' & S[S.size()-1]=='A') BAnum++;
    }
    if(BAnum>0){
        if(endA>0 | startB>0){
            cout<<ABnum+min(endA, startB) + BAnum;
        }
        else {
            cout<<ABnum+(BAnum-1);
        }
    }
    else{
        cout<<ABnum+min(endA, startB)<<endl;
    }
}


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

const int Maxn = 3;

int a[Maxn];

int main()
{
	for (int i = 0; i < Maxn; i++)
		scanf("%d", &a[i]);
	sort(a, a + Maxn);
	printf("%d\n", a[Maxn - 1] - a[0]);
	return 0;
}

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

int main(){
  int n, q;
  int a, b;
  cin >> n >> q;
  vector<vector<int>> connection(n+1);
  vector<vector<int>> children(n+1);
  vector<int> root(n+1, -1);
  vector<int> addvtx(n+1, 0);
  for (int i = 0; i < n-1; i++){
    cin >> a >> b;
    connection.at(a).push_back(b);
    connection.at(b).push_back(a);
  }
  for(int i = 0; i < q; i++){
    cin >> a >> b;
    addvtx.at(a) += b;
  }
  
  queue<int> rootcheck;
  rootcheck.push(1);
  int now;
  while(!rootcheck.empty()){
    now = rootcheck.front();
    rootcheck.pop();
    for(int child : connection.at(now)){
      if(child != root.at(now)){
        root.at(child) = now;
        rootcheck.push(child);
        children.at(now).push_back(child);
      }
    }
  }
  rootcheck.push(1);
  while(!rootcheck.empty()){
    now = rootcheck.front();
    rootcheck.pop();
    for(int child : children.at(now)){
      addvtx.at(child) += addvtx.at(now);
      rootcheck.push(child);
    }
  }
  for(int i = 1; i <= n; i++){
    cout << addvtx.at(i);
    if(i == n) cout << endl;
    else cout << ' ';
  }
}

Measured memory_bytes: 25856
#include <bits/stdc++.h>
using namespace std;
const long long mod = pow(10, 9) + 7;
const long long MOD = 998244353;
const long long INF = 1LL << 60;
const int inf = pow(10, 9) + 7;
template <class T> bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template <class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
int divCeil(int A, int B) {return (A + (B - 1)) / B;}
long long divCeil(long long A, int B) {return (A + (B - 1)) / B;}
long long divCeil(int A, long long B) {return (A + (B - 1)) / B;}
long long divCeil(long long A, long long B) {return (A + (B - 1)) / B;}

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

  int ans = 0;
  for (int i = 0; i <= A; i++)
  {
    for (int j = 0; j <= B; j++)
    {
      for (int k = 0; k <= C; k++)
      {
        if (i * 500 + j * 100 + k * 50 == X)
          ans++;
      }
      
    }
    
  }
  

  cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>
#define rad M_PI/3
#define N 2000200000
#define Max 10000
#define NTL -1
int main(){
  int n,m,i,j,k,l,q;
  int M[101],MM[101][101];
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d%d",&M[i],&m);
  }
  M[n]=m;
  for(i=1;i<n+1;i++){
    MM[i][i]=0;
  }
  for(i=2;i<n+1;i++){
    for(j=1;j<n-i+2;j++){
      k=i+j-1;
      MM[j][k]=N;
      for(l=j;l<=k-1;l++){
        q=(MM[j][l]+MM[l+1][k]+M[j-1]*M[l]*M[k]);
        if(MM[j][k]>q){
          MM[j][k]=q;
        }
      }
    }
  }
  printf("%d\n",MM[1][n]);
  return 0;
}


Measured memory_bytes: 2100
#include<bits/stdc++.h>
using namespace std;
#define    For(i,n) for(int i=0;i<n;i++)
#define    fors(i,s) for(int i=0;i<s.size();i++)
#define    forn(i,n) for(int i=1;i<=n;i++)
#define    nl     "\n"
#define    test  int T;cin>>T;for(int X=0;X<T;X++)
#define    pb     push_back
#define    End    return 0
#define    ll     long long int

int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    
    //test 
    {
        int n;
        cin>>n;
        string s="ACL";
        For(i,n)cout<<s;
    }
}


Measured memory_bytes: 3636
/*Lucky_Glass*/
#include<cstdio>
int Query(int ans)
{
	char ret[20];
	printf("%d\n", ans);
	fflush(stdout);
	scanf("%s", ret);
	if(ret[0] == 'V') return 2;
	return ret[0] == 'M' ? 1 : 0;
}
int n;
int main()
{
	scanf("%d",&n);
	int res0=Query(0);
	if(res0==2) return 0;
	int l=0,r=n-1;
	while(true)
	{
		int mid=(l+r)>>1;
		int res_mid=Query(mid);
		if(res_mid==2) return 0;
        if(res_mid!=res0)
		{
			if(mid%2) l=mid+1;
			else r=mid;
		}
		else
		{
			if(mid%2) r=mid;
			else l=mid+1;
		}
	}
	Query(r);
	return 0;
}


Measured memory_bytes: 760
#include<bits/stdc++.h>
#define ll long long
ll n,k,ans;
using namespace std;
int main()
{
	scanf("%lld%lld",&n,&k);
	if(k==0){
		cout<<n*n<<endl;
		return 0;
	}
	for(int b=k+1;b<=n;++b)
	{
		ans+=(b-k)*(n/b);
		ans+=max((ll)0,n%b-k+1);
	}
	
	cout<<ans;
}
  

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<climits>
#include<string>
#include<vector>
#include<list>
#include<map>
#include<set>
#include<cmath>
#include<queue>
#include<cstring>
#include<stack>
#include<functional>
using namespace std;

int main(){
	int s[15] = {0,1,2,3,4,5,6,7,8,9,5,4,3,2,1};
	int N;
	cin>>N;
	for(int ds=0;ds<N;ds++){
		int A,B;
		cin>>A>>B;
		vector<int> ans;
		int ss = find(s,s+15,A)-s, d = 0;
		for(int i=0;i<15;i++, d++){
			if(s[(ss+i)%15]==A){
				d = 0; ans.clear();
			}
			ans.push_back(s[(ss+i)%15]);
			if(s[(ss+i)%15]==B) break;
		}
		printf("%d",ans[0]); for(int i=1;i<ans.size();i++) printf(" %d",ans[i]); puts("");
	}
	return 0;
}

Measured memory_bytes: 1196
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
const int N=100000;
const int C=31;
const int T=100000;
ll n,c,t,cha[C][T],s,ans,co,w;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	ans = 0;
	CLR(cha);
	cin >> n >> co;
	FOR(i,0,n){
		cin >> s >> t >> c;
		for(ll i=s;i<=t;i++){
			cha[c][i] = 1ll;
		}
	}

	FOR(i,0,100000){
		w=0;
		FOR(j,0,co+1){
			if(cha[j][i])w++;
		}
		ans = max(ans,w);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 24576
#include<stdio.h>
#include<string.h>
#include<math.h>
int main(void){
  double x1, x2, y1, y2;
  double distance;
  scanf("%lf %lf %lf %lf", &x1, &y1, &x2, &y2);
  distance = hypot(x2-x1, y2-y1);
  printf("%.8f\n", distance);
  return 0;
}



Measured memory_bytes: 2068
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>

using namespace std;

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

using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

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

    int n;
    cin >> n;
    string s;
    cin >> s;

    int res = 0;
    for (int i = 0; i < n-2; i++)
    {
        if (s[i] == 'A' && s[i+1] == 'B' && s[i+2] == 'C') res++;
    }
    cout << res << "\n";
}

Measured memory_bytes: 256
import Data.Maybe
import Control.Monad
import qualified Data.ByteString.Char8 as C

readInteger' = fst.fromJust.C.readInteger
readLnInteger = map readInteger'.C.words<$>C.getLine
readCsInteger n = concat<$>replicateM n readLnInteger

x ? (a,b) = if x then a else b
half = flip div 2
aliq = ((0==).).mod

main = do
 [l,r] <- readLnInteger
 print $ solve [l,r]

solve [l,r]
 | any (\x -> aliq x 2019) [l..r] = 0 
 | otherwise = minimum' 2019 [mod (i*j) 2019 | i <- [l..r], j <- [l..r], i<j]

minimum' t (a:x) = (null x)?(ans, minimum' ans x) where
  ans = (t<a)?(t,a)


Measured memory_bytes: 1148
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

cur, goal = map(int,input().split())

ans = 1e10
if cur <= goal:
    ans = min(ans, goal - cur)
if cur <= -goal:
    ans = min(ans, 1 + (-goal - cur))
if -cur <= goal:
    ans = min(ans, 1 + (goal + cur))
if -cur <= -goal:
    ans = min(ans, 2 + (-goal + cur))
print(ans)


Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<map>
using namespace std;
typedef long long ll;
int main(){
  string s;
  cin>>s;
  if(s[0]==s[1]&&s[1]==s[2]) cout<<"No"<<endl;
  else cout<<"Yes"<<endl;
}


Measured memory_bytes: 256
#include<cstdio>


using namespace std;

using ll=long long;


ll gcd(ll a, ll b)
{
	ll c;

	while((c=a%b))
	{
		a=b;
		b=c;
	}
	return b;
}


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


int main(void)
{
	int n;

	while(scanf("%d", &n)==1)
	{
		ll ans=1;

		for(int i=0;i<n;i++)
		{
			ll t;
			scanf("%lld", &t);
			ans=lcm(ans, t);
		}
		printf("%lld\n", ans);
	}

	return 0;
}


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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << setprecision(20) << fixed;
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  if(A + B > C + D) cout << "Left" <<endl;
  else if(A + B == C + D) cout << "Balanced" <<endl;
  else cout << "Right" <<endl;
} 


Measured memory_bytes: 3608
import sys
import math
import itertools
import collections
import heapq
import re
import numpy as np
from functools import reduce

rr = lambda: sys.stdin.readline().rstrip()
rs = lambda: sys.stdin.readline().split()
ri = lambda: int(sys.stdin.readline())
rm = lambda: map(int, sys.stdin.readline().split())
rl = lambda: list(map(int, sys.stdin.readline().split()))
inf = float('inf')
mod = 10**9 + 7

o = rr()
e = rr()
s = ''
for a, b in itertools.zip_longest(o, e, fillvalue=''):
  s += a + b
print(s)








Measured memory_bytes: 27028
#include <bits/stdc++.h>
#define fi first
#define se second
using namespace std;

int main() {
    ios::sync_with_stdio(0); cin.tie(0);
    int n, m;
    cin >> n >> m;
    vector<bool> broken(n + 1);
    for(int x; m--; )
        cin >> x, broken[x] = true;
    vector<int> dp(n + 1);
    int constexpr MOD = (int) 1e9 + 7;
    dp[0] = 1;
    dp[1] = broken[1] == false;
    for(int i = 2; i <= n; ++i) {
        if(!broken[i - 2])
            dp[i] += dp[i - 2];
        if(!broken[i - 1])
            dp[i] += dp[i - 1];
        if(dp[i] >= MOD)
            dp[i] -= MOD;
    }
    cout << dp[n] << '\n';
}

Measured memory_bytes: 640
#include <stdio.h>
#include <math.h>

int main(void)
{
  int x, y;
  
  scanf("%d %d", &x, &y);
  
  if( y % 2 == 1 ){
      printf("No\n");
      return 0;
  }
  
  if( 2*x <= y && y <= 4*x ){
      printf("Yes\n");
  } else {
      printf("No\n");
  }
  return 0;
}

Measured memory_bytes: 1644
using System;
using System.Linq;

namespace ABC044_C_TakAndCards
{
    /// <summary>
    /// 復習
    /// </summary>
    public static class ABC044_C_Review
    {
        static void Main(string[] args)
        {
            string[] split = Console.ReadLine().Split(' ');
            int N = int.Parse(split[0]);
            int A = int.Parse(split[1]);

            int[] X = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();

            // 場合の数[選んだ枚数, 合計]のDP表
            int S = X.Sum();
            ulong[,] dp = new ulong[N + 1, S + 1];
            dp[0, 0] = 1;

            foreach (int x in X)
            {
                for (int i = N; i >= 0; i--)
                {
                    for (int j = S; j >= 0; j--)
                    {
                        if (dp[i, j] == 0)
                        {
                            continue;
                        }

                        dp[i + 1, j + x] += dp[i, j];
                    }
                }
            }

            ulong answerCount = 0;
            for (int i = 1; i <= N; i++)
            {
                for (int j = 0; j <= S; j++)
                {
                    if (j == A * i)
                    {
                        answerCount += dp[i, j];
                    }
                }
            }

            Console.WriteLine(answerCount);
        }
    }
}


Measured memory_bytes: 3800
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(a,b) for(int a=0;a<(b);++a)
#define REP1(i,n) for(int i=1;i<=(n);++i)
#define debug(x) cerr<<#x<<": "<<x<<'\n'
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair
#define INF (1<<29)
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

template<class T=int>
T in(){T x;cin>>x;return (x);}
template<class T>
void print(T& x){cout<<x<<'\n';}

const int MOD =(int)1e9+7;
const int MAX =510000;
ll fac[MAX],finv[MAX],inv[MAX];
void COMint(){
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    for(int i=2;i<MAX;i++){
        fac[i]=fac[i-1]*i%MOD;
        inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
        finv[i]=finv[i-1]*inv[i]%MOD;
    }
}
ll COM(int n,int k){
    if(n<k) return 0;
    if(n<0||k<0)return 0;
    return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}
ll gcd(ll a,ll b){
    if(b==0)return a;
    if(a>b){
        swap(a,b);
    }
    return gcd(a,b%a);
}
ll lcm(ll a,ll b){
    ll g;g=gcd(a,b);
    return a*b/g;
}
bool compare_by_b(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}

bool compare_by_a(pair<int, int> a, pair<int, int> b) {
    if(a.first != b.first){
        return a.first < b.first;
    }else{
        return a.second < b.second;
    }
}
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
ll RS(ll N,ll P,ll M){
    if(P==0){
        return 1;
    }else{
        if(P%2==0){
            ll t=RS(N,P/2,M);
            return t*t%M;
        }else{
            return N*RS(N,P-1,M)%M;
        }
    }
}
ll INV(ll a){
    return RS(a,MOD-2,MOD);
}
ll c(ll n,ll a){
    ll bunbo=1;
    ll bunshi=1;
    
    REP1(i,a){
        bunbo*=i;
        bunbo%=MOD;
        bunshi*=n+1-i;
        bunshi%=MOD;
    }
    return (bunshi*INV(bunbo)%MOD);
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N=in();
    REP(i,N){
        int a;
        cin>>a;

        if(a%2==0&&a%3!=0&&a%5!=0){
            cout<<"DENIED"<<endl;
            return 0;
        }
    }
    cout<<"APPROVED"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
    int a,b;
    scanf("%d %d",&a,&b);
    
    if (a<b) {
        printf("a < b\n");
    }
    
    else if (a>b){
        printf("a > b\n");
    }
    
    else{
        printf("a == b\n");
    }
    
    return 0;
}

Measured memory_bytes: 580
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        
        Scanner scan = new Scanner(System.in);
        String number = scan.next();
        
        int digit = 0;
        
        int numberin = number.length();
        
        int l = Integer.valueOf(number);
        for(int i = 0 ; i < numberin ; i++){
            digit = digit + Integer.valueOf(number.substring(i , i + 1));
        }
        
        int ans = l % digit;
        
        if(ans != 0) {
            System.out.println("No");
        } else {
            System.out.println("Yes");
        }
    }
}

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

int main(){
	// sengen
	long long a,b,c,k; 
	// nyuryoku
	cin >> a >> b >> c >> k;
	// keisan
	if(k<a){
		cout << k;
	}else if(k <= a+b){
		cout << a;
	}else if(k > a + b){
		cout << a - (k - a - b);
	}
	// syutsuryoku
}

Measured memory_bytes: 3636
N, Q = map(int, input().split())
S = str(input())

q_list = [0] * Q

for q in range(Q):
    q_list[q] = list(map(int, input().split()))

ac_list = [0] * len(S)
count = 0
for i in range(1, len(S)):
    if S[i - 1] == 'A' and S[i] == 'C':
        count += 1
        ac_list[i] = count
    else:
        ac_list[i] = count

for item in q_list:
    l, r = item[0], item[1]

    print(ac_list[r - 1] - ac_list[l - 1])

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

#define max(X, Y) ((X) > (Y) ? (X) : (Y))
#define min(X, Y) ((X) < (Y) ? (X) : (Y))

typedef long long ll;

ll n;
ll sum[2 * 100005];

int main()
{
	ll ans;

	scanf("%lld", &n);
	for (ll i = 1; i <= n; i++) {
		scanf("%lld", &sum[i]);

		sum[i] = sum[i] + sum[i - 1];
	}
	sum[n + 1] = sum[n] * 2;

	ans = sum[n + 1];
	// left, mid, right;
	// sum[left], sum[mid] - sum[left], sum[right] - sum[mid], sum[n] - sum[right]

	for (ll mid_part = 2; mid_part <= n - 2; mid_part++) {
		ll left_part, right_part;
		ll valid, invalid;
		ll key;

		valid = 1; invalid = mid_part;
		key = sum[mid_part] / 2;
		while (llabs(invalid - valid) > 1) {
			ll mid = (valid + invalid) / 2;

			if (sum[mid] <= key) {
				valid = mid;
			} else {
				invalid = mid;
			}
		}
		left_part = valid;
		if (llabs(sum[mid_part] - sum[left_part] - sum[left_part])
				> llabs(sum[mid_part] - sum[left_part + 1] - sum[left_part + 1]) &&
				left_part + 1 < mid_part) {
			left_part = left_part + 1;
		}

		valid = mid_part + 1; invalid = n + 1;
		key = (sum[n] - sum[mid_part]) / 2;
		while (llabs(invalid - valid) > 1) {
			ll mid = (valid + invalid) / 2;

			if (sum[mid] - sum[mid_part] <= key) {
				valid = mid;
			} else {
				invalid = mid;
			}
		}
		right_part = valid;
		if (llabs((sum[n] - sum[right_part]) - (sum[right_part] - sum[mid_part]))
				> llabs((sum[n] - sum[right_part + 1]) - (sum[right_part + 1] - sum[mid_part])) &&
				right_part + 1 < n) {
			right_part = right_part + 1;
		}

		/*
		printf("%lld : %lld : %lld\n", left_part, mid_part, right_part);
		printf("%lld, %lld, %lld, %lld\n", sum[left_part], sum[mid_part] - sum[left_part],
				sum[right_part] - sum[mid_part], sum[n] - sum[right_part]);
				*/

		ans = min(ans, max(sum[left_part], max(sum[mid_part] - sum[left_part], max(sum[right_part] - sum[mid_part], sum[n] - sum[right_part]))) -
				min(sum[left_part], min(sum[mid_part] - sum[left_part], min(sum[right_part] - sum[mid_part], sum[n] - sum[right_part]))));
	}

	printf("%lld\n", ans);

	return 0;
}


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

using namespace std;

#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(a)  (a).begin(),(a).end()
using ll = long long;
using Pair = pair<int, int>;
const ll mod = 1e9 + 7;

template<typename T>
struct BIT {
  int n;
  vector<T> d;
  BIT(int n): n(n), d(n+1) {}
  void add(int i, T x) {
    for(i++; i<=n; i+=i&(-i)) {
      d[i] += x;
    }
  }
  T sum(int i) {
    T x = 0;
    for(i++; i; i-=i&(-i)) {
      x += d[i];
    }
    return x;
  }
};

int main(int argc, char const* argv[])
{
  int n;
  ll d, a;
  cin >> n >> d >> a;

  vector<pair<ll, ll>> p(n);
  for (int i = 0; i < n; i++) {
    cin >> p[i].first >> p[i].second;
  }

  sort(ALL(p), [](pair<ll,ll> left, pair<ll,ll> right){return left.first < right.first;});

  BIT<ll> bit(n+1);
  ll ans = 0;
  for (int i = 0; i < n; i++) {
    ll x = p[i].first;
    ll h = p[i].second;
    h -= bit.sum(i);
    if (h > 0) {
      ll count = (h+a-1)/a;
      ans += count;
      ll damage = count * a;
      bit.add(i, damage);
      ll limit = upper_bound(ALL(p), pair<ll, ll>(x+2*d+1, -1)) - p.begin();
      bit.add(limit, -damage);
    }
  }

  cout << ans << endl;

  return 0;
}

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

int main() {
    int D;
    cin >> D;
    int d[26];
    vector<int> last(26, 1);

    rep(i, 26) {
        cin >> d[i];
    }

    vector<vector<int>> s(D, vector<int>(26));
    rep(i, D) rep(j, 26) cin >> s[i][j];

    vector<int> ans(D);

    ll level = 0;

    rep(i, D) {
        ll maxnow = -INF;
        ll now = 0;
        vector<int> prelast = last;

        rep(j, 26) {
            last = prelast;
            now = 0;
            //とりあえずの得点計算
            int t = j;
            now += s[i][t];
            last[t] = 0;
            rep(j, 26) {
                now -= d[j] * last[j];
            }

            if (maxnow < now) {
                ans[i] = j;
                maxnow = now;
            }
        }

        last = prelast;

        //本当の得点計算
        level += s[i][ans[i]];
        last[ans[i]] = 0;
        rep(j, 26) {
            level -= d[j] * last[j];
            last[j]++;
        }
    }

    rep(i, D) {
        cout << ans[i] + 1 << "\n";
    }

    return 0;
}

Measured memory_bytes: 3684
#include <stdio.h>
int main(void){
    // Your code here!
    int a,b,c;
    scanf("%d %d %d",&a,&b,&c);
    if(a-b<=c){
        c=c-(a-b);
    }
    else
    {
        c=0;
    }
    printf("%d",c);
}


Measured memory_bytes: 128
import numpy as np

r,g,b,n=map(int,input().split())

x = np.arange(3001)
rr=x*r
f=0
for i in range(3002):
    p = ((n-rr)%b==0)
    q = n-rr>=0
    f+=np.sum(np.logical_and(p,q))
    rr+=g
print(f)

Measured memory_bytes: 21132
n = int(input())
s = [input() for i in range(n)]
m = int(input())
t = [input() for i in range(m)]
l = []
ans = -1000
for i in range(n):
    if s[i] not in l:
        l.append(s[i])
        pnt = s.count(s[i]) - t.count(s[i])
        ans = max(ans, pnt)
if ans < 0:
    print(0)
else:
    print(ans)


Measured memory_bytes: 9052