akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
 
typedef long long ll;
#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
 
using namespace std;
int MOD = 1000000007;

signed main(){
    int a,b;

    cin >> a >> b;

    int cnt = b-a+1;
    int ans = 0;
    for(int i = a;i < a+cnt%4;i++){
        ans += i%2;
        ans %= 2;
    }
    //debug(ans);

    for(int i = 1;i <= 40;i++){
        int am = cnt%(1LL<<(i+1));
        if(am <= (1LL<<i)){
            if((a/(1LL<<i))%2 == 0){
                int w = (1LL<<i) - a%(1LL<<i);
                if(am - w >= 0){
                    if((am - w)%2 == 1)ans += (1LL<<i);
                }
            }else{
                int b = (1LL<<i) - a%(1LL<<i);
                if(am - b >= 0){
                    if(b%2 == 1)ans += (1LL<<i);
                }else{
                    if(am%2 == 1)ans += (1LL<<i);
                }
            }
        }else{
            if((a/(1LL<<i))%2 == 0){
                int w = (1LL<<i) - a%(1LL<<i);
                if(am - w < (1LL<<i)){
                    if((am - w)%2 == 1)ans += (1LL<<i);
                }
            }else{
                int b = (1LL<<i) - a%(1LL<<i);
                if(am - b < (1LL<<i)){
                    if(b%2 == 1)ans += (1LL<<i);
                }else{
                    if((am-(1LL<<i))%2 == 1)ans += (1LL<<i);
                }
            }
        }
        //debug(ans);
    }
    

    cout << ans << endl;

    return 0; 
}

// g++ -std=c++14 code1.cpp
// rm -r -f test;oj dl https://abc121.contest.atcoder.jp/tasks/abc121_a
// rm -r -f test;oj dl http://yahoo-procon2017-qual.contest.atcoder.jp/tasks/yahoo_procon2017_qual_c

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define mod 1000000007
double dp[3005][3005]={0};
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	//freopen("test.txt","r",stdin);
	ll n;
	cin>>n;
	double h[n+1];
	double t[n+1];
	for(ll i=1;i<=n;i++)
	{
		cin>>h[i];
		t[i]=1-h[i];
	}
	dp[0][0]=1;
	for(ll i=1;i<=n;i++)
	{
		for(ll j=0;j<i;j++)
		{
			dp[i][j]+=dp[i-1][j]*t[i];
			dp[i][j+1]+=dp[i-1][j]*h[i];
		}
	}
	double ans=0;
	for(ll i=(n+1)/2;i<=n;i++)
		ans+=dp[n][i];
	cout<<fixed<<setprecision(10)<<ans<<endl;



}


Measured memory_bytes: 69120
#include <iostream>
#include <algorithm>
#include <array>
#include <cstdint>
#include <functional>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string>
#include <unordered_map>
#include <utility>
#include <vector>

#define INF 1000000000
#define MOD 1000000007
#define rep(i,a,b) for(uint32 i = (a); i < (b); ++i)
#define bitget(a,b) (((a) >> (b)) & 1)
#define ALL(x) (x).begin(),(x).end()
#define C(x) std::cout << #x << " : " << x << std::endl
#define scanf scanf_s

using int32 = std::int_fast32_t;
using int64 = std::int_fast64_t;
using uint32 = std::uint_fast32_t;
using uint64 = std::uint_fast64_t;

