akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
#define ll long long
#define rep(i,n) for (int i = 0; i < n; i++)
#define MOD (1000000007)
#define vi vector<int>
#define vii vector<vi>

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

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

const ll INF = 1LL << 60;

int main(){
  int n; cin >> n;
  vi a(n); for(auto &x:a) cin >> x;
  int ans = a[0];

  for (int i = 1; i < n; i++) {
    ans = gcd(ans,a[i]);
  }
  std::cout << ans << '\n';
}


Measured memory_bytes: 640
n,k=map(int,input().split())
a=tuple(map(int,input().split()))
b=[-1 for i in range(n)]
b[0]+=1
h=0
for i in range(0,k):
    h=a[h]-1
    
    if b[h]==-1:
        b[h]=i+1
    
    else:
        t=i+1-b[h]
        for j in range((k-i-1)%t):
            h=a[h]-1
        print(h+1)
        break
else:
    print(h+1)

Measured memory_bytes: 32412
#include <iostream>
#include <vector>
#include <cmath>
#include <string>
#include <iomanip>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <sstream>
#include <complex>

using namespace std;

using ii = pair<int, int>;
using vi = vector<int>;
using vii = vector<ii>;
using vvi = vector<vi>;
using iii = pair<int, ii>;
using viii = vector<iii>;

using ll = long long int;
using vc = vector<char>;
using vb = vector<bool>;
using ib = pair<int, bool>;
using vib = vector<ib>;

#define MOD 1000 * 1000 * 1000 + 7
#define INF 1000 * 1000 * 1000
#define EMPTY -10
#define mp(a, b) make_pair(a,b)

bool resuelveCaso() {
	int n, m;
	cin >> n >> m;
	if (!cin) return false;

	int gcd = m / n;
	int sol;


	while (true) {
		if (m % gcd == 0) {
			sol = gcd;
			break;
		}
		else --gcd;
	}

	cout << sol << '\n';

	return true;
}

int main() {
	while (resuelveCaso()) {}
	return 0;
}

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

