akhauriyash/Code-Regression huggingface dataset:
using System;
using System.IO;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder.Contest.B
{
	class Program
	{
		public static void Main(string[] args)
		{
			var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
			Console.SetOut(sw);

			Scanner cin = new Scanner();
			int ans = 0;
			string s = cin.next();
			for (int i = 0; i < 3; i++)
			{
				if (s[i] == '1') ans++;
			}


			Console.WriteLine(ans);

			Console.Out.Flush();
		}
	}

	class Scanner
	{
		string[] s;
		int i;

		char[] cs = new char[] { ' ' };

		public Scanner()
		{
			s = new string[0];
			i = 0;
		}

		public string next()
		{
			if (i < s.Length) return s[i++];
			string st = Console.ReadLine();
			while (st == "") st = Console.ReadLine();
			s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
			if (s.Length == 0) return next();
			i = 0;
			return s[i++];
		}

		public int nextInt()
		{
			return int.Parse(next());
		}

		public int[] ArrayInt(int N, int add = 0)
		{
			int[] Array = new int[N];
			for (int i = 0; i < N; i++)
			{
				Array[i] = nextInt() + add;
			}
			return Array;
		}

		public long nextLong()
		{
			return long.Parse(next());
		}

		public long[] ArrayLong(int N, long add = 0)
		{
			long[] Array = new long[N];
			for (int i = 0; i < N; i++)
			{
				Array[i] = nextLong() + add;
			}
			return Array;
		}

		public double nextDouble()
		{
			return double.Parse(next());
		}

		public double[] ArrayDouble(int N, double add = 0)
		{
			double[] Array = new double[N];
			for (int i = 0; i < N; i++)
			{
				Array[i] = nextDouble() + add;
			}
			return Array;
		}
	}
}

Measured memory_bytes: 11092
#include <bits/stdc++.h>
//#pragma GCC optimize "-O3"
typedef unsigned long long ull;
typedef unsigned int ui;
typedef unsigned short us;
typedef long long ll;
typedef long double ld;
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const ll infll=(1ull<<63)-1,mod=1e9+7;
const int inf=(1ull<<31)-1;
int n,s=0;
vector<vector<pair<int,int>>> v(15);

int main()
{
	//freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
	ios_base::sync_with_stdio(false); cin.tie(0);cout.precision(18);
	cin>>n;
	for (int i=0,a;i<n;i++){
		cin>>a;
		v[i].resize(a);
		for (int j=0;j<a;j++)
			cin>>v[i][j].first>>v[i][j].second;
	}
	int k=(1<<n);
	for (int i=0;i<k;i++){
		int s1=0;
		for (int j=0;j<n;j++){
			bool q=true;
			if ((i>>j)&1){
				s1++;
				for (int l=0;l<v[j].size();l++){
					if (((i>>(v[j][l].first-1))&1)!=v[j][l].second){
						q=false;
						break;
					}
				}
			}
			if (!q){
				s1=0;
				break;
			}
		}
		s=max(s,s1);
	}
	cout<<s;
	return 0;
}

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

int main(){
    int a ,b;
    
    for(int i=0;i<4;i++){
        cin >> a >> b;
        if(a==1) cout << b*6000 << endl;
        if(a==2) cout << b*4000 << endl;
        if(a==3) cout << b*3000 << endl;
        if(a==4) cout << b*2000 << endl;
    }
    
    return 0;
}

Measured memory_bytes: 1160
#include <stdio.h>
int main(void){
    int n,m,sum=0;
    scanf("%d %d",&n,&m);
    int a[m];
    for(int i=0; i<m; i++){
        scanf("%d",&a[i]);
        sum+=a[i];
    }
    if(n>=sum)
        printf("%d",n-sum);
    else
        printf("-1");
}


Measured memory_bytes: 1756
/////////////////////////////////////////////////////////
//
//  c/temp.cpp file
//  Last Updated: 2018-10-23 ...Maybe
//
//    I hope you adding this code to the setting file
//    alias g++='g++ -std=c++1y -DDEBUG_LOCAL'
//
/////////////////////////////////////////////////////////

#include <bits/stdc++.h>

using namespace std;

#define fi first
#define se second
#define mp make_pair
#define pb push_back

//#define int long long

#define _overload3(_1,_2,_3,name,...) name
#define _REP(i,n) REAP(i,0,n)
#define REAP(i,a,b) for(int i=int(a);i<int(b);++i)
#define REP(...) _overload3(__VA_ARGS__,REAP,_REP,)(__VA_ARGS__)

#define _REPR(i,n) REAPR(i,n,0)
#define REAPR(i,a,b) for(int i=int(a-1);i>=int(b);--i)
#define REPR(...) _overload3(__VA_ARGS__,REAPR,_REPR,)(__VA_ARGS__)

#define ALL(a) a.begin(),a.end()
#define rALL(a) a.rbegin(),a.rend()

#define coutALL(a) {int loop_coutALL=0;for(auto e:a) cout<<(loop_coutALL++?" ":"")<<e; cout<<endl;}

#define coutYN(a) cout<<((a)?"YES":"NO")<<endl;
#define coutYn(a) cout<<((a)?"Yes":"No")<<endl;
#define coutyn(a) cout<<((a)?"yes":"no")<<endl;

#define pcnt __builtin_popcount
#define buli(x) __builtin_popcountll(x)

const int INF=1145141919;
//const long long INF=114514191911451419;
const int MOD=(int)1e9+7;
const double EPS=1e-12;
const int dx[]={1,0,-1,0},dy[]={0,1,0,-1};
//const int dx[]={-1,-1,-1,0,1,1,1,0},dy[]={-1,0,1,1,1,0,-1,-1};

using vi=vector<int>;
using vvi=vector<vi>;
using vs=vector<string>;

typedef pair<int,int> pii;
typedef pair<int,string> pis;
typedef pair<string,int> psi;
typedef pair<string,string> pss;

typedef long long ll;

template<typename T> istream &operator >> (istream &is, vector<T> &v){for(T &x:v) is>>x;return is;}
template<typename T> ostream &operator << (ostream &os, vector<T> &v){int i=0;for(T &x:v) os<<(i++?" ":"")<<x;return os;}

ll rev(ll n){ll x=0;for(;n>0;){x=x*10+n%10;n/=10;}return x;}

template<class T> ll upper(T n,T m){return (n+m-1)/m;};
template<class T> ll rounding(T n){return (long double)n+0.5;};

template<class T> bool inG(T x,T n){return 0<=x && 0<n;}
template<class T> bool outG(T x,T n){return x<0 || n<=x;}

