akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;

#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define mp make_pair
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define EPS 1e-8
#define DEB 0

int field[1024][1024];
int dp[1024][1024];
int h,w,n;

int main(){
  
  while(scanf("%d%d%d",&h,&w,&n),h|w|n){
    memset(dp,0,sizeof(dp));
    rep(i,h){
      rep(j,w){
	scanf("%d",&field[i+1][j+1]);
      }
    }
    dp[1][1] = n-1;
    REP(i,1,h+1){
      REP(j,1,w+1){
	int k1,k2;
	if( dp[i-1][j]%2 && field[i-1][j]==0 ){
	  k1 = 1;
	}else{
	  k1 = 0;
	}
	if( dp[i][j-1]%2 && field[i][j-1]==1 ){
	  k2 = 1;
	}else{
	  k2 = 0;
	}

	dp[i][j] += (dp[i-1][j]+k1)/2  + (dp[i][j-1]+k2)/2;
      }
    }
#if DEB
    REP(i,1,h+1){
      REP(j,1,w+1){
	printf("%2d ",dp[i][j]);
      }
      puts("");
    }
#endif
    
    // Nツ嘉アツ姪堋づ個湘ウツ妥板づーツ青カツ青ャ
    REP(i,1,h+1){
      REP(j,1,w+1){
	field[i][j] = (field[i][j]+dp[i][j])%2;
      }
    }
#if DEB
    puts("field");
    REP(i,1,h+1){
      REP(j,1,w+1){
	printf("%2d ",field[i][j]);
      }
      puts("");
    }
#endif
    
    int x=1;
    int y=1;
    for(;;){
      if( x>w || y>h )break;
      if( field[y][x]==1 ){
	x++;
      }else{
	y++;
      }
    }

    printf("%d %d\n",y,x);
  }
  return 0;
}

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

