akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define rep(i, n) for(int (i)=0 ;i <(n); ++(i))
#define REP(i,m,n) for(int (i) = (m); (i) <= (n); ++(i))
#define yorn(f) puts((f)?"Yes":"No")
#define YORN(f) puts((f)? "YES":"NO")
typedef long long ll;
using namespace std;

int main() {
  double a, b;
  cin >> a >> b;
  cout << ceil((a+b)/2) << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <utility>
#include <stack>
#include <vector>
#include <queue>
#include <algorithm>
#include <map>
#include <climits>
#include <set>
#include <numeric>
#include <iomanip>
#include <cmath>
#include <cstring>
using namespace std;
long long a[200000];
long long ans[200000];
int main(){
  int N;
  cin >> N;
  long long all_xor = 0;
  for(int i = 0; i < N; i++){
    cin >> a[i];
    all_xor ^= a[i];
  }

  for(int i = 0; i < N; i++){
    ans[i] = all_xor ^ a[i];
  }

  for(int i = 0; i < N; i++){
    if(i == N - 1){
      cout << ans[i] << endl;
    } else {
      cout << ans[i] << " ";
    }
  }
  return 0;
}


Measured memory_bytes: 6752
#include <iostream>
#include <algorithm>
#include <string>
#define rep(i, a, n) for(int i = a;i < n;i++)
using namespace std;


int n;
int d[110];


int solve(){
	int h = 1;
	rep(i, 1, n) if(d[i-1] < d[i]) h++;
	return h;
}


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

	sort(&d[0], &d[n]);

	cout << solve() << endl;

	return 0;
}

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

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

    if (s.length() == 2) cout<<s;
    else {
        reverse(s.begin(), s.end());
        cout<<s;
    }

    return 0;
}

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

int a[200001];

int main()
{
	int n;
	cin>>n;
	int temp;
	for(int i=1;i<n;i++)
	{
		cin>>temp;
		a[temp]++;
	}
	
	for(int i=1;i<=n;i++)
		cout<<a[i]<<endl;
	return 0;
}

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

prime_dict = {}
# N!の各要素の素因数を合わせたものの指数部分＋１をかけ合わせていく
# その素因数を個数分選ぶか選ばないか選択するのに相当する
# 1は素数でないし、素因数を何も選ばなかった場合に相当するので放置
# 素因数分解はO(logN)でそれを個数分なので、時間計算量はO(NlogN)となり、N<=10^3なので十分間に合う
while N > 1:
  pn = 2
  tmp = N
  while pn * pn <= tmp:
    while tmp % pn == 0:
      tmp = tmp / pn
      prime_dict[pn] = prime_dict.get(pn, 0) + 1
    pn += 1
  if tmp > 1:
    prime_dict[tmp] = prime_dict.get(tmp, 0) + 1
  N -= 1

cnt = 1  
for key in prime_dict.keys():
  cnt *= prime_dict[key]+1
  
print(cnt % (10**9+7))

Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <string>
#include <algorithm>
#include <set>
using namespace std;
const int maxn = 1e5 + 10;
int s[maxn], vis[maxn], n;

int main(){
    scanf("%d", &n);
    long long total = 0;
    for(int i = 0; i < n; i++){scanf("%d", &s[i]);}
    for(int c = 1; c < n; c++){
        int k = 0;
        long long ans = 0;
        memset(vis, 0, sizeof(vis));
        while(k * c < n - 1){// a + k * c == n - 1
            int next = (n - 1) - (k * c);
            if(next <= 0 || (next - c <= 0)){break;}
            if(vis[next]){break;}
            vis[next] = 1;
            ans += s[next];
            if(vis[k * c]){break;}
            vis[k * c] = 1;
            ans += s[k * c];
            total = max(total, ans);
            k++;
        }
    }
    printf("%lld", total);
    return 0;
}


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

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

int main(){
	int n;
	cin >> n;
	rep(i,n){
		int x, y, b, p;
		cin >> x >> y >> b >> p;
		cout << min( x*b+y*p, (x*max(5,b)+y*max(2,p))*4/5 ) << endl;
	}
	return 0;
}

Measured memory_bytes: 1164
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main{
	public static void main(String[] args){
		try{
			BufferedReader br =
					new BufferedReader(new InputStreamReader(System.in));
			String str = br.readLine();
			int count = 0;//countが1以上であればno
			for(int i=0;i<str.length()-1;i++){//iはスタート位置
				for(int j=i+1;j<str.length();j++){
					if(str.charAt(i)==str.charAt(j)){
						count++;
					}
				}
			}
			if(count>=1){
				System.out.println("no");
			}else{
				System.out.println("yes");
			}
		}catch(Exception e){}
	}

}


Measured memory_bytes: 22996
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define mst(a, b) memset((a), (b), sizeof(a))
#define mp(a, b) make_pair(a, b)
#define pi acos(-1)
#define pii pair<int, int>
#define pb push_back
const int INF = 0x3f3f3f3f;
const double eps = 1e-10;
const int maxn = 1e5 + 7;
const int maxm = 5e5 + 10;
int s[maxn];
ll dp[maxn][2];
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    for (int i = 1; i <= n; ++i)
        cin >> s[i];
    dp[1][0] = dp[1][1] = 0;
    dp[0][0] = dp[0][1] = 0;
    dp[2][0] = dp[2][1] = abs(s[2] - s[1]);
    for (int i = 3; i <= n; ++i)
    {
        dp[i][0] = min(dp[i - 1][0], dp[i - 1][1]) + abs(s[i] - s[i - 1]);
        dp[i][1] = min(dp[i - 2][0], dp[i - 2][1]) + abs(s[i] - s[i - 2]);
    }
    ll ans = min(dp[n][0], dp[n][1]);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 2176
#define _USE_MATH_DEFINES
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <math.h>
#include <complex>
#include <cassert>
#define rep(i,a,b) for (int i = (a); i < (b); i++)
#define case(i) cout<<"Case #"<<i<<": "
using namespace std;
typedef long long int ll;
typedef complex<double> com;
const int mod = 1e9 + 7;
const int MOD = 998244353;
const ll INF = 4e18;



int main() {
	int a, b; cin >> a >> b;
	cout << 100 << " " << 100 << endl;
	vector<string> ans(100);
	rep(i, 0, 100)rep(j, 0, 100) {
		if (i < 50)ans[i] += '#';
		else ans[i] += '.';
	}
	rep(i, 0, a-1) {
		ans[i / 50*2 + 1][i % 50*2 + 1] = '.';
	}
	rep(i, 0, b-1) {
		ans[i / 50*2 + 51][i % 50*2 + 1] = '#';
	}
	rep(i, 0, 100) cout << ans[i] << endl;
	return 0;
}

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



