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

int main(){
  string S,A;
  cin >> S;
  vector<int> s(4);
  for(int i=0;i<4;i++){
    s.at(i) = S.at(i) - '0';
  }
  
  for(int tmp=0;tmp < (1 << 3);tmp++){
    bitset<3> p(tmp);
    int sum=s.at(0);
    
    for(int i=0;i<3;i++){
      if(p.test(i)){
        sum += s.at(i+1);
      }else{
        sum -= s.at(i+1);
      }
    }
    
    if(sum == 7){
      A += to_string(s.at(0));
      for(int i=0;i<3;i++){
        if(p.test(i)){
          A += '+';
        }else{
          A += '-';
        }
        A += to_string(s.at(i+1));
      }
      A += "=7";
      break;
    }
  }
  cout << A << endl;
}
    


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

int main()
{
	int n;

	while (scanf("%d", &n) != EOF)
	{
		printf("Christmas"); 
		int need = 3 - (n - 22);
		for (int i = need; i; --i) printf(" Eve");
		puts("");
	}
	return 0;
}


Measured memory_bytes: 256
#pragma region
#include <assert.h>
#include <math.h>

#include <algorithm>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>
#define pb push_back
#define f(i, a, b) for (int i = a; i < b; i++)
#define revf(i, b, a) for (int i = b; i >= a; i--)
#define all(v) v.begin(), v.end()
#define srt(v) sort(v.begin(), v.end())
#define revsrt(v) sort(v.rbegin(), v.rend())
#define sp << ' ' <<
#define en << '\n'
#define precision(x) cout << fixed << setprecision(x);

using namespace std;

template <typename T, typename U>
ostream &operator<<(ostream &os, pair<T, U> &v) {
  os << "{" << v.first << ", " << v.second << "}" en;
  return os;
}

template <typename T> ostream &operator<<(ostream &os, set<T> &v) {
  for (T t : v)
    os << t << " ";
  os en;
  return os;
}

template <typename T> ostream &operator<<(ostream &os, vector<T> &v) {
  for (T t : v)
    os << t << " ";
  os en;
  return os;
}

template <typename T> istream &operator>>(istream &is, vector<T> &v) {
  int n = v.size();
  for (int i = 0; i < n; i++)
    is >> v[i];
  return is;
}

#define int long long
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef vector<vpii> vvpii;
#pragma endregion

int mod = 1e9 + 7; // 998244353;
const int MAX = 1e5 + 5;

void preprocessing() {}

void solvetestcase() {
  int n;
  cin >> n;
  cout << (n? 0 : 1) << endl;
}

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

  preprocessing();

  int t = 1;
  // UNCOMMENT FOR TESTCASES	\
	cin >> t;

  f(T, 1, t + 1) {
    // UNCOMMENT FOR CODEJAM,HACKERCUP	\
		cout << "Case #" << T << ": ";
    solvetestcase();
    cout.flush();
  }

  return 0;
};

/*
    AUTHOR:     KUNAL TAWATIA
    EDUCATION:  INDIAN INSTITUTE OF TECHNOLOGY, JODHPUR
*/


Measured memory_bytes: 3652
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author yassin
 */

#include <bits/stdc++.h>

using namespace std;

class arc100_a {
public:
    void solve(istream& in, ostream& out) {
        int N;
        in >> N;
        vector<int> A(N);
        for (int i = 0; i < N; ++i) {
            in >> A[i];
            A[i] -= i + 1;
        }
        sort(begin(A), end(A));
        int b;
        if (N % 2 == 1) {
            b = A[N / 2];
        } else {
            b = (A[N / 2 - 1] + A[N / 2]) / 2;
        }
        long long res = 0;
        for (int x : A) {
            res += abs(x - b);
        }
        out << res << "\n";
    }
};

int main() {
	std::ios::sync_with_stdio(false); cin.tie(nullptr);
	arc100_a solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 1024
using System;
using System.IO;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using System.Runtime.CompilerServices;
using static MyUtil;

class MyUtil
{
    public static int[] ReadIntArray()
    {
	return ReadLine().Split().Select(x => int.Parse(x)).ToArray();
    }
}

class Program
{
    public static void Main()
    {
	int n = int.Parse(ReadLine());
	int[] d = ReadIntArray();

	long ans = 0;
	for (int i = 0; i < n-1; i++)
	    for (int j = i+1; j < n; j++)
		ans += d[i] * d[j];

	WriteLine(ans);
    }
}


Measured memory_bytes: 11348
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep1(i, n) for (int i = 1; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const double PI=acos(-1);
const int INF = numeric_limits<int>::max();

bool isprime(long long n) {
    if (n <= 1) return false;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p == 0) return false;
    }
    return true;
}


int main(){
    ll x;
    cin >> x;

    ll res = x;
    while(!isprime(res)) ++res;
    cout << res << endl;

    return 0;
    
}

Measured memory_bytes: 256
program main
  implicit none
  integer(8) :: k, s, x, y, z, res
  read *, k, s
  res = 0
  do x = 0, k
    do y = 0, k
      z = s - x - y
      if (0 <= z .and. z <= k) res = res + 1
    end do
  end do
  print "(i0)", res
end program main


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define MOD 1000000007
#define INF (1<<30)
#define LINF (lint)(1LL<<56)
#define endl "\n"
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
#define plint pair<lint,lint>
typedef long long lint;
int dx[8]={1,1,0,-1,-1,-1,0,1};
int dy[8]={0,1,1,1,0,-1,-1,-1};

int main(void){
    lint N,K,S;
    cin >> N >> K >> S;
    lint ans[N]={};
    rep(i,N){
        if(i<K) ans[i]=S;
        else{
            if(S==1e9) ans[i]=1e9-1;
            else ans[i]=1e9;
        }
    }
    rep(i,N) cout << ans[i] << " ";
    cout << endl;
}

Measured memory_bytes: 2176
#include <bits/stdc++.h>
using namespace std;
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define fileio freopen("in.in", "r", stdin),freopen("out.out", "w", stdout);
#define ll long long int
#define FF first
#define SS second
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define pll pair<long long int,long long int>
#define sd(x) scanf("%d",&x)
#define slld(x) scanf("%lld",&x)
#define pd(x) printf("%d\n",x)
#define plld(x) printf("%lld\n",x)
#define pss printf
#define MOD 1000000007
#define INF 1e18
#define eps 0.00001
#define endl '\n'
#define debug(n1) cout<<n1<<endl
const int N = 1e5;  // limit for array size
ll n;  // array size

