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

int main()
{
	int N, X, T;
	scanf("%d%d%d", &N, &X, &T);
	
	if(N % X == 0)
		printf("%d", N / X * T);
		
	else
		printf("%d", (N / X + 1) * T);
}

Measured memory_bytes: 3776
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s;
	cin>>s;
	if(s=="SUN")	cout<<7<<endl;
	if(s=="SAT")	cout<<1<<endl;
	if(s=="MON")	cout<<6<<endl;
	if(s=="TUE")	cout<<5<<endl;
	if(s=="WED")	cout<<4<<endl;
	if(s=="THU")	cout<<3<<endl;
	if(s=="FRI")	cout<<2<<endl;
	return 0;
}

Measured memory_bytes: 256
const inputs = require('fs').readFileSync('/dev/stdin', 'utf8')
const [a, b] = inputs
  .trim()
  .split(' ')
  .map(n => Number.parseInt(n))

if ((a + b) % 2 === 1) {
  console.log('IMPOSSIBLE')
} else {
  console.log((a + b) / 2)
}


Measured memory_bytes: 7372
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define	endl		'\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define rep(i,a,b)	for(ll int i=a;i<b;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
using namespace std;

#define N  100005

void solve()
{
	int x,y,z;
	cin>>x>>y>>z;
	cout<<z<<" "<<x<<" "<<y;	
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int TESTS=1;
//	cin>>TESTS;
	while(TESTS--)
	{
		solve();
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int i = (int)(n); i >= 0; i--)
#define all(v) v.begin(),v.end()
typedef long long ll;

int main(){
    ll A,B,C,K;
    cin >> A >> B >> C >> K;
    if (K <= A) cout << K << endl;
    else if (K <= A + B) cout << A << endl;
    else cout << A - (K - A - B) << endl;
}


Measured memory_bytes: 3636
#include <stdio.h>
#include <math.h>

int main(void) {
	int    i,n;
	double a1,a2,b1,b2,c1,c2;
	double x1,y1,x2,y2,x3,y3,px,py,r;

	scanf("%d",&n);
	for(i=0;i<n;i++) {
		scanf("%lf %lf %lf %lf %lf %lf",&x1,&y1,&x2,&y2,&x3,&y3);
		a1=2*(x2-x1);
		a2=2*(x3-x1);
		b1=2*(y2-y1);
		b2=2*(y3-y1);
		c1=x1*x1-x2*x2+y1*y1-y2*y2;
		c2=x1*x1-x3*x3+y1*y1-y3*y3;
		px=(b1*c2-b2*c1)/(a1*b2-a2*b1);
		py=(c1*a2-c2*a1)/(a1*b2-a2*b1);
		r=sqrt((x1-px)*(x1-px)+(y1-py)*(y1-py));
		printf("%.3f %.3f %.3f\n",px,py,r);
	}
	return 0;
}

Measured memory_bytes: 656
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<cmath>
#include<climits>
#include<queue>
#include<stack>
#include<numeric>
#include<set>
#include<iomanip>
#include<map>
#include<type_traits>
#include<tuple>
#include<deque>
#include<cassert>
#include<bitset>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
const int mod = 1000000007;

int main() {
  int n;
  cin >> n;
  vector<ll> x(n), y(n), h(n);
  rep(i, n) cin >> x[i] >> y[i] >> h[i];
  ll ansh = 0;
  pair<int, int> p;
  int idxh = 0;
  rep(i, n) {
    if(h[i] > 0) idxh = i;
  }
  rep(cx, 101) {
    rep(cy, 101) {
      bool ok = true;
      ll H = h[idxh] + abs(x[idxh] - cx) + abs(y[idxh] - cy);

      rep(i, n) {
        ll hh = max(H - abs(x[i] - cx) - abs(y[i] - cy), 0LL);
        if (hh != h[i]) ok = false;
      }
      if (ok && ansh < H) {
        p.first = cx;
        p.second = cy;
        ansh = H;
      }
    }
  }
  cout << p.first << " " << p.second << " " << ansh << endl;
}

Measured memory_bytes: 256
a, b, k = map(int, input().split())
if b-a+1 < 2*k:
    for i in range(a, b+1):
        print(i)
else:
    for i in range(a, a+k):
        print(i)
    for i in range(b-k+1, b+1):
        print(i)

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

using namespace std;
typedef long long ll;
const int N = 110;
int _w;

int n, a[N], m = 10000;

int main() {
	_w = scanf( "%d", &n );
	for( int i = 1; i <= n; ++i )
		_w = scanf( "%d", a+i );
	int ans = 0;
	for( int i = 2; i <= n; ++i )
		if( a[i] == a[i-1] ) {
			++ans;
			a[i] = --m;
		}
	printf( "%d\n", ans );
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
    int num;
    while(~scanf("%d",&num)){
        int move = 0;
        int max = 0;
        int cur = 0;
        int last;
        for(int i = 0; i < num; i++){
            last = cur;
            scanf("%d",&cur);
            if(cur <= last){
                move++;
                if(move > max){
                    max = move;
                }
            }else{
                move = 0;
            }
        }
        printf("%d\n",max);
    }
    return 0;
}


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

#define LL long long

#define FOR(INDEX, START, END) for (LL INDEX = (START); INDEX < (END); ++INDEX)
#define REP(INDEX, COUNT) for (LL INDEX = 0; INDEX < (COUNT); ++INDEX)

int main()
{
	LL y;
	char c;
	LL m;
	LL d;
	cin >> y >> c >> m >> c >> d;

	if (y < 2019) {
		cout << "Heisei" << endl;
		return 0;
	} else if (y > 2019) {
		cout << "TBD" << endl;
		return 0;
	}

	if (m < 4) {
		cout << "Heisei" << endl;
		return 0;
	}
	else if (m > 4) {
		cout << "TBD" << endl;
		return 0;
	}

	if (d <= 30) {
		cout << "Heisei" << endl;
		return 0;
	}
	else {
		cout << "TBD" << endl;
		return 0;
	}

	return 0;
}


Measured memory_bytes: 256
from collections import Counter

# forを逆から回して下から素直にmodを取るとTLEだった
# 累積和的な計算で高速化、やりやすくするためにreverse
S = input()[::-1]
# ex. 1817181712114 → 4112171817181
# print(S)

# 0桁目までのMODを0とすることで、
# 1桁目を含む数が2019の倍数の時に都合が良くなる
X = [0]

# 4,14,114,2114,12114,...のmod2019を計算

# pow(a,b,c)は普通にMODするより速い
# 普通にやったらTLEだった
for i, s in enumerate(S):
    X.append((X[-1] + int(s) * pow(10, i, 2019)) % 2019)
# print(X)


C = Counter(X)
# print(C)

ans = 0
# Xが同じになったところを2つ選べば題意を満たす
# v_C_2の計算
for v in C.values():
    ans += v * (v - 1) // 2

print(ans)


Measured memory_bytes: 16696
// Problem : W - Intervals
// Contest : AtCoder - Educational DP Contest
// URL : https://atcoder.jp/contests/dp/tasks/dp_w
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

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

#define fi first
#define se second
#define eb emplace_back

using ll = long long;
using ii = pair <int, int>;

const int N = 200005;
const ll ninf = -1e18;

ll tr[N * 4], tg[N * 4];
int lo, hi, n, m;
vector <ii> a[N];

void push_tag(int i, ll v) {
    tr[i] += v; tg[i] += v;
}

void push_down(int i) {
    push_tag(i * 2, tg[i]);
    push_tag(i * 2 + 1, tg[i]);
    tg[i] = 0;
}

void push_up(int i) {
    tr[i] = max(tr[i * 2], tr[i * 2 + 1]);
}

void update(int i, int l, int r, ll v) {
    if (l > hi || r < lo) return;
    if (l >= lo && r <= hi)
        return push_tag(i, v);
    push_down(i);
    int m = (l + r) / 2;
    update(i * 2, l, m, v);
    update(i * 2 + 1, m + 1, r, v);
    push_up(i);
}

ll query(int i, int l, int r) {
    if (l > hi || r < lo) return ninf;
    if (l >= lo && r <= hi) return tr[i];
    push_down(i);
    int m = (l + r) / 2;
    return max(query(i * 2, l, m),
    query(i * 2 + 1, m + 1, r));
}

void update(int l, int r, ll v) {
    lo = l; hi = r;
    update(1, 0, n, v);
}

ll query(int l, int r) {
    lo = l; hi = r;
    return query(1, 0, n);
}

int main() {
    cin.tie(0)->sync_with_stdio(0);
    cin >> n >> m; ll sum = 0;
    for (int i = 0; i < m; i++) {
        int l, r, v;
        cin >> l >> r >> v;
        a[r].eb(l, v); sum += v;
    }
    update(0, n, sum);
    for (int i = 1; i <= n; i++) {
        update(i, i, query(0, i - 1) - sum);
        for (auto q : a[i])
            update(0, q.fi - 1, -q.se);
    }
    cout << tr[1] << '\n';
}

Measured memory_bytes: 22744
N,M=map(int, input().split())
k=[list(map(int,input().split()))for _ in range(M)]
p=list(map(int,input().split()))
import itertools
import operator
import functools
print(sum(1 for i in itertools.product([True,False],repeat=N)if functools.reduce(operator.and_,[functools.reduce(operator.xor,[i[j-1]for j in k[l][1:]])==p[l]for l in range(M)])))


Measured memory_bytes: 69332
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 2e5 + 5;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
template <typename T> void chkmax(T &x, T y) {x = max(x, y); }
template <typename T> void chkmin(T &x, T y) {x = min(x, y); } 
template <typename T> void read(T &x) {
	x = 0; int f = 1;
	char c = getchar();
	for (; !isdigit(c); c = getchar()) if (c == '-') f = -f;
	for (; isdigit(c); c = getchar()) x = x * 10 + c - '0';
	x *= f;
}
template <typename T> void write(T x) {
	if (x < 0) x = -x, putchar('-');
	if (x > 9) write(x / 10);
	putchar(x % 10 + '0');
}
template <typename T> void writeln(T x) {
	write(x);
	puts("");
}
int dp[MAXN][2];
char s[MAXN];
int main() {
	scanf("%s", s + 1);
	int n = strlen(s + 1);
	for (int i = 0; i <= n + 1; i++)
		dp[i][0] = dp[i][1] = -1e8;
	dp[0][0] = 0, dp[1][0] = 1;
	for (int i = 2; i <= n; i++) {
		chkmax(dp[i][0], dp[i - 1][1] + 1);
		if (s[i] != s[i - 1]) chkmax(dp[i][0], dp[i - 1][0] + 1);
		chkmax(dp[i][1], dp[i - 2][0] + 1);
		if (s[i] != s[i - 2] || s[i - 1] != s[i - 3]) chkmax(dp[i][1], dp[i - 2][1] + 1);
	}
	writeln(max(dp[n][0], dp[n][1]));
	return 0;
}

Measured memory_bytes: 2048
#include<bits/stdc++.h>
using namespace std;
using Int = long long;

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T>
vector<vector<T> > make_v(size_t a,size_t b){
  return vector<vector<T> >(a,make_v<T>(b));
}
template<typename T>
vector<vector<vector<T> > > make_v(size_t a,size_t b,size_t c){
  return vector<vector<vector<T> > > (a,make_v<T>(b,c));
}

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
  for(auto &e:t) fill_v(e,v);
}