int main()
{
	int a,b;
	char op;
	cin >> a >> op >> b;
	int ans;
	if (op == '+') ans = a+b;
	else ans = a-b;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=420,M=1e5+50;
int n,m,x[M],y[M],f[N][N],ans;bool fl[N];
int main(){
    scanf("%d%d",&n,&m);
    for(int i=1;i<=m;i++)
        scanf("%d%d",&x[i],&y[i]);
    for(int i=1;i<=n;i++)f[i][i]=1;
    for(int i=m;i;i--)
        for(int j=1;j<=n;j++){
            if(f[j][x[i]]&&f[j][y[i]])fl[j]=1;
            if(f[j][x[i]])f[j][y[i]]=1;
            if(f[j][y[i]])f[j][x[i]]=1;
        }
    for(int i=1;i<=n;i++)
        for(int j=i+1;j<=n;j++)if(!fl[i]&&!fl[j]){
            bool ff=0;
            for(int k=1;k<=n;k++)if(f[i][k]&&f[j][k]){ff=1;break;}
            ans+=!ff;
        }
    cout<<ans;
    return 0;
}

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

vector<int> p;

int main() {
	int N; cin >> N;
	p.push_back(3);
    for(int i=5; i<55555; i += 2){
        bool f=true;
        for(int j=0; j<p.size(); ++j){
            if(i%p[j]<1){
                f=false;
                break;
            }
        }
        if(f) p.push_back(i);
    }
	cout << 2;
	for(int i=1, j=1; i<N; ++j){
	    if(p[j]%5==1){
	        cout << ' ' << p[j];
	        ++i;
	    }
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <list>
#include <cstring>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)

int main()
{
    int n, val;
    scanf("%d", &n);
    char com[20];
    list<int> l;

    rep(i,n){
        scanf("%s", com);
        if (com[0] == 'i') {
            scanf("%d", &val); 
            l.push_front(val);
        }
        else if (com[6] == 'F') l.pop_front();
        else if (com[6] == 'L') l.pop_back();
        else {
            scanf("%d", &val);
            for (auto itr = l.begin(); itr != l.end(); ++itr){
                if (*itr == val){
                    l.erase(itr);
                    break;
                }
            }
        }
    }
    
    int i = 0;
    for ( auto itr = l.begin(); itr != l.end(); ++itr){
        if ( i++ ) printf(" ");
        printf("%d", *itr);
    }
    printf("\n");

    return 0;
}


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

int main(){
  int n=0;
  string s;

  cin >> s;
  n=s.size();
  if(s[n-1]=='s'){
  cout << s << "es" << endl;
  }
  else{
  cout << s << "s" << endl;
  }
  return 0;
}

Measured memory_bytes: 3620
#include<iostream>
#include<cstdio>
#include<cstring>
#include<queue>
#include<stack>
#include<cmath>
#include<algorithm>
#define inf 99999999
using namespace std;
typedef long long ll;
const int MAX=100000+10;
int cmp(int a,int b){
    return a<b;
}
ll a[MAX],b[MAX];
int main(){
    #ifdef SIYU
    //freopen("in.txt","r",stdin);
    #endif // SIYU
    int n;
    cin>>n;
    for(int i=0;i<n;i++)
        scanf("%lld",&a[i]);
    sort(a,a+n,cmp);
    for(int i=0;i<n;i++){
        if(i==0)    b[i]=a[i];
        else    b[i]=b[i-1]+a[i];
    }
    int countt=0;
    for(int i=n-1;i>=0;i--){
        if(a[i]<=b[i-1]*2)
            countt++;
        else
            break;
    }
    cout<<countt+1<<endl;
    return 0;
}

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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using ll = long long;
int mod = 1000000000+7;

int main(){

	int d;
	cin>>d;
	int c[26];
	rep(i,26)cin>>c[i];
	int lastd[26]={};
	int s[d][26];
	rep(i,d){
		rep(j,26){
			cin>>s[i][j];
		}
	}

	rep(i,d)cout<<1<<endl;
  
	return 0;
}


Measured memory_bytes: 3652
def s0():return input()
def s1():return input().split()
def s2(n):return [input() for x in range(n)]
def n0():return int(input())
def n1():return [int(x) for x in input().split()]
def n2(n):return [int(input()) for _ in range(n)]
def n3(n):return [[int(x) for x in input().split()] for _ in range(n)]

k,n=n1()
a=n1()

ans=0
for i in range(n-1):
    ans=max(a[i+1]-a[i],ans)
print(k-(max(ans,k-a[n-1]+a[0])))

Measured memory_bytes: 26444
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < int(n); ++i)
#define rep1(i, n) for (int i = 1; i < int(n); ++i)
#define repx(i, x, n) for (int i = int(x); i < int(n); ++i)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; --i)
#define ALL(n) begin(n), end(n)
#define IN(a, x, b) ((a) <= (x) && (x) < (b))
#define OUT(a, x, b) ((x) < (a) || (x) < (b))
typedef long long ll;
typedef long double ld;
const ll INF = 1e18;
const ll MOD = 1000000007;

int main()
{
    string S;
    char c;
    int ans = 0;
    cin >> S;
    c = S[0];
    rep1(i, S.length())
    {
        if (c != S[i])
        {
            c = S[i];
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}


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

using namespace std;

int main() {
   ios_base::sync_with_stdio(false); cin.tie(nullptr);
   int N, M; cin >> N >> M;
   vector<int> P(M, -1);
   vector<int> invP(M, -1);
   vector<int> freq(M+1);
   freq[0] = N;
   int Q; cin >> Q;
   vector<int> A(Q);
   for (int i = 0; i < Q; ++i) cin >> A[i], --A[i];
   int cur = 0;
   for (int i = Q-1; i >= 0; --i) {
      int z = A[i];
      if (invP[z] == -1) {
         P[cur] = z;
         invP[z] = cur;
         freq[cur]--;
         cur++;
         freq[cur]++;
         continue;
      }
      if (freq[invP[z]]) {
         freq[invP[z]]--;
         freq[invP[z]+1]++;
      }
   }
   for (int i = 0; i < M; ++i) if (invP[i] == -1) P[cur++] = i;
   cur = 0;
   while (freq[cur] == 0) cur++;
   if (is_sorted(P.begin()+cur, P.end())) {
      cout << "Yes\n";
   } else {
      cout << "No\n";
   }
   return 0;
}


Measured memory_bytes: 4800
s = list(input())
p = list(input())
#print(len(p))
import sys

for i in range(len(s)):
	t=0
	for j in range(len(p)):
		if p[j] == s[(i+j)%len(s)]:
			t = t+1
			#print(p[j], s[(i+j)%len(s)])
		else:
			t = 0
		if t == len(p):
			print('Yes')
			sys.exit()

if t < len(p):
	print('No')

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

using namespace std;

#define REP(i, a, b) for (int i = (a), i##_end_ = (b); i < i##_end_; ++i)
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define mp make_pair
#define x first
#define y second
#define pb push_back
#define SZ(x) (int((x).size()))
#define ALL(x) (x).begin(), (x).end()

template<typename T> inline bool chkmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }

typedef long long LL;

const int oo = 0x3f3f3f3f;

const int maxn = 100100;

int n, K;
int a[maxn + 5];

int d[maxn + 5];

inline int getd(int x)
{
	if (~d[x]) return d[x];
	return d[x] = getd(a[x]) + 1;
}

int main()
{
#ifdef matthew99
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	scanf("%d%d", &n, &K);
	REP(i, 0, n) scanf("%d", a + i), --a[i];
	int ret = 0;
	if (a[0]) ++ret, a[0] = 0;
	memset(d, -1, sizeof d);
	d[0] = 0;
	REP(i, 0, n) getd(i);
	static int pos[maxn + 5];
	REP(i, 0, n) pos[i] = i;
	sort(pos, pos + n, [&](int x, int y) { return d[x] > d[y]; });
	static bool vis[maxn + 5];
	memset(vis, 0, sizeof vis);
	REP(i, 0, n)
	{
		int u = pos[i];
		REP(j, 0, K - 1)
		{
			if (vis[u]) break;
			vis[u] = 1;
			u = a[u];
		}
		if (!vis[u] && a[u]) ++ret, a[u] = 0;
	}
	printf("%d\n", ret);
	return 0;
}


Measured memory_bytes: 3072
#include <iostream>
#include <map>
#include <vector>

int main() {
  std::string s;
  std::cin >> s;

  int n = s.size();

  // t[i] := s[i, n) mod 2019
  int pow = 1;
  std::vector<int> t(n + 1, 0);
  for (int i = n - 1; i >= 0; --i) {
    t[i] = (pow * (s[i] - '0') + t[i + 1]) % 2019;
    pow = (10 * pow) % 2019;
  }

  std::map<int, int> mp;
  for (int i = 0; i <= n; ++i)
    mp[t[i]] += 1;

  int res = 0;
  for (auto &kv : mp)
    res += kv.second * (kv.second - 1) / 2;

  std::cout << res << std::endl;
}


Measured memory_bytes: 4452
#include <bits/stdc++.h>
using namespace std;
int main () {
  string S;
  cin >> S;
  vector<long> data(2019);
  long base = 1, a = 0;
  data.at(a)++;
  for(int i = S.size() - 1; i >= 0; i--){
    a += (S.at(i) - '0') * base;
    a %= 2019;
    data.at(a)++;
    base *= 10;
    base %= 2019;
  }
  long ans = 0;
  for(int i = 0; i < 2019; i++){
    ans += data.at(i) * (data.at(i) - 1) / 2;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3744
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n,m;
    scanf("%d%d",&n,&m);
    int s[m], c[m];
    int ans[n];
    memset(ans,-1,sizeof(ans));
    for (int i = 0; i < m; i++){
        scanf("%d%d",&s[i],&c[i]);
        s[i]--;
        if (ans[s[i]] != -1 && ans[s[i]] != c[i]){
            printf("-1");
            return 0;
        }
        ans[s[i]] = c[i];
    }
    if (n == 1){
        if (ans[0] == -1) ans[0] = 0;
        printf("%d",ans[0]);
        return 0;
    }
    if (ans[0] == 0){
        printf("-1");
        return 0;
    }
    if (ans[0] == -1) ans[0] = 1;
    for (int i =0;  i < n; i++){
        if (ans[i] == -1) printf("0");
        else printf("%d",ans[i]);
    }

}


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

namespace ConsoleApp
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split().Select(s => int.Parse(s)).ToArray();
            var N = input[0];
            var Y = input[1] / 1000;

            for (int y = 0; y <= 8; y++)
            {
                var x = (Y - N - 4 * y) / 9;
                var z = (10 * N - Y - 5 * y) / 9;
                if (x >= 0 && z >= 0 && x + y + z == N && 10 * x + 5 * y + z == Y)
                {
                    Console.WriteLine(x + " " + y + " " + z);
                    return;
                }
            }

            Console.WriteLine("-1 -1 -1");
        }
    }
}


Measured memory_bytes: 13396
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		int i, n;
		try (Scanner sc = new Scanner(System.in)) {
			while(true) {
				double average = 0, alpha = 0;
				n = sc.nextInt();
				if(n == 0) {
					break;
				}
				int[] s = new int[n];
				for(i = 0; i < n; i++) {
					s[i] = sc.nextInt();
					average += s[i];
				}
				average /= n;
				for(i = 0; i < n; i++) {
					alpha += (s[i] - average) * (s[i] - average);
				}
				System.out.println(Math.sqrt(alpha / n));
			}
			
		}
	}
}



