akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stdint.h>
#include <inttypes.h>
#include <stdlib.h>

typedef unsigned long long int uint64;
typedef long long int          int64;
 
#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))

void get_N (int64 *n)
{
  int cnt;
  
  cnt = scanf("%lld", n);

  return;
}

void get_NAB (int64 *n, int64 *k, int64 *l)
{
  int cnt;
  
  cnt = scanf("%lld %lld %lld", n, k, l);

  return;
}

void omit_LF (void)
{
  char c;
  
  scanf("%c", &c);
  return;
}

char *get_S (int64 n)
{
  char *buf;
  int  i;

  buf = malloc((size_t)(n * sizeof(char)));
  if (buf == NULL) {
    return NULL;
  }

  for (i=0; i<n; i++) {
    scanf("%c", &buf[i]);
  }

//  if (NULL == fgets(buf, sizeof(buf), stdin)) {
//    return NULL;
//  }
  return buf;
}

char *get_SN (int64 max, int64 *size)
{
  char *buf;
  int  i;
  int  n;

  buf = malloc((size_t)(max * sizeof(char)));
  if (buf == NULL) {
    return NULL;
  }

  scanf("%s", buf);

  n = strlen(buf);

  *size = n;
  
  return buf;
}

int64 *get_NSeq (int64 n)
{
  int64 *buf;
  int64 i;

  buf = malloc((size_t)(n * sizeof(int64)));
  for (i=0; i<n; i++) {
    get_N(&buf[i]);
  }

  return buf;
}

typedef struct _tmp_t {
  int64    a;
  int64    b;
} tmp_t;


int compare_a(const void *a, const void *b)
{
  tmp_t *x;
  tmp_t *y;

  x = (tmp_t *)a;
  y = (tmp_t *)b;

  if (x->a > y->a) return 1;
  if (x->a < y->a) return -1;

  return 0;
}

int compare_b(const void *a, const void *b)
{
  tmp_t *x;
  tmp_t *y;

  x = (tmp_t *)a;
  y = (tmp_t *)b;

  if (x->b > y->b) return 1;
  if (x->b < y->b) return -1;

  return 0;
}

void qsort_a (tmp_t *array, int size)
{
  qsort(array, size, sizeof(tmp_t), compare_a);
}

void qsort_b (tmp_t *array, int size)
{
  qsort(array, size, sizeof(tmp_t), compare_b);
}

int main()
{
  int64 N, A, B, l, bl, al, x;

  get_NAB(&N, &A, &B);

  l = B - A;
  if ((l&1) == 0) {
    l = l/2;
  } else {
    bl = B - 1;
    al = N - A;
    if (bl < al) {
      l = bl;
      x = (A - 1);
    } else {
      l = al;
      x = (N - B);
    }
    if (x < l) {
      l -= x;
      if ((l&1) == 0) {
        l = l/2;
      } else {
        if (l > 1) {
          l++;
          l = l/2;
        }
      }
      l += x;
    }
  }
  // 1 2 3 4 5 6 7 8
  //   A B
  // A B
  // X
  
  // 1 2 3 4 5 6 7 8
  //   A         B
  // A         B
  // A       B
  //   A   B
  //     X
  
  printf("%lld\n", l);

  return 0;
}



Measured memory_bytes: 128
#include<bits/stdc++.h>
#define up(j,k,i) for(i=j;i<k;i++)
#define down(j,k,i) for(i=j;i>k;i--)
#define pp(n) printf("%lld\n",n)
#define pps(n) printf("%lld ",n)
#define all(x) x.begin(),x.end()
#define ps(s) printf("%s",s)
#define is(n) scanf("%lld",&n)
#define ips(n) scanf("%lld",n)
#define ss(s) scanf("%s",s)
#define cool 0
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define f(i) cout<<i<<endl;
#define pll pair<lld,lld> 
#define pi acos(-1)
#ifdef G
#define dg(x) cout<<#x<<' '<<x<<endl;
#define dg2(x,y) cout<<#x<<' '<<x<<' '<<#y<<' '<<y<<endl;
#define dg3(x,y,z) cout<<#x<<' '<<x<<' '<<#y<<' '<<y<<' '<<#z<<' '<<z<<endl;
#define dg4(x,y,z,zz) cout<<#x<<' '<<x<<' '<<#y<<' '<<y<<' '<<#z<<' '<<z<<' '<<#zz<<' '<<zz<<endl;
#else
#define dg(x) ;
#define dg2(x,y) ;
#define dg3(x,y,z) ;
#define dg4(x,y,z,zz) ;
#endif
#define ds(n,m) scanf("%lld %lld",&n,&m)
#define ts(n,m,k) scanf("%lld %lld %lld",&n,&m,&k)
#define yes printf("YES\n")
#define no printf("NO\n")
typedef long double ld;
typedef long long int lld;
using namespace std;
const lld M =1e6+7;
const lld mod=1e9+7;
const lld infi =LLONG_MAX;
lld ans,k,n,x,y,m,mymax=LLONG_MIN,mymin=LLONG_MAX,b,c,z,sum;
vector<lld> v[M];
int main()
{
      ds(n,k);
      lld curr=1;
      while(n--)
      {
        if(curr<=k)
        {
          curr+=curr; 
        }
        else
        {
          curr+=k;
        }
      }
      pp(curr);
        return 0;
}

Measured memory_bytes: 23680
import sys
input = sys.stdin.readline

a = [int(x) for x in input().split()]
cnt = 0
a.sort()
cnt += a[-1] - a[1]
a[0] += cnt
if (a[-1] - a[0]) % 2 == 1:
    cnt += 1
    a[-1] += 1
cnt += (a[-1] - a[0]) // 2
print(cnt)    

Measured memory_bytes: 38256
#include <iostream>

using namespace std;

