akhauriyash/Code-Regression huggingface dataset:
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric, std.container, std.range;

enum P = 10L^^9+7;

void main()
{
    auto N = readln.chomp.to!int;
    auto DP = new long[][](N+1, 4);
    DP[0][0] = 1;
    foreach (i; 0..N) {
        (DP[i+1][0] += DP[i][0] * 8 % P) %= P;
        (DP[i+1][1] += DP[i][0] + DP[i][1] * 9 % P) %= P;
        (DP[i+1][2] += DP[i][0] + DP[i][2] * 9 % P) %= P;
        (DP[i+1][3] += DP[i][1] + DP[i][2] + DP[i][3] * 10 % P) %= P;
    }
    writeln(DP[N][3]);
}

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

#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define vsort(v) sort(v.begin(), v.end());
#define rvisort(v) sort(v.begin(), v.end(), greater<int>());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
// #define int long long
#define sz(x) int(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using ul = unsigned long;

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

int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { return a * b / GCD(a, b); }

inline bool inside(int y, int x, int H, int W) {
    return (y >= 0 && x >= 0 && y < H && x < W);
}

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

signed main()
{
  int d,g;
  cin>>d>>g;
  vi p(d), c(d);
  rep(i,d)cin>>p[i]>>c[i];
  
  int ans = 1001;
  for(int bit=0; bit<(1<<d); ++bit){
    ll sum = 0;
    int cnt = 0;
    for(int i=0; i<d; ++i){
      if(bit & (1<<i)) sum += (ll)c[i]+p[i]*100*(i+1), cnt += p[i];
    }
    if(sum >= g) chmin(ans, cnt);
    else{
      for(int i=d-1; i>=0; --i){
        if(bit & (1<<i)) continue;
        rep(j, p[i]){
          sum += (ll)100*(i+1);
          cnt++;
          if(sum >= g) break;
        }
        if(sum >= g) break;
      }
      chmin(ans, cnt);
    }
  }
  cout<<ans<<endl;
}


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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repr(i, n) for(int i = (int)(n); i >= 0; i--)
#define repm(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define repmr(i, m, n) for(int i = (int)(n); i >= (int)(m); i--)
#define all(x) (x).begin(),(x).end()
#define inf 2e9

using namespace std;
typedef long long int lli;
typedef long long ll;

int main() {
    int n, k;
    cin >> n >> k;

    cout << ((n%k == 0)?0:1) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const ll INF = 1LL << 60;
const ll MOD = (int)1e9 + 7;

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

int h, w;

bool isValid(vector<string> &m, vector<vector<bool>> &v, int i, int j)
{
    if (i < 0 || h <= i || j < 0 || w <= j)
    {
        return false;
    }
    if (m[i][j] == '#' || v[i][j])
    {
        return false;
    }
    return true;
}

int main()
{
    int H, W;
    cin >> H >> W;
    h = H;
    w = W;
    vector<string> maze;
    for (int i = 0; i < h; i++)
    {
        string s;
        cin >> s;
        maze.push_back(s);
    }
    int ans = 0;
    for (int i = 0; i < h; i++)
    {
        for (int j = 0; j < w; j++)
        {
            if (maze[i][j] == '#')
            {
                continue;
            }
            vector<vector<bool>> visited(h, vector<bool>(w, false));
            vector<vector<int>> dist(h, vector<int>(w, 0));
            int cnt = 0;
            queue<pii> q;
            q.push({i, j});
            visited[i][j] = true;
            while (!q.empty())
            {
                pii now = q.front();
                q.pop();
                for (int k = 0; k < 4; k++)
                {
                    pii next = {now.first + dx[k], now.second + dy[k]};
                    if (!isValid(maze, visited, next.first, next.second))
                        continue;
                    q.push(next);
                    visited[next.first][next.second] = true;
                    dist[next.first][next.second] = dist[now.first][now.second] + 1;
                    cnt = max(cnt, dist[next.first][next.second]);
                }
            }
            ans = max(ans, cnt);
        }
    }
    cout << ans << "\n";
}

Measured memory_bytes: 256
#include "iostream"
#include "algorithm"
#include "cstring"
#include "cstdio"
#include "cmath"
#include "vector"
#include "map"
#include "set"
#include "queue"
using namespace std;
#define MAXN 200006
#define int long long
#define rep(i, a, b) for (int i = (a), i##end = (b); i <= i##end; ++i)
#define per(i, a, b) for (int i = (a), i##end = (b); i >= i##end; --i)
#define pii pair<int,int>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define vi vector<int>
#define all(x) (x).begin() , (x).end()
#define mem( a ) memset( a , 0 , sizeof a )
typedef long long ll;
int n , m;
ll a , b , c; 
int A[MAXN];

void solve() {
	cin >> a;
	int res = 0;
	ll t = a;
	for( ll i = 2 ; i * i <= t ; ++ i ) if( a % i == 0 ) {
		int pr = 0;
		while( a % i == 0 ) a /= i , pr ++;
		
		int c = 0 , cur = 1;
		while( c <= pr ) 
			c += cur , ++ cur;
		res += cur - 2;
	}
	if( a != 1 ) ++ res;
	cout << res << endl;
}

signed main() {
//    int T;cin >> T;while( T-- ) solve();
    solve();
}



Measured memory_bytes: 3640
#include <iostream>
//#include <bits/stdc++.h>
#include <cstdlib>
#include <cstring>
#include <cstdio>
#include <vector>
#include <queue>
#include <algorithm>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define pb(x) push_back(x)
#define F first
#define S second
using namespace std;
const int N=2000;
vector<int> g[N];
int n;
bool used[N];
int k;
vector<pair<int,int> >a;

int dfs(int u,int p,int maxd,int d){
	int ret=0;
	if(d>maxd){	
		ret++;
		}
	for(auto x:g[u]){
		if(x!=p){
			ret+=dfs(x,u,maxd,d+1);
		}
	}
	return ret;
}
void solve(){
	cin>>n>>k;
	int x;
	int y;
	loop(i,1,n){
		cin>>x>>y;
		x--;
		y--;
		g[x].pb(y);
		g[y].pb(x);
		a.pb(make_pair(x,y));
	}
	int ans=n;
	if(k&1){
		for(auto i:a){
			ans=min(ans,dfs(i.F,i.S,k/2,0)+dfs(i.S,i.F,k/2,0));
		}	
	}
	else{
		loop(i,0,n){
//			cout<<dfs(i,-1,k/2,0)<<endl;
			ans=min(ans,dfs(i,-1,k/2,0));
		}
	}
	cout<<ans<<endl;
}
int main(){
	solve();
}




Measured memory_bytes: 512
a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())

