akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>  //2fat2code a.k.a grandmixer420
#define ll long long
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#define all(a) (a).begin(), (a).end()
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define sz size
#define fr first
#define sc second
#define pb push_back
#define er erase
#define in insert
#define mp make_pair
#define pi pair
#define rc(s) return cout<<s,0
#define int long long
using namespace std;

int k,a,b,ans=1;

int32_t main(){
    ios_base :: sync_with_stdio(0); cin.tie(); cout.tie();
    cin >> k >> a >> b;
    if(b-a>=3){
        if(k>=a-1){
            ans=a;
            k-=(a-1);
        }
        int h=k/2;
        if(k%2==1) ans++;
        ans+=h*(b-a);
        rc(ans);

    }
    else rc(k+1);
}


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

#define ll long long
#define pb push_back
#define nl cout << '\n'
#define sor(x) sort(x.begin(), x.end())
#define rev(v) reverse(v.begin(), v.end())
#define maxin(v) *max_element(v.begin(), v.end())
#define minin(v) *min_element(v.begin(), v.end())
#define sumall(vect) accumulate(vect.begin(), vect.end(), 0)
#define count(x, vect) count(vect.begin(), vect.end(), x)
#define lb(v, temp) lower_bound(v.begin(), v.end(), temp)
#define ub(v, temp) upper_bound(v.begin(), v.end(), temp)
#define fi first
#define se second
#define llmax 100000000000000000
#define deb(x) cout << #x << " " << x << "\n"
#define pll pair<ll, ll> 
#define vll vector<ll> 
#define rub cout << "------------------------------------\n"
#define min(a, b, c) min(a, min(b, c))
#define max(a, b, c) max(a, max(b, c))
void read(vector<ll> &v)
{
	for (int i = 0; i < v.size(); i++)
		cin >> v[i];
}

void print(vector<ll> v)
{
	for (int i = 0; i < v.size(); i++)
		cout << v[i] << " ";
}
ll n,m,a,b,temp;
string str;
set<ll> s;
vll v;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>str;
    ll count1=0;
    ll count2=0;
    int len=str.length();
    string s1;
    string s2;
    int flag=0;
    for(int i=0;i<len;i++)
    {
        s1.pb('0'+flag);
        s2.pb('0'+!flag);
        flag=!flag;
    }
    for(int i=0;i<len;i++)
    {
        if(str[i]!=s1[i])
        count1++;
        if(str[i]!=s2[i])
        count2++;
    }
    cout<<min(count1,count2,(ll)llmax);
}

Measured memory_bytes: 720
#include<bits/stdc++.h>
#define fast {ios_base::sync_with_stdio(false);cin.tie(NULL);}
#define pb push_back
typedef long long int ll;
using namespace std;
int main(void){
	fast;
	int n,q,i,x,y;
	ll s=0;
	cin>>n;
	int a[n]
;	map<int,int>mp;
	for(i=0;i<n;i++){
		cin>>a[i];
		mp[a[i]]++;
		//cin>>a[i];
		s+=a[i];
	}
	cin>>q;
	for(i=0;i<q;i++){
		cin>>x>>y;
		s+=(y-x)*mp[x];
		mp[y]+=mp[x];
		mp[x]=0;
		cout<<s<<endl;
	}
}


Measured memory_bytes: 8428
object Main {
    def main(args: Array[String]) = {
        val in = io.Source.stdin.getLines
        for (cards <- in if cards != "-") {
            println(in.take(in.next.toInt).map(_.toInt).foldLeft(cards)((a, b) => a.drop(b) + a.take(b)))
        }
    }
}

Measured memory_bytes: 43948
/*@author Vipen Loka*/
#include <bits/stdc++.h>
#define endl '\n'
#define ff first
#define ss second
#define ll long long int
#define vi vector<int>
#define vll vector<ll>
#define vvi vector < vi >
#define pii pair<int,int>
#define pll pair<long long, long long>
#define mod 1000000007
#define inf 1000000000000000001;
#define deb(x) cout << #x << ':' << x << '\n';

using namespace std;

void solve(){
	int i,j;
	string a,b;
	cin >> a >> b;
	int x=a.size(),y=b.size();
	vector<vector<int>> dp(x+1,vector<int>(y+1,0));

	for (int i = 1; i < x+1; ++i)
	{
		for (int j = 1; j < y+1; ++j)
		{
			if(a[i-1]==b[j-1]){
				dp[i][j]=dp[i-1][j-1]+1;
			}
			else{
				dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
			}
		}
	}

	// printf("%d\n",dp[x][y]);
	i=x;j=y;
	string ans;
	// for(auto x:dp){
	// 	for(auto y:x){
	// 		cout << y << ' ';
	// 	}
	// 	cout << endl;
	// }
	while(i>0 && j>0){
		if(dp[i][j-1]==dp[i][j]){
			j--;
		}
		else if(dp[i-1][j]==dp[i][j]){
			i--;
		}
		else{
			ans=a[i-1]+ans;
			i--;
			j--;
		}
	}

	cout << ans << endl;
}


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


Measured memory_bytes: 38920
#include "bits/stdc++.h"
    using namespace std;

    #define pb push_back
    #define fr(i, n) for(int i = 0; i < n; i++)
    #define frr(i, n) for(int i = 1; i <= n; i++)

    #define dbg(x) cout << #x << " = " << x << endl
    #define all(x) x.begin(),x.end()
    #define ms(x, i) memset(x, i, sizeof(x))

    #define p(x) cout << x << "\n"
    #define pv(x) fr(i, x.size()) cout << x[i] << " \n"[i==x.size()-1]

    #define f first
    #define s second

    #define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)

    typedef long long int ll;
    typedef long double ld;
    typedef pair<int,int> pii;
    typedef pair<ll,ll> pll;
    typedef vector<int> vi;
    typedef vector<ll> vl;

    const int INF = 0x3f3f3f3f;
    const ll LINF = 0x3f3f3f3f3f3f3f;

    int main() {
        fastio;

        ll x, y, a, b, c;
        cin >> x >> y >> a >> b >> c;

        ll p[a], q[b], r[c];
        fr(i, a) cin >> p[i];
        fr(i, b) cin >> q[i];
        fr(i, c) cin >> r[i];

        sort(p, p+a); reverse(p, p+a);
        sort(q, q+b); reverse(q, q+b);
        sort(r, r+c); reverse(r, r+c);

        frr(i, c-1) r[i] += r[i-1];
        ll red = 0, green = 0, ans = 0;

        if (x+y-1 < c) ans = r[x+y-1];

        ll ac = 0ll, tk = 0;
        while (red < x && green < y) {

            if (p[red] > q[green]) ac += p[red++];
            else                   ac += q[green++];
            tk++;

            ll amt = x+y-tk;
            if (amt > 0 && amt <= c) ans = max(ans, ac+r[amt-1]);
        }

        while (red < x) {
            ac += p[red++];
            tk++;
            ll amt = x+y-tk;
            if (amt > 0 && amt <= c) ans = max(ans, ac+r[amt-1]);
        }

        while (green < y) {
            ac += q[green++];
            tk++;
            ll amt = x+y-tk;
            if (amt > 0 && amt <= c) ans = max(ans, ac+r[amt-1]);
        }

        ans = max(ans, ac);
        p(ans);
    }