Measured memory_bytes: 31168
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		int[] dp = new int[n];
		int[] h = new int[n];
		final int INF = 1000000000;
		dp[0] = 0;

		for(int i = 0; i < n; i++) {
			h[i] = sc.nextInt();
			if(i > 0)dp[i] = INF;
		}

		for(int i = 1; i < n; i++) {
			for(int j = 1; j <= k; j++) {
				if(i - j < 0) continue;
				dp[i] = min(dp[i], dp[i - j] + Math.abs(h[i] - h[i - j]));
			}
		}

		System.out.println(dp[n - 1]);

		sc.close();
	}

	public static int min(int a, int b) {
		if(a > b) {
			return b;
		}else {
			return a;
		}
	}
}


Measured memory_bytes: 53332
#include<bits/stdc++.h>
#define ll long long
#define re register
#define ull unsigned ll
using namespace std;
inline int read(){
	int s=0,t=1;
	char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')t=-1;ch=getchar();}
	while(ch>='0'&&ch<='9')s=(s<<3)+(s<<1)+(ch^48),ch=getchar();
	return s*t;
}
int n;
ll Ans;
int main(){
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	n=read();
	Ans=1ll*n*(n+1)/2*n;
	for(int i=1;i<=n;i++)Ans-=1ll*(n-i)*(n-i+1);
	for(int i=1;i<n;i++){
		int x=read(),y=read();
		if(x>y)swap(x,y);
		Ans-=1ll*x*(n-y+1);
	}cout<<Ans;
	return 0;
}

Measured memory_bytes: 3628
//ABC171_A
#include <stdio.h>

int main(){
	char c[5];
	
	scanf("%c",c);
	
//	printf("%c",c[0]);

	
	if('A' >= c[0] || c[0] <= 'Z'){
		printf("A");
	}
	else printf("a");
	
	return 0;
}


Measured memory_bytes: 1592
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define FORD(i,a,b) for(int i=a;i>=b;i--)
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) int((a).size())
#define SORT(c) sort((c).begin(),(c).end())
#define MEMSET(v, h) memset((v), h, sizeof(v))
#define sqr(x) ((x) * (x))
#define bit(n) (1LL<<(n))
#define pcnt(x) __builtin_popcountll(x)
#define PB push_back
#define MP make_pair
#define endl "\n"
using Edge = pair<int,int>;
using Graph = vector<vector<Edge>>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
// ll lcm(ll a,ll b){return a/gcd(a,b)*b;}



int main() {
  int q; cin >> q;
  FOR(i,0,q-1){
    int dp[1010][1010];
    string a,b; cin >> a >> b;
    MEMSET(dp,0);
    FOR(j,1,a.length()){
      FOR(k,1,b.length()){
        if(a[j-1] == b[k-1]) dp[j][k] = dp[j-1][k-1] + 1;
        else dp[j][k] = max(dp[j-1][k],dp[j][k-1]);
      }
    }
    // FOR(i,1,a.length()){
    //   FOR(j,1,b.length()){
    //     cout << dp[i][j] << " ";
    //   }
    //   cout << "\n";
    // }
    cout << dp[a.length()][b.length()] << "\n";
  }
}



Measured memory_bytes: 7164
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n) for (int i = (n - 1); i >= 0; i--)
#define ALL(v) v.begin(), v.end()
using namespace std;
using P = pair<int, int>;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int main() {
    int n, k;
  cin >> n >> k;
  vector<vector<ll>> dp(n + 1, vector<ll>(5000, 0));
  dp[0][2450] = 1;
  vector<int> A(n);
  for (int i = 0; i < n; i++){
    cin >> A[i];
  }
  rep(i, n){
    dp[i + 1] = dp[i];
    for (int j = 0; j <= 4900; j++){
      int j2 = j + A[i] - k;
      if (0 <= j2 && j2 <= 4900){
        dp[i + 1][j2] += dp[i][j];
      }
    }
  }
  ll ans = 0;
  ans = dp[n][2450];
  cout << ans -1 << endl;
}

Measured memory_bytes: 5356
#include <stdio.h>

int main(){
	
	int alas;
	int tinggi;
	int area;
	
	scanf("%d",&alas);
	scanf("%d",&tinggi);
	scanf("%d",&area);
	area=tinggi*alas/2;
	printf("%d",area);	
		
	
	return 0;
}

Measured memory_bytes: 1696
#include <stdio.h>

int main (void) {

    int a, b, res;
    char op;

    for (;;) {

        scanf ("%d %c %d", &a, &op, &b);

        if (op == '+') res = a+b;
        else if (op == '-') res = a-b;
        else if (op == '*') res = a*b;
        else if (op == '/') res = a/b;
        else if (op == '?') break;

        printf ("%d\n", res);
    }

    return 0;

}


Measured memory_bytes: 2108
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <queue>
#include <vector>
#include <map>
#include <set>
using namespace std;
#define pb(x) push_back(x)
#define ll long long
#define mk(x, y) make_pair(x, y)
#define mem(a) memset(a, 0, sizeof(a))
#define lson l, m, rt<<1
#define rson m+1, r, rt<<1|1
#define mem1(a) memset(a, -1, sizeof(a))
#define mem2(a) memset(a, 0x3f, sizeof(a))
#define rep(i, a, n) for(int i = a; i<n; i++)
#define ull unsigned long long
typedef pair<int, int> pll;
const double PI = acos(-1.0);
const int inf = 1061109567;
const double eps = 1e-8;
const int mod = 1e9+7;
const int dir[][2] = { {-1, 0}, {1, 0}, {0, -1}, {0, 1} };
int a[1005], vis[100000];
int main()
{
    int n;
    cin>>n;
    for(int i = 0; i<n; i++) {
        scanf("%d", &a[i]);
        vis[a[i]] = 1;
    }
    for(int i = 0; i<n; i++) {
        int tmp = 0;
        for(int j = i, len = 0;len<5&&j<n; j++, len++) {
            tmp = tmp*10+a[j];
            vis[tmp] = 1;
        }
    }
    for(int i = 0; i<50000; i++) {
        if(!vis[i]) {
            cout<<i<<endl;
            break;
        }
    }
}

Measured memory_bytes: 1636
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define mins(x,y) x = min(x,y)
#define maxs(x,y) x = max(x,y)
using namespace std;

const double inf = 1e10;

