akhauriyash/Code-Regression huggingface dataset:
x, y = [int(n) for n in input().split()]

g1 = [1, 3, 5, 7, 8, 10, 12]
g2 = [4, 6, 9, 11]
g3 = [2]

if x in g1 and y in g1:
    print('Yes')
elif x in g2 and y in g2:
    print('Yes')
elif x == 2 or y == 2:
    print('No')
else:
    print('No')

Measured memory_bytes: 3064
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<cstddef>
#include<queue>
#include<math.h>
using namespace std;

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

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

    vector<long long> w(N), v(N);
    for(int i = 0; i < N; ++i) cin >> w.at(i) >> v.at(i);

    vector<vector<long long>> dp(N + 1, vector<long long>(W + 1));

    for(int i = 0; i < N ;++i)
    {
        for(int sum_w = 0; sum_w < W + 1; ++sum_w)
        {
            chmax(dp.at(i + 1).at(sum_w), dp.at(i).at(sum_w));
            if((sum_w - w.at(i)) >= 0) chmax(dp.at(i + 1).at(sum_w), dp.at(i).at(sum_w - w.at(i)) + v.at(i));
            //cout << i + 1 << ' ' << sum_w << ' ' << dp.at(i + 1).at(sum_w) << endl;
        }
    }
    cout << dp.at(N).at(W) << endl; 
    return 0;
}

Measured memory_bytes: 80256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned int uint;
typedef unsigned char uchar;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;

#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();i++)
#define RFOR(i,c) for(__typeof((c).rbegin())i=(c).rbegin();i!=(c).rend();i++)
#define ALL(container) (container).begin(), (container).end()
#define RALL(container) (container).rbegin(), (container).rend()
#define SZ(container) ((int)container.size())
#define mp(a,b) make_pair(a, b)
#define pb push_back
#define eb emplace_back
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define __builtin_popcount __builtin_popcountll

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {
    os<<"["; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"]"; return os;
}
template<class T> ostream& operator<<(ostream &os, const set<T> &t) {
    os<<"{"; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"}"; return os;
}
template<class S, class T> ostream& operator<<(ostream &os, const map<S, T> &t) {
    os<<"{"; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"}"; return os;
}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}
template<class S, class T> pair<S,T> operator+(const pair<S,T> &s, const pair<S,T> &t){ return pair<S,T>(s.first+t.first, s.second+t.second);}
template<class S, class T> pair<S,T> operator-(const pair<S,T> &s, const pair<S,T> &t){ return pair<S,T>(s.first-t.first, s.second-t.second);}

const int INF = 1<<28;
const double EPS = 1e-8;
const int MOD = 1000000007;


int T, n, m;