Measured memory_bytes: 2560
#include <bits/stdc++.h>
#include <cmath>
#include <numeric>
using namespace std;
#define rep(i,a,b) for(int64_t i=(a); i<(b); ++i) // a ≦ i < b 
#define Rrep(i,a,b) for(int64_t i=(a);i>=(b);--i) // reverse repeat. a から b まで減少．
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend() //逆イテレータ
#define INF 1000000000000
#define MOD 1000000007LL
#define RANGE(a,b,c) (a).begin()+(b),(a).begin()+(c) // [b,c) イテレータ
typedef pair<int64_t, int64_t> PII;
typedef vector<int64_t> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;
typedef int64_t i64;

struct BIT{
    int N;
    VI bit; 
    BIT(VI s) : N(s.size()), bit(N, 0)  { 
        rep(i, 0, N) add(i, s[i]); //O(NlogN)
    }
    void add(int a, int w) { // v[a] += w. O(logN)
        for (int x = a; x < N;  x |= x + 1) bit[x] += w;
    }
    int sum(int a) { // [0, a) 和
        int ret = 0;
        for (int x = a - 1; x >= 0; x = (x & (x + 1)) - 1) 
            ret += bit[x];
        return ret;
    }
    int parsum(int a, int b){ // [a, b) 和.
        return sum(b) - sum(a);
    }
};

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

int n; cin >> n;
VI a(n); rep(i, 0, n) cin >> a[i];

VI cnt(2, 0);

for (int c: {0, 1}){
    BIT b(a);
    VI pm(n, 1); 
    for (int i = c; i < n; i += 2) pm[i] *= -1;

    rep(i, 1, n+1){
        i64 bsumi = b.sum(i);
        if (bsumi) {
            int sign = bsumi / abs(bsumi);
            if (pm[i-1] != sign) {
                b.add(i-1, -bsumi - sign);
                cnt[c] += abs(bsumi) + 1;
            }
        }
        else {
            b.add(i-1, pm[i-1]);
            ++cnt[c];
        }
    }
}

cout << *min_element(ALL(cnt))  << endl;

}
// 書いて考える
// 境界，出力文字列 チェック
// 可読性優先．高速化次点．
// まずは全探索，分割統治，次にDP
// 制限を見る．境界に注意．求めたい量の変域．動かせる量．
// 偶奇，逆から，ソート，出現回数，出現位置，DP， 余事象，包除
// データ構造． 問題の特徴量．単調性，二分探索
// 存在判定：構成方法，入力の特徴
// gcd, lcm ,素因数分解．
// 例外を十分に含む一般化．想像力の限界
// 小さい系から例示
// 代数的処理．前処理によるクエリ高速化．
// 始めは過剰に例示・場合分けしてもいい．各場合を確実に対処．
// 自明な例から処理，除外．
// 小数のときは，精度の設定する．doubel 変数に数値を入力するときは 123. とする．
// テストケース作成は数表あり
// 実行エラー：vector添え字超え．0割り．



Measured memory_bytes: 2672
#include<bits/stdc++.h>
using namespace std;
typedef int sign;
typedef long long ll;
#define For(i,a,b) for(register sign i=(sign)(a);i<=(sign)(b);++i)
#define Fordown(i,a,b) for(register sign i=(sign)(a);i>=(sign)(b);--i)
const int N=1e5+5;
template<typename T>bool cmax(T &a,T b){return (a<b)?a=b,1:0;}
template<typename T>bool cmin(T &a,T b){return (a>b)?a=b,1:0;}
template<typename T>T read()
{
	T ans=0,f=1;
	char ch=getchar();
	while(!isdigit(ch)&&ch!='-')ch=getchar();
	if(ch=='-')f=-1,ch=getchar();
	while(isdigit(ch))ans=(ans<<3)+(ans<<1)+(ch-'0'),ch=getchar();
	return ans*f;
}
template<typename T>void write(T x,char y)
{
	if(x==0)
	{
		putchar('0'),putchar(y);
		return;
	}
	if(x<0)
	{
		putchar('-');
		x=-x;
	}
	static char wr[20];
	int top=0;
	for(;x;x/=10)wr[++top]=x%10+'0';
	while(top)putchar(wr[top--]);
	putchar(y);
}
void file()
{
#ifndef ONLINE_JUDGE
	freopen("in","r",stdin);
	freopen("out","w",stdout);
#endif
}
int n;
ll A,B,a[N];
void input()
{
	n=read<int>()+1,A=read<ll>(),B=read<ll>();
	For(i,2,n)a[i]=read<ll>();
}
int dp[N][2];
const int mo=1e9+7;
void add(int &x,int y){x+=y;x-=(x>=mo?mo:0);}
int la[N],lb[N],ua[N],ub[N];
void init()
{
	la[1]=lb[1]=1;
	for(int i=2,j=2,k=2;i<=n;i++)
	{
		if(a[i-1]+A<=a[i])la[i]=la[i-1];
		else la[i]=i;
		if(a[i-1]+B<=a[i])lb[i]=lb[i-1];
		else lb[i]=i;
		while(a[j]+A<=a[i])j++;
		ua[i]=j-1;
		while(a[k]+B<=a[i])k++;
		ub[i]=k-1;
	}
//	For(i,1,n)cout<<la[i]<<' '<<ua[i]<<endl;
//	cout<<endl;
//	For(i,1,n)cout<<lb[i]<<' '<<ub[i]<<endl;
//	cout<<endl;
}
void work()
{
	dp[1][0]=dp[1][1]=1;
	ua[n+1]=n-1,ub[n+1]=n-1;
	For(i,2,n)
	{
		if(lb[i]-1<=ua[i+1])dp[i][0]=(dp[min(i-1,ua[i+1])][1]-dp[max(0,lb[i]-2)][1]+mo)%mo;		
		//cout<<min(i-1,ua[i])<<' '<<max(0,lb[i-1]-1)<<endl;
//		cout<<dp[min(i-1,ua[i])][1]<<' '<<dp[max(0,lb[i-1]-1)][1]<<endl;
		if(la[i]-1<=ub[i+1])dp[i][1]=(dp[min(i-1,ub[i+1])][0]-dp[max(0,la[i]-2)][0]+mo)%mo;		
		add(dp[i][0],dp[i-1][0]);
		add(dp[i][1],dp[i-1][1]);
	//	cout<<i<<' '<<dp[i][0]<<' '<<dp[i][1]<<endl;
	}
//	cerr<<dp[n][0]-dp[n-1][0]<<endl;
//	cerr<<dp[n][1]-dp[n-1][1]<<endl;
	int ans=(dp[n][0]-dp[n-1][0])+(dp[n][1]-dp[n-1][1]);
	ans=(ans%mo+mo)%mo;
	write(ans,'\n');
}
int main()
{
//	file();
	input();
	init();
	work();
	return 0;
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
#include <string>
using namespace std;
 
int main() {
  int n;
  cin >> n;
  vector<int> v(n);
  vector<int> c(n);
  for(int i=0;i<n;i++){
    cin >> v.at(i);
  }
  for(int i=0;i<n;i++){
    cin >> c.at(i);
  }
  vector<int> diff(n);
  for(int i=0;i<n;i++){
    diff.at(i) = v.at(i) - c.at(i);
  }
  
  int sum=0;
  for(int i=0;i<n;i++){
    if(diff.at(i) > 0){
      sum += diff.at(i);
    }
  }
  cout << sum << endl;
  return 0;
  
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>

using namespace std;

const int MAX_V = 15;
const int INF = 1<<28;

int G[MAX_V][MAX_V];

int V, E;
int memo[MAX_V][1 << MAX_V];
void init() {
    memset(memo, -1, sizeof(memo));
}
int dfs(int v, int used) {
    if (used == (1 << V) - 1) return G[v][0];
    if (memo[v][used] >= 0) return memo[v][used];
    int ret = INF;
    for (int u = 0; u < V; u++) {
        if (v == u || G[v][u] == INF || (used & (1 << u))) continue;
        ret = min(ret, dfs(u, used | (1 << u)) + G[v][u]);
    }
    return memo[v][used] = ret;
}
int TSP() {
    init();
    return dfs(0, 1);
}

int main() {
    cin >> V >> E;
    for (int i = 0; i < V; i++) {
        for (int j = 0; j < V; j++) G[i][j] = INF;
        G[i][i] = 0;
    }
    for (int i = 0; i < E; i++) {
        int s, t, d;
        cin >> s >> t >> d;
        G[s][t] = d;
    }
    int Ans = TSP();
    cout << (Ans >= INF ? -1 : Ans) << endl;
    return 0;
}

Measured memory_bytes: 3092
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<functional>
#include<queue>
#include<cmath>
#include<algorithm>
#include<complex>
#include<cstdlib>
#include<set>
#include<cctype>

#define DBG cout << '!' << endl;
#define REP(i,n) for(int i = 0;i < (n);++i)
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int i = 0;i < (n);i++)cout << v[i] << ' ';cout << endl << endl;}
#define SHOW2d(v,i,j) {for(int a = 0;a < i;a++){for(int b = 0;b < j;b++)cout << v[a][b] << ' ';cout << endl;}cout << endl;}
#define ALL(v) v.begin(),v.end()

