akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

class Main{

	public static void main(String[] args) {



		Scanner scanner = new Scanner(System.in);
		int N = scanner.nextInt();
		int t = scanner.nextInt();
		int ans = N -t;
		if(ans  < 0){
			System.out.println(0);
		}else{
			System.out.println(N-t);
		
		}
	}


}

class Pair implements Comparable{
	int from;
	int middle;
	int end;
	@Override
	public int compareTo(Object other) {
		Pair otherpair = (Pair)other;

		return end - otherpair.end;
	}
}





Measured memory_bytes: 21460
a = gets.chomp.split('')
b = gets.chomp.split('')
c = gets.chomp.split('')

def fin(x)
  puts x
  exit
end

t = 'a'
loop do
  case t
  when 'a'
    fin('A') if a.empty?
    t = a.shift
  when 'b'
    fin('B') if b.empty?
    t = b.shift
  when 'c'
    fin('C') if c.empty?
    t = c.shift
  end
end

Measured memory_bytes: 1788
# -*- coding: utf-8 -*-
import sys

def prime_list(n):
    l = range(2,n+1)
    i = 2
    while i * i <= n: 
        l = filter(lambda x: x == i or x % i != 0, l)
        i = i + 1
    return l

def mark(s, x):
    for i in xrange(x + x, len(s), x):
        s[i] = False

def sieve(n):
    s = [True] * n
    for x in xrange(2, int(n**0.5) + 1):
        if s[x]: mark(s, x)
    return [i for i in xrange(0,n) if s[i] and i > 1]

if __name__ == '__main__':
    l = sieve(999999)
    for line in sys.stdin:
        n = int(line)
        print len([x for x in l if x <= n])

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

int main() {
	ll X;
 	cin>>X;
  
  	ll yokin=100;
  	ll nen=0;
  while(yokin<X){
  	nen++;
    yokin+=(yokin*0.01); 
  }
  
  cout<<nen<<endl;
 
  
  
}

Measured memory_bytes: 3644
s=input()
l=len(s)
mod = pow(10,9)+7

dp = [[0 for _ in range(13)] for _ in range(l+1)]
dp[0][0] = 1
keta = 1

for i in range(1,l+1):
	num = s[-i]
	if num == '?':
		for j in range(10):
			for k in range(13):
				dp[i][(j * keta + k) % 13] += dp[i-1][k] % mod
	else:
		num = int(num)
		for k in range(13):
			dp[i][(num * keta + k) % 13] += dp[i-1][k] % mod
	keta = keta*10  % 13
print(dp[l][5] % mod)

Measured memory_bytes: 66268
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<functional>
#include<queue>
#include<map>
#include<limits>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<utility>
#include<complex>
#include<cstdlib>
#include<set>
#include<cctype>

#define DBG cerr << '!' << endl;
#define REP(i,n) for(int (i) = (0);(i) < (n);++i)
#define rep(i,s,g) for(int (i) = (s);(i) < (g);++i)
#define rrep(i,s,g) for(int (i) = (s);i >= (g);--(i))
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int i = 0;i < (n);i++)cerr << v[i] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()

using namespace std;

typedef long long ll;
typedef vector<int> iv;
typedef vector<iv> iiv;
typedef vector<string> sv;