l=[a,b,c,d,e]
ansl=[]
import itertools
for v in itertools.permutations(l,5):
  orderl=list(v)
  #print(orderl)
  t=0
  for order_time in orderl:
    if t%10!=0:
      t=((t//10)+1)*10
    t+=order_time
  ansl.append(t)
print(min(ansl))

Measured memory_bytes: 3064
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<vector>
#include<map>
#include<set>
using namespace std;
#define ll long long
#define pb(x) push_back(x)
#define mp(a,b) make_pair(a,b)
#define fi first
#define se second
#define pr(x) cerr<<#x<<"="<<(x)<<endl
#define pri(x,lo) {cerr<<#x<<"={";for (int ol=0;ol<=lo;ol++)cerr<<x[ol]<<",";cerr<<"}"<<endl;}
#define inf 100000000
#define N 100
int a[1000][1000],o,p,inv,i,j;
void print()
{
	printf("%d %d\n",N,N);
	for (int i=1;i<=N;i++)
	{	
		for (int j=1;j<=N;j++)
		printf("%c",(inv^a[i][j]?'#':'.'));
		printf("\n");
	}
}
int main()
{
	cin>>o>>p;
	if (o==1&&p==1)
	{
		printf("1 2\n");
		printf("#.\n");
		return 0;
	}
	if (o>p) swap(o,p),inv=1;o--;p-=o;
	pr(o);pr(p);
	if (o!=0)
	{
		for (i=1;i<=N;i++)
		{
			for (j=1;j<=N;j+=2)
			{
				//pr(i),pr(j);
				if (i&1)
				a[i][j]=0,a[i][j+1]=1;
				else a[i][j]=1,a[i][j+1]=0;
				o--;
				if (o==0) break;
			}
			if (o==0) break;
		}
	}
	//print();
	int tmpj=j+2;
	for (;tmpj<=N;tmpj++) if (a[i-1][tmpj]==1) p++;
	for (tmpj=1;tmpj<=j+1;tmpj++) if (a[i][tmpj]==1) p++;
	for (j+=2;j<=N;j++) a[i][j]=1;
	i++;
	for (j=1;j<=N;j++) a[i][j]=1;
	//print();pr(p);
	p--;
	for (i+=2;i<=N;i+=2)
	{
		for (j=1;j<=N;j+=2)
		{	
			a[i][j]=1;
			p--;
			if (p==0) break;
		}
		if (p==0) break;
	}
	print();
	return 0;
}	

Measured memory_bytes: 256
fun main(args: Array<String>) {
    var n = readLine()!!
    var x = readLine()!!.split(" ").map{it.toInt()}
    var n_4mod0 = x.filter{ it%4 == 0 }.size
    x = x.filter{ it%4 != 0 }
    
    
    var n_2mod0 = x.filter{it%2==0}.size
    x = x.filter{it%2!=0}
    
    var n_odd = x.size
    
    if((n_4mod0-n_odd >=-1 && n_2mod0 == 0 )||(n_4mod0>=n_odd && n_2mod0>0) ) println("Yes")
    else println("No")
}


Measured memory_bytes: 55948
import collections
n,k=map(int,input().split())
a=list(map(int,input().split()))
c=collections.Counter(a)
cm=c.most_common()[::-1]
cml=len(cm)
count=0
for i in range(cml):
    if cml<=k:
        break
    else:
        cml-=1
        count+=cm[i][1]
print(count)

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

int main() {
  int i, j, k, a, b; cin >> a >> b;
  string s = to_string(a), t = to_string(b);
  string x, y;
  rep (i, a) x += t;
  rep (i, b) y += s;
  cout << min(x, y) << endl;
  return 0;
}


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

using ll = long long;
using vint = vector<int>;
using vvint = vector<vint>;
using pint = pair<int, int>;
using vpint = vector<pint>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;
#define repi(n) for (int i = 0; i < n; i++)
#define repj(n) for (int j = 0; j < n; j++)
#define repk(n) for (int k = 0; j < n; k++)
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, a, b) for (int i = a; i < b; i++)
#define repv(itr) for (auto&& v : itr)
#define swap(x, y)    \
  {                   \
    auto ___temp = x; \
    x = y;            \
    y = ___temp;      \
  }

const int dx[] = {-1, 0, 0, 1, -1, -1, 1, 1};
const int dy[] = {0, -1, 1, 0, -1, 1, -1, 1};
template <typename T>
T minptr(T begin, T end) {
  T re = begin;
  for (T i = begin + 1; i != end; i++) {
    if (*i < *re) re = i;
  }
  return re;
}
template <typename T>
T maxptr(T begin, T end) {
  T re = begin;
  for (T i = begin + 1; i != end; i++) {
    if (*i > *re) re = i;
  }
  return re;
}
int __vmax(int x) {
  return INT_MAX;
}
double __vmax(double x) {
  return 1e+300;
}
ll __vmax(ll x) {
  return LLONG_MAX;
}
int __vmin(int x) {
  return INT_MIN;
}
double __vmin(double x) {
  return -1e+300;
}
ll __vmin(ll x) {
  return LLONG_MIN;
}
template <typename T>
vector<T> lis(T begin, T end, bool allowequal = false, bool lds = false) {
  using V = typename iterator_traits<T>::value_type;
  int n = end - begin;
  vector<V> a(n, lds ? __vmin(*begin) : __vmax(*begin));
  vector<int> id(n);
  if (lds && allowequal) {
    for (int i = 0; i < n; i++) {
      id[i] = n - 1 -
              (lower_bound(a.rbegin(), a.rend(), begin[i]) - 1 - a.rbegin());
      a[id[i]] = begin[i];
    }
  } else if (lds) {
    for (int i = 0; i < n; i++) {
      id[i] = n - 1 -
              (upper_bound(a.rbegin(), a.rend(), begin[i]) - 1 - a.rbegin());
      a[id[i]] = begin[i];
    }
  } else if (allowequal) {
    for (int i = 0; i < n; i++) {
      id[i] = upper_bound(a.begin(), a.end(), begin[i]) - a.begin();
      a[id[i]] = begin[i];
    }
  } else {
    for (int i = 0; i < n; i++) {
      id[i] = lower_bound(a.begin(), a.end(), begin[i]) - a.begin();
      a[id[i]] = begin[i];
    }
  }
  int m = *maxptr(id.begin(), id.end());
  vector<T> re(m + 1);
  for (int i = n - 1; i >= 0; i--) {
    if (id[i] == m) re[m--] = begin + i;
  }
  return re;
}
template <typename T>
T gcd(T a, T b) {
  return b ? gcd(b, a % b) : a;
}

int main() {
  string s;
  cin >> s;
  int n = s.length();
  int bs = 0, ws = 0;
  repi(n) {
    bs += (i % 2) ^ (s[i] - '0');
    ws += ((i + 1) % 2) ^ (s[i] - '0');
  }
  cout << min(bs, ws) << endl;
}


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

//型定義
typedef long long ll;

//定数
const int INF=1e+9;
const int MOD=1e+9+7;

//REPマクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define REP2(i,a,b) for(ll i=a;i<(ll)(b);i++)
#define REPD2(i,a,b) for(ll i=a;i>(ll)(b);i--)

//vectorの扱い
#define ALL(x) (x).begin(),(x).end() //sortなどの引数省略
#define SIZE(x) ((ll)(x).size()) //size
#define MAX(x) *max_element(ALL(x)) //最大値
#define MIN(x) *min_element(ALL(x)) //最小値

//グローバル変数


//ライブラリ挿入


int main(){
    int N,K;
    cin>>N>>K;
    string S;
    cin>>S;
    vector<int> A;
    A.push_back(0);
    REP(i,N-1){
        if(S[i]!=S[i+1]) A.push_back(i+1);
    }
    A.push_back(N);
    
    int ans=0;
    REP(i,A.size()){
        int l=A[i];
        int j,r;
        if(l==0) j=i+2*K;
        else if(S[l-1]=='1') j=i+2*K;
        else j=i+2*K+1;
        r=A[min(j,(int)A.size()-1)];
        ans=max(ans,r-l);
    }
    cout<<ans<<endl;
    
}

Measured memory_bytes: 1020
use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).ok();
    let mut it = buf.split_whitespace();
    let h = it.next().unwrap().parse::<usize>().unwrap();
    let w = it.next().unwrap().parse::<usize>().unwrap();
    let n = it.next().unwrap().parse::<usize>().unwrap();
    let mut a = (0..n).map(|_| it.next().unwrap().parse::<usize>().unwrap()).collect::<Vec<_>>();
    let mut res = vec![vec![0; w]; h];
    let mut color = 0;
    for i in 0..h {
        for j in 0..w {
            if a[color] == 0 { color = color + 1 }
            a[color] -= 1;
            res[i][if i%2 == 0 { j } else { w-1-j }] = color + 1;
        }
    }
    for i in 0..h {
        print!("{}", res[i][0]);
        for j in 1..w { print!(" {}", res[i][j]); }
        println!("");
    }
}


