akhauriyash/Code-Regression huggingface dataset:
//Name : Rupa Dey
  //Date : 05 September 2020
//joi sri gour hori gobindo...
//gobindo ja hobe vlor jonnoi hobe..
#include<bits/stdc++.h>
#define ll long long
#define d double
#define ld long double
#define vi vector<int>
#define vul vector<ull>
#define vl vector<ll>
#define pb push_back
#define si set<int>
#define sl set<ll>
#define yes cout<<"YES\n"<<endl
#define no cout<<"NO\n"<<endl
#define ys cout<<"Yes\n"<<endl
#define n0 cout<<"No\n"<<endl
#define test cin>>t; while(t--)
//#define for(i,a,n) for(i=a;i<n;i++)
#define mp make_pair
#define ft first
#define sc second
#define gp ' ';
#define MAX 9999999
#define MOD 1000000007
#define nd endl
using namespace std;
bool prime(int);

/*bool prime(int a)
{
    int cnt=0,i;
    for(i=2;i<=sqrt(a);i++)
    {
        if(a%i==0) cnt++;
    }
    if(cnt==0) return true;
    else  return false;
}*/
bool isPrime(ll a)
{
    ll i;
    if(a==2 || a==3) return true;
    if(a%2==0 || a%3==0) return false;
    for(i=5;i*i<=a;i++)
    {
        if(a%i==0 || a%(i+2)==0) return false;
    }
    return true;
}
/*int nxtPrime(ll x)
{
    if(x==2) return 2;
    if(x==3) return 3;
    ll p = x;
    bool prime = false;

    while(!prime)
    {
        p++;
    if(isPrime(p)) prime = true;
    }
    return p;
}*/
int main()
{
   ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n,i;
  //  cin>>n;
    //cout<<nxtPrime(n);
    for(cin>>n;;n++)
    {
        if(isPrime(n))
            cout<<n,exit(0);
        //return 0;
    }

}
//hare krishna...
//hey gobindo kripa koro......
//only gobindo exists..^..


Measured memory_bytes: 3636
#include <bits/stdc++.h>
// #include <fstream>
using namespace std;
int main()
{
    // // 以降 cin の入力元が 'input.txt' になる
    // std::ifstream in("tests/sample-2.in");
    // std::cin.rdbuf(in.rdbuf());

    // ここにプログラムを記載
    string wrongdate;
    cin >> wrongdate;
    wrongdate[3] = '8';
    cout << wrongdate << endl;
}

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

//typedef
//------------------------------------------
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

// grid
//--------------------------------------------
VL dx = {0, 1, 0, -1};
VL dy = {1, 0, -1, 0};
VL dx2 = {-1, 0, 1, -1, 1, -1, 0, 1};
VL dy2 = {-1, -1, -1, 0, 0, 1, 1, 1};
 
//debug
//--------------------------------------------
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//roop
//--------------------------------------------
#define rep(i,s,n) for(LL i = (s); i < (n); i++)
#define rep0(i,n) rep(i,0,n)
#define rep1(i,n) rep(i,1,n+1)