int main(){
	int thealth, tstr, ahealth, astr;
	cin >> thealth >> tstr >> ahealth >> astr;
	int round = 1;
	while(thealth > 0 && ahealth > 0){
		if(round == 1){
			ahealth = ahealth - tstr;
		}
		else if(round == 2){
			thealth = thealth - astr;
		}
		if(round == 1)
			round = 2;
		else if(round == 2)
			round = 1;
	}
	if(thealth <= 0){
		cout << "No";
	}
	else if(ahealth <= 0){
		cout << "Yes";
	}
	return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define ll long long
#define rep(X,N) for(ll X = 0; X < (N); X++)
#define bitrep(X,N) for(ll X = 0; X < (1 << (N)); X++)
#define PI (acos(-1.0))
#define sorta(V) sort(V.begin(), V.end())
#define pback push_back
#define mpair make_pair
#define MODN 1000000007
#define ALL(V) (V).begin(),(V).end() 


using namespace std;


int main(){

    int a,b;
    cin >> a >> b;

    int ans = a - 1;

    if(b >= a) ans++;

    cout << ans << endl;


    return 0;
}

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

using namespace std;

int my_max(int a, int b) {
    return a > b ? a : b;
}

int my_abs(int x) {
    return x < 0 ? -x : x;
}

int main() {

    int s, w;
    cin >> s >> w;

    if(s-w <= 0) {
        cout << "unsafe" << endl;
    }
    else {
        cout << "safe" << endl;
    }

    return 0;
}


Measured memory_bytes: 3636
import collections
N = int(input())

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

c = collections.Counter(prime_factorize(N))
answer = 0

for i in list(c.keys()):
    n = 1
    a = c[i]
    while a > n*(n+1)/2:
        n += 1
    if a == n*(n+1)/2:
        answer += n
    else:
        answer += n-1

print(answer)

Measured memory_bytes: 9464
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<queue>
#include<cmath>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<stack>
#include<cstdio>
#include<bitset>
#include<unordered_map>
#include<climits>
#include<fstream>
using namespace std;
///////////////////library zone!!!!!!!!!!!!!!!!!!!!!!!!!!!!
typedef long long ll;
typedef long double ld;
#define all(a) (a).begin(),(a).end()
#define EPS (1e-5)
#define bit(n,k) ((n>>k)&1)
const ll Mod = 1000000007;
const ll mod = 998244353;
struct H {
	ll x, y;
	bool operator<(const H &b) const {
		if (x != b.x) return x < b.x;
		return y < b.y;
	}
	bool operator>(const H &b) const {
		if (x != b.x) return x > b.x;
		return y > b.y;
	}
	bool operator==(const H &b) const { return x == b.x&&y == b.y; }
	bool operator!=(const H &b) const { return (*this) != b; }
};
struct P {
	ll pos, cost;
	bool operator<(const P &b) const { return cost < b.cost; }
	bool operator>(const P &b) const { return cost > b.cost; }
};
struct B {
	ll to, cost;
};
struct E {
	ll from, to, cost;
	bool operator<(const E &b) const { return cost < b.cost; }
	bool operator>(const E &b) const { return cost > b.cost; }
};
template<typename T, typename U>
void chmin(T &a, U b) {
	if (a > b) a = b;
}
template<typename T, typename U>
void chmax(T &a, U b) {
	if (a < b) a = b;
}
template<typename T>
T max_0(T a) {
	if (a < 0) return 0;
	return a;
}
template<typename T>
T min_0(T a) {
	if (a > 0) return 0;
	return a;
}
ll read() {
	ll u;
	ll k = scanf("%lld", &u);
	return u;
}
ll gcd(ll i, ll j) {
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcd(j%i, i);
}
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * x % p;
		x = x * x % p;
		n >>= 1;
	}
	return res;
}//x^n%p
vector<string>split(string s, char c = ' ') {
	vector<string>vec;
	string h = "";
	for (int i = 0; i < s.size();) {
		int j = i;
		while (j < s.size() && s[j] != ' ') {
			h += s[j++];
		}
		if (h.size() > 0) vec.push_back(h);
		h = "";
		i = j + 1;
	}
	return vec;
}
const ll Inf = 3023372036854775807;
const int inf = 1500000000;
#define int long long
//----------------------------------------------------
signed main() {
	ld a, b;
	cin >> a >> b;
	cout << a / b << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define mod 1000000007
#define inf 1000000000000000007
#define eps 0.000001
#define pi 3.141592653589793
#define pii pair<int , int>
#define pdd pair<ld,ld>
#define pll pair<ll,ll>
#define ff first
#define ss second
#define vii vector<int>
#define vpl vector<pll>
#define vll vector<ll>
#define sti stack <int>
#define stll stack <ll>
#define mseti set <ll>
#define msetd multiset <ll, greater <ll> >
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound 
#define stp setprecision(20)//use fixed before stp
#define endl '\n'
int main()
{  
    FAST
    string s;
    ll n,d;
    cin>>s>>d;
    n=s.length();
    ll a[n+1][d][10];
    for(ll i=0;i<=n;i++)
    {
        for(ll j=0;j<d;j++)
        {
            for(ll k=0;k<10;k++)
            {
                a[i][j][k]=0;
                if(i==0&&j==0&&k==9)
                    a[i][j][k]=1;
            }
        }
    }
    for(ll i=1;i<=n;i++)
    {
        for(ll j=0;j<d;j++)
        {
            for(ll k=0;k<10;k++)
            {
                ll q=j-k;
                q%=d;
                if(q<0)
                    q+=d;
                a[i][j][k]+=a[i-1][q][9];
                a[i][j][k]%=mod;
            }
        }
        for(ll j=0;j<d;j++)
        {
            for(ll k=1;k<10;k++)
            {
                a[i][j][k]+=a[i][j][k-1];
                a[i][j][k]%=mod;
            }
        }
    }
    ll m=0,ans=0,q;
    for(ll i=n;i>0;i--)
    {
        ll t=(int)(s[n-i])-48;
        q=-m;
        q%=d;
        if(q<0)
            q+=d;
        if(t!=0&&i!=1)
        {
            ans+=a[i][q][t-1];
        }
        if(i==1)
        {
            ans+=a[i][q][t];
        }
        ans%=mod;
        m+=t;
    }
    ans--;
    if(ans<0)
        ans+=mod;
    cout<<ans;
}

Measured memory_bytes: 78464
x, y= map(int,input().split())
ans = 10000000000
if x <= y:
    ans = y-x
if -x <= y:
    ans = min(y+x+1,ans)
if x <= -y:
    ans = min(-y-x+1,ans)
if -x <= -y:
    ans = min(-y+x+2,ans)
print(ans)

Measured memory_bytes: 38384
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7,ohara=1e6+10;
const ll LINF=1e18;
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl
#define doublecout(a) cout<<fixed<<setprecision(15)<<a<<endl;
#define Cerr(x) cerr<<(x)<<endl
#define fi first
#define se second
#define P pair<ll,ll> 
#define m_p make_pair
#define V vector<ll> 
#define U_MAP unordered_map<ll,ll>

ll n,cnt,ans,a,b,c,d,tmp,tmpp,m,h,w,x,y,sum,pos,k,s;
ld doua;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz");
bool fl;
struct edge{int to,cost;};

//-------------------------↓↓↓↓↓↓------------------------

//------ 自分を天才だと信じる ------

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

    cin>>s;
    if(s==1000000000000000000){
        cout<<"0 0 1000000000 0 0 1000000000\n";
    }
    else{
        a=1000000000;
        b=1;
        d=(s%a==0 ? s/a : s/a+1 );
        c=a*d-s;
        cout<<"0 0 "<<a<<" "<<b<<" "<<c<<" "<<d<<"\n";
    }
    return 0;
}


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

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