//INSERT ABOVE HERE
Int cross(Int x1,Int y1,Int x2,Int y2){
  return x1*y2-x2*y1;
}
signed main(){
  Int n;
  cin>>n;
  vector<Int> x(n),y(n);
  for(Int i=0;i<n;i++) cin>>x[i]>>y[i];
  const Int MOD = 998244353;
  vector<Int> po(n+1,1);
  for(Int i=0;i<n;i++) po[i+1]=po[i]*2%MOD;
  
  Int ans=po[n]+MOD-(n+1);
  auto used=make_v<Int>(n,n);
  fill_v(used,0);
  for(Int i=0;i<n;i++){
    for(Int j=0;j<i;j++){
      if(used[i][j]) continue;
      vector<Int> v;
      for(Int k=0;k<n;k++)
	if(cross(x[i]-x[k],y[i]-y[k],x[j]-x[k],y[j]-y[k])==0)
	  v.emplace_back(k);

      //cout<<i<<" "<<j<<":"<<v.size()<<endl;
      ans+=MOD-(po[v.size()]-v.size()-1);
      ans%=MOD;
      
      for(Int k:v)
	for(Int l:v)
	  used[k][l]=1;
    }
  }
  ans%=MOD;
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
int main() {
	int n[30];
	bool a[30] = {};
	for (int i = 0; i < 30; ++i) {
		n[i] = i + 1;
	}
	for (int i = 0; i < 28; ++i) {
		int t; 
		std::cin >> t;
		for (int j = 0; j < 30; ++j) {
			if (t == n[j])a[j] = true;
		}
	}
	for (int i = 0; i < 30; ++i) {
		if (!a[i]) {
			std::cout << i + 1 << std::endl;
		}
	}
	return 0;
}

Measured memory_bytes: 3096
#include<iostream>
using namespace std;
int main(){
	int T;
	while(cin>>T){
		int min=9999999;
		int f=0;
		int sum=0;
		for(int i=0;i<T;i++){
			int t;
			cin>>t;
			sum=sum+t;
			if(t%10!=0){
				f=1;
				if(t<min){
					min=t;
				}
			}
		}
		if(f==0){
			cout<<"0"<<endl;
		}else{
			if(sum%10!=0){
				cout<<sum<<endl;
			}else{
				cout<<sum-min<<endl;
			}
		}
	}
	return 0;
}

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

int main() {
  int N,M,K,x=1;
  cin >>N >>K ;
 
 for(N;N>0;N--){      
    if(x<=K) x+=x;
    else x+=K;
 }
   
   
  cout <<x;
    
}


Measured memory_bytes: 256
#![allow(non_snake_case)]

use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    let mut iter = buf.split_whitespace();
    let n: usize = iter.next().unwrap().parse().unwrap();
    let mut es: Vec<(f64, f64)> = (0..n)
        .map(|_| {
            let x: f64 = iter.next().unwrap().parse().unwrap();
            let y: f64 = iter.next().unwrap().parse().unwrap();
            (x, y)
        })
        .collect();
    es.sort_by(|&(x1, y1), &(x2, y2)| {
        let angle1 = y1.atan2(x1);
        let angle2 = y2.atan2(x2);
        angle1.partial_cmp(&angle2).unwrap()
    });

    for i in 0..n {
        let engine = es[i];
        es.push(engine);
    }

    let mut res = 0f64;
    for i in 0..n {
        let mut x_total = 0f64;
        let mut y_total = 0f64;
        for j in 0..n {
            x_total += es[i + j].0;
            y_total += es[i + j].1;
            res = res.max((x_total * x_total + y_total * y_total).sqrt());
        }
    }
    println!("{}", res);
}


