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

int main(){
    int n,t,a,b;
        cin >> n >> t >> a;
    int ans =10e5,count =0;
    for (int i=0;i<n;i++){
        cin >> b;
        b = abs((t*1000 -b*6)-a*1000);
        if(ans>b){
            ans = b;
            count =i;
        }
    }
    cout << count +1 << endl;
    
}


Measured memory_bytes: 256
n = int(input())
al=["z"]+[chr(ord('a') + i) for i in range(25)]
result = ""
while n>0:
    if n%26 !=0:
        result = al[n%26]+result
        n //= 26
    else:
        result = al[n%26]+result
        n //= 26
        n -= 1
print(result)

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

struct Benri { Benri() { std::cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(12);}} benri;

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using vll = vector<long long>;
using pll = pair<ll, ll>;
using ull = unsigned long long;

template <typename T> using PQ = priority_queue<T>;
template <typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define mp make_pair
#define F first
#define S second

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

constexpr long long MOD = 1000000007;
//constexpr long long MOD = 998244353;
//constexpr int INF = 1001001001;
constexpr ll INF = 1001001001001001001ll;
constexpr double EPS = 1e-10;
using number = long long;


template <class Abel> struct BIT {
    const Abel UNITY_SUM = 0;                       // to be set
    vector<Abel> dat;

    /* [1, n] */
    BIT(int n) : dat(n + 1, UNITY_SUM) { }
    void init(int n) { dat.assign(n + 1, UNITY_SUM); }

    /* a is 1-indexed */
    inline void add(int a, Abel x) {
        for (int i = a; i < (int)dat.size(); i += i & -i)
            dat[i] = dat[i] + x;
    }

    /* [1, a], a is 1-indexed */
    inline Abel sum(int a) {
        Abel res = UNITY_SUM;
        for (int i = a; i > 0; i -= i & -i)
            res = res + dat[i];
        return res;
    }

    /* [a, b), a and b are 1-indexed */
    inline Abel sum(int a, int b) {
        return sum(b - 1) - sum(a - 1);
    }

};

int main() {
    ll N; cin >> N;
    vi a(N);
    rep(i, N) cin >> a[i];

    int low = 0, high = 1 << 30;
    const int geta = N + 1; //Sum[i]を中央によせるため足す定数

    while (high - low > 1) {
        int mid = (low + high) / 2;
        ll num = 0;
        BIT<ll> bit(N * 2 + 10);

        int sum = 0; //累積和
        bit.add(sum + geta, 1);
        rep(i,N) {
            int val = (a[i] <= mid ? 1 : -1);
            sum += val;
            num += bit.sum(1, sum + geta);
            bit.add(sum + geta, 1);
        }
        if (num > (N + 1)*N / 2 / 2) high = mid;
        else low = mid;
    }

    cout << high << endl;
}



Measured memory_bytes: 2280
#include <iostream>
using namespace std;
int main(void){


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

    int key;
    int j;
    for(int i=0;i<n;i++){
        key=A[i];
        j = i-1;
        while(j>=0 and A[j] > key){
            A[j+1] = A[j];
            j--;
            A[j+1] = key;
        }
        
        for(int k=0;k<n;k++){
            if(k!=0) cout << " ";
            cout << A[k];
        }
        cout << endl;
        
    }
    

}



Measured memory_bytes: 3044
tops = []
s = []
v = 0
h = 0

gets.chomp.each_char do |c|
  case c
  when '\\'
    tops << {h: h, v: v}
    v += 1; h -= 1
    s << 0 if s[s.size-1] != 0
  when '/'
    v += 1; h += 1

    hit = false
    i = tops.size - 1
    top = {}
    merge = 0

    while 0 <= i
      top = tops[i]
      if h <= top[:h]
        hit = true
        break
      elsif (h - 1) == top[:h]
        merge += 1
      end
      i -= 1
    end
    if hit
      s[s.size-1] += (v - top[:v]) - 1
      s << s.pop(merge).inject(:+) if 2 <= merge
    end
  when '_'
    v += 1
  end
end
s.pop if s[s.size-1] == 0

puts (sum = s.inject(:+)) ? sum : 0
print "#{s.size}"
puts (s.size == 0) ? '' : ' ' + s * ' '

Measured memory_bytes: 11032
#include<bits/stdc++.h>
using namespace std;
int main()
{
    
    long long int sum=0,i,n;
    cin>>n;
    long long int a[n];
    for(i=0;i<n;i++)
    {
        cin>>a[i];
    }
    for(i=1;i<n;i++)
    {
        if(a[i]>=a[i-1])
            continue;
        sum+=a[i-1]-a[i];
        a[i]=a[i-1];

    }
    cout<<sum;
   
}    
        
 
       


Measured memory_bytes: 5152
#include <bits/stdc++.h>
#define FR first
#define SE second

using namespace std;

typedef pair<int,int> pr;

vector <int> e[2005];
int d[2005];

int fa[2005],dep[2005];

void dfs1(int x) {
  for(int i=0;i<e[x].size();i++)
    if (e[x][i]!=fa[x]) {
    	int u=e[x][i];
    	fa[u]=x;dep[u]=dep[x]+1;
    	dfs1(u);
	}
}

int lca(int x,int y) {
  if (dep[x]<dep[y]) swap(x,y);
  while (dep[x]>dep[y]) x=fa[x];
  while (x!=y) {
  	x=fa[x];
  	y=fa[y];
  }
  return x;
}

int sum[2005];

void dfs2(int x) {
  for(int i=0;i<e[x].size();i++)
    if (e[x][i]!=fa[x]) {
    	int u=e[x][i];
    	dfs2(u);
    	sum[x]+=sum[u];
	} 
}

int p[2005];
bool col[2005],vis[2005];

pr num[2005],fir[2005];

