akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using int64 = long long;
#define int int64
#define rep(i, n) for(int i=0; i<n; i++)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define SORT(x) sort(x.begin(), x.end())
#define GSORT(x) sort(x.begin(), x.end(), greater<int>())
#define mk make_pair
#define fi first
#define se second
#define pb push_back
#define ALL(x) x.begin(), x.end()
#define V(T) vector<T>
typedef pair<int, int> P;
typedef pair<P, P> PP;
typedef vector<int> vi;
typedef vector<vi> vvi;
int max(int a, int b) {if(b>a) return b; else return a;}
int min(int a, int b) {if(b<a) return b; else return a;}
const int INF = 1e18;

signed main() {
    int X, N;
    cin >> X >> N;
    map<int, bool> mp;
    rep(i, N) {
        int p;
        cin >> p;
        mp[p] = true;
    }

    int res = X;
    int dif = INF;
    for(int i=X; i>=X-101; i--) {
        if(!mp[i]) {
            res = i;
            dif = abs(i-X);
            break;
        }
    }
    for(int i=X; i<=X+101; i++) {
        if(!mp[i] && abs(i-X)<dif) {
            res = i;
            break;
        }
    }

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 3608
import std.stdio;
import std.c.stdio;
import std.range;
import std.array;
import std.functional;
import std.algorithm;
import std.conv;
import std.container;
import std.math;
import std.numeric;
import std.string;
import std.c.string;
import std.regex;
import std.typecons;
 
void main() {
    string[2] I;
    string O;

    bool input() {
        I[0] = readln.chomp;
        if (I[0] == "-") return false;
        I[1] = readln.chomp;
        O = readln.chomp;
        return true;
    }
    
    void solve() {
        int[2] x = [0, 0];
        int c = 1;
        string Ans;
        int i = 0;
        while (true) {
            //writeln(i, " ", x, " ", c, " ", Ans);
            if (i < O.length && O[i] == I[c][x[c]]) {
                x[c]++;
                c = 0;
                i++;
            } else {
                Ans ~= I[c][x[c]];
                x[c]++;
                c = 1;
            }
            if (x[0] == I[0].length && x[1] == I[1].length) break;
        }
        writeln(Ans);
    }

    while (input) solve;
}

Measured memory_bytes: 1060
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000

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

	int N;
	cin >> N;
	vector<int> A;
	rep(i, N) {
		int tmp; cin >> tmp;
		A.push_back(tmp);
	}
	vector<int> X(A);
	sort(X.begin(), X.end());
	map<int, int> mp;
	rep(i, N) mp[X[i]] = i;
	rep(i, N) A[i] = mp[A[i]];

	vector<int> B0;
	vector<int> B1;
	rep(i, N) {
		if (i % 2 == 0) B0.push_back(A[i]);
		else B1.push_back(A[i]);
	}
	int cnt0 = 0;
	int cnt1 = 0;
	// dump(cnt0);
	rep(i, B0.size()) {
		if (B0[i] % 2 == 1) cnt0++;
	}
	rep(i, B1.size()) {
		if (B1[i] % 2 == 0) cnt1++;
	}
	
	cout << max(cnt0, cnt1) << endl;



	return 0;
}


Measured memory_bytes: 6520
#define _USE_MATH_DEFINES //M_PI, M_E
#include<bits/stdc++.h>
#define mod 1000000007
#define ll long long int
#define ar array
#define pb push_back
ll power(ll a,ll b){ll r=1;for(;b;b>>=1){if(b&1)r=r*a%mod;a=a*a%mod;}return r;}
using namespace std;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	int n;
	cin>>n;
	int ans = 24;
	cout<<ans+(24-n)<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <vector>
using namespace std;
vector<int> v,G[26],rG[26];
bool vis[26];
bool used[26];
void DFS(int n) {
	vis[n]=1;
	for(int i=0;i<G[n].size();i++) {
		if(!vis[G[n][i]]) DFS(G[n][i]);
	}
	v.push_back(n);
}
int rDFS(int n) {
	int sum=1;
	vis[n]=1;
	for(int i=0;i<rG[n].size();i++) {
		if(!vis[rG[n][i]]) sum+=rDFS(rG[n][i]);
	}
	return sum;
}
int main() {
	int n;
	while(scanf("%d",&n),n) {
		char word[35];
		int in[26]={0},out[26]={0};
		memset(used,0,sizeof(used));
		for(int i=0;i<26;i++) G[i].clear(),rG[i].clear();
		for(int i=0;i<n;i++) {
			scanf("%s",word);
			int n1=word[0]-'a';
			int n2=word[strlen(word)-1]-'a';
			G[n1].push_back(n2);
			rG[n2].push_back(n1);
			out[n1]++;
			in[n2]++;
			used[n1]=used[n2]=1;
		}
		v.clear();
		memset(vis,0,sizeof(vis));
		int cnt=0;
		for(int i=0;i<26;i++) {
			if(used[i]) {
				cnt++;
				if(!vis[i]) DFS(i);
			}
		}
		bool OK=1;
		memset(vis,0,sizeof(vis));
		if(rDFS(v[v.size()-1])==cnt) {
			for(int i=0;i<26;i++) if(in[i]!=out[i]) OK=0;
		}else OK=0;
		if(OK) printf("OK\n"); else printf("NG\n");
	}
}

Measured memory_bytes: 1156
N,M,C = map(int, input().split())
B = list(map(int, input().split()))

count = 0

for i in range(N):
  left = 0
  for j, a in enumerate(map(int, input().split())):
    left += a * B[j]
  if left + C > 0:
    count += 1
print(count)

Measured memory_bytes: 3060
//
//AtCoder Beginner Contest 133
//D - Rain Flows into Dams
//

#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <ctime>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <functional>
#include <cassert>

using namespace std;

#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--)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define SIZE(x) (int)(x).size()
#define SIZEL(x) (ll)(x).size()
#define MSG(a) cout << #a << " " << a << endl;

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

const double PI = 3.14159265358979323846;

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

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

    vector<ll> a(n);
    REP(i, n) cin >> a[i];

    vector<ll> ans(n, 0);
    REP(i, n) {
        if(i%2==0) ans[0] += a[i];
        else ans[0] -= a[i];
    }
    REP(i, n-1){
        ans[i+1] = (a[i] - ans[i]/2)*2;
    }
    REP(i, n) cout << ans[i] << " ";
    cout << endl;
    return 0;
}


Measured memory_bytes: 2944
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "functional"
#include "ctime"

using namespace std;

