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


void solve(long long a, long long b, long long x){
    long double sita,xf=x,af=a,bf=b;
    std::cout<<std::fixed<<std::setprecision(10);

    if(x<=af*af*bf/2){
        sita=360/(2*M_PI)*atan(af*bf*bf/2/xf);
    }
    else{
        sita=360/(2*M_PI)*atan((2*bf*af*af-2*xf)/(af*af*af));
    }
    cout<<sita<<endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long a;
    scanf("%lld",&a);
    long long b;
    scanf("%lld",&b);
    long long x;
    scanf("%lld",&x);
    solve(a, b, x);
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <vector>
#include <iostream>
#include <queue>
#include <bits/stdc++.h>
 
#define rep(i,n) for (int i=0;i<(n);++i)
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<double> vd;
typedef pair<int, int> pi;


int main() {
  int n; string s;
  cin >> n >> s;
  int cnt = 0;
  rep(i, n-2){
    if (s.substr(i, 3) == "ABC") cnt++;
  }
  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 256
short*p,v[2][104];main(c,n,m,i,y){for(;m=scanf("%d %[^\n] %[^\n]",&n,v,v+1)*n;printf(m>n?"NA\n":"%d\n",m))for(i=2;i--;m=c)for(c=0,y=n-1;p=y+v[c+i&1],c<m&y>0;)y-=y==n|*p&2?-1:*p&p[-1]&1?1:!++c+2;}

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

int main(){
    long long int ha;
    cin >> ha;

    long long int i = 0;
    long  long int tmp = 0; 
    long long int result = 1;
    
    while(ha != 1){
        ha = ha / 2;
        i++;
        result += pow(2, i); 
    }
    
    cout << result << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef pair<int, int> Pint;
typedef pair<int64_t, int64_t> Pll;

int main() {
    int H, W, a, b;
    cin >> H >> W >> a >> b;
    for (int i = 0; i < b; i++) {
        for (int j = 0; j < a; j++) {
            cout << 1;
        }
        for (int j = 0; j < W - a; j++) {
            cout << 0;
        }
        cout << endl;
    }
    for (int i = 0; i < H - b; i++) {
        for (int j = 0; j < a; j++) {
            cout << 0;
        }
        for (int j = 0; j < W - a; j++) {
            cout << 1;
        }
        cout << endl;
    }
}


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

template <typename InputIterator>
typename InputIterator::value_type
summation(InputIterator first, InputIterator last) {
  using T = typename InputIterator::value_type;
  T *p = new T();
  const auto sum = std::accumulate(first, last, *p);
  delete p;
  return sum;
}
template <typename T>
std::istream& operator>> (std::istream &stream, std::vector<T> &v);
template <typename T1, typename T2>
std::istream& operator>> (std::istream &stream, std::pair<T1, T2> &p);
template <typename T>
std::istream& operator>> (std::istream &stream, std::vector<T> &v) {
  for (auto &i : v) {
    stream >> i;
  }
  return stream;
}
template <typename T1, typename T2>
std::istream& operator>> (std::istream &stream, std::pair<T1, T2> &p) {
  stream >> p.first >> p.second;
  return stream;
}

int64_t co(const int64_t n, const int64_t k) {
  int64_t ans = 1;

  for (int64_t i = 1; i <= k; i++) {
    ans *= n - i + 1;
    ans /= i;
  }

  return ans;
}

int main() {
  int64_t n, a, b;
  std::cin >> n >> a >> b;
  std::vector<int64_t> v(n);
  std::cin >> v;
  std::sort(v.begin(), v.end(), std::greater<int64_t>());

  double sum = 0;
  for (int64_t i = 0; i < a; i++) {
    sum += v[i];
  }
  std::cout << std::fixed << sum / a << std::endl;

  int64_t i = a - 1;
  int64_t count = 0;
  do {
    int64_t b = 0;

    for (int64_t j = 0; j <= i; j++) {
      if (v[j] == v[i]) {
        b++;
      }
    }

    const int64_t c = std::count(v.cbegin(), v.cend(), v[i]);
    count += co(c, b);

    i++;
  } while (i < b && v[i] == v.front());

  std::cout << count << std::endl;
  return 0;
}


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

template<class T> T read() {
	T t;
	cin >> t;
	return t;
}

template<class T> vector<T> read_vector(sint n) {
	vector<T> vs;
	for (sint i = 0; i < n; ++i) {
		vs.push_back(read<T>());
	}
	return vs;
}

inline void write() {
}

template<class T> void write(T const& t) {
	cout << t;
}

template<class T> void write(vector<T> const& ts) {
	if (ts.size() > 0) {
		cout << ts[0];
	}
	for (size_t i = 1; i < ts.size(); ++i) {
		cout << ' ' << ts[i];
	}
}

template<class T, class... Args> void write(T const& t, Args const&... args) {
	cout << t << ' ';
	write(args...);
}

template<class... Args> void writeln(Args const&... args) {
	write(args...);
	cout << '\n';
}

int main() {
	ios_base::sync_with_stdio(false);
	cin .exceptions(ios_base::badbit | ios_base::failbit);
	cout.exceptions(ios_base::badbit | ios_base::failbit);
	cin .tie(nullptr);
	cout.tie(nullptr);
	cout.precision(16);
	void run();
	run();
	return 0;
}

void run() {
	auto const N = read<sint>();
	for (sint i = sint(sqrt(N)); i > 0; --i) {
		if (N % i == 0) {
			writeln(i + (N / i) - 2);
			return;
		}
	}
}

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

int main() {
  ll a, b, x;
  cin >> a >> b >> x;
  ll cnt = (b / x) - (a / x);
  if (a % x == 0) {
    ++cnt;
  }
  cout << cnt << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define lowbit(x) (x&(-x))
#define CSE(x,y) memset(x,y,sizeof(x))
#define INF 0x3f3f3f3f
#define Abs(x) (x>=0?x:(-x))
#define FAST ios::sync_with_stdio(false);cin.tie(0);
using namespace std;

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

const int maxn = 111111;


int main()
{
	int l, r, d;
	cin >> l >> r >> d;
	int ans = 0;
	for (int i = l; i <= r; i++) {
		if (i % d == 0)
			ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
int main()
{
	char k[101];
	gets(k);
	int i,l=strlen(k),ans=0;
	for(i=0;i<l;i++)
	{
		if(k[i]=='C')
		{
			ans++;
		}
		if(ans!=0&&k[i]=='F')
		{
			printf("Yes");
			return 0;
		}
	}
	printf("No");
	return 0;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
	int n, a, b; cin >> n >> a >> b;
	if((b-a-1)%2==0){
		cout << "Borys" << endl;
		return 0;
	}
	if((b-a-1)%2==1){
		cout << "Alice" << endl;
		return 0;
	}
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<cctype>
#include<climits>
#include<string>
#include<bitset>
#include<cfloat>
#include<iomanip>
#include<numeric>

using namespace std;
using ll =  long long;
using pint =  pair<int,int>;
using vint = vector<int>;
using vvint = vector<vint>;
using vpint = vector<pint>;
#define repi(i,start,end) for(int (i)=(start),TemPNuM=(int)(end);(i)<TemPNuM;++(i))
#define rep(i,end) repi((i),0,(end))
#define rfor(x,v) for(auto& (x) : (v))
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define fsort(v,lambda) sort(all((v)),(lambda))
#define vin(v) rep(i,(v).size())cin >> (v)[i];
#define vpin(v) rep(i,(v).size())cin>>v[i].first>>v[i].second
//#define int long long
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; }
template<class T>void println(T a){if(cout.precision()!=12)cout<<setprecision(12);cout<<a<<endl;}
//lambda: [](int x, int y){return x<y;}

signed main(void) {
    int n; cin >> n;
    int x = 800 * n;
    int y = 200 * (n / 15);
    cout << x - y << endl;
    return 0;
}


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

int main(){
    int n;
    vector<pair<int64_t, int64_t>> r;

    cin >> n;
    set<int64_t> idx;
    
    for(int i=0;i<n;++i){
        int64_t x, l;
        cin >> x >> l;
        r.emplace_back(x+l, x-l);
        idx.insert(x+l);
        idx.insert(x-l);
    }
    sort(r.begin(), r.end());
    int64_t occ = INT32_MIN;
    int64_t ans = 0;
    for(int i=0;i<n;++i){
        if(r[i].second >= occ){
            ++ans;
            occ = r[i].first;
        }
    }
    cout << ans << endl;

    return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;

int main()
{
    ull N, K;
    cin >> N >> K;
    vector<ull> A(N);
    vector<int> bCount(64, 0);
    for(int i=0;i<N;i++){
        cin >> A[i];
        for(int j=0; j<64; j++){
            if(A[i] & ((ull)1<<j)) bCount[j]++;
        }
    }
    ull X = 0;
    for(int j=63; j>=0; j--){
        if(2 * bCount[j] < N){
            auto x = X | (ull)1 << j;
            if(x > K) continue;
            X = x;
        }
    }
    ull res = 0;
    for(auto v : A) res += X ^ v;
    cout<<res<<endl;

    return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<functional>
#include<math.h>

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

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

	return gcd(b, a%b);
}

int main() {
	int n;
	cin >> n;
	vector<int> b(n - 1);
	rep(i, n) cin >> b[i];
	vector<int> a(n);

	a[0] = b[0];
	for (int i = 0; i < n - 2; i++)
	{
		a[i+1] = min(b[i], b[i + 1]);
	}
	a[n - 1] = b[n - 2];

	int sum = 0;
	rep(i, n) sum += a[i];
	cout << sum << endl;

	return 0;
}

Measured memory_bytes: 256
/* {{{ Shinobu kawaii */
/*
  ______   __        _                  __                 
.' ____ \ [  |      (_)                [  |                
| (___ \_| | |--.   __   _ .--.   .--.  | |.--.   __   _   
 _.____`.  | .-. | [  | [ `.-. |/ .'`\ \| '/'`\ \[  | | |  
| \____) | | | | |  | |  | | | || \__. ||  \__/ | | \_/ |, 
 \______.'[___]|__][___][___||__]'.__.'[__;.__.'  '.__.'_/ 

*/
// clang-format off
/* }}} */

#include <bits/stdc++.h>
using namespace std;

// #define int long long
struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);}} fast;

/* cpp template {{{ */

/* short */
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) begin(v), end(v)
#define RALL(v) rbegin(v), rend(v)
#define X real()
#define Y imag()

/* REPmacro */
#define REPS(i, a, n) for (ll i = (a); i < (ll)(n); ++i)
#define REP(i, n) REPS(i, 0, n)
#define RREP(i, n) REPS(i, 1, n + 1)
#define DEPS(i, a, n) for (ll i = (a); i >= (ll)(n); --i)
#define DEP(i, n) DEPS(i, n, 0)

/* debug */
#define debug(x) cerr << x << " " << "(L:" << __LINE__ << ")" << '\n';

/* alias */
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using pii = pair<int, int>;
using D = double;
using P = complex<D>;
using vs = vector<string>;
template <typename T> using PQ = priority_queue<T>;
template <typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

/* const */
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;
const D EPS = 1e-9;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

/* func */
inline bool inside(int y, int x, int H, int W) {return y >= 0 && x >= 0 && y < H && x < W;}
inline int in() {int x; cin >> x; return x;}
inline ll IN() {ll x; cin >> x; return x;}
inline vs split(const string& t, char c) {vs v; stringstream s(t); string b; while(getline(s, b, c)) v.eb(b); return v;}
template <typename T> inline bool chmin(T& a, const T& b) {if (a > b) a = b; return a > b;}
template <typename T> inline bool chmax(T& a, const T& b) {if (a < b) a = b; return a < b;}
template <typename T, typename S> inline void print(const pair<T, S>& p) {cout << p.first << " " << p.second << endl;}
template <typename T> inline void print(const T& x) {cout << x << '\n';}
template <typename T, typename S> inline void print(const vector<pair<T, S>>& v) {for (auto&& p : v) print(p);}
template <typename T> inline void print(const vector<T>& v, string s = " ") {REP(i, v.size()) cout << v[i] << (i != (ll)v.size() - 1 ? s : "\n");}
// clang-format on
/* }}} */

int n;
int memo[10000001];


signed main() {
  cin >> n;
  vi v;
  RREP(i, n) memo[i] = i;
  REPS(i, 2, n + 1) memo[i] += memo[i - 1];
  RREP(i, n) {
    if (memo[i] >= n) {
      v.eb(i);
      break;
    }
  }
  int sum = v.front();

  DEPS(i, v.front() - 1, 1) {
    if (sum == n) break;
    if (sum + i <= n) {
      sum += i;
      v.eb(i);
    }
  }
  print(v, "\n");

  return 0;
}


Measured memory_bytes: 39424
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define int ll
#define Mid ((l+r)/2)
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
#define drep(i,a,b) for(int i=(a);i>=(b);--i)
#define file(a) freopen(#a".in","r",stdin),freopen(#a".out","w",stdout);
const int maxn=2e3+5,mod=1e9+7,inf=0x3f3f3f3f;
int n,m,Q,K,T;
int read(){
    int x=0,f=1;char c=getchar();
    while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
    while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}
    return x*f;
}
int dp[2005][2005];
int sum[maxn<<2];
#define lss rt<<1
#define rss rt<<1|1
#define lson lss,l,Mid
#define rson rss,Mid+1,r
void insert(int rt,int l,int r,int pos,int k){
    // cout<<l<<" "<<r<<endl;
    if(l==r)return (void)(sum[rt]=k);
    if(pos<=Mid)insert(lson,pos,k);
    else insert(rson,pos,k);
    sum[rt]=(sum[lss]+sum[rss])%mod;
}
int query(int rt,int l,int r,int L,int R){
    if(R<L)return 0;
    if(L<=l&&r<=R)return sum[rt];
    int res=0;
    if(L<=Mid)res+=query(lson,L,R);
    if(R>Mid)res=(res+query(rson,L,R))%mod;
    return res;
}
signed main(){
    //file(a);
    n=read();
    if(n<3){puts("0");return 0;}
    if(n==3){puts("1");return 0;}
    dp[0][0]=1;
    insert(1,1,n+1,0+1,1);//return 0;
    rep(i,1,n/3){
        rep(j,3,n){
            dp[i][j]=query(1,1,n+1,0+1,j-3+1);
            // cout<<"now"<<j<<" "<<0+1<<" "<<j-3+1<<" "<<dp[i][j]<<endl;
            /*rep(g,3,j){
                dp[i][j]+=dp[i-1][j-g];dp[i][j]%=mod;
            }*/
        }
        rep(j,0,n)insert(1,1,n+1,j+1,dp[i][j]);
    }int ans=0;
    rep(i,1,n/3)ans+=dp[i][n],ans%=mod;
    printf("%d\n",ans);


    return 0;
}

Measured memory_bytes: 14128
#include<stdio.h>

int main(void){
    int i;
    char s1[10],s2[10],s3[10];
    scanf("%s",s1);
    scanf("%s",s2);
    scanf("%s",s3);
    printf("%c%c%c\n",s1[0],s2[1],s3[2]);
    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define next Next
#define gc getchar
#define int long long
const int N=1e6+5;
int n,m,k,ans,a[N],b[N];
char s[N];
//char buf[1<<21],*p1=buf,*p2=buf;
//inline int gc(){return p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++;}
inline int read()
{
    int ret=0,f=0;char c=gc();
    while(!isdigit(c)){if(c=='-')f=1;c=gc();}
    while(isdigit(c)){ret=ret*10+c-48;c=gc();}
    if(f)return -ret;return ret;
}
signed main()
{
	m=read();n=read();
	for(int i=1;i<=n;i++)a[i]=read();
	ans=a[n]-a[1];
	for(int i=2;i<=n;i++)
		ans=min(ans,m-a[i]+a[i-1]);
	cout<<ans;
	return 0;
}

Measured memory_bytes: 4352
//2018.09.21

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

int ctoi(char moji){
    switch(moji){
        case 'a': return 0;
        case 'b': return 1;
        case 'c': return 2;
        case 'd': return 3;
        case 'e': return 4;
        case 'f': return 5;
        case 'g': return 6;
        case 'h': return 8;
        case 'i': return 9;
        case 'j': return 10;
        case 'k': return 11;
        case 'l': return 12;
        case 'm': return 13;
        case 'n': return 14;
        case 'o': return 15;
        case 'p': return 16;
        case 'q': return 17;
        case 'r': return 18;
        case 's': return 19;
        case 't': return 20;
        case 'u': return 21;
        case 'v': return 22;
        case 'w': return 23;
        case 'x': return 24;
        case 'y': return 25;
        case 'z': return 26;
        default : return -1;
    }
}

int main() {

    int n;
    cin >> n;

    char s[n];
    int i,j;
    for(i=0;i<n;i++){
        cin >> s[i];
    }

    vector<bool> x(27,false);
    vector<bool> y(27,false);
    int test=0,maxv=0;

    for(i=1;i<n-1;i++){
        for(j=0;j<i;j++){ x[ctoi(s[j])] = true;}
        for(j=i;j<n;j++){ y[ctoi(s[j])] = true;}
        for(j=0;j<27;j++){
            if(x[j]&&y[j]) test++;
        }
        maxv=max(maxv,test);
        x.assign(27,false);
        y.assign(27,false);
        test=0;
    }

    cout << maxv << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for (int i = s; i < (int)(n); i++)
#define out(x) cout << x << endl
#define INF 1000000;
#include <map>
#include <math.h>
 
using ll = long long;
using namespace std;

ll n, k;
const ll mod = 1000000007;

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

   if(a-b>=0) out("delicious");
   else if(a+x+1-b>0) out("safe");
   else out("dangerous");
}


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

int bubbleSort(int a[], int n) {
    int swapNum = 0;
    bool isSwaped = true;
    for (int i = 0; isSwaped; i++) {
        isSwaped = false;
        for (int j = n - 1; j >= i + 1; j--) {
            if (a[j] < a[j-1]) {
                swap(a[j], a[j-1]);
                isSwaped = true;
                swapNum++;
            }
        }
    }
    return swapNum;
}

int main() {
    int a[100], n, swapNum;

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

    swapNum = bubbleSort(a, n);

    for (int i = 0; i < n; i++) {
        if (i > 0) cout << " ";
        cout << a[i];
    }
    cout << endl;
    cout << swapNum << endl;
}



Measured memory_bytes: 3088
// 橋を求める
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
#define MOD 1000000007
#define INF 1e9
#define INFL 1e12
 
typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
template<class T>void pr(T x){cout << x << endl;}
template<class T>void prvec(vector<T>& a){rep(i, a.size()-1){cout << a[i] << " ";} cout << a[a.size()-1] << endl;}
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; }

typedef pair<int, bool> edge;

int v, e;
vector<vector<edge>> G;
vector<int> ord, low;
set<pair<int, int>> ans;
vector<bool> seen;
int k;
int zero_degree;

void dfs(int u, int r){
    // pr(u);
    seen[u] = true;
    ord[u] = k; k++;
    low[u] = ord[u];
    for(edge &ed: G[u]){
        int v = ed.first;
        if(v==r) continue;
        if(!seen[v]){
            ed.second = true;
            dfs(v, u);
            chmin(low[u], low[v]);
            if(ord[u] < low[v]){
                if(u<=v) ans.insert({u, v});
                else ans.insert({v, u});
            }
        }else if(ed.second==false){
            chmin(low[u], ord[v]);
        }
    }
}
 
int main()
{
    cin >> v >> e;
    G.resize(v); ord.resize(v), low.resize(v); seen.resize(v);

    int a, b;
    rep(i, e){
        cin >> a >> b;
        G[a].push_back({b, false});
        G[b].push_back({a, false});
    }
    rep(i, v) seen[i]=false;
    int k = 0;

    dfs(0, 0 );

    // rep(i, v) seen[i] = false;
    // dfs_search(0);

    // int tmp=0;
    // for(edge ed: G[0]){
    //     if(ed.second) tmp++;
    // }
    // if(tmp>1) ans.insert(0);

    for(pair<int, int> c: ans){
        printf("%d %d\n", c.first, c.second);
    }
    return 0;
}


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

int main(){
  int a,b;
  cin >> a >> b;
  if(a == b){
    for(int i = 0; i < b; i++){
      cout << a;
    }
    cout << endl;
    return 0;
  }else{
    if(a > b){
      for(int i = 0; i < a; i++){
        cout << b;
      }
      cout << endl;
    }else{
      for(int i = 0; i < b; i++){
        cout << a;
      }
      cout << endl;
    }
  }
}

Measured memory_bytes: 3564
#include <iostream>
#include <cmath>
typedef long long ll;
using namespace std;

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

    ll sum=0, cnt_first=0, cnt_second=0;

    //a[odd]<0 && a[even]>0
    for(int i=0; i<n; i+=2) {
        if(sum+a[i]<=0) {
            cnt_first += abs(1-sum-a[i]);
            a[i] = 1-sum;
        }
        sum+=a[i];

        if(i!=n-1) {
            if(sum+a[i+1]>=0) {
                cnt_first += abs(-1-sum-a[i+1]);
                a[i+1] = -1-sum;
            }
            sum += a[i+1];
        }
    }

    sum=0;
    //a[odd]>0 && a[even]<0
    for(int i=0; i<n; i+=2) {
        if(sum+b[i]>=0) {
            cnt_second += abs(-1-sum-b[i]);
            b[i] = -1-sum;
        }
        sum+=b[i];

        if(i!=n-1) {
            if(sum+b[i+1]<=0) {
                cnt_second += abs(1-sum-b[i+1]);
                b[i+1] = 1-sum;
            }
            sum+=b[i+1];
        }
    }


    cout << ((cnt_first<cnt_second)?cnt_first:cnt_second) << endl;
    return 0;
}


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

using namespace std;

long long cnt[26];

int main() {
	string a; cin >> a;
	long long n=a.size();
	for(int i=0;i<n;++i)
		++cnt[a[i]-'a'];
	long long ans=n*(n-1)/2+1;
	for(int i=0;i<26;++i)
		ans-=cnt[i]*(cnt[i]-1)/2;
	cout << ans << endl;
	
	return 0;
}


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

int main() {
  ll n,k,ans = 0,mod = 1e9+7;
  cin >> n >> k;
  for(int i = k;i <= n+1;i++){
    ans += i*(n-i+1)+1;
    ans %= mod;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
#define fastio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long
#define ull unsigned long long
#define vi vector<int>
#define pi pair<int, int>
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define deb(x) cout << #x << ":" << x << endl;
/* freopen("input.txt", "r", stdin); */
/* freopen("output.txt", "w", stdout); */
const int MOD = 1000000007;

int main() {
	fastio();
	string s, t;
	cin >> s >> t;
	int n = s.length();
	int i;
	for(i=0;i<n;i++)
		if(s[i] != t[i])
			break;
	if(i == n)
		cout << "Yes\n";
	else
		cout << "No\n";
	return 0;
}


Measured memory_bytes: 3668
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
typedef long long ll;
// const ll Mod = 1e9 + 7;
const ll Mod = 1000000007;
const int mxN = 2e5 + 5;
ll gcd(ll a, ll b) {
    return b ? gcd(b, a % b) : a;
}
ll power[mxN];
int main() {
    // ios::sync_with_stdio(false);
    // cin.tie(0);
    power[0] = 1;
    for (int i = 1; i < mxN; i++) {
        power[i] = power[i - 1] * 2 % Mod;
    }
    int n;
    // cin >> n;
    scanf("%d", &n);
    // map<double, pair<int, int>> mp;
    ll special = Mod - 1;
    map<pair<ll, ll>, pair<int, int>> mp;
    for (int i = 0; i < n; i++) {
        // double a, b;
        ll a, b;
        // cin >> a >> b;
        scanf("%lld%lld", &a, &b);
        if (a == 0LL && b == 0LL) {
            special++;
            continue;
        }
        if (make_pair(a, b) < make_pair(0ll, 0ll))
            a = -a, b = -b;
        ll g = gcd(abs(a), abs(b));
        a = a / g, b = b / g;
        // pair<ll, ll> ang = make_pair(a, b);
        // pair<ll, ll> bad = a >= 0 ? make_pair(-b, a) : make_pair(b, -a);
        if (b > 0)
            mp[{ a, b }].first++;
        else
            mp[{ -b, a }].second++;
        // if (mp.find(bad) != mp.end()) {
        //     mp[bad].second++;
        // } else {
        //     mp[ang].first++;
        // }
    }

    ll ans = 1;
    for (auto& p : mp) {
        // if (p.second.second == 0) {
        //     ans = ans * power[p.second.first] % Mod;
        // } else {
        //     ans = ans * (power[p.second.first] + power[p.second.second] - 1)
        //     %
        //           Mod;
        // }
        ans = ans * (power[p.second.first] + power[p.second.second] - 1) % Mod;
    }
    // cout << (ans - 1LL + special) % Mod << '\n';
    // cout << ans << " " << special << endl;
    printf("%lld\n", (ans + special) % Mod);
}

Measured memory_bytes: 17704
import java.io.*;
import java.util.*;

public class Main {
	static BufferedReader br;
	static int cin() throws Exception
	{
		return Integer.valueOf(br.readLine());
	}
	static int[] split() throws Exception
	{
		String[] cmd=br.readLine().split(" ");
		int[] ans=new int[cmd.length];
		for(int i=0;i<cmd.length;i++)
		{
			ans[i]=Integer.valueOf(cmd[i]);
		}
		return ans;
	}
	static long[] splitL() throws IOException
	{
		String[] cmd=br.readLine().split(" ");
		long[] ans=new long[cmd.length];
		for(int i=0;i<cmd.length;i++)
		{
			ans[i]=Long.valueOf(cmd[i]);
		}
		return ans;
	}
	public static void main(String[] args) throws Exception{
		// TODO Auto-generated method stub
		br=new BufferedReader(new InputStreamReader(System.in));
		int[]ar=split();
		int x=(ar[0]+ar[1]-1)/ar[1];
		System.out.println(ar[2]*x);
	}
}


Measured memory_bytes: 32580
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
    	int k = Integer.parseInt(sc.nextLine());
    	String s = sc.nextLine();
    	if(s.length() <= k) {
    		System.out.println(s);
    	}else {
    		System.out.println(s.substring(0, k) + "...");
    	}
    }
}

Measured memory_bytes: 26984
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define Sort(Array) sort(Array.begin(), Array.end())
#define Reverse(a) reverse(a.begin(), a.end())
#define out(ans) cout << ans << endl;
const int MOD = 1000000007;
const int INF = 2147483647;
const ld PI = 3.14159265358979323846;

//------------↓------------- M -------------- E ---------------- M --------------- O ---------------↓--------------//
// コンパイル 
// g++ -std=c++1z
//
// -------型変換--------
// int を string に変換
// string s = to_string(n);
// string を int に変換
// int n = stoi(s);
//
// -------二分探索---------
// k以上の値が最初に現れる時のイテレータ
// lower_bound(data.begin(), data.end(), k)
// kより大きい値が最初の現れる時のイテレータ O(logN)
// upper_bound(data.begin(), data.end(), k)
// kがdataに存在するかをtrue or falseで返す O(logN)
// binary_search(data.begin(), data.end(), k)
// 
//
//
//
//
//
// 
//------------↑------------- M -------------- E ---------------- M --------------- O ---------------↑--------------//



int main() {

    int a; cin >> a;
    cout << a + pow(a,2) + pow(a,3) << endl;


    
    return 0;
}









Measured memory_bytes: 4188
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.PriorityQueue;
import java.util.StringTokenizer;
import java.util.TreeSet;

public class Main {

    static BufferedReader in;
    static PrintWriter out;
    static StringTokenizer tok;

    void solve() throws IOException {
        int K = ni();
        int T = ni();
        int[] a = nia(T);

        int max = -1;
        for (int i = 0; i < T; i++) {
            if (max < a[i]) {
                max = a[i];
            }
        }

        if (K % 2 == 1) {
            if ((K + 1) / 2 >= max) {
                out.println(0);
            } else {
                out.println(K - (K - max) * 2 - 1);
            }
        } else {
            if (K / 2 >= max) {
                out.println(0);
            } else {
                out.println(K - (K - max) * 2 - 1);
            }
        }
    }

    String ns() throws IOException {
        while (!tok.hasMoreTokens()) {
            tok = new StringTokenizer(in.readLine(), " ");
        }
        return tok.nextToken();
    }

    int ni() throws IOException {
        return Integer.parseInt(ns());
    }

    long nl() throws IOException {
        return Long.parseLong(ns());
    }

    double nd() throws IOException {
        return Double.parseDouble(ns());
    }

    String[] nsa(int n) throws IOException {
        String[] res = new String[n];
        for (int i = 0; i < n; i++) {
            res[i] = ns();
        }
        return res;
    }

    int[] nia(int n) throws IOException {
        int[] res = new int[n];
        for (int i = 0; i < n; i++) {
            res[i] = ni();
        }
        return res;
    }

    long[] nla(int n) throws IOException {
        long[] res = new long[n];
        for (int i = 0; i < n; i++) {
            res[i] = nl();
        }
        return res;
    }

    public static void main(String[] args) throws IOException {
        in = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
        tok = new StringTokenizer("");
        Main main = new Main();
        main.solve();
        out.close();
    }
}

Measured memory_bytes: 8276
N, K = map(int, input().split())

# 赤いボールの数
R = N - K

import itertools
import math
def comb(n, k):
    if n-k < 0:
        return 0
    return math.factorial(n)//math.factorial(n-k)//math.factorial(k)



for i in range(1, K+1):
    a = comb(K-1, i-1)
    b = comb(R+1, i)
    print(a * b % 1000000007)


Measured memory_bytes: 3316
#include <iostream>
#include <queue>
#include <stack>
#include <vector>
#include <stdio.h>
#include <algorithm>
#include <string.h>
#include <string>
#include <cmath>
#include <complex>
#include <map>
using namespace std;

#define rep(i,n) for(int i=0;i<int(n);++i)
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define EPS 1e-8
#define F first
#define S second

static const double PI=6*asin(0.5);
typedef pair<double,double> P;
typedef complex<double> CP;
typedef long long ll;


ll a[100];
string s;
ll b[100];
ll tmp[100];

int main(){
	int pas=0;
	rep(i,100){
		a[i]=0;
		b[i]=0;
	}
	while(getline(cin,s)){
		int cou=0;
		rep(i,100){
			tmp[i]=a[i];
		}
		rep(i,s.size()){
			if(s[i]<='9'&&s[i]>='0'){
				int sum=0;
				for(int j=i;j<s.size();j++){
					if(s[j]<='9'&&s[j]>='0'){
						sum*=10;
						sum+=s[j]-'0';
					}
					else break;
					i=j;
				}
				//cout<<sum<<" ";
				b[cou++]=sum;
			}
		}
		//cout<<endl;
		rep(i,cou){
			//cout<<b[i]<<" ";
		}
		//cout<<endl;
		if(cou>pas){
			rep(i,cou){
				if(i==0) a[0]+=b[0];
				else if(i==cou-1) a[i]+=b[i-1];
				else a[i]=max(tmp[i],tmp[i-1])+b[i];
			}
		}
		else{
			rep(i,cou){
				a[i]=max(tmp[i],tmp[i+1])+b[i];
			}
		}
		//cout<<endl;
		pas=cou;
	}
	cout<<a[0]<<endl;
	return 0;
}

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

using namespace std;
using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vb = vector<bool>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vvb = vector<vector<bool>>;
using vvs = vector<vector<string>>;
template<typename T> using vv = vector<vector<T>>;
template<typename T> using vvv = vector<vector<vector<T>>>;
template<typename T> using pq = priority_queue<T>;
template<typename T> using pqg = priority_queue<T, vector<T>, greater<T>>;

const int INF = 1e9;
const ll LINF = 1e18;
const ll MOD = 1e9 + 7;
const int DX[4] = {1, 0, -1, 0};
const int DY[4] = {0, 1, 0, -1};

#define _sel(_1, _2, x, ...) x
#define repn(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, a, b) for (ll i = (a); i < (b); i++)
#define rep(i, ...) _sel(__VA_ARGS__, reps, repn)(i, __VA_ARGS__)
#define reppn(i, n) for (ll i = 1; i <= (n); i++)
#define repps(i, a, b) for (ll i = (a); i <= (b); i++)
#define repp(i, ...) _sel(__VA_ARGS__, repps, reppn)(i, __VA_ARGS__)
#define rrepn(i, n) for (ll i = (n) - 1; i >= 0; i--)
#define rreps(i, a, b) for (ll i = (b) - 1; i >= (a); i--)
#define rrep(i, ...) _sel(__VA_ARGS__, rreps, rrepn)(i, __VA_ARGS__)
#define rreppn(i, n) for (ll i = (n); i >= 1; i--)
#define rrepps(i, a, b) for (ll i = (b); i >= (a); i--)
#define rrepp(i, ...) _sel(__VA_ARGS__, rrepps, rreppn)(i, __VA_ARGS__)

#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define rng(v) (v).begin(), (v).end()
#define rrng(v) (v).rbegin(), (v).rend()
#define siz(x) int((x).size())
#define pow2(x) (1ll << (x))
#define bit(x, n) ((x) >> (n) & 1)
#define prt(x) cout << (x) << endl
#define dbg(x) dbgn(#x, x)

template<typename T, typename U> inline bool umax(T& m, U x) { if (m < x) { m = x; return true; } return false; }
template<typename T, typename U> inline bool umin(T& m, U x) { if (m > x) { m = x; return true; } return false; }
template<typename T> inline void errv(T& v) { for (auto x: v) cerr << x << " "; cerr << endl; }
inline void errv(vb& v) { for (auto x: v) cerr << (x ? 1 : 0) << " "; cerr << endl; }
template<typename T> inline void dbgn(string n, T x) { cerr << n << ": " << x << endl; }
template<typename T> inline void dbgn(string n, vector<T>& v) { cerr << n << ": "; errv(v); }
template<typename T> inline void dbgn(string n, vv<T>& m) { cerr << n << ":" << endl; for (auto& v: m) errv(v); }


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

    vi c(26);
    rep(i, 26) cin >> c[i];

    vvi s(d, vi(26));
    rep(i, d) rep(j, 26) cin >> s[i][j];

    rep(i, d) {
        ll ans = 0;
        ll m = 0;
        rep(j, 26) {
            if (umax(m, s[i][j]))
                ans = j;
        }
        prt(ans + 1);
    }

    return 0;
}