int main(int argc, char *argv[]){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    string s;
    while(cin >> n){
        double sum = 0;
        REP(i, n){
            double a;
            cin >> a;
            sum += 1 / a;
        }
        printf("%.10f\n", 1 / sum);
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <stdio.h>
 
using namespace std;
 
#define int long long
#define rep(i, a, b) for (int i = (a); i <= (b); ++i)

void solve();

signed main () {
    cout.precision(10);
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    #ifdef LOCAL
        freopen("input.txt", "r", stdin);
    #endif
    int t = 1; 
    // cin >> t;	
    int tt = t;
    while (t--) { 
        solve();
    }
    return 0;
}
const int N = 1e5 + 55;
string s;
int n;
int typ[N];
bool check (int n) {
	for (int i = 0; i < n; i += 1) {
		if (typ[i] == 1 and s[i] == 'o' and typ[(i - 1 + n) % n] != typ[(i + 1) % n])
			return false;
		if (typ[i] == 1 and s[i] == 'x' and typ[(i - 1 + n) % n] == typ[(i + 1) % n])
			return false;
		if (typ[i] == 0 and s[i] == 'x' and typ[(i - 1 + n) % n] != typ[(i + 1) % n])
			return false;
		if (typ[i] == 0 and s[i] == 'o' and typ[(i - 1 + n) % n] == typ[(i + 1) % n])
			return false;
	}
	return true;
}
void solve() {
	cin >> n;
	cin >> s;
	assert((int) s.size() >= 3);
	for (int a = 0; a < 2; ++a) {
		for (int b = 0; b < 2; ++b) {
			typ[0] = a;
			typ[1] = b;
			for (int i = 2; i < n; ++i) {
				if (s[i - 1] == 'o' and typ[i - 1] == 1)
					typ[i] = typ[i - 2];
				if (s[i - 1] == 'x' and typ[i - 1] == 1)
					typ[i] = typ[i - 2] ^ 1;
				if (s[i - 1] == 'o' and typ[i - 1] == 0)
					typ[i] = typ[i - 2] ^ 1;
				if (s[i - 1] == 'x' and typ[i - 1] == 0)
					typ[i] = typ[i - 2];	 
			}
			if (check(n)) {
				for (int i = 0; i < n; i += 1) {
					if (typ[i] == 1)
						cout << 'S';
					else
						cout << 'W';
				}
				return;
			}
		}
	}
	cout << -1;
}     	

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

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

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

	int result = 0;

	for (int i = 0; i < n; ++i) {
		result += 2 * min(x[i], k - x[i]);
	}

	cout << result << endl;
}


Measured memory_bytes: 256
n,k = map(int,input().split())
v = list(map(int,input().split()))
v_r = v[::-1]
ans = 0
for i in range(1,min(k+1,n+1)):
    for a in range(1,i+1):
        a_ = v[:a]
        b_ = v_r[:(i-a)]
        ab = a_+b_
        ab.sort()
        s = sum(ab)
        for j in range(k-i):
            if j<len(ab) and ab[j]<0:
                s -= ab[j]
            else:
                break
        ans = max(ans,s)
print(ans)

Measured memory_bytes: 39792
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <queue>
#include <unordered_map>

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

using namespace std;

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

struct V {
    int num;
    int depth;
    V(){}
    V(int num, int depth) {
        this->num = num;
        this->depth = depth;
    }
};

int main(){
    int n,u,v; cin >> n >> u >> v;
    u--; v--;
    vector<vector<ll>> adj(n);
    rep(i, n-1) {
        int a,b; cin >> a >> b;
        a--;b--;
        adj[a].push_back(b);
        adj[b].push_back(a);
    }
    vector<int> distfromAoki(n,0);
    vector<int> distfromTakahashi(n,0);

    queue<V> q;
    vector<int> visited1(n,0);
    q.push(V(u,0));
    // visited1[u] = 1;
    while(!q.empty()) {
        V next = q.front();
        q.pop();
        if(visited1[next.num] == 1)
            continue;
        visited1[next.num] = 1;
        distfromTakahashi[next.num] = next.depth;
        for(auto i : adj[next.num]) {
            q.push(V(i,next.depth+1));
        }
    }
    vector<int> visited2(n,0);
    q.push(V(v,0));
    while(!q.empty()) {
        V next = q.front();
        q.pop();
        if(visited2[next.num] == 1)
            continue;
        visited2[next.num] = 1;
        distfromAoki[next.num] = next.depth;
        for(auto i : adj[next.num]) {
            q.push(V(i,next.depth+1));
        }
    }
    int x = -1;
    int dst;
    rep(i,n) {
        // if(distfromTakahashi[i]==0)
        //     continue;
        int diff = distfromTakahashi[i] - distfromAoki[i];
        if(diff < 0 && distfromAoki[i]-1 > x){
            x = distfromAoki[i]-1;
            dst = i;
        }
    }
    if(x==-1) {
        if(distfromTakahashi[v] ==1)
            cout << 0 << endl;
        else
            cout << 1 << endl;
        return 0;
    }
    // cout << dst << endl;
    cout << x << endl;
}


Measured memory_bytes: 8064
# -*- coding: utf-8 -*-
"""
Created on Sat Dec  8 20:50:55 2018

@author: Owner
"""

import collections
import scipy.misc
import sys
import numpy as np
import math
from operator import itemgetter

def prime_decomposition(n):
  i = 2
  table = []
  while i * i <= n:
    while n % i == 0:
      n /= i
      table.append(int(i))
    i += 1
  if n > 1:
    table.append(int(n))
  return table   

def digit(i):
    if i > 0:
        return digit(i//10) + [i%10]
    else:
        return []

"""
N, X = map(int, input().split())

x = [0]*N
x[:] = map(int, input().split())

P = [0]*M
Y = [0]*M
for m in range(M):
    P[m], Y[m] = map(int, input().split())
    
all(nstr.count(c) for c in '753')
"""

N = int(input())

p = [0]*N
for n in range(N):
    p[n]= int(input())

p[np.argmax(p)] = p[np.argmax(p)]/2

print(int(sum(p)))



Measured memory_bytes: 23604
# from math import factorial,sqrt,ceil,gcd
# from itertools import permutations as permus
# from collections import deque,Counter
# import re
# from functools import lru_cache # 簡単メモ化 @lru_cache(maxsize=1000)
# from decimal import Decimal, getcontext
# # getcontext().prec = 1000
# # eps = Decimal(10) ** (-100)

# import numpy as np
# import networkx as nx
# from scipy.sparse.csgraph import shortest_path, dijkstra, floyd_warshall, bellman_ford, johnson
# from scipy.sparse import csr_matrix
# from scipy.special import comb

# slist = "abcdefghijklmnopqrstuvwxyz"
N = int(input())
arrA = list(map(int,input().split()))
travel1 = [abs(arrA[0])]
travel2 = [abs(arrA[1])]
for i in range(N-1):
    travel1.append(abs(arrA[i]-arrA[i+1]))
    if i <N-2:
        travel2.append(abs(arrA[i]-arrA[i+2])) 
    else:
        travel2.append(abs(arrA[i])) 
travel1.append(abs(arrA[N-1]))

sums = sum(travel1)

for i in range(N):
    print(sums-travel1[i]-travel1[i+1]+travel2[i])
# print(*ans)   # unpackして出力。間にスペースが入る
# for row in board:
#     print(*row,sep="")    #unpackして間にスペース入れずに出力する
# print("{:.10f}".format(ans))
# print("{:0=10d}".format(ans))


Measured memory_bytes: 17188
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <cmath>
#include <cassert>
using namespace std;

int main(){
    int N, M;
    cin >> N >> M;
    vector<pair<int, int>> BA(N);
    for(int i=0; i<N; i++){
        int A, B;
        cin >> A >> B;
        BA[i] = make_pair(B, A);
    }
    sort(BA.begin(), BA.end(), greater<pair<int, int>>());

    long long ans = 0;
    set<int> st;
    for(int i=0; i<M; i++)
        st.insert(-i);

    for(auto ba : BA){
        int b = ba.first;
        int a = ba.second;
        int ind = M - a;
        auto itr = st.lower_bound(-ind);
        if(itr != st.end()){
            ans += b;
            st.erase(itr);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 5760
#include <bits/stdc++.h>
using namespace std; 
long long power; 
int n;
int main() {
   cin >> n;
   for(int i=0;i<n;i++) 
	{
    	long long m;
        cin>>m;
        while(m%2==0) 
		{
            power++;
            m /= 2;
        }
    }
    cout << power << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
 
#define LEN 100005
#define NAME_LEN 100
 
 
using namespace std;
 
template <typename T>
class Queue
{
private:
    T* queueArray;
    int head;
    int tail;
    int queueSize;
public:
    Queue(int queueSize)
    {
        Initialize(queueSize);
    }
    void Initialize(int size) {
        head = tail = 0;
        queueSize = size;
        queueArray = new T[queueSize];
    }
    void Enqueue(T x) {
        if (IsFull()) {
            cout << "Queue is Full\n";
            return;
        }
        queueArray[tail] = x;
        tail = (++tail == queueSize) ? 0 : tail;
    }
    T Dequeue() {
        if (IsEmpty()) {
            cout << "Queue is Empty\n";
            //Write something that will throw error.
        }
        T dequeuingValue = queueArray[head];
        head = (++head == queueSize) ? 0 : head;
 
        return dequeuingValue;
 
    }
    bool IsFull() {
        return head == ((tail + 1) % queueSize);
    }
    bool IsEmpty() {
        return head == tail;
    }
     
    ~Queue() {}
};
 
struct ProcessCard {
    char name[NAME_LEN];
    int time;
};
 
int main() {
 
    int elapsedTime = 0;
    int maxProcessNumber, quantum;
    Queue<ProcessCard> queue = Queue<ProcessCard>(LEN);
    ProcessCard process;
 
    scanf("%d %d", &maxProcessNumber, &quantum);
 
    for (int i = 0; i < maxProcessNumber; i++) {
        scanf("%s", process.name, NAME_LEN);
        scanf("%d", &process.time);
        queue.Enqueue(process);
    }
 
    while (!(queue.IsEmpty())) {
        process = queue.Dequeue();
 
 
        elapsedTime += (process.time > quantum) ? quantum : process.time;
        process.time = (process.time > quantum) ? process.time - quantum : 0;
 
        if (process.time > 0) {
            queue.Enqueue(process);
        }
        else {
            printf("%s %d\n", process.name, elapsedTime);
        }
    }
 
     
     
    return 0;
}


Measured memory_bytes: 13308
#include<bits/stdc++.h>
using namespace std;
#define ll              long long
#define pb              push_back
#define read(s)         freopen(#s,"r",stdin)
#define write(s)        freopen(#s,"w",stdout)
#define lead_zero(x)    __builtin_clzll(x)
#define trail_zero(x)   __builtin_ctz(x)
#define total_1s(x)     __builtin_popcount(x)


int main()
{
    ll n,cnt=0,x;
    cin>>n;
    vector<bool>v(100,0);
    for(ll i=0;i<n;i++)
    {
        cin>>x;
        v[x]=1;
    }
    for(ll i=1;i<=100;i++)
    {
        if(v[i])
            cnt++;
    }
    cout<<cnt<<endl;
}


Measured memory_bytes: 256
import math
n=int(input())
ans=0
for i in range(2,int(math.sqrt(n)+1)):
    if n%i==0:
        prime=i
        power=0
        while n%i==0:
            n=n//i
            power+=1
        st=1
        while st<=power:
            ans+=1
            power-=st
            st+=1
if n>1:
    ans+=1
print(ans)
    


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

int main() {
    int n;
    cin >> n;
    int p[n];
    rep(i, n) cin >> p[i];

    int ans = 0;
    rep(i, n) {
        if (p[i] == i + 1) swap(p[i], p[i + 1]), ans++;
    }

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


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  long long sum = 0;
  cin >> n;
  for (int i = 1; i <= n; ++i)
  {
    if (i % 3 != 0 && i % 5 != 0) {
      sum += i;
    }
  }
  cout << sum;
}

Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define pi 3.141592653589
 
ll power(ll b,ll e,ll m)
{
    if(e==0) return 1;
    if(e&1) return b*power(b*b%m,e/2,m)%m;
    return power(b*b%m,e/2,m);
}
ll power(ll b,ll e)
{
    if(e==0) return 1;
    if(e&1) return b*power(b*b,e/2);
    return power(b*b,e/2);
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s;
    cin>>s;
    int n=s.size();
    if(s[n-1]=='s')
    {
        cout<<s;
        cout<<"es";
    }else
    {
        cout<<s;
        cout<<"s";
    }
    
    return 0;
}

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

int main() {
	int a, b, t;
	cin >> a >> b >> t;
	int y;
	y = t % a;
	int n;
	n = (t - y) / a;
	int ans;
	ans = n * b;
	cout << ans << endl;



	return 0;
}

Measured memory_bytes: 256
//
//AOJ DPL DPL_1 1A
//http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=DPL_1_A&lang=jp
//20170514
//640009E
//Yang Bo
//

#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
  int n, m;
  cin >> n >> m;
  vector<int> coin(m);
  vector<int> ans(n, n);
  
  for (int i = 0; i < m; i++)
    cin >> coin[i]; //?????????????¨?????????\???

  sort(coin.begin(), coin.end());

  for (int i = 0; i < m; i++)
    ans[coin[i] - 1] = 1; //???????????§???????????????

  
  //for (int i = 0; i < n; i++)
  //cout << "1????????????????????§???ans[" << i << "] = " << ans[i] << endl;
  
  
  int t = 0; //coin????????¢?´¢????????????
  
  for (int i = 0; i < n; i++) {
    if (ans[i] == 1) {
      t++;
      //cout << i << " " <<  "???????????????????????§???ans = " << ans[i] << endl;
      continue;
    }
    else {
      int s = ans[i];
      for (int j = 0; j < t; j++) {
	if (s > ans[i - coin[j]]) {
	  s = ans[i - coin[j]]; //???????????§???????????°????°??????????????????¢???
	  ans[i] = s + 1;
	}
	//cout << i << " " << j << " " << "???????????????????????§???ans = " << ans[i] << endl;
      }
    }
  }
  cout << ans[n - 1] << endl;
}

//????????\????????????????????¢?????´???????????????????????????????????§?????????

Measured memory_bytes: 3164
#include "bits/stdc++.h"
using namespace std;

#define EPS (1e-10)
class P{                    //???
public:
    double x,y;
    
    P(double _x=0,double _y=0):x(_x),y(_y){};
    P operator + (P &p     ){ return P( x+p.x , y+p.y ); }  //??????
    P operator - (P &p     ){ return P( x-p.x , y-p.y ); }  //??????
    P operator * (double k ){ return P( x*k   , y*k    ); } //??????
    P operator / (double k ){ return P( x/k   , y/k    ); } //??????
    
    bool operator == (const P &p){ return ( fabs(x-p.x)<EPS && fabs(y-p.y)<EPS ); }
    //    bool operator < (const P &p)const{ return ( x!=p.x ? x<p.x:y<p.y ); }
    
    double norm(){ return x*x+y*y; }        //?????????
    double abs() { return sqrt(norm()); }   //??§??????
    
};
struct L{P p1,p2;};         //??´???
typedef vector<P> Polygon;  //????§???¢
typedef P Vector;           //????????????

double dot  (Vector a,Vector b){ return a.x*b.x+a.y*b.y; }
double cross(Vector a,Vector b){ return a.x*b.y-a.y*b.x; }

int ccw(P p0,P p1,P p2){    //AOJ_BOOK_P386 verifyed
    Vector a = p1 - p0;
    Vector b = p2 - p0;
    
    if( cross(a,b) > EPS  ) return 1 ;      //COUNTER_CLOCKWISE
    if( cross(a,b) < -EPS ) return -1;      //CLOCKWISE
    if( dot(a,b)   < -EPS ) return 2;       //ONLINE_BACK
    if( a.norm()   < b.norm() ) return -2;  //ONLINE_FRONT
    
    return 0;                               //ON_SEGMENT;
}

//?????????????????? verifyed
bool intersect(P p1,P p2,P p3,P p4){ return ( ccw(p1,p2,p3)*ccw(p1,p2,p4)<=0 && ccw(p3,p4,p1)*ccw(p3,p4,p2)<=0 ); }



int main(){
    int n;
    cin>>n;
    for(int j=0;j<n;j++){
        P p[4];
        for(int i=0;i<4;i++){
            int x,y;
            cin>>x>>y;
            p[i] = P(x,y);
        }
        cout<<intersect(p[0],p[1],p[2],p[3])<<endl;
    }
}

Measured memory_bytes: 3096
#include <bits/stdc++.h>
#define GET_REP(_1, _2, _3, NAME, ...) NAME
#define rep(...) GET_REP(__VA_ARGS__, irep, _rep)(__VA_ARGS__)
#define rep1(...) GET_REP(__VA_ARGS__, irep1, _rep1)(__VA_ARGS__)
#define _rep(i, n) irep (i, 0, n)
#define _rep1(i, n) irep1(i, 1, n)
#define irep(i, a, n) for (int i = a; i < (int)(n); ++i)
#define irep1(i, a, n) for (int i = a; i <= (int)(n); ++i)
#define rrep(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define rrep1(i, n) for (int i = (int)(n); i >= 1; --i)
#define allrep(X, x) for (auto &&X : x)
#define all(x) begin(x), end(x)
#define debug(x) cout << #x " => " << (x) << endl
#ifdef LOCAL
  #include "../../Lib/cout_container.hpp"
#endif
using lint = long long;
constexpr int MOD = (int)1e9 + 7;
constexpr double EPS = 1e-9;
using namespace std;
namespace { struct INIT { INIT() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(15); } } INIT; }

int main(void) {
  int n;
  cin >> n;
  vector<string> s(n);
  rep (i, n) cin >> s[i];
  map<string, int> m;
  rep (i, n) m[s[i]]++;
  int maxi = max_element(all(m), [](auto &a, auto &b) { return a.second < b.second; })->second;
  allrep (x, m) {
    if (x.second == maxi) {
      cout << x.first << "\n";
    }
  }
  return 0;
}

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

int main() {
    long n; long ans = 10e+12;
    cin >> n;
    long int sqrtn = sqrtl(n);
    for (int i = 1; i <= sqrtn; i++) {
        if (n % i == 0) ans = min(ans, i+n/i-2);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
// In the name of god
#include <bits/stdc++.h>
#pragma GCC optimze("02")
using namespace std;
using ll = long long;
const ll maxn=1e7+7;
ll n,a[maxn],sum;
int main(){
	ios::sync_with_stdio(false) , cin.tie(0) , cout.tie(0);
	cin>>n;
	for(int i=1;i<=n;i++){
		for(int j=i;j<=n;j+=i)a[j]++;
		sum+=(a[i]*i);
	}
	cout<<sum;
}


Measured memory_bytes: 81772
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))

cnt=0

for i in range(n):
  if a[n-i]>=b[n-1-i]:
    cnt+=b[n-1-i]
  else:    
    if a[n-1-i]-(b[n-1-i]-a[n-i])>=0:
      a[n-1-i]-=b[n-1-i]-a[n-i]
      cnt+=b[n-1-i]
    else:
      cnt+=a[n-i]+a[n-1-i]
      a[n-1-i]=0
      
print(cnt)


Measured memory_bytes: 97680
#include <cmath>
#include <cstdio>
#include <vector>
#include <map>
#include <queue>
#include <list>
#include <stack>
#include <iostream>
#include <algorithm>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); ++i)
using ll = long long;
using P = pair<int, int>;

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

  int x,y,a,b,c;
  cin >> x >> y >> a >> b >> c;
  priority_queue<int> ps;
  rep(i, a) {
    int x;
    cin >> x;
    ps.push(x);
  }
  priority_queue<int> qs;
  rep(i, b) {
    int x;
    cin >> x;
    qs.push(x);
  }
  priority_queue<int> rs;
  rep(i, c) {
    int x;
    cin >> x;
    rs.push(x);
  }

  ll total = 0;
  queue<int> pp;
  queue<int> qq;
  rep(i, x) {
    pp.push(ps.top());
    ps.pop();
  }
  rep(i, y) {
    qq.push(qs.top());
    qs.pop();
  }
  rep(i, x + y) {
    int am = pp.empty() ? 0 : pp.front();
    int bm = qq.empty() ? 0 : qq.front();
    int cm = rs.empty() ? 0 : rs.top();
    int m = max(am, max(bm, cm));
    total += m;
    if (am == m) {
      pp.pop();
    }
    else if (bm == m) {
      qq.pop();
    } else {
      rs.pop();
    }
  }
  cout << total << endl;
}




Measured memory_bytes: 2168
#include <iostream>
#include <stdio.h>
using namespace std;

#define pi  3.14159265358979323846

int main()
{
    double x, r, s, l;
    cin >> x;
    s = x*pi;
    r = x*pi - s;

    printf("%.6lf", (s+r)*x);
    l = 2*x;
    r = 2*x - l;
    printf(" %.6lf", (l+r)*pi);
}

Measured memory_bytes: 1240
length=input()
#len-1
Narray=sorted(input().split())
n=0
while n<int(length)-1:
	if Narray[n] == Narray[n+1]:
		print("NO")
		break
	elif n==int(length)-2:
		print("YES")
		break
	else:
		n+=1
    	

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ll long long
#define PINT pair<int,int>
#define f1 first
#define s2 second
const int INF = 1e9 + 7;

using namespace std;

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

    int x,y,z,a;
    cin >> x>> y >> z >> a;
    if(x>y) x=y;
    if(z>a) z=a;
    cout << x+z << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define EPS (1e-10)
#define equals(a, b) (fabs((a)-(b)) < EPS)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;

struct mint {
  ll x;
  mint(ll x=0):x((x%MOD+MOD)%MOD){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= MOD) x -= MOD;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += MOD-a.x) >= MOD) x -= MOD;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= MOD; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
      mint a = pow(t>>1);
      a *= a;
    if (t&1) a *= *this;
      return a;
  }
   mint inv() const { return pow(MOD-2);}
   mint& operator/=(const mint a) { return *this *= a.inv();}
   mint operator/(const mint a) const { return mint(*this) /= a;}
};
typedef vector<mint> vm;
typedef vector<vm> vvm;