int main(){
  int N; cin >> N;
  vector<int> d(N); rep(i, N) cin >> d[i];
  long long ans = 0;
  rep(i, N) rep(j, N) {
    if (i >= j) continue;
    ans += d[i] * d[j];
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
import numpy as np
n=int(input())
s=input()
ans = 0
kuro = [0]*(n+1)
siro = [0]*(n+1)
if n==1:
    ans=0
if n ==2:
    if s=="#.":
        ans=1
else: 
    for i,j in enumerate(s[::-1]):
        if j==".":
            kuro[i+1]=kuro[i]+1
        else:
            kuro[i+1]=kuro[i]
    for i,j in enumerate(s):
        if j == "#":
            siro[i+1]=siro[i]+1
        else:
            siro[i+1]=siro[i]
            
    ku = np.array(kuro[::-1])
    si = np.array(siro)
    ans=np.min(ku+si)
    
print(ans)

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

#define int long long
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rep1(i,n) for(int i=1;i<=(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define repm(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define sperase(v,n) (v).erase(remove(all(v), n), (v).end());
#define vdelete(v) (v).erase(unique(all(v)), (v).end());
#define pb(n) push_back(n);
#define mp make_pair
#define MOD 1000000007
#define INF 9223372036854775807

int n,a,ans;
map<int,int,greater<int>> m;

main() {
    cin >> n;
    rep(i,n) cin >> a,m[a]++;
    for(auto i : m) {
        if (i.se >= 4) {
           if (ans) cout << ans*i.fi << endl;
           else cout << i.fi*i.fi << endl;
           return 0;
        }
        if (i.se >= 2) {
            if (ans) {cout << ans*i.fi << endl;return 0;}
            else ans = i.fi;
        }
    }
    cout << 0 << endl;
}


Measured memory_bytes: 6528
#include <stdio.h>
#include <string.h>

int main(void) {
   char S[4], T[4];
   int i, cnt = 0;


   gets(S);
   gets(T);

   for(i = 0; i < 3; i++) {
      if(S[i] == T[i]) {
         cnt++;
      }
   }

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

   return 0;
}


Measured memory_bytes: 128
#include <stdio.h>

int main(void)
{
	int x,y;
	int a=0;
	int c=0;
	
	scanf("%d %d",&x,&y);
	
	int b[]={4,6,9,11};
	
	for(int i=0;i<4;i++){
		if(x==b[i]){
			a++;
			break;
		}
	}
	for(int i=0;i<4;i++){
		if(y==b[i]){
			c++;
			break;
		}
	}
	
	if(x==2||y==2){
		printf("No\n");
	}else if((a!=0&&c==0)||(a==0&&c!=0)){
		printf("No\n");
	}else{
		printf("Yes\n");
	}
	
	return 0;
}
		

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 2e5+5;
ll u[N], v[N];
int main()
{
	ll n; scanf("%lld", &n);
	for (ll i = 1; i < n; i++) {
		scanf("%lld%lld", u+i, v+i);
		if (u[i] > v[i]) swap(u[i], v[i]);
	}
	ll ans = n*n*(n+1)/2;
	for (ll i = 1; i <= n; i++) ans -= n*(n+1)/2 - i*(n-i+1);
	for (ll i = 1; i < n; i++) ans -= u[i] * (n-v[i]+1);
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 6936
def main():
    N = int(input())
    trains = [list(map(int, input().split(' '))) for _ in range(N - 1)]
    ans = [0 for _ in range(N)]
    for i in range(N - 1):
        t = 0
        for train in trains[i:]:
            c, s, f = train
            wait_time = s - t if t <= s else (f - t) % f
            t += wait_time + c
        ans[i] = t
    for a in ans:
        print(a)


if __name__ == '__main__':
    main()

Measured memory_bytes: 3188
#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<algorithm>
using namespace std;
typedef long long ll;


class Graph
{
    public:
        int n;
        vector<vector<int> > adj;
        vector<int> dp;
        Graph(int n )
        {
            this->n  = n;
            adj.resize(n+1);
            dp.resize(n+1);
        }

        void add_edge(int u, int v)
        {
            adj[u].push_back(v);
        }
        void dfs(int u , vector<bool>& visited)
        {
            int res = 0;
            visited[u]  = true;
            for(auto v : adj[u])
            {
                if(!visited[v])
                    dfs(v,visited);
                res = max( res , 1 + dp[v]);
            }

            dp[u] = res;
        }

        void solve()
        {
            vector<bool> visited(n+1, false);
            for(int i = 1; i<= n; i++)
            {
                if(!visited[i])
                        dfs(i,visited);
            }

            cout<<*max_element(dp.begin(),dp.end())<<"\n";
        }


};

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n,m;
    cin>>n>>m;
    Graph g(n);
    for(int  i= 0; i<m;i++)
    {
        int x, y;
        cin>>x>>y;
        g.add_edge(x,y);
    }
    g.solve();
}

Measured memory_bytes: 7552
N,L = map(int,input().split())
A = list(map(int,input().split()))

for i,(a,b) in enumerate(zip(A,A[1:])):
    if a+b >= L:
        print('Possible')
        break
else:
    print('Impossible')
    exit()
ans = []
for j in range(1,i+1):
    ans.append(j)
for j in range(N-1,i+1,-1):
    ans.append(j)
ans.append(i+1)
print(*ans, sep='\n')

Measured memory_bytes: 14052
// eddy1021
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
typedef double D;
typedef long double LD;
typedef long long LL;
typedef pair<int,int> PII;
typedef pair<LL,LL> PLL;
#define mod9 1000000009LL
#define mod7 1000000007LL
#define INF  1023456789LL
#define INF16 10000000000000000LL
#define eps 1e-9
#define SZ(x) (int)(x).size()
#define ALL(x) (x).begin(), (x).end()
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#ifndef ONLINE_JUDGE
#define debug(...) printf(__VA_ARGS__)
#else 
#define debug(...)
#endif
inline LL getint(){
  LL _x=0,_tmp=1; char _tc=getchar();    
  while( (_tc<'0'||_tc>'9')&&_tc!='-' ) _tc=getchar();
  if( _tc == '-' ) _tc=getchar() , _tmp = -1;
  while(_tc>='0'&&_tc<='9') _x*=10,_x+=(_tc-'0'),_tc=getchar();
  return _x*_tmp;
}
inline LL add( LL _x , LL _y , LL _mod = mod7 ){
  _x += _y;
  return _x >= _mod ? _x - _mod : _x;
}
inline LL sub( LL _x , LL _y , LL _mod = mod7 ){
  _x -= _y;
  return _x < 0 ? _x + _mod : _x;
}
inline LL mul( LL _x , LL _y , LL _mod = mod7 ){
  _x *= _y;
  return _x >= _mod ? _x % _mod : _x;
}
LL mypow( LL _a , LL _x , LL _mod ){
  if( _x == 0 ) return 1LL;
  LL _ret = mypow( mul( _a , _a , _mod ) , _x >> 1 , _mod );
  if( _x & 1 ) _ret = mul( _ret , _a , _mod );
  return _ret;
}
LL mymul( LL _a , LL _x , LL _mod ){
  if( _x == 0 ) return 0LL;
  LL _ret = mymul( add( _a , _a , _mod ) , _x >> 1 , _mod );
  if( _x & 1 ) _ret = add( _ret , _a , _mod );
  return _ret;
}
inline bool equal( D _x ,  D _y ){
  return _x > _y - eps && _x < _y + eps;
}
#define Bye exit(0)
int __ = 1 , _cs;
/*********default*********/
#define N 202020
void build(){

}
int n , m;
set<int> s[ N ];
void init(){
  n = getint();
  m = getint();
  while( m -- ){
    int ai = getint();
    int bi = getint();
    s[ ai ].insert( bi );
    s[ bi ].insert( ai );
  }
}
bool okay(){
  for( auto i : s[ 1 ] )
    if( s[ n ].count( i ) )
      return true;
  return false;
}
void solve(){
  puts( okay() ? "POSSIBLE" : "IMPOSSIBLE" );
}
int main(){
  build();
  //__ = getint();
  while( __ -- ){
    init();
    solve();
  }
}


Measured memory_bytes: 28416
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <numeric>
#include <tuple>
#include <stack>

#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define print(s) cout << s << endl
typedef long long ll;
using namespace std;

int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

int main() {
	int n; cin >> n;
	vector<int> v(n);
	rep(i,n) cin >> v[i];
	int count = 0;
	while(true){
		bool roop = false;
		rep(i,n){
			if (v[i]%2 == 1){
				roop = true;
				break;
			}
		}
		if (roop){
			break;
		}
		rep(i,n){
			v[i] /= 2;
		}
		count++;
	}
	cout << count << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#define N 3
#define M 4

int a[N][N],temp[N][N],dx[M]={0,1,0,-1},dy[M]={1,0,-1,0};
void empty(int *x,int *y) {
  int i,j;
  for(i=0;i<N;i++){
    for(j=0;j<N;j++){
      if(!a[i][j]){
        *x=j;
        *y=i;
        return;
      }
    }
  }
}
void swap(int *a, int *b) {
  int temp;
  temp = *a;
  *a = *b;
  *b = temp;
}
int cal() {
  int i,u,sum=0;
  for(i=0;i<9;i ++){
    u=a[i/N][i%N];
    if(u != 0){
      u--;
      sum += abs(i/N - u/N)+abs(i%N - u%N);
    }
  }
  return sum;
}
int dfs(int x, int y, int p, int d, const int lim) {
  int i,v,nx,ny,res;
  v=cal();
  if(v == 0) return d;

  if(d+v > lim) return -1;

  for(i=0;i<M;i++){
    nx = x+dx[i];
    ny = y+dy[i];
    if(~p&&i == (p+2)%M) continue;
    if(!(0 <= nx && nx < N && 0 <= ny && ny < N)) continue;
    swap(&a[y][x],&a[ny][nx]);
    res=dfs(nx,ny,i,d+1,lim);
       if(~res) return res;

    swap(&a[y][x],&a[ny][nx]);
  }
  return -1;
}
int main() {
  int i,j,ans,x,y,l;
  for(i=0;i<N;i++){
    for(j=0;j<N;j++){
      scanf("%d",&a[i][j]);
    }
  }
  empty(&x,&y);
  for(l=0;l<100;l++){
    for(i=0;i<N;i++){
        for(j =0;j<N;j++){
        temp[i][j] = a[i][j];
      }
    }
    ans = dfs(x,y,-1,0,l);
    if(ans != -1){
      printf("%d\n",ans);
      break;
    }

    for(i=0;i<N;i++){
      for(j=0;j<N;j++){
        a[i][j]=temp[i][j];
      }
    }
    ans = -1;
    if(l == 99){
      printf("%d\n",ans);
    }
  }
  return 0;
}
        


Measured memory_bytes: 2108
#include <bits/stdc++.h>
#define ll long long
#define rep(i, n)(for i-0;i<(n);++i)
using namespace std;
int gcd(int x, int y) { return (x % y) ? gcd(y, x % y) : y; }
const double PI = 3.14159265358979323846;
int main() {
  string s;
  cin >> s;
  string b(s);
  reverse(b.begin(), b.end());
  // cout << b << endl;
  int n = s.size();
  // cout << n;
  if (s == b && s.substr(0, (n - 1) / 2) == b.substr((n + 1) / 2) &&
      s.substr((n + 1) / 2) == b.substr(0, (n - 1) / 2)) {
    cout << "Yes";
  } else {
    cout << "No";
  }
  return 0;
}

Measured memory_bytes: 256
from decimal import Decimal
a,b,c,d,e,f = list(map(int, input().split()))
maxn = -1
ans = ()
for at in range(0,31):
    for bt in range(0,31-at):
        water = (at * a + bt * b) * 100
        if water > f:
            continue

        # 溶け残らないように砂糖を選ぶ
        maxsugar = water * e // 100
        for ct in range(0, (maxsugar+1)//c + 1):
            for dt in range(0, (maxsugar-ct*c+1)//d + 1):
                sugar = ct * c + dt * d

                if 0 < sugar + water <= f and sugar <= (at * a + bt * b) * e:
                    # 水１００に対して溶けている砂糖の量
                    n = Decimal(100 * sugar / water)
                    if n == Decimal(e):
                        print(water + sugar, sugar)
                        exit()
                    if n > maxn:
                        ans = water + sugar, sugar
                        maxn = n
print(*ans)

Measured memory_bytes: 9952
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

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

using namespace std;
typedef long long ll;

int main()
{
    // Input
    int a, b;
    cin >> a >> b;

    cout << a * b;

    return 0;
}


Measured memory_bytes: 3188
package main

import (
	"fmt"
	"math"
)

func main() {
	var p,q,r int 
	fmt.Scanf("%d %d %d", &p,&q,&r)
	fmt.Print(int(math.Min(float64(q+r), math.Min(float64(p+q),float64(p+r)))))
}

Measured memory_bytes: 512
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, c) for (int i = 0; i < (int)c; i++)
#define all(v) v.begin(), v.end()
const int inf = 1000000000; //10^9
using ll = long long;
using P = pair<int, int>;
//加算代入演算子は+=！！！！！

int main()
{
    int n;
    cin >> n;
    vector<ll> t(n), a(n);
    rep(i, n) cin >> t[i] >> a[i];
    ll total_t = 1, total_a = 1; //合計投票数をとりあえず最小の1にする。
    rep(i, n)
    {
        ll x = total_t / t[i]; //n番目のTへの合計投票数（合計投票数 * 比率）
        ll y = total_a / a[i]; //n番目のAへの合計投票数
        if (total_t % t[i] != 0) x++; //切り捨てられちゃうから余りがあるときはxを加算する。
        if (total_a % a[i] != 0) y++;
        ll temp = max(x, y);
        total_t = temp * t[i];
        total_a = temp * a[i];
    }
    cout << total_t + total_a << endl;
    return 0;
}

Measured memory_bytes: 256
a,b,c,d = map(int,input().split())
ABdis = abs(a - b)
ACdis = abs(a - c)
BCdis = abs(b - c)

if ACdis <= d:
    print('Yes')
else:
    if ABdis <= d and BCdis <= d:
        print('Yes')
    else:
        print('No')

Measured memory_bytes: 3060
def main():
    N = int(input())
    G = [[] for _ in range(N)]
    edge = [-1] * (N-1)
    for i in range(N-1):
        a, b = (int(i)-1 for i in input().split())
        G[a].append(b*N + i)
        G[b].append(a*N + i)

    max_deg = max(len(G[i]) for i in range(N))

    from collections import deque

    def bfs(s):
        que = deque([])
        par = [-1]*N
        que.append(s)
        while que:
            pos = que.popleft()
            c = -1
            k = 1
            for vi in G[pos]:
                v, i = divmod(vi, N)
                if par[pos] == v:
                    c = edge[i]
            for vi in G[pos]:
                v, i = divmod(vi, N)
                if par[pos] == v:
                    continue
                if k == c:
                    k += 1
                par[v] = pos
                edge[i] = k
                k += 1
                que.append(v)

    bfs(0)

    print(max_deg)
    for i in range(N-1):
        print(edge[i])


if __name__ == '__main__':
    main()


Measured memory_bytes: 92584
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define OUT(s) cout << s << "\n";
#define S_LEN(s) s.length();
#define L_LEN(l) sizeof(l) / sizeof(l[0]);
using namespace std;
int K;
int N;
vector<int> A(200000, int(200000));

int l_m = 0;

void Main(){
    REP(i, N) {
        int tmp = 0;
        if (i == N-1) {
            tmp = A[0] + K - A[i];
        } else {
            tmp = A[i+1] - A[i];
        }
        if (tmp > l_m) {
            l_m = tmp;
        }
    }
    OUT(K - l_m);
}

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

    cin >> K >> N;
    REP(i, N) cin >> A[i];

    Main();
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define el '\n'
typedef long long ll;
const int MAXN = 1e5+2;
const ll MOD = 1e9+7;
int N, K;
ll F[MAXN], ans;
ll qu_pow(ll base, ll exp){
	if(exp==0)return 1;
	if(exp%2==0){
		ll tmp = qu_pow(base, exp/2)%MOD;
		return (tmp*tmp)%MOD;
	}else{
		ll tmp = qu_pow(base, exp-1)%MOD;
		return (base*tmp)%MOD;
	}
}
int main() {
	cin.tie(0);
	cin.sync_with_stdio(0);
	cin >> N >> K;
	for(int i = K;i>=1;i--){
		F[i] = qu_pow(K/i, N);
		for(int j = 2*i;j<=K;j+=i){
			F[i]-=F[j];
		}
		ans+=((1LL)*F[i]*i)%MOD;
		ans%=MOD;
	}
	cout << (ans+MOD)%MOD << el;
	return 0;
}

Measured memory_bytes: 4424
#include <bits/stdc++.h>
using namespace std;
#ifdef _DEBUG
#define dlog(str) cout << "====" << str << endl;
#else
#define dlog(str)
#endif
#define INF 999999999
#define MOD 1000000007
#define REP(i, n) for(int i = 0, i##_l = (n); i < i##_l; i++)
#define FOR(i, s, e) for(int i = s, i##_l = (e); i < i##_l; i++)
#define LLI long long int
#define _min(a, b) ((a < b) ? a : b)
#define _max(a, b) ((a < b) ? b : a)
#define chmax(a, b) a = _max(a, b)
#define chmin(a, b) a = _min(a, b)
#define bit(a, shift) ((a>>shift)&1))
#define pm(a) ((a) ? 1 : -1)
#define SORT(v) sort(v.begin(), v.end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
// int 2.14E±9    lli 9.2E±18    double 1.7E±380

int main() {
    cout << fixed << setprecision(10);
    int N;
    cin >> N;
    vector<int> h(N);
    REP(i, N) { cin >> h[i]; }
    int ma = 0;
    int cnt = 0;
    REP(i, N - 1) {
        if(h[i] >= h[i + 1]) {
            cnt++;
        } else {
            chmax(ma, cnt);
            cnt = 0;
        }
    }
    chmax(ma, cnt);
    cout << ma;
    return 0;
}

Measured memory_bytes: 640
n,m = map(int,input().split())
s = [0]*n
dp = [0]*(n+1)
for i in range(m):
    s[int(input())-1] = 1
dp[0] = 1
if s[0] == 1:
    dp[1] = 0
else:
    dp[1] = 1
for i in range(2,n+1):
    if s[i-1] == 1:
        dp[i] = 0
    else:
        dp[i] = dp[i-1]+dp[i-2]
print(dp[n]%1000000007)

Measured memory_bytes: 466544
import java.util.*;
class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int K = sc.nextInt();
    int[] h = new int[N];
    int count = 0;
    for (int i = 0; i < N; i++) {
      if (sc.nextInt() >= K) {
        count++; 
      }
    }
    System.out.println(count);
  }
}

Measured memory_bytes: 48844
#include <bits/stdc++.h>
using namespace std;
int main(){
	int N; 
	long long int X; 
	cin >> N >> X; 
	long long int A[4019] = {}; 
	long long int B[2019][2019] = {}; // B[スライムi][j回以下の魔法] = コストの最小値
	long long int S[2019] = {}; // j回の魔法のときのコストの最小値
	for(int i = 0; i < N; i++){
		cin >> A[i]; 
		A[i + N] = A[i]; 
		B[i][0] = A[i]; 
		S[0] += A[i]; 
	}
	for(int i = 0; i < N; i++){
		for(int j = 1; j < N; j++){
			B[i][j] = min(B[i][j-1], A[i+N-j]); 
			S[j] += B[i][j]; 
		}
	}
	long long int ans = 1e15; 
	for(int j = 0; j < N; j++){
		ans = min(ans, (long long) j * X + S[j]); 
	}
	cout << ans << endl; 
}

Measured memory_bytes: 32128
N,K = map(int,input().split())
V = list(map(int,input().split()))

value = max_value = 0
for j in range(K//2+1):
    for i in range(K-j+1):
        if K-j >= N:
            value = V
        else:
            if i == K-j:
                value = V[:K-j]
            else:
                value = V[:i]+V[-(K-j-i):]
        value.sort()
        # print(i,j,value)


        jj = min(len(value)-1,j)
        if value[jj] <= 0:
            s = sum(value[jj:])
        else:
            s = sum([i for i in value if i>0])

        if  s > max_value:
            max_value = s
print(max_value)

Measured memory_bytes: 3064
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>
#include <random>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
//#define int long long

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;
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; }

void solve() {
    int x;
    cin >> x;
    if (x >= 30) cout << "Yes" << endl;
    else cout << "No" << endl;
}

signed main() {
    solve();
    
    return 0;
}

Measured memory_bytes: 3632
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<string>
#include<sstream>
#include<cmath>
#include<numeric>
#include<map>
#include<stack>
#include<queue>
using namespace std;
long long mod = 1e9+7;

int main(void) {
  long long l, r; cin >> l >> r;
  long long ans = 2019;
  for(long long i=l; i<=r; i++) {
    for(long long j=i+1; j<=r; j++) {
      ans = min(ans, (i*j)%2019);
      if(ans == 0) {
        cout << ans << endl;
        return 0;
      }
    }
  }
  cout << ans << endl;

  return 0;
}

// EOF


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

const ll LINF = 1e18;
const int INF = 1e9;
const ll MOD = 1000000007;

int main(){

    string s;
    cin >> s;
    int a, b;
    a = stoi(s.substr(0, 2));
    b = stoi(s.substr(2, 2));
    if((0 < a) && (a <= 12)){
        if((0 < b) && (b <= 12)){
            cout << "AMBIGUOUS" << endl;
        }
        else{
            cout << "MMYY" << endl;
        }
    }
    else{
        if((0 < b) && (b <= 12)){
            cout << "YYMM" << endl;
        }
        else{
            cout << "NA" << endl;
        }
    }
    return 0;
}

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

using namespace std;
typedef long long int ll;
typedef pair<ll, ll > pi;  
typedef pair<pair<ll, ll >, ll > pii;  
vector<ll > vec;
vector<vector<ll > > vec2;
ll MOD = 1000000007;
ll INF = 1145141919454519;

//8近傍
ll dy[8] = {1, 1, 1, 0, -1, -1, -1, 0};
ll dx[8] = {-1, 0, 1, 1, 1, 0, -1, -1};
ll ans[100][100];
ll input[100][100];

int main() {

    ll H, W;
    cin >> H >> W;

    for(ll i = 1; i <= H; i++){
        string S;
        cin >> S;
        for(ll j = 1; j <= W; j++){
            input[i][j] = S[j-1];
        }
    }

    for(ll i = 1; i <= H; i++){
        for(ll j = 1; j <= W; j++){
            for(ll k = 0; k < 8; k++){
                if(input[i][j] == '#') ans[i+dy[k]][j+dx[k]]++;
            }
        }
    }

    for(ll i = 1; i <= H; i++){
        for(ll j = 1; j <= W; j++){
            if(input[i][j] == '#') cout << '#';
            else cout << ans[i][j];            
        }
        cout << endl;
    }
}

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


int main() {
    int n,k;
    cin>>n>>k; 
    int h[n];

    int ans = 0;
    rep(i,n){
        cin>>h[i];
        if(h[i] >= k) ++ans;
    }

    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 640
import java.util.Scanner;

class Main {

	public static void main(String args[]){

		Scanner scan = new Scanner(System.in);
		int n;
		n = scan.nextInt();
		scan.close();
		
		long power = 1;
		
		for(int i = 1; i <= n; i++){
			power *= i;
			power %= 1000000007;
		}
		System.out.print(power);
	}
}

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

using namespace std;
//#pragma GCC optimize("O3")

typedef long long ll;
typedef long double ld;

int main() {
    //freopen("input.txt", "r", stdin);
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    ll n, a, b;
    cin >> n >> a >> b;
    if (a > b || (n == 1 && (a != b))) {
        cout << 0;
        return 0;
    }
    cout << (n - 2) * (b - a) + 1;
    return 0;
}


Measured memory_bytes: 3612
class Dice:
    dice = {'N':2, 'E':4, 'S':5, 'W':3}
    currTop = 1

    def top(self):
        return self.currTop

    def rot(self, direction):
        newTop = self.dice[direction]
        currTop = self.currTop
        self.currTop = newTop
        if direction == 'N':
            self.dice['N'] = 7 - currTop
            self.dice['S'] = currTop
        elif direction == 'S':
            self.dice['N'] = currTop
            self.dice['S'] = 7 - currTop
        elif direction == 'E':
            self.dice['E'] = 7 - currTop
            self.dice['W'] = currTop
        elif direction == 'W':
            self.dice['E'] = currTop
            self.dice['W'] = 7 - currTop


faces = list(map(int, input().split()))
cmd = input()

d = Dice()
for c in cmd:
    d.rot(c)

print(faces[d.top()-1])

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

using namespace std;

int main() {
    string s;
    cin>>s;
    int len = s.length();
    int flag = 0;
    for(int i = 0; i < len-1; i++) {
        if(s[i] == s[i+1]) {
            cout<<i+1<<" "<<i+2;
            flag = 1;
            break;
        } else if( s[i] == s[i+2]) {
            cout<<i+1<<" "<<i+3;
            flag = 1;
            break;
        }
    }
    if(!flag) {
        cout<<-1<<" "<<-1;
    }
    cout<<endl;
    return 0;
}

Measured memory_bytes: 3740
let f x y =
  let rec loop n m=
    if n mod m = 0 then
      begin
        Printf.printf " %d" m;
        loop (n/m) m
      end
    else
      n
  in loop x y;
;;

let () =
  let num = read_int () in
  let s = (string_of_int num)^":" in
  let rec loop n m step =
    if n < m*m then
      if n != 1 then Printf.printf " %d" n else ()
    else
      if n mod m = 0 then
        begin
          Printf.printf " %d" m;
          loop (n/m) m step
        end
      else if step = 2 then
        loop n (m+2) 4
      else
        loop n (m+4) 2
  in
  Printf.printf "%s" s;
  let n2 = f num 2 in
  let n3 = f n2 3 in
  loop n3 5 2;
  print_newline ()
;;

Measured memory_bytes: 2348
#include <bits/stdc++.h>
using namespace std;
int main(){
int N;
  cin>>N;
  vector<int>T(N);
  int s=0;	
  for(int i=0;i<N;i++){
    cin>>T.at(i);
  }
  for(int i=0;i<N;i++){
    for(int j=N-1;j>i;j--){
      s+=T.at(i)*T.at(j);
    }
  }
  cout<<s<<endl;
}

Measured memory_bytes: 256
N = input()
s = [input() for _ in range(N)]
if sum(s) % 10 == 0:
  non_multiple_10 = [v for v in s if v % 10 != 0]
  if len(non_multiple_10) == 0:
    print 0
  else:
    print sum(s) - min(non_multiple_10)
else:
  print sum(s)

Measured memory_bytes: 2568
def gcd(a, b):
    if a < b:
        c = a
        a = b
        b = c

    r = a % b

    while r > 0:
        a = b
        b = r
        r = a % b

    return b

    # ll gcd(ll a, ll b) {
    #   if (a < b)
    #     swap(a, b);
    #   ll r = a % b;
    #
    #   while (r) {
    #     a = b;
    #     b = r;
    #     r = a % b;
    #   }
    #
    #   return b;
    # }


N = int(input())
a = []
for i in range(N):
    a.append(int(input()))
# a = list(map(int, input().split()))

ans = a[0]

for i in range(N):
    if i == 0:
        continue

    g = gcd(ans, a[i])
    ans = ans * a[i] // g

print(ans)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main(){
  string s; cin >> s;
  vector<int> ss[26];
  for (int i = 0; i < (int) s.size(); i++) {
    ss[s[i]-'a'].push_back(i);
  }
  string t; cin >> t;
  vector<bool> use(26, false);
  for (int x = 0; x < 26; x++) {
    if (ss[x].empty()) continue;
    int y = t[ss[x][0]] - 'a';
    if (use[y]) {
      cout << "No" << endl;
      return 0;
    } else use[y] = true;
    for (int z = 0; z < (int) ss[x].size(); z++) {
      if (t[ss[x][z]] - 'a' != y) {
        cout << "No" << endl;
        return 0;
      }
    }
  }
  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 1864
import math
N,A,B = map(int,input().split())
H = []
for i in range(N):
  H.append(int(input()))
ok = -1
ng = int(sum(H)/B)
while ng-ok > 1:
  mid = (ok+ng)//2
  cnt = 0
  for i in range(N):
    if H[i] < B*mid:
      None
    else:
      cnt += math.ceil((H[i]-B*mid)/(A-B))
  if cnt > mid:
    ok = mid
  else:
    ng = mid
print(ng)

Measured memory_bytes: 7068
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
 
const ll MOD=1e9+7;
ll n,m,anw=1;
vector<ll> a,b;
 
ll get(ll t)
{
	ll ret=0;	
	ll x=lower_bound(a.begin(),a.end(),t)-a.begin();	
	ll y=lower_bound(b.begin(),b.end(),t)-b.begin();
	if(a[x]==t&&b[y]==t)
		ret=1;
	else if(a[x]==t)
		ret=m-y;
	else if(b[y]==t)
		ret=n-x;
	else
		ret=(m-y)*(n-x)-(n*m-t);
	return ret;
}
 
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cin>>n>>m;
	for(int i=0;i<n;i++)
	{
		ll c;cin>>c;
		a.push_back(c);
	}
	for(int i=0;i<m;i++)
	{
		ll c;cin>>c;
		b.push_back(c);
	}
	sort(a.begin(),a.end());sort(b.begin(),b.end());
	a.erase(unique(a.begin(),a.end()),a.end());
	b.erase(unique(b.begin(),b.end()),b.end());
	if(a.size()!=n||b.size()!=m||a[a.size()-1]!=n*m||b[b.size()-1]!=n*m)
	{
		cout<<0;
		return 0;
	}
	for(ll i=1;i<=n*m;i++)
		anw=(anw*get(i))%MOD;
	cout<<anw;
	return 0;
}

Measured memory_bytes: 384
#!/usr/bin/env python3
#AGC33 A

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

h,w = LI()
maze = [list(input()) for _ in range(h)]
check = [[True]*w for _ in range(h)]
dx,dy = [0,1,0,-1],[1,0,-1,0]
que = deque()
for i in range(h):
    for j in range(w):
        if maze[i][j] == '#':
            check[i][j] = False
            que.append((j,i))
res = 0
while que:
    que2 = deque(que)
    que = deque()
    flg = False
    while que2:
        x,y = que2.popleft()
        for i in range(4):
            nx,ny = x + dx[i], y + dy[i]
            if 0 <= nx < w and 0 <= ny < h:
                if check[ny][nx]:
                    check[ny][nx] = False
                    que.append((nx,ny))
                    flg = True
    if flg:
        res += 1
print(res)

Measured memory_bytes: 130524
a = int(input())

is_prime = False
a_tmp = a
while is_prime == False:
  cnt = 0
  for i in range(1, a_tmp+1):
    is_div = (a_tmp % i == 0)
    if is_div:
      cnt += 1
  if cnt == 2:
    is_prime = True
    print(a_tmp)
  else:
    a_tmp += 1

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

int main() {
  int N, M, sum = 0;
  cin >> N >> M;
  vector<int> vec(M);
  
  for(int i = 0; i < M; i++) {
  	cin >> vec.at(i);
  }
    
  for(int i = 0; i < M; i++) {
  	sum += vec.at(i);
  }
  if(N - sum < 0) cout << "-1" << endl;
  else cout << N - sum << endl;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define debug(x) cerr<<#x<<" = "<<x
#define sp <<"  "
#define el <<endl
#define LL long long
#define M
using namespace std;
namespace IO{
	const int BS=(1<<20)+5; int Top=0;
	char Buffer[BS],OT[BS],*OS=OT,*HD,*TL,SS[20]; const char *fin=OT+BS-1;
	char Getchar(){if(HD==TL){TL=(HD=Buffer)+fread(Buffer,1,BS,stdin);} return (HD==TL)?EOF:*HD++;}
	void flush(){fwrite(OT,1,OS-OT,stdout);}
	void Putchar(char c){*OS++ =c;if(OS==fin)flush(),OS=OT;}
	void write(int x){
		if(!x){Putchar('0');return;} if(x<0) x=-x,Putchar('-');
		while(x) SS[++Top]=x%10,x/=10;
		while(Top) Putchar(SS[Top]+'0'),--Top;
	}
	int read(){
		int nm=0,fh=1; char cw=getchar();
		for(;!isdigit(cw);cw=getchar()) if(cw=='-') fh=-fh;
		for(;isdigit(cw);cw=getchar()) nm=nm*10+(cw-'0');
		return nm*fh;
	}
}
using namespace IO;
char ch[1000020];
int n,m,q[1000010];
LL p[1000020];
int main(){
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	n=read(),scanf("%s",ch+1);
	for(int T=read(),k,hd=0,tl=0;T;T--,tl=hd=0){
		LL ans=0,now=0,tag=0; k=read();
		for(int i=1;i<=n;i++){
			while(hd<tl&&q[hd]+k<=i) now-=tag+p[q[hd++]];
			if(ch[i]=='D') q[tl++]=i,p[i]=-tag;
			if(ch[i]=='M') tag++,now+=tl-hd;
			if(ch[i]=='C') ans+=now;
		} printf("%lld\n",ans);
	}
	return 0;
}

Measured memory_bytes: 14592
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>
#include <cstring>
#include <map>
#include <set>
#include <cmath>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define INF 1145141919
typedef long long int ll;
using namespace std;

template <typename T>
istream &operator>>(istream &is, vector<T> &vec)
{
    for (T &x : vec)
        is >> x;
    return is;
}

ll gcd(ll m, ll n)
{
    if ((0 == m) || (0 == n))
        return 0;
    while (m != n)
    {
        if (m > n)
            m = m - n;
        else
            n = n - m;
    }
    return m;
}

ll lcm(ll m, ll n)
{
    if ((0 == m) || (0 == n))
        return 0;
    return ((m / gcd(m, n)) * n);
}

int ctoi(const char c)
{
    if ('0' <= c && c <= '9')
        return (c - '0');
    return -1;
}

int main()
{
    int n, h, w;
    cin >> n >> h >> w;

    vector<int> a(n);
    vector<int> b(n);

    REP(i,n){
        cin >> a[i] >> b[i];
    }

    int ans=0;

    REP(i,n){
        if(a[i]>=h and b[i]>=w){
            ans++;
        }
    }

    cout << ans << endl;

    return 0;
}

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

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

    list<int> b;
    for(int i = 0; i < n;i++){
        cin >> a;
        
        if(i%2==0)b.push_front(a);
        else b.push_back(a);

        
    }
    
    if(n%2==0)reverse(b.begin(),b.end());
    
    list<int>::iterator itr;
    
    for(itr = b.begin(); itr != b.end();itr++){
        cout << *itr <<" ";
    }
    cout << endl;
    
    return 0;

    
}

Measured memory_bytes: 8448
# -*- coding: utf-8 -*-
import sys
import math
import os
import itertools
import _collections
import string
from functools import lru_cache
import heapq

class cin():
    def int():
        return int(sys.stdin.readline().rstrip())
    def string():
        return sys.stdin.readline().rstrip()
    def mapInt():
        return [int(x) for x in cin.string().split()]
    def stringList(n):
        return [input() for i in range(n)]
    def intListList(n):
        return [cin.mapInt() for i in range(n)]
    def intColsList(n):
        return [int(input()) for i in range(n)]
        
class Math():
    def gcd(a,b):
        if b == 0:
            return a
        return Math.gcd(b,a % b)
    def lcm(a,b):
        return (a * b) // Math.gcd(a,b)
    def roundUp(a,b):
        return -(-a // b)
    def toUpperMultiple(a,x):
        return Math.roundUp(a,x) * x
    def toLowerMultiple(a,x):
        return (a // x) * x
    def nearPow2(n):
        if n <= 0:
            return 0
        if n & (n - 1) == 0:
            return n
        ret = 1
        while(n > 0):
            ret <<= 1
            n >>= 1
        return ret
    def isPrime(n):
        if n < 2:
            return False
        if n == 2:
            return True
        if n % 2 == 0:
            return False
        d = int(n ** 0.5) + 1
        for i in range(3,d + 1,2):
            if n % i == 0:
                return False
        return True


MOD = int(1e09) + 7

def main():
    S = cin.string()
    while len(S) != 0:
        if S[-5:] == "dream":
            S = S[:-5]
        elif S[-7:] == "dreamer":
            S = S[:-7]
        elif S[-5:] == "erase":
            S = S[:-5]
        elif S[-6:] == "eraser":
            S = S[:-6]
        else:
            print("NO")
            return
    print("YES")
    return

if __name__ == "__main__":
    main()


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

int ri() {
	int n;
	scanf("%d", &n);
	return n;
}
int64_t rll() {
	long long n;
	scanf("%lld", &n);
	return n;
}

int main() {
	int t1 = ri(), t2 = ri();
	int64_t a1 = rll(), a2 = rll();
	int64_t b1 = rll(), b2 = rll();
	int64_t a = a1 - b1;
	int64_t b = a2 - b2;
	int64_t a_dist = t1 * a;
	int64_t b_dist = t2 * b;
	if ((a_dist > 0) == (b_dist > 0)) {
		std::cout << 0 << std::endl;
		return 0;
	}
	int64_t one_dist = a_dist + b_dist;
	if (!one_dist) {
		std::cout << "infinity" << std::endl;
		return 0;
	}
	if ((a_dist > 0) == (one_dist > 0)) {
		std::cout << 0 << std::endl;
		return 0;
	}
	int64_t res = 1;
	res += (std::abs(a_dist) / std::abs(one_dist)) * 2;
	if (std::abs(a_dist) % std::abs(one_dist) == 0) res--;
	std::cout << res << std::endl;
	
	return 0;
}


Measured memory_bytes: 256
#include<iostream>

int main() {
	char a, b;
	std::cin >> a >> b;

	if (a == 'H') {
		std::cout << (b == 'H' ? 'H' : 'D') << std::endl;
	}

	if (a == 'D') {
		std::cout << (b == 'H' ? 'D' : 'H') << std::endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<n; ++i)
#define rep1(i, n) for (int i=1; i<=n; ++i)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
constexpr ll  MOD = (1e9+7);
constexpr int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
constexpr int lcm(int a, int b) { return a / gcd(a, b) * b; }

template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
ll factorial(ll n, ll m=2) {
    // calculate n!
    m = max(2LL, m);
    ll rtn = 1;
    for (ll i=m; i<=n; i++) {
        rtn = (rtn * i) % MOD;
    }
    return rtn;
}
ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b;
        swap(a, b);
        u -= t * v;
        swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
ll modpow(ll a, ll n) {
    ll res = 1;
    while (n > 0) {
        if (n & 1)
            res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n, m; cin >> n >> m;
    if (n == m) puts("Yes"); 
    else puts("No");
    return 0;
}

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


int main(){

  int n;
  int i,j;
  int *A;
  int count=0,check;
  int key;


  scanf("%d",&n);
  A=malloc(n*sizeof(int));
  for(i=0;i<n;i++) scanf("%d",&A[i]);


  for(i=0;i<n-1;i++){
    check=count;
    for(j=n-2;j>=i;j--){
      if(A[j+1] < A[j]){
        key=A[j+1];
        A[j+1]=A[j];
        A[j]=key;
        count+=1;
      }
    }
    if(check==count) break;
  }
  
  printf("%d",A[0]);
  for(i=1;i<n;i++) printf(" %d",A[i]);
  printf("\n%d\n",count);
  return 0;
}


//バブルソート
//一つの過程で全く交換が行われなかったら、その後は続けなくて良い。
  
    

  


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

#include <iostream>
//#include <algorithm>
// #include <iomanip>
#define ll long long
#define map unordered_map
#define set unordered_set
#define pll pair<ll, ll>
#define vll vector<ll>
#define mll map<ll, ll>

using namespace std;

const ll MOD = 1000000007LL;
const ll INF = (1LL << 60LL);

int main() {
  // std::cout << std::fixed << std::setprecision(10);
  string str;
  cin >> str;

  ll K;
  scanf("%lld", &K);

  ll firstIndex = -1;
  for (ll i = 0; i < str.size(); i++) {
    if (str[i] != '1') {
      firstIndex = i;
      break;
    }
  }

  if (firstIndex == -1) {
    cout << (str[0]) << endl;
    return 0;
  }

  if (K >= firstIndex + 1) {
    cout << (str[firstIndex]) << endl;
    return 0;
  }

  cout << (1) << endl;
}


Measured memory_bytes: 3640
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>

using namespace std;
#define int long long int


// quoted from beet-aizu
template <typename T,typename E, typename F, typename G, typename H>
struct LazySegmentTree{
    //using F = function<T(T,T)>;
    //using G = function<T(T,E)>;
    //using H = function<E(E,E)>;
    int n,height;
    F f;
    G g;
    H h;
    T ti;
    E ei;
    vector<T> dat;
    vector<E> laz;
    LazySegmentTree(F f,G g,H h,T ti,E ei):
        f(f),g(g),h(h),ti(ti),ei(ei){}

    void init(int n_){
        n=1;height=0;
        while(n<n_) n<<=1,height++;
        dat.assign(2*n,ti);
        laz.assign(2*n,ei);
    }
    void build(const vector<T> &v){
        int n_=v.size();
        init(n_);
        for(int i=0;i<n_;i++) dat[n+i]=v[i];
        for(int i=n-1;i;i--)
            dat[i]=f(dat[(i<<1)|0],dat[(i<<1)|1]);
    }
    inline T reflect(int k){
        return laz[k]==ei?dat[k]:g(dat[k],laz[k]);
    }
    inline void eval(int k){
        if(laz[k]==ei) return;
        laz[(k<<1)|0]=h(laz[(k<<1)|0],laz[k]);
        laz[(k<<1)|1]=h(laz[(k<<1)|1],laz[k]);
        dat[k]=reflect(k);
        laz[k]=ei;
    }
    inline void thrust(int k){
        for(int i=height;i;i--) eval(k>>i);
    }
    inline void recalc(int k){    
        while(k>>=1)
            dat[k]=f(reflect((k<<1)|0),reflect((k<<1)|1));
    }
    void update(int a,int b,E x){
        thrust(a+=n);
        thrust(b+=n-1);
        for(int l=a,r=b+1;l<r;l>>=1,r>>=1){
            if(l&1) laz[l]=h(laz[l],x),l++;
            if(r&1) --r,laz[r]=h(laz[r],x);
        }
        recalc(a);
        recalc(b);
    }
    void set_val(int a,T x){
        thrust(a+=n);
        dat[a]=x;laz[a]=ei;
        recalc(a);
    }
    T query(int a,int b){
        thrust(a+=n);
        thrust(b+=n-1);
        T vl=ti,vr=ti;
        for(int l=a,r=b+1;l<r;l>>=1,r>>=1) {
            if(l&1) vl=f(vl,reflect(l++));
            if(r&1) vr=f(reflect(--r),vr);
        }
        return f(vl,vr);
    }
};

signed main(){
    
    int n, q; cin >> n >> q;
    auto f = [](int a, int b){ return a + b; };
    auto g = [](int a, int b){ return a + b; };
    auto h = [](int a, int b){ return a + b; };

    LazySegmentTree<int, int, decltype(f), decltype(g), decltype(h)> sg(f, g, h, 0, 0);
    sg.build(vector<int>(n, 0));
    for(int i = 0; i < q; i++){
        int com; cin >> com;
        if(!com){
            int s, t, x; cin >> s >> t >> x;
            sg.update(s - 1, t, x);
        }else{
            int idx; cin >> idx;
            cout << sg.query(idx - 1, idx) << endl;
        
        }
    }
    return 0;
}



Measured memory_bytes: 7556
fn solve() {
    let s = std::io::stdin();
    let mut sc = Scanner { stdin: s.lock() };
    let h: usize = sc.read();
    let w: usize = sc.read();
    if h == 1 || w == 1 {
        println!("{}", 1);
        return;
    }
    let x: usize = if w % 2 == 0 { w / 2 } else { w / 2 + 1 };
    let y: usize = if w % 2 == 0 { x } else { x - 1 };
    let a = if h % 2 == 0 { h / 2 } else { h / 2 + 1 };
    let b = h - a;
    println!("{}", x * a + b * y);
}

fn main() {
    std::thread::Builder::new()
        .stack_size(64 * 1024 * 1024) // 64MB
        .spawn(|| solve())
        .unwrap()
        .join()
        .unwrap();
}
pub mod utils {
    const DYX: [(isize, isize); 8] = [
        (0, 1),   //right
        (1, 0),   //down
        (0, -1),  //left
        (-1, 0),  //top
        (1, 1),   //down right
        (-1, 1),  //top right
        (1, -1),  //down left
        (-1, -1), //top left
    ];

    pub fn try_adj(y: usize, x: usize, dir: usize, h: usize, w: usize) -> Option<(usize, usize)> {
        let ny = y as isize + DYX[dir].0;
        let nx = x as isize + DYX[dir].1;
        if ny >= 0 && nx >= 0 {
            let ny = ny as usize;
            let nx = nx as usize;
            if ny < h && nx < w {
                Some((ny, nx))
            } else {
                None
            }
        } else {
            None
        }
    }
}

//snippet from kenkoooo
pub struct Scanner<R> {
    stdin: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn read_line(&mut self) -> String {
        use std::io::Read;
        let buf = self
            .stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b'\n' || b == b'\r')
            .take_while(|&b| b != b'\n' && b != b'\r')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }

    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 8572