struct D{
  vector<double>l,r;
  D():l(3,inf),r(3,-inf) {}
  void add(double x,int v){
    ++v;
    mins(l[v],x);
    maxs(r[v],x);
  }
  double get(double t){
    double nl = inf, nr = -inf;
    rep(i,3){
      mins(nl,l[i]+i*t);
      maxs(nr,r[i]+i*t);
    }
    return nr-nl;
  }
  vector <double> events(){
    vector<double>ts;
    rep(i,3)rep(j,i){
      {
        double t = (l[j]-l[i])/(i-j);
        if(t>0)ts.push_back(t);
      }
      {
        double t = (r[j]-r[i])/(i-j);
        if(t>0)ts.push_back(t);
      }
    }
    return ts;
  }
};

int main(){
  int n;
  cin >> n;
  D xd,yd;
  rep(i,n){
    int x,y;
    char d;
    cin >> x >> y >> d;
    if (d == 'L') xd.add(x,-1), yd.add(y,0);
    if (d == 'R') xd.add(x,1), yd.add(y,0);
    if (d == 'U') xd.add(x,0), yd.add(y,1);
    if (d == 'D') xd.add(x,0), yd.add(y,-1);
  }
  vector<double> ts;
  ts.push_back(0);
  // ts.push_back(inf);
  {
    auto nts =xd.events();
    ts.insert(ts.end(),nts.begin(),nts.end());
  }
  {
    auto nts = yd.events();
    ts.insert(ts.end(),nts.begin(),nts.end());
  }
  sort(ts.begin(),ts.end());
  double ans = 1e18;
  for(double t : ts){
    double now = xd.get(t)*yd.get(t);
    mins(ans,now);
  }
  printf("%.10f\n", ans);
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <climits>
#include <cmath>
#include <iomanip>
#include <math.h>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
//#define local
#ifdef local
    #include "dbg-macro/dbg.h"
#endif
//#define hacks
#ifdef hacks
    #include <boost/multiprecision/cpp_int.hpp>
#endif
#define p std::pair
#define ll long long
#define ld long double
#define ull unsigned long long
#define pi std::pair<int, int>
#define stdabs std::abs
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (unsigned long long i = 0; i < (unsigned long long)(n); ++i)
#define vec std::vector
#define oreq |=
#define npm next_permutation
using namespace std;
std::vector<unsigned ll> genprimevec(const unsigned ll N);
ll extgcd(ll a, ll b, ll& x, ll& y);
ll nCr(ll n, ll r);
void stat();
template <typename T> T fact(T num);
constexpr ll mod = 1000000000 + 7;

int main()
{
    stat();
    int n;
    cin >> n;
    vector<ll> a(n + 1), b(n);
    rep(i, n + 1) { cin >> a[i]; }
    rep(i, n) { cin >> b[i]; }
    ull ans = 0;
    rep(i, n)
    {
	    ans+=min(a[i],b[i]);
	    ans+=min(a[i+1],b[i]-min(a[i],b[i]));
a[i+1]-=  min(a[i+1],b[i]-min(a[i],b[i]));

    }
    cout<<ans<<endl;
    return 0;
}
ll extgcd(ll a, ll b, ll& x, ll& y)
{
    if (b == 0) {
        x = 1, y = 0;
        return a;
    }
    ll d = extgcd(b, a % b, y, x);
    y -= a / b * x;
    return d;
}


std::vector<unsigned ll> genprimevec(const unsigned ll N)
{
    std::vector<bool> is_prime(N + 1);
    for (unsigned ll i = 0; i <= N; i++) {
        is_prime[i] = true;
    }
    std::vector<unsigned ll> P;
    for (unsigned ll i = 2; i <= N; i++) {
        if (is_prime[i]) {
            for (unsigned ll j = 2 * i; j <= N; j += i) {
                is_prime[j] = false;
            }
            P.emplace_back(i);
        }
    }
    return P;
}

void stat(){
#ifdef local
    rep(i, 2){std::cout << "local enable" << std::endl;
}
#endif
#ifdef hacks
rep(i, 2) { std::cout << "boost enable" << std::endl; }
#endif
}

ll nCr(ll n, ll r)
{
    ll num = 1;
    for (ll i = 1; i <= r; i++) {
        num = num * (n - i + 1) / i;
    }
    return num;
}

template <typename T> T fact(T num)
{
    if (num == 1) { return 1; }
    return num * fact(num - 1);
}


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

typedef long long llong;
llong W, H;
int x, y;

int main(int argc, const char * argv[]) {
    cin >> W >> H >> x >> y;
    
    cout << fixed << setprecision(10);
    cout << (double(W) * double(H) / 2) << " " << (x + x == W && y + y == H) << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll= long long;
using vi= vector<int>;
using vvi= vector<vi>;
using vd= vector<double>;
using vvd= vector<vd>;
using vc= vector<char>;
using vb= vector<bool>;
using vl= vector<ll>;
using vs= vector<string>;
#define rep(i,x,n) for(int i=x; i<n; i++)
#define all(x) x.begin(), x.end()

int main(){
  int k;
  cin >> k;
  int a[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  cout << a[k-1];
  return 0;
}


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

#define FORE(i, a) for (auto i = a.begin(); i != a.end(); ++i)
#define REPU(i, a, b) for (int i = (a); i < (b); ++i)
#define REPD(i, a, b) for (int i = (a); i > (b); --i)
#define MEM(a, x) memset(a, x, sizeof(a))
#define ALL(a) a.begin(), a.end()
#define UNIQUE(a) a.erase(unique(ALL(a)), a.end())

vector<string> split(const string &s, char c) {
	vector<string> v; stringstream ss(s); string x;
	while (getline(ss, x, c)) v.push_back(x);
	return v;
}
#define DEBUG(args...) { vector<string> _v = split(#args, ','); err(_v.begin(), args); }
void err(vector<string>::iterator it) {}
template<typename T, typename... Args>
void err(vector<string>::iterator it, T a, Args... args) {
	cerr << "[DEBUG] " << it -> substr((*it)[0] == ' ', it -> length()) << " = " << a << '\n';
	err(++it, args...);
}

typedef long long ll;
const int MOD = 1000000007;

template<class T, class U> inline T tmin(T a, U b) { return (a < b) ? a : b; }
template<class T, class U> inline T tmax(T a, U b) { return (a > b) ? a : b; }
template<class T, class U> inline void amax(T &a, U b) { if (b > a) a = b; }
template<class T, class U> inline void amin(T &a, U b) { if (b < a) a = b; }
template<class T> T gcd(T a, T b) { while (b != 0) { T c = a; a = b; b = c % b; } return a; }

typedef pair<int, int> P;

int main(int argc, char *argv[]) {
	ios_base::sync_with_stdio(false);

	int n; cin >> n;
	vector<int> x(n), ans(n * n, -1);
	set<int> st;
	vector<int> rem;
	vector<P> pt;
	REPU(i, 0, n) {
		cin >> x[i];
		ans[x[i] - 1] = i + 1;
		st.insert(x[i]);
		pt.push_back(P(x[i], i));
		REPU(j, 0, n - i - 1) rem.push_back(i + 1);
	}
	sort(ALL(rem), [&x](const int v1, const int v2) {
		return x[v1 - 1] < x[v2 - 1];
	});
	int m = n * n;
	if (st.size() != n) {
		puts("No"); return 0;
	}
	else {
		sort(ALL(pt));
		int cur = 0;
		REPU(i, 0, n) {
			int up = pt[i].first, cnt = pt[i].second, id = cnt;
			if (cnt == 0) continue;
			while (cnt > 0 && cur < up) {
				if (ans[cur] > 0) cur++;
				else {
					ans[cur++] = id + 1;
					cnt--;
				}
			}
			if (cnt > 0) {
				puts("No"); return 0;
			}
		}
	}
	REPD(i, m - 1, -1) {
		if (ans[i] == -1) {
			ans[i] = rem.back();
			rem.pop_back();
		}
	}
	vector<vector<int>> g(n + 1);
	REPU(i, 0, m) {
		g[ans[i]].push_back(i + 1);
	}
	REPU(i, 1, n + 1) {
		if (g[i][i - 1] != x[i - 1]) {
			puts("No"); return 0;
		}
	}
	puts("Yes");
	REPU(i, 0, m) printf("%d%c", ans[i], " \n"[i == m - 1]);

	return 0;
}


Measured memory_bytes: 3704
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

// c++11
#include <array>
#include <tuple>
#include <unordered_map>
#include <unordered_set>

#define mp make_pair
#define mt make_tuple
#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;

using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;

const int INF = 1 << 29;
const ll LL_INF = 1LL << 60;
const double EPS = 1e-9;
const ll MOD = 1000000007;

const int dx[] = {1, 0, -1, 0}, dy[] = {0, -1, 0, 1};
double a, b;
int main()
{
    cin >> a >> b;
    double med = (a + b) / 2.0;
    cout << int(ceil(med)) << endl;
    return 0;
}


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

using namespace std;

int main() {
int n;
cin >> n;
double x[100],sum = 0;
string u[100];
for(int i = 0; i < n; ++i){
cin >> x[i] >> u[i];
if(u[i] == "BTC") x[i] = x[i]*380000;
sum += x[i];
}

cout << sum << endl;
return 0;

}


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

int main() {
    char ch;

    while (1) {
        scanf("%c", &ch);
        if (isalpha(ch)) {
            if (isupper(ch)) {
                printf("%c", tolower(ch));
            } else {
                printf("%c", toupper(ch));
            }
        } else {
            printf("%c", ch);
        }
         if (ch == '\n') break;
    }
    return 0;
}


Measured memory_bytes: 2604
use std::io::Write;

#[allow(unused)]
macro_rules! debug {
    ($($format:tt)*) => (write!(std::io::stderr(), $($format)*).unwrap());
}
#[allow(unused)]
macro_rules! debugln {
    ($($format:tt)*) => (writeln!(std::io::stderr(), $($format)*).unwrap());
}

fn main() {
    let n: usize = {
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).unwrap();
        let s = s.trim_right().to_owned();
        s.parse().unwrap()
    };

    let p: Vec<usize> = {
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).unwrap();
        let s = s.trim_right().to_owned();
        s.split_whitespace().map(|x| x.parse().unwrap()).collect()
    };

    let mut count = 0;
    let mut min = std::usize::MAX;
    for &a in p.iter() {
        if a < min {
            count += 1;
            min = a;
        }
    }

    println!("{}", count);
}


Measured memory_bytes: 12540
#![allow(non_snake_case, unused_imports)]

// Input
macro_rules! input { (source = $s:expr, $($r:tt)*) => { let mut iter = $s.split_whitespace(); let mut next = || { iter.next().unwrap() }; input_inner!{next, $($r)*} }; ($($r:tt)*) => { let stdin = std::io::stdin(); let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock())); let mut next = move || -> String{ bytes.by_ref().map(|r|r.unwrap() as char).skip_while(|c|c.is_whitespace()).take_while(|c|!c.is_whitespace()).collect() }; input_inner!{next, $($r)*} }; }
macro_rules! input_inner { ($next:expr) => {}; ($next:expr, ) => {}; ($next:expr, $var:ident : $t:tt $($r:tt)*) => { let $var = read_value!($next, $t); input_inner!{$next $($r)*} }; ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => { let mut $var = read_value!($next, $t); input_inner!{$next $($r)*} }; }
macro_rules! read_value { ($next:expr, ( $($t:tt),* )) => { ( $(read_value!($next, $t)),* ) }; ($next:expr, [ $t:tt ; $len:expr ]) => { (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>() }; ($next:expr, [ $t:tt ]) => { { let len = read_value!($next, usize); (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>() } }; ($next:expr, chars) => { read_value!($next, String).chars().collect::<Vec<char>>() }; ($next:expr, bytes) => { read_value!($next, String).into_bytes() }; ($next:expr, usize1) => { read_value!($next, usize) - 1 }; ($next:expr, $t:ty) => { $next().parse::<$t>().expect("Parse error") }; }

// Module
use std::cmp::{min,max};
use std::collections::{HashSet,HashMap,BTreeMap,VecDeque};

// Functions

// Main
fn main(){
    input!{
        S: String,
    }
    println!("{}", match S.as_str(){
        "Sunny" => "Cloudy",
        "Cloudy" => "Rainy",
        "Rainy" => "Sunny",
        _ => ""
    });
}


Measured memory_bytes: 4352
def calc(n):
    ok_list = []
    for i in range(1, 25):
        for j in range(1, 15):
            if (7*j+4*i) <= 100:
                ok_list.append(7 * j + 4 * i)

    if n % 11 == 0 or n % 4 == 0 or n % 7 == 0 or n in ok_list:
        ans = 'Yes'
    elif n < 4:
        ans = 'No'
    else:
        num7 = int(n / 7)
        num4 = int(n / 4)
        n_7 = n - num7 * 7 
        n_4 = n - num4 * 4 
        if n_7 % 4 == 0 or n_4 % 7 == 0:
            ans = 'Yes'
        else:
            ans = 'No'
    return ans 


if __name__ == '__main__':
  n = int(input())
  print(calc(n))

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <functional>
#include <bitset>
#include <cmath>
#include <stack>
#include <iomanip>
#include <map>
typedef long long ll;
using namespace std;

const int MOD = 1000000007;

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

int main()
{
    string n;
    cin >> n;
    if(n.at(n.size() - 1) == '3') cout << "bon" << endl;
    else if(n.at(n.size() - 1) == '0' || n.at(n.size() - 1) == '1' || n.at(n.size() - 1) == '6' || n.at(n.size() - 1) == '8' ) cout << "pon" << endl;
    else cout << "hon" << endl;
    return(0);
}

Measured memory_bytes: 3632
#include"bits/stdc++.h"

using namespace std;
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

#define FOR(k,m,n) for(ll (k)=(m);(k)<(n);(k)++)
#define REP(i,n) FOR((i),0,(n))
#define WAITING(str) int str;std::cin>>str;
#define DEBUGING(str) cout<< #str << " " str<<endl

constexpr int INF = (1 << 30);
constexpr ll INFL = (1ll << 60);
constexpr ll MOD = 1000000007;// 10^9+7
using ar3 = array<ll, 3>;

ll solve1(ll acorn, ll A, ll B) {
	ll res = acorn;
	ll gold = acorn / A;
	acorn -= gold * A;
	acorn += gold * B;

	return max(res, acorn);
}

ll solve2(ll acorn, vector<ll> A, vector<ll> B) {
	ll res = acorn;
	ll lim = acorn / A[0];
	REP(gold, lim + 1) {
		ll nacorn = acorn - A[0] * gold;
		ll silver = nacorn / A[1];
		nacorn -= A[1] * silver;
		nacorn += B[0] * gold + B[1] * silver;
		res = max(res, nacorn);
	}
	return res;
}

ll solve3(ll acorn, vector<ll> A, vector<ll> B) {
	ll res = acorn;
	ll lim = acorn / A[0];
	REP(gold, lim + 1) {
		ll acorn2 = acorn - A[0] * gold;
		ll lim2 = acorn2 / A[1];
		REP(silver, lim2 + 1) {
			ll acorn3 = acorn2 - A[1] * silver;
			ll bronze = acorn3 / A[2];
			acorn3 -= A[2] * bronze;
			acorn3 += B[0] * gold + B[1] * silver + B[2] * bronze;
			res = max(res, acorn3);
		}
	}
	return res;
}

ll solve(ll acorn, ar3 A, ar3 B) {
	vector<ll> na, nb;
	REP(i, 3)if (A[i] < B[i]) {
		na.push_back(A[i]);
		nb.push_back(B[i]);
	}
	switch (na.size()) {
	case 0: return acorn;
	case 1: return solve1(acorn, na[0], nb[0]);
	case 2: return solve2(acorn, na, nb);
	case 3: return solve3(acorn, na, nb);
	default: return 0;
	}
}


int main()
{
	ll N;
	ar3 A, B;
	cin >> N;
	REP(i, 3)cin >> A[i];
	REP(i, 3)cin >> B[i];

	N = solve(N, A, B);
	N = solve(N, B, A);
	cout << N << endl;
	return 0;
}


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

int main(){
  int n,x; cin >> n >> x; //n人K種類
  vector<int> count(n,1);
  for(int i=0; i<x; i++){
    int m; cin >> m;
    for(int j=0; j<m; j++){
      int k; cin >> k;
      count.at(k-1) = 0;
    }
  }
  int ans = 0;
  for(int i=0; i<n; i++)
    ans += count.at(i);
  cout << ans << endl;
}

Measured memory_bytes: 3628
n = int(input().strip())
s = input().strip()

arr = [
       ["A", 0],
       ["B", 1],
       ["C", 2],
       ["D", 3],
       ["E", 4],
       ["F", 5],
       ["G", 6],
       ["H", 7],
       ["I", 8],
       ["J", 9],
       ["K", 10],
       ["L", 11],
       ["M", 12],
       ["N", 13],
       ["O", 14],
       ["P", 15],
       ["Q", 16],
       ["R", 17],
       ["S", 18],
       ["T", 19],
       ["U", 20],
       ["V", 21],
       ["W", 22],
       ["X", 23],
       ["Y", 24],
       ["Z", 25]
       ]

ans = ""
for i in range(len(s)):
    idx = 0
    for j in range(len(arr)):
        if (s[i] == arr[j][0]):
            idx = arr[j][1]

    ans += arr[((idx + n) % 26)][0]
print(ans)


Measured memory_bytes: 41564
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
int main(){
    int n;
    cin >> n;
    map<ll,ll> hairetu;
    int ans=0;
    rep(i,n){
        int a;
        cin >> a;
        hairetu[a]++;
    }
    for(auto c:hairetu){
        int a,b;
        a = c.first; b=c.second;
        if(b<a) ans+=b;
        else ans += b-a;
    }
    cout << ans << endl;
}

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

#define pb push_back
#define ll long long
#define pi pair<int,int>
#define pii pair<int,pi>
#define pl pair<ll,ll>
#define pll pair<ll,pl>
#define debug cout<<"debugging"<<endl
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
int I_LIMIT = 999999999;
ll L_LIMIT = 99999999999999999;
ll mod = 1000000000;
vector <int> v[100005];

void solve()
{
    int x;
    cin>>x;

    if(x==0)
        cout<<"1\n";
    else
        cout<<"0\n";
    
}
int main()
{
    IOS;
    int t;
    //cin>>t;
    //for(int i=1;i<=t;i++)
        solve();
}


Measured memory_bytes: 5988
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int a,b,flag=0;
  cin >> a >> b;
  for(int i=1;i<1010;i++)
  {
    if((i*2)/25==a && i/10==b)
    {
      flag=1;
      cout << i;
      break;
    }
  }
  if(flag==0)
    cout<<"-1";
}

Measured memory_bytes: 3600
import collections
 
n = int(input())
st = [input() for i in range(n)]
 
c = collections.Counter(st)
c.most_common()
c_val, c_key= zip(*c.most_common()) 
c_key,c_val = list(c_val),list(map(int,c_key))
counter = 0
res = []
if len(c_val) == 1:
  print(c_key[0])
else:
  for i in range(len(c_val)):
    if c_val[i] >= counter:
      counter = c_val[i]
      res.append(c_key[i])
  res = list(set(res))
  res.sort()
  
  for i in range(len(res)):
    print(res[i])


Measured memory_bytes: 59632
//I wanna be the guy.
#include <bits/stdc++.h>
using namespace std;

int main(){
    int x,h,m,s,temp;
    cin>>x;
    temp=x%3600;
    h=(x-temp)/3600;
    s=temp%60;
    m=(temp-s)/60;
    cout<<h<<":"<<m<<":"<<s<<endl;
}

Measured memory_bytes: 3088
#include <stdio.h>
int n,i,res,A[2000];
int solve(int i,int m);
  
int main(){
    scanf("%d",&n);
    int q,m;
    for(i=0;i<n;i++){
      scanf("%d",&A[i]);
    }
    scanf("%d",&q);
    for(i=0;i<q;i++){
      scanf("%d",&m);
      if(1==solve(0,m))printf("yes\n");
      else printf("no\n");
    }
  return 0;
}

int solve(int i,int m){
  if (m==0)return 1;
  if (i>=n)return 0;
    res = solve(i+1,m)|| solve(i + 1, m - A[i]);
    return res;
  }



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

int main() {
    int ps[5];
    while (cin >> ps[0] >> ps[1] >> ps[2] >> ps[3] >> ps[4]) {
        int p_min = min(ps[0], min(ps[1], ps[2])) + min(ps[3], ps[4]) - 50;
        cout << p_min << endl;
    }
}

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

def II(): return int(input())
def MII(): return map(int, input().split())
def LII(): return list(map(int, input().split()))

def main():
    N, K = MII()
    p = LII()

    p.sort()

    print(sum(p[:K]))

if __name__ == '__main__':
    main()


Measured memory_bytes: 9068
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
using namespace std;
#define REP(i, j) for(int i = 0; i < (int)(j); ++i)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
const double EPS = 1e-8;
const double INF = 1e12;
#define EQ(a,b) (abs((a)-(b)) < EPS)
typedef complex<double> P;
const int L = 10;

int N, x[L], y[L], r[L];

struct C {
  P p; double r;
  C(){}
  C(const P &p, double r) : p(p), r(r) { }
};

void crosspointCC(const C &c1, const C &c2, vector<P> &ps){
  double d = abs(c1.p - c2.p);
  double rc = (d * d + c1.r * c1.r - c2.r * c2.r) / (2 * d);
  double dfr = c1.r * c1.r - rc * rc;
  if(EQ(dfr, 0.0)) dfr = 0.0;
  else if(dfr < 0.0) return ;
  double rs = sqrt(dfr);

  P diff = (c2.p - c1.p) / d;
  ps.push_back(c1.p + diff * P(rc, rs));
  ps.push_back(c1.p + diff * P(rc, -rs));
}

bool check(double h){
  C cs[L];
  REP(i, N){
    cs[i].p = P(x[i], y[i]);
    double rr = r[i] * r[i] - h * h;
    if(rr < 0) return false;
    cs[i].r = sqrt(rr);
  }
  vector<P> ps;
  REP(i, N) ps.push_back(cs[i].p);
  REP(i, N) FOR(j, i + 1, N) crosspointCC(cs[i], cs[j], ps);

  REP(i, ps.size()){
    bool f = true;
    REP(j, N) if(abs(cs[j].p - ps[i]) > cs[j].r + EPS) f = false;
    if(f) return true;
  }
  return false;
}

double solve(){
  double lb = 0, ub = 300;
  REP(i, 100){
    double m = (lb + ub) / 2.0;
    if(check(m)) lb = m;
    else ub = m;
  }
  return lb;
}

int main() {
  while(cin >>N && N){
    REP(i, N) cin >>x[i] >>y[i] >>r[i];
    printf("%.7lf\n", solve());
  }
  return 0;
}

Measured memory_bytes: 1256
a,b,c = map(int,input().split())

tmp = 0
sum = 0
ans = 0

for i in range(a+1):
  tmp = i
  sum = 0
  while tmp > 0:
    sum += tmp % 10
    tmp //= 10
  if b <= sum <= c:
#    print("i:" + str(i))
    ans += i
print(ans)

Measured memory_bytes: 3316
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define deb(x) cout << #x << " = "<< x << "\n";

signed main() {
	//freopen("in.txt", "r",stdin);
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	
	int n;
	cin >> n;
	double d;
	cin >> d;
	int ans = 0;
	for(int i = 0; i < n; i++) {
	    double x, y;
	    cin >> x >> y;
	    double dis = sqrt(x*x + y*y);
	    if(dis <= d) ans++;
	}
	cout << ans << "\n";
}


Measured memory_bytes: 3860
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
using namespace std;

ll inf=1ll<<60;

int main()
{
	//freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
	ios_base::sync_with_stdio(false); cin.tie(0);
	int n,i,a[100],b[8]={0},t=0,s=0;
	cin>>n;
	for (i=0;i<n;i++){
		cin>>a[i];
	}
	for (i=0;i<n;i++){
		if (a[i]<=399){b[0]++;}
		else if (a[i]<=799){b[1]++;}
		else if (a[i]<=1199){b[2]++;}
		else if (a[i]<=1599){b[3]++;}
		else if (a[i]<=1999){b[4]++;}
		else if (a[i]<=2399){b[5]++;}
		else if (a[i]<=2799){b[6]++;}
		else if (a[i]<=3199){b[7]++;}
		else {t++;}
	}
	for (i=0;i<8;i++){
		if (b[i]>0){
			s++;
		}
	}
	cout<<max(s,1)<<" "<<s+t;
	return 0;
}

Measured memory_bytes: 256
#define REP(i, n) for (int i = 0;i<(int)(n);i++)
#define REPI(i, a, n) for(int i=int(a);i<int(b);i++)
#define ALL(x) (x).begin(), (x).end()
#define SIZE(x) ((int)(x).size())

typedef long long ll;

#include <bits/stdc++.h>

using namespace std;


int main(){
    std::cin.tie(0);

    int a,b;
    cin >> a >> b;

    if(a<=8 && b <=8)cout << "Yay!";
    else cout << ":(";
    cout <<endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        String S = sc.next();
        String T = sc.next();

        //String lastChar = Character.toString(T.charAt(S.length()));

        String Tmatch=T.substring(0, S.length());

        //String str = T.substring(S.length());
        //System.out.println(str);
        if (Tmatch.equals(S) ){//&& str.equals(lastChar)) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
        sc.close();
    }
}

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

using namespace std;

int main(){
    int a, b;
    int ans = 0;
    cin >> a >> b;

    for (int i = 0 ; i < 2 ;i++){
        if(a > b){
            ans += a;
            a--;
        }
        else {
            ans += b;
            b--;
        }
    }
    cout << ans << endl;
    return 0;
}

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

const int N = (int)1e5;

class UFDS {
    int n;
    int par[N+5];
    //
    int findPar(int a) {
        return par[a] = (par[a] == a ? a : findPar(par[a]));
    }
public:
    int reset(int _n){
        for (int i=0; i<_n+3; i++) {
            par[i] = i;
        }
        return n = _n;
    }
    int unionDS(int a, int b) {
        a = findPar(a);
        b = findPar(b);
        return par[a] = b;
    }
    int solve() {
        int res = 0;

        for (int i=1; i<=n; i++) {
            res += (par[i] == i);
        }

        return res;
    }
};

UFDS ds;

int main() {
    int n,m; scanf("%d %d", &n, &m);

    ds.reset(n);

    for (int i=1; i<=m; i++) {
        int x,y,z; scanf("%d %d %d", &x, &y, &z);

        ds.unionDS(x,y);
    }

    printf("%d\n", ds.solve());

    return 0;
}


Measured memory_bytes: 640
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int Q;
	cin >> Q;
	ll bsum = 0, asum = 0, aminsum = 0;
	priority_queue<ll, vector<ll>, greater<ll>> maxque;
	priority_queue<ll> minque;
	maxque.push(2e9);
	ll sz = 0;
	rep(q,Q){
		int k;
		cin >> k;
		if(k == 2){
			while(minque.top() > maxque.top()){
				ll a = minque.top();
				ll b = maxque.top();
				minque.pop();
				maxque.pop();
				minque.push(b);
				maxque.push(a);
				aminsum += b - a;
			}
			ll x = minque.top();
			cout << x << " ";
			cout << (sz / 2) * (-x) + (asum - aminsum) + ((sz + 1) / 2) * x - aminsum + bsum << endl;
			continue;
		}
		ll a, b;
		cin >> a >> b;
		bsum += b;
		asum += a;
		++sz;
		if(sz%2 == 1){
			minque.push(a);
			aminsum += a;
		}
		else{
			maxque.push(a);
		}
	}
	return 0;
}