int main() {
  int n,m;
  scanf("%d%d",&n,&m);
  for(int i=1;i<n;i++) {
  	int x,y;
  	scanf("%d%d",&x,&y);
  	e[x].push_back(y);
  	e[y].push_back(x);
  	d[x]++;d[y]++;
  }
  dfs1(1);
  for(int i=1;i<=m;i++) {
  	int x,y;
  	scanf("%d%d",&x,&y);
  	fir[i]=num[i]=pr(x,y);
  	sum[x]++;sum[y]++;
  	sum[lca(x,y)]-=2;
  }
  dfs2(1);
  int ans=0;
  for(int i=2;i<=n;i++) ans+=min(sum[i],2);
  printf("%d\n",ans);
  for(int i=2;i<=n;i++) {
  	int u=0;
  	for(int j=2;j<=n;j++)
  	  if (d[j]==1&&!vis[j]) {
  	  	  u=j;
  	  	  break;
		}
	vis[u]=1;
	int v=0;
	for(int j=0;j<e[u].size();j++)
	  if (!vis[e[u][j]]) {
	  	v=e[u][j];
	  	break;
	  }
	d[v]--;
	int id1=0,id2=0;
	for(int j=1;j<=m;j++)
	  if ((num[j].FR==u)^(num[j].SE==u)) {
	  	if (!id1) id1=j;
	  	else if (!id2) id2=j;
	  }
	if (!id1&&!id2) continue;
	if (!id2) {
		if (num[id1].FR==u) num[id1].FR=v;
		else num[id1].SE=v; 
		continue;
	}
	if (num[id1].FR==u) {
		if (num[id2].FR==u) {
			num[id1].FR=num[id2].SE;
			col[id2]^=1;
		}
		else num[id1].FR=num[id2].FR;
	}
	else {
		if (num[id2].SE==u) {
			num[id1].SE=num[id2].FR;
			col[id2]^=1;
		}
		else num[id1].SE=num[id2].SE;
	}
	num[id2].FR=num[id2].SE;
	p[id2]=id1;
	for(int j=1;j<=m;j++)
	  if ((num[j].FR==u)^(num[j].SE==u)) {
	  	if (num[j].FR==u) num[j].FR=v;
	  	else num[j].SE=v;
	  }
  }
  for(int i=1;i<=m;i++)
    if (p[i]) col[i]^=col[p[i]];
  for(int i=1;i<=m;i++) {
  	if (col[i]) swap(fir[i].FR,fir[i].SE);
  	printf("%d %d\n",fir[i].FR,fir[i].SE);
  }
  return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a,b,c,k;
    cin >> a >> b >> c >> k;
    if(c>b && b>a){
        cout << "Yes";
        return 0;
    }
    for(int i=0;i<k;i++){
        if(a>=b)b*=2;
        else if(b>=c)c*=2;
        if(c>b && b>a){
            cout << "Yes";
            return 0;
        }
    }
    cout << "No";
}

Measured memory_bytes: 3632
A, B, H, M = map(int, input().split())

import numpy as np

hour = 30*H + M/2

t = abs(hour-6*M)
if t >= 180:
  t = 360 - t

t = np.pi/180*t

ans2 = A**2 + B**2 - 2*A*B*np.cos(t)
print(np.sqrt(ans2))

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

int main(){
	int h, n, a, cnt=0;
	scanf("%d %d", &h, &n);
	for (int i = 0; i < n; ++i){
		scanf("%d", &a);
		cnt+=a;
		if (cnt>=h){
			printf("Yes");
			return 0;
		}
	}
	printf("No");
	return 0;
}

Measured memory_bytes: 256
// 
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
#define int long long
const long long INF = 1LL << 60;    // 1.15x10^18