int main(){
    int N, buttun;
    cin >> N;
    int cnt = 0;
    int i = 0;
    int a[N] = {};
    rep0(i, N){
        cin >> a[i];
    }
    rep1(j,N){
        buttun = a[i];
        i = buttun - 1;
        cnt++;
        if (buttun == 2){
            cout << cnt << endl;
            return 0;
        }
    }
    cout << -1 << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include<algorithm>
#include<string>
#include <map>
#include <queue>
#include <stack>
#include<set>

#define DIV 1000000007

using namespace std;
using ll = long long;
using ldb = long double;

int main() {
	int N; cin >> N;
	string s; cin >> s;
	int L = 0, R = 0;
	for (int i = 0; i < N; i++) {
		if (s[i] == '(') L++;
		else if (s[i] == ')') {
			if (L > 0) L--;
			else R++;
		}
	}
	int cnt = 0;
	for (int i = 0; i < R; i++) cout << '(';	
		cout << s;
	for (int i = 0; i < L; i++) cout << ')';
}


Measured memory_bytes: 256
import sys
from heapq import heapify, heappush, heappop
from itertools import accumulate

inf = 1<<100

def solve():
    N = int(input())
    a = [int(i) for i in input().split()]
    ps = [0] + list(accumulate(a))

    psmin = [0] * (N + 1)
    minhp = a[:N]
    heapify(minhp)

    for i in range(1, N + 1):
        heappush(minhp, a[N - 1 + i])
        x = heappop(minhp)
        psmin[i] = psmin[i - 1] + x

    psmax = [0] * (N + 1)
    maxhp = [-ai for ai in a[2*N:]]
    heapify(maxhp)

    for i in range(1, N + 1):
        heappush(maxhp, -a[2*N - i])
        x = -heappop(maxhp)
        psmax[i] = psmax[i - 1] + x

    # print(psmin)
    # print(psmax)

    ans = -inf

    for i in range(0, N + 1):
        # print(ps[N + i], psmin[i], ps[3*N] - ps[N + i], psmax[N - i])
        v = (ps[N + i] - psmin[i]) - (ps[3*N] - ps[N + i] - psmax[N - i])
        ans = max(ans, v)

    print(ans)
    pass

if __name__ == '__main__':
    solve()

Measured memory_bytes: 119840
#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 10;

int N;
double x[MAX_N], y[MAX_N], sum = 0, t = 0;
int frac[MAX_N], C[MAX_N];

void init(int N) {
    frac[0] = 1;
    for (int i = 1; i <= N; i++) frac[i] = frac[i-1]*i;
    C[0] = 1;
    N -= 2;
    for (int i = 1; i <= N; i++) C[i] = C[i-1]*(N-i+1)/i;
    return;
}

int main() {
    scanf("%d", &N);
    for (int i = 1; i <= N; i++) {
        scanf("%lf %lf", &x[i], &y[i]);
    }
    for (int i = 1; i <= N; i++) {
        for (int j = i+1; j <= N; j++) {
            sum += sqrt(pow(x[i]-x[j], 2)+pow(y[i]-y[j], 2));
        }
    }
    sum *= 2;
    init(N);
    for (int i = 0; i <= N-2; i++) {
        t += C[i]*frac[i]*frac[N-2-i];
    }
    t /= frac[N];
    printf("%.10lf\n", t*sum);
    return 0;
}


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

int main() {
    int n;
    cin>>n;
    vector<int> vec(n);
    for(int i=0;i<n;i++){
        cin>>vec.at(i);
    }
    int min=vec.at(0);
    int result=1;
    for(int i=1;i<n;i++){
        if(vec.at(i)<=min){
            min=vec.at(i);
            result++;
        }else{
            continue;
        }
    }
    cout<<result<<endl;

}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int inf=0x3f3f3f3f;
const int MOD=1e9+7;
const int maxn=5e5+10;
ll gcd(ll a, ll b){return (b==0)?a:gcd(b, a%b);}
bool isPrime(ll n) {
    if(n<=3){
        return n>1;
    }
    if(n%6!=1&&n%6!=5){
        return false;
    }
    ll sqr=sqrt(n);
    for(ll i=5;i<=sqr;i+=6){
        if(n%i==0||n%(i+2)==0){
            return false;
        }
    }
    return true;
}
int dis[4][2]={0,1,0,-1,1,0,-1,0};
 
 
 int main()
 {
 	int n,m;cin>>n>>m;
 	int sum=0;
 	sum+=(n-1)*n/2;
 	sum+=(m-1)*m/2;
 	cout<<sum<<endl;
  } 


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <functional>
#include <iostream>
#include <queue>
#include <string>
#include <vector>
#include <climits>

using namespace std;
using ll  = long long;
template <typename T> T In() {
    T t;
    cin >> t;
    return t;
}
template <typename T> vector<T> ReadVec1(int N) {
    vector<T> vec(N);
    for(int i = 0; i < N; i++)
        vec[i] = In<T>();
    return move(vec);
}
template <typename T> vector<vector<T>> Vec2(int i, int j, T ini = 0) {
    vector<vector<T>> vec(i, vector<T>(j, ini));
    return move(vec);
}
template <typename T> vector<vector<vector<T>>> Vec3(int i, int j, int k, T ini = 0) {
    vector<vector<vector<T>>> vec(i, vector<vector<T>>(j, vector<T>(k, ini)));
    return move(vec);
}

int main() {
    int N = In<int>(), W = In<int>();
    vector<int> ws(N), vs(N);
    for(int n = 0; n < N; n++){
        ws[n] = In<int>();
        vs[n] = In<int>();
    }
    const int maxV = N * 1000;
    auto dp = Vec2<ll>(N + 1, maxV + 1, INT_MAX);
    dp[0][0] = 0;
    for(int n = 0; n < N; n++) {
        dp[n+1][0] = 0;
        for(int v = 1; v <= maxV; v++) {
            if(v - vs[n]>=0){
                dp[n + 1][v] = min(dp[n][v], dp[n][v-vs[n]]+ws[n]);
            }
            else{
                dp[n + 1][v] = dp[n][v];
            }
        }
    }

    for(int v = maxV; v >= 0; v--) {
        if(dp[N][v] <= W){
            cout << v << endl;
            break;
        }
    }
}

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

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;

int main() {
  int n;
  cin >> n;
  rep(i, n) {
    int a;
    cin >> a;
    if (a % 2 == 0) {
      if (a % 3 != 0 && a % 5 != 0) {
        cout << "DENIED" << endl;
        return 0;
      }
    }
  }
  cout << "APPROVED" << endl;
  return 0;
}

Measured memory_bytes: 256
/*
[agc035] A - XOR Circle
*/

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;

const int MAX_N = 1e5;

int N;
int a[MAX_N];

bool solve() {
    if (a[N - 1] != 0 && N % 3 != 0) {
        return false;
    }
    sort(a, a + N);

    return (a[0] == a[N / 3 - 1] && a[N / 3] == a[2 * N / 3 - 1] &&
            a[2 * N / 3] == a[N - 1] && (a[0] ^ a[N / 3] ^ a[2 * N / 3]) == 0);
}

int main() {
    cin >> N;
    for (int i = 0; i < N; i++) {
        cin >> a[i];
    }

    cout << (solve() ? "Yes" : "No") << endl;

    return 0;
}


Measured memory_bytes: 640
#include <stdio.h>
int main(void)
{
	int a,b,c;
	
	while(scanf("%d",&a)!=EOF)
	{
	
	b=39;
	c=a%b;
	if(c==0)
	{
	printf("3C39\n");
	}
	else if(c<10)
	{
	printf("3C0%d\n",c);
	}
	else{
		printf("3C%d\n",c);
	}
	}

return 0;
}

Measured memory_bytes: 608
import java.util.Scanner;
class Main {
    public static void main (String[] args) {
        Scanner sc = new Scanner(System.in);
        while (true) {
        int a = sc.nextInt();
        String s = sc.next();
        int b = sc.nextInt();
        if (s.equals("?")) break;
        switch (s) {
        case "+":
        		System.out.println(a+b);
        		break;
        case "-":
        		System.out.println(a-b);
        		break;
        case "*":
        		System.out.println(a*b);
        		break;
        case "/":
        		System.out.println(a/b);
        		break;
        }
        }
    }
}


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

int countDivisor(int n){
    int result = 0;
    
    for (int i = 1; i<= n; i++){
        if (n % i == 0) result++;
    }
    return result;
}

int main(){
    int n;
    cin >> n;
    
    int numberOfAns = 0;
    
    for (int i = 1; i <= n; i += 2){
        if (countDivisor(i) == 8) numberOfAns++;
    }
    cout << numberOfAns << endl;
}

Measured memory_bytes: 256
fn gcd(x: usize, y: usize) -> usize {
    let mut x = x;
    let mut y = y;
    while y != 0 {
        let t = y;
        y = x % y;
        x = t;
    }
    x
}

fn lcm(x: usize, y: usize) -> usize {
    x * y / gcd(x, y)
}

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).unwrap();
    let mut iter = buf.split_whitespace();
    let n: usize = iter.next().unwrap().parse().unwrap();
    let m: usize = iter.next().unwrap().parse().unwrap();

    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).unwrap();
    let a_s = buf.split_whitespace()
        .map(|x| x.parse::<usize>().unwrap())
        .collect::<Vec<_>>();

    let mut div_cnt = 0usize;
    let mut a = a_s[0];
    loop {
        if a % 2 == 1 {
            break;
        }
        a /= 2;
        div_cnt += 1;
    }
    let div = 2usize.pow(div_cnt as u32);

    let mut ans = 0usize;
    if a_s.iter().find(|&&x| (x < div) || ((x/div)%2 == 0)) == None {
        let lcm_all = a_s.iter().fold(1, |lcm_all, a| lcm(lcm_all, (*a)/2));
        let lcm_mul = m / lcm_all;
        ans = lcm_mul / 2 + lcm_mul % 2;
    }

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