Measured memory_bytes: 4476
/// b.cpp

# include <stdio.h>
# include <bits/stdc++.h>
using namespace std;
const pair < int , int > DD[] = {{1,0},{1,1},{0,1},{-1,1},{-1,0},{-1,-1},{0,-1},{1,-1}};
# define fi cin
# define fo cout
# define x first
# define y second
# define ll long long
# define IOS ios_base :: sync_with_stdio(0);cin.tie(0)
# define p(v) cerr << #v << " = " << v << '\n'
# define p2(v) cerr << #v << " = " << (complex < __typeof(v.x) > (v.x,v.y)) << '\n'
# define vi vector < int >
# define vl vector < ll >
# define pll pair < ll , ll >
# define pii pair < int , int >
# define mp make_pair
# define db long double
# define fail puts("-1")
# define yes puts("YES")
# define no puts("NO")
# define PP puts("Possible")
# define II puts("Impossible")
# define vii vector < pii >
# define vll vector < ll >
# define pb push_back
# define pdd pair < db , db >
template < class T > T smin(T &a,T b) {if (a > b) a = b;return a;}
template < class T > T smax(T &a,T b) {if (a < b) a = b;return a;}
int main(void)
{
    #ifdef CF
    freopen("input","r",stdin);
    #endif // CF
    srand(time(0));
    fo << fixed << setprecision(7);
    cerr << fixed << setprecision(7);
    int n;
    fi>>n;
    static int s[1 << 20];
    for (int i = 1;i <= n;++i)
        fi>>s[i];
    sort(s + 1,s + 1 + n);
    ll sum = accumulate(s + 1,s + 1 + n,0ll);
    int ans = 0;
    for (int i = n;i;--i)
    {
        ++ans;
        sum -= s[i];
        if (sum + sum < s[i])
            return fo << ans << '\n',0;
    }
    fo << ans << '\n';
    cerr << "Time elapsed :" << clock() * 1000.0 / CLOCKS_PER_SEC << " ms" << '\n';
    return 0;
}


Measured memory_bytes: 640
n = int(input())
a = []
for i in range(n):
    a.append(int(input()))
a_sort = list(sorted(a))
a_max = a_sort[-1]
a_second = a_sort[-2]
for i in range(n):
    if a[i] == a_max:
        print(a_second)
    else:
        print(a_max)

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

#define F first
#define S second
#define MP make_pair
#define PB push_back

using namespace std;

typedef long long ll;
typedef long double ld;

const int max_n = 100011, inf = 1000111222;



int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    string s;
    cin >> s;
    string a = "keyence";
    int cnt1 = 0, cnt2 = 0;
    for (int i  =0; i < a.length(); ++i) {
    	if (s[i] == a[i]) ++cnt1;
    	else break;
    }
    for (int q = 0; q < a.length(); ++q) {
    	if (s[s.length() - q - 1] == a[a.length() - q - 1]) ++cnt2;
    	else break;
    }
    if (cnt1 + cnt2 >= a.length()) {
    	cout << "YES\n"; 
    } else {
    	cout << "NO\n";
    }
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bits/stdc++.h>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;

#define rep(X, Y) for (int(X) = 0; (X) < (Y); ++(X))
#define rrep(X, Y) for (int(X) = (Y)-1; (X) >= 0; --(X))
#define all(X) (X).begin(), (X).end()
#define pb push_back
#define mp make_pair
#define fi first
#define sc second
#define print(x) cout << x << endl

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

class UnionFindTree {
private:
  vector<int> par;
  vector<int> rnk;
  vector<int> siz;

public:
  UnionFindTree(int n) {
    par.assign(n, -1);
    rnk.assign(n, -1);
    siz.assign(n, -1);

    for (int i = 0; i < n; ++i) {
      par[i] = i;
      rnk[i] = 0;
      siz[i] = 1;
    }
  }

  int find(int x) {
    if (par[x] == x)
      return x;
    else
      return par[x] = find(par[x]);
  }

  bool same(int x, int y) { return find(x) == find(y); }

  void unite(int x, int y) {
    x = find(x);
    y = find(y);
    if (x == y)
      return;
    if (rnk[x] < rnk[y]) {
      par[x] = y;
      siz[y] += siz[x];
    } else {
      par[y] = x;
      siz[x] += siz[y];
      if (rnk[x] == rnk[y])
        ++rnk[x];
    }
  }

  int size(int x) {
    x = find(x);
    return siz[x];
  }
};

void solve(long long N, long long M, std::vector<long long> A,
           std::vector<long long> B) {
  UnionFindTree uf(N + 1);

  vector<long long> unconv(M + 1);
  unconv[M] = (N * (N - 1)) / 2;

  rrep(m, M) {
    auto a = A[m];
    auto b = B[m];

    if (uf.same(a, b)) {
      unconv[m] = unconv[m + 1];
    } else {
      auto as = uf.size(a);
      auto bs = uf.size(b);
      unconv[m] = unconv[m + 1] - as * bs;
      uf.unite(a, b);
    }
  }

  for (int m = 1; m <= M; m++) {
    print(unconv[m]);
  }
  return;
}

int main() {
  long long N;
  scanf("%lld", &N);
  long long M;
  scanf("%lld", &M);
  std::vector<long long> A(M);
  std::vector<long long> B(M);
  for (int i = 0; i < M; i++) {
    scanf("%lld", &A[i]);
    scanf("%lld", &B[i]);
  }
  solve(N, M, std::move(A), std::move(B));
  return 0;
}


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

#define all(v) (v).begin(),(v).end()

using namespace std ;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;




int main()
{
  int a, b ;
  cin >> a >> b ;
  
  cout <<(a-1)*(b-1)<<endl ;
  
    return 0 ;
}


Measured memory_bytes: 256
n = int(input())
l = list(map(int, input().split()))
l.sort()
ans = 0
for i in range(n):
    for j in range(i+1, n):
        if l[i] == l[j]:
            continue
        s = l[i] + l[j]
        for k in range(j+1, n):
            if l[i] == l[k] or l[j] == l[k]:
                continue
            if s > l[k]:
                ans += 1
