akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <utility>

using namespace std;

int main() {
	int N, K;
	cin >> N >> K;
	vector<int> a(N);
	for(auto &x: a) cin >> x;
	vector<pair<bool, bool> > dp(K+1);

	for(int i = 0; i <= K; i++) {
		pair<bool, bool> flg = make_pair(false, false);
		for(auto x: a) {
			if(i - x >= 0) {
				if(dp[i - x].first == false) {
					flg.second = true;
				}
				if(dp[i - x].second == false) {
					flg.first = true;
				}
			}
		}
		dp[i] = flg;
	}

/*
	for(auto x: dp) {
		cout << "(";
		cout << (x.first ? "t" : "f");
		cout << ",";
		cout << (x.second ? "t" : "f") << ")";
	}
	cout << endl;
*/
	if(dp[K].first) {
		cout << "First" << endl;
	} else {
		cout << "Second" << endl;
	}
}


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

int main() {
    int n;
    cin >> n;
    vector<double> a(n);
    double sum = 0.0;
    rep(i, n) {
        cin >> a.at(i);
        sum += 1.0 / a.at(i);
    }
    double ans = 1.0 / sum;
    cout << fixed << setprecision(10) << ans << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define _overload3(_1,_2,_3,name,...)name
#define _rep(i,n)repi(i,0,n)
#define repi(i,a,b)for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define MSVC_UNKO(x)x
#define rep(...)MSVC_UNKO(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define all(c)c.begin(),c.end()
#define write(x)cout<<(x)<<'\n'
using namespace std; typedef long long ll; template<class T>using vv = vector<vector<T>>;
template<class T>auto vvec(int n, int m, T v) { return vv<T>(n, vector<T>(m, v)); }
template<class T, class U>bool chmax(T& a, U&& b) { return a < b ? a = b, 1 : 0; }
template<class T, class U>bool chmin(T& a, U&& b) { return b < a ? a = b, 1 : 0; }
constexpr int INF = 1 << 29, MOD = int(1e9) + 7; constexpr ll LINF = 1LL << 60;
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10); }; }aaaa;

int main() {
    int r;
    cin >> r;
    write(r * r);
}

Measured memory_bytes: 256
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    sx, sy, tx, ty = LI()

    dx = tx - sx
    dy = ty - sy
    ans_f0 = 'U' * dy + 'R' * dx
    ans_b0 = 'D' * dy + 'L' * dx
    ans_f1 = 'L' + 'U' * (dy + 1) + 'R' * (dx + 1) + 'D'
    ans_b1 = 'R' + 'D' * (dy + 1) + 'L' * (dx + 1) + 'U'

    print(ans_f0 + ans_b0 + ans_f1 + ans_b1)

if __name__ == '__main__':
    resolve()


Measured memory_bytes: 10036
#include <stdio.h>
int main()
{
  int i, j, k, N, A[1000], v;

  scanf("%d",&N);
  for (i = 0; i < N; i++)
    scanf("%d",&A[i]);
  for (i = 1; i < N; i++){
    for (k = 0; k < N; k++){
      printf("%d",A[k]);
      if (k != N-1)
	printf(" ");
    }
    printf("\n");
    v = A[i];
    j = i - 1;
    while (j >= 0 && A[j] > v){
      A[j+1] = A[j];
      j--;
    }
    A[j+1] = v;
  }
  for (k = 0; k < N; k++){
    printf("%d",A[k]);
    if (k != N-1)
      printf(" ");
  }
  printf("\n");
  
  return 0;
}



Measured memory_bytes: 2080
import java.util.Scanner;

public class Main {