Measured memory_bytes: 3680
#include<stdio.h>
int main(void)
{
  int p[30];
  int n;
  int count=0;
  scanf("%d",&n);
  for(int i=0;i<n;i++){
    scanf("%d",&p[i]);
  }
  for(int i=0;i<n-2;i++){
    if((p[i]<p[i+1]&&p[i+1]<p[i+2])||(p[i+2]<p[i+1]&&p[i+1]<p[i])){
      count++;
    }
  }

  printf("%d\n",count);
  return 0;
}


Measured memory_bytes: 128
// ACM-ICPC国内予選2013 E. つながれた風船

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

using namespace std;

pair<int,int> search(const vector< vector< pair<int,int> > >& g, int start, int n){
	vector<int> dist(n, -1);
	queue<int> qu; qu.push(start);
	dist[start] = 0;
	while(!qu.empty()){
		int pos = qu.front(); qu.pop();
		for(int i=0;i<g[pos].size();i++){
			if(dist[g[pos][i].first] != -1) continue;
			dist[g[pos][i].first] = dist[pos] + g[pos][i].second;
			qu.push(g[pos][i].first);
		}
	}
	int res = start;
	for(int i=0;i<n;i++){
		if(dist[res] < dist[i]) res = i; 
	}
	return make_pair(res, dist[res]);
}