using namespace std;

typedef long long ll;
typedef vector<int> iv;
typedef vector<iv> iiv;
typedef vector<string> sv;

int main()
{
	ll n;
	cin >> n;
	
	for(int i = 1;i <= 3500;++i)
	{
		for(int j = 1;j <= 3500;++j)
		{
			ll tmp1 = n * i * j;
			ll tmp2 = 4 * i * j - n * i - n * j;
			
			if(tmp2 > 0 && tmp1 % tmp2 == 0)
			{
				ll tmp3 = tmp1 / tmp2;
				cout << i << ' ' << j << ' ' << tmp3 << endl;
		//		cout << 4 * i * j * tmp3 - n * (i * j + j * tmp3 + tmp3 * i);
				return 0;
			}
		}
	}
	
	
	
	
	
	return 0;
}

Measured memory_bytes: 256
#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 N;
  cin >> N;
  vector<int> H(N);
  for (int i = 0; i < N; i++)
  {
    cin >> H[i];
  }
  
  int ans = 0;
  int MH = H[0];
  for (int i = 0; i < N; i++)
  {
    if (MH <= H[i]) {
      ans++;
      MH = H[i];
    }
  }
  cout << ans << endl;

  return 0;
}


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

int m, n, k;
int field[3][1010][1010];

int main()
{
  scanf("%d%d%d", &m, &n, &k);
  
  for(int i = 1; i <= m; i++)
    for(int j = 1; j <= n; j++){
      char in;
      cin >> in;
      for(int j2 = 0; j2 < 3; j2++)
	field[j2][i][j] = field[j2][i - 1][j] + field[j2][i][j - 1] - field[j2][i - 1][j - 1];
      if(in == 'J')
	field[0][i][j]++;
      else if(in == 'O')
	field[1][i][j]++;
      else
	field[2][i][j]++;
    }
  
  for(int i = 0; i < k; i++){
    int a, b, c, d;
    scanf("%d%d%d%d", &a, &b, &c, &d);
    printf("%d %d %d\n",
	   field[0][c][d] + field[0][a - 1][b - 1] - field[0][a - 1][d] - field[0][c][b - 1],
	   field[1][c][d] + field[1][a - 1][b - 1] - field[1][a - 1][d] - field[1][c][b - 1],
	   field[2][c][d] + field[2][a - 1][b - 1] - field[2][a - 1][d] - field[2][c][b - 1]);
  }
  return 0;
}

Measured memory_bytes: 13092
# -*- coding: utf-8 -*-
n = int(input())
f = []
for _ in range(n):
    f.append(input().split())
p = []
for _ in range(n):
    p.append(list(map(int, input().split())))

res = None
for i in range(1,2**10):
    joisino = [str(i>>n&1) for n in range(10)]
    prof = 0
    for j in range(n):
        c = 0
        for k in range(10):
            if joisino[k]=="1" and f[j][k]=="1":
                c += 1
        prof += p[j][c]
    if res is None:
        res = prof
    else:
        res = max(res, prof)
print(res)


Measured memory_bytes: 3064
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define all(v) v.begin(), v.end()
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define Rep(n) for (ll _ = 0; _ < (ll)(n); _++)
#define P pair<ll,ll>
#define fs first
#define sc second

template<class S>S sum(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));}
ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
ll min(int a,ll b){return min((ll)a,b);} ll min(ll a,int b){return min(a,(ll)b);}
template <class S> void print(vector<S> &v){for(ll i=0; i<(ll)v.size(); i++){cerr << v[i] << ' ';}cerr << endl;}
template <class S> void print(vector<vector<S>> &v) {for (ll i = 0; i < (ll)v.size(); i++) {for (ll j = 0; j < (ll)v[i].size(); j++) {cerr << v[i][j] << ' ';}cerr << endl;}}