Measured memory_bytes: 5024
import Data.List

sums::Int->[Int]->[Int]
sums i [] = [i]
sums i (x:xs) = i:(sums (i+x) xs)

proc::Int->[Int]->Integer
proc m ls = let c =  map (\ v -> mod v m) (sums 0 ls) in
            let nums = ((map (\l -> length l)).group.sort) c in
            sum (map ((\i-> div (i*(i-1)) 2).toInteger) nums)

main::IO()
main=do
  c<-getLine
  let n:m:[]=map read (words c)
  d<-getLine
  let dat = map read (words d)
  print (proc m dat) 

Measured memory_bytes: 38268
N=int(input())
li = list(map(int, input().split()))
c=0
ali=[]
for i in range(0,N):
  for j in range(0,N):
    for k in range(0,N):
      if li[i]+li[j]>li[k] and li[j]+li[k]>li[i] and li[k]+li[i]>li[j]:
        if li[i]!=li[j] and li[j]!=li[k] and li[k]!=li[i]:
          if i!=j and j!=k and k!=i and i<j and j<k:
            ali.append(sorted([i,j,k]))
print(len(ali))

Measured memory_bytes: 28012
#include<stdio.h>
int main()
{
    long long a,b,k;
    scanf("%lld %lld %lld",&a,&b,&k);
    if(a<=k)
    {
    	long long s=b-(k-a);
    	if(s<0)
    	{
    		s=0;
    	}
    	printf("0 %lld\n",s);
    }
    else
    {
    	printf("%lld %lld\n",a-k,b);
    }	 
    return 0;   	
}


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

