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

#define FOR(i, j, n) for (int i(j); i < n; ++i)
#define FORR(v, c) for (auto &v : c)
#define F first
#define S second
#define SQ(x) (x)*(x)
#define pb push_back
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define dbg(x) std::cerr<<#x<<" = " << (x) << std::endl
#define pnl(x) std::cout << x << '\n'
#define pns(x) std::cout << x << ' '
#define read(x) std::cin >> x
#define read2(x,y) std::cin >> x >> y
#define read3(x, y, z) std::cin >> x >> y >> z
#define read4(a, b, c, d) std::cin >> a >> b >> c >> d
#define readv(v) FORR(c,v) read(c)

struct Arrete { int v, c;};
struct Point {int x, y; double distance(Point other) const {return sqrt(SQ(x-other.x)+SQ(y-other.y));}};

typedef	std::vector<int>	vi;
typedef std::pair<int,int>	ii;
typedef std::vector<std::string>	vs;
typedef std::vector<ii>	vii;
typedef std::vector<Arrete>	vg;
typedef std::vector<long long>	vl;
typedef	long long ll;

const int	NB_D = 4;
const int	DY[] = {-1, 1, 0, 0};
const int	DX[] = {0, 0, -1, 1};

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

	ll	N, M;
	read2(N, M);
	if (N == 1 and M == 1) pnl(1);
	else if(N == 1) pnl(std::max(0LL,M-2));
	else if (M == 1) pnl(std::max(0LL, N-2));
	else pnl(std::max(0LL, (N-2)*(M-2)));
}



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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
using P = pair<ll, ll>;
using V = vector<ll>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep1(i, n) for(ll i=1;i<=(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define MOD 1000000007
#define INF 1000000000

void solve_abc_a() {
	ll n, m;
	ll x, y;
	ll a, b, d;
	ll h;
	ll k;
	string s, t;
	char c;
	ll l_ans = 0;
	string s_ans = "NG";

	cin >> a;

	l_ans = a + a * a + a * a * a;

	cout << l_ans << "\n";

	return;
}


int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed;
	cout << setprecision(7);

	solve_abc_a();

	return 0;
}

Measured memory_bytes: 3664
/*版权所有，拷贝必究！*/
/*若想获得，请联系许希泉*/
#include<bits/stdc++.h>
#pragma GCC optimize("O999")
const int INF = 0x3f3f3f3f;
int maxn=5000005;
using namespace std;

bool is_pal(string a)
{
    string s=a;
    reverse(s.begin(),s.end());
    if(s==a)
    return true;
    else
    return false;
}
bool is_prime(int n)
{
    if(n==1)
	return false;
    if(n==2||n==3)
	return true;
    if(n%6!=1&&n%6!=5)
	return false;
    for(register int i=5;i*i<=n;i+=6)
    if(n%i==0||n%(i+2)==0)
	return false;
    return true;
}
int main()
{
 	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	ios::sync_with_stdio(0);
	string s1,s2;
    int h,a,n,m,x,y,sum=0;
    cin>>h>>a;
    n=h/a;
    if(a*n>=h)
	cout<<n;
	else
	cout<<n+1;
    
    return 0;
}


Measured memory_bytes: 256
'''
自宅用PCでの解答
'''
import math
#import numpy as np
import itertools
import queue
import bisect
from collections import deque,defaultdict
import heapq as hpq
from sys import stdin,setrecursionlimit
#from scipy.sparse.csgraph import dijkstra
#from scipy.sparse import csr_matrix
ipt = stdin.readline
setrecursionlimit(10**7)
mod = 10**9+7
dir = [(-1,0),(0,-1),(1,0),(0,1)]
alp = "abcdefghijklmnopqrstuvwxyz"

def main():
    n,k = map(int,ipt().split())
    if k > (n-1)*(n-2)//2:
        print(-1)
    else:
        num = (n-1)*(n-2)//2-k
        print(num+(n-1))
        for i in range(2,n+1):
            print(1,i)
        for i in range(2,n+1):
            for j in range(i+1,n+1):
                if num == 0:
                    break
                print(i,j)
                num -= 1
    


    return None

if __name__ == '__main__':
    main()


Measured memory_bytes: 76368
from pprint import pprint
import sys

s = sys.stdin.readline().strip()
t = sys.stdin.readline().strip()

len_s = len(s)
ss = s+s
 
#table[ord(t)-97][i] = 文字tがi番目orそれ以降で登場する最初のindex
table = [[-1] * (len_s * 2) for _ in range(26)]
prev = [-1] * 26
for i,c in enumerate(ss):
    cind = ord(c)-97
    table[cind][prev[cind]+1:i+1] = [i] * (i - prev[cind])
    prev[cind] = i
# pprint(table)

ans = 0
now = 0
for i in t:
    pos = table[ord(i)-97][now]
    if pos == -1:
        print(-1)
        exit()

    ans += pos + 1 - now
    now = ans % len_s

print(ans)

Measured memory_bytes: 103772
A,B,M = list(map(int, input().split()))
a = list(map(int, input().split()))
b = list(map(int, input().split()))
x =[]
y = []
c = []
wari = []
for i in range (M):
    s = list(map(int, input().split()))
    x.append(s[0])
    y.append(s[1])
    c.append(s[2])
for j in range(M):
    d = a[x[j]-1] + b[y[j]-1] - c[j]
    wari.append(d)
f1 = min(a) + min(b)
f2 = min(wari)
if f1 >= f2:
    print(f2)
else:
    print(f1)

Measured memory_bytes: 28076
import Control.Monad
import Data.Maybe
import qualified Data.ByteString.Char8 as BS
import Data.List

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine

main = do
    [n,m] <- getIntList
    ab <- concat <$> replicateM m getIntList
    let check = all even . map length . group $ sort ab
    putStrLn $ if check then "YES" else "NO"

Measured memory_bytes: 42560
import itertools
import math
import sys
from collections import Counter
from fractions import gcd
from functools import reduce
import sys
sys.setrecursionlimit(4100000)

INF = 1 << 60

# ここから書き始める
n = int(input())
cnt = [[0] * 9 for i in range(9)]
# print(len(cnt), len(cnt[0]))
# print(cnt)
for i in range(1, n + 1):
    prefix = int(str(i)[0])
    suffix = int(str(i)[-1])
    if suffix != 0:
        cnt[prefix - 1][suffix - 1] += 1
ans = 0
for i in range(9):
    for j in range(9):
       ans += cnt[i][j] * cnt[j][i]
print(ans)


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

int main(){
    int N, L;
    string input;
    list<string> ls;
    list<string>::iterator itr;
    
    cin >> N >> L;
    for (int i=0; i<N; i++){
        cin >> input;
        ls.push_back(input);
    }
    ls.sort();
    for (itr=ls.begin(); itr!=ls.end(); itr++){
        cout << *itr;
    }
    return 0;
}

Measured memory_bytes: 3596
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc =new Scanner(System.in);
    String N =sc.next();
    int n =N.length();
    if(n==1){System.out.println(N);System.exit(0);}
    String M[]=N.split("",0);
    int x=0;
    for(int i=1;i<n;i++){
      if(!(M[i].equals("9"))){x=-1;break;}}
    long m =Integer.parseInt(M[0]);
    long ans ;
    if(x==-1){ans=m-1+(n-1)*9;}
    else{ans =m+(n-1)*9;}
    System.out.println(ans);
  }
}

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

