akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <iomanip>
#include <map>
#include <set>
#include <tuple>
#include <unordered_map>
#include <iterator>
#include <string>
#include <limits>

using namespace std;

using i64 = int64_t;
using P = pair<i64, i64>;
i64 mod = 1000000007;
int int_max = 2147483647;
int max_n = 1e5;

void recursive_comb(std::vector<i64>& indexes, i64 s, i64 rest, std::function<void(std::vector<i64>&)> f) {
  if (rest == 0) {
    f(indexes);
  } else {
    if (s < 1) return;
    recursive_comb(indexes, s - 1, rest, f);
    indexes[rest - 1] = s;
    recursive_comb(indexes, s, rest - 1, f);
    recursive_comb(indexes, s - 1, rest - 1, f);
  }
}

void foreach_comb(int n, int k, std::function<void(std::vector<i64>&)> f) {
  std::vector<i64> indexes(k);
  recursive_comb(indexes, n, k, f);
}

i64 check_cnt(std::vector<tuple<i64, i64, i64, i64>>& conf, std::vector<i64>& pattern) {
    i64 ret{0};
    for (auto tp : conf) {
        i64 a = get<0>(tp);
        i64 b = get<1>(tp);
        i64 c = get<2>(tp);
        i64 d = get<3>(tp);
        //cout << "  "<<b <<" b:" << pattern[b]<< " "<< a << " a:" << pattern[a] << " c:"<< c<<endl;
        if (pattern[b] - pattern[a] == c) {
            ret += d;
        }
    }
    return ret;
}