Measured memory_bytes: 4352
#include <cstdio>

int main()
{
    int a;
    scanf("%d", &a);
    if (a == 1)
    {
        printf("Hello World");
    }
    
    else if (a == 2)
    {
        int a,b;
        scanf("%d %d", &a, &b);
        printf("%d", a + b);
    }
}

Measured memory_bytes: 1688
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
#include <deque>
#include <iomanip>
#include <limits>
#include <fstream>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define MOD1 1000000007

int main() {
  string s;
  cin >> s;
  s[3] = '8';
  cout << s << endl;

}

Measured memory_bytes: 384
const main = (input) => {
  input = input.trim().split('\n')
  const [, k] = input[0].split(' ').map(Number)
  const logs = input[1].split(' ').map(Number).sort((a, b) => b - a)
  let small = 0
  let big = logs[0]
  let mid = Math.floor((big-small)/2) + small

  let ans = logs[0]

  while (true) {
    if (judge(logs, mid, k)) {
      ans = Math.min(ans, mid)

      const newMid = Math.ceil((mid + small) / 2)
      if (newMid === mid) break
      big = mid
      mid = newMid
    } else {
      const newMid = Math.ceil((big + mid) / 2)
      if (newMid === mid) break
      small = mid
      mid = newMid
    }
  }

  return console.log(ans)
}

const judge = (logs, max, k) => {
  if (logs[0] <= max) return true

  let count = 0
  for (let i=0; i<logs.length; i++) {
    count += Math.floor((logs[i] - 1) / max)
    if (count > k) return false
  }

  return count <= k
}

process.env.MYTEST ? test() : main(require('fs').readFileSync('/dev/stdin', 'utf8'))

Measured memory_bytes: 52928
#include <stdio.h>

int main(){
  int S[10000];
  int T[500];
  int n, q, i, j, count = 0;

  //input
  scanf("%d",&n);
  for(i = 0; i < n; i++){
    scanf("%d",&S[i]);
  }

  scanf("%d",&q);
  for(i = 0; i < q; i++){
    scanf("%d",&T[i]);
  }

  //excution
  for(i = 0; i < q; i++){
    for(j = 0; j < n; j++){
      if(S[j] == T[i]){
	count++;
	break;
      }
    }
  }

  //output
  printf("%d\n",count);

  return 0;
}