#define fastio                  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define input_output            freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); 

#define ll                      long long
#define read1(x)                 cin>>x
#define read2(x,y)               cin>>x>>y
#define print(x)				cout<<x<<endl
#define pii                     pair<int, int>
#define pli                     pair<ll, int>
#define pil                     pair<int, ll>
#define pll                     pair<ll, ll>
#define vi                      vector<int>
#define vll                     vector<ll>
#define vb                      vector<bool>
#define vd                      vector<double>
#define vs                      vector<string>
#define ff                      first
#define ss                      second
#define pb                      push_back
#define ppb                     pop_back
#define pf                      push_front
#define ppf                     pop_front
#define vpii                    vector<pii>
#define umap                    unordered_map
#define uset                    unordered_set
#define clr(a,b)                memset(a,b,sizeof a)
#define all(ds)                 ds.begin(), ds.end()
#define rev(ds)                 ds.rbegin(), ds.rend()
#define asc(A)                  sort(A.begin(), A.end())
#define dsc(A)                  sort(A.begin(), A.end(), greater<int>())
#define gcd(x,y)                __gcd(x,y)
#define clr(a,b)                memset(a,b,sizeof a)
#define fr(i, n)                for(int i=0; i<n;++i)
#define fr1(i, n)               for(int i=1; i<=n; ++i)
#define rfr(i, n)               for(int i=n-1; i>=0; --i)
#define printVector(v)          for(int i= 0;i<v.size();i++) {cout<<v[i]<<" ";} cout<<endl;
#define precise(x)              cout<<fixed<<setprecision(x)
#define inf                     10000000000000

 

ll lcm(ll a, ll b) {return (a*b)/__gcd(a, b); }
ll power(ll x, ll y, ll m) { if(!y) return 1; ll p=power(x, y>>1, m)%m; p=p*p%m; return (y&1)?(x*p)%m:p;}
ll modInverse(ll a, ll m){ return power(a, m-2, m); }
bool isPrime(ll num){bool flag=true;for(ll i =2;i<=num/2;i++){if(num%i==0) {flag=false; break;} }return flag;}
ll sumofdigits(ll n){ll c=0;while(n>0){c++;n/=10;}return c;}
bool sortinrev(const pair<int,int>&a,const pair<int,int>&b) {return a.first > b.first; }
bool sortbysec(const pair<int,int> &a, const pair<int,int> &b) {return a.second < b.second; }

//const double PI= 2*acos(0.0);
// const long long MOD= 1000000007;



void solve(){
    ll x, k, d;
    cin>>x>>k>>d;
    x = abs(x);
    ll mn = min(k, x/d);
    k -= mn;
    x -= (mn*d);
    if(k&1)cout<<abs(x-d)<<endl;
    else cout<<x<<endl;
}
int main()
{
#ifndef ONLINE_JUDGE  
    input_output  
#else   
    fastio
#endif

    int t =1 ;
    // cin>>t;
    while(t--){
        solve();
    }

    return 0;
}

Measured memory_bytes: 3656
fun main(args: Array<String>) {
    edpc()
}

fun edpc() {
    val n = readLine()!!.toInt()
    val vacations = (1..n)
        .map { readLine()!!.split(" ").map { it.toLong() } }

    val dp = Array(n + 1) { LongArray(3) { 0 } }
    dp[0][0] = vacations[0][0]
    dp[0][1] = vacations[0][1]
    dp[0][2] = vacations[0][2]

    for (i in 1 until n) {
        for (j in 0..2) {
            (0..2).filter { it != j }.forEach {
                dp[i][j] = Math.max(dp[i][j], dp[i - 1][it] + vacations[i][j])
            }
        }
    }

    val answer = dp[n - 1].max()!!

    println(answer)
}


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

long long MOD = 1000000007;

int main(){
    //input
    long long N;
    cin >> N;
    long long A[N+1];
    long long i, j;
    for(j=1; j<=N; j++){
        cin >> A[j];
    }

    //calc
    long long ans=1;
    long long height[3];
    height[0]=-1;
    height[1]=-1;
    height[2]=-1;
    for(j=1; j<=N; j++){
        i = lower_bound(height,height+3,A[j])-height;
        i--;
        if(i<0){
            ans=0;
            break;
        }
        if(height[i]+1!=A[j]){
            ans=0;
            break;
        }
        if(i==2){
            if(height[2]==height[1]){
                if(height[1]==height[0]){
                    ans = (ans*3)%MOD;
                    height[2]++;
                }else{
                    ans = (ans*2)%MOD;
                    height[2]++;
                }
            }else{
                height[2]++;
            }
        }else if(i==1){
            if(height[1]==height[0]){
                ans = (ans*2)%MOD;
                height[1]++;
            }else{
                height[1]++;
            }
        }else if(i==0){
            height[0]++;
        }
    }

    //answer
    cout << ans << endl;
    system("pause");
    return 0;
}

