akhauriyash/Code-Regression huggingface dataset:
while (line = gets)
  ns = line.chomp.split("").map{|s| s.to_i}

  while ns.length > 1
    ns0 = []
    for i in (1...ns.length)
      ns0.push (ns[i - 1] + ns[i]) % 10
    end
    ns = ns0
  end

  puts ns[0]
end

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

using namespace std;

int main(){
    long A, B;
    cin>>A>>B;

    long ans = 0;
    long x;
    int a, b;
    if((B-(A-1))%4==3){
        if(A%2==0){
            ans=1;
        }
    }else if((B-(A-1))%4==1){
        if(A%2==1){
            ans=1;
        }
    }else if((B-(A-1))%4==2){
        ans=1;
    }
    for(int i=1; i<=40; ++i){
        a = 0;
        b = 0;

        x = B%long(pow(2, i+1));
        if(x >= pow(2, i) && (x==1 || x%2==0)){
            b=1;
        }

        x = (A-1)%long(pow(2, i+1));
        if(x >= pow(2, i) && (x==1 || x%2==0)){
            a=1;
        }

        if(a!=b){
            ans += pow(2, i);
        }
    }

    cout<<ans<<endl;

    return 0;
}

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

#define all(v) (v).begin(), (v).end()
#define sortv(v) sort(all(v))
#define uniqv(v) (v).erase(unique(all(v)), (v).end())
#define pb push_back
#define FI first
#define SE second
#define lb lower_bound
#define ub upper_bound
#define mp make_pair
#define test 1
#define TEST if(test)

using namespace std;

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

const int MOD = 1000000007; // 998244353
const int INF = 2e9;
const ll INFLL = 1e18;
const int MAX_N = 1;

int N;
ll ans;
ll cnt[10][10];

int main(){
	cin>>N;
	for(int i=1; i<=N; i++){
		int t = i%10, n=i;
		while(n>=10)	n/=10;
		cnt[n][t]++;
	}
	for(int i=0; i<=9; i++){
		for(int j=0; j<=9; j++){
			ans += cnt[i][j]*cnt[j][i];
		}
	}
	cout<<ans;
	return 0;
}


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

using namespace std;