#define rep(i,n) for(ll (i)=0; (i)<(ll)(n); (i)++)
#define frep(i,m,n) for(ll (i)=(m); (i)<=(ll)(n); (i)++)
#define rrep(i,n) for(ll (i)=(n)-1; (i)>-1; (i)--)
#define frrep(i,m,n) for(ll (i)=(n); (i)>(ll)(m); (i)--)
#define ALL(x) (x).begin(), (x).end()
#define PB(x) push_back(x)
#define MP(x, y) make_pair(x, y)

const ll INF = 100100100100100100;
const ll MOD = 1000000007;

// get abs
ll my_abs(ll a);
// a^n
ll a_n(ll a, ll n);
// get gcd
ll my_gcd(ll a, ll b);
// a^(-1) % MOD 
ll inv(ll a);
// (a+b+c)%MOD
ll madd(ll a, ll b, ll c);
// (a-b)%MOD
ll msub(ll a, ll b);
// (a*b*c)%MOD
ll mtime(ll a, ll b, ll c);


int main() {
    ll s; cin >> s;
    vector<ll> dp(s+1, 0);
    dp[0] = 1;
    for(ll i = 1; i <= s; i++) {
        ll sum = 0;
        for(ll j = i-3; j >= 0; j--) {
            sum += dp[j];
            sum %= MOD;
        }
        dp[i] = sum;
    }
    cout << dp[s] << endl;
    return 0;
}

ll my_abs(ll a) {
    if(a >= 0) return a;
    else return -1 *a;
}

ll a_n(ll a, ll n) { 
    if(n == 0) return 1;
    
    ll ret = a, count = 1;
    while(count * 2 < n) {
        ret *= ret;
        count *= 2;
    }
    if(count == n) return ret;
    else return (ret * a_n(a, n-count));
}

ll my_gcd(ll a, ll b) {
    if(b == 0) return a;
    return my_gcd(b, a%b);
}

ll inv(ll a) {
    return a_n(a, MOD-2);
}

ll madd(ll a, ll b, ll c) {
    ll ret = (a+b) % MOD;
    return (ret+c) % MOD;
}

ll msub(ll a, ll b) {
    if(a < b) return (a-b+MOD) % MOD;
    else return (a-b) % MOD;
}

ll mtime(ll a, ll b, ll c) {
    ll ret = (a*b) % MOD;
    return (ret*c) % MOD;
}


Measured memory_bytes: 3640
N = int(input())
D = list(map(int, input().split()))
if D[0] != 0:
    print(0)
else:
    D = D[1:]
    C = [0]*N
    m = max(D)
    for d in D:
        C[d] += 1
    if C[0] != 0 or 0 in C[1: m + 1]:
        print(0)
    else:
        res = 1
        i = 1
        for i in range(1, m):
            res *= (C[i]**C[i + 1])%998244353
        print(res%998244353)

Measured memory_bytes: 14396
N, D = map(int,input().split())

X = []

for _ in range(N) :
    X.append(list(map(int,input().split())))

ans = 0

for i in range(N) :
    for j in range(i+1,N) :
        x = X[i]
        y = X[j]
        dist = 0
        for k in range(D) :
            dist += (x[k] - y[k])**2
        b = int(dist**0.5)
        if abs(b**2 - dist) < 1e-10 :
            ans += 1

print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
  string s;
  cin>>s;
  int n=s.length();
  if(n<5)
  {
    cout<<"No\n";
  }
  else
  {
    if(s[2]==s[3] && s[4]==s[5])
    {
      cout<<"Yes\n";
    }
    else
    {
      cout<<"No\n";
    }
  }
}

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

int main(){
	int N;
	string S;
	cin >> N >> S;

	int i;
	int left = 0;
	int right = 0;
	for(i=1;i<N;i++){
		right += (S[i]=='E')?1:0;
	}

	int min = left + right;

	for(i=1;i<N;i++){
		if(S[i-1] == 'W')left++;
		if(S[i] == 'E')right--;
		min = (left + right) < min ? left + right: min;
	}

	cout << min << endl;
	return 0;
}


Measured memory_bytes: 900
n = int(input())
s = input()

ans = 0
for si in s:
    if si == '#':
        ans += 1

white = [0] * (n+1)
black = [0] * (n+1)

for i in range(n):
    if s[i] == "#":
        white[i+1] = white[i]
        black[i+1] = black[i] + 1
    else:
        white[i+1] = white[i] + 1
        black[i+1] = black[i]



for i in range(n):
    if s[i] == ".":
        continue
    ans = min(ans, black[i] + white[n] - white[i + 1])

print(ans)



Measured memory_bytes: 12808
# -*- coding: utf-8 -*-

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

s=input()
t='CODEFESTIVAL2016'

cnt=0
for i in range(len(s)):
    if s[i]!=t[i]:
        cnt+=1
print(cnt)


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> PLL;
typedef vector<int> VI;
typedef vector<char> VC;
typedef vector<double> VD;
typedef vector<double> VL;
typedef vector<string> VS;
typedef vector<PLL> VP;
typedef vector<ll> VLL;
const static int INF = 1000000000;
const static int MOD = 1000000007;
#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 rept(i,m,n) for(ll i=m; i<n; i++)
#define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define PF push_front
#define PB push_back
#define SORT(V) sort((V).begin(), (V).end())
#define RVERSE(V) reverse((V).begin(), (V).end())
#define paired make_pair
#define PRINT(V) for(auto v : (V)) cout << v << " "
int ctoi(char c) { if (c >= '0' && c <= '9') { return c - '0'; } return 0; } //charを整数に
void cum_sum(int N,vector<double> a, vector<double> &s){ for(int i=0; i<N; i++){ s[i+1]=s[i]+a[i];}}
//空白文字も入力 getline(cin, S);
//桁数指定 setprecision
// 累積和 for (int i = 0; i < N; ++i) s[i+1] = s[i] + a[i];

