akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include<stdio.h>
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <stack>
#include <queue>
#include<map>
#include <set>
#include<math.h>
using namespace std;
#define int long long
#define ll long long
#define rep(i,n) for(ll i=0;i<n;++i)
#define Rep(i,n) for(ll i=1;i<=n;++i)
#define loop(i,m,n) for(ll i=m;i<n;++i)
#define ggr getchar(); getchar();return 0;
#define pie 3.141592653589793238462643383279
#define elif else if
#define P pair<ll,ll>
#define prique priority_queue<ll>
#define all(a)  (a).begin(),(a).end()
const int mod = 1000000007;
const int mod2 = 998244353;
int bin(int bina) {
	int ans = 0;
	for (int i = 0; bina > 0; i++)
	{
		ans = ans + (bina % 2) * pow(10, i);
		bina = bina / 2;
	}
	return ans;
}
bool prime(int n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n % i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x,y)* mod_pow(kai(y,y), mod - 2, mod) % mod;
}
int per(int n, int r) {
	r = n - r;
	int sum = 1;
	int i;
	for (i = n; i >= r + 1; i--)sum *= i;
	return sum;
}
struct UnionFind {
	vector<int> par;

	UnionFind(int n) : par(n, -1) { }

	int root(int x) {
		if (par[x] < 0) return x;
		else return par[x] = root(par[x]);
	}

	bool issame(int x, int y) {
		return root(x) == root(y);
	}

	bool merge(int x, int y) {
		x = root(x); y = root(y);
		if (x == y) return false;
		if (par[x] > par[y]) swap(x, y);
		par[x] += par[y];
		par[y] = x;
		return true;
	}

	int size(int x) {
		return -par[root(x)];
	}
};
P a[100010];
priority_queue<int> que;
signed main() {
	int n, m;
	cin >> n >> m;
	rep(i, n) {
		cin >> a[i].first >> a[i].second;
	}
	sort(a, a + n);
	int s = 0,ans=0;
	Rep(i, m) {
		while (s < n&&a[s].first==i) {
			que.push(a[s].second);
			s++;
		}
		int sum = 0;
		if (que.size()) {
			sum = que.top();
			que.pop();
		}
		ans += sum;
	}
	cout << ans << endl;
}


Measured memory_bytes: 2936
n,S,r=int(input()),input(),0
dp1=[0]*n
dp2=[0]*n
d=set()
for i, c in enumerate(S):
    dp1[i] = len(d)
    d.add(c)

cs = [0 for i in range(10)]
d=set()
for i, c in enumerate(S[::-1]):
    dp2[i] = len(d)
    r += dp1[n-i-1]*(dp2[i]-dp2[cs[int(c)]])
    d.add(c)
    cs[int(c)] = i
print(r)


Measured memory_bytes: 3572
from itertools import permutations

n, c = [int(_) for _ in raw_input().split()]
d = [[int(_) for _ in raw_input().split()] for __ in xrange(c)]
st = [[0] * c for _ in range(3)]
for y in xrange(n):
    for x, g in enumerate(raw_input().split()):
        g = int(g) - 1
        st[(x + y) % 3][g] += 1


ds = [[
    sum(st[m3][oldc] * d[oldc][newc] for oldc in xrange(c))
    for newc in xrange(c)] for m3 in range(3)]

p = None
for c1, c2, c3 in permutations(range(c), 3):
    np = ds[0][c1] + ds[1][c2] + ds[2][c3]
    p = np if p is None else min(np, p)

print p


Measured memory_bytes: 2696
// -*- coding:utf-8-unix -*-

use proconio::input;

fn main() {
    input! {
        mut x: u8,
        mut y: u8,
        mut z: u8,
    }

    let mut tmp = x;
    x = y;
    y = tmp;

    tmp = x;
    x = z;
    z = tmp;

    println!("{} {} {}", x, y, z);
}


Measured memory_bytes: 2076
S = input()