    public static void main(String args[]){
        Scanner scanner = new Scanner(System.in);
        String input = scanner.next();
        if(input.charAt(2) == input.charAt(3) && input.charAt(4) == input.charAt(5)){
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
        scanner.close();
    }

}


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

int main(){
	int n,m,a,b;
	cin>>n>>m>>a>>b;
	if(a*2>m||b*2>n){
		puts("-1");
		exit(0);
	}
	for(int i=0;i<n;i++){
		for(int j=0;j<m;j++){
			putchar('0'^(i<b)^(j<a));
		}
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 1280
#include <cstdio>
#include <cmath>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>

#ifdef _DEBUG
#define DMP(x) cerr << #x << ": " << x << "\n"
#else
#define DMP(x) ((void)0)
#endif

const int MOD = 1000000007, INF = 1111111111;
using namespace std;
typedef long long lint;

lint dp[101][4][4][4];

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int N;
	cin >> N;

	// AGC, ACG, GAC, A?GC, AG?C (021, 012, 201, 0?21, 02?1)の4つがダメ、3つ前までを見れば帰納的に求まる。
	// ACGTに0123を対応

	dp[0][3][3][3] = 1;

	for (int len = 0; len < N; len++) {

		for (int i = 0; i < 4; i++) {
			for (int j = 0; j < 4; j++) {
				for (int k = 0; k < 4; k++) {

					if (dp[len][i][j][k] == 0) continue;

					for (int add = 0; add < 4; add++) {

						if (j == 0 && k == 2 && add == 1) continue;
						if (j == 0 && k == 1 && add == 2) continue;
						if (j == 2 && k == 0 && add == 1) continue;
						if (i == 0 && k == 2 && add == 1) continue;
						if (i == 0 && j == 2 && add == 1) continue;

						dp[len + 1][j][k][add] += dp[len][i][j][k];
						dp[len + 1][j][k][add] %= MOD;
					}
				}
			}
		}
	}

	lint ans = 0;
	for (int i = 0; i < 4; i++) {
		for (int j = 0; j < 4; j++) {
			for (int k = 0; k < 4; k++) {

				ans += dp[N][i][j][k];
				ans %= MOD;
			}
		}
	}

	cout << ans << "\n";

	return 0;
}


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

int k;

double les(int n){
    int res = 0;
    while(n < k){
        n *= 2;
        res++;
    }
    return res;
}

int main(){
    int n;
    cin >> n >> k;
    double ans = 0;
    for(int i = 1; i <= n; i++){
        ans += pow(0.5, les(i));
    }
    printf("%.15f\n", ans / n);
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
#define FIO \
    freopen("input.txt","r",stdin); \
    freopen("output.txt","w",stdout);
int main()
{
    //FIO;
    int n,k; cin>>n>>k;
   long long int a[n]; for(int i = 0 ; i < n; i++) cin>>a[i];
    for(int i = k; i < n; i++)
    {
        if(a[i-k]<a[i])
          cout<<"Yes\n";
        else
          cout<<"No\n";
        
    }
    return 0;
}

Measured memory_bytes: 4608
n, x = list(map(int, input().split()))

def length_burger(k):
	if k == 0:
		return(1)
	else:
		return(2*length_burger(k-1) + 3)

def num_pate(k, s):
	if s <= 0:
		return 0
	elif k == 0:
		return 1
	else:
		middle = length_burger(k) // 2 + 1
		if s < middle:
			return num_pate(k - 1, s - 1)
		elif s == middle:
			return num_pate(k - 1, s - 2) + 1
		else:
			if s == length_burger(k):
				return 2 * num_pate(k - 1, middle - 2) + 1
			else:
				return num_pate(k - 1, middle - 2) + 1 + num_pate(k - 1, s - middle)

print(num_pate(n, x))

Measured memory_bytes: 3064
from math import sqrt
import sys
sdin = sys.stdin.readline

q = int(sdin())
ab = []
for i in range(q):
    ab.append(tuple(map(int, sdin().split())))

for a, b in ab:
    if a == b or a == b-1:
        print(2*a - 2)
        
    else:
        if not (sqrt(a*b) - int(sqrt(a*b))):
            c = int(sqrt(a*b) - 1)
        else:
            c  = int(sqrt(a*b))
        
        if c*(c+1) >= a*b:
            print(2*c - 2)
        else:
            print(2*c - 1)
            

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
 
int main() {
  int N;
  cin >> N;
  unsigned long long ans=0;
  
  for(int i = 1; i<=N; ++i){
    if(i%3==0 || i%5==0)
      continue;
    ans+=i;
  }
  cout << ans << endl;
  return 0;
}

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

using namespace std;

int main() {
#ifdef LOCAL
  freopen("input.txt", "r", stdin);
#endif
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  vector<int> a(n);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  long long ans = n;
  vector<int> l(n), r(n);
  set<pair<int, int>> st;
  set<int> cur;
  for (int i = 0; i < n; ++i) {
    l[i] = r[i] = 1;
    st.emplace(a[i], i);
    cur.insert(i);
  }
  while (!st.empty()) {
    int p = st.begin()->second;
    st.erase(st.begin());
    vector<int> pos(1, p);
    while (true) {
      auto it = cur.lower_bound(pos.back() + 1);
      if (it == cur.end() || a[*it] != a[p]) {
        break;
      }
      st.erase(make_pair(a[p], *it));
      pos.push_back(*it);
    }
    int s = pos.size();
    if (s >= m) {
      for (int p : pos) {
        cur.erase(p);
      }
      long long pref = 0;
      for (int i = m - 1; i < s; ++i) {
        pref += l[pos[i - m + 1]];
        ans += pref * r[pos[i]];
      }
      int new_s = s / m;
      vector<int> new_l(new_s), new_r(new_s);
      for (int i = 0; i < s; ++i) {
        int p = pos[i];
        if (i >= m - 1) {
          new_r[(i - m + 1) / m] += r[p];
        }
        if (i + m <= s) {
          new_l[new_s - 1 - (s - m - i) / m] += l[p];
        }
      }
      for (int i = 0; i < new_s; ++i) {
        int p = pos[i];
        l[p] = new_l[i]; r[p] = new_r[i];
        st.emplace(++a[p], p);
        cur.insert(p);
      }
      if (new_s >= m) {
        pref = 0;
        for (int i = m - 1; i < new_s; ++i) {
          pref += l[pos[i - m + 1]];
          ans -= pref * r[pos[i]];
        }
      }
    }
  }
  cout << ans << "\n";
  return 0;
}


Measured memory_bytes: 21764
n, m = map(int, input().split())
lis = []

for i in range(n):
    a, b = map(int, input().split())
    lis.append([a, b])
lis.sort()
c = 0
ans = 0
while True:
    if m <= lis[c][1]:
        ans += m * lis[c][0]
        break
    else:
        ans += lis[c][0] * lis[c][1]
        m -= lis[c][1]
        c +=1
   
print(ans)


Measured memory_bytes: 20048
import itertools
na = lambda: list(map(int, input().split()))

n, m = na()
t = [[0] * 10 for _ in range(10)]
for _ in range(m):
    a, b = na()
    a -= 1
    b -= 1
    t[a][b] = t[b][a] = 1

ans = 0
for l in itertools.permutations(range(n)):
    if l[0]: continue
    flag = 1
    for i in range(1, n):
        if t[l[i]][l[i-1]] == 0:
            flag = 0
            break
    if flag:
        ans += 1

print(ans)

Measured memory_bytes: 3064
def n0():return int(input())
def n1():return [int(x) for x in input().split()]
def n2(n):return [int(input()) for _ in range(n)]
def n3(n):return [[int(x) for x in input().split()] for _ in range(n)]

a,b,c,d=n1()

while True:
    c=c-b
    if c<=0:
        print("Yes")
        break
    a=a-d
    if a<=0:
        print("No")
        break

Measured memory_bytes: 9204
import sys

stdin = sys.stdin
inf = 1 << 60
mod = 1000000007

ni      = lambda: int(ns())
nin     = lambda y: [ni() for _ in range(y)]
na      = lambda: list(map(int, stdin.readline().split()))
nan     = lambda y: [na() for _ in range(y)]
nf      = lambda: float(ns())
nfn     = lambda y: [nf() for _ in range(y)]
nfa     = lambda: list(map(float, stdin.readline().split()))
nfan    = lambda y: [nfa() for _ in range(y)]
ns      = lambda: stdin.readline().rstrip()
nsn     = lambda y: [ns() for _ in range(y)]
ncl     = lambda y: [list(ns()) for _ in range(y)]
nas     = lambda: stdin.readline().split()

s, w = na()

if w >= s:
    print("unsafe")
else:
    print("safe")

Measured memory_bytes: 9236
#include<stdio.h>
int main(){
  int A,B,K,i;
  scanf("%d %d %d",&A,&B,&K);
  if(B-A<2*K){
    for(i=A;i<=B;i++){
      printf("%d\n",i);
    }
  }else{
    for(i=0;i<K;i++){
      printf("%d\n",A+i);
    }for(i=0;i<K;i++){
      printf("%d\n",B-K+1+i);
    }
  }
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i = a; i < b; ++i)
#define all(c) c.begin(), c.end()
#define gmax(x,y) x=max(x,y)
#define gmin(x,y) x=min(x,y)
#define gadd(x,y) x=add(x,y)
#define gmul(x,y) x=mul(x,y)
using namespace std;

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

string a[4] = {"AC", "WA", "TLE", "RE"};
int cnt[4];

int main(){
	cin.tie(0);
	cout.tie(0);
	ios_base::sync_with_stdio(0);
	int n;
	cin >> n;
	while(n--){
		string s;
		cin >> s;
		rep(i,0,4){
			if(s == a[i]){
				++cnt[i];
			}
		}
	}
	rep(i,0,4){
		cout << a[i] << " x " << cnt[i] << '\n';
	}
}


Measured memory_bytes: 3668
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=200010;
int n;
ll k,a[maxn],f[maxn],sum=0,need=0;
bool check(ll score)
{
	need=0;
	for(int i=0;i<n;i++)
		need+=(max(0LL,a[i]-score/f[i]));
	if(need<=k)
		return true;
	return false;
}
int main()
{
	cin>>n>>k;
	ll mxa=1,mxf=1;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
		mxa=max(mxa,a[i]);
		sum+=a[i];
	}
	for(int i=0;i<n;i++)
	{
		cin>>f[i];
		mxf=max(mxf,f[i]);
	}
	ll lbound=0,ubound=mxa*mxf;
	sort(a,a+n);
	sort(f,f+n);
	reverse(f,f+n);
	while(lbound<ubound)
	{
		ll mid=(lbound+ubound)/2;
		if(check(mid))
			ubound=mid;
		else
			lbound=mid+1;
	}
	cout<<lbound<<endl;
	return 0;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a,b;
  cin >> a >> b;
  int c=a*b;
  if (c%2==1) {
    cout <<"Odd"<<endl;
  }
  else {
    cout <<"Even"<<endl;
  }  
}

Measured memory_bytes: 256
import sys
#import math
#import queue
#import copy
import bisect#2分探索

def input():
    return sys.stdin.readline()[:-1]
def inputi():
    return int(input())
def inputl():
    return list(map(int, input().split()))
def printl(li):
    print(*li, sep="\n")
def argsort(s):
    return sorted(range(len(s)), key=lambda k: s[k])

#mod = 10**9+7

N = inputi()
#N, K = inputl()
#L = [int(input()) for i in range(N)]
A = inputl()
B = inputl()
C = inputl()
#S = [inputl() for i in range(H)]
#q = queue.Queue() #q.put(i) #q.get() 
#q = queue.LifoQueue() #q.put(i) #q.get() 

#a= [[0]*3 for i in range(5)] #2次元配列はこう準備、[[0]*3]*5だとだめ
#b=copy.deepcopy(a)  #2次元配列はこうコピーする
#w.sort(key=lambda x:x[1],reverse=True)  #二個目の要素で降順並び替え

#素数リスト
# n = 100
# primes = set(range(2, n+1))
# for i in range(2, int(n**0.5+1)):
#     primes.difference_update(range(i*2, n+1, i))
# primes=list(primes)

#bisect.bisect_left(a, 4)#aはソート済みである必要あり。aの中から最も左の4位置を返す。
#bisect.insort_left(a, 4)#挿入


##TLE
# A.sort(reverse=True)
# B.sort()
# C.sort()
# tot=0
# cut=N
# for a in A:
#     cut=bisect.bisect_right(B[0:cut], a)
#     cut2=N
#     for i in reversed(range(cut,N)):
#         b=B[i]
#         cut2=bisect.bisect_right(C[0:cut2], b)
#         tot+=N-cut2

#right ans
tot=0
A.sort()
C.sort()
for b in B:
    cut1=bisect.bisect_left(A, b)
    cut2=bisect.bisect_right(C, b)
    tot+=cut1*(N-cut2)
print(tot)

Measured memory_bytes: 92968
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <vector>
#include <cmath> 

using namespace std;

int countDigit(int n) {
    int sum = 0;
    while (n > 0) {
        sum += n % 10;
        n /= 10;
    }

    return sum;
}

int main() {
    int N, A, B;
    int sum = 0;
    cin >> N >> A >> B;

    for (int number = 1; number <= N; number++) {
        int digit = countDigit(number);
        if (digit >= A && digit <= B) {
            sum += number;
        }
    }

    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define mod 1000000007
using ll=long long;
const int INF=1000000000;
const ll LINF=1001002003004005006ll;
int dx[]={1,0,-1,0},dy[]={0,1,0,-1};
// ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
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(b<a){a=b;return true;}return false;}
 
struct IOSetup{
    IOSetup(){
        cin.tie(0);
        ios::sync_with_stdio(0);
        cout<<fixed<<setprecision(12);
    }
} iosetup;
 
template<typename T1,typename T2>
ostream &operator<<(ostream &os,const pair<T1,T2>&p){
    os<<p.first<<" "<<p.second;
    return os;
}
 
template<typename T>
ostream &operator<<(ostream &os,const vector<T>&v){
    for(int i=0;i<(int)v.size();i++) os<<v[i]<<(i+1==(int)v.size()?"":" ");
    return os;
}

template<typename T1,typename T2>
istream &operator>>(istream &is,pair<T1,T2>&p){
    is>>p.first>>p.second;
    return is;
}

template<typename T>
istream &operator>>(istream &is,vector<T>&v){
    for(T &x:v)is>>x;
    return is;
}

template<typename T>
struct LiChaoTree{
    struct Line{
        T a,b;
        Line(T a,T b):a(a),b(b){}
        T get(T x)const{return a*x+b;}
        bool over(const Line &b,const T &x){return get(x)<b.get(x);}
    };

    vector<T> xs;
    vector<Line> seg;
    int sz;
    LiChaoTree(const vector<T> &x,T INF):xs(x){
        sz=1;
        while(sz<(int)xs.size())sz<<=1;
        while((int)xs.size()<sz)xs.push_back(xs.back()+1);
        seg.assign(2*sz,Line(0,INF));
    }
    void update(Line &x,int k,int l,int r){
        int m=(l+r)/2;
        bool lc=x.over(seg[k],xs[l]),mc=x.over(seg[k],xs[m]);
        if(mc)swap(seg[k],x);
        if(l+1>=r) return ;
        else if(lc!=mc) update(x,2*k,l,m);
        else            update(x,2*k+1,m,r);
    }
    // add ax+b
    void update(T a,T b){
        Line l(a,b);
        update(l,1,0,sz);
    }
    // xs[k]
    T query(int k){
        T x=xs[k];
        k+=sz;
        T ret=seg[k].get(x);
        while(k>1){
            k>>=1;
            chmin(ret,seg[k].get(x));
        }
        return ret;
    }
};


signed main(){
    int n;ll c;cin>>n>>c;
    ll h0;cin>>h0;
    n--;
    vector<ll> h(n);
    cin>>h;
    for(auto &x:h)x-=h0;

    LiChaoTree<ll> seg(h,LINF);
    seg.update(0,0);
    ll d;
    rep(i,n){
        d=seg.query(i);
        d+=h[i]*h[i]+c;
        seg.update(-2*h[i],h[i]*h[i]+d);
    }
    cout<<d<<endl;
    return 0;
}


Measured memory_bytes: 15152
import sys

input = sys.stdin.readline

ri = lambda: int(input())
rs = lambda: input().rstrip()
ril = lambda: list(map(int, input().split()))
rsl = lambda: input().rstrip().split()
ris = lambda n: [ri() for _ in range(n)]
rss = lambda n: [rs() for _ in range(n)]
rils = lambda n: [ril() for _ in range(n)]
rsls = lambda n: [rsl() for _ in range(n)]


def f(x):
    s = 0
    while x > 0:
        s += x % 10
        x //= 10
    return s


n = ri()
res = float('inf')
for a in range(1, n):
    res = min(res, f(a) + f(n - a))
print(res)

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

struct Doubling {
    int sz, n;
    vector<vector<int>> table;
    Doubling(int n, long long ma = (1LL << 62) - 1) : sz(334), n(n) {
        //while ((1LL << sz) < ma) ++sz;    // 64 - __builtin_clzll(ma)
        table.assign(sz, vector<int>(n, -1));
    }
    void set_next(int i, int x) { table[0][i] = x; }
    void build() {
        for (int k = 0; k < sz - 1; k++) for (int i = 0; i < n; i++) {
            if (~table[k][i]) table[k + 1][i] = table[k][table[k][i]];
        }
    }
    int query(int i, string t) {
        for (int k = t.length() - 1; k >= 0; k--) {
            if (t[k] - '0') i = table[k][i];
        }
        return i;
    }
};

int main() {
    string s; cin >> s;
    int n = s.size();
    Doubling dbl(n);
    for (int i = 0; i < n; i++) {
        if (s[i] == 'R') dbl.set_next(i, i + 1);
        else dbl.set_next(i, i - 1);
    }
    dbl.build();
    string big = "100100100100110101101001001011001010011000011011111001110101100001011001001111000010011000100110011100000101111110011100010101100111001000000100011100010000100011010011111001010101010110010010000110000100010101000001011101000111100010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000";
    reverse(big.begin(), big.end());
    vector<int> ans(n);
    for (int i = 0; i < n; i++) ans[dbl.query(i, big)]++;
    for (int i = 0; i < n; i++) cout << ans[i] << " \n"[i == n - 1];
    return 0;
}

Measured memory_bytes: 131960
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include<ext/pb_ds/tree_policy.hpp>
#include<cstdio>
#include<vector>
#include<stdio.h>
#include<cstring>
#include<algorithm>
#include<string>
#include<iostream>
#include<map>
#include<set>
#include<queue>
#include<set>
#define READ                freopen("in.txt", "r", stdin)
#define WRITE               freopen("out.txt", "w", stdout)
#define INF9                1000000010
#define INF18               1000000000000000010
#define dist(ax,ay,bx,by)   sqrt((ax-bx)*(ax-bx)+(ay-by)*(ay-by))
#define gcd(a,b)            __gcd(a,b)
#define lcm(a,b)            (a*b)/__gcd(a,b)
#define m_p(a,b)            make_pair(a,b)
#define sqr(a)              ((a)*(a))
#define pb                  push_back
#define bpll(a)             __builtin_popcountll(a)
#define MX                  100006
#define PI                  acos(-1)
#define mod                  1000000007
#define cnt_bin(n)          __builtin_clzll(0ll) - __builtin_clzll(n)

typedef long long lli;
using namespace std;


int main()
{
    lli d, t, s;
    cin>>d>>t>>s;

    if(t*s>=d) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;

    return 0;
}


Measured memory_bytes: 3584
#include <iostream>
#include <vector>
#include <deque>
#include <algorithm>
#include <numeric>
#include <string>
#include <cstring>
#include <list>
#include <unordered_set>
#include <tuple>
#include <cmath>
#include <limits>
#include <type_traits>
#include <iomanip>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <set>
#include <bitset>
#include <regex>
#include <random>
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
#define rep(i,n)for(ll i=0;i<n;++i)
#define exout(x) printf("%.10f\n", x)
const double pi = acos(-1.0);
const ll MOD = 1000000007;
const ll INF = 1e10;
const ll MAX_N = 1010;

//組み合わせの余りを求める
ll fac[MAX_N], finv[MAX_N], inv[MAX_N];

void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX_N; i++) {
		fac[i] = fac[i - 1] * i;
	}
}