int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  int cal=0;
  for(int i=0;i<n;++i){
    cin >> a[i];
    cal^=a[i];
  }
  vector<int> ans(n);
  for(int i=0;i<n;++i){
    int tmp=cal;
    tmp^=a[i];
    ans[i]=tmp;
  }
  for(int i=0;i<n;++i){
    if(i!=n-1) cout << ans[i] << " ";
    else cout << ans[i] << endl;
  }
  return 0;
}


Measured memory_bytes: 4840
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include <map>
#include <cmath>
#include <string>
using namespace std;

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


ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll c, ll d) { return c / gcd(c, d) * d; }

int main() {
  int n, t, a;
  cin >> n >> t >> a;

  vector<double> h(n); double mini = 1000; int index = n;
  rep(i, n) {
      cin >> h[i];
      double average = (double)t - h[i] * 0.006;
      if (min(mini, abs(average - a)) != mini) {
          mini = min(mini, abs(average - a));
          index = i+1;
      }
  }
  cout << index << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
  int h,w,x,y;

  while(1){
    scanf("%d %d",&h,&w);

    if(h+w == 0) break;

    for(y=0;y<h;++y){
      for(x=0;x<w;++x){
	printf("#");
      }
      printf("\n");
    }
    printf("\n");
  }
  return 0;
}



Measured memory_bytes: 2040
#include <stdio.h>

int main(void) {
	int N, M;
	int i, j;
	int h[100];
	int m[100];
	int k[100];
	int g[100];
	int witch;
	
	scanf("%d", &N);
	for (i = 0; i < N; i++) 
		scanf("%d %d", &h[i], &m[i]);
	scanf("%d", &M);
	for (i = 0; i < M; i++)
		scanf("%d %d", &k[i], &g[i]);
	
	i = j = 0;
	while (i < N || j < M) {
		if( i == N)
			witch = 1;
		else if ( j == M)
			witch = 0;
		else {
			if( h[i] == k[j]) {
				if( m[i] < g[j])
					witch = 0;
				else
					witch = 1;
			} else if( h[i] < k[j])
				witch = 0;
			else
				witch = 1;
			if( h[i] == k[j] && m[i] == g[j])
				witch = 2;
		}
		if( i != 0 || j != 0)
			printf(" ");
		switch(witch) {
			case 0:
				printf("%d:%02d", h[i], m[i]);
				i++;
				break;
			case 1:
				printf("%d:%02d", k[j], g[j]);
				j++;
				break;
			case 2:
				printf("%d:%02d", h[i], m[i]);
				i++;j++;
				break;
		}
	}
	printf("\n");
	
	return 0;
}

Measured memory_bytes: 616
#include<iostream>
#include<cstdint>
#include<string>

int const MAXNL = 100;
int const MAXK = 3;

int64_t dp1[MAXNL+1][MAXK+1] = {0};
int64_t dp2[MAXNL+1][MAXK+1] = {0};
std::string N;
int K;

int main() {
  std::cin >> N >> K;
  int l = N.size();
  dp1[0][0] = 1;
  for(int i = 0; i < l; ++i) {
    int d = N[i] - '0';
    // dp1[i][k] -> ...
    if(d > 0) {
      // dp1[i][k] -> d
      for(int k = 0; k+1 <= K; ++k) dp1[i+1][k+1] += dp1[i][k];
      // dp1[i][k] -> [1,d)
      for(int k = 0; k+1 <= K; ++k) dp2[i+1][k+1] += dp1[i][k]*(d-1);
      // dp1[i][k] -> 0
      for(int k = 0; k <= K; ++k) dp2[i+1][k] += dp1[i][k];
    } else {
      // dp1[i][k] -> 0
      for(int k = 0; k <= K; ++k) dp1[i+1][k] += dp1[i][k];
    }
    // dp2[i][k] -> ...
    //   dp2[i][k] -> ... [1,9]
    for(int k = 0; k+1 <= K; ++k) dp2[i+1][k+1] += dp2[i][k]*9;
    //   dp2[i][k] -> ... 0
    for(int k = 0; k <= K; ++k) dp2[i+1][k] += dp2[i][k];
  }
  std::cout << dp1[l][K] + dp2[l][K] << std::endl;
  return 0;
}


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

typedef pair<int, int> pii;
typedef long long ll;
template<class T> using V = vector<T>;
template<class T> using VV = V<V<T>>;

#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 dump(x) cerr << #x << " = " << (x) << endl
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

template<class T, class U> void chmin(T& t, const U& u) { if (t > u) t = u; }
template<class T, class U> void chmax(T& t, const U& u) { if (t < u) t = u; }

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, v.size()) {
		if (i) os<<",";
		os<<v[i];
	}
	os<<"}";
	return os;
}