def is_kaibun(s):
    return s[:len(s)//2] == s[:(len(s)-1)//2:-1]

flg = is_kaibun(S) and is_kaibun(S[:len(S)//2]) and is_kaibun(S[:len(S)//2:-1])

print('Yes' if flg else 'No')

Measured memory_bytes: 61860
#include <bits/stdc++.h>
#include <queue>
#include <string>
#include <algorithm>

using namespace std;

int gcd(int a, int b) {
    if (b==0) return a;
    else return gcd(b, a%b);
}


#define rep(i, n) for (int i = 0; i < n; i++)
#define rep1(i, n) for (int i = 1; i < n + 1; i++)
#define repr(i, n) for (int i = n - 1; i >= 0; i--)
#define repr1(i, n) for (int i = n; i > 0; i--)
#define FOR(i, j, n) for (int i = j; i < n; i++)
typedef long long ll;
const ll MOD = 1000000007;

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

    int64_t power=1;
    rep1(i,n){
        power *= i;
        power %= MOD;
    }

    cout << power%MOD << endl;

}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <sstream>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <numeric>
#include <cctype>
//#include <tuple>
//#include <array>

// BEGIN CUT HERE
#ifdef _MSC_VER
#include <agents.h>
#endif
// END CUT HERE 

#define FOR(i, a, b) for(int i = (a); i < (int)(b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define ALL(v) begin(v), end(v)
#define REV(v) rbegin(v), rend(v)
#define MEMSET(v, s) memset(v, s, sizeof(v))
#define MP make_pair
#define MT make_tuple
#define X first
#define Y second

using namespace std;

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

struct UnionFind{
	vector<int> par, sz;
	UnionFind(int n){
		par = sz = vector<int>(n);
		for (int i = 0; i < n; ++i) par[i] = i, sz[i] = 1;
	}
	int find(int x){
		if (x == par[x]) return x;
		return par[x] = find(par[x]);
	}
	void unite(int x, int y){
		x = find(x), y = find(y);
		if (x == y) return;
		par[x] = y;
		sz[y] += sz[x];
	}
	bool same(int x, int y){
		return find(x) == find(y);
	}
	int size(int x){
		return sz[find(x)];
	}
};

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

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

	int n;
	while (cin >> n, n){
		UnionFind uf(n * 4);
		const int N = n * 2;
		map<P, int> m;
		int id = 0;
		rep(i, n){
			int x, y;
			char c;
			cin >> x >> y >> c;
			int nx = x, ny = y;
			if (c == 'x') ++nx;
			else ++ny;
			m[MP(x, y)] = id++;
			m[MP(nx, ny)] = id++;
		}
		for (auto dat : m){
			P pos = dat.first;
			int id = dat.second;
			rep(i, 4){
				int nx = pos.first + dx[i], ny = pos.second + dy[i];
				if (!m.count(MP(nx, ny))) continue;
				int adj = m[MP(nx, ny)];
				if (id / 2 == adj / 2){
					uf.unite(id, adj + N);
					uf.unite(id + N, adj);
				}
				else{
					uf.unite(id, adj);
					uf.unite(id + N, adj + N);
				}
			}
		}

		bool ok = true;
		rep(i, N){
			if (uf.same(i, i + N)) ok = false;
		}
		cout << (ok ? "Yes" : "No") << endl;
	}



	return 0;
}

Measured memory_bytes: 4492
#include <stdio.h>

int main()
{
	int n, t[101] = { 0 };
	int i, j;
	int a, b, at, bt, p[101] = { 0 };
	scanf("%d", &n);
	for (i = 0;i <( n*(n - 1) / 2);i++) {
		scanf("%d%d%d%d", &a, &b, &at, &bt);
		if (at > bt) { t[a] += 3; }
		else if (bt > at) { t[b] += 3; }
		else if (at == bt) { t[a] += 1;t[b] += 1; }
	}
	for (i = 1;i <= n;i++) {
		for (j = 1;j <= n;j++) {
			if (t[i] < t[j])p[i]++;
		}
		printf("%d\n", p[i]+1);
	}
	return 0;
}

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

int main()
{
  int n,i;
  scanf("%d",&n);
  long long int a[n];
  for(i=0;i<n;i++)
  {
    scanf("%lld",&a[i]);
  }
  sort(a,a+n);
  if(n==2)
  {
      printf("%lld",a[1]);
  }
  else
  {
  long long int sum=0;
  i=1;
  sum+=a[n-1];
  int j=2;
  while(i<n-1)
  {
      if((i+1)<(n-1))
      {
          sum+=(2*a[n-j]);
          j++;
          i=i+2;
      }
      else
      {
          sum+=a[n-j];
          break;
      }
      
  }
  printf("%lld",sum);
  }
  
 
}


Measured memory_bytes: 5368
#include <iostream>
using std::cin;
using std::cout;

void shell_sort(unsigned a[], unsigned n){
  const unsigned gaps[] = {1,8,23,77,281,1073,4193,16577,65921,262913,1050113};
  // pow(4,i)+3*pow(2,i-1)+1 (prefixed with 1)

  unsigned gap_num = 11, count = 0;
  while(gaps[--gap_num] > n);

  for(int i = gap_num+1; i; i--){
    unsigned gap = gaps[i-1];
    for(unsigned j = gap; j < n; j++){
      unsigned v = a[j];
      int k = j - gap;
      while(k >= 0 && a[k] > v){
        a[k+gap] = a[k];
        k -= gap;
        count++;
      }
      a[k+gap] = v;
    }
  }

  cout << (gap_num+1) << '\n';

  for(; gap_num; gap_num--) cout << gaps[gap_num] << ' ';
  cout << gaps[0] << '\n';

  cout << count << '\n';
}

int main(){
  std::ios::sync_with_stdio(false);
  cin.tie(0);
  unsigned n,i;
  cin >> n;
  auto a = new unsigned[n];
  for(i = 0; i < n; i++) cin >> a[i];
  shell_sort(a,n);
  for(i = 0; i < n; i++) cout << a[i] << '\n';
  delete[](a);
}

Measured memory_bytes: 4956
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF  9223300000000000000
#define LINF2 1223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
//const long long MOD = 998244353;

using namespace std;


void solve()
{
    int n;
    scanf("%d", &n);
    map<int, int> cnt;
    int i;
    for (i = 0; i < n; i++) {
        int tmp;
        scanf("%d", &tmp);
        cnt[tmp]++;
    }
    vector<int> z0, z1;
    auto it = cnt.begin();
    for (; it != cnt.end(); ++it) {
        if (it->second >= 4) z1.push_back(it->first);
        if(it->second>=2) z0.push_back(it->first);
    }
    ll ans = -LINF;
    if(!z1.empty()){
        sort(z1.rbegin(), z1.rend());
        int tmp = z1[0];
        ans = (ll)tmp * tmp;
    }
    if (z0.size() > 1) {
        sort(z0.rbegin(), z0.rend());
        ans = MAX(ans, (ll)z0[0] * z0[1]);
    }
    if (ans < 0) {
        printf("0\n");
    }
    else {
        printf("%lld\n", ans);
    }
    return;
}

int main(int argc, char* argv[])
{
#if 1
    solve();
#else
    int T; scanf("%d", &T);
    while(T--) {
        solve();
    }
#endif
    return 0;
}


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

int main(){
  int n, m, x;
  int a[40] = {0};
  cin >> n >> m;
  
  for(int i = 0; i < n; i++){
    int k;
    cin >> k;
    for(int j = 0; j < k; j++){
      cin >> x;
      a[x] += 1;
    }
  }
  int ans = 0;
  for(int i = 0; i < 35; i++){
    if(a[i] == n){
      ans ++;
    }
  }
  cout << ans << endl;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define pb emplace_back
#define pob pop_back()
#define ff first
#define ss second
typedef long long int ll;
#define vll vector<ll>
#define vpll vector<pair<ll,ll>>
#define vvll vector<vector<ll>>
#define pll pair<ll,ll>
#define prq priority_queue<ll>
#define psq priority_queue<ll,vector<ll>,greater<ll>>
#define m_p make_pair
#define vcc vector<char>
#define vss vector<string>
#define bs binary_search
#define lb lower_bound
#define ub upper_bound
#define test ll t; cin>>t; while(t--)
main()
{
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	#endif
	
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    ll n,i,j,k;
    cin>>i>>j;
    k=i*j;
      cout<<k;
    
}

Measured memory_bytes: 3652
n,k=map(int,input().split())
sunu=[0]*n
for i in range(k):
    d=int(input())
    a=list(map(int,input().split()))
    for j in range(d):
        sunu[a[j]-1]+=1
ans=0
for i in range(len(sunu)):
    if sunu[i]==0:
        ans+=1
print(ans)                

Measured memory_bytes: 9104
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
const ll inf = (ll)1e9 + 7;
int main()
{
    ll i, j, k;
    char s[105], r[105];
    cin >> s;
    k = strlen(s);
    ll f = 0;
    ll n = k;
    for (i = 0; i < n; i++)
    {
        if (s[i] != s[n - 1 - i])
            f = 1;
    }
    j = k / 2 - 1;
    for (i = 0; i <= j; i++)
    {
        if (s[i] != s[j - i])
            f = 1;
    }
    //cout << f << k << n;
    j = k / 2 + 1;
    for (i = j; i < n; i++)
    {
        if (s[i] != s[n - 1 - i])
            f = 1;
    }
    if (f == 0)
        cout << "Yes";
    else
    {
        cout << "No";
    }
    return 0;
}

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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}

using ll=long long;
using R=long double;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

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

// Problem Specific Parameter:
ll n,w,h,k;
bool bomb[55][55];

inline int query(int a,int b,int c,int d){
	cout << "? " <<  a << " " << b << " " << c-1 << " " << d-1 << endl << flush;
	int ret;
	cin >> ret;
	return ret;
}

inline int rec(int a,int b,int c,int d,int rest){
	if(c<=a or d<=b) return 0;
	if(rest==0) return 0;
	//cout << a << " " << b << " " << c << " " << d << endl;
	
	const int area=(c-a)*(d-b);
	int res=query(a,b,c,d);
	if(res==0) return 0;
	if(res==area){
		rep(y,a,c)rep(x,b,d) bomb[y][x]=true;
		return area;
	}
	chmin(rest,res);

	const int ym=(a+c)/2,xm=(b+d)/2;
	rest-=rec(a,b,ym,xm,rest);
	rest-=rec(ym,b,c,xm,rest);
	rest-=rec(a,xm,ym,d,rest);
	rest-=rec(ym,xm,c,d,rest);
	return rest;
}

int main(void){
	cin >> h >> w >> n >> k;
	rec(0,0,h,w,n);
	
	ll ans=0LL,cur=1LL;
	rep(i,h)rep(j,w){
		if(bomb[i][j]) ans=(ans+cur)%k;
		cur=(2LL*cur)%k;
	}

	cout << "! " << ans << endl  << flush;
	return 0;
}

Measured memory_bytes: 596
#include "stdio.h"
int main()
{
	int a,b,c;
	//printf("1<=ai<=13\n");
	scanf("%d %d %d",&a,&b,&c);
	if(a+b+c>=22)
	{
		printf("bust");
	}
	else
	{
		printf("win");
	}
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
const int MAXN=100010;
int n,ans;
char s[MAXN];
int main () {
	scanf("%d%s",&n,s+1);
	for (int i=1;i<=n;i++) {
		if (i==1||s[i]!=s[i-1]) {ans++;}
	}
	printf("%d\n",ans);
}

Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <cstdio>
#define rep(i,n) for(int i = 0; i < n; ++i)
#define rep1(i,n) for(int i = 1; i <= n; ++i)
#define F first
#define S second
using namespace std;
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(a > b){ a = b; return 1; } return 0; }
using ll = long long;
using pi = pair<int,int>;
int main()
{
  int n; cin >> n;
  vector<string> a(n);
  rep(i,n) {
    cin >> a[i];
  }
  vector<ll> b(n, 0);
  rep(i,n) {
    ll cnt = 0;
    bool f = false;
    rep(j,a[i].size()) {
      if(a[i][j] == '.') {
	f = true;
      }
      else {
	b[i] += (ll)a[i][j] - '0';
	b[i] *= (ll)10;	
	if(f) {
	  cnt++;
	}
      }
    }
    b[i] *= pow((ll)10, 8 - cnt);
  }
  
  //  rep(i,n) cout << b[i] << "\n";

  using vl = vector<ll>;
  using vll = vector<vl>;
  vll d(19, vl(19, 0));
  rep(i,n) {
    ll cnt2 = 0;
    while(b[i] % 2 == 0) {
      cnt2++;
      b[i] /= 2;
    }
    ll cnt5 = 0;
    while(b[i] % 5 == 0) {
      cnt5++;
      b[i] /= 5;
    }
    cnt2 = min((ll)18, cnt2);
    cnt5 = min((ll)18, cnt5);
    d[cnt2][cnt5]++;
  }

  // rep(i,19) cout << i << " ";
  // cout  << "\n";
  // rep(i,19) {
  //   cout << i << " ";
  //   rep(j,19) {
  //     cout << d[i][j] << " ";
  //   }
  //   cout << "\n";
  // }
  
  
  ll res = 0;
  rep(i,19) rep(j,19) rep(k,19) rep(l,19) {
    if(i == k && j == l) {
      if(i >= 9 && j >= 9) {
	res += d[i][j] * (d[i][j] - 1);
      }
    }
    else {
      if(i + k >= 18 && j + l >= 18) res += d[i][j] * d[k][l];
    }
  }
  cout << res/2 << "\n";
  return 0;
}


Measured memory_bytes: 11012
/*
    Author: Nguyen Tan Bao
    Status:
    Idea:
*/
 
#include <bits/stdc++.h>
#define FI first
#define SE second
#define EPS 1e-9
#define ALL(a) a.begin(),a.end()
#define SZ(a) int((a).size())
#define MS(s, n) memset(s, n, sizeof(s))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
//__builtin_ffs(x) return 1 + index of least significant 1-bit of x
//__builtin_clz(x) return number of leading zeros of x
//__builtin_ctz(x) return number of trailing zeros of x
 
using namespace std;
using ll = long long;
using ld = double;
typedef pair<int, int> II;
typedef pair<II, int> III;
typedef complex<ld> cd;
typedef vector<cd> vcd;
 
const ll MODBASE = 1000000007LL;
const int MAXN = 110;
const int MAXM = 1000;
const int MAXK = 16;
const int MAXQ = 200010;

int n;
map<int, int> ma;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    cin >> n;
    FOR(i,1,n) {
        int x;
        cin >> x;
        ma[x]++;
    }
    FORALL(it, ma) {
        if (it->SE > 1) {
            cout << "NO";
            return 0;
        }
    }
    cout << "YES";
    return 0;
}


