akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <algorithm>

using ll = long long int;
using P = std::pair<int, int>;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

int cnt[50];
bool sw[50];

int main(void){
	int n,i,j,ans=0;
	ll a;
	std::cin >> n;
	for(i=0; i<n; ++i){
		std::cin >> a;
		for(j=0; j<50; ++j){
			cnt[j] += (a>>j)&(1ll);
		}
		j = 0;
		while(!(a%2)){
			++j; a /= 2;
		}
		sw[j] = true;
	}
	for(j=49; j>=0; --j){
		if((cnt[j]+ans)%2){
			if(!sw[j]){
				std::cout << "-1" << std::endl;
				return 0;
			}
			++ans;
		}
	}
	std::cout << ans << std::endl;
	return 0;
}


Measured memory_bytes: 3584
#include <algorithm>
#include <cstdio>
#include <vector>
#include <utility>

using namespace std;

#define int long long
#define dotimes(i, n) for (int i = 0, i##max__ = (n); i < i##max__; i++)
#define whole(x, f, ...) ([&](decltype((x)) c__) { return (f)(begin(c__), end(c__), ## __VA_ARGS__); })(x)

int rint() {
  int x;
  scanf("%lld", &x);
  return x;
}

void wint(int x) {
  printf("%lld\n", x);
}

template<typename T> int size(T const& c) { return static_cast<int>(c.size()); }
template <typename T> bool maxs(T& a, T const& b) { return a < b ? a = b, true : false; }
template <typename T> bool mins(T& a, T const& b) { return a > b ? a = b, true : false; }
inline int lg(int x) { return 63 - __builtin_clzll(static_cast<unsigned int>(x)); }

signed main() {
  const int N = rint();
  const int K = rint();
  const int L = rint();
  const int R = rint();
  const int ss[2] = {(N+1)/2, N/2};
  vector<pair<int, int>> cs[2];
  vector<int> as[2];
  dotimes(i, 2) dotimes(j, ss[i])
    as[i].emplace_back(rint());
  dotimes(i, 2) {
    dotimes(b, 1 << ss[i]) {
      int c = __builtin_popcount(b);
      if (c > K)
        continue;
      int s = 0;
      dotimes(j, ss[i])
        if (b & (1 << j))
          s += as[i][j];
      if (s <= R)
        cs[i].emplace_back(c, s);
    }
    whole(cs[i], sort);
  }
  int r = 0;
  for (auto it = whole(cs[0], lower_bound, make_pair(K - ss[1], 0LL)); it != cs[0].end(); ++it) {
    auto p = *it;
    int c = K - p.first;
    r += whole(cs[1], upper_bound, make_pair(c, R - p.second)) - whole(cs[1], lower_bound, make_pair(c, L - p.second));
  }
  wint(r);
  return 0;
}



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

int dp[41][1<<17];
int main()
{
    int n, x, y, z; cin>>n>>x>>y>>z;
    const int mod=1e9+7;

    int xyz=(1<<x+y+z-1)|(1<<y+z-1)|(1<<z-1);
    int mask=(1<<x+y+z)-1;

    dp[0][0]=1;
    for(int i=0; i<n; ++i) {
        for(int j=1; j<=10; ++j) {
            for(int k=0; k<=mask; ++k) {
                int t=(k<<j|1<<j-1)&mask;
                if ((t&xyz)!=xyz) (dp[i+1][t]+=dp[i][k])%=mod;
            }
        }
    }

    long res=1;
    for(int i=0; i<n; ++i) (res*=10)%=mod;
    for(int i=0; i<=mask; ++i) (res-=dp[n][i])%=mod;
    cout<<(res+mod)%mod<<endl;
}


Measured memory_bytes: 20736
#include<iostream>
#include<algorithm>
#include<bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
#define int long long
#define pi 3.141592653589793238462643383279502
#define M 998244353
#define F first
#define S second
#define pii pair<int,int>
#define rep(i,n) for(int i=0;i<n;i++)

bool isPowerOfTwo(int n)
{
   if(n==0)
   return false;

   return (ceil(log2(n)) == floor(log2(n)));
}
int power(int x, unsigned int y)
{
    if (y == 0)
        return 1;
    else if (y % 2 == 0)
        return power(x, y / 2) * power(x, y / 2);
    else
        return x * power(x, y / 2) * power(x, y / 2);
}
signed main()
{
int n;
cin>>n;
int p[n];
for(int i=0;i<n;i++)
    cin>>p[i];
int ans[n];
 ans[0]=p[0];
for(int i=1;i<n;i++)
    ans[i]=min(ans[i-1],p[i]);
int c=0;
for(int i=0;i<n;i++)
{
    if(ans[i]==p[i])
        c++;
}
cout<<c<<endl;
    }



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

using namespace std;

typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vii;
typedef vector<ll> vll;
typedef pair<int,int> pii;

#define FASTIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb push_back
#define ff it->first
#define ss it->second
#define all(v) (v).begin(),(v).end()
#define rep(i,n) for(auto i=0;i<n;++i)
#define LOOP_IT(it,s) for(auto it=(s).begin();it!=(s).end();++it)


#ifdef LOCAL
#define cerr cout
#else
#endif

#define TRACE

#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif


void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}


template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif




int main(int argv, char* argc[])
{
    FASTIO


    ll x;cin>>x;
    ll i,j;
    ll y = x;
    bool f1=0,f2=0;
    ll n = 3982;

    for(i=0ll;i<=n;++i)
    {
        ll a = i*i*i*i*i;
        for(j=0ll;j<=n;++j)
        {

            ll b = j*j*j*j*j;
            if(a+b==y)
                {f1=1;goto label;}
            if(abs(a-b)==x)
                {f2=1;goto label;}

        }
    }
    label:
    if(f1)
    cout<<i<<" "<<-j;
    else if(f2)
        {
            if(i<j)
                swap(i,j);
            cout<<i<<" "<<j;
        }
    else
        cout<<"nono";

    return 0;
}


Measured memory_bytes: 3620
#include <stdio.h>