int main() {
	int N; cin >> N;
	V<pair<string, int>> vec(N);
	rep(i, N) {
		string s; int t;
		cin >> s >> t;
		vec[i] = mp(s, t);
	}

	string X; cin >> X;

	rep(i, N) {
		if (vec[i].fi == X) {
			int ans = 0;
			for (int j = i + 1; j < N; ++j) {
				ans += vec[j].se;
			}
			cout << ans << endl;
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;


public class Main{
	
	static Scanner sc = new Scanner(System.in);
	static double x, y;
	static double a[] = new double[6];

	public static void main(String[] args) {
		
		while(read())
		{
			solve();
		}
	}
	
	static boolean read(){
		if(!sc.hasNext()) return false;
		
		for(int i = 0; i < 6; i++)
		{
			a[i] = sc.nextDouble();
		}
		
		return true;
	}
	
	static void solve(){
		
		double don = (a[0] * a[4] - a[3] * a[1]);
		
		x = (a[2] * a[4] - a[1] * a[5]) / don;
		y = (a[0] * a[5] - a[3] * a[2]) / don;
			
		if(-0.0005< x && x <= 0)x = 0;
        if(-0.0005< y && y <= 0)y = 0; 
		
		System.out.printf("%.3f %.3f\n", x, y);
	}

}

Measured memory_bytes: 12000
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;

const long double PI = acos(-1);
constexpr long double EPS = 1e-15;
constexpr int inf = 2e9;
constexpr ll INF = 2e18;
constexpr ll MOD = 1e9+7;
constexpr ll MOD1 = 998244353;
typedef pair<ll,ll> P;

//#define all(v) (v).begin(), (v).end()
#define rep(i,a,b) for (int i = (a); i < (b); i++)
#define REP(i,n) rep(i,0,n)
#define sz(s) (s).size()
#define pb push_back
#define fi first
#define se second
//#define mp make_pair

int main(){
    string s;
    while (getline(cin,s)) {
        double w = 0;
        int i = 0;
        while (i < sz(s) && s[i] != ' ') {
            w *= 10;
            w += s[i] - '0';
            i++;
        }
        i++;
        vector<double> v;
        while (i < sz(s)) {
            int k = 0;
            while (i < sz(s) && s[i] != ' ') {
                k *= 10;
                k += s[i] - '0';
                i++;
            }
            i++;
            v.pb(k);
        }
        sort(v.begin(),v.end());
        deque<double> dq;
        for (int i = 0; i < sz(v); i++) {
            dq.pb(v[i]);
        }
        deque<double> dq1;
        dq1.pb(dq.back());
        dq.pop_back();
        while (!dq.empty()) {
            bool f2f = 0;
            bool f2b = 0;
            bool b2f = 0;
            bool b2b = 0;
            double front = dq.front();
            double back = dq.back();
            double k = abs(front - dq1.front());
            f2f = 1;
            double kk = abs(front - dq1.back());
            if (kk > k) {
                k = kk;
                f2f = 0;
                f2b = 1;
            }
            kk = abs(back - dq1.front());
            if (kk > k) {
                k = kk;
                f2f = 0;
                f2b = 0;
                b2f = 1;
            }
            kk = abs(back - dq1.back());
            if (kk > k) {
                k = kk;
                f2f = 0;
                f2b = 0;
                b2f = 0;
                b2b = 1;
            }
            if (f2f) {
                dq1.push_front(dq.front());
                dq.pop_front();
            } else if (f2b) {
                dq1.push_back(dq.front());
                dq.pop_front();
            } else if (b2f) {
                dq1.push_front(dq.back());
                dq.pop_back();
            } else if (b2b) {
                dq1.push_back(dq.back());
                dq.pop_back();
            }
        }
        double ans = dq1.front() + dq1.back();
        double before = dq1.front();
        dq1.pop_front();
        while (!dq1.empty()) {
            int tp = dq1.front();
//            cout << before << " ";
            dq1.pop_front();
            ans += 2 * sqrt(before * tp);
            before = tp;
        }
//        cout << before << endl;
        cout << (ans <= w? "OK":"NA") << endl;
    }
}


Measured memory_bytes: 3204
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	ios_base::sync_with_stdio(0); 
    cin.tie(0);   
	ll n;
	long double m,temp;
	string s;
	cin>>n>>m;
	temp=n*m;
	cout<<ll(floor(temp));
	return 0;
}

Measured memory_bytes: 3784
#include<iostream>
#include<math.h>
#include <algorithm>
#include<float.h>
#include <limits>
#include <vector> 
#include <numeric>
#include <string.h>

#define rep(i,a,n) for(ll int (i) = (a);(i) < (n);(i)++)
#define urep(i,a,n) for(ll int (i) = (a);(i) > (n);(i)--)
#define MOD 1000000007
#define ll long long

using namespace::std;

int jo(ll int jxo, ll int jyo){
	ll int jhogeo = 1;
	rep(jinto,0,jyo) jhogeo=jhogeo*jxo;
	return jhogeo;
}
char tobig(char toxbig){
  return (toxbig-0x20);
}
char tolow(char toxlow){
  return (toxlow+0x20);
}
  


int main(){
  int a,b;
  cin>>a>>b;
  cout<<(a-1)*(b-1);
}
// int *p = new int[N];

//  vector<int> 変数名(要素数);
//  sort(変数名.begin(),変数名.end());//昇順ソート

// vector<vector<int>> 変数名(左の個数, vector<int>(右の個数));

//


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

using namespace std;

#define LOG(...) fprintf(stderr, __VA_ARGS__)
//#define LOG(...)
#define FOR(i, a, b) for(int i = (int)(a); i < (int)(b); ++i)
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define RREP(i, n) for(int i = (int)(n - 1); i >= 0; --i)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EXIST(s, e) ((s).find(e) != (s).end())
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort(RALL(c))
#define SQ(n) (n) * (n)

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<pii> vpi;
typedef vector<pll> vpl;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vc> vvc;
typedef vector<vll> vvll;

bool allKnow(vi &know, vi &leak){
  for(auto id : leak) {
    if (find(ALL(know), id) == know.end()) return false;
  }
  return true;
}

int main() {
  int n;
  while(cin >> n, n) {
    vvi know(n);
    REP(i, n){
      int m;
      cin >> m;
      know[i].resize(m);
      REP(j, m){
        cin >> know[i][j];
      }
    }
    int k;
    cin >> k;
    vi leak(k);
    REP(i, k) cin >> leak[i];

    int res = -1;
    REP(i, n){
      if (allKnow(know[i], leak)) {
        if (res != -1) {
          res = -1;
          break;
        }
        res = i + 1;
      }
    }
    cout << res << endl;
  }
}

Measured memory_bytes: 3132
#include <iostream>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <queue>
#include <map>
 
using namespace std;
typedef long long int ll;
typedef pair <int,int> pii;
typedef pair<ll,ll> pll;
 
 
/*bool compare_function(const pair<int, int> a, const pair<int, int> b)
{
    return a.first < b.first;
}*/
// use case
//sort(V.begin(), V.end(), compare_function);
 
/*struct compare
{
    bool operator ()(const pair<int, int> &a, const pair<int, int> &b) {
    if (a.second-a.first==b.second-b.first)
    {
        return a.first>b.first;
    }
    return a.second-a.first < b.second-b.first;}
};
priority_queue <pair<int,int>, vector <pair<int,int>>, compare> Q;*/
 
/*void print1(vector <int> X)
{
    for (int i=0; i<X.size(); i++)
    {
        cout<<X[i]<<" ";
    }
    cout<<endl;
    return;
}
 
void print2(vector <vector <int>> X)
{
    for (int i=0; i<X.size(); i++)
    {
    for (int j=0;j<X[i].size();j++) {
        cout<<X[i][j]<<" ";}
    cout<<endl;}
    return;
}*/

 
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int T;
    cin>>T;
    int x=0;
	int y=0;
	int z=0;
	int v=0;
    for (int t=0; t<T; t++)
    {
	string s;
	cin>>s;
	if (s=="AC") {x++;}
	if (s=="WA") {y++;}
	if (s=="TLE") {z++;}
	if (s=="RE") {v++;}
    }
    cout<<"AC x "<<x<<endl;
    cout<<"WA x "<<y<<endl;
    cout<<"TLE x "<<z<<endl;
    cout<<"RE x "<<v<<endl;
    return 0;
}


Measured memory_bytes: 3656
N,M=map(int,input().split())
A=[0]*M;p=-1

for i in range(M):
    a,b=map(int,input().split())
    A[i]=[a,b]
A.sort(reverse=True, key=lambda x: x[1])
#print(A)
#print("Yes" if A[0][1]==N else "No")

if A[0][1]!=N:
    print("IMPOSSIBLE")
else:
    d = [False] * (N + 5)
    for i in range(M):
        if A[i][1] == N:
            d[A[i][0]] = True
        if A[i][0] == 1 and d[A[i][1]]:
            p = 2
            #print(1,A[i][0],A[i][1],A[0][0],p)
    if p == 2:
        print("POSSIBLE")
    else:
        print("IMPOSSIBLE")


Measured memory_bytes: 39604
N = int(input())
X = list(map(int,input().split()))
A = [0]*100
for i in range(N):
  A[X[i]-1] += 1

ans = 10**9
for i in range(100):
  r = 0
  for j in range(100):
    r += ((i-j)**2)*A[j]
  ans = min(r,ans)
print(ans)

Measured memory_bytes: 3064
#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 c = 0;
  string s, cs = "CODEFESTIVAL2016";
  cin >> s;
  REP(i, cs.length()) if (s[i] != cs[i]) c++;
  cout << c << endl;
  return 0;
}

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

