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

#define int long long
#define rep(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define reps(i, n) for (int (i) = 1; (i) <= (n); (i)++)
#define rrep(i, n) for (int (i) = (n - 1); (i) >= 0; (i)--)
#define rreps(i, n) for (int (i) = (n); (i) > 0; (i)--)
typedef vector<int> vint;
typedef pair<int, int> pint;
const double PI = 3.141592653589793238462643383279;
const int DY[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const int DX[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
template<typename T, typename U> inline bool chmax(T &a, const U &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> inline bool chmin(T &a, const U &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
struct Init {
    Init() {
        cout << fixed << setprecision(20);
    };
} init;

int a, b;
signed main() {
    cin >> a >> b;
    if (a > 0) { cout << "Positive" << endl; }
    else if (a == 0 || b >= 0) { cout << "Zero" << endl; }
    else if ((b - a) & 1) { cout << "Positive" << endl; }
    else { cout << "Negative" << endl; }
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"reflect"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)
var out = bufio.NewWriter(os.Stdout)

func solve(a int64, b int64, c int64) int64 {
    ret := int64(0)
    for i := a ; i <= b; i++ {
	if c % i == 0 {
            ret ++;
}
}
return ret 
}

func main() {
	sc.Split(bufio.ScanWords)
	defer out.Flush()

	a := nextInt()
	b := nextInt()
	c := nextInt()
	res := solve(a, b, c)
	fmt.Fprintln(out, res)
}

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextStringAsBytes(n int64) []byte {
	sc.Scan()
	return []byte(sc.Text())
}

func nextInt() int64 {
	a, _ := strconv.ParseInt(next(), 10, 64)
	return a
}

func nextFloat() float64 {
	a, _ := strconv.ParseFloat(next(), 64)
	return a
}

func nextInts(n int64) []int64 {
	ret := make([]int64, n)
	for i := int64(0); i < n; i++ {
		ret[i] = nextInt()
	}
	return ret
}

func nextFloats(n int64) []float64 {
	ret := make([]float64, n)
	for i := int64(0); i < n; i++ {
		ret[i] = nextFloat()
	}
	return ret
}
func nextStrings(n int64) []string {
	ret := make([]string, n)
	for i := int64(0); i < n; i++ {
		ret[i] = next()
	}
	return ret
}

func containStr(arr []string, target string) bool {
	for _, v := range arr {
		if v == target {
			return true
		}
	}
	return false
}

func PrintOut(src interface{}, joinner string) {
	switch reflect.TypeOf(src).Kind() {
	case reflect.Slice:
		s := reflect.ValueOf(src)
		for idx := 0; idx < s.Len(); idx++ {
			fmt.Fprintf(out, "%v", s.Index(idx))
			if idx < s.Len()-1 {
				fmt.Fprintf(out, "%s", joinner)
			} else {
				fmt.Fprintln(out)
			}
		}
	default:
		fmt.Fprintln(out, "orz")
	}
}

// mapからkeysとvaluesを返す
func splitKeyValue(m map[interface{}]interface{}) (keys, values []interface{}) {
	switch reflect.TypeOf(m).Kind() {
	case reflect.Map:
		s := reflect.ValueOf(m)
		for _, v := range s.MapKeys() {
			keys = append(keys, v)
			values = append(values, s.MapIndex(v))
		}
	default:
		fmt.Fprintln(out, "orz")
	}
	return
}



Measured memory_bytes: 1116
#include <bits/stdc++.h>
        #include<iostream>
        #include<cstdio>
        #include<vector>
        #include<queue>
        #include<map>
        #include<cstring>
        #include<string>
        #include <math.h>
        #include<algorithm>
    //    #include <boost/multiprecision/cpp_int.hpp>
        #include<functional>
      #define int long long
        #define inf  1000000007
        #define pa pair<int,int>
#define ll long long
        #define pal pair<ll,ll>
        #define ppa pair<int,pa>
        #define  mp make_pair
        #define EPS (1e-10)
        #define equals(a,b) (fabs((a)-(b))<EPS)

        using namespace std;

        class Point{
        	public:
        	double x,y;
        	Point(double x=0,double y=0):x(x),y(y) {}
        	Point operator + (Point p) {return Point(x+p.x,y+p.y);}
        	Point operator - (Point p) {return Point(x-p.x,y-p.y);}
        	Point operator * (double a) {return Point(x*a,y*a);}
        	Point operator / (double a) {return Point(x/a,y/a);}
        	double absv() {return sqrt(norm());}
        	double norm() {return x*x+y*y;}
        	bool operator < (const Point &p) const{
        		return x != p.x ? x<p.x: y<p.y;
        	}
        	bool operator == (const Point &p) const{
        		return fabs(x-p.x)<EPS && fabs(y-p.y)<EPS;
        	}
        };
        typedef Point Vector;

        struct Segment{
        Point p1,p2;
        };

    double hen(Vector a){
    if(fabs(a.x)<EPS && a.y>0) return acos(0);
    else if(fabs(a.x)<EPS && a.y<0) return 3*acos(0);
    else if(fabs(a.y)<EPS && a.x<0) return 2*acos(0);
    else if(fabs(a.y)<EPS && a.x>0) return 0.0;
    else if(a.y>0) return acos(a.x/a.absv());
    else return 2*acos(0)+acos(-a.x/a.absv());

    }

        double dot(Vector a,Vector b){
        	return a.x*b.x+a.y*b.y;
        }
        double cross(Vector a,Vector b){
        	return a.x*b.y-a.y*b.x;
        }
        int dx[4] = {1, 0, -1, 0};
        int dy[4] = {0, 1, 0, -1};
        //----------------kokomade temple------------


signed main(){
string s1,s2,s3;
	cin>>s1>>s2>>s3;
	int n1=s1.length();
	int n2=s2.length();
	int n3=s3.length();
//	int n1=s1.length();
	
	int z1=0,z2=0,z3=0;
	
	int y=1;
	while(1){
		if((y==1 && z1==n1)||(y==2 && z2==n2)||(y==3 && z3==n3)){
			if(y==1) cout<<"A"<<endl;
			if(y==2) cout<<"B"<<endl;
			if(y==3) cout<<"C"<<endl;
			return 0;
			
		}
		
		string s;
		if(y==1){
			if(s1[z1]=='a') y=1;
			if(s1[z1]=='b') y=2;
			if(s1[z1]=='c') y=3;
			z1++;
		}
		else if(y==2){
			if(s2[z2]=='a') y=1;
			if(s2[z2]=='b') y=2;
			if(s2[z2]=='c') y=3;
			z2++;
		}
else if(y==3){
			if(s3[z3]=='a') y=1;
			if(s3[z3]=='b') y=2;
			if(s3[z3]=='c') y=3;
			z3++;
		}
		
		
	}
	
	return 0;
        }
        
//printf("%.10f\n",ans);


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

int main(){
  int N, M;
  cin >> N >> M;

  vector<int> A(N);
  for(int i = 0; i < N; i++)
    cin >> A.at(i);
  
  vector<int> B(M);
  vector<int> C(M);

  for(int i = 0; i < M; i++)
    cin >> B.at(i) >> C.at(i);

  map<int,int,greater<int>> X;

  for(int &i:A){
    X[i]++;
  }
  
  for(int i = 0; i < M; i++){
    X[C.at(i)] += B.at(i);
  }

  int remain = N;
  long long ans = 0;
  for(auto &i: X){
    ans += (long long)i.first * (i.second < remain ? i.second : remain);

    remain -= i.second;

    if(remain <= 0)
      break;
  }

  cout << ans << endl;

}

Measured memory_bytes: 10752
#include <cstdio>
#include <algorithm>

using namespace std;

int main()
{
	int N;
	int a[40000], b[40000], plus[40000];
	
	while (scanf("%d", &N) && N){
		for (int i = 0; i < N; i++) scanf("%d", a + i);
		for (int i = 0; i < N; i++) scanf("%d", b + i);
		
		for (int i = 0; i < N; i++) plus[i] = 0;
		sort(a, a + N); sort(b, b + N);
		reverse(a, a + N); reverse(b, b + N);
		
		int idx = 0;
		for (int i = 0; i < N; i++){
			while (idx < N && b[i] < a[idx]) idx++;
			if (idx < N){
				plus[idx++] = 1;
			}
		}
		
		int sum = 0;
		bool flag = false;
		for (int i = 0; i < N - 1; i++){
			sum += plus[i];
			if ((i + 1) - sum > (i + 1) / 2){
				printf("%d\n", i + 1); flag = true; break;
			}
		}
		if (!flag) printf("NA\n");
	}
	
	return (0);
}

Measured memory_bytes: 1524
import sys

# 立方体で数字が自由なさいころ
class Dice:
    def __init__(self, top, bottom, front, rear, right, left):
        self.top = top
        self.front = front
        self.right = right
        self.bottom = bottom
        self.rear = rear
        self.left = left

    def rotate_front(self):
        t, b, f, r = self.top, self.bottom, self.front, self.rear
        self.top = r
        self.bottom = f
        self.front = t
        self.rear = b

    def rotate_rear(self):
        t, b, f, r = self.top, self.bottom, self.front, self.rear
        self.top = f
        self.bottom = r
        self.front = b
        self.rear = t

    def rotate_right(self):
        t, b, r, l = self.top, self.bottom, self.right, self.left
        self.top = l
        self.bottom = r
        self.right = t
        self.left = b

    def rotate_left(self):
        t, b, r, l = self.top, self.bottom, self.right, self.left
        self.top = r
        self.bottom = l
        self.right = b
        self.left = t

    def get_tfr(self):
        return [self.top, self.front, self.right]

    def get_all(self):
        return (self.top, self.bottom, self.front, self.rear, self.right, self.left)

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")

def main():
    n=int(input())
    fin=set()
    top, front, right, left, rear, bottom = map(int, input().split())
    fin.add((top, bottom, front, rear, right, left))
    for _ in range(n-1):
        top, front, right, left, rear, bottom = map(int, input().split())
        d = Dice(top, bottom, front, rear, right, left)
        states = set()
        states.add(d.get_all())
        for _ in range(3):
            d.rotate_right()
            states.add(d.get_all())
        d.rotate_front()
        d.rotate_front()
        states.add(d.get_all())
        for _ in range(3):
            d.rotate_right()
            states.add(d.get_all())

        d.rotate_front()
        states.add(d.get_all())
        for _ in range(3):
            d.rotate_right()
            states.add(d.get_all())
        d.rotate_front()
        d.rotate_front()
        states.add(d.get_all())
        for _ in range(3):
            d.rotate_right()
            states.add(d.get_all())

        d.rotate_right()
        d.rotate_front()
        states.add(d.get_all())
        for _ in range(3):
            d.rotate_right()
            states.add(d.get_all())
        d.rotate_front()
        d.rotate_front()
        states.add(d.get_all())
        for _ in range(3):
            d.rotate_right()
            states.add(d.get_all())

        for t in fin:
            if t in states:
                print("No")
                exit()
    print("Yes")

main()



Measured memory_bytes: 5632
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<iomanip>
using namespace std;

int main(){
    int n;
    cin>>n;
    int x[n],maxv=0,minv=101;
    long long ans=1e18;
    for(int i=0;i<n;i++){
        cin>>x[i];
        maxv=max(maxv,x[i]);
        minv=min(minv,x[i]);
        }
    for(int j=minv;j<=maxv;j++){
        long long tmp=0;
        for(int i=0;i<n;i++){
            tmp+=(j-x[i])*(j-x[i]);
        }
        ans=min(ans,tmp);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3592
#include <iostream> // cin, cout, cerr
#include <algorithm> // minmax, sort, swap
#include <numeric> // iota
#include <cstdio> // printf, scanf
#include <string> // string, stoi, to_string
#include <vector> // vector
#include <queue> // queue, priority_queue
#include <deque> // deque
#include <map> // key-value pairs sorted by keys
#include <set> // set
#include <iomanip> // cout<<setprecision(n)
#include <functional> // function<void(int)>
#include <cmath>
#include <cassert>
#include <bitset>
#include <stack>

#ifdef DEBUG
#include "debug.hpp"
#else
#define debug(...)
#endif

#define int long long // at least int64 > 9*10^18
#define EL '\n'
#define rep(i,n) for(int i = 0; i < (n); i++)
#define print(i) std::cout << (i) << '\n'
#define all(v) (v).begin(), (v).end()
using Graph = std::vector<std::vector<int> >;
const int INF = 1e17;
/* libraries */

signed main() {
	int n;
	std::cin >> n;
	int d=n%10;
	if(d==3) print("bon");
	else if(d==0 || d==1 || d==6 || d==8) print("pon");
	else print("hon");

	return 0;
}


Measured memory_bytes: 3620
from itertools import permutations

n = int(input())
xy = [list(map(int, input().split())) for _ in range(n)]

dist = 0
cnt = 0
for pattern in permutations(xy):
    cnt += 1
    for i in range(n - 1):
        x1, y1 = pattern[i]
        x2, y2 = pattern[i + 1]
        dist += pow(pow(x1 - x2, 2) + pow(y1 - y2, 2), 1 / 2)
res = dist / cnt
print(res)

Measured memory_bytes: 3064
from fractions import gcd


class SegmentTree():
    _data = []
    _offset = 0

    def __init__(self, size):
        t = 1
        while t <= size:
            t *= 2
        self._offset = t - 1
        self._data = [0] * (t * 2 - 1)

    def update_all(self, iterable):
        for i, v in enumerate(iterable):
            self._data[i + self._offset] = v
        for i in range(self._offset - 1, -1, -1):
            self._data[i] = gcd(self._data[i * 2 + 1], self._data[i * 2 + 2])

    def update(self, index, value):
        i = self._offset + index
        self._data[i] = value
        while i >= 1:
            i = (i - 1) // 2
            self._data[i] = gcd(self._data[i * 2 + 1], self._data[i * 2 + 2])

    def _query(self, start, stop, index, left, right):
        if right <= start or stop <= left:
            return 0
        if start <= left and right <= stop:
            return self._data[index]
        a = self._query(start, stop, index * 2 + 1, left, (left + right) // 2)
        b = self._query(start, stop, index * 2 + 2, (left + right) // 2, right)
        return gcd(a, b)

    def query(self, start, stop):
        return self._query(start, stop, 0, 0, self._offset + 1)


N = int(input())
A = list(map(int, input().split()))

st = SegmentTree(N)
st.update_all(A)

result = st.query(1, N)
for i in range(1, N - 1):
    result = max(result, gcd(st.query(0, i), st.query(i + 1, N)))
result = max(result, st.query(0, N - 1))
print(result)


Measured memory_bytes: 125512
#include <iostream>
#include <cmath>
using namespace std;
int n,d;
int a[15][15];
double sum=0,ans=0;
bool ispow(int x){
	for(int i=0;i*i<=x;i++){
		if(i*i==x) return 1;
	}
	return 0;
}
int main(){
	cin>>n>>d;
	for(int i=1;i<=n;i++){
		for(int j=1;j<=d;j++)
			cin>>a[i][j];
	}
	for(int i=1;i<=n;i++){
		for(int j=i+1;j<=n;j++){
			sum=0;//////
			for(int k=1;k<=d;k++){
				sum+=(a[i][k]-a[j][k])*(a[i][k]-a[j][k]); 
			}
			if(ispow(sum)){
				//cout<<i<<" "<<j<<endl;
				ans++;
			} 
		}
	}
	cout<<ans;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

const int KMAX = 200000 + 5;
const int N = 2000 + 5;
const int MOD = 1000000000 + 7;
const int INV2 = 500000000 + 4;

int comb[4 * N][2 * N];

void precalc_comb() {
    for (int i = 0; i < 4 * N; ++ i) {
        comb[i][0] = 1;
        for (int j = 1; j <= i && j < 2 * N; ++ j) {
            comb[i][j] = comb[i - 1][j - 1] + comb[i - 1][j];
            if (comb[i][j] >= MOD)
                comb[i][j] -= MOD;
        }
    }
}

int K;
int A[KMAX];
int B[KMAX];

int dp[2 * N][2 * N];

int main()
{
    ios_base :: sync_with_stdio(false);
    cin >> K;

    for (int i = 1; i <= K; ++ i)
        cin >> A[i] >> B[i];
    for (int i = 1; i <= K; ++ i)
        ++ dp[N - A[i]][N - B[i]];

    for (int i = 1; i < 2 * N; ++ i)
        for (int j = 1; j < 2 * N; ++ j) {
            dp[i][j] += dp[i][j - 1];
            if (dp[i][j] >= MOD)
                dp[i][j] -= MOD;

            dp[i][j] += dp[i - 1][j];
            if (dp[i][j] >= MOD)
                dp[i][j] -= MOD;
        }

    precalc_comb();

    int ans = 0;
    for (int i = 1; i <= K; ++ i) {
        ans += dp[N + A[i]][N + B[i]];
        if (ans >= MOD)
            ans -= MOD;
        ans -= comb[A[i] + B[i] + A[i] + B[i]][A[i] + A[i]];
        if (ans < 0)
            ans += MOD;
    }

    ans = (1LL * ans * INV2) % MOD;

    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 172800
#include<stdio.h>

int main(void){

    long long int n;
    scanf("%lld",&n);

    long long int a[n];
    for (long long int i=0;i<n;i++){
        a[i]=0;
    }

    long long int ans=0;
    int flag=0;
    for (long long int i=0;i<n;i++){
        scanf("%lld",&a[i]);
        if (a[i]==0){
            flag=1;
        }
        if (i==0){
            ans=a[i];
        }else{
            ans=ans*a[i];
        }
    }

    if (ans>1000000000000000000)
        printf("-1\n");
    else if (flag==0 && ans==0)
        printf("-1\n");
    else
        printf("%lld\n",ans);
    
    return 0;
}

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

void solve(){
    string s;
    cin>>s;
    int n = 3;
    int ans = 0;
    for(int i=0; i<3; i++){
        int cnt = 0;
        for(int j=i; j<3; j++){
            if(s[j] == 'R')cnt++;
            else{
                break;
            }
        }
        ans = max(ans,cnt);
    }
    cout<<ans;
}

int main() {
    int t;
    t = 1;
    // cin>>t;
    while(t--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 3592
#include<algorithm>
#include<iostream>
using namespace std;
int main(){
  int i;
  int n,s;
  while(cin>>n>>s,n||s){
    int a[20001];
    a[n]=1000;
    for(i=0;i<n;++i)
      cin>>a[i];
    sort(a,a+n);
    int ct=0;
    for(i=0;i<n-1;++i)
      ct+=n-(lower_bound(a+i+1,a+n+1,s-a[i]+1)-a);
    cout<<ct<<endl;
  }
  return 0;
}

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

using namespace std;

#define SZ(x) (int)(x.size())

using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;

template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}

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

  int n; cin >> n;
  string s; cin >> s;

  vector<bool> dp1(1000, false), dp2(1000, false), dp3(1000, false);
  for(int i=0;i<n;++i) {
    int now = s[i] - '0';
    for(int j=0;j<1000;++j) {
      if(dp2[j] && j * 10 + now < 1000) {
        dp3[j * 10 + now] = true;
      }
    }
    for(int j=0;j<1000;++j) {
      if(dp1[j] && j * 10 + now < 1000) {
        dp2[j * 10 + now] = true;
      }
    }
    dp1[now] = true;
  }

  int cnt = 0;
  for(int i=0;i<1000;++i) {
    cnt += dp3[i];
  }
  cout << cnt << endl;
}


Measured memory_bytes: 384
#include <stdio.h>
#include <set>
using namespace std;

set<int> S[200200];
int N,M;

int main()
{
	scanf ("%d %d",&N,&M);
	for (int i=0;i<M;i++){
		int x,y; scanf ("%d %d",&x,&y);
		S[x].insert(y);
		S[y].insert(x);
	}

	int ans = 0;
	for (int x : S[1]) if (S[N].count(x)) ans++;
	puts(ans?"POSSIBLE":"IMPOSSIBLE");

	return 0;
}

Measured memory_bytes: 28416
// #include "pch.h"
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <climits>
#include <string>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <ctime>
#include <cassert>
#include <fstream>
#include <stack>
#include <random>
#include <atcoder/math>

typedef long long ll;
typedef std::pair<int, int> Pii;
typedef std::pair<long long, long long> Pll;
typedef std::pair<double, double> Pdd;

#define rip(i, n, s) for (int i = (s);i < (int)( n ); i++)
#define all(a) a.begin(), a.end()
#define MM << " " <<

template<typename T>
using MaxHeap = std::priority_queue<T>;
template<typename T>
using MinHeap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

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

template<typename T>
void vdeb(std::vector<T> &da) {
    for (int i = 0;i < da.size();i++) {
        if (i == da.size() - 1) std::cout << da[i];
        else std::cout << da[i] << ' ';
    }
    std::cout << '\n';
}
template<typename T>
void vdeb(std::vector<std::vector<T>> &da) {
    for (int i = 0;i < da.size();i++) {
        std::cout << i << ' ';
        vdeb(da[i]);
    }
    std::cout << '\n';
}

using namespace std;
namespace ac = atcoder;

int main() {
    int t; cin >> t;
    rip(i,t,0) {
        ll n,m,a,b; cin >> n >> m >> a >> b;
        printf("%lld\n", ac::floor_sum(n,m,a,b));
    }
}

Measured memory_bytes: 3756
a=input()
b=input()
mincount=1000000
for i in range(len(a)-len(b)+1) :
  count=0
  for j in range(len(b)) :
    if a[i+j]!=b[j] :
      count+=1
  mincount=min(count,mincount)
print(mincount)
  
  

Measured memory_bytes: 67532
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        String s = sc.next();
        int counter = 0;
        for (int i = 1; i < s.length(); i++) {
            if (s.charAt(i) == 'E') {
                counter++;
            }
        }
        int res = counter;
        for (int i = 1; i < s.length(); i++) {
            if (s.charAt(i - 1) == 'W') {
                counter++;
            }
            if (s.charAt(i) == 'E') {
                counter--;
            }
            res = Math.min(res, counter);
        }
        System.out.println(res);
        sc.close();
    }
}

Measured memory_bytes: 42376
#include <iostream>

int main()
{
	int n {}; // number of participants
	long k {}; // initial score
	int q {}; // total number of answers
	std::cin >> n >> k >> q;
	
	long a[n] {}; // initial score
	for (int i {}; i < n; i++)
		a[i] = k - q;
	
	for (int i {}; i < q; i++)
	{
		int temp_ans {};
		std::cin >> temp_ans;
		temp_ans--;
		a[temp_ans]++;
	}
	
	for (int i {}; i < n; i++)
		if (a[i] > 0)
			std::cout << "Yes" << std::endl;
		else std::cout << "No" << std::endl;
}

Measured memory_bytes: 1408
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <math.h>
#include <iomanip>
#include <bitset>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <utility>
#include <set>
#include <map>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> pairs;

#define MOD 998244353


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

bool primeNumber(ll n){
    if(n < 2) return false;
    else{
        for(ll i = 2; i * i <= n; i++){
            if(n % i == 0) return false;
        }
        return true;
    }
}


bool isPalindrome(string s){
    string t = s;
    reverse(t.begin(), t.end());
    return s == t;
}

int main(){
    string s;
    cin>>s;
    bool ans = true;
    if (!isPalindrome(s)) ans = false;
    if(!isPalindrome (s.substr(0, s.size()/2))) ans = false;
    cout<<(ans ? "Yes":"No")<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
int main() {
    string s,t;
    cin>>s>>t;
    int ans=0;
    for(int i = 0;i < s.size();++i) {
        if(s[i]!=t[i])++ans;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3916
#include<iostream>
#include<cstdio>
#include<string>
#include<cstring>
#include<climits>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<stack>
#include<queue>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pb push_back
#define mp make_pair
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define INF 1e9+7
#define LLINF 1e18
// #define int ll
using namespace std;
const int MOD = 1e9 +7;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,k;
    ll ans=0;
    cin>>n>>k;
    if(k==0){
        ans =(ll)n*n;
        cout<<ans<<endl;
        return 0;
    }
    rep2(i,1,n+1){
        if(k<i){
            ans += i-k;
            ans += (n-i+1)/i *(i-k);
            int a =(n-i+1)%i;
            if(a>=k){
                ans+= a-k;
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
N = int(input())

List = []
point = [0,(0,0)]
Answer = 'Yes'
for _ in range(N):
  t,x,y = map(int,input().split())
  List.append([t,(x,y)])

for item in List:
  ability = item[0] -point[0]
  length = item[1][0]+item[1][1]-point[1][0]-point[1][1]
  if length > ability:
    Answer = 'No'
    break
  elif (ability - length) % 2 == 1:
    Answer = 'No'
    break
  else:
    point = item

print(Answer)

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

int main() {
  int a,b;
  cin>>a>>b;
  int res=0;
  vector<int> mo={-1,31,30,31,30,31,30,31,31,30,31,30,31};
  for (int i=1; i<=a; i++) {
    for (int j=1; j<=(i<a?mo[i]:b); j++) {
      res+=(i==j);
    }
  }
  cout<<res<<endl;
  return 0;
}

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

int main(){
	int n;	cin>>n;
	vector<bool> cat(100,false);
	stack<int> hole;

	int ans=0;

	for(int i=1;i<=n;i++){
		int x;	cin>>x;
		if(x>0){
			if(cat[x]==false){
				cat[x]=true;
				hole.push(x);
			}
			else{
				ans=i;
				break;
			}
		}else if(x<0){
			x*=(-1);
			if(cat[x]==true && hole.top()==x){
				hole.pop();
				cat[x]=false;
			}
			else{
				ans=i;
				break;
			}
		}
	}
	if(ans!=0)cout<<ans<<endl;
	else cout<<"OK"<<endl;

	return 0;
}



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

int modnum = 1e9+7;

int main(){
    int N;
    std::cin >> N;
    std::vector< int > A(N);
    for(int i=0; i<N; i++){
        std::cin >> A[i];
    }
    
    long long cur_sum = 0;
    long long ans = 0;
    for(int i=0; i<N; i++){
        ans = (ans + (cur_sum * A[i]) % modnum) % modnum;
        cur_sum = (cur_sum + A[i]) % modnum;
    }
    
    std::cout << ans << std::endl;
    
    
    return 0;
    
}


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

//using Graph = vector<vector<edge>>;
using dou =long double;
string yes="yes";
string Yes="Yes";
string YES="YES";
string no="no";
string No="No";
string NO="NO";

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define rep(i, n)         for(int i = 0; i < (int)(n); i++)
#define brep(n)           for(int bit=0;bit<(1<<n);bit++)
#define erep(i,container) for (auto i : container)
#define irep(i, n)        for(int i = n-1; i >= (int)0; i--)
#define rrep(i,m,n) for(ll i = m; i < (ll)(n); i++)
#define reprep(i,j,h,w) rep(i,h)rep(j,w)
#define all(x) (x).begin(),(x).end()
#define VEC(type,name,n) std::vector<type> name(n);rep(i,n)std::cin >> name[i];
#define pb push_back
#define pf push_front
#define query int qq;std::cin >> qq;rep(qqq,qq)
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define itn int
#define mp make_pair
#define sum(a) accumulate(all(a),0ll)
#define keta fixed<<setprecision
#define vvector(name,typ,m,n,a)vector<vector<typ> > name(m,vector<typ> (n,a))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<t>(n,a)));
#define vvvvector(name,t,k,l,m,n,a) vector<vector<vector<vector<t> > > > name(k,vector<vector<vector<t> > >(l, vector<vector<t> >(m, vector<t>(n,a)) ));
#define case std::cout <<"Case #" <<qqq+1<<": "
#define res resize
#define as assign
#define ffor for(;;)
#define ppri(a,b) std::cout << a<<" "<<b << std::endl
#define pppri(a,b,c) std::cout << a<<" "<<b <<" "<< c<<std::endl
#define aall(x,n) (x).begin(),(x).begin()+(n)
#define ssum(a) accumulate(a,0ll) 
#define gre(n) greater<n>()

typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
//typedef long long T;
const int INF = 1000000000;
const ll INF64 = 922337203685477580ll;
const ll MOD = 1000000007ll;
const dou pi=3.141592653589793;

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 moddiv(ll a,ll b){
    a%=MOD;
    return a*modinv(b,MOD)%MOD;
}
int main(){
    ll n,k;
    std::cin >> n>>k;
    VEC(ll,a,n);
    std::vector<ll> c1(n),c2(n);
    ll ans=0;
    rep(i,n){
        rep(j,n){
            if(a[i]>a[j]){
                c1[i]++;
                if(i<j)c2[i]++;
            }
        }
    }

    rep(i,n){
        ll d=((2*c2[i]+(k-1)*c1[i]))%MOD;
        
        d*=k;
        //d/=2;
        d=moddiv(d,2ll);
        ans+=d;
        //ans+=k*((2*c2[i]+((k-1)*c1[i])))/2;
        ans%=MOD;
    }
    
    std::cout << ans << std::endl;
 //   erep(i,c2)std::cout << i << std::endl;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    int n, v[100], c[100], x, y, i;
    
    scanf("%d",&n);
    for(i=0;i<n;i++) scanf("%d",&v[i]);
    for(i=0;i<n;i++) scanf("%d",&c[i]);
    
    x=y=0;
    for(i=0;i<n;i++){
        if(v[i]>c[i]){
            x+=v[i];
            y+=c[i];
        }
    }
    printf("%d\n",x-y);
    return 0;
}

Measured memory_bytes: 128
#define _USE_MATH_DEFINES
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <ctype.h>
#include <limits.h>	
#define inf (INT_MAX-1)
#define INF 9223372036854775807
#define EPS 1e-10
#define sq(n) ((n)*(n))
#define rep(i,n) for(i=0;i<n;i++)
#define rev(i,n) for(i=n-1;i>=0;i--)
#define sort(a,n) qsort(a,n,sizeof(TYPE),cmp)
#define sort_r(a,n) qsort(a,n,sizeof(TYPE),cmp_r);
#define chsort(s,n) qsort(s,n,sizeof(char),cmp)
#define chsort_r(s,n) qsort(s,n,sizeof(char),char_cmp_r);
#define TYPE int
#define MEMSET(a) memset(a,0,sizeof(a))
const int mod=(int)1e09+7;

int in(void){
	int i;scanf("%d",&i);
	return i;
}
long long llin(void){
	long long i;scanf("%lld",&i);
	return i;
}
double din(void){
	double i;scanf("%lf",&i);
	return i;
}
void chin(char s[]){
	scanf("%s",s);
}
void print(int a){
	printf("%d\n",a);
}
void llprint(long long a){
	printf("%lld\n",a);
}
void dprint(double a){
	printf("%.10f\n",a);
}
void print2(int a,int b){
	printf("%d %d\n",a,b);
}
long long max(long long a,long long b){
	return a>b?a:b;
}
long long min(long long a,long long b){
	return a<b?a:b;
}
long long llabs(long long a){
	return a>0?a:-a;
}
double dmax(double a,double b){
	return a>b?a:b;
}
int cmp(const void *a,const void *b){
	return *(TYPE *)a-*(TYPE *)b;
}
int cmp_r(const void *a,const void *b){
	return *(TYPE *)b-*(TYPE *)a;
}
int char_cmp(const void *a,const void *b){
	return strcmp((char *)a,(char *)b);
}
int char_cmp_r(const void *a,const void *b){
	return strcmp((char *)b,(char *)a);
}
void swap(int *a,int *b){
	int t=*a;
	*a=*b;
	*b=t;
}
long long gcd(long long x,long long y){
	return x%y?gcd(y,x%y):y;
}
long long lcm(long long x,long long y){
	return x/gcd(x,y)*y;
}

// konoshita kara kaku

int main(void){
	int n=in(),a[100000],i,m=0,b=0,c=inf;
	rep(i,n)a[i]=in();
	sort(a,n);
	m=a[n-1];
	rep(i,n){
		if(c>abs(a[i]-(m+1)/2)){
			b=a[i];
			c=abs(a[i]-(m+1)/2);
		}
	}
	print2(m,b);
	return 0;
}

Measured memory_bytes: 892
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <cmath>
#include <iomanip>
#include <algorithm>
using namespace std;
using ll = long long;

int main(){
    int n;
    cin >> n;
    cout << n*n << endl;
    return 0;
}


Measured memory_bytes: 256
#coding:utf-8
import sys
sys.setrecursionlimit(10**6)
write = sys.stdout.write
dbg = lambda *something : print(*something) if DEBUG else 0
DEBUG = False
def main(given = sys.stdin.readline):
    input = lambda : given().rstrip()
    LMIIS = lambda : list(map(int,input().split()))
    II = lambda : int(input())
    XLMIIS = lambda x : [LMIIS() for _ in range(x)]

    N = II()
    P = input().replace(' ','')
    Q = input().replace(' ','')

    kouho = set(range(1,N+1))
    def kaijo(n):
        ans = 1
        for i in range(1,n+1):
            ans *= i
        return ans
    numbers = [0] * kaijo(N)
    # print(len(numbers))
    from copy import copy
    def mkp(kouho,i,p):
        if i == N-1:
            numbers.append(p+kouho[0])
            return

        for j in range(len(kouho)):
            kouho2 = copy(kouho)
            kouho2.remove(kouho[j])
            mkp(kouho2,i+1,p+kouho[j])
    mkp(list(map(str,range(1,N+1))),0,'')
    numbers = numbers[kaijo(N):]


    print(abs(numbers.index(P)-numbers.index(Q)))
    



   




if __name__ == '__main__':
    main()

Measured memory_bytes: 55388
#include <bits/stdc++.h>
#define loop(n, i) for(int i=0;i<n;i++)
#define loop1(n, i) for(int i=1;i<=n;i++)
#define rloop(n, i) for(int i=n-1;i>=0;i++)
#define HERE cout << "HERE: " << __LINE__ << endl;
#define INSP(v) cout << v << " at " << __LINE__ << endl;
using namespace std;
using ll = long long;
template <class T>
using V = vector<T>;

V<ll> A;
ll sum = 0;
ll n, k;

int solve(ll m) {
    V<ll> B(n);
    if (sum % m) return 0;
    loop (n, i) B[i] = A[i] % m;
    ll sum2 = 0;
    loop (n, i) sum2 += B[i];
    if (sum2 % m) return 0;

    sort(B.begin(), B.end());
    ll s = 0;
    loop (n - sum2 / m, i) s += B[i];
    return s <= k;
}

int main() {
    cin >> n;
    cin >> k;
    A.assign(n, 0);
    loop (n, i) cin >> A[i];
    loop (n, i) sum += A[i];

    for (ll i = 1; i * i <= sum; i++) {
        if (sum % i) continue;
        ll m = sum / i;
        if (solve(m)) {
            cout << m << endl;
            return 0;
        }
    }
    for (ll m = sqrt(sum) + 1; m > 0; m--) {
        if (sum % m) continue;
        if (solve(m)) {
            cout << m << endl;
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 384
#pragma region
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue> 
#include <stack>
#include <set>
#include <list>

using namespace std;
typedef long long ll;
//#define rep(i, s, e) for (int(i) = (s); (i) < (e); ++(i))
#define rep(i, e) for (int(i) = 0; (i) < (e); ++(i))
#define rrep(i, s) for (int(i) = (s) - 1; (i) >= 0; --(i))
#define all(x) x.begin(),x.end()
#pragma endregion


int main()
{
	string s; cin >> s;
	int q; cin >> q;
	int now = 0;
	deque<char> dq;
	for (char x : s)dq.push_back(x);
	while (q--)
	{
		int x; cin >> x;
		if (x == 1)now = 1 - now;
		else
		{
			int f; cin >> f;
			char c; cin >> c;
			if ((now + f) % 2 == 1)dq.push_front(c);
			else dq.push_back(c);
		}
	}
	if (now == 1)
	{
		while (!dq.empty())
		{
			cout << dq.back();
			dq.pop_back();
		}
	}
	else
	{
		while (!dq.empty())
		{
			cout << dq.front();
			dq.pop_front();
		}
	}
}

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

int main(){
  int n,m[200000],max=-1000000000,min;
  cin>>n;
  for(int i=0;i<n;i++) cin>>m[i];
  min=m[0];
  for(int i=1;i<n;i++){
      if(max<m[i]-min) max=m[i]-min;
      if(min>m[i]) min=m[i];
    }
  cout<<max<<endl;
  return 0;
}

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

using namespace std;
using ll = long long;
using v1 = vector<int>;
using v2 = vector<vector<int>>;

int main(){
	string s;
	cin >> s;
	ll sum = 0;
	int sz = s.size()-1;
	reverse(s.begin(), s.end());
	for(int bit = 0; bit < (1<<sz); ++bit){
		for(int i = 0; i <= sz; ++i){
			int start = i;
			int goal = 1;
			while(!(bit & (1 << i))){
				if(i == sz) break;
				i++;
				goal++;
			}
			string s2 = s.substr(start, goal);
			reverse(s2.begin(), s2.end());
			sum += stoll(s2);
		}
	}
	cout << sum << endl;
}


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

using namespace std;

const int maxn = 100010;

int n, A[maxn], B[maxn];
long long ans = 0, s = 0;

int main() {
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) scanf("%d%d", &A[i], &B[i]);
	for (int i = n; i >= 1; i--) {
		A[i] = (A[i] + s) % B[i];
		if (!A[i]) continue;
		else {
			ans += B[i] - A[i];
			s += B[i] - A[i];
		}
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 1024
import sys
sys.setrecursionlimit(2147483647)
INF = 1 << 60
MOD = 10**9 + 7 # 998244353
input = lambda:sys.stdin.readline().rstrip()
from collections import Counter
def resolve():
    m, n, k = map(int, input().split())
    grid = [list(map(int, input())) for _ in range(m)]
    
    # grid が 1 の個数を k 以下にする
    # m <= 10 なので、m についてどこで切るかを全探索 -> その後 n について貪欲
    res = INF
    def adding(j):
        for i in range(m):
            counter[index_to_number[i]] += grid[i][j]

    for U in range(1 << (m - 1)):
        counter = Counter()
        index_to_number = [None] * m
        now = 0
        for i in range(m):
            index_to_number[i] = now
            now += (U >> i) & 1
        score = bin(U).count('1')
        # print(U, index_to_number)
        for j in range(n):
            # 一旦足してみる
            adding(j)
            if max(counter.values()) > k:
                score += 1
                counter.clear()
                adding(j) # もう1回やりなおす
                if max(counter.values()) > k: # やりなおした結果ダメなら無理
                    break
        else: # break されずに済めば OK
            res = min(res, score)

    print(res)
resolve()

Measured memory_bytes: 44892
#include <iostream>
#include <cstdint>
#include <vector>
#include <algorithm>

int main() {
    int N, M;
    
    std::cin >> N >> M;
    std::vector<std::pair<int, int>> price;
    
    std::pair<int, int> temp;
    
    for (int i=0; i<N; ++i) {
        std::cin >> temp.first >> temp.second;
        price.push_back(temp);
    }
    std::sort(price.begin(), price.end(), [](const std::pair<int,int>& x, const std::pair<int,int>& y){return x.first < y.first;});
    
    int64_t ans = 0;
    int64_t num = 0;
    for (int i=0; i<N; ++i) {
        for (int j=0; j<price[i].second; ++j) {
            if (num >= M) {
                break;
            } else {
                ans += price[i].first;
                num++;
            }
        }
    }
    std::cout << ans << std::endl;
}

Measured memory_bytes: 1400
// Coded by- Rad0n  275484HW

#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define all(a) a.begin(),a.end()
#define lb(a,x) (lower_bound(all(a),x)-a.begin())
#define ub(a,x) (upper_bound(all(a),x)-a.begin())
#define forn(i,n) for(int i=0;i<int(n);i++)
#define forr(i,n) for(int i=int(n-1);i>=0;i--)
#define fora(i,a,b) for(int i=int(a);i<=int(b);i++)
#define forb(i,a,b) for(int i=int(a);i>=int(b);i--)
#define test int t,o;cin>>o;for(t=1;t<=o;t++)
#define kickstart int t,o;cin>>o;for(t=1;t<=o;t++){cout<<"Case #"<<t<<": ";solve();}
#define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#define time__(d) for(long blockTime = 0; (blockTime == 0 ? (blockTime=clock()) != 0 : false); debug("%s time : %.4fs", d, (double)(clock() - blockTime) / CLOCKS_PER_SEC))
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define o_set tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>
#define o_multiset tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update>
using namespace __gnu_pbds;
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
using ll=long long int;
#define mod 1000000007
mt19937 rng(time(NULL));
vector<int> pew[100];
int arr[100];
int rans=1e9;
void go(int cur,int n,int m,int k,std::vector<int> skills,int cost)
{
	bool good=1;
	for(auto i:skills)
	{	
		if(i<k)good=0;
	}
	if(good)rans=min(cost,rans);
	if(cur==n)
	{
		return;
	}

	forn(i,m)
	{
		skills[i]+=pew[cur][i];
	}

	go(cur+1,n,m,k,skills,cost+arr[cur]);

	forn(i,m)
	{
		skills[i]-=pew[cur][i];
	}
	go(cur+1,n,m,k,skills,cost);

}
void solve()
{
	int n,m,k;
	cin>>n>>m>>k;
	for(int i=0;i<n;i++)
	{
		cin>>arr[i];
		for(int j=0;j<m;j++)
		{
			int a;
			cin>>a;
			pew[i].pb(a);
		}
	}
	vector<int> skills(m,0);
	go(0,n,m,k,skills,0);
	if(rans==1e9)rans=-1;
	cout<<rans<<endl;

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


Measured memory_bytes: 3644
#include <bits/stdc++.h>
#define FOR(i, a, n) for(int (i) = (int)(a); (i) < (int)(n); ++(i))
#define FORe(i, a, n) for(int (i) = (int)(a); (i) <= (int)(n); ++(i))
#define rFOR(i, a, n) for(int (i) = (int)(n)-1; (i) >= (int)(a); --(i))
#define rFORe(i, a, n) for(int (i) = (int)(n); (i) >= (int)(a); --(i))
#define REP(i, n) FOR((i), 0, (n))
#define REPe(i, n) FORe((i), 1, (n))
#define REPo(i, n) FORe((i), 0, (n))
#define rREP(i, n) rFOR((i), 0, (n))
#define rREPe(i, n) rFORe((i), 1, (n))
#define rREPo(i, n) rFORe((i), 0, (n))
#define rep(i, n) FOR((i), 0, (n))
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define fi first
#define se second
#define dup(x, y) (((x)+(y)-1)/(y))
#define vc(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
using ll = long long;
using P = pair<int,int>;
using T = tuple<int,int,int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vs = vector<string>;
using vp = vector<P>;
using vt = vector<T>;

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

int n, m, q;
vi a, b, c, d;
int ans;

void dfs(vi A) {
  if (A.size() == n+1) {
    int now = 0;
    REP(i, q) {
      if (A[b[i]] - A[a[i]] == c[i]) now += d[i];
    }
    chmax(ans, now);
    return;
  }
  A.emplace_back(A.back());
  while (A.back() <= m) {
    dfs(A);
    A.back()++;
  }
}

int main() {
  cin >> n >> m >> q;
  a = b = c = d = vi(q);
  REP(i, q) cin >> a[i] >> b[i] >> c[i] >> d[i];
  dfs(vi(1,1));
  cout << ans << endl; 

  return 0;
}

Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<LL,LL> P;

int main(){
    int N;
    cin >> N;
    deque<LL> dq;
    if(N%2==0){
        for(int i=0;i<N;i++){
            LL t;
            cin >> t;
            if(i%2==0) dq.push_back(t);
            else dq.push_front(t);
        }
        for(int i=0;i<N;i++){
            cout << dq.front() << " ";
            dq.pop_front();
        }
        cout << "\n";
    }
    else{
        for(int i=0;i<N;i++){
            LL t;
            cin >> t;
            if(i%2==0) dq.push_front(t);
            else dq.push_back(t);
        }
        for(int i=0;i<N;i++){
            cout << dq.front() << " ";
            dq.pop_front();
        }
        cout << "\n";
    }
    return 0;
}

Measured memory_bytes: 3840
import sys
def input(): return sys.stdin.readline().rstrip()

def main():
    H, W, K = map(int, input().split())
    S = [tuple(map(int, list(input()))) for _ in range(H)]

    ans = 10 ** 9

    for bit in range(1 << (H-1)):
        canSolve = True
        ord = [0] * (H + 1)
        N = 0
        for i in range(H):
            if bit & 1 << i:
                ord[i+1] = ord[i] + 1
                N += 1
            else:
                ord[i+1] = ord[i]
        nums = [0] * (H + 1)
        for w in range(W):
            one = [0] * (H + 1)
            overK = False
            for h in range(H):
                one[ord[h]] += S[h][w]
                nums[ord[h]] += S[h][w]
                if one[ord[h]] > K:
                    canSolve = False
                if nums[ord[h]] > K:
                    overK = True
            if not canSolve:
                break
            if overK:
                N += 1
                nums = one
        if canSolve and ans > N:
            ans = N
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 42972
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cstring>
#include <queue>
#include <vector>
#include <functional>
#include <map>
#include <set>
#include <cmath>
#include <string>
#define SIZE 100005
#define INF 1000000005LL

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

ll S[SIZE];
ll A,B;
int n;

bool check(ll t)
{
	ll cnt=0;
	for(int i=0;i<n;i++)
	{
		ll now=max(0LL,S[i]-B*t);
		cnt+=(now+A-1)/A;
	}
	return cnt<=t;
}
int main()
{
	scanf("%d %lld %lld",&n,&A,&B);
	A-=B;
	for(int i=0;i<n;i++) scanf("%lld",&S[i]);
	ll l=-1,r=INF;
	while(r-l>1)
	{
		ll m=(l+r)/2;
		if(check(m)) r=m;
		else l=m;
	}
	printf("%lld\n",r);
	return 0;
}


Measured memory_bytes: 896
#include<stdio.h>
int main(){
	long int N,K;
	long int t[200001];
    long int ans=0;
	scanf("%d %d",&N, &K);

	for(long int a = 0; a < N; a++)
	{
		scanf("%ld", &t[a]);
	}
   
    t[N]=1000000001+K;

	for(long int b = 0; b < N;b++){
		if (K > t[b+1]-t[b])
		{
			ans += t[b + 1] - t[b];
		}else{
			ans += K;
		}
	}

	printf("%ld", ans);
	return 0;
}

Measured memory_bytes: 1664
N = int(input())
A = []
for _ in range(N):
    A.append(int(input()))
A.sort()
ans = 0
idx = 0
while idx < N:
    sub = 0
    while idx + sub < N and A[idx] == A[idx + sub]:
        sub = sub + 1
    if sub % 2 == 1:
        ans = ans + 1
    idx = idx + sub
print(ans)

Measured memory_bytes: 7388
dx,dy = [-1,0,1,0],[0,-1,0,1]
while 1:
	N = input()
	if N == 0: break
	x,y = [0]*N,[0]*N
	for i in range(1,N):
		n,d = map(int,raw_input().split())
		x[i] = x[n]+dx[d]
		y[i] = y[n]+dy[d]
	print max(x)-min(x)+1,max(y)-min(y)+1

Measured memory_bytes: 4244
//自称高知能系Vtuberの高井茅乃です。
//Twitter: https://twitter.com/takaichino
//YouTube: https://www.youtube.com/channel/UCTOxnI3eOI_o1HRgzq-LEZw

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

#define INF 1999999999
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define MODA 1000000007 

int main() {
    int ans = 0;
	int li[31]= {};
	int n, m, k, temp;
	cin >> n >> m;
	REP(i, n){
		cin >> k;
		REP(j, k){
			cin >> temp;
			li[temp]++;

		}
	}
	REP1(i,m){
		if(li[i]==n)ans ++;
	}
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define MOD 1000000007
#define all(ppp) ppp.begin(),ppp.end()
#define out(ppp) cout<<(ppp)<<endl
#define out1(ppp) cout<<(ppp) 
#define MAX_CHAR 256

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
#define pb push_back

typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
typedef vector<vpi> vvpi;

typedef set<pi> spi;

const int INF=INT_MAX;

void solve(){
    int X,A;
    cin>>X>>A;
    if(X<A){
        out(0);
    }else{
        out(10);
    }

}

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

Measured memory_bytes: 256
/*
	rupc2017day1_E: Graduation_Ceremony
	https://github.com/ixmelrd/rupc2017/blob/master/Graduation_Ceremony/Yazaten/main.cc
*/
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define ALL(A) A.begin(), A.end()

using namespace std;

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

int dp[2][2][2001][2001];

int main()
{
	memset(dp, 0, sizeof(dp));
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	string s; cin >> s;
	int k; cin >> k;
	
	int n = s.length();
	map<char,int> mp[2][2];
	mp[0][0]['U'] = 0, mp[0][0]['D'] = 0, mp[0][0]['R'] =+1, mp[0][0]['L'] =-1;
	mp[0][1]['U'] = 0, mp[0][1]['D'] = 0, mp[0][1]['R'] =-1, mp[0][1]['L'] =+1;
	mp[1][0]['U'] =+1, mp[1][0]['D'] =-1, mp[1][0]['R'] = 0, mp[1][0]['L'] = 0;
	mp[1][1]['U'] =-1, mp[1][1]['D'] =+1, mp[1][1]['R'] = 0, mp[1][1]['L'] = 0;

	rep (x_y, 2){
 		rep (pos_neg, 2){
			for (int i = 1; i <= n; ++i){
				for (int j = 0; j <= k; ++j){
					int sign = (j % 2 == 0 ? +1 : -1);
					int add  = mp[x_y][pos_neg][s[i-1]] * sign;
					dp[x_y][pos_neg][i][j] = dp[x_y][pos_neg][i-1][j] + add;
					if (j - 1 >= 0){
						dp[x_y][pos_neg][i][j] = max(dp[x_y][pos_neg][i][j], dp[x_y][pos_neg][i-1][j-1] - add);
					} // end if
				} // end for
			} // end for
		} // end rep
	} // end rep

	vector<int> x(k+1, 0), y(k+1, 0);
	for (int i = 0; i <= k; ++i){
		x[i] = max(abs(dp[0][0][n][i]), abs(dp[0][1][n][i]));
	} // end for
	rep (i, k){
		x[i+1] = max(x[i+1], x[i]);
	} // end rep
	for (int i = 0; i <= k; ++i){
		y[i] = max(abs(dp[1][0][n][i]), abs(dp[1][1][n][i]));
	} // end for
	rep (i, k){
		y[i+1] = max(y[i+1], y[i]);
	} // end for

	int ans = -1;
	for (int i = 0; i <= k; ++i){
		ans = max(ans, x[i] + y[k-i]);
	} // end for
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 65812