int main(){
	int n;
	int p[800];
	while(cin >> n && n){
		vector<int> con(n, 0);
		vector< vector< pair<int,int> > > g(n);
		for(int i=0;i<n-1;i++){
			cin >> p[i];
			con[i+1]++;
			con[p[i]-1]++;
		}
		int res = 0;
		vector<int> e;
		for(int i=0;i<n-1;i++){
			int d; cin >> d;
			if(con[i+1] == 1 || con[p[i]-1] == 1) res += d;
			else {
				res += 3*d;
				g[i+1].push_back(make_pair(p[i]-1, d));
				g[p[i]-1].push_back(make_pair(i+1, d));
			}
		}
		for(int i=0;i<n;i++){
			if(con[i] == 1) continue;
			pair<int,int> pr = search(g, i, n);
			pr = search(g, pr.first, n);
			res -= pr.second;
			break;
		}
		cout << res << endl;
	}
}

Measured memory_bytes: 1268
#include <bits/stdc++.h>
using namespace std;
int main(void){
    vector <string> gdata;
    vector <string> bdata;
    int n; cin>>n;
    for(int i=0;i<n;i++){
        string s; cin>>s;
        gdata.push_back(s);
    }
    int w; cin>>w;
    for(int i=0;i<w;i++){
        string s; cin>>s;
        bdata.push_back(s);
    }
    int ans = 0;
    for(int i=0;i<gdata.size();i++){
        int cnt=0;
        for(int j=0;j<gdata.size();j++){
            if(gdata[i]==gdata[j]) cnt++;
        }
        for(int j=0;j<bdata.size();j++){
            if(gdata[i]==bdata[j]) cnt--;
        }
        ans = max(ans,cnt);
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <cstring>
#include <numeric>
#include <algorithm>
#include <functional>
#include <array>
#include <map>
#include <queue>
#include <limits.h>
#include <set>
#include <stack>
#include <random>
#include <complex>
#include <unordered_map>
#include <nmmintrin.h>
#include <chrono>
#define rep(i,s,n) for(int i = (s); (n) > i; i++)
#define REP(i,n) rep(i,0,n)
#define RANGE(x,a,b) ((a) <= (x) && (x) <= (b))
#define DUPLE(a,b,c,d) (RANGE(a,c,d) || RANGE(b,c,d) || RANGE(c,a,b) || RANGE(d,a,b))
#define INCLU(a,b,c,d) (RANGE(a,c,d) && (b,c,d))
#define PW(x) ((x)*(x))
#define ALL(x) (x).begin(), (x).end()
#define MODU 1000000007
#define bitcheck(a,b)   ((a >> b) & 1)
#define bitset(a,b)      ( a |= (1 << b))
#define bitunset(a,b)    (a &= ~(1 << b))
#define MP(a,b) make_pair((a),(b))
#define Manh(a,b) (abs((a).first-(b).first) + abs((a).second - ((b).second))
#define pritnf printf
#define scnaf scanf
#define itn int
#ifdef _MSC_VER
#define __builtin_popcount _mm_popcnt_u32
#define __builtin_popcountll _mm_popcnt_u64
#endif
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a%b);
}
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T &val) {
	std::fill((T*)array, (T*)(array + N), val);
}