Measured memory_bytes: 8444
N = gets.to_i
as = gets.split.map(&:to_i)

def judge(a,c)
    if a % 2 == 0
        judge(a/2,c+1)
    else
        return c
    end
end

ans = 0

t = as.map{|x| judge(x,0)}
p t.inject(0) { |m, x| m + x }


Measured memory_bytes: 2428
#include <stdio.h>
#include <string.h>
int a[26];
int main(void){
    char s[100001];
    scanf("%s",s);
    int len=strlen(s),i;
    for(i=0;i<len;i++){
        a[s[i]-'0'-49]++;
    }
    for(i=0;i<26;i++){
        if(a[i]==0){
            printf("%c",i+'0'+49);
            break;
        }
    }
    if(i==26) printf("None");
    return 0;
}

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

using namespace std;

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

int main() {
	int k, s;
	cin >> k >> s;
	ll ans = 0;
	int x, y, z;
	for (int i = 0; i <= k; i++) {
		x = i;
		if (x > s) {
			break;
		}
		for (int j = 0; j <= k; j++) {
			y = j;
			if (y > s) {
				break;
			}
			z = s - (x + y);
			if (z <= k && z >= 0) {
				ans++;
			}
		}
	}
	
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using ll     = long long;
using pii    = pair<int, int>;
using pll    = pair<ll, ll>;
using vi     = vector<int>;
using vl     = vector<ll>;
using vvi    = vector<vi>;
using vvl    = vector<vl>;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}
template <class C>
void print(const C &c, std::ostream &os = std::cout) {
    std::copy(std::begin(c), std::end(c), std::ostream_iterator<typename C::value_type>(os, " "));
    os << std::endl;
}

int main() {
    ll n;
    cin >> n;
    vi x(n);
    vector<pii> xs;
    xs.reserve(n * n);
    for (ll i = 0; i < n; ++i) {
        cin >> x[i];
        x[i]--;
        xs.emplace_back(x[i], i + 1);
    }
    sort(xs.begin(), xs.end());
    vi ret(n * n, -1);
    vi touse;
    ll idx = 0;
    for (ll i = 0; i < n; ++i) {
        ret[xs[i].first] = xs[i].second;
        for (ll j = 0; j < xs[i].second - 1; ++j) {
            while (ret[idx] != -1)
                idx++;
            ret[idx] = xs[i].second;
        }
        for (int j = 0; j < n - xs[i].second; ++j) {
            touse.push_back(xs[i].second);
        }
    }
    idx = 0;
    for (auto &u : touse) {
        while (ret[idx] != -1)
            idx++;
        ret[idx] = u;
    }

    vi cnt(n + 1, 0);
    for (ll i = 0; i < n * n; ++i) {
        cnt[ret[i]]++;
        if (ret[i] == cnt[ret[i]]) {
            if (x[ret[i] - 1] != i) {
                cout << "No"
                     << "\n";
                return 0;
            }
        }
    }
    cout << "Yes"
         << "\n";
    print(ret);
    return 0;
}

Measured memory_bytes: 2812
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a,b,c,n,ans=0;
	cin>>a>>b>>c>>n;
	for(int i=0;i<=a;i++)
		for(int j=0;j<=b;j++)
			for(int k=0;k<=c;k++)
				if(500*i+100*j+50*k==n)
					ans++;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define vi vector<int>
#define vvi vector<vector<int>>
#define all(a) (a).begin(), (a).end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
const int MOD = 1e9+7;
const ll LINF = 1e18;
const int INF = 1e9;
ll A, B, C, D, E, F, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S, T;

int main()
{
    cin >> N;
    cout << ((N%1000) ? (1000-(N%1000)) : 0);
    
    return 0;
}

Measured memory_bytes: 3624
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <memory.h>
#include <math.h>
#include <assert.h>
#include <queue>
#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <iostream>
#include <functional>
#include <unordered_map>

using namespace std;
typedef pair<int, int> Pi;
typedef long long ll;
#define Fi first
#define Se second
#define pb(x) push_back(x)
#define sz(x) (int)x.size()
#define rep(i, n) for(int i=0;i<n;i++)
#define all(x) x.begin(), x.end()

int x, y;

void solve(){
	scanf("%d%d", &x, &y);
	int ans = ~0u>>1;
	if(x <= y)ans = min(ans, y-x);
	if(-x <= y)ans = min(ans, y+x+1);
	if(x <= -y)ans = min(ans, -y-x+1);
	if(-x <= -y)ans = min(ans, -y+x+2);
	printf("%d", ans);
}