int main(void){
	int N, p[11];
 	cin >> N;
  	for(int i=0; i<N; i++)
      cin >> p[i];
  	sort(p, p+N, greater<int>());
  	int ans = 0;
  	for(int i=0; i<N; i++){
    	if(i == 0)
          ans += p[i] / 2;
      	else
          ans += p[i];
    }
  	cout << ans;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int a,b,c,d,s1=0,s2=0,s3=0;
    while(cin>>a>>b>>c>>d){
            s1=(a*b);
    s2=(c*d);
    if(s1==s2){
        cout<<s1<<endl;
    }
    else if(s1<s2){
        cout<<s2<<endl;
    }
    else if(s1>s2){
        cout<<s1<<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)
#define FOR(i, a, b) for(int i = a; i < (int)b; ++i)
#define rrep(i, n) for(int i = ((int)n - 1); i >= 0; --i)

using ll = long long;
using ld = long double;

const ll INF = 1e18;
const int Inf = 1e9;
const double EPS = 1e-9;
const ll MOD = 1e9 + 7;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(0);
	ll a, b, n;
	cin >> a >> b >> n;
	n = min(n, b - 1);
	cout << (a * n) / b - a * (n / b) << endl;
    
    return 0;
}


Measured memory_bytes: 3648
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define FOR(i, a, b) for(int i=(a);i<(b);i++)
#define RFOR(i, a, b) for(int i=(b-1);i>=(a);i--)
#define REP(i, n) for(int i=0; i<(n); i++)
#define RREP(i, n) for(int i=(n-1); i>=0; i--)
#define REP1(i, n) for(int i=1; i<=(n); i++)
#define RREP1(i, n) for(int i=(n); i>=1; i--)
#define ALL(a) (a).begin(),(a).end()
#define UNIQUE_SORT(l) sort(ALL(l)); l.erase(unique(ALL(l)), l.end());
#define CONTAIN(a, b) find(ALL(a), (b)) != (a).end()
#define out(...) printf(__VA_ARGS__)

int dxy[] = {0, 1, 0, -1, 0};

void solve();
signed main()
{
#if DEBUG
    std::ifstream in("input.txt");
    std::cin.rdbuf(in.rdbuf());
#endif
    cin.tie(0);
    ios::sync_with_stdio(false);
    solve();
    return 0;
}

/*================================*/
int X,Y;
const int MAX = 1110000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    if (!fac[n]) COMinit();
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

void solve() {
    cin>>X>>Y;
    if ((X + Y) % 3 != 0) {
        cout << 0 << endl;
        return;
    }
    int d = (X+Y)/3;
    int f = X-d;
    cout << COM(d,f) << endl;
}

Measured memory_bytes: 26240
#include <stdio.h>

int main(void)
{
    int n,a[4],i=0;
    scanf("%d",&n);
    do{
        a[i]=n%10;
        i++;
    }while(n/=10);
    puts(a[0]==a[1]&&a[1]==a[2]||a[1]==a[2]&&a[2]==a[3]?"Yes":"No");
    return 0;
}

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

int main(){
    int N;
    cin >> N;
    vector<int> light(N);
    for(int i = 0; i < N; i++){
        int num;
        cin >> num;
        light.at(i) = num - 1 ;
    }

    int count = 0;
    int now = 0;
    while(true){
        if(now == 1){
            cout << count << endl;
            break;
        }
        if(count >= N){
            cout << -1 << endl;
            break;
        }

        count++;
        now = light.at(now);
    }
    
}

Measured memory_bytes: 3760
#include <algorithm>
#include <bitset>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <deque>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

int main() {
    int n, m;
    cin >> n >> m;
    vector<pair<long long, int>> pr(n);

    for (int i = 0; i < n; i++) {
        cin >> pr[i].first >> pr[i].second;
    }

    sort(pr.begin(), pr.end());
    int now = m;

    long long cost = 0;
    for (int i = 0; i < n; i++) {
        if (pr[i].second >= now) {
            cost += now * pr[i].first;
            break;
        } else {
            now -= pr[i].second;
            cost += pr[i].first * pr[i].second;
        }
    }

    cout << cost << endl;

    return 0;
}

Measured memory_bytes: 1792
import sys
sys.setrecursionlimit(100000)
x=10**9+7
n,k=map(int,input().split())
t=[set()for _ in range(n)]
for i in range(n-1):
  a,b=map(int,input().split())
  t[a-1].add(b);t[b-1].add(a)
c=k
def b(o):
  global c
  for i,j in enumerate(t[o-1]):c=(c*(k-2-i))%x;t[j-1].discard(o);b(j)
for i,j in enumerate(t[0]):c=(c*(k-1-i))%x;t[j-1].discard(1);b(j)
print(c)

Measured memory_bytes: 109900
#include<bits/stdc++.h>
#define rep(a,b,c) for(int a=b;a<=c;a++)
#define per(a,b,c) for(int a=b;a>=c;a--)
#define ios; ios::sync_with_stdio(false); cin.tie(0);
#define pb push_back
#define mk make_pair
#define fi first
#define se second
#define mem(a,b) memset(a,b,sizeof(a))
#define inf 0x3f3f3f3f
#define INF 0x3f3f3f3f3f3f3f3f
#define ls(x) (x<<1)
#define rs(x) (ls(x)|1)
#define eps 1e-11
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef vector<int> VI;
typedef double db;
mt19937 rnd(random_device{}());
const int mod = 1e9 + 7;
const int N = 1e3 + 5;
const int M = 1e3 + 5;
inline ll gcd(ll a,ll b){ return b?gcd(b,a%b):a; }
inline ll lcm(ll a,ll b){ return a*b/gcd(a,b); }
inline ll ksm(ll x,ll y){ ll res=1; while(y){if(y&1) res=res*x%mod;
x=x*x%mod; y>>=1;} return res; }
int n,m,k;
string s;

int main(){
    cin>>s;
    int ans=0;
    rep(i,0,2){
        if(s[i]=='R') ++ans;
    }
    if(ans==2){
        if(s[1]=='S') --ans;
    }
    cout<<ans;
    return 0;
}
/*
*/
//
//                            _ooOoo_
//                           o8888888o
//                           88" . "88
//                           (| -_- |)
//                           O\  =  /O
//                        ____/`---'\____
//                      .'  \|     |//  `.
//                     /  \|||  :  |||//  \
//                    /  _||||| -:- |||||-  \
//                    |   | \  -  /// |   |
//                    | \_|  ''\---/''  |   |
//                    \  .-\__  `-`  ___/-. /
//                  ___`. .'  /--.--\  `. . __
//               ."" '<  `.___\_<|>_/___.'  >'"".
//              | | :  `- \`.;`\ _ /`;.`/ - ` : | |
//              \  \ `-.   \_ __\ /__ _/   .-` /  /
//         ======`-.____`-.___\_____/___.-`____.-'======
//                            `=---='
//        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
//                     佛祖保佑      永无BUG


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

int main(){
    int N;
    cin >> N;
    string s;
    cin >> s;
    int big = 0;
    int cnt = 0;
    for(int i = 0; i < s.size(); i++){
        if(s[i]=='I'){
            cnt++;
        }else{
            cnt--;
        }
        big = max(big, cnt);
    }
    cout << big << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repp(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define rrep(i, n, m) for (int i = n; i >= m; i--)
#define p(a, b) printf(a, b);
#define c(s) cout << (s) << endl;
#define yes cout << "Yes" << endl;
#define no cout << "No" << endl;
#define YES cout << "YES" << endl;
#define NO cout << "NO" << endl;
#define cyn(c) cout << (c ? "Yes" : "No") << endl;
#define cYN(c) cout << (c ? "YES" : "NO") << endl;
#define pyn(c) printf("%s\n", c ? "Yes" : "No");
#define pYN(c) printf("%s\n", c ? "YES" : "NO");
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<LL, LL> P;
template <class T>
bool contain(const std::string &s, const T &v)
{
    return s.find(v) != std::string::npos;
}

int main()
{
    int N, M;
    cin >> N >> M;
    ULL A[100005] = {}, B[100005] = {}, ans = 0;
    vector<P> v;
    rep(i, N)
    {
        cin >> A[i] >> B[i];
        v.push_back(make_pair(A[i],B[i]));
    }
    sort(v.begin(),v.end());
    for(auto v1 : v){
        if(M==0) break;
        // cout<<v1.first<<" "<<v1.second<<endl;
        if(M > v1.second){
            ans+=v1.first*v1.second;
            M -= v1.second;
        }else{
            ans += v1.first * M;
            M = 0;
        }
    }
    c(ans);
}


Measured memory_bytes: 3956
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const int mod=1e9+7;
template <class T> inline bool  chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
int main() {
int a,b,c;
  cin>>a>>b>>c;
  if(a<=c&&c<=b)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}


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

typedef long long int ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<string> vs;
typedef pair<ll,ll> P;
typedef vector<P> vp;
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define REPR(i,n) for(int i=n-1;i>=0;i--)
#define FORR(i,n,m) for(int i=n-1;i>=m;i--)
#define ARR(array) for(int i=0;i<array.size();i++)
#define all(in) (in).begin(),(in).end()
#define ALL(in,K) (in),(in)+(K)

#define INF 1e18
#define MOD 1000000007
#define SIZE 10005
#define PI 	3.14159265358979323846

ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; } //最大公約数
ll lcm(ll a, ll b) { return a/gcd(a, b)*b; } //最小公倍数

ll input(){
  ll a;
  cin >> a;
  return a;
}

int main(){
  int n;
  cin >> n;
  vector<int> vec(n);
  REP(i,n)cin >> vec.at(i);
  sort(vec.begin(),vec.end());
  int ans = 1;
  REP(i,n-1)if(vec.at(i)!=vec.at(i+1))ans++;
  cout << ans << endl;
}

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

//abc135D
int main(void) {
  int n, i, cou=0, m=0;
  scanf("%d", &n);
  int a[n], b[n];
  for(i=0; i < n; i++){
    scanf("%d", &a[i]);
    b[i]=0;
  }

  for(i=n - 1; i >= 0; i--){
    cou=0;
    while((i + 1) * (cou + 2) <= n)
      b[i]^= b[(i + 1) * (cou + 2) - 1], cou++;
    b[i]^=a[i], m+=b[i];
  }

  printf("%d\n", m);
  for(i=0; i < n; i++)
    if(b[i] == 1) printf("%d ", i + 1);
  return 0;
}

Measured memory_bytes: 2432
#include<stdio.h>
#define MAX 1000
long long F[MAX];
long long fibonacci(int n){
  if(n==0 || n==1) return F[n]=1;
  if(F[n]!=0) {
    return F[n];
  }
  
  return F[n]= fibonacci(n-2) + fibonacci(n-1);
}
int main(){
  int i;
  int n;
  scanf("%d",&n);
   for(i=0;i<n;i++) F[i]=0;
   printf("%lld\n",fibonacci(n));
   //for(i=0;i<n;i++) printf("%d ",F[i]);
  return 0;
}



Measured memory_bytes: 2108
import sys
def S(): return sys.stdin.readline().rstrip()
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())

import math

a,b,h,m = LI()

b_x = b*math.cos(math.radians(6*m))
b_y = b*math.sin(math.radians(6*m))
a_x = a*math.cos(math.radians(30*h + m/2))
a_y = a*math.sin(math.radians(30*h + m/2))

l = math.sqrt(pow(b_x - a_x,2) + pow(b_y - a_y,2))
print(l)

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

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

int main(){
  int n;
  cin >> n;
  
  int k=0;
  
  for(int i=1;i<=n;i++){
    for(int j=1;j<=n;j++){
      int x=gcd(i,j);
      for(int l=1;l<=n;l++){
        k+=gcd(x,l);
      }
    }
  }
  cout << k << endl;
}

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

#define MAX_KN (200002)

int main() {

    int N, K;
    double p[MAX_KN];

    cin >> N >> K;
    for(int i=0; i<N; i++) {
        cin >> p[i];
        p[i] = (1.0+p[i])/2.0;
    }

    double max = 0.0;

    int f = 0;
    int t = f + K - 1;
    for(int i=f; i<=t;i++) {
        max += p[i];     
    }

    double prev = max;
    for(int f=1; f<N-K+1; f++) {
        int t = f + K - 1;
        double tmp = prev - p[f-1] + p[t];
        if(max<tmp) {
            max = tmp;
        }
        prev = tmp;
    }
    ::printf("%.10f\n", max);
    return 0;
}


Measured memory_bytes: 1792
amount, num_cnt = map(int, input().split())
hate_list = input().split()

payment = 0
for i in range(amount, 100000):
    nums = set(list(str(i)))
    flg = False
    for j in nums:
        if j in hate_list:
            flg = True
            break
    if not flg:
        payment = i
        break

print(payment)

Measured memory_bytes: 3060
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Tarek
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        ARepeatACL solver = new ARepeatACL();
        solver.solve(1, in, out);
        out.close();
    }

    static class ARepeatACL {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int k = in.nextInt();
            for (int i = 0; i < k; i++) {
                out.print("ACL");
            }
            out.println();
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

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

    }
}