Measured memory_bytes: 1272
#include <bits/stdc++.h>
#include <typeinfo>
#include <cxxabi.h>
#ifdef LOCAL
#include "dbgtoki.hpp"
#define DUMP(i) dump((string)TOSTRING(i), demangle(typeid(i).name()), __LINE__ , i) 
#else
#define DUMP(i) 
#endif

using namespace std;
#define TOSTRING(x) #x
#define SZ(x) (int)(x).size()
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(s) (s).begin(), (s).end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()) , v.end());
#define dis distance


typedef long long unsigned int llu;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
const int EPS = 1e-9;
const int MOD = 1e9+7;


int main (){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vi A(n);
  REP(i,n)cin >> A[i];
  sort(ALL(A));
  int ma = A[n-1];
  cout << ma << " ";
  A.erase(A.begin()+n-1,A.end());
  int ind = dis(A.begin(),upper_bound(ALL(A),ma/2));
  DUMP(ind);
  int ans = -INT_MAX;
  if(ind < n-1){
    ans = A[ind];
  }
  DUMP(ans);
  if(ind - 1 >= 0){
    if(abs(ma/2-ans) > abs(ma/2-A[ind-1])){
      ans = A[ind-1];
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include<algorithm>
#include<string>
using namespace std;
typedef long long int ll;
int main(void) {
	ll a, b, n, sum,s,amari;
	cin >> n >> a >> b;
	sum = a + b;
	s = n / sum; amari = n % sum;
	if (a < amari)
		cout << s * a + a << endl;
	else
		cout << s * a + amari << endl;
    return 0;
}

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

using pii = pair<int, int>; using vpii = vector<pii>;
using vi = vector<int>; using vvi = vector<vi>;
using ll = long long;
using pll = pair<ll, ll>; using vpll = vector<pll>;
using vll = vector<long long>; using vvll = vector<vll>;
template <class T> using min_queue = priority_queue<T, vector<T>, greater<T>>;
template <class T> istream &operator>>(istream &, vector<T> &);
template <class T> ostream &operator<<(ostream &, const vector<T> &);
template <class T, class U> istream &operator>>(istream &, pair<T, U> &);
template <class T, class U> ostream &operator<<(ostream &, const pair<T, U> &);
template <class T> struct Inf { static constexpr T inf() { return std::numeric_limits<T>::has_infinity ? std::numeric_limits<T>::infinity() : std::numeric_limits<T>::max(); } };
template <> struct Inf<int> { static constexpr int inf() { return 0x3f3f3f3f; } };
template <> struct Inf<long long> { static constexpr long long inf() { return 0x3f3f3f3f3f3f3f3fLL; } };
constexpr int INF = Inf<int>::inf(); constexpr ll BINF = Inf<ll>::inf();
// mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
// }}}
// Preprocessing & "Global" variables {{{
struct Solver {
	Solver() {}
	int solve();
};
// }}}

int Solver::solve() {
	char c; cin >> c;
	if (isupper(c))
		cout << 'A' << endl;
	else
		cout << 'a' << endl;
	return 0;
}

// Template Main {{{
int main() {
	ios::sync_with_stdio(0); cin.tie(0);
	Solver solver;
	#ifdef JUDGE_MULTI_CASE
		int t; cin >> t; for (int i = 1; i <= t; i++)
	#endif
	solver.solve();
	// cout << "Case #" << i << ": ", solve();
	return 0;
}

template <class T> istream &operator>>(istream &is, vector<T> &v) {
	for (auto it=v.begin();it!=v.end();++it) is >> *it;
	return is;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
	for (auto it=v.begin();it!=v.end();) os << *it, os << " \n"[++it==v.end()];
	return os;
}

template <class T, class U> istream &operator>>(istream &is, pair<T, U> &p) {
	return is >> p.first >> p.second;
}

template <class T, class U> ostream &operator<<(ostream &os, const pair<T, U> &p) {
	return os << p.first << ' ' << p.second;
}
// }}}

// vim: fdm=marker


Measured memory_bytes: 3632
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<iomanip>
#include<cstdio>
#include<cstdlib>
#include<cstring>
using namespace std;
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)
#define NREP(i, n) FOR(i, 1, n)
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const ll dx[4] = { 0, -1, 1, 0 };
const ll dy[4] = { -1, 0, 0, 1 };
const int INF = 1e9 + 7;
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}
void mul(ll a, ll b) {
	a = a * b % INF;
}
///////////////////////////////////////


int main() {
	int N; cin >> N;
	set<int>st;
	for (int i = 0; i < N; ++i) {
		int d; cin >> d;
		st.insert(d);
	}
	cout << st.size() << endl;
	return 0;
}

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

mod = 10**9+7

bin_a = []

for i in range(n):
    bin_a.append(format(a[i],'060b'))

ans = 0

for i in range(60):
    one = 0
    zero = 0
    for j in range(n):
        #print(bin_a[j])
        if bin_a[j][i] == '1':
            one += 1
        else:
            zero += 1
    #print(i,zero,one)
    ans += zero * one * (2**(59-i))
    ans %= mod
    
print(ans%mod)

Measured memory_bytes: 127760
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
using namespace std;
typedef long long ll;

int main() {
    int n; ll k;
    cin >> n >> k;
    vector<int> a(n), f(n);
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    for (int i = 0; i < n; i++)
    {
        cin >> f[i];
    }
    
    sort(a.begin(), a.end());
    reverse(a.begin(), a.end());
    sort(f.begin(), f.end());

    ll left = -1, right = 1e12;
    while (left+1 < right) {
        ll mid = (left+right)/2;

        //ラムダ式
        bool ok = [&] {
            ll ex = 0;
            for (int i = 0; i < n; i++)
            {
                ex += max(a[i] - mid/f[i], 0ll);
            }
            return ex <= k;
        }();

        if(ok) right = mid;
        else left = mid;
    }
    cout << right << endl;
    return 0;
}

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

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

	bool lock[100];
	for (int i = 0; i < n; i++)lock[i] = false;
	
	int left = 0, right = 0;
	for (int i = 0; i < n; i++) {
		if (lock[i])continue;
		bool ok = false;
		if (s[i] == '(') {
			for (int j = i + 1; j < n; j++) {
				if (!lock[j] && s[j] == ')') {
					ok = lock[j] = lock[i] = true;
					break;
				}
			}
			if (!ok)right++;
		}
		else {
			for (int j = i - 1; 0 <= j; j--) {
				if (!lock[j] && s[j] == '(') {
					ok = lock[j] = lock[i] = true;
					break;
				}
			}
			if (!ok)left++;
		}
	}
	for (int i = 0; i < left; i++)cout << '(';
	cout << s;
	for (int i = 0; i < right; i++)cout << ')';
	cout << endl;
  
  	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <iomanip>
#include <cassert>
#include <bitset>
using namespace std;

typedef pair<int, int> P;
#define rep(i, n) for (int i=0; i<(n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define index(xs, x) (int)(lower_bound(all(xs), x) - xs.begin())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007
inline void chmin(int &x, int v) {
  if (x > v) x = v;
}

int N;
string S;
int dp[500001][2];
int T[500001];

signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  cin >> N >> S;
  rep(i, N+1) rep(j, 2) dp[i][j] = INF;

  dp[0][0] = 0;
  rep(i, N) {
    if (S[i] == '0') {
      chmin(dp[i+1][0], dp[i][0]);
    }
    else {
      chmin(dp[i+1][0], dp[i][0]+1);
      chmin(dp[i+1][1], dp[i][1]);

      if (i >= 2 && S[i-1] == '0' && S[i-2] == '1') {
        chmin(dp[i+1][1], dp[i-2][0]+1);
        chmin(dp[i+1][0], T[i-2]+1);
      }
      chmin(dp[i+1][0], dp[i+1][1]);
    }
    if (i<N && S[i+1]=='0') T[i+1] = INF;
    else T[i+1] = min(T[i], dp[i+1][0]);
  }
  int ones = 0;
  rep(i, N) if (S[i] == '1') ones++;
  cout << ones-dp[N][0] << "\n";
  return 0;
}


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

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

  int odd = 0, even = 0;
  for(int i = 0; i < n; i++){
    int a;
    cin >> a;

    if(a%2) odd++;
    else even++;
  }

  if(odd%2) cout << "NO" << endl;
  else cout << "YES" << endl;

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
  int N,i,j,num=0;
  int A[100];

  scanf("%d\n",&N);
  for(i = 0 ; i < N ; i++){
    scanf("%d",&A[i]);
  }

  for(i = 0 ; i < N ; i++){
    for(j = 0 ; j < N-1-i ; j++){
      if(A[j] > A[j+1]){
        num++;
        int t = A[j];
        A[j] = A[j+1];
        A[j+1] = t;
      }
    }
  }

  for(i = 0 ; i < N ; i++){
    if(i < N-1) printf("%d ",A[i]);
    else printf("%d",A[i]);
  }
  printf("\n");
  printf("%d\n",num);
  return 0;
}