// 二項係数計算
long long COM(ll n, ll k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	if (n > k * 2) {

	}
	return fac[n] / (fac[k] * fac[n - k]);
}

ll dp[201010][2];
ll dx[4] = { 0,0,-1,1 };
ll dy[4] = { -1,1,0,0 };
char c[10][10];
bool flag[10][10];
bool flag2[10][10];

//long longしか使わない
//素数は1より大きい
int main() {
	ll n;
	cin >> n;
	vector<ll>a(n);
	rep(i, n) {
		cin >> a[i];
	}
	sort(a.rbegin(), a.rend());
	ll ans = 0;
	ll zanki = 1;
	ll target = a[0];
	vector<ll>target2;
	rep(i, n) {
		if (i > 0) {
			ans += target;
			zanki--;
			if (a[i] == target)zanki += 2;
			if (a[i] != target)target2.push_back(a[i]);
			if (zanki == 0) {
				target = target2[0];
				target2.erase(target2.begin());
				zanki = 2;
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 5864
object Main {
  def main(args:Array[String]) {
    val read = readLine()
    val N = read.split(' ')(0).toInt
    val R = read.split(' ')(1).toInt

    var alpha = 0
    if(N <= 10) alpha = 100 * (10 - N)
    println(R + alpha)
  }
}



Measured memory_bytes: 25412
import java.util.*;
public class Main {
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		int l = sc.nextInt();
		double a = sc.nextInt();
		double b = sc.nextInt();
		double c = sc.nextInt();
		double d = sc.nextInt();
		int j, m;
		j = (int)Math.ceil(a / c);
		m = (int)Math.ceil(b / d);
		if(j > m) System.out.println(l - j);
		else System.out.println(l - m);
	}

}

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

using namespace std;

using ll = long long;
using vl = vector<ll>;
using vs = vector<string>;
using vvl = vector<vl>;
using pll = pair<ll,ll>;
using vb = vector<bool>;

const ll oo = 0x3f3f3f3f3f3f3f3fLL;
const double eps = 1e-9;

#define sz(c) ll((c).size())
#define all(c) begin(c),end(c)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define xx first
#define yy second

#define has(c,i) ((c).find(i) != end(c))
#define FOR(i,a,b) for (int i=(a); i<(b); i++)
#define FORD(i,a,b) for (int i=int(b)-1; i>=(a); i--)

#define rv(type,name,count) vector<type> name(count); FOR(_i,0,count) cin >> name[_i];
#define grid(type,name,c1,c2) vector<vector<type>> name(c1, vector<type>(c2)); FOR(_i,0,c1)FOR(_j,0,c2)cin >> name[_i][_j];

int main() {
	ll n, w;
	cin >> n >> w;
	vl v(100005, oo);
	v[0] = 0;
	FOR(i, 0, n) {
		ll wei, val;
		cin >> wei >> val;
		FORD(k, val, sz(v)) v[k] = min(v[k], v[k - val] + wei);
	}
	ll best = 0;
	FOR(i,0,sz(v)) if (v[i] <= w) best = i;
	cout << best << endl;
}


Measured memory_bytes: 1024
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)

	fmt.Println(pow(n, 3))
}

func pow(a, b int) (ret int) {
	ret = a
	// 10^2 = 100 は10に10を1回掛けること
	// つまり初期値を含めると上限b-1未満
	for i := 0; i < b-1; i++ {
		ret *= a
	}
	return
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
//#include<iostream>
using namespace std;
#define ll long long

int main()
{
    ll i,j,k,n,q,t,a,b;
    cin>>n>>a>>b;
    t=min(abs(n-a),abs(n-b));
    if(t==abs(n-a))
        cout<<'A'<<endl;
    else
        cout<<'B'<<endl;

}

Measured memory_bytes: 256
import java.util.*;
class Main{
    public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        String s = scanner.next();
        long r = 0;
        long g = 0;
        long b = 0;
        for(int i = 0; i < n; i++){
            if(s.charAt(i) == 'R'){r++;}
            else if(s.charAt(i) == 'G'){g++;}
            else{b++;}
        }
        long ans = r * g * b;
        for(int i = 0; i < n-2; i++){
            for(int j = i+1; j < n; j++){
                int k = 2 * j - i;
                if(k >= n) break;
                if(s.charAt(i) != s.charAt(j) && s.charAt(i) != s.charAt(k) && s.charAt(k) != s.charAt(j)) ans--;
            }
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 37716
#include <bits/stdc++.h>
#include <vector>
#include <numeric>
#define PI 3.14159265358979323846
#define MAXINF 1e18L
#define INF 1e9L
#define EPS 1e-9
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v), greater<int>())S
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define pb push_back
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
typedef long long ll;
typedef pair<int, int> pii;

ll gcd(ll a, ll b) {
    if (b == 0) return a;
    return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
    return a * b / gcd(a, b);
}

int main(void)
{
    int a;
    cin >> a;
    pr(lcm(a,2));
}

Measured memory_bytes: 256
left = [0]*4; right = [0]*4;
while 1:
    try:
        l,r = map(float, raw_input().split())
        if l>0.7: l-=0.1
        if r>0.7: r-=0.1
        left[min(15,2+int(10*l))/4]+=1
        right[min(15,2+int(10*r))/4]+=1
    except EOFError:
        break
for i in xrange(3,-1,-1):
    print left[i],right[i]

Measured memory_bytes: 4244
#include <bits/stdc++.h>
//\\//\\//\\//\\//\\//\\//\\//
#define fio ios::sync_with_stdio(false); cin.tie(nullptr)
#define all(x) (x).begin(),(x).end()
#define dlog(x) cerr<<#x<<'='<<x<<'\n'
#define endl '\n'
#define eb emplace_back
#define f first
#define s second
//\\//\\//\\//\\//\\//\\//\\//
using namespace::std;
using ll=long long;
using pii=pair<int,int>;
const int inf=INT_MAX,mod=1e9+7;
//\\//\\//\\//\\//\\//\\//\\//

vector<pii>vec;

unordered_map<int,ll>dp;
ll solve(ll x){
      if (x<=0) return 0;
      ll res=inf;
      for (pii i:vec) {
            if(!dp.count(x-i.f)) dp[x-i.f]=solve(x-i.f);
            res=min(res,dp[x-i.f]+i.s);
      }
      return res;
}


signed main(){
      fio;
      int x,n; cin>>x>>n;
      vec.resize(n);

      for (int i=0; i<n; i++) {
            cin>>vec[i].f>>vec[i].s;
      }

      cout<<solve(x);
}

Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
using namespace std;

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

	sort(p.begin(), p.end(), greater<int>());
	p[0] /= 2;

	int ans = 0;
	for (int pi : p)ans += pi;
	cout << ans << endl;
}

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

int main()
{
  int x,n,jdu=0,jdt=0,ans;
  cin >> x >> n;
  ans=x;
  vector<int> p(n);
  for(int i=0; i<n;i++)cin >> p[i];

  for(int i=0; i<60; i++){
    jdu=0;
    jdt=0;
    for(int j=0; j<n; j++){
      if(x-i==p[j]){
        jdu=1;
      }
      if(x+i==p[j]){
        jdt=1;
      }
    }
    if(jdu==0){
      ans=x-i;
      break;
    }
    else if(jdt==0){
      ans=x+i;
      break;
    }
  }

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

Measured memory_bytes: 3628
import java.util.Scanner

object Main {
  val sc = new Scanner(System.in)
  def main(args: Array[String]): Unit = {
    val n = sc.nextInt
    val tuple = List.fill(n){(sc.next, sc.next)}

    val res = tuple.foldLeft(0.0d){(r, t) =>
      r  + (if(t._2 == "BTC") t._1.toDouble * 380000.0 else t._1.toLong)
    }

    println(res)

  }
}


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

using std::min;

typedef long long LL;

const int N=210,Mod=1e9+7;

struct Edge{ int to,next; }way[N<<1];

int n,m,k,num[N],tot,cntnode[N],cntedge[N],cnt,inv[N],C[N][N];

int gcd(int a,int b) { return (!b)?a:gcd(b,a%b); }

void Build(int a,int b) { way[++tot]=(Edge){b,num[a]}; num[a]=tot; }

void Init() {
	scanf("%d%d%d",&n,&m,&k);
	int a,b; tot=1;
	for (int i=1;i<=m;++i) {
		scanf("%d%d",&a,&b);
		Build(a,b);
		Build(b,a);
	}
}

int dfn[N],cntdfn,low[N],que[N],top;
bool divv[N],vis[N],app[N];

void Dfs(int x,int fa) {
	dfn[x]=low[x]=++cntdfn;
	int son=0;
	for (int i=num[x];i;i=way[i].next) {
		int v=way[i].to;
		if (v==fa) continue;
		if (dfn[v]) {
			if (dfn[v]<dfn[x]){
				low[x]=min(low[x],dfn[v]);
				que[++top]=i;
			}
		}else {
			que[++top]=i;
			Dfs(v,x); ++son;
			low[x]=min(low[x],low[v]);
			if (v==19)
				v++,v--;
			if ((fa || son>=2) && low[v]>=dfn[x]){
				++cnt; int d=top;
				while (que[top]!=i) {
					cntedge[cnt]++;
					if (!app[way[que[top]].to]) app[way[que[top]].to]=1,cntnode[cnt]++;
					if (!app[way[que[top]^1].to]) app[way[que[top]^1].to]=1,cntnode[cnt]++;
					top--;
				}
				if (!app[way[que[top]].to]) app[way[que[top]].to]=1,cntnode[cnt]++;	
				if (!app[way[que[top]^1].to]) app[way[que[top]^1].to]=1,cntnode[cnt]++;	
				cntedge[cnt]++; top--;
				while (que[d]!=i) {
					app[way[que[d]].to]=0;
					app[way[que[d]^1].to]=0;
					d--;
				}
				app[way[que[d]].to]=0; app[way[que[d]^1].to]=0; d--;
			}
		}
	}
	if (!fa && top) {
		++cnt; int d=top;
		while (top) {
			cntedge[cnt]++;
			if (!app[way[que[top]].to]) app[way[que[top]].to]=1,cntnode[cnt]++;
			if (!app[way[que[top]^1].to]) app[way[que[top]^1].to]=1,cntnode[cnt]++;
			top--;
		}
		while (d) {
			app[way[que[d]].to]=0;
			app[way[que[d]^1].to]=0;
			d--;
		}	
	}
}

void Tarjan() {
	cnt=0; cntdfn=0;
	for (int i=1;i<=n;++i) if (!dfn[i]) Dfs(i,0);
}

int power(int x,int t) {
	int ret=1;
	while (t) {
		if (t&1) ret=1ll*ret*x%Mod;
		x=1ll*x*x%Mod;
		t>>=1;
	}
	return ret;
}

void Prepare() {
	inv[1]=1; for (int i=2;i<=m;++i) inv[i]=1ll*(Mod-Mod/i)*inv[Mod%i]%Mod;
	C[0][0]=1; 
	for (int i=1;i<=m+k;++i) {
		C[i][0]=1;
		for (int j=1;j<=i;++j)
			C[i][j]=(C[i-1][j-1]+C[i-1][j])%Mod;
	}
}

void Solve() {
	Tarjan();
	Prepare();
	LL ans=1;
	for (int i=1;i<=cnt;++i) {
		if (cntnode[i]==cntedge[i]) {
			int sum=0;
			for (int j=1;j<=cntedge[i];++j) 
				sum=(sum+power(k,gcd(j,cntedge[i])))%Mod;
			sum=1ll*sum*inv[cntedge[i]]%Mod;
			ans=1ll*ans*sum%Mod;
		}else ans=1ll*ans*C[cntedge[i]+k-1][k-1]%Mod;
	}
	printf("%lld\n",ans);
}

int main() {
	Init();
	Solve();
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using VI = vector<int>;
using VL = vector<ll>;
using VS = vector<string>;
template<class T> using PQ = priority_queue<T, vector<T>, greater<T>>;
#define FOR(i,a,n) for(int i=(a);i<(n);++i)
#define eFOR(i,a,n) for(int i=(a);i<=(n);++i)
#define rFOR(i,a,n) for(int i=(n)-1;i>=(a);--i)
#define erFOR(i,a,n) for(int i=(n);i>=(a);--i)
#define each(i, a) for(auto &i : a)
#define SORT(a) sort(a.begin(),a.end())
#define rSORT(a) sort(a.rbegin(),a.rend())
#define fSORT(a,f) sort(a.begin(),a.end(),f)
#define all(a) a.begin(),a.end()
#define out(y,x) ((y)<0||h<=(y)||(x)<0||w<=(x))
#define tp(a,i) get<i>(a)
#define line cout << "-----------------------------\n" 
#define ENDL(i,n) ((i) == (n) - 1 ? "\n" : " ")
#define stop system("pause")
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
constexpr ld eps = 1e-10;
constexpr ld pi = 3.1415926535897932;
template<class T>inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; }return false; }
template<class T>inline bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; }return false; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& is, vector<T>& v) { for (auto& a : v)is >> a; return is; }
template<class T>inline istream& operator>>(istream& is, deque<T>& v) { for (auto& a : v)is >> a; return is; }
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template<class T>inline vector<T> vec(size_t a) { return vector<T>(a); }
template<class T>inline vector<T> defvec(T def, size_t a) { return vector<T>(a, def); }
template<class T, class... Ts>inline auto vec(size_t a, Ts... ts) { return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...)); }
template<class T, class... Ts>inline auto defvec(T def, size_t a, Ts... ts) { return vector<decltype(defvec<T>(def, ts...))>(a, defvec<T>(def, ts...)); }
template<class T>inline void print(const T& a) { cout << a << "\n"; }
template<class T, class... Ts>inline void print(const T& a, const Ts&... ts) { cout << a << " "; print(ts...); }
template<class T>inline void print(const vector<T>& v) { for (int i = 0; i < v.size(); ++i)cout << v[i] << (i == v.size() - 1 ? "\n" : " "); }
template<class T>inline void print(const vector<vector<T>>& v) { for (auto& a : v)print(a); }
inline string reversed(const string& s) { string t = s; reverse(all(t)); return t; }