Measured memory_bytes: 32720
n, k = map(int, input().split())
r, s, p = map(int, input().split())
t = input()
u = []
a = 0
for i in range(n):
    if i <= k-1:
        if t[i] == "r":
            u.append("p")
            a += p
        elif t[i] == "s":
            u.append("r")
            a += r
        else:
            u.append("s")
            a += s
    else:
        if t[i] == "r" and u[i-k] != "p":
            u.append("p")
            a += p
        elif t[i] == "s" and u[i-k] != "r":
            u.append("r")
            a += r
        elif t[i] == "p" and u[i-k] != "s":
            u.append("s")
            a += s
        elif t[i] == "r" and u[i-k] == "p":
                u.append("_p")
        elif t[i] == "s" and u[i-k] == "r":
            u.append("_r")
        elif t[i] == "p" and u[i-k] == "s":
            u.append("_s")
print(a)

Measured memory_bytes: 4212
#include <bits/stdc++.h>
#include <stdio.h>
using namespace std;
int main(){
int n;
cin>>n;
int ton[n];
for (int i=0; i<n;i++)
    cin >>ton[i];
int ttim=0;
for (int i=0; i<n;i++)
ttim+=ton[i];
int m;
cin>>m;
int p ,x;
int a[m];
for(int i=0;i<m;i++){
    cin>>p>>x;
    a[i]=(ttim-ton[p-1])+x;


}
for (int i=0; i<m;i++)
    cout<<a[i]<<endl;
return 0;
}


Measured memory_bytes: 256
# coding: utf-8
import sys
from collections import defaultdict

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

# 左から累積和のリストを持ちながらApplePen
N, M = lr()
A = lr()
dic = defaultdict(int)
dic[0] = 1
answer = 0
cur = 0
for a in A:
    cur += a
    cur %= M
    answer += dic[cur]
    dic[cur] += 1

print(answer)


Measured memory_bytes: 62576
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
using namespace std;

typedef long long LL;

const int N=3005;
const int MOD=1000000007;

int n,m,c[N][N],a[N],f[N][N];
struct data{int l,r;}op[N];
char str[N];

bool cmp(data a,data b)
{
	return a.l<b.l||a.l==b.l&&a.r<b.r;
}

void mod(int &x)
{
	x-=x>=MOD?MOD:0;
}

void prepare()
{
	c[0][0]=1;
	for (int i=1;i<=n;i++)
	{
		c[i][0]=1;
		for (int j=1;j<=i;j++) mod(c[i][j]=c[i-1][j]+c[i-1][j-1]);
	}
}