Measured memory_bytes: 1772
#include <bits/stdc++.h>
using namespace std;
using i64 = int64_t;
using vi = vector<i64>;
using vvi = vector<vi>;

int main() {
    int n;
    cin >> n;
    vvi dp(n + 1, vi(3));
    for (int i = 0; i < n; i++) {
        vi as(3);
        for (int j = 0; j < 3; j++) {
            cin >> as[j];
        }
        for (int j = 0; j < 3; j++) {
            i64 nax = 0;
            for (int k = 0; k < 3; k++) {
                if (j != k) {
                    nax = max(nax, dp[i][k] + as[j]);
                }
            }
            dp[i + 1][j] = nax;
        }
    }
    cout << max({dp[n][0], dp[n][1], dp[n][2]}) << endl;
}

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

typedef long long ll;

ll N, W, Base;
deque<ll> Values[4];
ll R;

int main() {
  cin >> N >> W;
  for (ll i = 0; i < N; ++i) {
    ll w, v;
    cin >> w >> v;
    if (i == 0) Base = w;
    Values[w - Base].push_back(v);
  }
  for (ll i : {0, 1, 2, 3}) {
    sort(Values[i].begin(), Values[i].end(), greater<ll>());
    Values[i].push_front(0);
    for (ll j = 1; j < Values[i].size(); ++j) Values[i][j] += Values[i][j - 1];
  }
  for (ll i = 0; i < Values[0].size(); ++i)
    for (ll j = 0; j < Values[1].size(); ++j)
      for (ll k = 0; k < Values[2].size(); ++k)
        for (ll l = 0; l < Values[3].size(); ++l) {
          if (Base * (i + j + k + l) + j + 2 * k + 3 * l > W) continue;
          R = max(R, Values[0][i] + Values[1][j] + Values[2][k] + Values[3][l]);
        }
  cout << R << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF= 1LL << 60;
#define REP(i,n) for(ll i=0; i<n; i++)
#define FOR(i,a,n) for(ll i=a; i<n; i++)
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);  
    int n;  
    string a,b,c;
    cin >> n >> a >> b >> c;
    int cnt= 0;
    REP(i,n){
        cnt+= ((a[i]==b[i] && a[i]!=c[i]|| a[i]==c[i] && a[i]!=b[i]|| b[i]==c[i]&& b[i]!=a[i])?1:((a[i]==b[i] && b[i]==c[i])?0:2));
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rrep(i,n) for(ll i = 1; i <= (n); ++i)
#define drep(i,n) for(ll i = (n)-1; i >= 0; --i)
#define all(v) v.begin(),v.end()
#define len(x) (ll)(x).length()
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define pb push_back
#define sz(x) (ll)(x).size()
#define v(T) vector<T>
#define vv(T) vector<vector<T>>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
ll gcd(ll a,ll b){if(a%b==0){return b;}else{return(gcd(b,a%b));}}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
const int INF=1e9;
const ll MX = 1e18;
const ll MOD=INF+7;
const int di[] = {-1,0,1,0};
const int dj[] = {0,-1,0,1};
const double PI=acos(-1);
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
const int MAX = 1000001;
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {fac[0] = fac[1] = 1;finv[0] = finv[1] = 1;inv[1] = 1;for (int i = 2; i < MAX; i++){fac[i] = fac[i - 1] * i % MOD;inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;finv[i] = finv[i - 1] * inv[i] % MOD;}}
long long COM(int n, int k){if (n < k) return 0;if (n < 0 || k < 0) return 0;return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;}

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


Measured memory_bytes: 3564
N = int(input())
A = input()
a = A.split()
s = 1
flag = 0
if "0" in a:
    print(0)
else:
    for i in range(N):
        s *= int(a[i])
        if s > 10**18:
            print(-1)
            flag = 1
            break
    if flag == 0:
        print(s)


Measured memory_bytes: 19372
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,m,n) for(ll i = (m); i <= n; i++){cout << (x[i]) << " ";} cout<<endl;