#define rep(i, N) for (ll i = 0; i < N; i++)
#define rep1(i, N) for (ll i = 1; i <= N; i++)
#define repr(i, N) for (ll i = N-1; i >= 0; i--)
#define repr1(i, N) for (ll i = N; i > 0; i--)

#define MOD 1000000007

using ll = long long;
using namespace std;

typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<P> vpi;


int main() {
    ll n,ans = 0,num = 0;
    cin >> n;
    vi a(n);
    rep(i,n) cin >> a[i];

    if(n%2 == 0) {
        repr(i,n/2) cout << a[i*2+1] << " ";
        rep(i,n/2) cout << a[i*2] << " ";
    } else {
        repr(i,n/2+1) cout << a[i*2] << " ";
        rep(i,n/2) cout << a[i*2+1] << " ";
    }
    
    //printf("%.15lf", ans);
    cout << "\n";
    return 0;
}


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

int main(void)
{
   double yama;
   double ymax=0.0,ymin=1000005.0;
   double ans;
   while(scanf("%lf",&yama)!=EOF){
       ymax=max(ymax,yama);
       ymin=min(ymin,yama);
   }
   ans=ymax-ymin;
   printf("%.1f\n",ans);
   return 0;
}


Measured memory_bytes: 3160
//AOJ0577

#include <iostream>

int main(){
	int N;
	std::cin >> N;
	int score[201][3];
	for (int i = 0; i < N; ++i){
		std::cin >> score[i][0] >> score[i][1] >> score[i][2];
	}
	int ans[201];
	for (int i = 0; i < N; ++i)ans[i] = 0;
	for (int i = 0; i < N; ++i){
		for (int j = 0; j < 3; ++j){
			bool f = true;
			for (int k = 0; k < N; ++k){
				if (k == i)continue;
				if (score[i][j] == score[k][j]){
					f = false;
					break;
				}
			}

			if (f)ans[i] += score[i][j];
		}
	}
	for (int i = 0; i < N; ++i){
		std::cout << ans[i] << std::endl;
	}
	//system("pause");
}

Measured memory_bytes: 1164
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);
		String Nb1 = scan.next();
		int Nb2 = Integer.valueOf(Nb1);
		String Nb3 = scan.next();
		int Nb4 = Integer.valueOf(Nb3);

		int ans1 = Nb2 + Nb4;
		int ans2 = Nb2 * Nb4;
		String result = "x";

		if (ans1 == 15) {
			result = "+";
		} else if (ans2 == 15) {
			result = "*";
		} else {

		}

		System.out.println(result);

	}
}

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

using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define MIN(a,b) ((a)>(b)? (b): (a))
#define MAX(a,b) ((a)<(b)? (b): (a))

const long long INF = 1LL << 60;
typedef long long ll;
const long long MOD = 1000000000 + 7;

int main(){
    int n;
    cin >> n;
    vector<bool> seen(n, false);
    vector<ll> comfo(n, INF);
    vector<ll> a(n, 0);
    priority_queue<ll> que;
    rep(i, n) cin >> a[i];
    sort(a.begin(), a.end(), greater<ll>());
    seen[0] = true;
    comfo[0] = a[0];
    que.push(a[0]);
    int place;
    ll cnt = 0;
    for (int i = 1; i < n; i++)
    {
        cnt += que.top();
        //cout << cnt << endl;
        que.pop();
        que.push(a[i]);
        que.push(a[i]);
    }
    cout << cnt << endl;

    return 0;
}

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

int main(){
  int n;
  cin >> n;
  vector <int> l(n);
  for (int i = 0; i < n; i++){
    cin >> l.at(i);
  }
  int max = *max_element(l.begin(), l.end());
  int sum = accumulate(l.begin(), l.end(), 0) - max;
  if (max < sum){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}



Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    int a, op, b, i;
    for(i=0; i<20000; i++){
    scanf("%d %c %d",&a, &op, &b);
    if (op == '+'){
        printf("%d\n", a+b);
    }
    if(op == '-'){
        printf("%d\n", a-b);
    }
    else if(op == '*'){
        printf("%d\n", a*b);
    }
    else if(op == '/'){
        printf("%d\n", a/b);
    }
    else if(op == '?'){
        break;
    }
    }
    return 0;
}



Measured memory_bytes: 2104
class Card:
    def __init__(self, mark, value):
        self.mark = mark
        self.value = value

    def __eq__(self, other):
        if not isinstance(other, Card):
            return NotImplemented
        return self.value == other.value and self.mark == other.mark

    def __lt__(self, other):
        return self.value < other.value

    def __str__(self):
        return self.mark + str(self.value)