int main(){
	int n; cin >> n;
	ll h; cin >> h;
	vector<ll> A(n), B(n);
	rep(i,n){cin >> A[i]; cin >> B[i];}
	ll a = max(A);
	sort(B.rbegin(), B.rend());
	ll ans = 0;
	for(ll b:B){
		if(b < a){
			break;
		}
		if(h <= 0){
			cout << ans << endl;
			return 0;
		}
		ans++;
		h-=b;
	}
	cout << ans + (h<0 ? 0 : (ll)ceil(h/(double)a)) << endl;
}


Measured memory_bytes: 1792
from collections import Counter
from heapq import heappop, heappush


def solve(n, sss):
    ccc = Counter(sss)
    keys = sorted(ccc.keys(), reverse=True)
    if ccc[keys[0]] != 1:
        return False

    q = [(1, keys[0])]
    for k in keys[1:]:
        nq = []
        for _ in range(ccc[k]):
            try:
                r, s = heappop(q)
            except IndexError:
                return False
            if r < n:
                nq.append((r + 1, k))
                heappush(q, (r + 1, s))
        for item in nq:
            heappush(q, item)

    return True


n = int(input())
sss = list(map(int, input().split()))
print('Yes' if solve(n, sss) else 'No')


Measured memory_bytes: 40512
#include<iostream>
#include<algorithm>
#include<vector>
#include<functional>
#include<string>
#include<cmath>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<cstdio>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;

int main() {
  int H, W;
  cin >> H >> W;
  vector<vector<int>> s(H * W, vector<int>(H * W, 0)), dp(H * W,vector<int>(H * W, 1001001001));
  int black = 0;
  for(int h = 0; h < H; h++) {
    string tmp;
    cin >> tmp;
    for(int w = 0; w < W; w++){
      if(tmp[w] == '.'){
        s[h][w] = 1;
      }else{
        black++;
      }
    }
  }
  if(s[0][0] == 0){
    cout << -1 << endl;
    return 0;
  }

  Graph G(H * W);
  for(int i = 0; i < H * W; i++) {
    //cout << i << " ";
    for(int j = 0; j < H * W; j++){
      if(i == j) {

        //cout << 2 << " ";
      } else if(s[i / W][i % W] == 1 && s[j / W][j % W] == 1) {
        //縦　横
        if(abs(i / W - j / W) == 1 && i % W == j % W || abs(i % W - j % W) == 1 && abs(i / W - j / W) == 0) {
          //cout << j << " ";
          G[i].push_back(j);
          //G[j].push_back(i);
        }else{
          //cout << 0 << " ";
        }
      }else{
        //cout << 0 << " ";
      }
    }
    //cout << endl;
  }
  vector<int> dist(H * W, -1);
  queue<int> que;
  dist[0] = 0;
  que.push(0);

  while(!que.empty()){
    int v = que.front();
    que.pop();

    for(int nv : G[v]){
      if(dist[nv] == -1){
        dist[nv] = dist[v] + 1;
        que.push(nv);
      }
    }
  }
  /*
  for(int i = 0; i < H * W; i++){
    cout << i << ":" << dist[i] << " ";
  }
  cout << endl;
  cout << dist[H * W - 1] << endl;
  */
  if(dist[H * W - 1] == -1){
    cout << -1 << endl;
    return 0;
  }
  cout << H * W - (dist[H * W - 1] + 1) - black << endl;
  return 0;
}

Measured memory_bytes: 49408
import java.util.*;
//import java.math.BigInteger;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        //String str = sc.next();
        int N = sc.nextInt();
        //int[] m = new int[N];
        
        if(N < 1000){
            System.out.println("ABC");
        }else{
            System.out.println("ABD");
        }
    }
}


Measured memory_bytes: 35636
//////////////////////////
/*      _        ____   */
/*  U  /"\  u U /"___|  */
/*   \/ _ \/  \| | u    */
/*   / ___ \   | |/__   */
/*  /_/   \_\   \____|  */
/*   \\    >>  _// \\   */
/*  (__)  (__)(__)(__)  */
/*  Compro by NULL_CT©  */
//////////////////////////
/*STL Libs*/
#include <algorithm>
#include <array>
#include <bitset>
#include <cctype>
#include <chrono>
#include <cmath>
#include <complex>
#include <cstdint>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iomanip>
#include <ios>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

/*Boost*/
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

#define REP(i, lower, upper) for (long long i = lower; i < upper; i++)
#define ALL(list) (list.begin()), (list.end())

using namespace std;
using bint = boost::multiprecision::cpp_int;
typedef long long ll;

constexpr int MOD = 10000007;

vector<long long> divisor(long long n) {
  vector<long long> head, tail;
  for (long long i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      head.push_back(i);
      if (i * i != n)
        tail.push_back(n / i);
    }
  }
  head.insert(head.end(), tail.rbegin(), tail.rend());
  return (head);
}

//--------------------------------

void execute() {
  string s;
  cin >> s;
  ll size = s.size();
  vector<ll> ls(s.size() + 1, 0);
  // 0 <(0) 1 <(1) 2

  for (ll i = 0; i < size; i++)
    if (s[i] == '<')
      ls[i + 1] = ls[i] + 1;

  for (ll i = size - 1; i >= 0; i--)
    if (s[i] == '>')
      ls[i] = max(ls[i], ls[i + 1] + 1);

  ll ans = 0;
  for (auto i : ls) {
    ans += i;
  }
  cout << ans << endl;
}

//--------------------------------

int main() {
  cin.tie(0);
  ios::sync_with_stdio(0);
  // cout<<fixed<<setprecision(20);

  execute();

  return (0);
}


Measured memory_bytes: 7360
import sys
import math
import heapq
sys.setrecursionlimit(10**7)
INTMAX = 9223372036854775807
INTMIN = -9223372036854775808
DVSR = 1000000007
def POW(x, y): return pow(x, y, DVSR)
def INV(x, m=DVSR): return pow(x, m - 2, m)
def DIV(x, y, m=DVSR): return (x * INV(y, m)) % m
def LI(): return map(int, sys.stdin.readline().split())
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())


def FLIST(n):
    res = [1]
    for i in range(1, n+1):
        res.append(res[i-1]*i % DVSR)
    return res


N = II()
AS = [0]+list(LI())

res = 0
for i in range(1, N+1):
    res += AS[i] % 2 and i % 2

print(res)


