akhauriyash/Code-Regression huggingface dataset:
X,Y,A,B,C = map(int,input().split())
P = list(map(int,input().split()))
Q = list(map(int,input().split()))
R = list(map(int,input().split()))

P = sorted(P,reverse=True)
Q = sorted(Q,reverse=True)
R = sorted(R,reverse=True)
P = P[:X]
Q = Q[:Y]
P.append(-100)
Q.append(-100)
R.append(-100)

ans = sum(P)+sum(Q)

p=0
q=0
r=0

x = 0
y = 0

ans = 0
while(x<=X or y<=Y):
    mm = max(P[p],Q[q],R[r])
    if R[r] == mm:
        ans += R[r]
        r+=1
    elif P[p]==mm:
        ans += P[p]
        p+=1
        x+=1
    elif Q[q]==mm:
        ans += Q[q]
        q+=1
        y+=1
    if (x+y+r)==(X+Y):
        break
    # print(p,q,r)

print(ans)

Measured memory_bytes: 23216
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n,k;
    cin>>n>>k;
    int ans=n;
    map<int,int> m;
    while(k--)
    {
        int num;
        cin>>num;
        while(num--)
        {
            int num2;
            cin>>num2;
            if(m[num2]==0)
                ans--;
            m[num2]=1;
        }
    }
    cout<<ans;





}


Measured memory_bytes: 3656
using System;
using System.Collections.Generic;

namespace DPL4_B
{
    class Program
    {
        static void Main(string[] args)
        {
            int N, K;
            long L, R;
            var t = scan;
            N = (int)t[0]; K = (int)t[1]; L = t[2]; R = t[3];
            var a = scan;

            var n = N / 2;
            var G = new List<long>[n + 1];
            for (int i = 0; i <= n; i++)
            {
                G[i] = new List<long>();
            }

            for (int i = 0; i < 1 << n; i++)
            {
                int k = 0; long p = 0;
                for (int j = 0; j < n; j++)
                {
                    if ((i >> j & 1) == 1)
                    {
                        k++;
                        p += a[j];
                    }
                }
                G[k].Add(p);
            }
            var H = new long[n + 1][];

            for (int i = 0; i <= n; i++)
            {
                H[i] = G[i].ToArray();
                Array.Sort(H[i]);
            }

            long ans = 0;
            for (int i = 0; i < 1 << (N - n); i++)
            {
                int k = 0; long p = 0;
                for (int j = 0; j < N - n; j++)
                {
                    if ((i >> j & 1) == 1)
                    {
                        k++;
                        p += a[n + j];
                    }
                }
                if (k <= K && K - k <= n)
                {
                    ans += UpperBound(H[K - k], R - p) - LowerBound(H[K - k], L - p);
                }

            }

            Console.WriteLine(ans);
        }

        static int LowerBound(long[] arr, long val)
        {
            int low = 0, high = arr.Length;
            int mid;

            while (low < high)
            {
                mid = ((high - low) >> 1) + low;
                if (arr[mid] < val) low = mid + 1;
                else high = mid;
            }
            return low;
        }


        static int UpperBound(long[] arr, long val)
        {
            int low = 0, high = arr.Length;
            int mid;

            while (low < high)
            {
                mid = ((high - low) >> 1) + low;
                if (arr[mid] <= val) low = mid + 1;
                else high = mid;
            }
            return low;
        }

        static long[] scan { get { return Array.ConvertAll(Console.ReadLine().Split(), long.Parse); } }
    }
}

Measured memory_bytes: 31196
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)) {
			int w = sc.nextInt();
			if (w <= 0 || w > 100) {
				System.exit(0);
				;
			}
			int h = sc.nextInt();
			if (h <= 0 || h > 100) {
				System.exit(0);
				;
			}
			int x = sc.nextInt();
			if (x < -100 || x > 100) {
				System.exit(0);
				;
			}

			int y = sc.nextInt();
			if (y < -100 || y > 100) {
				System.exit(0);
				;
			}
			int r = sc.nextInt();
			if (r <= 0 || r > 100) {
				System.exit(0);
				;
			}

			if (x - r < 0 || x + r > w) {
				System.out.println("No");
			} else if (y - r < 0 || y + r > h) {
				System.out.println("No");
			} else {
				System.out.println("Yes");
			}
		}
	}
}

Measured memory_bytes: 26216
N, Y = map(int, input().split())