Measured memory_bytes: 9600
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        ArrayList<Integer> edges[]=new ArrayList[n];
        long[] pairs=new long[n-1];
        int[] pcol=new int[n];
        for(int i=0;i<n-1;i++){
            int a=sc.nextInt()-1, b=sc.nextInt()-1;
            if(edges[a]==null) edges[a]=new ArrayList<Integer>();
            edges[a].add(b);
            pairs[i]=(long)a*n+b;
        }
        sc.close();
        HashMap<Long, Integer> colors=new HashMap<>();
        int dim=0;
        for(int v=0;v<n;v++){
            if(edges[v]==null) continue;
            int c=0;
            for(int u:edges[v]) colors.put((long)v*n+u, pcol[u]=pcol[v]==++c?++c:c);
            if(c>dim) dim=c;
        }
        System.out.println(dim);
        for(int i=0;i<n-1;i++) System.out.println(colors.get(pairs[i]));
    }
}

Measured memory_bytes: 103044
//Author: Fuadul Hasan(fuadul202@gmail.com)
#include<bits/stdc++.h>
using namespace std;

#define ll long long
const int N   = 2e5 + 5;

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

	int x = ((c/a) * b)	;
	cout<<x<<endl;


	

	return 0;
}

Measured memory_bytes: 3632
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <vector>