int main() {
    init();

    int n; cin >> n;
    VI a(n); cin >> a;
    int ans = 0;
    FOR(i, 0, n) {
        if (i % 2 == 0 && a[i] % 2 == 1)++ans;
    }
    print(ans);

    return 0;
}

Measured memory_bytes: 3612
import java.util.*;
import javax.lang.model.util.ElementScanner6;

class Record {
    int ac = 0;
    int wa = 0;
}

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        // 入力
        int n = sc.nextInt();
        int m = sc.nextInt();

        // 処理
        Map<Integer, Record> xx = new HashMap<>();
        for (int i = 0; i < m; i++) {
            int no = sc.nextInt();
            String result = sc.next();

            if (xx.get(no) == null) {
                Record record = new Record();
                if (result.equals("AC")) {
                    record.ac += 1;
                } else if (result.equals("WA")) {
                    record.wa += 1;
                }
                xx.put(no, record);
            } else {
                Record record = xx.get(no);
                if (result.equals("AC") && record.ac == 0) {
                    record.ac += 1;
                } else if (result.equals("WA") && record.ac == 0) {
                    record.wa += 1;
                }
                xx.put(no, record);
            }
        }

        int out_ac = 0;
        int out_wa = 0;
        for (Record record : xx.values()) {
            out_ac += record.ac;
            out_wa += record.ac > 0 ? record.wa : 0;
        }

        // 出力
        System.out.print(out_ac);
        System.out.print(' ');
        System.out.println(out_wa);
    }
}