vvm mul(vvm &a,vvm &b) {
  vvm c(sz(a),vm(sz(b[0])));
  rep(i,sz(a)) {
    rep(k,sz(b)) {
      rep(j,sz(b[0])) {
        c[i][j] += a[i][k]*b[k][j];
      }
    }
  }
  return c;
}

vvm pow(vvm a,ll n) {
  vvm b(sz(a),vm(sz(a)));
  rep(i,sz(a)) {
    b[i][i]=1;
  }
  while(n>0) {
    if(n&1) {
      b = mul(b,a);
    }
    a = mul(a,a);
    n >>= 1;
  }
  return b;
}
  
int main() {
  int N;
  ll K;
  cin >> N >> K;
  vvm G(N,vm(N,0));
  rep(i,N) {
    rep(j,N) {
      int x;
      cin >> x;
      G[i][j]+=x;
    }
  }
  vvm dst = pow(G,K);
  mint ans = 0;
  rep(i,N) {
    rep(j,N) {
      ans += dst[i][j];
    }
  }
  cout << ans.x << endl;
  return 0;
}

Measured memory_bytes: 384
import java.io.PrintWriter;
import java.util.Scanner;

public class Main {

    static Scanner sc = new Scanner(System.in);
    static PrintWriter out = new PrintWriter(System.out);