signed main() {
	int n;
	scanf("%d", &n);
	vector<int> p(n);
	ll sum = 0;

	int Min = INT_MAX;

	REP(i, n) {
		scanf("%d", &p[i]);
		if (p[i] % 10) {
			Min = min(Min, p[i]);
		}
		sum += (ll)p[i];
	}

	if (sum % 10)
		printf("%d\n", sum);
	else if (Min != INT_MAX)
		printf("%d\n", sum - Min);
	else
		printf("0\n");
	return 0;
}

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

bool check(string s,int n,int m)
{
    unordered_map <string,pair<int,int>> mp;
    int i,j;
    for(i=0;i<=n-m;i++)
    {
        string a;
        for(j=i;j<i+m;j++)
            a.push_back(s[j]);
        if(mp.find(a)==mp.end())
            mp[a]={i,j-1};
        else if(i>mp[a].second)
            return true;
    }
    return false;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n,len,i,maxm=0,l,h,m;
    cin>>n;
    string s;
    cin>>s;

    h = n/2;
    l = 1;

    while(l<h)
    {
        m = (l+h+1)/2;
        if(check(s,n,m))
            l=m;
        else
            h=m-1;
    }
    if(!check(s,n,l))
        l--;
    cout<<l<<endl;
}

Measured memory_bytes: 18500
#include <stdio.h>
 