//constexpr long long int MOD = 1000000007;
//constexpr int MOD = 1000000007;
constexpr int MOD = 998244353;
//constexpr long long int MOD = 998244353;
constexpr double EPS = 1e-8;

//int N, M, K, H, W, L, R;
long long int N, M, K, H, W, L, R;



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

	cin >> N;
	vector<long long int>v(N);
	long long int x = 0;
	for (auto &i : v) {
		cin >> i;
		x ^= i;
	}
	long long int add = 0;
	for (int i = 0; i < 59; i++) {
		if ((x >> i) & 1) {
			add += 1LL << i;
			x ^= 1LL << i;
			for (auto &j : v)if ((j >> i) & 1)j ^= 1LL << i;
		}
	}
	for (int i = 59; i >= 0; i--) {
		for (int j = 0; j < N; j++) {
			if ((v[j] >> i) & 1) {
				bool flag = false;
				for (int k = i + 1; k < 60; k++) {
					if ((v[j] >> k) & 1)flag = true;
				}
				if (flag)continue;
				for (int k = 0; k < N; k++) {
					if (j == k)continue;
					if ((v[k] >> i) & 1)v[k] ^= v[j];
				}
				break;
			}
		}
	}
	sort(v.begin(), v.end());
	reverse(v.begin(), v.end());
	//for (auto i : v)cout << i << endl;
	long long int  y = 0;
	for (auto i : v) y ^= i;
	x ^= y;
	//cout << x << " " << y << endl;
	//for (int i = 59; i >= 0; i--) {
	//	if ((x >> i) & 1)y ^= box[i];
	//	else x ^= box[i];
	//	cout << x << " " << y << endl;
	//}
	cout << x + y + add << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int N;
    int l, r, x;
    int s = 0;
    cin >> N;
    for(int i = 0; i < N; i++)
    {
        cin >> l >> r;
        x = r - l + 1;
        s = s + x;
    }
    
    cout << s << endl;

}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>

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

using namespace std;

inline int max(int a, int b) {
	if (b > a) swap(a, b);
	return a;
}

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

long long int dfs(vector<vector<int>> &to, int now, int from, int K){
  long long int case_num = 1;
  int ab_num;
  if(from == -1){
    ab_num = K - 1;
  }else{
    ab_num = K - 2;
  }
  
  if(to[now].size() > K){
    return 0;
  }else{
    for(auto a: to[now]){
      if(a == from) continue;
      case_num *= ab_num;
      case_num %= 1000000007;
      ab_num--;
    }
    for(auto a: to[now]){
      if(a == from) continue;
      case_num *= dfs(to, a, now,K);
      case_num %= 1000000007;
    }
    return case_num;
  }
}