template<typename T>
class hashmap64 {
	std::vector<std::pair<uint64, T>> map;
	uint64 mask, count, temp;
	uint64 hash64(uint64 key) {
		key ^= key << 13;
		key ^= key >> 19;
		return key ^ (key << 17);
	}
public:
	hashmap64() :map(1024, std::make_pair(~static_cast<std::uint_fast64_t>(0), T())) {
		mask = 1023; count = 0;
	}
	hashmap64(size_t s) :map(1<<s, std::make_pair(~static_cast<std::uint_fast64_t>(0), T())) {
		mask = (1 << s) - 1; count = 0;
	}
	T &operator[](uint64 suf) {
		temp = mask&hash64(suf);
		while (~map[temp].first) {
			if (map[temp].first == suf) {
				return map[temp].second;
			}
			temp = mask&(temp + 1);
		}
		std::cerr << "?????¨????????????????????§????????????\n";
		std::abort();
	}
	void insert(uint64 key, const T &value) {
		temp = mask&hash64(key);
		while (~map[temp].first) {
			if (map[temp].first == key) {
				map[temp].second = value;
				return;
			}
			temp = mask&(temp + 1);
		}
		map[temp] = std::make_pair(key, value);
		++count;
		if ((count << 1) > mask) {
			std::pair<uint64, T> mkey;
			mask = mask << 1 | 1;
			map.resize(mask + 1, std::make_pair(~static_cast<std::uint_fast64_t>(0), T()));
			for (uint64 t = 0;t <= mask >> 1;++t) {
				if (!~map[t].first) {
					mkey = map[t];
					map[t].first = ~0;
					temp = mask&hash64(mkey.first);
					while (~map[temp].first) {
						temp = mask&(temp + 1);
					}
					map[temp] = mkey;
				}
			}
		}
		return;
	}
	bool find(uint64 key) {
		temp = mask&hash64(key);
		while (~map[temp].first) {
			if (map[temp].first == key) {
				return true;
			}
			temp = mask&(temp + 1);
		}
		return false;
	}
	bool empty(void) {
		return !count;
	}
	size_t size(void) {
		return count;
	}
};
int main(void) {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	std::unordered_map<uint64,uint32> map;
	uint32 n;
	std::cin >> n;
	int64 a,sum = 1e15;
	uint32 ans = 0;
	map[sum] = 0;
	rep(i, 0, n) {
		std::cin >> a;
		sum += a;
		if (map.find(sum)!=map.end()) {
			ans = std::max(ans,i+1-map[sum]);
		}
		else {
			map[sum] = i + 1;
		}
	}
	std::cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 10968
PROGRAM welcomeToAtcoder
      IMPLICIT NONE
      integer(16) :: n,m
      integer(16),allocatable :: p(:),w(:)
      character(2),allocatable :: s(:)
      integer(16) :: i
      logical,allocatable :: flag(:)
      integer(16) :: ac=0,wa=0
      
      
      read*,n,m
      allocate( p(m),s(m),flag(n),w(n) )
      do i = 1,m
        read*,p(i),s(i)
      end do
      
      
      flag(:) = .true.
      w(:) = 0
      do i = 1,m
        if( flag(p(i)) )then
          if( s(i)(1:2)=='AC' )then
            ac = ac + 1
            wa = wa + w(p(i))
            flag(p(i)) = .false.
          else
            w(p(i)) = w(p(i)) + 1
          end if
        end if
      end do
      
      print*,ac,wa
      
      
      END PROGRAM

Measured memory_bytes: 3968
#include<bits/stdc++.h>
using namespace std;
#define fio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

const ll MOD = 1e9 + 7;
const ll INF = 1e9 + 9;
const ll N   = 500500;

int main()
{
	fio
	#ifndef ONLINE_JUDGE
	    freopen("input.txt", "r", stdin);
	    freopen("output.txt", "w", stdout);
	#endif
	ll n, i, j, k;
	cin>>n;
	vector<pair<ll, ll>>v;
	for(i=0;i<n;i++)
	{
		ll a, b;
		cin>>a>>b;
		v.push_back({a, b});
	}
	bool ok = true;
	ll cnt = 0;
	for(auto x:v)
	{
		if(x.first==x.second)
		{
			cnt++;
			if(cnt==3)
			{
				cout<<"Yes\n";
				return 0;
			}
		}
		else
			cnt = 0;
	}
	cout<<"No\n";
	return 0;
}

Measured memory_bytes: 3576
import java.util.*

fun main(args: Array<String>) {
  val sc = Scanner(System.`in`)
  val n = sc.nextLong()
  val m = sc.nextLong()

  if (n == 1L && m == 1L) {
    println(1)
    return
  }

  if (n <= 2L && m <= 2L) {
    println(0)
    return
  }
  if (n == 1L || m == 1L) {
    println(n*m - 2L)
    return
  }
  if (n == 2L || m == 2L) {
    println(0)
    return
  }

  println((n-2L)*(m-2L))

}


Measured memory_bytes: 36548
from collections import*
class UnionFind():
    def __init__(self,size):
        self.table=[-1]*size
    def root(self,x):
        while self.table[x]>=0:
            x=self.table[x]
        return x
    def unite(self,x,y):
        s1=self.root(x)
        s2=self.root(y)
        if s1!=s2:
            if self.table[s1]>self.table[s2]:
                s1,s2=s2,s1
            self.table[s1]+=self.table[s2]
            self.table[s2]=s1
        return
    def same(self,x,y):
        return self.root(x)==self.root(y)
    def size(self,x):
        return -self.table[self.root(x)]
n,m,*t=map(int,open(0).read().split())
u=UnionFind(n+1)
f=defaultdict(list)
e=defaultdict(list)
for l,r,d in zip(t[::3],t[1::3],t[2::3]):
    u.unite(l,r)
    e[l].append((r,d))
for i in range(n+1):
    f[u.root(i)].append(i)
for t in f.values():
    if len(t)<3:continue
    outs=defaultdict(list)
    ins=defaultdict(int)
    for i in t:
        outs[i]=[j for j,v in e[i]]
        for j in outs[i]:
            ins[j]+=1
    q=deque(v1 for v1 in t if ins[v1]==0)
    res=[]
    while q:
        v1=q.popleft()
        res.append(v1)
        for v2 in outs[v1]:
            ins[v2]-=1
            if ins[v2]==0:
                q.append(v2)
    if not res:
        print('No')
        exit()
    c=defaultdict(int)
    for i in res:
        for j,v in e[i]:
            if c[j]and c[j]!=c[i]+v:
                print('No')
                exit()
            c[j]=c[i]+v
print('Yes')

Measured memory_bytes: 88840
#pragma GCC optimize("Ofast,fast-math,unroll-loops")
 
#include <bits/stdc++.h>
 
#define int ll
//#define double long double
#define endl '\n'
#define all(C) (C).begin(), (C).end()
#define rall(C) (C).rbegin(), (C).rend()
#define mp make_pair 
#define pb emplace_back
#define dbg(x) cerr << #x << " : " << x << endl
#define PI 3.1415926535
 
using namespace std;
        
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair <int, int>;
using pld = pair <ld, ld>;

/*
const ll MAX_MEM = 3e6;
char MEM[MAX_MEM];
ll MEM_POS = 0;
void* operator new(size_t x)
{
    auto ret = MEM + MEM_POS;
    MEM_POS += x;
    assert(MEM_POS < MAX_MEM);
    return ret;
}
void operator delete(void*)
{}
*/
        
template <class T>
istream& operator>> (istream &in, vector <T> &a)
{
    for (auto &i : a)
        in >> i;
    return in;
}
        
template <class T> 
ostream& operator<< (ostream &out, vector <T> a)
{
    for (auto &i : a)
        out << i << ' ';
    return out;
}
        
template <class T, class U>
istream& operator>> (istream &in, pair <T, U> &p)
{
    in >> p.first >> p.second;
    return in;
}
        
template <class T, class U>
ostream& operator<< (ostream &out, pair <T, U> p)
{
    out << p.first << " " << p.second << " ";
    return out;
}
        
inline void Start()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    //freopen("lol.in", "r", stdin);
    //freopen("lol.out", "w", stdout);
}

