akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define all(a)  (a).begin(),(a).end()
typedef long long ll;
ll mod=1000000007;

int main() {
  int n; cin >>n;
  string s; cin >> s;
  std::vector<int> vnume(n), vnumw(n);
  int cnte=0;
  int cntw=0;
  for(int i =0; i<n;++i){
    vnumw[i] = cntw;
    vnume[n-1-i] = cnte;
    string sw = s.substr(i,1);
    string se = s.substr(n-1-i,1);
    if(sw =="W") ++ cntw;
    if(se =="E") ++ cnte;
  }
  int min_cnt = 2*s.size();
  for(int j=0;j<n;++j){
    min_cnt = min(min_cnt,vnume[j] + vnumw[j]);
  }
  cout << min_cnt << endl;
  return 0;
}


Measured memory_bytes: 3076
N = int(input())
A = list(map(int, input().split()))
k = max(A)

def pow_k(x, n):
    """
    O(log n)
    """
    if n == 0:
        return 1

    K = 1
    while n > 1:
        if n % 2 != 0:
            K *= x % 998244353
        x *= x % 998244353
        n //= 2

    return K * x % 998244353


R = [0] * (k + 1)
result = 1
for i in A:
    R[i] += 1

if A[0] != 0 or R[0] != 1:
    print(0)
    exit()

for j in range(k):
    result *= pow_k(R[j], R[j + 1])

    if result == 0:
        print(0)
        exit()

print(result % 998244353)


Measured memory_bytes: 14396
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

# 本番後に自力で回答
#
# 左の列から順に見ていく
#
# 例えば、以下の盤面にて、「CCDD」の部分に何が入るかを考える。
#   AACC
#   BBDD
# AAがa色、BBがb色で塗られているとすると、塗り方は
#   aabb  aacc  aabb
#   bbaa  bbaa  bbcc
# の3通り。なので3をかける

import array
from bisect import *
from collections import *
import fractions
import heapq 
from itertools import *
import math
import random
import re
import string
import sys

MOD = 1000000007
N = int(input())
S1 = input()
S2 = input()

i = 0
prev = None
ans = 1
while i < N:
    if S1[i] == S2[i]:
        if prev is None:
            ans *= 3
        if prev == 'ver':
            ans *= 2
        if prev == 'hor':
            pass
        prev = 'ver'
        i += 1
    else:
        if prev is None:
            ans *= 6
        if prev == 'ver':
            ans *= 2
        if prev == 'hor':
            ans *= 3
        prev = 'hor'
        i += 2
    ans %= MOD
print(ans)


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

int main() {
  string s;
  cin >> s;
  int x[100000];
  int l[100000] = {0};
  int r[100000] = {0};
  int a[100000] = {0};
  char k = s[0];
  int ii = 0;
  for(int i = 1; i < s.size(); ++i) {
    if (k != s[i]) {
      if(s[i] == 'L') {
        l[ii] = i;
        r[ii] = i-1;
        ii += 1;
      }
      k = s[i];
    }
  }
  
  ii = 0;
  k = 'R';
  for(int i = 0; i < s.size(); ++i) {
    if(s[i] == 'R' && s[i] != k)
      ii += 1;
    
    int c;
    if(s[i] == 'R')
      c = l[ii] - i;
    else
      c = i - l[ii];
     
    if((l[ii] - i) % 2 == 0)
      a[l[ii]] += 1;
    else
      a[r[ii]] += 1;
      
    k = s[i];
  }

  for(int i = 0; i < s.size(); ++i) {
    cout << a[i] << ' ';
  }
  cout << '\n';
  return 0;
}

Measured memory_bytes: 1792
n = int(input())
a = [int(i) for i in input().split()]


def euclid_lcf(a, b):
    if b < a:
        a, b = b, a

    if b % a == 0:
        return a
    else:
        r = b % a
        return euclid_lcf(a, r)


com_factor = euclid_lcf(a[0], a[1])

if len(a) == 2:
    print(com_factor)
else:
    for i in range(2, len(a)):
        com_factor = euclid_lcf(com_factor, a[i])

    print(com_factor)


Measured memory_bytes: 14252
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int i,n,t;
    string s;
    cin>>n;
    pair<pair<string,int>,int> p[101];
    for(int j=0;j<n;j++)
    {
        cin>>s>>t;
        p[j]=make_pair(make_pair(s,-t),j);
    }
    sort(p,p+n);
    for(int j=0;j<n;j++)
    {
        cout<<p[j].second+1<<"\n";
    }
}

Measured memory_bytes: 3596
#include <iostream>
#include <algorithm>
#include <map>
#include <vector>
using namespace std;
struct Boat
{
    int s,e;
} boat[200050];
bool cmp(Boat b1,Boat b2)
{
    return b1.s<b2.s||(b1.s==b2.s&&b2.e<b2.e);
} vector<int> v[200010];
int main()
{
    int n,m;
    cin>>n>>m;
    int x,y;

    int flag=0;
    for(int i=0; i<m; i++)
    {
        cin>>x>>y;
        v[x].push_back(y);
    }
    for(int i=0;i<v[1].size();i++)
    {
        x=v[1][i];
        for(int j=0;j<v[x].size();j++)
        {
            y=v[x][j];
            if(y==n)
            {
                flag=1;
                break;
            }
        }
        if(flag) break;
    }
      //  cin>>boat[i].s>>boat[i].e;
    //sort(boat,boat+m,cmp);

    //int flag=0;
   /* if(boat[0].s>1||boat[m-1].e<n) flag=1;
    else
    {
        int res;
        //int tt=
        /*int cnt=0;
        for(int i=0; i<m; i++)
        {
             if(boat[i].s==1)
             {
                 res=i;
                 cnt=max()
             }
             else break;
        }
        int tt=boat[res].e;

        for(int i=res;i<m;i++)
        {
            if(boat[i].s<=tt)
            {
                cnt=max(cnt,boat[i].e);
            }
        }*/

    if(!flag) cout<<"IMPOSSIBLE"<<endl;
    else cout<<"POSSIBLE"<<endl;

    // cout << "Hello world!" << endl;
    return 0;
}