int main() {
	int n, k;
	long long int ans;
	cin >> n >> k;
	vector<vector<int>> to(n);
	rep(i, n-1) {
		int tmp1, tmp2;
		cin >> tmp1 >> tmp2;
		tmp1--;
		tmp2--;
		to[tmp1].emplace_back(tmp2);
		to[tmp2].emplace_back(tmp1);
	}

	ans = k * dfs(to, 0, -1, k);
    ans %= 1000000007;

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



Measured memory_bytes: 11520
#include <bits/stdc++.h>
using namespace std;
#define rep2(i,m,n) for (int i = (m); i < (n); ++i)
#define rep(i,n) rep2(i,0,n)
// #define debug(x) cerr << x << endl
typedef long long int ll;
typedef long double ld;
typedef pair<int, int> P;
template<typename T> struct V : vector<T> { using vector<T>::vector; };
V() -> V<int>;
V(size_t) -> V<int>;
template<typename T> V(size_t, T) -> V<T>;
template<typename T> vector<T> make_vec(size_t n, T a) { return vector<T>(n, a); }
template<typename... Ts> auto make_vec(size_t n, Ts... ts) { return vector<decltype(make_vec(ts...))>(n, make_vec(ts...)); }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &v) { for (auto &e : v) os << e << ' '; return os; }
struct fast_ios { fast_ios(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
template<typename T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
template<typename T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
const int INF = 1<<30;
const ll LINF = 1LL<<61;
const ll MOD = 1000000007;

int main()
{
    int n, m;
    cin >> n >> m;
    V<ll> a(n), b(m);
    rep(i,n) cin >> a[i];
    rep(i,m) cin >> b[i];
    // debug(a), debug(b);
    auto dp = make_vec(n+1, m+1, 0LL);
    rep(i,n+1) dp[i][0] = 1;
    rep(i,m+1) dp[0][i] = 1;
    rep(i,n) rep(j,m)
    {
        dp[i+1][j+1] += dp[i+1][j];
        dp[i+1][j+1] += dp[i][j+1];
        if(a[i] != b[j])
        {
            dp[i+1][j+1] = (MOD + dp[i+1][j+1] - dp[i][j]) % MOD;
        }
        dp[i+1][j+1] %= MOD;
    }
    cout << dp[n][m] << endl;
    // debug(dp);
    return 0;
}

Measured memory_bytes: 34596
import sys
from collections import deque
input=sys.stdin.readline
N=int(input())
tree=[[] for _ in range(N)]
for _ in range(N-1):
  u,v,w=map(int,input().split())
  tree[u-1].append((v-1,w))
  tree[v-1].append((u-1,w))
ans=[-1]*N
ans[0]=0
d=deque([0])
while d:
  p=deque.popleft(d)
  color=ans[p]
  for v,w in tree[p]:
    if ans[v]==-1:
      deque.append(d,v)
      ans[v]=color^(w%2)
print(*ans,sep='\n')

Measured memory_bytes: 96124
#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>//可変長配列

using namespace std;
using ll = long long;
// typedef vector<int> v;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v){o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
#define debug(v) {cerr<<"\033[1;36m[debug]\033[m "<<#v<<" : "<<v<<endl;}
#define rep(i, c) for(int i = 0; i < int(c); i++)
#define ALL(x) (x).begin(), (x).end() //sort(ALL(obj))みたいな
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値
#define pb push_back //
// const int MOD = 1000000007;

static const double pi = 3.141592653589793;



int main() {
  double a, b, x;
  cin >> a >> b >> x;
  double v = (a*a*b) / 2.0;

  if (x <= v) {
    double a_a = 2.0 * x / (a * b);
    printf("%.6f\n", atan(b/a_a) * (180.0/pi));
  } else {
    x = a * a * b - x;
    double b_b = 2.0 * x / (a * a);
    printf("%.6f\n", atan(b_b/a) * (180.0/pi));
  }
}


Measured memory_bytes: 888
//usr_name : paras.gautam243
//dated :

#include<iostream>
using namespace std;

int main(){
//#ifndef ONLINE_JUDGE
   //freopen("in.txt", "r", stdin);
   //freopen("out.txt", "w", stdout);
//#endif

ios::sync_with_stdio(0);
cin.tie(0);


//...
string s;
cin>>s;
int a[26]={0};
for(char c:s){
    ++a[c-'a'];
}

for(int i=0; i<26; i++){
	if (a[i]%2!=0){
		cout<<"No";
		return 0;
     } 
     	
}
cout<<"Yes";

return 0;
}



Measured memory_bytes: 3128
n = int(input())
s = []
t = []
for i in range(n):
  st = input().split()
  s.append(st[0])
  t.append(int(st[1]))
x = input()
ans = 0
for i in range(n-1):
  if s[i]==x:
    print(sum(t[i+1:]))
    break
else:
  print(0)

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

#define what_is(x) cerr << #x << " is " << x << endl; 
#define PI acos(-1)
#define hell 1000000007
#define HELL 998244353
#define io ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define fix(n) cout << fixed << setprecision(n)
#define mset(a,n) memset(a,n,sizeof a)
#define rep(i,a,b) for (__typeof((b)) i=(a);i<(b);i++)
#define repp(i,a,b,p) for(__typeof((b)) i=(a);i<(b);i+=p)
#define ren(i,a,b) for(__typeof((a)) i=(a);i>=(b);i--)
#define renn(i,a,b,p) for(__typeof((a) i=(a);i>=(b);i-=p)
#define ADD(a,b,c) ((a)%c+(b)%c)%c
#define SUB(a,b,c) ((a)%c-(b)%c+c)%c
#define MUL(a,b,c) (((a)%c)*((b)%c))%c
#define lbd lower_bound
#define ubd upper_bound
#define ll long long
#define ld long double
#define pb push_back
#define fi first
#define se second
#define vll vector<ll>
#define pll pair<ll,ll>
#define vpll vector<pll>
#define all(v) (v).begin(), (v).end()
#define sz(x) (ll)x.size()
#define out(n) cout<<n<<" "
#define outl(n) cout<<n<<endl
#define bug(n) {outl(n);return;}
#define N 250001
#define pii pair<int,int>
#define M 1000000007
 
ll gcd(ll a,ll b){
 	if(a==0)
 		return b;
 	return gcd(b%a,a);
 }
ll vpow(ll a,ll b,ll p){
	if(b==0)
		return 1;
	if(b==1)
			return a;
	ll temp=vpow(a,b/2,p);
	temp*=temp;
	temp%=p;
	if(b%2==0)
		return temp;
	temp=temp*a;
	temp%=p;
	return temp;
}
 
ll inverseMod(ll a,ll b,ll p){
	ll temp=vpow(b,p-2,p);
	ll ans=temp*a;
	ans%=p;
	return ans;
}
 
ll minl(ll a,ll b){
	if(a>b)
		return b;
	return a;
}
ll maxl(ll a,ll b){
	if(a>b)
		return a;
	return b;
}


ll lcm(ll a,ll b){
	ll g=__gcd(a,b);
	a/=g;
	a*=b;
	return a;
}
void solve(){
	ll n;
	cin>>n;
	ll sum=0;
	vector<pair<string,ll > > a(n);
	rep(i,0,n){
		cin>>a[i].first>>a[i].second;
		sum+=a[i].second;
	}
	string x;
	cin>>x;
	ll lsum=0;
	rep(i,0,n){
		lsum+=a[i].second;
		if(a[i].first==x)
			break;
	}
	cout<<sum-lsum<<endl;

}

int main(){
    io;
     ll t=1;
    //cin>>t;
    fix(12);
    while(t--)
        solve();
    return 0;
}		


Measured memory_bytes: 256
m=998244353
M=1<<20
f=[0]*M
g=[0]*M
h=[0]*M
f[0]=g[0]=f[1]=g[1]=h[1]=1
for i in range(2,M):
	f[i]=f[i-1]*i%m
	h[i]=m-h[m%i]*(m//i)%m
	g[i]=g[i-1]*h[i]%m
A,B=map(int,input().split())
if A<B:
	A,B=B,A
b=1
a=0
for j in range(1,B+1):
	a+=b*f[A+B-j]*g[B-j]*g[A]
	b=b*2%m
print((a*f[A]*f[B]*g[A+B]+A)%m)

Measured memory_bytes: 65132
#include<bits/stdc++.h>
using namespace std;
int main() {

    int i,K,N;
    ios::sync_with_stdio(0);
    cin.tie(0);
    long long a[200000],sum=0;

    cin>>N>>K;

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

    for(i=0;i<N-K;++i)
    {
        sum += a[i];
    }

    cout<<sum;



}


Measured memory_bytes: 1792
#include<iostream>
using namespace std;
int main()
{
  int x,y;
  cin>>x>>y;
  if(x%y==0){
    cout<<"-1";
  }
  else{
    for(int i=1;i<=1000000000000000000/x;i++){
      int z=x*i;
      if(y%z>0){
        cout<<z;
        break;
      }
    }
  }
}


Measured memory_bytes: 3588
#include <bits/stdc++.h>
#include <boost/range.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/algorithm_ext.hpp>
#include <boost/range/numeric.hpp>
#include <boost/range/adaptors.hpp>
#include <boost/range/irange.hpp>
using namespace std;
constexpr char nl = '\n';
using ll = long long;
using boost::irange;
using boost::adaptors::reversed;
namespace rng { using namespace boost; using namespace boost::range; }
struct init_ { init_(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(10); } } init_;

template<class C> auto operator>>(istream& in, C& c) -> typename enable_if<!is_void<decltype(c.begin())>::value && !is_same<C, string>::value, istream&>::type {
    for (auto& v : c) { in >> v; } return in; }
template<class C> auto operator<<(ostream& out, const C& c) -> typename enable_if<!is_void<decltype(c.begin())>::value && !is_same<C, string>::value, ostream&>::type {
    int i = 0; for (const auto& v : c) { if (i++) { out << ' '; } out << v; } return out; }
template<size_t N, class T, class R> using when_last = typename enable_if<N == tuple_size<remove_reference_t<T>>::value - 1, R>::type;
template<size_t N, class T, class R> using when_init = typename enable_if<N != tuple_size<remove_reference_t<T>>::value - 1, R>::type;
template<size_t N = 0, class T> auto operator>>(istream& in, T&& t) -> when_last<N, T, istream&> { return in >> get<N>(t); }
template<size_t N = 0, class T> auto operator>>(istream& in, T&& t) -> when_init<N, T, istream&> { return operator>><N + 1>(in >> get<N>(t), forward<T>(t)); }
template<size_t N = 0, class T> auto operator<<(ostream& out, const T& t) -> when_last<N, T, ostream&> { return out << get<N>(t); }
template<size_t N = 0, class T> auto operator<<(ostream& out, const T& t) -> when_init<N, T, ostream&> { return operator<<<N + 1>(out << get<N>(t) << ' ', t); }

#ifdef LOCAL
constexpr auto color_s_ = "\033[2m\033[33m", color_e_ = "\033[0m";
template<class T> void trace_(const T& v) { cerr << v; }
template<class T> void trace_(const vector<vector<T>>& m) { cerr << "\n"; for (const auto& v : m) { trace_(v); cerr << "\n"; } }
template<class T> void trace_(const char* s, const T& v) { cerr << color_s_ << s << "="; trace_(v); cerr << color_e_ << "\n"; cerr.flush(); }
template<class T, class... Ts> void trace_(const char* s, const T& v, const Ts&... vs) { cerr << color_s_; for (; *s != ','; ++s) { cerr << *s; } cerr << "="; trace_(v); cerr << ","; trace_(++s, vs...); }
#define TRACE(...) trace_(#__VA_ARGS__, __VA_ARGS__)
#else
#define TRACE(...)
#endif

int main() {
    int n;
    cin >> n;
    string s;
    cin >> s;
    int ans = 0;
    for (int i : irange(0, 1000)) {
        int si = -1;
        int tmp = i;
        for (int t : irange(0, 3)) {
            si++;
            if (si >= n) break;
            int a = tmp % 10; tmp /= 10;
            while (si < n && (s[si] - '0') != a) {
                si++;
            }
        }
        if (si < n) {
            ans++;
            TRACE(i);
        }
    }
    cout << ans << nl;
}


Measured memory_bytes: 512
N, M = [int(s) for s in input().split()]

def main():
    n = [0 for _ in range(N)]
    for _ in range(M):
        a, b = [int(s) - 1 for s in input().split()]
        n[a] += 1
        n[b] += 1
    print('\n'.join(map(str,n)))

if __name__ == '__main__':
    main()


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

int N;
int okashi[2][110];

/*制限が緩いからDPを使う必要がない？*/
/*{(N-1)+1}C1通り((1,1)から(2,N)までたどり方)*/

int main(){
  cin >> N;

  for(int i = 0; i < 2; i++){
    for(int j = 0; j < N;  j++){
      int v;  cin >> v;
      okashi[i][j] = v;
    }
  }
    

  int maX = 0;  int sum = 0;
  for(int i = 0; i < N; i++){
    sum = 0;
    for(int j = 0; j <N; j++) {
      if(j < i) sum += okashi[0][j];
      else if(i == j) sum += (okashi[0][j] + okashi[1][j]);
      else if(j > i) sum += okashi[1][j];
    }
    maX = max(maX, sum);
  }

  cout << maX << endl;
  return 0;
}
    
      
    
    

Measured memory_bytes: 256
#ifdef LOCAL
  #define debug_echo(expr) cout << expr;
#else
  #define debug_echo(expr)
#endif

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

#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
using namespace std;

template<class T>
ostream& operator <<(ostream& out, const vector<T>& v) {
    out << "[";
    bool isfirst = false;
    for (const T& e : v) {
        out << (isfirst ? ", " : "") << e;
        isfirst = true;
    }
    out << "]";
    return out;
}
template<class T>
ostream& operator <<(ostream& out, const set<T>& s) {
    out << "{";
    bool isfirst = false;
    for (const T& e : s) {
        out << (isfirst ? ", " : "") << e;
        isfirst = true;
    }
    out << "}";
    return out;
}
template<class A, class B>
ostream& operator <<(ostream& out, const pair<A, B>& p) {
    out << "(" << p.first << ", " << p.second << ")";
    return out;
}
template<class K, class V>
ostream& operator <<(ostream& out, const map<K, V>& s) {
    out << "{";
    bool isfirst = false;
    for (const auto& e : s) {
        out << (isfirst ? ", " : "") << e;
        isfirst = true;
    }
    out << "}";
    return out;
}

//
// Implementation
//

// int prices[4];
int N;
long long N100;
int prices[4];
vector<pair<pair<long long, long long>, float> > sortedprices(4);

bool buy_tea(long long& curlittle, long long& curprice, long long little, long long price) {
    // printf("%lld\n", N100);
    if (curlittle + little <= N100) {
        curlittle += little;
        curprice += price;
        return true;
    } else {
        return false;
    }
}

int main() {
    // scanf("%d %d %d %d", &prices[0], &prices[1], &prices[2], &prices[3]);
    scanf("%d %d %d %d", &prices[0], &prices[1], &prices[2], &prices[3]);
    scanf("%d", &N);
    N100 = (long long)N * (long long)100;

    sortedprices[0] = make_pair(make_pair(25, prices[0]), 25.0 / (float)prices[0]);
    sortedprices[1] = make_pair(make_pair(50, prices[1]), 50.0 / (float)prices[1]);
    sortedprices[2] = make_pair(make_pair(100, prices[2]), 100.0 / (float)prices[2]);
    sortedprices[3] = make_pair(make_pair(200, prices[3]), 200.0 / (float)prices[3]);
    sort(sortedprices.begin(), sortedprices.end(), [](pair<pair<long long, long long>, float> a, pair<pair<long long, long long>, float> b) -> int {
            return a.second > b.second;
        });

    long long curlittle = 0;
    long long curprice = 0;
    while (true) {
        rep (i, 4) {
            bool b = buy_tea(curlittle, curprice, sortedprices[i].first.first, sortedprices[i].first.second);
            if (b) {
                break;
            }
        }
        // printf("%lld %lld\n", curlittle, curprice);
        if (curlittle == N100){
            break;
        }
    }
    printf("%lld\n", curprice);
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub


import sys
# sys.setrecursionlimit(10**6)
# buff_readline = sys.stdin.buffer.readline
buff_readline = sys.stdin.readline
readline = sys.stdin.readline
readline = input

INF = 2**62-1


def read_int():
    return int(buff_readline())


def read_int_n():
    return list(map(int, buff_readline().split()))


def read_float():
    return float(buff_readline())


def read_float_n():
    return list(map(float, buff_readline().split()))


def read_str():
    return readline().strip()


def read_str_n():
    return readline().strip().split()

def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap

from fractions import Fraction

@mt
def slv(N, A):
    c = Counter()
    for a in A:
        a += '.0'
        t = a.split('.')
        b = int(t[0]) * 10**9 + int(t[1]) * 10**(9-len(t[1]))
        n5 = 0
        n2 = 0
        while b % 2 == 0:
            n2 += 1
            b //= 2
        while b % 5 == 0:
            n5 += 1
            b //= 5
        c[(n2, n5)] += 1

    ans = 0
    for k, kk in combinations_with_replacement(c.keys(), r=2):
        if k[0] + kk[0] >= 18 and k[1] + kk[1] >= 18:
            if k == kk:
                ans += c[k] * (c[k]-1) // 2
            else:
                ans += c[k] * c[kk]

    return ans



def main():
    N = read_int()
    A = [input() for _ in range(N)]
    print(slv(N, A))



if __name__ == '__main__':
    main()


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

#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
#define MOD 1000000007

using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

int iy[]={0, 0, 1, -1};
int ix[]={1, -1, 0, 0};

long long int n, m, sf, cho, nf, ns, nm;
priority_queue<long long int> q;
int main(){
	cin >> n;
	for(int i=0;i<n;i++){
		cin >> m;
		q.push(m);
	}
	for(int i=1;i<=n/2;i++){
		if(i==n/2)nf = q.top();
		sf += q.top();
		q.pop();
	}
	if((n+2)%2){
		nm = q.top();
		q.pop();
	}
	for(int i=1;i<=n/2;i++){
		if(i==1)ns = q.top();
		sf -= q.top();
		q.pop();
	}
	if((n+2)%2){
		cho = max(nm-nf, ns-nm);
	}else{
		cho = ns-nf;
	}

	cout << sf*2+cho << endl;
	return 0;
}

Measured memory_bytes: 1400
class Card:
    def __init__(self, num, suit, input_index):
        self.num = num
        self.suit = suit
        self.input_index = input_index


def partition(A, p, r):
    x = A[r - 1].num
    i = p - 1
    for j in range(p, r - 1):
        if A[j].num <= x:
            i = i + 1
            A[i], A[j] = A[j], A[i]
    A[i + 1], A[r - 1] = A[r - 1], A[i + 1]
    return i + 1


def quick_sort(A, p, r):
    if p < r-1:
        index = partition(A, p, r)
        quick_sort(A, p, index)
        quick_sort(A, index, r)


n = int(input())
li = [None] * n
for i in range(n):
    temp_list = list(map(str, input().split()))
    li[i] = Card(int(temp_list[1]), temp_list[0], i)

quick_sort(li, 0, n)

for i in range(n):
    if i < n - 1 and li[i].num == li[i + 1].num and li[i].input_index > li[i + 1].input_index:
        print('Not stable')
        break
    if i == n - 1:
        print('Stable')

for card in li:
    print(card.suit + ' {}'.format(card.num))



Measured memory_bytes: 29456
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
typedef long long ll;
#define ALL(v) v.begin(), v.end()
#define vmax(v) *max_element(ALL(v))
#define vmin(v) *min_element(ALL(v))
#define chmax(x, a) x = max(x, a)
#define chmin(x, a) x = min(x, a)

int main() {
    int K, A, B; cin >> K >> A >> B;
    while(A <= B) {
        if (A % K == 0) {
            cout << "OK" << endl;
            return 0;
        }
        A++;
    }
    cout << "NG" << endl;
}


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

using ll = long long;
const int INF = 1e9 + 1;

int main() {

	int N, K, R, S, P;
	cin >> N >> K >> R >> S >> P;
	string T;
	cin >> T;

	vector<bool>flag(N);

	ll ans = 0;

	rep(i, T.size()) {
		if (i-K<0||T[i] != T[i - K]) {
			if (T[i] == 'r')
				ans += P;
			else if (T[i] == 's')
				ans += R;
			else
				ans += S;
			flag[i] = true;
		}
		else {
			if (!flag[i - K]) {
				if (T[i] == 'r')
					ans += P;
				else if (T[i] == 's')
					ans += R;
				else
					ans += S;
				flag[i] = true;
			}
		}
	}

	cout << ans << endl;

	return 0;
}


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

int main() {
int K, A, B;
	cin >> K;
	cin >> A >> B;
	bool Check;
	Check = false;


	for (A; A <= B; A++)
	{
		if (A % K == 0)
		{
			Check = true;
		}
		else
		{
			
		}
	}
	if (Check == true)
	{
		cout << "OK" << endl;
	}
	else
	{
		cout << "NG" << endl;
	}
  
 
  
}

Measured memory_bytes: 3600
N,K= map(int,input().split())
p=10**9+7
q=0
 
def calc(n,k):
  if k==1:
    return n+1
  else:
    maxi = k*n- k*(k-1)//2
    mini=  k*(k-1)//2
    #print(k,maxi,mini,maxi-mini+1)
    return maxi-mini+1
  
ans=0
for i in range(K,N+2):
  ans = ( ans+calc(N,i) )%p
  
print(ans)


Measured memory_bytes: 9048
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
	int n;
	cin >> n;
	if(n==1){
		cout << 1 << endl;
	}
	if(1<n && n<4){
		cout << 2 << endl;
	}
	if(4<=n && n<8){
		cout << 4 << endl;
	}
	if(8<=n && n<16){
		cout << 8 << endl;
	}
	if(16<=n && n<32){
		cout << 16 << endl;
	}
	if(32<=n && n<64){
		cout << 32 << endl;
	}
	if(64<=n && n<=100){
		cout << 64 << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
using namespace std; 
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define ll long long
#define pb push_back
int cnt[2005];
vector<ll>rd,gr,wu; 
int main(int argc, char** argv) {
	int x,y,a,b,c;
	cin>>x>>y>>a>>b>>c;
	rep(i,1,a)
	{
		ll x;
		scanf("%lld",&x);
		rd.pb(x);
	}
	rep(i,1,b)
	{
		ll x;
		scanf("%lld",&x);
		gr.pb(x);	
	}
	rep(i,1,c)
	{
		ll x;
		scanf("%lld",&x);
		wu.pb(x);
	}
	int ans=0,rr=0,gg=0;
	sort(rd.begin(),rd.end());
	sort(gr.begin(),gr.end());
	sort(wu.begin(),wu.end());
	int now1=rd.size()-1;
	int now2=gr.size()-1;
	ll as=0;
	int now3=wu.size()-1;
	while(ans<x+y)
	{
	//	cout<<"sd";
		if(rr<x&&gg<y)
		{
			if(now3>=0&&wu[now3]>=rd[now1]&&wu[now3]>=gr[now2])
			{
				as+=wu[now3];
				now3--;
			}
			else if((rd[now1]>wu[now3]||now3<0)&&rd[now1]>=gr[now2])
			{
				as+=rd[now1];
				now1--;
				rr++;
			}
			else
			{
				as+=gr[now2];
				now2--;
				gg++;
			}
			ans++;
		}
		else if(rr<x)
		{
			if(now3>=0&&wu[now3]>=rd[now1])
			{
				as+=wu[now3];
				now3--;
			}
			else
			{
				as+=rd[now1];
				now1--;
				rr++;	
			}	
			ans++;		
		}
		else if(gg<y)
		{
			if(now3>=0&&wu[now3]>=gr[now2])
			{
				as+=wu[now3];
				now3--;
			}
			else
			{
				as+=gr[now2];
				now2--;
				gg++;	
			}	
		ans++;	
		}
	}
	cout<<as;
	return 0;
}

Measured memory_bytes: 3316
#include<bits/stdc++.h>
using namespace std;
template<class T> T read(){
	T x=0,w=1;char c=getchar();
	for(;!isdigit(c);c=getchar())if(c=='-') w=-w;
	for(;isdigit(c);c=getchar()) x=x*10+c-'0';
	return x*w;
}
template<class T> T read(T&x){
	return x=read<T>();
}
#define CO const
#define IN inline
typedef long long LL;

CO int mod=1000000000+7;
IN int add(int a,int b){
	return (a+=b)>=mod?a-mod:a;
}
IN int mul(int a,int b){
	return (LL)a*b%mod;
}
IN int fpow(int a,int b){
	int ans=1;
	for(;b;b>>=1,a=mul(a,a))
		if(b&1) ans=mul(ans,a);
	return ans;
}

int a[200010],b[200010];
int f[4020][4020];
#define dp(i,j) f[i+2001][j+2001]
int fac[8010],ifac[8010];

int main(){
	int n=read<int>();
	for(int i=1;i<=n;++i) read(a[i]),read(b[i]);
	for(int i=1;i<=n;++i) ++dp(-a[i],-b[i]);
	for(int i=-2000;i<=2000;++i)
		for(int j=-2000;j<=2000;++j) dp(i,j)=add(dp(i,j),add(dp(i-1,j),dp(i,j-1)));
	int ans=0;
	for(int i=1;i<=n;++i) ans=add(ans,dp(a[i],b[i]));
	fac[0]=1;
	for(int i=1;i<=8000;++i) fac[i]=mul(fac[i-1],i);
	ifac[8000]=fpow(fac[8000],mod-2);
	for(int i=7999;i>=0;--i) ifac[i]=mul(ifac[i+1],i+1);
	for(int i=1;i<=n;++i) ans=add(ans,mod-mul(fac[2*a[i]+2*b[i]],mul(ifac[2*a[i]],ifac[2*b[i]])));
	ans=mul(ans,fpow(2,mod-2));
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 65024
// Version.20.09.25.05.17.20.
#include <bits/stdc++.h>
#define pll pair<ll, ll>
using namespace std;
const int mod = 1e9 + 7;
typedef long long ll;

inline int fsp(int x, int k = mod - 2) {
    int res = 1;
    while (k) {
        if (k & 1) res = 1ll * res * x % mod;
        x = 1ll * x * x % mod, k >>= 1;
    }
    return res;
}

int n;
map<pll, int> num;
pll now[200200];

int main() {
#ifdef isLOCAL
    freopen(".in", "r", stdin);
    freopen(".out", "w", stdout);
#endif

    cin >> n;
    int aa = 0, bb = 0, cc = 0;
    for (int i = 1; i <= n; ++i) {
        long long x, y, g;
        scanf("%lld%lld", &x, &y);
        if (!x || !y) {
            if (!x && !y)
                ++cc;
            else if (!x) ++aa;
            else if (!y) ++bb;
            --i, --n;
            continue;
        }
        g = __gcd(abs(x), abs(y));
        if (x < 0) x = -x, y = -y;
        x /= g, y /= g;
        num[now[i] = make_pair(x, y)]++;
    }

    int ans = (fsp(2, aa) + fsp(2, bb) - 1) % mod;
    for (int i = 1; i <= n; ++i) {
        if (!num[now[i]]) continue;
        pll tmp = make_pair(-now[i].second, now[i].first);
        if (tmp.first < 0) tmp.first *= -1, tmp.second *= -1;
        int x = num[now[i]], y = num[tmp];
        num[now[i]] = num[tmp] = 0;
        int t = (fsp(2, x) + fsp(2, y) - 1) % mod;
        ans = 1ll * ans * t % mod;
    }

    ans = (ans - 1 + cc) % mod;
    if (ans < 0) ans += mod;
    cout << ans << endl;

    return 0;
}


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

// #define int long long
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; 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 SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#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 PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#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 pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

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

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


signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  ll n; cin>>n;
  vll a(n), b(n);
  ll prev=0;
  rep(i,n){
    a[i]=b[i]=prev+20000;
    prev=a[i];
  }
  reverse(all(b));
  vll p(n);
  rep(i,n){
    ll a; cin>>a; a--;
    p[i]=a;
  }
  ll now=0;
  rep(i,n){
    a[p[i]]+=now;
    now++;
  }
  rep(i,n){
    if(i) cout<<" ";
    cout<<a[i];
  }
  cout<<endl;
  rep(i,n){
    if(i) cout<<" ";
    cout<<b[i];
  }
  cout<<endl;
}


Measured memory_bytes: 1152
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
int main(){
    int n;
    cin >> n;
    vector<int> a(100010,0);
    for(int i=0;i<n;i++){
        int x;
        cin >> x;
        if(x==0){
            a[0]++;
            a[1]++;
        }else if(x==100000){
            a[99999]++;
            a[100000]++;
        }else{
            a[x-1]++;
            a[x]++;
            a[x+1]++;
        }
    }
    sort(a.begin(),a.end());
    reverse(a.begin(),a.end());
    cout << a[0] << endl;
}

Measured memory_bytes: 640
X, N = map(int, input().split())
P = list(map(int, input().split()))

Q = [q for q in range(-1, 102) if q not in P]  # -1以上101以下整数のうちPに存在しないもの
ans = min(Q, key=lambda q: (abs(q - X), q))  # maspyさん解法
print(ans)

Measured memory_bytes: 9116
#define M 393
i,j,d[M+1],phrase[M+1],r[M];
main(n,m,s,l,p){
	for(scanf("%d",&n);i<n;i++)for(scanf("%d%d%d",&s,&l,&p);s<=l;s++)if(phrase[s]<p)phrase[s]=p;
	for(i=1;i<=M;i++)d[i]=-1;
	for(i=1;i<=M;i++)if(phrase[i])for(j=0;j+i<=M;j++)if(d[j]>=0&&d[j+i]<d[j]+phrase[i])d[j+i]=d[j]+phrase[i];
	for(scanf("%d",&m),i=0;i<m;r[i++]=d[s])if(scanf("%d",&s),d[s]<0)exit(!puts("-1"));
	for(i=0;i<m;i++)printf("%d\n",r[i]);
exit(0);}

Measured memory_bytes: 600
#pragma GCC optimize("Ofast")
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<string.h>
#include<math.h>
#include<map>
#include<iomanip>
#include<queue>

const long long INF_L = 1e17+7;
const long long INF_I = 1e9+7;
const long long MOD = 1e9+7;
const double EPS = 1e-8;
const double PI=acos(-1);

using namespace std;


int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
  
	int n;
	cin >> n;
  
	vector<int> h(n);
	for(int i=0;i<n;i++){
		cin >> h[i];
	}
	
	h.push_back(INF_I);
	h.push_back(INF_I);
	h.push_back(INF_I);
	
	vector<int> dp(n,INF_I);
	dp[0]=0;
  
	for(int i=0;i<n;i++){
		dp[i+1]=min(dp[i+1],dp[i]+abs(h[i]-h[i+1]));
		dp[i+2]=min(dp[i+2],dp[i]+abs(h[i]-h[i+2]));
	}
  
	cout << dp[n-1] << endl;
	
	return 0;
}


Measured memory_bytes: 3996
import bisect
import sys


def input():
    return sys.stdin.readline()[:-1]

# N = int(input())
# A = [int(x) for x in input().split()]
# a, b, c = map(int, input().split())
# name1 = str(input())
# alph = {"A": 1, "B": 2, "C": 3, "D": 4, "E": 5}
# b = list(map(lambda x: math.ceil(x/10)*10, a))


n, y = map(int, input().split())
ans = [-1, -1, -1]
for man in range(n+1):
    for gosen in range(n+1-man):
        if 10000*man + 5000*gosen + 1000*(n-man-gosen) == y:
            ans = [man, gosen, n-man-gosen]
            break
print(" ".join(map(str, ans)))


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n, sum = 0;
  cin >> n;
  const int maxn = 25;
  int a[maxn], b[maxn], c[maxn];
 
  for(int i = 0; i < n; i++){
      cin >> a[i];
  }
  for(int i = 0; i < n; i++){
      cin >> b[i];
  }
  for(int i = 0; i < n-1; i++){
      cin >> c[i];
  }
 
  for(int i = 0; i < n; i++){
      sum += b[a[i]-1];
      if(i > 0 && a[i] == a[i-1]+1){
          sum += c[a[i-1]-1];
      }
  }
 
  cout << sum << endl;
} 

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<string>
#include<cstring> 
#include<cassert>
#include<cmath>
#include<sstream>
#include<fstream>
#include<map>
#include<set>
#include<vector>
#include<queue>
#include<stack>
#include<bitset>
using namespace std;
int a[100005];
int main()
{
	int n;
	cin>>n;
	int cnt=0;
	for(int i=1;i<=n;i++)
	{
		int x;
		cin>>x;
		if(x==i) a[x]=1;
	}
	for(int i=1;i<=n;i++)
	{
		int x=i;
		if(a[x]&&a[x+1])
		{
			cnt++;
			a[x]=0;
			a[x+1]=0;
		}
		else if(a[x])
		{
			cnt++;
			a[x]=0;
		}
	}
	cout<<cnt;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    int n;
    cin>>n;
    string s;
    cin>>s;
    int ans = 0;
    for(int i=0;i<n-2;i++){
        if(s[i]=='A' and s[i+1]=='B' and s[i+2]=='C')ans++;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
import numpy as np


N, X = map(int, input().split())
L_list = list(map(int, input().split()))

initial_val = 0
res = 0

if initial_val <= X:
    res += 1

for i in range(N):
    cd = initial_val + L_list[i]
    if cd <= X:
        res += 1
    initial_val = cd
    i += 1

print(res)


Measured memory_bytes: 12504
N,P=list(map(int,input().strip().split(' ')))
A=list(map(int,input().strip().split(' ')))
import math
odd=0
even=0
for i in range(len(A)):
    if A[i]%2==0:
        even+=1
    else:
        odd+=1
ans=0
def bino(a,b):
    return math.factorial(a)//(math.factorial(a-b)*math.factorial(b))


if P==0:
    for i in range(even+1):
        for j in range(0,odd+1,2):
            ans+=bino(even,i)*bino(odd,j)
else:
    for i in range(even+1):
        for j in range(1,odd+1,2):
            ans+=bino(even,i)*bino(odd,j)    
print(ans)        

Measured memory_bytes: 41200
//保留所有权利。
#include<iostream>
#include<stdio.h>//printするよ
#include<vector>
#include<algorithm>//辞書順はnext_permutationだよ
#include<set>
#include<string>
#include<string.h>
#include<time.h>
#include<random>
#include<cmath>
#include<math.h>
#include<queue>
#include<time.h>
#include<iomanip>
#include<utility>//swapで数値交換するよ
//END OF LIBRARIES.
#define rt "\n"//改行を最速化させるよ
#define rep(i,n) for(int i=0;i<n;i++)
#define rop(i,n) for(int i=1;i<=n;i++)
#define drep(i,n) for(int i=n-1;0<=i;i--)
#define yes(ans) if(ans)cout<<"yes"<<rt;else cout<<"no"<<rt;
#define Yes(ans) if(ans)cout<<"Yes"<<rt;else cout<<"No"<<rt;
#define YES(ans) if(ans)cout<<"YES"<<rt;else cout<<"NO"<<rt;
#define vcin(v) for (int i = 0; i < (v).size(); i++) { cin >> (v)[i]; }
#define sort(s) sort(s.begin(),s.end())
#define reve(s) reverse(s.begin(),s.end())
#define asas int ans=0
#define llcncn llint cnt=0
#define llasas llint ans=0
#define cncn int cnt=0
#define smsm int sum=0
#define str srting
#define v vector
#define nn int n=0
#define please return
#define AC 0//おまじないだよ
#define Rapid cin.tie(0);ios::sync_with_stdio(false)
//END OF DEFINE.
using namespace std;
typedef vector<int> vint;
typedef vector<string> vstr;
typedef vector<char> vcha;
typedef vector<double> vdou;
typedef long long int llint;
typedef pair<int, int> pint;
typedef pair<llint, llint> pllint;
typedef vector<llint> vllint;
typedef vector<pint> vpint;
typedef vector<pair<llint, llint>> vpllint;
typedef vector<vector<int>> vvint;
typedef vector<vector<llint>> vvllint;
typedef vector<vector<string>> vvstr;
typedef vector<vector<pint>> vvpint;
typedef vector<bool> vbool;
//printf("%02d:%02d:%02d\n", h, m, s);・・・2文字は埋める・h、m、ｓ
//END OF TYPEDEF.

//最大公約数（GCD）を求めるよ
//最小公倍数（LCM）は＜＜　A × B ÷ GCD　 ＞＞で求まるよ

long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}
long long LCM(long long a, long long b) {
	return a * b / GCD(a, b);
}
int x = 0, y = 0, z = 0,n = 0;
asas;
cncn;
//BEGIN OF CODE.
int main(void) {
	cin >> n >> x;
	vint c(n), t(n);
	rep(i, n)cin >> c[i] >> t[i];
	cnt = 10000;
	rep(i, n) {
		if (t[i] <= x) {
			if (cnt > c[i])	cnt = c[i];
		}
	}
	if (cnt == 10000) {
		cout << "TLE" << rt;
		return 0;
	}
	cout << cnt << rt;
	please AC;
}

Measured memory_bytes: 256
import Data.List

main = do
    [a,b,c,d] <- map read.words <$> getLine
    putStrLn.show.answer a b c d $ lcm c d

answer a b c d e = (b-a+1) -abc-abd+abe where
    ac_start = if mod a c == 0 then a else a + (c-mod a c)
    bc_end = b - mod b c
    abc = (div bc_end c - div ac_start c + 1)
    ad_start = if mod a d == 0 then a else a + (d-mod a d)
    bd_end = b - mod b d
    abd = (div bd_end d - div ad_start d + 1)
    ae_start = if mod a e == 0 then a else a + (e-mod a e)
    be_end = b - mod b e
    abe = (div be_end e - div ae_start e + 1)

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

#define NDEBUG
#ifdef DEBUG
#include "../cout11.h"
#undef NDEBUG
#endif
#include <cassert>

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> ii;
typedef pair<ll,ll> llll;
typedef pair<double,double> dd;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ii> vii;
typedef vector<vector<ii>> vvii;
typedef vector<ll> vll;

#define sz(a)  int((a).size())
#define pb  push_back
#define FOR(var,from,to) for(int var=(from);var<=(to);++var)
#define rep(var,n)  for(int var=0;var<(n);++var)
#define rep1(var,n)  for(int var=1;var<=(n);++var)
#define repC2(vari,varj,n)  for(int vari=0;vari<(n)-1;++vari)for(int varj=vari+1;varj<(n);++varj)
#define ALL(c)  (c).begin(),(c).end()
#define RALL(c)  (c).rbegin(),(c).rend()
#define tr(i,c)  for(auto i=(c).begin(); i!=(c).end(); ++i)
#define found(s,e)  ((s).find(e)!=(s).end())
#define mset(arr,val)  memset(arr,val,sizeof(arr))
#define mid(x,y) ((x)+((y)-(x))/2)
#define IN(x,a,b) ((a)<=(x)&&(x)<=(b))

#define INTSPACE 12
char _buf[INTSPACE*1000000 + 3];

int loadint() {
    if (fgets(_buf, INTSPACE+3, stdin)==NULL) return 0;
    return atoi(_buf);
}

int loadvec(vector<int>& v, int N=-1) {
    if (N == -1) {
        N = loadint();
        if (N==0) return 0;
    }
    int bufsize = INTSPACE*N + 3;
    if (fgets(_buf, bufsize, stdin)==NULL) return 0;
    v.resize(N);

    int i=0;
    bool last = false;
    for (char *p=&_buf[0]; ;) {
        char *q = p;
        while (*q > ' ') ++q;
        if (*q == 0x0D || *q == 0x0A) last = true;
        *q = 0;
        v[i++] = atoi(p);
        if (last || i == N) break;
        p = q+1;
    }
    // assert(i <= N);
    return i;
}

ll solve(ll s, ll c){
    ll cc = c/2;
    if (s >= cc) return cc;

    // s < cc
    ll ans = s;
    cc -= s; s = 0;
    return ans + cc/2;
    // return s + h/2;
}

int main() {
    ll N, M; cin >> N >> M;
    cout << solve(N,M) << endl;
    return 0;
}


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

int main() {
	int a, b;
  	string S;
	cin >> a >> b;
  	for (int i = 0; i < b+2; i++){
    	if (i == b+1){
        	cout << "#" << endl;
        }
      	else{
        	cout << "#";
        }
    }
  	for (int i = 0; i < a; i++){
    	cin >> S;
    	cout << '#' + S + '#' << endl;
    }
  	for (int i = 0; i < b+2; i++){
    	if (i == b+1){
        	cout << "#" << endl;
        }
      	else{
        	cout << "#";
        }
    }
}


Measured memory_bytes: 3624
//高知能系Vtuberの高井茅乃です。
//Twitter: https://twitter.com/takaichino
//YouTube: https://www.youtube.com/channel/UCTOxnI3eOI_o1HRgzq-LEZw

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

#define INTINF 1999999999
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define MODA 1000000007 

int main() {
	int ans = 0;
	int tmp;
	int x, y, z;
	cin >> x >> y >> z;
	x -= z;
	cout << x / (y+z) << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<iomanip>
#include<cstdlib>
#include<cstdio>
#include<cmath>

using namespace std;
int main()
{
    int a,b,c,d,e,n,i,ans=0;
    scanf("%d%d%d%d",&a,&b,&c,&n);
    d=max(a,b);
    ans=a+b-d;
    e=max(d,c);
    ans+=d+c-e;
    for(i=0; i<n; i++)
    {
        e=e*2;
    }
    ans+=e;
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 256
import math

A = int(input())
B = int(input())
C = int(input())
D = int(input())
E = int(input())


def main():
    M = [A, B, C, D, E]
    L = [int(math.ceil(m / 10) * 10) for m in M]

    x = min([(m-1) % 10 for m in M]) + 1

    print(sum(L) - 10 + x)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064