signed main()
{
    Start();
    int n, k;
    cin >> n >> k;
    int mn = n;
    n %= k;
    for (int i = 0; i < 100000; ++i)
        n = llabs(n - k), mn = min(mn, n);
    cout << mn;
    return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<algorithm>
using namespace std;
int a_1(int a) {//素数判定
	int x = 0;
	for (int i = 2; i < a; i++) {
		if (a % i == 0)x++;
	}
	if (x == 0) {
		return 0;//素数であるとき
	}
	if (x != 0) {
		return 1;//素数でないとき
	}
}
int yakusuu(int n) {
	int ans = 1;
	for (int i = 2; i <= sqrt(n); i++) {
		int cnt = 0;
		while (n % i == 0) {
			cnt++;
			n /= i;
		}
		ans *= (cnt + 1);
		if (n == 1) break;
	}
	if (n != 1) ans *= 2;
	return ans;
}
int gcd(int a, int b) {
	if (a < b) {
		a ^= b;
		b ^= a;
		a ^= b;
	}
	return b ? gcd(b, a % b) : a;
}
int lcm(int a, int b) {
	return a * b / gcd(a, b);
}
int main() {
	int x;
	for (int i = 1;; i++) {
		cin >> x;
		if (x != 0) {
			cout << "Case " << i << ": " << x << endl;
		}
		else break;
	}
	return 0;
}


Measured memory_bytes: 3084
#include <bits/stdc++.h>
using namespace std;
  long long a[1001],i,ma=100000,p,n;
  long double m1,m2;
int main(){
  cin>>n;
  for(;i<n;i++)cin>>a[i];
  sort(a,a+n);
  m1=(double)(a[n-1]+a[n-2])/(a[1]-a[0]);
  for(i=n-1;i>0;i--)if(a[i]-a[i-1]<=ma){
    ma=a[i]-a[i-1];
    p=i;
  }
  for(i=n-1;i>0;i-=2)if(i!=p){
    m2=(double)(a[i-1]+a[i])/(a[p]-a[p-1]);
    break;
  }
  m1=max(m1,m2);
  printf("%.9Lf\n",m1);
}

Measured memory_bytes: 3288
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100005;
int n, k, w[3], ans, f[MAXN], a[MAXN];
char s[MAXN];
int main () {
	scanf("%d%d", &n, &k);
	scanf("%d%d%d", &w[0], &w[1], &w[2]);
	scanf("%s", s+1);
	for(int i = 1; i <= n; ++i) {
		a[i] = s[i] == 'r' ? 2 : s[i] == 's' ? 0 : 1;
		if(i <= k) { f[i] = 1; continue; }
		else {
			if(a[i] == a[i-k]) f[i] = f[i-k] + 1;
			else f[i] = 1, ans += w[a[i-k]] * ((f[i-k]+1)>>1);
		}
	}
	for(int i = n; i > n-k; --i) ans += w[a[i]] * ((f[i]+1)>>1);
	printf("%d\n", ans);
}

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

int main()
{

        int N;
        cin >> N;
        string S;
        cin >> S;
        int len = S.length();

        int x = 0;
        int max = 0;
        for (int i = 0; i < N; ++i) {

                if (S[i] == 'I') {
                        x++;
                }
                else if (S[i] == 'D') {
                        x--;
                }

                if (x > max) {

                        max = x;

                }
        }
        cout << max << endl;









}


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

using namespace std;

int n;
int a[300005], cnt[300005], sum[300005];

bool solve(int s, int t) {
	int tot = 0;
	auto itr = lower_bound(a, a + n, s);
	
	if (itr == a + n) tot = sum[n - 1];
	else {
		int id = itr - a;
		if (id) tot += sum[id - 1];
		tot += (n - id) * s;
	}
	
	return tot >= 1LL * s * t;
}

int main() {
	scanf("%d", &n);
	
	for (int i = 0; i < n; i++) {
		int x;
		scanf("%d", &x);
		x--;
		cnt[x]++;
	}
	
	for (int i = 0; i < n; i++) a[i] = cnt[i];
	
	sort(a, a + n);
	
	for (int i = 0; i < n; i++) {
		sum[i] = a[i];
		if (i) sum[i] += sum[i - 1];
	}
	
	for (int k = 1; k <= n; k++) {
		int lb = 0;
		int ub = n + 1;
		
		while (ub - lb > 1) {
			int mid = (lb + ub) / 2;
			if (solve(mid, k)) lb = mid;
			else ub = mid;
		}
		
		printf("%d\n", lb);
	}
}


Measured memory_bytes: 4480
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <numeric>
#define rep(i, n) for(int i=0;i<(int)(n);i++)
#define pb(a) push_back(a)
#define MAX(a, b) ((a < b)?b:a)
#define MIN(a, b) ((a > b)?b:a)
typedef long long int ll;
typedef unsigned long long int ull;
using namespace std;


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

	int res = n;
	rep(i, n + 1)
	{
		int cc = 0;
		int t = i;
		while ( t > 0 ) cc += t % 9, t /= 9;
		t = n - i;
		while ( t > 0 ) cc += t % 6, t /= 6;
		if ( res > cc ) res = cc;
	}

	cout << res << endl;

	return 0;
}


Measured memory_bytes: 256
from bisect import bisect_left

N, M = list(map(int, input().split()))
M_max = 10**5+1
B = [[] for _ in range(M_max)]
for _ in range(N):
    a,b = list(map(int, input().split()))
    B[a].append(b)

for a in range(M_max):
    B[a] = sorted(B[a])

queue = []
ans = []
for m in range(1,M+1):
    if B[m]:
        b = B[m].pop(-1)
        idx = bisect_left(queue, (b, m))
        queue.insert(idx, (b, m))

    if queue:
        b, a = queue.pop(-1)
        ans.append(b)
        if B[a]:
            b_ = B[a].pop(-1)
            idx = bisect_left(queue, (b_, a))
            queue.insert(idx, (b_, a))

    #print(queue)                                                                                                                                                                                                  
    #print(ans)                                                                                                                                                                                                    
    #print()                                                                                                                                                                                                       

print(sum(ans))

Measured memory_bytes: 25084
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
int n, dg[N], h[N], z, ans, st;
bool dp[N];
vector<int> gr[N];
set <pair< int, pair<int, int> > > s;
void find(int v, int par) {
	h[v] = h[par] + 1;
	s.insert({-h[v], {v, par}});
	for (auto u : gr[v]) {
		if (u != par) {
			find(u, v);
		}
	}
}
void dfs(int v, int par) {
	for (auto u : gr[v]) {
		if (u != par)
			dfs(u, v);
	}
	int zr = 0, seen = 0;
	for (auto u : gr[v]) {
		if (u != par && !dp[u])
			zr++;
		if (u != par && dp[u])
			seen = 1;
	}
//	cout << "v = " << v << " zr = " << zr;
	if (zr > 1) {
		ans += zr - 1, dp[v] = 1;
	}
	if (seen)
		dp[v] = 1;
//	cout << " dp = " << dp[v] << endl;
	return;
}
int main() {
	cin >> n;
	for (int i = 0; i < n - 1; i++) {
		int x, y;
		cin >> x >> y;
		gr[x].push_back(y);
		gr[y].push_back(x);
		dg[x]++, dg[y]++;
	}
	for (int i = 0; i < n; i++) {
		if (dg[i] >= 3)
			z = i + 1;
	}
	if (!z) {
		cout << 1;
		return 0;
	}
	z--;
	find(z, z);
	while (!s.empty()) {
		auto p = *s.begin();
		int par = p.second.second;
		if (dg[par] >= 3) {
			st = p.second.first;
			break;
		}
		s.erase(s.begin());
	}
//	cout << "st = " << st << endl;
	dfs(st, st);
	cout << ans + 1;
	return 0;
}