print(ans)

Measured memory_bytes: 9200
/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/* 
 * File:   main.c
 * Author: Mu-Chan
 *
 * Created on August 2, 2018, 2:08 PM
 */

#include <stdio.h>
#include <stdlib.h>
#define SIZE 8

void putQueen(int,int[],int[],int[],int[],int[]);
void printBoard(int[]);

int main(int argc, char** argv) {
    int queenPosRow[SIZE], colTaken[SIZE], skip[SIZE], dposTaken[SIZE*2 - 1], dnegTaken[SIZE*2 - 1];
    int count, i, j;
    for(int i = 0; i < SIZE; i++){
        skip[i] = 0;
        queenPosRow[i] = -1;
        colTaken[i] = 0;
    }
    for(i = 0; i < SIZE*2 - 1; i++){
        dposTaken[i] = 0;
        dnegTaken[i] = 0;
    }
    scanf("%d",&count);
    for(int c = 0; c < count; c++){
        scanf("%d %d", &i, &j);
        queenPosRow[i] = j;
        skip[i] = 1;
        colTaken[j] = 1;
        dposTaken[i+j] = 1;
        dnegTaken[i-j+SIZE-1] = 1;
    }
    putQueen(0,queenPosRow,colTaken,skip,dposTaken,dnegTaken);
    return (EXIT_SUCCESS);
}

void putQueen(int c, int queenPosRow[SIZE], int colTaken[SIZE], int skip[SIZE], int dposTaken[SIZE*2 - 1], int dnegTaken[SIZE*2 - 1]){
    if(c == SIZE){
        printBoard(queenPosRow);
        return;
    }
    if(!skip[c]){
        for(int j = 0; j < SIZE; j++)
            if(!colTaken[j]&&!dposTaken[c+j]&&!dnegTaken[c-j+SIZE-1]){
                queenPosRow[c] = j;
                colTaken[j] = 1;
                dposTaken[c+j] = 1;
                dnegTaken[c-j+SIZE-1] = 1;
                putQueen(c+1,queenPosRow,colTaken,skip,dposTaken,dnegTaken);
                colTaken[j] = 0;
                dposTaken[c+j] = 0;
                dnegTaken[c-j+SIZE-1] = 0;
            }
    }
    else
        putQueen(c+1,queenPosRow,colTaken,skip,dposTaken,dnegTaken);
    return;
}

void printBoard(int row[SIZE]){
    for(int i = 0; i < SIZE; i++){
        for(int j = 0; j < SIZE; j++){
            if(row[i] == j)
                printf("Q");
            else
                printf(".");
        }
        printf("\n");
    }
}



Measured memory_bytes: 2060
#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 INF 1000000000
#define mod 1000000007
using ll=long long;
const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int 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 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int n;
ll a[16][16];
ll dp[(1<<16)+1];
ll cnt;
ll p[(1<<16)+1];


ll DP(int bit){
    if(dp[bit]>=0) return dp[bit];
    int m=__builtin_popcount(bit);
    if(m==1) return dp[bit]=0;
    
    //subsetを全て一緒のグループにして他を再起
    //subsetが0だと再起先が自分なので死
    int subset=bit;
    ll ret=-LINF;
    do{
        if(subset!=0){
            chmax(ret,DP(bit^subset)+p[subset]);
        }
        subset=(subset-1)&bit;
    }while(subset!=bit);
    return dp[bit]=ret;
}

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

    cin>>n;
    rep(i,n){
        rep(j,n){
            cin>>a[i][j];
        }
    }
    rep(i,(1<<16)) dp[i]=-1;
    dp[0]=0;
    rep(bit,(1<<n)){
        rep(i,n){
            for(int j=i+1;j<n;j++){
                if(( (bit>>i)&1 ) and ( (bit>>j)&1 )){
                    p[bit]+=a[i][j];
                }
            }
        }
    }
    cout<<(DP((1<<n)-1))<<endl;
    return 0;
}


Measured memory_bytes: 1280
S = "0" + input()

ans = 0
b = 0
c = 0
for a in S[::-1]:
    A = int(a) + b
    if A == 5 and c == 0:
        ans += 5
        b = 0
        c = 1
    elif A < 5:
        ans += A
        b = 0
        c = 0
    else:
        ans += 10 - A - c
        b = 1
        c = 0

print(ans)

Measured memory_bytes: 62192
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
typedef long long ll;
#define MOD 998244353
using namespace std;
int main() {
    ll n, s;
    cin >> n >> s;
    vector<ll> a(n);
    for(int i = 0; i < n; i++) {
        cin >> a[i];
    }
    vector<vector<ll>> dp(n + 1, vector<ll>(s + 1, 0));
    dp[0][0] = 1;
    for(int i = 0; i < n; i++) {
        for(int j = 0; j <= s; j++) {
            dp[i + 1][j] += 2 * dp[i][j];
            dp[i + 1][j] %= MOD;
            if(j - a[i] >= 0) {
                dp[i + 1][j] += dp[i][j - a[i]];
                dp[i + 1][j] %= MOD;
            }
        }
    }
    cout << dp[n][s] << endl;
}

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