    public static void main(String[] args) {
        int a = nextInt();

        int Answer = a * a;

        println(Answer);
    }

    static int nextInt() {
        return Integer.parseInt(next());
    }

    static String next() {
        return sc.next();
    }

    static String nextLine(){
        return sc.nextLine();
    }

    static void println(Object o) {
        out.println(o);
        out.flush();
    }
}


Measured memory_bytes: 22996
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string s;
  int counter=0;
  cin >> s;
  if(s[0]=='o') ++counter;
  if(s[1]=='o') ++counter;
  if(s[2]=='o') ++counter;
  
    cout << 700+100*counter << endl;
}

Measured memory_bytes: 3596
<?php
fscanf(STDIN, '%d %d', $N, $K);
$pp = [];
for ($i = 0; $i < $N; $i++) {
	fscanf(STDIN, '%s', $P);
	$pp[substr($P, 0, 1)]++;
}

$res = 0;
$len = count($pp);
while (true) {
	arsort($pp);
	$pp = array_values($pp);
	$idx = 0;
	for ($i = 0; $i < $K; $i++) {
		if ($pp[$idx] > 0) {
			$pp[$idx++]--;
		} else {
			break 2;
		}
	}
	$res++;
}
echo $res.PHP_EOL;

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

using namespace std;