Measured memory_bytes: 18048
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007
#define s(x, n) memset(x, n, sizeof(x));
#define pb(x) push_back(x)
#define NIL -1
#define MAXN 11

void solve()
{
    int n;
    cin >> n;
    int a[n], b[n], c[n];
    for (int i = 0; i < n; i++)
        cin >> a[i] >> b[i] >> c[i];

    int dp[n][3];
    s(dp, 0);
    dp[0][0] = a[0];
    dp[0][1] = b[0];
    dp[0][2] = c[0];
    // cout << dp[0][0] << " " << dp[0][1] << " " << dp[0][2] << "\n";
    for (int i = 1; i < n; i++)
    {
        dp[i][0] = max(dp[i - 1][1], dp[i - 1][2]) + a[i];
        dp[i][1] = max(dp[i - 1][2], dp[i - 1][0]) + b[i];
        dp[i][2] = max(dp[i - 1][0], dp[i - 1][1]) + c[i];
        //   cout << dp[i][0] << " " << dp[i][1] << " " << dp[i][2] << "\n";
    }
    cout << max(dp[n - 1][0], max(dp[n - 1][1], dp[n - 1][2])) << "\n";
}
int main()
{
#ifdef WIN32
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

#ifndef WIN32
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
#endif
    int t;
    t = 1;
    /// cin >> t;
    for (int I = 1; I <= t; I++)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 5884
#include<iostream>
#include<algorithm>

using namespace std;

int main(void) {
  int S[10000];
  int T[500];
  int n, m;

  cin >> m;
  for(int i = 0; i < m; i++) {
    cin >> S[i];
  }
  sort(S, S + m);
  
  cin >> n;
  for(int i = 0; i < n; i++) {
    cin >> T[i];
  }
  sort(T, T + n);

  int ans = 0;
  for(int i = 0; i < n; i++) {
    if( binary_search(S, S + m, T[i]) ) {
      ans++;
    }
  }
  cout << ans << endl;

  return 0;
}

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

#define ll          long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        1000000007
#define rep(i,a,b)  for(int i=a;i<b;i++)
using namespace std;

void solve(){
    string a,b;
    cin>>a>>b;
    if(sz(a)+1!=sz(b)){
    	cout<<"No"<<endl;
    	return;
    }
    b.pop_back();
    if(a!=b) cout<<"No"<<endl;
    else cout<<"Yes"<<endl;
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t=1;
    // cin>>t;
    while(t--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 3660
A, B = map(int, input().split())
# 1..4k = 4k
# 1..(4k+1) = 1
# 1..(4k+2) = 4k+3
# 1..(4k+3) = 0

def xorall(aa):
    remz = aa % 4
    if remz == 0:
        return aa

    if remz == 1:
        return 1

    if remz == 2:
        return aa+1

    #if remz == 3:
    return 0

ans = xorall(B) ^ xorall(A-1)
print(ans)


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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

#define ld long double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

//-------------------------------------------------
//--Range Set
//-------------------------------------------------
template<typename T>
class RangeSet
{
private:
    ::std::vector<int> v;
    ::std::unordered_map<T, int> Map;
    ::std::vector<::std::vector<int> > data;
    int kind;
public:
    RangeSet(const ::std::vector<T> &v_):v(v_.size()){
        int sz = v_.size(); kind = 0;
        for(int i=0;i<sz;i++){
            T t = v_[i];
            if (Map.count(t)){
                data[Map[t]].push_back(i);
            }else{
                Map[t] = kind++;
                data.push_back(::std::vector<int>());
                data.back().push_back(i);
            }
            v[i] = Map[t];
        }
    }
    int query(T x){
        if (!Map.count(x)) return 0;
        return data[Map[x]].size();
    }
    int query(int a, int b, T x){
        if (a>b) return 0;
        if (!Map.count(x)) return 0;
        int xi = Map[x];
        auto right = ::std::upper_bound(data[xi].begin(),data[xi].end(),b);
        auto left  = ::std::lower_bound(data[xi].begin(),data[xi].end(),a);
        return right-left;
    }
    void update(int k, T x){
        int ei = v[k];
        auto eitr = ::std::lower_bound(data[ei].begin(),data[ei].end(),k);
        data[ei].erase(eitr);
        v[k] = Map[x];
        if (Map.count(x)){
            int xi = Map[x];
            auto itr = ::std::lower_bound(data[xi].begin(),data[xi].end(),k);
            data[xi].insert(itr, k);
        }else{
            Map[x] = kind++;
            data.push_back(::std::vector<int>());
            data.back().push_back(k);
        }
    }
};

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

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,k; cin>>n>>k;
    vll a(n);
    rep(i,n){cin>>a[i]; a[i]--;}
    vll s(n+1);
    s[0] = 0;
    rep(i,n) s[i+1]=(s[i]+a[i])%k;
    RangeSet<ll> rs(s);
    ll ans=0;
    rep(i, n){
        ans+=rs.query(i+1, i+k-1, s[i]);
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 25204
// In the name of GOD
#include<bits/stdc++.h>
using namespace std;

#define debug(x) cout<<#x<<" :: "<<x<<"\n";
#define debug2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\n";
#define debug3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\n";

#define     IOS         ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define 	setprecn(x) cout<<fixed<<setprecision(x);
#define 	ll          long long int
#define 	pb          push_back
#define 	pll         pair<ll,ll>
#define 	vll         vector<ll>
#define 	ff          first
#define 	ss          second
#define 	all(a)      (a).begin(),(a).end()
#define 	sz(x)       (ll)x.size()
#define 	mod         1000000007
#define 	inf         10000000000000007
#define 	rep(i,n)    for(ll i=0;i<n;i++)
#define 	repe(i,a,b) for(ll i=a;i<b;i++)
#define 	lbnd        lower_bound
#define 	ubnd        upper_bound
#define 	bs          binary_search

ll power(ll a,ll b,ll m=mod)
{
	if(b==0)
		return 1;
	if(b==1)
		return a;
	ll c=power(a,b/2,m);
	if(b%2==0)
		return((c%m)*(c%m))%m;
	return ((((c%m)*(c%m))%m)*(a%m))%m;
}

/********************************************************/
//	d.erase(unique(all(d)), d.end());



int main()
{
	IOS;
	ll n,k,m,i,j,c=0,cs=0,t;
	t=1;

	// cin>>t;
	string s;
	while(t--)
	{
		cin>>n>>m>>k;
		// n=s.length();
		// ll a[n];
		c=k-n+m;
		c=max(c,0ll);
		cout<<c;
		
		if(t!=0)
	   		cout<<"\n";
	}
	return 0;
}

Measured memory_bytes: 256
//Author: kaiyu
#include <iostream>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <set>
#include <unordered_map>
#include <cstring>
#include <string>
#include <queue>
#include <stack>
#include <numeric>
#include <iomanip>
using namespace std;
typedef long long ll;
#define SZ(x) ((int)(x).size())
#define all(x)  x.begin(),x.end()
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define tt ll t;cin >> t;while(t--)
#define int3(x,y,z) ll x,y,z;cin >> x >> y >> z;
#define int2(x,y) ll x,y;cin >> x >>y;
#define int1(x) ll x;cin>>x;
#define  fio ios::sync_with_stdio(0);cin.tie(NULL);
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
//bool cmp(pair<string,int>p1,pair<string,int>p2) {
//    return p1.ss > p2.ss;
//}
//if (s1.find(s2) != std::string::npos) {
//   std::cout << "found!" << '\n';
//}


using namespace std;

int main() {
    fio
    int2(n,m)
    ll a[n];
    float sum = 0;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        sum+=a[i];
    }
    sum = sum/(4*m);
    int count = 0;
    for (int j = 0; j < n; ++j) {
        if(a[j] >= sum) {
            count++;
        }
    }
    if(count>=m) {
        cout << "Yes" << endl;
    }
    else
        cout << "No" << endl;




}





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

int main() {


//int n,a,b;
int *num=new int[4];
cin >> num[0] >> num[1] >> num[2] >> num[3];
//int *num=new int[3];

//int num[]={300000,200000,100000,0};
//string *name=new string[N+1];


sort(num,num+4);
if(num[0]==1 && num[1]==4 && num[2]==7 && num[3]== 9)
cout << "YES" << endl;
else
cout << "NO" << endl;



}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

namespace CSharpSample01
{
    
    class Program
    {
        
        static void Main(string[] args)
        {
            string S = Console.ReadLine();

            int first_one = 0;
            int first_zero = 0;

            for(int i = 0; i < S.Length; i++)
            {
                int color = int.Parse(S[i].ToString());

                if(i % 2 == 0)
                {
                    if(color == 0)
                    {
                        first_one++;
                    }
                }
                else
                {
                    if(color == 1)
                    {
                        first_one++;
                    }
                }

            }

            for (int i = 0; i < S.Length; i++)
            {
                int color = int.Parse(S[i].ToString());

                if (i % 2 == 0)
                {
                    if (color == 1)
                    {
                        first_zero++;
                    }
                }
                else
                {
                    if (color == 0)
                    {
                        first_zero++;
                    }
                }

            }

            Console.WriteLine(first_one < first_zero ? first_one : first_zero);


        }
    }
}


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

bool input(int&, int&);
void sharp(const int&);
void line(const int&, const int&);

int main() {
	int h;
	int w;
	
	while (input(h, w)) {
		line(h, w);
	}
	
	return 0;
}

bool input(int& h, int& w) {
	cin >> h >> w;
	return !((h == 0) && (w == 0));
}

void sharp(const int& w) {
	if (w > 0) {
		cout << '#';
		sharp(w - 1);
	}
}

void line(const int& h, const int& w) {
	if (h > 0) {
		sharp(w);
		cout << endl;
		line(h - 1, w);
	} else {
		cout << endl;
	}
}

Measured memory_bytes: 1164
import java.util.*;
import java.io.*;
 
public class Main {
  public static void main(String[] args) throws Exception{
    Scanner sc = new Scanner(System.in);
    int k = sc.nextInt();
    int n = sc.nextInt();
    int[] num = new int[n];
    for(int i = 0; i < n; ++i) {
      num[i] = sc.nextInt();
    }
    new Solution(n, k, num);
  }
}

class Solution {
  public Solution(int n, int k, int[] num) {
    int res = 0;
    Arrays.sort(num);
    for(int i = 1; i < n; ++i) {
      if(res < num[i] - num[i - 1]) res = num[i] - num[i - 1];
    }
    if(res < k + num[0] - num[n - 1]) res = k + num[0] - num[n - 1];
    System.out.println(k - res);
      // System.out.println(res);
  }
}

class Scanner {
  StringTokenizer st;
  BufferedReader br;

  public Scanner(InputStream system) {
    br = new BufferedReader(new InputStreamReader(system));
  }

  public Scanner(String file) throws Exception {
    br = new BufferedReader(new FileReader(file));
  }

  public String next() throws IOException {
    while (st == null || !st.hasMoreTokens())
      st = new StringTokenizer(br.readLine());
    return st.nextToken();
  }

  public String nextLine() throws IOException {
    return br.readLine();
  }

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

  public double nextDouble() throws IOException {
    return Double.parseDouble(next());
  }

  public char nextChar() throws IOException {
    return next().charAt(0);
  }

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

  public int[] nextArrInt(int n) throws IOException {
    int[] a = new int[n];
    for (int i = 0; i < n; i++)
      a[i] = nextInt();
    return a;
  }

  public long[] nextArrLong(int n) throws IOException {
    long[] a = new long[n];
    for (int i = 0; i < n; i++)
      a[i] = nextInt();
    return a;
  }

  public boolean ready() throws IOException {
    return br.ready();
  }

  public void waitForInput() throws InterruptedException {
    Thread.sleep(3000);
  }
}

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

#define ll long long
#define forr(i,n) for(ll i=0;i<n;i++)
#define f(i,a,b) for(ll i=a;i<b;i++)
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define vi vector<ll>
#define endl '\n'
#define ce(ele) cout<<ele<<' '
#define cs(ele) cout<<ele<<'\n'
#define CASE(t) ll t; cin>>t; while(t--)
#define sor(v) sort(v.begin(),v.end())
#define rev(v) reverse(v.begin(),v.end())

ll power(ll a,ll b){ll r=1;while(b--)r*=a;return r;}

int solve(int a,int b){
    if(a==b)return 0;
    return 1+solve(min(a,b),max(a,b)-min(a,b));
}
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);

    int n,cnt=0;double d,x,y;cin>>n>>d;
    f(i,0,n){
        cin>>x>>y;
        if(sqrt(x*x+y*y)<=d)cnt++;
    }cs(cnt);
    

  }


Measured memory_bytes: 3860
n,x=map(int,input().split())
a=list(map(int,input().split()))
a.insert(0,0)
cnt=0
for i in range(n):
	if a[i]+a[i+1]>x:
		cnt+=a[i]+a[i+1]-x
		a[i+1]-=(a[i]+a[i+1]-x)
print(cnt)

Measured memory_bytes: 14540
import sys
from collections import Counter

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N, P = lr()
S = sr()
# 累積和
remain = [0] * N
cur = 0
answer = 0
S_rev = S[::-1]
power = 1
for i in range(N):
    if i >= 1:
        power *= 10
        power %= P
    num = cur + power * int(S_rev[i])
    cur = num % P
    remain[i] = cur

if P == 2 or P == 5:
    ind = (i for i, x in enumerate(S, 1) if int(x) % P == 0)
    answer = sum(ind)

else:
    counter = Counter(remain)
    answer += counter[0]
    for k, v in counter.items():
        answer += v * (v-1) // 2

print(answer)


Measured memory_bytes: 12288
#include<bits/stdc++.h>
#define int long long
#define rep(i, l, r) for(register int i = l; i <= r; ++ i)
using namespace std;
const int N = 3000010;
inline int read()
{
	register char cc = getchar(); register int cn(0), flus(1);
	while(cc < '0' || cc > '9') {if(cc == '-') flus = - flus; cc = getchar();}
	while(cc >= '0' && cc <= '9') {cn = cn * 10 + cc - '0'; cc = getchar();}
	return cn * flus;
}
set<int> s;
signed main()
{
	int n = read();
	bool ans(1);
	while(n --)
	{
		int tmp = read();
		if(s.find(tmp) != s.end())
		{
			ans = 0;
			break; 
		} 
		s.insert(tmp);
	}
	if(ans) printf("YES\n");
	else printf("NO\n");
	return 0;
}


Measured memory_bytes: 9600
#include <stdio.h>
 
int main()
{
  int N;
  double M;
  double com;
  double sum = 0.0;
  int count = 0;
  scanf("%d", &N);
  scanf("%lf", &M);
  int A[N+1];
  for(int i = 0; i < N; i++){
    scanf("%d", &A[i]);
    sum += A[i];
  }
  com = sum / (4 * M);
  for(int i = 0; i < N; i++){
    if(A[i] >= com){
      count += 1;
    }
  }
  if(count >= M){
    printf("Yes\n");
  }
  else{
    printf("No\n");
  }
 
  return 0;
}

Measured memory_bytes: 1728
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define REP(i,n) for(int i = 0; i < n; i++)
const int INF = 1e9;
const int N = 2e5+7;
const int MOD = 1e9+7;

int a[N];

int main(){

  int n; cin >> n;
  REP(i,n) cin >> a[i];

  sort(a,a+n);
  ll k = 1,c = 2;
  for(int i = n-2; i >= 0; i--){
    if(a[i+1] == a[i]){
      k *= a[i];
      i--;
      c--;
    }
    if(!c) break;
  }
  cout << ((!c)?k:0) << endl;

  return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;

int main()
{
	int n;
	cin >> n;
	for (int i = 0; i < n; i++){
		double x1, y1, x2, y2, x3, y3;
		cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;
		double c1 = (x1 + x2) / 2;
		double c2 = (x1 + x3) / 2;
		double d1 = (y1 + y2) / 2;
		double d2 = (y1 + y3) / 2;
		double k1, k2, px, py, r;
		if (x1 != x2 && x1 != x3){
			k1 = (y2 - y1) / (x2 - x1);
			k2 = (y3 - y1) / (x3 - x1);
			py = (c2 - c1 + k2 * d2 - k1 * d1) / (k2 - k1);
			px = k1 * (d1 - py) + c1;
		}
		else{
			if (x1 == x2){
				py = d1;
				px = c2;
			}
			else if (x1 == x3){
				py = d2;
				px = c1;
			}
		}
		r = sqrt((px - x1)*(px - x1) + (py - y1)*(py - y1));

		cout << setprecision(3);
		cout << fixed;
		cout << px << " " << py << " " << r << endl;
	}
	return 0;
}

Measured memory_bytes: 1288
h, w, k = map(int, input().split())
mat = []
for r in range(h):
    mat.append(list(input()))

from itertools import product
ans = 0
for mask in product(['0', '1'], repeat = h + w):
    mask = int(''.join(mask), 2)
    count = 0
    for r in range(h):
        for c in range(w):
            if ((mask >> r)&1 == 0) and ((mask >> (h + c))&1 == 0) and mat[r][c] == '#':
                count +=1
    if count == k: ans += 1
print(ans)

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

int main() {
    int n, m, c;
    std::cin >> n >> m >> c;
    std::vector<long long> b(m, 0);
    int a = 0;
    for (int mm = 0; mm < m; mm++) {
        std::cin >> b[mm];
    }

    for (int nn = 0; nn < n; nn++) {
        long long s = 0;
        for (int mm = 0; mm < m; mm++) {
            int a;
            std::cin >> a;
            s += a * b[mm];
        }
        if (s + c > 0) {
            a++;
        }
    }
    std::cout << a << std::endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>

using namespace std;
typedef pair<string, int> P;

void solve()
{
	int n, m;
	while(cin >> n >> m)
	{
		if(!n && !m)
		{
			break;
		}
		vector<P> Vec(n);
		for(int i = 0; i < n; ++i)
		{
			cin >> Vec[i].first >> Vec[i].second;
		}
		vector<string> SVec(m);
		for(int i = 0; i < m; ++i)
		{
			cin >> SVec[i];
		}
		int sum = 0;
		for(int i = 0; i < m; ++i)
		{
			for(int j = 0; j < n; ++j)
			{
				bool flag = true;
				for(int k = 0; k < 8; ++k)
				{
					if(Vec[j].first[k] == '*')
					{
						continue;
					}
					if(SVec[i][k] != Vec[j].first[k])
					{
						flag = false;
						break;
					}
				}
				if(flag)
				{
					sum += Vec[j].second;
				}
			}
		}
		cout << sum << endl;
	}
}

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

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

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

int v[1000005], v2[1000005];
int sieve1[100005];

void precomp() {
	sieve1[0] = 0;
	sieve1[1] = 0;
	rep(i, 2, 100005) sieve1[i] = 1;
	rep(i, 2, 100005) if (sieve1[i]) for (int j = 2 * i; j < 100005; j += i) sieve1[j] = 0;
}

int main() {
	cin.tie(0)->sync_with_stdio(0);
	cin.exceptions(cin.failbit);

	int l, r; cin >> l >> r;
	int n = r - l + 1;
	rep(i, 0, n) v[i] = l + i;

	precomp();

	rep(i, 0, 100005) if (sieve1[i]) {
		for (int j = (i - l % i) % i; j < n; j += i) while (v[j] > 1 && v[j] % i == 0) v[j] /= i, v2[j]++;
	}
	rep(i, 0, n) if (v[i] > 1) v[i] = 1, v2[i]++;
	
	int ans = 0;
	rep(i, 0, n) if (sieve1[v2[i]]) ans++;
	cout << ans << endl;
}



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

#define rep(i,n) for(int i = 0; i < n; i++)
#define REP(i,n) for(int i = 1; i < n; i++)
#define repll(i,n) for(ll i = 0; i < n; i++)
#define REPll(i,n) for(ll i = 1; i < n; i++)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define yesorno(a) printf(a ? "yes\n" : "no\n")
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define YESorNO(a) printf(a ? "YES\n" : "NO\n") 
#define endl "\n"
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vii = vector<vi>;
using vl = vector<ll>;
using vll = vector<vl>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll a, const ll b){return ((a)+(b)-1)/b;}


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

  ll n, k;
  cin >> n >> k;
  ll m[100005] = {};
  rep(i,n){
    ll a, b;
    cin >> a >> b;
    m[a] += b;
  }
  rep(i,100001){
    if(m[i] >= k){
      cout << i << endl;
      return 0;
    }
    else{
      k -= m[i];
    }
  }
}

Measured memory_bytes: 1024
while True:
    i = input()
    H,W = map(int, i.split())
    
    if H == 0 and W == 0:
        break
    
    y = 0
    while H != y:
        
        x = 0
        while W != x:
            if (x == 0 or x == W-1 or
                y == 0 or y == H-1):
                print("#", end="")
            else:
                print(".", end="")

            x += 1
            
        print("")
        y += 1

    print  ("")


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

using namespace std;
//131073
const int maxn = 223456;
typedef pair<int, int> pii;
typedef long long ll;
multiset<int>s;
multiset<int>::iterator it;

int main(){
    ios_base::sync_with_stdio(0);
//    freopen("input.txt", "r", stdin);
    int a, b;
    cin >> a >> b;
    if(a <= 8 && b <=8)cout << "Yay!" << '\n';
    else cout << ":(" << '\n';
    return 0;
}

Measured memory_bytes: 256
N = int(input())
S = []
for _ in range(N):
    a = int(input())
    S_ = []
    for _ in range(a):
        S_.append(tuple(map(int,input().split())))
    S.append(S_)

def judge(S,bin):
    #矛盾があるかどうかの判定
    #正直者:1,不親切な人:0
    for i in range(N):
        if bin[i] == 1:
            for j in range(len(S[i])):
                if (S[i][j][1] == 1 and bin[S[i][j][0]-1] != 1) \
                or (S[i][j][1] == 0 and bin[S[i][j][0]-1] != 0):
                    return False
    return True

ans = 0
for i in range(2**N):
    b = bin(i)
    b = b[2:]
    while len(b) < N:
        b = "0"+b
    bit = []
    for j in range(len(b)):
        if b[j] == "0":
            bit.append(0)
        else:
            bit.append(1)
    if judge(S,bit):
        ans = max(ans,sum(bit))

print(ans)


Measured memory_bytes: 3064
#ifdef __GNUC__
#pragma GCC target("avx2")
#pragma GCC optimize ("O20")
#pragma GCC optimize ("tree-vectorize")
#pragma GCC optimize("unroll-loops")
#define iss std::cin
#endif
#include "bits/stdc++.h"
#define rep(i, times) for(ll i = 0; i < (times); ++i)
#define pr(x) (cout << x << "\n")
using ll = int_fast64_t; using namespace std;

#ifndef __GNUC__
string text =
R"X(9876543210)X";
stringstream iss{text};
#endif

inline ll keta(ll n) { return ll(log10(n)) + 1; }
int main( ) {
	cin.tie(0);	ios::sync_with_stdio(0);
	ll N; iss >> N;
	ll minK{LLONG_MAX};
	ll sqN{ll(sqrt(N)) + 1};
	for (ll a = 1; a < sqN; ++a) {
		ll b = N / a;
		if (b * a == N) {
			minK = min(minK, keta(max(a, b)));
		}
	}
	pr(minK);
}

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

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define MOD 1000000007
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)