int main()
{
	scanf("%d%d",&n,&m);
	prepare();
	scanf("%s",str+1);
	for (int i=1;i<=n;i++) a[i]=a[i-1]+str[i]-'0';
	for (int i=1;i<=m;i++) scanf("%d%d",&op[i].l,&op[i].r);
	sort(op+1,op+m+1,cmp);
	int tmp=m,mx=0;
	for (int i=1;i<=m;i++)
		if (op[i].l==op[i+1].l||op[i].r<=mx) tmp--,op[i].l=n+1;
		else mx=max(mx,op[i].r);
	sort(op+1,op+m+1,cmp);
	m=tmp;
	f[op[1].l-1][a[op[1].l-1]]=1;
	op[m+1].l=n+1;
	for (int i=1;i<=m;i++)
	{
		int l=op[i].l,r=op[i].r,nx=op[i+1].l;
		for (int j=0;j<l;j++)
		{
			if (!f[l-1][j]) continue;
			int s=a[r]-j,p=max(0,s-(r-nx+1)),q=min(s,nx-l);
			if (nx>r) {mod(f[nx-1][a[nx-1]]+=(LL)f[l-1][j]*c[r-l+1][s]%MOD);continue;}
			if (p>q) continue;
			for (int k=p;k<=q;k++) mod(f[nx-1][j+k]+=(LL)f[l-1][j]*c[nx-l][k]%MOD);
		}
	}
	printf("%d",f[n][a[n]]);
	return 0;
}

Measured memory_bytes: 69120
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <string.h>
#include <cmath>

using namespace std;

int main()
{
    int h, w;
    cin >> h >> w;
    char a[h][w];
    for (int i=0; i<h; i++) {
        for (int j=0; j<w; j++) cin >> a[i][j];
    }
    for (int i=0; i<w+2; i++) cout << '#';
    cout << '\n';
    for (int i=0; i<h; i++) {
        for (int j=-1; j<w+1; j++) {
            if (j == -1 or j == w) cout << '#';
            else cout << a[i][j];
        }
        cout << '\n';
    }
    for (int i=0; i<w+2; i++) cout << '#';
    
    return 0;
}

Measured memory_bytes: 3552
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstring>

using namespace std;

#define MAX 100000
#define INF 2140000000
#define MOD 1000000007

int main() {
	int n;
	cin >> n;
	vector<int> a(n);

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

	long long m = 0, sign = 1;

	for (int i = 0; i < n; ++i) {
		m += sign * a[i];
		sign *= -1;
	}

	cout << m << " ";

	for (int i = 0; i < n - 1; ++i) {
		cout << (a[i] - m / 2) * 2 << " ";
		m = (a[i] - m / 2) * 2;
	}

	cout << endl;

	return 0;
}