// Repetitions
#define FOR(i,a,n) for(ll i = ((ll) a); i < ((ll) n); ++i)
#define FORR(i, s, g) for(ll i = ((ll)s - 1); i >= ((ll) g); --i)
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) FORR(i, n, 0)

// Container Utils
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define SORTALL(v) sort(ALL(v))
#define SZ(a) int((a).size())
#define CLR(a) memset((a), 0 ,sizeof(a))
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())

// For Debug
#define DMP(x)  cerr << #x << " = " << (x) << endl
#define DBG(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl

// Aliases
#define PB push_back
#define MP make_pair
typedef long long ll;
typedef string str;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;

// I/O Asynchronizing
struct aaa{
    aaa(){
        cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);
    };
}aaaaaaa;

int main() {
    str s;
    int n;
    cin >> s >> n;
    int ans = 0;
    REP(i, n) {
        str t;
        cin >> t;
        int len = t.length();
        t += t;
        REPR(i, len) {
            if(t[i] == s[0] && t.substr(i, s.length()) == s) {
                ans++;
                break;
            }
        }
    }
    cout << ans << "\n";

    return 0;
}



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

#define d(x) cerr << #x ":" << x << endl;
#define dd(x, y) cerr << "(" #x "," #y "):(" << x << "," << y << ")" << endl
#define rep(i, n) for (int i = (int)(0); i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define dump(v)                  \
    cerr << #v ":[ ";            \
    for (auto macro_vi : v) {    \
        cerr << macro_vi << " "; \
    }                            \
    cerr << "]" << endl;
#define ddump(v)                           \
    cerr << #v ":" << endl;                \
    for (auto macro_row : v) {             \
        cerr << "[";                       \
        for (auto macro__vi : macro_row) { \
            cerr << macro__vi << " ";      \
        }                                  \
        cerr << "]" << endl;               \
    }
using lint       = long long;
const int INF    = 1e9;
const lint LINF  = 1e18;
const double EPS = 1e-10;

int main() {
    lint H, W;
    cin >> H >> W;
    vector<string> G(H);
    rep(h, H) { cin >> G[h]; }

    map<char, int> mp;
    rep(h, H) rep(w, W) { mp[G[h][w]]++; }

    int set_4 = 0, set_2 = 0, set_1 = 0;
    for (auto p : mp) {
        char c = p.first;
        int x  = p.second;
        set_4 += x / 4;
        x %= 4;
        set_2 += x / 2;
        x %= 2;
        set_1 += x;
    }

    dd(set_4, set_2);
    d(set_1);

    rep(i, H / 2) rep(j, W / 2) {
        if (set_4 == 0) {
            cout << "No" << endl;
            return 0;
        }
        set_4--;
    }
    set_2 += set_4 * 2;

    if (H % 2 == 1) {
        rep(w, W / 2) {
            if (set_2 == 0) {
                cout << "No" << endl;
                return 0;
            }
            set_2--;
        }
    }

    if (W % 2 == 1) {
        rep(h, H / 2) {
            if (set_2 == 0) {
                cout << "No" << endl;
                return 0;
            }
            set_2--;
        }
    }

    set_1 += set_2 * 2;

    if (H % 2 == 1 && W % 2 == 1) {
        if (set_1 == 0) {
            cout << "No" << endl;
            return 0;
        }
        set_1--;
    }

    cout << "Yes" << endl;
}

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

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()
#define endl "\n"

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

  int N,M;
  cin>>N>>M;
  vector<int>A(N);
  for(int i=0;i<N;i++)cin>>A[i];
  int sum=0;
  for(auto it:A)sum+=it;
  int ans=0;
  for(auto it:A)if(it*4*M>=sum)ans++;
  if(ans>=M)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;

  return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
const double EPS=1e-8;
typedef vector<double> vec;
typedef vector<vec> mat;