/*template<typename T>
using ordered_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int rand(int l, int r){
    uniform_int_distribution<int> uid(l, r);
    return uid(rng);
}
*/
int main(){
    int n;cin>>n;
    int b[n];
    for(int i=0;i<n-1;i++){
    	cin>>b[i];
	}
	
	ll sum=0;
	int temp=100005;
	
	for(int i=0;i<n-1;i++){
		if(b[i]<=temp){
			sum+=b[i];
		}
		else{
			sum+=temp;
		}
		temp=b[i];
	}
	
	cout<<sum+b[n-2]<<endl;
	
	return 0;
}


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

const int MAX = 1e6 + 1;

int n, m, sum;

void solve(){
	scanf("%d %d", &n, &m);
	sum = 0;
	for (int i = 0, x; i < m; ++i){
		scanf("%d", &x);
		sum += x;
	}
	if (sum <= n) printf("%d", n-sum);
	else printf("-1");
}

int main(){

	ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
	solve();
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

#define INF 1<<30
#define LINF 1ll<<60ll
#define MOD 1000000007
#define pb(a) push_back(a)

#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) _repi(i,0,n)
#define _repi(i,a,b) for(int i=a, i##_len=(b); i<i##_len; ++i)
#define REP(...) _overload3(__VA_ARGS__,_repi,_rep,)(__VA_ARGS__)

#define REPR(i, n) for(int i = n;i >= 0;--i)
#define REPARR(i, v) for(int i = 0;i < sz(v);++i)

#define all(vec) (vec.begin()),(vec.end())
#define sz(x) ((int)(x).size())
#define bit(n) (1ll<<(n))

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

#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define yes(n) cout<<((n)?"yes":"no")<<endl
#define poss(n) cout<<((n)?"possible":"impossible")<<endl
#define Poss(n) cout<<((n)?"Possible":"Impossible")<<endl

ll gcdl(ll a,ll b){ // log N
    while((a%=b)&&(b%=a));
    return a+b;
}

ll lcml(ll a,ll b){
    return a/gcdl(a,b)*b;
}

int gcd(int a,int b){ // log N
    while((a%=b)&&(b%=a));
    return a+b;
}

int lcm(int a,int b){
    return a/gcd(a,b)*b;
}

int main(){
    int n;
    cin>>n;
    ll t,a;
    ll bt,ba;
    cin>>bt>>ba;
    REP(i,n-1){
        cin>>t>>a;
        if(bt>t || ba>a){
            ll b=max((bt+t-1)/t,(ba+a-1)/a);
            t*=b;a*=b;
        }
        //cout<<t<<" "<<a;
        bt=t;ba=a;
    }
    cout<<bt+ba<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main() {
	int a, b, c;
	int f, s;

	cin >> a >> b >> c;

	if (a == 5)f++;
	if (a == 7)s++;
	if (b == 5)f++;
	if (b == 7)s++;
	if (c == 5)f++;
	if (c == 7)s++;

	if (f == 2 && s == 1) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}

	return 0;
}


Measured memory_bytes: 256
extern crate proconio;
use proconio::input;
use std::cmp;

fn count_mod_ge(n:i32, b:i32, k:i32) -> i64 {
  let r = n / b;
  let m = n % b;
  let c = r * (b - k) + cmp::max(m + 1 - k, 0);
  match k {
    0 => (c - 1) as i64,
    _ => c as i64,
  }
}

fn main(){
  input!{ N: i32, K:i32 }
  let ans : i64 = (K + 1 ..= N).into_iter().map(|b| count_mod_ge(N, b, K)).sum();
  println!("{}", ans);
}

Measured memory_bytes: 2140
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,a,b) for (int i = a; i < (b); ++i)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define YY cout << "Yes" << endl;
#define NN cout << "No" << endl;
#define ve vector
#define pint pair<int,int>
const int INF = 1000000007;
const long double EPS = 1e-15;
const long double PI = acos(-1);
typedef long long ll;
using namespace std;
using Graph = vector<vector<int>>;
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 lcm(ll a, ll b) { return (a * b) / gcd(a,b); }
// *max_element(all(d))
int solve(){
  int N,K,R,S,P;
  string t;
  cin >> N >> K >> R >> S >> P >> t;
  vector<int>cnt(N,-1);
  ll ans = 0;
  rep(i,N){
    int r = R,s = S,p = P;
    if(i > K - 1){
      if(cnt[i - K] == 0)r = 0;
      else if(cnt[i - K] == 1)s = 0;
      else if(cnt[i - K] == 2)p = 0;
    }
    if(t[i] == 'r'){
      if(p == 0)continue;
      ans += p;
      cnt[i] = 2;
    }
    else if(t[i] == 's'){
      if(r == 0)continue;
      ans += r;
      cnt[i] = 0;
    }
    else{
      if(s == 0)continue;
      ans += s;
      cnt[i] = 1;
    }
  }
  cout << ans << endl;
  return 0; 
}
int main(){
  // ios::sync_with_stdio(false);cin.tie(nullptr);
  cout << fixed;cout << setprecision(16);
  solve();
  return 0;
}
//2 9,4 7,6 2

Measured memory_bytes: 896
#include<stdio.h>
int main(){
	int a,b;
	scanf("%d %d",&a,&b);
	if(a<b){
		printf("a < b\n");
	}
	else if(a>b){
		printf("a > b\n");
	}
	else{
	printf("a == b\n");
	}
	return 0;
}


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

using namespace std;

int main(){

  cout << fixed << setprecision(12);

  double r;
  cin>>r;

  double PI = acos(-1);
  double area = r * r * PI;
  double cir = (r + r) * PI;
  cout<<area <<" "<<cir<<endl;

}



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

int main(){
    long long x, y;cin>>x>>y;
    if (x % y == 0){
        cout << -1 << endl;
    } else {
        long long num=1;
        bool success_flag = true;
        while(true){
            if (x * num <= 1000000000000000000){
                if (x * num % y != 0){
                    break;
                }
            } else {
                success_flag = false;
                break;
            }
        }
        if (success_flag){
            cout << x * num <<endl;
        } else {
            cout << -1 << endl;
        }
    }
    return 0;
}

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

const int INF = 1001001001;

int a[12][12];