#define mod 1000000007
#define INF2 9999999999
#define INF (1 << 30)
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)

using namespace std;
using ll = __int64_t;

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

bool comp(const pair<int, ll>& p1, const pair<int, ll>& p2){
    return p1.second > p2.second;
}

int h, w;
char s[2000][2000];
int L[2000][2000], R[2000][2000], D[2000][2000], U[2000][2000];

void solve(){
    cin >> h >> w;
    int res=0;
    rep(i, h){
        rep(j, w){
            cin >> s[i][j];
        }
    }
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            if(s[i][j] == '#'){
                L[i][j] = 0;
            }else if(j == 0){
                L[i][j] = 1;
            }else{
                L[i][j] = L[i][j-1] + 1;
            }
        }
    }
    for(int i = 0; i < h; i++){
        for(int j = w-1; j >= 0; j--){
            if(s[i][j] == '#'){
                R[i][j] = 0;
            }else if(j == w-1){
                R[i][j] = 1;
            }else{
                R[i][j] = R[i][j+1] + 1;
            }
        }
    }
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            if(s[i][j] == '#'){
                U[i][j] = 0;
            }else if(i == 0){
                U[i][j] = 1;
            }else{
                U[i][j] = U[i-1][j] + 1;
            }
        }
    }
    for(int i = h-1; i >= 0; i--){
        for(int j = 0; j < w; j++){
            if(s[i][j] == '#'){
                D[i][j] = 0;
            }else if(i == h-1){
                D[i][j] = 1;
            }else{
                D[i][j] = D[i+1][j] + 1;
            }
        }
    }
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            res = max(res, L[i][j]+R[i][j]+U[i][j]+D[i][j]-3);
        }
    }
    cout << res << endl;
}

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

Measured memory_bytes: 66688
#include<bits/stdc++.h>
typedef long long ll;
#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=ll(b);i--)
#define ALL(x) x.begin(),x.end()

#define INF (int)1e9 //10^9:∞
#define LLINF (long long)1e12
#define MOD (int)1e9+7 //10^9+7:合同式の法
#define PI 3.141592653589

#define YESNO(T) if(T){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define yesno(T) if(T){cout<<"yes"<<endl;}else{cout<<"no"<<endl;}
#define YesNo(T) if(T){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}

#define Graph vector<vector<int>>
#define PII pair<int,int>
#define VI vector<int>
#define VVI vector<vector<int>>
#define VPII vector<pair<int,int>>

#define DDD fixed<<setprecision(10)

typedef  long long INT;

using namespace std;
/*........................................Define functions.........................................*/


/*....................................Define global variables .....................................*/



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

	string S;
	cin >> S;

	int res = 0;
	REP(i, S.size()) { //0スタート
		if (i % 2 == 0 && S[i] == '0')continue;
		else if (i % 2 == 0 && S[i] == '1')res++;

		if (i % 2 == 1 && S[i] == '1')continue;
		else if (i % 2 == 1 && S[i] == '0')res++;
	}
	int res2 = 0;
	REP(i, S.size()) { //0スタート
		if (i % 2 == 0 && S[i] == '1')continue;
		else if (i % 2 == 0 && S[i] == '0')res2++;
		if (i % 2 == 1 && S[i] == '0')continue;
		else if (i % 2 == 1 && S[i] == '1')res2++;
	}

	int ans = min(res, res2);
	cout << ans << endl;













	return 0;
}




Measured memory_bytes: 3664
stdin = [input() for i in range(3)]
line = stdin[0].split(' ')
A = int(line[0])
V = int(line[1])
line = stdin[1].split(' ')
B = int(line[0])
W = int(line[1])
T = int(stdin[2])
length = 0
if B > A:
    length = B-A
else:
    length = A-B
if (V-W)*T < length:
    print('NO')
else:
    print('YES')

Measured memory_bytes: 9212
use std::io;

fn main() {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();

    let v: Vec<_> = buf.split_whitespace().collect();
    for i in 0..2 {
        if v[i].chars().last() != v[i+1].chars().nth(0) {
            println!("NO");
            return
        }
    }

    println!("YES");
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
int main() {
int s;
cin>>s;
int counter=1;
int counter1=0;
int a[s];
for(int i=0;i<s;i++){
cin>>a[0];
if(a[0]==counter){
counter++;
counter1--;}
counter1++;}
if(counter==1)
cout<<-1<<endl;
else
cout<<counter1<<endl;}


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

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


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

 vector<pair<int,int>> path(m);
 vector<int> point(n);

 rep(i,n){
     point.at(i)=1+i;
 }

rep(i,m){
    int a,b;
    cin>>a>>b;
    path.at(i)=make_pair(a,b);
}

sort(path.begin(),path.end());
sort(point.begin(),point.end());

int sum=0;
do{
    if(point.at(0)==1){
        bool is_all_path=false;
        for (int i=0;i<n-1;i++){
            bool is_thispath=false;
         for(int j=0;j<m;j++){
             if(path.at(j).first==point.at(i)&&path.at(j).second==point.at(i+1)||
             path.at(j).second==point.at(i)&&path.at(j).first==point.at(i+1)){
                is_thispath=true;
                break;

             }
            }
            if(!is_thispath){
            is_all_path=false;
            break;
        
            }
            else{
            is_all_path=true;

            }
    
        }
        if(is_all_path){
        sum++;

        }
    }
}while(next_permutation(point.begin(),point.end()));
  cout<<sum<<endl;
}