def BubbleSort(arr):
    res = [Card(c.mark, c.value) for c in arr]
    swap_flg = True
    i = 0
    while swap_flg:
        swap_flg = False
        for j in range(len(res) - 1, i, -1):
            if (res[j] < res[j - 1]):
                res[j], res[j - 1] = res[j - 1], res[j]
                swap_flg = True
        i += 1
    return res


def SelectionSort(arr):
    res = [Card(c.mark, c.value) for c in arr]
    for i in range(0, len(res)):
        minj = i
        for j in range(i, N):
            if res[j] < res[minj]:
                minj = j
        if (i != minj):
            res[i], res[minj] = res[minj], res[i]
    return res


def isStable(in_arr, out_arr):
    stable_arr = BubbleSort(in_arr)
    return all(out_arr[i] == stable_arr[i] for i in range(0, len(out_arr)))


N = int(input())
arr = [Card(s[0], int(s[1])) for s in input().split()]
b_arr = BubbleSort(arr)
print(' '.join(map(str, b_arr)))
print('Stable' if isStable(arr, b_arr) else 'Not stable')
s_arr = SelectionSort(arr)
print(' '.join(map(str, s_arr)))
print('Stable' if isStable(arr, s_arr) else 'Not stable')



Measured memory_bytes: 5616
let n = stdin.ReadLine() |> int

let a =
  stdin.ReadLine().Split(' ') |> Array.map int

let ans =
  let extremumCadidate =
    a
    |> Array.sum
    |> (fun sum -> (float sum) / (float n))
    |> floor
    |> int

  [extremumCadidate; extremumCadidate + 1]
  |> List.map (
    fun cad ->
      a
      |> Array.sumBy (fun x -> (x - cad) * (x - cad)))
  |> List.min

ans |> stdout.WriteLine

Measured memory_bytes: 13396
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef double db;
typedef std::string str;
#define sei set<int>
#define sell set<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pld pair<ld,ld>
#define vi vector<int>
#define vll vector<ll>
#define vvi vector<vi>
#define vvll vector<vll>
#define vld vector<ld>
#define vstr vector<str>
#define vpii vector<pii>
#define vpll vector<pll>
#define all(v) v.begin(),v.end()
#define foa(i,v) for(auto i : v)
#define fo(i,a,b) for(int i=a;i<b;i++)
#define fo_(i,a,b) for(int i=a;i>b;i--)
#define M(a) memset(a,0,sizeof a)
#define M_(a) memset(a ,-1,sizeof a)
#define deb(x)  cerr << #x << " = " << x << endl
#define pb push_back
#define pob pop_back
#define lb lower_bound
#define ub upper_bound
#define F first
#define S second
#define OK order_of_key
#define FO find_by_order
#define nmax 1000100
const ld PI = 3.141592653589793238462643383279;
const ll inf = std::numeric_limits<ll>::max();
const int infint = std::numeric_limits<int>::max();
const ll mod = 1e9+7;
using namespace __gnu_pbds;
using namespace std;
/*#pragma GCC optimization ("unroll-loops")
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,avx,avx2")*/
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

vll divs(ll n){
    vll out;
    fo(i,1,sqrt(n)+1){
        if(n%i == 0 && n/i != i){
            out.pb(i);
            out.pb(n/i);
        }else if(n%i == 0 && n/i == i) out.pb(i);
    }
    sort(out.begin(),out.end());
    return out;
}

int main(){
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    ll n;
    cin >> n;
    ll ans = n-1;
    foa(i,divs(n)){
        ans = min(ans,i-1+n/i-1);
    }
    cout << ans;

    return 0;
}



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

template<class T> void vin(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
    }
}

ll dist[100000];
int R[100000], C[100000];
int main() {
    int h, w, d;
    cin >> h >> w >> d;
    rep(r, h) rep(c, w) {
        int a;
        cin >> a;
        R[a] = r;
        C[a] = c;
    }
    for (int i = d+1; i<=h*w; ++i) {
        dist[i] = dist[i-d]+abs(R[i]-R[i-d])+abs(C[i]-C[i-d]);
    }
    int q;
    cin >> q;
    rep(i, q) {
        int l, r;
        cin >> l >> r;
        cout << dist[r]-dist[l] << endl;
    }
    return 0;
}


Measured memory_bytes: 2560
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
printV = lambda x: print(*x, sep="\n")
printH = lambda x: print(" ".join(map(str,x)))
def IS(): return sys.stdin.readline()[:-1]
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LII(rows_number): return [II() for _ in range(rows_number)]
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]