ll n, m;
string s;

int main(){
	cin.tie(0); ios::sync_with_stdio(false);
	
	cin >> s;
	
	string ans = "Yes";
	rep(i, 0, s.size()){
		if((i%2 == 1 && s[i] == 'R') || (i%2 == 0 && s[i] == 'L')){
			ans = "No";
		}
	}
	
	print(ans)
	return 0;
}

Measured memory_bytes: 256
from collections import Counter
n=int(input())
a=list(map(int,input().split()))
C=Counter(a)
#print(C)
total=0
for k,v in C.items():
    if v>=2:
        total+=v*(v-1)//2
#print(total)
for i in range(n):
    V=C[a[i]]
    ans=total-(V*(V-1))//2+((V-1)*(V-2))//2
    print(ans)

Measured memory_bytes: 26772
N,X,Y=map(int,input().split())
X-=1
Y-=1
#ld=[[0 for _ in range(N)] for _ in range(N)]
lnd=[0 for _ in range(N)]#sonomama
for i in range(N):
    for j in range(i+1,N):
        if (0<=i<=X and 0<=j<=X) or (Y<=i<=N-1 and Y<=j<=N-1):
            #ld[i][j]=j-i
            lnd[j-i]+=1

     
        else:
            tmp=min(j-i,abs(i-X)+abs(j-Y)+1)
            lnd[tmp]+=1
for i in range(1,N):
    print(lnd[i])


Measured memory_bytes: 3444
import sys
import fractions
input = sys.stdin.readline

A, B, C, D = map(int, input().split())

total = B - A + 1
count_C = B//C - (A-1)//C 
count_D = B//D - (A-1)//D 
lcm = int(C * D / fractions.gcd(C, D))
count_CD = B//lcm - (A-1)//lcm

print(total - count_C - count_D + count_CD)

Measured memory_bytes: 5048
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools
sys.setrecursionlimit(10**8)
mod = 10**9+7
mod2 = 998244353
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

s = input()
n = len(s)
now = [0] * 13
now[0] = 1
for i in range(n)[::-1]:
    prev = now[::]
    now = [0] * 13
    c = n - i - 1#桁
    m = pow(10,c,13)
    if s[i] == '?':
        for k in range(10):
            l = (m*k) % 13
            for j in range(13):
                now[(j+l)%13] += prev[j]
                now[(j+l)%13] = now[(j+l)%13] % mod
    else:
        k = int(s[i])
        l = (m*k) % 13
        for j in range(13):
            now[(j+l)%13] = prev[j]
    # print(now)
print(now[5])