//Ax=bを解く
//解が一意でない場合は長さ0の配列
vec solve(const mat &A, const vec &b)
{
	int n=A.size();
	//cerr<<n<<endl;
	mat B(n,vec(n+1));
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<n;j++)
			B[i][j]=A[i][j];
	}
	for(int i=0;i<n;i++)
		B[i][n]=b[i];
	
	for(int i=0;i<n-1;i++)
	{
		int pivot=i;
		for(int j=i;j<n;j++)
		{
			if(abs(B[j][i])>abs(B[pivot][i]))
				pivot=j;
		}
		swap(B[i],B[pivot]);

		//解がない
		if(abs(B[i][i])<EPS)
			return vec();
		
		for(int j=i+1;j<=n;j++)
			B[i][j]/=B[i][i];
		for(int j=0;j<n;j++)
		{
			if(i!=j)
			{
				for(int k=i+1;k<=n;k++)
					B[j][k]-=B[j][i]*B[i][k];
			}
		}
	}
	vec x(n);
	for(int i=0;i<n;i++)
	{
		//cerr<<B[i][n]<<endl;
		x[i]=B[i][n];
	}
	return x;
}

vec v;
mat a;
mat mother;
vec b;
int main()
{
	while(1)
	{
		v.clear();
		mother.clear();
		int d;
		cin>>d;
		if(d==0)
			break;
		for(int i=0;i<d+3;i++)
		{
			double c;
			cin>>c;
			v.push_back(c);
		}
		//motherを構成する
		for(int i=0;i<v.size();i++)
		{
			vec tmp;
			for(int j=d;j>0;j--)
				tmp.push_back(pow(i,j));
			tmp.push_back(1);
			tmp.push_back(0);
			mother.push_back(tmp);
		}
		//aを構成する
		//vからひとつずつ抜いて連立方程式を解く
		//解けたら抜いたvが誤り
		for(int i=0;i<d+3;i++)
		{
			b.clear();
			a.clear();
			for(int j=0;j<d+3;j++)
			{
				if(i==j)
					continue;
				a.push_back(mother[j]);
				b.push_back(v[j]);
			}
			/*
			for(int i=0;i<a.size();i++)
			{
				for(int j=0;j<a[i].size();j++)
					cerr<<a[i][j]<<" ";
				cerr<<"\t"<<b[i]<<endl;
			}*/
			//解く
			vec ans=solve(a,b);
			if(ans.size()==0)
				continue;
			//残りの部分に当てはめて正しければ答え
			if(abs(ans[d+1])<1e-5)
			{
				cout<<i<<endl;
				break;
			}
		}
	}
	return 0;
}


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

using namespace std;

int a,b,c,x;
int sol = 0;

int main(){
	cin >> a >> b >> c >> x;
	for(int i = 0; i <= a; i++){
		for(int j = 0; j <= b; j++){
			for(int k = 0; k <= c; k++){
				if(500*i + 100*j + 50*k == x) sol++;
			}
		}
	}
	cout << sol;	
}

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