int main()
{
    string S;
    cin >> S;
    ll ans=0;
    ll count=0;
    VLL ho(S.size());
    rep(i,S.size()){
        if(S[i]=='B'){
            count++;
        }
    }
    for(ll i=S.size()-1; i>=0; i--){
        if(S.at(i)=='B'){
            count--;
        }
        else{
            ho[i]=count;
        }
    }
    rep(i,ho.size()){
        ans+=ho[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 2180
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
bool isPalindrome(string str){
    ll l=0,h=str.length()-1;
    while(l<h){
        if(str[l++]!=str[h--])
            return false;
    }
    return true;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    string str;
    cin>>str;
    ll n=str.length();
    string first=str.substr(0,(n-1)/2);
    ll len=n-(n+3)/2;
    string second=str.substr((n+3)/2-1,len+1);
    if(isPalindrome(str) && isPalindrome(first) && isPalindrome(second))
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>

using namespace std;

const int Maxn = 2e5+7;

int n, k, cnt, add;
long long ans;
long long s[2][Maxn];

int main()
{
    scanf("%d%d", &n, &k);
    if(k == 1)
    {
        printf("%lld\n", 1ll*n*n*n);
        return 0;
    }
    add = k&1 ? k : k/2;
    for(int i = add, cnt = 1; i <= n; i += add, ++cnt)
    {
        // i i i
        ans++;
        // i i j && i j j
        ans += (i/k-(i%k == 0))*3*2;
        s[0][cnt] = s[0][cnt-1];
        s[1][cnt] = s[1][cnt-1];
        s[i%k == 0][cnt] += i/k-(i%k == 0);
        // i j j2
        ans += s[i%k == 0][cnt-1]*6;
        /*
        for(int j = i; j > 0; j -= k)
        {
            for(int j2 = j; j2 > 0; j2 -= k)
            {
                if(i == j && j == j2) ans++;
                else if(i == j || j == j2 || i == j2) ans += 3;
                else ans += 6;
                printf("%d %d %d %lld\n", i, j, j2, ans);
            }
        }
        */
    }
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 3328
import math
N=input()

def F(x,y):
	return max( len(str(x)),len(str(y)) )


def div_list(num):
    if num < 1:
        return []
    elif num == 1:
        return [1]
    else:
        l = []
        l.append(1)
        for i in range(2, int(math.sqrt(num)) + 1):
            if num % i == 0:
                l.append(i)
        l.append(num)

        return l

a=div_list(N)
#print a

ans=11
for i in a:
	ans=min(ans,F(i,N/i))

print ans




Measured memory_bytes: 5764
#include<iostream>
#include<queue>
using namespace std;
int main(){
    int n;
    while(cin>>n,n){
        int a[150];
        for(int i=0;i<150;i++)a[i]=0;
        while(n--){
            char x,y;
            cin>>x>>y;
            a[x]=y;
        }
        int m;
        queue<char>Q;
        cin>>m;
        while(m--){
            char z;
            cin>>z;
            if(a[z]!=0)z=a[z];
            Q.push(z);

        }
        while(Q.size()){
            cout<<Q.front();
            Q.pop();
        }
        cout<<endl;
    }
    return 0;
}

Measured memory_bytes: 1316
num = [int(i) for i in input().split()]
sorted_num = sorted(num)

if sorted_num[0] % 2 == sorted_num[1] % 2:
    count = sorted_num[2] - (sorted_num[0] + sorted_num[1])/2
elif sorted_num[0] % 2 != sorted_num[1] % 2:
    count = ((sorted_num[2] + 1) - (sorted_num[0] + sorted_num[1] + 1)/2) + 1

print(int(count))

Measured memory_bytes: 3060
#include<stdio.h>
int main(void)
{
	int n,i,j,k;
	int a[200][3],flg[200][3],sum[200];
	scanf("%d",&n);
	for(i=0;i<n;i++)	{
		for(j=0;j<3;j++)	{
			scanf("%d",&a[i][j]);
			flg[i][j]=0;
			sum[i]=0;
		}
	}
	for(j=0;j<3;j++){
		for(i=0;i<n;i++){
			for(k=0;k<n;k++){
				if(i!=k&&a[i][j]==a[k][j]){
					flg[i][j]=1;
				}
			}
//		printf("%d\n",flg[i][j]);
		}
	}
	for(j=0;j<3;j++){
		for(i=0;i<n;i++){
			if(flg[i][j]==1){
				a[i][j]=0;
			}
		}
	}
	for(i=0;i<n;i++){
		for(j=0;j<3;j++){
			sum[i]=sum[i]+a[i][j];
		}
		printf("%d\n",sum[i]);
	}
	return 0;
}
	

Measured memory_bytes: 1808
N = int(input())
l = list(map(int, input().split()))

x_1 = 0
for i, a in enumerate(l):
    if i % 2 == 0:
        x_1 += a
    else:
        x_1 -= a
ans = x_1

for a in l:
    print(ans)
    ans = 2 * a - ans 

Measured memory_bytes: 14028
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define db double
#define pii pair<int,int>
#define pli pair<ll,int>
#define pil pair<int,ll>
#define pll pair<ll,ll>
const int inf = 1 << 30;
const ll linf = 1e18;
template<class T> void chmin(T& x, T y){if(x > y) x = y;}
template<class T> void chmax(T& x, T y){if(x < y) x = y;}

int N;
ll A[2010];
ll dp[2010][2010];
bool used[2010][2010];
vector<pll> as;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> N;
    for(int i = 0; i < N; i++){
        ll A;
        cin >> A;
        as.push_back(pll{A, i});
    }
    sort(as.rbegin(), as.rend());
    set<pll> st;
    queue<pll> q;
    q.push({0, N - 1});
    used[0][N - 1] = true;
    ll ans = 0;
    while(!q.empty()){
        pii p = q.front();
        q.pop();
        ll l = p.first;
        ll r = p.second;
        chmax(ans, dp[l][r]);
        if(l > r) continue;
        ll val = as[N - 1 - r + l].first;
        ll idx = as[N - 1 - r + l].second;
        chmax(dp[l + 1][r], dp[l][r] + val * abs(l - idx));
        if(!used[l + 1][r]) q.push({l + 1, r}), used[l + 1][r] = true;
        chmax(dp[l][r - 1], dp[l][r] + val * abs(r - idx));
        if(!used[l][r - 1]) q.push({l, r - 1}), used[l][r - 1] = true;
    }
    cout << ans << endl;
}

Measured memory_bytes: 30336
import { readFileSync } from "fs";

const read = () =>
  readFileSync(0, "utf8")
    .split("\n")
    .map((line) => line.split(" "));

const main = (input: string[][]) => {
  const [N, X] = input[0].map(Number);
  const M = input.slice(1, -1).map((line) => Number(line[0]));

  const sum = M.reduce((acc, cur) => acc + cur);

  return N + Math.floor((X - sum) / Math.min(...M));
};

console.log(main(read()));


Measured memory_bytes: 29652
let input f = stdin.ReadLine() |> f
let inputs f = stdin.ReadLine().Split() |> Array.map f

let N = input int
let A = inputs int64
let ord = [|0..N-1|] |> Array.sortByDescending (fun i -> A.[i])

let inf = System.Int64.MinValue
let dp = Array2D.create (N + 1) (N + 1) inf
dp.[0, 0] <- 0L

for i in 0..N-1 do
    for j in 0..N-1 do
        if dp.[i, j] <> inf && i + j < N then
            let k = ord.[i + j]
            dp.[i + 1, j] <- max dp.[i + 1, j] (dp.[i, j] + A.[k] * int64 (k - i))
            dp.[i, j + 1] <- max dp.[i, j + 1] (dp.[i, j] + A.[k] * int64 ((N - 1 - j) - k))

[for i in 0..N -> dp.[i, N - i]]
|> List.max
|> printfn "%d"

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

int main() {
	int n,c;
	cin >> n;
	int a = n*800;
	int b = 0;
	while (n >= 15) {
		b = b+200;
		n = n-15;
	}
	c = a-b;
	cout << c;
}


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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << setprecision(20) << fixed;
  int N;
  cin >> N;
  vector<int> A(N);
  for(int i = 0; i < N; i++) cin >> A[i];
  sort(A.begin(), A.end());
  /*
  for(int i = 0; i < N; i++) cout << A[i] << " ";
  cout <<endl;
  //*/
  vector<int> maisu(100001);
  for(int i = 0; i < N; i++){
    maisu[A[i]]++;
  }
  int daburi = 0;
  for(int i = 0; i < 100001; i++){
    if(maisu[i] > 0){
      maisu[i]--;
    }
      daburi += maisu[i];
  }
  if((N - daburi) % 2 != 1){
    daburi++;
  }
  cout << N - daburi <<endl;
}

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

using namespace std;
#define int int64_t
#define rep(i, a, n) for (int i = (a); i < (n); ++i)
#define reps(i, a, n) for (int i = (a); i < (n); --i)
#define all(x) (x).begin(), (x).end()
#define gsort(x, n) sort((x), (x + n) greater<int>())
#define rv(s) reverse((s).begin(), (s).end())
#define setout(n, x) setw(n) << setfill(x)
#define Fixed(n) fixed << setprecision(n)
#define pb(x, a) (x).push_back(a)
#define fb(x, a) (x).flont_back(a)
#define eb(x, a) (x).emplaes_back(a)
using pii = pair<int, int>;
constexpr int INF = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const long long mod = 1e9 + 7;

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

    int a,b,c;
    cin>>a>>b>>c;

    cout<<c<<' '<<a<<' '<<b<<'\n';
    return 0;
}

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

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

#define     endl               "\n"
#define     fast_io            ios::sync_with_stdio(false); cin.tie(0);
#define     file_io            freopen("input.txt", "r", stdin);   \
                               freopen("output.txt", "w", stdout);
#define     all(x)             begin(x), end(x)
#define     debug(x)           cerr <<"Line "<< __LINE__ <<" : "<< #x " = "<< x <<endl;
 
template<typename T, typename TT>
ostream& operator<<(ostream &os, const pair<T, TT> &t) { return os<<"("<<t.first<<", "<<t.second<<")"; }
template<typename T>
ostream& operator<<(ostream& os, const vector<T> &t) { for(auto& i: t) os<<i<<" "; return os; }






int main(int argc, char** argv) {
    fast_io
   
	int n, l = 1, a;
	cin >> n;
	for(int i = 0; i < n; ++i) {
		cin >> a;
		l = a * l / __gcd(l, a);
	}
	
	cout << l << endl;

    return 0;
}















Measured memory_bytes: 3200
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
long long int st[4444];
int stf[4444];
int main(void)
{
  while(1){
    int n;
    bool f = true;
    cin >> n;
    if(!n) break;
    memset(st,0,sizeof(st));
    memset(stf,0,sizeof(stf));
    for(int i = 0; i < n; i++){
      long long int a,b,c;
      cin >> a >> b >> c;
      st[a] += b * c;
      if(1000000 <= st[a] && !stf[a]){
	cout << a << endl;
	stf[a] = 1;
	f = false;
      }
    }
    if(f) puts("NA");
  }
}

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

int main(void)
{
  int THealth, TAttack;
  int AHealth, AAttack;
  cin >> THealth >> TAttack >> AHealth >> AAttack;

  int TTarn = AHealth / TAttack;
  if (AHealth % TAttack != 0)
  {
    TTarn++;
  }
  int ATarn = THealth / AAttack;
  if (THealth % AAttack != 0)
  {
    ATarn++;
  }
  if (TTarn <= ATarn)
  {
    cout << "Yes" << endl;
  }
  else
  {
    cout << "No" << endl;
  }

  return 0;
}

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

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

const int MAXN = 3000;

int n, m;
string s, t, ans;

int dp[MAXN+10][MAXN+10];

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

    cin>>s>>t;
    n=s.size(); m=t.size();

    s="!"+s; t="!"+t;

    for(i=1; i<=n; i++) for(j=1; j<=m; j++)
    {
        if(s[i]==t[j]) dp[i][j]=dp[i-1][j-1]+1;
        else dp[i][j]=max(dp[i-1][j], dp[i][j-1]);
    }

    for(i=n, j=m; i!=0 && j!=0; )
    {
        if(s[i]==t[j]) ans+=s[i], i--, j--;
        else if(dp[i-1][j]>dp[i][j-1]) i--;
        else j--;
    }
    reverse(ans.begin(), ans.end());
    cout<<ans;
    return 0;
}


Measured memory_bytes: 35584
#include <bits/stdc++.h>
#define REP(i,n) for (long long i=0;i<(n);i++)
using namespace std;
template<typename V,typename Weight>
class Dijekstra {
private:
	struct edge {
		Weight dist;V node;V prev;
		bool operator<(edge const& a) const {
			return dist < a.dist;
		}
		bool operator>(edge const& a) const {
			return dist > a.dist;
		}
	};
	//vector<V> trace;
	vector<vector<pair<V,Weight>>> E;
	V const sz;
public:
	Weight const inf = numeric_limits<Weight>::max();
	vector<Weight> D;
	Dijekstra(V v) :
		E(v),sz(v),D(v,inf) {}

	void inline addEdgeDirected(V from,V to,Weight dis){
		E[from].emplace_back(make_pair(to,dis));
	}
	void inline addEdgeUndirected(V from,V to,Weight dis){
		E[from].emplace_back(make_pair(to,dis));
		E[to].emplace_back(make_pair(from,dis));
	}

	V size() {return sz;}
	Weight & operator[] (V n) { if (0 <= n && n < sz) return D[n];} 

	void dijekstra(V start){
		priority_queue<pair<Weight,V>,vector<pair<Weight,V>>,greater<pair<Weight,V>>> que;
		D[start] = 0;
		que.push(make_pair(0,start));
		while(!que.empty()){
			pair<Weight,V> cur = que.top();que.pop();
			Weight d = cur.first;
			V v = cur.second;
			if (D[v] < d) continue; //既により最適が見つかっている
			for(V i = 0;i < E[v].size();i++){
				V next = E[v][i].first;
				Weight newCost = d + E[v][i].second;
				if (D[next] > newCost) {
					D[next] = newCost;
					que.push(make_pair(newCost,next));
				}
			}
		}
	}
/*
	vector<V> show_trace(V start,V goal){ // startからgoalの最短距離上のノード
		vector<V> ret;
		for (V node = goal;node != start;node = trace[node]) ret.push_back(node);
		ret.push_back(start);
		return ret; // 配列の先頭がgoal,末尾がstart
	}
*/
};

int main(void){
	long V,E,R;
	long s,t,d;
	cin >> V >> E >> R;
	Dijekstra<long,long> dij(V);

	REP(i,E){
		cin >> s >> t >> d;
		dij.addEdgeDirected(s,t,d);
	}
	dij.dijekstra(R);
	REP(i,V) {
		if (dij[i] == dij.inf) cout << "INF" << endl;
		else cout << dij[i] << endl;
	}

	return 0;
}





Measured memory_bytes: 19340
#[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, 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,
        k: usize,
        s: i64,
    }

    const MAX: i64 = 1_000_000_000;

    let mut ans = vec![0; n];

    if k == 0 {
        if s == MAX {
            for i in 0..n {
                ans[i] = s-1;
            }
        } else {
            for i in 0..n {
                ans[i] = MAX;
            }
        }
    } else if s == MAX {
        ans[0] = s;
        for i in 1..k {
            ans[i] = s;
        }
        for i in k..n {
            ans[i] = 1;
        }
    } else {
        ans[0] = s;
        for i in 1..k {
            ans[i] = s;
        }
        for i in k..n {
            ans[i] = MAX;
        }
    }

    for i in 0..n {
        if i > 0 {
            print!(" ");
        }
        print!("{}", ans[i]);
    }
    println!();
}