Measured memory_bytes: 9984
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <cmath>
#include <climits>
#define endl "\n"
typedef long long int ll;
typedef unsigned long long int ull;
typedef float fl;
typedef short int si;
using namespace std;

void solve()
{
    char a[3]; cin >> a;
    int cnt=0,ans=INT_MIN;
    for (int i=0;i<3;++i) {
        if(a[i]=='S') cnt=0;
        else ++cnt;
        ans=max(ans,cnt);
    }
    cout << ans;
    return;
}
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    solve();
    return 0;
}


Measured memory_bytes: 3660
#include<stdio.h>

int main(void) {
	char x[1001];
	int n[10000];
	int i = 0;
	int flag = 1, cnt = 0;
	
	do {
		n[cnt] = 0;
		scanf("%s", x);
		
		
		for(i = 0; x[i] != '\0'; i++) {
			n[cnt] += x[i] - '0';
		}
		
		if(n[cnt] == 0) {
			flag = 0;
		}
		
		cnt++;
	} while(flag);
	
	for(i = 0; i < cnt-1; i++) {
		printf("%d\n", n[i]);
	}
	
	return 0;
}

Measured memory_bytes: 544
#include <bits/stdc++.h>
#define FOR(i, n) for(ll i = 0; i < n; i++)
#define FORR(i, n) for(ll i = n; i >= 0; i--)
#define FORS(i, m, n) for(ll i = m;i < n;i++)
#define ALL(v) accumulate(v.begin(),v.end(),0)
#define SORT(v) sort(v.begin(),v.end())
#define FIND(v,item) find(v.begin(),v.end(),item)
#define OUT(n) (cout << n << endl)
#define IN1(a) (cin >> a)
#define IN2(a,b) (cin >> a >> b)
#define IN3(a,b,c) (cin >> a >> b >> c)
#define IN4(a,b,c,d) (cin >> a >> b >> c >> d)
#define REVS(v) reverse(v.begin(),v.end())
#define PI 3.14159265359
using namespace std;
typedef long long ll;
int main(){
  ll inta,intb;
  double doubleb;
  cin >> inta >> doubleb;
  doubleb += 0.0005;
  intb = (doubleb)*100;
  ll ans;
  ans = inta*intb;
  ans = ans / 100;
  OUT(ans);
}

Measured memory_bytes: 3732
#include <bits/stdc++.h>
using namespace std;
#define Hello ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long
#define endl '\n'
void trace(int n, int arr[]){for(int i = 0; i < n; i++){cout << arr[i] << " ";} cout << endl << endl;}
const int N = 1005, mod = 1e9 + 7;
ll h, w, dp[N][N];
char arr[N][N];
bool check(int i, int j){
    return (i >= 0 && i < h) && (j >= 0 && j < w);
}
ll solve(int i, int j){
    if(!check(i, j) || arr[i][j] == '#')
        return 0;
    if(i == h - 1 && j == w - 1)
        return 1;
    if(dp[i][j] != -1)
        return dp[i][j];
    dp[i][j] = ((solve(i, j + 1) % mod) + (solve(i + 1, j))) % mod;
    return dp[i][j];
}
int main()
{
    Hello
    memset(dp, -1, sizeof dp);
    cin >> h >> w;
    for(int i = 0; i < h; i++)
        for(int j = 0; j < w; j++)
            cin >> arr[i][j];
    cout << solve(0, 0) % mod;
    return 0;
}

Measured memory_bytes: 12604
#include<iostream>
#include<vector>
#define loop(i,a,b) for(long long i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;

int main(){
	vector<int> weight,length;
	long long n;
	while(1){
		cin>>n;
		if(n==0)break;
		rep(i,n){
			int x,y,h,w;
			cin>>x>>y>>h>>w;
			length.push_back(x+y+h);
			weight.push_back(w);
		}
		long long price=0;
		rep(i,weight.size()){
			int nl=length[i],nw=weight[i];
			if(nl>160 || nw>25){}
			else if(nl>140 || nw>20) price+=1600;
			else if(nl>120 || nw>15) price+=1400;
			else if(nl>100 || nw>10) price+=1200;
			else if(nl>80 || nw>5) price+=1000;
			else if(nl>60 || nw>2) price+=800;
			else price+=600;
		}
		cout<<price<<endl;
		while(!weight.empty()){
			weight.pop_back();
			length.pop_back();
		}
	}
	return 0;
}

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

//#define int long long
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i < b; i++)
#define out(x) cout << x << endl
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<bool> > vvb;
typedef vector<vector<double> > vvd;
typedef vector<vector<string> > vvs;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

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;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

signed main()
{   
    gearup;
    ll x;cin>>x;
    for(ll i=-1000;i<=1000;i++){
        for(ll j=-1000;j<=1000;j++){
            ll a = i*i*i*i*i;
            ll b = j*j*j*j*j;
            if(a-b == x){
                cout << i << " " << j << endl;
                return 0;
            }
        }
    }
}


Measured memory_bytes: 3652
/*----------------------------------------------------*
* लेखक --> अमित सिंह
* संस्थान --> राष्ट्रीय प्रौद्योगिकी संस्थान, कुरुक्षेत्र
*-----------------------------------------------------*/
   #include <bits/stdc++.h>
   using namespace std;
   #define ll long long
   #define w(t) int t; cin>>t; while(t--)
   #define fo(i,n) for(int i=0;i<n;i++)
   #define endl "\n" 
   #define MOD 1000000007
   const ll inf=1e18;
   void Tez(){
      ios::sync_with_stdio(0);
      cin.tie(0);
      cout.tie(0);
   }
   ll power(ll a,ll b){
      ll ans=1;
      while(b){
         if(b&1){
           ans=(ans*a)%MOD;
         }
         b=b>>1;
         a=(a*a)%MOD;
      }
      return ans;
   }
   int main(){
      Tez();
      ll n;
      cin>>n;
      if(n==1){cout<<0; return 0;}
      if(n==2){cout<<2; return 0;}  
      ll ans=(((power(10,n)%MOD-power(9,n)%MOD+MOD)%MOD-power(9,n)%MOD+MOD)+power(8,n)%MOD)%MOD;
      cout<<ans;
      return 0;
   }