signed main() {
    int N, X; cin >> N >> X;
    vector<int> A(N);
    for (int i = 0; i < N; i++) cin >> A[i];
    vector<vector<int>> B(N, vector<int>(N));
    for (int i = 0; i < N; i++) {
        B[i][0] = A[i];
        for (int k = 1; k < N; k++) {
            B[i][k] = min(B[i][k - 1], A[(i - k + N) % N]);
        }
    }
    long long ans = INF;
    for (int k = 0; k < N; k++) {
        long long tmp = k * X;
        for (int i = 0; i < N; i++) {
            tmp += B[i][k];
        }
        ans = min(ans, tmp);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 31616
#include <iostream>

using namespace std;

int main(void){
	int k,s,x,y,z,res=0;
	cin >> k >> s;
	for(int x=0;x<=k;x++){
		for(int y=0;y<=k;y++){
			z = s - x - y;
			if(z >= 0&&z <= k)res++;
		}
	}
	cout << res << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define LF '\n'
#define ALL(x) x.begin(), x.end()
#define iostreamBooster() { cin.tie(nullptr); ios_base::sync_with_stdio(false); }
using namespace std;
typedef int64_t i64;
typedef pair<int,int> pii;
template<class A, class B>inline bool chmax(A &a, const B &b){return b>a ? a=b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b<a ? a=b,1 : 0;}
constexpr int INF = 0x3f3f3f3f;
template<class Itr> void dump(Itr begin, Itr end) { for (;begin != end; ++begin) clog << *begin << LF; }

signed main()
{
  int N, L;
  string a[105];
  cin >> N >> L;
  for (int i = 0; i < N; i++) {
    cin >> a[i];
  }

  sort(a, a+N);
  for (int i = 0; i < N; i++) {
    cout << a[i];
  }
  cout << LF;

  return 0;
}



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

const int nax = 1e5+3;
int n;
int dp[nax];
int a[nax];
int f(int i){
	if (i==n-1) return 0;
	if(dp[i]!=-1) return dp[i];
	int ans = abs(a[i]-a[i+1])+f(i+1);
	if(i!=n-2) ans = min(ans, abs(a[i]-a[i+2])+f(i+2));
	return dp[i]=ans;
}
int main(){
	cin>>n;
	for(int i=0; i<n; i++) cin>>a[i];
	memset(dp, -1, sizeof dp);
	cout<<f(0)<<endl;
	return 0;
}

Measured memory_bytes: 4224
from collections import deque
from collections import Counter
from itertools import product, permutations,combinations
from operator import itemgetter
from heapq import heappop, heappush
from bisect import bisect_left, bisect_right, bisect
#pypyではscipy, numpyは使えない
#from scipy.sparse.csgraph import shortest_path, floyd_warshall, dijkstra, bellman_ford, johnson, minimum_spanning_tree
#from scipy.sparse import csr_matrix, coo_matrix, lil_matrix
import numpy as np
from fractions import gcd
from math import ceil,floor, sqrt, cos, sin, pi, factorial, log, log10, log2
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10**8)
INF = float('inf')
from datetime import datetime as dt

def main():
  n = int(readline())
  v = list(map(int, readline().split()))
  v.sort()
  total = 0
  for i in range(n):
    if i == 0:
      total += v[i]
    else:
      total += (2**(i-1))*v[i]
  print(total/(2**(n-1)))
  
  
  
if __name__ == '__main__':
  main()

Measured memory_bytes: 13468
n=int(input())
a=[0] + list(map(int,input().split()))

boxes=[0]*(n+1)
m=0
b=[]
for i in reversed(range(1,n+1)):
    if sum(boxes[i::i])%2 != a[i]:
        boxes[i]=1
        m+=1
        b.append(i)
print(m)
print(*b)


Measured memory_bytes: 18284
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
using namespace std;
#ifndef FAST_IO
 #define IOS ios_base::sync_with_stdio(false);cin.tie(nullptr);
#endif

#define FILE_IO freopen("input.txt","r",stdin)
#define int long long
#define f first
#define s second
#define endl '\n'
#define all(c) c.begin(),c.end()
#define debug(x) cerr << #x << " = " << x << endl;

const int MOD=1e9+7;
const int INF=1<<29;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template<typename T>void print(T t){for(auto &it:t)cout<<it<<" ";}
inline int powerexp(int a,int b,int m=MOD){int res=1;while(b){if(b&1)res=res*a%m;a=a*a%m,b>>=1;}return res%m;}
inline int modinv(int a){return powerexp(a,MOD-2,MOD);}
inline int lcm(int a,int b){int g=__gcd(a,b);return a/g*b;}

//-------------------< start here >-------------------------//
const int N=1e3+11;
bool isprime[N];
void gen_primes(){
  	for(int i=2;i<N;i++)isprime[i]=true;
  	for(int i=2;i<N;i++){
	  if(isprime[i]){
		 for(int j=2;i*j<N;j++){
			  isprime[i*j]=false; 
			} 
		 }	
	}
}
int calc(int n){
   int ret=1;
   for(int i=2;i<=n;i++){
	   if(isprime[i]){
		    int cnt=0;
		    int curr=i;
		    while(curr<=n){
			    cnt+=n/curr;
			    curr*=i;	
			 }
		ret*=(1+cnt);
	    ret%=MOD;  
		  }
	 }
  return ret;	
}
void solve(){
    gen_primes();
    int n;
    cin>>n;
    int ret=calc(n);
    cout<<ret<<endl;
}
//-----------------------------
//comment from here for TOPCODER 
int32_t main(){
   IOS;
   solve();
   #ifdef LOCAL_DEFINE
   cerr<<"time elapsed "<<(double)clock()/CLOCKS_PER_SEC<<endl;
   #endif
}


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


#define BLACK 1
#define WHITE -1


long long N;
vector<pair<long long, long long> > tree[100005];
long long ans[100005];

void dfs(long long cur) {

	for(long long i = 0; i < tree[cur].size(); i++){
		long long next = tree[cur][i].first;
		long long cost = tree[cur][i].second;
		if(ans[next] != 0){
			continue;
		}
		if(cost % 2 == 0){
			ans[next] = ans[cur];
			dfs(next);
		}else{
			ans[next] = -ans[cur];
			dfs(next);
		}
	}
}


int main(){
	cin >> N;
	for(long long i = 0; i < N-1; i++){
		long long u,v,w;
		cin >> u >> v >> w; u--;v--;
		tree[u].push_back(make_pair(v, w));
		tree[v].push_back(make_pair(u, w));
	}
	ans[0] = BLACK;
	dfs(0);


	for(long long i = 0; i < N; i++){
		if(ans[i] == BLACK){
			cout << 1 << endl;
		}else{
			cout << 0 << endl;
		}
	}
}

Measured memory_bytes: 10240
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  queue<int> h;
  for(int i=0; i<n; i++){
    int tmp;
    cin>>tmp;
    h.push(tmp);
  }
  int ans=0;
  int count =0;
  int form=0;
  int temp;
  while(!h.empty()){
    temp =h.front();
    if(temp<=form) count++;
    else{
      if(ans<count){
        ans =count;
      }
      count =0;
    }
    form =temp;
    h.pop();
  }
  if(ans<count) ans =count;

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

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

template<const int N>
struct fenwick_tree{
	vector<long long> bit = vector<long long>(N);
	long long getSum(int i){
		int res = 0;
		for(; i >= 0; i = (i & (i + 1)) - 1) res += bit[i];
		return res;
	}
	long long query(int l, int r){
		return getSum(r) - getSum(l - 1);
	}
	void update(int i, int add){
		for(; i <= N; i = i | (i + 1)) bit[i] += add;
	}
};

int n, q;
fenwick_tree<500001> cnt[26];
string s;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> n >> s >> q;
	s = 'x' + s;
	for(int i = 1; i <= n; i++) cnt[(int)(s[i] - 'a')].update(i, 1);
	for(int i = 0; i < q; i++){
		int a, b;
		cin >> a >> b;
		if(a == 1){
			char c;
			cin >> c;
			cnt[(int)(s[b] - 'a')].update(b, -1);
			cnt[(int)(c - 'a')].update(b, 1);
			s[b] = c;
		}else{
			int c, sum = 0;
			cin >> c;
			for(int j = 0; j < 26; j++) sum += cnt[j].query(b, c) > 0;
			cout << sum << "\n";
		}
	}
	return 0;
}

Measured memory_bytes: 102940
import sys

input = sys.stdin.readline


def main():
    N, K = map(int, input().split())
    x = list(map(int, input().split()))

    n_zero = x.count(0)
    if n_zero >= K:
        print(0)
        exit()
    
    K -= n_zero
    A = []  # < 0
    B = []  # > 0
    for _x in x:
        if _x < 0:
            A.append(-_x)
        elif _x > 0:
            B.append(_x)
    A = A[::-1][:K]
    B = B[:K]
    ans = float("INF")

    for n_A in reversed(range(len(A) + 1)):
        n_B = K - n_A
        if n_B > len(B):
            break

        if n_A == 0 and n_B == K:
            ans = min(ans, B[-1])
        elif n_A == K and n_B == 0:
            ans = min(ans, A[-1])
        else:
            a = A[n_A - 1]
            b = B[n_B - 1]
            time = a + b + min(a, b)
            ans = min(ans, time)

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 21056
// 4/25
// 区間スケジューリング問題

#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main() {
    int N, M;
    cin >> N >> M;

    pair<int, int> itv[100000];

    for (int i = 0; i < M; i++) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        itv[i].first = b;
        itv[i].second = a;
    }

    // for (int i = 0; i < M; i++) {
    //     printf("%d: %d ~ %d\n", i, itv[i].second, itv[i].first);
    // }

    // printf("sort!");
    sort(itv, itv + M);

    // for (int i = 0; i < M; i++) {
        // printf("%d: %d ~ %d\n", i, itv[i].second, itv[i].first);
    // }


    int ans = 0, d = 0;

    for (int i = 0; i < M; i++) {
        if (itv[i].second >= d) {
            // printf("%d: %d ~ %d\n", i, itv[i].second, itv[i].first);
            d = itv[i].first;
            ans++;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 1024
#pragma region Include
#include <bits/stdc++.h>
// #include <algorithm>
// #include <bitset>
// #include <climits>
// #include <cmath>
// #include <iostream>
// #include <iterator>
// #include <map>
// #include <queue>
// #include <sstream>
// #include <stack>
// #include <string>
// #include <unordered_map>
// #include <unordered_set>
// #include <vector>
#pragma endregion

using namespace std;

#pragma region Macros
typedef pair<int, int> pii;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i, n) rep2(i, 0, n)
#define rep2(i, m, n) for (int i = m; i < (n); i++)
#define all(c) (c).begin(), (c).end()
#define newl "\n"
#define out(x) cout << (x) << newl
#define dump(x) \
  cout << "Line " << __LINE__ << " : " << #x << " = " << (x) << newl
template <class T>
using VV = vector<vector<T>>;
#define Uni(v) (v).erase(unique((v).begin(), (v).end()), (v).end());

template <typename T>
ostream& operator<<(ostream& os, vector<T>& vec) {
  os << "[";
  rep(i, vec.size()) os << vec[i] << (i + 1 == vec.size() ? "" : ", ");
  os << "]";
  return os;
}

template <typename T>
ostream& operator<<(ostream& os, vector<vector<T>>& mat) {
  os << "[";
  rep(i, mat.size()) os << mat[i] << (i + 1 == mat.size() ? "" : ",\n ");
  os << "]";
  return os;
}

template <typename T>
istream& operator>>(istream& is, vector<T>& vec) {
  for (T& x : vec) is >> x;
  return is;
}

template <typename V, typename H>
void resize(vector<V>& vec, const H head) {
  vec.resize(head);
}

template <typename V, typename H, typename... T>
void resize(vector<V>& vec, const H& head, const T... tail) {
  vec.resize(head);
  for (auto& v : vec) resize(v, tail...);
}
constexpr double EPS = 1e-10;
const int INF = 0x3f3f3f3f;

string tostring(int i, int digit) {
  auto cur = cout.flags();
  stringstream ss;
  ss << setw(4) << setfill('0') << i;
  string ret = ss.str();
  cout.flags(cur);
  return ret;
}

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

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

#pragma endregion

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  string S;
  cin >> S;
  // SUN,MON,TUE,WED,THU,FRI,SAT
  if (S == "SUN")
    out(7);
  else if (S == "MON")
    out(6);
  else if (S == "TUE")
    out(5);
  else if (S == "WED")
    out(4);
  else if (S == "THU")
    out(3);
  else if (S == "FRI")
    out(2);
  else if (S == "SAT")
    out(1);

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> vec;
typedef vector<vec> mat;
ll n,m,h,a,ans=0;
vector<ll> A,B;
int solve(ll x){
    h=0;
    rep(i,n) h+=A.end()-lower_bound(A.begin(),A.end(),x-A[i]);
    if(h>=m) return 1;
    else return 0;
}
ll ok=2,ng=2e5+1;
int search(){
    while(abs(ok-ng)>1){
        ll mid=(ok+ng)/2;
        if(solve(mid)) ok=mid;
        else ng=mid;
    }
}
int main(){
    cin>>n>>m;
    rep(i,n) cin>>a,A.push_back(a);
    sort(A.begin(),A.end());
    search();
    B.push_back(0);
    rep(i,n) B.push_back(B[i]+A[i]);
    solve(ok);
    rep(i,n) ans+=B[n]-B[lower_bound(A.begin(),A.end(),ok-A[i])-A.begin()]+(A.end()-lower_bound(A.begin(),A.end(),ok-A[i]))*A[i];
    cout<<ans-(h-m)*ok<<"\n";
}

Measured memory_bytes: 2548
#include<bits/stdc++.h>
using namespace std;
typedef long long 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++)
const ll mo=1000000007;
ll ans=0;
ll dp[0][0];