int main(int argc, char **argv) {
    i64 n, m, q;
    cin >> n >> m >> q;

    std::vector<tuple<i64, i64, i64, i64>> conf;
    for (int i=0; i<q; ++i) {
        i64 a,b,c,d;
        cin >> a >> b >> c >>d;
        --a; --b;
        conf.push_back(make_tuple(a, b, c, d));
    }
    i64 ans{0};
    foreach_comb(m, n, [&conf, &ans](std::vector<i64>& indexes) {
/*
        for (auto i : indexes) {
            cout << i << " ";
        }
        cout << endl;
*/
        i64 tmp = check_cnt(conf, indexes);
        //cout << tmp << endl;
        ans = max(ans, tmp);
    });

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3600
import java.util.*;

class Main {
    public static void main(String[] args) {
      Scanner sc = new Scanner(System.in);
      int A = sc.nextInt();
      int B = sc.nextInt();
      int C = sc.nextInt();
      int X = sc.nextInt();

      int cnt = 0;
      for(int a = 0; a <= A; a++) {
          for(int b =0; b <= B; b++) {
            int c = (X - a * 500 - b * 100) / 50;
            if (c >= 0 && c <= C)
                cnt++;
          }
      }
      System.out.println(cnt);
    }      
}

Measured memory_bytes: 22868
#define _CRT_SECURE_NO_WARNINGS 1
#include <iostream>
#include <fstream>
#include <string> 
#include <cmath>  
#include <cstdlib>
#include <ctime>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <functional>

char x[200005];

int main(void) {
	char input;
	int i = 0;
	while (1) {
		scanf("%c", &input);
		if (input == '\n') {
			x[i] = '\0';
			break;
		}
		x[i] = input;
		if (input == 'T') {
			if (i > 0 && x[i - 1] == 'S') {
				i -= 2;
			}
		}
		i++;
	}
	printf("%d\n", strlen(x));
	return 0;
}

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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    int N;
    cin >> N;
    vector<int> A(N);
    rep(i, N) cin >> A[i];
    vector<int> cnt(N + 1, 0);
    cnt[0] = 3;
    ll ans = 1;
    rep(i, N) {
        int a = A[i];
        ans *= cnt[a];
        ans %= MOD;
        cnt[a]--;
        cnt[a + 1]++;
    }
    cout << ans << '\n';
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 1024
include Math
A, B, H, M = $stdin.gets.split.map {|i| i.to_i }
adeg = PI / 2.0 - 2 * PI * (H + M / 60.0) / 12
bdeg = PI / 2.0 - 2 * PI * M / 60.0
ax = A * cos(adeg)
ay = A * sin(adeg)
bx = B * cos(bdeg)
by = B * sin(bdeg)
d = sqrt((ax - bx) ** 2 + (ay - by) ** 2)
puts d


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

int main(){
	int n; cin>>n;
	if(n%10==3) cout << "bon" << endl;
	else if(n%10==0||n%10==1||n%10==6||n%10==8) cout << "pon" << endl;
	else cout << "hon" << endl;
}

Measured memory_bytes: 3636
N,M=map(int,input().split())
mod=10**9+7

def cmb(n,r):
  global mod
  if r<0 or r>n:
    return 0
  return (g1[n]*g2[r]*g2[n-r])%mod

def perm(n,r):
  global mod
  if r<0 or r>n:
    return 0
  return (g1[n]*g2[n-r])%mod

g1=[1,1]
g2=[1,1]
inv=[0,1]
for i in range(2,N+M+10):
  g1.append((g1[-1]*i)%mod)
  inv.append((-inv[mod%i]*(mod//i))%mod)
  g2.append((g2[-1]*inv[-1])%mod)
P=0
for i in range(N+1):
  P=(P+pow(-1,i&1)*cmb(N,i)*perm(M,i)*perm(M-i,N-i)**2)%mod
print(P)

Measured memory_bytes: 216780
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(int)(a); (i)<(int)(b); ++(i))
#define rFor(i, a, b) for(int (i)=(int)(a)-1; (i)>=(int)(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
typedef pair<lint, lint> pll;
template<class T> bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T> bool chmin(T &a, const T &b){if(a>b){a=b; return true;} return false;}
template<class T> T div_floor(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>=0 ? a/b : (a+1)/b-1;
}
template<class T> T div_ceil(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>0 ? (a-1)/b+1 : a/b;
}

constexpr lint mod = 1e9+7;
constexpr lint INF = mod * mod;
constexpr int MAX = 200010;

int main(){
    int n, K, q;
    scanf("%d%d%d", &n, &K, &q);
    int a[n];
    rep(i, n) scanf("%d", &a[i]);

    int ans = mod;
    rep(i, n){
        vector<int> u, v;
        int l = 0;
        while(l < n){
            if(a[l] < a[i]){
                ++l;
                continue;
            }
            int r = l;
            while(r < n && a[r] >= a[i]) ++r;
            For(j, l, r) u.push_back(a[j]);
            l = r;

            sort(u.begin(), u.end());
            rep(j, u.size()-K+1) v.push_back(u[j]);
            u.clear();
        }
        if(v.size() < q) continue;
        sort(v.begin(), v.end());
        chmin(ans, v[q-1] - a[i]);
    }
    printf("%d\n", ans);
}


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


int main() {

	int X;

	cin >> X;

	if (X == 7 || X == 5 || X == 3) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}


	return 0;

}


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

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

using namespace std;

using ll = long long int;

const int MOD_NUM = 1e9 + 7;

int main() {
    // Input
    ll N;
    cin >> N;

    // Process
    string ans;

    ll n = N;
    ans = "";
    while (n > 0) {
        char c = n % 26 + 'a' - 1;
        if (n % 26 == 0) {
            c = 'z';
            n--;
        }

        ans += c;
        n /= 26;
    }
    reverse(ans.begin(), ans.end());

    // Output
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3620
from itertools import combinations
a, b, c, d, e, k = map(int, [input() for _ in range(6)])
for c in combinations([a, b, c, d, e], 2):
  l = list(c)
  if abs(l[0] - l[1]) > k:
    print(":(")
    exit(0)
print("Yay!")

Measured memory_bytes: 3060
n,m,k=map(int,input().split())
A=[0]+list(map(int,input().split()))
B=[0]+list(map(int,input().split()))

for i in range(1,n+1):
    A[i] += A[i-1]

for i in range(1,m+1):
    B[i] += B[i-1]

ans=0
for a_cnt in range(n+1):
    if A[a_cnt]>k:
        continue
    start=0
    goal=m+1
    while start!=goal:
        b_cnt=(start+goal)//2
        if A[a_cnt]+B[b_cnt]>k:
            goal=b_cnt
        else:
            start=b_cnt+1
            ans=max(ans,a_cnt+b_cnt)
print(ans)

Measured memory_bytes: 40116
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<climits>
#include<iostream>
#include<sstream>
#include<utility>
#include<map>
#include<vector>
#include<queue>
#include<algorithm>
#include<set>
#include<stack>
using namespace std;
typedef long long ll;
typedef pair<int,int>P;
priority_queue<int>Q;
char S[10];
int a;
int main()
{
	for(;scanf("%s",S);)
	{
		if(S[0]=='i')
		{
			scanf("%d\n",&a);
			Q.push(a);
		}
		else if(S[1]=='x')
		{
			a=Q.top();
			printf("%d\n",a);
			Q.pop();
		}
		else
			break;
	}
}

Measured memory_bytes: 6992
s = input()

def pa(ai, an, n):
    #print(ai,an,n)
    s = (ai+an)*n//2
    #print('pa',s) 
    return s


c = []
ant = s[0]
cont = 1
for i in s[1:]:
    if i != ant:    
        c.append((cont, ant))
        ant = i
        cont = 1
    else:   
        cont += 1
        
c.append((cont, ant))

soma = 0

for x in range(len(c)):
    i = c[x]
    if i[1] == '<':
        soma += pa(0, i[0]-1, i[0])
    else:
        soma += pa(i[0], 1, i[0])
        if x>0:
            off = max(0, c[x-1][0] - i[0])
            #print('off',off)
            soma += off

if c[-1][1] == '<':
    soma += c[-1][0]
    
print(soma)


Measured memory_bytes: 75336
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <numeric>

using namespace std;

int main()
{
    int N;
    vector<int> L;

    cin >> N;
    for (int i = 0; i < N;i++)
    {
        int a;
        cin >> a;
        L.push_back(a);
    }

    int t = accumulate(L.begin(), L.end(), 0) - 2 * (*max_element(L.begin(), L.end()));

    if(t > 0)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 888
#include"bits/stdc++.h"
using namespace std;
using ll = int64_t;

int main() {
    ll X;
    cin >> X;
    if (X == 3 || X == 5 || X == 7) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
}

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

int main() {
    int a, b, n;
    cin >> a >> b >> n;
    int s, e, che[1000] = {};
    for(int i = 0; i < n; i++) {
        cin >> s >> e;
        for(int j = s - 1; j < e - 1; j++) {
            che[j] = 1;
        }
    }
    // for(int i = 0; i < 10; i++) cout << che[i] << endl;

    for(int i = a - 1; i < b - 1; i++) {
        if(che[i] == 1) {
            cout << 1 << endl;
            return 0;
        }
    }
    cout << 0 << endl;
}



Measured memory_bytes: 3100
#include "bits/stdc++.h"

// Begin {{{
using namespace std;

#define all(x) x.begin(), x.end()
#define rep(i, n) for (i64 i = 0; i < (n); ++i)
#define reps(i, b, e) for (i64 i = (b); i <= (e); ++i)
#define repr(i, b, e) for (i64 i = (b); i >= (e); --i)
#define var(Type, ...) Type __VA_ARGS__; input(__VA_ARGS__)

#ifdef DEBUG
#define dump(...) dump_(#__VA_ARGS__, __VA_ARGS__);
#else
#define dump(...)
#endif

using i64 = int_fast64_t;
using pii = pair<i64, i64>;

template <class A, class B>
inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }

template <class A, class B>
inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int MOD = int(1e9) + 7;

// input
void input() {}
template <class Head, class... Tail>
void input(Head&& head, Tail&&... tail) {
  cin >> head;
  input(forward<Tail>(tail)...);
}

// outs
void outs() {}
template <class Head, class... Tail>
void outs(Head&& head, Tail&&... tail) {
  cout << head << " \n"[sizeof...(tail)==0];
  outs(forward<Tail>(tail)...);
}

template <class T>
void outs(vector<T> &vec) { for (auto &e : vec) cout << e << " \n"[&e==&vec.back()]; }

template <class T>
void outs(vector<vector<T>> &df) { for (auto &vec : df) OUTS(vec); }

// outl
void outl() {}
template <class Head, class... Tail>
void outl(Head&& head, Tail&&... tail) {
  cout << head << "\n";
  outl(forward<Tail>(tail)...);
}

template <class T>
void outl(vector<T> &vec) { for (auto &e : vec) cout << e << "\n"; }

// outn
void outn() {}
template <class Head, class... Tail>
void outn(Head&& head, Tail&&... tail) {
  cout << head;
  outn(forward<Tail>(tail)...);
}

template <class T>
void outn(vector<T> &vec) { for (auto &e : vec) cout << e; }

// dump
template <class T>
void dump_(const char *s, T&& x) {
  clog << '{';
  while(*s != '\0') clog << *(s++);
  clog << ": " << x << '}' << "\n";
}

template <class Head, class... Tail>
void dump_(const char *s, Head&& head, Tail&&... tail) {
  clog << '{';
  while(*s != ',') clog << *(s++);
  clog << ": " << head << "}, ";
  for (++s; !isgraph(*s); ++s);
  dump_(s, forward<Tail>(tail)...);
}
// }}} End

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

  var(int, N);

  vector<i64> p(N + 10);
  rep(i, N) input(p[i]);

  i64 res = 0;
  reps(i, 1, N - 2) {
    if (p[i-1] <= p[i] && p[i] <= p[i+1]) ++res;
    else if (p[i-1] >= p[i] && p[i] >= p[i+1]) ++res;
  }

  outl(res);

  return 0;
}


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

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

  a = N/1000;
  b = (N-a*1000)/100;
  c = (N-a*1000-b*100)/10;
  d = N-a*1000-b*100-c*10;
  
  if (a==b && b==c || b==c && c==d) {
    cout << "Yes" << endl;
  }
  
  else {
    cout << "No" << endl;
  }
  
}

Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); scanf().tie(0); cout.tie(0);
#define ll long long
#define pb push_back
#define mp make_pair