struct card {
    char suit;
    int value;
};
 
void swap(struct card *, struct card *);
void printc(int, struct card *);
 
int main(void)
{
    int i, j, minj, n, flag;
    struct card Cb[36], Cs[36];
     
    scanf("%d",&n);
    for (i=0; i<n; i++) {
        scanf(" %c%d", &Cb[i].suit, &Cb[i].value);
        Cs[i] = Cb[i];
    }
     
    for (i=0; i<n; i++) {
        for (j=n-1; j>i; j--) {
            if ( Cb[j].value < Cb[j-1].value ) swap( &Cb[j] , &Cb[j-1] );
        }
    }
     
    for (i=0; i<n; i++) {
        minj = i;
        for (j=i; j<n; j++) {
            if( Cs[j].value < Cs[minj].value ) minj = j;
        }
        if(i != minj) swap( &Cs[i], &Cs[minj]);
    }
    flag = 1;
    for (i=0; i<n; i++) {
        if( Cb[i].suit != Cs[i].suit ) {
            flag = 0;
            break;
        }
    }
     
    printc(n, Cb);
    printf("Stable\n");
    printc(n, Cs);
    if(flag) printf("Stable\n");
    else printf("Not stable\n");
     
    return 0;
}
 
void swap(struct card *card1, struct card *card2)
{
    struct card temp;
    temp = *card1;
    *card1 = *card2;
    *card2 = temp;
}
 