def main():
	S = IS()
	N = len(S)
	rS = ''.join(list(reversed(S)))
	if(S==rS and S[:(N-1)//2]==rS[(N+3)//2-1:] and S[(N+3)//2-1:]==rS[:(N-1)//2]):
		print("Yes")
	else:
		print("No")

if __name__ == '__main__':
	main()

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

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

const ll p = 998244353;

string s;
int kk, n;

int dp[305][305][305];

int comp(int i, int j, int k) {
	if (k < 0)
		return -1000;
	if (i > j)
		return 0;

	if (dp[i][j][k] != -1)
		return dp[i][j][k];

	if (i == j) {
		dp[i][j][k] = 1;
		return dp[i][j][k];
	}

	if (s[i] == s[j]) {
		dp[i][j][k] = 2 + comp(i+1, j-1, k);
		return dp[i][j][k];
	}

	dp[i][j][k] = comp(i+1, j, k);
	dp[i][j][k] = max(dp[i][j][k], comp(i, j-1, k));
	dp[i][j][k] = max(dp[i][j][k], 2 + comp(i+1, j-1, k-1));

	// cout << i << ' ' << j << ' ' << k << ' ' << dp[i][j][k] << endl;
	return dp[i][j][k];
}

int main() {
	cin >> s >> kk;
	n = s.length();

	for (int i = 0; i < 305; ++i)
		for (int j = i; j < 305; ++j)
			for (int a = 0; a <= kk; ++a)
				dp[i][j][a] = -1;

	cout << comp(0, n-1, kk) << endl;
}

Measured memory_bytes: 110848
#include<iostream>
#include<cstring>
#include<cassert>
#include<cmath>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<cstdio>
#include<vector>
#include<time.h>
#include<algorithm>
using namespace std;
#define REP(i,x,y) for(ll i=x;i<=y;i++)
#define rep(i,n) REP(i,1,n)
#define rep0(i,n) REP(i,0,n-1)
#define repG(i,x) for(ll i=pos[x];~i;i=e[i].next)
#define ll long long
#define db double
const ll N=107;
const ll INF=1e18+7;
const ll mod=1e9+7;
ll Q,cnt,x,y,mx,Ans;
ll f[N];
bool check(ll a,ll b,ll st){
	ll X=f[st+1]*a+f[st]*b,Y=f[st]*a+f[st-1]*b;
	return (X>x)|(Y>y);
}
void dfs(ll a,ll b,ll st){
	if(check(a,b,mx-st))return;
	if(st==mx-1){
		if(x>=a)Ans=((y-b)/a%mod+Ans)%mod;
		if(y>=a)Ans=((x-b)/a%mod+Ans)%mod;
		return;
	}
	dfs(b+a,a,st+1);
	if(st==mx-2)dfs(b+a+a,a,st+1);
	else{
		ll p1=b+a+a,p2=a,p=mx-1-(st+1);
		dfs(f[p+1]*p1+f[p]*p2,f[p]*p1+f[p-1]*p2,mx-1);
	}
}
int main(){
	f[0]=0;
	f[1]=1;
	for(ll i=2;;i++){
		f[i]=f[i-1]+f[i-2];
		if(f[i]>INF){
			cnt=i;
			break;
		}
	}
	scanf("%lld",&Q);
	rep(gg,Q){
		scanf("%lld%lld",&x,&y);
		if(x==1&&y==1){
			puts("1 1");
			continue;
		}
		if(x<y)swap(x,y);
		mx=0;
		rep(i,cnt){
			if(f[i+1]>x||f[i]>y){
				mx=i-2;
				break;
			}
		}
		if(mx==1){
			printf("%lld %lld\n",mx,(x%mod)*(y%mod)%mod);
			continue;
		}
		Ans=0;
		dfs(1,1,0);
		printf("%lld %lld\n",mx,Ans);
	}
	return 0;
}


Measured memory_bytes: 3968
import sys
input = lambda: sys.stdin.readline().rstrip()

def main():
    a = int(input())
    exist = [0] * (10**6 + 1)
    exist[a] = 1
    ans = 1
    while(True):
        ans += 1
        if a%2 == 0: 
            a //= 2
        else: 
            a = 3*a + 1
        if exist[a] == 1: 
            print(ans)
            return
        else: 
            exist[a] = 1
        
if __name__ == '__main__':
    main()

Measured memory_bytes: 16816
import java.math.BigInteger;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		for(int i = 0; i < n; i++) {
			BigInteger n1 = sc.nextBigInteger();
			BigInteger n2 = sc.nextBigInteger();
			BigInteger m = n1.add(n2);
			if(m.toString().length() <= 80) {
				System.out.println(m.toString());
			}else {
				System.out.println("overflow");
			}
		}
		sc.close();
	}
}


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

#define REP(i,n) for(int (i)=0; (i)<(n); (i)++)
#define For(i,a,b) for(int (i)=(a); (i)<(b); (i)++)

void conv(string &M) {
    int n = 1;
    string s = "";
    REP(i, M.size()-1) {
        if (M[i] == M[i+1]) {
            n++;
        }
        else {
            s += to_string(n);
            s += M[i];
            n = 1;
        }
    }
    s += to_string(n);
    s += M[M.size()-1];
    M = s;
}

void solve6 (int N, string M) {
    REP(i, N) {
        conv(M);
    }
    cout << M << endl;
}

int main() {
    int N;
    string M;
    while(cin >> N >> M, N) {
        solve6(N, M);
    }
    return 0;
}

Measured memory_bytes: 3252
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
#define REP(i, a, n) for(int i=a; i<n; i++)