int main(){
  ll n,d,a;
  cin>>n>>d>>a;
  P xh[200005];
  rep(i,n) cin>>xh[i].first>>xh[i].second;
  sort(xh,xh+n);
  ll x[200005],h[200005];
  rep(i,n){
    x[i]=xh[i].first;
    h[i]=xh[i].second;
  }
  vector<ll> sum(n+1,0);
  ll att_cnt=0;
  rep(i,n){
    if(i>0) sum[i]+=sum[i-1];
    h[i]-=sum[i];
    if(h[i]>0){
      ll att=(h[i]+a-1)/a*a;
      sum[i]+=att;
      att_cnt+=(h[i]+a-1)/a;
      sum[upper_bound(x,x+n,x[i]+2*d)-x]-=att;
    }
  }
  cout<<att_cnt<<endl;
  return 0;
}

Measured memory_bytes: 8064
#include<stdio.h>
#define N 100000


int partition(int *A,int c,int d){
  int x,y,i,j;
  x=A[d];
  i=c-1;
  for(j=c;j<d;j++){
    if(A[j]<=x){
      i++;
      y=A[i];
      A[i]=A[j];
      A[j]=y;
    }
  }
  y=A[i+1];
  A[i+1]=A[d];
  A[d]=y;
  return i+1;
}