inline int qp(int a,ll b){if(!b)return 1;int ans=1;do{if(b&1)ans=1ll*ans*a;a=1ll*a*a;}while(b>>=1);return ans;}
inline int qp(int a,ll b,int mo){if(!b)return 1;int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}

inline ll fac(ll k,ll n){ll a=1;for(int i=0;i<n;i++)a*=k--;return a;}
inline ll fac(ll k,ll n,int mo){ll a=1;for(int i=0;i<n;i++)a*=k--,a%=mo;return a;}

inline int dsum(ll n){int a=0;for(;n;n/=10)a+=n%10;return a;}

struct Arithmetic{Arithmetic(){cin.tie(0);ios::sync_with_stdio(0);cout<<fixed<<setprecision(20);}};

//#define DEBUG_LOCAL

#ifdef DEBUG_LOCAL
template<typename T> void deb(T a){cerr<<"deb: "<<a<<"です"<<endl;}
#define debl {cerr<<"debug: "<<__LINE__<<"行目だ"<<endl;}
void what_cr(){cout<<__GCC_ATOMIC_CHAR16_T_LOCK_FREE<<" ←？"<<endl;}
//ori_func S

//ori_func E
#else
template<typename T>void deb(T a){}
#define debl
void what_cr(){}void t_t(){}
#endif

signed main(){

  Arithmetic Exception;

  int a,b;
  cin>>a>>b;

  cout<<qp(100,a)*(b+b/100)<<endl;
  return 0;

}


Measured memory_bytes: 256
#import numpy as np

N = int(input())
A = list(map(int, input().split()))
A.sort()#わるほう

#kouho = sorted([x for x in set(A) if A.count(x) == 1])
#maxA = 10**5

#target = kouho[:]
maxA = A[-1]
work=[0]*(A[-1]+1)

for i in range(len(A)):
    maxN = int(maxA/A[i])
    for n in range(1,maxN+1):
        buf = A[i]*n
        #remove_list.append(buf)
        work[buf]+=1
            #print(A[i]*n)
#target = kouho[:]
#kouho = list(set(kouho) - set(remove_list))

sm=0
for s in A:
    if work[s]==1: sm+=1
print(sm)

#print(len(kouho))

Measured memory_bytes: 33280
# -*- coding: utf-8 -*-
import bisect
import sys
input = sys.stdin.readline


def main():
    n = int(input())
    l = list(map(int, input().split()))
    l = sorted(l)

    result = 0
    for i in range(n-2):
        for j in range(i + 1, n - 1):
            result += bisect.bisect_left(l, l[i] + l[j]) - (j + 1)

    print(result)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define int long long
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
signed main(){
  int n,x=0;
  cin>>n;
  for(int i=1;i<=n;i++){
    int a=0;
    for(int j=1;j<=i;j++)if(i%j==0)a++;
      if(i%2&&a==8)x++;
  }
  cout<<x<<endl;
}

Measured memory_bytes: 256
x1,x2,x3,x4,x5 = map(int,input().split())

if x1 == 0:
  print(1)
elif x2 == 0:
  print(2)
elif x3 == 0:
  print(3)
elif x4 == 0:
  print(4)
else:
  print(5)

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

using namespace std;

int main()
{
  while(1){
    int T,D,L;
    cin>>T;
    cin>>D;
    cin>>L;

    if(T == 0 && D == 0 && L == 0){
      break;
    }

    int lt = 0;
    int temp = 0;
    int times = 0;
    int check = 0;

    for(int i = 0;i < T;++i){
      cin>>temp;

      if(check == 0){
        if(temp >= L){
          lt = i;
          check = 1;
        }
      }
      else{
        if(temp >= L){
          times += i - lt;
          lt = i;
        }
        else{
          if(i - lt == D){
            times += D;
            check = 0;
          } 
          else if(i - lt < D && i == T - 1){
            times += i - lt;
          }
        }
      }
    }
    cout<<times<<endl;
  }
  return 0;
}



Measured memory_bytes: 3108
#include<stdio.h>
#include<string.h>
#pragma GCC optimize("O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define rep(i,N) for(int i=0;i<(int)N;i++)
const int pw[13]={1,3,9,27,81,243,729,2187,6561,19683,59049,177147,531441};
static inline void OUT(long x){if(x<0)putchar('-'),x=-x;if(x>=10)OUT(x/10);putchar(x%10+48);}
int main(void)
{
  int N,len,carry[200000],temp[531441],A[531441],add[531441];char T[200001];
  if(scanf("%d %s",&N,T)!=0)len=strlen(T);
  rep(i,N)
  {
    int flip=0;
    memset(add,0,pw[i]*sizeof(int));
    rep(j,len)
    {
      if(T[j]=='S'){flip^=1;}
      else
      {
        int x=carry[j];
        add[x]=(add[x]+(flip?2:1))%3;
        carry[j]+=(3-add[x])%3*pw[i];
      }
    }
    memcpy(temp,A,pw[i]*sizeof(int));
    rep(c,3){rep(j,pw[i])A[c*pw[i]+j]=temp[j]+(flip?2:1)*(c+add[j])%3*pw[i];}
  }
  rep(i,pw[N])OUT(A[i]),putchar(' ');
}

Measured memory_bytes: 8388
s=input()
s=s[::-1]
md=[0]
ex10=1
tmp=0
mod=2019
for i in range(len(s)):
    tmp+=ex10*int(s[i])
    tmp%=mod
    md.append(tmp)
    ex10*=10
    ex10%=mod
from collections import Counter

sc= Counter(md)
ans=0
for k in sc:
    sck=sc[k]
    ans+= sck*(sck-1)//2
print(ans)

Measured memory_bytes: 76088
/* template.cpp {{{ */
#include <bits/stdc++.h>
using namespace std;
#define get_macro(a, b, c, d, name, ...) name
#define rep(...) get_macro(__VA_ARGS__, rep4, rep3, rep2, rep1)(__VA_ARGS__)
#define rrep(...) get_macro(__VA_ARGS__, rrep4, rrep3, rrep2, rrep1)(__VA_ARGS__)
#define rep1(n) rep2(i_, n)
#define rep2(i, n) rep3(i, 0, n)
#define rep3(i, a, b) rep4(i, a, b, 1)
#define rep4(i, a, b, s) for (ll i = (a); i < (ll)(b); i += (ll)(s))
#define rrep1(n) rrep2(i_, n)
#define rrep2(i, n) rrep3(i, 0, n)
#define rrep3(i, a, b) rrep4(i, a, b, 1)
#define rrep4(i, a, b, s) for (ll i = (ll)(b) - 1; i >= (ll)(a); i -= (ll)(s))
#define each(x, c) for (auto &&x : c)
#define fs first
#define sc second
#define all(c) begin(c), end(c)
using ui = unsigned;
using ll = long long;
using ul = unsigned long long;
using ld = long double;
const int inf = 1e9 + 10;
const ll inf_ll = 1e18 + 10;
const ll mod = 1e9 + 7;
const ll mod9 = 1e9 + 9;
const int dx[]{-1, 0, 1, 0, -1, 1, 1, -1};
const int dy[]{0, -1, 0, 1, -1, -1, 1, 1};
template<class T, class U> void chmin(T &x, const U &y){ x = min<T>(x, y); }
template<class T, class U> void chmax(T &x, const U &y){ x = max<T>(x, y); }
struct prepare_ { prepare_(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(12); } } prepare__;
/* }}} */