Measured memory_bytes: 3652
N, M = map(int, input().split())
students = []
for i in range(0, N):
	students.append(list(map(int, input().split())))
checkpoints = []
for i in range(0, M):
	checkpoints.append(list(map(int, input().split())))
for i in range(0, N):
	nearest = 0
	min = 5000000000000000
	for j in range(0, M):
		d = abs(students[i][0]-checkpoints[j][0]) + abs(students[i][1]-checkpoints[j][1])
		if d < min:
			min = d
			nearest = j+1
	print(nearest)

Measured memory_bytes: 39280
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <ctime>
#include <iterator>
#include <bitset>
#include <numeric>
#include <list>
#include <iomanip>
using namespace std;
#define ll int64_t
const long MOD = 1e9 + 7;
const long LINF = 1e13;
const long LLINF = 1e18;
const long ALPHABET = 26;

template <class T>
void Swap(T& r, T& l) {
  T tmp = r;
  r = l;
  l = tmp;
}



int main() {

  long a,b;
  cin >> a >>b;


  long ans = 0;



  // cout << (b%a==0)? (a+b) : (b-a)   ;
  if (b%a==0){
    cout << (a+b);
  }else{
    cout << (b-a);
  }




  // cout << (t/x);

  // cout << (ans-mx/2) <<endl;


}




















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

int n;
int beaker[128];
bool filled[128];
bool used[128];

bool check();

bool pour(int vol, int indx) {
	if(vol == 0)
		return true;
	if(vol < 0)
		return false;
	if(indx >= n)
		return false;

	if(!filled[indx] && !used[indx] && beaker[indx] <= vol) {
		filled[indx] = used[indx] = true;
		if(pour(vol - beaker[indx], indx + 1) && check())
			return true;
		filled[indx] = used[indx] = false;
	}

	return pour(vol, indx + 1);
}

bool check() {
	for(int i = 0; i < n; i++) {
		if(filled[i]) {
			filled[i] = false;
			if(pour(beaker[i], i + 1))
				return true;
			filled[i] = true;
		}
		else if(!used[i]) {
			return false;
		}
	}
	return true;
}

int main() {
	while(cin >> n, n) {
		for(int i = 0; i < n; i++)
			cin >> beaker[i];

		sort(beaker, beaker + n, greater<int>());
		for(int i = 0; i < 128; i++) {
			filled[i] = used[i] = false;
		}
		filled[0] = used[0] = true;

		if(check())
			cout << "YES" << endl;
		else
			cout << "NO" << endl;
	}
}

Measured memory_bytes: 1172
#include<bits/stdc++.h>
using namespace std;
bool d[111111];
int main(){
	int n,s=0,x;
	d[0]=1;
	for(scanf("%d",&n);n--;){
		scanf("%d",&x);
		for(int i=s; i>=0; i--)
			if(d[i]) d[i+x]=1;
		s+=x;
	}
	while(s > 0 && (s%10==0 || !d[s])) s--;
	cout << s << endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>

int main(){
  long long int a,b,c,r,tmp;
  scanf("%lld %lld",&a,&b);
  c = a*b;
  if(a<b){
    tmp = a;
    a = b;
    b = tmp;
  }
 
  r = a % b;
  
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }
 

  printf("%lld\n",c/b);

  return 0;
}
 

Measured memory_bytes: 128
#include <stdio.h>

void trace(int A[], int N)
{
    for(int i = 0; i < N; ++i)
    {
        if(i > 0)
            printf(" ");
        printf("%d", A[i]);
    }
    printf("\n");
}

void insertionSort(int A[], int N)
{
    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;
        trace(A, N);
    }
}

int main()
{
    int N, A[100];
    scanf("%d", &N);
    for(int i = 0; i < N; ++i)
        scanf("%d", &A[i]);
    trace(A, N);
    insertionSort(A, N);
    return 0;
}


Measured memory_bytes: 2612
from functools import reduce

n = input()
xs = map(float, input().split())
ys = map(float, input().split())

d = list(map(lambda x, y: abs(x - y), xs, ys))
ds = [sum([i ** p for i in d]) ** (1 / p) for p in range(1, 4)]
ds.append(max(d))

print(reduce(lambda h, t: h + '\n' + t, [str(e) for e in ds]))

Measured memory_bytes: 8316
#include <iostream>
    #include <vector>
     
    using namespace std;
     
    int main() {
    string board;
    cin >> board;
    int change = 0;
    char c = board[0];
    for (int i=1; i<board.size(); i++) {
    if (c != board[i]) {
    change++;
    }
    c = board[i];
    }
    if (change == 0) {
    cout << board[0] << endl;
    } else {
    if (change % 2 == 1) {
    cout << "o" << endl;
    } else {
    cout << board[0] << endl;
    }
    }
    return 0;
    }

Measured memory_bytes: 1176
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef vector<double> Vec;
typedef vector<Vec> Mat;
typedef pair<ll,ll> P;
typedef pair<double,ll> Pd;
typedef pair<double,double> PD;
typedef priority_queue<P,vector<P>,greater<P> > P_queue;
typedef priority_queue<Pd,vector<Pd>,greater<Pd> > Pd_queue;

const ll MOD=998244353;
const ll mod=1000000007;
const ll INF=1e15;
const double DEL=1e-6;


#define REP(i,a,b) for(int i=(int)a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define mp make_pair
#define ALL(a) a.begin(),a.end()
#define SORT(a) sort(ALL(a))
#define U_ERASE(V) V.erase(unique(ALL(V)), V.end());
#define ADD(a,b) a=(a+b)%mod
#define MUL(a,b) a=(a*b)%mod

int d[6][6];
int main(){
    ll H,W,K; cin>>H>>W>>K;
    rep(i,H){
        string S; cin>>S;
        rep(j,W) if(S[j]=='#') d[i][j]=1;
    }
    
    ll ans=0;
    ll h=(1<<H), w=(1<<W);
    rep(i,h) rep(j,w){
        ll Count=0;
        rep(I,H) if(i & (1<<I)){
            rep(J,W) if(j & (1<<J)) {
                //cout<<i<<' '<<I<<' '<<j<<' '<<J<<endl;
                if(d[I][J]) Count++;
            }
        }
        //cout<<i<<' '<<j<<' '<<Count<<endl;
        if(Count==K) ans++;
    }
    cout<<ans<<endl;

}