int main(){
  int A[N+1],b,n,i;
  scanf("%d",&n);
  for(i=1;i<=n;i++){
    
    scanf("%d",&A[i]);
  }
  b=partition(A,1,n);
  for(i=1;i<b;i++){
    
    printf("%d ",A[i]);
    
  }
  
  printf("[%d] ",A[b]);
  
  for(i=b+1;i<n;i++){
    
    printf("%d ",A[i]);
    
  }
  printf("%d\n",A[n]);
  return 0;
}



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

int main() {
	int n; scanf("%d", &n);
	int cnt = 0;
	rep(i, n) {
		string s; cin >> s;
		if (s == "A")cnt++;
		else cnt--;
		if (cnt < 0)break;
	}
	puts(cnt ? "NO" : "YES");
}

Measured memory_bytes: 3228
#include<bits/stdc++.h>
using namespace std;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int R, G, B, N;
  cin >> R >> G >> B >> N;
  int ans = 0;
  for(int r = 0; r <= N; r++){
    for(int g = 0; g <= N; g++){
      int rest = N - R*r - G*g;
      if(rest > 0){
        if(rest%B == 0) ans++;
      }
      else if(rest == 0){
        ans++;
      }
    }
  }
  cout << ans << endl;
  return 0;
}

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

template<class T> inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