int main(){
  string s;
  cin >> s;
  int res = 0;
  rep(i, 1, s.size()){
    res += s[i - 1] != s[i];
  }
  cout << res << endl;
}



Measured memory_bytes: 512
//              +-- -- --++-- +-In the name of ALLAH-+ --++-- -- --+              \\

#include <bits/stdc++.h>

#define F first
#define S second
#define _sz(x) (int)x.size()

using namespace std ;
using ll = long long ;
using ld = long double ;
using pii = pair <int , int> ;

const int N = 200 + 5 , M = 1e5 + 20 , mod = 1e9 + 7 ;
int n , x , a[N] , dp[N][M] , ans ;

inline void add (int &a , int b) {
	a += b ;
	if (a >= mod) a -= mod ;
}

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

	cin >> n >> x ;

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

	sort(a , a + n , greater<int>()) ;


	dp[0][x] = 1 ;

	for (int i = 0 ; i < n ; i ++) {
		for (int j = 0 ; j <= x ; j ++) add(dp[i + 1][j % a[i]] , dp[i][j]) ;

		for (int j = 0 ; j <= x ; j ++) {
			add(dp[i + 1][j] , 1ll * (n - i - 1) * dp[i][j] % mod) ;
		}
	}

	for (int i = 0 ; i <= x ; i ++) add(ans , 1ll * i * dp[n][i] % mod) ;

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


Measured memory_bytes: 79744
def main():
    s = input()
    t = input()

    ans = len(t)
    for i in range(len(s) - len(t) + 1):
        match_count = 0
        for ti, c in enumerate(t):
            if s[i + ti] == c:
                match_count += 1
                ans = min(len(t) - match_count, ans)

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 67728
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;cin>>n;
  int64_t mod=1000000007;
  vector<int64_t>a(n);
  int64_t sum=0;
  int64_t ans=0;
  for(int i=0;i<n;i++){
    cin>>a.at(i);
    sum+=a.at(i);
  }
  int64_t tmp;
  for(int i=0;i<n-1;i++){
    sum-=a.at(i);
    tmp=sum;
    tmp%=mod;
    tmp*=a.at(i);
    tmp%=mod;
    ans+=tmp;
    ans%=mod;
  }
  cout<<ans<<endl;
}

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

//ただの辺
struct edge {
    using lint = long long int;
    int to;
    lint cost;
    //引数一つの時は距離1
    edge(int t, lint c = 1) : to(t), cost(c) {
    }
};

// 木のlcaをキビキビ計算
// depend:edge
struct lowest_common_ancestor {
    using G = vector<vector<edge>> &;
    G g;
    int sz;
    int root;
    int log;
    vector<int> dep;
    vector<vector<int>> parent;
    lowest_common_ancestor(G _g, int _root)
        : g(_g), sz(_g.size()), root(_root), dep(_g.size()) {
        log = 1;
        while (1 << log < sz) log++;
        parent.assign(log, vector<int>(sz, -1));
    }
    // parent[0]埋め、深さ埋め
    void dfs(int now, int p, int d) {
        parent[0][now] = p;
        dep[now] = d;
        for (int i = 0; i < (int)g[now].size(); i++) {
            int next = g[now][i].to;
            if (next != p) dfs(next, now, d + 1);
        }
    }
    // 前計算を済ませる O(nlog n)
    void build() {
        dfs(root, -1, 0);
        for (int i = 1; i < log; i++) {
            for (int j = 0; j < sz; j++) {
                if (parent[i - 1][j] == -1)
                    parent[i][j] = -1;
                else
                    parent[i][j] = parent[i - 1][parent[i - 1][j]];
            }
        }
    }
    // uとvのlcaを求める O(log sz)
    int query(int u, int v) {
        if (dep[u] > dep[v]) swap(u, v);
        for (int i = 0; i < log; i++) {
            if ((dep[v] - dep[u]) & (1 << i)) v = parent[i][v];
        }
        if (u == v) return u;
        for (int i = log - 1; i >= 0; i--) {
            if (parent[i][u] != parent[i][v])
                u = parent[i][u], v = parent[i][v];
        }
        return parent[0][u];
    }
    // 頂点の深さ
    int depth(int u) {
        return dep[u];
    }
    // uからnだけ遡る
    int root_back(int u, int n) {
        if (n > (1 << (log - 1))) return -1;
        for (int i = 0; (1 << i) <= n; i++) {
            if ((n >> i) & 1) u = parent[i][u];
        }
        return u;
    }
    // u,v間の距離
    int dist(int u, int v) {
        return depth(u) + depth(v) - 2 * depth(query(u, v));
    }
};

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

int main() {
    int n, u, v;
    cin >> n >> u >> v;
    u--, v--;
    vector<vector<edge>> g(n);
    for (int i = 0; i < n - 1; i++) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    lowest_common_ancestor lca(g, v);
    lca.build();
    int ans = 0;
    // 高橋くんは葉iまで行きたい
    for (int i = 0; i < n; i++) {
        if (g[i].size() > 1) {
            continue;
        }
        int l = lca.query(i, u);
        if (lca.dist(l, u) >= lca.dist(l, v)) {
            continue;
        }
        chmax(ans, lca.depth(i) - 1);
    }
    cout << ans << endl;
}

Measured memory_bytes: 17400
N,M = list(map(int, input().split()))

ans = 1

for i in range(2,100000):
    ans += i*((1-(1/(2**M)))**(i-1))

if int(ans*((N-M)*100+M*1900)/(2**M))%10 == 0:
    print(int(ans*((N-M)*100+M*1900)/(2**M)))
else:
    print(int(ans*((N-M)*100+M*1900)/(2**M))+1)



Measured memory_bytes: 3188
#include <set>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <algorithm>
using std::min; using std::max;
using std::swap; using std::sort;
typedef long long ll;