void printc(int n, struct card *C)
{
    int i;
    for (i=0; i<n-1; i++) {
        printf("%c%d ", C[i].suit, C[i].value);
    }
    printf("%c%d\n", C[n-1].suit, C[n-1].value);
}

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

int main () {
  
  int N; cin >> N;
  int M = N;
  int sum = 0;
  
  while (N > 0) {
    sum += N % 10;
    N /= 10;
  }
  
  if(M % sum == 0) cout << "Yes" << endl;
  else cout << "No" << endl;
  
  
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;

int main(){
  int n;

  while(cin >> n ,n){
    ll a[n],ans = 0;

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

    for(int i = 1 ; i < n ; i++){
      a[i] += a[i-1];
      ans += a[i-1];
    }

    cout << ans << endl;
  }

  return 0;
}

Measured memory_bytes: 1260
package main
  
import (
    "fmt"
)

func main() {
    var s []byte
    fmt.Scan(&s)
    var bad bool
    for i := 0; i < 3; i++ {
        if s[i] == s[i+1] {
            bad = true
        }
    }
    if bad {
        fmt.Println("Bad")
    } else {
        fmt.Println("Good")
    }
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const int MAX = 5100000;
ll gcd(ll a, ll b) {
    return (b==0) ? a : gcd(b, a%b);
}

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;
    }
}