template<class T> inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;

int n, m;
ll a[100010];
ll dp[100010];

int main() {
  cin >> n >> m;
  rep(i, m) cin >> a[i];
  vector<int> x(n + 1, false);
  rep(i, m) x[a[i]] = true;
  rep(i, 100010) dp[i] = 0;
  dp[0] = 1;
  for (int i = 1; i <= n; i++) {
    if (x[i]) continue;
    dp[i] += dp[i - 1];
    if (i >= 2) dp[i] += dp[i - 2];
    dp[i] %= MOD;
  }
  cout << dp[n] << endl;
  return 0;
}


Measured memory_bytes: 5028
import math
from math import gcd,pi,sqrt
INF = float("inf")

import sys
sys.setrecursionlimit(10**6)
import itertools
from collections import Counter,deque
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_str(N): return [s_list() for _ in range(N)]
def s_row_list(N): return [list(s_input()) for _ in range(N)]

def main():
    n = i_input()
    l = []
    cnt = 0
    while True:
        if cnt%2 == 0:
            l.append(n%2)
            n = -(n//2)
            cnt += 1
        else:
            l.append(n%2)
            n = -(n//2)
            cnt += 1
        if n == 0:
            break
        # break
    l.reverse()
    print("".join(map(str,l)))


if __name__=="__main__":
    main()


Measured memory_bytes: 9472