int main()
{
  double r;
  cin>>r;
  cout<<setprecision(15)<<2*3.141592653589793*r;
}


Measured memory_bytes: 3748
import sys
input=sys.stdin.readline
N=int(input())
dist=[list(map(int,input().split())) for i in range(N)]
ans=sum([sum(dist[i]) for i in range(N)])
for i in range(N):
    dist[i][i]=float('inf')
ans//=2
def main(ans):
    for i in range(N):
        for j in range(i+1,N):
            Min=min(map(sum,zip(dist[i],dist[j])))
            if Min<dist[i][j]:
                return -1
            if Min==dist[i][j]:
                ans-=dist[i][j] 
    return ans
print(main(ans))

Measured memory_bytes: 6772
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
//#define int ll
typedef ll Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
#define mt make_tuple
typedef tuple<int,int,int> tp;
typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
//template<class C>constexpr int size(const C &c){return (int)c.size();}
//template<class T,size_t N> constexpr int size(const T (&xs)[N])noexcept{return (int)N;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
//nCr mod m
#define MOD 1000000007
#define M 1000000
vector<ll> fact;
bool h=false;
void init(){
	h=true;
	fact=vector<ll>(M);
	fact[0]=fact[1]=1;
	loop(i,2,M)fact[i]=fact[i-1]*i%MOD;
}
// a^b mod MOD
ll powmod(ll a,ll b,ll m=MOD){
	ll out=1;
	ll p=a%m;
	while(b){
		if(b&1)out=out*p%m;
		p=p*p%m;
		b>>=1;
	}
	return out;
}
//nCr
ll nCr(ll n,ll r,ll m=MOD){
	if(!h)init();
	if(n<0||r<0||n<r)return 0;//??????
	ll out=fact[n]*powmod(fact[r]*fact[n-r]%m,m-2,m)%m;
	return out;
}
int main(){
	init();
	int n;
	cin>>n;
	vi po(n+1,1);
	rep(i,n)po[i+1]=po[i]*(i+1)%MOD;
	ll out=0;
	ll sum=0;
	loop(i,1,n){
		(out+=i*(po[i]*po[n-1-i]%MOD*nCr(i-1,n-1-i)%MOD+MOD-sum)%MOD)%=MOD;
		sum=po[i]%MOD*po[n-1-i]%MOD*nCr(i-1,n-1-i)%MOD;
	}
	cout<<out<<endl;
}










Measured memory_bytes: 15872
#include "bits/stdc++.h"

using namespace std;

using ll = long long;
using ld = long double;

const double PI = 3.1415926535897932384626433832795;

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

int gcd(int x, int y) { return y ? gcd(y, x % y) : abs(x); }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : abs(x); }
int lcm(int x, int y) { return x / gcd(x, y) * y; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }

ll f(ll x) {
	switch (x % 4) {
	case 0:
		return x;
	case 1:
		return 1;
	case 2:
		return x ^ 1;
	case 3:
		return 0;
	default:
		break;
	}
}

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

	ll a, b;
	cin >> a >> b;

	cout << (f(a - 1) ^ f(b)) << endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] a = new int[n];
		int[] b = new int[n];
		for (int i = 0; i < a.length; i++) {
			a[i] = sc.nextInt();
		}
		for (int i = 0; i < a.length; i++) {
			b[i] = a[n - i - 1];
			System.out.print(b[i]);
			if (i == a.length - 1)
				break;
			System.out.print(" ");
		}
		System.out.println();
		sc.close();
	}
}



Measured memory_bytes: 26308
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //これつけるとA[N]でもいいらしい
//for文のマクロ
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define big 1000000007
#define all(a) sort((a).begin(),(a).end()) //ソートのマクロ

int conbi[100][100];
void conbimemo(int n,int r){ //動的計画法での組み合わせ
    int i,j;
    for(i=0;i<=n;i++){
        conbi[i][0] = 1;
        
    }
    for(j=1;j<=n;j++){
    conbi[j][1] = j;
    }
    for(i=1;i<=n;i++){
        for(j=1;j<=r;j++){
            conbi[i][j] = conbi[i-1][j-1] + conbi[i-1][j];
        }
    }
    //return conbi[n][r];
}
int64_t pow2(int64_t g){
    if(g==0){
        return 1;

    }
    else{
        return 2*pow2(g-1);
    }
}
int main(){
    int n,p;
    cin>>n>>p;
    vector<int> a(n);
    int g=0,k=0;
    rep(i,n){
        cin>>a[i];
        if(a[i]%2==0){
            g++;
        }
        else{
            k++;
        }
    }
    conbimemo(n,n);
    //まずp=1の場合だけやる
    int64_t ans=0;
    if(p==1){ 
        int i=1;
        while(i<=k){
            ans += conbi[k][i];
            i += 2;
        }
        ans = ans * pow2(g);
    }
    else{
        int i = 0;
        while(i<=k){
            ans += conbi[k][i];
            i += 2;
        }
        ans  = ans*pow2(g);
    }
    cout<<ans<<endl;
}

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