int n, a;
int main()
{
	cin >> n >> a;
	n %= 500;
	if (n <= a) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

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

static const int MAX = 200000;


int main() {
  int a,b;
  cin >> a >> b;
  if (0 <= a && a <= 9 && 0 <= b && b <= 9) {
    cout << a * b << endl;
  } else {
    cout << -1 << endl;
  }
}


Measured memory_bytes: 3628
#include <iostream>
#include <vector>
#include <algorithm>
#include <limits>

using namespace std;

long long solve(int N, int K, const vector<long long> &x)
{
	long long ans = numeric_limits<long long>::max();

	for (int i = 0; i + K <= N; ++i) {
		auto p = lower_bound(x.begin() + i, x.begin() + i + K, 0);
		if (p == x.begin() + i + K) {
			ans = min(ans, -x[i]);
		}
		else {
			if (x[i] >= 0) {
				ans = min(ans, x[i + K - 1]);
			}
			else {
				ans = min(ans, -2 * x[i] + x[i + K - 1]);
				ans = min(ans, -x[i] + 2 * x[i + K - 1]);
			}
		}
	}
	return ans;
}

int main()
{
	int N, K;
	cin >> N >> K;
	vector<long long> x(N);
	for (auto &x_i : x) {
		cin >> x_i;
	}
	cout << solve(N, K, x) << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>

#define INF 1000000021
#define MOD 1000000007
#define pb push_back
#define sqr(a) (a)*(a)
#define M(a, b) make_pair(a,b)
#define T(a, b, c) make_pair(a, make_pair(b, c))
#define F first
#define S second
#define all(x) (x.begin(), x.end())
#define deb(x) cerr << #x << " = " << x << '\n'
#define N 222222

using namespace std;
//using namespace __gnu_pbds;

typedef long double ld;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;

const ld pi = 2 * acos(0.0);
template<class T> bool umin(T& a, T b){if(a>b){a=b;return 1;}return 0;}
template<class T> bool umax(T& a, T b){if(a<b){a=b;return 1;}return 0;}
template<class T, class TT> bool pal(T a, TT n){int k=0;for(int i=0;i<=n/2;i++){if(a[i]!=a[n-i-1]){k=1;break;}}return k?0:1;}

//int month[] = {0,31,28,31,30,31,30,31,31,30,31,30,31};

int main()
{
	ll x, y, a, b, c;
	cin >> x >> y >> a >> b >> c;
	priority_queue<ll> p1, p2, p3, p;
	for(int i = 1; i <= a; i ++)
	{
		ll e;
		cin >> e;
		p1.push(e);
	}
	for(int i = 1; i <= b; i ++)
	{
		ll e;
		cin >> e;
		p2.push(e);
	}
	for(int i = 1; i <= c; i ++)
	{
		ll e;
		cin >> e;
		p3.push(e);
	}
	vll foo, hoo;
	for(int i = 1; i <= x; i ++)
	{
		foo.pb(p1.top());
		p1.pop();
	}
	for(int i = 1; i <= y; i ++)
	{
		hoo.pb(p2.top());
		p2.pop();
	}
	ll ans = 0;
	for(auto it : foo)
	{
		p.push(-it);
	}
	for(auto it : hoo)
	{
		p.push(-it);
	}
	while(p.size() > 0)
	{
		ll t = -p.top();
		p.pop();
		ll r = -1;
		while(p3.size())
		{
			ll w = p3.top();
			p3.pop();
			if(w > t)
			{
				r = w;
				break;
			}
		}
		if(r != -1)
			ans += r;
		else
			ans += t;
	}
	cout << ans;

	





	getchar();
	getchar();
	return 0;
	//ios::sync_with_stdio(false);
	//cin.tie(0);
}

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

int main() {
  int N; /*ロボの数*/
  int K; /*Bロボの位置*/
  cin >> N >> K;
  int x; /*ボールの位置*/
  int sum = 0;
  int temp = 0;
  

   while(cin >> x){
     if(x > K / 2){
       temp = (K - x) *2;
     }
     else{
       temp = x * 2;
     }
     sum = sum + temp;
   }
  cout << sum;
}


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


#define M_MAX 20
#define N_MAX 50000
#define INFTY 1 << 29
int main(){

int n;
cin >> n ;
int v[n];

double maxi=0;


for(int i=0;i<n;i++)cin >> v[i];
sort(v,v+n);


double temp=v[0];
	
        for(int i=1; i<n; i++){
        temp=(temp+v[i])/2;   
        }

cout << temp;



}


Measured memory_bytes: 256
from collections import deque

N, M = map(int, input().split())
ARR = []

for i in range(M):
    ARR.append(list(map(int, input().split())))


def prepare(n, m, arr):
    nodes = [[] for i in range(n)]
    nodeStatus = [False for i in range(n)]
    for i in range(m):
        startNode = arr[i][0] - 1
        endNode = arr[i][1] - 1

        nodes[startNode].append(endNode)
        nodes[endNode].append(startNode)

    return nodes, nodeStatus


def calculate(n, nodes, nodeStatus):
    nodeMarks = [-1 for i in range(n)]

    q = deque()

    q.append((0, -1))

    while len(q) > 0:
        currentNode, parentNode = q.popleft()

        if nodeStatus[currentNode] == True:
            continue

        nodeStatus[currentNode] = True
        nodeMarks[currentNode] = parentNode
        childNodes = nodes[currentNode]

        for childNode in childNodes:
            q.append((childNode, currentNode))

    minusNumber = nodeMarks.count(-1)
    if minusNumber > 1:
        print("No")
        return

    print("Yes")
    for i in range(1, n):
        print(nodeMarks[i] + 1)


nodes, nodeStatus = prepare(N, M, ARR)

calculate(N, nodes, nodeStatus)


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

A=list(map(int,input().split()))

s=1000//A[0]
m=1000-s*A[0]
am=1000
for i in range(N-1):
  if A[i]<A[i+1]:
    am=m+A[i+1]*s
  else:
    s=am//A[i+1]
    m=am-A[i+1]*s
M=max([s*A[N-1]+m,am])
print(M)

Measured memory_bytes: 9128
#-*- coding: utf-8 -*-
"""
oj dl https://atcoder.jp/contests/abc116/tasks/abc116_d -d test-d
oj test -d test-d -c "python abc116d.py"
oj test -d test-d -c "python abc116d.py" test-d/sample-3.in
"""
from collections import defaultdict
import sys
import math
from datetime import datetime
import re
import math
#sys.setrecursionlimit(314159265)

def gcd(a,b):
    while b!=0:
        a,b=b,a%b
    return a


def lcm(a,b):
    return a*b//gcd(a,b)

def lcm_list(nums):
    if len(nums) == 0:
        return None
    if len(nums) == 1:
        return nums[0]
    if len(nums) == 2:
        lcm(nums[0], nums[1])
    else: # > 2
        a = lcm(nums[0], nums[1])
        for i in range(2, len(nums)):
            A = lcm(a, nums[i])
            a = A
        return a




def sol(S):
    mod = 10**9 + 7
    x = lcm_list(S)
    #print(x)
    T = [ x//s for s in S]
    return sum(T) % mod







do_submit = True
#do_submit = False

def input_parse(input_str):
    lines = [x.strip() for x in input_str.split("\n") if x.strip()]
    parsed_lines = [list(map(str, line.split())) for line in lines]
    print(parsed_lines)
    # n = int(parsed_lines[0][0])
    # k = int(parsed_lines[0][1])
    S = parsed_lines[0][0]
    return S


if not do_submit:
    S = input_parse("""
    1905
    """)
    print(sol(S))

    S = input_parse("""
    0112
    """)
    print(sol(S))

    S = input_parse("""
    1700
    """)
    print(sol(S))

    S = input_parse("""
    0000
    """)
    print(sol(S))

    S = input_parse("""
    1001
    """)
    print(sol(S))



else:
    n = int(input())
    S = list(map(int, input().split()))
    #S = input()
    print(sol(S))

    # S = input().strip()
    # print(sol(S))
    # print(lcm(2, 3))
    # print(lcm_list([2, 3, 4]))
    # print(lcm_list([27, 9, 3]))






Measured memory_bytes: 263280
#include <iostream>
#include <fstream>
#include <cassert>
#include <typeinfo>
#include <vector>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#include <random>
#include <complex>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<long double,long double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<62;
const double pi=acos(-1);
const long double eps=1e-7;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

int a,b;

int main(){
	cin>>a>>b;
	bool B=1;
	for(int i=0;i<=a+b;i++){
		char c;
		cin>>c;
		if(i==a&&'0'<=c&&c<='9'||i!=a&&c=='-') B=0;
	}
	cout<<(B?"Yes":"No")<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
typedef long long ll;
int main() {
    ll N;
    cin >> N;
    vector<ll> C;
    for (int i = 0; i < N; i++) {
        int c;
        cin >> c;
        if (i == 0) {
            C.emplace_back(c);
        } else if (C.back() != c) {
            C.emplace_back(c);
        }
    }
    vector<ll> dp(200010, 0LL);
    dp[0] = 1LL;
    vector<ll> num(200010, 0);
    for (int i = 0; i < C.size(); i++) {
        dp[i] += num[C[i]];
        dp[i] %= mod;
        if (i == 0) {
            num[C[i]] = 1LL;
        } else {
            num[C[i]] += dp[i - 1];
        }
        if (i > 0) dp[i] += dp[i - 1];
        dp[i] %= mod;
    }
    cout << dp[C.size() - 1] << endl;
}

Measured memory_bytes: 5104
d = int(input())
C = list(map(int, input().split()))
S = []
for _ in range(d):
    S.append(list(map(int, input().split())))
v = 0
LDs = [0 for _ in range(26)]
for i in range(d):
    t = int(input()) - 1
    R = [(i + 1 - LDs[j]) * C[j] for j in range(26)]
    del R[t]
    v += S[i][t] - sum(R)
    LDs[t] = i + 1
    print(v)

Measured memory_bytes: 9140
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iostream>
#include <iostream>
#include <fstream>
#include <numeric>
#include <cstring>
#include <cassert>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <cmath>
#include <set>
#include <map>
#include <functional>
#include <bitset>
#include <iomanip>
#include <stack>
#include <list>
#include <cstdint>
#include <chrono>
//#include "atcoder/all"
using namespace std;
//using namespace atcoder;
#define     loop(n,i,a)     for(ll i=a;i<n;i++)
#define     loopR(n,i,a)    for(ll i=a-1;i>=n;i--)
#define     all(arr,n)      arr,arr+n
#define     allv(v)         (v).begin(),(v).end()
#define     rallv(v)        (v).rbegin(),(v).rend()
#define     m_p             make_pair
#define     ll              long long
#define     pii             pair<ll,ll>
#define     vi              vector<int>
#define     vll             vector<ll>
#define     vii             vector<pii>
#define     sz(x)           (int)x.size()
#define     pb              push_back
#define     endl            "\n"
#define     Endl            "\n"
#define     f               first
#define     s               second
#define     mem(dp,n)       memset(dp,n,sizeof dp)
template<typename T>void max_self(T &a,T b){a=max(a,b);}
template<typename T>void min_self(T &a,T b){a=min(a,b);}
int dx[] = { 1 , 0 ,-1 , 0 ,-1 ,-1 , 1 , 1 };
int dy[] = { 0 , 1 , 0 ,-1 ,-1 , 1 ,-1 , 1 };
int KnightI[] = { 2, 1, -1, -2, -2, -1, 1, 2 };
int KnightJ[] = { 1, 2, 2, 1, -1, -2, -2, -1 };
void fast(){
    std::ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
}
vector<string> vec_splitter(string s) {
    s += ',';
    vector<string> res;
    while(!s.empty()) {
        res.push_back(s.substr(0, s.find(',')));
        s = s.substr(s.find(',') + 1);
    }
    return res;
}
void debug_out(
        vector<string> __attribute__ ((unused)) args,
        __attribute__ ((unused)) int idx,
        __attribute__ ((unused)) int LINE_NUM) { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
    if(idx > 0) cerr << ", "; else cerr << "Line(" << LINE_NUM << ") ";
    stringstream ss; ss << H;
    cerr << args[idx] << " = " << ss.str();
    debug_out(args, idx + 1, LINE_NUM, T...);
}
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
const ll mxN=3e5+10,oo=0x3f3f3f3f,MOD=1e9+7;
const long double PI = acos(-1),eps=1.0e-14;
ll dp[(int)1e6+5][2][2],n;
ll go(int idx,int z,int ni){
    if(idx==n)
        return z&&ni;
    ll &ret=dp[idx][z][ni];
    if(~ret)
        return ret;
    ret=0;
    loop(10,i,0){
        ret=((ret%MOD)+(go(idx+1,z||(i==0),ni||(i==9))%MOD))%MOD;
    }
    return ret;
}

void solve() {
    cin >> n;
    /*ll P = n * (n - 1);
    cout << mul(P, power(10, n - 2)) % MOD << Endl;*/
    mem(dp,-1);
    cout<<go(0,0,0)<<endl;

}
int main() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    fast();
    solve();

}


Measured memory_bytes: 112936
n, m = gets.split(' ').map{|i| i.to_i}
a = []
b = []
ans = []

m.times do
  x, y = gets.split(' ').map{|i| i.to_i}
  a << x
  b << y
end

n.times do |i|
  ans << a.count(i+1) + b.count(i+1)
end

puts ans

Measured memory_bytes: 1788
N = input()
a = list(map(int, input().split()))
answer = 0
a.sort()
a_count = [0 for _ in range(10 ** 5 + 10)]
for x in a:
  a_count[x] += 1
for i in range(1, 10 ** 5 + 5):
  answer = max(answer, a_count[i - 1] + a_count[i] + a_count[i + 1])
print(answer)

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

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

int f(const string &s, int i){
  if(s[i-1]!=']'){
    int o=1, ret=0;
    for(int j=i-1; j>=0; j--){
      if(s[j]=='[') break;
      else ret+=(s[j]-'0')*o, o*=10;
    }
    return (ret-1)/2+1;
  }
  int c=0;
  vector<int> idx;
  for(int j=i-1; j>=0; j--){
    if(c<0) break;
    if(s[j]==']'){
      if(c==0) idx.push_back(j);
      c++;
    }else if(s[j]=='['){
      c--;
    }
  }
  vector<int> a;
  for(int j: idx) a.push_back(f(s, j));
  sort(a.begin(), a.end());
  int k=((int)a.size()-1)/2+1;
  int ret=0;
  rep(j, k) ret+=a[j];
  return ret;
}

int main(){

  int n; cin>> n;
  while(n--){
    string s; cin>> s;
    cout<< f(s, (int)(s.size())-1)<< endl;
  }

  return 0;
}


Measured memory_bytes: 3148
#include <bits/stdc++.h>
#define pb push_back
#define all(a) a.begin(), a.end()
#define sz(a) (int)a.size()
#define x first
#define y second
#define debug(...) cout<<"["<<#__VA_ARGS__<<": "<<__VA_ARGS__<<"]\n"
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int>pii;
const int maxn = 1e5 + 100;
const int mod = 1e9 + 7;
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
int n, k, h[maxn], dp[maxn];
int main()
{
    ios_base::sync_with_stdio(false), cin.tie(0);
    cin >> n >> k;
    for(int i = 1; i <= n; i++)
        cin >> h[i];
    memset(dp, 127, sizeof dp);
    dp[1] = 0;
    for(int i = 2; i <= n; i++)
        for(int j = i - 1; j >= max(i - k, 1); j--)
            dp[i] = min(dp[i], dp[j] + abs(h[i] - h[j]));
    cout << dp[n];
    return 0;
}


Measured memory_bytes: 1024