Measured memory_bytes: 5372
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    
    int n = sc.nextInt();
    int[] p = new int[n];
    
    for(int i = 0; i < n; i++) {
      p[i] = sc.nextInt();
    }
    
    int cnt = 0;
    for(int i = 1; i < n-1; i++) {
      if((p[i-1]<p[i]&&p[i]<p[i+1]) || (p[i+1]<p[i]&&p[i]<p[i-1])) {
        cnt++;
      }
    }
    System.out.println(cnt);
  }
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
const ll MOD = 1000000007;
const int IINF = INT_MAX;
const ll LLINF = LLONG_MAX;
const int MAX_N = int(1e5 + 5);
const double EPS = 1e-8;
const int di[] = {0, 1, 0, -1}, dj[] = {1, 0, -1, 0};
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define SORT(v) sort((v).begin(), (v).end())
#define ALL(v) (v).begin(), (v).end()

int cnt[MAX_N]{};
bool inCycle[MAX_N];
vector<vector<int> > g;

void dfs(int i){
    inCycle[i] = false;
    cnt[i]--;
    for(auto k : g[i]){
        cnt[k]--;
        if(cnt[k]==1){
            dfs(k);
        }
    }
}

int main() {
    int n;
    cin >> n;
    g.resize(n);
    REP(i,n){
        int u, v;
        cin >> u >> v;
        u--;
        v--;
        g[u].push_back(v);
        g[v].push_back(u);
        cnt[u]++;
        cnt[v]++;
    }
    fill(inCycle,inCycle+n,true);
    REP(i,n){
        if(cnt[i]==1){
            dfs(i);
        }
    }
    int q;
    cin >> q;
    REP(i,q){
        int u, v;
        cin >> u >> v;
        u--;
        v--;
        if(inCycle[u]&&inCycle[v]){
            cout << 2 << endl;
        }
        else {
            cout << 1 << endl;
        }
    }
    return 0;
}



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