Measured memory_bytes: 3560
using System;
using System.Linq;

class Program
{
    public static void Main(string[] args) {
        while(true) {
            int n = int.Parse(Console.ReadLine());
            if (n == 0) break;
            int[] s = Console.ReadLine().Split().Select(int.Parse).ToArray();
            double m = s.Average();
            double sum = 0;
            for (int i = 0; i < n; i ++) {
                sum += Math.Pow(s[i] - m, 2);
            }
            Console.WriteLine(Math.Sqrt(sum/n));
        }
    }
}


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

#define LL long long
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ALL(x) (x).begin(),(x).end()
const int IINF = 1e9;
const LL LINF = 1e18;
const LL mod = 1e9+7;

struct nya {
    int a;
    int i;
    int b;
};

int main() {
    int N;
    cin >> N;
    nya A[N];
    REP(i, N) {
        cin >> A[i].a;
        A[i].i = i;
    }
    sort(A, A + N, [](nya x, nya y){return x.a < y.a;});
    REP(i, N/2) {
        A[i].b = A[N/2].a;
    }
    FOR(i, N/2, N) {
        A[i].b = A[N/2 - 1].a;
    }
    sort(A, A + N, [](nya x, nya y){return x.i < y.i;});
    REP(i, N) {
        cout << A[i].b << endl;
    }
    return 0;
}



Measured memory_bytes: 4480
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <stack>
#include <algorithm>
#include <iostream>
#include <string>
#include <map>

using namespace std;