Measured memory_bytes: 256
// input! macro is published in the following URLs.
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
// https://github.com/tanakh/competitive-rs.git
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: usize,
        mut x: i64,
        ms: [i64; n],
    }
    x -= ms.iter().fold(0, |sum, i| sum + i);
    let ans = n as i64 + x / ms.iter().min().unwrap();
    println!("{}", ans);
}


Measured memory_bytes: 4352
//__n1colai__
#include <bits/stdc++.h>
#include<stdint.h>
using namespace std;
#define vi vector<int>
#define pb emplace_back
#define w(t)   int t;cin>>t;while(t--)
#define show(ar) for(int i=0;i<ar.size();i++) cout<<ar[i]<<" "; cout<<endl;
#define mod 1e9+7
#define ff first
#define ss second
#define fio ios::sync_with_stdio(false); std::cin.tie(NULL); std::cout.tie(NULL);
#define all(x) (x.begin(),x.end())
#define inf 1e9+7
#define MAX 90000000
#define ll long long

vi inp(int n)
{
	vi v; int x;
	for(int i=0;i<n;i++) {
		cin>>x; v.pb(x);
	}
	return v;
}


int main()
{
	fio
	int n; cin>>n;
	ll sum=0;
	map<ll,ll> mp;
	for(int i=0;i<n;i++){
		ll x; cin>>x;
		sum+=x; mp[x]++;
	}
	int q; cin>>q;
	while(q--){
		ll b,c; cin>>b>>c;
		ll t=mp[b];
		sum=sum+(c-b)*t;
		mp[c]+=t; mp[b]-=t;
		cout<<sum<<endl;
	}
	return 0;
}


Measured memory_bytes: 9456
#include <stdio.h>

int p[10001];

int main(void)
{
  	unsigned i,k, n;
  	for (i = 0; i < 10000; i++){
   		p[i] = 1; 
 	}
	p[0] = 0;   
 
 	for (i = 2; i*i <= 10000; i++) {
    	if (p[i] == 1) {
     		for (k = 2*i; k <=10000 ; k += i){
        		p[k] = 0;  
  			}
		}
	}
	
	while(1){
		scanf("%d" , &n);
		if(n == 0)
			break;
		for(i = n ; i > 1;i--){
			if(p[i]*p[i -2] ==1)
				break;
		}
			if(n >= 5)
				printf("%d %d\n",i-2,i);
	}
		return 0;
}

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

int main()
{
    ll A;
    float B;
    cin >> A >> B;
    cout << (A * (ll)( B * 100 + 0.1) )/ 100 << endl;
    return 0;
}

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

LL dp[MAXN]; // O(w) version

int main()
{
	ios::sync_with_stdio(false);
	
	int n, w, wei, val;
	cin >> n >> w;
	
	fill(dp, dp+MAXN, LLONG_MAX-10000000000000);
	
	dp[0] = 0;
	
	for (int i = 1; i <= n; i++)
	{
		cin >> wei >> val;
		
		for (int j = MAXN-1; j >= val; j--)
		{
			dp[j] = min(dp[j], dp[j-val]+wei);
		}
	}

    /*for (int i = 0; i < MAXN; i++)
    {
    	cout << dp[i] << " ";
	}
	cout << "\n";*/
	
	//cout << *min_element(dp[n]+1, dp[n]+MAXN) << "\n";
	
	/*for (int i = 103; i >= 0; i--)
	{
		for (int j = MAXN-1; j >= 0; j--)
		{
			if (dp[i][j] < w)
			{
				cout << j << "\n";
				exit(0);
			}
		}
	}*/
	
	for (int i = MAXN-1; i >= 0; i--)
	{
		if (dp[i] <= w){
			cout << i << "\n"; exit(0);
		}
	}
	assert(0);
}

Measured memory_bytes: 1024
mod = 10**9 + 7

def modpow(a, n, mod):
    res = 1
    while(n>0):
        if(n&1):
            res = res * a % mod
        a = (a**2) % mod
        n >>= 1
    return res

def modinv(a, mod):
    return modpow(a, mod-2, mod)

N, A, B = [int(i) for i in input().split()]
A = min(A, N-A)
B = min(B, N-B)
ext_A = 1
ext_B = 1
for ind, a in enumerate(range(N, N-A, -1)):
    ext_A *= a
    ext_A *= modinv(ind+1, mod)
    ext_A %= mod

for ind, b in enumerate(range(N, N-B, -1)):
    ext_B *= b
    ext_B *= modinv(ind+1, mod)
    ext_B %= mod

print((modpow(2, N, mod) - 1 -ext_A - ext_B)%mod)


Measured memory_bytes: 42092
N , K = map(int,input().split(" "))
A = list(map(int,input().split(" ")))

ans = 0
num = {}
key = 0
for i in A:
	if i in num:
		num[i] += 1
	else:
		num[i] = 1
		key += 1

if key - K <= 0:
	print("0")
	exit(0)

num2 = sorted(num.items(), key=lambda x:x[1])
for i in range(key-K):
	ans += num2[i][1]

print(ans)






Measured memory_bytes: 38964
#define _USE_MAT_DEFINES
#include<iostream>
#include <iomanip>
#include<stdio.h>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include <queue>
#include <utility>
#include <map>
#include <set>
#include <deque>
#include <numeric>
#include <functional>
using namespace std;

#define INF 1e9



//右,下,左,上,の順番で埋めていく
int dirX[4] = { 0,+1,0,-1 };
int dirY[4] = { +1,0,-1,0 };