// 二項係数計算
ll COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

// 以下から
const int MAX_N = 100000;
struct Edge {
    int to;
    int id;
};

vector<vector<Edge>> g;
vector<int> ans;
const int MN = 15;
vector<int> searched(MN, 0);
vector<int> color(MN, -1);

int main() {
    int n; cin >> n;
    vector<int> v(n);
    int orderNum = 1;
    int breakCount = 0;
   rep(i,n) {
       cin >> v[i];
       if (orderNum == v[i]) {
           orderNum++;
       } else {
           breakCount++;
       }
   }
   if (orderNum == 1) {
       cout << -1 << endl;
   } else {
       cout << breakCount << endl;
   }

   //割る数を求める





}


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

#define FOR(i,s,e) for(int i = (s);i <= (e);i++)

int N;
int W;

int v[110];
int w[110];

int dp[110][10010];

int main()
{

	cin >> N >> W;
	FOR(i,0,N - 1) cin >> v[i] >> w[i];
	
	FOR(i,0,N - 1)
	{
		FOR(j,0,W)
		{
			
			if(j - w[i] >= 0)
			{
				dp[i + 1][j] = max(dp[i][j] , dp[i][j - w[i]] + v[i]);
			}
			else
			{
				dp[i + 1][j] = dp[i][j];
			}
		}
	}

	cout << dp[N][W] << endl;
	return 0;
}