Measured memory_bytes: 69940
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
//#include <conio.h>
using namespace std;

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

#define rep(i,n)	for(ll i=0;i<(n);i++)
#define SZ(x) ((ll)x.size())
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define F first
#define S second
#define int ll
#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
// const ll MOD = INT_MAX;
const double PI = acos(-1);

void openfile(){
	freopen("in.txt", "r", stdin);
	freopen("out.txt", "w", stdout);
}

const int leng = 1e4+7;
char k[leng];
const int mod = 1e9+7;

void add(int &a, int b){
	a += b;
	if(a >= mod)	a -= mod;
}

signed main(){
	IOS
	scanf("%s", k);
	int D;
	scanf("%lld", &D);
	int len = strlen(k);
	vector<vector<int>> dp(D, vector<int>(2));
	// dp[sum][b] = 
	// 		sum : current sum mod D is sum
	//		b : whether we've already chosen some digit 'smaller' than in K

	dp[0][0] = 1;
	rep(i,len){
		vector<vector<int>> dp1(D, vector<int>(2));
		rep(sum,D){
			for(bool b : {false,true}){
				rep(digit,10){
					if(digit > k[i] - '0' && !b)	break;
					add(dp1[(sum+digit) % D][b || (digit < k[i] - '0')], dp[sum][b]);
				}
			}
		}

		dp = dp1;
	}
	int ans = (dp[0][0] + dp[0][1] - 1 + mod) % mod;
	printf("%lld\n", ans);
}