ans = "-1 -1 -1"
for man in range(Y // 10000 + 1):
    for gosen in range(Y // 5000 + 1):
        hoge = Y - man * 10000 - gosen * 5000
        if hoge >= 0 and hoge % 1000 == 0:
            sen = hoge // 1000
            if man + gosen + sen == N:
                ans = " ".join(map(str, [man, gosen, sen]))
                break

print(ans)


Measured memory_bytes: 40684
#define _USE_MATH_DEFINES

#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <utility>
#include <climits>
#include <vector>
#include <map>
#include <queue>
using namespace std;

#define ll long long
const int MOD = 1000000007;//10^9+7
const string SPACE = " ";

ll max(ll a, ll b) {

	if (a > b)return a;
	else return b;

}
double max(double a, double b) {

	if (a > b)return a;
	else return b;

}
//aとbの大きい方

ll min(ll a, ll b) {

	if (a < b)return a;
	else return b;

}
//aとbの小さい方

ll avd_i(ll a, ll b) {

	if (a > b)return a - b;
	else return b - a;

}
double avd_d(double a, double b) {

	double re;
	if (a > b)re = a - b;
	else re = b - a;
	return re;

}
//aとbの差の絶対値

ll powsur(ll a, ll b, ll p) {

	if (b == 0) {

		return 1;

	}
	else if (b % 2 == 0) {

		ll d = powsur(a, b / 2, p);
		return ((d%p)*(d%p)) % p;

	}
	else {

		return ((a%p)*powsur(a, b - 1, p) % p) % p;

	}

}
//pは素数,aのb乗をpで割った余り

ll CMOD(ll n, ll r, ll p) {

	ll a = 1, b = 1, c = 1, re;
	for (int i = 1; i <= n; i++) {

		a *= i;
		a = a%p;

	}
	for (int i = 1; i <= r; i++) {

		b *= i;
		b = b%p;

	}
	for (int i = 1; i <= n - r; i++) {

		c *= i;
		c = c%p;

	}
	b = powsur(b, p - 2, p);
	c = powsur(c, p - 2, p);
	re = ((a%p)*(b%p)) % p;
	re = ((re%p)*c%p) % p;

	return re;

}
//pは素数,(nCr)%p

ll gcd(ll a, ll b) {

	if (a > b) {

		ll tmp = a;
		a = b;
		b = tmp;

	}
	ll r;
	r = b%a;
	if (r == 0)return a;
	else return gcd(r, a);

}
//最大公約数

ll lcm(ll a, ll b) {

	return (a / gcd(a, b))*b;

}
//最小公倍数

int main() {

	int N;
	char c[105];
	bool f = false;
	cin >> N;
	for (int i = 0; i < N; i++) {

		cin >> c[i];
		if (c[i] == 'Y')f = true;

	}
	if (f)cout << "Four" << endl;
	else cout << "Three" << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#define rep(i, n) for(i = 0; i < n; i++)
#define int long long
using namespace std;
typedef pair<int, int> P;

struct BIT {
	int n;
	int v[100001];
	void init(int n) { this->n = n; int i; rep(i, n + 1) v[i] = 0; }
	void add(int pos, int x) { for (int p = pos; p <= n; p += p & -p) v[p] += x; }
	int sum(int pos) { int ret = 0; for (int p = pos; p > 0; p -= p & -p) ret += v[p]; return ret; }	//a[1] + … + a[pos]
	int ssum(int l, int r) { return sum(r) - sum(l - 1); }	//a[l] + … + a[r] (1-indexed)
};

int n;
int a[100000];
vector<P> pa;
BIT flag;

signed main() {
	int i;
	
	cin >> n;
	rep(i, n) cin >> a[i];
	rep(i, n) pa.push_back(P(a[i], i));
	sort(pa.begin(), pa.end());
	
	flag.init(n);
	rep(i, n) flag.add(i + 1, 1);
	
	int ans = 0;
	int j = 0;
	rep(i, n) {
		int val = pa[i].first;
		int pos = pa[i].second;
		
		for (; j < n && pa[j].first <= val; j++) {
			int del_pos = pa[j].second;
			flag.add(del_pos + 1, -1);
		}
		
		int left = flag.sum(pos);
		int right = flag.ssum(pos + 2, n);
		
		ans += min(left, right);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 6180
import java.util.Scanner;

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

    int A = scanner.nextInt();
    int B = scanner.nextInt();
    int Q = scanner.nextInt();
    long[] a = new long[A];
    long[] b = new long[B];
    long[] q = new long[Q];
    long[] r = new long[Q];
    for (int i = 0; i < A; i++) a[i] = scanner.nextLong();
    for (int i = 0; i < B; i++) b[i] = scanner.nextLong();
    for (int i = 0; i < Q; i++) q[i] = scanner.nextLong();

    int[] na = new int[2];
    int[] nb = new int[2];
    for (int i = 0; i < Q; i++) {
      long x = q[i];
      na[0] = lowerBound(a, x);
      na[1] = na[0] - 1;
      if (na[0] == A) na[0]--;
      if (na[1] < 0) na[1]++;
      nb[0] = lowerBound(b, x);
      nb[1] = nb[0] - 1;
      if (nb[0] == B) nb[0]--;
      if (nb[1] < 0) nb[1]++;

      long min = Long.MAX_VALUE;
      for (int j : na) {
        for (int k : nb) {
          long dist;
          long left = Math.min(a[j], b[k]);
          long right = Math.max(a[j], b[k]);
          if (x <= left) {
            dist = right - x;
          } else if (x >= right) {
            dist = x - left;
          } else {
            dist = Math.min(x - left, right - x) + right - left;
          }
          min = Math.min(min, dist);
        }
      }
      r[i] = min;
    }

    StringBuilder sb = new StringBuilder();
    for (int i = 0; i < Q; i++) sb.append(r[i]).append('\n');
    System.out.println(sb.toString());
  }

  private static int lowerBound(long[] a, long k) {
    int left = -1;
    int right = a.length;
    while (right - left > 1) {
      int mid = (left + right) / 2;
      if (k <= a[mid]) {
        right = mid;
      } else {
        left = mid;
      }
    }
    return right;
  }
}


Measured memory_bytes: 96236
#include<bits/stdc++.h>
using namespace std;
#define int long long
struct P{
  int r,i;
  P(){}
  P(int r,int i):r(r),i(i){}
  P operator+(P p){return P(r+p.r,i+p.i);}
  P operator-(P p){return P(r-p.r,i-p.i);}
  P operator*(P p){return P(r*p.r-i*p.i,r*p.i+i*p.r);}
};

P expr(string s,int& p);
P factor(string s,int& p);
P term(string s,int& p);
P number(string s,int& p);

bool ov;

void check(P p){
  ov|=abs(p.r)>10000;
  ov|=abs(p.i)>10000;
}

P expr(string s,int& p){
  //cout<<"e "<<p<<endl;
  P res=factor(s,p);
  check(res);
  while(p<(int)s.size()){
    //cout<<res.r<<" "<<res.i<<endl;
    check(res);
    if(s[p]=='+'){
      p++;
      P tmp=factor(s,p);
      check(tmp);
      res=res+tmp;
      continue;
    }
    if(s[p]=='-'){
      p++;
      P tmp=factor(s,p);
      check(tmp);
      res=res-tmp;
      continue;
    }
    break;
  }
  check(res);
  return res;
}
P factor(string s,int& p){
  //cout<<"f "<<p<<endl;
  P res=term(s,p);
  check(res);
  while(p<(int)s.size()){
    check(res);
    if(s[p]=='*'){
      p++;
      P tmp=term(s,p);
      check(tmp);
      res=res*tmp;
      continue;
    }
    break;
  }
  check(res);
  return res;
}
P term(string s,int& p){
  //cout<<"t "<<p<<endl;
  P res;
  if(s[p]=='('){
    p++;
    res=expr(s,p);
    assert(s[p]==')');
    p++;
  }else res=number(s,p);
  check(res);
  return res;
}
P number(string s,int& p){
  if(s[p]=='i'){
    p++;
    return P(0,1);
  }
  int res=0;
  while(p<(int)s.size()&&isdigit(s[p])){
    res=res*10+(s[p++]-'0');
    check(P(res,0));
  }
  return P(res,0);
}

signed main(){
  string s;
  while(getline(cin,s)){
    ov=0;
    int p=0;
    P ans=expr(s,p);
    assert(p==(int)s.size());
    
    
    if(ov){
      cout<<"overflow"<<endl;
      continue;
    }

    if(ans.r==0&&ans.i==0){
      cout<<0<<endl;
      continue;
    }
    
    if(ans.r!=0) cout<<ans.r;
    if(ans.r!=0&&ans.i>0) cout<<"+";
    if(ans.i!=0) cout<<ans.i<<"i";
    cout<<endl;
  }
  return 0;
}

Measured memory_bytes: 3156
#include <string>
#include <vector>
#include <iostream>
using namespace std;
int main() {
	int N;
	cin >> N;
	vector<int> c(5);
	for (int i = 0; i < N; ++i) {
		string s;
		cin >> s;
		if (string("MARCH").find(s[0]) != string::npos) {
			++c[string("MARCH").find(s[0])];
		}
	}
	long long ans = 0;
	for (int i = 0; i < 5; ++i) {
		for (int j = 0; j < i; ++j) {
			for (int k = 0; k < j; ++k) {
				ans += 1LL * c[i] * c[j] * c[k];
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
mazui_med, umai_med, umai_doku = map(int, input().split())

N_med = mazui_med + umai_med

if (N_med >= umai_doku):
    ans = umai_med + umai_doku
else:
    ans = umai_med + (mazui_med + umai_med + 1)


print(ans)

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

int main(){
  string j,k;
  cin >> j >> k;
  sort(j.begin(),j.end());
  sort(k.begin(),k.end());
  reverse(k.begin(),k.end());
  if(j<k)cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i,n){
    cin >> a.at(i);
  }
  int sum = 0;
  rep(i,n){
    rep(j,n){
      sum += a.at(i) * a.at(j);
    }
    sum -= a.at(i) * a.at(i);
  }
  cout << sum/2 << endl;
  }


Measured memory_bytes: 256
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = int(a); i < int(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
const long long INFLL = 1LL << 60;
const int INFINT = 1 << 30;
const long long MOD = 1e9 + 7;

template <class T> void vecout(T V) {
    auto t = V.begin();
    while(t != V.end()) {
        cout << *t++;
        if(t != V.end()) cout << " ";
    }
    cout << endl;
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m, d;
    cin >> n >> m >> d;
    vector<vector<char>> M(n, vector<char>(m));
    vector<int> sp;
    rep(i, n) rep(j, m) cin >> M[i][j];
    rep(i, n) {
        int c = 0;
        rep(j, m) {
            if(M[i][j] == '.') {
                c++;
            } else {
                if(c >= d) sp.push_back(c);
                c = 0;
            }
        }
        if(c >= d) sp.push_back(c);
    }

    rep(j, m) {
        int c = 0;
        rep(i, n) {
            if(M[i][j] == '.') {
                c++;
            } else {
                if(c >= d) sp.push_back(c);
                c = 0;
            }
        }
        if(c >= d) sp.push_back(c);
    }

    int t = 0;
    for(auto e : sp)
        t += e - d + 1;
    cout << t << endl;
}


Measured memory_bytes: 3176
h, w = map(int, input().split())
a = [list(input()) for _ in range(h)]

tmp1 = [i for i in a if set(i) != {"."}]
tmp2 = [list(i) for i in zip(*tmp1)]
tmp3 = [i for i in tmp2 if set(i) != {"."}]
ans = [list(i) for i in zip(*tmp3)]
for i in ans:
    print("".join(i))

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

deque< char > dq;

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

    int len = s.size();
    for(int i = 0; i < len; i++) {
        if(s[i] == '0') dq.push_back('0');
        else if(s[i] == '1') dq.push_back('1');
        else {
            if(!dq.empty()) dq.pop_back();
        }
    }

    while(!dq.empty()) {
        printf("%c", dq.front());
        dq.pop_front();
    }
    return 0;
}


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

int N;
int X;
vector<int> m;

int main(){
    cin >> N >> X;
    m.resize(N);
    rep(i,0,N - 1) cin >> m[i];
    rep(i,0,N - 1) X -= m[i];
    int ans = N;
    ans += X / *min_element(m.begin(),m.end());

    cout << ans << endl;

}


Measured memory_bytes: 256
//   _/                _/                 _/_/_/   _/
//_/_/_/_/   _/_/   _/_/_/_/   _/_/    _/       _/_/
// _/     _/    _/   _/     _/    _/  _/_/_/     _/
//_/     _/    _/   _/     _/    _/  _/    _/   _/
// _/_/   _/_/       _/_/   _/_/      _/_/     _/
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<queue>
#include<vector>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const int inf=1e9;
const ll INF=1e18;
const double pi=3.1415926535897932384626433832;
ll n,m,c,d,ans[100005]={},cnt[100005]={},par[100005]={},a[100005]={},b[100005]={};
int find(int x) {
  if(par[x]==x) {
    return x;
  }
  return par[x]=find(par[x]);
}
bool same(int x,int y) {
  return find(x)==find(y);
}
void unit(int x,int y) {
  x=find(x);
  y=find(y);
  if(x!=y) {
    par[x]=y;
  }
}
int main() {
  cin.tie(0),cout.tie(0);
  ios::sync_with_stdio(false);
  cin >> n >> m;
  ans[m-1]=n*(n-1)/2;
  for(int i=0; i<n; i++) {
    cnt[i]=1;
  }
  for(int i=0; i<n; i++) {
    par[i]=i;
  }
  for(int i=0; i<m; i++) {
    cin >> a[i] >> b[i];
    a[i]--,b[i]--;
  }
  for(int i=m-2; i>=0; i--) {
    c=find(a[i+1]),d=find(b[i+1]);
    if(same(c,d)) {
      ans[i]=ans[i+1];
    }
    else {
      ans[i]=ans[i+1]-cnt[c]*cnt[d];
      unit(c,d);
      cnt[d]+=cnt[c];
    }
  }
  for(int i=0; i<m; i++) {
    cout << ans[i] << endl;
  }
}

Measured memory_bytes: 5248
#include <iostream>

using namespace std;

int main()
{
   string arr[7];
   arr[0]="SAT";
   arr[1]="SUN";
   arr[2]="MON";
   arr[3]="TUE";
   arr[4]="WED";
   arr[5]="THU";
   arr[6]="FRI";
   string s;
   cin>>s;
   for(int i=0;i<7;i++)
   {
       if (s=="SAT")
       {cout<<1;
       return 0;}
       if(s==arr[i])
        cout<<abs(7-i)+1;

   }
    return 0;
}


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

typedef long long ll;

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

    int x,a,b;
    cin >> x >> a >> b;
    if(a>=b) cout << "delicious" << endl;
    else if(b-a<=x) cout << "safe" << endl;
    else cout << "dangerous" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <iomanip>
#include <string>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <utility>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>

using namespace std;

const int MAXN = 1000100;
const int MOD7 = 1000000007ll;
const int MOD9 = 1000000009ll;
const int INF = 2000000000;
const double EPS = 1e-9;
const double PI = 3.14159265358979;
const int dir_4r[] = { -1, 1, 0, 0 };
const int dir_4c[] = { 0, 0, -1, 1 };
const int dir_8r[] = { -1, -1, -1, 0, 0, 1, 1, 1 };
const int dir_8c[] = { -1, 0, 1, -1, 1, -1, 0, 1 };

int main()
{
	int n;
	scanf("%d", &n);
	bool flag = false;
	while (n)
	{
		int dig = n % 10;
		if (dig == 9)
		{
			flag = true;
			break;
		}
		n /= 10;
	}
	if (flag)
		printf("Yes\n");
	else
		printf("No\n");

	//system("pause");
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cmath>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>
#include <random>
#include <algorithm>
#include <functional>

using namespace std;
typedef long long ll;

const int INF = (1 << 30) - 1;
const ll INFLL= (1LL << 61) - 1;
const int MOD = 1000000007;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

int main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  ll N;
  cin>>N;
  cout<<N*(N-1)/2<<endl;
}


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

int main(){
    char n[5];
    int max=0,tmp=1;

    cin >> n;

    for(int i = 0; i < 4; i++){
        if(n[i] == n[i+1]){
            tmp++;
        }else{
            if(max < tmp){
                max = tmp;
            }
            tmp = 1;
        }
    }
    if(max < 3){
        cout << "No" << endl;
    }else{
        cout << "Yes" << endl;
    }
}

Measured memory_bytes: 256
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctype.h>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>

using namespace std;

#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i, n) REP(i, 0, n)
#define lengthof(x) (sizeof(x) / sizeof(*(x)))
#define FILL(ptr, value) FILL_((ptr), sizeof(ptr)/sizeof(value), (value))
template <typename T>
void FILL_(void * ptr, size_t size, T value){
  std::fill((T*)ptr, (T*)ptr+size, value);
}
//4方向ベクトル→↑←↓
int dx[] ={1,0,-1,0};
int dy[] ={0,-1,0,1};
unsigned long long N;
int main()
{
  
  while(cin>>N,N){
    long long int sum = 0;
    for(int i = N;i >0;i--){
      int k;
      if(i%5){
	continue;
      }else{
	k = i;
	while(k%5==0){
	  sum++;
	  k = k/5;
	}
      }
    }
    cout<<sum<<endl;
  }
  return 0;
}

Measured memory_bytes: 1152
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <iomanip>
#include <algorithm>
#include <sstream>
#include <string>
#include <math.h>
using namespace std;

int main() {
	ios::sync_with_stdio(false);
	string w,w1;
	int x=1,y=0,z=1;
	cin >> w;
	int w2[w.length()]={};
	for (int i=0;i<w.length();i++) {
		z=1;
		for (int j=0;j<w1.length();j++) {
			if (w1[j]==w[i]) {
				w2[j]+=1;
				z=0;
				break;
			}
		}
		if (z){
			w1+=w[i];
			w2[y]+=1;
			y+=1;
		} 
	}
	for (int i=0;i<w.length();i++) {
		if (w2[i]%2==1) {
			cout << "No";
			x=0;
			break;
		}
	}
	if (x) cout << "Yes";
}

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

#define ll long long
#define For(i,a,b) for(int (i)=(a);(i) < (b); ++(i))

const int N =100;
bool isprime(int n)
{
    if (n <= 1)
        return false;
    for (int i = 2; i*i<=n; i++)
        if (n % i == 0)
            return false;

    return true;
}
int binarySearch(int arr[], int l, int r, int x)
{
    if (r >= l) {
        int mid = l + (r - l) / 2;
        if (arr[mid] == x)
            return mid;
        if (arr[mid] > x)
            return binarySearch(arr, l, mid - 1, x);
        return binarySearch(arr, mid + 1, r, x);
    }
    return -1;
}
long long lcm(long long a,long long b)
{
    long long p,r;
    p = a*b;
    r = __gcd(a, b);
    return p/r;
}
bool ispalindrome(string s)
{
    int n = s.length();
    for(int i=0;i<n/2;i++)
    {
        if(s[i]!=s[n-i-1])
            return false;
    }
    return true;
}
bool isPerfectSquare(long double x)
{
  long double sr = sqrt(x);
  return ((sr - floor(sr)) == 0);

}
ll f(ll n) {
	return n * (n - 1) / 2;
}
bool cmp(const tuple<int, string, string>& a,
               const tuple<int, string, string>& b)
{
    return (get<0>(a) < get<0>(b));
}
void solve()
{
    long double n,d,x,y;
    cin>>n>>d;
    vector<long double>v;
    while(n--)
    {
        cin>>x>>y;
        v.push_back((x*x)+(y*y));
    }
    sort(v.begin(),v.end());
    int ans=0;
    for(int i=0;i<v.size();i++)
    {
        if(v[i]<=d*d)
            ans++;
    }
    cout<<ans<<endl;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t;
    t=1;
    //cin>>t;
    while(t--)
    {
        solve();
    }
}


Measured memory_bytes: 7500
#include <bits/stdc++.h>
using namespace std;
template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}
#ifdef __LOCAL
#define debug(x) cerr << __LINE__ << ": " << #x << " = " << x << endl
#define debugArray(x, n)                           \
  cerr << __LINE__ << ": " << #x << " = {";        \
  for (long long hoge = 0; (hoge) < (n); ++(hoge)) \
    cerr << ((hoge) ? "," : "") << x[hoge];        \
  cerr << "}" << endl
#else
#define debug(x) (void(0))
#define debugArray(x, n) (void(0))
#endif

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a, b, x;
  cin >> a >> b >> x;
  auto f = [&](long double theta) {
    if (a * tan(theta) < b) {
      return (b - a * tan(theta) / 2) * a * a;
    } else {
      return b * b * a / tan(theta) / 2;
    }
  };
  auto to_rad = [](long double theta) { return acos(-1) / 180 * theta; };
  long double low = 0, high = 90;
  for (int i = 0; i < 100; i++) {
    long double mid = (high + low) / 2;
    if (f(to_rad(mid)) < x) {
      high = mid;
    } else {
      low = mid;
    }
  }
  cout << fixed << setprecision(12) << low << '\n';
  return 0;
}


Measured memory_bytes: 4168
#include <list>
#include <cstdio>
#include <iostream>

using namespace std;

int main(){
  list<int> L;
  int n; scanf("%d",&n);
  for(int i=0;i<n;i++){
    char com[20];
    scanf("%s",com);
    if(com[0]=='i'){
      int x; scanf("%d",&x);
      L.push_front(x);
    }else if(com[6]=='F'){
      L.pop_front();
    }else if(com[6]=='L'){
      L.pop_back();
    }else{
      int x; scanf("%d",&x);
      list<int>::iterator it;
      for(it=L.begin();it!=L.end();it++){
        if(x==*it){
          L.erase(it);
          break;
        }
      }
    }
  }
  for(list<int>::iterator it=L.begin();it!=L.end();it++){
    if(it==L.begin()){
      printf("%d",*it);
    }else{
      printf(" %d",*it);
    }
  }
  cout << endl;
}

Measured memory_bytes: 34420
#include <bits/stdc++.h>
#define F first
#define S second

using namespace std;
typedef long long int64;

const int INF = 1e5 + 7;
vector<pair<int, int>> dirs = {{1, 0}, {-1, 0}, {0, 1}, {0, -1}};
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int h, w;
    cin >> h >> w;
    int matrix[h][w];
    int node[h][w];
    int cnt = 0;
    memset(matrix, 0, sizeof(matrix));
    for (int i = 0; i < h; ++ i) {
        for (int j = 0; j < w; ++ j) {
            char ch;
            cin >> ch;
            if (ch == '.') matrix[i][j] = 1;
            node[i][j] = cnt ++;
        }
    }
    int adj[h * w][h * w];
    for (int i = 0; i < h * w; ++ i) {
        for (int j = 0; j < h * w; ++ j) {
            adj[i][j] = (i == j ? 0 : INF);
        }
    }
    for (int i = 0; i < h; ++ i) {
        for (int j = 0; j < w; ++ j) {
            if (!matrix[i][j]) continue;
            for (auto& x : dirs) {
                if (i + x.F >= 0 && i + x.F < h &&
                    j + x.S >= 0 && j + x.S < w &&
                    matrix[i + x.F][j + x.S]) {
                    adj[node[i][j]][node[i + x.F][j + x.S]] = 1;
                }
            }
        }
    }
    for (int k = 0; k < h * w; ++ k) {
        for (int i = 0; i < h * w; ++ i) {
            for (int j = 0; j < h * w; ++ j) {
                adj[i][j] = min(adj[i][j], adj[i][k] + adj[k][j]);
            }
        }
    }
    int ans = 0;
    for (int i = 0; i < h * w; ++ i) {
        for (int j = 0; j < h * w; ++ j) {
            if (adj[i][j] == INF) continue;
            ans = max(ans, adj[i][j]);
        }
    }
    cout << ans;
}

Measured memory_bytes: 896
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#define MOD 1000000007LL

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

vector<ll> polymul(vector<ll> f, vector<ll> g){
	int m=f.size(), n=g.size();
	vector<ll> h;
	for(int k=0; k<m+n-1; k++){
		h.push_back(0);
	}
	for(int i=0; i<m; i++){
		for(int j=0; j<n; j++){
			h[i+j]+=(f[i]*g[j]);
			h[i+j]%=MOD;
		}
	}
	return h;
}

int main()
{
	int n;
	cin>>n;
	ll p2[90001];
	p2[0]=1;
	for(int i=1; i<=n*n; i++){
		p2[i]=p2[i-1]*2%MOD;
	}
	int c[300][300];
	for(int i=0; i<n; i++){
		for(int j=0; j<n; j++){
			cin>>c[i][j];
		}
	}
	int r=0;
	for(int j=0; j<n; j++){
		int i0=-1;
		for(int i=0; i<n; i++){
			if(c[i][j]==1){
				i0=i;
				break;
			}
		}
		if(i0==-1) continue;
		for(int i=i0+1; i<n; i++){
			if(c[i][j]==0) continue;
			c[i][j]=0;
			for(int k=j+1; k<n; k++){
				if(c[i0][k]==1) c[i][k]=1-c[i][k];
			}
		}
		for(int k=j+1; k<n; k++){
			c[i0][k]=0;
		}
		r++;
	}
	ll ans=0;
	for(int s=r; s<=n; s++){
		if(s==0){
			ans+=p2[n*n];
			continue;
		}
		ll ans1=1;
		for(int i=0; i<s; i++){
			ans1*=(p2[n]+MOD-p2[i]);
			ans1%=MOD;
		}
		vector<ll> p;
		p.push_back(1);
		for(int i=0; i<=s-r; i++){
			vector<ll> q;
			for(int j=0; j<=n-s; j++){
				q.push_back(p2[i*j]);
			}
			p=polymul(p, q);
			p.resize(n-s+1);
		}
		ans1*=p[n-s];
		ans1%=MOD;
		ans1*=p2[n*(n-s)];
		ans1%=MOD;
		ans+=ans1;
		ans%=MOD;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1280
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <regex>
#define rep(i,n) for(int i = 0; i < n; i++)
#define reps(i,j,n) for(int i = j; i < n; i++)
#define rrep(i,j,n) for(int i = j-1; i >= n; i--)
#define prec(n) fixed << setprecision(n)
#define print_array(v) rep(__k, v.size()) { cout << v[__k]; if(__k != v.size()-1) cout << " "; else cout << endl; }
#define YesorNo(a) printf(a?"Yes\n":"No\n")
#define fi first
#define se second
using namespace std;

int inf = 2147483647;
int64_t inf64 = 9223372036854775807;
int mod = 1e+7;

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

  int n, k;
  cin >> n >> k;
  vector<int> trees(n);
  rep(i,n) cin >> trees[i];
  sort(trees.begin(), trees.end());

  int res = inf;
  rep(i,n-k+1) {
    res = min(res, trees[i+k-1]-trees[i]);
  }
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;

int main(){
  int h, w, n, ind_x=0, ind_y=0, to=0;
  cin >> h >> w >> n;
  vector<vector<int>> vv(h, vector<int>(w, 0));
  for(int i=1;i<=n;i++){
    int a;
    cin >> a;
    for(int j=0;j<a;j++){
      if (ind_x == w){
        ind_x--, ind_y++;
        vv[ind_y][ind_x] = i;
        ind_x--;
        to = 1;
      }else if (ind_y != 0 && ind_x == -1){
        ind_x++, ind_y++;
        vv[ind_y][ind_x] = i;
        ind_x++;
        to = 0;
      }else{
        vv[ind_y][ind_x] = i;
        if (to == 0){
          ind_x++;
        }else{
          ind_x--;
        }
      }
    }
  }
  for(int i=0;i<h;i++){
    for(int j=0;j<w-1;j++){
      cout << vv[i][j]  << " ";
    }
    cout << vv[i][w-1] << endl;
  }
  return 0;
}

Measured memory_bytes: 384
a1 = input()
a2 = input()
a3 = input()
a1_list = a1.split(' ')
a2_list = a2.split(' ')
a3_list = a3.split(' ')

num = input()
num = int(num)
bingo = []

for i in range(num):
    y = input()
    bingo.append(y)

for i in bingo:
    i = str(i)
    for y in range(3):
        if a1_list[y] == i:
            a1_list[y] = 'OK'
        elif a2_list[y] == i:
            a2_list[y] = 'OK'
        elif a3_list[y] == i:
            a3_list[y] = 'OK'

bingo1 = (a1_list[0] == a1_list[1] and a1_list[1] == a1_list[2] and a1_list[2] == a1_list[0])
bingo2 = (a2_list[0] == a2_list[1] and a2_list[1] == a2_list[2] and a2_list[2] == a2_list[0])
bingo3 = (a3_list[0] == a3_list[1] and a3_list[1] == a3_list[2] and a3_list[2] == a3_list[0])
bingo4 = (a1_list[0] == a2_list[0] and a2_list[0] == a3_list[0] and a1_list[0] == a3_list[0])
bingo5 = (a1_list[1] == a2_list[1] and a2_list[1] == a3_list[1] and a1_list[1] == a3_list[1])
bingo6 = (a1_list[2] == a2_list[2] and a2_list[2] == a3_list[2] and a1_list[2] == a3_list[2])
bingo7 = (a1_list[0] == a2_list[1] and a2_list[1] == a3_list[2] and a1_list[0] == a3_list[2])
bingo8 = (a1_list[2] == a2_list[1] and a2_list[1] == a3_list[0] and a3_list[0] == a1_list[2])

if bingo1 or bingo2 or bingo3:
    print('Yes')
elif bingo4 or bingo5 or bingo6:
    print('Yes')
elif bingo7 or bingo8:
    print('Yes')
else:
    print('No')


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

using i64 = int64_t;

const i64 MOD = 1e9+7;

const i64 INF = 1e18+7;

struct Matrix{
	int h, w;
	vector<i64> v;

	Matrix(int h, int w) : h(h), w(w), v(h * w, 0){}

	Matrix(vector<vector<i64>> v_) : h(v_.size()), w(v_[0].size()), v(h * w){
		for(int i = 0; i < h; ++i)
			for(int j = 0; j < w; ++j)
				v[i * w + j] = v_[i][j];
	}

	static Matrix makeUnit(int n){
		Matrix mat(n, n);
		for(int i = 0; i < n; ++i)
			mat.at(i, i) = 1;
		return mat;
	}

	static Matrix modMul(const Matrix& a, const Matrix& b, const int mod = MOD){
		assert(a.w == b.h);
		Matrix ret(a.h, b.w);
		for(int i = 0; i < a.h; ++i)
			for(int k = 0; k < a.w; ++k)
				for(int j = 0; j < b.w; ++j)
					ret.v[i * b.w + j] = (ret.v[i * b.w + j] + a.v[i * a.w + k] * b.v[k * b.w + j]) % mod;
		return ret;
	}

	i64& at(int i, int j){
		assert(0 <= i && i <= h && 0 <= j && j < w);
		return v[i * h + j];
	};

	Matrix pow(i64 x, const i64 mod = MOD){
		assert(h == w);
		auto mat = x & 1 ? *this : makeUnit(h);
		auto u = *this;
		while(u = modMul(u, u, mod), x >>= 1)
			if(x & 1)
				mat = modMul(mat, u, mod);
		return mat;
	}

	Matrix& operator+=(const Matrix& mat){
		assert(h == mat.h && w == mat.w);
		for(int i = 0; i < h * w; ++i)
			v[i] += mat.v[i];
		return *this;
	}

	Matrix& operator-=(const Matrix& mat){
		assert(h == mat.h && w == mat.w);
		for(int i = 0; i < h * w; ++i)
			v[i] -= mat.v[i];
		return *this;
	}

	Matrix& operator%=(const i64 mod){
		for(int i = 0; i < h * w; ++i)
			v[i] %= mod;
		return *this;
	}

	Matrix operator*(const Matrix& mat){
		assert(w == mat.h);
		Matrix ret(h, mat.w);
		for(int i = 0; i < h; ++i)
			for(int k = 0; k < w; ++k)
				for(int j = 0; j < mat.w; ++j)
					ret.v[i * mat.w + j] += v[i * w + k] * mat.v[k * mat.w + j];
		return ret;
	}

	Matrix operator+(const Matrix& mat){return Matrix(*this) += mat;}
	Matrix operator-(const Matrix& mat){return Matrix(*this) -= mat;}
	Matrix operator%(const i64 mod){return Matrix(*this) %= mod;}
	Matrix& operator*=(const Matrix& mat){return *this = *this * mat;}
};

signed main(){
	int n;
	i64 k;
	cin >> n >> k;
	vector<vector<i64>> v(n, vector<i64>(n));
	for(auto& x : v)
		for(auto& y : x)
			cin >> y;
	Matrix mat(v);
	mat = mat.pow(k);
	mat = Matrix::modMul(mat, vector<vector<i64>>(n, vector<i64>(1, 1)));
	cout << accumulate(mat.v.begin(), mat.v.end(), 0LL) % MOD << endl;
}


Measured memory_bytes: 384
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a) (a).begin(),(a).end()
#define pb emplace_back
#define INF (1e9+1)

int main(){
    string s;
    cin>>s;
    
    vector<string> vs = {"dream", "dreamer", "erase", "eraser"};
    
    rep(i,vs.size())reverse(all(vs[i]));
    reverse(all(s));
    
    int ind = 0;
    while(ind<s.size()){
        rep(i,4){
            string str = vs[i];
            if(s.substr(ind,str.size())==str){
                ind += str.size();
                break;
            }
            if(i==3){
                cout<<"NO"<<endl;
                return 0;
            }
        }
    }
    cout<<"YES"<<endl;
}

Measured memory_bytes: 512
def ret_max_index(n, list):
    i = 0
    tmp = 0
    max = 0
    for i in range(n):
        if(max < list[i]):
            tmp = i
            max = list[i]
    return tmp

N = int(input())
lis = [int(i) for i in input().split()]

j = 0
k = 0
alice = 0
bob = 0
max = 0
lis_elem = len(lis)

for j in range(N):
    lis_elem = len(lis)
    max = lis[ret_max_index(lis_elem, lis)]
    #print("max:",max)
    del lis[ret_max_index(lis_elem, lis)]
    if(j%2 == 0):
        alice = alice + max
    elif(j%2 == 1):
        bob = bob + max

print(alice - bob)

Measured memory_bytes: 3064
import sys
input = sys.stdin.readline

n, m = [int(x) for x in input().split()]
ab = [[int(x) for x in input().split()] for _ in range(n)]
cd = [[int(x) for x in input().split()] for _ in range(m)]

ans = []

for i in range(n):
    a, b = ab[i]
    res = [0, float('inf')]
    for j in range(m):
        c, d = cd[j]
        dis = abs(a - c) + abs(b - d)
        if dis < res[1]:
            res = [j + 1, dis]
    ans.append(res[0])

for k in ans:
    print(k)

Measured memory_bytes: 39280
from collections import defaultdict
import os, sys
# def debug(*args): print(*args, file=sys.stderr)# os.environ.get("USER")
# def debug(*args): os.environ.get("USER")
def debug(*args): pass
N=int(input())
A=[int(i) for i in input().split()]
dd=defaultdict(int)
for a in A:
    dd[a]+=1
#print(dd)
B=sorted(A,reverse=True)
ans=0
for x in B:
    debug(A)
    #print(x)
    if dd.get(x,-1)==0:
        continue
    s=len(bin(x))-3
    if x==1<<s:
        t=dd.get(x,-1)
        if t!=-1:
            ans+=t//2
            dd[x]-=(t//2)*2
            #print(ans)
            #print(dd)
    else:
        s+=1
        #print((1<<s)-x)
        t=dd.get((1<<s)-x,-1)
        if t>=1:
            ans+=1
            dd[x]-=1
            dd[(1<<s)-x]-=1
            #print(ans)
            #print(dd)
print(ans)


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

typedef long long LL;

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ALL(x) (x).begin(),(x).end()
const int IINF = 1e9;
const LL LINF = 1e18;
const LL mod = 1e9+7;

int main() {
    int A, B;
    cin >> A >> B;
    string s;
    cin >> s;
    REP(i, A) {
        if(s[i] == '-') {
            cout << "No" << endl;
            return 0;
        }
    }
    if(s[A] != '-') {
        cout << "No" << endl;
        return 0;
    }
    FOR(i, A + 1, A + B + 1) {
        if(s[i] == '-') {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){

int N,ans=0;
scanf("%d",&N);

long buff;

for (int i = 0; i < N; i++){
    scanf("%ld",&buff);
    long div_count=0;
    while (buff%2==0)
    {
      div_count++;
      buff /= 2;
    }
    ans += div_count;
}

printf("%d",ans);
return 0;

}

Measured memory_bytes: 1720
#include <bits/stdc++.h>
using namespace std;
 
int N, a[101], dp[101][76];
 
int main() {
	cin >> N;
	for (int i = 1; i != N + 1; ++i) {
		int k = i;
		int j = 2;
		while (k != 1) {
			if (k%j)
				++j;
			else {
				k /= j;
				++a[j];
			}
		}
	}
	dp[0][1] = 1;
	for (int i = 1; i != N + 1; ++i) {
		for (int j = 1; j != 76; ++j) {
			for (int k = 0; k != a[i]+1 && (k + 1)*j <= 75; ++k) {
				dp[i][(k + 1)*j] += dp[i - 1][j];
			}
		}
	}
	cout << dp[N][75] << endl;
	return 0;
}

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

int main(){
    int n;
    while( cin >> n, n ){
        int m_id, max_dist = 0, id, d1, d2;
        while( n-- > 0 ){
            cin >> id >> d1 >> d2;
            if( d1 + d2 > max_dist ){
                m_id = id;
                max_dist = d1 + d2;
            }
        }
        cout << m_id << ' ' << max_dist << endl;
    }
    return 0;
}

Measured memory_bytes: 1156
import java.util.Scanner;

public class Main {
    public static void output(int array[]){
        int k;
        for(k = 0; k < array.length - 1; ++k) System.out.print(array[k] + " ");
        System.out.println(array[k]);
    }

    public static void main(String[] args){

        Scanner scanner = new Scanner(System.in);
        int i, j, k, key, n = scanner.nextInt();
        int[] array = new int[n];
        for(i = 0; i < n; ++i) array[i] = scanner.nextInt();

        for(i = 1; i < array.length; ++i){
            output(array);
            key = array[i];
            j = i - 1;
            while(j >= 0 && array[j] > key){
                array[j + 1] = array[j];
                j--;
            }
            array[j + 1] = key;
        }
        output(array);
        scanner.close();
    }
}


Measured memory_bytes: 31112
#include<iostream>
#include<cstdint>
using namespace std; // 575

const int MAX = 100001;
const int INF = 1073741823; // 10^30-1、使わない辺とかに用いる
int main() {
	int N;
	static int A[MAX], mi = INF, neg = 0, zero = 0;
	int64_t sum = 0;
	cin >> N;
	for (int i = 0;i < N;++ i) {
		cin >> A[i];
		if (A[i] < 0) ++ neg;
		else if (A[i] == 0) ++ zero;
		mi = min(mi, abs(A[i]));
		sum += abs(A[i]);
	}
	
	if (neg & 1 & !zero) sum -= mi << 1;
	cout << sum;
	return 0;
}
/*
31536000のコメント解説欄
ここテンプレで用意してるから、A問題とかだとこの先空欄の危険あり
また、コンテスト後に https://31536000.hatenablog.com/ で解説していると思うので、良かったら読んでねー

操作によって負数の位置は移動させることができ、偶数個は消すことができる

*/

Measured memory_bytes: 640
#include <stdio.h>
int main(){
 
  int a,i,j,d500,d100,d50,d10,d5,d1;
 
  while(1){
     
    scanf("%d",&a);
 
    if(a != 0){
       
      a=1000-a;
       
      d500=a/500;
      a -= 500*d500;
       
      d100=a/100;
      a -= 100*d100;
       
      d50=a/50;
      a -= 50*d50;
       
      d10=a/10;
      a -= 10*d10;
       
      d5=a/5;
      a -= 5*d5;
       
      d1=a/1;
       
      //printf("%d %d %d %d %d\n",d500,d100,d10,d5,d1);
       
      printf("%d\n",d500+d100+d50+d10+d5+d1);
 
    } else {
 
      break;
 
    }
 
  }
     
  return 0;
   
}

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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

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

int LCM(int a, int b){
   return (a * b)/(GCD(a, b));
}

int xxx(int x, int r, int d, int i){
   if(i == 10){return 0;}
   cout << r*xxx(x, r, d, i) - d << endl;
   return 0;
}

int main(){
   int r, D, x2000;
   cin >> r >> D >> x2000;

   int prev = r * x2000 - D;
   int next;
   for(int i = 0; i < 10; i++){
      cout << prev << endl;
      next = r*prev - D;
      prev = next;
   }
   return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;
typedef pair<ll, int> P;
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define ALL(v) (v).begin(), (v).end()
#define SP cout << fixed << setprecision(10)
const int INF = (int)1e9;
const int MOD = (int)1e9 + 7;
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

int main(void) {
        int n;
        cin >> n;
        string w[n];
        REP(i, n) cin >> w[i];

        bool same = false;
        REP(i, n) {
                REP(j, i) {
                        if (w[i] == w[j])
                                same = true;
                }
        }
        if (same) {
                cout << "No" << endl;
                return 0;
        }

        bool ok = true;
        FOR(i, 0, n - 1) {
                if (w[i].substr(w[i].length() - 1) != w[i + 1].substr(0, 1))
                        ok = false;
        }
        if (ok)
                cout << "Yes" << endl;
        else
                cout << "No" << endl;

        return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main()
{
    long long int x, t, r;
    scanf("%lld %lld", &x, &t);
    if(x>t)
    {
        r = x-t;
        printf("%lld", r);
    }
    else
    {
        r = 0;
        printf("%lld", r);
    }
    return 0;
}


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

int main(){
    int D;
    std::cin >> D;
    std::vector< int > C(26);
    for(int i=0; i<26; i++){
        std::cin >> C[i];
    }
    std::vector< std::vector< int > > S(D, std::vector< int >(26));
    std::vector< int > best_index(D, 0);
    for(int i=0; i<D; i++){
        int max = 0;
        for(int j=0; j<26; j++){
            std::cin >> S[i][j];
            if(max < S[i][j] || (max == S[i][j] && C[j] > C[best_index[i]])){
                max = S[i][j];
                best_index[i] = j;
            }
        }
    }
    std::vector< int > T(D);
    for(int i=0; i<D; i++){
        T[i] = best_index[i] + 1;
    }
    
    for(int i=0; i<D; i++){
        std::cout << T[i] << std::endl;
    }
    
    return 0;
}



Measured memory_bytes: 3680
#include <stdio.h>
char str[7];
int main() {
	int I, N;
	scanf("%d", &N);
	for(I = 0; I < N; ++ I) {
		int score = 0, hit = 0, out = 0;
		while(out < 3) {
			scanf("%s", str);
			if(str[0] == 'H' && str[1] == 'O') {
				score += hit + 1;
				hit = 0;
			} else if(str[0] == 'H') {
				if(++hit == 4) {
					score ++;
					hit = 3;
				}
			} else {
				out ++;
			}
		}
		printf("%d\n", score);
	}
	return 0;
}

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

bool flag[102];

void isBuy() {
	for (int i = 0; i < 102; i += 11) {
		flag[i] = true;
		for (int j = 4+i; j < 102; j += 4) 
			flag[j] = true;
		for (int j = 7+i; j < 102; j += 7) 
			flag[j] = true;
	}
}

int main() {
	int N;
	cin >> N;
	isBuy();
	if (flag[N])
		cout << "Yes\n";
	else
		cout << "No\n";
}


Measured memory_bytes: 256
#include <float.h>
#include <inttypes.h>
#include <limits.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
#include <math.h>
#ifdef __cplusplus
#include <bits/stdc++.h>
#endif

#define getchar getchar_unlocked
#define putchar putchar_unlocked
int32_t nextint(void){ char c=getchar_unlocked(); while(c!='-'&&(c<'0'||'9'<c)) c=getchar_unlocked(); bool s=false; if(c=='-'){s=true;c=getchar_unlocked();} uint32_t x=0; while('0'<=c && c<='9'){ x=x*10+c-'0'; c=getchar_unlocked(); } return s?-x:x; }
int64_t nextlong(void){ char c=getchar_unlocked(); while(c!='-'&&(c<'0'||'9'<c)) c=getchar_unlocked(); int s=0; if(c=='-'){s=1;c=getchar_unlocked();} uint64_t x=0; while('0'<=c && c<='9'){ x=x*10+c-'0'; c=getchar_unlocked(); } return s?-x:x; }
uint32_t nextstr(char *s){ char c=getchar_unlocked(); while(c==' '||c=='\n') c=getchar_unlocked(); uint32_t len=0; while(c!=' '&&c!='\n'){ *s++=c; len++; c=getchar_unlocked(); } *s='\0'; return len; }

char s[100001];
int main(void){
	int n=nextstr(s);
	int l=0, r=n-1;
	int ans=0;
	while(l<r){
		if(s[l]==s[r]){
			l++;
			r--;
		}else if(s[l]=='x'){
			l++;
			ans++;
		}else if(s[r]=='x'){
			r--;
			ans++;
		}else{
			ans=-1;
			break;
		}
	}
	printf("%d\n", ans);
}


Measured memory_bytes: 256
N,K = map(int,input().split())
R,S,P = map(int,input().split())
T = input()

dp = [[0]*3 for _ in range(N)]
for i in range(K):
    for j in range(i,N,K):
        c = T[j]
        if j < K:
            if c=='r':
                dp[j][0] = P
            elif c=='s':
                dp[j][1] = R
            else:
                dp[j][2] = S
        else:
            if c=='r':
                dp[j][0] = max(dp[j-K][1], dp[j-K][2]) + P
                dp[j][1] = max(dp[j-K][0], dp[j-K][2])
                dp[j][2] = max(dp[j-K][0], dp[j-K][1])
            elif c=='s':
                dp[j][0] = max(dp[j-K][1], dp[j-K][2])
                dp[j][1] = max(dp[j-K][0], dp[j-K][2]) + R
                dp[j][2] = max(dp[j-K][0], dp[j-K][1])
            else:
                dp[j][0] = max(dp[j-K][1], dp[j-K][2])
                dp[j][1] = max(dp[j-K][0], dp[j-K][2])
                dp[j][2] = max(dp[j-K][0], dp[j-K][1]) + S
ans = 0
for i in range(N-1,N-1-K,-1):
    ans += max(dp[i])
print(ans)

Measured memory_bytes: 16532