Measured memory_bytes: 7004
if __name__ == "__main__":
    inp = [int(i) for i in input().split()]
    K = inp[0]
    S = inp[1]
    c = 0
    for x in range(K+1):
        for y in range(K+1):
            z = S - x - y
            if z >= 0 and z <= K:
                c += 1
    print(c)

Measured memory_bytes: 3060
//17571@nith.ac.in (mail address) @Ankit Verma
#include<bits/stdc++.h>
using namespace std;
int main()
{
   string s, t; cin >> s;
   cin >> t;
   int res = 0;
   for(int i = 0; i < 3; i++) {
   		if(s[i] == t[i]) {
   			res++;
   		}
   }
   cout << res << endl;

 
   return 0;
}

Measured memory_bytes: 256
N, M = map(int, input().split())
s = [input().split() for i in range(M)]
fl = 1
ans = -1

if M == 0:
  if N != 1:
  	ans = 10**(N-1)
  else:
    ans = 0
else:
  for num in range(1000):
    if fl == 0:
      break
    else:
      if len(str(num)) != N:
        continue
      for i in range(M):
          if int(str(num)[int(s[i][0])-1]) != int(s[i][1]):
            break
          elif i == M-1:
            ans = num
            fl = 0
print(ans)


		

Measured memory_bytes: 3064
#include <stdio.h>

#define rep(i, n) for (int i = 0; i < n; i = i + 1)
#define MAX 10010
#define MAX_INT 9223372036854775807

int main() {
  char input;
  scanf("%c", &input);

  char UpperCase[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
  char LowerCase[] = "abcdefghijklmnopqrstuvwxyz";

  rep(i, 26) {
    if (input == UpperCase[i]) {
      printf("%c\n", 'A');
      break;
    } else if (input == LowerCase[i]) {
      printf("%c\n", 'a');
      break;
    }
  }

  return 0;
}


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

int main(void){
    int N, D1buf, D2buf;
    int numSame = 0;
    int numSameMax = 0;
    cin >> N;
    for(int i=0; i<N; i++){
        cin >> D1buf >> D2buf;
        if(D1buf == D2buf){
            numSame++;
        }else numSame = 0;
        numSameMax = max(numSameMax, numSame);
    }
    if(numSameMax >= 3){
        cout << "Yes" << endl;
    }else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3592
#include <iostream>

bool is_prime(int n) {
    for (int i = 2; i < n; i++) {
        if (n % i == 0) {
            return false;
        }
    }

    return true;
}

int main() {
    int N;
    std::cin >> N;

    std::cout << "11 31 41 61 71";
    N -= 5;

    for (int n = 101; n < 55555; n += 10) {
        if (N == 0) break;

        if (is_prime(n)) {
            std::cout << " " << n;
            N--;
        }
    }

    std::cout << std::endl;

    return 0;
}



Measured memory_bytes: 256
N, M, R = map(int, input().split())
r = list(map(int, input().split()))
ABC = [list(map(int, input().split())) for i in range(M)]

dist = [[float('inf') for _ in range(N+1)] for _ in range(N+1)]

for i in range(N+1):
    dist[i][i] = 0
for a, b, c in ABC:
    dist[a][b] = c
    dist[b][a] = c

# ワーシャルフロイドで各頂点ごとの最短距離を求める
for k in range(N+1):
    for i in range(N+1):
        for j in range(N+1):
            dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j])

from itertools import permutations as per

ans = float('inf')
for k in per(r, R):
    score = 0
    for i in range(R-1):
        score += dist[k[i]][k[i+1]]
    ans = min(ans, score)

print(ans)


Measured memory_bytes: 71896
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define MOD 1000000007
#define INF (1<<30)
#define LINF (1LL<<60)
#define endl "\n"
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
typedef unsigned long long int ull;
typedef long long lint;
 
int main(void){
    int N,K;
    cin >> N >> K;
    int h[N];
    rep(i,N) cin >> h[i];
    int ans=0;
    rep(i,N) if(K<=h[i]) ans++;
    cout << ans << endl;
}

Measured memory_bytes: 768
import math

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

gcd_list = [0 for _ in range(N)]

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

for i in range(1, N):
    gcd_list[i] = gcd(gcd_list[i-1], A[i-1])
last_gcd = 0
for i in range(N-2, -1, -1):
    last_gcd = gcd(last_gcd, A[i+1])
    gcd_list[i] = gcd(last_gcd, gcd_list[i])

print(max(gcd_list))


Measured memory_bytes: 14436