Measured memory_bytes: 384
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace B
{
    public class Program
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var n = int.Parse(Console.ReadLine());
            var s = Console.ReadLine();
            var count = 0;
            var index = 0;
            while (true)
            {
                index = s.IndexOf("ABC");
                if (index < 0) break;
                s = s.Substring(index + 3);
                count++;

            }
            Console.WriteLine(count);
        }
    }
}


Measured memory_bytes: 11488
/*

参考にした提出
https://agc023.contest.atcoder.jp/submissions/2435072

*/


#include<cstddef>
#include<cstdint>
#include<cstdio>

using uint64 = std::uint_fast64_t;

constexpr uint64 M = 1000000007;

template<std::size_t N>
struct Fact {
	uint64 val[N], v2[N];
	constexpr Fact() :val(), v2() {
		val[0] = 1;
		for (std::size_t i = 1; i < N; ++i) val[i] = val[i - 1] * i % M;
		for (std::size_t i = 1; i < N; ++i) v2[i] = val[i - 1] * val[i] % M;
		for (std::size_t i = 1; i < N; ++i) val[i] = val[i] * i % M;
	}
};

template<std::size_t N, uint64 F>
struct IFact {
	uint64 val[N];
	constexpr IFact() : val() {
		val[N - 1] = F;
		for (std::size_t i = N - 1; i; --i) val[i - 1] = val[i] * i % M;
	}
};