int main(){

    int a,b;
    cin >> a >> b;
    bool flag = true;
    if(a > 8 || b > 8){
        flag = false;
    }

    if(flag){
        cout << "Yay!" << endl;
    }
    else{
        cout << ":(" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
N, T = map(int,input().split())
cnt = 1000
jdg = False
for _ in range(N):
    c, t = map(int,input().split())
    if t <= T: 
        cnt = min(cnt,c)
        jdg = True
        
if jdg:
    print(cnt)
else:
    print("TLE")

Measured memory_bytes: 38320
object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val n = sc.nextLong()
  val x, m = sc.nextInt()

  val a = Array.fill(m)(0L)
  val idx = Array.fill(m)(-1)

  var i = 0
  var now = x.toLong
  while (idx(now.toInt) == -1) {
    idx(now.toInt) = i
    a(i) = now
    now = (now * now) % m
    i += 1
  }

  val s = idx(now.toInt)
  val e = i - 1
  val l = e - s + 1
  val ac = a.scanLeft(0L)(_+_)
  var ans = 0L

  var r = n
  ans += ac(s)
  r -= s

  ans += (ac(e+1) - ac(s)) * (r / l)
  ans += ac(s + (r % l).toInt) - ac(s)

  println(ans)
}


Measured memory_bytes: 58988
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;
using ll = long long;

int main(int argc, const char * argv[]) {
    int a, b;
    cin >> a >> b;
    if (a > 8 || b > 8) {
        cout << ":(" << endl;
    }else{
        cout << "Yay!" << endl;
    }
    
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
	const int secPerHour = 60 * 60;
	const int secPerMin = 60;
	int sec;
	cin >> sec;
	int h = sec / secPerHour;
	sec %= secPerHour;
	int m = sec / secPerMin;
	sec %= secPerMin;
	cout << h << ":" << m << ":" << sec << endl;
}


Measured memory_bytes: 3068
#include <bits/stdc++.h>
#define Int int64_t

using namespace std;

int f[10000010];

int main() {
	constexpr int sz = 1e7 + 10;
	Int N;
	cin >> N;

	for (int i = 0; i < sz; ++i) { f[i] = 0; }
	for (int i = 1; i <= N; ++i) {
		for (int j = 1; j * i <= N; ++j) {
			f[j * i] += 1;
		}
	}
	
	Int ans = 0;
	for (Int i = 1; i <= N; ++i) {
		ans += i * f[i];
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 42692
#include<bits/stdc++.h>
using namespace std;
double f[301][301][301];
int main()
{
	double tmp,x,y,z;
	int i,j,k,n,a,one,two,three;
	scanf("%d",&n);
	one=two=three=0;
	for(i=1;i<=n;i++)
	{
		scanf("%d",&a);
		if(a==1)
			one++;
		else if(a==2)
			two++;
		else if(a==3)
			three++;
	}
	for(k=0;k<=n;k++)
	{
		for(j=0;j<=n;j++)
		{
			for(i=0;i<=n;i++)
			{
				tmp=i+j+k;
				if(i+j+k==0)
					continue;
				if(i+j+k>n)
					continue;
				x=y=z=0;
				if(i!=0)
					x=(double)i/tmp*f[i-1][j][k];
				if(j!=0)
					y=(double)j/tmp*f[i+1][j-1][k];
				if(k!=0)
					z=(double)k/tmp*f[i][j+1][k-1];
				f[i][j][k]+=x+y+z+(double)n/tmp;
			}
		}
	}
	printf("%.10lf",f[one][two][three]);
	return 0;
}

Measured memory_bytes: 213248
import java.util.*;

public class Main{

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

        int x = sc.nextInt();
        int i = 0;
        int y = 0;

        while(true){
            if(y >= x){
                System.out.print(i);
                return;
            }
            i++;
            y += i;
        }

    }
}


Measured memory_bytes: 21844
s=input()

ans=0
for i in range(1<<(len(s)-1)):
    sum=0
    temp=int(s[0])
    for j in range(len(s)-1):
        if i>>j&1:
            temp=temp*10+int(s[j+1])
        else :
            sum+=temp
            temp=int(s[j+1])
    sum+=temp
    ans+=sum
print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define Nmax 100005

using namespace std;

const long long INF=1e18l;
ifstream f("1.in");
ofstream g("1.out");

int n, m, x, y, ans;
vector <int> v[Nmax];
bool vis[Nmax];
int d[Nmax], in_deg[Nmax];

void dfs(int a)
{
    vis[a]=1;
   for (auto b:v[a])
   {
       d[b]=max(d[b], d[a]+1);

       in_deg[b]--;
       if(in_deg[b] == 0) dfs(b);
   }
}

int main()
{
    cin >> n >> m;
    for (int i = 1; i <= m; i++)
    {
        cin >> x >> y;
        v[x].push_back(y);
        in_deg[y]++;
    }
    for (int i = 1; i <= n; i++)
        if(!vis[i] && in_deg[i] == 0) dfs(i);

    dfs(0);

    for (int i = 1; i <= n; i++)
        ans=max(ans, d[i]);

    cout << ans;
    return 0;
}


Measured memory_bytes: 9728
import java.util.Scanner;

class Main{
	public static void main(String[] args) {
		Scanner scan=new Scanner(System.in);
		int n=scan.nextInt(),k=scan.nextInt(),x,s=0,i;
		for(i=0;i<n;i++) {
			x=scan.nextInt();
			if(x*2>(k-x)*2) s+=(k-x)*2;
			else s+=x*2;
		}
		scan.close();
		System.out.print(s);
	}
}

Measured memory_bytes: 21840
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE BangPatterns #-}

import Control.Applicative
import Control.Monad
import Control.Arrow
import Data.List
import Data.Maybe
import Data.Char
import qualified Data.ByteString.Char8 as B
import Text.Printf

readInt = ( readLn :: IO Int )
readInts = map ( read :: String -> Int ) . words <$> getLine

getList = map ( fst . fromJust . B.readInt ) . B.words <$> B.getLine

which a b f = if f then a else b
mp [ a, b ] = ( a, b )

main = do
	s <- getLine
	k :: Integer <- readLn
	let
		head1s = toInteger $ length $ takeWhile ( == '1' ) s
	printf "%c\n" $ if k <= head1s then '1' else ( head $ filter ( /= '1' ) s )

Measured memory_bytes: 508
import java.util.ArrayDeque

fun main(args: Array<String>){
    var s = readLine()!!
    val q = readLine()!!.toInt()
    var reversed = false
    val deque = ArrayDeque<String>()
    s.toCharArray().map { it.toString() }.forEach { deque.addLast(it) }
    repeat(q){
        val query = readLine()!!.split(" ")
        if(query.size == 1){
            reversed = !reversed
        }else{
            if(!reversed && query[1] == "1" || reversed && query[1] == "2"){
                deque.addFirst(query[2])
            }else{
                deque.addLast(query[2])
            }
        }
    }
    if(reversed){
        println(deque.reversed().joinToString(separator = ""))
    }else{
        println(deque.joinToString(separator = ""))
    }
}

Measured memory_bytes: 92384
/*Read the problem carefully before starting to work on it*/
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//using namespace boost::multiprecision;
//#include <ext/pb_ds/assoc_container.hpp> 
//#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
//using namespace __gnu_pbds;

typedef long long ll;

//ll ncr(ll n,ll r){ll ans=1;r=min(r,n-r);for (int i=1;i<=r;i++){ans*=(n-r+i);ans/=i;}return ans;}

#define pb push_back
#define eb emplace_back
#define mp(x,y) make_pair(x,y)
#define mod 1000000007

double PI=3.1415926535897932384626;

//template<typename T> T power(T x,T y,ll m=mod){T ans=1;while(y>0){if(y&1LL) ans=(ans*x)%m;y>>=1LL;x=(x*x)%m;}return ans%m;}

//typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ost;

#define fi first
#define se second

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
    ll n;
    cin>>n;
    vector<ll>arr(n);
    for(ll i=0;i<n;i++)
        cin>>arr[i];
    ll ans=(arr[n-1]^arr[0]^arr[1]);
    for(ll i=1;i<n;i++)
    {
        ll tmp=(arr[i-1]^arr[i]^arr[(i+1)%n]);
        ans^=tmp;
    }
    if(ans==0)
        cout<<"Yes";
    else
        cout<<"No";
    return 0;
}

Measured memory_bytes: 1152
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <utility>
#include <tuple>
#include <string>
#include <cctype>
#include <cstdio>
#include <math.h>
using i8 = int8_t;
using u8 = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
using f32 = float;
using f64 = double;
constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
const int AMAX = 100000; 
using namespace std;
#define rep(i, n) for (i64 i = 0; i < (int)(n); i++)
#define FOR(i, m, n) for (i64 i = m; i < n; i++)
#define SORT(x) sort(x.begin(), x.end())
#define REVE(x) reverse(x.begin(), x.end())
#define all(x) (x).begin(), (x).end()
#define fst first
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define pob pop_back
#define sw swap
#define UP(x) transform(x.begin(), x.end(), x.begin(), ::toupper);
#define down(x) transform(x.begin(), x.end(), x.begin(), ::tolower);
using LL = long long;
using ULL = unsigned long long;
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return 1;
    }
    return 0;
}