int main()
{ 
ll n;
cin >> n; 
ll t[n]={};
rep(i,n) {
    cin >> t [i];
}
if(n==2){
    cout << max(t[0],t[1]) << endl;
    return 0;
}

sort(t,t+n);

vector<int> yaku;
double sqrtNum = sqrt(t[0]);
for (int i = 1; i <= sqrtNum; i++){
    if(t[0]%i==0){yaku.push_back(i);yaku.push_back(t[0]/i);}
}
sort(yaku.rbegin(), yaku.rend());
rep(i,yaku.size()){
    ll co=0;
    rep1(j,n){
        if(t[j]%yaku[i]==0)co++;
    }
    if(co==n-2||co==n-1){
        ans=yaku[i];
        break;
    }
}

swap(t[0],t[1]);
vector<int> yakua;
sqrtNum = sqrt(t[0]);
for (int i = 1; i <= sqrtNum; i++){
    if(t[0]%i==0){yakua.push_back(i);yakua.push_back(t[0]/i);}
}
sort(yakua.rbegin(), yakua.rend());
rep(i,yakua.size()){
    ll co=0;
    rep1(j,n){
        if(t[j]%yakua[i]==0)co++;
    }
    if(co==n-2||co==n-1){
        if(ans<yakua[i])ans=yakua[i];
        break;
    }
}

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

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, h0, h;
  bool flag = true;
  cin >> N;
  cin >> h0;
  h0--;
  for(int i = 0; i < N-1; i++){
    cin >> h;
    if(h0<h) h--;
    else if(h0==h) continue;
    else{
      flag = false;
      break;
    }
    h0 = h;
    if(flag == false) break;
  }
  if(flag == true) cout << "Yes" << endl;
  else cout << "No" << endl;
}

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

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


    deque<char> que;

    for(int i = 0;i < s.size();i++)
        que.push_back(s[i]);


    int ans = 0;
    while(que.size() > 1){
        if(que.front() != que.back()){
            if(que.front() == 'x'){
                ans++;
                que.pop_front();
            }else if(que.back() == 'x'){
                ans++;
                que.pop_back();
            }else{
                cout << -1 << endl;
                return 0;
            }
        }else{
            que.pop_front();
            que.pop_back();
        }
    }

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