int main() {
  int h, w;
  while(1) {
    scanf("%d %d", &h, &w);
    if (h == 0 && w == 0) {
      break;
    }
    for (int y = 0; y < h; y++) {
      for (int x = 0; x < w; x++ ) {
        if ((x+y) % 2 == 0) {
          printf("#");
        } else {
          printf(".");
        }
      }
      printf("\n");
    }
    printf("\n");
  }
}




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

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] sa = br.readLine().split(" ");
		long n = Integer.parseInt(sa[0]);
		long m = Integer.parseInt(sa[1]);
		long k = Integer.parseInt(sa[2]);
		br.close();

		int mod = 1000000007;
		long x = 0;
		for (long i = 1; i < n; i++) {
			x += i * (n - i);
		}
		x %= mod;
		x *= m;
		x %= mod;
		x *= m;
		x %= mod;

		long y = 0;
		for (long i = 1; i < m; i++) {
			y += i * (m - i);
		}
		y %= mod;
		y *= n;
		y %= mod;
		y *= n;
		y %= mod;

		long ans = x + y;
		ans *= nCr(n * m - 2, k - 2, mod);
		ans %= mod;
		System.out.println(ans);
	}

	static long nCr(long n, long r, int m) {
		long val = 1;
		for (int i = 1; i <= r; i++) {
			val = val * (n - i + 1) % m;
			val = val * modinv(i, m) % m;
		}
		return val;
	}

	static long modinv(long a, int m) {
		long b = m;
		long u = 1;
		long v = 0;
		long tmp = 0;

		while (b > 0) {
			long t = a / b;
			a -= t * b;
			tmp = a;
			a = b;
			b = tmp;

			u -= t * v;
			tmp = u;
			u = v;
			v = tmp;
		}

		u %= m;
		if (u < 0) u += m;
		return u;
	}
}


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

#define ll       long long
#define LL       long long
#define ull      unsigned ll
#define pii      pair<int, int>
#define pll      pair<ll, ll>
#define mp       make_pair
#define ff       first
#define ss       second
#define sz(s)    (int) s.size()
#define all(s)   s.begin(), s.end()

template<typename T> inline void smin(T &a, T b) {
    a = a < b ? a : b;
}
template<typename T> inline void smax(T &a, T b) {
    a = a > b ? a : b;
}

template<typename T> inline void Int(T &n) {
    n = 0;
    int f = 1;
    register int ch = getchar();
    for(; !isdigit(ch); ch = getchar()) if(ch == '-') f = -1;
    for(; isdigit(ch); ch = getchar()) n = (n << 3) + (n << 1) + ch - '0';
    n *= f;
}
template<typename T, typename TT> inline void Int(T &n, TT &m) {
    Int(n), Int(m);
}
template<typename T, typename TT, typename TTT> inline void Int(T &n, TT &m, TTT &l) {
    Int(n), Int(m, l);
}

#define error(args...) { string _s = #args; replace(all(_s), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {
    cout << endl;
}
template<typename T, typename... Args> void err(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a << ", ";
    err(++it, args...);
}

const int mod = (int) 1e9 + 7;

int add(int a, int b) {
    a += b;
    if(a >= mod) a -= mod;
    return a;
}
int sub(int a, int b) {
    a -= b;
    if(a <= 0) a += mod;
    return a;
}
int mul(int a, int b) {
    return (ll) a * b % mod;
}

const int inf = (int) 2e9 + 5;
const ll  Inf = (ll) 2e18 + 5;
const int   N = (int) 2e5 + 5;




int solve() {
    int n;
    Int(n);
    vector<int> dp(3, 0);
    while(n--) {
        vector<int> dp_new(3, 0);
        vector<int> a(3);
        for(int i = 0; i < 3; i++) {
            Int(a[i]);
        }
        for(int i = 0; i < 3; i++) {
            for(int j = 0; j < 3; j++) {
                if(i == j) continue;
                smax(dp_new[j], dp[i] + a[j]);
            }
        }
        dp = dp_new;
    }
    printf("%d\n", max({dp[0], dp[1], dp[2]}));
    return 0;
}

int main() {
    int test = 1, tc = 0;
    //Int(test);
    while(test--) {
        //printf("Case %d: ", ++tc);
        solve();
    }
    return 0;
}




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

