akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;

int main() {
    ll n;
    string s;
    cin >> n >> s;
    vector<ll> r, g, b;
    for (int i = 0; i < n; ++i) {
        if (s[i] == 'R') r.emplace_back(i);
        else if (s[i] == 'G') g.emplace_back(i);
        else b.emplace_back(i);
    }
    ll ans = r.size() * g.size() * b.size();
    for (ll i : r) {
        for (ll j : g) {
            ll target = abs(i - j);
            ll x = min(i, j) - target;
            if (binary_search(b.begin(), b.end(), x)) ans--;
            x = max(i, j) + target;
            if (binary_search(b.begin(), b.end(), x)) ans--;
            if (abs(i - j) % 2 == 0) {
                if (binary_search(b.begin(), b.end(), abs(i + j) / 2)) ans--;
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3664
n,k=map(int,input().split())
B=list(map(int,input().split()))
S=list(input())
A=[[] for i in range(k)]
for i in range(n):
  if S[i]=="s":
    A[i%k].append(0)
  elif S[i]=="p":
    A[i%k].append(1)
  else:
    A[i%k].append(2)
ans=0
for i in range(k):
  f=0
  for j in range(len(A[i])):
    if f==0:
      ans=ans+B[A[i][j]]
      if j!=len(A[i])-1:
        if A[i][j]==A[i][j+1]:
          f=1
    else:
      f=0
print(ans)

Measured memory_bytes: 18608
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int even = sc.nextInt();
		int odd = sc.nextInt();

		sc.close();

		List<Integer> numberList = new ArrayList<Integer>();

		int evenNumber = 2;
		for (int i = 1; i <= even; i++) {
			numberList.add(evenNumber);
			evenNumber += 2;
		}

		int oddNumber = 1;
		for (int i = 1; i <= odd; i++) {
			numberList.add(oddNumber);
			oddNumber += 2;
		}

		int result = 0;
		for (int i = 0; i < numberList.size(); i++) {
			for (int j = i; j < numberList.size(); j++) {
				int parent = numberList.get(i).intValue();
				int child = numberList.get(j).intValue();

				if (parent == child) {
					continue;
				}
				if ((parent + child) % 2 == 0) {
					result++;
				}
			}
		}

		System.out.print(result);
	}
}


Measured memory_bytes: 21972
#include <bits/stdc++.h>
#define li 100005
#define lo long long
#define fi first
#define FOR for(int i=1;i<=n;i++)
#define	FOr for(int i=n;i>=1;i--)
#define For for(int j=1;j<=n;j++)
#define se second
#define inf 1000000000
using namespace std;
int n,k,m,cevv,cev,orta;
string s;
int main(){
    scanf("%d",&n);
    for(int i=1;i<=n;i++){
		for(int j=1;j<=i;j++){
			if(i%2==0)
				break;
			if(i%j==0)
				cev++;
		}
		if(cev==8)
			cevv++;
		cev=0;	
	}
	printf("%d",cevv);
    return 0;
}



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

using namespace std;

template <typename T>
using Vec = vector<T>;

typedef long double ld;
typedef long long ll;

#define FO(i, N) for (int (i) = 0; (i) < (N); ++(i))
#define FOll(i, N) for (ll (i) = 0; (i) < (N); ++(i))
#define READALL(c) for (auto &e : c) { cin >> e; }
#define PRINTALL(c) for (const auto &e : c) { cout << e << "\t"; } cout << "\n";
#define MP(x, y) (make_pair((x), (y)))
#define MT(...) make_tuple(__VA_ARGS__)
#define G(i, x) get<i>(x)
#define ALL(x) begin(x), end(x)

int A[3123];

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

	string A, B;
	cin >> A >> B;

	FO(i, A.size()) {
		string C =  A.substr(i+1)+A.substr(0, i+1);
		if (C == B) {
			cout << "Yes" << endl;
			return 0;
		}
	}

	cout << "No" << endl;
}

Measured memory_bytes: 256
import heapq
from collections import deque
from enum import Enum
import sys
import math
from _heapq import heappush, heappop

BIG_NUM = 2000000000
MOD = 1000000007
EPS = 0.000000001


class UnionFind:
    def __init__(self,arg_V):
        self.V = arg_V
        self.boss = [None]*arg_V
        self.height = [None]*arg_V

    def init(self):
        for i in range(self.V):
            self.boss[i] = i
            self.height[i] = 0

    def get_boss(self,index):
        if index == self.boss[index]:
            return index
        else:
            self.boss[index] = self.get_boss(self.boss[index])
            return self.boss[index]


    def is_same_group(self,a,b):
        return self.get_boss(a) == self.get_boss(b)

    def unite(self,x,y):
        boss_x = self.get_boss(x)
        boss_y = self.get_boss(y)

        if boss_x == boss_y:
            return

        if self.height[x] > self.height[y]:

            self.boss[boss_y] = boss_x

        elif self.height[x] < self.height[y]:

            self.boss[boss_x] = boss_y

        else:
            self.boss[boss_y] = boss_x
            self.height[x] += 1

class Edge:
    def __init__(self,arg_FROM,arg_TO,arg_WEIGHT):
        self.FROM = arg_FROM
        self.TO = arg_TO
        self.WEIGHT = arg_WEIGHT

    def __lt__(self,arg):
        return self.WEIGHT < arg.WEIGHT


V = int(input())

TABLE = []
for i in range(V):
    input_array = list(map(int,input().split()))
    for k in range(len(input_array)):
        if input_array[k] != -1:
            TABLE.append(Edge(i,k,input_array[k]))

UF = UnionFind(V)
UF.init()

TABLE.sort()

ans = 0

for i in range(len(TABLE)):
    if UF.is_same_group(TABLE[i].FROM, TABLE[i].TO) == False:
        UF.unite(TABLE[i].FROM, TABLE[i].TO)
        ans += TABLE[i].WEIGHT

print("%d"%(ans))



Measured memory_bytes: 7888
import java.util.Scanner;

public class Main {
    public static void main(String args[]) {
        double debt = 100000.0;
        int nWeeks = new Scanner(System.in).nextInt();
        for(int i = 0; i < nWeeks; i++) {
            debt = ((int)(debt * 0.00105 + 0.99999)) * 1000.0;
        }
        System.out.println((int)debt);

    }
} 

Measured memory_bytes: 15324
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef pair<int, int> P;
typedef long long ll;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    rep(i, n)
    {
        cin >> a[i];
    }
    ll ans = 1e18;
    rep(i, (1 << n))
    {
        ll cost = 0;
        int cnt = 0;
        int mx = 0;
        rep(j, n)
        {
            if (i & (1 << j))
            {
                if (a[j] <= mx)
                {
                    cost += mx + 1 - a[j];
                    mx = mx + 1;
                }
                cnt++;
            }
            mx = max(mx, a[j]);
        }
        if (cnt >= k)
        {
            ans = min(ans, cost);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll>pi;
const int MAXN=100005;
const int MOD=1000000007;

#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define DEC(i,a,b) for(int i=(a);i>=(b);i--)
#define fst first
#define snd second
#define pb push_back
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(),(v).end()
#define db(x) cerr<<#x<<" = "<<x<<"\n"
#define LOW(v,x) (lower_bound(all(v),(x))-(v).begin())
#define UP(v,x) (upper_bound(all(v),(x))-(v).begin())
int N,A,B,C;
string s;
vector<string> vec;
void check(){
	//db(A),db(B),db(C);
	if(min({A,B,C})<0) {
		cout<<"No";
		exit(0);
	}
}

vector<string> sol;
void give(int x, int y, int z){
	if (x==1) sol.pb("A");
	if (y==1) sol.pb("B");
	if (z==1) sol.pb("C");
	A+=x, B+=y, C+=z;
}


void solve(int i){
	check();
	if (vec[i]=="AB"){
		if (A<B) give(1,-1,0);
		else if (B<A) give(-1,1,0);
		else{
			if (i!=N-1 && vec[i+1]=="AC") give(1,-1,0);
			else if (i!=N-1 && vec[i+1]=="BC") give(-1,1,0);
			else give(1,-1,0);			
		}
	}
	if (vec[i]=="AC"){
		if (A<C) give(1,0,-1);
		else if (C<A) give(-1,0,1);
		else{
			if (i!=N-1 && vec[i+1]=="AB") give(1,0,-1);
			else if (i!=N-1 && vec[i+1]=="BC") give(-1,0,1);
			else give(1,0,-1);
		}
	}
	if (vec[i]=="BC"){
		if (B<C) give(0,1,-1);
		else if (C<B) give(0,-1,1);
		else{
			if (i!=N-1 && vec[i+1]=="AC") give(0,-1,1);
			else if (i!=N-1 && vec[i+1]=="AB") give(0,1,-1);
			else give(0,1,-1);		
		}
	}
	check();
}
main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cin>>N>>A>>B>>C;
	FOR(i,1,N){
		cin>>s;
		vec.pb(s);
	}
	FOR(i,1,N){
		solve(i-1);
	}
	cout<<"Yes\n";
	for (auto i:sol) cout<<i<<"\n";
}


Measured memory_bytes: 12424
#include <iostream>
#include <vector>
#include <algorithm>
#include <string.h>
#include <iomanip>
#include <math.h>
#include <string>
#include <queue>
#include <map>
#include <set>
#include <functional>

using namespace std;

typedef long long int ll;
typedef std::pair<int, int> pii;
typedef std::pair<ll, int> pli;
typedef std::pair<ll, ll> pll;

#define FOR(i,n,m) for(ll i=(ll)(m);i<(ll)(n);++i)
#define REP(i,n) FOR(i,n,0)
#define IREP(i,n) for(ll i=(ll)(n);i>=0;--i)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

int n, k;
int w[100005];

bool canAllocate(ll m)
{
	int t = 1;
	ll sum = 0;
	REP(i, n)
	{
		if (w[i] > m)return false;
		if (sum + w[i] > m)
		{
			sum = w[i];
			++t;
		}
		else
		{
			sum += w[i];
		}
	}
	return t <= k;
}

int main()
{
	cin >> n >> k;
	REP(i, n)
	{
		cin >> w[i];
	}

	ll min = 0, max = 1000000000;
	while (abs(max - min) > 1)
	{
		ll mid = (min + max) / 2;
		if (canAllocate(mid))
		{
			max = mid;
		}
		else
		{
			min = mid;
		}
	}
	cout << min + 1 << endl;
	return 0;
}


Measured memory_bytes: 3464
#include<bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for(int _b=(b),i=(a);i<=_b;++i)
#define ROF(i, b, a) for(int _a=(a),i=(b);i>=_a;--i)
#define REP(n) for(int _n=(n);_n--;)
#define _1 first
#define _2 second
#define PB(x) push_back(x)
#define SZ(x) int((x).size())
#define ALL(x) (x).begin(), (x).end()
#define MSET(m,v) memset(m,v,sizeof(m))
#define MAX_PQ(T) priority_queue<T>
#define MIN_PQ(T) priority_queue<T,vector<T>,greater<T>>
#define IO(){ios_base::sync_with_stdio(0);cin.tie(0);}
#define cint1(a) int a;cin>>a
#define cint2(a,b) int a,b;cin>>a>>b
#define cint3(a,b,c) int a,b,c;cin>>a>>b>>c
typedef long long int ll; typedef pair<int,int> PII;typedef unsigned long long int ull;
typedef vector<int>VI; typedef vector<ll> VL; typedef vector<PII> VP;
template<class A,class B>inline bool mina(A &x,const B &y){return(y<x)?(x=y,1):0;}
template<class A,class B>inline bool maxa(A &x,const B &y){return(x<y)?(x=y,1):0;}

string s[3];
int main() {
	IO();
	cin >> s[0] >> s[1] >> s[2];
	int t = 0;		
	while(true) {
		if(s[t].empty()) {
			cout << (char)(t+'A') << endl;
			return 0;
		}
		char c = s[t][0];
		s[t].erase(s[t].begin());
		t = c - 'a';
	}
	return 0;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int,input().split()))
r = [0 for _ in range(max(a)+1)]
l = [0 for _ in range(max(a)+1)]
ans = n
for i in a:
    r[i] += 1
    l[i] = 1
for i in range(len(r)):
    if r[i]:
        if 1 < r[i]:
            l[i] = 0
        for j in range(2*i,len(r),i):
            if r[j]:
                l[j] = 0
print(sum(l))

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

namespace yui
{
    class Program
    {
        static void Main(string[] args)
        {
            int ans = 0;
            int[] n = Console.ReadLine().Split().Select(int.Parse).ToArray();
            char[,] a = new char[n[0], n[1]];
            for (int i = 0; i < n[0]; i++)
            {
                string yu = Console.ReadLine();
                for (int k = 0; k < n[1]; k++)
                {
                    a[i, k] = yu[k];
                }
                for (int k = 0; k <= n[1] - n[2]; k++)
                {
                    bool f = true;
                    for (int j = k; j < n[2] + k; j++)
                    {
                        if (a[i, j] == '#') { f = false; break; }
                    }
                    ans += f ? 1 : 0;
                }
            }
            for (int k = 0; k < n[1]; k++)
            {
                for (int i = 0; i <= n[0] - n[2]; i++)
                {
                    bool f = true;
                    for (int j = i; j < i + n[2]; j++)
                    {
                        if (a[j, k] == '#') { f = false; break; }
                    }
                    ans += f ? 1 : 0;
                }
            }
            Console.WriteLine(ans);
            Console.ReadLine();
        }
    }
}

Measured memory_bytes: 9596
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <numeric>
typedef long long Int;
#define rep(i,a,b) for(Int i=a;i<b;++i)
#define rrep(i,a,b) for(Int i=a;i>=b;--i)
using namespace std;

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

    Int A, B, C;
    cin >> A >> B >> C;
    cout << min(B/A, C) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
const double PI = acos(-1);
const ll MOD = 1000000007;
using Graph = vector<vector<int>>;

int main() {
  int N; cin >> N;
  vector<int> A(N);
  rep(i,N) cin >> A[i];

  rep(i,N) A[i] -= (i+1);
  sort(all(A));
  int b;
  ll ans = 0;
  if (N % 2 == 0) {
    b = (A[N/2] + A[N/2-1]) / 2;
    rep(i,N) ans += abs(A[i] - b);
  } else {
    b = A[N/2];
    rep(i,N) ans += abs(A[i] - b);
  }

  cout << ans << endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define ll long long
#define loop(n) for(ll i = 0; i<n; i++)
#define sort(a) sort(a.begin(), a.end())
using namespace std;
#define m 1000000007

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

    int N, M, c; cin>>N>>M>>c;
    vector<int> b(M);
    loop(M) cin>>b[i];

    int count = 0, x;
    while(N--){
        int sum = 0;
        loop(M){
            cin>>x;
            sum = sum + x*b[i];
        }

        sum = sum + c;
        if(sum>0) count++;
    }
    cout<<count<<"\n";
    return 0;
}

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

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string n;
    cin>>n;
    int f=0;
    for(int i=0;i<3;i++)
    {
        if(n[i]==n[i+1])
        {
            f=1;
            break;
        }
    }
    if (f==1)
    cout<<"Bad"<<endl;
    else
    cout<<"Good"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int mod = 1e9+7;
int a[10005];
bool prime[1000005];
int f[1000005];

int cnt[1000005];
map<int, int> cur;
map<int, int>::iterator its;

LL pow2(LL a, LL b = mod-2){
    LL res = 1;
    while(b != 0){
        if(b%2 == 1) res = res*a%mod;
        a = a*a%mod;
        b/=2;
    }
    return res;
}

int main(){
    for(int i=0;i<=1000000;i++) prime[i] = 1;
    prime[0] = prime[1] = 0;
    for(int i=2;i*i<=1000000;i++){
        if(prime[i]){
            for(int j=i*i;j<=1000000;j+=i){
                prime[j] = 0;
                if(f[j] == 0) f[j] = i;
            }
        }
    }
    for(int i=2;i<=1000000;i++) if(f[i] == 0) f[i] = i;
    int n;
    scanf("%d", &n);

    for(int i=1;i<=n;i++){
        scanf("%d", &a[i]);
        int x = a[i];

        cur.clear();
        while(x != 1){
            cur[f[x]]++;
            x/=f[x];
        }

        for(its = cur.begin();its != cur.end();its++){
            cnt[its->first] = max(cnt[its->first], its->second);
        }
    }   

    LL mul = 1;
    for(int i=1;i<=1000000;i++){
        if(cnt[i] > 0) mul = mul*pow2(i, cnt[i])%mod;
    }
    LL ans = 0;
    for(int i=1;i<=n;i++) ans = (ans + mul*pow2(a[i]))%mod;
    printf("%lld\n", ans);
}

Measured memory_bytes: 8832
N,X = list(map(int,input().split()))

data = []
l_sum=0
for i in range(N):
    b,l,u = list(map(int,input().split()))
    data.append([b,l,u,(X-b)*u+b*l])
    l_sum+=b*l

if l_sum==0:
    print(0)
else:
    data=sorted(data,key=lambda x:x[3],reverse=True)
    
    S=[-l_sum]
    s=-l_sum
    for i in range(N):
        s += data[i][3]
        S.append(s)
    
    def judge(P):
    
        n=P//X
        p=P%X
    
        if S[n]>=0:
            return True
        else:
            new_list = []
            for i in range(N):
                if i>=n:
                    b,l,u,x = data[i]
                    if p>=b:
                        new_list.append(u*(p-b)+l*b)
                    else:
                        new_list.append(l*p)
                else:
                    b,l,u,x = data[i]
                    new_list.append(max(u*(p-X),l*p-u*X+b*(u-l))+data[n][3])
                    
            if S[n] + max(new_list)>=0:
                return True
            else:
                return False
    
    max_P=N*X
    
    def bisect(m,M):
        if M-m==1:
            return M
        else:
            if judge((m+M)//2):
                return bisect(m,(m+M)//2)
            else:
                return bisect((m+M)//2,M)
    
    print(bisect(0,max_P))

Measured memory_bytes: 110424
#include <iostream>
#include <bits/stdc++.h>
#define MAX_SIZE 2000000
#define INFTY 2000000000
using namespace std;

int H = 0;
int A[MAX_SIZE];

int left(int i) {
    return 2 * i;
}
int right(int i) {
    return 2 * i + 1;
}
int parent(int i) {
    return i / 2;
}

void maxHeapify(int i) {
    int largest = i;
    int l = left(i);
    int r = right(i);
    if (l <= H && A[l] > A[i]) {
        largest = l;
    } 
    if (r <= H && A[r] > A[largest]) {
        largest = r;
    }

    if (largest != i) {
        swap(A[i], A[largest]);
        maxHeapify(largest);
    }
}

void insert(int k) {
    H++;
    A[H] = k;
    int i = H;
    while (i > 1 && A[parent(i)] < A[i]) {
        swap(A[parent(i)], A[i]);
        i = parent(i);
    }
    return;
}


int extract() {
    int max = A[1];
    A[1] = A[H];
    H--;
    maxHeapify(1);
    return max;
}

int main(){
    int n, k;
    char cmd[10];
    cin >> n;
    while (1) {
        scanf("%s", cmd);
        if (cmd[0] == 'i') {
            scanf("%d\n", &k);
            insert(k);
        }
        else if (cmd[0] == 'e') {
            if (cmd[1] == 'x') {
                k = extract();
                printf("%d\n", k);
            } else {
                break;
            }
        }
    }
    return 0;
} 


Measured memory_bytes: 7036
#include <bits/stdc++.h>
#define chmin(a, b) ((a)=min((a), (b)))
#define chmax(a, b) ((a)=max((a), (b)))
#define fs first
#define sc second
#define eb emplace_back
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;

const ll MOD=1e9+7;
const ll INF=1e18;

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

int main(){
    int n; cin>>n;
    string a, b, c; cin>>a>>b>>c;

    int ans=0;
    for(int i=0; i<n; i++){
        if(a[i]==b[i] && b[i]==c[i]);
        else if(a[i]!=b[i] && b[i]!=c[i] && c[i]!=a[i]) ans+=2;
        else ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

/**
 * Geometric Data
 */
public class Main {

	static final int BASE = 1009;

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		int[] p = new int[3];
		Set<Long> set = new HashSet<>();
		int count = 0;

		for (int i = 0; i < N; i++) {
			p[0] = sc.nextInt();
			p[1] = sc.nextInt();
			p[2] = sc.nextInt();

			Arrays.sort(p);

			long hash = 0;
			hash += p[0] * BASE * BASE;
			hash += p[1] * BASE;
			hash += p[2];

			if (set.contains(hash)) {
				count++;
				continue;
			}

			set.add(hash);
		}

		System.out.println(count);
	}
}



Measured memory_bytes: 35280
import java.io.*;
import java.util.*;
class Main{
	static final long MOD = 1_000_000_007; // 10^9+7
    static final int MAX = 2_147_483_646; // intMax 
    static final int INF = 1_000_000_000; // 10^9  
    public static void main(String[] args) throws Exception {
		hayami saori = new hayami();
		int a = saori.saori_hayami();
		int b = saori.saori_hayami();
		int c = saori.saori_hayami();
		if(a == b && b == c){
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
		
		saori.close();
    }
}

class hayami implements Closeable {
	private final InputStream in = System.in;
	private final byte[] hayami = new byte[1024];
	private int Hayami = 0;
	private int saori = 0;
	private boolean HayamiSaori() {
		if (Hayami < saori) {
			return true;
		}else{
			Hayami = 0;
			try {
				saori = in.read(hayami);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (saori <= 0) {
				return false;
			}
		}
		return true;
	}
	private int SaoriHayami() { 
		if (HayamiSaori()) {
            return hayami[Hayami++];
         }else{
             return -1;
         }
	}
	private static boolean hayami_saori(int hayami) { 
		return 33 <= hayami && hayami <= 126;
	}
	public boolean hayamisaori() { 
		while(HayamiSaori() && !hayami_saori(hayami[Hayami])) Hayami++; return HayamiSaori();
	}
	public String nextHayami() {
		if (!hayamisaori()) throw new NoSuchElementException();
		StringBuilder hayamin = new StringBuilder();
		int saori = SaoriHayami();
		while(hayami_saori(saori)) {
			hayamin.appendCodePoint(saori);
			saori = SaoriHayami();
		}
		return hayamin.toString();
	}
	public long saorihayami() {//nextLong
		if (!hayamisaori()) throw new NoSuchElementException();
		long hayami = 0;
		boolean misao = false;
		int saori = SaoriHayami();
		if (saori == '-') {
			misao = true;
			saori = SaoriHayami();
		}
		if (saori < '0' || '9' < saori) {
			throw new NumberFormatException();
		}
		while(true){
			if ('0' <= saori && saori <= '9') {
				hayami *= 10;
				hayami += saori - '0';
			}else if(saori == -1 || !hayami_saori(saori)){
				return misao ? -hayami : hayami;
			}else{
				throw new NumberFormatException();
			}
			saori = SaoriHayami();
		}
	}
	public int saori_hayami() {//nextInt
		long hayami = saorihayami();
		if (hayami < Integer.MIN_VALUE || hayami > Integer.MAX_VALUE) throw new NumberFormatException();
		return (int) hayami;
	}
	public double Hayamin() { //nextDouble
		return Double.parseDouble(nextHayami());
	}
	public void close() {
		try {
			in.close();
		} catch (IOException e) {
		}
    }
    
}

Measured memory_bytes: 21076
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cstring>
#include <string>
#include <cstdlib>
#include <iomanip>
#include <cmath>
using namespace std;

int main(){
    int A, B;
    cin >> A >> B;
    for(int i=0; i<=1300; i++){
        int a = i * 0.08;
        int b = i * 0.1;
        if(A==a && B==b){
            cout << i;
            return 0;
        }
    }
    cout << -1;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
string S;
int64_t x, y, OFFSET = 8000;
const int MAXS = 8010;
bool DPx[MAXS][MAXS * 2]; // i回目の移動後、jに存在する確率
bool DPy[MAXS][MAXS * 2];

int main()
{
  cin >> S >> x >> y;
  vector<int> F, X, Y;
  int cnt = 0;
  for (int i = 0; i < S.size(); i++)
  {
    if (S[i] == 'T')
    {
      F.push_back(cnt);
      cnt = 0;
      continue;
    }
    cnt++;
  }
  F.push_back(cnt);
  for (int i = 0; i < F.size(); i++)
  {
    if (i % 2)
      Y.push_back(F[i]);
    else
      X.push_back(F[i]);
  }
  DPx[0][OFFSET] = 1, DPy[0][OFFSET] = 1;
  if (X.size())
    DPx[1][OFFSET + F[0]] = 1; // 1回目はx軸の正方向のみ
  for (int i = 1; i < X.size(); i++)
  {
    for (int j = 0; j < MAXS * 2; j++)
    {
      if (DPx[i][j])
      {
        DPx[i + 1][j + X[i]] = 1;
        DPx[i + 1][j - X[i]] = 1;
      }
    }
  }
  for (int i = 0; i < Y.size(); i++)
  {
    for (int j = 0; j < MAXS * 2; j++)
    {
      if (DPy[i][j])
      {
        DPy[i + 1][j + Y[i]] = 1;
        DPy[i + 1][j - Y[i]] = 1;
      }
    }
  }
  cout << ((DPx[X.size()][x + OFFSET] && DPy[Y.size()][y + OFFSET]) ? "Yes" : "No") << endl;
}


Measured memory_bytes: 35400
#include<cstdio>
#include<set>
#include<queue>
#include<deque>
#include<utility>
#include<cstring>
using namespace std;
using P = std::pair<int, int>;
int H, W, Ch, Cw, Dh, Dw;
unsigned block = 0;
const static int MAX_H = 1000, MAX_W = 1000;
bool is_road[MAX_H][MAX_W];
int x[4] = {-1, 0, 1, 0};
int y[4] = {0, -1, 0, 1};
int d[MAX_H][MAX_W];

bool is_inside_the_maze(int x, int y){
	return x >= 0 && x < H && y >= 0 && y < W;
}
void Bfs(P start) {
    int start_x = start.first, start_y = start.second;
	std::deque<pair<P, pair<unsigned, unsigned> > > next_vertex_to_visit;
	next_vertex_to_visit.push_front(std::make_pair(start, std::make_pair(0, 5)));
	while( !next_vertex_to_visit.empty() ) {
		P u = next_vertex_to_visit.front().first;
        unsigned type = next_vertex_to_visit.front().second.second, d_tmp = next_vertex_to_visit.front().second.first;
		next_vertex_to_visit.pop_front();
        if(d[u.first][u.second] >= 0) continue;
        d[u.first][u.second] = d_tmp;
        if(u.first == Dh && u.second == Dw) return;
		for (unsigned i = 0; i < 4; ++i){
			int next_x = u.first + x[i], next_y = u.second + y[i];
			if(is_inside_the_maze(next_x, next_y) && is_road[next_x][next_y] && d[next_x][next_y] < 0){
				next_vertex_to_visit.push_front(std::make_pair(std::make_pair(next_x, next_y), std::make_pair(d_tmp, i)));
			}
		}
        if(type == 0 || type == 2){
            int shift = x[type]*2;
            for (int i = -2; i < 3; i++){
                if(is_inside_the_maze(u.first + shift, u.second + i) && is_road[u.first + shift][u.second + i] && d[u.first + shift][u.second + i] < 0){
                    next_vertex_to_visit.push_back(std::make_pair(std::make_pair(u.first + shift, u.second + i), std::make_pair(d_tmp + 1, 5)));
                }
            }
        }else if(type == 1 || type == 3){
            int shift = y[type]*2;
            for (int i = -2; i < 3; i++){
                if(is_inside_the_maze(u.first + i, u.second + shift) && is_road[u.first + i][u.second + shift] && d[u.first + i][u.second + shift] < 0){
                    next_vertex_to_visit.push_back(std::make_pair(std::make_pair(u.first + i, u.second + shift), std::make_pair(d_tmp + 1, 5)));
                }
            }
        }else{
            for (int i = -2; i < 3; i++){
                for (int j = -2; j < 3; j++){
                    if(is_inside_the_maze(u.first + i, u.second + j) && is_road[u.first + i][u.second + j] && d[u.first + i][u.second + j] < 0){
                        next_vertex_to_visit.push_back(std::make_pair(std::make_pair(u.first + i, u.second + j), std::make_pair(d_tmp + 1, 5)));
                    }
                }
            }
        }
	}
}

int main(){
    scanf("%d %d\n%d %d\n%d %d", &H, &W, &Ch, &Cw, &Dh, &Dw);
    Ch--;Cw--;Dh--;Dw--;
    char tmp;
    for (int i = 0; i < H; i++){
        scanf("\n");
        for (int j = 0; j < W; j++){
            scanf("%c", &tmp);
            is_road[i][j] = tmp == '.';
        }
    }
    memset(d, -1, sizeof d);
    Bfs(make_pair(Ch, Cw));
    printf("%d\n", d[Dh][Dw]);
	return 0;
}

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

int main (){
    int d,n,a;
    scanf("%d %d",&d,&n);
    if(d ==0) a = 1;
    if(d ==1) a = 100;
    if(d ==2) a = 10000;

    if(n ==100) printf("%d",101*a);
        else printf("%d",a*n);
}

Measured memory_bytes: 128
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let n = read::<i64>();
    let mut ans;
    if n >= 10000 {
        ans = min(9 + 900 + n - 9999, 90909);
    } else if n >= 100 {
        ans = min(9 + n - 99, 909);
    } else {
        ans = min(n, 9);
    }
    println!("{}", ans);
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


Measured memory_bytes: 4352
from math import gcd


def eratosthenes(n):
    is_prime = [0, 0] + [1] * (n - 1)
    for i in range(int(n**0.5) + 1):
        if is_prime[i] == 0:
            continue
        for j in range(i * 2, n + 1, i):
            is_prime[j] = 0
    return [i for i, pi in enumerate(is_prime) if pi == 1]


def factorize(N):  # 素因数分解
    PRIME = set()
    for p in prime_list:
        if p * p > N:
            break
        while N % p == 0:
            N //= p
            PRIME.add(p)
    if N > 1:
        PRIME.add(N)
    return PRIME


n = int(input())
a = list(map(int, input().split()))

ans = 0
for ai in a:
    ans = gcd(ans, ai)
if ans != 1:
    print('not coprime')
    exit()

prime_list = eratosthenes(10 ** 6)
num = set()
for ai in a:
    prime = factorize(ai)
    if len(prime & num) > 0:
        print('setwise coprime')
        break
    num |= prime
else:
    print('pairwise coprime')


Measured memory_bytes: 196844
#include <bits/stdc++.h>
#define f first
#define s second
#define rep(i, l, r) for (long long i = (l); i < (r); i++)
#define repb(i, r, l) for (long long i = (r); i > (l); i--)
#define pb push_back
 
using namespace std;
typedef vector<long long> vl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector< pair<long long, long long> > vp;
typedef deque <long long> dq;
typedef long long int lli;
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull; 
const int MAX_CHAR=256;
 
 
ll gcd(ll x, ll y) {
    if (x < y) return gcd(y, x);
    if (y == 0) return x;
    return gcd(y, x % y);
} 
 
const ll mod = 1e9 + 7;
 
ll modexp(ll x, ll ex) {
    ll ans = 1ll;
    while (ex > 0) {
        if (ex & 1ll) ans = (ans * x) % mod;
        ex >>= 1ll;
        x = (x * x) % mod;
    }
    return ans;
} 
 
ll nCrModp(ll n, ll r, ll p) 
{ 
    ll C[r+1]; 
    memset(C, 0, sizeof(C)); 
  
    C[0] = 1; 
    for (ll i = 1; i <= n; i++) 
    { 
        for (ll j = min(i, r); j > 0; j--) 
            C[j] = (C[j] + C[j-1])%p; 
    } 
    return C[r]; 
}
 
bool isPrime(ll n) 
{ 
    if (n <= 1)  return false; 
    if (n <= 3)  return true;  
    if (n%2 == 0 || n%3 == 0) return false; 
  
    for (ll i=5; i*i<=n; i=i+6) 
        if (n%i == 0 || n%(i+2) == 0) 
           return false; 
  
    return true; 
} 

bool sortinrev(const pair<ll,string> &a,  
               const pair<ll,string> &b) 
{ 
       return (a.first > b.first); 
}
 
vl countFreq(ll arr[], ll n) 
{ 
    unordered_map<ll, ll> mp; 
    vector <ll> v;
    
    for (ll i = 0; i < n; i++) 
        mp[arr[i]]++; 
   
    for (auto x : mp) 
        v.pb(x.second);
    
    return v;
}
 
bool sortbysec(const pair<ll, ll>& a, 
               const pair<ll, ll>& b) 
{ 
    return (a.second < b.second); 
} 

ll binarySearch(ll arr[], ll l, ll r, ll x) 
{ 
    while (l <= r) 
    { 
        ll m = l + (r - l) / 2; 
        if (arr[m] == x) 
            return m; 
        if (arr[m] < x) 
            l = m + 1; 
        else
            r = m - 1; 
    }
    return -1; 
}

ll smallestDivisor(ll n) 
{ 
    if (n % 2 == 0) 
        return 2; 
  
    for (ll i = 3; i * i <= n; i += 2) { 
        if (n % i == 0) 
            return i; 
    } 
  
    return n; 
} 

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    ll t=1;
    // cin >> t;
    
    while(t--)
    {
        ll n,m;
        cin >> n >>m;
        ld m1=m*1.0;
        
        ld arr[n];
        rep(i,0,n)
            cin >> arr[i];
        
        ld sum=0.0;
        rep(i,0,n)
            sum+=arr[i];
        
        ld mi=sum/4.0;
        mi=mi/(m1);
        
        sort(arr,arr+n,greater<ld>());
        if(arr[m-1]<mi)
            cout << "No" << endl;
        else
            cout << "Yes" << endl;
    }
}


Measured memory_bytes: 256
import java.util.Scanner

object Main {
  def main(args: Array[String]): Unit = {
    //nextLineとnextを同時に使ったら死ぬ
    val sc = new Scanner(System.in)
    val n, k = sc.nextLong()

    if (k % 2L != 0L) {
      println(pow(n / k, 3))
    } else {
      val m = n / (k / 2)
      val max = (m + 1) / 2
      val min = m - max
      debug(max, min)
      println(pow(max, 3) + pow(min, 3))
    }
  }

  def debug(args: Any*): Unit = {
    Console.err.println(args.mkString(" "))
  }

  def pow(n: Long, x: Long): Long = {
    x match {
      case 0L              => 1L
      case 1L              => n
      case a if a % 2 == 0 => pow(n * n, x / 2)
      case a               => n * pow(n, x - 1)
    }
  }
}


Measured memory_bytes: 25912
s = input()
lst = [0 for _ in range(len(s))]

count = 0
num_lst = []
lr = "R"
for i in s:
    if i == lr:
        count += 1
    else:
        num_lst.append(count)
        count = 1
        lr = i
num_lst.append(count)

count = 0
for i, num in enumerate(num_lst):
    if i % 2 == 0:
        count += num
        lst[count - 1] += (num + 1) // 2
        lst[count] += num // 2
    else:
        lst[count - 1] += num // 2
        lst[count] += (num + 1) // 2
        count += num
for num in lst:
    print(num, end=" ")

Measured memory_bytes: 5616
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int maxn=2e5+5;
const int mod=998244353;
ll fac[maxn];
ll inv[maxn];
ll power(ll base,ll n)
{
    ll r=1;
    while(n)
    {
        if(n%2) r=r*base%mod;
        base=base*base%mod;
        n/=2;
    }
    return r;
}
void init()
{
    fac[0]=1;
    for(int i=1;i<maxn;i++)
    {
        fac[i]=fac[i-1]*i%mod;
    }
    inv[maxn-1]=power(fac[maxn-1],mod-2);
    for(int i=maxn-1;i>=1;i--)
    {
        inv[i-1]=inv[i]*i%mod;
    }
}
ll C(ll m,ll n)
{
    return fac[n]*inv[m]%mod*inv[n-m]%mod;
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n,m,k;
    cin>>n>>m>>k;
    ll ans=0;
    init();
    for(int i=0;i<=k;i++)
    {
        ans+=m*C(i,n-1)%mod*power(m-1,n-i-1)%mod;
        ans%=mod;
    }
    cout<<ans<<'\n';//

}


Measured memory_bytes: 6728
N = int(input())
D = [list(map(int, input().split())) for i in range(N)]
for i in range(N-2):
    if D[i][0] == D[i][1]:
        if D[i+1][0] == D[i+1][1] and D[i+2][0] == D[i+2][1]:
            print('Yes')
            exit()
print('No')

Measured memory_bytes: 9184
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>
#include <time.h>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = (1LL << 31) - 1;
const ll MOD = 1e9 + 7;

#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(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1
#define MAX_N 100100 * 3

int n, m, k;
double sum[100100];
double cntd[100100];

void solve(int num, int cnt) {
	if (cnt == n) {
		cntd[num]++;
		return;
	}
	FOR(i, 1, m + 1)solve(num + i, cnt + 1);
}

int main() {
	while (cin >> n >> m >> k&&n + m + k) {
		fill(sum, sum + 100100, 0);
		fill(cntd, cntd + 100100, 0);
		double t = pow(m, n);
		ll lb = n, ub = n*m;
		double num = 1;
		solve(0, 0);
		while (1) {
			//cout << lb << " " << ub << " ";
			//cout << num << endl;
			if (lb == ub) {
				if (lb > k)sum[lb] += cntd[lb];
				else sum[k + 1] += cntd[lb];
				break;
			}
			else {
				if (lb > ub)break;
				if (lb > k)sum[lb] += cntd[lb];
				else sum[k + 1] += cntd[lb];
				if (ub > k)sum[ub] += cntd[lb];
				else sum[k + 1] += cntd[lb];
			}
			lb++;
			ub--;
		}
		double ans = 0;
		REP(i, n*m + 1) {
			double num = i;
			//cout << i << " " << sum[i] << " " << sum[i] / t << endl;
			ans += (sum[i] / t)*(num - k);
		}
		printf("%.10lf\n", ans);
	}
}

Measured memory_bytes: 4748
n,k=map(int,input().split())
ans=0
for i in range(k+1,n+1):#iは割る数
  num=i-k#k以上のあまりの種類
  c=n//i
  ans+=num*c#(c-1)~0まであまりがk~i-1
  r=n%i
  if r<k:
    pass
  else:
    ans+=r-k+1
if k==0:
  print(ans-n)
  exit()
print(ans)

Measured memory_bytes: 3060
from collections import Counter
n=int(input())
V=list(map(int,input().split()))
A=V[::2]
B=V[1::2]
a=Counter(A)
b=Counter(B)
x=a.most_common(2)
y=b.most_common(2)
if x[0][0]!=y[0][0]:
  print((n//2-x[0][1])+(n//2-y[0][1]))
else:
  if len(x)>1 and len(y)>1:
    s=(n//2-x[0][1])+(n//2-y[1][1])
    t=(n//2-x[1][1])+(n//2-y[0][1])
    print(min(s,t))
  elif len(x)>1:
    print(n//2-x[1][1])
  elif len(y)>1:
    print(n//2-y[1][1])
  else:
    print(n//2)

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

#define ll long long
#define ull unsigned long long
#define vi vector<ll>
#define pp pair<ll,ll>
#define mp make_pair
#define all(v) v.begin(),v.end()
#define pb push_back
#define FOR(i,a,b) for(i=a;i<b;i++)
#define FREV(i,a,b) for(i=a;i>=b;i--)
#define DEBUG(x) cerr<<"In file "<< __FILE__ <<" at line "<< __LINE__ <<" :: "<< #x <<" = "<<x<<endl
#define S(n) scanf("%lld", &n)

using namespace std;

int main() {
    int n,m,i;
    cin >> n >> m;
    vector<int> a(n);
    FOR(i,0,n) cin >> a[i];
    vector<pair<int, int>>bc(m);
    FOR(i,0,m) cin >> bc[i].second >> bc[i].first;
    sort(all(a));
    sort(all(bc));
    int cur_size = 0;
    int pointer = m-1;
    int limit;
    vector<ull> bc_v(n);
    while (cur_size < n and pointer >= 0) {
        if (cur_size + bc[pointer].second > n) {
            limit = n-cur_size;
        }
        else {
            limit = bc[pointer].second;
        }
        FOR(i,0,limit) {
            bc_v[cur_size+i] = bc[pointer].first;
        }
        cur_size += bc[pointer].second;
        pointer--;
    }

    ull ans=0;
    FOR(i,0,n) {
        ans += (bc_v[i] > a[i])? bc_v[i] : a[i];

    }
    cout << ans;
    return 0;
}

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

typedef long long ll;

const ll mod=1e9+7;
ll dp[405][405]={0};
ll rpow[405][405]={0};
ll lb[405],rb[405];

int main(){
  ll n,c;
  cin>>n>>c;
  dp[0][0]=1;
  for(int i=0;i<405;i++) rpow[i][0]=1;
  for(int i=0;i<405;i++){
    for(int j=1;j<405;j++){
      rpow[i][j]=(rpow[i][j-1]*i)%mod;
    }
  }
  for(int i=1;i<405;i++){
    for(int j=0;j<405;j++){
      rpow[i][j]+=rpow[i-1][j];
      rpow[i][j]%=mod;
    }
  }
  for(int i=0;i<n;i++) cin>>lb[i];
  for(int i=0;i<n;i++) cin>>rb[i];
  for(int i=0;i<n;i++){
    for(int j=0;j<=c;j++){
      for(int k=0;j+k<=c;k++){
        dp[i+1][j+k]+=dp[i][j]*(rpow[rb[i]][k]-rpow[lb[i]-1][k]+mod);
        dp[i+1][j+k]%=mod;
      }
    }
  }
  cout<<dp[n][c]<<'\n';
}

Measured memory_bytes: 2816
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author tatsumack
 */

#include <iostream>
#include <fstream>

#include <iostream>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>

#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <queue>
#include <unordered_map>
#include <unordered_set>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(12)

using namespace std;

typedef pair<int, int> P;

class BIronBarCutting {
public:
    static constexpr int kStressIterations = 0;
    static void generateTest(std::ostream& test) {
    }

    void solve(std::istream& cin, std::ostream& cout) {
        int N;
        cin >> N;
        vector<int> A(N);

        int sum = 0;
        REP(i, N) {
            cin >> A[i];
            sum += A[i];
        }

        double half = (double) sum / 2;
        int tmp = 0;
        int target = -1;
        REP(i, N) {
            tmp += A[i];
            if (tmp >= half) {
                target = i;
                break;
            }
        }

        int res = min(abs(sum - tmp - tmp), abs(tmp - A[target] - (sum - (tmp - A[target]))));
        cout << res << endl;
    }
};


signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    std::istream& in(std::cin);
    std::ostream& out(std::cout);

    BIronBarCutting solver;
    solver.solve(in, out);
    return 0;
}


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

using namespace std;

int main()
{
    int a,b,c,x;
    cin >> a >> b >> c >> x ;

    int cnt=0;
    for(int i=0; i <= a; i++){
        for(int j=0; j<=b; j++){
            for(int k=0; k<=c; k++){
                if(500*i+100*j+50*k == x) cnt++;
            }
        }
    }

    cout << cnt << endl;

}

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

typedef long long ll;

const ll INF = 1ll << 60;
const int MAX_N = 100000;

ll A[MAX_N], D[MAX_N];
ll stops[MAX_N];

int main() {
	ll N, T, Q;
	cin >> N >> T >> Q;

	ll s = -INF;
	cin >> A[0] >> D[0];
	if (D[0] == 2) stops[0] = s;
	else stops[0] = INF;

	for (int i = 1; i < N; i++) {
		cin >> A[i] >> D[i];

		if (D[i - 1] == 1 && D[i] == 2) {
			s = (A[i] + A[i - 1]) / 2;

			for (int j = i - 1; j >= 0 && D[j] == 1; j--)
				stops[j] = s;
		}
		
		if (D[i] == 2) stops[i] = s;
		else stops[i] = INF;
	}

	for (int i = 0; i < Q; i++) {
		ll x;
		cin >> x;
		x--;
		ll ans;
		if (D[x] == 1) ans = min(A[x] + T, stops[x]);
		else ans = max(A[x] - T, stops[x]);
		cout << ans << endl;
	}
}

Measured memory_bytes: 5392
def input_int():
    return map(int, input().split())

def one_int():
    return int(input())

def one_str():
    return input()

def many_int():
    return list(map(int, input().split()))



K=one_int()
A,B=many_int()

flg=False
for i in range(A,B+1):
    if i%K==0:
        flg=True
if flg:
    print("OK")
else:
    print("NG")

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

int N;
string S;

void solve() {
    cin >> N >> S;
    S.push_back('#');
    int ans = 0;
    for(int i = 0; i + 1 < S.size(); i++) {
        if(S[i] != S[i+1]) ans++;
    }
    cout << ans;
    return;
}

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


Measured memory_bytes: 512
n=int(input())
if n<10: print(n); exit()
l=[[[] for _ in range(10)] for _ in range(10)]
l[0]=[[i] for i in range(10)]
c=9
for i in range(9):
  for j in range(10):
    for k in (-1,0,1):
      if 0<=j+k<=9:
        for h in l[i][j+k]:
          if j: c+=1
          t=j*10**(i+1)+h
          l[i+1][j]+=[t]
          if c==n: print(t); exit()

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

using namespace std;
int main(void){
  int row,column,colsum=0,rowsum=0;
  cin>>row>>column;
  row++;column++;
  vector<vector<int>> vec(row,vector<int>(column));

  for(int i=0;i<row-1;i++){
    colsum=0;
    for(int j=0;j<column;j++){
      if(j==column-1) vec.at(i).at(j)=colsum;
        else{
          cin>>vec.at(i).at(j);
          colsum+=vec.at(i).at(j);
      }
    }
  }
  for(int j=0;j<column;j++){
    rowsum=0;
    for(int i=0;i<row-1;i++){
      rowsum+=vec.at(i).at(j);
    }
    vec.at(row-1).at(j)=rowsum;
  }

  for(int i=0;i<row;i++){
    for(int j=0;j<column;j++){
      if(j==column-1){
        cout<<vec.at(i).at(j);
        continue;
      }
      cout<<vec.at(i).at(j)<<" ";
    }
    cout<<endl;
  }
  return 0;
}



Measured memory_bytes: 3056
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORS(i, m, n) for (int i = m; i <= n; i++)
#define BIT(n) (1LL << (n))
#define INF 2e9
#define MOD (1000000007)
#define EPS 1e-9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long long int lli;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector< vector< pair< int, int > > > count(
      2, vector< pair< int, int > >(100001));
  REP(i, 100001) {
    count[0][i] = make_pair(0, i);
    count[1][i] = make_pair(0, i);
  }
  REP(i, n) {
    int p;
    cin >> p;
    count[i % 2][p].first++;
  }
  sort(ALL(count[0]));
  sort(ALL(count[1]));

  reverse(ALL(count[0]));
  reverse(ALL(count[1]));

  int a0 = count[0][0].first;
  int a1 = count[1][0].first;
  int v0 = count[0][0].second;
  int v1 = count[1][0].second;

  if (v0 == v1) {
    int val = max(a0 + count[1][1].first, a1 + count[0][1].first);
    cout << n - val << "\n";
  } else {
    cout << n - a0 - a1 << "\n";
  }
}

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

typedef long long ll;
 
int main(){
  int n;
  cin >> n;
  int s[n];
  int ans=0;
  for(int i=0; i<n; i++){
    cin >> s[i];
    ans += s[i];
  }
  if(ans%10!=0){
    cout << ans << endl;
    return 0;
  }
  sort(s, s+n);
  for(int i=0; i<n; i++){
    if(s[i]%10!=0){
      ans -= s[i];
      break;
    }
  }
  if(ans%10==0) ans = 0;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int maxn=1e3+5;
char buff[maxn][maxn];
int dp[maxn][maxn];
int tag[maxn][maxn];
int cnt=0;
int n,m;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
void bfs(int y,int x) {
	queue<pii> Q;tag[y][x]=++cnt;
	Q.push({y,x});
	while(!Q.empty()) {
		auto tem=Q.front();Q.pop();
		for(int i=0;i<4;i++) {
			int nx=tem.second+dx[i],ny=tem.first+dy[i];
			if(nx>=1&&nx<=m&&ny>=1&&ny<=n&&buff[ny][nx]=='.'&&!tag[ny][nx]) {
				tag[ny][nx]=cnt;
				Q.push({ny,nx});
			}
		}
	}
}

const int MAXN=1000005;
const int MAXM=5000005;
struct EDGE{
    int nex,to;
    ll w;
}edge[MAXM];
int ecnt,head[MAXN];
inline void addedge(int u,int v,ll weight){
    edge[++ecnt].nex=head[u];head[u]=ecnt;
    edge[ecnt].to=v;edge[ecnt].w=weight;
}
ll dis[MAXN];
bool spsa(int s){
    queue <int> Q;
    Q.push(s);
    while (!Q.empty()){
    	int u=Q.front();Q.pop();
    	for(int i=head[u];i;i=edge[i].nex) {
    		int v=edge[i].to;if(dis[v]) continue;
    		dis[v]=dis[u]+1;
    		Q.push(v);
    	}
    }
    return 0;
}

map<pii,int> M;
int main() {
    cin>>n>>m;
    int sy,sx,dy,dx;cin>>sy>>sx>>dy>>dx;
    for(int i=1;i<=n;i++) cin>>(buff[i]+1);

    for(int i=1;i<=n;i++) 
    	for(int j=1;j<=m;j++) 
    		if(!tag[i][j]&&buff[i][j]=='.') 
    			bfs(i,j);

    for(int i=1;i<=n;i++) {
    	for(int j=1;j<=m;j++) {
    		if(tag[i][j])
    		for(int a=-2;a<=2;a++) {
    			for(int b=-2;b<=2;b++) {
    				int ny=i+a,nx=j+b;
    				if(ny>=1&&ny<=n&&nx>=1&&nx<=m&&tag[ny][nx]&&tag[i][j]!=tag[ny][nx]) {
    					addedge(tag[ny][nx],tag[i][j],1);
    					addedge(tag[i][j],tag[ny][nx],1);
    				}
    			}
    		}
    	}
    }

    spsa(tag[sy][sx]);
    if(dis[tag[dy][dx]]==0&&tag[dy][dx]!=tag[sy][sx]) cout<<-1<<endl;
    else cout<<dis[tag[dy][dx]]<<endl;

    return 0;
}


Measured memory_bytes: 67900