int main() {
    string S;
    ll K;
    ios::sync_with_stdio(false);
    cin>>S>>K;
    REP(i,S.length()) {
        int t=S[i]-'0';
        if((t==1&&K<=i+1)||t!=1){
            cout<<t;
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=2505;
int n,m,p,ti[N],h[N],nh[N];
struct E{
	int l,to,w;
}e[5005],ne[5005];
bool iq[N],v[N];
queue<int>Q;
long long w[N];
void sa(){
	w[1]=0;
	Q.push(1);iq[1]=1;
	ti[1]++;
	while(!Q.empty()){
		int k=Q.front();Q.pop();
		iq[k]=0;
		for(int i=h[k];i;i=e[i].l){
			int to=e[i].to;
			if(!v[to])continue;
			if(w[to]>w[k]+e[i].w){
				w[to]=w[k]+e[i].w;
				if(!iq[to]){
					Q.push(to);iq[to]=1;
					ti[to]++;
					if(ti[to]>n){
						puts("-1");
						return;
					}
				}
			}
		}
	}
	if(w[n]==w[n+1])puts("-1");
	else printf("%lld\n",max(-w[n],0ll));
}
void se(int x){
	v[x]=1;
	for(int i=nh[x];i;i=ne[i].l){
		if(!v[ne[i].to])se(ne[i].to);
	}
}
int main(){
	int x;
	scanf("%d %d %d",&n,&m,&p);
	for(int i=1;i<=m;++i){
		scanf("%d %d %d",&x,&e[i].to,&e[i].w);
		e[i].l=h[x];h[x]=i;e[i].w-=p;e[i].w=-e[i].w;
		ne[i].to=x;ne[i].l=nh[e[i].to];nh[e[i].to]=i;
	}
	se(n);
	memset(w,127,sizeof(w));
	sa();
}

Measured memory_bytes: 384
#include <iostream> 
using namespace std;
#define ll long long 
const ll mod = 1e9 + 7;
ll substring_count[105][4][4][4];

void add( ll& a, ll& b ) {
  a = ( a + b ) % mod;
}

bool ng( int a, int b, int  c ) {
  if ( a == 1 && b == 2 && c == 3 ) {
    return true;
  } else {
    return false;
  }
}

int main() {
  int n; cin >> n;
  substring_count[0][0][0][0] = 1;

  for ( int i = 0; i < n; ++i ) {
    for ( int a = 0; a < 4; ++a ) {
      for ( int b = 0; b < 4; ++b ) {
        for ( int c = 0; c < 4; ++c ) {
          for ( int d = 0; d < 4; ++d ) {
            
            
            if ( ng(b,c,d) || ng(c,b,d) || ng(b,d,c) ) continue;
            if ( ng(a,c,d) || ng(a,b,d) ) continue;
          
            add( substring_count[i + 1][b][c][d], substring_count[i][a][b][c] );
          }
        }
      }  
    }  
  }
  ll ans = 0;
  for ( int a = 0; a < 4; ++a ) {
    for ( int b = 0; b < 4; ++b ) {
      for ( int c = 0; c < 4; ++c ) {
        add( ans, substring_count[n][a][b][c] );  
      }
    }  
  }
  cout << ans << endl;
}


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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;

#define mt make_tuple
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sqr(x) ((ll)(x) * (x))

int a[20];
int x[20][20];
int y[20][20];

int main()
{
    int n;
    cin >> n;
    for(int i = 1; i <= n; i++)
    {
        cin >> a[i];
        for(int j = 1; j <= a[i]; j++)
        {
            cin>>x[i][j]>>y[i][j];
        }
    }

    int odg=0;
    for(int i = 1; i < (1<<n); i++)
    {
        bool ok = true;
        for(int j = 1; j<=n; j++)
        {
            if(!(i & (1<<(j-1))))continue;
            for(int u = 1; u <= a[j]; u++)
            {
                if(((i>>(x[j][u]-1)) & 1) ^ y[j][u])
                {
                    ok = false;
                    break;
                }
            }

            if(ok==false)
            {
                break;
            }
        }

        if(ok)
        {
            odg=max(odg,__builtin_popcount(i));
        }
    }

    cout<<odg<<'\n';

    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;
#define dump(x) cerr<<#x<<"="<<x<<endl
using P = pair<int, int>;

int main() {
   int n; cin >> n;
   if(n%1000==0){
      cout << 0 << endl;
      return 0;   
   }
   
   n %= 1000;
   cout << 1000 - n << endl; 
   return 0;
}


Measured memory_bytes: 3624
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;


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

	long long n, ans;
	cin >> n;
	if (n == 1) ans = 0;
	else if (n % 2 == 0) ans = n / 2 - 1;
	else ans = n / 2;

	cout << ans << "\n";


	return 0;
}


Measured memory_bytes: 888
#include <math.h>
#include <iostream>
#include <algorithm>

using namespace std;

int main()
{
int H,W;
cin >> H >> W;
while(H!=0&&W!=0)
{
for(int i=0;i<H;i++){
for(int j=0;j<W;j++){
cout << "#";
}
cout << endl;
}
cout << endl;
cin >> H >> W;
}
}


Measured memory_bytes: 3104
#include<stdio.h>
int main()
{
    int i,flag=0;
    char str[100];
    gets(str);

    for(i=0;i<str[i]!='\0';i++){
        if(str[i]==str[i+1]){
            flag=1;
        }
    }

    if(flag){
        printf("Bad");
    }
    else{
        printf("Good");
    }



    return 0;
}


Measured memory_bytes: 128
#include<stdio.h>
int R=1,C=1,H[2000010],N[2000010];
int hyouka(int a,int b){
  if(C<b)return 1;
  if(C<a||b==0)return 0;
  return N[H[a]]<N[H[b]]?1:0;
}
void hin(int a){
  int i=C++;
  for(N[H[0]=R]=a;hyouka(0,i/2);i/=2)H[i]=H[i/2];
  H[i]=R++;
}
int hout(){
  int rt=H[1],i,j=2,k=H[--C];
  for(i=1;hyouka(i,C);i=j)H[i]=H[j=i*2+1-hyouka(i*2,i*2+1)];
  H[j/2]=k;
  return rt;
}
int ta[100010],nt[400010],to[400010],co[400010];
void mkls(int v,int e,int *a,int *b,int *c){
  int i;
  for(i=0;i<v;i++)ta[i+1]=-1;
  for(i=0;i<e;i++){
    nt[i  ]=ta[to[i+e]=a[i]];
    nt[i+e]=ta[to[i  ]=b[i]];
    co[ta[b[i]]=i+e]=co[ta[a[i]]=i]=c[i];
  }
}
int MAX(int a,int b){return a<b?b:a;}
int MIN(int a,int b){return a<b?a:b;}
int main(){
  int n,m,k,a[200010],b[200010],c[200010],d[100010],f[100010],e[100010]={};
  int q[100010],t,r,i,j;
  scanf("%d %d %d",&n,&m,&k);
  for(i=0;i<m;i++)scanf("%d %d",&a[i],&b[i]);
  for(i=0;i<m;i++)c[i]=1e9;
  for(i=0;i<k;i++){
    scanf("%d",&j);
    c[j-1]=i+1;
  }
  mkls(n,m,a,b,c);
  q[t=0]=1;
  for(i=0;i<n;i++)d[i+1]=1e9;
  d[1]=0;
  e[1]=1e9;
  for(r=1;r-t;t++){
    hin(e[q[t]]);
    for(i=ta[q[t]];i+1;i=nt[i]){
      if(d[to[i]]<d[q[t]]+1)continue;
      if(d[to[i]]>d[q[t]]+1)q[r++]=to[i];
      d[to[i]]=d[q[t]]+1;
      e[to[i]]=MAX(e[to[i]],MIN(e[q[t]],co[i]));
    }
  }
  for(i=0;i<n;i++)f[i]=N[hout()];
  for(i=j=0;i<k;i++){
    while(f[j]<=i+1)j++;
    printf("%d\n",j);
  }
  return 0;
}

Measured memory_bytes: 12840
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<map>
#include<set>
#include<tuple>
#include<cmath>
#include<iomanip>


#define MOD 1000000007
#define INF 1001001001
#define MIN -1001001001
#define rep(i,k,N) for(int i=k;i<N;i++)
#define MP make_pair
#define MT make_tuple //tie,make_tuple は別物
#define PB push_back
#define PF push_front
#define all(x) (x).begin(),(x).end()


using namespace std;
typedef long long ll;
typedef vector<ll> v;
typedef vector<vector<ll>> vv;

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

int main(){
    string S;
    cin>>S;
    ll N = S.size();
    map<char,ll> m;
    rep(i,0,N){
        m[S[i]]++;
    }
    if(N!=26)rep(i,0,26){
        if(m['a'+i] == 0){
            cout<<S + char('a'+i);
            return 0;
        }
    }

    vector<char> a;
    a.PB(S[25]);
    char prev = S[25], las = 'Z';
    ll fin = 26;
    for(int i = 24;i>=0;i--){
        if(prev < S[i]){
            a.PB(S[i]);
            prev = S[i];
        }
        else{
            a.PB(S[i]);
            las = S[i];
            fin = i;
            break;
        }
    }
    sort(all(a));
    string ans;
    bool ok = false;
    if(las == 'Z'){
        cout<<-1;
        return 0;
    }
    rep(i,0,fin){
        cout<<S[i];
    }
    for(int i=0; i<a.size();i++){
        if(las < a[i] && !ok){
            ok = true;
            las = a[i];
        }
        else{
            ans+=a[i];
        }
    }
    cout<<las;
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
//#include<boost/multiprecision/cpp_int.hpp>
//#include<boost/multiprecision/cpp_dec_float.hpp>
//namespace mp=boost::multiprecision;
//#define mulint mp::cpp_int
//#define mulfloat mp::cpp_dec_float_100
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
//constexpr int MOD=1000000007;
constexpr int MOD=998244353;
#define INF (1<<30)
#define LINF (lint)(1LL<<56)
#define endl "\n"
#define rep(i,n) for(lint (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(lint (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
#define plint pair<lint,lint>
#define fi first
#define se second
typedef long long lint;
int dx[8]={1,1,0,-1,-1,-1,0,1};
int dy[8]={0,1,1,1,0,-1,-1,-1};
const int MAX_N=2e5+5;

int main(void){
    lint N,K;
    cin >> N >> K;
    lint A[N];
    rep(i,N) cin >> A[i];
    rep(i,N) A[i]--;
    rep(i,N) A[i]%=K;
    lint sum[N+1]={};
    rep(i,N) sum[i+1]=(sum[i]+A[i])%K;
    lint ans=0;
    map<lint,lint> fact;
    rep(i,min(K,N+1)) fact[sum[i]]++;
    rep(i,N+1){
        ans+=fact[sum[i]]-1;
        fact[sum[i]]--;
        if(i+K<=N) fact[sum[i+K]]++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 19268
#include "bits/stdc++.h"
using namespace std;
#define Would
#define you
#define all(n)  n.begin(),n.end()
#define rall(n) n.rbegin(),n.rend()
typedef long long ll;
const ll INF = 1e18;
const ll MOD = 1e9 + 7;
const double EPS = 1e-10;
const double pi = acos(-1);//3.1415926535897932384626433832795028...
const ll SIZE = 1 << 17;
int dx[] = { 1,0,-1,0 }, dy[] = { 0,1,0,-1 }, alp[30];
ll fac[200005], finv[200005], inv[200005];
vector<ll>dij;
struct edge { ll to, cost; };
vector<vector<edge> >G;

ll mod_pow(ll a, ll b) {
	ll res = 1, mul = a;
	for (int i = 0; i < 31; ++i) {
		if (b >> i & 1) {
			res *= mul;
			res %= MOD;
		}
		mul = (mul * mul) % MOD;
	}
	return res;
}

void addedge(int from, int to, int cost) {
	G[from].push_back({ to,cost });
	G[to].push_back({ from,cost });
}

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 V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T & t, const V & v) { t = v; }

template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T & t, const V & v) {
	for (auto& e : t) fill_v(e, v);
}

template<typename T>
void outp(vector<T>v) {
	for (int i = 0; i < v.size(); ++i) {
		cout << v[i];
		if (i != v.size() - 1) { cout << " "; }
	}
}

double add(double a, double b) {
	if (abs(a + b) < EPS * (abs(a) + abs(b))) { return 0; }
	return a + b;
}


int main() {
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	ll mon = max({ a,b,c });

	for (int i = 0; i < d; ++i) { mon *= 2; }

	cout << mon + a + b + c - max({ a,b,c }) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
using namespace std;
signed main(){
  int N;
  string S;
  cin>>N>>S;
  string T=S;
  sort(T.begin(),T.end());
  int R=0,W=0;
  for(int i=0;i<S.size();i++){
    if(S[i]=='R' && T[i]=='W')R++;
    else if(S[i]=='W' && T[i]=='R')W++;
  }
  cout<<max(R,W)<<endl;
}

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

int main() {
  int N,M,A=0,B=0;
  cin>>N>>M;
  int a=N-1;
  int b=M-1;
   
  if(a>0||b>0){
  for(int i=1;i<=a;i++){
    A=A+i;
  }
  for(int j=1;j<=b;j++){
    B=B+j;
  }
  }
  else{
    A=0;
    B=0;
  }
  cout <<A+B<<endl; 
}


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

using namespace std;

int main(){
  string S;
  cin >> S;
  
  for(int i=0;i<S.size();i++){
    if(S.size()%2!=0){
      cout << "No" << endl;
      break;
    }
    if(i%2==0 && S.at(i)=='h'){
      continue;
    }else if(i%2==1 && S.at(i)=='i'){
      if(i==S.size()-1)
      cout << "Yes" << endl;
      continue;
    }else{
      cout << "No" << endl;
      break;
    }
    
  }
}


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

int main(void) {
  int N;
  cin >> N;

  int y_ans = 0;
  for (int i = 0; i < N; i++) {
    string a;
    cin >> a;
    if (a == "Y") {
      y_ans++;
    }
  }

  if (y_ans) {
    cout << "Four" << endl;
  } else {
    cout << "Three" << endl;
  }
  return 0;
}

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

#define debug(x) cout<<#x<<" :: "<<x<<endl;
#define debug2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<endl;
#define debug3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<endl;
#define boost ios::sync_with_stdio(0); cin.tie(0)
#define fi first
#define se second
#define  pb push_back
#define  pob pop_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define rep(i,a,b)  for(int i=a;i<b;i++)
#define sz(x) (int)x.size()
#define endl '\n'
#define mod 1000000007
#define MAX 100005

typedef long long ll;
//typedef int ll;
typedef double ld;
typedef pair<ll, ll> pll;
typedef vector<ll> vll;

/********************************************************/

signed main()
{
    boost;
    #ifndef ONLINE_JUDGE
    // freopen("in.txt","r",stdin);
    // freopen("out.txt","w",stdout);
    #endif // ONLINE_JUDGE
    
    ll n;
    cin >> n;
    vll v(n);
    rep(i,0,n)cin >> v[i];
    sort(all(v),greater<>());
    ll ans = 0;
    ans = -v[0];
    ll tot = 0;
    rep(i,0,n){
      if(tot + 2 > n){
        ans += v[i];
        break;
      }
      else {
        ans += 2*v[i];
        tot += 2;
      }
      if(tot == n)break;
    }
    cout << ans << endl;
    return 0;

}



Measured memory_bytes: 4784
N = int(input())
S = ["S"]
H = ["H"]
C = ["C"]
D = ["D"]
for i in range(N):
    s, n = input().split()
    if s == "S":
        S.append(int(n))
    elif s == "H":
        H.append(int(n))
    elif s == "C":
        C.append(int(n))
    else:
        D.append(int(n))

def finder(d):
    for j in range(1, 14):
        if j not in d:
            print(d[0], j)

finder(S)
finder(H)
finder(C)
finder(D)

Measured memory_bytes: 7792
#include <stdio.h>
                                                                                                
  
int main(void){
                                                                                                
   
    char s1[101];

    char s2[101];

    char s3[101];
   
      
    scanf("%s %s %s", s1, s2, s3 );
     

    printf("%c%c%c\n", s1[0], s2[0], s3[0] );


    return 0;
                                                          
}

Measured memory_bytes: 128
S = input()
s_str = ''

for s in S:
    
    if(s in ('A', 'C', 'G', 'T')):
        s_str += s
    
    else:
        s_str += ' '

if(s_str.split() == []):
    print(0)

else:
    print(len(max(s_str.split(), key = len)))

Measured memory_bytes: 3060