using namespace std;
typedef long long ll;
long long mod = 1000000007;
const int INF = 100100100;

int count(int x){
  if(x == 0) return 0;
  return count(x>>1) + (x&1);
}

int main(){
  int n; cin >> n;
  vector<vector<int>> tfmx(n,vector<int>(n,-1));
  for(int i=0;i<n;i++){
    int NoTe; cin >>NoTe;
    for(int j=0;j<NoTe;j++){
      int x,y; cin >> x >> y;
      x--; 
      tfmx.at(i).at(x) = y;
    }
  }
  int ans = 0;
  for(int tmp=0;tmp<(1<<16);tmp++){
    if(tmp>=pow(2,n)) continue;
    bitset<16> s(tmp);
    bool flag = false;
    for(int j=0;j<n;j++){
      if(s.test(j)){
        for(int k=0;k<n;k++){
          if(j==k || tfmx.at(j).at(k) == -1) continue;
          if((int) tfmx.at(j).at(k) + s.test(k) == 1){
            flag = true;
            break;
          }
        }
      }
      if(flag) break;
    }
    if(!flag){
      ans = max(ans,count(tmp));
    }
  }
  cout << ans << endl;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(ll i=(a);i<(b);i++)
#define per(i,a,b) for(ll i=(b)-1;i>=(a);i--)
const ll maxn=100+5;
ll n,k,d,a,cnt[maxn];
int main() {
    ios_base::sync_with_stdio(0);
    cin>>n>>k;
    while(k--) {
        cin>>d;
        while(d--) {
            cin>>a;
            cnt[a]=1;
        }
    }
    ll ans=0;
    rep(i,1,n+1) if(!cnt[i]) ans++;
    cout<<ans<<"\n";
}

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

using namespace std;

int main(){
  int k,a,b;
  cin >> k;
  cin >> a >> b;
  
  if(a%k==0 || (a/k+1)*k<=b){
    cout << "OK" << endl;
  }else{
    cout << "NG" << endl;
  }
}


Measured memory_bytes: 3624
n, x = map(int, input().split())
lst = [0] + sorted(list(map(int, input().split())))
for i in range(n):
  lst[i + 1] += lst[i]
for i in range(n):
  if lst[i] <= x < lst[i + 1]:
    print(i)
    exit()
if x == lst[n]:
  print(n)
else:
  print(n - 1)

Measured memory_bytes: 9136
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define MAX 2000001
#define VMAX 10000

int main(void)
{
  unsigned short *A, *B;
  int C[VMAX + 1];
  int i, j, n;

  scanf("%d", &n);

  A = malloc(sizeof(short)*n + 1);
  B = malloc(sizeof(short)*n + 1);

  for(i = 0; i <= VMAX; i++){
    C[i] = 0;
  }

  for(i = 0; i < n; i++){
    scanf("%d", &A[i + 1]);
    C[A[i + 1]]++;
  }

  for(i = 1; i <= VMAX; i++){
    C[i] += C[i - 1];
  }

  for(j = 1; j <= n; j++){
    B[C[A[j]]] = A[j];
    C[A[j]]--;
  }

  for(i = 1; i <= n; i++){
    if(i > 1) printf(" ");
    printf("%d", B[i]);
  }

  printf("\n");

  return 0;
}



Measured memory_bytes: 9580
#include <bits/stdc++.h>
using namespace std;
#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++)
typedef long long ll;
#define ALL(v) v.begin(), v.end()
#define vmax(v) *max_element(ALL(v))
#define vmin(v) *min_element(ALL(v))
#define chmax(x, a) x = max(x, a)
#define chmin(x, a) x = min(x, a)

int main() {
    int ti = clock();
    int D; cin >> D;
    vector<ll> c(26);
    rep(i, 26) cin >> c[i];
    vector<vector<ll>> s(D, vector<ll>(26));
    rep(i, D)rep(j, 26) cin >> s[i][j];
    vector<ll> t(D);
    rep(i, D) t[i] = 26-i%26;
    ll ans = 0;
    vector<ll> last(26);
    vector<ll> t_ans(ALL(t));
    for (int d = 1; d <= D; d++) {
        for (int i = 1; i <= 26; i++) {
            if (t[d-1] == i) {
                ans += s[d-1][i-1];
                last[i-1] = d;
            }
            else {
                ans -= c[i-1]*(d-last[i-1]);
            }
        }
    }
    ll tmp;
    while ((double)(clock() - ti)/CLOCKS_PER_SEC <= 1.98) {
        t[rand()%D] = rand()%26 + 1;
        last.clear();
        last.resize(26);
        tmp = 0;
        for (int d = 1; d <= D; d++) {
            for (int i = 1; i <= 26; i++) {
                if (t[d-1] == i) {
                    tmp += s[d-1][i-1];
                    last[i-1] = d;
                }
                else {
                    tmp -= c[i-1]*(d-last[i-1]);
                }
            }
        }
        if (tmp > ans || rand() % 10000 == 0) {
            swap(ans, tmp);
            rep(i, D) t_ans[i] = t[i];
        }
    }
    rep(i, D) cout << t_ans[i] << endl;
  	//cout << ans << endl;
}


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

double ans, mon;
int main() {
	int a, b, monn;
	cin >> a >> b;
	for (int i = 1; i <= a; ++i) {
		mon = 1.0 / a;
		monn = i;
		while (monn < b) {
			mon /= 2;
			monn *= 2;
		}
		ans += mon;
	}

	cout << setprecision(20) << ans << endl;
}

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

using namespace std;
using llong = long long;
using ldbl = long double;
using lpair = pair<llong, llong>;

#define ALL(x) x.begin(), x.end()

const llong inf = 1100100100100100ll;
const llong mod = 1e9+7;

int main() {
	llong L, R;
	cin >> L >> R;

	if (R - L >= 2018)
		cout << 0 << endl;
	else {
		llong ans = inf;
		for (llong i = L; i <= R; ++i)
			for (llong j = i+1; j <= R; ++j)
				ans = min(ans, i*j%2019ll);
		cout << ans << endl;
	}

	return 0;
}

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

string getLowerString(string s) {
    string t = s;
    for (int i = 0; i < s.size(); i++) {
        t[i] = tolower(s[i]);
    }
    return t;
}
int main() {
    string W, T;
    int count = 0;
    cin >> W;
    W = getLowerString(W);
    while (1) {
        cin >> T;
        if (T == "END_OF_TEXT") break;
        T = getLowerString(T);
        if (W == T) count++;
    }
    cout << count << endl;
    return 0;
}


Measured memory_bytes: 3200
def p_a():
    A, B = map(int, input().split())
    print(A * B if A < 10 and B < 10 else -1)


def p_b():
    pass


def p_c():
    pass


def p_d():
    pass


def p_e():
    pass


def p_f():
    pass


if __name__ == '__main__':
    p_a()


Measured memory_bytes: 38384
def main():
    n, x, *a = map(int, open(0).read().split())
    a = [0] + a
    ans = 0
    tmp = 0
    for i, j in zip(a, a[1:]):
        i -= tmp
        if i + j - x > 0:
            c = i + j - x
            ans += c
            tmp = c
        else:
            tmp = 0

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 14092
#include <iostream>
#include<algorithm>
#include<string>
#include <cmath>
#include <vector>
#include <map>
#include <cstdio>
#include <iomanip>
#include<set>
#include <numeric>
#pragma region Macros
#define int long long
#define double long double
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979323846;
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
#define LAST(x) x[x.size()-1]
#define ALL(x) (x).begin(),(x).end()
#define swap(a,b) (a += b,b = a - b,a -= b)
#define DIVCEIL(a,b) ((a+b-1)/b)
//int CHMAX

int FACT(int a) {
	if (a == 0)
		return 1;
	else
		return a * FACT(a - 1);
}
int nPr(int n, int r) {
	int s = n - r + 1;
	int sum = 1;
	for (int i = s; i <= n; i++)
		sum *= i;
	return sum;
}
//int nCr(int n, int r)
int nCr2(int n, int r) {
	return FACT(n) / (FACT(r) * FACT(n - r));
}
int GCD(int a, int b)
{
	if (a < b)
		swap(a, b);
	if (b == 0)
		return a;
	if (a % b == 0)
		return b;
	return GCD(b, a % b);
}
int LCM(int a, int b)
{
	return  a * b / GCD(a, b);
}
int NUMOFDIV(int n) {
	int ans = 0;
	REP(i, n) {
		if (n % i == 0)
			ans++;
	}
	return ans;
}
int CEIL1(int n) {
	return (n + 9) / 10 * 10;
}
int DIGITSUM(int n) {
	int sum = 0, dig;
	while (n) {
		dig = n % 10;
		sum += dig;
		n /= 10;
	}
	return sum;
}
int DIVTIME(int n, int k) {
	int div = 0;
	while (n % k == 0) {
		div++;
		n /= k;
	}
	return div;
}
double LOG(int a, int b) {
	return log(b) / log(a);
}
inline bool BETWEEN(int x, int min, int max) {
	if (min <= x && x <= max)
		return true;
	else
		return false;
}
inline bool PRIMEOR(int x) {
	if (x == 1)
		return false;
	if (x == 2)
		return true;
	if (x % 2 == 0)
		return false;
	double sqrtx = sqrt(x);
	for (int i = 3; i <= sqrtx; i += 2) {
		if (x % i == 0)
			return false;
	}
	return true;
}
bool SQRTOR(int n) {
	if (sqrt(n) == (int)sqrt(n))
		return true;
	else
		return false;
}
// 順位付け
using namespace std;
#pragma endregion
signed main() {
	int N = 0, W = 0, S = 0, E = 0;
	string s;
	cin >> s;
	rep(i, s.size()) {
		if (s[i] == 'N')
			N++;
		if (s[i] == 'W')
			W++;
		if (s[i] == 'S')
			S++;
		if (s[i] == 'E')
			E++;
	}
	if (((N == 0 && S == 0) || (N > 0 && S > 0)) && ((W == 0 && E == 0) || (W > 0 && E > 0)))
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
typedef pair<int, int> P;
 
bool m[21][21];
int a[4][2] = {{0,1},{0,-1},{1,0},{-1,0}};
 
int main(){
  int h, w;
  cin >> h >> w;
  for(int i=0; i<h; i++){
    for(int j=0; j<w; j++){
      char c; cin >> c;
      if(c=='.') m[i][j]=true;
    }
  }
  int bmax=0;
  for(int i=0; i<h; i++){
    for(int j=0; j<w; j++){
      if(!m[i][j]) continue;
      int dist[h][w];
      fill((int*)dist,(int*)(dist+h),-1);
      dist[i][j] = 0;
      queue<P> que;
      que.push(P(i,j));
      while(!que.empty()){
        P p = que.front(); que.pop();
        for(int k=0; k<4; k++){
          int dx=a[k][0],dy=a[k][1];
          int x = p.first+dx, y=p.second+dy;
          if(0<=x&&x<h&&0<=y&&y<w&&dist[x][y]<0&&m[x][y]){
            dist[x][y]=dist[p.first][p.second]+1;
            que.push(P(x,y));
            bmax = max(bmax,dist[x][y]);
          }
        }
      }
    }
  }
  cout << bmax << endl;
  return 0;
}

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

using namespace std;

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define FORR(i, a, b) for(int i = (a); i > (b); --i)
#define REP(i, n) for(int i = 0; i < (n); ++i)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOREACH(x, a) for(auto &(x) : (a))
#define VECCIN(x)                                                              \
    for(auto &youso_ : (x)) cin >> youso_
#define mp make_pair
#define bitcnt __builtin_popcount
#define All(a) (a).begin(), (a).end()
template <typename T = long long> inline T IN() {
    T x;
    cin >> x;
    return (x);
}
inline void CIN() {}
template <class Head, class... Tail>
inline void CIN(Head &&head, Tail &&... tail) {
    cin >> head;
    CIN(move(tail)...);
}
#define CINT(...)                                                              \
    int __VA_ARGS__;                                                           \
    CIN(__VA_ARGS__)
#define LCIN(...)                                                              \
    ll __VA_ARGS__;                                                            \
    CIN(__VA_ARGS__)
#define SCIN(...)                                                              \
    string __VA_ARGS__;                                                        \
    CIN(__VA_ARGS__)
#define Yes(a) cout << (a ? "Yes" : "No") << "\n"
#define YES(a) cout << (a ? "YES" : "NO") << "\n"

typedef long long ll;
typedef vector<int> V;
typedef vector<ll> VL;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
typedef priority_queue<int> PQ;
typedef priority_queue<int, V, greater<int>> PQG;

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

ll N;

ll dfs(ll last, bool flag7, bool flag5, bool flag3) {
    ll res = 0;
    if(last > N) return 0;
    if(flag7 && flag5 && flag3) res++;
    res += dfs(last * 10 + 7, true, flag5, flag3);
    res += dfs(last * 10 + 5, flag7, true, flag3);
    res += dfs(last * 10 + 3, flag7, flag5, true);
    return res;
}

int main() {
    cin >> N;
    cout << dfs(0, false, false, false) << "\n";
}

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


int main()
{
    stringstream ss;
    // 入力
    int A,B,C,X,Y;
    cin>>A>>B>>C>>X>>Y;
    int price=0;
    if(2*C>A+B) {
        price=X*A+Y*B;
    }
    else if (X>Y)
    {
        if(2*C<A){
            price=2*C*X;

        }
        else{
            price=2*C*Y+(X-Y)*A;
        /* code */
        }
    }
    else if(Y>=X)
    {
        if(2*C<B){
            price=2*C*Y;
        } else{
            price=2*C*X+(Y-X)*B;
        }

    }
    cout<<price<<endl;
    return 0;
}

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

int main(){
	long money=100000;
	int n;
	cin >> n;
	
	for(int i=0; i<n; ++i){
		money*=1.05;
			
		if(money%1000!=0)
			money+= 1000-(money%1000);
	}

	printf("%ld\n",money);
	
	return 0;
}

Measured memory_bytes: 1148
#include <stdio.h>
 
int main(void) {
	long long n;
	scanf("%lld", &n);
 
	long long result = 0;
	for (long long i = 1; i <= n; i++) {
		if (i % 3 != 0 && i % 5 != 0) {
			result = result + i;
		}
	}
	printf("%lld\n", result);
}

Measured memory_bytes: 1736
N = int(input())
A = []
for _ in range(2):
    A.append(list(map(int, input().split())))

sum_candy = []

for i in range(N):
    sum = 0
    for j in range(i+1):
        sum += A[0][j]
    for j in range(i, N):
        sum += A[1][j]

    sum_candy.append(sum)

print(max(sum_candy))

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

#define rep(i, a, b) for (int i = (a); i < (int)(b); i++)
#define rrep(i, a, b) for (int i = (a); i >= (int)(b); i--)
#define all(x) (x).begin(), (x).end()
using i32 = int32_t;
using i64 = int64_t;
using f32 = float;
using f64 = double;
using P   = pair<int, int>;

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

template <class T>
void dump_vec(const vector<T> &v) {
    auto len = v.size();
    rep(i, 0, len) {
        cout << v[i] << (i == (int)len - 1 ? "\n" : " ");
    }
}

struct Setup {
    Setup() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} SETUP;

//---------------------------------------------------------------------------------------------------

//---------------------------------------------------------------------------------------------------

struct Edge {
    int from, to;
    i64 cost;
    Edge() {}
    Edge(int t, i64 c) : from(-1), to(t), cost(c) {}
    Edge(int f, int t, i64 c) : from(f), to(t), cost(c) {}

    bool operator<(const Edge &r) const {
        return cost < r.cost;
    }
};

using Vertex = vector<Edge>;
using Graph  = vector<Vertex>;

// 無向
void undirected_connect(Graph &g, int from, int to, int cost = 1) {
    g[from].push_back(Edge(from, to, cost));
    g[to].push_back(Edge(to, from, cost));
    return;
}

// 有向
void directed_connect(Graph &g, int from, int to, int cost = 1) {
    g[from].push_back(Edge(from, to, cost));
    return;
}

signed main() {
    int N;
    cin >> N;
    Graph graph(N);
    // 親ノード
    vector<int> pars(N, -1);
    rep(i, 0, N) {
        int id;
        cin >> id;
        int K;
        cin >> K;
        rep(j, 0, K) {
            int c;
            cin >> c;
            // 親ノードを別のデータで管理しているから、子供しか見なくて良い -> 有向グラフで考えてよい
            directed_connect(graph, id, c);
            pars[c] = id;
        }
    }

    rep(i, 0, N) {
        const auto par = pars[i];
        printf("node %d: parent = %d, ", i, par);

        int depth = 0;
        // 根方向に巡回
        for (int j = i; pars[j] != -1; j = pars[j])
            depth++;
        printf("depth = %d, ", depth);

        string s;
        if (depth == 0) {
            s = "root";
        } else if (graph[i].empty()) {
            s = "leaf";
        } else {
            s = "internal node";
        }
        printf("%s, ", s.c_str());

        printf("[");
        vector<int> cs;
        rep(j, 0, graph[i].size()) {
            auto c = graph[i][j].to;
            printf("%d", c);
            if (j < (int)graph[i].size() - 1) {
                printf(", ");
            }
        }
        printf("]\n");
    }
}



Measured memory_bytes: 7960
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define REP(i, m, n) for (ll(i) = (ll)(m); i < (ll)(n); ++i)
#define REP2(i, m, n) for (ll(i) = (ll)(n)-1; i >= (ll)(m); --i)
#define rep(i, n) REP(i, 0, n)
#define rep2(i, n) REP2(i, 0, n)
#define all(hoge) (hoge).begin(), (hoge).end()
#define en '\n'
using Edge = pair<int, long long>;
using Graph = vector<vector<Edge>>;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<ll>>> vvvl;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef pair<ll, ll> pll;
constexpr long long INF = 1LL << 60;
constexpr int INF_INT = 1 << 25;
const int MOD = 1000000007;
// constexpr long long MOD = (ll)1e9 + 7;
// constexpr long long MOD = 998244353LL;
using ld = long double;
static const ld pi = 3.141592653589793L;
template <class T> inline void print(T x) { cout << x << '\n'; }
template <class T> bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> bool chmin(T& a, const T& b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}

// ~~~~~~~~~~~~~~memo~~~~~~~~~~~~~~
// for (int i = 0; i < n; ++i)
// int型の2次元配列(h×w要素の)の宣言
// vector<vector<int>> data(h, vector<int>(w));
// rotate(s.begin(), s.begin() + 1, s.end());
// sort(all(a),greater<int>());
// s.substr(0,2) 先頭から2文字切り出す
// for (auto it = mp.rbegin();it != mp.rend(); ++it)
// vector<vector<vector<int>>> dp(n + 1, vector<vector<int>>(w + 1, vector<int>(k+1, 0)));
ll f(ll x) {
    ll res = 0;
    ll countxor = 0;
    countxor = (x+2-1)/2;
    if (x%2 == 0) {
        if (countxor%2 == 1) {
            res = 1^x;
        } else {
            res = 0^x;
        }
    } else {
        if (countxor%2 == 1) {
            res = 1;
        } else {
            res = 0;
        }
    }
    return res;
};

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll a,b;
    cin >> a >> b;
    print(f(b)^f(a-1));

    return 0;
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    ll n,m,x,q;
    cin>>n>>m>>x;
    ll dis[n][n];
    for(int i=0;i<n;i++)for(int j=0;j<n;j++)dis[i][j]=((i==j)?0:1e18);
    ll a,b,c;
    for(int i=0;i<m;i++){
        cin>>a>>b>>c;
        a--;b--;
        dis[a][b]=dis[b][a]=c;
    }
    for(int k=0;k<n;k++){
        for(int i=0;i<n;i++){
            for(int j=0;j<n;j++){
                dis[i][j]=min(dis[i][j],dis[i][k]+dis[k][j]);
            }
        }
    }
    ll d[n][n];
    for(int i=0;i<n;i++)for(int j=0;j<n;j++)d[i][j]=1e18;
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            if(dis[i][j]<=x){
                d[i][j]=1;
            }
        }
    }
    for(int k=0;k<n;k++){
        for(int i=0;i<n;i++){
            for(int j=0;j<n;j++){
                d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
            }
        }
    }
    cin>>q;
    vector<ll> v;
    for(int i=0;i<q;i++){
        cin>>a>>b;

        v.pb(d[a-1][b-1]);
    }
    for(int i=0;i<q;i++){
        if(v[i]==1e18)cout << -1<<endl;
        else cout << v[i]-1<<endl;
    }
    return 0;
}