Measured memory_bytes: 512
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<string>
#include<utility>
#include<vector>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll MOD = 1000000007;
#define rep(i,n) for(int i=0;i<n;i++)
#define repl(i,s,e) for(int i=s;i<e;i++)
#define reple(i,s,e) for(int i=s;i<=e;i++)
#define revrep(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()

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

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

	vector<int> A(N), B(N);
	rep(i, N) cin >> A[i] >> B[i];

	//dp[i] := 体力をi以下にするために必要な魔力の最小値
	vector<ll> dp(H + 1, 1000000000000);
	dp[0] = 0;

	reple(i, 1, H)
	{
		rep(j, N)
		{
			int h = max(i - A[j], 0);

			dp[i] = min(dp[i], dp[h] + B[j]);
		}
	}

	cout << dp[H] << endl;

	return 0;
}	

Measured memory_bytes: 384
#pragma region header
#include <bits/stdc++.h>
#define int long long
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define rev(i, n) for(int i = (int)(n - 1); i >= 0; i--)
#define rev1(i, n) for(int i = (int)(n); i > 0; i--)
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define resort(v) sort((v).rbegin(), (v).rend())
#define vi vector<int>
#define vvi vector<vector<int>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
using ll = long long;
using P = pair<int, int>;
/* ----------------よく使う数字や配列----------------- */
int dx[] = {1,0,-1,0};
int dy[] = {0,1,0,-1};
constexpr ll mod = 1e9+7;
constexpr int inf = INT32_MAX/2;
constexpr ll INF = LLONG_MAX/2;
constexpr long double eps = DBL_EPSILON;
constexpr long double pi = 3.141592653589793238462643383279;
/* ----------------------end----------------------- */

/* --------------------テンプレート------------------ */
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
/* ----------------------end----------------------- */