int main(){
	int Tc = 1; //scanf("%d", &Tc);
	for(int tc=1;tc<=Tc;tc++){
		solve();
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<algorithm>
#include<string>
#include<vector>
#include <math.h>
#include <iomanip>

using namespace std;

int main()
{
	string s1,s2,s3;
	cin >> s1 >> s2 >> s3;
	cout << (s1[s1.length()-1] == s2[0] && s2[s2.length()-1] == s3[0] ? "YES": "NO") << endl;
}

Measured memory_bytes: 256
while True:
    n,k = map(int, input().split())
    if n == k == 0:
        break
    s = [int(x) for x in input().split()]
    for _ in range(n):
        b = [int(x) for x in input().split()]
        for i in range(k):
            s[i] -= b[i]
    print("Yes" if min(s) >= 0 else "No")

Measured memory_bytes: 7788
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <numeric>
#include <utility>
#include <string>
#include <deque>
#include <cassert>

using namespace std;

const int mod = 1e9 + 7;

bool can_plus(int n_plus, int n_minus, int k) {
	if (k % 2 == 1) {
		if (n_plus == 0) {
			return false;
		}
		k--;
		n_plus--;
	}

	return n_plus + (n_minus / 2 * 2) >= k;
}

int main() {
	int n, k;
	cin >> n >> k;

	int a;
	bool has0 = false;

	deque<int> num1, num2, num;  // plus, minus, both

	for (int i = 0; i < n; i++) {
		cin >> a;
		num.emplace_back(abs(a));
		if (a > 0) {
			num1.emplace_back(a);
		} else if (a < 0) {
			num2.emplace_back(abs(a));
		} else {
			has0 = true;
		}
	}

	fprintf(stderr, "num1 %lu, num2 %lu, has0 %d, k %d\n",
		num1.size(), num2.size(), has0 ? 1 : 0, k);

	long long ans = 1;
	if (can_plus(num1.size(), num2.size(), k)) {
		cerr << "plus" << endl;

		sort(num1.begin(), num1.end(), greater<int>());
		sort(num2.begin(), num2.end(), greater<int>());

		// 正にできる -> 絶対値の最大値
		if (k % 2 == 1) {
			ans = num1[0];
			num1.pop_front();
			k--;
		}
		while (k >= 2) {
			long long x1 = num1.size() < 2 ? -1 : 1LL * num1[0] * num1[1];
			long long x2 = num2.size() < 2 ? -1 : 1LL * num2[0] * num2[1];
			if (x1 >= x2) {
				ans *= num1[0];
				num1.pop_front();
				k--;
			} else {
				ans *= x2 % mod;
				num2.pop_front();
				num2.pop_front();
				k -= 2;
			}
			ans %= mod;
		}
		if (k > 0) {
			ans *= num1[0];
			ans %= mod;
			num1.pop_front();
			k--;
		}
	} else if (has0) {
		cerr << "zero" << endl;
		ans = 0;
	} else {
		// 負になる -> 絶対値の最小値
		cerr << "minus" << endl;
		sort(num.begin(), num.end());

		while (k > 0) {
			ans *= num.front();
			ans %= mod;
			num.pop_front();
			k--;
		}

		ans = mod - ans;
	}
	cout << ans << endl;
	return 0;
}


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

int main(){
  int n,k;
  cin >> n >> k;
  int h[n],dp[n];
  for(int i = 0;i < n;i++){
    cin >> h[i];
  }
  dp[0] = 0;
  dp[1] = abs(h[1] - h[0]);
  for(int i = 2;i < n;i++){
    dp[i] = dp[i-1] + abs(h[i] - h[i-1]);
    for(int j = 2;j <= min(i,k);j++){
      if(dp[i] > dp[i-j] + abs(h[i] - h[i-j])){
        dp[i] = dp[i-j] + abs(h[i] - h[i-j]);
      }
    }
  }
  cout << dp[n-1] << endl;
}

Measured memory_bytes: 1024
#include<stdio.h>
	int main(void){
		int i,j,k,n,x,count=0;
		while(1){
			scanf("%d %d",&n,&x);
			if(n==0 && x==0) break;
			for(i=1;i<=n;i++){
				for(j=i+1;j<=n;j++){
					for(k=j+1;k<=n;k++){
						if(i+j+k==x){
							count++;
							//printf("%d %d %d \n",i,j,k);
							
						}
					}
				}
			}
			printf("%d\n",count);
			count=0;
		}
		return 0;
	}

Measured memory_bytes: 600
n, k = gets.split.map(&:to_i)
snk = Array.new(n, 1)
k.times do
  d = gets.to_i
  a = gets.split.map(&:to_i)
  a.each do |v|
    snk[v - 1] = 0
  end
end
count = snk.inject(0) { |result, v| result += v }
puts count


Measured memory_bytes: 14364
#include <iostream>

using namespace std;

using ll =  long long;

constexpr int N_MAX = 1000;
constexpr int M_MAX = 1000;
constexpr ll MOD = 1000000007;

ll fact[N_MAX+1], rfact[N_MAX+1];

ll perm(ll n, ll k) {
    if(n-k < 0LL) return 0LL;
    return (fact[n] * rfact[n-k]) % MOD;
}

ll modpow(ll a, ll p) {
    ll ret = 1LL;
    while(p) {
        if(p & 1) {
            ret = (ret * a) % MOD;
        }
        a = (a * a) % MOD;
        p >>= 1;
    }
    return ret;
}

void init_fact(ll n) {
    fact[0] = fact[1] = 1;
    rfact[0] = rfact[1] = 1;
    for(ll i=2;i<=n;++i) {
        fact[i] = (fact[i-1] * i) % MOD;
        rfact[i] = modpow(fact[i], MOD-2);
    }
}

int main() {
    ll n, k;
    cin >> n >> k;
    init_fact(N_MAX);
    cout << perm(k, n) << endl;
}



Measured memory_bytes: 3124
#include<iostream>
#include<algorithm>
using namespace std;
int N_MAX=1000;
int main()
{
  int n,m,i,s=0;
  int a[N_MAX];
  cin >> n >> m;
  for(i=0;i<n;i++){
    cin >> a[i];
    s+=a[i];
  }
  sort(a,a+n,greater<int>());
  if(a[m-1]*4*m>=s)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner();
		int i = sc.nextInt();
		boolean b = i == 3 
				|| i == 5
				|| i == 7;
		System.out.println(b ? "YES" : "NO");
	}
}

class Scanner {
	private static final int SPACE = (int)' ';
	private static final int LINE_END_0 = 13;
	private static final int LINE_END_1 = 10;
	private static final int BEFORE = -1;
	private BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	
	public String next(){
		StringBuilder sb = new StringBuilder();
		
		int length = BEFORE;
		readLoop: while(true) {
			try {
				int value = br.read();
				switch(value) {
				case LINE_END_1:
					if(length == BEFORE)
						break;
					
					if((int)sb.charAt(length) == LINE_END_0)
						sb.deleteCharAt(length);
				case SPACE:
					break readLoop;
				}
				sb.append((char)value);
				length++;

			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
		return sb.toString();
	}
	
	public String[] nextArray(int length) {
		String[] array = new String[length];
		for(int i = 0; i < length; i++)
			array[i] = next();
		return array;
	}
	
	public double nextDouble() {
		return Double.parseDouble(next());
	}
	
	public double[] nextDoubleArray(int length) {
		double[] array = new double[length];
		for(int i = 0; i < length; i++)
			array[i] = nextDouble();
		return array;
	}
	
	public int nextInt() {
		return Integer.parseInt(next());
	}
	
	public int[] nextIntArray(int length) {
		int[] array = new int[length];
		for(int i = 0; i < length; i++)
			array[i] = nextInt();
		return array;
	}
	
	public long nextLong() {
		return Long.parseLong(next());
	}
	
	public long[] nextLongArray(int length) {
		long[] array = new long[length];
		for(int i = 0; i < length; i++)
			array[i] = nextLong();
		return array;
	}
	
	public boolean ready() {
		try {
			return br.ready();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return false;
	}
}


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

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

using namespace std;

int main(){
  int k,s;
  cin>>k>>s;
  int result=0;
  rep(i,k+1){
    rep(j,k+1){
      if(0<=s-i-j && s-i-j <= k)result++;
    }
  }

  cout<<result;
  return 0;
}

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

const LL inf = 0x3f3f3f3f3f3f3f3f;
const int N = 55, M = 110;
struct Edge {
	int to, next;
	LL a, b;
}e[M * 2];
int head[N], idx;
LL c[N], d[N];
LL dis[N][2510];
int n, m, s;

void add(int u, int v, LL a, LL b) {
	e[++idx].to = v;
	e[idx].next = head[u];
	e[idx].a = a;
	e[idx].b = b;
	head[u] = idx;
}

void spfa() {
	queue<PII> q;
	for(int i = 1; i <= n; i++) {
		for(int j = 0; j <= 2500; j++) {
			dis[i][j] = inf;
		}
	}
	dis[1][s] = 0;
	q.push({1, s});
	while(!q.empty()) {
		int u = q.front().first, w = q.front().second; q.pop();
		for(int i = head[u]; i; i = e[i].next) {
			int v = e[i].to;
			LL a = e[i].a, b = e[i].b;
			if(w >= a && dis[v][w - a] > dis[u][w] + b) {
				dis[v][w - a] = dis[u][w] + b;
				q.push({v, w - a});
			}
		}
		if(dis[u][min(w + c[u], (LL)2500)] > dis[u][w] + d[u]) {
			dis[u][min(w + c[u], (LL)2500)] = dis[u][w] + d[u];
			q.push({u, min(w + c[u], (LL)2500)});
		}
	}
}

int main() {
	scanf("%d%d%d", &n, &m, &s);
	s = min(s, 2500);
	while(m--) {
		int u, v;
		LL a, b;
		scanf("%d%d%lld%lld", &u, &v, &a, &b);
		add(u, v, a, b);
		add(v, u, a, b);
	}
	for(int i = 1; i <= n; i++) {
		scanf("%lld %lld", &c[i], &d[i]);
	}
	spfa();
	for(int i = 2; i <= n; i++) {
		LL res = inf;
		for(int j = 0; j <= 2500; j++) res = min(res, dis[i][j]);
		printf("%lld\n", res);
	}
	return 0;
}


Measured memory_bytes: 5084
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <utility>
#include <cmath>
#include <climits>

#define ll long long int
#define pb push_back
#define mk make_pair
#define pq priority_queue

using namespace std;
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
const int inf = 1e9;
const ll linf = 1LL << 50;
const double EPS = 1e-10;

int main(int argc, char const* argv[])
{
  ll a, b, c;
  cin >> a >> b >> c;
  int power[3] = {0};
  ll num[3] = {2 * a - b - c, 2 * b - a - c, 2 * c - a - b};
  for(int i = 0; i < 3; i++){
    while(num[i] % 2 == 0 && num[i] != 0){
      power[i]++;
      num[i] /= 2;
    }
  }
  ll res = inf;
  ll nnum = a + b + c;
  if(nnum % 2 == 1){
    cout << 0 << endl;
    return 0;
  }
  for(int i = 0; i < 3; i++){
    if(num[i] == 0){

    } else res = min(res, (ll)power[i] - 1);
  }
  if(res > inf / 2)cout << - 1 << endl;
  else cout << res + 1 << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);i++)
typedef long long ll;
bool aaa[11111111];
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
ll gcd(ll a, ll b) {
  if(a < b) return gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}


int main() {
  int a;
  int k,x,y,m,memo=1,sx=1,sy=1,gx,gy;
  string ka,ss;
  int n,ans;
  cin>>ka;
  if(ka[2]==ka[3]&&ka[5]==ka[4])cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  int num[n];
  vector<int> count(n,0);
  map<int,int>mp;
  
  
  
  //cout<<dp[x-1][y-1]<<endl;

  //vector<vector<bool>> sinsetsu(15,vector<bool>(14)),usotsuki(15,vector<bool>(14));
  //vector<vector<int>> sss(15,vector<int>(14))
  //vector<vector<int>> sss(h,vector<int>(w));
  //vector<int> a(k),b(k);
  //char x;
}

Measured memory_bytes: 256
s = input()

n = len(s)
c = [0]*2019
c[0]+=1
t = 0
digit = 1
for ss in s[::-1]:
    t = (t+int(ss)*digit) % 2019
    digit = (digit * 10) % 2019
    c[t]+=1
ans = 0
ans = sum(cc*(cc-1)//2 for cc in c)
print(ans)

Measured memory_bytes: 9316
n = int(input())
a = list(map(int, input().split()))
flag = True
for num in a:
    if num % 2 == 0:
        if num % 3 != 0 and num % 5 != 0:
            flag = False
            break

if flag:
    print("APPROVED")
else:
    print("DENIED")


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

//#define int long long
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i < b; i++)
#define out(x) cout << x << endl
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<bool> > vvb;
typedef vector<vector<double> > vvd;
typedef vector<vector<string> > vvs;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

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;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

signed main()
{   
    gearup;
    ll n,m; cin >> n >> m;
    if(n == 1 && m == 1)out(1);
    else if(n == 1 || m == 1)out(max(n,m)-2);
    else out((n-2)*(m-2));
}


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

const int MAX = 1010000;
const int mod = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % mod;
        inv[i] = mod - inv[mod%i] * (mod / i) % mod;
        finv[i] = finv[i - 1] * inv[i] % mod;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);
    
    ll x,y;
    cin>>x>>y;
    ll dx=0,dy=0;
    for(int i=0;i<=x;i++){
        ll a=x-i*2;
        ll b=y-i;
        if(a*2==b){
            dx = i;
            dy = a;
            break;
        }
    }
    if(dx==0 && dy==0){
        cout << 0 << endl;
        return 0;
    }
    COMinit();
    ll ans = COM(dx+dy,dx);
    cout << ans << endl;
    
}

Measured memory_bytes: 23936
<?php
$string_tmp = array();
// 回答保存用
$ans_set = array();
// 入力受付処理
while ($line = fgets(STDIN)) {
   $tmp[] = trim($line);
}
// INIT処理
$max_lenge = 8;
// 列閲覧用のForeach
foreach($tmp as $val){
    // データセットをデクリメント
    $max_lenge--;
    // 1があるかどうかを確認
    // 1があった場合tmpに格納
    if(preg_match('/1/',$val)){
        $string_tmp[] = $val;
    }// 一つデータセットを見終わった時の処理
     // 見つかった行数によって図形を判別
    if($max_lenge < 0){
        $ans_set[] = judge($string_tmp);
        // INIT 処理
        $string_tmp = array();
        $max_lenge = 8;
    }
}
$ans_set[] = judge($string_tmp);
// 出力処理
foreach($ans_set as $val){
    echo $val."\n";
}

// 図形判別処理
function judge($string_tmp){
    $ans;
    $tmp_length = count($string_tmp);
        if($tmp_length == 4){
            $ans = "B";
        }elseif($tmp_length == 1){
            $ans = "C";
        }elseif($tmp_length == 2){
            $ans = judge_line2($string_tmp);
        }elseif($tmp_length == 3){
            $ans = judge_line3($string_tmp);
        }
    return $ans;
}
// ラインが二列だった時の図形判別用
function judge_line2($string_tmp){
    $pos = strpos($string_tmp[0], "1");
    $pos2 = strpos($string_tmp[1], "1");
    if($pos == $pos2){
        return "A";
    }elseif ($pos < $pos2) {
        return "E";
    }else{
        return "G";
    }
}// ラインが三列だった時の図形判別用    
function judge_line3($string_tmp){
    $pos = strpos($string_tmp[0], "1");
    $pos2 = strpos($string_tmp[1], "1");
    if($pos > $pos2){
        return "D";
    }else{
        return "F";
    }
}


Measured memory_bytes: 9424
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;

namespace AtCorder
{
	public class Program
	{
		static void Main(string[] args)
		{
			int n = int.Parse(Console.ReadLine());
			var a = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
			
			int m = n + 2;
			var b = new long[m];
			for (int i = 0; i < n; i++) {
				b[i + 1] = a[i];
			}

			long sum = 0;
			for (int i = 1; i < m; i++) {
				sum += Math.Abs(b[i] - b[i - 1]);
			}

			var sb = new StringBuilder();
			for (int i = 0; i < n; i++) {
				long temp = sum;
				if (b[i + 1] < b[i] && b[i + 2] > b[i + 1]) {
					temp -= Math.Min(b[i + 2] - b[i + 1], b[i] - b[i + 1]) * 2;
				} else if (b[i + 1] > b[i] && b[i + 2] < b[i + 1]) {
					temp -= Math.Min(b[i + 1] - b[i], b[i + 1] - b[i + 2]) * 2;
				}

				sb.AppendLine(temp.ToString());
			}

			Console.Write(sb.ToString());
		}
	}
}

Measured memory_bytes: 34268
#include<iostream>
#include<cstring>
#include<climits>
using namespace std;
int dp[100005][4];
int main(){
    int n; 
    cin>>n;
    int maxi=0;
    int a[n+1][3];
    for(int i=1;i<=n;i++)
    {
        for(int j=0;j<3;j++)
        cin>>a[i][j];
    }
    memset(dp,sizeof dp,0);
   //cout<<frog(a,n,k)<<"\n";
   int flag=0;
  int ans=0;
 for(int i=1;i<=n;i++)
 {
   
    dp[i][0]=ans;
 }
 dp[1][0]=a[1][0];
 dp[1][1]=a[1][1];
 dp[1][2]=a[1][2];
for(int i=2;i<=n;i++)
{
    dp[i][0]=a[i][0]+max(dp[i-1][1],dp[i-1][2]);
    dp[i][1]=a[i][1]+max(dp[i-1][0],dp[i-1][2]);
    dp[i][2]=a[i][2]+max(dp[i-1][1],dp[i-1][0]);
}
cout<<max(dp[n][0],max(dp[n][1],dp[n][2]))<<"\n";
return 0;
}

Measured memory_bytes: 6300
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define rfor(i, a, b) for(int i = a; i < (int)b; i++)
#define all(ary) (ary).begin(), (ary).end()
#define debug(x) cerr << #x << ": " << x << '\n'
const long long INF = 1LL << 60;
const int MOD = 1000000007; // 1e9 + 7
using namespace std;
using vec = vector<int>;
using ll = long long;
template <class T = int> T in(){ T x; cin >> x; return (x);}
template <class T> inline bool chmin(T &a, T b) { if ( a > b ) { a = b; return 1; } return 0; }
template <class T> inline bool chmax(T &a, T b) { if ( a < b ) { a = b; return 1; } return 0; }
const int dy[4] = {-1, 0, 0, 1};
const int dx[4] = {0, -1, 1, 0};

ll N, K;
ll res = INF;

int main(int argc, char *argv[]){
    cin >> N >> K;
    vec X(N);
    rep(i, N) cin >> X[i];
    vec L(N - 1);
    rep(i, N - 1) L[i] = X[i + 1] - X[i];
    for(int i = 0; i + K - 1 < N; i++){
        ll tmp = 0;
        if(X[i + K - 1] < 0){
            tmp = abs(X[i]);
        }else if(X[i] < 0 && X[i + K - 1] > 0){
            ll mini = min(abs(X[i]), abs(X[i + K - 1]));
            ll maxi = max(abs(X[i]), abs(X[i + K - 1]));
            tmp = 2 * mini + maxi;
        }else{
            tmp = abs(X[i + K - 1]);
        }
        res = min(res, tmp);
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 1024
use std::io;
use std::str::FromStr;

fn input_char_vec() -> Vec<char> {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    line.trim().chars().collect()
}

fn main() {
    let s = input_char_vec();
    for _ in 0..s.len() {
        print!("x");
    }
    println!();
}


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

typedef long long ll;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define each(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); ++itr)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second

const int INF=12345678;

int T,n;
int t[30];
int interview[101];

int dp[102][30];
int dfs(int day, int cycle)
{
    if(dp[day][cycle]>=0) return dp[day][cycle];
    if(day==101) return 0;

    // failed
    if(interview[day]<t[cycle]) return INF;

    int ret=INF;

    // take
    ret=min(ret,dfs(day+1,(cycle+1)%T));
    // don't take
    ret=min(ret,dfs(day+1,0)+1);

    return dp[day][cycle]=ret;
}

int main()
{
    while(cin >>T,T)
    {
        fill(interview,interview+101,INF);
        memset(dp,-1,sizeof(dp));

        rep(i,T) scanf(" %d", &t[i]);
        scanf(" %d", &n);
        rep(i,n)
        {
            int d,m;
            scanf(" %d %d", &d, &m);
            interview[d]=min(interview[d],m);
        }

        printf("%d\n", dfs(1,0));
    }
    return 0;
}

Measured memory_bytes: 3104
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B,L,R;
string S, T;
const ll MOD = 998244353;
const ll INF = 1LL << 60;
typedef pair<ll,ll> P;

int main() {
    cin>>N;
    mat ab(2, vec(N)), ord(2, vec(N));
    rep(i,2) rep(j,N) cin>>ab[i][j];
    rep(i,2) rep(j,N) ord[i][j] = j;
    rep(i,2){
        sort(ALL(ord[i]), [&](ll x, ll y){
            return ab[i][x] < ab[i][y];
        });
    }
    bool yes = true;
    rep(i,N){
        if(ab[0][ord[0][i]] > ab[1][ord[1][i]]) yes = false;
    }
    if(yes){
        vec ord_inv(N);
        rep(i,N) ord_inv[ord[1][i]] = i;
        ll v = 0;
        rep(i,N){
            v = ord[0][ord_inv[v]];
            if(v == 0 && i != N - 1) {
                cout << "Yes" << endl;
                return 0;
            }
        }
        yes = false;
        reps(i,1,N){
            if(ab[0][ord[0][i]] <= ab[1][ord[1][i-1]]) yes = true;
        }
    }
    cout<<(yes ? "Yes" : "No")<<endl;
}

Measured memory_bytes: 4104
n = int(input())
a = [int(i) for i in input().split()]
ans = True
a[0] -= 1
for i in range(1,n):
  if a[i]>a[i-1]:
    a[i] -= 1
  elif a[i]==a[i-1]:
    pass
  else:
    ans = False
    break
if ans==True:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 14396
#include <bits/stdc++.h>
using namespace std;
const int INF=0x3f3f3f3f;
int main()
{
    unsigned long long n,i,j,k;
    unsigned long long sum=0;
    scanf("%lld",&n);
    int a[100005],b[100005],c[100005];
    for(int i=0;i<n;i++)
        scanf("%lld",&a[i]);
    sort(a,a+n);
    for(int i=0;i<n;i++)
        scanf("%lld",&b[i]);
    sort(b,b+n);
    for(int i=0;i<n;i++)
        scanf("%lld",&c[i]);
    sort(c,c+n);
    a[n]=c[n]=INF;
    for(i=0;i<n;i++)
    {
        j=lower_bound(a,a+n,b[i])-a;
        if(j>=n) j=n;
        k=lower_bound(c,c+n,b[i]+1)-c;
        if(k>=n) break;
        sum+=j*(n-k);
    }
    printf("%lld\n",sum);
    return 0;
}



Measured memory_bytes: 1408
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>

using namespace std;

//typedef
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//conversion
inline LL toLong(string s) {LL v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) LL((a).size())
#define EACH(i,c) for(auto i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define UNTIL(p) while(!(p))

//constant
const double EPS = 1e-5;
const double PI  = acos(-1.0);

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

#define PUTS(x) cout << (x) << endl;

LL n,m,q;
LL a[50],b[50],c[50],d[50];
LL ans = 0;

LL arr[10] = {0};
void f(LL pre, LL dep){
    if(dep == n){
        LL sum = 0;
        REP(i,q){
            if(arr[b[i]-1] - arr[a[i]-1] == c[i]){
                sum += d[i];
            }
        }
        ans = max(ans, sum);
        return;
    }

    FOR(i,pre,m+1){
        arr[dep] = i;
        f(i, dep+1);
    }
}

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin>>n>>m>>q;
    REP(i,q)cin>>a[i]>>b[i]>>c[i]>>d[i];
    f(1,0);
    PUTS(ans);
}

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

int main(){
  int D1, D2, count = 0;
  int N;
  cin >> N;
  while(cin >> D1 >> D2){
    //cout << D1 << D2 << endl;
    if(D1 == D2){
      count++;
    }else{
      count = 0;
    }
    
    if(count == 3){
      cout << "Yes" << endl;
      return 0;
    }
  }
  
  cout << "No" << endl;
  return 0;
}


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

int main() {
    int n;
    cin >> n;
    vector<vector<int>> a(n, vector<int>(3));
    pair<int, pair<int, int>> p(0, make_pair(0, 0));

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < 3; j++) {
            cin >> a.at(i).at(j);
        }
    }
    bool can = false;
    for (int i = 0; i < n; i++) {
        int t = a.at(i).at(0) - p.first;
        int x = abs(a.at(i).at(1) - p.second.first);
        int y = abs(a.at(i).at(2) - p.second.second);
        bool flag = false;
        if ((x + y) % 2 == t % 2 && x + y <= t) {
            flag = true;
        }
        p.first = t;
        p.second.first = x;
        p.second.second = y;

        if (!flag) {
            break;
        }

        else if (i == n - 1) {
            can = true;
        }
    }
    if (can) {
        cout << "Yes" << endl;
    }

    else {
        cout << "No" << endl;
    }
}


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