int main()
{
    LL a , b, c=0,n;
    vector<LL> d;
  cin>>n;
    rep(i,n){
        cin >> a;
        d.pb(a);
    }
rep(i,n){
    for(int j=i+1;j<n;j++){
    c =c+d[i]*d[j];
    }
}
cout << c;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
clock_t t=clock();
namespace my_std{
	using namespace std;
	#define pii pair<int,int>
	#define fir first
	#define sec second
	#define MP make_pair
	#define rep(i,x,y) for (int i=(x);i<=(y);i++)
	#define drep(i,x,y) for (int i=(x);i>=(y);i--)
	#define go(x) for (int i=head[x];i;i=edge[i].nxt)
	#define templ template<typename T>
	#define sz 202020
	typedef long long ll;
	typedef double db;
	mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
	templ inline T rnd(T l,T r) {return uniform_int_distribution<T>(l,r)(rng);}
	templ inline bool chkmax(T &x,T y){return x<y?x=y,1:0;}
	templ inline bool chkmin(T &x,T y){return x>y?x=y,1:0;}
	templ inline void read(T& t)
	{
		t=0;char f=0,ch=getchar();double d=0.1;
		while(ch>'9'||ch<'0') f|=(ch=='-'),ch=getchar();
		while(ch<='9'&&ch>='0') t=t*10+ch-48,ch=getchar();
		if(ch=='.'){ch=getchar();while(ch<='9'&&ch>='0') t+=d*(ch^48),d*=0.1,ch=getchar();}
		t=(f?-t:t);
	}
	template<typename T,typename... Args>inline void read(T& t,Args&... args){read(t); read(args...);}
	char __sr[1<<21],__z[20];int __C=-1,__zz=0;
	inline void Ot(){fwrite(__sr,1,__C+1,stdout),__C=-1;}
	inline void print(register int x)
	{
		if(__C>1<<20)Ot();if(x<0)__sr[++__C]='-',x=-x;
		while(__z[++__zz]=x%10+48,x/=10);
		while(__sr[++__C]=__z[__zz],--__zz);__sr[++__C]='\n';
	}
	inline void chktime()
	{
		#ifndef ONLINE_JUDGE
		cout<<(clock()-t)/1000.0<<'\n';
		#endif
	}
	#ifdef mod
	ll ksm(ll x,int y){ll ret=1;for (;y;y>>=1,x=x*x%mod) if (y&1) ret=ret*x%mod;return ret;}
	ll inv(ll x){return ksm(x,mod-2);}
	#else
	ll ksm(ll x,int y){ll ret=1;for (;y;y>>=1,x=x*x) if (y&1) ret=ret*x;return ret;}
	#endif
//	inline ll mul(ll a,ll b){ll d=(ll)(a*(double)b/mod+0.5);ll ret=a*b-d*mod;if (ret<0) ret+=mod;return ret;}
}
using namespace my_std;

int n,m;
pii q[sz];

int a[sz];
char s[sz];

int check(int pos)
{
	rep(i,1,m) if (a[pos]==q[i].fir) pos+=q[i].sec;
	return pos;
}

int main()
{
	read(n,m);
	cin>>(s+1);
	rep(i,1,n) a[i]=s[i]-'A'+1;
	rep(i,1,m)
	{
		char c1,c2;cin>>c1>>c2;
		q[i].fir=c1-'A'+1,q[i].sec=(c2=='R'?1:-1);
	}
	int l,r,L,R;
	l=0,r=n;
	while (l<=r)
	{
		int mid=(l+r)>>1;
		if (check(mid)==0) L=mid,l=mid+1;
		else r=mid-1;
	}
	l=1,r=n+1;
	while (l<=r)
	{
		int mid=(l+r)>>1;
		if (check(mid)==n+1) R=mid,r=mid-1;
		else l=mid+1;
	}
	cout<<(R-1)-(L+1)+1;
	return 0;
}

Measured memory_bytes: 4352
#include <stdio.h>

int main(void){
	int height[10], comp, i, j;

	for(i = 0;i < 10;i++){
		scanf("%d", &height[i]);
	}

	for(i = 0;i < 10;i++){
		for(j = i + 1;j < 10;j++){
			if(height[i] < height[j]){
				comp = height[i];
				height[i] = height[j];
				height[j] = comp;
			}
		}
	}

	for(i = 0;i < 3;i++){
			printf("%d\n", height[i]);
	}

	return 0;
}

Measured memory_bytes: 600
// https://atcoder.jp/contests/abc174/tasks/abc174_c
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define DIV(a, b) ((a - 1) / b + 1)

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int K;
    cin >> K;
    int t = 7;
    REP(i, 1000001) {
        if (t % K == 0) {
            cout << i + 1 << endl;
            return 0;
        }
        t = t * 10 + 7;
        if (t > K) {
            t %= K;
        }
    }

    cout << -1 << endl;

    return 0;
}


Measured memory_bytes: 3632
import java.util.*;
public class Main{
	public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int aa = sc.nextInt();
        int bb = sc.nextInt();
        int a[] = new int[999];
        a[0] = 1;
        for(int i=1; i<999; i++){
            a[i] = a[i-1] + i + 1;
        }
        System.out.println(a[bb-aa-1]-bb);
    }
}


Measured memory_bytes: 21460
a,b,c,d=map(int, input().split())
n=int(input())
oneltr=min(4*a, 2*b, c, 2*a+b)
twoltr=min(8*a, 4*b, 2*c, d, c+2*b, c+b+2*a,c+4*a,4*a+2*b,b+6*a,3*b+2*a)