Measured memory_bytes: 9248
#include <bits/stdc++.h>//Carefully Crafted by hetp111
using namespace std;
#define int long long
#define double long double
#define all(v) (v).begin(),(v).end()
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int,int>
#define vii vector<pii>
#define MOD 1000000007
#define MOD2 998244353
#define MOD3 1000000009
#define PI acos(-1)
#define eps (1e-8)
#define INF (1e18)
#define FASTER ios_base::sync_with_stdio(0);cin.tie(0)
template<class A,class B>ostream&operator<<(ostream&out,const pair<A,B>&a){return out<<"("<<a.first<<","<<a.second<<")";}
template<class A>ostream&operator<<(ostream&out,const vector<A>&a){for(const A &it:a)out<<it<<" ";return out;}
template<class A,class B>istream&operator>>(istream&in,pair<A,B>&a){return in>>a.first>>a.second;}
template<class A>istream&operator>>(istream&in,vector<A>&a){for(A &i:a)in>>i;return in;}
ifstream cinn("in.in");ofstream coutt("out.out");
int poww(const int &a,int b,const int &m=MOD){if(b==0)return 1;int x=poww(a,b/2,m);x=x*x%m;if(b&1)x=x*a%m;return x;}
int ceil(const int &a,const int &b){return (a+b-1)/b;}
////Read:
//Check corner cases, n==1;
//
////Some function:
//__builtin_popcountll(), is_sorted(),

signed main(){
    FASTER;
    int x;cin>>x;
    int a;
    if(x>=400 && x<=599)a=8;
    if(x>=600 && x<=799)a=7;
    if(x>=800 && x<=999)a=6;
    if(x>=1000 && x<=1199)a=5;
    if(x>=1200 && x<=1399)a=4;
    if(x>=1400 && x<=1599)a=3;
    if(x>=1600 && x<=1799)a=2;
    if(x>=1800 && x<=1999)a=1;
    cout<<a;
}

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

int N;

int main() {
	scanf("%d", &N);
	multiset<int> A;
	for (int i = 0; i < N; i++) {
		int d; scanf("%d", &d);
		A.insert(d);
	}

	// on diameter path
	int diam = *A.rbegin();
	int low = diam;
	for (int i = 0; i <= diam; i++) {
		int d = max(i, diam-i);
		if (A.find(d) == A.end()) {
			puts("Impossible");
			return 0;
		}
		A.erase(A.find(d));
		low = min(low, d);
	}

	if (!A.empty() && *A.begin() <= low) {
		puts("Impossible");
	} else {
		puts("Possible");
	}

	return 0;
}

Measured memory_bytes: 256
/*{{{*/
//#pragma GCC optimize("O3")

#include <bits/stdc++.h>

#ifdef __linux__
#define getchar getchar_unlocked
#define putchar putchar_unlocked
#endif

typedef long long ll;
typedef std::pair<int, int> pii;

std::string Name = __FILE__;
std::string iput = Name.substr(0, Name.length() - 4) + ".in";
std::string oput = Name.substr(0, Name.length() - 4) + ".out";

template <class T> inline bool chkmin(T &x, T y) { return x > y ? x = y, true : false; }
template <class T> inline bool chkmax(T &x, T y) { return x < y ? x = y, true : false; }

template <class T> inline T &read(T &x)
{
    static int f;
    static char c; 
    for (f = 1; !isdigit(c = getchar()); ) {
        if (c == '-')
            f = -1;
    }
    for (x = 0; isdigit(c); c = getchar()) {
        x = x * 10 + c - 48;
    }
    return x *= f;
}
 
template <class T> inline void write(T x, const char p = '\n')
{
    static int top;
    static int s[30];
    if (x < 0) {
        x = -x;
        putchar('-');
    }
    do s[++ top] = x % 10 + 48;
    while (x /= 10);
    while (top)
        putchar(s[top --]);
    putchar(p);
}
/*}}}*/
 
const int maxn = 2000 + 5;
 
int n;
int k;
std::vector<int> E[maxn];
std::vector<pii> e;

int dfs(int u, int fa, int dep)
{
    if (dep == 0) return 1;
    int ret = 1;
    for (int i = 0; i < E[u].size(); ++ i) if (E[u][i] != fa) ret += dfs(E[u][i], u, dep - 1);
    return ret;
}

void exec()
{
    read(n);
    read(k);
    for (int i = 1; i < n; ++ i) {
        int u, v;
        read(u), read(v);
        E[u].push_back(v);
        E[v].push_back(u);
        e.push_back(pii(u, v));
    }
    int ans = 0x3f3f3f3f;
    if (k & 1)
        for (int i = 0; i < e.size(); ++ i)
            chkmin(ans, n - dfs(e[i].first, e[i].second, k / 2) - dfs(e[i].second, e[i].first, k / 2));
    else
        for (int i = 1; i <= n; ++ i)
            chkmin(ans, n - dfs(i, 0, k / 2));
    write(ans);
}

/*{{{*/
int main() 
{
    if (fopen(iput.c_str(), "r") != NULL) {
        freopen(iput.c_str(), "r", stdin);
        freopen(oput.c_str(), "w", stdout);
    }

    exec();

    fclose(stdin);
    fclose(stdout);

    return 0;
}
/*}}}*/




Measured memory_bytes: 384
#include<bits/stdc++.h>
#define MOD (long long)(1e9+7)
using namespace std;
int h,w,d,q,x[100005],y[100005];
int main()
{
	cin >> h >> w >> d;
	long long sum[d][h*w/d+10]={0};
	for(int i=0,k; i<h; i++) for(int j=0; j<w; j++) cin >> k,x[k]=i,y[k]=j;
	for(int i=0; i<d; i++) 
		for(int j=1; i+d*j<=h*w; j++) sum[i][j]=sum[i][j-1]+abs(x[i+d*j]-x[i+d*j-d])+abs(y[i+d*j]-y[i+d*j-d]);
	cin >> q;
	for(int i=0,l,r; i<q; i++)
	{
		cin >> l >> r;
		cout << sum[l%d][r/d]-sum[l%d][l/d] << '\n';
	}
	return 0;
}


Measured memory_bytes: 11840
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
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 int64_t INF = 1LL << 60;

int main() {
 int a,b,t;
 cin>>a>>b>>t;
 cout<<t/a*b<<endl;
return 0;
} 

Measured memory_bytes: 256
n ,k = input().split()
ki = int(k) - 1
str_array = input()

for i,v in enumerate(str_array):
    if ( i == ki):
        if (v == "A"):
            print("a",end="")
        elif ( v == "B"):
            print("b",end="")
        else :
            print("c",end="")
    else :
        print(v,end="")
print()


Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <numeric>
#include <iomanip>
#include <vector>
#include <cmath>
#include <cstdint>
#include <string>
#include <climits>
#include <queue>

using namespace std;

struct Node;

struct Edge {
  int node;
  int cost;
};

struct Node {
  bool done = false;
  int cost = -1;
  std::vector<Edge> edges;
};

struct ProcessTarget {
  int node;
  int cost;
};

bool compareTargets(const ProcessTarget& a, const ProcessTarget& b) {
  return a.cost > b.cost;
}