constexpr auto fact = Fact<1000000>();
constexpr auto ifact = IFact<1000000, 498215386>();

int main() {
	unsigned int n;
	uint64 ans;
	scanf("%u", &n);
	const std::size_t N = n;
	for (std::size_t i = (N + 1) >> 1; i < N - 1; ++i) {
		ans = (ans + fact.v2[i] * ifact.val[(i << 1) - N]) % M;
	}
	long long unsigned int o = (fact.val[N - 1] + M - ans) % M;
	printf("%llu\n", o);
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

void swap(char *a, char *b) {
  char t;
  t = *a, *a = *b, *b = t;
}

int main(void) {
  char a[4];
  scanf("%s", a);
  if(a[0] > a[1]) swap(a, a + 1);
  if(a[0] > a[2]) swap(a, a + 2);
  if(a[1] > a[2]) swap(a + 1, a + 2);
  if(a[0] == 'a' && a[1] == 'b' && a[2] == 'c') printf("Yes");
  else printf("No");
  return 0;
}

Measured memory_bytes: 128
#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()
ll d1[4] = {1, -1, 0, 0};
ll d2[4] = {0, 0, 1, -1};

int main(){
  ll n;
  cin >> n;
  ll ans = 0;
  rep(i, 1, n+1){
    ll a ;
    cin >> a;
    if(a % 2 == 1 && i % 2 == 1) ans++;
  }
  cout << ans << endl;
    return 0;
}


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


public class Main {
	public static void main(String[] args) throws NumberFormatException, IOException {
		//????????????????????????
		BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
		
		//?????????
		int n = Integer.parseInt(bf.readLine());
		String[] sString = bf.readLine().split(" ");
		int q = Integer.parseInt(bf.readLine());
		String[] tString = bf.readLine().split(" ");
	
		int count=0;

		for(int i=0;i<q;i++){
			int num=Integer.parseInt(tString[i]);
			for(int j=0;j<n;j++){
				if(num==Integer.parseInt(sString[j])){
					count++;
					break;
				}
			}
		}
		System.out.println(count);
	}
 }

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

#ifdef LOCAL
	#define D(a) cerr << #a << " = " << a << endl
#else
	#define D(a)
	#define cerr false && cerr
#endif
#define fastio ios_base::sync_with_stdio(0); cin.tie(0)
#define dforsn(i,s,n) for(int i=int(n-1);i>=int(s);i--)
#define forsn(i,s,n) for(int i=int(s);i<int(n);i++)
#define dforn(i,n) dforsn(i,0,n)
#define forn(i,n) forsn(i,0,n)
#define all(a) a.begin(),a.end()
#define si(a) int((a).size())
#define pb emplace_back
#define mp make_pair
#define snd second
#define fst first
#define endl '\n'
using pii = pair<int,int>;
using vi = vector<int>;
using ll = long long;

int main() {
	fastio;
	
    int a,b;
    cin >> a >> b;
    if(b<0)cout << ((b-a+1)%2?"Negative":"Positive") << endl;
    else cout << (a>0?"Positive":"Zero") << endl;
	
	return 0;
}



Measured memory_bytes: 256
//#pragma GCC optimize ("O3")
//#pragma GCC target ("sse4")

#include <bits/stdc++.h>

using namespace std;

// CHECK THE LIMITS
typedef long long ll;

static const int NMAX = 1e5;

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

    int n;
    cin >> n;
    int p = 1;
    int k = 1;
    ll sol = 0;
    int nr = (int) log10(n) + 1;
    while(k < nr)
    {
        sol+=p*9;
        p*=100;
        k+=2;
    }
    if(k == nr)
    {
        sol += 1LL * (n - p)+1; 
    }
    cout << sol;


    return 0;
}

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