int main(){
    int n, l;
    cin >> n >> l;
    
    int min=0;
    if(l >= 0){
        min = l;
    }else if(l+n-1 <= 0){
        min = l+n-1;
    }

    cout << n * (l-1) + n*(n+1)/2 - min << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
using namespace std;
#define MAX 1000005
#define NIL -1

struct Node { int p, l, r; };

Node T[MAX];
int n, D[MAX];

void print(int u) {
	int i, c;
	printf("node %d: ", u);
	printf("parent = %d", T[u].p);
	printf(", ");
	printf("depth = %d", D[u]);
	printf(", ");

	if (T[u].p == NIL) {
		printf("root,");
	}
	else if (T[u].l == NIL) {
		printf("leaf,");
	}
	else {
		printf("internal node,");
	}

	printf(" [");
	for (i = 0, c = T[u].l; c != NIL; i++, c = T[c].r) {
		if (i != 0) { printf(", "); }
			printf("%d", c);
	}
	printf("]\n");
}

//再帰的に深さを求める
int rec(int u, int p) {
	D[u] = p;
	if (T[u].r != NIL) {
		rec(T[u].r, p);//右の兄弟にも同じ深さを設定する
	}
	if (T[u].l != NIL) {
		rec(T[u].l, p + 1);//左の子が存在する場合はその子に対して深さを一つ足して再帰呼び出しを行う
	}
	return D[u];
}


int main(void) {
	int i, j, d, v, c, l, r;
	scanf("%d", &n);
	for (i = 0; i < n; i++) {
		T[i].p = T[i].l = T[i].r = NIL;//節点の初期化。この場合、どの点も他の節点とつながっていない
	}

	for (i = 0; i < n; i++) {
		scanf("%d%d", &v, &d);
		for (j = 0; j < d; j++) {
			scanf("%d", &c);
			if (j == 0)T[v].l = c;
			else T[l].r = c;
			l = c;
			T[c].p = v;
		}
	}
	for (i = 0; i < n; i++) {
		if (T[i].p == NIL)r = i;
	}

	rec(r, 0);

	for (i = 0; i < n; i++) {
		print(i);
	}

	return 0;
}


Measured memory_bytes: 7900
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
#define VL vector<ll>
#define VS vector<string>
#define VB vector<bool>
#define VP vector<pair<ll,ll>>
#define VVL vector<vector<ll>>
#define VVP vector<vector<pair<ll,ll>>>
#define PL pair<ll,ll>
#define ALL(v) (v).begin(), (v).end()

int main(){
    ll A,B,C;
    cin>>A>>B>>C;
    if((A*100+B*10+C)%4==0)cout<<"YES";
    else cout<<"NO";
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
typedef struct{
int k;
char mozi;
}card;
   
int main(){
int m,min;
card num[36],suit[36],temp;
scanf("%d",&m);
int i,j;  
for(i=0;i<m;i++){
scanf(" %c%d",&num[i].mozi,&num[i].k);
suit[i].mozi=num[i].mozi;
suit[i].k=num[i].k;
}
for(i=0;i<m;i++){
for(j=m-1;j>i;j--){
if(num[j].k<num[j-1].k){
temp=num[j];
num[j]=num[j-1];
num[j-1]=temp;
}
}
}
for(i=0;i<m-1;i++){
printf("%c%d ",num[i].mozi,num[i].k);
}
printf("%c%d\nStable\n",num[i].mozi,num[i].k);
for(i=0;i<m-1;i++){
min=i;
for(j=i;j<=m-1;j++){
if(suit[j].k<suit[min].k)
min=j;
}
temp=suit[i];
suit[i]=suit[min];
suit[min]=temp;
}
 for(i = 0; i < m-1; i++){ 
printf("%c%d ",suit[i].mozi,suit[i].k);
}
printf("%c%d\n",suit[i].mozi,suit[i].k);
for(i = 0;i<m; i++){
if(suit[i].mozi!=num[i].mozi) {
printf("Not stable\n");
break;
}
}
if(i==m)printf("Stable\n");
return 0;
}

Measured memory_bytes: 1784
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <numeric>
#include <iomanip>
#include <tuple>

using namespace std;

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

   for(int i=0;i<s.size();i++){
      if(s[i]=='B' && !ans.empty()) ans.pop_back();
      else if(s[i]=='B' && ans.empty())continue;
      else ans.push_back(s[i]);
   }
   cout<<ans<<endl;
}

   


Measured memory_bytes: 256
#include <iostream>
using namespace std;
bool isPrime(int i)
{
  if(i == 2) return true;
  else if(i % 2 == 0) return false;
  for(int j = 3; j*j<=i; j+=2){
    if(i % j == 0) return false;
  }
  return true;
}
int main()
{
  int N;
  while(cin >> N){
    int count=0;
    for(int i=0; i<N; i++){
      int j;
      cin >> j;
      if(isPrime(j)) count++;
    }
    cout << count << endl;
  }
  return 0;
}

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

#define endl "\n"
#define ioss ios::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define eb emplace_back
//#define int long long

typedef  long long ll;

using namespace std;


int main()
{
    ioss
    int n,k;cin>>n>>k;
  vector<int>a(n);
  for(int i=0;i<n;i++)
  {
      cin>>a[i];
  }
  ll dp[100005];
  for(int i=0;i<100005;i++)dp[i]=10000000000;

  dp[0]=0;
  dp[1]=abs(a[1]-a[0]);
  //for(int i=0;i<20;i++) cout<<dp[i]<<endl;
  for(int i=0;i<n;i++)
      {
        for(int j=i+1;j<=i+k;j++)
        {
          if(j<n)
          {
            dp[j]=min(dp[j],dp[i]+ll(abs(a[j]-a[i])));
          }
        }
      }
  cout<<dp[n-1]<<endl;
    return 0;
}




Measured memory_bytes: 1408
#include <iostream>

using namespace std;

int main(){
	int row[]= {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
	int k;
	cin>>k;
	if(k>=1 && k<=32){
	cout<<row[k-1]<<"\n";
}

	return 0;
	}


Measured memory_bytes: 256