int main() {

    int a;
    cin >> a;
    string s;
    cin >> s;

    if (a >= 3200) {
        cout << s << "\n";
    } else {
        cout << "red" << endl;
    }


    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<queue>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SORT(list) sort(ALL((list)));
#define MOD 1000000007
using namespace std;
using ll = long long;
int main(){
    ll n,a,b;
    cin >> n >> a >> b;
    ll unit = a+b;
    ll answer = 0;
    answer += (n/unit) * a;
    
    if(n%unit <= a)answer += n%unit;
    else answer += a;
    cout << answer << endl;
    return 0;
}

Measured memory_bytes: 256
S = input()
Q = int(input())
reverse = False
front = ""
end = ""
 
for i in range(Q):
    inp = input()
    if inp[0] == "1":
        reverse = not reverse
    else:
        _, F, C = inp.split()
        if (F == "1") ^ reverse:
            front = front+C
        else:
            end = end+C
if reverse:
    print(end[::-1]+S[::-1]+front)
else:
    print(front[::-1]+S+end)


Measured memory_bytes: 4468
/******************************************************************************
 
рассвет. 
 
*******************************************************************************/
#include <bits/stdc++.h>
typedef long long int lli;
typedef unsigned long long int ulli;
typedef long double ld;
#define rapgame ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back
#define eb emplace_back
#define vi vector <int>
#define vlli vector <lli>
#define vulli vector <ulli>
#define vchar vector <char>
#define vstr vector <string>
#define vb vector <bool>
#define fst first
#define sec second
#define all(a) (a).begin(),(a).end()
#define srt(a) sort(a.begin(),a.end())
#define rev(a) reverse(a.begin(),a.end())
#define vpii vector <pair <int,int> >
#define pii pair <int,int> 
#define pll pair <lli,lli> 
#define vplli vector <pair <lli,lli> >
#define vvi vector <vector <int> >
#define vvlli vector <vector <lli> >
#define vvpii vector <vector <pair <int,int>> >
#define fr(i,n) for (int i = 0; i < (n); ++i)
#define frbig(i,n) for (lli i = 0; i < (n); ++i)
#define fra(i,a,n) for (lli i = a; i < (n); ++i)
#define run(c,s) for(auto c:s) 
#define read(n) int n; cin >> n;
#define readchar(n) char n; cin >> n;
#define readstr(n) string n; cin >> n;
#define readarr(a,n) fr(i,n) cin >> a[i];
#define read2(x,y) int x,y; cin >> x >> y;
#define read2ll(x,y) long long int x,y; cin >> x >> y;
#define readll(n) lli n; cin >> n;
#define watch(x) cout << (#x) << " is " << (x) << endl
#define print_array(x) fr(i,x.size()) cout << x[i] << " ";
using namespace std;
 
const lli MOD=1e9+7;
const lli MAXN=2e6;
const lli INF=2e18;
const ld PI=acos(-1);
 
int main(){
    rapgame
    //freopen("brokeday.in", "r", stdin);
    //freopen("richday.out", "w", stdout);
    int t=1;
    //cin>>t;
    while(t--){
        read(n);
        cout << n+n*n+n*n*n;
    }
    return 0;
}

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

int main() {
    long mod = 1e9+7;
    long X, Y;
    cin>>X>>Y;
    long ans;
    if((X+Y)%3!=0) ans = 0;
    else {
        long n, m;
        n = (2*Y-X)/3;
        m = (2*X-Y)/3;
        if(n<0 | m<0){
            ans = 0;
        }
        else {
            long ue=1;
            long sita=1;
            for(long i=0;i<n;++i){
                ue *= (n+m-i);
                ue %= mod;
                sita *= i+1;
                sita %= mod;
            }
            long hp = mod - 2;
            long sita1=1;
            while(hp!=0){
                long tmp = sita;
                long tmp1 = 1;
                while(tmp1*2 <= hp){
                    tmp1 *= 2;
                    tmp *= tmp;
                    tmp %= mod;
                }
                hp -= tmp1;
                sita1 *= tmp;
                sita1 %= mod;
            }
            ans = (ue*sita1)%mod;
        }
    }
    cout<<ans<<endl;
}


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

using namespace std;
using   ll=long long;

#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

#define pb          	push_back
#define mp          	make_pair
#define F           	first
#define S           	second
#define int             long long int
#define pll				pair<int , int>

#define ALL(v)      	v.begin(),v.end()
#define ALLR(v)     	v.rbegin(),v.rend()
#define pii         	3.14159265358979323
#define inf     		LLONG_MAX
#define ones(x)     	__builtin_popcount(x)
#define fill(a,b)   	memset(a,b,sizeof(a))
#define mod 			1000000007
#define hell            998244353

ll mod_pow(ll a,ll b,ll m)
{
    ll res = 1;
    while(b)
    {
        if(b&1)
        {
        	res=(res*a) % m;
        }
        a=(a*a) % m;
        b>>=1;
    }
    return res;
}

ll mod_inverse(ll a)
{
	return mod_pow(a , mod-2 , mod);
}

void solve()
{
	int n , k;
	
	cin >> n >> k;
	
	int arr[k] {};
	
	int near = (n/k)*k;
	
	for(int i = 0; i < k; ++i) {
		arr[i] = (n/k);
		
		if(n % k >= i && i != 0) {
			arr[i]++;
		}
	}
	
	int ans = 0;
	
	for(int i = 0; i < k; ++i) {
		int a = i;
		int b = (k - a) % k;
		int c = (2*k - b) % k;
		
		if((a+c) % k == 0) {
			ans = ans + (arr[a]*arr[b]*arr[c]);
		}
	}
	
	cout << ans;
}

signed main() {
	fast;
   
    int t = 1;

	//cin >> t;

    while(t--) {
        solve();
    }

    return 0;
}


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

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

#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define MIN(a) *min_element(all(a))
#define MAX(a) *max_element(all(a))
#define SUM(a) accumulate(all(a), 0LL)
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define RREP(i, n) for(int (i)=(n)-1; (i)>=0; (i)--)
#define FOR(i, m, n) for(int (i)=(m); (i)<(n); i++)
#define FORR(i, m, n) for(int (i)=(n)-1; (i)>=(m); i--)
#define debug(x) cerr << #x << " = " << x << endl
//#define int long long

typedef long long ll;
//ll const MOD = 998244353;
ll const MOD = 1e9+7;
int const inf = 1e9;
ll const INF = 1e18;

inline void ios_(){cin.tie(0); ios::sync_with_stdio(false);}
template<typename T> int size(const T& a){return (int)a.size();}
template<typename T> T Div(T a, T b){return (a + b - 1) / b;}
template<typename T> bool chmin(T& a, const T& b){if(a > b){a = b; return true;} return false;}
template<typename T> bool chmax(T& a, const T& b){if(a < b){a = b; return true;} return false;}

bool f(string s){
    bool res = true;
    int n = s.size();
    REP(i, n/2){
        res &= s[i] == s[n - 1 - i];
    }
    return res;
}

signed main(){
    string str;
    cin >> str;
    int n = str.size();
    string s = str.substr(0, (n-1)/2);
    string t = str.substr((n+1)/2);
    cout << (f(str) && f(s) && f(t) ? "Yes" : "No") << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int m(int x){
  if(x==1)return 300000;
  if(x==2)return 200000;
  if(x==3)return 100000;
  else return 0;
}
int main(){
  int a, b;
  cin >> a >> b;
  int sum = 0;
  sum+=m(a)+m(b);
  if(a==1&&b==1)sum+=400000;
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define mkp make_pair
#define rep(i,s,f) for(i=s;i<f;i++)
#define db cout<<'h'<<'i'<<endl 
#define pb push_back
#define pii pair<int,int>
#define F first
#define S second
#define B begin()
#define E end()
#define vi vector<int>
#define vii vector<pair<int,int>>
#define boost ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define PI 3.14159265
#define mod 1000000007
#define mod2 998244353
#define space 100005
//<<fixed << setprecision(9)

int main()
{
    int n,i,j,t;
    boost;

    cin>>n>>j;
    for(i=j-n+1;i<=j+n-1;i++)
    {
        if(i>=-1e6 && i<=1e6)
        {
            cout<<i<<' ';
        }
    }

    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fcout cout<<fixed<<setprecision(10)
int a,b,c,d;
int main(){
    cin>>a>>b>>c>>d;
    fcout<<double(b)*double(a)/2<<" "<<(c*2==a&&d*2==b?1:0)<<endl;
}


Measured memory_bytes: 256
#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
const ll Inf = 3023372036854775807;
const int inf = 1500000000;
#define int long long
//----------------------------------------------------
int x, n;
signed main() {
	cin >> n >> x;
	int t = 1;
	if (x == 2) t = 5;
	if (x == 1 || x == 2 * n - 1) {
		cout << "No\n";
	}
	else {
		cout << "Yes\n";
		if (n == 2) {
			cout << "1\n2\n3\n";
		}
		else {
			for (int i = 0; i < 2 * n - 1; i++) {
				if (i == n - 1) cout << x << endl;
				else if (i == n) {
					if (x == 2) cout << x - 1 << endl;
					else cout << x + 1 << endl;
				}
				else if (i == n - 2) {
					if (x == 2) cout << x + 1 << endl;
					else cout << x - 1 << endl;
				}
				else if (i == n + 1) {
					if (x == 2) cout << x + 2 << endl;
					else cout << x - 2 << endl;
				}
				else {
					if (x != 2) {
						if (t == x - 2) {
							t = x + 2;
						}
					}
					cout << t << endl;
					t++;
				}
			}
		}
	}
}

Measured memory_bytes: 1536
package main

import (
	"fmt"
	"bufio"
	"os"
	"strings"
	"strconv"
)

func main() {

	// 繰り返し回数
	N, _ := strconv.Atoi(readLine())

	strWords := strings.Fields(readLine())

	arr := make([]int, 0)
	for _, strWord := range strWords {
		intWord, _ := strconv.Atoi(strWord)
		arr = append(arr, intWord)
	}

	changeNum := 0
	// n
	for n := 0; n < N-1; {

		//fmt.Println(arr[n], "ターゲット", n)
		//fmt.Println(arr)
		//fmt.Println(range_f, "####", range_l)

		range_f := n
		range_l := N - 1

		min_k := range_f

		// 最終ラインまで
		for ; range_f != range_l+1; {

			// 最小値を更新する
			if arr[min_k] > arr[range_f] {
				min_k = range_f
			}
			range_f++
		}

		// 最小値とターゲットを交換
		if min_k != n {
			//fmt.Println(arr[n], " ==> ", arr[min_k])

			changeNum++

			temp := arr[n]
			arr[n] = arr[min_k]
			arr[min_k] = temp
		}
		//fmt.Println(arr)
		n++
	}

	fmt.Println(reduce(arr))
	fmt.Println(changeNum)

	return
}

var rdr = bufio.NewReaderSize(os.Stdin, 1000000)

func readLine() string {
	buf := make([]byte, 0, 1000000)
	for {
		l, p, e := rdr.ReadLine()
		if e != nil {
			panic(e)
		}
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}

func reduce(intArray []int) string {
	reducedString := ""
	for _, inz := range intArray {
		reducedString += " " + strconv.FormatInt(int64(inz), 10)
	}
	return strings.Trim(reducedString, " ")
}



Measured memory_bytes: 3272
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int inf = 0x7ffffff;
const int mod = 1000000007;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll n;
	cin >> n;
	vector<ll> a(n);
	rep(i, n) cin >> a[i];
	ll ans = 0;
	rep(i, 60) {
		ll cnt = 0;
		rep(j, n) {
			if (a[j] & (1ll << i)) cnt++;
		}
		ll now = (1ll << i) % mod;
		(now *= cnt) %= mod;
		(now *= (n - cnt)) %= mod;
		(ans += now) %= mod;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define pb push_back
const int maxn = 10000;
const int INF32 = 1'050'000'000;
const long long INF64 = 4'000'000'000'000'000'000;
const int MOD7 = 1'000'000'007;
const int MOD9 = 1'000'000'009;

ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
int dx[8]={-1,0,1,0,1,1,-1,-1};
int dy[8]={0,-1,0,1,1,-1,1,-1};

int main()
{
	string s;
	cin >> s;
	//--------------------------------------------
	vector<char> vec;
	for(int bit = 0; bit < (1<<3); bit++){
	 	int res = s[0]-'0';
	 	int pos = 1;
	 	vec.clear();
	 	for(int i = 0; i < 3; i++){
	 		if(bit & (1<<i)) res += s[pos++]-'0', vec.pb('+');
 			else res -= s[pos++]-'0', vec.pb('-');
	 	}
	 	if(res == 7) break;
	 }
	 rep(i,3) cout << s[i]-'0' << vec[i];
	 cout << s[3]-'0' << "=7" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(void){
	int a; cin>>a;
	int ue=a/100;
	int shita=a-ue*100;
	if(0<ue&&ue<=12&&0<shita&&shita<=12){
		cout<<"AMBIGUOUS"<<endl;
	}else if(0<ue&&ue<=12){
		cout<<"MMYY"<<endl;
	}else if(0<shita&&shita<=12){
		cout<<"YYMM"<<endl;
	}else{
		cout<<"NA"<<endl;
	}
	
	
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for (int i=0;i<(n);i++)
#define ALL(a) (a).begin(),(a).end()
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define ll long long
#define ull unsigned long long
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
#define vi vector

using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
	int n,a;
	cin >> n >> a;
	vector<int> x(n+1);
	REP(i,n) cin >> x[i+1];
	vi<vi<vi<long long>>> dp(n+1,vi<vi<long long>>(n+1,vi<long long>(n*a+2,0)));
	REP(i,n+1) dp[i][0][0] = 1;
	for(int i = 1;i<=n;i++){
		for(int j = 1;j<=i;j++){
			for(int k = 0;k<=n*a+1;k++){
				if(k-x[i] >= 0)
					dp[i][j][k] = dp[i-1][j-1][k-x[i]] + dp[i-1][j][k];
				else
					dp[i][j][k] = dp[i-1][j][k];
			}
		}
	}
	long long ans = 0;
	for(int i = 1;i<=n;i++){
		ans += dp[n][i][i*a];
		//		cout << dp[n][i][i*a] << endl;
	}
	cout << ans << endl;
  return 0;
}


Measured memory_bytes: 52224
#include <iostream>
using namespace std;
 
int
main()
{
int N;
 
cin >> N;
 
int n = 0;
while(n <= N)
{
if((N-n) % 7 == 0)
{
cout << "Yes\n";
return 0;
}
n += 4;
}
 
cout << "No\n";
 
return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void){
    int N,D;
    scanf("%d%d",&N,&D);

    int w=1+2*D;
    int base=0;
    int count=0;

    while(base<N){
        count++;
        base+=w;
    }

    printf("%d",count);

    return 0;
}

Measured memory_bytes: 128
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <stack>
#include <string>
#include <vector>

#define REP(i, n) for(int i = 0; i < n; ++i)
using namespace std;
using LLONG = long long;
const LLONG MOD = 1000000007;

int main()
{
	int N; LLONG K; cin >> N >> K;
	map<int, LLONG> val2NumMap;
	REP(i, N)
	{
		int ai; LLONG bi; cin >> ai >> bi;
		val2NumMap[ai] += bi;
	}
	LLONG totalNum = 0;
	for (const auto &kvp : val2NumMap)
	{
		totalNum += kvp.second;
		if (totalNum >= K)
		{
			cout << kvp.first << endl;
			break;
		}
	}
}


Measured memory_bytes: 7460
fn main(){
	let mut s = String::new();
	std::io::stdin().read_line(&mut s).unwrap();

	for n in s.trim().chars() {
		print!("{}",
			match n {
				'1' => '9',
				'9' => '1',
				_ => n,
			}
		);
	}
	println!("");
}



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



int main(){
    int n,m;cin >> n >> m;
    vector<P> ans(m);
    if(n % 2){
        for (int i = 1; i <= m; i++) {
            ans[i-1] = mp(i, n-i);
        }
    }
    else{
        int t = (m + 1) / 2;
        for (int i = 0; i < (m + 1) / 2; i++) {
            ans[i] = mp(i+1, n - i);
        }
        int e = m / 2;
        for (int i = 0; i < e; i++) {
            ans[i+t] = mp(i+t+1, (e-i)*2+t+1+i);
        }
    }
    for (int i = 0; i < m; i++) {
        cout << ans[i].fs << " " << ans[i].sc << endl;
    }
    return 0;
}



Measured memory_bytes: 4580
from math import sin, cos, radians, sqrt
a,b,h,m = map(int, input().split())
# 時針:30度/1時間 0.5度/1分
h_deg = h*30 + m*0.5  # H時M分後の時針の角度(deg)
# 分針:6度/1分
m_deg = m*6 # M分後の分針の角度(deg)
h_rad = radians(h_deg)
m_rad = radians(m_deg)
ax = a*cos(h_rad)
ay = a*sin(h_rad)
bx = b*cos(m_rad)
by = b*sin(m_rad)
c2 = (ax-bx)**2 + (ay-by)**2
print(sqrt(c2))


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

// int dp[105][4][2];

int main() {
  string S;
  cin >> S;
  int n = S.size();
  int K;
  cin >> K;
  
  // dp[i][j][k]
  // i桁目まで決めてj個の非0を使って、
  // k=0：i桁目まではNと一致している
  // k=1：i桁目まででNより小さいことが確定している
  vector<vector<vector<int> > > dp(105, vector<vector<int>>(4, vector<int>(2, 0)));
  dp[0][0][0] = 1;
  rep(i, n) rep(j, 4) rep(k, 2) {
    int nd = S[i] - '0';  // 今の桁
    rep(d, 10) { // 次の桁
      int ni = i + 1, nj = j, nk = k;
      if (d != 0) nj++;
      if (nj > K) continue;
      if (k == 0) {
        if (d > nd) continue;  // Sよりも大きい場合
        if (d < nd) nk = 1;
      }
      dp[ni][nj][nk] += dp[i][j][k];
    }
  }

  int ans = dp[n][K][0] + dp[n][K][1];
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
n = gets.to_i
a = gets.split.map{|a| a.to_i}
for i in (0..n-1)
  a[i] -= i+1
end
a = a.sort
if n%2==1
  m = (n-1)/2
  b = a[m]
else
  m = n/2
  b= (a[m]+a[m-1])/2
end
puts a.inject(0){|memo,item| memo +(item-b).abs}


Measured memory_bytes: 19072
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    string s;
    cin>>n>>s;
    ll num=0;
    for(int i=1;i<n;i++){
    	if(s[i]=='E')num++;
    }
    ll ans=num;
    for(int i=1;i<n;i++){
    	if(s[i-1]=='W')num++;
    	if(s[i]=='E')num--;
    	ans=min(ans,num);
    }
    cout << ans<<endl;
    return 0;
}

Measured memory_bytes: 720
#include <iostream>
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <math.h>
#define int long long
using namespace std;
signed main() {
	int N;
    cin>>N;
    int ans=0;
    int A=0;

    for(double i=0;i<=N;i++){
        A=i*1.08;
        if(A==N){
            
            ans=i;
        }
    }
    if(ans!=0){
        cout<<ans<<endl;
    }
    else{
        cout<<":("<<endl;
    }
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
#define testing 1
#define FOR(i,s,e) for(ll i = s; i <= (ll)e; ++i)
#define DEC(i,s,e) for(ll i = s; i >= (ll)e; --i)
#define IAMSPEED ios_base::sync_with_stdio(false); cin.tie(0);
#define db(x) cerr << #x << "=" << x << "\n"
#define db2(x, y) cerr << #x << "=" << x << " , " << #y << "=" << y << "\n"
#define db3(a,b,c) cerr<<#a<<"="<<a<<","<<#b<<"="<<b<<","<<#c<<"="<<c<<"\n"
#define dbv(v) cerr << #v << ":"; for (auto ite : v) cerr << ite << ' '; cerr <<"\n"
#define dbvp(v) cerr << #v << ":"; for (auto ite : v) cerr << "{"  << ite.f << ',' << ite.s << "} "; cerr << "\n"
#define dba(a,ss,ee) cerr << #a << ":"; FOR(ite,ss,ee) cerr << a[ite] << ' '; cerr << "\n"
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define ll long long 
#define pb push_back
#define inf (int)(1e9+500)
#define oo (ll)(1e18+500)
#define all(x) (x).begin(), (x).end()
#define f first
#define s second
#define reach cerr << "LINE: " << __LINE__ << "\n";
typedef pair <int, int> pi;
typedef tuple<int,int,int> ti3;
string cts(char x) {string t(1,x); return t;}
ll rand(ll a, ll b) { return a + rng() % (b-a+1); }
const int MOD = 1e9 + 7;
template <typename T> void chmax(T& a, T b) { a = max(a, b); }
template <typename T> void chmin(T& a, T b) { a = min(a, b); }
#define MAXN (int)1e5+5
#if !testing
#define cerr if(0)cout
#endif
int A[MAXN];

struct ufds_ {
	int p[MAXN];
	ufds_() {
		FOR(i,0,MAXN-1)p[i]=i;
	}
	int find(int x) {
		if(x==p[x])return x;
		else return p[x]=find(p[x]);
	}
	void merge(int a, int b) {
		a = find(a), b = find(b);
		p[b]=a;
	}
	
} ufds;
int32_t __attribute__((optimize("Ofast"), target("arch=sandybridge"))) main()
{
	IAMSPEED
	int n,m; cin >> n >> m;
	FOR(i,1,n)cin>>A[i];
	FOR(i,1,m) {
		int a,b; cin >> a >> b;
		ufds.merge(a,b);
	}
	int ans = 0;
	FOR(i,1,n) {
		if(i==A[i])++ans;
		else if(ufds.find(A[i])==ufds.find(i))++ans;
	}
	cout<<ans;
	
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef pair<long long, long long> P;
#define override_rep(i, l, r, mes, ...) mes
#define rep1(i, n) for (int i = 0; i < n; i++)
#define rep2(i, l, r) for (int i = l; i < r; i++)
#define rep(...) override_rep(__VA_ARGS__, rep2, rep1)(__VA_ARGS__)
#define int long long
template<typename T, typename U>
istream& operator>>(istream& in, pair<T, U>& p) {
	in >> p.first >> p.second;
	return in;
}

signed main(signed argc, char* argv[]) {
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	const int MOD = 1e9 + 7;
	int h,n;
	cin>>h>>n;
	rep(i,n){
	    int a;
	    cin>>a;
	    h-=a;
	}
	if(h>0)cout<<"No"<<endl;
	else cout<<"Yes"<<endl;
}

Measured memory_bytes: 256
N = int(input())


def max_square(n):
    """
    >>> max_square(10)
    9
    >>> max_square(81)
    81
    >>> max_square(271828182)
    271821169
    """
    base = 0
    while (base + 1)**2 <= n:
        base += 1
    return base**2


print(max_square(N))


Measured memory_bytes: 2940
N = int(input())
S = [input() for _ in range(N)]

res = 0
counta = 0
countb = 0
countab = 0

for s in S:
    res += s.count("AB")
    if s[0] == "B" and s[-1] == "A":
        countab += 1
    elif s[0] == "B":
        countb += 1
    elif s[-1] == "A":
        counta += 1

if counta + countb == 0:
    res += max(0, countab - 1)
else:
    res += countab + min(counta, countb)

print(res)


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

using namespace std;
const long long INF = 1LL <<60;
const long long Mo=1000000007;
         

long long gcn(long long x,long long y){
  if(x%y==0){  
    return y;    
  }
  else{
    return gcn(y,x%y);
  }
}

long long modpow(long long a, long long n, long long mod) {
  long long res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

long long pow_fast(long long a, long long n){
  long long x=1;
  while(n>0){
    if(n&1){
      x=x*a%Mo;
    }
    a=a*a%Mo;
    n>>=1;
  }
  return x;
}

int main(void){
  long long tmp,tmp1,tmp2;
  long long n,b,c;
  long long i,j;
  long long res=0;
  long long ave=0;

  cin>>n;
  long long a[n];
  for(i=0;i<n;i++){
    cin>>tmp;
    a[i]=tmp-(i+1);
    //cout<<a[i]<<endl;
  }

  sort(a,a+n);
  
  if(n%2==0){
    tmp=a[n/2];
  }
  else{
    tmp=a[(n-1)/2];
  }
  for(i=0;i<n;i++){
    res+=abs(a[i]-tmp);
  }
  
  //cout<<setprecision(15)<<res<<endl;
  cout<<res<<endl;

  
  return 0;
}

Measured memory_bytes: 5088
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// using namespace __gnu_pbds;
// gp_hash_table<int, int> mapka;

using namespace std;
#define PB push_back
#define MP make_pair
#define LL long long
#define int LL
#define FOR(i,a,b) for(int i = (a); i <= (b); i++)
#define RE(i,n) FOR(i,1,n)
#define REP(i,n) FOR(i,0,(int)(n)-1)
#define R(i,n) REP(i,n)
#define VI vector<int>
#define PII pair<int,int>
#define LD long double
#define FI first
#define SE second
#define st FI
#define nd SE
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())

template<class C> void mini(C &a4, C b4) { a4 = min(a4, b4); }
template<class C> void maxi(C &a4, C b4) { a4 = max(a4, b4); }

template<class TH> void _dbg(const char *sdbg, TH h){ cerr<<sdbg<<'='<<h<<endl; }
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',')cerr<<*sdbg++;
  cerr<<'='<<h<<','; _dbg(sdbg+1, a...);
}

template<class T> ostream &operator<<(ostream& os, vector<T> V) {
  os << "["; for (auto vv : V) os << vv << ","; return os << "]";
}
template<class L, class R> ostream &operator<<(ostream &os, pair<L,R> P) {
  return os << "(" << P.st << "," << P.nd << ")";
}

#ifdef LOCAL
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define debug(...) (__VA_ARGS__)
#define cerr if(0)cout
#endif

const int MAX = 100001;
int n,m;
int f[MAX];
vector<int> d[MAX];
vector<PII> res;
int deg[MAX];
int find(int v){
  return f[v] == v ? v : f[v] = find(f[v]);
}
bool uni(int a,int b){
  a = find(a);
  b = find(b);
  if(a == b)return 0;
  f[a] = b;
  return 1;
}
bool dfs(int v,int oj){
  for(int el:d[v])if(el!=oj){
    if(dfs(el,v)){
      deg[v] ^= 1;
    }
  }
  if(deg[v] % 2){
    res.PB({v,oj});
    return 0;
  }else{
    res.PB({oj,v});
    return 1;
  }
}

int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout << fixed << setprecision(11);
  cerr << fixed << setprecision(6);
  cin >> n >> m;
  if(m & 1){
    cout << "-1\n";
    return 0;
  }
  R(i,n){
    f[i] = i;
  }
  R(i,m){
    int a,b;
    cin >> a >> b;
    a--;b--;
    if(uni(a,b)){
      d[a].PB(b);
      d[b].PB(a);
    }else{
      deg[a] ^= 1;
      res.PB({a,b});
    }
  }
  dfs(0,-1);
  for(PII el:res){
    if(el.FI != -1 && el.SE != -1){
      cout << el.FI + 1 << " " << el.SE + 1 << "\n";
    }
  }
}


Measured memory_bytes: 15472
H, W = gets.chomp.split.map(&:to_i)

G = Array.new(H + 1)
(1..H).each do |i|
  G[i] = gets.chomp.split.map{|x| x.to_i % 2 == 1}.unshift(nil)
end

ans = []
(1...H).each do |i|
  g1 = G[i]
  g2 = G[i + 1]
  (1..W).each do |j|
    if g1[j]
      ans << "#{i} #{j} #{i + 1} #{j}"
      g2[j] = !g2[j]
    end
  end
end

g = G[H]
(1...W).each do |j|
  if g[j]
    ans << "#{H} #{j} #{H} #{j + 1}"
    g[j + 1] = !g[j + 1]
  end
end

puts ans.size
puts ans

Measured memory_bytes: 19580
#include <iostream>
#include <cstdio>
int prime[10001];

int main(){
	prime[0] = prime[1] = 0;
	for(int i=2;i<=10000;++i){
		if(prime[i]==0){
			prime[i]=1;
			for(int j=i*2;j<=10000;j+=i){
				prime[j]=2;
			}
		}else{
			continue;
		}
	}
	int n;
	while(scanf("%d", &n), n){
		for(int i = n; i >= 2; --i){
			if(prime[i]==1 && prime[i-2]==1){
				printf("%d %d\n",i-2, i);
				break;
			}
		}
	}
}

Measured memory_bytes: 1224