int main() {
    int H, W, N;
    cin >> H >> W >> N;

    vector<vector<int>>ans(H+2, vector<int>(W+2, -1));
    for (int i = 1; i <= H; i++) {
        for (int j = 1; j <= W; j++) {
            ans[i][j] = 0;
        }
    }

    int x = 1, y = 1;
    int dir = 0;
    for (int i = 1; i <= N; i++) {
        int a;
        cin >> a;

        while (a != 0) {
            ans[x][y] = i;//塗る
            int next_x = x + dirX[dir], next_y = y + dirY[dir];
            if (ans[next_x][next_y] != 0) {
                dir = (dir + 1) % 4;
                x += dirX[dir];
                y += dirY[dir];
            }
            else {
                x = next_x;
                y = next_y;
            }
            a--;
        }
    }

    for (int i = 1; i <= H; i++) {
        for (int j = 1; j <= W; j++) {
            cout << ans[i][j] << " ";
        }
        cout << endl;
    }



    return 0;
}

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


int main() {

	priority_queue<long long> qu;
	
	string order;
	
	while(cin >> order){
		if(order == "end"){
			break;
		}else if(order == "insert"){
			long long num;
			cin >> num;
			qu.push(num);
		}else{
			cout << qu.top() << endl;
			qu.pop();
		}
	}

	return 0;
}


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

using namespace std;

typedef long long ll;

#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=b-1LL;i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;

#define MOD 1000000007

int main(){
  ll n;
  cin>>n;
  if(n==1){
    cout << "Hello World" << endl;
  }
  else{
    ll a,b;
    cin>>a>>b;
    cout << a+b << endl;
  }
  return 0;
}

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

using namespace std;

#define uint unsigned int
#define llong long long int
#define ullong unsigned long long int
#define rep(i, n) for (int i = 0; i < n; ++i)

int main (int argc, char *argv[]) {
    cin.tie(0);
    ios::sync_with_stdio(false);

    int Q, H, S, D, N;
    cin >> Q >> H >> S >> D >> N;

    vector<llong> L05, L1, L2;
    L05.push_back(H);
    L05.push_back(Q * 2);
    llong min_L05 = *min_element(L05.begin(), L05.end());

    L1.push_back(S);
    L1.push_back(min_L05 * 2);
    L1.push_back(min_L05 + Q * 2);
    L1.push_back(Q * 4);
    llong min_L1 = *min_element(L1.begin(), L1.end());

    L2.push_back(D);
    L2.push_back(min_L1 * 2);
    L2.push_back(min_L1 + min_L05 * 2);
    L2.push_back(min_L1 + min_L05 + Q * 2);
    L2.push_back(min_L1 + Q * 4);
    L2.push_back(min_L05 * 4);
    L2.push_back(min_L05 * 3 + Q * 2);
    L2.push_back(min_L05 * 2 + Q * 4);
    L2.push_back(min_L05 + Q * 6);
    L2.push_back(Q * 8);
    llong min_L2 = *min_element(L2.begin(), L2.end());
    
    //cout << Q << " " << min_L05 << " " << min_L1 << " " << min_L2 << endl;
    llong ans = 0;
    ans = (N / 2) * min_L2 + (N % 2) * min_L1;

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

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

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

int main(){
int A,B,C,X;
int count =0;
cin >> A >> B >> C >> X;

rep(i,A+1) rep(j,B+1) rep(h,C+1){
 if(500*i + 100 * j + 50 * h == X)count++; 
} 

cout << count << endl;
return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
const int INF = 1 << 30;
const ll INFll = 1ll << 60;
template <typename T>
bool chmax(T& a, const T& b) {
  if (a < b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}
template <typename T>
bool chmin(T& a, const T& b) {
  if (a > b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}

int main() {
  string s;
  cin >> s;
  cout << s[0] << s.size() - 2 << s[s.size() - 1] << endl;
  return 0;
}

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

typedef unsigned long long ll;
#define mod 1000000007
#define all(x) (x).begin(),(x).end()

void solve(){
  string n;
  cin>>n;
  int sum=0;
  for(char c:n)
  	sum += c - '0';

  if(sum%9==0){
  	cout<<"Yes\n";
  }else{
  	cout<<"No\n";
  }
}

int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  solve();
  return 0;
}

Measured memory_bytes: 3784
n = int(input())
t, a = map(int, input().split())
points = map(int, input().split())
result = 0
_min = None
for i, p in enumerate(points):
    temp = t - p * 0.006
    diff = abs(a - temp)
    if _min is None or _min > diff:
        _min = diff
        result = i + 1
print(result)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	int a,b,c;
    char d,e;
  	string s;
  	cin>>a>>b>>c;
	
  
    cout<<max({a+b,a-b,a*b})<<endl;
  
  
 return 0;
}


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

static const int MAX = 100;

int main() {
	int A[MAX], n;

	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> A[i];
	}

	for (int i = 0; i < n; i++) {
		if (i == n - 1) {
			cout << A[i] << endl;
		}
		else {
			cout << A[i] << ' ';
		}

	}


	for (int i = 1; i < n; i++) {
		int v = A[i];
		int j = i - 1;

		while (j >= 0 && A[j] > v) {
			A[j + 1] = A[j];
			j--;
		}
		A[j + 1] = v;

		for (int i = 0; i < n; i++) {
			if (i == n - 1) {
				cout << A[i] << endl;
			}
			else {
				cout << A[i] << ' ';
			}

		}
	}
}


Measured memory_bytes: 3116
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner stdIn = new Scanner(System.in);
		String s = stdIn.next();
		int q = stdIn.nextInt();

		for (int i=0; i<q; i++) {
			String com = stdIn.next();
			int a = stdIn.nextInt();
			int b = stdIn.nextInt();

			if(com.equals("reverse")){
				String rev = s.substring(a,b+1);
				String temp = s.substring(b+1);
				s = s.substring(0,a);
				for (int index=rev.length()-1; index>=0; index--) {
					s += rev.charAt(index);
				}
				s += temp;

			}else if(com.equals("replace")){
				String p = stdIn.next();
				s = s.substring(0,a) + p + s.substring(b+1);

			}else{
				String temp = s.substring(a,b+1);
				System.out.println(temp);
			}
		}
    }
}


Measured memory_bytes: 61860
#include <iostream>
#include<bitset>
#include <string>

using namespace std;