int main() {
    int p,q,r;
  cin >> p >> q >> r ;
    int min=p+q;
    if(min > q+r){
        min = q + r;
    }
    if(min > r+p){
        min = r + p;
    }
    cout << min << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl; 
#define INF 1000000000
#define mod 1000000007
typedef long long ll;
const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

ll n,m,v,p,ans=-1;
vector<ll> a;


bool solve(ll mid){
    vector<ll> b(n);
    rep(i,n) b[i]=a[i];
    ll ad=m*v;
    b[mid]=a[mid]+m;ad-=m;
    for(int i=0;i<n and ad>0;i++){
        if(i<mid){
            b[i]=a[i]+m;
            ad-=m;
        }
        else if(i==mid){
            continue;
        }
        else{
            if(b[mid]>a[i]){
                ll dif=min(m,b[mid]-a[i]);
                b[i]=a[i]+dif;
                ad-=dif;
            }    
        }
    }

    if(ad>0){
        for(int j=0;j<p and ad>0;j++){
            int i=n-j-1;
            if(i==mid) break;
            ll can_up=m-(b[i]-a[i]);
            b[i]+=can_up;
            ad-=can_up;
        }
    }
    ll num=b[mid],cnt=0;
    rep(i,n){
        if(b[i]>num) cnt++;
    }
    if(cnt<p and ad<=0){
        return true;
    }else{
        return false;
    }

}

void f(ll l,ll r){
    if(l>r) return ;
    ll mid=(l+r)/2;
    if(solve(mid)){
        f(l,mid-1);
    }else{
        chmax(ans,mid);
        f(mid+1,r);
    }
}

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

    cin>>n>>m>>v>>p;
    a.resize(n);
    rep(i,n) cin>>a[i];
    sort(ALL(a));
    f(0,n-1);
    cout<<n-ans-1<<endl;
    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  
  vector<int> vec(N);
  for(int i=0; i<N; i++){
    cin >> vec.at(i);
  }
  
  int sum = 0;
  for(int i=0; i<N; i++){
    if(vec.at(i) % 2 == 0 && vec.at(i) % 3 != 0 && vec.at(i) % 5 != 0){
      sum++;
    }
  } 
  if(sum == 0){
    cout << "APPROVED";
  }
  else{
    cout << "DENIED";
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define uint unsigned int
#define ull unsigned long long
#define inf 1010000000
#define infll 1010000000000000000ll
#define vi vector<int>
#define vll vector<ll>
#define pb push_back
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define mpr make_pair
#define fi first
#define se second
#define pq priority_queue<int>
#define pqll priority_queue<ll>
#define up(x,y) (x<(y)?x=(y):0)
#define dn(x,y) (x>(y)?x=(y):0)
#define ad(x,y) (x=(x+(y))%mod)
#define cbn(x,y) ((ll)fac[x]*inv[y]%mod*inv[(x)-(y)]%mod)
#define mod 1000000007
using namespace std;

int read(); ll readll();
char ch[1009][1009];
void work1(int x,int y,char c){
	ch[x][y]=ch[x][y+1]=c; ch[x+1][y]=ch[x+1][y+1]=c+1;	
}
void work2(int x,int y,char c){
	ch[x][y]=ch[x+1][y]=c; ch[x][y+1]=ch[x+1][y+1]=c+1;	
}
void fill3(int x,int y){
	ch[x][y]=ch[x][y+1]='a'; ch[x+1][y+2]=ch[x+2][y+2]='b';	
}
void fill4(int x,int y){
	work1(x,y,'a'); work1(x+2,y+2,'a');
	work2(x,y+2,'c'); work2(x+2,y,'c');
}
void fill5(int x,int y){
	work1(x+2,y,'a'); work2(x,y+2,'a');
	ch[x+4][y]=ch[x+4][y+1]=ch[x][y+4]=ch[x+1][y+4]='c';
	ch[x+2][y+2]=ch[x+2][y+3]='d';
	ch[x+2][y+4]=ch[x+3][y+4]='e';
	ch[x+3][y+2]=ch[x+4][y+2]='f';
	ch[x+4][y+3]=ch[x+4][y+4]='g';
}
void fill6(int x,int y){
	work1(x,y,'a'); work1(x+2,y+2,'c'); work1(x+4,y+4,'e');
	work2(x,y+2,'g'); work2(x+2,y+4,'i'); work2(x+4,y,'k');
}
void fill7(int x,int y){
	ch[x][y]=ch[x][y+1]='a'; ch[x][y+2]=ch[x+1][y+2]='b';
	ch[x+1][y]=ch[x+2][y]='c'; ch[x+2][y+1]=ch[x+2][y+2]='d';
	work1(x,y+3,'e'); ch[x+2][y+5]=ch[x+2][y+6]='e';
	work2(x+3,y,'e'); ch[x+5][y+2]=ch[x+6][y+2]='e';
	work1(x+3,y+5,'a'); work2(x+5,y+3,'a');
}
int main(){
	int n; scanf("%d",&n);
	if (n<3){ puts("-1"); return 0; }
	int i,j;
	for (i=1; i<=n; i++) for (j=1; j<=n; j++) ch[i][j]='.';
	if (!(n%3))
		for (i=1; i<=n; i+=3) fill3(i,i);	
	else if (n%6==1){
		fill7(1,1);
		for (i=8; i<=n; i+=6) fill6(i,i);	
	} else if (n%6==2){
		fill4(1,1); fill4(5,5);
		for (i=9; i<=n; i+=6) fill6(i,i);	
	} else if (n%6==4){
		fill4(1,1);
		for (i=5; i<=n; i+=6) fill6(i,i);		
	} else if (n%6==5){
		fill5(1,1);
		for (i=6; i<=n; i+=6) fill6(i,i);	
	}
	for (i=1; i<=n; i++) puts(ch[i]+1);
	return 0;
}

int read(){
	int x=0; char ch=getchar(); bool flag=0;
	while (ch<'0' || ch>'9'){ if (ch=='-') flag=1; ch=getchar(); }
	while (ch>='0' && ch<='9'){ x=x*10+ch-'0'; ch=getchar(); }
	return flag?-x:x;
}
ll readll(){
	ll x=0; char ch=getchar(); bool flag=0;
	while (ch<'0' || ch>'9'){ if (ch=='-') flag=1; ch=getchar(); }
	while (ch>='0' && ch<='9'){ x=x*10+ch-'0'; ch=getchar(); }
	return flag?-x:x;
}

Measured memory_bytes: 2176
import java.util.Scanner;

public class Main {

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

		if (s.charAt(0) == s.charAt(1) && s.charAt(1) == s.charAt(2)) {
			System.out.println("Yes");
		} else if (s.charAt(1) == s.charAt(2) && s.charAt(2) == s.charAt(3)) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}

		sc.close();

	}

}