template<typename T>
void read(T &x) {
	int flag = 1; x = 0; char ch = getchar();
	while(ch < '0' || ch > '9') { if(ch == '-') flag = -flag; ch = getchar(); }
	while(ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar();
	x *= flag;
}
#if __cplusplus >= 201103l
template<typename T, typename... V>
void read(T &x, V&... v) { read(x), read(v...); }
#endif

const int _ = 2e5 + 10, Inf = 2e9 + 10;
int n, rmx, rmn = Inf, bmx, bmn = Inf; ll ret;
std::multiset<int> r, b;

struct node {
	int v1, v2;
	node() {}
	node(int _v1, int _v2) { v1 = _v1, v2 = _v2; }
	bool operator < (const node &a) const { return v1 < a.v1; }
} p[_];

ll calc() { return 1ll * (*r.rbegin() - *r.begin()) * (*b.rbegin() - *b.begin()); }

int main () {
	read(n);
	for(int i = 1, x, y; i <= n; ++i) {
		read(x, y); if(x > y) swap(x, y);
		p[i] = node(x, y), r.insert(x), b.insert(y);
	}
	ret = calc(), sort(p + 1, p + n + 1);
	for(int i = 1; i <= n; ++i) {
		int x = p[i].v1, y = p[i].v2;
		r.erase(r.find(x)), b.erase(b.find(y));
		r.insert(y), b.insert(x);
		ret = min(ret, calc());
	}
	printf("%lld\n", ret);
	return 0;
} 

Measured memory_bytes: 20608
n, k = map(int, input().split())
s = list(str(input()))

L = []
cur = s[0]
cnt = 0
for i in range(n):
    if s[i] == cur:
        cnt += 1
    else:
        L.append((cnt, int(cur)))
        cnt = 1
        cur = s[i]
else:
    L.append((cnt, int(cur)))

#print(L)

t = 0
S = 0
C = 0
ans = 0
for s in range(len(L)):
    while C <= k and t < len(L):
        if C == k and L[t][1] == 0:
            break
        S += L[t][0]
        if L[t][1] == 0:
            C += 1
        t += 1
    #print(S, C)
    ans = max(ans, S)
    if s == t:
        t += 1
    else:
        S -= L[s][0]
        if L[s][1] == 0:
            C -= 1
print(ans)

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

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

using ll = long long;
using namespace std;

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

    cout << (s[2] == s[3] && s[4] == s[5] ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
Scanf.scanf "%d" (fun n ->
    let hist = Array.make 100001 0 in
    for i = 1 to n do
        Scanf.scanf " %d" (fun a -> hist.(a) <- hist.(a) + 1)
    done;
    let rec loop i odd even =
        if i = 0 then Printf.printf "%d\n" (odd + even - (even mod 2)) else
            let odd  = if hist.(i) mod 2 = 1                  then odd + 1 else odd  in
            let even = if hist.(i) mod 2 = 0 && hist.(i) > 0 then even + 1 else even in
            loop (i - 1) odd even
    in
    loop 100000 0 0
)

Measured memory_bytes: 5248
#include<iostream>
using namespace std;
int main(){
  int a,b;cin>>a>>b;
  int ans=0;
  for(int i=0;i<=a;i++){
    for(int j=0;j<=a;j++){
      if(i+j<=b&&(b-(i+j))<=a)ans++;
    }
  }
  cout<<ans<<endl;
  return 0;
}


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

using namespace std;

#define FOR(i,n) for(int i=0; i<n; ++i)
#define FORR(i,a,n) for(int i=a; i<n; ++i)
#define ALL(c) (c).begin(), (c).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
 
//int in() { int x; scanf("%d", &x); return x; }
//ll lin() { ll x; scanf("%lld", &x); return x; }
void printfv(VI a){ int n = a.size(); FOR(i, n) cout << a[i] << " "; }

int main(void){

	int n, a, b;

	cin >> n >> a >> b;

	cout << min(n*a, b);
    return 0;
}


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

def rev(n,mod=(10**9+7)):
    ni = n
    nm = 1
    m2 = mod-2
    while m2 > 0:
        if m2&1:
            nm = (nm*ni)%mod
        m2 >>= 1
        ni = (ni**2)%mod
    return nm

#素因数分解
def factorization(n):
    d = dict()
    ni = n
    pn = 2
    t = 0
    while pn**2 <= n and ni > 1:
        if ni%pn == 0:
            t += 1
            ni //= pn
        else:
            if not t == 0:
                d[pn] = t
                t = 0
            if pn == 2:
                pn = 3
            else:
                pn += 2
    if t > 0:
        d[pn] = t
    if ni > 1:
        d[ni] = 1
    return d

def main():
    n = int(ipt())
    ans = 0
    a = [int(i) for i in ipt().split()]
    d = defaultdict(int)
    for i in a:
        ans += rev(i)
        di = factorization(i)
        for ki,vi in di.items():
            d[ki] = max(d[ki],vi)
        ans %= mod

    for ki,vi in d.items():
        ans *= pow(ki,vi,mod)
        ans %= mod

    print(ans)

    return None

if __name__ == '__main__':
    main()


Measured memory_bytes: 10764
K = 4000
A = input()
B = input()
C = input()
la, lb, lc = len(A), len(B), len(C)

def check(S, T):
    R = [1] * (K * 2 + 1)
    for i in range(-len(T), len(S)):
        for j in range(max(i, 0), min(len(S), len(T)+i)):
            if S[j] != T[j-i] and S[j] != "?" and T[j-i] != "?":
                R[i] = 0
                break
    return R

AB = check(A, B)
AC = check(A, C)
BC = check(B, C)

mi = K * 3
for i_ab in range(-K, K + 1):
    if AB[i_ab] == 0: continue
    for i_ac in range(max(-K, min(i_ab, 0) - lc), min(K + 1, max(la, i_ab + lb))):
        if AC[i_ac] == 0: continue
        if BC[i_ac - i_ab] == 0: continue
        mi = min(mi, max(i_ab + lb, i_ac + lc, la) - min(i_ab, i_ac, 0))

print(mi)

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

namespace ConsoleApp11
{
    class Class75
    {
        static void Main()
        {
            int x = int.Parse(Console.ReadLine());
            int ans = 0;
            int count;
            for(count=1; ; count++)
            {
                ans += count;
                if (ans >= x) break;
            }
            Console.WriteLine(count);
        }
    }
}


Measured memory_bytes: 11092
#include <stdio.h>

int main(void){

	int i,n,minv,maxv,R[200000];
	
	scanf("%d",&n);
	
	for(i=0;i<n;i++){
		scanf("%d",&R[i]);
	}
	
	minv=R[0];
	maxv=-2000000000;
	
	for(i=1;i<n;i++){
		if(maxv<(R[i]-minv)){
			maxv=R[i]-minv;
		}
		
		if(minv>R[i]){
			minv=R[i];
		}
	}
	printf("%d\n",maxv);
	
	return 0;
}


Measured memory_bytes: 2548
#include <bits/stdc++.h>
using namespace std;
using ll =long long;
#define all(v) v.begin(),v.end()
 
int main() {
 string A,B;
  cin>>A>>B;
  if(A.size()>B.size()) {
cout<<"GREATER"<<endl;
    return 0;
  }
  else if(A.size()<B.size()) {
cout<<"LESS"<<endl;
    return 0;
  }
  
  
  for(ll i=0;i<A.size();i++) {
if(A[i]>B[i]) {
cout<<"GREATER"<<endl;
  return 0;
}
    else if(A[i]<B[i]) {
cout<<"LESS"<<endl;
      return 0;
    }
  }
  
  
  cout<<"EQUAL"<<endl;
}
  
 
  


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

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

    int n, m;
    cin >> n >> m;

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

    vector<vector<int64_t>> s(3, vector<int64_t>(m + 2));
    for (int i = 1; i < n; i++) {
        int d = a[i] - a[i - 1];

        if (d > 0) {
            s[1][0] += d;
            s[2][a[i - 1] + 2] += -1;
            s[2][a[i] + 1] -= -1;
            s[1][a[i] + 1] -= -1 * (d - 1);

        } else {
            d += m;

            s[1][0] += a[i] + 1;
            s[1][a[i] + 1] -= a[i] + 1;
            s[2][1] += -1;
            s[2][a[i] + 1] -= -1;
            s[1][a[i] + 1] -= -1 * a[i];

            s[1][a[i] + 1] += d;
            s[2][a[i - 1] + 2] += -1;
        }
    }

    for (int k = 1; k >= 0; k--) {
        int64_t c = 0;
        for (int j = 0; j < m; j++) {
            s[k][j] += (c += s[k + 1][j]);
        }
    }

    cout << *min_element(&s[0][0], &s[0][m]) << endl;

    return 0;
}

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

alph = ['z', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j',\
     'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w',\
         'x', 'y']

seq = []

while N > 0:
    s = N % 26
    N  = (N - 1) // 26
    seq.append(s)
L = len(seq)

name = ''

for i in range(L):
    name = alph[seq[i]] + name

print(name)

Measured memory_bytes: 9196
#include <stdio.h>
int main()
{
  char a[3];
  int i,b=0,c=0,d=0;
  
  scanf("%s",a);
  
  for(i=0;i<3;i++){
   if(a[i]=='a')  b++;
      else if (a[i]=='b')  c++;
         else if (a[i]=='c')  d++;
  }
 
  if(b==1&&c==1&&d==1)
       printf("Yes\n");
     else printf("No\n");           
  return 0;
}

Measured memory_bytes: 128
N = int(input())
x = []
y = []
words = []
for i in range(N):
  A = int(input())
  W = []
  for _ in range(A):
    x, y = map(int, input().split())
    W.append([x-1, y])
  words.append(W)
  
ans = 0
for bit in range(1<<N):
  ok = True
  is_honest = [(bit>>i) & 1 for i in range(N)]
  for i in range(N):
    if not is_honest[i]:
      continue
    for x, y in words[i]:
      if is_honest[x] != y:
        ok = False
  if ok:
    ans = max(ans, sum(is_honest))
print(ans)

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

using namespace std;

int main() {
    string s, t;
    cin >> s >> t;
    sort(s.begin(), s.end());
    sort(t.begin(), t.end(), greater <char>());
    if (s < t)
        puts("Yes");
    else
        puts("No");
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main{
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		HashMap<String, String> hm = new HashMap<String, String>();
		hm.put("Sunny", "Cloudy");
		hm.put("Cloudy", "Rainy");
		hm.put("Rainy", "Sunny");
		System.out.println(hm.get(sc.next()));
	}
}

Measured memory_bytes: 22100
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long LL;
 
LL mod = 1000000007;

int main()
{
	LL a, b, k;
	cin >> a >> b >> k;

	if (a > k) {
		a -= k;
		k = 0;
	}
	else {
		k -= a;
		a = 0;
	}

	if (b > k) {
		b -= k;
		k = 0;
	}
	else {
		k -= b;
		b = 0;
	}

	cout << a << " " << b << endl;


}

Measured memory_bytes: 256
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import collections


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

    result = collections.deque()

    for i in range(N):
        if i % 2 == N % 2:
            result.append(A[i])
        else:
            result.appendleft(A[i])
    print(*result)


if __name__ == "__main__":
    main()


Measured memory_bytes: 25412
#include <bits/stdc++.h>
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define ll long long
#define LEFT(a) ((a)<<1)
#define RIGHT(a) (LEFT(a) + 1)
#define MID(a,b) ((a+b)>>1)
#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
//#define temo

using namespace std;
const int N = 300000;


int main()
{
    int x, y;
    cin>>x>>y;
    cout<<x+y/2<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vvl = vector<vl>;
using vi = vector<int>;
using vvi = vector<vi>;
#define ote(x) cout<<(x)<<endl
#define all(x) (x).begin(),(x).end()
#define rp(i,s,e) for(int i=(s);i<(e);++i)
#define rpz(i,e) rp(i,0,e)

bool isprime(ll p){
	if(p <= 1L) return false;
	for(ll i=2L; i*i<=p; ++i) if(p%i == 0) return false;
	return true;
}


int main(){
	ll X; cin>>X;
	for(ll i=X;i<<X*X; i++){
		if(isprime(i)){
			ote(i);
			return 0;
		}
	}
}


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

/* constant */

#define MOD     (100000)

/* typedef */

/* global variables */

static int dp[50][3001];

/* subroutines */

/* main */

int main(int argc, char **argv) {
  int i, j, k, m, n, nn, s;

  for (;;) {
    scanf("%d%d%d", &n, &m, &s);
    if ((n | m | s) == 0) break;

    nn = n * n;

    memset(dp, 0, sizeof(dp));
    dp[0][0] = 1;

    for (i = 1; i <= m; i++)
      for (j = nn; j >= 1; j--)
        for (k = i; k <= s; k++)
          dp[j][k] = (dp[j][k] + dp[j - 1][k - i]) % MOD;

    printf("%d\n", dp[nn][s]);
  }

  return 0;
}

Measured memory_bytes: 1192
/**
 * @author      : omgursocute
 * @file        : 149/A.cpp
 * @created     : 30/12/2019
 */

#include <bits/stdc++.h>

using namespace std;

typedef int64_t ll;
typedef uint64_t ull;
typedef long double ld;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	
	string s, t;
	cin >> s >> t;
	cout << t << s;
	
	return 0;
}



Measured memory_bytes: 256
import statistics
n = int(input())
arraya = []
arrayb = []
for i in range(n):
    a,b = map(int, input().split())
    arraya.append(a)
    arrayb.append(b)

min_median = statistics.median(arraya)
max_median = statistics.median(arrayb)
if n%2 == 0:
    print(int((max_median - min_median)//0.5 + 1))
else:
    print(int(max_median - min_median + 1))

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

#define int long long
#define INF 1e18

signed main() {
    int a, b, k; cin >> a >> b >> k;
    for(int i = a; i <= min(a + k - 1, b); i++) cout << i << endl;
    for(int i = max(a + k, b - k + 1); i <= b; i++) cout << i << endl;

}


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

int main( void )
{
  int A, B, C, X;
  cin >> A >> B >> C >> X;
  int count = 0;

  for( int i = 0; i <= A; i++ )
    for( int j = 0; j <= B; j++ )
      for( int k = 0; k <= C; k++ )
	if( i * 500 + j * 100 + k * 50 == X )
	  count++;

  cout << count << endl;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll mod = 1e9 + 7;
const ll inf = (1 << 30) - 1;
const ll infll = (1LL << 61) - 1;

ll a[5], n, b[6], m = infll, ind;

int main()
{
    cin >> n;
    for (int i = 0; i < 5; i++)
    {
        cin >> a[i];
        m = min(a[i], m);
    }
    cout << (n + m - 1) / m + 4 << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
int main ()
{
    int book[105]={0};
    int i,k,n;
    scanf("%d %d",&n,&k);
    while(k--)
    {
        scanf("%d",&i);
        int tmp;
        while(i--)
        {
            scanf("%d",&tmp);
            book[tmp]++;
        }
    }
    int sum=0;
    for(i=1;i<=n;i++)if(book[i]==0)sum++;
    printf("%d",sum);
    return 0;
}


Measured memory_bytes: 1736
(X, Y, Z, K) = gets.split.map(&:to_i)
data = []
3.times do
  data << gets.split.map(&:to_i)
end
ab = data[0].product(data[1]).map do |x, y|
  x + y
end.sort.reverse[0, K]
abc = ab.product(data[2]).map do |e, z|
  e + z
end.sort.reverse[0, K]
abc.each do |r|
  puts r
end

Measured memory_bytes: 286928
#include <bits/stdc++.h>
#define LOCAL
using namespace std;
template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
out << "(" << a.first << "," << a.second << ")";
return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');
cerr.write(names, comma - names) << ": " << arg1 << " |";
__f(comma + 1, args...);
}
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
#define int long long
using P = pair<int,int>;
//#########################################
signed main(){
    string s,t;cin >> s >> t;
    int n = s.size();
    int m = t.size();
    int ind = 0;
    int cnt = 0;
    vector<int> a(26);
    rep(i,n)a[s[i] - 'a']++;
    rep(i,m){
        if(a[t[i] - 'a'] == 0){
            cout << -1  << endl;
            return 0;
        }
    }
    vector<set<int>> st(26);
    rep(i,n)st[s[i] - 'a'].insert(i);
    rep(i,m){
        auto tmp = st[t[i]-'a'].lower_bound(ind);
        //trace(i,t[i],ind,*tmp,cnt);
        if(tmp != st[t[i] - 'a'].end()){
            ind = *tmp;
            
        }
        else{
            cnt++;
            ind = *st[t[i] - 'a'].begin();
        }
        //trace(i,t[i],ind,*tmp,cnt,ind);
        ind++;
        

    }
    int ans = cnt*n + ind;
    cout << ans  << endl;
    return 0;
}

Measured memory_bytes: 8536
n, k = map(int, input().split())
r,s,p = map(int, input().split())
point = {}
can_win = {}
point["r"] = r
point["s"] = s
point["p"] = p
can_win["r"] = "p"
can_win["s"] = "r"
can_win["p"] = "s"
t = input()
acc = [0 for i in range(n + k + 10)]
ans = 0
pattern = ""
for i in range(n):
    pattern += (can_win[t[i]])
ans = 0
pattern = list(pattern)
for i in range(n):
    if i - k < 0:
        ans += point[pattern[i]]
    else:
        if pattern[i] == pattern[i-k]:
            pattern[i] = "q"
            continue
        else:
            ans += point[pattern[i]]
print(ans)



Measured memory_bytes: 5500
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define MOD 1000000007
using namespace std;


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    char c;
    cin >> c;
    cout << (char)(c+1) << "\n";
    return 0;
}



Measured memory_bytes: 256
n, d = map(int, input().split())
x=[]
for i in range(n):
    x.append([int(x) for x in input().split()])

from math import sqrt
ans=0

for i in range(n-1):
    for j in range(i+1,n):
        forsq=0
        for k in range(d):
            forsq += (x[i][k] - x[j][k])**2
        a = (sqrt(forsq))
        if a.is_integer():
            ans+=1

print(ans)

Measured memory_bytes: 9164
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using std::cerr;
using std::cin;
using std::cout;
using std::endl;

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

  int n;
  std::string s;
  cin>>n>>s;

  int cum_sharp[200001]={};
  int cum_dot[200001]={};
  for(int i=1;i<=n;i++){
    if(s[i-1]=='#'){
      cum_sharp[i]=cum_sharp[i-1]+1;
      cum_dot[i]=cum_dot[i-1];
    }else{
      cum_sharp[i]=cum_sharp[i-1];
      cum_dot[i]=cum_dot[i-1]+1;
    }
  }

  int result=INT32_MAX;
  for(int dot_end=0;dot_end<=n;dot_end++){
    int change_left=cum_sharp[dot_end];
    int change_right=cum_dot[n]-cum_dot[dot_end];
    int change_sum=change_left+change_right;
    result=std::min(result,change_sum);
  }
  cout<<result<<endl;


  return 0;
}


Measured memory_bytes: 2804
#include<stdio.h>
int main(void)
{
    int n,i,j,s,ans=0;
    scanf("%d",&n);
    for(i=1;i<=n;i+=2){
        s=0;
        for(j=1;j<=i;j++){
            if(i%j==0)
                s++;
        }
        if(s==8)
            ans++;
    }
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pii pair<int,int>
#define mx INT_MAX
#define mn INT_MIN
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define itr set<int> :: iterator
#define map_itr map<int,int> :: iterator
const int mod = 1e9+7;
int n;

vector<vector<int> > a(22, vector<int> (22));
int ALL_WOMEN;

int main(){
    // ******* START HERE ******
    
    cin>>n;
    ALL_WOMEN = (1<<n);
    for(int i=0; i<n; i++){
      for(int j=0; j<n; j++){
          cin>>a[i][j];
      }
    }
    
    vector<int> dp(ALL_WOMEN);

    dp[0] = 1;

    for(int mask=0; mask<ALL_WOMEN-1; mask++){
      int i = __builtin_popcount(mask);
       for(int j=0; j<n; j++){
          if(a[i][j]==1 && !(mask&(1<<j)) ){
            int m2 = mask^(1<<j);
            dp[m2] = (dp[m2] + dp[mask])%mod;
          }
       }
    }

    cout<<dp[ALL_WOMEN-1]<<endl;
    // ***** END HERE ***** 
    return 0;
}

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


int compare_int(const void *a, const void *b)
{
//    return *(int*)a - *(int*)b;
    return *(long long*)a - *(long long*)b;
}
//  qsort(A, b, sizeof(int), compare_int);

//long long  factorial(long long n) {
//    if (n > 0) {
//        return n * factorial(n - 1);
//    } else {
//        return 1;
//    }
//}
long long  factorial(long long n, long long depth) {
    if (n > 1) {
        depth++;
        return factorial(n / 2, depth);
    } else {
        return depth;
    }
}

int min(int a, int b) {
    if (a > b)
        return b;
    else
        return a;
}

int distance(int a, int b) {
  return abs(a-b)*abs(a-b);
}



//int ()
/*
int triangle(int a, int b, int c){
  if(a<b+c){
    if(b<c+a){
      if(c<a+b){
        printf("1\n");
        return 1;
      }
    }
  }
  printf("1\n");
  return 0;
}
*/

int main()
{
//  int  a ,b, c, d, e, X, Y ,r;
  long long  a, b, c, d, e, X, Y;
  //  double  c;
 long long  A[200003]={};
//  int  A[100003]={};
  int  B[100003]={};
  long long  C[100003][100001]={};

  int  flg=0;

//  char s[101][101]={};
  char s[100001]={};
  char t[100001]={};
//  int N, M;
//  int A[1000000001]={};
//  long long  C[101]={};
  int i,j,k;
  long long p=0,q=0;
//  int flag=0;
//  int tmp=0;
//  char tmp[101]={};
//  long long min=10000000000;
//  long long min=100000001;
  long long min =100000001;
  int len=0;
  int l=0;
//  int r=1000001;
  int cnt=0;
  int num=0;
  int num1=0;
  int num2=0;
  long long  ans=0;
  int ans_ac=0;
  int ans_wa=0;
  int max=0;
  long long sum=0;
  int addr=0;
  int ptn=0;
  int  tmp=0;
  double per=0; 
//  bool on_off[100]={};
  
//  char alp[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};

  //  a=0;
  scanf("%lld", &a );


  
  printf("%lld\n", (a+1)/2); 
  
return 0;
}


Measured memory_bytes: 128
#[allow(unused_imports)]
use std::io;

#[allow(unused_macros)]
macro_rules! get {
    ($i:ident) => {
        let mut $i = String::new();
        io::stdin().read_line(&mut $i).ok();
    };
}

#[allow(unused_macros)]
macro_rules! to_vec {
    ($s:ident, $t:ty) => {
        $s.split_whitespace().map(|i| i.parse().ok().unwrap()).collect::<Vec<$t>>()
    }
}

#[allow(unused_macros)]
macro_rules! parse {
    ($s:ident, $t:ty) => {
        $s.trim().parse::<$t>().ok().unwrap()
    }
}

#[allow(unused_macros)]
macro_rules! max {
    ($v:ident) => {
        $v.iter().max().unwrap()
    };
}

#[allow(unused_mut)]
fn main() {
    get!(s);
    let n = parse!(s, i32);
    get!(s);
    let mut v: Vec<f64> = to_vec!(s, f64);
    v.sort_by(|a, b| a.partial_cmp(b).unwrap());
    v.reverse();
    let mut ans: f64 = 0.0;
    for _i in 0..(n-1) {
        let a = v.pop().unwrap();
        let b = v.pop().unwrap();
        ans = (a + b) / 2.0;
        v.push(ans);
    }
    println!("{}", ans);
}

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

const int MAXN = 1e5 + 10;
const int INF = 2*1e9;

int dp[MAXN],N,K,h[MAXN];

int main(){

	scanf("%d %d",&N,&K);
	for(int i = 1;i<=N;i++){
		scanf("%d",&h[i]);
	}

	for(int i = 2;i<=N;i++){
		dp[i] = INF;
		for(int j = i-1;j>=max(i - K,1);j--){
			dp[i] = min(dp[i], dp[j] + abs(h[i] - h[j]) );
		}
	}

	printf("%d\n",dp[N]);

	return 0;

}

Measured memory_bytes: 1024
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <map>
#include <set>
#include <vector>
#include <queue>
#include <cmath>
#define rint register int
#define LL long long
#define P 998244353
#define MAXN 10005
using namespace std;

int n, g, tot, pri[MAXN], vis[MAXN], a[MAXN], b[MAXN];

set<int> ans;
set<int>::iterator it;



bool check(int p)
{
	for(rint i=0; i<=p-1; ++i) b[i]=0;
	for(rint i=0; i<=n; ++i) b[i%(p-1)]=(b[i%(p-1)]+a[i])%p;
	for(rint i=0; i<=p-1; ++i)
		if(b[i]) return false;
	return true;
}

void init()
{
	for(rint i=2; i<=n; ++i)
	{
		if(!vis[i]) pri[++tot]=i;
		for(rint j=1; j<=tot && pri[j]*i<=n; ++j)
		{
			vis[pri[j]*i]=1;
			if(i%pri[j]==0) break;
		}
	}
}

int main()
{
	scanf("%d", &n);
	init();
	for(rint i=n; i>=0; --i)
	{
		scanf("%d", &a[i]);
		g=__gcd(abs(a[i]), g);
	}
	for(rint i=2; i*i<=g; ++i)
	{
		if(g%i) continue;
		ans.insert(i);
		while(g%i==0) g/=i;
	}
	if(g>1) ans.insert(g);
	for(rint i=1; i<=tot; ++i)
	{
		if(a[0]%pri[i]) continue;
		if(check(pri[i])) ans.insert(pri[i]);
	}
	for(it=ans.begin(); it!=ans.end(); ++it) printf("%d\n", *it);
}

Measured memory_bytes: 384
r,c=list(map(int,input().split()))
table=[list(map(int,input().split())) for i in range(r)]

for i in range(r):
    sum = 0
    for j in range(c):
        sum += table[i][j]
    table[i].append(sum)
    
newrow=[]
for i in range(c+1):
    newrow.append(0)
    for j in range(r):
        newrow[i] += table[j][i]
table.append(newrow)   
for i in table:
    print(*i)


Measured memory_bytes: 6232
#include<iostream>
#include<bits/stdc++.h>
#define ll long long
using namespace std;

ll max(ll a, ll b, ll c = 0, ll d = 0)
{
  if (c == 0 && d == 0)
    return a > b ? a : b;
  return max(a, max(b, max(c, d)));
}

int main()
{
  ll n, w;
  cin >> n >> w;
  vector<vector<ll>> dp(w + 1, vector<ll>(n + 1, 0));
  vector<ll> weights(n + 1, 0), value(n + 1, 0);
  for(int i = 1; i <= n; i++)
  {
    cin >> weights[i] >> value[i];
  }
  for (int i = 1; i <= w; i++)
  {
    for (int j = 1; j <= n; j++)
    {
      dp[i][j] = max(dp[i-1][j], dp[i][j - 1]);
      if (i - weights[j] >=0)
      {
        dp[i][j] = max(dp[i][j], value[j] +
            dp[i - weights[j]][j - 1]);
      }
    }
  }
  cout << dp[w][n] << endl;
  return 0;
}

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

using namespace std;

#define sq(a) ((a) * (a))
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define mp(a, b) make_pair(a, b)
#define what_is(x) cerr << fixed << setprecision(2) << #x << " = " << x << endl
#define setbitj(n, j) (n |= (1 << (j)))
#define isbitjOn(n, j) (((n & (1 << (j))) > 0) ? 1 : 0)
#define safeMod(a, m) ((((a)%(m))+(m))%(m))/*handling negative sign of remainder*/

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vii;

const double EPS = 1e-9;
const int INF = 0x3f3f3f3f;
const double PI = acos(-1.0);
const int MAX = 100005;
const int MOD = 1000000007;

inline bool isEq(double a, double b){return abs(a - b) < EPS;}
inline double toRad(double deg){return deg*PI/180;}
inline double toDeg(double rad){return rad*180/PI;}

inline int geti(int &_int){return scanf("%d", &_int);}
inline int getii(int &_int, int &_int2){return scanf("%d %d", &_int, &_int2);}
inline int getiii(int &_int, int &_int2, int &_int3){return scanf("%d %d %d", &_int, &_int2, &_int3);}

inline int getl(ll &_ll){return scanf("%lld", &_ll);}
inline int getll(ll &_ll, ll &_ll2){return scanf("%lld %lld", &_ll, &_ll2);}
inline int getlll(ll &_ll, ll &_ll2, ll &_ll3){return scanf("%lld %lld %lld", &_ll, &_ll2, &_ll3);}

inline int getd(double &_double){return scanf("%lf", &_double);}
inline int getdd(double &_double, double &_double2){return scanf("%lf %lf", &_double, &_double2);}

inline int getstr(char *str){return scanf("%s", str);}

//#define isValid(a, b) (a >= 0 && a < b)
//int dr[]  =  {0, -1, -1, -1,  0,  1, 1, 1};
//int dc[]  =  {1,  1,  0, -1, -1, -1, 0, 1};

int main(int argc, char* argv[])
{
    //freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    //ios_base::sync_with_stdio(false); cin.tie(NULL);
    int n, a, b;
    while(cin>>n>>a>>b)
    {
        if(abs(a-b)%2==0) cout << "Alice\n";
        else cout << "Borys\n";
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define ll long long
#define li long
#define pb push_back
#define mem(arr,x) memset(arr,x,sizeof(arr))

ll n;
vector<ll>adj[100001];
ll dp[100001][2];

// 0 -> black_color
// 1 -> white_color

ll totalWays(ll node,ll parent,ll color)
{
	if(dp[node][color]!=-1) return dp[node][color];
	ll total=1;
	for(auto child : adj[node])
	{
		ll count=0;
		if(child!=parent)
		{
			if(color==0)
				count+=totalWays(child,node,1)%MOD;
			else
				count+=totalWays(child,node,0)+totalWays(child,node,1)%MOD;

			total=((total%MOD)*(count%MOD))%MOD;
		}
	}
	dp[node][color]=total%MOD;
	return total%MOD;
}

int main() 
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>n;
    ll i,u,v;
    for(i=0;i<n-1;i++)
    {
    	cin>>u>>v;
    	adj[u].pb(v);
    	adj[v].pb(u);
    }
    mem(dp,-1);
    cout<<(totalWays(1,-1,0)%MOD+totalWays(1,-1,1)%MOD)%MOD;
    return 0;
}

Measured memory_bytes: 19028
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    final Scanner s = new Scanner(System.in);
    final int N = Integer.parseInt(s.next());
    final int L = Integer.parseInt(s.next());
    int before = Integer.parseInt(s.next());
    int last = 0;

    for (int i = 1; i < N; i++) {
      final int a = Integer.parseInt(s.next());
      if (a + before >= L) {
        last = i;
        break;
      }
      before = a;
    }
    if (last == 0) {
      System.out.println("Impossible");
    } else {
      System.out.println("Possible");
      for (int i = 1; i < last; i++) {
        System.out.println(i);
      }
      for (int i = N - 1; i > last; i--) {
        System.out.println(i);
      }
      System.out.println(last);
    }
  }
}

Measured memory_bytes: 49092
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
    int k,a,b,n;
    n = 0;
    cin >> k >> a >> b;
    int l = (b/k)*k;
    if (a <=l){
        cout << "OK";
    }else {
        cout << "NG";
    }
}

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

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define LCM(a, b) (a) / __gcd((a), (b)) * (b)
#define CEIL(a, b) (a)/(b)+(((a)%(b))?1:0)
#define ln '\n'

using namespace std;

typedef long long LL;
typedef long double ldouble;
typedef pair<int, int> P;
typedef pair<LL, LL> LP;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1e9 + 7;
static const int SIZE = 200005;

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

vector<LL> Div(LL n) {
    vector<LL> ret;
    for(LL i = 1; i * i <= n; ++i) {
        if(n % i == 0) {
            ret.pb(i);
            if(i * i != n) ret.pb(n / i);
        }
    }
    sort(all(ret));
    return ret;
}

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

    int n;
    cin >> n;
    int t = n;
    int s = 0;
    while(t > 0) {
        s += t % 10;
        t /= 10;

    }
    if(n % s == 0) cout << "Yes";
    else cout << "No";
    cout << endl;

    return 0;
}


Measured memory_bytes: 256