int period(int K, int N) {

	long long int x = K;
	int cnt = 0;

	for (;;) {
		if (x % 2 == 1) { x = (x - 1) / 2; }
		else { x = x / 2 + ((long long int) 1 << (N - 1)); }
		cnt++;
		if (x == K) { break; }
	}
	return cnt;
}

//const int N =12;

int N;
string X;

long long int C[400005];

long long int MOD = 998244353;

long long int NUM(int M) {
	long long int tmp = 0;

	for (int i = 0; i < M; i++) {
		tmp *= 2; tmp %= MOD;
		tmp += X[i] - '0';
	}

	string str;
	str = X.substr(0, M);

	string c_str;
	for (int i = 0; i < (int)str.size(); i++) {
		if (str[i] == '1') { c_str += '0'; }
		else { c_str += '1'; }
	}

	string S;
	int p = 0;
	while (S.size() < X.size()) {
		if (p == 0) { S += str; }
		else { S += c_str; }
		p = (p + 1) % 2;
	}

	//cout << "S= " << S << endl;

	if (S <= X) { tmp++; }

	return tmp%MOD;
}

long long int cnt_X(void) {
	long long int ret = 0;
	for (int i = 0; i <(int) X.size(); i++) {
		ret *= 2; ret %= MOD;
		ret += X[i] - '0';
	}
	return (ret+1)%MOD;
}

int main(void) {

	/*for (int x = 0; x < (1<<N); x++) {
		if (period(x, N) == 2 * N) { continue; }
		cout << x <<" "<< bitset<N>(x)<< " " << period(x, N) << endl;
	}*/

	cin >> N >> X;

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

	for (int P = 2; (P/2)*3 <= N; P += 2) {

		if ((N - (P / 2) * 3) % P != 0) { continue; }

		//cout << "P= " << P << endl;

		int M = P / 2;

		C[P] = NUM(M);

	}

	C[N * 2] = cnt_X();

	/*for (int i = 1; i <= N*2; i++) {
		cout << "C[" << i << "]= " << C[i] << endl;
	}*/

	for (int i = 1; i <= N * 2; i++) {
		if (C[i] >0) {
			for (int j = 2; j*i <= N * 2; j++) {
				if (C[j*i] == -1) { continue; }
				C[j*i] = (C[j*i] - C[i] + MOD) % MOD;
			}
		}
	}

	/*for (int i = 1; i <= N * 2; i++) {
		cout << "C[" << i << "]= " << C[i] << endl;
	}*/

	long long int ans = 0;

	for (int i = 1; i <= N * 2; i++) {
		if (C[i] > 0) { ans += C[i] * i; ans %= MOD; }
	}

	cout << ans << endl;

	return 0;
}

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