if n%2==0 :
               print(twoltr * (n//2))
else :
               print(oneltr+twoltr * ((n-1)//2))


Measured memory_bytes: 3060
/*
for (int i = 0; i < N; ++i){}

// 各桁の和を計算する関数
int findSumOfDigits(int n) {
  int sum = 0;
  while (n > 0) { // n が 0 になるまで
    sum += n % 10;
    n /= 10;
  }
  return sum;
}

sort(a, a + N, greater<int>());  // a[0:N] を大きい順にソート

int num[110] = {0};  // バケット
for (int i = 0; i < N; ++i) {
    num[d[i]]++;  // d[i] が 1 個増える
}

map<string, int> mp; // 連想配列 map<キー型, 値型> オブジェクト名
for (int i = 0; i < N; ++i) {
    auto itr = mp.find(s[i]);        // s[i] が設定されているか？
    if(itr != mp.end() ) {
         mp[s[i]] += 1;
    }
    else {
         mp[s[i]] += 1 ;
    }
}
stack<int> s;	//intをデータとするスタックを用意
s.push(1);		//{} -> {1}
printf("%d\n", s.top());	// 3
s.pop();

queue<int> que;	//intをデータとするキューを用意
que.push(1);		//{} -> {1}
printf("%d\n", que.front());	// 1
que.pop();
*/
#include <iostream>
#include <set>
#include <map>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>

using namespace std;

// #define for(i,a,b) for (int i=(a);i<(b);++i)
typedef long long ll;
typedef pair<int,int> point;
#define rep(i,n) for(i,0,n)
 
int main() {
	// 入力
	int N, K;
	cin >> N >> K;
	

	//出力
	if (N%K==0) cout << 0 <<endl;
	else cout << 1 << endl;
}
 


Measured memory_bytes: 256
#include<string>
#include<stdio.h>
#include<algorithm>
#include<iostream>
#include<math.h>
typedef long long ll;
using namespace std;
int main(){ 
	int t,a[51],b[51],sum=0;
	scanf("%d",&t);
	for(int i=0;i<t;i++){
		scanf("%d",&a[i]);
	}
	for(int i=0;i<t;i++){
		scanf("%d",&b[i]);
		if(a[i]>b[i]) sum+=(a[i]-b[i]);
	}
	printf("%d",sum);
}

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

using namespace std;

int main(){

    int a,b,c;

    cin >> a >> b >> c;
    if((a<=5)&&(b<=5)&&(c<=7)){
        cout << "YES" << '\n';
    }    
    else if((a<=5)&&(b<=7)&&(c<=5)){
        cout << "YES" << '\n';
    }
    else if((a<=7)&&(b<=5)&&(c<=5)){
        cout << "YES" << '\n';
    }
    else{    
        cout << "NO" << '\n';
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll; 
typedef unsigned long long ull;
 typedef unsigned int uint; 
typedef long double ld;
 
int main() { ios_base::sync_with_stdio(false); cin.tie(0);
 
int n;
cin >> n;
ll t;
ld ans = 1;
for (int i = 0; i < n; i++)
{
    cin >> t;
    if (ans != -1)
       ans *= t;
    if (ans > 1000000000000000000 || ans < 0)
       ans = -1;
    if (t == 0)
       ans = 0;
}
cout << (ll)ans;
return 0;
}

Measured memory_bytes: 3644
n = int(input())

l = []

for i in range(n + 1):
    if i == 0:
        l.append(2)

    elif i == 1:
        l.append(1)

    else:
        l.append(l[i - 1] + l[i - 2])


print(l[len(l) - 1])


Measured memory_bytes: 2940
#include<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
    int a[20][50]={{0}};
    int i=4;
    int x,y;
    for(int k=1;k<=31;k++)
    {
        a[1][k]=i;
        i++;
        if(i==8)i=1;
    }
    for(int k=1;k<=29;k++)
    {
        a[2][k]=i;
        i++;
        if(i==8)i=1;
    }
    for(int k=1;k<=31;k++)
    {
        a[3][k]=i;
        i++;
        if(i==8)i=1;
    }
    for(int k=1;k<=30;k++)
    {
        a[4][k]=i;
        i++;
        if(i==8)i=1;
    }
    for(int k=1;k<=31;k++)
    {
        a[5][k]=i;
        i++;
        if(i==8)i=1;
    }
    for(int k=1;k<=30;k++)
    {
        a[6][k]=i;
        i++;
        if(i==8)i=1;
    }
    for(int k=1;k<=31;k++)
    {
        a[7][k]=i;
        i++;
        if(i==8)i=1;
    }
    for(int k=1;k<=31;k++)
    {
        a[8][k]=i;
        i++;
        if(i==8)i=1;
    }
    for(int k=1;k<=30;k++)
    {
        a[9][k]=i;
        i++;
        if(i==8)i=1;
    }
    for(int g=1;g<=31;g++)
    {
        a[10][g]=i;
        i++;
        if(i==8)i=1;
    }
    for(int k=1;k<=30;k++)
    {
        a[11][k]=i;
        i++;
        if(i==8)i=1;
    }
    for(int k=1;k<=31;k++)
    {
        a[12][k]=i;
        i++;
        if(i==8)i=1;
    }
    //for(int bb=1;bb<=12;bb++)
    //{
    //    for(int aa=1;aa<32;aa++)
    //   {
    //        printf("a[%d][%d]=%d\n",bb,aa,a[bb][aa]);
    //    }
    //}
    while(cin>>x>>y)
    {
        if(x==0)break;
        if(a[x][y]==1)cout<<"Monday"<<endl;
        if(a[x][y]==2)cout<<"Tuesday"<<endl;
        if(a[x][y]==3)cout<<"Wednesday"<<endl;
        if(a[x][y]==4)cout<<"Thursday"<<endl;
        if(a[x][y]==5)cout<<"Friday"<<endl;
        if(a[x][y]==6)cout<<"Saturday"<<endl;
        if(a[x][y]==7)cout<<"Sunday"<<endl;
    }
    return 0;
}

Measured memory_bytes: 1156
#import sys
#import numpy as np
import math
#from fractions import Fraction
import itertools
from collections import deque
from collections import Counter
#import heapq
from fractions  import gcd
#input=sys.stdin.readline
import bisect
def factorize(n):
    fct={}
    temp=n
    if temp<4:
        fct[temp]=1
    else:
        e=0
        while temp%2==0:
            temp=temp//2
            e+=1
        if e>0:
            fct[2]=e
    
    for b in range(3,int(n**0.5)+1,2):
        e=0
        while temp%b == 0:
            temp=temp//b
            e+=1
        if e>0:
            fct[b]=e
    if temp!=1:
        fct[temp]=1
    return fct
n,m=map(int,input().split())
f=factorize(m)
Mod=10**9+7
M=10**7 #書き換え
fac=[0]*M
finv=[0]*M
inv=[0]*M

#finvに逆元、facに階乗のmod
def COMinit():
  fac[0]=fac[1]=1
  finv[0]=finv[1]=1
  inv[1]=1
  for i in range(2,M):
    fac[i]=(fac[i-1]*i%Mod)%Mod
    inv[i]=Mod-inv[Mod%i]*(Mod//i) %Mod
    finv[i]=(finv[i-1]*inv[i]%Mod)%Mod
def COM(n,k):
  if n<k:
    return 0
  if n<0 or k<0:
    return 0
  return (fac[n]*(finv[k]*finv[n-k]%Mod)%Mod)%Mod

COMinit()
ans=1
if m==1:
  print(1)
  exit()
for i in f:
    a=f[i]
    ans*=COM(n-1+a,n-1)
    ans%=Mod
print(ans)

Measured memory_bytes: 313288
#!/usr/bin/env python3
n = int(input())
s = input()

dp = [[False] * 1000 for i in range(4)]
for i in range(10):
    dp[0][i] = True
for c in s:
    k = int(c)
    for i in range(3)[::-1]:
        for j in range(10**i):
            dp[i + 1][10 * j + k] |= dp[i][j]
print(sum(dp[3]))


Measured memory_bytes: 3316
#include<stdio.h>

#define MAX 100000
#define NIL -1

struct Node {
  int pa,le,ri;
};

struct Node Tree[MAX];

int Depth[MAX],Height[MAX];

void setdepth(int,int);

int setheight(int);

int getsibling(int);

void print(int);

int main(){
  int h,i,nu,l,r;
  int root=0;

  scanf("%d",&h);

  for(i=0;i<h;i++)Tree[i].pa=NIL;

  for(i=0;i<h;i++){
    scanf("%d%d%d",&nu,&l,&r);
    Tree[nu].le=l;
    Tree[nu].ri=r;
    if(l!=NIL)Tree[l].pa=nu;
    if(r!=NIL)Tree[r].pa=nu;
  }

  for(i=0;i<h;i++)if(Tree[i].pa==NIL)root=i;

  setdepth(root,0);
  setheight(root);

  for(i=0;i<h;i++)print(i);

  return 0;
}

void setdepth(int x,int y){
  if(x == NIL)return;
  Depth[x]=y;
  setdepth(Tree[x].le,y+1);
  setdepth(Tree[x].ri,y+1);
}

int setheight(int x){
  int a1=0,a2=0;
  if(Tree[x].le!=NIL)a1 = setheight(Tree[x].le) + 1;
  if(Tree[x].ri!=NIL)a2 = setheight(Tree[x].ri) + 1;

  if( a1 > a2) return Height[x]=a1;
  else return Height[x]=a2;
}

  int getsibling(int x){
  if(Tree[x].pa==NIL)return NIL;
  if(Tree[Tree[x].pa].le!=x && Tree[Tree[x].pa].le!=NIL){
    return Tree[Tree[x].pa].le;
  }
  if(Tree[Tree[x].pa].ri!=x && Tree[Tree[x].pa].ri!=NIL){
    return Tree[Tree[x].pa].ri;
  }
  return NIL;
}

void print(int x){
  int deg = 0;
  printf("node %d: ",x);
  printf("parent = %d, ",Tree[x].pa);
  printf("sibling = %d, ",getsibling(x));
  if(Tree[x].le!=NIL) deg++;
  if(Tree[x].ri!=NIL) deg++;
  printf("degree = %d, ",deg);
  printf("depth = %d, ",Depth[x]);
  printf("height = %d, ",Height[x]);

  if(Tree[x].pa==NIL){
    printf("root\n");
  }
  else if(Tree[x].le==NIL && Tree[x].ri==NIL){
    printf("leaf\n");
  }
  else printf("internal node\n");
}
  
    
  



Measured memory_bytes: 2084
// Problem link - https://atcoder.jp/contests/dp/tasks/dp_f

#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false);	cin.tie(NULL);	cout.tie(NULL);
#define ll long long
#define pb push_back
#define pii pair<ll,ll>
#define INF 0x3f3f3f3f
#define mod 1000000007

int main()
{
	fast;
	string s,t;
	cin>>s>>t;
	int l1=(int)s.size();
	int l2=(int)t.size();
	int i,j;
	int dp[l1+1][l2+1];
	pii track[l1+1][l2+1];
	for(i=0;i<=l1;i++)
	{
		for(j=0;j<=l2;j++)
		{
			if(i==0 || j==0)
				dp[i][j]=0;
			else if(s[i-1]==t[j-1])
			{
				dp[i][j]=1+dp[i-1][j-1];
				track[i][j]=pii(i-1,j-1);
			}
			else
			{
				int a=dp[i-1][j];
				int b=dp[i][j-1];
				if(a>b)
					track[i][j]=pii(i-1,j);
				else
					track[i][j]=pii(i,j-1);
				dp[i][j]=max(a,b);
			}
		}
	}
	vector<int> v;
	i=l1;
	j=l2;
	while(dp[i][j]!=0)
	{
	    int p_i=track[i][j].first;
	    int p_j=track[i][j].second;
		if(dp[i][j]!=dp[p_i][p_j])
			v.pb(i);
		i=p_i;
		j=p_j;
	}
	for(i=v.size()-1;i>=0;i--)
		cout<<s[v[i]-1];
	return 0;
}

Measured memory_bytes: 176256
#include <stdio.h>
#include <iostream>
#include <cassert>
#include <algorithm>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <deque>

#include <iomanip>      // std::setprecision

#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define irep(i,a,b) for(int i=(a);i>=(b);i--)

using namespace std;
using ll=long long;
using vi=vector<int>;
using pii=pair<int,int>;


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


  int W, H, x, y;
  cin >> W >> H >> x >> y;

  double ans = W * 1.0 * H / 2.0;
  if (W % 2 == 0 && H % 2 == 0 && x == W/2 && y == H/2) {
    cout << std::setprecision(15) <<  ans << " " << 1 << endl;
  } else
    cout << std::setprecision(15) << ans << " " << 0 << endl;


  return 0;
}


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

int main(){
    int n,x,y;
    cin >> n >> x >> y;
    x--;
    y--;
    vector<vector<int>> dist(n,vector<int>(n, 0));
    /*
    for(int i=0; i<x; i++){
        for(int j=0; j<n; j++){
            if(j <= x + (y-x+1)/2){
                dist.at(i).at(j) = j-x;
            } 
            else{
                dist.at(i).at(j) = x+1+abs(j-y);
            }
        }
    }
    */
    for(int i=0; i<n; i++){
        for(int j=0; j<n; j++){
            int p1,p2,p3;
            p1 = abs(i-j);
            p2 = abs(i-x) + 1 + abs(y-j);
            p3 = abs(i-y) + 1 + abs(x-j);
            dist.at(i).at(j) = min(min(p1, p2), p3);
        }
    }
    vector<int> ans(n,0);
    for(int i=0; i<n; i++){
        for(int j=0; j<n; j++){
            ans.at(dist.at(i).at(j))++;
            //cout << dist.at(i).at(j);
        }
        //cout << endl;
    }
    for(int i=1; i<n; i++){
        cout << ans.at(i)/2 << endl;
    }
}


Measured memory_bytes: 19220
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>

using namespace std;

#define REP(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
#define pb(a) push_back(a)
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

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

int main(){
	string S;
	cin >>S;
	int win=0;
	REP(i,S.size()){
		if(S[i]=='o'){
			win++;
		}
	}
	if(15-S.size()>=8-win){
		cout <<"YES"<<endl;
	}else{
		cout <<"NO"<<endl;
	}
}


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

public class Main
{
	public static void main(String[] Arguments) throws IOException 
	{
		BufferedReader BR = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer ST;
		int N = Integer.parseInt(BR.readLine()), A; HashMap<Integer, Integer> Counts = new HashMap<>();
		ST = new StringTokenizer(BR.readLine());
		for (int i = 1; i < N; i++)
		{
			A = Integer.parseInt(ST.nextToken());
			if (Counts.containsKey(A)) Counts.put(A, Counts.get(A) + 1);
			else Counts.put(A, 1);
		}
		for (int i = 1; i <= N; i++) System.out.println((Counts.containsKey(i)) ? Counts.get(i) : "0");
	}
}


Measured memory_bytes: 72424