int main() {
  int N, L;
  cin >> N >> L;
  vector<string> A(N);
  rep(i, N){
    cin >> A.at(i);
  }
  
  sort(A.begin(), A.end());
  string S;
  rep(i, N){
    S += A.at(i);
  }
  
  cout << S << endl;
}


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

int main() {
	long long n,i,k,j,sum=0,count=0,ans=0;
	string s;
	cin>>s;
    n=s.length();
    if(n==1)
    {
        cout<<0; return 0;
    }
   
        for(i=0;i<n/2;i++)
        {
            if(s[i]!=s[n-i-1])
            sum++;
        }
        cout<<sum;
    
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep0(i,n) for (int i = 0; i < (n); ++i)
#define rep1(i,n) for (int i = 1; i < (n); ++i)
#define REP(i,a,b) for (int i = a; i < (b); ++i)
#define mREP(i,a,b) for (int i = a; i > (b); --i)
#define all(x) (x).begin(),(x).end()
const int INF = 1000000007;
typedef long long ll;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; } 
ll ans[2000];
int main(){
  ll n;
  cin >> n;
  ans[0] = 2;
  ans[1] = 1;
  for(int i = 2; i <= n; i++){
    ans[i] = ans[i-1] + ans[i-2];
  }
  cout << ans[n] << endl;
  
  return 0;
}

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

int main(){
	string s;
	cin>>s;
	int flag=0;
	for(int i=0;i<s.size();i++){
		if(s[i]=='C'){
			for(int j=i;j<s.size();j++){
				if(s[j]=='F') flag=1;
			}
		}
	}
	if(flag) cout<<"Yes";
	else cout<<"No";
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#define MOD 2019
#define modml(RHS,LHS) ((RHS) * (LHS) % MOD)
#define modadd(RHS,LHS) (((RHS)+(LHS))%MOD)

static inline int modpow(int num,int ind){
    unsigned cnt = ind;
    int res = 1;
    while(cnt){
        if(cnt & 1u)res = modml(num,res);
        num = modml(num,num);
        cnt >>= 1;
    }
    return res;
}

static inline long long nck2(int n){
    return (n * (n-1)) / 2;
}

int rs[2019];

int main(void){
    register int i;
    char num[200200];
    scanf("%s",num);
    int nlen = strlen(num);
    int cusm[nlen+1];
    int nums[nlen];
    for(i = 0;i < nlen;i++)nums[i] = num[nlen-i-1] - '0';
    cusm[0] = 0;
    for(i = 0;i < nlen;i++)cusm[i+1] = modadd(cusm[i],modml(modpow(10,i),nums[i]));
    for(i = 0;i <= nlen;i++)rs[cusm[i]]++;
    long long ans = 0;
    for(i = 0;i < 2019;i++)ans += nck2(rs[i]);
    printf("%lld",ans);
}

Measured memory_bytes: 3464
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef tuple<int,int,int> T;
typedef vector<P> vp;
typedef vector<T> vt;

int main() {
  ll N;
  cin >> N;
  ll sum=0;
  for(int i=0; i<=N; i++) {
    if((i%3 != 0) && (i%5 != 0)){
      sum+=i;
    }
  }
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 3652
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<deque>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<iterator>
#include<complex>
#include<stack>
#include "stdio.h"
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf = 1e9 + 7;
const ll longinf = 1LL << 60;
const long long mod_const = 1e9+7;
using MIte = multimap<long, long, greater<long> >::iterator;

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

	//
	int N;
	cin >> N;

	vector<long long> vA(N, 0);
	rep(i, N) cin >> vA[i];

	set<long long> setA(vA.begin(), vA.end());
	vector<long long> vA2(setA.begin(), setA.end());

	long long maxelem = *prev(vA2.end());

	long long maxans = 100000000000000;
	long long maxn = 0;
	long long maxr = 0;
	for (int i = 0; i != vA2.size(); ++i) {
		long long n = maxelem;
		long long r = vA2[i];
		if (n <= r) continue;
		if (maxans > abs(2*r-n)) {
			maxn = n;
			maxr = r;
			maxans = abs(2 * r - n);
		}
	}

	cout << maxn << " " << maxr << endl;

	return 0;
}

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

void find1(int X,int Y)
{
    if(X<0 || Y<0)
        cout<<"No";
    else
    {
     double a,b;
     b = ((4*X)-Y);
     a = b/2;
     //cout<<a;
     if(a<0 || X-a<0 || !(abs(a-(int)a)==0) )
        cout<<"No";
     else
        cout<<"Yes";
    }

}
int main()
{
    int X,Y;
    cin>>X>>Y;
    find1(X,Y);
    return 0;
}


Measured memory_bytes: 3624