Measured memory_bytes: 2808
#include <bits/stdc++.h>
#define loop2(i, s, n, a) for (int i = int(s); i < int(n); i += a)
#define loop(i, s, n) loop2(i, s, n, 1)
#define rep(i, n) loop(i, 0, n)

#define pb push_back
#define all(in) in.begin(),in.end()

using ll = long long;
using ull = unsigned long long;
using namespace std;

struct UnionFind {
    vector<int> data;
    UnionFind(int size) : data(size, -1) { }
    bool unionSet(int x, int y) {
        x = root(x);
        y = root(y);

        if (x != y) {
            if (data[y] < data[x]) swap(x, y); // xの方が小さい→→sizeはxの方が大きい
            data[x] += data[y];
            data[y] = x;
        }
        return x != y;
    }
    bool findSet(int x, int y) { return root(x) == root(y); }
    int root(int x) { return data[x] < 0 ? x : data[x] = root(data[x]); } // rootは-size,それ以外はroot(parent)
    int size(int x) { return -data[root(x)]; }
};

int main(){
    ll n, m; cin >> n >> m;
    vector<pair<ll,ll>> data(m);
    rep(i,m){
        ll a, b; cin >> a >> b;
        data[i].first = a-1;
        data[i].second = b-1;
    }

    vector<ll> ans(m,0);
    ans[m-1] = n*(n-1)/2;

    UnionFind an(n);

    for(ll i = m-1; i > 0; i--){
        ll count = an.size(data[i].first) * an.size(data[i].second);
        ans[i-1] = ans[i];
        if(an.unionSet(data[i].first, data[i].second)) ans[i-1] -= count;
    }
    rep(i,m) cout << ans[i] << endl;
}