lli calc(lli num){
    lli sum=0;
    while(num>0){
        sum+=num%10;
        num/=10;
    }
    return sum;
}

void func(long long N, long long A, long long B){
    lli ans=0;
    REP(i,1,N+1){
        lli num = calc(i);
        if(A<=num && num <= B)ans += i;
    }
    cout<<ans<<endl;
}

int main(){
    // cout << fixed << setprecision(5);

    long long N;
    scanf("%lld",&N);
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    func(N, A, B);
    return 0;
}


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

int main(){
    int n; cin >> n;
    msi m;
    rep(i, n){
        string s; cin >> s;
        m[s] += 1;
    }
    int max = 0;
    for(const auto&x : m) {
        int v = x.second;
        if(v > max) max = v;
    }
    for(const auto&x : m){
        if(x.second == max) cout << x.first << endl;
    }
    return 0;
}


Measured memory_bytes: 19260
#include <cstdio>
#include <vector>
#define ll long long
#define rep(i, j, k) for (i=j;i<=k;i++)
using namespace std;
ll n;
int i, k;
vector<int> a;

void solve(ll n, int &k) {
    if (n == 1) {
        a.push_back(1);
        k = 1;
        return;
    }
    if (n & 1) {
        solve((n - 1) / 2, k);
        k++;
        a.push_back(k);
    } else {
        solve(n - 1, k);
        k++;
        a.insert(a.begin(), k);
    }
}

