akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())

using namespace std;
using ll = long long;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const int INF = 1001001001;
const long long INFL = (1LL<<60);
const double eps = (1e-9);

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

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

  map<ll, ll> mp;
  for (int i = 0; i < n; i++) {
    mp[i+1 - a[i]]++;
  }

  ll ans = 0;
  for (int i = 0; i < n-1; i++) {
    mp[i+1 -a[i]]--;   // 自分の分を引く
    ans += mp[i+1 + a[i]];
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 27472
#include <bits/stdc++.h>
using namespace std;
#define ll          long long
#define vl          vector<ll>
#define vi          vector<int>
#define pi          pair<int,int>
#define pl          pair<ll,ll>
#define all(a)      a.begin(),a.end()
#define mem(a,x)    memset(a,x,sizeof(a))
#define pb          push_back
#define mp          make_pair
#define F           first
#define S           second
#define trace(x)     cerr<<#x<<":"<<x<<endl;
#define trace2(x,y) cerr<<#x<<":"<<x<<"|"<<#y<<":"<<y<<endl;
#define trace3(x,y,z) cerr<<#x<<":"<<x<<"|"<<#y<<":"<<y<<"|"<<#z<<":"<<z<<endl;
#define fast_io     std::ios::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
ll dp[407][407];
ll pre [407];
ll solve(int l, int r, vl &a) {
	if (dp[l][r] != -1)return dp[l][r];
	if (l == r) {
		return 0;
	}
	if(r==l+1)return a[l]+a[r];
	ll sum = pre[r + 1] - pre[l];
	ll ans = 1e18 + 7;
	for (int i = l; i < r; i++) {
		ans = min(ans, solve(l,i,a)+solve(i+1,r,a));
	}
	dp[l][r] = ans+sum;
	return dp[l][r];
}
int main() {
	fast_io;
	int n;
	cin >> n;
	vl a(n);
	for (int i = 0; i < n; i++)cin >> a[i];
	mem(dp, -1);
	pre[0] = 0;
	for (int i = 1; i <= n; i++) {
		pre[i] = pre[i - 1] + a[i-1];
	}
	// for(int i=0;i<=n;i++)trace2(i,pre[i])
	cout<<solve(0, n-1 , a);
	// cout << dp[0][n - 1];

	// cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
	return 0;
}

Measured memory_bytes: 1664
using System;
using System.Linq;

namespace abc134_d
{
    static class Program
    {
        static void Main(string[] args)
        {
            var n = Console.ReadLine().ToInteger();
            var a = Console.ReadLine().ToIntArray();

            // 偶数か奇数かなので、ボールを1つ入れるか入れないかだけを考えればいい。

            var boxes = new int[n];
            for (int i = 0; i < a.Length; i++)
            {
                // 逆さから考える。
                var number = a.Length - i;
                var index = number - 1;
                if (number > n / 2)
                {
                    // 後ろ半分は、倍数は他に存在しないので、確定。
                    boxes[index] = a[index];
                }
                else
                {
                    // 倍数がいくつあるか
                    var div = n / number - 1;
                    // 倍数の総和
                    var sum = 0;
                    for (int j = 0; j < div; j++)
                    {
                        sum += boxes[number * (j + 2) - 1];
                    }
                    if (sum % 2 != a[index])
                    {
                        // 総和が条件に一致しないときだけ1を足す
                        boxes[index] = 1;
                    }
                }
            }
            Console.WriteLine($"{boxes.Where(m => m > 0).Count()}");
            Console.WriteLine($"{string.Join(" ", boxes.Select((m, i) => m > 0 ? (i + 1).ToString() : ""))}");
        }

        static int ToInteger(this string s)
        {
            return int.Parse(s);
        }

        static int[] ToIntArray(this string s, char separator = ' ')
        {
            return s.Split(separator).Select(m => m.ToInteger()).ToArray();
        }
    }
}


Measured memory_bytes: 32988
#include<stdio.h>
#include<iostream>
#include<iomanip>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<algorithm>
#include<string>
#include<math.h>
using namespace std;

const int MAX = 100000;
const long long MOD = 1000000007;

int main(){
    int N;
    string S;
    int table[26] = {0};

    cin >> N >> S;

    for(int i = 0;i < N;i++){
        table[S[i] - 'a']++;
    }

    long long ans = 1;

    for(int i = 0;i < 26;i++){
        ans = ans * (table[i] + 1) % MOD;
    }

    cout << ans - 1 << endl;

    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <cmath>
#include <cstdio>

using namespace std;

int main() {
    double a,b,c,d;
    cin >> a >> b >> c >> d;
    printf("%.8f\n",sqrt(pow(c-a,2)+pow(d-b,2)));
    
    return 0;
}

Measured memory_bytes: 1240
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;

ll ceil(ll a, ll b) {  // a÷b以上の最小の整数

    if(b == 0) {
        return 0;  // 0除算エラーを防ぐ
    }

    if(a%b == 0) {
        return a/b;
    }
    else {
        return a/b + 1LL;
    }
}

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

    vector<ll> a(k+1);
    for(int i = 1; i <= k; i++) {
        cin >> a[i];
    }
    
    vector<ll> L(k+1), R(k+1);
    L[k] = R[k] = 2LL;
    
    for(int i = k; i >= 1; i--) {
        ll y = (R[i]/a[i])*a[i];
        if(y < L[i]) {
            cout << -1 << endl;
            return 0;
        }
        L[i-1] = ceil(L[i], a[i])*a[i];
        R[i-1] = y + a[i] - 1;
    }

    cout << L[0] << " " << R[0] << endl;
    return 0;
}

Measured memory_bytes: 2688
import collections
n=int(input())
list=list(map(int,input().split()))
#print(list)
list_1=list[::2]
list_2=list[1::2]
#print(list_1)
#print(list_2)
a=collections.Counter(list_1)
b=collections.Counter(list_2)
#print(a.most_common()[0]==b.most_common()[0])
#print(len(list_1),a.most_common()[0][1])
if((a.most_common()[0]==b.most_common()[0]) & (a.most_common()[0][1]!=len(list_1))):#2つの数列の最大をとる数が等しい場合どちらかは最大個数の数に、もう１つはその次に多い数に置き換える。
  #print('test2')
  if(n-a.most_common()[0][1]-b.most_common()[1][1]>n-a.most_common()[1][1]-b.most_common()[0][1]):
  	print(n-a.most_common()[1][1]-b.most_common()[0][1])
  else:
    print(n-a.most_common()[0][1]-b.most_common()[1][1])
elif ((a.most_common()==b.most_common()) & (a.most_common()[0][1]==len(list_1))):#２つの数列の全要素が一致する場合どちらかの数字を変更
  #print('test1')
  print(n//2)
else:
  #print(a)
  #print(b)
  #print(a.most_common())
  #print(b.most_common())
  #print(a.most_common()[0][1])
  #print(b.most_common()[0][1])

  print(n-a.most_common()[0][1]-b.most_common()[0][1])

Measured memory_bytes: 21952
#include <bits/stdc++.h>
#define FOR(I,X,Y) for(int (I)=(X);(I)<(Y);(I)++)
#define REP(I,X,Y) for(int (I)=(Y)-1;(I)>=(X);(I)--)
#define ALL(X) (X).begin(),(X).end()
#define INF 1000000007
#define LINF 1000000000000000007
typedef long long ll;
using namespace std;

void tanzaku(string S){
  int N = S.size();
  FOR(i,0,(int)1<<8)N = N;
  FOR(i,0,N+2){
    FOR(j,0,3){
      if(i == 0 && j == 0)cerr << "┏";
      else if(i == N+1 && j == 2)cerr << "┛";
      else if(i == 0 && j == 2)cerr << "┓";
      else if(i == N+1 && j == 0)cerr << "┗";
      else if(i == 0 || i == N+1)cerr << "━";
      else if(j == 0 || j == 2)cerr << "┃";
      else cout << S[i-1];
    }
    cerr << endl;
  }
  return;
}

int main(){
  int N,i;
  cin >> N >> i;
  tanzaku(to_string(N - i + 1));
}


Measured memory_bytes: 256
S = list(input())

for i in range(-1, -len(S), -1):
    S1 = S[:i]
    #print(S1)
    if len(S1) % 2 != 0:
        continue
    l = len(S1)//2
    if S1[:l] == S1[l:]:
      #print(l)
      print(len(S1))
      break

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define chmin(x,y) x = min(x,y)
using namespace std;
typedef long long ll;
const int INF = 1001001001;

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    if(a+b == c || a+c == b || b+c==a){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <set>
#include <algorithm>

using namespace std;

int main()
{
	int N;
	cin >> N;
	set<int> s;
	for (int i = 0; i < N; ++i) {
		int d;
		cin >> d;
		s.insert(d);
	}
	cout << s.size() << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep1(i, n) for (int i =1; i <= (int)(n);++i)
int par[60];
void init(int n){
   rep1(i,n)
     par[i]=i;  
}
int find(int x){
   if(par[x]==x)
     return x;
   else
     return par[x]=find(par[x]); 
}
void unite(int x,int y){
   x=find(x);
   y=find(y);
   if(x==y)
     return;
   par[x]=y; 
}
bool same(int x,int y){
   return find(x)==find(y);
}
int main(){
  int n,m,c=0;
  cin>>n>>m;
  int p[m][2];
  rep(i,m)
     cin>>p[i][0]>>p[i][1];
  rep(i,m){
    init(n);
    rep(j,m)
      if(i!=j)
        unite(p[j][0],p[j][1]);
    rep1(j,n)
      if(!same(1,j)){
         c++;
         break; 
      }
  }
  cout<<c;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <climits>

using namespace std;
typedef long long int ll;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
ll MOD = 1000000007;
#define INF (1e9)

ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
typedef pair <ll,ll> P;

int main()
{
    ll x;
    cin >> x;
    if (x < 1200) cout << "ABC" << endl;
    else cout << "ARC" << endl;
    return 0;
}


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

int main(){
  int n,maxn=0;
  cin>>n;
  char s[n+1];
  cin>>s;
  
  for(int i=0,t=0;i<n;maxn=max(maxn,t),i++)
    t+=((s[i]=='I')? 1:-1);
  cout<<maxn<<'\n';
}

Measured memory_bytes: 256
# your code goes here


def main(array):
	
	mini = min(array)
	newarray = [mini]
	if mini ==1:
		return 1
	else:
		for a in array:
			if a%mini > 0:
				newarray.append(a%mini)
		if len(newarray) == 1:
			return mini
		else:
			return main(newarray)


n = input()
array = input().split(' ')
array = [int(c) for c in array]

print(main(array))

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

int main(){
	int x,y;
	cin >> x >> y;
	while(!(x==0&&y==0)){
		if(x<y) cout << x << " " << y << endl;
		else cout << y << " " << x << endl;
		cin >> x >> y;
	}
	return 0;
}


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

const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int main(){
    int h, w;
    cin >> h >> w;
    vector<vi> c(10, vi(10));
    rep(i, 10) rep(j, 10) cin >> c[i][j];
    vector<vi> a(h, vi(w));
    rep(i, h) rep(j, w) cin >> a[i][j];
    vector<vi> dp(10, vi(10, INF));
    rep(i, 10) rep(j, 10) dp[i][j] = c[i][j];
    rep(k, 10) rep(i, 10) rep(j, 10) dp[i][j] = min(dp[i][j], dp[i][k]+dp[k][j]);
    int ans = 0;
    rep(i, h) rep(j, w) {
        if (a[i][j] == -1) continue;
        ans += dp[a[i][j]][1];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3768
# -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0108
AC
"""
import sys
from sys import stdin
input = stdin.readline


def main(args):
    while True:
        # S = [4, 5, 1, 1, 4, 5, 12, 3, 5, 4]
        n = int(input())
        if n == 0:
            break
        S = [int(x) for x in input().split(' ')]

        A = []                  #  After[]
        B = S[:]                #  Before[]
        count = 0
        while True:
            # for s in B:
            #    A.append(B.count(s))
            A = [B.count(b) for b in B]
            if A == B:
                break
            B = A[:]
            A = []
            count += 1

        print(count)
        print(*A)


if __name__ == '__main__':
    main(sys.argv[1:])

Measured memory_bytes: 8068
#include <iostream>
#include <cstdio>
#include <vector>
using namespace std;

vector<vector<long long> > G(200000);
vector<long long> counter(200000 ,0);
void dfs(long long i , long long p){
    if(G[i].size() == 1 and i != 0){
        //printf("G[%lld]\n", i);
        return;
    }
    for(long long v = 0; v < G[i].size(); v++){
        if(p == G[i][v]){
            continue;
        }
        counter[G[i][v]] += counter[i];
        dfs(G[i][v], i);
    }
    //return;
}
int main(){
    long long n ,q;
    cin >> n >> q;

    vector<vector<long long> > children(n);
    
    for(long long i = 0; i < n-1; i++){
        long long a, b;
        cin >> a >> b;
        a -= 1;
        b -= 1;
        
        children[a].push_back(b);
        G[a].push_back(b);
        G[b].push_back(a);
    }

    
    for(long long i = 0; i < q; i++){
        long long p, x;
        cin >> p >> x;
        p -= 1;
        counter[p] += x;

    }

    /*for(long long i = 0; i < n; i++){
        for(long long j = 0; j < children[i].size(); j++){
            counter[children[i][j]] += counter[i];
        }
    }*/

    dfs(0, -1);

    for(long long i = 0; i < n; i++){
        printf("%lld ", counter[i]);
    }
    printf("\n");

    return 0;
}

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

int main() {
    using namespace std;
    unsigned long N;
    cin >> N;
    vector<unsigned long> d(N - 1);
    for(unsigned long i = 0, p = N, a; i < N; ++i){
        cin >> a;
        if(a == p + 1)d[p - 1] = 1;
        swap(a, p);
    }
    unsigned long ans{0};
    for(unsigned long i = 0, b; i < N; ++i){
        cin >> b;
        ans += b;
    }
    for(unsigned long i = 0, c; i + 1 < N; ++i){
        cin >> c;
        ans += c * d[i];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a =sc.nextInt(), b= sc.nextInt(), c= sc.nextInt();
		if(b-a == c-b) {
			System.out.println("YES");
		}else {
			System.out.println("NO");
		}
	}
}



Measured memory_bytes: 21844
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#pragma warning(disable : 4996)
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<time.h>
#include<random>
#include<array>


using namespace std;

#define REP(i, n) for(int i = 0;i < n;++i)
#define REPR(i, n) for(int i = n-1;i >= 0;--i)
#define FOR(i, m, n) for(int i = m;i < n;++i)
#define FORR(i, m, n) for(int i = m-1;i >= n;--i)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end())
#define ll long long
#define print(x) cout<<(x)<<'\n'
#define pe(x) cout<<(x)<<" "
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define lb(v,n) lower_bound(v.begin(), v.end(), (n))
#define ub(v,n) upper_bound(v.begin(), v.end(), (n))
#define int long long
//#define double long double
#define all(x) (x).begin(), (x).end()
#define print_space(v) REP(i,v.size())cout << v[i] << ((i == v.size() - 1) ? "\n" : " ")
template<typename T1, typename T2> inline void chmin(T1 & a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
typedef pair<int, int>P;
typedef array<int, 3> arr3;
std::random_device rd;
std::mt19937 mt(rd());
constexpr ll MOD = 998244353; constexpr int MAX = 2000020;
const double pi = acos(-1); constexpr double EPS = 1e-8;
constexpr ll INF = 1e18;

ll fac[2000020];
void init() {
	FOR(i, 1, 2000001) {
		int x = i;
		int res = 0;
		while (x % 2 == 0) {
			res++;
			x /= 2;
		}
		fac[i] = fac[i - 1] + res;
	}
}
int calc(vector<int>&v,int N) {
	init();
	bool found1 = false;
	REP(i, N)if (v[i] == 1)found1 = true;
	if (!found1) {
		REP(i, N)if (v[i] == 2)v[i] = 1;
	}
	int sum = 0;
	REP(i, N) {
		if (v[i] == 0||v[i]==2)continue;
		int cnt = fac[N - 1];
		cnt -= (fac[N - i - 1] + fac[i]);
		if (cnt == 0)sum += 1;
		sum %= 2;
	}
	if (sum) {
		if (found1)return 1;
		else return 2;
	}
	else return 0;
}

void solve() {
	int N; cin >> N;
	string S; cin >> S;
	vector<int>v;
	REP(i, N - 1) {
		v.push_back(abs(S[i] - S[i + 1]));
	}
	//print_space(v);
	print(calc(v, N - 1));
}

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	//int q; cin >> q;
	//while (q--)
	solve();
}



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

int main() {

  int n;
  cin >> n;
  
  cout << (n >= 30 ? "Yes" : "No") << endl;
  
  
}


Measured memory_bytes: 3592
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <string>
#include <cstring>
#include <map>
#include <math.h>
#include <queue>
#include <deque>
typedef long long ll;
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 int INF = 1<<30;
using namespace std;

ll dp[110][100010];
int v[110], w[110];

int main(){
	int n, W;
	memset(dp,-1,sizeof dp);
	for (int i = 0; i < 100010; i++) dp[0][i] = 0;
	cin >> n >> W;
	for (int i = 1; i <= n; i++) cin >> w[i] >> v[i];
	for (int i = 0; i < n; i++) {
		for (int j = 0; j <= W; j++) {
			if(j<w[i+1]) dp[i+1][j] = dp[i][j];
			else dp[i+1][j] = max(dp[i][j], dp[i][j-w[i+1]] + v[i+1]);
		}
	}
	cout << dp[n][W] << endl;
	return 0;
}


Measured memory_bytes: 86144
#include <cstdio>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <set>
#include <limits.h>

#define rep(i,N) for(int (i)=0;(i)<(N);(i)++)
#define MOD 1000000007

using ll = long long;

using namespace std;

ll pow_mod(ll a, ll b, ll p) {
	if (b == 0)return 1;
	else if (b % 2 == 0)return (pow_mod(a*a, b / 2, p) % p);
	else return (pow_mod(a, b - 1, p)*a%p);
}

ll sum_digit(ll N) {
	int ans = 0;
	for (; N != 0;) {
		ans += N % 10;
		N /= 10;
	}
	return ans;
}

ll gcd(ll a,ll b) {
	if (!b)return a;
	return gcd(b, a%b);
}

ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}

int N;

int A1[110], A2[110];

int ans = 0;

int main(){
	scanf("%d", &N);
	rep(i, N)scanf("%d", &A1[i]);
	rep(i, N)scanf("%d", &A2[i]);
	rep(i, N) {
		int temp = 0;
		rep(j, i + 1)temp += A1[j];
		for (int j = i; j < N; j++)temp += A2[j];
		ans = max(ans, temp);
	}
	printf("%d", ans);
	return 0;
}

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

using namespace std;

#define ll long long
#define uint unsigned int

int main() {
    int mm = 12;
    int ans = 36;

    while (mm < 24) {
        ++mm;
        --ans;
    }

    int m;
    cin >> m;

    while (mm > m) {
        --mm;
        ++ans;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
int main () {
  double X, Y, x, y;
  cin >> X >> Y >> x >> y;
  cout << fixed << setprecision(6);
  cout << X*Y/2 << " ";
  if (X/2==x && Y/2==y) cout << 1 << endl;
  else cout << 0 << endl;
}

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

using namespace std;

int a[110];
int main()
{
    int n, md = 0; cin >> n;
    for (int i = 0; i < n; i ++){
        int d; cin >> d; a[d] ++;
        md =  max(d, md);
    }
    int r = (md + 1) / 2;
    for (int i = 0; i < r; i ++){
        if (a[i] >= 1) return cout << "Impossible", 0;
    }
    if (md % 2 == 0) if (a[r] != 1) return cout << "Impossible", 0;
    if (md % 2 != 0) if (a[r] != 2) return cout << "Impossible", 0;
    for (int i = r + 1; i <= md; i ++){
        if (a[i] <= 1) return cout << "Impossible", 0;
    }
    cout << "Possible";
    return 0;
}


Measured memory_bytes: 256
n,m = map(int,input().split())
a = [input() for i in range(n)]
b = [input() for i in range(m)]


for j in range(0,n-m+1):
  for k in range(0,n-m+1):
    flag =True
    for row in range(m):
      for clm in range(m):
        if a[row+j][clm+k]!=b[row][clm]:
          flag = False
    if flag:
      print("Yes")
      exit()
print("No")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
#define VL vector<ll>
#define VS vector<string>
#define VB vector<bool>
#define VP vector<pair<ll,ll>>
#define VVL vector<vector<ll>>
#define VVP vector<vector<pair<ll,ll>>>
#define PL pair<ll,ll>
#define ALL(v) (v).begin(), (v).end()


int main()
{
    int A, B, K, C;
    cin >> A >> B >> K;
    vector<int> v;
 
    C = max(A, B);
 
    for (int i = 1; i <= C; i++)
    {
        if (A % i == 0 && B % i == 0)
        {
            v.push_back(i);
        }
    }
 
    sort(v.begin(), v.end(), greater<>());
 
    cout << v[K - 1];
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define E "\n"

using namespace std;
const long long MOD = (long long)998244353;

int n, x, d, to[200009];
pair<int, int> dat[200009];
bool vis[200009];
long long cnt[200009], pos[200009];

long long fun(int cur)
{
	if (cur >= n) return 1;
	if (!vis[cur]) {
		vis[cur] = true;
		int tmp = lower_bound(pos, pos + n, to[cur]) - pos;
		cnt[cur] += fun(tmp);
		cnt[cur] %= MOD;
		cnt[cur] += fun(cur + 1);
		cnt[cur] %= MOD;
	}
	return cnt[cur];
}

int seg[40000009], N;

void upd(int p, int v)
{
	p = p + N / 2;
	seg[p] = v;
	p /= 2;
	while (p) {
		seg[p] = max(seg[p], v);
		p /= 2;
	}
}

int query(int a, int b, int l, int r, int p)
{
	if (r <= a || b <= l) return -1e9;
	if (l == r) return -1e9;
	if (a <= l && r <= b) return seg[p];
	int ret = query(a, b, l, (l + r) / 2, 2 * p);
	ret = max(ret, query(a, b, (l + r) / 2, r, 2 * p + 1));
	return ret;
}

int main()
{
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> x >> d;
		dat[i] = { x, d };
	}
	sort(dat, dat + n);
	N = 1;
	while (N < n) {
		N = N << 1;
	}
	N = N << 1;
    for (int i = 0; i < N; i++) seg[i] = -1e9;
	for (int i = 0; i < n; i++) pos[i] = dat[i].fi;
	for (int i = 0; i < n; i++) {
		to[i] = dat[i].first + dat[i].second;
		upd(i, to[i]);
	}
	for (int i = n - 2; i >= 0; i--) {
		int tmp = lower_bound(pos + i, pos + n, dat[i].first + dat[i].second) - pos;
		to[i] = query(i, tmp, 0, N / 2, 1);
		upd(i, to[i]);
	}
	cout << fun(0) << E;
	//system("pause");
	return 0;
}


Measured memory_bytes: 16896
import sys
from collections import defaultdict, Counter, deque
from itertools import accumulate, permutations, combinations
from operator import itemgetter
from bisect import bisect_left, bisect_right, bisect
from heapq import heappop, heappush
from fractions import gcd
from math import ceil, floor, sqrt, cos, sin, pi
from copy import deepcopy

# If you use recursive call, uncomment this code
#sys.setrecursionlimit(10**6)

def main():
    n = int(input())
    aa = list(map(int,input().split()))
    bb = list(map(int,input().split()))
    cc = list(map(int,input().split()))
    ba = aa[0]-1
    ans = bb[ba]
    for a in aa[1::]:
        if ba+1 == a-1:
            ans += cc[ba]
        ba = a-1
        ans += bb[ba]
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 5716
s = input()
a_list = []
z_list = []
for i in range(0, len(s)):
        if s[i] == 'A':
                a_list.append(i)
        elif s[i] == 'Z':
                z_list.append(i)
print(max(z_list) - min(a_list) + 1)

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

const int N = 301;
double dp[N][N][N];

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

	int cnt[4] = {0};

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

	dp[0][0][0] = 0;

	for(int three = 0 ; three <= n ; three++){
		for(int two = 0 ; two <= n ; two++){
			for(int one = 0 ; one <= n ; one++){
				int zero = n - three - two - one;
				if (zero == n){
					continue;
				}
				if (one + two + three > n){
					continue;
				}
				double val = 1;
				if(three > 0)val += (1.0 * three/n) * dp[three-1][two+1][one];
				if(two > 0)val += (1.0 * two/n) * dp[three][two-1][one+1];
				if(one > 0)val += (1.0 * one/n) * dp[three][two][one-1];

				dp[three][two][one] = val / (1 - 1.0 * zero/n);
			}
		}
	}

	cout << setprecision(9) << fixed;
	cout << dp[cnt[3]][cnt[2]][cnt[1]];

	return 0;
}



Measured memory_bytes: 111176
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

class T
{
public:
	string n;
	int w,d;

	T(string n, int w, int d)
	:n(n),w(w),d(d)
	{}
	
	bool operator<(const T& t) const
	{
		if(w!=t.w) return w>t.w;
		return d<t.d;
	}

};

int main()
{
	int N;
	while(cin >> N, N)
	{
		vector<T> v;
		for(int j=0; j<N; j++)
		{
			string n;
			int w=0, d=0;
			cin >> n;
			for(int i=0; i<N-1; i++)
			{
				int t;
				cin >> t;
				if(t==0) w++;
				if(t==1) d++;
			}
			v.push_back(T(n,w,d));
		}
		
		sort(v.begin(), v.end());
		for(int i=0; i<v.size(); i++)
			cout << v[i].n << endl;
	}
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
int n,a,b,s;
int calc(int x){
	int r=0;
	while(x){
		r+=x%10;
		x/=10;	
	}
	return r;
}
int main(){
	cin>>n>>a>>b;
	for(int i=1;i<=n;i++){
		int k=calc(i);
		if(k>=a&&k<=b) s+=i;
	}
	cout<<s<<endl;
	return 0;
} 

Measured memory_bytes: 256
// 13A.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

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

#define N 8
#define FREE -1
#define NOT_FREE 1

int row[N], col[N], dpos[2 * N - 1], dneg[2 * N - 1];

bool X[N][N];

void intitialize() {
    for (int i = 0; i < N; i++) { row[i] = FREE, col[i] = FREE; }
    for (int i = 0; i < 2 * N - 1; i++) { dpos[i] = FREE; dneg[i] = FREE; }

}

void printBoard() {
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
            if (X[i][j]) {
                if (row[i] != j)return;
            }
        }
    }

    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
            cout << ((row[i] == j) ? "Q" : ".");
        }
        cout << endl;
    }
}

void recursive(int i) {
    if (i == N) {
        printBoard(); return;
    }


    for (int j = 0; j < N; j++) {
        if (NOT_FREE == col[j] ||
            NOT_FREE == dpos[i + j] ||
            NOT_FREE == dneg[i - j + N - 1])continue;
        row[i] = j; col[j] = dpos[i + j] = dneg[i - j + N - 1] = NOT_FREE;

        recursive(i + 1);
        row[i] = col[j] = dpos[i + j] = dneg[i - j + N - 1] = FREE;
    }
}

int main()
{
    intitialize();

    for (int i = 0; i < N; i++)
        for (int j = 0; j < N; j++)X[i][j] = false;

    int k; cin >> k;
    for (int i = 0; i < k; i++) {
        int r, c; cin >> r >> c;
        X[r][c] = true;
    }

    recursive(0);

    return 0;
}

// プログラムの実行: Ctrl + F5 または [デバッグ] > [デバッグなしで開始] メニュー
// プログラムのデバッグ: F5 または [デバッグ] > [デバッグの開始] メニュー

// 作業を開始するためのヒント: 
//    1. ソリューション エクスプローラー ウィンドウを使用してファイルを追加/管理します 
//   2. チーム エクスプローラー ウィンドウを使用してソース管理に接続します
//   3. 出力ウィンドウを使用して、ビルド出力とその他のメッセージを表示します
//   4. エラー一覧ウィンドウを使用してエラーを表示します
//   5. [プロジェクト] > [新しい項目の追加] と移動して新しいコード ファイルを作成するか、[プロジェクト] > [既存の項目の追加] と移動して既存のコード ファイルをプロジェクトに追加します
//   6. 後ほどこのプロジェクトを再び開く場合、[ファイル] > [開く] > [プロジェクト] と移動して .sln ファイルを選択します



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

using namespace std;

#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define SZ(v) ((int)(v).size())
#define ALL(v) (v).begin(),(v).end()
#define one first
#define two second
typedef long long ll;
typedef pair<int, int> pi;
const int INF = 0x3f2f1f0f;
const ll LINF = 1ll * INF * INF;

ll N, A, B;
int main() {
	cin >> N >> A >> B;
	printf("%lld\n", max(0ll, N * B - B + A - (N * A - A + B) + 1) );
	return 0;
}

Measured memory_bytes: 256
g :: Double
g = 9.8

calc :: Int -> Double
calc n = t * g where
	h = (5 * (fromIntegral n)) - 5
	t = sqrt $ (2 * h) / g 

solve :: String -> String
solve str = do
	let v = read str :: Double
	show $ head $ dropWhile (\ n -> (calc n) < v) [1..]

main :: IO ()
main = interact (unlines . (map solve) . lines)

Measured memory_bytes: 4100
#pragma region template
#include <bits/stdc++.h>
#define all(a) (a).begin(),(a).end()
#define rep(i,n) for(ll i=0,i##_len=(n);i<i##_len;i++)
#define rep2(i,a,b) for(ll i=(a),i##_len=(b);i<=i##_len;i++)
#define rrep(i,n) ll i=(n);ll now=-1;while(i--&&(now++||1))
#define Yes(n) cout<<((n)?Yes:No)
#define pb push_back
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vbl = vector<bool>;
using vint = vector<int>;
using vstr = vector<string>;
static inline void ignore_ret(int x) {x++;}
template<class T> inline bool chmax(T&a,const T&b){if(a<b){a=b;return true;}return false;}
template<class T> inline bool chmin(T&a,const T&b){if(a>b){a=b;return true;}return false;}
template<class T> inline T gcd_vec(vector<T>v){T r=v.at(0);for(T i=1;i<v.size();i++)r=gcd(r,v.at(i));return r;}
template<class T> inline T lcm_vec(vector<T>v){T r=v.at(0);for(T i=1;i<v.size();i++)r=lcm(r,v.at(i));return r;}
template<class T> inline T factorial(T n){if(n==0)return 1;T r=1;for(T i=2;i<=n;i++)r*=i;return r;}
template<class T> inline T nCr(T n,T k){if(n<k||n<0||k<0)return 0;T r=1;k=min(k,n-k);for(T i=n-k+1;i<=n;i++)r*=i;return r/factorial(k);}
template<class T> inline T dot_product(vector<T>u,vector<T>v){T r=0;for(T i=0;i<u.size();i++)r+=u.at(i)*v.at(i);return r;}
template<class T> inline T sum(vector<T>v){return reduce(all(v),0LL);}
#pragma endregion template

int main() {
  int H, W; cin >> H >> W;
  while (H--) {
    string S; cin >> S;
    cout << S << "\n" << S << "\n";
  }
  return 0;
}

Measured memory_bytes: 384
#include <cstdio>
using namespace std;
#define MOD 998244353
long long fac[300006], ifac[300006];
long long fastpow(register int a, register int n){
	register long long t, p;
	for (t = 1, p = a; n; n >>= 1, p = p * p % MOD) if (n & 1) t = p * t % MOD;
	return t;
}
int main(){
	register int n, i, a, b;
	register long long k, ans, p;
	scanf("%d %d %d %lld", &n, &a, &b, &k);
	ifac[0] = fac[0] = fac[1] = 1;
	for (i = 2; i <= n; ++i) fac[i] = fac[i - 1] * i % MOD;
	ifac[n] = fastpow(fac[n], MOD - 2);
	for (i = n - 1; i; --i) ifac[i] = ifac[i + 1] * (i + 1) % MOD;
	ans = 0;
	for (i = 0; i <= n; ++i) {
		p = k - 1ll * i * a;
		if (p % b == 0) {
			p /= b;
			if (0 <= p && p <= n) {
				ans = (ans + 1ll * fac[n] * ifac[i] % MOD * ifac[n - i] % MOD * fac[n] % MOD * ifac[p] % MOD * ifac[n - p]) % MOD;
			}
		}
	}
	printf("%lld", ans);
	return 0;
}

Measured memory_bytes: 4864
#include <bits/stdc++.h>
#include <string>
#include <vector>
/* 変数i を n回繰り返すマクロ */
#define rep(i,n) for (int i = 0;i < (n);i++)
typedef long long ll;
using namespace std;
using Graph = vector<vector<int>>;
int main()
{
    cout << fixed << setprecision(10);//小数点以下10桁出力
    int a,b;
    vector<int> v = {1,2,3};
    cin >> a >> b;
    a--;b--;
    v.at(a) = 0;
    v.at(b) = 0;
    rep(i,3){
        if(0 != v.at(i)){
            cout << v.at(i) << endl;
        }
    }

    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <algorithm>
#define rep(i, n) for (int i=0; i<n; ++i)
#define all(obj) (obj).begin(),(obj).end()
using namespace std;
typedef long long ll;

int main(){
    ll A, B, C, K;
    cin >> A >> B >> C >> K;
    if(A>=K){
        cout << K << endl;
    }
    else if(A+B>=K){
        cout << A << endl;
    }
    else{
        if(A+B+C<=K){
            cout << A-C << endl;
        }
        else{
            cout << A-(K-A-B) << endl;
        }
    }
}


Measured memory_bytes: 3612
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <boost/multiprecision/cpp_int.hpp>

using namespace std;
namespace mp = boost::multiprecision;

int main(){
	int n = 1; 
	int q;
	mp::cpp_int k;
	cin >> n >> k >> q;
	int j;

	int a[n];
	vector<mp::cpp_int> b(n);
	for (int i = 0; i < n; i++) {
		a[i] = 0;
		b[i] = 0;
	}

	for (int i = 0; i < q; i++) {
		cin >> j;
		a[j-1]++;
	}

	for (int i = 0; i < n; i++) {
		b[i] = k - (q - a[i]);
	}

	for (int i = 0; i < n; i++) {
		if (b[i] <= 0) {
			cout << "No" << endl;
		} else {
			cout << "Yes" << endl;
		}
	}
	
	return 0;
}

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

const int nmax = 40, abmax = 10, inf = 1000000;

int a[nmax], b[nmax], c[nmax];
int dp[nmax + 1][nmax * abmax + 1][nmax * abmax + 1];

int main() {
    int n, ma, mb;
    cin >> n >> ma >> mb;

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

    for (int i = 0; i <= n; i++) {
        for (int ca = 0; ca <= nmax * abmax; ca++) {
            for (int cb = 0; cb <= nmax * abmax; cb++) {
                dp[i][ca][cb] = inf;
            }
        }
    }

    dp[0][0][0] = 0;

    for (int i = 0; i < n; i++) {
        for (int ca = 0; ca <= nmax * abmax; ca++) {
            for (int cb = 0; cb <= nmax * abmax; cb++) {
                if (dp[i][ca][cb] == inf) continue;
                dp[i + 1][ca][cb] = min(dp[i + 1][ca][cb], dp[i][ca][cb]);
                dp[i + 1][ca + a[i]][cb + b[i]] = min(dp[i + 1][ca + a[i]][cb + b[i]], dp[i][ca][cb] + c[i]);
            }
        } 
    }

    int ans = inf;
    for (int ca = 1; ca <= nmax * abmax; ca++) {
        for (int cb = 1; cb <= nmax * abmax; cb++) {
            if (ca * mb == cb * ma) ans = min(ans, dp[n][ca][cb]);
        }
    }

    if (ans == inf) ans = -1;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 25984
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define rfor(i, a, b) for(int i = a; i < (int)b; i++)
#define all(ary) (ary).begin(), (ary).end()
#define debug(x) cerr << #x << ": " << x << '\n'
const long long INF = 1LL << 60;
const int MOD = 1000000007;
using namespace std;
using vec = vector<int>;
using ll = long long;
template <class T = int> T in(){ T x; cin >> x; return (x);}
template <class T> inline bool chmin(T &a, T b) { if ( a > b ) { a = b; return 1; } return 0; }
template <class T> inline bool chmax(T &a, T b) { if ( a < b ) { a = b; return 1; } return 0; }
const int dy[4] = {-1, 0, 0, 1};
const int dx[4] = {0, -1, 1, 0};

int N;
int res = 0;

int gcd(int a, int b){
    int tmp = a % b;
    while(tmp){
        a = b;
        b = tmp;
        tmp = a % b;
    }
    return b;
}

int main(int argc, char *argv[]){
    cin >> N;
    vector<ll> A(N);
    rep(i, N) cin >> A[i];
    int t = A[0];
    int tmp;
    rep(i, N - 1){
        tmp = gcd(t, A[i + 1]);
        t = tmp;
    }
    cout << tmp << endl;
    return 0;
}

Measured memory_bytes: 1024
import sys
from collections import defaultdict
input = sys.stdin.readline

D, G = [int(x) for x in input().strip().split()]
P = [''] * D
for d in range(D):
    p, c = [int(x) for x in input().strip().split()]
    P[d] = [0] + [(d + 1) * 100 * (i + 1) for i in range(p)]
    P[d][-1] += c

d = defaultdict(int)
def f(P, D, qnum, trial, d, flag=False, score=[]):
    if (qnum, trial, sum(score)) in d:
        return d[(qnum, trial, sum(score))]
    #print('qnum={}, trial={}, score={}'.format(qnum,trial,score))
    if qnum == D:
        if sum(score) >= G:
            #print('  OK : {}'.format(trial))
            return trial
        else:
            #print('  NG')
            return 10 ** 9 + 7
    ret = 10 ** 9 + 7
    if flag:
        N = [0, len(P[qnum])-1]
    else:
        N = range(len(P[qnum]))
    for n in N:
        flag2 = flag
        t = score[:]
        t.append(P[qnum][n])
        if not flag and n != len(P[qnum]) - 1 and n != 0:
            flag2 = True
        ret = min(ret, f(P, D, qnum+1, trial+n, d, flag2, t))
    d[(qnum, trial, sum(score))] = ret
    return ret

print(f(P, D, 0, 0, d))

Measured memory_bytes: 53468
let n, d, x, a_s = Scanf.scanf " %d %d %d" @@ fun a b c -> a, b, c, Array.init a @@ fun _ -> Scanf.scanf " %d" (+) 0
let _ = Array.fold_left (fun c a -> c + (d - 1) / a + 1) x a_s |> Printf.printf "%d\n"

Measured memory_bytes: 384
#include <cstdio>
#include <algorithm>
using namespace std;
#define Maxn 100000
struct Segment{
	int left,right;
	friend bool operator <(Segment p,Segment q){
		if(p.left==q.left){
			return p.right>q.right;
		}
		return p.left<q.left;
	}
}a[Maxn+5];
int f[Maxn+5];
int ans;
int mx(int a,int b){
	return a>b?a:b;
}
int mn(int a,int b){
	return a<b?a:b;
}
int main(){
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d%d",&a[i].left,&a[i].right);
		ans=mx(ans,a[i].right-a[i].left+1);
	}
	int tmp=ans;
	int maxn=0,minn=(1<<30);
	for(int i=1;i<=n;i++){
		maxn=mx(maxn,a[i].left);
		minn=mn(minn,a[i].right);
	}
	ans=mx(ans,tmp+minn-maxn+1);
	sort(a+1,a+1+n);
	f[n+1]=(1<<30);
	for(int i=n;i>0;i--){
		f[i]=mn(f[i+1],a[i].right);
	}
	for(int i=1;i<n;i++){
		ans=mx(ans,mx(0,f[i+1]-maxn+1)+mx(0,minn-a[i].left+1));
	}
	printf("%d\n",ans);
	return 0;
}


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

using namespace std;

#define int long long
#define faster ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define cint int t;cin>>t;while(t--)
#define rep(i,a,b) for(int i=a;i<b;i++)
#define vint vector<int>
#define all(v) (v).begin(), (v).end()
#define pii pair<int,int>
#define pb push_back
const int N=1e5+5;



int32_t main() {
    faster;

    string s;
    cin>>s;

    if(s[3]==s[2]&&s[4]==s[5]) {
        cout<<"Yes"<<endl;
    }else cout<<"No"<<endl;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**6)
def input(): return sys.stdin.readline()
def read(): return int(input())
def reads(): return [int(i) for i in input().split()]

N, Y = reads()

x_max = min(N, Y//10000)
y_max = min(N, Y//5000)

ans = (-1, -1, -1)

for x in range(x_max+1):
	for y in range(min(y_max+1, N-x+1)):
		if 10000*x + 5000*y + 1000*(N-x-y) == Y:
			ans = (x, y, N-x-y)
			break

print(str(ans[0])+' '+str(ans[1])+' '+str(ans[2]))

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

using pii = pair<int,int>;
using ll = long long;
#define rep(i, j) for(int i=0; i < (int)(j); i++)
#define repeat(i, j, k) for(int i = (j); i < (int)(k); i++)
#define all(v) v.begin(),v.end()
#define debug(x) cerr << #x << " : " << x << endl

template<class T> bool set_min(T &a, const T &b) { return a > b  ? a = b, true : false; }
template<class T> bool set_max(T &a, const T &b) { return a < b  ? a = b, true : false; }
// vector
template<class T> istream& operator >> (istream &is , vector<T> &v) { for(T &a : v) is >> a; return is; }
template<class T> ostream& operator << (ostream &os , const vector<T> &v) { for(const T &t : v) os << "\t" << t; return os << endl; }
// pair
template<class T, class U> ostream& operator << (ostream &os , const pair<T, U> &v) { return os << "<" << v.first << ", " << v.second << ">"; }

const int INF = 1 << 30;
const ll INFL = 1LL << 60;


class Solver {
  public:
    bool solve() {
        string S; cin >> S;
        int i = 0, j = S.size() - 1;
        int ans = 0;
        while(i < j) {
            ans += S[i] != S[j];
            i++; j--;
        }
        cout << ans << endl;
        return 0;
    }
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    Solver s;
    s.solve();
    return 0;
}


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

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] ab = Console.ReadLine().Split(" ").Select(x => int.Parse(x)).ToArray();
            int z = 0;
            int a = ab[0];
            int b = ab[1];
            int[] X = new int[1000];
            int[] Y = new int[1000];
            for (int i = 1; i < 1000; i++)
            {
                
                z += i;
                X[i] = z - a;
                Y[i] = z - b;
                if(X[i - 1] == Y[i])
                {
                    Console.WriteLine(Math.Abs(Y[i]));
                    return;
                }
            }
        }
    }
}
//int[] N = Console.ReadLine().Split(" ").Select(x => int.Parse(x)).ToArray();

Measured memory_bytes: 28196
/*
　　　　 ∧＿∧　にっぽんちゃちゃちゃ
　／＼（　・∀・）／ヽ
（ ●　と　　　つ　● ）　にっぽんちゃちゃちゃ
　＼/⊂、 ノ　　＼ノ
　　　　　し'
*/
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define repone(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define Rep(j,n) for(int j=0;j<(int)(n);++j)
#define Repo(j,o,n) for(int j=o;j<(int)(n);++j)
#define Repone(j,n) for(int j=1;j<(int)(n);++j)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define int long long
#define MOD 1000000007
#define INF 9223372036854775807

signed main(){
int x=0,y=0,z=0,w=0;
std::cin >> x;
std::cout << x*32 << '\n';
}



Measured memory_bytes: 3112
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <bitset>
#include<iomanip>
#include<functional>
using namespace std;
typedef long long ll;


long long GCD(long long a, long long b) {
    if (b == 0) return a;
    else return GCD(b, a % b);
}


int main() {
    ll n;
    cin >> n;
    ll mod = 1e9 + 7;
    ll sum10 = 1;
    ll sum9 = 1;
    ll sum8 = 1;
    for (int i = 0; i < n; i++) {
        sum10 *= 10;
        sum9 *= 9;
        sum8 *= 8;
        sum10 %= mod;
        sum9 %= mod;
        sum8 %= mod;
    }
    ll ans = sum10 - sum9 - sum9 + sum8;
    ans %= mod;
    ans = (ans + mod) % mod;
    cout << ans << endl;
}


Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i,n) for(int i=0;i<n;++i)
#define MOD (int) 1e9+7

int main(){
    int n;
    cin >> n;
    map<string, int> mp;
    // vector<ll> vals(n);
    rep(i, n){
        string s;
        cin >> s;
        sort(s.begin(), s.end());
        mp[s]++;
    }
    
    ll ans = 0;
    for (auto u:mp){
        ans += (ll)u.second * (u.second-1)/2;
    }
    cout << ans << endl;
    // printf("%d\n", N);
    return 0;
}

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

template<class c> auto try_out(c a) -> decltype(cerr << a, 0);
char try_out(...);

struct debug {
#ifdef LOCAL
template<class c, class d> debug& operator << (pair<c, d> e) {
	return *this << "(" << e.first << ", " << e.second << ")";
}
template<class c> typename enable_if<sizeof(try_out(declval<c>())) != 1, debug&>::type operator << (c a) {
	cerr << boolalpha << a;
	return *this;
}
template<class c> typename enable_if<sizeof(try_out(declval<c>())) == 1, debug&>::type operator << (c a) {
	*this << "[";
	for (auto it = a.begin(); it != a.end(); ++it)
		*this << ","[1 - (it != a.begin())] << *it;
	return *this << "]";
}
#else
template<class c> debug& operator << (c) {
	return *this;
}
#endif
};

#define aty(x) " [" << #x ": " << x << "] "

using ll = long long;




int main() {
	
    double a, b, t;
    cin >> a >> b >> t;
    
    t += 0.5;
    
    int ans = 0;
    
    for (double i = a; i <= t; i += a) {
        ans += b;
    }
    
    cout << ans;
    
	
}


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

#define ll long long
#define ld long double
#define pb push_back
#define pr pair<ll, ll>
#define vct vector<ll>
#define vpt vector<pr>
#define st set<ll>
#define pq priority_queue<ll>
#define mat vector<vector<ll> >
#define F(i, n) for (i = 0; i < (1LL*n); i++)
#define Fr(i, n) for (i = n - 1; i >= 0; i--)

struct custom_hash
{
    static uint64_t splitmix64(uint64_t x)
    {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }
    size_t operator()(uint64_t x) const
    {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
#define umap unordered_map<long long, long long, custom_hash>
void prv(vct v)
{
    for (ll i = 0; i < v.size(); i++)
        cout << v[i] << " ";
    cout << "\n";
}
ll poww(ll x, ll y, ll m)
{
    ll res = 1;
    while (y)
    {
        if (y % 2 == 0)
        {
            x = (x * x) % m;
            y = y / 2;
        }
        else
        {
            res = (res * x) % m;
            y--;
        }
    }
    return res;
}
void deb(string s, ll n)
{
    cout << s << " : " << n << "\n";
}
void prn(ll n) { cout << n << "\n"; }
void prs(string n) { cout << n << "\n"; }

mat mt;
void setmtsize(ll m,ll n, ll ini=0){
    mt.resize(m,vector<ll>(n,ini));
}
void prmt(mat m){
    for(ll i=0;i<(1LL*m.size());i++)prv(m[i]);
}
vct divsors(ll n)
{
    vct ans;//ans.push_back(1);
    for(ll i=1;i<=sqrt(n);i++)
    {if(n%i==0){ans.push_back(i);if(i!=(n/i))ans.push_back(n/i);}}
    sort(ans.begin(),ans.end());
    return ans;
}
vct sieve(ll n){
    vct ans(n+1,-1);
    for(ll i=2;i<=n;i++){
        if(ans[i]==-1){
            for(ll j=i;j<=n;j+=i)if(ans[j]==-1)ans[j]=i;
        }
    }
    return ans;
}
ll n, k, m, l, r, x, y, z, ans=0;
ll t, t1, t2;
// ll q;
ll i, j;
ll a, b, c;
ll mod = 1000000007;
ll cas=0;

ll chk(ll md, vct v, ll cuts){
    ll an=-1;
    ll mxn=-1;
    for(ll i=0;i<v.size();i++){
        ll cr=v[i]-1;
        ll r1=cr/md;
        ll rm=cr%md;
        if(r1>0){
            if(cuts<r1)return -1;
            cuts-=r1;
            an=md;
        }
        else{
            an=max(an,rm);
        }
    }
    return an;
}

void solve()
{
    cin>>n>>k;
    vct v(n);
    r=-1;
    F(i,n){cin>>v[i];r=max(r,v[i]);}
    if(k==0){
        prn(r);
        return;
    }
    l=1;
    ans=-1;ll prmx=LLONG_MAX;
    while(l<=r){
        ll md=l+(r-l)/2;
        ll an=chk(md,v,k);
        if(an==-1){
            l=md+1;
            continue;
        }
        else {
            ans=md;
            r=md-1;
        }
    }
    prn(ans);
}
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    // freopen("input.txt", "r", stdin); 
    // freopen("output.txt", "w", stdout);
    
    ll t = 1;
    // cin >> t;
    cas=1;
    // stress();
    while (t--){
        solve();
        cas++;
    }
    return 0;
}

Measured memory_bytes: 6360
#include <cstdio>

int main()
{
  char s[5];
  scanf("%s", s);
  printf("%d\n", (s[0] == '+' ? 1 : -1) + (s[1] == '+' ? 1 : -1) + (s[2] == '+' ? 1 : -1) + (s[3] == '+' ? 1 : -1));
  return 0;
}

Measured memory_bytes: 128
N=int(input())
s=[""]*N
t=[0]*N

for i in range(N):
    s[i],t[i]=map(str,input().split())
X=input()

index=-1
ans=0
for i in range(N):
    if index!=-1:
        ans+=int(t[i])
    if X==s[i]:
        index=i
print(ans)

Measured memory_bytes: 38256