int main(){
  string ans, o, e;

  cin >> o >> e;

  for(unsigned int i=0; i<min(o.size(), e.size()); ++i){
    ans += o[i];
    ans += e[i];
  }

  if(o.size() > e.size()){
    ans += o[o.size()-1];
  }else if(o.size() < e.size()){
    ans += e[e.size()-1];
  }

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


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

void trace(int a[], int n)
{
  int i;
  for (i = 0; i < n; i++) {
    if (i > 0) cout << " ";
    cout << a[i];
  }
  cout << endl;
}

int main(void)
{
  int a[3];
  cin >> a[0] >> a[1] >> a[2];
  sort(a, a + 3);
  trace(a, 3);
  return 0;
}

Measured memory_bytes: 1176
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<climits>
#include<string>
#include<vector>
#include<list>
#include<map>
#include<set>
#include<cmath>
#include<queue>
#include<cstring>
using namespace std;

struct Data{
	int n,p;
	Data(int _n,int _p){
		n=_n; p=_p;
	}
	bool operator<(const Data &a)const{
		if(p==a.p) return n>a.n;
		return p<a.p;
	}
};

int cnt[1000000];

int main(){
	priority_queue<Data> pq;
	int N,Q,A,V;
	cin>>N>>Q;
	for(int i=0;i<N;i++) pq.push(Data(i,0));
	for(int i=0;i<Q;i++){
		cin>>A>>V; A--;
		cnt[A] += V;
		pq.push(Data(A,cnt[A]));
		while(cnt[pq.top().n]!=pq.top().p) pq.pop();
		printf("%d %d\n",pq.top().n+1,pq.top().p);
	}
	return 0;
}

Measured memory_bytes: 21516
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <utility>

#include <stdio.h>

#define rep(i, n) for (int i = 0; i < (n); i++)
#define irep(i, k, n) for (int i = (k); i < (n); i++)
#define rrep(i, k, n) for (int i = (k); i >= (n); i++)
#define pb push_back
#define vec vector
#define ref(a) &(a)

const int mod = 1e9 + 7;

typedef long long ll;

using namespace std;

ll n;
vec<ll> a;

string solve() {
  ll fc = 0;
  ll tc = 0;
  ll odd = 0;
  rep(i, n) {
    if (a[i] % 2 == 1) odd++;
    else if (a[i] % 2 == 0 && (a[i] / 2) % 2 == 1) tc++;
    else fc++;
  }
  if (odd + (tc > 0 ? 1 : 0) <= fc + 1) {
    return "Yes";
  } else {
    return "No";
  }
}

int main() {
  cin >> n;
  rep(i, n) {
    ll x; cin >> x;
    a.pb(x);
  }
  cout << solve() << endl;
  return 0;
}

Measured memory_bytes: 1400
#include<random> // random_device mt19937
#include<iostream>
#include<cmath>
using namespace std;
#define df 0

const double pi=acos(-1.0);

random_device rnd;
mt19937 ran_gen(rnd());

double random_arg(){
  return ran_gen()*1.0/ran_gen.max()*2*pi;
}

bool foword(double dx,double dy,int x,int y){
  return dx*x+dy*y>0;
}

long int norm(long int x,long int y){
  return x*x+y*y;
}

int main(){
  if(df) printf("*debug mode*\n");
  int n; cin >> n;
  pair<int,int> engs[n];
  for(auto& eng:engs){
    cin >> eng.first >> eng.second;
  }
  long int max_d=0;
  for(int i=0;i<300;i++){
    double arg=random_arg();
    double dx=cos(arg),dy=sin(arg);
    long int x=0,y=0,temp=0;
    for(auto& eng:engs){
      if(foword(dx,dy,eng.first,eng.second)){
	x+=eng.first;
	y+=eng.second;
	temp=norm(x,y);
	if(max_d<temp){
	  max_d=temp;
	}
      }
    }
  }
  printf("%.15lf",sqrt(max_d));
}

/// confirm df==0 ///

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

#define fs first
#define se second
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define pb emplace_back

using pii = pair<int, int>;
using vi = vector<int>;
using lint = long long;

const int inf = 1001001001;
const lint linf = 1001001001001001001ll;
const int mod = 1e9 + 7;
const int dx[]{0, 1, 0, -1, -1, -1, 1, 1}, dy[]{1, 0, -1, 0, -1, 1, -1, 1};

template<typename T> inline bool chmin(T &a, T b) { if (a > b) { a = b; } return a > b; }
template<typename T> inline bool chmax(T &a, T b) { if (a < b) { a = b; } return a < b; }
template<typename T> inline void print(const T &x, string s = "\n") { cout << x << s; }
template<typename T> inline void print(const vector<T> &v, string s = " ") 
{ rep(i, v.size()) cout << v[i] << (i + 1 == v.size() ? "\n" : s); }
inline bool inside(int y, int x, int H, int W) { return 0 <= y && y < H && 0 <= x && x < W; }
inline lint in() { lint x; std::cin>>x; return x; }

int n, m, q;
int s[2020][2020];
int ei[2][2020][2020];

int v(int y, int x, int yy, int xx) {
	x--; y--;
//	printf("(%d, %d), (%d, %d)\n", x, y, xx, yy);
	return s[yy][xx] - s[yy][x] - s[y][xx] + s[y][x];
}

int e0(int y, int x, int yy, int xx) {
	x--; y--; xx--;
	return ei[0][yy][xx] - ei[0][yy][x] - ei[0][y][xx] + ei[0][y][x];
}

int e1(int y, int x, int yy, int xx) {
	x--; y--; yy--;
	return ei[1][yy][xx] - ei[1][yy][x] - ei[1][y][xx] + ei[1][y][x];
}

void prints() {
	rep(i, n + 1) {
		rep(j, m + 1) {
			cout << s[i][j] << " ";
		}
		puts("");
	}

	rep(k, 2) rep(i, n + 1) {
		rep(j, m + 1) {
			cout << ei[k][i][j] << " ";
		}
		puts("");
	}
}

int main() {
	cin >> n >> m >> q;
	for (int i = 1; i <= n; ++i) {
		for (int j = 1; j <= m; ++j) {
			scanf("%1d", &s[i][j]);
		}
	}

	//prints();

	rep(i, n + 1) rep(j, m) if (s[i][j] && s[i][j + 1]) ei[0][i][j]++;
	rep(j, m + 1) rep(i, n) if (s[i][j] && s[i + 1][j]) ei[1][i][j]++;

	rep(i, n + 1) for (int j = 1; j <= m; ++j) { 
		s[i][j] += s[i][j - 1]; 
		ei[0][i][j] += ei[0][i][j - 1]; 
		ei[1][i][j] += ei[1][i][j - 1];
	}
	rep(j, m + 1) for (int i = 1; i <= n; ++i) {
		s[i][j] += s[i - 1][j]; 
		ei[0][i][j] += ei[0][i - 1][j];
		ei[1][i][j] += ei[1][i - 1][j]; 
	}

//	prints();
	rep(_, q) {
		int a = in(), b = in(), c = in(), d = in();
		//cout << "v : " << v(a, b, c, d) << endl;
		//cout << "e : " << e0(a, b, c, d) + e1(a, b, c, d) << endl;
		cout << v(a, b, c, d) - e0(a, b, c, d) - e1(a, b, c, d) << endl;
	}
}


Measured memory_bytes: 49536
#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;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;

int main(){
	string s;cin>>s;
	vector<int> x(26,0);
	string s1 = "";
	for(int i = 0; i < s.size(); i++) {
		if(s[i] != 'x')s1.pb(s[i]);
	}
	for(int i = 0; i < s1.size(); i++) {
		if(s1[i] != s1[s1.size() - i - 1]){
			cout << -1 << endl;
			return 0;
		}
	}

	int l = 0;
	int r = s.size() - 1;
	vector<char> back;
	int ans = 0;
	while(l != r){
		if(s[l] == s[r]){
			l++;r--;
			if(l > r){
				break;
			}
		}
		else if(s[l] == 'x'){
			l++;
			ans++;
		}
		else{
			r--;
			ans++;
		}
	}
	cout << ans << endl;

	return 0;
}

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

int main() {
    int N;
    cin >> N;
    pair<int,int> max = make_pair(1, 0);

    for (int i=2; i<=N; i+=2) {
        int a = i;
        int counter = 0;
        while (true) {
            if (a%2 == 0) a /= 2;
            else break;
            counter++;
        }
        if (counter > max.second) max = make_pair(i, counter);
    }
    cout << max.first << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  N +=1;
  long long x,y,z;
  x=2;
  y=1;
  
  if(N==1)
  cout << x << endl;
  
  else if(N ==2)
  cout << y << endl;
  
  else {
    for(int i =0; i <N-2; i++){
      z= x+y;
      x=y;
      y=z;
    }
    cout << z << endl;
  }
}

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

int main() {
	string s;
	cin >> s;
	int count = 0;
	if (s[0] == '1') ++count;
	if (s[1] == '1') ++count;
	if (s[2] == '1') ++count;
	cout << count << endl;
}

Measured memory_bytes: 256
N,M,Q=map(int,input().split())
s=[list(map(int, input().split())) for i in range(Q)]
def ju(N,a,l):
    k=[]
    if N==1:
        for i in range(a,M+1):
            k+=[l+[i]]
    else:
        for i in range(a,M+1):
            k+=ju(N-1,i,l+[i])
    return k
l=ju(N,1,[])
a=0
for i in l:
    t=0
    for j in s:
        if i[j[1]-1]-i[j[0]-1]==j[2]:
            t+=j[3]
    if t>a:
        a=t
print(a)

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

using namespace std;


void solve() {
    int s,n;
    cin >> s >> n;
    int sum = 0;
    for (int _ = 0; _ < n; _++) {
        int x; cin >> x;
        sum += x;
    }
    cout << (sum>=s?"Yes":"No");
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    return 0;
}


Measured memory_bytes: 256