int main() {
    int n, m, x;
    cin >> n >> m >> x;
    vector<int> c(n);

    rep(i, n) {
        cin >> c[i];
        rep(j, m) {
            cin >> a[i][j];
        }
    }

    int ans = INF;
    rep(s, 1 << n) {
        int cost = 0;
        vector<int> d(m);
        rep(i, n) {
            if ((s >> i) & 1) {
                cost += c[i];
                rep(j, m) d[j] += a[i][j];
            }
        }
        bool ok = true;
        rep(j, m) if (d[j] < x) ok = false;
        if (ok) ans = min(ans, cost);
    }

    if (ans == INF)
        cout << -1 << endl;
    else
        cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3580
#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;

    vector<string> ans = {
        "pon",
        "pon",
        "hon",
        "bon",
        "hon",
        "hon",
        "pon",
        "hon",
        "pon",
        "hon",
    };

    cout << ans[n % 10] << endl;

    return 0;
}

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

using namespace std;

////typedef
////------------------------------------------
//typedef vector<int> vi;
//typedef vector<vi> vii;
//typedef vector<string> vs;
//typedef vector<bool> vb;
//typedef vector<vb> vbb;
//typedef pair<int, int> pii;
//typedef long long ll;
//typedef unsigned long long ull;
//
////container util
////------------------------------------------
//#define all(a)  (a).begin(),(a).end()
//#define rall(a) (a).rbegin(), (a).rend()
//#define pb push_back
//#define mp make_pair
//#define iter(i,c) for(auto i=(c).begin(); i!=(c).end(); ++i)
//
////repetition
////------------------------------------------
//#define loop(i,a,b) for(int i=(a);i<(b);++i)
//#define rep(i,n)  loop(i,0,n)
//
////constant
////--------------------------------------------
//const double eps = 1e-10;
//const double pi  = acos(-1.0);
//const double inf = (int)1e8;
//
//// output vector
//// ------------------------------------------
//namespace std {
//    template<typename T> ostream & operator<<(ostream& os, vector<T> const& v){
//        for(auto it=v.begin(); it!=v.end(); ++it){
//            os << *it << (it+1==v.end() ? "" : ",");
//        }
//        return os;
//    }
//}
//
////clear memory
//#define clr(a) memset((a), 0 ,sizeof(a))

int main(){
    int n;
    while(cin >> n, n){
        int ans = 0;
        for(int i=0; i < n; i++){
            int x, y, h, w;
            cin >> x >> y >>h >> w;

            int s = x+y+h;
            if(160 < s || 25 < w);
            else if(140 < s || 20 < w) ans += 1600;
            else if(120 < s || 15 < w) ans += 1400;
            else if(100 < s || 10 < w) ans += 1200;
            else if(80 < s || 5 < w) ans += 1000;
            else if(60 < s || 2 < w) ans += 800;
            else ans += 600;
        }
        cout << ans << endl;
    }
}

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

int main()
{
  // 項目数
  int N;
  cin >> N ;

  //答え
  long answer = 0;
  int b = 0;

  //素朴に
  for (int i = 1; i <= N; i++)
  {
    //i を文字列に
    string a = to_string(i);
    string first_a = a.substr(0, 1); //string(a.front());
    string last_a = a.substr(a.length() - 1, 1); // string(a.back());

    //末尾0の場合一致しないので飛ばす
    if (last_a == "0")
    {
      continue;
    }

    //a をもとに、N以下で条件が許される数を作り出す方針で行く
    //１桁の場合、条件を満たすのは先頭と末尾が一致する場合のみ、a < N なので条件はとばす
    if (0 < N )
    {
      if (first_a == last_a)
      {
        answer++;
      }
    }

    //２桁の場合、許される数はひっくり返した数、ただし < Nのときだけ
    if (10 <= N )
    {
      b = stoi(last_a) * 10 + stoi(first_a);
      if (b <= N)
      {
        answer ++;
      }
    }
    //３桁の場合、許される数はひっくり返した数＋１０の位に任意の数値、ただし < Nのときだけ
    if (100 <= N)
    {
      b = stoi(last_a) * 100 + stoi(first_a);
      for (int j = 0; j < 10; j++)
      {
        if (b <= N)
        {
          answer++;
        }
        else
        {
          break;
        }
        b += 10;

      }
    }
    //４桁の場合、許される数はひっくり返した数＋１００、１０の位に任意の数値、ただし < Nのときだけ
    if (1000 <= N)
    {
      b = stoi(last_a) * 1000 + stoi(first_a);
      for (int j = 0; j < 100; j++)
      {
        if (b <= N)
        {
          answer++;
        }
        else
        {
          break;
        }
        b += 10;
      }
    }
    //５桁の場合、許される数はひっくり返した数＋１００００、１００、１０の位に任意の数値、ただし < Nのときだけ
    if (10000 <= N)
    {
      b = stoi(last_a) * 10000 + stoi(first_a);
      for (int j = 0; j < 1000; j++)
      {
        if (b <= N)
        {
          answer++;
        }
        else
        {
          break;
        }
        b += 10;
      }
    }
    //５桁の場合、許される数はひっくり返した数＋１００００、１００、１０の位に任意の数値、ただし < Nのときだけ
    if (100000 <= N)
    {
      //N < 200000なので、末尾2の場合は飛ばす
      if (last_a >= "2")
      {
        continue;
      }
      b = stoi(last_a) * 100000 + stoi(first_a);
      for (int j = 0; j < 10000; j++)
      {
        if (b <= N)
        {
          answer++;
        }
        else
        {
          break;
        }
        b += 10;
      }
    }
  }
  
  cout << answer;

  return 0;

}

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

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

  int ans = 0;
  for (int i = a; i <= b; i ++) {
    if (c % i == 0) ans ++;
  }

  cout << ans << endl;
}



Measured memory_bytes: 3124
N, K = map(int, input().split())
if K == 0:
    print(N * N)
    exit()
cnt = 0
for b in range(K + 1, N + 1):
    p, r = divmod(N, b)
    cnt += p * (b - K) + max(r - K + 1, 0)
print(cnt)

Measured memory_bytes: 3060
// A.

#include <iostream>
#include <sstream>
#include <algorithm>
#include <cstdio>
#include <cstdlib>

using namespace std;