Measured memory_bytes: 1664
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
using namespace std;
char s[111111];
int n,pre[111111],nxt[111111],cnt,pr,l,r,ans;
string str;
int main()
{
	scanf("%s",s);
	n=strlen(s);
	for (int i=0;i<n;i++)
	{
		if (s[i]!='x')
		{
			cnt++;
			pre[cnt]=nxt[cnt-1]=i-pr;
			pr=i+1;
			str+=s[i];
		}
	}
	nxt[cnt]=n-pr;
	int sz=str.size();
	for (int i=0;i<sz/2;i++) 
	{
		if (str[i]!=str[sz-1-i]) 
		{
			printf("-1\n");
			return 0;
		}
	}
	l=1;r=cnt;
	while(l<=r)
	{
		ans+=max(pre[l]-nxt[r],nxt[r]-pre[l]);
		l++;
		r--;
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

int main() {
  FAST
  int N; 
  cin >> N;
  string S; 
  cin >> S;
  map<char,int> toIdx = {
    {'R', 0},
    {'G', 1},
    {'B', 2},
  };
  vector<ll> cnt(3);
  for(int i=0;i<N;i++) cnt[toIdx[S[i]]]++;
 
  ll ans = 1;
  for(int i=0;i<3;i++) ans *= cnt[i];
  for(int j=0;j<N;j++)
   for(int i=0;i<j;i++){
    int k = j + j - i;
    if (k < N) {
      if (S[i] == S[j]) continue;
      if (S[i] == S[k]) continue;
      if (S[k] == S[j]) continue;
      --ans;
    }
  }
 
  cout<<ans;
  return 0;
    
}

Measured memory_bytes: 3636
#include <iostream>

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

using namespace std;

int main(void) {

	int N;
	scanf("%d", &N);

	int ans = 0;

	// 1 - 9         9
	// 100 - 999     900
	// 10000 - 99999 90000
	// 10000
	if ( N <= 9 ) ans += N;
	else if ( N > 9 ) ans += 9;

	if ( N >= 100 && N <= 999 ) ans += N - 100 + 1;
	else if ( N > 999 ) ans += 900;

	if ( N >= 10000 && N <= 99999 ) ans += N - 10000 + 1;
	else if (N > 99999) ans += 90000;

	printf("%d\n", ans); 

	return 0;
}


Measured memory_bytes: 256
s = input()

if s[0] == s[1] and s[2] == s[3] or\
   s[0] == s[2] and s[1] == s[3] or\
   s[0] == s[3] and s[2] == s[1]:
   if not s[0] == s[1] == s[2] == s[3]:
       print('Yes')
else:
    print('No')

if s[0] == s[1] == s[2] == s[3]:
    print('No')


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

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  vector<int> v(3);
  v.at(0) = a;
  v.at(1) = b;
  v.at(2) = c;
  sort(v.begin(), v.end());
  if (v.at(0) + v.at(1) == v.at(2)) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<vector>
#include<set>
#include<iostream>
#define pb push_back
#define fi first
#define se second
#define sz(x)  x.size()
#define cl(x)  x.clear()
#define all(x)  x.begin() , x.end()
#define r(x)  scanf("%d", &x)
#define rr(x , y)  scanf("%d%d" , &x , &y)
#define rst(s)  scanf("%s" , s)
#define rl(x)  scanf("%lld" , &x)
#define rrl(x , y)  scanf("%lld%lld" , &x , &y)
#define w(x)  printf("%d" , x)
#define ww(x , y)  printf("%d %d" , x , y)
#define wl(x)  printf("%lld" , x)
#define wwl(x , y)  printf("%lld %lld" , x , y)
#define sp()  printf(" ")
#define en()  puts("")
#define rep(i , x , n)  for(int i = x ; i <= n ; i ++) 
#define per(i , n , x)  for(int i = n ; i >= x ; i --) 
#define mem0(x)  memset(x , 0 , sizeof(x))
#define mem_1(x)  memset(x , -1 , sizeof(x))
#define mem_inf(x)  memset(x , inf , sizeof(x))
#define mem__inf(x)  memset(x , -inf , sizeof(x))
#define p_queue priority_queue
#define debug(x)  printf("%d\n" , x)
#define ddebug(x , y)  printf("%d %d\n" , x , y)
using namespace std ;
//mt19937  rnd(chrono::high_resolution_clock::now().time_since_epoch().count()) ;
typedef long long ll ;
typedef unsigned long long ull ;
typedef pair<int , int> pii ;
typedef pair<ll , ll> pll ;
typedef pair<int , ll> pil ;
typedef pair<ll , int> pli ;
const int inf = 0x3f3f3f3f ;
const int maxn = 3e5 + 5 ;
const int maxm = 2e6 + 5 ;
const ll mod = 998244353 ;
int main()
{
    int k ;
    r(k) ;
    int ans = 0 ;
    rep(a , 1 , k)
      rep(b , 1 , k)
        rep(c , 1 , k)
          ans += __gcd(a , __gcd(b , c)) ;
    w(ans) , en() ;
	return 0 ;
}


Measured memory_bytes: 3824
N = int(input())
arr = list(sorted(map(int, input().split())))

memo = [0]*1001
for x in range(1001):
    for i in arr:
        if i < x:
            memo[x] += 1

result = 0
for a in range(N):
    for b in range(a+1, N):
        aa = arr[a]
        bb = arr[b]
        if aa+bb > 1000:
            result += N-b-1
        else:
            result += memo[aa+bb]-b-1

print(result)


Measured memory_bytes: 3188
import numpy as np
n = int(input())
a = np.array(list(map(int, input().split())))
data = []
if np.sum(a >= 0) == n:
    flag = 1
elif np.sum(a >= 0) == 0:
    flag = -1
else:
    max_a = np.max(a)
    max_ind = np.argmax(a)
    min_a = np.min(a)
    min_ind = np.argmin(a)
    if np.abs(max_a) > np.abs(min_a):
        flag = 1
        a = a + max_a
        for i in range(n):
            data.append([max_ind+1, i+1])
    else:
        flag = -1
        a = a + min_a
        for i in range(n):
            data.append([min_ind+1, i+1])
if flag == 1:
    for i in range(n-1):
        data.append([i+1, i+2])
else:
    for i in range(n-1, 0, -1):
        data.append([i+1, i])
print (len(data))
for i in range(len(data)):
    print (data[i][0], data[i][1])


Measured memory_bytes: 12508
open Printf open Scanf
module MyInt = struct
	let (+) = (+) let (-) = (-) let (/) = (/) let ( * ) = ( * ) let (mod) = (mod) let (%) = (mod) let (+=) r v = r := !r + v let (-=) r v = r := !r - v let ( *=) r v= r := !r * v let (/=) r v = r := !r / v
	(* let input_int_array n = Array.init n (fun _ -> Scanf.scanf " %d" (fun v -> v))	
	let get_int () = Scanf.scanf " %d" (fun v -> v)
	let get_2_ints () = Scanf.scanf " %d %d" (fun u v -> u,v)
	let get_3_ints () = Scanf.scanf " %d %d %d" (fun u v w -> u,v,w)
	let get_4_ints () = Scanf.scanf " %d %d %d %d" (fun u v w x -> u,v,w,x)
	let get_5_ints () = Scanf.scanf " %d %d %d %d %d" (fun u v w x y -> u,v,w,x,y)
	let print_int_endline n = n |> string_of_int |> print_endline *)
end
(* module MyInt64 = struct *)
	let (+$) = (+) let (-$) = (-) let (/$) = (/) let ( *$) = ( * )
	let (+) p q = Int64.add p q let (-) p q = Int64.sub p q let ( * ) p q = Int64.mul p q let (/) p q = Int64.div p q let (+=) r v = r := !r + v let (-=) r v = r := !r - v let ( *=) r v= r := !r * v let (/=) r v = r := !r / v
	let labs p = if p < 0L then -1L*p else p
	let (~|) p = Int64.to_int p
	let (~~|) p = Int64.of_int p

	let input_i64_array n = Array.init (~| n) (fun _ -> Scanf.scanf " %Ld" (fun v -> v))
	let get_i64 () = Scanf.scanf " %Ld" (fun v -> v)
	let get_2_i64 () = Scanf.scanf " %Ld %Ld" (fun u v -> u,v)
	let get_3_i64 () = Scanf.scanf " %Ld %Ld %Ld" (fun u v w -> u,v,w)
	let get_4_i64 () = Scanf.scanf " %Ld %Ld %Ld %Ld" (fun u v w x -> u,v,w,x)
	let get_5_i64 () = Scanf.scanf " %Ld %Ld %Ld %Ld %Ld" (fun u v w x y -> u,v,w,x,y)
	let print_i64_endline n =
		n |> Int64.to_string |> print_endline
	
	let (mod) m n = m - (m/n) * n let (%) = (mod)
	let rec gcd m n = match m,n with | m,0L -> m | m,n -> gcd n (m mod n)
	let rec lcm m n = (m*n) / gcd m n
	let rep from_ to_ fbod =
		let i,f = ref ~|from_,ref true in while !i <= ~|to_-$1 && !f do
			match fbod !i with
			| `Ok -> i := !i +$ 1;
			| `Ng -> f := false
		done
(* end open MyInt64 *)

let () =
	let a = input_i64_array 3L
	in
	Array.sort compare a;
	labs (a.(2) - a.(1)) + labs (a.(1) - a.(0))
	|> printf "%Ld\n"

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

typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, P> P1;
typedef pair<P, P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i, x) for (long long i = 0; i < x; i++)
#define repn(i, x) for (long long i = 1; i <= x; i++)
#define SORT(x) sort(x.begin(), x.end())
#define ERASE(x) x.erase(unique(x.begin(), x.end()), x.end())
#define POSL(x, v) (lower_bound(x.begin(), x.end(), v) - x.begin())
#define POSU(x, v) (upper_bound(x.begin(), x.end(), v) - x.begin())
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define rrepn(i, n) for (int i = ((int)(n)); i > 0; --i)
#define SZ(x) ((int)(x).size())
template <class T> bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
vector<pair<string, P>> vec;
// vector<vector<int>> data(3, vector<int>(4));

int main() {
    int D;
    cin >> D;
    vector<int> c(26);
    rep(i, 26) cin >> c[i];
    vector<vector<int>> s(D, vector<int>(26));
    rep(i, D) rep(j, 26) cin >> s[i][j];

    vector<int> t(D);
    // rep(i, D) {
    //     cin >> t[i];
    //     t[i]--;
    // }

    rep(i, D) {
        int now = 0;
        rep(j, 26) {
            if (now <= s[i][j]) {
                now = s[i][j];
                t[i] = j;
            }
        }
    }

    auto scoring = [&]() {
        vector<int> last(26);
        int score = 0;
        rep(i, D) {
            score += s[i][t[i]];
            last[t[i]] = i + 1;
            int m = 0;
            rep(j, 26) m += c[j] * (i + 1 - last[j]);
            score -= m;
            // cout << score << endl;
        }
        return score;
    };

    int score = scoring();
    srand((unsigned int)time(NULL));
    rep(i, 300000) {
        int d = rand() % D;
        int q = rand() % 26;
        int old = t[d];
        t[d] = q;
        int now = scoring();
        if (score > now) {
            t[d] = old;
        } else {
            score = now;
        }
    }

    rep(i, D) { cout << t[i] + 1 << endl; }
    return 0;
}


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


int main() {

    string s;
    cin >> s;
    int n = s.length();
    for (int i = 1; i < n; ++i) {
        s.erase(n-i);
        int m = s.length();
        if (m % 2 == 0) {
            if (s.substr(0,m/2) == s.substr(m/2,m/2)) {
                cout << m << endl;
                return 0;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 256
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<long, long> PLL;
typedef long long LL;
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
#define INF 1000000000
#define MAX_N 100003
#define MAX_V 100003
#define MOD 1000000007
struct edge{int to,cost;};
typedef pair<int,int> P;//firstは最短距離,secondは頂点番号

long bit[MAX_N],n;

LL sum(long i){
	LL s=0;
	while(i>0){
		s+=bit[i];
		i-=i&-i;//iの最後の1のビットはi&-iで表せる
	}
	return s;
}


int add(long i,int x){
	while(i<=n){
		bit[i]+=x;
		i+=i&-i;
	}
	return 0;
}



LL dp[MAX_N+1];
int main(){
	long N,R;
	dp[0]=1;
	for(LL i=1;i<=MAX_N;i++)dp[i]=dp[i-1]*i%MOD;
	while(cin>>N){
		if(N==0)break;
		cin>>R;
		n=N;
		long a[MAX_N];
		REP(i,N){
			a[i]=i+1;
			bit[i]=0;
		}
		bit[N]=0;
		REP(i,R){
			long s,t;
			cin>>s>>t;
			s--;t--;
			swap(a[s],a[t]);
		}
		LL res=0;
		for(long i=N-1,j=0;i>=0;i--,j++){
			res+=(sum(a[i])*dp[j]);
			add(a[i],1);
			res%=MOD;
			//cout<<kai<<" "<<sum(a[i])<<endl;
		}
		cout<<res<<endl;
	}
	return 0;
}

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

#define pb         push_back

typedef long long ll;
const ll INF = 1000000000ll;
const ll MOD = 1000000007ll;
const double EPS = 1e-8;

int main(void) {
	//ios_base::sync_with_stdio(false);
	//cin.tie(0);
	
	int n, a, b;
	vector<long long> x;
	cin >> n >> a >> b;

	for(int i=0; i<n; i++){
		int t;
		cin >> t;
		x.pb(t);
	}

	ll ans = 0;
	for(int i=1; i<n; i++){
		ll cost = (x[i] - x[i-1]) * a;
		if(cost < b){
			ans += cost;
		}else{
			ans += b;
		}
	}

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


Measured memory_bytes: 1400
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <utility>
#include <algorithm>
#include <functional>
#include <deque>
#define INF 1000000000
#define MOD 1000000007
#define mod(x) ((x % MOD) + MOD) % MOD
#define MAX_N 1001

using namespace std;

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


bool is_prime[MAX_N];

void init(ll n) {
  fill(is_prime, is_prime + n+1, true);
  is_prime[1] = false;

  for (ll i = 2; i <= n; i++) {
    if (is_prime[i]) {
      for (ll k = 2; i * k <= n; k++) {
        is_prime[i * k] = false;
      }
    }
  }
}

ll num[MAX_N];

void solve(ll n) {
  for (ll i = 1; i <= n; i++) {
    ll tmp = i;
    for (ll p = 2; p <= n; p++) {
      if (is_prime[p]) {
        while (tmp % p == 0) {
          tmp /= p;
          num[p]++;
        }
      }
    }
  }
}

ll ans(ll n) {
  ll res = 1;
  for (ll p = 2; p <= n; p++) {
    if (is_prime[p]) {
      res = mod(res * (num[p] + 1));
    }
  }
  return res;
}


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

  init(N);

  solve(N);

  cout << ans(N) << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
//#include "h.h"
using namespace std;

#define MOD 1000000007

#define ll long long
#define pint pair<int, int>
#define pll pair<ll, ll>
#define pb push_back
#define mp make_pair
#define pm(first, second) pb(mp(first, second))
#define SPACE " "
#define fpf first.first
#define fps first.second
#define spf second.first
#define sps second.second

#define all(X) (X).begin(), (X).end()

int main(){

	ll N, A;
	cin >> N >> A;
	vector<ll> X(N);
	for(ll i = 0; i < N; i ++)cin >> X[i];
	vector<vector<vector<ll>>> DP = vector<vector<vector<ll>>>(52, vector<vector<ll>>(52, vector<ll>(2551, 0)));
	DP[0][0][0] = 1;
	for(ll i = 0; i < N; i ++){
		for(ll j = 0; j < N; j ++){
			for(ll k = 0; k < N * 50 + 1; k ++){
				DP[i + 1][j + 1][k + X[i]] += DP[i][j][k];
				DP[i + 1][j][k] += DP[i][j][k];
			}
		}
	}
	ll ans = 0;
	for(ll i = 1; i < N + 1; i ++){
		ans += DP[N][i][A * i];
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 55296
#include <iostream>
#define REP(i, n) for (int i = 0; i < (n); i++)
using namespace std;
const int INF = 1001001001;

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

    int n;
    cin >> n;

    int a[n];
    REP(i, n)
        cin >> a[i];

    int ans = INF;
    REP(i, n) {
        int count = 0;
        while (a[i] % 2 == 0) {
            a[i] /= 2;
            count++;
        }
        if (count < ans)
            ans = count;
    }

    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 256
# coding: utf-8
# Your code here!

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

X = int(N/A)
Y = int(N/C)
KX = int()
KY = int()
if N%A==0:
   KX = X*B
   KY = (Y+1)*D
elif N%C==0:
    KX = (X+1)*B
    KY = Y*D
   
else:
    KX = (X+1)*B
    KY = (Y+1)*D

if KX>KY:
    print(KY)
else:
    print(KX)


Measured memory_bytes: 5600
# coding: utf-8
# Your code here!
while True:
    H,W=map(int,input().split())
    
    if H+W==0:
        break
    
    for i in range(H):
        for j in range(W):
            if i==0 or j==0 or i==H-1 or j==W-1:
                print('#',end='')
            else:
                print('.',end='')
        print()
    print()


Measured memory_bytes: 7004
// </> : towhid1zaman

#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;typedef vector<ll> vll;
#define fill(a) memset(a, 0, sizeof (a))
#define all(v) (v).begin(),(v).end()
#define sp(k) cout<<setprecision(k)<<fixed;
#define rep(i,a) for(int i=0; i<a;i++)
#define rep1(i,a,b) for(int i=(a);i<=(b);++i)
#define irep(i,b,a) for(int i=(b);i>=(a);--i)
#define minv(v) *min_element(v.begin(),v.end())
#define maxv(v) *max_element(v.begin(),v.end())
#define each(it,s) for(auto it = s.begin(); it != s.end(); ++it)
#define unq(v) sort(all(v)),(v).erase(unique((v).begin(),(v).end()),(v).end())
#define getpos(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define _ios ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define sqr(a) ((a)*(a))
#define sz(a) int(a.size())
#define ff first
#define ss second
#define pb push_back

const int INF = 1e9 + 10;
const double pi = acos(-1.0);
const int mod = 1000000007; // (int)1e9+7
const int maxn = 2000100;
bool is(string s){
    string t = s;
    reverse(all(s));
    return (t==s);
}
int main(){
        _ios;
        string s; cin >> s;
        int n = s.length();
        bool a=is(s);
        string st1=s.substr(0,(n-1)/2);
        string st2=s.substr((n+3)/2-1,n-1);
        bool b=is(st1);
        bool c=is(st2);
        if(a&&b&&c)
            cout<<"Yes"<<endl;
        else
            cout<<"No"<<endl;

return 0;
}








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

int main() {
  int X, A;
  cin >> X >> A;
  if(X < A){
    cout << 0 << endl;
  }else{
    cout << 10 << endl;
  }
}


Measured memory_bytes: 256
import java.util.*;
class Main{
public static void main(String[]args){
Scanner sc=new Scanner(System.in);
  String s=sc.next();
  int l=s.length();
  char prev=s.charAt(0);
  char nex='Z';
  int cnt=0;
  for(int i=1;i<l;i++){
    nex=s.charAt(i);
    if(prev!=nex){
      cnt++;
    }
    prev=nex;
  }
  System.out.println(cnt);   
}
}

Measured memory_bytes: 24148
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;
ll n, a[210000], res;
int main(void){
    // Your code here!
    cin >> n;
    for (ll i = 0; i < n; i++) cin >> a[i];
    sort(a, a + n);
    cout << a[n - 1] << ' ';
    ll ans = abs(a[0] * 2 - a[n - 1]);
    for (ll i = 0; i < n; i++) {
        if (ans > abs(a[i] * 2 - a[n - 1])) {
            ans = abs(a[i] * 2 - a[n - 1]);
            res = a[i];
        }
    }
    cout << res << endl;
}


Measured memory_bytes: 1024
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main()
{
    int n,a,b,i;
    scanf("%d %d %d",&n,&a,&b);
    if(a>b)
    {
        i=a;
        a=b;
        b=i;
    }
    i=1;
    while(1)
    {
        if(i%2==0)
        {
            if(b-1!=a)
                b=b-1;
            else
                break;
        }
        else
        {
            if(a+1!=b)
                a=a+1;
            else
                break;
        }
        i++;
    }
    if(i%2==0)
        printf("Alice");
    else
        printf("Borys");
    return 0;
}


Measured memory_bytes: 128
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)
	vs := make([]int, n)
	cs := make([]int, n)
	for i := range vs {
		fmt.Scan(&vs[i])
	}
	for i := range cs {
		fmt.Scan(&cs[i])
	}

	ans := 0
	for i, c := range cs {
		v := vs[i]
		if p := v - c; p > 0 {
			ans += p
		}
	}
	fmt.Println(ans)
}


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

int main(void){
    long n;
    cin >> n;
    for(long i=0; i<n; i++){
        long t;
        cin >> t;
        if(t%2==1){
            cout << "first" << endl;
            return 0;
        }
    }
    cout << "second" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>

using namespace std;

#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,N) for(long long i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define fi first
#define se second

#define PI acos(-1.0)
#define INF 10e15+9
#define EPS 1e-10
#define MAX_N 100100
#define MAX_M 100100

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<double, double> PD;
typedef pair<string, ll> PS;
typedef vector<ll> V;
typedef pair<P, char> PC;

ll n, x;

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

int main(){ 
	cin >> n >> x;
	cout << 3 * (n - gcd(n, x)) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define prArr(Arr,n) for(int _=0;_<n;_++)   cout<<(Arr)[_]<<" ";
using namespace std;
const int INF=(int)1e9+10;
const int MOD=(int)1e9+7;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    string a,b;
    cin>>n>>a>>b;
    for(int i=0;i<n;i++)
        cout<<a[i]<<b[i];
    return 0;
}


Measured memory_bytes: 256
dantai = int(input())
lis = []
for _ in range(1, dantai+1):
  lis.append(input())
cus = 0
for a in lis:
  b1, b2= a.split()
  cus = cus + (int(b2)-int(b1)) + 1
print(cus)
  

Measured memory_bytes: 3060
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Linq;

public class Program
{
    public static void Main()
    {
        var x = Console.ReadLine().Split();
        int a = int.Parse(x[0]);
        int b = int.Parse(x[1]);
        
        if (a == 1 || b == 1)
        {
            if (a == b)
            {
                Console.WriteLine("Draw");
            }
            else if (a == 1)
            {
                Console.WriteLine("Alice");
            }
            else if (b == 1)
            {
                Console.WriteLine("Bob");
            }
        }
        else
        {
            if (a == b)
            {
                Console.WriteLine("Draw");
            }
            else if (a > b)
            {
                Console.WriteLine("Alice");
            }
            else if (b > a)
            {
                Console.WriteLine("Bob");
            }
        }
    }
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(long long)(n);++i)
#define all(a) a.begin(), a.end()
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
const ll MOD=1e9+7;
const ll INF=1e18;
const int MAX=510000;
const double pi=acos(-1);
int dx[8] = {1,0,-1,0,1,1,-1,-1};
int dy[8] = {0,1,0,-1,-1,1,1,-1};
// int d[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false); 
  ll k;
  cin >> k;
  if(k==7){
    cout << 1 << endl;
    return 0;
  }
  else if(k%2==0){
    cout << -1 << endl;
    return 0;
  }
  else{
    ll now = 0;
    rep(i,k){
      ll res = modpow(10,i,k);
      now+=7*res;
      now%=k;
      if(now==0){
        cout << i+1 << endl;
        return 0;
      }
    }
  }
  cout << -1 << endl;
  return 0;
}


Measured memory_bytes: 3684
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c;
  cin >> a >> b >> c;
  if(a + b + c == 17){
    if(a == 5 && b == 5)
      cout << "YES" << endl;
    else if(a == 5 && c == 5)
      cout << "YES" << endl;
    else if(b == 5 && c == 5)
      cout << "YES" << endl;
    else
     cout << "NO" << endl;
  }
  else
    cout << "NO" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb emplace_back
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pint;

vector<int> g[100001];
int dfs(int r){
    vector<int> vi;
    rep(i,g[r].size()){
        vi.pb(dfs(g[r][i]));
    }
    int ret=vi.size();
    sort(vi.begin(),vi.end(),greater<int>());
    rep(i,vi.size()){
        ret=max(ret,vi[i]+i+1);
    }
    return ret;
}
int main(){
    int n,ai;
    cin>>n;
    FOR(i,1,n){
        cin>>ai;
        --ai;
        g[ai].pb(i);
    }
    int ans;
    ans=dfs(0);
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 15104
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const int INF = 1 << 30;

int numc(char c){
    rep(i, 9){
        if(c == '1'+i){
            return i+1;
        }
    }
    return 0;
}

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

    int len = s.length();
    int diffs = INF;
    rep(i, len-2){
        int a = numc(s.at(i))*100+numc(s.at(i+1))*10+numc(s.at(i+2));
        diffs = min(abs(753-a), diffs);
    }
    
    cout << diffs << endl;
    return 0;
}

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

#include <math.h>
#include <stdlib.h>


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

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

//INT_MAX	2,147,483,647 = 2*1.0e9



int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    int D, G; cin >> D >> G;
    vector<int> p(D);
    vector<int> c(D);
    for(int i = 0; i < D; i++) cin >> p[i] >> c[i];

    int ans = 1e9;
    for(int bit = 0; bit < (1<<D); bit++){
        int ansTmp = 0;
        int sumTmp = 0;
        for(int i = 0; i < D; i++){
            if(bit&(1<<i)){
                sumTmp += p[i] * (i+1) * 100;
                sumTmp += c[i];
                ansTmp += p[i];
            }
        }
        if(sumTmp < G){
            for(int i = 0; i<D; i++){
                int pos = D-1-i;
                if(!(bit&(1<<pos))){
                    int need = (G-sumTmp-1)/((pos+1)*100)+1;
                    if(need > p[pos]){
                        ansTmp=1e9;
                    } else {
                        ansTmp += need;
                        sumTmp += need * ((pos+1)*100);
                        break;
                    } 
                }
            }
        }

        if(ansTmp < ans && sumTmp >= G) ans = ansTmp;
    }

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


Measured memory_bytes: 256
def gcd(a,b):
  while b:a,b=b,a%b
  return a
n,a,b=int(input()),list(map(int,input().split())),[]
if n==2:print(max(a[0],a[1]))
elif n==3:print(max(gcd(a[0],a[1]),gcd(a[0],a[2]),gcd(a[1],a[2])))
else:
  no,mi=a[0],a[0]
  for i in range(1,n):
    s=gcd(no,a[i])
    if s!=no:
      no=max(s,mi)
      mi=gcd(s,mi)
  print(no)

Measured memory_bytes: 14076