Measured memory_bytes: 5844
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define f first
#define s second
#define go ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
/*bool sortbysec(const pair<int,int> &a,
              const pair<int,int> &b)
{
    return (a.second < b.second);
} */
int main()
{
     ll n,sum=0;
     cin>>n;
     for(int i=1;i<=n;i++)
     {
         if(i%3!=0 && i%5!=0)
            sum+=i;
     }
     cout<<sum<<endl;
}


Measured memory_bytes: 3628
#include<iostream>
#include<string>
#include<stdio.h>
#include<algorithm>
#include<cmath>
using namespace std;

int main() {
	int n;
	double s1[1000], s2[1000];
	cin >> n;
	double ans[4] = {};

	for (int j = 0; j < n; j++) {
		cin >> s1[j];
	}
		for (int j = 0; j < n; j++) {
			cin >> s2[j];
		}

		for (int i = 0; i < 3; i++) {
			for (int j = 0; j < n; j++) {
				ans[i] += pow(abs(s1[j] - s2[j]), i+1);
			}
			ans[i] = pow(ans[i], 1 / (double)(i+1));
		}
		for (int j = 0; j < n; j++) {
			if (ans[3] < abs(s1[j] - s2[j])) {
				ans[3] = abs(s1[j] - s2[j]);
			}
		}

		for (int i = 0; i < 4; i++) {
			printf("%.6f\n",ans[i]);
		}
	
	return 0;

}