int main(int argc, char *argv[]) {
	int pos[5], k;
	for (int i = 0; i < 5; ++i) {
		cin >> pos[i];
	}
	cin >> k;
	sort(pos, pos + 5);
	bool ans = pos[4] - pos[0] <= k;
	cout << (ans ? "Yay!" : ":(") << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll max_val(ll wt[],ll val[],ll n,ll w){

	vector<ll> dp(w+1,0);
	for(ll i=0;i<n;++i){
		for( ll j=w-wt[i];j>=0;--j){
			dp[j+wt[i]] = max(dp[j+wt[i]],dp[j] + val[i]);
			
			
		}
	}
	ll ans = 0;
	for(int i=0;i<=w;++i){
		ans = max(ans,dp[i]);
	}
	return ans;
}


int main(){

	ll N,W;
	cin>>N>>W;
	ll wt[N],val[N];
	for(ll i=0;i<N;++i){
		cin>>wt[i] >> val[i];
	}

	cout << max_val(wt,val,N,W) << endl;;



	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<LL,LL> P;
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; }
template<typename T> T gcd(T a,T b){return b?gcd(b,a%b):a;}
const LL mod=1000000007;
const LL LINF=1LL<<62;
const int INF=1<<30;
int dx[]={1,0,-1,0,1,-1,1,-1};
int dy[]={0,1,0,-1,1,-1,-1,1};


int main(){
    int k;string s;cin >> k >> s;
    if(s.length() <= k){
        cout << s << endl;
    }
    else{
        string ans = "";
        for (int i = 0; i < k; i++) {
            ans += s[i];
        }
        cout << ans << "..." << endl;
    }
    return 0;
}



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

int POW(int K,int N){
    if(!N) return 1;
    return K*POW(K,N-1);
}

signed main(){
   int N,K;
   cin>>N>>K;
   cout<<K*POW(K-1,N-1)<<endl;
}

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

using namespace std;

typedef long long ll;

const int Mod = 1e9 + 7;

void add_self(int& x, int y)
{
    if((x += y) >= Mod) x -= Mod;
}

int mul(int x, int y)
{
    return (ll) x * y % Mod;
}

typedef vector <int> Row;
typedef vector <Row> Matrix;

Matrix Zero(int n, int m)
{
    return Matrix(n, Row(m, 0));
}

Matrix Ident(int n)
{
    Matrix Res = Zero(n, n);
    for(int i = 0; i < n; i++)  Res[i][i] = 1;
    return Res;
}

Matrix Multy(const Matrix& A, const Matrix& B)
{
    assert(A[0].size() == B.size());
    Matrix Res = Zero(A.size(), B[0].size());

    for(int i = 0; i < Res.size(); i++)
        for(int j = 0; j < Res[0].size(); j++)
            for(int k = 0; k < B.size(); k++)
                add_self(Res[i][j], mul(A[i][k], B[k][j]));

    return Res;
}

Matrix Power(const Matrix& A, ll k)
{
    if(!k)      return Ident(A.size());
    if(k & 1)   return Multy(A, Power(A, k - 1));
    return Power(Multy(A, A), k / 2);
}

int Fibo(ll n)
{
    Matrix Dp0 = Zero(1, 2);
    Dp0[0][0] = 0, Dp0[0][1] = 1;

    Matrix A = Zero(2, 2);
    A[0][0] = 0, A[0][1] = 1;
    A[1][0] = 1, A[1][1] = 1;

    Matrix Dpn = Multy(Dp0, Power(A, n));
    return Dpn[0][0];
}

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

    Matrix Graph = Zero(n, n);
    for(int i = 0; i < n; i++)
        for(int j = 0; j < n; j++)
            cin >> Graph[i][j];

    Matrix A = Zero(1, n);
    for(int i = 0; i < n; i++)  A[0][i] = 1;

    Matrix C = Multy(A, Power(Graph, k));

    int Ans = 0;
    for(int i = 0; i < n; i++)  add_self(Ans, C[0][i]);
    cout << Ans << endl;
}