Measured memory_bytes: 43500
#include<iostream>
using namespace std;
bool b[3][3];
int main()
{
	int d[3][3];
	
	int n;
	for(int i=0;i<3;i++)
	for(int j=0;j<3;j++)
	cin>>d[i][j];
	cin>>n;
	int t;
	while(n--)
	{
		cin>>t;
		for(int i=0;i<3;i++)
		for(int j=0;j<3;j++)
		{
			if(d[i][j]==t)
			{
				b[i][j]=true;
				break;
			}
		}
	}
	
	
	bool flag=false;
	for(int i=0;i<3;i++)
	{
		if(b[0][i]== true and b[1][i]==true and b[2][i]==true) 
		{
			flag=true;
			break;
		}
	}
	for(int i=0;i<3;i++)
	{
		if(b[i][0]== true and b[i][1]==true and b[i][2]==true) 
		{
			flag=true;
			break;
		}
	}
	if(b[0][0]==true and b[1][1]==true and b[2][2]==true) 
	{
		flag=true;
		
	}
	if(b[0][2]==true and b[1][1]==true and b[2][0]==true)
	{
		flag=true;
		
	}
	if(flag) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
/*
*/

#pragma GCC optimize("O3")
#define _CRT_SECURE_NO_WARNINGS
#include <assert.h>
#include <math.h>
#include <memory.h>
#include <stdio.h>

#include <algorithm>
#include <complex>
#include <ctime>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

#define y0 sdkfaslhagaklsldk

#define y1 aasdfasdfasdf
#define yn askfhwqriuperikldjk
#define j1 assdgsdgasghsf
#define tm sdfjahlfasfh
#define lr asgasgash
#define norm asdfasdgasdgsd
#define left asdgashgrketwjklrej
#define have adsgagshdshfhds
#define ends asdgahhfdsfshdshfd
#define prev asdgSHJsfgsdfhdsh
#define hash asdgasdgasdgdfrywewery

#define eps 1e-12
#define M_PI 3.141592653589793
#define bsize 1024

#define ldouble long double
using namespace std;

#define bs 1000000007

const int N = 1100031;

int n;
string st[N];
int C;
int is_terminal[26*N];
int parent[N];
int son[N][26];
long long ans;
int count_with[N][26];
int edge_letter[N];
int already_have[30];
int subtree_size[N];

void add_to_trie(string st){
	int cur=0;
	for (int i=0;i<st.size();i++){
		int id=st[i]-'a';
		if (son[cur][id]==0){
			++C;
			son[cur][id]=C;
			parent[C]=cur;
			edge_letter[C]=id;
		}
		cur=son[cur][id];
	}
	is_terminal[cur]=1;
	for (int i=0;i<26;i++){
		already_have[i]=0;
	}
	while (cur>0){
		subtree_size[cur]++;
		already_have[edge_letter[cur]]=1;
		cur=parent[cur];
		for (int i=0;i<26;i++){
			if (already_have[i])
				count_with[cur][i]++;
		}
	}
}

int main() {
   //freopen("input.txt", "r", stdin);
   //freopen("output.txt", "w", stdout);
  ios_base::sync_with_stdio(0);
  // cin.tie(0);

  cin>>n;

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

  for (int i=1;i<=n;i++){
	  reverse(st[i].begin(),st[i].end());
	  add_to_trie(st[i]);
  }

  for (int i=1;i<=C;i++){
	  if (is_terminal[i]){
		  int Q=parent[i];
		  int interesting_letter=edge_letter[i];
		  for (int j=0;j<26;j++){
			  if (son[Q][j]>0){
				  int to=son[Q][j];
				  if (j!=edge_letter[i])
					  ans+=count_with[to][interesting_letter];
				  else
				  {
					  ans+=subtree_size[to];
				  }
			  }
		  }
		  --ans; // with itself
	  }
  }

  cout<<ans<<endl;

  cin.get(); cin.get();
  return 0;
}


Measured memory_bytes: 255828
import java.util.*;

public class Main{
	
	public static void main (String[] args) {
		
		Scanner scanner = new Scanner (System.in);
		Integer[] list = new Integer[3];
		int one = 0;
		int two = 0;
		int three = 0;
		int four = 0;
		for (int i=0; i<6; i++) {
			int temp = scanner.nextInt();
			
			switch (temp) {
			
			case 1:
				one++;
				break;
			case 2:
				two++;
				break;
			case 3:
				three++;
				break;
			case 4:
				four++;
				break;
			}
		}
		
		if (one>=3 || two>=3 || three>=3 || four>=3) {
			System.out.println("NO");
		} else {
			System.out.println("YES");
		}
	}
}

Measured memory_bytes: 21716
#include <bits/stdc++.h>
        using namespace std;
   #define int long long
   #define PP pair<int,pair<int,int>>
const int MAX = 1000001;
const int MOD =  998244353;
const int INV2 = (MOD+1)/2;

     signed main(){
       
        int a,b,n,ans=0;
        cin>>a>>b>>n;
        cout<<(a*min(b-1,n))/b<<endl;
   




}


        


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
long long n, a, b;
int main() {
    
    cin >> n >> a >> b;
    if (n > 1 && b >= a || n == 1 && a == b) {
        cout << (n - 2) * (b - a) + 1;
        
    }
    else {
        cout << 0; 
    }
 } 

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

bool ok(string const& s){
    string t = s;
    reverse(t.begin(),t.end());
    return t == s;
}
int main(){
    string s;
    int ans=0;
    while(cin>>s)ans+=ok(s);
    cout << ans << endl;
}

Measured memory_bytes: 1196
#include<bits/stdc++.h>
using namespace std;
int main() {
  int a,b,c,d,e,f;
  cin>>a>>b;
  e=10*b; f=e+9;
  if (a%2==0) {c=25*a/2; d=c+12;}
  else if (a%2==1) {c=25*(a-1)/2+13; d=c+11;}
  if (f<c || d<e) cout<<-1<<endl;
  else cout<<max(c,e)<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
using ll = long long;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define rep2(i, s, n) for(ll i = s; i < n; i++)
#define repr2(i, s, n) for(ll i = n-1; i >= s; i++)
using namespace std;

const ll mod = 1000000007;
ll modPow(ll a, ll n){
  if (n == 0) return 1;
  if (n == 1) return a % mod;
  if (n % 2 == 1) return (a * modPow(a, n-1)) % mod;
  ll t = modPow(a, n/2);
  return (t * t) % mod;
}

int main(){
  ll n, a, b;
  cin >> n >> a >> b;
  
  ll ans = modPow(2, n) - 1;
  ll x1 = 1, y1 = 1, x2 = 1, y2 = 1;
  rep2(i, n-a+1, n+1) x1 = (x1 * i) % mod;
  rep2(i, 1, a+1) y1 = (y1 * i) % mod;
  rep2(i, n-b+1, n+1) x2 = (x2 * i) % mod;
  rep2(i, 1, b+1) y2 = (y2 * i) % mod;
  ll ac = (x1 * modPow(y1, mod-2)) % mod;
  ll bc = (x2 * modPow(y2, mod-2)) % mod;
  ans = (ans - ac - bc + 2*mod) % mod;
  
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
N=int(input())
def factorize(n):
    b = 2
    fct = []
    while b * b <= n:
        while n % b == 0:
            n //= b
            fct.append(b)
        b = b + 1
    if n > 1:
        fct.append(n)
    return fct
a=factorize(N)

q={}
for i in range(len(a)):
  if a[i] in q:
    q[a[i]]+=1
  else:
    q[a[i]]=1
def k(n):
    B=[i*(i+1) for i in range(20)]
    s=0
    for j in range(20):
      if 2*n>=B[j]:
        s=j
      else:
        s=s
    return s
c=0
for key in q.keys():
  c+=k(q[key])
print(c)

Measured memory_bytes: 9220
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder
{
    class Program
    {
        static void Main()
        {
            Solve();

            Console.ReadKey();
        }

        static void Solve()
        {
            var str = IO.GetIntList();
            var A = IO.GetIntList();

            var ans = Math.Min(A.Count(a => a < str[2]), A.Count(a => a > str[2]));

            Console.Write(ans);
        }
    }


    static class IO
    {
        static public string GetString() { return Console.ReadLine(); }
        static public int GetInt() { return int.Parse(Console.ReadLine()); }
        static public long GetLong() { return long.Parse(Console.ReadLine()); }
        static public List<string> GetStringList() { return Console.ReadLine().Split(' ').ToList(); }
        static public List<int> GetIntList() { return Console.ReadLine().Split(' ').Select(int.Parse).ToList(); }
        static public List<long> GetLongList() { return Console.ReadLine().Split(' ').Select(long.Parse).ToList(); }
        static public List<double> GetDoubleList() { return Console.ReadLine().Split(' ').Select(double.Parse).ToList(); }
        static public void WriteStrings<T>(IEnumerable<T> values) { foreach (var o in values) { Console.Write(o + " "); } }
    }
}

Measured memory_bytes: 13268
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int k = sc.nextInt();
    int x = sc.nextInt();
    int count = 0;
    for(int i = -1000000;i<1000001;i++){
      if(x-k+1<=i&&i<=x+k-1)System.out.println(i);
    }
  }
}


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

using namespace std;

int a[200005];
int d[200005];

int main(){
    int k,n;
    scanf("%d%d",&k,&n);
    for (int i = 0 ; i < n;i++){
        scanf("%d",&a[i]);
    }
    int maxi = -1;
    for (int i = 1; i < n;i++){
        d[i]=a[i]-a[i-1];
       // printf("d[i] = %d\n",d[i]);
        maxi = max(d[i],maxi);
    }
    d[n] = k-a[n-1] + a[0];
    maxi = max(maxi,d[n]);
    printf("%d\n",k-maxi);
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
 
#define P(p) cout<<(p)<<endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.begin(), v.end(),greater<int>());
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return
#define lb(v,n) lower_bound(v.begin(),v.end(),n)
#define ub(v,n) upper_bound(v.begin(),v.end(),n)
#define mae(v) max_element(v.begin(),v.end())
#define mie(v) min_element(v.begin(),v.end())
#define INF 0x7FFFFFFF
#define mod 1000000007
typedef long long ll;
////////////////////////////////////////////////////////////

ll n , k;
int main(){
	cin >> n >> k;
	vector<ll> a(n);
	
	rep(i,0,n) cin >> a[i]; 
	
	int i=0;
	while(1){
		int num = (k-1)*i+k;

		if( num >= n ){
			cout << i + 1 << endl;
			break;
		}

		i++;
	}
	ret 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <set>
#include <iomanip>
#include <stack>
#include <fstream>
#include <cstdint>
#include <cmath>
#include <algorithm>
#include <utility>
#include <numeric>
#include <functional>
using namespace std;
typedef int64_t ll;
typedef uint64_t ull;
constexpr uint64_t L1 = 1ull;
constexpr ull bit(int n){ return 1ull << n;}

constexpr ll INF       = 1000000000;/* 1e+9a */
// for(auto && i : Range(l,r))
// -> i = [l..r)
class Range {
private: struct It{ int x; int operator*(){return x;}
 bool operator!=(It& lhs){ return x<lhs.x;} void operator++(){++x;} }; It l,r;
public: Range(int n):l({0}),r({n}){} Range(int i,int n):l({i}),r({n})
 {}It& begin(){return l;} It& end(){return r;} };

void solve(istream& cin) {
    ll N, K;
    while(cin >> N >> K){
        ll ans = 0;
        ll d = N / K;
        ans = d * d * d;
        if(K % 2 == 0) {
            ll k = (N + K/2) / K;
            ans += k * k * k;
        }

        cout << ans << endl;
    }
}

int main(int argc, char *argv[]) {
    string FileName("C"), Modifier("MEPH_");
    string ExecutionName = Modifier + FileName;
    string sub(argv[0]);
    if(sub.size() > ExecutionName.size())
        sub = sub.substr(sub.size()-ExecutionName.size(), ExecutionName.size());

    cout << setprecision(16) << scientific;
    if (sub != ExecutionName) {
        cin.tie(0);
        ios::sync_with_stdio(false);
        solve(cin);
    }
    else {    
	    cerr << sub << endl;
        string inFile = "sample.txt";
        auto fs = fstream(inFile, fstream::in);
        solve(fs);
    }
}

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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

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

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
  for(auto &e:u) fill_v<T>(e,v...);
}

int64 W, H;

void solve() {
    vector<string> f(H);
    REP(i, H) cin >> f[i];
    auto dp = make_v<string>(H, W, H+W+1);
    fill_v<string>(dp, "");
    REP(j, H) {
        REP(k, W) {
            if (isdigit(f[j][k]))
                dp[j][k][0] += f[j][k];
        }
    }
    string res = string(H+W, '0');
    REP(i, H+W) {
        REP(j, H) {
            REP(k, W) {
                if (dp[j][k][i] == "") continue;
                if (j+1 < H && isdigit(f[j+1][k])) {
                    chmax(dp[j+1][k][i+1], dp[j][k][i]+f[j+1][k]);
                }
                if (k+1 < W && isdigit(f[j][k+1])) {
                    chmax(dp[j][k+1][i+1], dp[j][k][i]+f[j][k+1]);
                }
                chmax(res, string(H+W-i, '0')+dp[j][k][i]);
            }
        }
    }
    int64 st = 0;
    while(st < res.size() && res[st] == '0') st++;
    cout << res.substr(st, res.size()-st) << endl;
}

int main(void) {
    while (cin >> W >> H && W+H) {
        solve();
    }
}



Measured memory_bytes: 6684
import java.util.Scanner;

/**
 * Flag
 */
public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int W, H;
		char c;

		W = sc.nextInt();
		H = sc.nextInt();
		c = sc.next().charAt(0);

		for (int i = 0; i < H; i++) {
			for (int j = 0; j < W; j++) {
				if ((i == 0 || i == H - 1) && (j == 0 || j == W - 1)) {
					System.out.print('+');
				} else if (i == 0 || i == H - 1) {
					System.out.print('-');
				} else if (j == 0 || j == W - 1) {
					System.out.print('|');
				} else if (i == H / 2 && j == W / 2) {
					System.out.print(c);
				} else {
					System.out.print('.');
				}
			}
			System.out.println();
		}
	}
}

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