Measured memory_bytes: 2108
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define f(i, s, n, k) for(int i=s;i<n;i+=k)
#define all_(a) a.begin(),a.end()
#define mp make_pair
#define INF INT_MAX
#define pb push_back


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    // freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);  
    int n;
    cin >> n;
    int a[n];
    f(i, 0, n, 1)
    {
        cin >> a[i];
    }  
    ll dp[n+1][n+1] = {0};  // dp[i][j] -> max diff. from i to j
    memset(dp, 0, sizeof(dp));
    for(int L = n-1;L >= 0; --L)
    {
        for(int R = L;R < n; ++R)
        {
            if(L == R) dp[L][R] = a[L];
            else       
                dp[L][R] = max(a[L] - dp[L+1][R], a[R] - dp[L][R-1]);
        }
    }
    cout << dp[0][n-1];
    return 0;
}

Measured memory_bytes: 70656
#include "stdio.h"

int main(){
  int n;
  char c[10001];//,ans[10001];
  scanf("%d",&n);
  scanf("%s",&c);
  for(int i=0;i < strlen(c);i++){
    if((int)c[i]+n<=90){c[i]+=n;}
    else c[i]=c[i]+n-26;
  }
  
  printf("%s",c);
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <map>
#include <cstring>
#include <string>
#include <algorithm>
#include <cmath>
#include <set>
const int N = 1005;
using namespace std;
typedef long long ll;
int a[N];

int main()
{
    int a,b;
    scanf("%d%d",&a,&b);
    int c=a*b;
    if(c%2==1)
        printf("Odd\n");
    else
        printf("Even\n");
}


Measured memory_bytes: 256
//インクルード(アルファベット順)
#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>//可変長配列
#include<valarray>//なんとなく追加
//メモ：表示桁数を大きくする　　cout << fixed << setprecision(20) << cm << endl;
using namespace std;
typedef long long ll;

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define PI acos(-1.0)
#define answer(ans) cout<<ans<<endl;
#define input(N) cin >> N ;

int func(long a){
    int ans=-1;
    if(a % 2 ==0){
        ans = func(a/2);
    }
    ans +=1;

    return ans;
}



signed main() {
int ans=0,N;
cin >> N;
vector<long> a(N);
REP(i,N){
    cin >> a[i];
}
REP(i,N){
ans +=func(a[i]);
}


answer(ans);
return 0;
}


Measured memory_bytes: 3700
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <cmath>
using namespace std;

typedef long long ll;

int main () {
	int N;
	vector <ll> v1, v2;
	cin >> N;
	for (int i=0; i<N; i++) {
		ll A, B;
		cin >> A >> B;
		v1.push_back (A);
		v2.push_back (B);
	}
	sort(v1.begin(), v1.end());
	sort(v2.rbegin(), v2.rend());
	if (N%2==1) {
		cout << v2[(N-1)/2] - v1[(N-1)/2] + 1 << endl;
	} else {
		ll b = v1[N/2] + v1[N/2-1];
		ll e = v2[N/2-1] + v2[N/2];
		cout << e - b + 1 << endl;
	}
	return 0;
}

Measured memory_bytes: 6648
#include <stdio.h>

int main(void){
    int n,k,ans=0,x,y,cell[1000][2000]={0};
    scanf("%d%d",&n,&k);
    for (int i=0; i<n; i++){
        char s;
        scanf("%d%d %c\n",&x,&y,&s);
        y=y%(k*2);
        x=s=='W'?x+k:x;
        x=y<k?x:x+k;
        y=y<k?y:y-k;
        x=x%(k*2);
        cell[y][x]++;
        if (x<k){
            cell[y][x+k]--;
            if (y!=0){
                cell[0][x+k]++;
                cell[y][x+k]--;
                if (x!=0){
                    cell[0][0]++;
                    cell[y][0]--;
                    cell[0][x]--;
                    cell[y][x]++;
                }
            }
        } else {
            cell[y][0]++;
            cell[y][x-k]--;
            if (y!=0){
                cell[0][x-k]++;
                cell[y][x-k]--;
                cell[0][x]--;
                cell[y][x]++;
            }
        }
    }
    for (int i=0; i<k-1; i++){
        for(int j=0; j<k*2; j++){
            cell[i+1][j]+=cell[i][j];
        }
    }
    for (int i=0; i<k ;i++){
        for (int j=0; j<k*2-1; j++){
            cell[i][j+1]+=cell[i][j];
        }
    }
    for (int i=0; i<k; i++){
        for (int j=0; j<k*2; j++){
            ans=ans>cell[i][j]?ans:cell[i][j];
        }
    }
    printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 7936
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
    int n;
    cin>>n;
    int ans=0;
    for(int i=1;i<=n;i++)
    {
        if(i%2==0)continue;
        int cnt=0;
        for(int j=1;j<=sqrt(i);j++)
            if(i%j==0)cnt++;
        if(cnt==4)ans++;
    }
    cout<<ans;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
int uruu(int y);
int mdays(int y, int m);
int sumdays(int y1 ,int m1 ,int d1 ,int y2 ,int m2 ,int d2);
int main()
{
    int y1,m1,d1,y2,m2,d2,sum;
    while(scanf("%d %d %d %d %d %d",&y1,&m1,&d1,&y2,&m2,&d2)!=EOF){
        if(y1==-1) break;
        sum = sumdays(y1 ,m1 ,d1 ,y2 ,m2 ,d2);
        printf("%d\n",sum);
    }
    return 0;
}

int uruu(int y){
    int result=0;
    if(y%4==0){
        result = 1;
        if(y%100==0){
            if(y%400==0){
                result = 1;
            }else{
                result = 0;
            }
        }
    }else{
        result = 0;
    }
    return result;
}

int mdays(int y ,int m){
    if(m==4||m==6||m==9||m==11){
        return 30;
    }else if(m==2){
        if(uruu(y)){
            return 29;
        }else{
            return 28;
        }
    }else{
        return 31;
    }
}

int sumdays(int y1 ,int m1 ,int d1 ,int y2 ,int m2 ,int d2){
    int result=0;
    while(1){
        result += mdays(y1,m1);
        if(y1==y2&&m1==m2){
            break;
        }
        if(m1==12){
            m1 = 1;
            y1++;
        }else{
            m1++;
        }
    }
    result = result-(d1-1)-(mdays(y2,m2)-(d2-1));
    return result;
}

Measured memory_bytes: 596
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var s = bufio.NewScanner(os.Stdin)

func getInt() int {
	s.Scan()
	a, _ := strconv.Atoi(s.Text())
	return a
}

func main() {
	s.Split(bufio.ScanWords)
	k, x := getInt(), getInt()

	min := x - k + 1
	max := x + k - 1

	for i := min; i <= max; i++ {
		fmt.Printf("%d ", i)
	}
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll ar[5000005];
int main()
{
    ll a;
    cin >> a;
    for(int i=1;i<=a;i++)
    {
        cin >> ar[i];
    }
    sort(ar+1,ar+a+1);
    for(int i=2;i<=a;i++)
    {
        if(ar[i-1]==ar[i])
        {
            cout << "NO\n";
            return 0;
        }
    }
    cout << "YES\n";
    return 0;
}



Measured memory_bytes: 1792
#include<iostream>
using namespace std;
const int mod=1e9+7;
int b,w;
long fac[1000000],inv[1000000];

long modpow(long a,int b){
	long res=1;
	while(b){
		if(b&1) res=res*a%mod;
		a=a*a%mod;
		b>>=1;
	}
	return res;
}

long C(long a,long b){return fac[a]*inv[b]%mod*inv[a-b]%mod;}

int main(){
	cin >> b >> w;
	fac[0]=inv[0]=1;
	for(int i=1;i<1e6;i++) fac[i]=fac[i-1]*i%mod;
	inv[1000000-1]=modpow(fac[1000000-1],mod-2);
	for(int i=1e6-2;i>=0;i--) inv[i]=inv[i+1]*(i+1)%mod;
	long p=0,q=0,r=1;
	for(int i=0;i<b+w;i++){
		if(i>=b) p+=C(i-1,b-1)*r,p%=mod;
		if(i>=w) q+=C(i-1,w-1)*r,q%=mod;
		cout << (1-p+q+mod)%mod*inv[2]%mod << endl;
		r=r*inv[2]%mod;
	}
	return 0;
}


Measured memory_bytes: 17792
n, m = map( int, raw_input().strip().split() )
data = map( int, raw_input().strip().split() )

ans = 0

freq1 = [0] * ( max( data ) + 1 )
for x in data:
	freq1[ x ] += 1

freq2 = [0] * m
freq3 = [0] * m

for i in range( len( freq1 ) ):
	freq2[ i % m ] += freq1[i]
	freq3[ i % m ] += 2 * ( freq1[i] / 2 )

for i in range(m) :
	if ( i + i ) % m == 0:
		ans += freq2[i] / 2
	else:
		mx = 0
		val = min( freq2[i], freq2[m-i] )
		ans += val
		ans += min( freq3[i], freq2[i] - val ) / 2
		ans += min( freq3[m-i], freq2[m-i] - val ) / 2
		freq2[i] = freq2[ m-i ] = 0
		freq3[i] = freq3[ m-i ] = 0

print ans 

Measured memory_bytes: 12408
a, b, m = map(int, input().split())
a = list(map(int, input().split())) 
b = list(map(int, input().split())) 

ans = min(a) + min(b)

for _ in range(m):
    x, y, c = map(int, input().split())

    ans = min(ans, (a[x-1]+b[y-1]-c))

print(ans)

Measured memory_bytes: 18736
#include<bits/stdc++.h>
using namespace std;
int util(vector<vector<int>>&adj,int u,vector<int>&dp){
	if(dp[u]!=-1)
		return 1+dp[u];
	dp[u]=0;
	for(int v=0;v<adj[u].size();v++){
		dp[u]=max(dp[u],util(adj,adj[u][v],dp));
	}
	return 1+dp[u];
}
int main(){
	int node,edges;
	cin>>node>>edges;
	vector<vector<int>>adj(node+1);
	for(int i=0;i<edges;i++){
		int u,v;
		cin>>u>>v;
		adj[u].push_back(v);
	}
	vector<int>dp(node+1,-1);
	for(int i=1;i<=node;i++){
		util(adj,i,dp);
	}
	int res=INT_MIN;
	for(int i=0;i<=node;i++){
		res=max(res,dp[i]);
	}
	cout<<res;
	return 0;
}

Measured memory_bytes: 8832
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <functional>
#include <ctime>
#include <cmath>
#include <limits>
#include <numeric>
#include <type_traits>
using namespace std;
using ll = long long;

unsigned euclidean_gcd(unsigned a, unsigned b) {
    if (a < b) return euclidean_gcd(b, a);
    unsigned r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}

class UnionFind {
public:
    vector <ll> par;
    vector <ll> siz;
    UnionFind(ll sz_) : par(sz_), siz(sz_, 1LL) {
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    void init(ll sz_) {
        par.resize(sz_);
        siz.assign(sz_, 1LL);
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    ll root(ll x) {
        while (par[x] != x) {
            x = par[x] = par[par[x]];
        }
        return x;
    }
    bool merge(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool issame(ll x, ll y) {
        return root(x) == root(y);
    }

    ll size(ll x) {
        return siz[root(x)];
    }
};

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

long long modinv(long long a, long long mod) {
    return modpow(a, mod - 2, mod);
}

int main() {
    int a;
    cin >> a;
    vector<pair<ll, ll>> z(a);
    for (int i = 0; i < a; i++) {
        cin >> z.at(i).second >> z.at(i).first;
    }
    sort(z.begin(), z.end());
    string ans = "Yes";
    ll tm = 0;
    for (int i = 0; i < a; i++) {
        tm += z.at(i).second;
        if (tm > z.at(i).first)ans = "No";
    }
    cout << ans << endl;
}

Measured memory_bytes: 3328
N, Y = map(int, input().split())
for x in range(int(Y / 10000) + 1):
	for y in range(int((Y - x * 10000) / 5000) + 1):
		z = int((Y - x * 10000 - y * 5000) / 1000)
		if x + y + z == N:
			print(x, y, z)
			break
	else:
		continue
	break
else:
	print("-1 -1 -1")

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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

typedef long long ll;

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

const int maxn = 1e6 + 5;

int a,b,x;

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

  cin>>a>>b>>x;
  if (a>x) out("NO");
  if (a+b<x) out("NO");
  out("YES");
  

  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 repi(i,a,b) for (int i = (a); i < (b); i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using vc = vector<char>;
using vvc = vector<vc>;
using vs = vector<string>;

int sum(int n) {
  return n ? n + sum(n-1) : 0;
}
  
int main() {
  int N;
  cin >> N;
  
  cout << sum(N) << endl;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
 
money = 1000
stock = 0
 
for i in range(N):
    if i == N - 1:
        money += stock * A[i]
        break
    if A[i] < A[i + 1]:
        buy_stock = money // A[i]
        money -= A[i] * buy_stock
        stock += buy_stock
    elif A[i] > A[i + 1]:
        money += A[i] * stock
        stock = 0
 
print(money)

Measured memory_bytes: 9204
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll inf = 1e18;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define per(i, a, b) for (int i = b - 1; i >= a; i--)
#define int ll
using pint = pair<int, int>;
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

signed main() {
    int n, m;
    cin >> n >> m;
    int ans = 1;
    for (int i = 1; i * i <= m; i++) {
        if (m % i == 0) {
            if (m / i >= n) {
                ans = max(ans, i);
            }
            if (i >= n) {
                ans = max(ans, m / i);
            }
        }
    }
    cout << ans << "\n";
}

Measured memory_bytes: 3608
while line =gets
	a,b,c,d,e,f=line.split(" ").map{|i| i.to_f}
		x =((c*e-f*b)/(a*e-b*d))
		y=((c*d-a*f)/(b*d-a*e))
	puts "%.3f %.3f" % [x+0,y+0]
end

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

int main()
{
    int k, s;
    cin >> k >> s;
    ll ans = 0;
    rep(x, k + 1)
    {
        rep(y, k + 1)
        {
            int z = s - (x + y);
            if (0 <= z && z <= k)
                ans++;
        }
    }
    cout << ans << endl;
}

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


long num_of_digits(long n)
{
	long i;
	for (i = 0; n != 0; i++)
		n /= 10;

	return i;
}

int main(void)
{
	long n;
	cin >> n;

	long min;
	for (long a = 1; a <= sqrt(n); a++) {
		if (n % a != 0)
			continue;
		long b = n / a;

		long val = max(num_of_digits(a), num_of_digits(b));
		if (val < min || a == 1)
			min = val;
	}

	cout << min << endl;
	return 0;
}


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

int main(){
  int n;cin>>n;
  int v[n],c[n];
  fol(i,n)cin>>v[i];
  fol(i,n)cin>>c[i];
  int ans = 0;
  fol(i,n){
    if(v[i] > c[i]){
      ans += v[i] - c[i];
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define MAX_N 10000
#define MAX_L 100
const int MOD=1e9+7;
int dp[MAX_N+1][2][MAX_L+2];

int main() {
    int K,l;
    string N;
    cin >> N >> K;
    l = N.size();

    rep(i,l+1)
        rep(j,2)
            rep(k,l+1)
                dp[i][j][k] = 0;

    dp[0][0][1] = 1;
    rep(i,l) {
        int x = N.at(i)-'0';
        rep(j,2)
            rep(k,l+2)
                rep(p,(j?9:x)+1)
                    dp[i+1][j || p<x][k + (p!=0)] += dp[i][j][k];
    }
    
    cout << dp[l][0][K+1]+dp[l][1][K+1] << endl;
}

Measured memory_bytes: 384
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<queue>
#include<set>
#include<map>
#include<vector>
using namespace std;
#define MAX 100005
typedef long long ll;
int mapp[105];
int vis[105];
int main()
{
    int n;
    int ans=0;
    int sum=0;
    int k=0;
    scanf("%d",&n);
    for(int i=0;i<n;i++)
    {
        scanf("%d",&mapp[i]);
        if(mapp[i]%10!=0)
        {
            ans+=mapp[i];
            vis[k++]=mapp[i];
        }
        else
        {
            sum+=mapp[i];
        }
    }
    if(ans==0)
        printf("0\n");

    else if(ans%10==0)
    {
        sort(vis,vis+k);
        ans-=vis[0];
        printf("%d\n",ans+sum);
    }
    else
    {
        printf("%d\n",ans+sum);
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a[10],x;
char c;
int main()
{
    while(cin>>c&&c!='\0')
    {
        if(c=='0') a[x++]=0;
        else if(c=='1') a[x++]=1;
        else{
            if(x) x--;
        }
    }
    if(x){
        for(int i=0;i<x;i++) printf("%d",a[i]);
        printf("\n"); 
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;

#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define range(i,a,n) for(int i=(a);i<(n);i++)

#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI 3.1415926535897932384

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

template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S acm(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
void YN(bool b){cout<<(b?"YES":"NO")<<"\n";}
void Yn(bool b){cout<<(b?"Yes":"No")<<"\n";}
void yn(bool b){cout<<(b?"yes":"no")<<"\n";}

ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s;a=0;} return os;}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin>>n;
	fcout(10)<<(double)(n-n/2)/n<<endl;
}


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

int main(){
    int ans = 1e9;
    int N;
    cin >> N;
    for(int i = 0; i < N; i++){
        int A;
        cin >> A;
        int count = 0;
        while(A % 2 == 0){
            A /= 2;
            count++;
        }
        ans = min(ans, count);
    }

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

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

int main() {
	int A[3][3];
	for (int i = 0; i < 3; i++)
		for (int j = 0; j < 3; j++)
			cin >> A[j][i];
	int N;
	cin >> N;
	bool B[3][3];
	for (int i = 0; i < 3; i++)
		for (int j = 0; j < 3; j++)
			B[j][i] = false;
	for (int k = 0; k < N; k++) {
		int in;
		cin >> in;
		for (int i = 0; i < 3; i++) {
			for (int j = 0; j < 3; j++) {
				if (A[j][i] == in)
					B[j][i] = true;
			}
		}
	}
	for (int i = 0; i < 3; i++) {
		if (B[i][0] == true && B[i][1] == true && B[i][2] == true) {
			cout << "Yes" << endl;
			return 0;
		}
	}
	for (int j = 0; j < 3; j++) {
		if (B[0][j] == true && B[1][j] == true && B[2][j] == true) {
			cout << "Yes" << endl;
			return 0;
		}
	}
	if (B[0][0] == true && B[1][1] == true && B[2][2] == true) {
		cout << "Yes" << endl;
		return 0;
	}
	if (B[2][0] == true && B[1][1] == true && B[0][2] == true) {
		cout << "Yes" << endl;
		return 0;
	}
	cout << "No" << endl;
	return 0;
}


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

int main() {
    int K; cin >> K;
    int vec[32] = { 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51 };
    cout << vec[K - 1] << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
    int n;
    cin>>n;
    int q[n+2];
    for (int i=1; i<=n; i++)
        cin>>q[i];
        
    int dp[n+2];
    
    dp[1] = 0;
    dp[2] = abs(q[1]-q[2]);
    
    for (int i=3; i<=n; i++)
        dp[i] = min(dp[i-1] + abs(q[i]-q[i-1]), dp[i-2] + abs(q[i]-q[i-2]));
        
    cout<<dp[n];
}

Measured memory_bytes: 4388
#include<bits/stdc++.h>
#define rep(i,a) for(int (i)=0; (i)<(a); (i)++)
#define rrep(i,a) for(int (i)=a-1; (i)>=(0); (i)--)
#define rep2(i,a,b) for(int (i)=(a); (i)<(b); (i)++)
#define MOD 1000000007
#define all(v) v.begin(), v.end()
#define m0(x) memset(x,0,sizeof(x))
typedef long long ll;
using namespace std;

int dp1[3050][3050];
int dp2[3050][3050];
int a[3050],b[3050];

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
  
    int n,t; cin >> n >> t;
    rep2(i,1,n+1) cin >> a[i] >> b[i];  
    m0(dp1); m0(dp2);
  
    rep2(i,1,n+1)rep(j,t+1){
		dp1[i][j] = dp1[i-1][j];
        if(j-a[i] >= 0)dp1[i][j] = max(dp1[i-1][j], dp1[i-1][j-a[i]] + b[i]);
    }
    for(int i = n; i >= 1; i--)rep(j,t+1){
        dp2[i][j] = dp2[i+1][j];
		if(j-a[i] >= 0) dp2[i][j] = max(dp2[i+1][j], dp2[i+1][j-a[i]] + b[i]); 
    }
  
    int ans = 0;
    rep2(i,1,n+1)rep(j,t) ans = max(ans, dp1[i-1][j]+dp2[i+1][t-j-1]+b[i]);
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 72960
s=list(input())
t=list(input())
n=len(s)
ans="No"
for i in range(n):
    for j in range(n-1):
        ex=s[n-2-j]
        s[n-2-j]=s[n-1-j]
        s[n-1-j]=ex
    if(s==t):
        ans="Yes"
print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lvector vector<ll>
#define cvector vector<char>
#define svector vector<string>
#define lque queue<ll>
#define lpque priority_queue<ll>
#define dlpque priority_queue<ll,lvector,greater<ll>>
#define P pair<ll,ll>
#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
#define rep(i,n) for(ll i=0; i<n; ++i)
#define print(a) cout << (a) << endl

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n,ans=0;cin>>n;
  lvector num(1e7+1,1);
  for(ll i=2;i<=n;++i) {
    for(ll j=1;j*i<=n;++j) {
      num[i*j]++;
    }
  }
  for(ll i=1;i<=n;++i) ans+=i*num[i];
  print(ans);
  return 0;
}

Measured memory_bytes: 81336
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

typedef long long int ll;

const ll MOD = 1000000007;

int gcd(int a, int b) {
  while (b > 0) {
    int rem = a % b;
    a = b;
    b = rem;
  }
  return a;
}

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

  int N;
  cin >> N;
  vector<int> A(N);
  for (auto &x: A) cin >> x;

  vector<int> left(N);
  vector<int> right(N);
  left[0] = A[0];
  for (int i = 1; i < N; i++) {
    left[i] = gcd(left[i-1], A[i]);
  }
  right[N-1] = A[N-1];
  for (int i = N-2; i >= 0; i--) {
    right[i] = gcd(right[i+1], A[i]);
  }
  int ans = max(left[N-2], right[1]);
  for (int i = 0; i < N-2; i++) {
    ans = max(ans, gcd(left[i], right[i+2]));
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1408
#define _USE_MATH_DEFINES
#include<iostream>
#include <iomanip>
#include<stdio.h>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include <queue>
#include <utility>
#include <map>
#include <set>
#include <deque>
#include <numeric>
using namespace std;

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

    if (b < a)swap(a, b);
    if (a + W >= b)cout << 0 << endl;
    else cout << b - (a + W) << endl;

    return 0;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))

sa = [0 for i in range(n)]
sc = sum(a)
c = 0
for i in range(n):
  c += a[i]
  sa[i] = c
ans = 10**10

for i in range(1,n):
  x = sc-sa[i-1]
  v = abs(x-sa[i-1])
  ans = min(ans,v)
print (ans)


Measured memory_bytes: 30488
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <numeric>
using namespace std;
using ll = long long;
const ll mod =  998244353;

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REP_FROM(i, j, n) for (int i = (j); i < (n); ++i)
#define all(x) (x).begin(),(x).end()

ll power(ll base, ll exponent, ll module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ ll root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
ll inverse(ll x){ return power(x, mod - 2, mod);}
ll gcd(ll a, ll b) {if(a < b) gcd(b, a);ll r;while(r=a%b) {a=b;b=r;}return b;}
struct combination{ vector<ll> fact, inv; combination(int sz) : fact(sz + 1), inv(sz + 1){ fact[0] = 1; for(int i = 1; i <= sz; i++){ fact[i] = fact[i - 1] * i % mod; } inv[sz] = power(fact[sz], mod - 2, mod); for(int i = sz - 1; i >= 0; i--){ inv[i] = inv[i + 1] * (i + 1) % mod; } } ll C(int p, int q) const{ if(q < 0 || p < q) return 0; return (fact[p] * inv[q] % mod * inv[p - q] % mod); } };

ll dp[100010][2] = {};

signed main() {
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<ll> a(n);
  REP(i, n) cin >> a[i];
  dp[0][0] = a[0];
  dp[0][1] = a[a.size()-1];
  REP(i, n) {
    dp[i+1][0] = gcd(dp[i][0], a[i]);
    dp[i+1][1] = gcd(dp[i][1], a[a.size()-1-i]);
  }
  ll ans = max(dp[a.size()-1][1], dp[a.size()-1][0]);
  REP(i, n-1) {
    ans = max(gcd(dp[i][0], dp[a.size()-1-i][1]), ans);
  }
  cout << ans << endl;
  return 0;
}


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

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

    long long ans = 0;

    if(s.size() == 1){
        ans = s[0] - '0';
    }

    for (auto bit = 0; bit < (1 << s.size() - 1); bit++)
    {
        vector<int> bits(s.size() - 1);
        for (auto i = 0; i < s.size() - 1; i++)
        {
            if (1 & (bit >> i))
            {
                bits[i] = 1;
            }
            else
            {
                bits[i] = 0;
            }
        }

        long long now = s[0] - '0';
        long long pans = 0;

        for (auto i = 1; i < s.size(); i++)
        {
            if (bits[i - 1] == 0)
            {
                now = now * 10 + s[i] - '0';
            }
            else
            {
                pans += now;
                now = s[i] - '0';
            }
            if (i == (s.size() - 1))
            {
                pans += now;
            }
        }

        ans += pans;
    }


    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <functional>
#include <numeric>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cassert>
#define bogo_sort   std::sort
#define bozo_sort   std::stable_sort
#define alles(obj)  obj.begin(), obj.end()
#define elif        else if
#define unless(flg) if(!(flg))
#define elless(flg) else if(!(flg))
#define echo        std::cout <<
#define read        std::cin >>
#define endl        std::endl
#define fin         << '\n'
#define bash        push_back
#define makePair    std::make_pair
#define _           << ' ' <<
// type-define
#define Stack       std::stack
#define Queue       std::queue
#define Set         std::set
#define PQueue      std::priority_queue
#define Vector      std::vector
#define Pair        std::pair
#define Map         std::map
#define HashMap     std::unordered_map
#define Greater     std::greater
using String  =     std::string;
using llong   =     long long;
using boolean =     bool;
using Pii     =     Pair<int, int>;
using Vi      =     Vector<int>;
using Vii     =     Vector<Pii>;
// utils
constexpr int   dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
constexpr int   dy[] = {0, 1, 0, -1, 1, -1, 1, -1};
constexpr int   INF  = 0x3f3f3f3f;
constexpr llong LINF = 0x3f3f3f3f3f3f3f3fLL;

namespace {
    template<class A, class B> A power ( llong x, llong n, llong mod ) {
        llong ans = 1;
        while ( n > 0 ) {
            if ( n & 1 ) ans = ( ans * x ) % mod;
            x = ( x * x ) % mod;
            n >>= 1;
        }
        return ans;
    }
    template<class A, class B> A power ( A x, B n ) { return power( x, n, 1000000007 ); }
    template<class A> A gcd ( A x, A y ) { return x % y ? gcd( y, x % y ) : y; }
    template<class A, class B> A lcm   ( A x,  B y ) { return ( x / gcd(x, y) * y ); }
    template<class A> inline A abs ( A n ) { return ( n < 0 ) ? -n : n; }
    template<class A, class B> inline bool chmax ( A &a, const B &b ) { return b > a ? a = b, true : false; }
    template<class A, class B> inline bool chmin ( A &a, const B &b ) { return b < a ? a = b, true : false; }
    boolean isMovable ( int x, int y, int w, int h ) {
        return ( x >= 0 && y >= 0 && x < w && y < h );
    }
}

namespace Rlyeh {

    signed call_of_Cthulhu( signed datum ) {

        int x, y;
        read x >> y;
        if ( gcd(x, y) == y ) echo -1 fin;
        else {
            echo x fin;
        }

        return 0;
    }
}

signed main(){std::cin.tie(0); std::ios::sync_with_stdio(false); int main_result = Rlyeh::call_of_Cthulhu(114514); return 0;}


Measured memory_bytes: 256
n = input()
a_list = list(map(int, input().split()))
score = 0

for i in range(len(a_list) - 1):
  if a_list[i] > a_list[i+1]:
    score += a_list[i] - a_list[i+1]
    a_list[i+1] = a_list[i]
    
print(score)

Measured memory_bytes: 94232
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>

const int MOD = 1000000007, INF = 1111111111;
using namespace std;
using lint = long long;

template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
	for (int i = 0; i < (int)vec.size(); i++) {
		os << vec[i] << (i + 1 == vec.size() ? "" : " ");
	}
	return os;
}

#ifdef _DEBUG
template <class Head>
void dump(const char* str, Head &&h) { cerr << str << " = " << h << "\n"; };
template <class Head, class... Tail>
void dump(const char* str, Head &&h, Tail &&... t) {
	while (*str != ',') cerr << *str++; cerr << " = " << h << "\n";
	dump(str + 1, t...);
}
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int H, W, N;
	cin >> H >> W >> N;

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

	int cnt = 0;
	vector<vector<int>> ans(H, vector<int>(W));
	for (int row = 0; row < H; row++) {
		for (int col = 0; col < W; col++) {

			if (row & 1) ans[row][col] = cnt + 1;
			else ans[row][W - col - 1] = cnt + 1;

			a[cnt]--;
			if (a[cnt] == 0) cnt++;

		}
	}
	assert(cnt == N);

	for (int row = 0; row < H; row++) {
		for (int col = 0; col < W; col++) {
			cout << ans[row][col] << " ";
		}
		cout << "\n";
	}
	

	return 0;
}

Measured memory_bytes: 384