int main() {
    scanf("%lld", &n);
    solve(n, k);
    rep(i, 1, k) a.push_back(i);
    printf("%d\n", a.size());
    rep(i, 0, a.size() - 1) printf("%d ", a[i]);
    return 0;
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var a, b int
	var op string
L:
	for {
		fmt.Scan(&a)
		fmt.Scan(&op)
		fmt.Scan(&b)

		switch op {
		case "+":
			fmt.Println(a + b)
		case "-":
			fmt.Println(a - b)
		case "*":
			fmt.Println(a * b)
		case "/":
			fmt.Println(a / b)
		case "?":
			break L
		}
	}
}



Measured memory_bytes: 1116
#include<stdio.h>
int main(void)
{
    int array[5][4][11]={};
    int a,b,x,y,z,p;

    scanf("%d",&b);
    for(a=0;a<b;a++){
        scanf("%d %d %d %d",&x,&y,&z,&p);
    array[x][y][z]+=p;
    }
        for(x=1;x<5;x++){
            for(y=1;y<4;y++){
                for(z=1;z<11;z++){
                    printf(" %d",array[x][y][z]);
                }
                printf("\n");
                }
            if(x!=4){
                printf("####################\n");
            }
        }
    return 0;
}

Measured memory_bytes: 612
#include <stdio.h>
#include <stdlib.h>
#define min(a, b) ((a) < (b) ? (a) : (b))
typedef long long ll;