int main(){
  string s;
  cin >> s;
  int cnt=0;
  for(int i=0;i<3;i++){
    if(s[i] == 'o')
      cnt++;
  }
  cout << 700 + cnt * 100 << endl;
  return 0;
}





Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder2 {
	class Program {
		static void Main(string[] args) {
          
          	var inputArray = retreiveLongArray();
			var inputCount = 3;

			// 不正な入力は処理しない
			if (inputArray.Length != inputCount) {
				Console.WriteLine("invalid input");
				return;
			}
			long L = inputArray[0];
			long R = inputArray[1];
			long d = inputArray[2];

			var count = 0;
			for (var i = L; i <= R; i++) {
				if (i%d==0) {
					count++;
				}
			}


			//答えの出力
			var ans = count;
			Console.WriteLine(ans);

		}

		/// <summary>
		/// スペースで区切られた文字列配列の入力を受け取る
		/// </summary>
		/// <returns></returns>
		private static string[] retreiveStringArray() {
			var inputArray = Console.ReadLine().Split(' ');
			return inputArray;
		}

		/// <summary>
		/// スペースで区切られた整数配列の入力を受け取る
		/// </summary>
		/// <returns></returns>
		private static long[] retreiveLongArray() {
			var inputArray = Console.ReadLine().Split(' ');
			var longArray = inputArray.Select(s => long.Parse(s));
			return longArray.ToArray();
		}


		/// <summary>
		/// 2組みずつの入力データ(数値)からTuppleListを作成する
		/// </summary>
		/// <param name="N"></param>
		/// <returns></returns>
		private static List<Tuple<long, long>> createLongTuppleList(long N) {
			var inpList = new List<Tuple<long, long>>();

			for (int i = 0; i < N; i++) {
				var inp = retreiveLongArray();
				var item1 = inp[0];
				var item2 = inp[1];
				inpList.Add(new Tuple<long, long>(item1, item2));
			}
			return inpList;
		}
	}
}