Measured memory_bytes: 3428
#include<iostream>
#include <string>
#include<algorithm>
#include <set>
#include <cmath>
using namespace std;

int main(void) {
	ios::sync_with_stdio(false);
	int A, B;
	cin >> A >> B;
	if (B%A == 0) cout << A + B;
	else cout << B - A;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

struct Data {
  int a,b;
  bool operator<(const Data& right) const {
    return a < right.a;
  }
};

int main(){
  int N;
  long long int K;
  cin>>N>>K;
  vector<Data> data(N);
  for(int i=0;i<N;i++){
    cin>>data[i].a>>data[i].b;
  }

  sort(data.begin(),data.end());
  int ans;
  for(int i=0;K>0&&i<N;i++){
    K-=data[i].b;
    ans=data[i].a;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <iomanip>//setprecision
#include<math.h>
#include <functional>
#include<climits>
using namespace std;
#define rep(i, n)        for(int i=0; i<(int)(n); ++i)
#define ll  long long 
  vector<ll>to[1000005];
int main(){
  string s,t,u;cin>>s>>t;
  ll a,b;cin>>a>>b;
  cin>>u;
  if(u==s)a--;
  else b--;
  cout<<a<<" "<<b;
}


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

int N,M;
const int MAX_N = 505;
string a[MAX_N];

char A[MAX_N][MAX_N],B[MAX_N][MAX_N];

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

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


	for(int i=0;i<N;i++){
		for(int j=0;j<M;j++){
			if(a[i][j]=='#'){
				A[i][j] = '#';
				B[i][j] = '#';
			}else if(i==0){
				A[i][j] = '#';
				B[i][j] = '.';
			}else if(i==N-1){
				A[i][j] = '.';
				B[i][j] = '#';
			}else if(j%2==0){
				A[i][j] = '#';
				B[i][j] = '.';
			}else{
				A[i][j] = '.';
				B[i][j] = '#';
			}
		}
	}

	for(int i=0;i<N;i++){
		cout << A[i] << '\n';
	}
	cout << '\n';
	for(int i=0;i<N;i++){
		cout << B[i] << '\n';
	}

	return 0;
}

Measured memory_bytes: 1536
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
int gi(){
	int x=0,w=1;char ch=getchar();
	while ((ch<'0'||ch>'9')&&ch!='-') ch=getchar();
	if (ch=='-') w=0,ch=getchar();
	while (ch>='0'&&ch<='9') x=(x<<3)+(x<<1)+ch-'0',ch=getchar();
	return w?x:-x;
}
int n,x,a[1000005];
int main(){
	n=gi();x=gi();
	for (int i=1;i<=n;++i) a[i]=gi();
	sort(a+1,a+n+1);
	for (int i=1;i<=n;++i) if (x>=a[i]) x-=a[i];else return printf("%d\n",i-1),0;
	if (!x) printf("%d\n",n);else printf("%d\n",n-1);return 0;
}


Measured memory_bytes: 128
#![allow(non_snake_case)]
#![allow(unused_imports)]
 
use proconio::{input, fastout};
use proconio::marker::*;
use whiteread::parse_line;
use std::collections::*;

#[fastout]
fn main() {
    input!{
        a: usize, b: usize,
    }
    println!("{}",  a * b);
}


Measured memory_bytes: 2172
#include<bits/stdc++.h>
using namespace std;
long long a, b, c, tot;
int main(){
	cin>>a>>b;
	c=__gcd(a, b);
	for(long long i=2;i*i<=c;i++){
		if(c%i==0){
			tot++;
			while(c%i==0) c/=i;
		}
	}
	if(c!=1) tot++; 
	cout<<tot+1;
}


Measured memory_bytes: 256
import           Control.Applicative

data Tpl = Tpl {a :: Int, b :: Int, c :: Int}
instance Show Tpl where
  show o | a o < b o && b o < c o = "Yes"
         | otherwise = "No"

readTuple :: IO Tpl
readTuple = do
  ns <- map read . words <$> getLine
  return $ Tpl (head ns) (last $ take 2 ns) (last $ take 3 ns)

main = readTuple >>= print



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

#define int long long
#define double long double
#define rep(i, n) for (int i = 0; i < (n); i++)
#define reps(i, n) for (int i = 1; i <= (n); i++)
#define all(x) (x).begin(), (x).end()
#define uniq(x) (x).erase(unique(all(x)), (x).end())
#define bit(n) (1LL << (n))
#define dump(x) cerr << #x " = " << (x) << endl
using vint=vector<int>;
using vvint=vector<vint>;
using pint=pair<int, int>;
using vpint=vector<pint>;
template<typename T> using priority_queue_rev=priority_queue<T, vector<T>, greater<T>>;
constexpr double pi = 3.1415926535897932384626433832795028;
constexpr int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int gcd(int a, int b) {
    while (b) { swap(a %= b, b); }
    return a;
}
int lcm(int a, int b) { return a / gcd(a, b) * b; }
template<typename T1, typename T2> bool chmax(T1 &a, const T2 &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T1, typename T2> bool chmin(T1 &a, const T2 &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &rhs) {
    os << "(" << rhs.first << ", " << rhs.second << ")";
    return os;
}
template<typename T> ostream &operator<<(ostream &os, const vector<T> &rhs) {
    os << "{";
    for (auto itr = rhs.begin(); itr != rhs.end(); itr++) {
        os << *itr << (next(itr) != rhs.end() ? ", " : "");
    }
    os << "}";
    return os;
}
struct setup {
    static constexpr int PREC = 20;
    setup() {
        cout << fixed << setprecision(PREC);
        cerr << fixed << setprecision(PREC);
    };
} setup;

template<typename T>
struct cumulative_sum {
    int n;
    T ZERO;
    std::vector<T> data;
    template<typename I> cumulative_sum(I begin, I end, T ZERO = T())
        : n(end - begin), ZERO(ZERO), data(n + 1) {
        std::copy(begin, end, data.begin() + 1);
        for (int i = 0; i < n; i++) { data[i + 1] += data[i]; }
    }
    T get_sum(int l, int r) const {
        if (l < 0) { l = 0; }
        if (l > n) { l = n; }
        if (r < 0) { r = 0; }
        if (r > n) { r = n; }
        return data[r] - data[l];
    }
};

int N, Q;
string S;
int D[1100000], M[1100000], C[1100000];
signed main() {
    cin >> N >> S;
    rep(i, N) {
        D[i] = S[i] == 'D';
        C[i] = S[i] == 'C';
        M[i] = S[i] == 'M';
    }
    cumulative_sum<int> Dcs(D, D + N), Mcs(M, M + N), Ccs(C, C + N);
    //oppaimankomankochinpo
    cin >> Q;
    rep(i, Q) {
        int k, ans = 0;
        cin >> k;
        rep(j, N) {
            if (S[j] == 'D') { ans -= Ccs.get_sum(j, j + k) * Mcs.get_sum(0, j); }
            if (S[j] == 'C') { ans += Dcs.get_sum(j - k + 1, j + 1) * Mcs.get_sum(0, j); }
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 49796
#include <iostream>
using namespace std;
typedef long long ll;

int main(){
    ll N, a, m = 1e18;
    cin >> N;
    for(int i = 0; i < 5; ++i){
        cin >> a;
        m = min(m, a);
    }
    cout << (N-1)/m + 5 << endl;
}


Measured memory_bytes: 256