int main(void)
{
    ll n, k;
    scanf("%lld%lld", &n, &k);

    n = n % k;
    printf("%lld\n", min(abs(n - k), n));
    
    return 0;
}

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

int main(){
    int H, N;
    cin >> H >> N;
    int inf = 1e9;
    vector<int> A(N), B(N);
    for (int i = 0; i < N; i++) cin >> A[i] >> B[i];
    vector<int> dp(H+1, inf);
    dp[0] = 0;
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < H; j++) {
            int k = min(j+A[i], H);
            dp[k] = min(dp[k], dp[j]+B[i]);
        }
    }
    cout << dp[H] << endl;
    return 0;
}


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

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define REP(i,n) FOR(i,0,n)
typedef long long ll;
using ll = long long;
using vi = vector<int>;
using mii = map<int, int>;
using msi = map<string, int>;
using pii = pair<int, int>;

int main()
{
    ios::sync_with_stdio(false);
    int a, b, c;
    cin >> a >> b >> c;

    FOR(i, 1, b + 1) {
        if((i * a) % b == c) {
            cout << "YES" << endl;
            return 0;
        }
    }
    cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		int ans = 0;
		for (int i=0; i<n; i++){
			int a = scanner.nextInt();
			while (a%2==0){
				ans++;
				a = a/2;
			}
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 34180
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a, b, c, x, y;
    cin >> a >> b >> c >> x >> y;
    int ans = 1000000000;
    for(int i = 0; i <= max(x, y); i++){
        int m = 2*c*i + max(0, x-i)*a + max(0, y-i)*b;
        ans = min(ans, m);
    }
    cout << ans << endl;
}

Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define pii pair<int,int>
const long long MOD=1e9+7;

double mkaijo(int n){
  if(n<=1) return 1;
  return n*mkaijo(n-1);
}

int main() {
  int n;
  cin>>n;
  vector<pair<int,int>> city(n);
  rep(i,n) cin>>city[i].first>>city[i].second;
  double count=mkaijo(n-1)*2;
  double sum=0;
  rep(i,n) rep(j,i){
    int dx=city[i].first-city[j].first;
    int dy=city[i].second-city[j].second;
    double l=pow(dx*dx+dy*dy,0.5);
    //cout<<l*count<<endl;
    sum+=l*count;
  }
  //cout<<mkaijo(n)<<endl;
  cout<<fixed<<setprecision(15)<<sum/mkaijo(n)<<endl;
  return 0;
}

Measured memory_bytes: 512
### main

while true
  t = gets.strip.to_i
  break if t == 0

  n = gets.strip.to_i

  sum = 0
  n.times do
    ts, tf = gets.strip.split(' ').map{|s| s.to_i}
    sum += (tf - ts)
  end

  puts (sum >= t ? 'OK' : t - sum)
end

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

int main(){
    int n,h,w;
    cin>>n>>h>>w;
    vector<int> windows(n*w+1,0);
    for (int i = 0; i < n; ++i) {
        int t;
        cin>>t;
        if(i%2==0){
            ++windows[w*i+t];
            --windows[w*(i+1)+t];
        }
        else{
            ++windows[w*i-t];
            --windows[w*(i+1)-t];
        }
    }
    for (int i = 1; i < n*w+1; ++i) {
        windows[i]+=windows[i-1];
    }
    int ans=h*-1;
    for (auto i:windows){
        if(i<=0)ans+=h;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3128
*> AtCoder My Practice
       *> author: Leonardone @ NEETSDKASU
       *>
       IDENTIFICATION DIVISION.
       PROGRAM-ID. Answer.
       ENVIRONMENT DIVISION.
       CONFIGURATION SECTION.
       REPOSITORY.
              FUNCTION ALL INTRINSIC.
       DATA DIVISION.
       WORKING-STORAGE SECTION.
              01 Input-Values.
                     05 s      PIC X(50).
                     05 a      PIC X(10).
                     05 b      PIC X(10).
              01 Calc-Values.
                     05 disp   PIC X(5).
                     05 v      BINARY-LONG.
                     05 i      BINARY-LONG.
                     05 r      BINARY-LONG.
       PROCEDURE DIVISION.
       AnswerMain SECTION.
       000-Start.
       
              ACCEPT s.
              UNSTRING s DELIMITED BY SPACE INTO a b.
              MOVE CONCATENATE(TRIM(a),TRIM(b)) TO s
              MOVE s TO v.
              MOVE "No" TO disp.
              PERFORM WITH TEST AFTER
              VARYING i FROM 1 BY 1 UNTIL i >= 1000
                     MOVE i TO r
                     MULTIPLY i BY r
                     IF r = v THEN
                            MOVE "Yes" TO disp
                     END-IF
              END-PERFORM.
              DISPLAY disp.
              
       END PROGRAM Answer.


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int f=-2e9;
	string s;
	cin>>s;
	for (int i=0;i<s.size();++i)
		if (s[i]=='C')
			f=i;
	if (f==-2e9)
		{cout<<"No"<<endl;return 0;}
	for (int i=f+1;i<s.size();++i)
		if (s[i]=='F')
			{cout<<"Yes"<<endl;return 0;}
	cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int l,i,j,a[1000],t,n,A;
    int d=20000000,h,k;
    string s;
    cin>>s;
    for(i=0;i<s.size()-2;i++){
t=(s[i]-'0')*100+(s[i+1]-'0')*10+s[i+2]-'0';
        d=min(abs(t-753),d);
    }
    cout<<d<<endl;
    

}

Measured memory_bytes: 256