int main()
{
	int n;
	cin >> n;
	
	cout << n*800 - (n/15)*200 << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<algorithm>
#include<vector>
#include<queue>
#include<cstring>
#include<cmath>
#include<memory.h>
#include<set>
#include<sstream>
#include<map>
using namespace std ;
#define ll long long 
#define all(x) x.begin() , x.end()
#define pb push_back
const int N = 3e5+19;
int n;
ll v[N] ;
vector<int>team[N];
bool vis[N];
int main(){
  //  freopen("input.txt","r",stdin);
    scanf("%d",&n);
    for(int i=0;i<3*n;++i)
    {
    	scanf("%lld",v+i);
    }
   sort(v,v+(3*n));
   reverse(v,v+(3*n));
   ll an = 0 , cnt = 0 ; 
   for (int i = 0; i < 3 * n ; ++i)
   {
   	/* code */ 
      if((i+1)%2==0 && cnt < n){ an+=v[i]; ++cnt;}
   }
   printf("%lld",an);
 }

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

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

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

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int main(){
    int n, m;
    cin >> n >> m;
    vector<vector<bool>> g(n, vector<bool>(n));
    rep(i, m) {
        int a, b;
        cin >> a >> b;
        --a; --b;
        g[a][b] = g[b][a] = true;
    }
    vi b(n);
    rep(i, n) b[i] = i;
    ll ans = 0;
    do {
        bool ok = true;
        rep(i, n-1) {
            if (!g[b[i]][b[i+1]]) ok = false;
        }
        if (ok) ++ans;
    } while (next_permutation(b.begin()+1, b.end()));
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import itertools
 
N, M, X = (int(v) for v in input().split())
c = [0]*N
a = [0]*N
 
for i in range(N):
    items = [int(v) for v in input().split()]
    c[i] = items[0]
    a[i] = items[1:]

# bit 探索
coin = list(itertools.product([0,1], repeat=N))
ans_cost = -1

for i in range(len(coin)):
    score = [0] * M
    for j in range(N):
        if coin[i][j] == 1:
            for k in range(M):
                score[k] += a[j][k]
    if min(score) >= X:
        cost = 0
        for l in range(N):
            cost += coin[i][l] * c[l]
        if (ans_cost == -1) | (cost < ans_cost):
            ans_cost = cost

print(ans_cost)



Measured memory_bytes: 9524
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
string s;
int main()
{
	cin>>s;
	int len=s.size();
	for(int i=0;i<len;i++)
	{
		if(s[i]=='b'&&s[len-i-1]=='d') continue;
		if(s[i]=='d'&&s[len-i-1]=='b') continue;
		if(s[i]=='p'&&s[len-i-1]=='q') continue;
		if(s[i]=='q'&&s[len-i-1]=='p') continue;
		cout<<"No";
		return 0;
	}
	cout<<"Yes";
	return 0;
} 

Measured memory_bytes: 512
#include <stdint.h>
#include <algorithm>
#include <bitset>
#include <functional>
#include <iostream>
#include <string>
#include <vector>

int main(int argc, char *argv[]) {
  using namespace std;
  int64_t a, b, c;
  cin >> a >> b >> c;
  int64_t ans = 0;
  if ((a * b * c) & 1) {
    ans = min(a * b, min(b * c, c * a));
  } else {
    ans = 0;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
import java.lang.Math;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next()); //switch
        int m = Integer.parseInt(sc.next()); // light
        int b[] = new int[m];
        for(int i=0;i<m;i++){
            int k = Integer.parseInt(sc.next());
            for(int j=0;j<k;j++){
                int l = Integer.parseInt(sc.next());
                b[i] += Math.pow(2,l-1);      
            }
        }
        int p[] = new int[m];
        for(int j=0;j<m;j++){
            p[j] = Integer.parseInt(sc.next());
        }
        int all=0;
        int count = 0;
        for(int i=0;i<Math.pow(2,n);i++){
            for(int j=0;j<m;j++){
                int a = b[j] & i;
                int sum=0;
                for(int k=0;k<n;k++){
                    if((a & 1) == 1){
                        sum++;
                    }
                    a /= 2;
                }
                if(p[j] != sum%2){
                    break;
                }
                count++;
            }
            if(count==m){
                all++;
            }
            count = 0;
        }
        System.out.println(all);
        sc.close();
    }
}

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

using namespace std;
using LL = long long;

const int MOD = 1e9+7;

class Edge{
public:
    LL from,to, value;
    Edge(int f,int t, int c){
        from = f;
        to = t;
        value = c;
    }
};

class SegmentTreeRSQ {
private:
    int n;
    vector<LL> node, lazy;

public:
    void init(vector<LL> v) {
        int sz = (int)v.size();
        n = 1; while(n < sz) n *= 2;
        node.resize(2*n-1);
        lazy.resize(2*n-1, 0);

        for(int i=0; i<sz; i++) node[i+n-1] = v[i];
        for(int i=n-2; i>=0; i--) node[i] = node[i*2+1] + node[i*2+2];
    }

    void eval(int k, int l, int r) {
        if(lazy[k] != 0) {
            node[k] += lazy[k];
            if(r - l > 1) {
                lazy[2*k+1] += lazy[k] / 2;
                lazy[2*k+2] += lazy[k] / 2;
            }
            lazy[k] = 0;
        }
    }

    void add(int a, int b, LL x, int k=0, int l=0, int r=-1) {
        if(r < 0) r = n;
        eval(k, l, r);
        if(b <= l || r <= a) return;
        if(a <= l && r <= b) {
            lazy[k] += (r - l) * x;
            eval(k, l, r);
        }
        else {
            add(a, b, x, 2*k+1, l, (l+r)/2);
            add(a, b, x, 2*k+2, (l+r)/2, r);
            node[k] = node[2*k+1] + node[2*k+2];
        }
    }

   LL getsum(int a, int b, int k=0, int l=0, int r=-1) {
        if(r < 0) r = n;
        eval(k, l, r);
        if(b <= l || r <= a) return 0;
        if(a <= l && r <= b) return node[k];
        LL vl = getsum(a, b, 2*k+1, l, (l+r)/2);
        LL vr = getsum(a, b, 2*k+2, (l+r)/2, r);
        return vl + vr;
    }
};

int main(){
    int N,C;cin >> N >> C;
    SegmentTreeRSQ Seg;
    Seg.init(vector<LL>(1e5+1));
    for(int i = 0;i < N;i++){
        int s,t;cin >>s >> t;
        s--,t--;
        int c;cin >> c;
        Seg.add(s, t+1, (1 << c));
    }
    int ans = 0;
    for(int i = 0;i < 1e5+10;i++){
        //if(i <= 10)cout<<bitset<60>(Seg.getsum(i, i+1))<<endl;
        ans = max((int)bitset<60>(Seg.getsum(i, i+1)).count(), ans);
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 6384
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <limits.h>
#include <algorithm>
using namespace std;

int main(){
  long long int A, B, C, box, count = 0, ans = 1;
  cin >> A >> B >> C ;
  box = C - A - B ;
  if(box < 0) ans = 0 ;
  box *= box ;
  if((4 * A * B) >= box) ans = 0 ;
  
  if(ans){
    cout << "Yes" << endl ;
  }  
  else{
    cout << "No" << endl ;
  }  
  return 0 ;
}

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

  
int main() {
 int N ;
  cin >> N;
  vector<int> A(N);
  for (int i=0;i<N;i++){
	cin >> A[i];
    
  }
  bool f =true;
 for (int i=0;i<N;i++){
   if(A[i]%2 ==  0 &&A[i]%3 !=0 && A[i] %5  != 0){
   // f =false; 
     puts("DENIED");
     return 0;
   }
  }
    //if(f){
      puts("APPROVED");
        return 0;
    //}
    //else{ 
       //   puts("DENIED");
     // }
     // cout<<endl;
}

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

#define sqr(A) ((A) * (A))
#define F first
#define S second
#define mp make_pair
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
const int MOD = 1e9 + 7;
const int INF = INT_MAX;
const ll LINF = LLONG_MAX;

const int N = 1e5 + 20;
int a[N], n, l;

int main() {
	ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	cin >> n >> l;
	for (int i = 1; i <= n; i++)
		cin >> a[i];
	int idx = -1;
	for (int i = 1; i < n; i++)
		if (a[i] + a[i + 1] >= l) {
			idx = i;
			break;
		}
	if (idx == -1)
		return cout << "Impossible" << endl, 0;
	cout << "Possible" << endl;
	for (int i = 1; i < idx; i++)
		cout << i << endl;
	for (int i = n - 1; i > idx; i--)
		cout << i << endl;
	cout << idx << endl;
}

Measured memory_bytes: 1280
#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <algorithm>
const int mod=1e9+7;
using LL=long long;
using std::cout;using std::endl;using std::cin;
using std::vector;using std::string;using std::set;using std::multiset;
using std::pair;using std::map;
using std::min;using std::max;
using std::make_pair;using std::swap;
std::ostream& operator<<(std::ostream& os,std::map<int,int>& obj){for(std::map<int,int>::iterator itr=obj.begin();itr!=obj.end();itr++){os<<itr->first<<"^"<<itr->second<<" ";}return os;}
std::ostream& operator<<(std::ostream& os,std::vector<std::map<int,int>>& obj){for(auto itr=obj.begin();itr!=obj.end();itr++){os<<*itr<<std::endl;}return os;}
std::ostream& operator<<(std::ostream& os,std::vector<int>& obj){for(auto itr=obj.begin();itr!=obj.end();itr++){os<<*itr<<" ";}return os;}

namespace ndifix{
template<class T> void sort(T &v){std::sort(v.begin(),v.end());}
}
std::ostream& operator<<(std::ostream& os,std::vector<std::vector<int>>& obj){
  for(auto itr=obj.begin();itr!=obj.end();itr++){
    os<<*itr<<std::endl;
    }
  return os;
}

int main(){
  int h,w;cin>>h>>w;
  vector<string> s(h);for(int i=0;i<h;i++)cin>>s[i];

  vector<vector<int>> hori(h,vector<int>(w)),vert(h,vector<int>(w));

  for(int i=0;i<h;i++){
  for(int j=0;j<w;j++){
    if(s[i][j]=='#')hori[i][j]=0;
    else if(j==0)hori[i][0]=1;
    else hori[i][j]=hori[i][j-1]+1;
  }}
  for(int j=0;j<w;j++){
  for(int i=0;i<h;i++){
    if(s[i][j]=='#')vert[i][j]=0;
    else if(i==0)vert[i][j]=1;
    else vert[i][j]=vert[i-1][j]+1;
  }}
  for(int i=0;i<h;i++){
  for(int j=w-2;j>=0;j--){
    if(hori[i][j]!=0 && hori[i][j+1]!=0)hori[i][j]=hori[i][j+1];
  }}
  for(int j=0;j<w;j++){
  for(int i=h-2;i>=0;i--){
    if(vert[i][j]!=0 && vert[i+1][j]!=0)vert[i][j]=vert[i+1][j];
  }}
//cout<<hori<<endl;
//cout<<vert<<endl;
  int ans=0;
  for(int i=0;i<h;i++){
  for(int j=0;j<w;j++){
    if(s[i][j]=='#')continue;
    ans = max(ans, hori[i][j]+vert[i][j]);
  }}

  cout<<ans-1<<endl;
  return 0;
}


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

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define inf 1e18
#define ceill(a, b) (a+b-1)/b
#define ok cout << "ok" << endl;
#define sp << " " <<
ll mod = 1e9+7;
void ans(bool b, ostream& out=cout){ out << (b ? "Yes" : "No") << endl; }
void ans2(bool b, ostream& out=cout){ out << (b ? "YES" : "NO") << endl; }
template<typename T> inline bool chmax(T &a, T b){ if(a<b) a=b; return a<b; }
template<typename T> inline bool chmin(T &a, T b){ if(b<a) a=b; return b<a; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val){fill((T*)array, (T*)(array+N), val);}
int dx[] = {1, 0, -1, 0, 1, -1, 1, -1};
int dy[] = {0, 1, 0, -1, 1, -1, -1, 1};

#ifndef INCLUDE_DEBUG_HPP
#define INCLUDE_DEBUG_HPP

class debug
{
public:
    template<typename T> void vdeb(T vec);
    template<typename T1, typename T2> void adeb(T1 *arr, T2 n);
    template<typename T> void mdeb(T mp);
};

#endif //INCLUDE_DEBUG_HPP

template<typename T> void debug::vdeb(T vec)
{
    cout << "#vector set debug" << endl;
    for(auto vv : vec) cout << vv << " ";
    cout << endl;
}

template<typename T1, typename T2> void debug::adeb(T1 *arr, T2 n)
{
    cout << "#adebug" << endl;
    for(int i=0; i<=n; i++) cout << arr[i] << " ";
    cout << endl;
}

template<typename T> void debug::mdeb(T mp)
{
    cout << "#map pair debug" << endl;
    for(auto const& m : mp) cout << m.first sp m.second << endl;
}
debug dbg;

class ATaskSchedulingProblem {
public:
	void solve(std::istream& in, std::ostream& out)
	{
	    int a;
	    vector<int> v;
	    for(int i=0; i<3; i++){
	        in >> a;
	        v.push_back(a);
	    }

	    sort(v.begin(), v.end());
	    out << v[2]-v[0] << endl;
	}
};


int main() {
	ATaskSchedulingProblem solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
def read_input():
    n = int(input())
    tlist = list(map(int, input().split()))
    m = int(input())

    drinks = []
    for i in range(m):
        p, x = map(int, input().split())
        drinks.append((p, x))

    return n, tlist, drinks


def submit():
    n, tlist, drinks = read_input()

    original_time = sum(tlist)

    for drink in drinks:
        diff = tlist[drink[0] - 1] - drink[1]
        print(original_time - diff)



if __name__ == '__main__':
    submit()


Measured memory_bytes: 38384
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>

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

using namespace std;
#define int long long
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repr(i,n) for(ll i=n;i>=0;i--)
#define P pair<ll, ll>
#define sz(x) (ll)x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define VE vector<ll>
#define COUT(x) cout<<(x)<<endl
#define MA map<ll,ll>
#define SE set<ll>
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,VE,greater<ll>>
#define COUT(x) cout<<(x)<<endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define EPS (1e-10)


const long long MOD = 1000000007;
//const long long MOD = 998244353;
const long long INF = 1LL << 60;


long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	unsigned r;
	while ((r = a % b)) {
		a = b;
		b = r;
	}
	return b;
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a * g / b;
}
bool prime(ll n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}




const long double PI = 3.14159265359;
const int MAX_N = 100010;

int n, a, b, c;
int l[10];

int dfs(int now, int sa, int sb, int sc) {
	if (now == n) {
		if (min({ sa,sb,sc }) > 0)return abs(sa - a) + abs(sb - b) + abs(sc - c) - 30;
		else return INF;
	}
	return min({ dfs(now + 1,sa,sb,sc),dfs(now + 1,sa + l[now],sb,sc) + 10,dfs(now + 1,sa,sb + l[now],sc) + 10,dfs(now + 1,sa,sb,sc + l[now]) + 10 });
}

signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cin >> n >> a >> b >> c;
	rep(i, n)cin >> l[i];
	cout << dfs(0, 0, 0, 0) << endl;
	return 0;
}

Measured memory_bytes: 256
n = int(input())
t = []
ans = []
for i in range(n-1):
    t.append(list(map(int, input().split())))
    tmp = t[i]
    ans.append(tmp[0]+tmp[1])
    for j in range(i):
        if ans[j] > tmp[1]:
            if ans[j] % tmp[2] != 0:
                ans[j] = ans[j] + tmp[2] - (ans[j] % tmp[2])
        else:
            ans[j] = tmp[1]
        ans[j] += tmp[0]
ans.append(0)
for a in ans:
    print(a)


Measured memory_bytes: 3188
// Template
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <stack>
#include <tuple>
#include <map>
#include <set>
#include <algorithm>
#include <utility>
#include <cmath>
#define rep(i, x) for (int i = 0; i < (x); ++i)
#define rng(i, x, y) for (int i = (x); i < (y); ++i)
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
#define pb push_back
using namespace std;
using ll = long long;
constexpr int inf = 1001001001;
constexpr ll INF = 3003003003003003003;
template <typename T> inline bool chmin(T &x, const T &y) {if (x > y) {x = y; return 1;} return 0;}
template <typename T> inline bool chmax(T &x, const T &y) {if (x < y) {x = y; return 1;} return 0;}

// Main Code
int main() {
    int n, m, q;
    cin >> n >> m >> q;
    vector<vector<char>> s(n, vector<char>(m));
    rep(i, n) rep(j, m) cin >> s[i][j];
    
    vector<vector<int>> bsum(n + 1, vector<int>(m + 1, 0));
    rep(i, n) rep(j, m) {
        bsum[i + 1][j + 1] = bsum[i + 1][j] + bsum[i][j + 1] - bsum[i][j];
        if (s[i][j] == '1') ++bsum[i + 1][j + 1];
    }
    vector<vector<int>> tsum(n, vector<int>(m + 1, 0));
    rep(i, n - 1) rep(j, m) {
        tsum[i + 1][j + 1] = tsum[i + 1][j] + tsum[i][j + 1] - tsum[i][j];
        if (s[i][j] == '1' && s[i + 1][j] == '1') ++tsum[i + 1][j + 1];
    }
    vector<vector<int>> ysum(n + 1, vector<int>(m, 0));
    rep(i, n) rep(j, m - 1) {
        ysum[i + 1][j + 1] = ysum[i + 1][j] + ysum[i][j + 1] - ysum[i][j];
        if (s[i][j] == '1' && s[i][j + 1] == '1') ++ysum[i + 1][j + 1];
    }
    
    rep(_, q) {
        int x1, y1, x2, y2;
        cin >> x1 >> y1 >> x2 >> y2;
        --x1; --y1;
        int ans = bsum[x2][y2] - bsum[x2][y1] - bsum[x1][y2] + bsum[x1][y1];
        ans -= (tsum[x2 - 1][y2] - tsum[x1][y2] - tsum[x2 - 1][y1] + tsum[x1][y1]);
        ans -= (ysum[x2][y2 - 1] - ysum[x1][y2 - 1] - ysum[x2][y1] + ysum[x1][y1]);
        cout << ans << "\n";
    }
    return 0;
}


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

sx,sy,tx,ty = list(map(int,input().split()))
right = tx - sx
up = ty - sy

go1 = 'R'*right + 'U'*up
back1 =""
for i in range(len(go1)):
    if go1[i] == 'R':
        back1 += 'L'
    elif go1[i] == 'U':
        back1 += 'D'
    elif go1[i] == 'L':
        back1 += 'R'
    elif go1[i] == 'D':
        back1 += 'U'
        
go2 = 'D' + 'R'*(right+1)+'U'*(up+1)+'L'

back2 =""
for i in range(len(go2)):
    if go2[i] == 'R':
        back2 += 'L'
    elif go2[i] == 'U':
        back2 += 'D'
    elif go2[i] == 'L':
        back2 += 'R'
    elif go2[i] == 'D':
        back2 += 'U'

print(go1+back1+go2+back2)


Measured memory_bytes: 9220
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#define MOD 1000000007
#define INT long long int
#define REP(i,n) for(int(i)=0;(i)<(n);(i)++) 
using namespace std;
const long long INF = numeric_limits<long long>::max();


int main()
{
  int N;
  cin>>N;
  string S;
  cin>>S;
  int ans = 0;
  REP(i,10)REP(j,10)REP(k,10){
    char val[3] = {'0'+i,'0'+j,'0'+k};
    int idx=0;
    for(int t=0;t<N;++t){
      if (S[t]==(val[idx])) idx++;
      if (idx>2){
        ans++;
        break;
      }
    }
  }
  cout<<ans<<endl;
  return 0;
}

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

int main(){
  int a=0,b=0,c=0;
  cin >> a >> b >> c;
  int ans = int(b/a);
  if(ans > c) {
    cout << c;
  }else{
    cout << ans;
  }
  cout << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<tuple>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define Per(i,sta,n) for(int i=n-1;i>=sta;i--)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;

int a[3][3];
int n;
bool b[3][3];

void solve(){
    rep(i,3){
        rep(j,3){
            cin >> a[i][j];
        }
    }
    cin >> n;
    rep(l,n){
        int s;cin >> s;
        rep(i,3){
            rep(j,3){
                if(a[i][j]==s){
                    b[i][j]=true;
                }
            }
        }
    }
    rep(i,3){
        if(b[i][0] && b[i][1] && b[i][2]){
            cout << "Yes" << endl;
            return;
        }
        if(b[0][i] && b[1][i] && b[2][i]){
            cout << "Yes" << endl;
            return;
        }
    }
    if(b[0][0] && b[1][1] && b[2][2]){
        cout << "Yes" << endl;
        return;
    }
    if(b[2][0] && b[1][1] && b[0][2]){
        cout << "Yes" << endl;
        return;
    }
    cout << "No" << endl;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(50);
    solve();
}

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

class Node {
public:
	int location;
	int p, l, r;
	Node() {}
};

class Point {
public:
	int id, x, y;
	Point() {}
	Point(int id, int x, int y) : id(id), x(x), y(y) {}
	bool operator < (const Point& p) const {
		return id < p.id;
	}

	void print() {
		printf("%d\n", id);	// cout より高速なprintf関数を使用
	}
};

static const int MAX = 1000000;
static const int NIL = -1;

int N;
Point P[MAX];
Node T[MAX];
int np;

bool lessX(const Point& p1, const Point& p2) { return p1.x < p2.x; }
bool lessY(const Point& p1, const Point& p2) { return p1.y < p2.y; }

int makeKDTree(int l, int r, int depth)
{
	if (!(l < r)) return NIL;
	int mid = (l + r) / 2;
	int t = np++;
	if (depth % 2 == 0) {
		sort(P + l, P + r, lessX);
	} else {
		sort(P + l, P + r, lessY);
	}
	T[t].location = mid;
	T[t].l = makeKDTree(l, mid, depth + 1);
	T[t].r = makeKDTree(mid + 1, r, depth + 1);

	return t;
}

void find(int v, int sx, int tx, int sy, int ty, int depth, vector<Point>& ans)
{
	int x = P[T[v].location].x;
	int y = P[T[v].location].y;

	if (sx <= x && x <= tx && sy <= y && y <= ty) {
		ans.push_back(P[T[v].location]);
	}

	if (depth % 2 == 0) {
		if (T[v].l != NIL) {
			if (sx <= x) find(T[v].l, sx, tx, sy, ty, depth + 1, ans);
		}
		if (T[v].r != NIL) {
			if (x <= tx) find(T[v].r, sx, tx, sy, ty, depth + 1, ans);
		}
	}else {
		if (T[v].l != NIL) {
			if (sy <= y) find(T[v].l, sx, tx, sy, ty, depth + 1, ans);
		}
		if (T[v].r != NIL) {
			if (y <= ty) find(T[v].r, sx, tx, sy, ty, depth + 1, ans);
		}
	}
}


int main(void)
{
	int x, y;
	scanf("%d", &N);
	for (int i = 0; i < N; i++)
	{
		scanf("%d %d", &x, &y);	//cin より高速な scanf関数を使用
		P[i] = Point(i, x, y);
		T[i].l = T[i].r = T[i].p = NIL;
	}

	np = 0;

	int root = makeKDTree(0, N, 0);

	int q;
	scanf("%d", &q);
	int sx, tx, sy, ty;
	vector<Point> ans;
	for (int i = 0; i < q; i++)
	{
		scanf("%d %d %d %d", &sx, &tx, &sy, &ty);
		ans.clear();
		find(root, sx, tx, sy, ty, 0, ans);
		sort(ans.begin(), ans.end());
		for (int j = 0; j < ans.size(); j++) {
			ans[j].print();
		}
		printf("\n");
	}

	return 0;
}


Measured memory_bytes: 16384
#include <stdio.h>

int main(int argc, char *argv[])
{
	int i = 1;
	while (1)
	{
		int x;
		scanf("%d\n",&x);
		if(x == 0){
			break;
		}
		else{
			printf("Case %d: %d\n",i,x);
		}
		i++;
	}

	return 0;
}


Measured memory_bytes: 2032
#include<cstdio>
int main(){
  int a[10],v1,v2;
  while(scanf("%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d",
	      &a[0],&a[1],&a[2],&a[3],&a[4],
	      &a[5],&a[6],&a[7],&a[8],&a[9],
	      &v1,&v2)>0){
    for(int i=1;i<10;i++) a[i]+=a[i-1];
    for(int i=0;i<10;i++){
      if(a[9]*v1<=a[i]*(v1+v2)){
	printf("%d\n",i+1);
	break;
      }
    }
  }
}

Measured memory_bytes: 1008
N,M = map(int,input().split())
A = list(map(int,input().split()))
A.sort()
A = A[::-1]
ans = []
s = sum(A)
for i in range(M):
    if A[i]>=s/(4*M):
        ans.append(A[i])
if len(ans)==M:
    print('Yes')
else:
    print('No')

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

int price(int s,int w) {
  int sizeprice,wprice;
  if(s <=60) {
    sizeprice = 0;
  }
  else if(s <= 80) {
    sizeprice = 1;
  }
  else if(s <= 100) {
    sizeprice = 2;
  }
  else if(s <= 120) {
    sizeprice = 3;
  }
  else if(s <= 140) {
    sizeprice = 4;
  }
  else if(s <= 160) {
    sizeprice = 5;
  }
  else {
    sizeprice = 6;
  }
  if(w <=2) {
    wprice = 0;
  }
  else if(w <= 5) {
    wprice = 1;
  }
  else if(w <= 10) {
    wprice = 2;
  }
  else if(w <= 15) {
    wprice = 3;
  }
  else if(w <= 20) {
    wprice = 4;
  }
  else if(w <= 25) {
    wprice = 5;
  }
  else {
    wprice = 6;
  }
  if(max(sizeprice,wprice)<6) {
    return max(sizeprice,wprice) * 200 +600;
    }
  else {
    return 0;
  }
}

int main() {
  int n,x,y,h,w,size,sum=0;
  while(cin >> n) {
    if(n==0) break;
    for(int i=0;i<n;i++) {
      cin >> x >> y >> h >> w;
      size = x+y+h;
      sum += price(size,w);
    }
    cout << sum << endl;
    sum=0;
  }
}

Measured memory_bytes: 0
import math
 
def combination(n, k):
    return math.factorial(n) // math.factorial(k) // math.factorial(n - k)
 

n, k = map(int, input().split())
 
for i in range(1, k + 1):
    if i <= n - k + 1:
        print(combination(n-k+1,i) * combination(k-1,i-1) % 1000000007)
    else:
        print(0)

Measured memory_bytes: 69976
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
ll MOD = 1e9+7;

#define vec     vector<int>
#define vecll   vector<ll>
#define vec2    vector<vector<int>>
#define vec2ll  vector<vector<ll>>
#define vpair   vector<pair<int, int>>
#define vpairll vector<pair<ll, ll>>
#define vecst   vector<string>
#define vecb    vector<bool>

#define rep(i,n)         for(ll i=(ll)0; i<(ll)n; i++)
#define REP(i,m,n)       for(ll i=(ll)m; i<(ll)n; i++)
#define arr(var, n)      vec var(n); rep(i,n){cin >> var[i];}
#define arrll(var, n)    vecll var(n); rep(i,n){cin >> var[i];}
#define arrst(var, n)    vecst var(n); rep(i,n){cin >> var[i];}
#define all(var)         (var).begin(), (var).end()
#define sortall(var)     sort(all(var))
#define uniqueall(v)     v.erase(unique(v.begin(), v.end()), v.end());
#define f_sum(var)       accumulate(all(var), 0)
#define f_sumll(var)     accumulate(all(var), 0LL)
#define chmin(v1, v2)    v1 = min(v1, v2)
#define chmax(v1, v2)    v1 = max(v1, v2)
#define mpair(v1, v2)    make_pair(v1, v2)
#define pb(var)          push_back(var)
#define prt(var)         cout << var << "\n"
#define prtd(n, var)     cout << fixed << setprecision(n) << var << "\n"
#define prtfill(n, var)  cout << setw(n) << setfill('0') << var;
#define prt2(v1, v2)     cout << v1 << " " << v2 << "\n"
#define prt3(v1, v2, v3) cout << v1 << " " << v2 << " " << v3 << "\n"
#define prtall(v)        rep(i,v.size()){cout<<v[i]<<(i!=v.size()-1?" ":"\n");}
void prtok(bool ok){prt((ok ? "Yes" : "No"));}
//----------------------------------------------------------------

int main(void) {
  int n, x;
  cin >> n >> x;
  arrll(a,n);

  ll ans=0;
  rep(i,n-1){
    if(a[i]+a[i+1]>x){
      ll eat=a[i]+a[i+1]-x;
      ans+=eat;
      if(a[i+1]>=eat){
        a[i+1]-=eat;
      } else {
        a[i]-=eat-a[i+1];
        a[i+1]=0;
      }
      //prtall(a);
    }
  }

  prt(ans);
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int a[20];
int x[20][20];
int y[20][20];
int counter(int x)
{
    if(x==0)
    {
        return 0;
    }
    return counter(x>>1)+(x & 1);
}
void solve()
{
    int N;
    cin>>N;
    for(int i=1;i<=N;i++)
    {
        cin>>a[i];
        for(int j=1;j<=a[i];j++)
        {
            cin>>x[i][j]>>y[i][j];
        }
    }
    int ans=0;
    for(int bits=1;bits<( 1 << N);bits++)
    {
        bool ok=true;
        for(int i=1;i<=N;i++)
        {
            if(!(bits & (1<< (i-1))))continue;
            for(int j=1;j<=a[i];j++)
            {
                if(((bits >> (x[i][j]-1)) & 1 )^ y[i][j])ok=false;
            }
        }
        if(ok)ans=max(ans,counter(bits));

    }
    cout<<ans<<endl;

}
int main()
{   
     
    solve();
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <iomanip>
#include <bitset>
#include <set>
#include <map>
#include <stdio.h>
#include <numeric>
#include <cstring>

#define rep(i,n) for (int i = 0; i < (n); i++)
#define rep1(i,n) for (int i = 1; i < (n); i++)
#define FOR(i,a,b) for (int i=(a); i < (b); i++)
#define MOD 1000000007 //10^9+7
using namespace std;
using ll = long long;
using PII = pair<int, int>;
const int INF = numeric_limits<int>::max();

// 負の数にも対応した % 演算
long long mod(long long val, long long m) {
    long long res = val % m;
    if (res < 0) res += m;
    return res;
}

//greatest common divisor
long long gcd(ll a, ll b) 
{
    if (a % b == 0) {
        return b;
    } else {
        return gcd(b, a % b);
    }
}

//least common multiple
long long lcm(ll a, ll b)
{
    return a / gcd(a, b) * b ;
}

int main()
{
    ll n; cin >> n;
    cout << n*(n-1)/2 << endl;
    return 0;
}


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

int main() {
  int W, H, x, y, r;

  cin >> W >> H >> x >> y >> r;

  if (x + r <= W && x -r >= 0 && y + r <= H && y - r >= 0) cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;
}
 

Measured memory_bytes: 3088
#include <stdio.h>

int main(void)
{
  char x[1000] = {0};
  int sum = 0;
  int i;

  while(1){
    scanf("%s", x);

    if(x[0] == '0')
      break;

    for(i = 0; i < 1000; i++){
      if(x[i] == '\0')
	break;
      
      switch(x[i]){
       case '0' : sum += 0;  break;
       case '1' : sum += 1;  break;
       case '2' : sum += 2;  break;
       case '3' : sum += 3;  break;
       case '4' : sum += 4;  break;
       case '5' : sum += 5;  break;
       case '6' : sum += 6;  break;
       case '7' : sum += 7;  break;
       case '8' : sum += 8;  break;
       case '9' : sum += 9;  break;
      }
    }

    printf("%d\n", sum);

    sum = 0;
  }

  return 0;
}

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

int main() {
  int l,r,d;
  cin >> l >> r >> d;
  int cnt=0;
  rep(i,r-l+1){
    if((i+l)%d==0) cnt++;
  }
  cout << cnt << endl;
}

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

int main() {
  int H, W;
  cin >> H;
  cin >> W;


   vector<vector<char>> matrix(H, vector<char>(W));

  
  for (int i = 0; i < H; i++){
    for (int j = 0; j < W; j++){
      cin >> matrix.at(i).at(j);
    }
  }  


  int hcheck = 0;
  vector<bool> hflag(H, false);
  int wcheck = 0;
  vector<bool> wflag(W, false);

  for (int i = 0; i < matrix.size(); i++){
    for (int j=0; j< matrix.at(0).size();j++){
      if(matrix.at(i).at(j) == '#') {
        hflag.at(i) = true;
        wflag.at(j) = true; 
      }
    }
  }
  for (int i = 0; i < matrix.size(); i++){
    for (int j=0; j< matrix.at(0).size();j++){
      if(hflag.at(i) == true  && wflag.at(j) == true ) {
          cout << matrix.at(i).at(j);
      }
      
    }
    if (hflag.at(i) == true) cout << endl;
  }
}


Measured memory_bytes: 256
#%%
n = int(input())
d = list(map(int, input().split()))
m = int(input())
t = list(map(int, input().split()))

d.sort()
t.sort()
flag2 = True
pos = 0

for i in range(m):
    flag = False
    for j in range(pos, n):
        if t[i] == d[j]:
            pos = j+1
            flag = True
            break
        else:
            pass
    if flag :
        pass
    else:
        flag2 = False
        break

if flag2:
    print('YES') 
else:
    print('NO')

Measured memory_bytes: 35420
#include<bits/stdc++.h>
using namespace std;
int n;
string s;
bool s1[15],s2[105],s3[1005];
int ans;
int main() {
	cin>>n;
	cin>>s;
	for(int i=0;i<n;i++) {
		int k=int(s[i])-48;
		for(int i=0;i<=99;i++) if(s2[i]) s3[i*10+k]=1;
		for(int i=0;i<=9;i++) if(s1[i]) s2[i*10+k]=1;
		s1[k]=1;
	}
	for(int i=0;i<=1000;i++) if(s3[i])ans++;
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
from numba import jit
import math
N, K = map(int, input().split())
h = list(map(int, input().split()))
 
@jit
def nya(N, K, h):
    S = [0] * N
    S[0] = 0
 
    for i in range(1, N):
        value = math.inf
        for step in range(1, K + 1):
            if i - step < 0:
                break
            value = min(value, S[i - step] + abs(h[i] - h[i - step]))
        S[i] = value
    return S[N-1]

print(nya(N, K, h))

Measured memory_bytes: 117792
#include <iostream>
#include <bits/stdc++.h>
#include <vector>
#include <utility>
#include <string>
#include <math.h>
#include <algorithm>
#include <cstring>
#include <cctype>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) for(int i=0;i<(n);++i)

typedef long long int lli;

using namespace std;

int main() {
   
  int A,B;
   cin >> A >> B;
   cout << A * B <<endl;

}

Measured memory_bytes: 3636
n = int(input())
*a, = map(int, input().split())

x = [0]*(n+1)
for i in range(n):
    x[i+1] = x[i] + a[i]

y = [0]*(n+1)
for i in reversed(range(n)):
    y[i] = y[i+1] + a[i]

ans = float("inf")
for i in range(1, n):
    ans = min(ans, abs(x[i]-y[i]))

print(ans)


Measured memory_bytes: 28548
#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 K;
  cin >> K;
  long long ans = 0;
  for (int a = 1; a <= K; a++) {
    for (int b = 1; b <= K; b++) {
      for (int c = 1; c <= K; c++) {
        ans += __gcd(a, __gcd(b, c));
      }
    }
  }
  cout << ans << endl;
  return 0;
}


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

int main(){
    int N, height_max=0, count=0;
    vector<int> H;

    cin >> N;
    H.resize(N);
    for(int i=0; i<N; i++){
        cin >> H[i];
    }

    for(int i=0; i<N; i++){
        if(height_max <= H[i]){
            count++;
            height_max = H[i];
        }
    }

    cout << count << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <stdlib.h>

using namespace std;


int main(){

	int i,j;
	int top1=0, top2=0, top3=0;
	int temp1, temp2;

	for(i=0 ; i<10 ; i++){
		cin >> temp1;
		if(temp1 >= top1){
			top3 = top2;
			top2 = top1;
			top1 = temp1;
		}else if((temp1 < top1) && (temp1 >= top2)){
			top3 = top2;
			top2 = temp1;
		}else if(temp1 >= top3){
			top3 = temp1;
		}
	}

		cout << top1 << endl;
		cout << top2 << endl;
		cout << top3 << endl;

	return 0;
}

Measured memory_bytes: 1164
#include<stdio.h>

int main(){
int A,B,C;
C=0;

scanf("%d %d",&A,&B);
if( A>=B ){ C+=A ; A-- ;}else{ C+=B;B--; }
if( A>=B ){ C+=A ; A-- ;}else{ C+=B;B--; }
printf("%d\n",C);
return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using LL = long long int;
#define incID(i, l, r) for(int i = (l)    ; i <  (r); ++i)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); --i)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); ++i)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); --i)
#define inc(i, n)  incID(i, 0, n)
#define dec(i, n)  decID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec1(i, n) decII(i, 1, n)
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))
#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define MT make_tuple
#define FI first
#define SE second
#define FR front()
#define BA back()
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
auto setmin   = [](auto & a, auto b) { return (b <  a ? a = b, true : false); };
auto setmax   = [](auto & a, auto b) { return (b >  a ? a = b, true : false); };
auto setmineq = [](auto & a, auto b) { return (b <= a ? a = b, true : false); };
auto setmaxeq = [](auto & a, auto b) { return (b >= a ? a = b, true : false); };
#define SI(v) static_cast<int>(v.size())
#define RF(e, v) for(auto & e: v)
#define until(e) while(! (e))
#define if_not(e) if(! (e))
#define ef else if
#define UR assert(false)
#define IN(T, ...) T __VA_ARGS__; IN_(__VA_ARGS__);
void IN_() { };
template<typename T, typename ... U> void IN_(T &  a, U &  ... b) { cin >> a; IN_(b ...); };
template<typename T                > void OUT(T && a            ) { cout << a << endl; }
template<typename T, typename ... U> void OUT(T && a, U && ... b) { cout << a << " "; OUT(b ...); }

// ---- ----

template<typename T> istream & operator>>(istream & s, vector<T> & v) { RF(e, v) { s >> e; } return s; }
template<typename T> ostream & operator<<(ostream & s, vector<T> const & v) {
	inc(i, SI(v)) { s << (i == 0 ? "" : " ") << v[i]; }
	return s;
}

#define bit(b, i) (((b) >> (i)) & 1)
#define PC __builtin_popcountll
#define BL(a) (a ? 64 - __builtin_clzll(a) : 0)

int main() {
	auto f = [&](vector<LL> & v, LL x) -> bool {
		int r = 0;
		dec(k, 60) {
			incID(j, r, SI(v)) {
				if(bit(v[j], k) == 0) { continue; }
				inc(jj, SI(v)) {
					if(jj != j && bit(v[jj], k) == 1) { v[jj] ^= v[j]; }
				}
				if(bit(x, k) == 1) { x ^= v[j]; }
				swap(v[r], v[j]);
				r++;
			}
		}
		return (x == 0);
	};
	
	IN(int, t);
	inc(q, t) {
		IN(int, n);
		vector<LL> a(n);
		cin >> a;
		IN(string, s);
		
		int ans = 0;
		inc(i, n) {
			if(s[i] == '0') { continue; }
			
			LL x = a[i];
			vector<LL> v;
			incID(j, i, n) { if(s[j] == '0') { v.PB(a[j]); } }
			if(! f(v, x)) { ans = 1; break; }
		}
		OUT(ans);
	}
}


Measured memory_bytes: 3596
# include "cstdio"
# include "iostream"
 
using namespace std;

int
	ans1,ans2;
		 
int main(){
	int n,m,x,now;
	scanf("%d%d%d",&n,&m,&x);
	register int i;
	for(i=1;i<=m;i++){
		scanf("%d",&now); 
		ans1+=now<x?1:0;
		ans2+=now>x?1:0; 
	}
	printf("%d",min(ans1,ans2));
	return 0; 
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
int inf = 10e17;
#define mod 1000000007

bool vis[200005];
vector<int> vec[2000005], v1;
int child[2000005];
int parent[2000005];
int div1[100005];
int min_indx[900005];
int count1 = 0;
int height = 0;
int max_indx[200005];
void dfs(int node)
{

    vis[node] = 1;
    // cout << node << "\n";
    min_indx[count1] = node;
    max_indx[node] = min(max_indx[node], count1);
    count1++;

    //  count1++;
    child[node] = height++;
    for (int i = 0; i < vec[node].size(); i++)
    {
        if (!vis[vec[node][i]])
        {
            dfs(vec[node][i]);
            min_indx[count1] = node;
            max_indx[node] = min(max_indx[node], count1);
            count1++;
        }
    }
    height--;
}

int MAXN = 200005;
int LOGMAXN = (int)log2(200005) + 1;
int M[200005][60];
void process2(int A[], int N)
{
    int i, j;

    //initialize M for the intervals with length 1
    for (i = 0; i < N; i++)
        M[i][0] = i;
    //compute values from smaller to bigger intervals
    for (j = 1; 1 << j <= N; j++)
        for (i = 0; i + (1 << j) - 1 < N; i++)
            if (A[M[i][j - 1]] < A[M[i + (1 << (j - 1))][j - 1]])
                M[i][j] = M[i][j - 1];
            else
                M[i][j] = M[i + (1 << (j - 1))][j - 1];
}
//int parent[200005];
vector<int> vec1;
//bool vis[200005];
//int hei[200005];
int lev[200005];
int dis[200005];
bool cmp(pair<int, int> &a,
         pair<int, int> &b)
{
    return a.second < b.second;
}
int32_t main()
{
    // ios_base::sync_with_stdio(false);
    // cin.tie(NULL);
    //  int t;
    int n, m;
    cin >> n >> m;
    if (n == 0)
    {
        if (m == 100)
            cout << 101 << "\n";
        else
            cout << m << "\n";
    }
    if (n == 1)
    {
        if (m == 100)

            cout << m * 100 + 100 << "\n";
        else
            cout << m * 100 << "\n";
    }
    if (n == 2)
    {
        if (m == 100)

            cout << m * 100 * 100 + 100 * 100 << "\n";
        else
            cout << m * 100 * 100 << "\n";
    }

    return 0;
}


Measured memory_bytes: 50532
#include<stdio.h>
 
int main(){
  int a,b,c,d,e,f;
  float x,y;
  while(scanf("%d %d %d %d %d %d",&a,&b,&c,&d,&e,&f)!=-1){
    x = (float)(c*e-b*f)/(a*e-d*b);
    y = (float)(c*d-a*f)/(b*d-a*e);
    if(-0.0005<x && x<=0)
      x=0;
    if(-0.0005<y && y<=0)
      y=0;
    printf("%.3f %.3f\n",x,y);
  }
  return 0;
}

Measured memory_bytes: 636
#include<bits/stdc++.h>
#include<math.h>
#define rep(i,k,n) for(int i=k;i<n;i++)
#define ll long long
#define MOD 1000000007
#define INF 100000008880LL
#define MIN(a,b) (a>b?b:a)
#define pii pair <ll,ll>
using namespace std;
#define mp make_pair
#define fi first
#define se second
#define piii pair<pair<ll,ll>,ll>
char str[200005];
ll n,size_,l;
pii ar[200005];
ll func();
int main()
{
	scanf(" %s",str);
	n=strlen(str);
	ll ans=0;
	rep(i,0,n)
	{
		//cout<<i<<" "<<str[i];
		if(str[i]=='A')
		{
			//cout<<i<<"X ";
			ar[size_]=mp(1,size_);
			size_++;
		}
		else if(i+1<n&&str[i]=='B'&&str[i+1]=='C')
		{
			///cout<<i<<"Y ";
			i++;
			ar[size_]=mp(0,size_);
			size_++;
		}
		else
		{
			ans+=func();
			size_=0;
		}
	}
	ans+=func();
	cout<<ans;
}
ll func()
{
	sort(ar,ar+size_);
	// rep(i,0,size_)
	// cout<<ar[i].fi<<" ";
	// cout<<"XX\n";
	ll ans=0;
	rep(i,0,size_)
	{
		if(ar[i].fi==1)
			ans+=abs(ar[i].se-i);
	}
	return ans;
}

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

// int/long:		-2,147,483,648 - 2,147,483,647 (-2^31 <= int < 2^31)
// long/long long:	-9,223,372,036,854,775,808 - 9,223,372,036,854,775,807 (-2^63 <= long < 2^63)

#define	INF (1<<30)
//1,073,741,824
//= 536,870,912 *2

#define	MOD 1000000007

// lower_bound(A.begin(), A.end(), N)
// upper_bound(...

// A.erase(unique(A.begin(), A.end()), A.end())

// bit: &/and, |/or, ^/xor, ~/not

// getline(cin, String)
// while (getline(cin, S)) {}

// cout <<fixed <<setprecision(10)

// priority_queue<int> q;
// priority_queue<int, vector<int>, less<int>> q; // Default: vector, less
// priority_queue<vector<int>, vector<vector<int>>, greater<vector<int>>> q;

// Graph
// Warshall-Floyd: Distance between each node, N^3
// Dijkstra: Distance from the start node, N^2
// DFS(Depth-First Search)

//
// Notes
//
// When specified less than N, try full scan.
// RE: empty vector
// Check Qs
// long/int
// xor -> count each bit
// Check values
// 	1,000,000 -> Loop
// 	100,000	-> vector(int:400KB, long:800KB) 

int	main() {
	int H, N;
	cin >>H >>N;
	for (int i=0; i<N; i++) {
		int A;
		cin >>A;
		H -=A;
		if (0>=H) {
			cout <<"Yes" <<endl;
			return 0;
		}
	}
	cout <<"No" <<endl;
	return 0;
}



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

#define rep(i, k, n) for(int i = (k); i < (n); i++)
#define irep(i, k, n) for(int i = (k); i > (n); i--)
using namespace std;
using ll = long long;

ll gcd(ll a, ll b){ return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b){ return a/gcd(a,b)*b; }

int main(void){
  ll a, b;
  cin >> a >> b;
  
  ll c = gcd(a, b);
  ll ans = 1;
 rep(i, 2, 1e6+1){
    if(c % i) continue;
    while(!(c%i)) c /= i;
    ans++;
  }
  if(c != 1) ans++;

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
# ABC166_B.py
n,k=map(int,input().split())
sunuke=[0]*n
for i in range(k):
  d=int(input())
  # d-=1
  a=list(map(int,input().split()))
  for aa in a:
    sunuke[aa-1]+=1
# print(sunuke)
ans=0
for ss in sunuke:
  if ss==0:
    ans+=1
print(ans)





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

int main(){
    string s;
    cin >> s;
    string ans = "";
    for (int i = 0; i < s.size(); i++){
        if (i % 2 != 0){
            continue;
        }
        else{
            ans += s.at(i);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 512