/* --------------------ライブラリ-------------------- */
ll fact(int i) {       //階乗
    if (i == 0) return 1;
    return (fact(i - 1)) * i % mod;
}
ll gcd(ll a, ll b) {        //最大公約数
    if(b == 0) return a;
    return gcd(b, a % b); 
}
ll lcm(ll a, ll b) {      //最小公倍数
    return a * b / gcd(a, b);
}
int keta(ll n) {        //桁数を求める
    if(n == 0) return 1;
    int count = 0;
    while(n != 0) {
        n /= 10;
        count++;
    }
    return count;
}
ll ketasum(ll n) {    //各桁の和
    ll sum = 0;
    while(n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
/* ----------------------end----------------------- */
#pragma endregion
signed main() {
    int n;cin >> n;
    int ma1=-1,ma2=-1;
    int p,q;
    vi one(114514),two(114514);
    rep(i, n) {
        int a;cin >> a;
        a--;
        if(i%2==0) {
            one[a]++;
            if(chmax(ma1,one[a])) p=a;
        }
        else {
            two[a]++;
            if(chmax(ma2,two[a])) q=a;
        }
    }
    sort(all(one));
    sort(all(two));
    // one.erase(remove(all(one),0),one.end());
    // two.erase(remove(all(two),0),two.end());
    if(q!=p) cout << n-ma1-ma2 << endl;
    // else cout << min(n-ma1-(two[two.size()-2]>n/2)?two[two.size()-1]:two[two.size()-2],n-ma2-(one[one.size()-2]>n/2)?one[one.size()-1]:one[one.size()-2]) << endl;
    else cout << min(n-ma1-two[two.size()-2],n-ma2-one[one.size()-2]) << endl;
    // cout << n-ma1-two[0] << ' ' << n-ma2-one[0] << endl;
    // cout << two[two.size()-2] << ' ' << one[one.size()-2] << endl;
    return 0;
}

Measured memory_bytes: 5108
#include <bits/stdc++.h>
  
using namespace std;
  
template<class T> void ckmin(T &a, T b) { a = min(a, b); }
template<class T> void ckmax(T &a, T b) { a = max(a, b); }
  
#define pb push_back
#define mp make_pair
#define cotu cout
#define itn int
#define Red ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int i = 0; i < n; ++i)
#define repr(i,n) for(int i = n - 1; i >= 0; --i)
#define Rep(i, a, n) for(int i = (a); i <=(n); ++i)
#define repst(i, n) for(auto it = n.begin(); it != n.end(); ++it)
#define Repr(i, a, n) for(int i = (n); i >= (a); --i)
  
#define ordered_set tree<int , null_type,less<int >, rb_tree_tag,tree_order_statistics_node_update> 
  
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
  
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
  
const int inf = int(1e9);
const int mod = inf + 7;
const int N = 1e6 + 555; // TL MB
const double PI = acos(-1.0);
 
map<pii, int> b;
int h, w, n;
bool ok(int x, int y){
	if(x >= 1 && x <= h && y >= 1 && y <= w) return true;
	return false;
}
set<pii > ans[11];
	
void add(int x, int y){
	if(!ok(x, y)) return;
	int cnt = 0;
	for(int i = 0; i < 3; ++i){
		for(int j = 0; j < 3; ++j){
			if(!ok(x + i, y + j)) return;
			if(b[{x + i, y + j}]) ++cnt;
		}
	}
	if(cnt == 0) return;
	else {
		for(int i = 1; i <= 9; ++i) if(ans[i].find({x, y}) != ans[i].end()) ans[i].erase(ans[i].find({x, y}));
		ans[cnt].insert({x, y});
	}
}

void solve()
{

	cin >> h >> w >> n;
	for(int i = 0; i < n; ++i){
		int x, y;
		cin >> x >> y;
		b[{x, y}] = 1;
		for(int j = x - 2; j <= x; ++j){
			for(ll k = y - 2; k <= y; ++k){
				add(j, k);
			}
		}
	}
	ll sum = 1ll * (h - 2) * (w - 2);
	for(int i = 1; i <= 9; ++i) sum -= sz(ans[i]);
	cout << sum << '\n';
	for(int i = 1; i <= 9; ++i) cout << sz(ans[i]) << '\n';
}


 // a b c a b c a b c a b c
 
int main()
{
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
    Red;
  	int T = 1;
  //	cin >> T;
  	for(int i = 1; i <= T; ++i){
  		solve();
  	}
  	return 0;

}

Measured memory_bytes: 198656
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
#include <string.h>
using namespace std;

int main() {
	long long int hen=0,maxsq=0,t=0,y=0,maxty=0,c=1,ans=0,N,A[100000]={};
	cin>>N;
	for(int i=0;i<N;i++)
	{
		cin>>A[i];
	}
	sort(A,A+N);
	for(int i=0;i<N-1;i++)
	{
		if(A[i]!=A[i+1])c=1;
		if(A[i]==A[i+1])c++;
		if(c==2)
		{
			y=t;
			t=A[i];
		}
		if(c>3)hen=A[i];
	}
	ans=max(y*t,hen*hen);
	cout<<ans;
}


Measured memory_bytes: 1024
import sys
import numpy as np

A = [list(map(int, input().split())) for _ in range(3)]
N = int(input())
n = [int(input()) for _ in range(N)]

for i in range(3):
    for j in range(N):
        if A[i][0] == n[j]:
            for k in range(N):
                if A[i][1] == n[k]:
                    for l in range(N):
                        if A[i][2] == n[l]:
                            print('Yes')
                            sys.exit()

for i in range(3):
    for j in range(N):
        if A[0][i] == n[j]:
            for k in range(N):
                if A[1][i] == n[k]:
                    for l in range(N):
                        if A[2][i] == n[l]:
                            print('Yes')
                            sys.exit()

for j in range(N):
    if A[0][0] == n[j]:
        for k in range(N):
            if A[1][1] == n[k]:
                for l in range(N):
                    if A[2][2] == n[l]:
                        print('Yes')
                        sys.exit()

for j in range(N):
    if A[2][0] == n[j]:
        for k in range(N):
            if A[1][1] == n[k]:
                for l in range(N):
                    if A[2][0] == n[l]:
                        print('Yes')
                        sys.exit()

print('No')


Measured memory_bytes: 12448
<?php
	fscanf(STDIN, "%d %d", $a, $b);
 
	$A = '';
	$B = '';

	for ($i = 1; $i <= $b; $i++) {
      $A .= $a;
    }
	for ($i = 1; $i <= $a; $i++) {
      $B .= $b;
    }

	if (strcasecmp($A, $B) < 0) {
      echo ($A);
    } else {
      echo ($B);
    }

?>

Measured memory_bytes: 3828
#include <stdio.h>

int main(void){
    int a,b;
    scanf("%d%d",&a,&b);
    if(0 <= a <= 100 && 2 <= b <= 1000 && b%2 == 0){
        if(13 <= a){
            printf("%d\n",b);
        }else if(6 <= a && a <= 12){
            printf("%d\n",b/2);
        }else if(a <= 5){
            printf("%d\n",0);
        }
    }
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using V = vector<int>;
using VV = vector<vector<int>>;
using VVV = vector<vector<vector<int>>>;
using VL = vector<ll>;
using VVL = vector<vector<ll>>;
using VVVL = vector<vector<vector<ll>>>;
using pq = priority_queue<int>;
template<class T>
using P = pair<T, T>;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define REP(i,k,n) for(int i=(k);i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define output(x,y) cout << fixed << setprecision(y) << x << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
int under = (1 << 31);
int upper = under - 1;
ll UNDER = (1LL << 63);
ll UPPER = UNDER - 1;
const int MOD = 1e9 + 7;
const long double pi = 3.141592653589793;
int main() {
	string s;
	cin >> s;
	int ans = 0;
	rep(i, 4) {
		ans = (s[i] == '+') ? ans + 1 : ans - 1;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
# coding: utf-8
# Your code here!
while True:
   x = int(input())
   if x == 0:
      break
   
   y = 1000 - x;
   a = y % 500
   b = a % 100
   c = b % 50
   d = c % 10
   e = d % 5
   z = y // 500 + a // 100 + b // 50 + c // 10 + d // 5 + e
   
   print(z)


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

using namespace std;

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

	int n = atoi((a + b).c_str());

	int i = 1;
	while (i * i < n) {
		i++;
	}
	if (i * i == n) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;

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

    int n;
    cin >> n;

    vector <int> p(n);
    for (int i = 0; i < n; i++) cin >> p[i];

    vector <int> dp(n+1, 0);
    for (int i : p) dp[i] = dp[i-1] + 1;

    cout << n - *max_element(dp.begin(), dp.end()) << "\n";
    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <cctype>
#include <cstdio>
#include <math.h>
using namespace std;

int main(){
	int d,a;
	double b=90,x=0,y=0;
	while(scanf("%d,%d",&d,&a),d||a){
		x+=d*cos(b/180*acos(-1.0));y+=d*sin(b/180*acos(-1.0));
		b-=a;
	}
	cout<<(int)x<<endl<<(int)y<<endl;
}

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

int main() {
  int d;
  cin >> d;
  if (d == 22) {
    cout << "Christmas Eve Eve Eve" << endl;
  } else if (d == 23) {
    cout << "Christmas Eve Eve" << endl;
  } else if (d == 24) {
    cout << "Christmas Eve" << endl;
  } else {
    cout << "Christmas" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <algorithm>
#include <string>
using namespace std;
int main(){
	int H, W, K; 
	cin >> H >> W >> K; 
	long long int dp[110][10] = {}; 
	long long int P = 1e9 + 7; 
	int Fib[8] = {1, 1, 2, 3, 5, 8, 13, 21}; 
	if(W == 1){cout << 1 << endl; }
	else{
	dp[0][1] = 1; 
	for(int i = 1; i < 105; i++){
		dp[i][1] = ((dp[i-1][1] * Fib[W-1]) % P + (dp[i-1][2] * Fib[W-2]) % P) % P; 
		dp[i][W] = ((dp[i-1][W] * Fib[W-1]) % P + (dp[i-1][W-1] * Fib[W-2]) % P) % P; 
		for(int j = 2; j < W; j++){
			dp[i][j] = ((dp[i-1][j-1] * Fib[j-2] * Fib[W-j]) % P + (dp[i-1][j] * Fib[j-1] * Fib[W-j]) % P + (dp[i-1][j+1] * Fib[j-1] * Fib[W-j-1]) % P ) % P; 
	}
        }
	cout << dp[H][K] << endl; 
	}
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

const int INF = 191919;

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

    vector<int> nx(n);
    rep(i,n)
    {
        int a;
        cin >>a;
        nx[i] = (i+a)%n;
    }

    int ans = 0;
    vector<int> d(n,INF);
    rep(i,n)if(d[i]==INF)
    {
        vector<int> vis;
        d[i] = 0;
        int now = i;
        vis.pb(i);
        while(1)
        {
            if(d[nx[now]]==INF)
            {
                d[nx[now]] = d[now]+1;
                now = nx[now];
                vis.pb(now);
            }
            else
            {
                if(d[nx[now]]>=0) ans += d[now]-d[nx[now]]+1;
                break;
            }
        }

        for(int j:vis) d[j]=-1;
    }

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

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

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

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

#define MAX 100005
#define INF INT_MAX

int main(int, char**)
{
    int n;
    cin >> n;

    vector< vector<int> > G(n, vector<int>(n,0));
    int u, k, v;
    rep(i,n) {
        cin >> u >> k; u--;
        rep(j,k) {
            cin >> v; v--;
            G[u][v] = 1;
        }
    }
    rep(i,n) {
        rep(j,n) {
            if (j) cout << " ";
            cout << G[i][j];
        }
        cout << endl;
    }
    return 0;
}



Measured memory_bytes: 3168
#include <iostream>
using namespace std;
#define N 101
int main(){
	int n,d[N]={};
	cin >> n;
	for(int i=0;i<n;i++){
		cin >> d[i];
	}
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			if(d[i]>d[j]){
				int temp=d[i];
				d[i]=d[j];
				d[j]=temp;
			}
		}
	}
	int ans=0;
	int a[N]={};
	for(int i=0;i<n;i++){
		a[d[i]]++;
	}
	for(int i=0;i<N;i++){
		if(a[i]>0) ans++;
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var Arr=input.split("\n");
var A=Arr[1].split(" ").map(Number);
var N=Arr[0]-0;
console.log(A.join(" "));
for(var i=1;i<=N-1;i++){
   var v=A[i];
   var j=i-1;
   while(j>=0 && A[j]>v){
      A[j+1]=A[j];
      A[j]=v;
      j--;
   }
console.log(A.join(" "));
}

Measured memory_bytes: 7904
#include <bits/stdc++.h>
 
int main() {         
    int X, Y;
    std::cin >> X >> Y;

    const int Z =  Y - 2*X;
    std::string ret = "No";
    if (Z >= 0 && Z % 2 == 0) {
        const int b = Z / 2;
        if (X - b >= 0) {
            ret = "Yes";
        }
    }

    std::cout << ret << std::endl;
}


Measured memory_bytes: 3636
import math
a, b, x = [int(x) for x in input().split()]
L = x/a
if(2*L/a < b):
    print(math.atan(b**2/(2*L))*180/math.pi)
else:
    t = 2*L/a - b
    print(math.atan((b-t)/a)*180/math.pi)


Measured memory_bytes: 3060
# フェルマーの小定理
K = int(input())
S = input()

m = 1000000007


def make_factorial_table(n):
    result = [0] * (n + 1)
    result[0] = 1
    for i in range(1, n + 1):
        result[i] = result[i - 1] * i % m
    return result


def mcomb(n, k):
    if n == 0 and k == 0:
        return 1
    if n < k or k < 0:
        return 0
    return fac[n] * pow(fac[n - k], m - 2, m) * pow(fac[k], m - 2, m) % m


fac = make_factorial_table(len(S) - 1 + K)

result = 0
for i in range(K + 1):
    result += pow(26, i, m) * mcomb(len(S) - 1 + K - i, len(S) - 1) * pow(25, K - i, m)
    result %= m
print(result)


Measured memory_bytes: 107608
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, n) for(int i = 0; i < (n); i++)
#define MEM(a, x) memset(a, x, sizeof(a))
#define ALL(a) a.begin(), a.end()
#define UNIQUE(a) a.erase(unique(ALL(a)), a.end())
typedef long long ll;

int h, w;
string s[105];

int main(int argc, char const *argv[]) {
	ios_base::sync_with_stdio(false);
	cin >> h >> w;
	FOR(i, h) cin >> s[i];
	FOR(i, 2*h) cout << s[i/2] << endl;
	return 0;
}

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

int main() {
	string s;
	cin >> s;
	int Anum = 0;
	int state = 0;
	long long ans = 0;
	for (char c : s) {
		if (state == 0 && c == 'A') {
			Anum = 1;
			state = 1;
		}
		else if (state == 1) {
			switch (c) {
			case 'A':
				Anum++;
				break;
			case 'B':
				state = 2;
				break;
			default:
				Anum = 0;
				state = 0;
			}
		}
		else if (state == 2) {
			switch (c) {
			case 'A':
				Anum = 1;
				state = 1;
				break;
			case 'C':
				ans+=Anum;
				state = 1;
				break;
			default:
				Anum = 0;
				state = 0;
			}
		}
	}
	cout << ans << endl;
}

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

typedef long long int lli;
typedef unsigned long long int ulli;
typedef pair<int,int> pii;

#define ones(x) __builtin_popcount(x)
#define onesl(x) __builtin_popcountl(x)
#define onesll(x) __builtin_popcountll(x)

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define scn(n) scanf("%d",&n)
#define scnll(n) scanf("%lld",&n)
#define scn2(n,m) scanf("%d%d",&n,&m)
#define scn3(n,m,w) scanf("%d%d%d",&n,&m,&w)
#define scn2ll(n,m) scanf("%lld%lld",&n,&m)
#define atoz(v) v.begin(),v.end()
#define ratoz(v) v.rbegin(),v.rend()
#define Fill(a,v) memset(a,v,sizeof(a))
#define sz(v) v.size()
#define fi first
#define se second
#define inf 1e9
#define pi acos(-1.0)
#define sqr(x) x*x
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define ten(n) (int)1e##n
#define tenll(n) (lli)1e##n
#define mod 1000000007
#define FastIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

int Set(int N,int pos)
{
    return N=N | (1<<pos);
}
int reset(int N,int pos)
{
    return N = N & ~(1<<pos);
}
bool check(int N,int pos)
{
    return (bool)(N & (1<<pos));
}

void we_r_done(){cout<<"NO"; exit(0);}

void debug(string mssg){cout<<mssg; exit(0);}


int main()
{
    ///freopen("output.txt","w",stdout);
    ///freopen("input.txt","r",stdin);

    ///FastIO;

    int n,m;
    scn2(n,m);

    int lo = 1, hi = n;

    for(int i=1; i<=m; i++){
        int x,y;
        scn2(x,y);

        lo = max(x,lo);
        hi = min(hi,y);
    }

    cout<<max(0,hi-lo+1);

    return 0;
    ///return main();
}

///sin and cos expect input in radians not degrees. so use , sin(degrees * pi / 180)
///priority_queue< int, vector< int >, greater< int > > minHeap;
///using bs = bitset<MX>; // how many distinct number can be form?


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

using namespace std; 
#define REP(i, n) for (int i = 0; i < (n); i++)

typedef long long ll;
int res[300][300];  
vector<string> cake;
int main(int argc, char const *argv[])
{
    cin.tie(0);
   	ios::sync_with_stdio(false);
    int H, W, K; cin >> H >> W >> K;
    
    REP(i,H){
        REP(j,W) {
            res[i][j] = 0;        }
    }
    REP(i,H) {
        string l; cin >> l;
        cake.push_back(l);
    }
    int idx = 1;
    REP(ca, H) {
        REP(i, W){
            bool pr = true;
            bool po = true;
            if (cake[ca][i] == '#'){
                res[ca][i] = idx;
                int j = 1;
                while(i-j>=0 || i+j < W){
                    if (pr && i-j>=0 && cake[ca][i-j] == '.' && res[ca][i-j] == 0) res[ca][i-j] = idx;
                    else pr = false;
                    if (po && i+j< W && cake[ca][i+j] == '.' && res[ca][i+j] == 0) res[ca][i+j] = idx;
                    else po = false;
                    j++;
                    if (pr == po && pr == false) break;
                }
                idx++;
            }
        }
    }
    //i行目に一個もいちごがないパターンの扱い
    REP(i,H) {
        bool pu = true;
        bool pd = true;
        if (i == 0) pu = false;
        if (i == H - 1) pd = false;
        if (res[i][0] == 0) {
            int j = 1;
            while(i-j >= 0 || i + j < H) {
                if (pu && i-j >= 0) {
                    if(res[i-j][0] != 0){
                        REP(a,W) {res[i][a] = res[i-j][a];}
                        break;
                    }
                }
                else pu = false;
                if (pd && i+j < H) {
                    if(res[i+j][0] != 0){
                        REP(a,W) {res[i][a] = res[i+j][a];}
                        break;
                    }
                }
                else pd = false;
                j++;
            }
        }
    }
    REP(i,H){
        REP(j,W) {
            if (j == W-1) cout << res[i][j] << endl;
            else cout << res[i][j] << " ";
        }
    }
    return 0;
}


Measured memory_bytes: 1280
n,m=gets.split.map(&:to_i)
arr=Array.new(n)
flag=true
m.times do
    s,c=gets.split.map(&:to_i)
    
    if arr[s-1].nil? or arr[s-1]==c
        arr[s-1]=c
    else
        flag=false
    end
end
flag=false if arr[0]==0 and n!=1
n.times { |i| arr[i]=0 if arr[i].nil?}
if arr[0]==0 and n!=1
    arr[0]=1
end
    
puts flag ? arr.join : -1

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

using ll = long long;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)

#define rng(a) a.begin(), a.end()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using ld = long double;

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

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  rep(i, (int)v.size()) {
    if (i)
      os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
  for (auto val : array)
    std::cout << val << ", ";
  std::cout << "\n";
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

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

  int n; std::cin >> n;
  map<char, int> cnt;
  rep(i, n) {
    string s; std::cin >> s;
    if (s[0] == 'M' || s[0] == 'A' || s[0] == 'R' || s[0] == 'C' || s[0] == 'H')
      cnt[s[0]]++;
  }
  vi vec;
  for (auto p : cnt) {
    vec.pb(p.se);
  }
  ll ans = 0;
  rep(i, vec.size()) srep(j, i+1, vec.size()) srep(k, j+1, vec.size()) {
    ans += 1ll * vec[i] * vec[j] * vec[k];
  }
  std::cout << ans << "\n";
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int m, f, r;
	while(1)
	{
		cin >> m >> f >> r;
		if(m == -1 && f == -1 && r == -1)
			break;
	     /* 入力された点数に対する処理... */
	    if(m == -1 || f == -1){
		    cout << "F" << endl;
		}else if(m + f >= 80){
		    cout << "A" << endl;
		}else if(m + f >= 65 && m+f < 80){
		    cout << "B" << endl;
		}else if(m+ f >= 50 && m + f < 65){
		    cout << "C" << endl;
		}else if(m + f >= 30 && m + f < 50){
		    if(r >= 50){
		       cout << "C" << endl;
		    }else{
		       cout << "D" << endl;
		    }
		}else{
		    cout << "F" << endl;
		}
	}
	return 0;
}



Measured memory_bytes: 3120
// Garg's Code
#include <bits/stdc++.h>
#include <string.h>
using namespace std;
 
#define ll long long
#define vec vector < ll >
#define pb push_back
#define po pop_back
#define mp make_pair
#define mt make_tuple
#define F  first
#define S  second
#define f(i,x,n) for(ll i=x;i<n;i++)
#define rf(i,x,n) for(ll i = x; i >= x; i--) 
#define all(c) c.begin(),c.end()
#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL)
const ll MAX = LLONG_MAX, MOD = 1000000007, MODA = 1e9 - 1;
const ll MIN = LLONG_MIN;
const long double PI = 3.1415926535;

int main()
{
  fast();

  
  ll n;
  cin >> n;
  ll arr[n];
  ll minm[n];
  f(i,0,n)
  {
    cin >> arr[i];
  }
  minm[0] = arr[0];
  f(i,1,n)
  {
    minm[i] = min(arr[i], minm[i-1]);
  }
  ll ans = 0;
  f(i,0,n)
  {
    if(arr[i] == minm[i])
      ans += 1;
  }
  cout << ans;
  return 0;
}

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

int main() {
  int N, A = 0;
  cin >> N;
  
  for (int i = 0; i < N; i++) {
    int l, r;
  	cin >> l >> r;
    
    A += r-l+1;
  }
  
  cout << A << endl;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
n = int(input())
a1 = [int(i) for i in input().split()] 
a2 = [int(i) for i in input().split()] 

ans = 0
for i in range(n):
    tmp = sum(a1[:i+1]) + sum(a2[i:])
    if tmp >= ans:
        ans = tmp
print(ans)


Measured memory_bytes: 2940