Measured memory_bytes: 28032
#include <stdio.h>
#include <stdlib.h>

struct node{
  struct node *right;
  struct node *left;
  struct node *p;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x != NIL){
    y = x;
    if(z->key < x->key)
      x = x->left;
    else x = x->right;
  }
  z->p = y;
    
    if(y == NIL)
      root = z;
    else if(z->key < y->key)
      y->left = z;
    else
      y->right = z;
}

void inorder(Node u){
  if(u == NIL)
    return;
  inorder(u->left);
    printf(" %d",u->key);
  inorder(u->right);
}
void preorder(Node u){
  if(u == NIL)
    return;
  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);
}


int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }

  return 0;
}



Measured memory_bytes: 25220
n=int(input())
a_list=[list(map(int,input().split())) for _ in range(n)]

f_list_0 = []
f_list_1 = []
for i in range(n):
    f_list_0.append(a_list[i][0]+a_list[i][1])
    f_list_1.append(a_list[i][0]-a_list[i][1])

ans_0 = max(f_list_0) - min(f_list_0)
ans_1 = max(f_list_1) - min(f_list_1)

print(max((ans_0, ans_1)))

Measured memory_bytes: 61408
#include <cstdio>

typedef long long ll;

const int MAXN = 2E3 + 10;
const int MOD = 1E9 + 7;

ll modExp(ll e, ll n, ll m = MOD){
	ll ret = 1;
	for (; n; n >>= 1, e = e * e % m)
		if (n & 1)
			ret = ret * e % m;
	return ret;
}

inline void update(int &x, int y){
	if ((x += y) >= MOD)
		x -= MOD;
}

int f[MAXN][MAXN];

int main(){
	int n, k;
	scanf("%d%d", &n, &k);
	f[0][0] = 1;
	for (int i = 1; i < k; ++i){
		int s = f[i - 1][i - 1];
		for (int j = i; j < n; ++j){
			update(f[i][j], s);
			update(f[i][j], f[i - 1][j]);
			update(s, f[i - 1][j]);
		}
	}
	int ans = 0;
	for (int i = 0; i < n; ++i)
		update(ans, f[k - 1][i]);
	printf("%d\n", (int)(ans * modExp(2, n == k ? 0 : n - k - 1) % MOD));
	return 0;
}


Measured memory_bytes: 13952
N = int(input())
As = list(map(int,input().split()))
As.sort(reverse=True)
first_d = As[0]
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors

if N == 2:
    print(max(As))
else:
    first = make_divisors(As[0])
    second = make_divisors(As[1])
    third  = make_divisors(As[2])
    div_list = list((set(first) & set(second)) | (set(first) & set(third)) | (set(third) & set(second)))
    div_list.sort(reverse=True)
    
    for d in range(len(div_list)):
        cnt = 0
        for i in range(N):
            if As[i] % (div_list[d]) != 0:
                cnt += 1
                if cnt > 1:
                    break
        if cnt <= 1 :
            ans = div_list[d]
            break
    print(ans)

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

using namespace std;

#define FOR(i, a, b) for(ll i = (a); i < (b); ++i)
#define FORR(i, a, b) for(ll i = (a); i > (b); --i)
#define REP(i, n) for(ll i = 0; i < (n); ++i)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOREACH(x, a) for(auto &(x) : (a))
#define VECCIN(x)                                                              \
    for(auto &youso_ : (x)) cin >> youso_
#define mp make_pair
#define bitcnt __builtin_popcount
#define SZ(x) ((ll)(x).size())
#define All(a) (a).begin(), (a).end()
template <typename T = long long> inline T IN() {
    T x;
    cin >> x;
    return (x);
}
inline void CIN() {}
template <class Head, class... Tail>
inline void CIN(Head &&head, Tail &&... tail) {
    cin >> head;
    CIN(move(tail)...);
}
#define CINT(...)                                                              \
    int __VA_ARGS__;                                                           \
    CIN(__VA_ARGS__)
#define LCIN(...)                                                              \
    ll __VA_ARGS__;                                                            \
    CIN(__VA_ARGS__)
#define SCIN(...)                                                              \
    string __VA_ARGS__;                                                        \
    CIN(__VA_ARGS__)
#define Yes(a) cout << (a ? "Yes" : "No") << "\n"
#define YES(a) cout << (a ? "YES" : "NO") << "\n"

typedef long long ll;
typedef unsigned long long ul;
typedef vector<int> V;
typedef vector<ll> VL;
typedef pair<ll, ll> PL;
typedef priority_queue<ll> PQ;
typedef priority_queue<ll, V, greater<ll>> PQG;

const int INF = 1e9;
const int MOD = 1e9 + 7;
// const int MOD = 998244353;
const ll LINF = 1e18;

ll N;
VL A;

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

int main() {
    cin >> N;
    ll ans = 0;
    REP(i, N) { ans += IN() - 1; }
    cout << ans << "\n";
}

Measured memory_bytes: 256