int main() {
  int nv, ne, r;
  cin >> nv >> ne >> r;
  vector<Node> V(nv);
  for (int i = 0; i < ne; ++i) {
    int begin, end, cost;
    cin >> begin >> end >> cost;
    Edge edge;
    edge.cost = cost;
    edge.node = end;
    V[begin].edges.push_back(edge);
  }
  priority_queue<ProcessTarget, vector<ProcessTarget>, decltype(&compareTargets)> queue(compareTargets);
  ProcessTarget first;
  first.node = r;
  first.cost = 0;
  queue.push(first);
  V[r].cost = 0;

  while (!queue.empty()) {
    int processing = queue.top().node;
    queue.pop();

    for (auto& edge : V[processing].edges) {
      int newCost = V[processing].cost + edge.cost;
      if (V[edge.node].cost < 0 || newCost < V[edge.node].cost) {
        V[edge.node].cost = newCost;
        ProcessTarget next;
        next.node = edge.node;
        next.cost = newCost;
        queue.push(next);
      }
    }
  }

  for (auto& v : V) {
    if (v.cost == -1) {
      cout << "INF" << endl;
    } else {
      cout << v.cost << endl;
    }
  }
}



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

#define rp(i, k, n) for (int i = k; i < n; i++)
typedef long long ll;
typedef double ld;

template<class T>inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>inline bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll INF = 1ll << 60;
const ll MOD = 1e9 + 7ll;
const double PI=3.14159265358979323846;

const int MAX_N = 200010;
int n;
ll k;
vector<ll> A;
vector<ll> F;

int main() {
    cin >> n >> k;
    rp(i, 0, n) {
        ll a; scanf("%lld", &a);
        A.emplace_back(a);
    }
    rp(i, 0, n) {
        ll f; scanf("%lld", &f);
        F.emplace_back(f);
    }
    sort(F.begin(), F.end());
    sort(A.rbegin(), A.rend());
    ll ng = -1ll; ll ok = 1ll<<50;
    while(llabs(ok-ng) > 1) {
        ll x = (ng+ok)/2;
        ll m = 0;
        rp(i, 0, n) {
            ll req = x / F[i];
            if(A[i] > req) m += (A[i] - req);
        }
        if(m <= k) ok = x;
        else ng = x;
    }
    cout << ok << endl;
    return 0;
}

Measured memory_bytes: 7980
n = int(input())
a = list(map(int,input().split()))
l = [0]*n
l[0] = a[0]

for i in range(1,n):
    l[i] = l[i-1] + a[i]
sum = sum(a)
ans = 10**10+1
for i in range(len(l)-1):
    x = l[i]
    y = sum - l[i]
    tmp = abs(x-y)
    ans = min(ans,tmp)

print(ans)


Measured memory_bytes: 30668
#include<stdio.h>
int main(){
int player,i,j,k,sum,flag=0;
scanf("%d\n",&player);
int point[player][3];
int respoint[player][3];
for(j=0;j<player;j++){
scanf("%d %d %d\n",&point[j][0],&point[j][1],&point[j][2]);
}
for(j=0;j<player;j++){
for(i=0;i<3;i++){
for(k=0;k<player;k++){
if(point[j][i]==point[k][i] && j!=k)flag=1;
}
if (flag==0) respoint[j][i]=point[j][i];else respoint[j][i]=0;
flag=0;
}
}
for(i=0;i<player;i++){
sum = respoint[i][0]+respoint[i][1]+respoint[i][2];
printf("%d\n",sum);
}
return 0;
}

Measured memory_bytes: 604
using System;    
public class Program {
        static void Main(string[] args) {
            var line = Console.ReadLine().Split(' ');
            var s = Console.ReadLine();

            var a = int.Parse(line[1]);
            var b = int.Parse(line[2]);
            var c = int.Parse(line[3]);
            var d = int.Parse(line[4]);

            if (IsOk(s, a-1, b-1, c-1, d-1)) {
                Console.WriteLine("Yes");
            } else {
                Console.WriteLine("No");
            }

        }

        private static bool IsOk(string root, int a, int b, int c, int d) {
            while (a != c || b != d) {
                if (a + 1 <= c && root[a + 1] == '.' && a+1 != b) {
                    return IsOk(root, a + 1, b, c, d);
                } else if (a + 2 <= c && a + 2 != b && root[a + 2] == '.' ) {
                    return IsOk(root, a + 2, b, c, d);
                } else if (b + 1 <= d && b + 1 != a && root[b + 1] == '.' ) {
                    return IsOk(root, a, b + 1, c, d);
                } else if (b + 2 <= d && b + 2 != a && root[b + 2] == '.' ) {
                    return IsOk(root, a, b + 2, c, d);
                }
                return false;
            }
            return true;
        }
    }

Measured memory_bytes: 18912
function Main(input) {
    input = input.split("\n");
    for (i=0; i < input.length-1; i++) {
        tmp = input[i].split(" ")
        var a = parseInt(tmp[0])
        var b = parseInt(tmp[1])
        var c = parseInt(tmp[2])
        var yakusuu = []
        var num = []
        for (j=0; j<= c; j++) {
            if (c % j === 0) {
                yakusuu.push(j)
            }
        }
        for (k=a; k <= b; k++) {
            num.push(k)
        }
        var yakunum = [...yakusuu, ...num]
        const duplicatedArr = yakunum.filter(
            item => yakusuu.includes(item) && num.includes(item)
        )
        var result = new Set(duplicatedArr)
        var arr = Array.from(result)
        console.log(arr.length)
    }
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));


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

int main(void) {
  int d;
  cin >> d;
  if (d == 25) {
    cout << "Christmas" << endl;
  }else if (d == 24) {
    cout << "Christmas Eve" << endl;
  } else if (d == 23){
    cout << "Christmas Eve Eve" << endl;
  } else {
    cout << "Christmas Eve Eve Eve" << endl;
  }

  return 0;
}

Measured memory_bytes: 256
import numpy as np
import sys

n, m = map(int, input().split())
x = np.array(sorted(list(map(int, input().split()))))

if n >= m:
    print(0)
    sys.exit()

x_diff = np.diff(x)
x_diff_sort = sorted(x_diff)[::-1]

ans = sum(x_diff_sort[n - 1 :])
# print(x)
# print(np.diff(x), x_diff_sort, ans)
print(ans)


Measured memory_bytes: 23048
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);//cout.tie(NULL);
#define mod 1000000007

int F[1000000];

int cost(int n, int k, int* h)
{
    if(n==2)
        F[n] = abs(h[2] - h[1]);
    else
    {
        if(F[n]==-1)
        {
            F[n] = INT_MAX;
            for(int i = 1; (i <= min(k,n)) && (n-i >= 1); i++)
                F[n] = min(F[n], cost(n-i,k,h) + abs(h[n] - h[n-i]));
        }
    }
    return F[n];
}