Measured memory_bytes: 35556
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
#define bit(n) (1LL << (n))
#define sz(x) ((int)(x).size())
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;

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;
}

int main() {
  int N;
  cin >> N;
  string S;
  cin >> S;
  int ans = 0;
  rep(i, N - 1) {
    if (S[i] != S[i + 1])
      ans++;
  }
  ans++;
  cout << ans << endl;
}

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

#define mod 1000000007

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

using namespace std;
typedef long long ll;
const long long INF = 1LL << 60;
 
int main(void){
	
	int N;
	
	cin >> N;
	
	cout << N * N * N;
	
	return 0;
}

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

using namespace std;

int main()
{
	string s, t;
	cin >> s >> t;
	int sum = 0;
	for (int i = 0; i < s.size(); i++)
	{
		sum += s[i] != t[i];
	}

	cout << sum << endl;

	return 0;
}


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

#define rep(i,n) for(int i=0,i##_cond=(n);i<i##_cond;++i)
constexpr int inf = 1<<30;

signed main(){
  string s; cin >> s;
  int ans = inf;
  rep(i,2){ // 初めの色をiにする
    int tmp = 0;
    rep(j,s.size()){
      if(j % 2 == 0 and s[j]-'0' != i) tmp++;
      else if(j % 2 == 1 and s[j]-'0' != (i^1)) tmp++;
    }
    ans = min(ans, tmp);
  }
  cout << ans << endl;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define repA(i, a, n) for(int  i = a; i <= (n); ++i)
#define all(x) x.begin(), x.end()
#define sz(x) (int) (x).size()
#define fill(a) memset(a, 0, sizeof(a))
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
#define endl '\n'
#define init(n) int n;cin>>n;int a[n];rep(i,n)cin>>a[i];
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long long int> vll;
typedef vector<pii> vii;

int main() {
    cin.sync_with_stdio(0); cin.tie(0); 
    cin.exceptions(cin.failbit);
    int T=1;
    // cin>>T;
    while(T--){
        int n;cin>>n;
        pair<int,int> a[n];
        double x[n],l[n];
        rep(i,n){
            cin>>a[i].fst>>a[i].snd;
            // a[i].snd--;
        }
        sort(a,a+n);
        rep(i,n){
            x[i]=a[i].fst;
            l[i]=a[i].snd-(0.5);
        }
        int ans=1,last=0;
        for(int i=1;i<n;i++){
            if(x[last]+l[last]<(x[i]-l[i])){
                // cout<<i<<endl;
                ans++;
                last=i;
            }
            else{
                if(x[last]+l[last]>(x[i]+l[i])){
                    // cout<<i<<endl
                    last=i;
                }
            }
        }
        cout<<ans<<endl;
    }
    return 0;   
}

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

int main(){
    int n;
    cin >> n;
    int b[n-1];
    for(int i=0; i<n-1; i++){
        cin >> b[i];
    }
    long long ans=b[0];
    for(int i=0; i<n-2; i++){
        ans += min(b[i],b[i+1]);
    }
    ans += b[n-2];
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<string>
#include<cmath>
#include<algorithm>
#define ll long long
using namespace std;
int n;

int main()
{
    cin>>n;
    cout<<3*n*n<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n,ans;
unordered_map<ll,bool>vis;
void solve(ll x)
{
    for(ll i=1;i*i<=x;i++)
        if(x%i==0)
        {
            vis[i]=true;
            vis[x/i]=true;
            if(i!=1) ans++;
            if(x/i!=1&&x/i!=i) ans++;
        }
}
bool judge(ll k)
{
    ll x=n;
    while(x%k==0&&x>1) x/=k;
    return x%k==1;
}
int main()
{
    scanf("%lld",&n);
    solve(n-1);
    for(ll i=1;i*i<=n;i++)
        if(n%i==0)
        {
            if(!vis[i]) ans+=judge(i);
            if(n/i!=i&&!vis[n/i]) ans+=judge(n/i);
        }
    printf("%lld\n",ans);
}


Measured memory_bytes: 512
#include<stdio.h>
#include<string.h>
int main(){
  char s[102],t[102];
  scanf("%s %s",s,t);
  int a=strlen(s),b=strlen(t);
  if(a<b){
    printf("LESS");
  }else if(a>b){
    printf("GREATER");
  }else{
    int f=1;
    for(int i=0; i<a; i++){
      if(s[i]<t[i]){
        printf("LESS");
        f=0;
        break;
      }else if(s[i]>t[i]){
        printf("GREATER");
        f=0;
        break;
      }
    }
    if(f){printf("EQUAL");}
  }
  return 0;}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repr(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;

signed main(){
    int y, m, d;
    scanf("%d/%d/%d", &y, &m, &d);
    if(y < 2019 || (y == 2019 && (m <= 4))) cout << "Heisei" << endl;
    else cout << "TBD" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	long long n,ans=0,x,summ[200005],sum[200005];
	scanf("%lld",&n);
	sum[0]=0;summ[0]=0;ans=0;
	for(long long i=1;i<=n;i++){
		scanf("%lld",&x);
		sum[i]=sum[i-1]^x;
		summ[i]=summ[i-1]+x;
	}
	int j=1;
	for(int i=1;i<=n;i++){
        while((summ[i]-summ[j-1])!=(sum[i]^sum[j-1])&&j<n) j++;
        if(summ[i]-summ[j-1]==sum[i]^sum[j-1]) ans+=(i-j+1);
	}
	cout<<ans<<endl;
	return 0;
}

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

int compare_char(char *a,char *b){
	return strcmp(a,b);
}

int intsort(const void *a, const void *b){
	return *(int*)b - *(int*)a;
	/*qsort(a,aの配列数,sizeof(int),intsort);*/
}

int longsort(const void *a, const void *b){
	long *A=(long *)a;
	long *B=(long *)b;
	if(*A>*B) return -1;
	if(*A<*B) return 1;
	return 0;
}

int main(){
  int i,N,K,a[200000];
  char ss[10000];
  scanf("%d",&N);
  scanf("%d",&K);

  printf("%d\n",(N*3+K)/2);
  return 0;
}

Measured memory_bytes: 256
#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(){
  int n;
  cin>>n;
  ll ans=0;
  rep(i,n){
    int a;
    cin>>a;
    ans=ans^a;
  }
  if(ans==0)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

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


int main() {
    ll h,w,x,y;
    cin >> w >> h >> x >> y;
    cout << fixed << setprecision(10);
    double menseki = h*w/2.0;
    //角
    if(x+x == w && y+y == h){
        cout << menseki << " " << 1 << endl;
        return 0;
    }
    cout << menseki << " " << 0 << endl;
    return 0;
}
/*
やっほい！
　　　　　　　やほほい！
　　　　+　　 　*
　　　 ∧∧　　. ∧∞∧　*
*　ヽ(=´ω｀)人(´ω｀*)ﾉ
　.～（ O x.） （ 　 O)～　+
。*　 　∪　　　　∪
*/

Measured memory_bytes: 256