Measured memory_bytes: 896
#include<iostream>
#include<algorithm>
#define LL long long
int N;
int C[501];
int S[501];
int F[501];
int main() {
	std::cin >> N;
	for (int i = 1; i < N; i++) {
		std::cin >> C[i] >> S[i] >> F[i];
	}
	for (int i = 1; i <= N; i++) {
		int t = S[i] + C[i];
		for (int j = i + 1; j < N; j++) {
			if (t <= S[j])t = S[j] + C[j];
			else {
				int add = (t - S[j] - 1) / F[j] + 1;
				t = S[j] + add * F[j] + C[j];
			}
		}
		std::cout << t << std::endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;
int main()
{
    string S;
    cin >> S;
    int ans = 0;
    rep(i, S.size()) {
        if (S[i] == '-') ans--;
        else ans++;
    }

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

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

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repp(i, l, r) for(int i = (l); i < (r); i++)
#define per(i, n) for(int i = ((n)-1); i >= 0; i--)
#define perr(i, l, r) for(int i = ((r)-1); i >= (l); i--)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define IINF 1000000000
#define LINF 1000000000000000000
#define SP <<" "<<
#define CYES cout<<"Yes"<<endl
#define CNO cout<<"No"<<endl
#define CFS cin.tie(0);ios::sync_with_stdio(false)

typedef long long LL;
typedef long double LD;

double dot(vector<double> l, vector<double> r){
  return l[0]*r[0]+l[1]*r[1]+l[2]*r[2];
}

double norm(vector<double> l){
  return dot(l,l);
}

vector<double> add(vector<double> l, vector<double> r){
  return {l[0]+r[0],l[1]+r[1],l[2]+r[2]};
}

vector<double> mul(double k, vector<double> l){
  return {k*l[0],k*l[1],k*l[2]};
}

vector<double> diff(vector<double> l, vector<double> r){
  return {l[0]-r[0],l[1]-r[1],l[2]-r[2]};
}

struct obst{
public:
  vector<double> p;
  double r;
  LL c;
  obst():p(3){}
};

int main(){
  int n,q;
  cin >> n >> q;
  vector<obst> ob(n);
  rep(i,n){
    cin >> ob[i].p[0] >> ob[i].p[1] >> ob[i].p[2] >> ob[i].r >> ob[i].c;
  }
  vector<double> s(3),t(3);
  rep(tt,q){
    rep(i,3) cin >> s[i];
    rep(i,3) cin >> t[i];
    LL ans=0;
    rep(i,n){
      vector<double> vs = diff(s,ob[i].p);
      vector<double> vt = diff(t,ob[i].p);
      double k = dot(vt,diff(vt,vs))/norm(diff(vt,vs));
      double x = norm(add(mul(k,vs),mul(1-k,vt)));
      vector<double> pos = add(ob[i].p,add(mul(k,vs),mul(1-k,vt)));
      if(0<=k&&k<=1&&x<=ob[i].r*ob[i].r+0.0000001) ans+=ob[i].c;
    }
    cout << ans << endl;
  }
  return 0;
}



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

int main() {
	// your code goes here
	string s;
	cin >> s;
	bool f = true;
	for(int i = 0; i < s.length(); i++){
	    if((i + 1)% 2 != 0){ //odd
	        if(s[i] == 'L'){
	            f = false;
	        }
	    }
	     else if((i + 1) % 2 == 0){
	        if(s[i] == 'R'){
	            f = false;
	        }
	    }
	}
	
	if(!f) cout << "No" << endl;
	else cout << "Yes" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <numeric>
using namespace  std;
typedef long long int ll;
typedef long double ld;
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define pb push_back
#define mp make_pair
#define sz(a) a.size()
#define rsz(a,n) a.resize(n)
#define test(t) ll t;cin>>t;while(t--)
#define forn(i,e) for(int i = 0; i < e; i++)
#define forsn(i,s,e) for(int i = s; i < e; i++)
#define rforn(i,s) for(int i = s; i >= 0; i--)
#define rforsn(i,s,e) for(int i = s; i >= e; i--)
#define fillv(a,k) memset(a,k,sizeof(a))
#define filla(a,k,n) memset(a,k,sizeof(a[0])*n)
#define leadzero(a) __builtin_clz(a) //count leading zeros
#define trailzero(a) __builtin_ctz(a) //count trailing zeros
#define bitcount(a) __builtin_popcount(a) // count set bits (add ll)
#define ln cout<<"\n"
#define sp cout<<" "
#define spaceprint(a,i,s,n) {forsn(i,s,n) { cout<<a[i]; sp;}}
#define lineprint(a,i,s,n) {forsn(i,s,n) {cout<<a[i]; ln;}}
#define maxe(a) *max_element(a.begin(),a.end())
#define maxi(a) max_element(a.begin(),a.end())-a.begin()
#define mine(a) *min_element(a.begin(),a.end())
#define mini(a) min_element(a.begin(),a.end())-a.begin()
#define all(c) c.begin(),c.end()
#define trav(container, it) for(typeof(container.begin()) it = container.begin(); it != container.end(); it++)
#define present(container, element) (container.find(element) != container.end())
#define cpresent(container, element)  (find(all(container),element) != container.end())// check the presence of element
//copy(from_begin, from_end, to_begin); copy function
typedef unsigned long long int ull;
typedef long double ld;
typedef pair<ll,ll> p64;
typedef pair<int,int> p32;
typedef pair<int,p32> p96;
typedef vector<ll> v64;
typedef vector<string> vs;
typedef vector<int> v32;
typedef vector<v32> vv32;
typedef vector<v64> vv64;
typedef vector<p32> vp32;
typedef vector<vp32> vvp32;
typedef map<int,int> m32;
const int LIM = 1e5+5, MOD = 1e9+7;
#define sumv(v) accumulate(all(v),ll(0))
#define productv(v) accumulate(all(v), ll(1), multiplies< ll >())
ll dp[1005][1005];
char a[1005][1005];
ll i,j,k;
ll pow1(ll a,ll b)
{
    if(b==0)
        return 1;
    if(b%2==0)
        return pow1(a*a,b/2);
    else
        return a*pow1(a*a,b/2);
}
int main()
{
    ll n,i,j,m;
    cin>>n>>m;
    forn(i,n)
        forn(j,m)
            cin>>a[i][j];
    fillv(dp,0);
    //solve(n);
    dp[0][0]=1;
    forsn(i,1,n)
    {
        if(a[i][0]=='#')
            dp[i][0]=0;
        else
            dp[i][0]=dp[i-1][0];
    }
    forsn(j,1,m)
    {
        if(a[0][j]=='#')
            dp[0][j]=0;
        else
            dp[0][j]=dp[0][j-1];
    }
    forsn(i,1,n)
        forsn(j,1,m)
    {
        if(a[i][j]=='#')
        {
            dp[i][j]=0;
        }
        else
        {
            dp[i][j]=(dp[i-1][j]+dp[i][j-1])%MOD;
        }
    }

    cout<<dp[n-1][m-1];


}


Measured memory_bytes: 9088
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = (int)(a); i <= (int)(n); ++i)
#define rrep(i, a, n) for (int i = (int)(a); i >= (int)(n); --i)
#define debug(x) cerr << #x << " = " << x << "\n"
#define debugv(x) \
  rep(f, 0, (x.size() - 1)) cerr << x[f] << (f == (x.size() - 1) ? "\n" : " ")
#define debug2(x, y)                       \
  cerr << "(" << #x << "," << #y << ") = " \
       << "(" << x << "," << y << ")\n"
#define all(x) x.begin(), x.end()
#define each(a, x) for (auto& a : (x))
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define int long long
using namespace std;
typedef pair<int, int> pii;
typedef vector<int> vi;
const int MX = 1e5 + 5, INF = 5LL << 57, MOD = 1e9 + 7;

int N, M;
vi va, vb;
int K;
string T;
int R, S, P;
int Sc[3];

void input() {
  ;
  cin >> N >> K;
  cin >> R >> S >> P;
  cin >> T;
  Sc[0] = R;
  Sc[1] = S;
  Sc[2] = P;

  ;
}
int E[MX * 2];
int dp[MX][3];
vi sums;
void solve() {
  rep(i, 0, N - 1) {
    if (T[i] == 'r') {
      E[i + 1] = 2;
    } else if (T[i] == 's') {
      E[i + 1] = 0;  // ぐーでかつ
    } else {
      E[i + 1] = 1;  // ちょきでかつ
    }
  };

  rep(i, 0, 2) { dp[1][i] = (E[i] == i ? Sc[i] : 0); }

  // rep(i, 0, 2) { debug(dp[1][i]); }

  sums.resize(N + 1);
  rep(i, 1, N) { sums[i] = sums[i - 1] + (Sc[E[i]]); }
  // debugv(sums);
  // greedy!

  int ans = 0;
  rep(i, 1, N) {
    int aite = E[i];
    // debug2(i, aite);
    if (aite == 4) {
      continue;
    }
    ans += Sc[aite];
    if (E[i + K] == aite) {
      E[i + K] = 4;
    }
    //   debug2(i, ans);
  }
  cout << ans << endl;

  // rep(i, 2, N) {
  // int mx = max({dp[i - 1][0], dp[i - 1][1], dp[i - 1][2]});
  // dp[i+K]
  // debug2(i, mx);
  // rep(j, 0, 2) {
  //   dp[i][j] = mx + (E[j] == i ? Sc[j] : 0);
  //   if (i - K >= 1) {
  //     int mxa, mxi;
  //     mxa = -1, mxi = -1;
  //     rep(k, 0, 2) {
  //       if (j == k) continue;
  //       if (mxa <= dp[i - 1][k]) {
  //         mxa = dp[i - 1][k];
  //         mxi = k;
  //       }
  //     }
  //     dp[i][j] = mxa +
  //   }
  // }
  // }
  // cout << max({dp[N][0], dp[N][1], dp[N][2]}) << endl;

  ;
}
signed main() {
  input();
  solve();
  return 0;
}

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

int main() {
  long int X,Y;
  
  cin >> X >> Y;
  
  long int a,b,r;

  a = Y;
  b = X;

  r = a % b;
  while (r!=0){
    a = b;
    b = r;
    r = a% b;
  }

  map<long int, int> C;
  for ( long int i = 2; i*i <= b; i++ ) {
    while ( b%i == 0 ) {
      C[i]++;
      b /= i;
    }
  }
  if ( b > 1 ) C[b]= 1;

  cout << C.size() + 1 ;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
const ll mod=1e9+7;
const ll N = 2e5+10;



void Solve(){
            
        
        ll h,w,ans;
        cin>>h>>w;
        ll x=h*w;
        if(h==1||w==1){
            cout<<1;
            return;
        }
        if(x&1){
            cout<<(x/2)+1;
            return;
        }
        cout<<x/2;
}


int main(){
    
        #ifdef debug
            freopen("input.txt", "r", stdin);
            freopen("output.txt", "w", stdout); 
            
        #endif
            ios_base::sync_with_stdio(0);
            cin.tie(0);cout.tie(0);
            
            
            
                Solve();
            
            
            
        return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**7)
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return sys.stdin.readline().strip()
INF = 10 ** 18
MOD = 10 ** 9 + 7

debug = True
debug = False

def dprint(*objects):
    if debug == True:
        print(*objects)


def solve():
    N = II()
    print(int(N*(N-1)//2))

solve()

Measured memory_bytes: 3064
import math

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

inf = int(1e6+5)
C = [0]*inf

for a in A:
    C[a] += 1

pa = True
se = True
for i in range(2, inf):
    cnt = 0
    for j in range(i, inf, i):
        cnt += C[j]
    if cnt > 1:
        pa = False
    if cnt == N:
        se = False
        
if pa:
    print("pairwise coprime")
elif se:
    print("setwise coprime")
else:
    print("not coprime")


Measured memory_bytes: 194252
def resolve():
    import math
    N, D = map(int, input().split())
    A = []
    count = 0
    for i in range(N):
        A.append(list(map(int, input().split())))
    for j in range(N):
        for g in range(N):
            ans = 0
            if j != g:
                for k in range(D):
                    ans += (A[j][k]-A[g][k])**2
                if math.sqrt(ans)%1== 0:
                    count += 1
    print(count//2)
resolve()

Measured memory_bytes: 3188
//  ROAD TO GREEN
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <stack>
#include <iomanip>
#include <queue>
#include <set>
#include <bitset>

#define ll long long
#define uint unsigned int
#define ull unsigned ll
#define mp make_pair
#define pb push_back
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()
#define speedhack() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);


using namespace std;
const ll MAXN = 2e9+2;
const ll SIZE = 1e6+2;
const ll mod = 1e9+7;



int main(){ 
	speedhack()
	int n,m;
	cin >> n >> m;
	if((n+m)%2 == 0 && n+m > 0){
		cout << (n+m)/2 << endl;
	}else if(n-m == 0 || n+m == 0){
		cout << 0 << endl;
	}else{
		cout << "IMPOSSIBLE" << endl;
	}
	return 0;
}


Measured memory_bytes: 256
extern crate core;

use std::io::{self, Read};

#[macro_use]
mod parser {
    macro_rules! input {
    ($s:expr=>$($t:tt)*) => {
        let mut lines=$s.split("\n");
        $(
            line_parse!(lines,$t);
        )*
    };
    }

    macro_rules! line_parse {
    ($lines:expr,($($name:ident:$t:tt)*)) => {
        let mut line=$lines.next().unwrap().split_whitespace();
        $(value_def!(line,$name,$t);)*
    };

    //複数行
    ($lines:expr,{$n:expr;$name:ident:$t:tt}) => {
        values_def!($lines,$n,$name,$t);
    };
    }

    macro_rules! value_def {
        ($line:expr, $name:ident, $t:tt) => {
            let $name = value!($line, $t);
        };
    }

    macro_rules! values_def {
        ($lines:expr, $n:expr, $name:ident, $t:tt) => {
            let $name = {
                let mut vec = Vec::new();
                for i in 0..$n {
                    let mut next = $lines.next().unwrap().split_whitespace();
                    vec.push(value!(next, $t));
                }
                vec
            };
        };
    }

    macro_rules! value {
    //配列
    ($line:expr,[$t:tt]) => {
        $line.map(|x|{
        let mut iter=::std::iter::once(x);
        value!(iter,$t)
        }).collect::<Vec<_>>()
    };
    //タプル
    ($line:expr,($($t:tt),*)) => {
        ($(value!($line,$t),)*)
    };
    //文字列
    ($line:expr,#) => {
        $line.next().unwrap()
    };
    //単一値
    ($line:expr,$t:ty) => {
        $line.next().unwrap().parse::<$t>().unwrap()
    };
    }
}

fn main() {
    let mut input = String::new();
    io::stdin().read_to_string(&mut input).unwrap();
    let output = solve(input.trim().to_string());
    println!("{}", output);
}

fn solve(input: String) -> String {
    input!(input=>(a:i64 b:i64 c:i64 k:i64));
    if k % 2 == 0 { -b + a } else { b - a }.to_string()

    /*
    (1,0,0)(0,1,0)(0,0,1)
    (0,1,1)(1,0,1)(1,1,0)
    (2,1,1)(1,2,1)(1,1,2)
    (2,3,3)(3,2,3)(3,3,2)
    (6,5,5)(5,6,5)(5,5,6)
    */
    /*
    aについて
    (x[i],y[i],y[i])
    とすると
    x[1]=1
    y[1]=0

    (x[i],y[i])
    (1,0)
    (0,1)
    (2,1)
    (2,3)
    (6,5)

    x[i+1]=y[i]*2
    y[i+1]=x[i]+y[i]

    x[1]=1
    x[2]=0
    x[i+2]=x[i+1]+x[i]*2
    x[i]=1/6(2^i-4(-1)^i)


    y[1]=0
    y[2]=1
    y[i+2]=y[i+1]+y[i]*2
    y[i]=1/6(2(-1)^i+2^i)




    b,cについても同様に成り立つ
    */
    /*
    x[k](a-b)+y[k](b-a)
    1/6((2^k-4(-1)^k)(a-b)+(2(-1)^k+2^k)(b-a))
    b(-1)^k-a(-1)^k
    */
}

macro_rules! tests {
    ($($name:ident: $input:expr=>$output:expr,)*) => {
        mod tests {
            $(
                #[test]
                fn $name() {
                    assert_eq!($output.trim().to_string(),super::solve($input.trim().to_string()));
                }
            )*
        }
    }
}

tests! {
    test1: "1 2 3 1" => "1",
    test2: "2 3 2 0" => "-1",
    test3: "1000000000 1000000000 1000000000 1000000000000000000" => "0",
}


Measured memory_bytes: 4352
#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++)

int main(){
    ll N;
    string A, B, C;
    cin >> N >> A >> B >> C;
    ll ans = 0;
    rep(i, 0, N){
        if(A[i] == B[i]){
            if(A[i] != C[i]) ans++;
        }else{
            if(A[i] == C[i] || B[i] == C[i]) ans++;
            else ans += 2;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        int K, A, B;
        Scanner sc = new Scanner(System.in);
        K = sc.nextInt();
        A = sc.nextInt();
        B = sc.nextInt();
        int temp = B/K;
        if(temp*K >= A)
        System.out.println("OK");
        else System.out.println("NG");
    }
}


Measured memory_bytes: 35776
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {

		// input
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		String numString = "";
		for (int i = 2; i <= n; i++) {
			numString = numString + i;
		}
		int m = in.nextInt();
		int[][] mat = new int[n + 1][n + 1];
		for (int i = 0; i < m; i++) {
			int ai = in.nextInt();
			int bi = in.nextInt();
			mat[ai][bi] = 1;
			mat[bi][ai] = 1;
		}

		// solve
		List<String> numList = new ArrayList<String>();
		numList = MathUtils.permute(numString.toCharArray(), 0, numString.length() - 1, numList);

		int ans = 0;
		for (String num : numList) {
			num = (1 + num);
			boolean isConnect = true;
			for (int i = 0; i < num.length() - 1; i++) {
				int from = Integer.parseInt(num.substring(i, i+1));
				int to = Integer.parseInt(num.substring(i+1, i+2));
				if (mat[from][to] != 1) {
					isConnect = false;
					break;
				}
			}
			if (isConnect) ans++;
		}
		System.out.println(ans);

	}

	static class MathUtils {

		public static List<String> permute(char[] ary, int startIndex, int endIndex, List<String> list) {
			if (startIndex == endIndex) {
				list.add(String.valueOf(ary));
			} else {
				for (int i = startIndex; i <= endIndex; i++) {
					swap(ary, startIndex, i);
					permute(ary, startIndex + 1, endIndex, list);
					swap(ary, startIndex, i);
				}
			}
			return list;
		}

		public static void swap(char[] ary, int x, int y) {
			char temp = ary[x];
			ary[x] = ary[y];
			ary[y] = temp;
		}
	}

}


Measured memory_bytes: 25164
#include <bits/stdc++.h>
#define maxn ((ll)(1e5+10))
#define mod ((ll)(1e9+7))
using namespace std;
typedef long long ll;
int n,a[maxn],cnt[maxn][3];
ll ans;
bool t;
bool f(int b) {
	if (b<1||b>n)
		return 0;
	if (cnt[b][0]==2)
		return 0;
	cnt[b][0]++;
	cnt[b][cnt[b][0]]=b;
	return 1;
}
int main() {
	scanf("%d",&n);
	t=true;
	for (int i=1;i<=n;i++) {
		scanf("%d",&a[i]);
		int b=n-1+a[i];
		if (b%2==0) {
			b/=2;
			t=f(b+1);
			if (n-b!=b+1)
				t=f(n-b);
			else if (cnt[b+1][0]==2)
				t=false;
			if (!t)
				break;
		}
		else {
			t=false;
			break;
		}
	}
	if (!t)
		ans=0;
	else {
		ans=1;
		for (int i=1;i*2<=n;i++) {
			ans*=(ll)cnt[i][0];
			ans%=mod;
		}
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 1792
//
// Created by yamunaku on 2019/07/14.
//

#include <bits/stdc++.h>

using namespace std;

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repl(i, l, r) for(int i = (l); i < (r); i++)
#define per(i, n) for(int i = ((n)-1); i >= 0; i--)
#define perl(i, l, r) for(int i = ((r)-1); i >= (l); i--)
#define all(x) (x).begin(),(x).end()
#define MOD9 998244353
#define MOD1 1000000007
#define IINF 1000000000
#define LINF 1000000000000000000
#define SP <<" "<<
#define CYES cout<<"Yes"<<endl
#define CNO cout<<"No"<<endl
#define CFS cin.tie(0);ios::sync_with_stdio(false)
#define CST(x) cout<<fixed<<setprecision(x)

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vector<int>> mti;
typedef vector<ll> vl;
typedef vector<vector<ll>> mtl;

int main(){
    int n;
    cin >> n;
    rep(i,31){
        if(n==(1<<i)){
            CNO;
            return 0;
        }
    }
    CYES;
    if(n%2){
        cout << 1 SP 2 << endl;
        cout << 2 SP 3 << endl;
        cout << 3 SP n+1 << endl;
        cout << n+1 SP n+2 << endl;
        cout << n+2 SP n+3 << endl;
        for(int i=4;i<n;i+=2){
            cout << i SP 1 << endl;
            cout << i+1 SP 1 << endl;
            cout << i+n SP i+1 << endl;
            cout << i+1+n SP i << endl;
        }
    }else{
        int v;
        rep(i,31){
            if(n-2==(1<<i)){
                v=n-2;
                goto next;
            }
        }
        rep(i,31){
            if(n&(1<<i)){
                v=n-(1<<i);
                break;
            }
        }
        cout << 1 SP 2 << endl;
        cout << 2 SP 3 << endl;
        cout << 3 SP n+1 << endl;
        cout << n+1 SP n+2 << endl;
        cout << n+2 SP n+3 << endl;
        for(int i=4;i<n;i+=2){
            if(i!=v){
                cout << i SP 1 << endl;
                cout << i+1 SP 1 << endl;
                cout << i+n SP i+1 << endl;
                cout << i+1+n SP i << endl;
            }else{
                cout << i SP n-i+n << endl;
                cout << i+1 SP n-i+1+n << endl;
                cout << i+n SP i+1 << endl;
                cout << i+1+n SP i << endl;
            }
        }
        cout << n SP v << endl;
        cout << n+n SP n-v+n << endl;
        return 0;
        next:;
        cout << 1 SP 2 << endl;
        cout << 2 SP 3 << endl;
        cout << 3 SP n+1 << endl;
        cout << n+1 SP n+2 << endl;
        cout << n+2 SP n+3 << endl;
        for(int i=4;i<n;i+=2){
            cout << i SP n+1 << endl;
            cout << i+1 SP n+1 << endl;
            cout << i+n SP i+1 << endl;
            cout << i+1+n SP i << endl;
        }
        cout << n SP 3 << endl;
        cout << n+n SP v << endl;
    }
    return 0;
}



Measured memory_bytes: 2304
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <queue>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <stdio.h>
#include <complex>
#include <cstdint>
#include <tuple>
#include <regex>
#include <numeric>

#define M_PI       3.14159265358979323846

using namespace std;

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

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<int, PII> TIII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

//container util

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

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define MOD 1000000007

char str[256];

int main() {
	LL n;
	cin >> n;
	int p = 0;
	if (n < 0) {
		n = -n;
		p = 1;
	}
	int idx = 0;
	do {
		str[idx++] = '0' + n % 2;
		if (p == 1 && (n & 1))
		{
			n += 2;
		}
		n >>= 1;
		p = 1 - p;
	} while (n);
	reverse(str, str + idx);
	cout << str << endl;
	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("avx2")
#pragma GCC optimize("Os")
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);
#define FO cout.tie(NULL);
#define FI cin.tie(NULL);
#define IN cin>>
#define OUT cout<<
#define loop(i,a,n) for(ll i=a; i<n; i++)
#define rloop(i,a,n) for(int i=a; i>=n; i--)
#define endl "\n";
#define pb push_back
#define mp make_pair
#define set_bits(a) __builtin_popcountll(a)
#define ll long long int
#define ld long double
#define vll vector<long long int>
#define pll pair<long long int, long long int>
#define mod 1000000007
#define M 998244353
using namespace std;
ll gcd(ll a, ll b)
{
    return (b?gcd(b,a%b):a);
}
ll P(ll B, ll power, ll modulo)
{
    ll ans=1LL;
    while(power>0LL)
    {
        if(power%2LL==1LL)
        {
            ans=(ans*B)%modulo;
        }
        B=(B*B)%modulo;
        power/=2LL;
    }
    return ans;
}
bool isPrime(ll n)
{
    if(n<=1LL)
    {
        return false;
    }
    if(n<=3LL)
    {
        return true;
    }
    if(n%2==0LL || n%3==0LL)
    {
        return false;
    }
    for(ll i=5LL; (i*i)<=n; i+=6LL)
    {
        if(n%i==0LL || n%(i+2LL)==0LL)
        {
            return false;
        }
    }
    return true;
}
void vok()
{
    FAST
    FO
    FI
    #ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
        freopen("error.txt","w",stderr);
    #endif
}
const int mxN=int(2e5)+100;
vector<ll> graph[mxN];
int main()
{
    vok();
    ll n;
    IN n;
    ll ans=0LL;
    loop(i,0,n-1)
    {
        ll a,b;
        IN a>>b;
        ans-=(min(a,b)*(n-max(a,b)+1));
    }
    loop(i,1,n+1)
    {
        ans+=((i)*(n-i+1));
    }
    OUT ans<<endl
    return 0;
}

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

using namespace std;
using ll = long long;
using ii = pair<ll, ll>;

const int MAX { 200010 };
const ll MOD { 1000000007 }, oo { 1LL << 62 };

ll solve(int N, const vector<ll>& xs)
{
    return 0;
}

int main()
{
    ios::sync_with_stdio(false);

    int N;
    cin >> N;

    cout << (N + 1)/2 << '\n';

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; ++i)
#define ll long long
template <typename T>
bool PN(T x){ if (x <= 1) return false; if (x == 2) return true; for (int i = 2; i < sqrt(x) + 1; i++) if (x % i == 0) return false; return true;}

const ll MOD = 1e9+7;
long long Comb(int n, int i){long long ans = 1; if(i>n || i < 0) return 0; if(i == 0 || i == n) return 1; else {for(int j = 1; j <= i; ++j){ans *=(n+1-j); ans /= j; ans %= MOD;} }return ans;}
template<typename T> T gcd(T a, T b){if(b == 0) return a;else return gcd(b, a%b);}
template<typename T> T lcm(T a, T b){if(b > a) swap(a, b); T g = gcd(a, b);return a / g * b;}

void solve(){
  int n; cin >> n;
  ll a[n];
  ll sums[n];
  ll sum = 0;
  rep(i, n) {
    cin >> a[i];
    sum += a[i];
  }
  rep(i, n){
    if(i == 0) sums[i] = sum - a[i];
    else {
      sums[i] = sums[i-1] -a[i];
    }
  }
  ll ans = 0;
  rep(i, n){
    sums[i] %= MOD;
    a[i] %= MOD;
    ans += a[i] * sums[i];
    ans %= MOD;
    // cout << sums[i] << endl;
  }
  cout << ans << endl;
}

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


Measured memory_bytes: 6760