int main() {

	int W, H, N;
	cin >> W >> H >> N;

	int x, y, a;
	int x0, x1, y0, y1;
	x0 = 0;
	x1 = W;
	y0 = 0;
	y1 = H;
	rep(i, 0, N) {
		cin >> x >> y >> a;
		if (a == 1 && x > x0) x0 = x;
		if (a == 2 && x < x1) x1 = x;
		if (a == 3 && y > y0) y0 = y;
		if (a == 4 && y < y1) y1 = y;
	}

	//cout << x0 << x1 << y0 << y1 << endl;

	if (x0 < x1 && y0 < y1) {
		cout << (x1 - x0)*(y1 - y0) << endl;
	}
	else {
		cout << 0 << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mk make_pair
#define fs first
#define sc second
using namespace std;
typedef long long ll;
typedef long double ld;
int a[100010], n, dp[100010], m, nxt[100010];
char s[100010];
int cal(){
    if(s[n]=='1')
        return -1;
    dp[n]=0;
    multiset<pair<int, int> > st;
    st.insert(mk(0, n));
    for(int i=n-1; i>=0; --i){
        if(i+m+1<=n){
            if(s[i+m+1]=='0')
                st.erase(st.find(mk(dp[i+m+1], i+m+1)));
        }
        if(st.empty()){
            return -1;
        }
        if(s[i]=='1')
            continue;
        dp[i]=1+((*st.begin()).fs);
        nxt[i]=((*st.begin()).sc);
        st.insert(mk(dp[i], i));
    }
    if(s[0]=='1')
        return -1;
    return dp[0];
}
int main(){
    while(cin>>n>>m){
        scanf("%s",s);
        int ans=cal(), tmp;
        if(ans==-1){
            cout<<ans<<endl;
        }
        else {
            tmp=0;
            while(tmp!=n){
                cout<<nxt[tmp]-tmp<<" ";
                tmp=nxt[tmp];
            }
        }
    }
  return 0;
}




Measured memory_bytes: 3712
#include<bits/stdc++.h>
#include <sys/stat.h>
using namespace std;
using ll = int64_t;

int main(int , char **)
{
#ifdef LOCAL_DEBUG
	struct stat sb;
	ifstream in("/dev/shm/input.txt");
	if (stat("/dev/shm/input.txt",&sb)==0){ cin.rdbuf(in.rdbuf()); }
#endif

	char S[12];
	cin >> S;
	int lng = strlen(S);
	if (lng < 4){ printf("No\n");return 0;}
	if ((S[0]=='Y')&&(S[1]=='A')&&(S[2]=='K')&&(S[3]=='I')){
		printf("Yes\n");
	}else{
		printf("No\n");
	}

	return 0;
}


Measured memory_bytes: 256
a,b,c,d,e,f=[int(x) for x in input().split()]
a=100*a
b=100*b
ans = 0
v = 0
su = 0
for i in range(f//a+1):
  for j in range((f-a*i)//b+1):
    for k in range((e*(i*a//100+j*b//100))//c+1):
      for l in range((e*(a*i//100+j*b//100)-k*c)//d+1):
        if (i!=0 or j!=0 or k!=0 or l!=0) and ans<=(c*k+l*d)/(a*i+b*j+c*k+l*d) and (a*i+b*j+c*k+l*d)<=f:
          ans=(c*k+l*d)/(a*i+b*j+c*k+l*d)
          v = (a*i+b*j+c*k+l*d)
          su = c*k+l*d
print(v,su)
        
        
  

Measured memory_bytes: 42988
#include <stdio.h>
int main(void){
    int i;
    int a[47]={0};
    char w[101];
    scanf("%s",w);
    for(i=0;w[i]!='\0';i++){
	  if(w[i]=='a')a[0]++;
	else if(w[i]=='b')a[1]++;
	else if(w[i]=='c')a[2]++;
	else if(w[i]=='d')a[3]++;
	else if(w[i]=='e')a[4]++;
	else if(w[i]=='f')a[5]++;
	else if(w[i]=='g')a[6]++;
	else if(w[i]=='h')a[7]++;
	else if(w[i]=='i')a[8]++;
	else if(w[i]=='j')a[9]++;
	else if(w[i]=='k')a[10]++;
	else if(w[i]=='l')a[11]++;
	else if(w[i]=='m')a[12]++;
	else if(w[i]=='n')a[13]++;
	else if(w[i]=='o')a[14]++;
	else if(w[i]=='p')a[15]++;
	else if(w[i]=='q')a[16]++;
	else if(w[i]=='r')a[17]++;
	else if(w[i]=='s')a[18]++;
	else if(w[i]=='t')a[19]++;
	else if(w[i]=='u')a[20]++;
	else if(w[i]=='v')a[21]++;
	else if(w[i]=='w')a[22]++;
	else if(w[i]=='x')a[23]++;
	else if(w[i]=='y')a[24]++;
	else if(w[i]=='z')a[25]++;
    	}
    int j=0;
    for(i=0;i<26;i++){
	if(a[i]%2==1)j++;
	}
    if(j==0)printf("Yes");
    else printf("No");

    return 0;
    }


Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <algorithm>
#define int long long
#define ll long long
using namespace std;
inline int read()
{
	int x = 0, f = 1; char ch = getchar();
	while(ch < '0' || ch > '9') {if(ch == '-') f = -1; ch = getchar();}
	while(ch >= '0' && ch <= '9') {x = (x << 3) + (x << 1) + (ch ^ 48); ch = getchar();}
	return x * f;
}
const int N = 1e5 + 1000;
int n,num; ll dis,siz[N];
int u[N],to[N];
struct node
{
	ll v; int id;
	int friend operator <(node a,node b){return a.v < b.v;}
}p[N];
signed main()
{
	n = read();
	for(int i = 1;i <= n;i ++) {p[i] = node{read(),i}; siz[i] = 1;}
	sort(p + 1,p + 1 + n);
	for(int i = n;i > 1;i --)
	{
		ll Dis = p[i].v - n + (siz[i] << 1);
		int t = lower_bound(p + 1,p + 1 + n,node{Dis,0}) - p;
		if(p[t].v != Dis) {puts("-1"); return 0;}
		num ++; u[num] = p[i].id; to[num] = p[t].id;
		siz[t] += siz[i]; dis += siz[i]; 
	}
	if(dis != p[1].v) {puts("-1"); return 0;}
	else for(int i = 1;i < n;i ++) cout << u[i] << " " << to[i] << "\n";
}


Measured memory_bytes: 5376
#include <bits/stdc++.h>
#define ll long long
#define endl "\n"
#define pb push_back
#define ms(v,x) memset(v,x,sizeof(v))
#define ff first
#define ss second
#define td(v) v.begin(),v.end()
#define rep(i,a,n) for (int i=(a);i<(n);i++)
#define pii pair<int,int>
#define pll pair<ll,ll>
using namespace std;
void solve(){
	ll a,b,n;
	cin >> a >> b >> n;
	ll x = min(b-1, n);
	cout << ((a*x) / b) - (a * (x/b)) << endl;
}
int main(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);  
    int t=1,l=1;
   	//cin >> t;
    while(t--){
    	solve();
    }    
}

Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
typedef long long  ll;
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define mod 1000000007

int main()
{


	fast;

	ll  n, k, j;
	cin >> n >> k;

	ll a[n], i;
	rep(i, 0, n)
	{
		cin >> a[i];
	}
	ll dp[n];
	memset(dp, 10001, sizeof(dp));
	dp[0] = 0;
	dp[1] = abs(a[1] - a[0]);
	for (i = 2; i < min(n, k); i++)
	{

		for (j = 1; j <= i; j++)
		{
			dp[i] = min(dp[i - j] + abs(a[i] - a[i - j]), dp[i]);
		}
	}
	for (i = k; i < n; i++)
	{
		for (j = 1; j <= k; j++)
		{
			dp[i] = min(dp[i - j] + abs(a[i] - a[i - j]), dp[i]);
		}
	}
	cout << dp[n - 1] << "\n";
}

Measured memory_bytes: 1792
from math import sqrt, floor

num = 10**5

pnl = [False] * num
pnl[1:3] = [True] * 2
cln = [0] * (num + 1)

for i in range(3, num):
    if not i % 2:
        if pnl[i//2] and pnl[i-1]:
            cln[i-1] += 1
    else:
        sq = floor(sqrt(i))
        for j in range(3, sq+1, 2):
            if not i % j: break
        else: pnl[i] = True
    cln[i] = cln[i-1]

q = int(input())
for _ in range(q):
    l, r = map(int, input().split())
    print(cln[r] - cln[l-1])


Measured memory_bytes: 4980
n, k = map(int, input().split())
data = list(map(int, input().split()))
visited = [False for _ in range(n)]
nex = 0
visited[0] = True
t_l = 0
while True:
    nex = data[nex]-1
    if visited[nex] is True:
        break
    else:
        visited[nex] = True
        t_l += 1
start = nex
cycle = 1
c = [start]
while True:
    nex = data[nex]-1
    if nex == start:
        break
    else:
        cycle += 1
        c.append(nex)
before = t_l - cycle + 1
if k < before:
    nex = 0
    n = 0
    while n < k:
        nex = data[nex]-1
        n += 1
    print(nex+1)
elif start != 0:
    print(c[(k-before)%cycle]+1)
else:
    print(c[k%cycle]+1)


Measured memory_bytes: 32380
#include<iostream>
#include<algorithm>
#include<cstdio>
using namespace std;
int main(void)
{
	int H=0,W=0,a=0,c=0;
	cin>>H>>W;
	char d=0;
	for(int i=0;i<H;i++){
		for(int j=0;j<W;j++){
			cin>>d;
			if(d=='.'&&c==0){cout<<"-1";}
			else if(d=='c'){cout<<"0";c=1;a=0;}
			else if(d=='.'){a++;cout<<a;}
			if(j==W-1){cout<<endl;c=0;a=0;}
			else{cout<<" ";}
		}
	}
	return 0;
}


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

int main() {
  int64_t N,K;
  cin >> N;
  cin >> K;
  int64_t ans=0;
  vector<int64_t> H(N);
  for (int64_t i=0; i<N; i++){
   cin >> H.at(i);
  }
  sort(H.begin(), H.end());
  if (N<=K) ans=0;
  else {
    for (int64_t i=0; i<N-K; i++){
      ans=ans+H.at(i);
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 1792
#include <stdio.h>
int main(void){
    int a,b,c,t;
    scanf("%d %d %d\n",&a,&b,&c);
    if (a>b)
    t=a,a=b,b=t;
    if (b>c)
    t=b,b=c,c=t;
    if (a>b)
    t=a,a=b,b=t;
    printf("%d %d %d\n",a,b,c);
    return 0;
}


Measured memory_bytes: 2104
//{{{
#include<algorithm>
#include<cmath>
#include<fstream>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<random>
#include<set>
#include<sstream>
#include<sys/time.h>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(prints) FUNC(printw) FUNC(printwe) FUNC(printb) FUNC(printbe) FUNC(printd) FUNC(printde) FUNC(printdu);
#endif
template <class S, class T>
istream& operator >> (istream& in, pair<S, T>& p){ return in >> p.first >> p.second; }
template <class T>
istream& operator >> (istream& in, vector<T>& v){ for(auto& e : v){ in >> e; } return in; }
//}}}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    string a; cin >> a;
    string b; cin >> b;
    string c; cin >> c;
    int ans = 0;
    for(int i = 0; i < n; i++){
        set<char> st;
        st.insert(a[i]);
        st.insert(b[i]);
        st.insert(c[i]);
        ans += st.size() == 1 ? 0 : st.size() == 2 ? 1 : 2;
    }
    cout << ans << '\n';
}


Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<stdio.h>
using namespace std;
int main(){
  double a,b,c,PI=3.1415926535;
  cin >> a >> b >> c;
  printf("%.5f\n",a*b*sin(c*PI/180)/2);
  printf("%.5f\n",sqrt(a*a+b*b-2*a*b*cos(c*PI/180))+a+b);
  printf("%.5f\n",b*sin(c*PI/180));
  return 0;
}



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

int main(){
	string a,b,c;
	cin >> a >> b >> c;
	char x,y,z;
	x=a[0]-32;
	y=b[0]-32;
	z=c[0]-32;
	cout << x << y << z << endl;
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <algorithm>
using namespace std;
const int Maxn = 200010;
int s[Maxn];
int n, K;
int main() {
	int i, j, k;
	scanf("%d%d", &n, &K);
	for(i = 1; i <= n; i++){
		int x;
		scanf("%d", &x);
		s[x]++;
	}
	sort(s+1, s+n+1);
	int ans = 0;
	for(i = n; i > n-K; i--) ans += s[i];
	printf("%d\n", n-ans);
	return 0;
}

Measured memory_bytes: 896
a,b=map(int,input().split())
s=input()
if len(s) != a+b+1:
    print('No')
    exit()
else:
    if s[a] != '-':
        print('No')
        exit()
    else:
        for i in range(0,a):
            if s[i] == '-':
                print('No')
                exit()
        for i in range(a+1,a+b+1):
            if s[i] == '-':
                print('No')
                exit()
print('Yes')
        
            

Measured memory_bytes: 9184
object Main extends App {
  val in = new java.util.Scanner(System.in)
  val N, K, R, S, P = in.nextInt
  val T = in.next

  def win(h: Char): Int = h match {
    case 'r' => P
    case 's' => R
    case _ => S
  }

  def score(i: Int, sum: Int, pre: Char): Int = {
    if (i >= N) sum
    else T.charAt(i) match {
      case `pre` => score(i + K, sum, 'X')
      case h => score(i + K, sum + win(h), h)
    }
  }

  println((0 until K).map(i => score(i, 0, 'X')).sum)
}

Measured memory_bytes: 33128
#include "bits/stdc++.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
#define int ll
#define fi first
#define se second
#define SORT(a) sort(a.begin(),a.end())
#define rep(i,n) for(int i = 0;i < (n) ; i++) 
#define REP(i,n) for(int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define INF LLONG_MAX/2
#define all(x) (x).begin(),(x).end()
#define debug(x) cerr<<#x<<": "<<x<<endl
#define debug_vec(v) cerr<<#v<<":";rep(i,v.size())cerr<<" "<<v[i];cerr<<endl
//----------------------------------------------------------------

// int MOD = 998244353;
int MOD = 1000000007;


//----------------------------------------------------------------
signed main(){

	string s;
	cin >> s;
	ll n = s.size();
	ll ans = 0;
	for(int bit = 0;bit < (1LL<<(n-1));bit++){
		ans += s[n-1]-'0';
		ll x = 1;
		rep(i,n-1){
			if(bit&(1LL<<i))x=1;
			else x *= 10;
			ans += x*(s[n-2-i]-'0');
		}
	}
	cout << ans << endl;

	

	return 0;
}

//----------------------------------------------------------------

// g++ -std=c++14 code1.cpp
// sudo pip3 install --upgrade online-judge-tools
// rm -r -f test;oj dl https://code-festival-2018-quala.contest.atcoder.jp/tasks/code_festival_2018_quala_c
// rm -r -f test;oj dl https://ddcc2017-final.contest.atcoder.jp/tasks/ddcc2017_final_b
// rm -r -f test;oj dl https://arc061.contest.atcoder.jp/tasks/arc061_a

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

# Generated by 1.1.5 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    ret = 'Yes'
    S = str(input())
    for i in range(len(S)):
        if i%2 == 0: #odd
            if S[i] not in ['R', 'U', 'D']:
                ret = 'No'
                break
        else: #even
            if S[i] not in ['L', 'U', 'D']:
                ret = 'No'
                break
    print(ret)

if __name__ == '__main__':
    main()


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

int main() {
    int N; cin >> N;
    long long ans = 0;
    for (int i = 1; i <= N; i++) {
        if (i % 3 != 0 && i % 5 != 0) {
            ans += i;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3636
#include <stdio.h>
int main(void){
    // Your code here!
    int m,f,r;
    
    while(1){
        scanf("%d %d %d", &m, &f, &r);
        if(m==-1&&f==-1&&r==-1) break;
        if (m==-1||f==-1){
            printf("F\n");
        }
        else if(m+f>=80){
            printf("A\n");
        }
        else if(m+f>=65){
            printf("B\n");
        }
        else if(m+f>=50){
            printf("C\n");
        }
        else if(m+f>=30){
            if(r>=50){
                printf("C\n");
            }
            else{
                printf("D\n");
            }
        }
        else{
            printf("F\n");
        }
    }
    return 0;
}



Measured memory_bytes: 2128
#include<stdio.h>
const int N = 305;
const int M = 305;
int main()
{
	int n, m;
	while(scanf("%d %d", &n, &m))
	{
		if(n == 0 && m == n)
		{
			break;
		}
		for(int i = 0; i < n; i++)
		{
			for(int j = 0; j< m; j++)
			{
				printf("#");
			}
			printf("\n");
		}
		printf("\n");
	}
	return 0;
}


Measured memory_bytes: 2696
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <queue>
using namespace std;
typedef long long LL;
const int inf = 1 << 30;
const LL INF = 1LL << 60;
const int MaxN = 100005;

int n, a, b;

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

Measured memory_bytes: 128
from itertools import accumulate
N = int(input())
s =[]
t =[]
for i in range(N):
    s1, t1 = map(str,input().split())
    s.append(s1)
    t.append(int(t1))
X = input()

T = list(accumulate(t[::-1]))[::-1] + [0]

print(T[s.index(X) + 1])

Measured memory_bytes: 3064
### constant

MAX_N = 100000
DELTA = 1.0e-16

### main

evs = [0.0, 1.0]

for i in (2..MAX_N)
  pi = 1.0
  w = 0.5
  evs[i] = 0.0

  for k in (1...i)
    break if pi < DELTA

    evs[i] += pi * (1 - w) * (k + evs[[0, i - k - 1].max])
    pi *= w
    w /= 2
  end

  evs[i] += i * pi
end

loop do
  n = gets.to_i
  break if n == 0

  puts "%.8f" % evs[n]
end

Measured memory_bytes: 7088
n = gets.chomp.to_i
arr = gets.chomp.split.map(&:to_i)
sum = 0
(n-1).times do |i|
	if arr[i] > arr[i + 1]
		sum += arr[i] - arr[i + 1]
		arr[i + 1] = arr[i]
	end
end
puts sum

Measured memory_bytes: 30084
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.stream.IntStream;
import java.util.StringTokenizer;
import java.io.IOException;
import java.util.InputMismatchException;
import java.io.BufferedReader;
import java.util.OptionalInt;
import java.io.InputStreamReader;
import java.io.InputStream;

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

    static class TaskB {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            String s = in.nextString();
            String t = in.nextString();

            int maxS = s.chars().max().getAsInt();
            int minS = s.chars().min().getAsInt();
            int maxT = t.chars().max().getAsInt();
            int minT = t.chars().min().getAsInt();

            if (minS < maxT) {
                out.println("Yes");
                return;
            }

            if (minS == maxS && minT == maxT && s.length() < t.length()) {
                out.println("Yes");
                return;
            }

            out.println("No");
        }

    }

    static class InputReader {
        BufferedReader in;
        StringTokenizer tok;

        public String nextString() {
            while (!tok.hasMoreTokens()) {
                try {
                    tok = new StringTokenizer(in.readLine(), " ");
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
            }
            return tok.nextToken();
        }

        public InputReader(InputStream inputStream) {
            in = new BufferedReader(new InputStreamReader(inputStream));
            tok = new StringTokenizer("");
        }

    }
}



Measured memory_bytes: 26580
#include<iostream>
#include<vector>
#include<cstdlib>

using namespace std;

int main(){
  int i,j,k,n,x,max=0,cnt=0;
  cin >>n;
  for(i=0;i<n;i++){
    cin >> x;
    if(x>=max){
      max=x;
      cnt++;
    }
  }
  cout << cnt <<endl;
  return 0;
}

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

#include <iostream>
#include <iomanip>
#include <sstream>
#include <stdint.h>
#include <string.h>

#define _USE_MATH_DEFINES
#include <math.h>

#include <vector>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <deque>
#include <string>

#include <algorithm>
#include <functional>
#include <bitset>
#include <functional>
#include <chrono>
#include <random>

#define sqr(x) (x) * (x)

typedef unsigned int u32;
typedef int i32;
typedef unsigned long long int u64;
typedef long long int i64;
typedef uint16_t u16;
typedef int16_t i16;
typedef uint8_t u8;
typedef int8_t i8;

using namespace std;
using namespace std::chrono;

const i64 mod = 1000000007ll;
const i64 smod = 998244353ll;
const i64 inf = 10000000000000007ll;

const double eps = 1e-10;

struct less_key {
    bool operator()(const std::pair<i64,i64> &left, const std::pair<i64,i64> &right) {
        return left.first < right.first;
    }
};

i64 gcd (i64 a, i64 b, i64 & x, i64 & y) {
    if (a == 0) {
        x = 0;
        y = 1;
        return b;
    }
    i64 x1, y1;
    i64 d = gcd (b % a, a, x1, y1);
    x = y1 - (b / a) * x1;
    y = x1;
    return d;
}

i64 rev(i64 a, i64 m) {
    i64 x, y;
    i64 g = gcd(a, m, x, y);
    if (g != 1) {
        throw g;
    }
    return (x % m + m) % m;
}

i64 binpow(i64 a, i64 p) {
    if (p == 0) {
        return 1;
    }
    if (p == 1) {
        return a;
    }
    i64 t = binpow(a, p / 2);
    t *= t;
    t %= mod;

    if (p % 2) {
        t *= a;
        t %= mod;
    }

    return t;
}

const i64 MAXN = 300005;

i64 n;

pair<string, i64> a[MAXN];

int main() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cout.precision(15); cout.setf(ios::fixed);

    cin >> n;

    for (i64 i = 0; i < n; i++) {
        cin >> a[i].first >> a[i].second;
    }

    string s;
    cin >> s;
    bool f = false;
    i64 R = 0;
    for (i64 i = 0; i < n; i++) {
        if (f) {
            R += a[i].second;
        } else {
            if (s == a[i].first) {
                f=  true;
            }
        }
    }

    cout <<R << endl;

    return 0;
}

Measured memory_bytes: 4992
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {

        static void Main(string[] args)
        {

            while (true)
            {
                string[] str = Console.ReadLine().Split(' ');
                int n = int.Parse(str[0]);
                int[] ks = new int[n];
                int p = int.Parse(str[1]);
                int ps = p;

                int a = 0;
                if (n == 0 && p == 0) { return; }
                while (true)
                {

                    if (p > 0) { ks[a]++; p--; if (ks[a] == ps) { break; } }
                    else { p += ks[a]; ks[a] = 0; }
                    if (a == n - 1) { a = 0; }
                    else { a++; }
                }
                Console.WriteLine(a);
            }
        }
    }
}

Measured memory_bytes: 9144
#include<iostream>
#include<algorithm>
#include<cstdio>
using namespace std;
int main()
{
	int n,a;
	pair<int,int> teams[100];
	int rank[101];
	fill(rank,rank+101,0);
	int cnt=0;
	while(scanf("%d,%d",&n,&a),n)
	{
		teams[cnt].first=a; teams[cnt].second=n;
		cnt++;
	}

	sort(teams,teams+cnt);
	int r=0;
	for(int i = cnt-1; 0 <= i; --i)
	{
		if(i<cnt-1&&teams[i+1].first==teams[i].first)
		{
			rank[teams[i].second]=r;
		}
		else
		{
			++r;
			rank[teams[i].second]=r;
		}
	}
	while(cin>>n)
	{
		cout<<rank[n]<<endl;
	}
  return 0;
}

Measured memory_bytes: 1248
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <string>
#include <cstring>
#include <cmath>
#include <climits>
#include <ctime>
#include <fstream>
#include <functional>
#include <unordered_map>
#include <unordered_set>
#define MAGIC cin.tie(NULL); ios_base::sync_with_stdio(false)
#define endl '\n'
//#define ll long long
#define mod (1000000007)
//#define NCONS 100001
//#define NCONS 100001
//#define NCONS 1001
//#define NCONS 101
//#define MCONS 2001
//#define LIMIT 1000000000
#define TRUE 1
#define FALSE 0
#define toRadian(degree) ((degree) * (M_PI / 180.))
#define toDegree(radian) ((radian) * (180. / M_PI))
#define int long long
//#define double long double
using namespace std;
struct Point{int x; int y;};
struct PPoint{Point x; Point y;};
typedef long long ll;

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

#define YYYY cout << "YES" << endl
#define NNNN cout << "NO" << endl
#define yyyy cout << "Yes" << endl
#define nnnn cout << "No" << endl
int dx[]{0, 1, 0, -1};
int dy[]{1, 0, -1, 0};

int32_t main()
{
    MAGIC;
    char ch; cin >> ch;
    cout << (char)(ch + 1);
    
   
    return 0;
}



Measured memory_bytes: 764
#include<bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
//long long int countt[200003];
#include<ext/pb_ds/assoc_container.hpp> // include the associative containers or group of templates such as set, multimap, map etc.
#include<ext/pb_ds/tree_policy.hpp> // include the tree_order_statistics_node update
using namespace __gnu_pbds; //necessary for the GNU based Policy based data structures.
typedef tree<pair<int,int> ,null_type,less<pair<int,int>>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

#define int long long
#define f first
#define s second
signed main()
{
    FAST;
    
     int i=0,j=0,k=0,n=0,m=0,count=0,temp=0,z;
    int temp1=0,temp2=0,temp3=0,x=0,l=0,y=0,sum=0;
    int left=0,up=0,anss=0,start=0,end=0,r=0,q=0,total=0;
    int maxx=0,minn=0,curr=0,ans=0,places=0,zeroes=0,low=0,high=0;
    int prev=0,mid=0,zz=0,d=0,val=0;
    int a,b,c;
    
    cin>>x>>y>>a>>b>>c;
    
    int red[a],green[b],color[c];
    
    for(i=0;i<a;i++)
    {
        cin>>red[i];
    }
    
    for(i=0;i<b;i++)
    {
        cin>>green[i];
    }
    
    for(i=0;i<c;i++)
    {
        cin>>color[i];
    }
    
    sort(red , red + a , greater<int>());
    sort(green , green + b , greater<int>());
    sort(color , color + c , greater<int>());
    
    priority_queue <int , vector<int>, greater<int> > pq;
    
    for(i=0;i<x;i++)
    {
        pq.push(red[i]);
    }
    
    for(i=0;i<y;i++)
    {
        pq.push(green[i]);
    }
    
    //cout<<pq.size()<<endl;
    curr=0;
    for(i=0;i<pq.size();i++)
    {
        temp  = pq.top();
        if(curr<c && color[curr]>temp)
        {
            pq.pop();
            pq.push(color[curr]);
            curr++;
        }
        
        else
        {
            break;
        }
    }
    sum=0;
    //cout<<pq.size()<<endl;
    while(pq.size())
    {
        //cout<<pq.top()<<endl;
        sum=sum+pq.top();
        pq.pop();
    }
    
    cout<<sum<<endl;
    
    
    
}


Measured memory_bytes: 4852
#include <algorithm>
#include <cmath>
#include <vector>
#include <functional>
#include <cstdlib>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <ctype.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); i++)


int main(){
   int n;
   cin >> n;
   vector<pair<int,int>> a;
   int input;
   REP(i,n){
      cin >> input;
      a.push_back(make_pair(input,i));
   }
   
   sort(a.begin(),a.end());
   
   REP(i,n){
      cout << a[i].second+1 << " ";
   }
   cout << endl;
   
   
   return 0;
}

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

using namespace std;
typedef long long ll ;
ll n ,A ,B  ;
ll tab[100000];

bool check(int c){
    int C = c ;
    for(int i = 0 ;  i < n ; i++){
        if( (tab[i]/B + ((tab[i]%B)!=0)) > C ){
            ll a = tab[i]- C * B ;
            c -= (a/(A-B) + (a%(A-B)!=0) ) ;
//            cout <<i << ' '<<a << ' '<< (a/(A-B) + (a%(A-B)!=0) ) << endl;
            if(c<0) return 0 ;
        }
    }
    return 1;
}

int main()
{
    cin >> n >> A >> B ;
    for(int i = 0 ; i<n ; i++)cin>>tab[i];
//    check(2);
    int l = 1  , r = 1000000000 ;
    int ans ;
    while(l<=r){
        int m = (l+r)/2 ;
        if(check(m))ans = m , r = m-1 ;
        else l = m+1 ;
    }
    cout << ans ;

    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int fx[5]={1,-1,0,0},fy[5]={0,0,1,-1};//方位数组 
struct node
{
	int x,y;
};
int n,m,ans=0;
int d[25][25];
char p[25][25];
bool vis[25][25];
queue<node> q;
int main()
{
	memset(p,10,sizeof(p));//初始化为正无穷 
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)
			cin>>p[i][j];//输入
	for(int i=1;i<=n;i++)//循环遍历每一个点，做一遍bfs，找出最大点 
	{
		for(int j=1;j<=m;j++)
		{
			if(p[i][j]=='#') continue;//如果这个点是墙 就跳过
			memset(d,0,sizeof(d));//清空两个数组，d数组用来记录从起点到当前点所需的距离 
			memset(vis,0,sizeof(vis));//记录当前位置是否已经访问 
			q.push((node){i,j});
			vis[i][j]=1;
			while(!q.empty())//开始bfs
			{
				node no=q.front();
				q.pop();
				for(int k=0;k<4;k++)
				{
					int nx=no.x+fx[k],ny=no.y+fy[k];
					if(nx<=n&&ny<=m&&nx>0&&ny>0&&p[nx][ny]=='.'&&!vis[nx][ny])//判断下一点是否可以到达 
					{
						vis[nx][ny]=1;
						d[nx][ny]=d[no.x][no.y]+1;//到达坐标(nx,ny)所需的步数 
						ans=max(d[nx][ny],ans);//取最大距离作为答案 这里d每个点都会重置为0
						q.push((node){nx,ny});
					}
				}
			}
		}
	}
	printf("%d",ans);//输出答案即可
	return 0;
}


Measured memory_bytes: 3756
#include <bits/stdc++.h>
using namespace std ;
 int main()
 {
   int n; cin>>n;
   string iparr[n];
   for(int i=0;i<n;i++)
   {cin>>iparr[i];
   }
   bool flagone=true;

   map<string,bool> mp;
   map<string,bool> ::iterator it;
   for(int i=0;i<n;i++)
   {
      if(mp.find(iparr[i])==mp.end())
      {mp[iparr[i]]=true; }
      else { flagone =false;
        // cout<<" mapalert ";
        break;}
     //mp[iparr[i]]=true;

   }

   bool flagtwo=true;
   for(int i=1;i<n;i++){
     int lenone=iparr[i-1].length();
     //int lentwo=iparr[i];
     if(iparr[i][0]!=iparr[i-1][lenone-1])
     {flagtwo=false;
     //   cout<<" other alert ";
     }
   }

  if(flagone && flagtwo){cout<<"Yes";}
  else {cout<<"No";}

  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 rep1(i,n) for(int i=1;i<=n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define per1(i,n) for(int i=n;i>0;i--)
#define all(v) v.begin(), v.end()
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<ll> vec;
typedef vector<vec> mat;
ll n,k;
vec A;
ll ok,ng;
int solve(ll x){
    ll a=0;
    if(x==1) return 1;
    rep(i,n){
        a+=(A[i]-1)/x;
    }
    if(a<=k) return 1;
    return 0;
}
ll search(){
    while(abs(ok-ng)>1){
        ll mid=(ok+ng)/2;
        if(solve(mid)) ok=mid;
        else ng=mid;
    }
    return ok;
}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll a;
    cin>>n>>k;
    rep(i,n) cin>>a,A.push_back(a);
    ok=1e10,ng=0;
    cout<<search();
}

Measured memory_bytes: 5316
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rep3(i, l, n) for (int i = l; i < n; ++i)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define out(a) cout << a << endl
#define SZ(v) (int)v.size()
#define inf (int)(1e9+7)

int xl, yl, xr, yr;
int dist(int sx, int sy, int x, int y) {
    return abs(sx - x) + abs(sy - y);
}
bool safe_(int x, int y) {
    return (xl <= x && x <= xr && yl <= y && y <= yr);
}
int dist_safe(int x, int y) {
    if (safe_(x, y)) return 0;
    //4角が一番とは限らない
    if (xl <= x && x <= xr) {
        return min(dist(x, y, x, yl), dist(x, y, x, yr));
    } else if (yl <= y && y <= yr) {
        return min(dist(x, y, xl, y), dist(x, y, xr, y));
    }
    return min({dist(x, y, xl, yl), dist(x, y, xl, yr), dist(x, y, xr, yl), dist(x, y, xr, yr)});
    
}
int main() {
    int n;
    while (cin >> n && n) {
        cin >> xl >> yl >> xr >> yr;
        int sum = 0;
        int x = -1, y = -1;
        rep(i, n + 1) {
            int befx, befy; befx = x; befy = y;
            cin >> x >> y;
            if (i == 0) continue;
            // そのまま次へ行くか
            int go = 0;
            if (!safe_(befx, befy) && !safe_(x, y)) go = dist(befx, befy, x, y);
            else if (!safe_(befx, befy)) go = dist_safe(befx, befy);
            else if (!safe_(x, y)) go = dist_safe(x, y);
            // 一旦安全地帯へ行くか
            if (safe_(befx, befy)) { //すでに安全地帯
                sum += go;
                continue;
            }
            //出発点は危険
            //行き先で場合分け
            int tmp;
            if (!safe_(x, y)) {
                tmp = dist_safe(befx, befy) + dist_safe(x, y) - 1;
            } else {
                tmp = dist_safe(befx, befy) - 1;
            }
            //out(go << " " << tmp);
            sum += min(go, tmp);
            
        }
        out(sum);
    }
}




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

int main()
{
    int a, b;
    string result = "";
    cin >> a >> b;
    if (a >= b)
        cout << result.append(a, (char)(b + '0')) << endl;
    else
        cout << result.append(b, (char)(a + '0')) << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <map>

#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,x,n) for(int i=x; i<(n); i++)
#define rrep(i,n) for(int i=(n)-1; i>=0; i--)
#define all(X) (X).begin(),(X).end()
#define X first
#define Y second
#define pb push_back
#define eb emplace_back

using namespace std;
typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

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

template<class A, size_t N, class T> void Fill(A (&a)[N], const T &v){ fill( (T*)a, (T*)(a+N), v ); }

const ll INF = 0x3fffffff;


int main(){
	//ios_base::sync_with_stdio(0);
	int N, M;
	string A[55], B[55];
	bool ans = false;

	cin >> N >> M;
	rep(i,N) cin >> A[i];
	rep(i,M) cin >> B[i];

	rep(x,N-M+1){ rep(y,N-M+1){
		ans = true;
		rep(i,M){
			//cout << x << " " << y << " " << A[y+i].substr(x,M) << " " << B[i] << endl;
			if( A[y+i].substr(x,M) != B[i] ) ans = false;
		}
		if( ans ) break;
	}
		if( ans ) break;
	}

	cout << (ans?"Yes":"No") << endl;

	return 0;
}


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

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

  int n, k;
  cin >> n >> k;

  ll ans = 0;
  for (int i = 0; i + k - 1 < n; i++) {
    ans++;
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
	#include <set>
	#include <map>
	#include <string>
	#include <math.h>
	#include <algorithm>
	#include <vector>
	#include <stack>
	#include <queue>
	#include <bitset>
	#include <string.h>

	using namespace std;

	// #define for(i,a,b) for (int i=(a);i<(b);++i)
	typedef long long ll;
	typedef pair<ll,ll> P;
	#define REP(i,n) for(long long i = 0; i < (long long)(n); i++)
	#define pb push_back // vectorに要素追加
	#define INF (ll)1e18

	ll mod = 1e9+7;
	/**/
	int main() {
		// 入力
		ll N;cin>>N;
		
		// 解法
		ll ans = 0;
		ll n_div = 10;
		if (N%2==1){
			ans = 0;
		}
		else{
			while (N>=n_div){
				ans += N/n_div;
				n_div *= (ll)5;
			}
		}

		//出力
		printf("%lld\n", ans);
	}


Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
#include <string>
#include <math.h>
#include <vector>
#include <algorithm>
using namespace std;
//もっともっと簡単に
int main(){
    int n; cin>>n;
    int sum=0;
    int maxj=0;
    for(int i=0;i<n;i++){
        int p; cin>>p;
        sum+=p;
        maxj=max(maxj,p);
    }
    cout<<sum-maxj/2<<endl;
    return 0;
}

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

vector<pair<int, long long>> e[100010];
vector<int> c(100010, -1);

void dfs(int cur, int prev) {
    for (auto &ed: e[cur]) {
        if (ed.first == prev) continue;
        if (ed.second & 1) c[ed.first] = !c[cur];
        else c[ed.first] = c[cur];
        dfs(ed.first, cur);
    }
}

int main() {
    int n; cin >> n;
    for (int i = 0; i < n-1; i++) {
        int u, v; long long w;
        cin >> u >> v >> w;
        u--; v--;
        e[u].emplace_back(v, w);
        e[v].emplace_back(u, w);
    }
    c[0] = 1;
    dfs(0, -1);
    for (int i = 0; i < n; i++) {
        cout << c[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 9856
#include <bits/stdc++.h>
using namespace std;
int main(){
  int k,a,b;
  cin >> k;
  cin >> a >> b;
  if(a%k==0 or b%k==0)
    	cout << "OK\n";
  else if((a-a%k)+k<=b)
    cout << "OK\n";
  else
    	cout << "NG\n";
}

Measured memory_bytes: 3640
#include <stdio.h>
int main (void)
{
    int a[5],k;
    int i,j;
    scanf("%d %d %d %d %d %d",&a[0],&a[1],&a[2],&a[3],&a[4],&k);
    for (i = 0; i < 5; i++) {
        for (j = i; j < 5; j++) {
            if (a[i] - a[j] > k || a[j] - a[i] > k) {
                printf(":(");
                return 0;
            }
        }
    }
    printf("Yay!");
    return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
#define max(a, b) a>b ? a : b

int main(){
  int k, n, i, zeroA, prevA, nowA, ans, Max=0;
  scanf("%d%d", &k, &n);
  scanf("%d", &zeroA);
  prevA = zeroA;
  for(i=1; i<n; i++){
    scanf("%d", &nowA);
    Max = max(Max, nowA-prevA);
    prevA = nowA;
  }
  Max = max(Max, zeroA+(k-nowA));
  ans = k-Max;
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 128