int main()
{
    //io
    memset(F, -1, sizeof(F));
    int n,k;
    cin>>n>>k;
    int h[n+1];
    for(int i=1;i<=n;i++) cin>>h[i];
    h[0]  = F[1] = 0;
    cout<<cost(n,k,h);
    return 0;
}



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

int main(){
    string s;
    cin >> s;
    int ans = 1213313;
    for(int i = 0; i <= s.size()-3;i++) {
        int a = s[i]-'0';
        int b = s[i+1]-'0';
        int c = s[i + 2] - '0';
        int t = a*100+b*10+c;
        ans=min(ans, abs(753-t));
    }

    cout<<ans<<endl;
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,tune=native")

#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <functional>
#include <iomanip>
#include <numeric>
#include <cassert>
#include <bitset>

using namespace std;
using ll = long long;

const int N = 2e5 + 5;

vector<int> g[N];
int col[N];
int sz[3];

void dfs(int v) {
    sz[col[v]]++;
    for (int u : g[v]) {
        if (!col[u]) {
            col[u] = 3 - col[v];
            dfs(u);
        }
    }
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    for (int i = 1; i < n; i++) {
        int a, b;
        cin >> a >> b;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    col[1] = 1;
    dfs(1);
    if (sz[1] > sz[2]) {
        swap(sz[1], sz[2]);
        for (int i = 1; i <= n; i++) {
            col[i] = 3 - col[i];
        }
    }
    vector<int> ans(n + 1);
    if (sz[1] <= n / 3) {
        int kek = 3;
        int cur = 1;
        for (int i = 1; i <= n; i++) {
            if (col[i] == 1) {
                ans[i] = kek;
                kek += 3;
            } else {
                if (cur <= n) {
                    ans[i] = cur;
                    cur += (cur % 3 == 2 ? 2 : 1);
                } else {
                    ans[i] = kek;
                    kek += 3;
                }
            }
        }
    } else {
        vector<int> cur = { 3, 1, 2 };
        for (int i = 1; i <= n; i++) {
            if (cur[col[i]] <= n) {
                ans[i] = cur[col[i]];
                cur[col[i]] += 3;
            } else {
                ans[i] = cur[0];
                cur[0] += 3;
            }
        }
    }
    for (int i = 1; i <= n; i++) {
        cout << ans[i] << " \n"[i == n];
    }
    return 0;
}

Measured memory_bytes: 15872
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<LL,LL> P;
const LL mod=1000000007;
const LL LINF=1LL<<60;
const int INF=1<<30;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};



int main(){
    int n,m;cin >> n >> m;
    vector<int> x(n),v(m,0),vv(m,0);
    map<int,int> ma;
    for(int i=0;i<n;i++){
        cin >> x[i];
        ma[x[i]]++;
        v[x[i]%m]++;
    }
    for(auto p:ma){
        vv[p.fs%m] += p.sc / 2;
    }
    LL ans = 0;
    for(int i=0;i<=m/2;i++){
        if((m%2==0&&i==m/2)||i==0){
            ans += v[i] / 2;
        }
        else{
            if(v[i]<v[m-i]){
                ans += v[i];
                ans += min(vv[m-i],(v[m-i] - v[i]) / 2);
            }
            else{
                ans += v[m-i];
                ans += min(vv[i],(v[i] - v[m-i]) / 2);
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 6144
m='+=+j[0]*Math.',n='(s*Math.PI/180)',x=y=s=0;require("fs").readFileSync("/dev/stdin","utf8").split('\n').map(function(i){j=i.split(','),eval('x'+m+'sin'+n+',y'+m+'cos'+n),s+=+j[1]});console.log(~~x+'\n'+~~y)

Measured memory_bytes: 7640
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using static System.Console;
using static System.Math;

namespace CP
{
    class Atria
    {
        static void Main(string[] args)
        {
            string s = ReadLine();
            string t = ReadLine();
            int ans = 0;
            for (int i = 0; i < s.Length - t.Length+1; i++)
            {
                int tmp = 0;
                for (int j = 0; j < t.Length; j++)
                {
                    if (s[i + j] == t[j]) tmp++;
                }
                ans = Max(tmp, ans);
            }
            WriteLine(t.Length-ans);
        }
        
    }
}


Measured memory_bytes: 25860
#include<iostream>
#include<string>
#define rep(i,n) for(ll i = 0; i < (n); i++)
using ll = long long;
using namespace std;

int main()
{
    string s;
    ll sum = 0;
    cin >> s;
    for(ll i = 0;s[i] != '\0'; i++){
        if(s[i] == '0') sum += 0;
        else if(s[i] == '1') sum += 1;
        else if(s[i] == '2') sum += 2;
        else if(s[i] == '3') sum += 3;
        else if(s[i] == '4') sum += 4;
        else if(s[i] == '5') sum += 5;
        else if(s[i] == '6') sum += 6;
        else if(s[i] == '7') sum += 7;
        else if(s[i] == '8') sum += 8;
        else sum += 9;
    }
    if(sum % 9 == 0) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

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

int main() {
    string s,t; cin >> s >> t;
    vector<string> ans;
    int l = s.size()-t.size()+1;
    for(int i = 0; i < max(0, l); i ++) {
        string tmp = s;
        for(int j = 0; j < t.size(); j ++) {
            if(i+j>s.size()-1) break;
            if(tmp[i+j]=='?' || tmp[i+j]==t[j]) tmp[i+j] = t[j];
            else break;
            if(j==t.size()-1) {
                for(int k = 0; k < tmp.size(); k ++) {
                    if(tmp[k]=='?') tmp[k] = 'a';
                }
                ans.push_back(tmp);
            }
        }
    }
    sort(ans.begin(), ans.end());
    cout << (ans.size() > 0 ? ans[0] : "UNRESTORABLE") << endl;
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;

namespace ConsoleApp4
{
	class Program
	{
		static void Main(string[] args)
		{
			var nk = Console.ReadLine().Split();
			int n = int.Parse(nk[0]);
			int k = int.Parse(nk[1]);
			var rsp = Console.ReadLine().Split();
			int r = int.Parse(rsp[0]);
			int s = int.Parse(rsp[1]);
			int p = int.Parse(rsp[2]);
			var t = Console.ReadLine().ToCharArray();

			var previousList = new char[k];
			long point = 0;

			// k回1セット
			for (int i = 0; ; i++)
			{
				for (int j = 0; j < k; j++)
				{
					char next = ' ';
					if ((i + 1) * k + j < n)
					{
						next = t[(i + 1) * k + j];
					}
					bool win = false;
					char select;
					Select(previousList[j], t[i * k + j], next, out select, ref win);
					previousList[j] = select;
					if (win)
					{
						switch(select)
						{
							case 'r':
								point += r;
								break;
							case 's':
								point += s;
								break;
							case 'p':
								point += p;
								break;
							default:
								break;
						}
					}
					if (i * k + j + 1 >= n)
					{
						Console.WriteLine(point);
						return;
					}
				}
			}
		}

		static char ToWin(char opp)
		{
			switch (opp)
			{
				case 'r':
					return 'p';
				case 's':
					return 'r';
				case 'p':
				default:
					return 's';
			}
		}

		static void Select(char previous, char current, char next, out char select, ref bool win)
		{
			char c = ToWin(current);
			if (previous != c)
			{
				select = c;
				win = true;
			}
			else
			{
				select = Leave(previous, ToWin(next));
				win = false;
			}
		}

		static char Leave(char a, char b)
		{
			var ls = new List<char>(){'r', 's', 'p' };
			ls.Remove(a);
			ls.Remove(b);
			return ls[0];
		}
	}
}


Measured memory_bytes: 15136
n, m = map(int, input().split())
point = sorted(list(map(int, input().split())))
cost = []
for i in range(m-1):
    cost.append(point[i+1] - point[i])
if m <= n:
    print(0)
else:
    cost.sort()
    for _ in range(n-1):
        cost.pop()
    print(sum(cost))

Measured memory_bytes: 13960
s = gets.chomp.split('')
h = Hash.new([])
0.upto(s.size - 1) do |i|
  h[s[i]] += [i]
end
def diffmax(ary, size)
  nary = [-1] + ary + [size]
  max = 0
  1.upto(nary.size-1) do |i|
    diff = nary[i] - nary[i-1] - 1
    max = diff if max < diff
  end
  max
end
min = 10**12
h.each do |k, v|
  diff = diffmax(v, s.size)
  min = diff if min > diff
end
puts min


Measured memory_bytes: 1788
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		String s=sc.nextLine();
		if(s.equals("Sunny")){
			System.out.println("Cloudy");
		}else if(s.equals("Cloudy")){
			System.out.println("Rainy");
		}else{
			System.out.println("Sunny");
		}
		
	}}

Measured memory_bytes: 22484
//============================================================================
// Name        : JOI.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <math.h>
#include <stdio.h>
#include <vector>
using namespace std;
typedef long long ll;
int N;
int main() {
	cin>>N;

    ll A=N;
    ll B=0;
    while(A!=0){
    	B+=A%10;
    	if(A<10)break;
    	A=A/10;
    }

    if(N%B==0)cout<<"Yes"<<endl;
    if(N%B!=0)cout<<"No"<<endl;



	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
typedef tuple<ll, ll, ll> tll;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    vector<ll> reds(2 * N, -1);
    vector<ll> blues(2 * N, -1);
    for (int i = 0; i < N; i++)
    {
        ll a, b;
        cin >> a >> b;
        reds.at(a) = b;
    }
    for (int i = 0; i < N; i++)
    {
        ll c, d;
        cin >> c >> d;
        blues.at(c) = d;
    }
    ll answer = 0;
    set<ll> prevReds;
    for(int i = 0; i < 2 * N; i++)
    {
        if(blues.at(i) != -1)
        {
            if(!prevReds.empty())
            {
                auto ite = prevReds.lower_bound(blues.at(i));
                if(ite != prevReds.begin())
                {
                    ite--;
                }
                if(*ite < blues.at(i))
                {
                    answer++;
                    prevReds.erase(*ite);
                }
            }
        }else if(reds.at(i) != -1)
        {
            prevReds.insert(reds.at(i));
        }
    }
    cout << answer << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define int long long
#define pii pair<int, int>
#define mp make_pair
using namespace std;
using namespace __gnu_pbds;
using ordered_set = tree< pii , null_type, less< pii >, rb_tree_tag, tree_order_statistics_node_update>;
const int N=2e5+5;
ordered_set S;
int n, k, arr[N], pref[N],ans=0;
signed main()
{
	cin >> n >> k;
	for(int i = 1; i <= n; i++)
	{
		cin >> arr[i];
		arr[i]-=k;
		pref[i]=pref[i-1]+arr[i];
	}		
	S.insert(mp(0, 0));
	for(int i = 1; i <= n; i++)
	{
		ans+=S.order_of_key(mp(pref[i], i));
		S.insert(mp(pref[i], i));
		//cout << i << " " << ans << endl;
	}
	cout << ans;
}

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

int main() {
  int N;
  int count = 0;
  string S;
  cin >> N >> S;
  vector<int> v(N);
  int ans = 0;

  for (int i = 0; i < N; i++) {
    count += S[i] == 'I' ? 1 : -1;
    v[i] = count;
  }

  for (int i = 0; i < N; i++) {
    ans = max(ans, v[i]);
  }

  cout << ans << endl;
}

Measured memory_bytes: 3604
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
#include <array>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <utility>
#include <functional>

using namespace std;
using lli = long long int;

int main() {

    string S;
    cin >> S;

    if((count(S.cbegin(), S.cend(), S[0]) == 2) && (count(S.cbegin(), S.cend(), S[1]) == 2) && (count(S.cbegin(), S.cend(), S[2]) == 2) && (count(S.cbegin(), S.cend(), S[3]) == 2)) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <algorithm>

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[i][j];
		}
	}

	int n;

	cin >> n;

	int* b = new int[n];

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

	bool flag = false;
	int count = 0;
	for (int i = 0; i < 3; i++) {
		for (int k = 0; k < n; k++) {
			if (a[i][i] == b[k]) {
				count++;
			}
		}
	}
	if (count == 3) {
		flag = true;
	}


	count = 0;

	for (int i = 0; i < 3 && !flag; i++) {
		for (int k = 0; k < n; k++) {
			if (a[i][2 - i] == b[k]) {
				count++;
			}
		}
	}
	if (count == 3) {
		flag = true;
	}


	for (int i = 0; i < 3 && !flag; i++) {
		count = 0;
		for (int j = 0; j < 3; j++) {
			for (int k = 0; k < n; k++) {
				if (a[i][j] == b[k]) {
					count++;
				}
			}
		}
		if (count == 3) {
			flag = true;
		}
	}


	for (int i = 0; i < 3 && !flag; i++) {
		count = 0;
		for (int j = 0; j < 3; j++) {
			for (int k = 0; k < n; k++) {
				if (a[j][i] == b[k]) {
					count++;
				}
			}
		}
		if (count == 3) {
			flag = true;
		}
	}

	cout << (flag ? "Yes" : "No");


	return 0;
}

Measured memory_bytes: 256
N = int(input())
S = []
X = []
for i in range(N):
  s = int(input())
  S.append(s)
for i in S:
  if i%10 == 0:
    pass
  else:
    X.append(i)
num = sum(S)
Y = sorted(X)
if num%10 == 0:
  if len(Y)!=0:
    ans = num - Y[0]
  else:
    ans = 0
else:
  ans = num
print(ans)
  


Measured memory_bytes: 3060