akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    ll n;
    cin>>n;
    vector<ll> t(n+1,0);
    vector<ll> x(n+1,0);
    vector<ll> y(n+1,0);
    for(ll i=1;i<=n;i++)
    {
        cin>>t[i]>>x[i]>>y[i];
    }
    for(ll i=1;i<=n;i++)
    {
        ll pt=t[i-1];
        ll px=x[i-1];
        ll py=y[i-1];
        ll ts=abs(x[i]-px)+abs(y[i]-py);
        ll td=t[i]-t[i-1];
        //cout<<ts<<" "<<td<<endl;
        if(td==ts)
        {
            continue;
        }
        else if(td<ts)
        {
            cout<<"No\n";
            return 0;
        }
        else
        {
            //ll RT=ts-td;
            if((ts+td)%2!=0)
            {
                cout<<"No\n";
                return 0;
            }
            else
            {
                continue;
            }
        }
    }
    cout<<"Yes\n";
    return 0;
}


Measured memory_bytes: 2560
s = input()
n = len(s)
tmp_1 = (n-1) // 2

tmp_2 = (n+3) // 2

tmp_1_s = s[:tmp_1]
tmp_2_s = s[tmp_2-1:n]
if s == s[::-1] and tmp_1_s == tmp_1_s[::-1] and tmp_2_s == tmp_2_s[::-1]:
    print('Yes')
else:
    print('No')


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

using namespace std;
typedef long long ll;
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    ll n ;
    cin >> n ;
    ll arr[n];

    for(int i = 0 ; i < n; i++)
    {
        cin >> arr[i];
    }
    ll st;
    ll have=1000 , cands=0;
    for(int i = 0 ; i <n; i++)
    {
        if(i==0)
            st=arr[i];
        else
        {
            if(arr[i]<arr[i-1])
            {
                cands+=(have/st);
                have-=(cands*st);
                have+=cands*arr[i-1];
                cands=0;
                st=arr[i];
            }
        }
    }
    cands+=(have/st);
    have-=(cands*st);
    have+=cands*arr[n-1];
    cout << have << "\n";
    return 0;
}


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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  cout.precision(10);
  cout<<fixed;
  ll N, K;
  cin>>N>>K;
  vector<ll> v(N);
  for(ll &i:v) cin>>i;
  sort(v.begin(), v.end(), greater<ll>());
  ll sum=0;
  for(ll i=K; i<N; ++i) sum+=v[i];
  cout<<sum<<"\n";
  return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define vtpl(x,y,z) vector<tuple<x,y,z>>
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

int main(){
    ll k;cin >> k;
    ll a,b;cin >> a >>b;
    ll ans=0;
    while(true){
        ans+=k;
        if(b<ans)break;
        if(ans>=a){
            cout << "OK" <<endl;
            return 0; 
        }
    }
    cout << "NG" <<endl;
}

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

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

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

#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC targett("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

using namespace std;
#define fast ios::sync_with_stdio(0);cin.tie(0);
#define endl        '\n'
#define ll          long long int
#define pb          push_back
#define sz(x)       (int)(x).size()
const ll mod = 1e9 + 7;

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


ll powm(ll a, ll b) {
	ll res = 1;
	while (b) {
		if (b & 1)
			res = (res * 1LL * a) % mod;
		b >>= 1LL;
		a = (a * 1LL * a) % mod;
	}
	return res;
}

//--------------------------------------------------------------------------------------------------------------------------//
ll w[105] , v[105];
ll inf = 1e18L;
int main() {
	fast
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	int n, m;
	cin >> n >> m;

	for (int i = 0; i < n; i++)
		cin >> w[i] >> v[i];
	int sum = 0;

	for (int i = 0; i < n; i++)
		sum += v[i];

	vector<ll> dp(sum + 1, inf);
	dp[0] = 0;

	for (int i = 0; i < n; i++) {
		for (int j = sum - v[i] ; j >= 0; j--) {
			dp[j + v[i]] = min(dp[j + v[i]] , dp[j] + w[i]);
		}
	}
	ll ans = 0;
	for (ll i = 0; i <= sum; i++) {
		if (dp[i] <= m) {
			ans = max(ans , i);
		}
	}
	cout << ans << endl;
	return 0;

}





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

const int MS = 2e6 + 5, mod = 1e9 + 7;

typedef long long ll;

ll fact[MS];

void cal_fact()
{
    fact[0] = 1;
    for (int i = 1; i < MS; i++)
    {
        fact[i] = i * fact[i - 1];
        fact[i] %= mod;
    }
}

// modular exponentiation 
ll binpow(ll val, ll deg, ll mod)
{
    if (!deg)
        return 1 % mod;
    if (deg & 1)
        return binpow(val, deg - 1, mod) * val % mod;
    ll res = binpow(val, deg >> 1, mod);
    return (res * res) % mod;
}

ll cal_c(ll n, ll i)
{
    ll res = fact[n]; 
    ll div = fact[n - i] * fact[i];
    div %= mod;
    // using fermat little theorum
    div = binpow(div, mod - 2, mod); // modular inverse  
    return (res * div) % mod; 
}

int main()
{
    cal_fact();
    ll n, k;
    cin >> k;
    string s;
    cin >> s;
    n = s.size();

    ll ans = 0;
    for (int i = n; i <= n + k; i++){
        ans+=cal_c(n+k,i)*binpow(25,n+k-i,mod);
        ans%=mod;
    }
    cout<<ans<<"\n";
}


Measured memory_bytes: 20936
N, M, Q = map(int, input().split())
rail = []
for i in range(M):
    r = list(map(int, input().split()))
    rail.append(r)
 
query = []
for i in range(Q):
    q = list(map(int, input().split()))
    query.append(q)
 
f = [[0 for i in range(N)] for j in range(N)]
g = [[0 for i in range(N)] for j in range(N)]
 
for i in range(M):
    f[rail[i][0]-1][rail[i][1]-1] += 1
 
for i in range(N):
    j = 0
    while j + i < N:
        if i == 0:
            g[j][j+i] = f[j][j+i]
        else:
            g[j][j+i] = f[j][j+i] + g[j+1][j+i] + g[j][j+i-1] - g[j+1][j+i-1]
        j += 1
 
for i in range(Q):
    print(g[query[i][0]-1][query[i][1]-1])


Measured memory_bytes: 75412
N = int(input())
ab = [list(map(int, input().split())) for _ in range(N)]
cd = [list(map(int, input().split())) for _ in range(N)]
ab.sort(reverse=True)
cd.sort()
p = 0
for c in cd:
    ac = [-1, -1]
    for a in ab:
        if c[0] > a[0] and c[1] > a[1] and ac[1] < a[1]:
            ac = a
    if ac != [-1, -1]:
        p += 1
        ab.remove(ac)

print(p)

Measured memory_bytes: 3064
using System;
using System.Linq;
using System.Text;

namespace ALDS1_6_C {
    public class Card {
        public char Suit { get; set; }
        public int Number { get; set; }

        public override string ToString() {
            return Suit + " " + Number;
        }
    }

    public static class MyExtension {
        public static void QuickSort(this Card[] arr,int p,int r) {
            if (p < r) {
                int q = arr.Pertition(p, r);
                arr.QuickSort(p, q - 1);
                arr.QuickSort(q + 1, r);
            }
        }

        public static int Pertition(this Card[] arr, int p, int r) {
            Card x = arr[r];
            int i = p - 1;
            for (int j = p; j < r; j++) {
                if (arr[j].Number <= x.Number) {
                    i++;
                    arr.Replace(i, j);
                }
            }
            arr.Replace(i + 1, r);
            return i + 1;
        }

        public static void Replace(this Card[] arr, int indexA, int indexB) {
            Card temp = arr[indexA];
            arr[indexA] = arr[indexB];
            arr[indexB] = temp;
        }
    }

    class Program {
        static void Main(string[] args) {
            int n = int.Parse(Console.ReadLine());
            Card[] cards = new Card[n];
            for(int i = 0; i < n; i++) {
                string[] input = Console.ReadLine().Split(' ');
                cards[i] = new Card { Suit = input[0][0], Number = int.Parse(input[1]) };
            }
            Card[] stable = cards.OrderBy(c => c.Number).ToArray();
            cards.QuickSort(0, n - 1);

            StringBuilder sb = new StringBuilder();
            sb.AppendLine(cards.SequenceEqual(stable) ? "Stable" : "Not stable");
            foreach (Card card in cards)
                sb.AppendLine(card.ToString());
            Console.Write(sb);
        }
    }
}

Measured memory_bytes: 21676
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int a = scanner.nextInt();
		int b = scanner.nextInt();
		int height = 0;

		int diff = b - a;

		for (int i = 0; i < diff; i++) {
			height = height + i;
			//System.out.println(height);
		}
		int snow = height - a;
		System.out.println(snow);
	}
}

Measured memory_bytes: 21844
package main

import "fmt"

func main() {
	var a, b int
	fmt.Scanf("%d %d", &a, &b)
	out := a + b
	if out <= (a - b) {
		out = a - b
	}
	if out <= a*b {
		out = a * b
	}
	fmt.Printf("%d", out)
}


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

int main(){
    int a,b,c,d,e,f;
    int Ans1=0,Ans2=0;
    double Ans=0;
    bool ab[300]={};
    bool cd[30000]={};
    cin >> a >> b >> c >> d >> e >> f;
    ab[0]=1;cd[0]=1;
    for(int i=0;i<=30;i++){
        if(i-a>=0){
            if(ab[i-a]==1){
                ab[i]=1;
            }
        }
        if(i-b>=0){
            if(ab[i-b]==1){
                ab[i]=1;
            }
        }
    }
    for(int i=0;i<=3000;i++){
        if(i-c>=0){
            if(cd[i-c]==1){
                cd[i]=1;
            }
        }
        if(i-d>=0){
            if(cd[i-d]==1){
                cd[i]=1;
            }
        }
    }
    
    REP(i,30){
        REP(j,3000){
            if(i==0 )continue;
            if(ab[i]==0 || cd[j]==0)continue;
            if(100*i+j<=f && j <= i*e){
                if(Ans<=(double)(100*(double)j/(100*(double)i+(double)j))){
                    Ans=(double)(100*(double)j/(100*(double)i+(double)j));
                    Ans1=i*100+j;
                    Ans2=j;
                    //cout << Ans << " ";
                }
            }
        }
    }
    /*
    REP(i,30){
        if(ab[i]==1){cout << i << " ";}
    }cout << endl;
    REP(i,3000){
        if(cd[i]==1){cout << i << " ";}
    }cout << endl;
    */
    
    cout << Ans1 <<" "<<Ans2 << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int in(){int a;cin>>a;return a;}
int a[100001],b[100001],ans,ak=1e9+7,ac=ak;
int main(){
	int n=in(),m=in(),k=in();
	for(int i=1;i<=n;i++)a[i]=in(),ac=min(a[i],ac);
	for(int i=1;i<=m;i++)b[i]=in(),ak=min(b[i],ak);
	ans=ak+ac;
	while(k--)ans=min(ans,a[in()]+b[in()]-in());
	return cout<<ans<<endl,0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int,int>;
#define rep(i,n) for(int i=0; i<n; i++)
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end()) //sortしてから使う
#define INF 2147483647
#define LLINF 9223372036854775807LL

int main(){
  string s; cin>>s;
  int wa = 0;
  rep(i, s.size()){
    wa += s[i] - '0';
  }
  if (wa%9 == 0) cout << "Yes" <<endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 3744
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i=0;i < (int)(n);i++)

int main(){
  int a,b;
  cin >> a >> b;
  int ans = (b-a)*(b-a+1)/2;
  ans -= b;
  cout << ans << endl;
  
  return 0; 
}



Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define all(c) begin(c),end(c)

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 long long int ll;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007


//ここから編集する
class Solve {
public:
    void input() {

    }

    int cal(int y, int m, int d) {
        int ret = 0;

        while (y < 1000) {
            ret++;
            d++;
            if (y % 3 == 0) {
                if (d == 21) {
                    d = 1;
                    m++;
                    if (m == 11) {
                        m = 1;
                        y++;
                    }
                }
            } else {
                if (m % 2 == 1) {
                    if (d == 21) {
                        d = 1;
                        m++;
                        if (m == 11) {
                            m = 1;
                            y++;
                        }
                    }
                } else {
                    if (d == 20) {
                        d = 1;
                        m++;
                        if (m == 11) {
                            m = 1;
                            y++;
                        }
                    }
                }
            }
        }

        return ret;
    }

    void solve() {
        input();
        int n;
        cin >> n;

        for (int i = 0; i < n; ++i) {
            int y, m, d;
            cin >> y >> m >> d;
            int ans = cal(y, m, d);
            cout << ans << endl;
        }


    }
};


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

    Solve().solve();


    return 0;
}



Measured memory_bytes: 3172
#exec({'RUBY_THREAD_VM_STACK_SIZE'=>'100000000'},'/usr/bin/ruby', $0) if !ENV['RUBY_THREAD_VM_STACK_SIZE']
require 'prime'

def inpf() a=gets.chomp.split(" ").map(&:to_f)end

def inps() a=gets.chomp.split(" ")end

def copy(a) Marshal.load(Marshal.dump(a)) end

def kaijo(n,r = 10**9+7)(n < 2)? 1 : (2..n).inject{|memo,u|memo=(memo*u)%r} end

def na(n,d=0) Array.new(n,d)end

def na2(n,m,d=0) Array.new(n){Array.new(m,d)}end

def na3(n,m,l,d=0) Array.new(n){Array.new(m){Array.new(l,d)}}end

def inp() a=gets.chomp.split(" ").map(&:to_i)end

def r_up(a, b) (a+b-1)/b end

def sum(a) a.inject(:+) end

def big(a,b) return (a>b)? a:b end

def small(a,b) return (a<b)? a:b end

x = inp[0]
now = 100
ans = 0
while now < x
  ans += 1
  now += now/100
end
p ans

Measured memory_bytes: 14416
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define fi first
#define se second
#define pb push_back
signed main(){
    int n;
    ll ans=0,a=0,b=0;
    ll x=0;
    cin >> n;
    vector<string> v(n);

    for(int i=0;i < n;i++)
    {
        cin>>v.at(i);

        for(int j=0;j < v.at(i).size()-1;j++)
        {
            if(v.at(i).at(j)=='A' && v.at(i).at(j+1)=='B'){
                ans++;
            }
        }

        if(v.at(i).at(0)=='B'){
            b++;
        }
        if(v.at(i).at(v.at(i).size()-1)=='A'){
            a++;
        }
        if(v.at(i).at(0)=='B' && v.at(i).at(v.at(i).size()-1)=='A'){
            x++;
        }
    }

    ans+= min(a,b);

    if(a==b && x>=1 && a>0 && x==min(a,b)){
        ans-=1;
    }

    cout << ans << endl;
}

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

#define pb push_back
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define REP(i,n) for(int _n=n, i=0;i<_n;++i)
#define FOR(i,a,b) for(int i=(a),_b=(b);i<=_b;++i)
#define FORD(i,a,b) for(int i=(a),_b=(b);i>=_b;--i)
#define trav(a, x) for (auto& a : x)
using ull = uint64_t;
using ll = int64_t;
using PII = pair<int, int>;
using VI = vector<int>;
#define INF (1ll<<60)

string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string) s); }
string to_string(bool b) { return (b ? "true" : "false"); }
template <typename A, typename B> string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")"; }
template <typename A> string to_string(A v) {
bool first = true; string res = "{";
for (const auto &x : v) { if (!first) { res += ", "; } first = false; res += to_string(x); }
res += "}"; return res; }
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H); debug_out(T...); }
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)


int main() {
    ios::sync_with_stdio(false), cin.tie(0);
    int N, K;
    cin >> N >> K;
    vector<pair<ll, ll>> V(N);
    REP(i, N) {
        int x, y;
        cin >> x >> y;
        V[i] = {x, y};
    }
    sort(all(V));
    ll ans = LLONG_MAX;
    REP(i, N - 1) {
        FOR(j, i + 1, N - 1) {
            vector<ll> A;
            FOR(k, i, j) {
                A.pb(V[k].second);
            }
            sort(all(A), greater<ll>());
            REP(k, SZ(A) - 1) {
                FOR(l, k + 1, SZ(A) - 1) {
                    if (l - k + 1 < K) continue;
                    ll mxY = max(max(V[i].second, V[j].second), max(A[k], A[l]));
                    ll mnY = min(min(V[i].second, V[j].second), min(A[k], A[l]));
                    ll area = abs(V[i].first - V[j].first) * (mxY - mnY);
                    ans = min(area, ans);
                }
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mp make_pair
#define X first
#define Y second
#define pii pair<ll,ll>
#define x1 dlfjl
#define x2 dkfj
#define MOD 1000000007
#define y1 dskgj
#define y2 dskfj
#define SQ 320
typedef int ll;
using namespace std;
ll n,i,j,k,x,y,z,m,q,h,r,timer,mx,l;
ll a[100500];
string s;
int main() {
    //freopen("input.txt","r",stdin);
    cin >> s;
    ll n = s.size();
    ll l = 0, r = n-1;
    while (l <= r) {
        if (s[l] == s[r])
            l++, r--;
        else
        if (s[l] != s[r])
        {
            if (s[l] == 'x')
                l++,k++;
            else
            if (s[r] == 'x')
                r--, k++;
            else {
                cout << -1 << endl;
                return 0;
            }
        }
    }
    cout << k << endl;
    return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <functional>
#include <queue>
#include <string>
#include <cstring>
#include <numeric>
#include <cstdlib>
#include <cmath>
using namespace std;

typedef long long ll;

#define INF 10e10
#define rep(i,n) for(int i=0; i<n; i++)
#define repr(i,n,m) for(int i=m; i<n; i++)
#define END cout << endl
#define MOD 1000000007
#define pb push_back
// 昇順sort
#define sorti(x) sort(x.begin(), x.end())
// 降順sort
#define sortd(x) sort(x.begin(), x.end(), std::greater<int>())

int main() {
  int n;
  cin >> n;
  vector<int> t(n+1), a(n+1);
  vector<pair<int,bool> > ans(n);
  
  rep(i,n) {
    cin >> t[i+1];
  }
  rep(i,n) {
    cin >> a[i];
  }

  t[0] = -1, a[n] = -1;

  repr(i,n+1,1) {
    if (t[i] > t[i-1]) {
      ans[i-1].first = t[i];
      ans[i-1].second = true;
    } else if (t[i] == t[i-1]) {
      ans[i-1].first = t[i];
      ans[i-1].second = false;
    }
  }

  /*for (auto itr : ans) {
    cout << itr.first << " " << itr.second << endl;
  }*/

  for (int i = n-1; i >= 0; --i) {
    if (a[i] > a[i+1]) {
      if (ans[i].second and a[i] != ans[i].first) {
        
        cout << 0 << endl;
        return 0;
      } else if (a[i] > ans[i].first) {
        
        cout << 0 << endl;
        return 0;
      }
      ans[i].first = a[i];
      ans[i].second = true;
    } else if (a[i] == a[i+1]) {
      if (!ans[i].second) {
        if (a[i] < ans[i].first) {
          ans[i].first = a[i];
        }
      }
    }
  }

  ll res = 1;
  for (auto itr : ans) {
    if (!itr.second) {
      res = (res * itr.first) % MOD;
    }
  }
  cout << res << endl;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using PII = pair<int, int>;
#define FI(i, a, b) for (int i = (a); i <= (b); ++i)
#define FD(i, a, b) for (int i = (b); i >= (a); --i)
#define DEBUG(x) cerr << #x << ": " << (x) << '\n';


int main() {
  int n;
  cin >> n;
  multiset<int> se;
  for (int i = 0; i < (1 << n); ++i) {
    int x;
    scanf("%d", &x);
    se.insert(x);
  }
  vector<int> s;
  s.push_back(*prev(se.end(), 1));
  se.erase(prev(se.end(), 1));
  for (int i = 0; i < n; ++i) {
    for (int j = 0, tn = s.size(); j < tn; ++j) {
      int x = s[j];
      auto it = se.lower_bound(x);
      if (it == se.begin()) return puts("No"), 0;
      --it;
      s.push_back(*it);
      se.erase(it);
    } 
    sort(s.begin(), s.end(), greater<int>());
  }
  puts("Yes");
}


Measured memory_bytes: 13692
#include <bits/stdc++.h>
#include <string>
#include <cstring>
#include <algorithm>
#include <math.h>
#include <map>
#include <bitset>
#include <cmath>
#include <set>
#include <utility>

#define INF 1000000000000
#define MOD 1000000007 //10^9+7:合同式の法

using namespace std;
typedef long long ll;

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

int main(){
    int A,ans =0;
    cin >> A;

    ans = A + A*A + A*A*A;

    cout << ans << endl;
}

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

int main()
{
    int A, B, C, X;
    cin >> A >> B >> C >> X;
    int answer = 0;
    for (int a = 0; a < A + 1; ++a)
    {
        for (int b = 0; b < B + 1; ++b)
        {
            for (int c = 0; c < C + 1; ++c)
            {
                if (500 * a + 100 * b + 50 * c == X)
                {
                    ++answer;
                }
            }
        }
    }
    cout << answer << endl;
}

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

using namespace std;

int main(){
  int a,b; cin >> a >> b;
  if(a>=13){
    cout << b << endl;
  }
  else if(a>=6 && a<=12){
    cout << b/2 << endl;
  }
  else{
    cout << 0 << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define pp pop_back
#define in insert
#define ff first
#define ss second
#define  show for(int j=0;j<v.size();j++) cout<<v[j]<<" ";
#define ld long double
#define e endl
#define bc __builtin_popcount
#define MOD 1000000007
#define INT_SIZE 32
#define me(x) memset(x,0,sizeof(x))
ll fast_expo(ll x,ll p)
{if(p==0) return 1;
else if(p%2==0){ ll t=fast_expo(x,p/2)%MOD;return (t*t)%MOD;} else return (x*(fast_expo(x,p-1))%MOD)%MOD;}

int main()
{
int n,i;
string s;
cin>>n>>s;
int cnt=1;
for(i=1;i<n;i++)
{
    if(s[i]!=s[i-1])
    {
        cnt++;
    }
}
cout<<cnt;





}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define dunk(a) cout << (a) << endl
#define rall(a) (a).rbegin(),(a).rend()
const int INF = 2e9;
using namespace std;
using Graph = vector<vector<int>>;
typedef pair<int,int> P;
typedef long long ll;

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

    cout << min(min(a+b,b+c),c+a) << endl;
}

Measured memory_bytes: 256
a,b,c,d = map(int,input().split())
t = False
if(a<=c<=b or a<=d<=b or c<=a<=d or c<=b<=d):
    t = True
else:
    t = False

if t:
    if(a<=c<=b and b<d):
        print(b-c)
    elif(a<=c<=b and b>=d):
        print(d-c)
    elif(a<=d<=b and a<=c):
        print(d-c)
    elif(a<=d<=b and a>c):
        print(d-a)
    elif(c<=a<=d and b<=d):
        print(b-a)
    elif(c<=a<=d and b>d):
        print(d-a)
    elif(c<=b<=d and a<c):
        print(b-c)
    elif(c<=b<=d and a>c):
        print(b-a)
else:
    print(0)

Measured memory_bytes: 3064
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cassert>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
using namespace std;


typedef long long i64;
const int inf = (int)1.05e9;

bool is_eq(char* s, int x, int y, int l) {
	for(int i = 0; i < l; i++) {
		if(s[x - l + 1 + i] != s[y - l + 1 + i]) {
			return false;
		}
	}
	return true;
}

int main()
{
	vector<vector<int>> dp;
	char s[200005];

	scanf("%s", s);
	int len = strlen(s);

	dp.resize(7);
	for(auto& d : dp) {
		d.resize(len, -inf);
	}

	dp[1][0] = 1;

	for(int pos = 1; pos < len; pos++) {
		for(int l = 1; l <= 6; l++) {

			int& v = dp[l][pos];

			if(pos - l < 0) {
				continue;
			}

			for(int r = 1; r <= 6; r++) {
				int w = dp[r][pos - l];
				if(l == r && is_eq(s, pos - l, pos, r)) {
					continue;
				}
				v = max(v, w + 1);
			}
		}
	}

	int ans = 0;
	for(int i = 0; i <= 6; i++) {
		ans = max(ans, dp[i][len - 1]);
	}

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

	return 0;
}

/* waffle */


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

int main() {
  int N;
  cin >> N;
  
  vector<int> time(N);
  
  long long totaltime = 0;
  
  for (int i=0; i<N; i++){
    cin >> time.at(i);
    totaltime += time.at(i);
  }
  
  int M;
  cin >> M;
  
  for (int i=0; i<M; i++){
    int P, X;
    cin >> P >> X;
    cout << totaltime - time.at(P-1) + X << endl;
  }
}

Measured memory_bytes: 256
import java.util.Scanner;
 
public class Main {
 
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int l = sc.nextInt();
		int n = 1, m = 0;
		StringBuilder sb = new StringBuilder();
		while((1<<n-1)-1<l) n++;
		n--;
		for (int i = 1; i < n; i++) {
			sb.append(Convert(i,i+1,0));
			sb.append(Convert(i,i+1,1<<i-1));
			m += 2;
		}
		int max = (1<<n-1)-1;
		while(l-max>1) {
			int k = 1;
			while((1<<k-1)<l-max) k++;
			k--;
			sb.append(Convert(k, n, max+1));
			m++;
			max += (1<<k-1);
		}
		System.out.printf("%d %d\n",n,m);
		System.out.println(new String(sb));
		sc.close();
	}
	public static String Convert(int a, int b, int c) {
		return String.valueOf(a)+' '+String.valueOf(b)+' '+String.valueOf(c)+"\n";
	}
}

Measured memory_bytes: 21844
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <set>
#include <map>
using namespace std;

string S;


int main()
{
    cin >> S;

    for(int i = 0;i < S.size();i++)
    {
        if(i == 3)
        {
            cout << 8;
        }
        else 
            cout << S[i];
    }

    cout << endl;
    return 0;
}


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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define forn(i, a, n) for (int i = a; i < n; ++i)
#define ford(i, a, n) for (int i = n - 1; i >= a; --i)
#define fore(i, a, n) for (int i = a; i <= n; ++i)
#define all(a) (a).begin(), (a).end()
#define fs first
#define sn second
#define trace(a)\
    for (auto i : a) cerr << i << ' ';\
    cerr << '\n'
#define eb emplace_back

#ifndef M_PI
const ld M_PI = acos(-1.0);
#endif

const ld eps = 1e-9;
const int INF = 2000000000;
const ll LINF = 1ll * INF * INF;
const ll MOD = 1000000007;

const int N = 1000;
vector<int> solve(int n, int k) {
    assert(n % k);
    vector<int> a(n);
    forn(i, 0, n) {
        if (i % k == k - 1) a[i] = -(k - 1) * N - 1;
        else a[i] = N;
    }
    return a;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int H, W, h, w;
    cin >> H >> W >> h >> w;
    if (H % h) {
        cout << "Yes\n";
        vector<int> a = solve(H, h);
        forn(i, 0, H) {
            forn(j, 0, W) cout << a[i] << ' ';
            cout << '\n';
        }
    } else if (W % w) {
        cout << "Yes\n";
        vector<int> a = solve(W, w);
        forn(i, 0, H) {
            forn(j, 0, W) cout << a[j] << ' ';
            cout << '\n';
        }
    } else cout << "No\n";
}


Measured memory_bytes: 1664
#include<iostream>
#include<cstring>
#include<cstdio>
#include<cmath>
using namespace std;
int main()
{
    int n;
    cin>>n;
    long long t[n],a[n];
    for(int i=0;i<n;i++){
        cin>>t[i]>>a[i];
    }
    long long nt=t[0],na=a[0];
    for(int i=1;i<n;i++){
        long long tt=nt/t[i];
        tt=tt*t[i];
        if(tt<nt){
            tt=tt+t[i];
        }
        if(tt/t[i]>na/a[i]){
            nt=tt;
            na=tt/t[i];
            na=na*a[i];
        }
        else{
            long long aa=na/a[i];
            aa=aa*a[i];
            if(aa<na){
                aa=aa+a[i];
            }
            na=aa;
            nt=aa/a[i];
            nt=nt*t[i];
        }
        //cout<<nt<<" "<<na<<endl;
    }
    long long wa=na+nt;
    cout<<wa<<endl;
    return 0;
}

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

using namespace std;
using ll = long long;

int main() {
    ll n,k = 0;
    cin >> n >> k;
    vector<ll> p(n);
    for(ll i = 0;i < n;i++){
        cin >> p[i];
    }

    sort(p.begin(),p.end());
    ll sum = 0;
    for(ll i = 0;i < k;i++){
        sum += p[i];
    }

    cout << sum << endl;
    return 0;
}

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

using namespace std;

template <int p>
struct Modint
{
	int value;

	Modint() : value(0) {}
	Modint(long x) : value(x >= 0 ? x % p : (p + x % p) % p) {}

	inline Modint &operator+=(const Modint &b)
	{
		if ((this->value += b.value) >= p)
			this->value -= p;
		return (*this);
	}
	inline Modint &operator-=(const Modint &b)
	{
		if ((this->value += p - b.value) >= p)
			this->value -= p;
		return (*this);
	}
	inline Modint &operator*=(const Modint &b)
	{
		this->value = (int)((1LL * this->value * b.value) % p);
		return (*this);
	}
	inline Modint &operator/=(const Modint &b)
	{
		(*this) *= b.inverse();
		return (*this);
	}

	Modint operator+(const Modint &b) const { return Modint(*this) += b; }
	Modint operator-(const Modint &b) const { return Modint(*this) -= b; }
	Modint operator*(const Modint &b) const { return Modint(*this) *= b; }
	Modint operator/(const Modint &b) const { return Modint(*this) /= b; }

	inline Modint &operator++(int) { return (*this) += 1; }
	inline Modint &operator--(int) { return (*this) -= 1; }

	inline bool operator==(const Modint &b) const { return this->value == b.value; }
	inline bool operator!=(const Modint &b) const { return this->value != b.value; }
	inline bool operator<(const Modint &b) const { return this->value < b.value; }
	inline bool operator<=(const Modint &b) const { return this->value <= b.value; }
	inline bool operator>(const Modint &b) const { return this->value > b.value; }
	inline bool operator>=(const Modint &b) const { return this->value >= b.value; }

	//requires that "this->value and p are co-prime"
	// a_i * v + a_(i+1) * p = r_i
	// r_i = r_(i+1) * q_(i+1) * r_(i+2)
	// q == 1 (i > 1)
	// reference: https://atcoder.jp/contests/agc026/submissions/2845729 (line:93)
	inline Modint inverse() const
	{
		assert(this->value != 0);
		int r0 = p, r1 = this->value, a0 = 0, a1 = 1;
		while (r1)
		{
			int q = r0 / r1;
			r0 -= q * r1;
			swap(r0, r1);
			a0 -= q * a1;
			swap(a0, a1);
		}
		return Modint(a0);
	}

	friend istream &operator>>(istream &is, Modint<p> &a)
	{
		long t;
		is >> t;
		a = Modint<p>(t);
		return is;
	}
	friend ostream &operator<<(ostream &os, const Modint<p> &a)
	{
		return os << a.value;
	}
};

const int MOD = 1e9 + 7;

using Int = Modint<MOD>;

void solve(void)
{
	string n;
	cin >> n;
	vector<Int> dp(3);
	dp[0] = 1;
	for (char c : n)
	{
		vector<Int> nx(3);
		int x = c - '0';
		for(int s = 0; s <= 2; s++)
		{
			for(int k = 0; k < 2; k++)
			{
				int s2 = min(2, 2*s + x - k);
				if(s2 >= 0)
				{
					nx[s2] += dp[s] * Int(k ? 2 : 1);
				}
			}
        }
		swap(dp, nx);
	}
	Int ans = 0;
	for (Int v : dp)
	{
		ans += v;
	}
	cout << ans << endl;
}

int main()
{
	solve();
	//cout << "yui(*-v・)yui" << endl;
	return 0;
}


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

#define fast ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define ll long long
#define ldb long double 
#define db double
#define str string

#define fr first
#define se second
#define lb lower_bound 
#define ub upper_bound 
#define pb push_back
#define mpr make_pair

#define pi pair<int,int>
#define pll pair<ll,ll>
#define pdb pair<db,db>
#define pldb pair<ldb,ldb>

#define vi vector<int>
#define vll vector<ll>
#define vdb vector<db>
#define vldb vector<ldb>
#define vpi vector< pi >
#define vpll vector< pll >

#define mi map<int,int>
#define mll map<ll,ll>
#define mdb map<db,db>
#define mldb map<ldb,ldb>


#define forr(a,b) for (int i = (a); i < (b); ++i)
#define rrof(a,b) for (int i = (b)-1; i >= (a); --i)

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

const int md = 1e9+7;
const int MX = 2e5+5;
const ll INF = 1e18; 
const ldb PI = 4*atan((ldb)1);

ll power(ll a,ll n)
{
 ll res=1;
 while(n)
{
 if(n%2)
  res*=a;
  a*=a;
  n/=2;
}
return res;
}

ll abst(ll a)
{
 return ((a<0)?(-1*a):(a));
}

int main()
{
    ll n;
    cin>>n;
    if(n<=9)
     cout<<n<<"\n";
     else
     {
         ll cnt=0;
         map< pair<int,int>,int > mp;
    for(int i=1;i<=n;i++)
    {
        int p=i%10;
        ll c=i;
        while((c/10)!=0)
         c/=10;
        int q=c;
        if(p!=0&&q!=0)
         mp[{p,q}]++;
    }
    for(int i=1;i<=n;i++)
    {
        int p=i%10;
        ll c=i;
        while((c/10)!=0)
         c/=10;
        int q=c;
        if(p!=0&&q!=0)
        cnt+=mp[{q,p}];
    }
    cout<<cnt<<"\n";
     }
    return 0;
}

Measured memory_bytes: 256
import sys
from sys import stdin,stdout
import math
import random
import heapq
from collections import Counter
from functools import lru_cache
#@lru_cache(maxsize=None) #for optimizing the execution time of callable objects/functions(placed above callable functions)
try:
    for _ in range(1):
        n=int(input())
        c=0
        flg=0
        for i in range(n):
            a,b=map(int,input().split())
            if a==b:
                c+=1
                if c>=3:
                    flg=1
            else:
                c=0
        if flg:
            print("Yes")
        else:
            print("No")







    
except EOFError as e:
    print(e)


Measured memory_bytes: 76728
#include <iostream>
#include <cstring>
#include <cstdlib>


int main()
{
    const uint N_MAX = 100000;

    int N = 1;
    int t[N_MAX], x[N_MAX], y[N_MAX] = {0};
    bool possible = true;

    // Input
    std::cin >> N;
    for (int i = 0; i < N; ++i) {
        std::cin >> t[i] >> x[i] >> y[i];
    }
    
    // Judge
    for (int i = 0; i < N; ++i) {
        // Max distance
        possible = x[i] + y[i] <= t[i];
        // Count
        if (possible) {
            possible = (x[i] + y[i] + t[i]) % 2 == 0;
        }
        if (!possible) {
            break;
        }
    }

        // Output
        std::cout << (possible ? "Yes" : "No") << std::endl;
    return 0;
}


Measured memory_bytes: 1408
#include<iostream>
#include<map>
#include<vector>
#include<algorithm>
using namespace std;

int main()
{
  int N;
  cin >> N;
  vector<tuple<string, int, int>> vp;
  for(int i = 0; i < N; i++){
    int n;
    string s;
    cin >> s >> n;
    vp.push_back(make_tuple(s, n, i+1));
  }
  sort(vp.begin(), vp.end(), [](auto const &lvp, auto const &rvp)->bool{
    if(get<0>(lvp) != get<0>(rvp)) return get<0>(lvp) < get<0>(rvp);
    else return get<1>(lvp) > get<1>(rvp);
  });
  for(tuple<string, int, int> p : vp){
    int n;
    tie(ignore, ignore, n) = p;
    cout << n << endl;
  }
  return 0;
}

Measured memory_bytes: 764
#include <bits/stdc++.h>
#define ff first
#define ss second
#define endl '\n'
using namespace std;
const long long INF = (long long) 1e18;
const int mod = (int) 1e9+7;
const int MAXN = (int) 1e5+5;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
ll n, k;
ll dp[105][MAXN];
ll pre[105][MAXN];
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);cout.tie(nullptr);

    #ifdef Local
        freopen("../IO/int.txt","r",stdin);
        freopen("../IO/out.txt","w",stdout);
    #endif

    cin>>n>>k;

    ll a;
    cin>>a;
    for(int i = 0; i <= a; i++){
        dp[0][i] = 1;
        pre[0][i] = (i != 0 ? pre[0][i - 1] : 0) + 1;
    }
    for(int i = a + 1; i <= k; i++){
        pre[0][i] = pre[0][i - 1];
    }
    for(int i = 1; i < n; i++){
        ll a;
        cin>>a;
        for(int j = 0; j <= k; j++){
            dp[i][j] = pre[i - 1][j] - (j >= a + 1 ? pre[i - 1][j - a - 1] : 0) + mod;
            dp[i][j] %= mod;
            pre[i][j] = (j != 0 ? pre[i][j - 1] : 0) + dp[i][j];
            pre[i][j] %= mod;
        }
    }

    cout<<dp[n - 1][k]<<endl;

    #ifdef Local
        cout<<endl<<fixed<<setprecision(2)<<1000.0 * clock() / CLOCKS_PER_SEC<< " milliseconds ";
    #endif
}

Measured memory_bytes: 160000
#include <stdio.h>
#include <math.h>

int isPrime(int);
int main(){
  int n,count=0,i,v[100001];

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&v[i]);
    count+=isPrime(v[i]);
  }
  
  
  printf("%d\n",count);

  return 0;
}



int isPrime(int x)
{
  int i=3;
  if(x==2) return 1;
  if(x<2 || x%2==0){
    return 0;
  }
  while(i<=sqrt(x)){
    if(x%i==0)      return 0;
      i=i+2;
  }
  return 1;
}

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

using namespace std;

#define FOR(i,a,b) for(int i(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second

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

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

const ll INF = 1e9+100;
const bool debug = 0;

ll N, M;
ll d, v, ans;
ll S[112];

int main() {
	while (cin>>N>>M, (N||M)){
		fill(S, S+112, 0);
		ans = 0;
		REP( i, N ){
			cin>>d>>v;
			S[d] = max( S[d], v );
		}
		FOR( i, 1, M+1 ) ans += S[i];
		cout<<ans<<endl;
	}
	return 0;
}


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

//#include <atcoder/all>

using namespace std;
//using namespace atcoder;

//#define int long long
#define ll long long

ll INF = (1LL << 60);
int mod = 998244353;
using P = pair<ll, ll>;

signed main() {
	int r; cin >> r;
	cout << 3 * r*r << endl;
	return 0;
}




Measured memory_bytes: 3612
#include<cstdio>
#include<algorithm>
#include<string.h>
#include<iostream>
#include<map>
using namespace std;
map<int,string> name;
map<int,string>::iterator it;
int d[1000000];
int main()
{
   int n,m,i,a; string b; 
   cin>>n>>m;
   int s=0,ss=0;
   memset(d,0,sizeof(d));
   for(i=0;i<m;i++)
   {   cin>>a>>b;
      if(!name.count(a))
      name[a]=b;
      if(b=="AC")
      name[a]=b;
      if(name[a]!="AC")
      d[a]++;
   }
   s=0;
   for(i=1;i<=n;i++)
   {
   	if(name[i]=="AC")
   	{
	   ss++;
   	   s+=d[i];
   	}
   }
   printf("%d %d\n",ss,s);
}

Measured memory_bytes: 15104
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_int.hpp>
//typedef boost::multiprecision::cpp_int ll;
typedef long double dd;
//#define i_7 (ll)(1E9+7)
#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E17;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
///////////////////////////////////////


int main(){fastio
    
    ll a=0;
    string b,c;cin>>b>>c;
    rep(i,0,b.size()-1){
        if(b[i]==c[i])a++;
    }
    cout<<a<<endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <cassert>
#include <random>
#include <bitset>
using namespace std;
 

#define FAST_IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define all(x) x.begin(), x.end()
#define ff first
#define ss second
#define pb push_back
#define forn(i, n) for (int i = 0; i < n; ++i)
#define int long long

 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
 
 
const int MAXN = 5e5 + 5;
const ll MOD = 998244353;
const ll INF = INT64_MAX;


random_device rd;
mt19937 rnd(rd());


ll pw(ll a, ll x) {
	ll res = 1;
	while (x > 0) {
		if (x & 1) {
			res = (res * a) % MOD;
		}
		a = (a * a) % MOD;
		x >>= 1;
	}
	return res;
}


signed main() {
	FAST_IO;
	string s;
	cin >> s;
	s = "00" + s;
	int ans = 0;
	int n = s.size();
	for (int i = n - 1; i > 0; i--) {
		if (s[i] < '5') {
			ans += (s[i] - '0');
			continue;
		}
		if (s[i] == '5' && s[i - 1] < '5') {
			ans += 5;
		} else {
			int j = i - 1;
			ans += (10 - (s[i] - '0'));
			while (j >= 0 && s[j] == '9') {
				s[j] = '0';
				j--;
			}
			s[j]++;
		}
	}
	cout << ans << "\n";
 	return 0;
}

Measured memory_bytes: 2332
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors
    
N=int(input())
#print(make_divisors(N))
A=sorted( make_divisors(N))
ans=0
for a in A:
    m=((N//a)-1)
    if m!=0:
        if N//m ==N%m:
            ans+=m
#    if N%((N//a)-1) !=0:
#        ans+=((N//a)-1)
print (ans)


#223092870000

Measured memory_bytes: 39152
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
inline int read()
{
	int x=0,f=1;char c=getchar();
	while(!isdigit(c)){if(c=='-')f=-1;c=getchar();}
	while(isdigit(c)){x=x*10+c-'0';c=getchar();}
	return x*f;
}
const int maxn=310;
const int maxv=500010;
const int mod=1e9+7;
int n,d[maxn];
ll fac[maxv],inv[maxv],f[maxn][maxn][maxn],anc[maxv];
template<typename T> inline void sol(T &x){if(x>=mod)x%=mod;}
inline void init()
{
	fac[0]=fac[1]=inv[0]=inv[1]=anc[0]=anc[1]=1;
	for(int i=2;i<=maxn;i++) fac[i]=fac[i-1]*i%mod;
	for(int i=2;i<=maxn;i++) inv[i]=(mod-mod/i)*inv[mod%i]%mod;
	for(int i=2;i<=maxn;i++) anc[i]=anc[i-1]*inv[i],sol(anc[i]);
//	printf("%lld\n",fac[100]*anc[100]%mod);
}
int main()
{
	init();
	n=read();for(int i=0;i<n;i++) d[i]=read();
	
	//special_judge
	bool flag=1;for(int i=0;i<n;i++) if(d[i]!=2){flag=0;break;}
	if(flag) return printf("%lld\n",fac[n-1]%mod*inv[2]%mod),0;
	//end of special_judge
	f[0][0][0]=1;
	for(int i=0;i<n;i++)
		for(int j=0;j<=i;j++)
		{
			for(int k=0;k<=n;k++)
			{
//				printf("%d %d %d %lld\n",i,j,k,f[i][j][k]);
				f[i+1][j][k]+=f[i][j][k]*anc[d[i]-1]%mod;sol(f[i+1][j][k]);
				if(d[i]>=2) f[i+1][j+1][k+d[i]-2]+=f[i][j][k]*anc[d[i]-2]%mod,sol(f[i+1][j+1][k+d[i]-2]); 
			}
		}
	
	ll ans=0;
	for(int i=3;i<n;i++)
		for(int j=0;j<=n;j++) 
//			printf("%d %d %lld\n",i,j,f[n][i][j]),
			ans+=f[n][i][j]*fac[n-i-1]%mod*j%mod*inv[2]%mod*fac[i-1]%mod,sol(ans);
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 233856
#include<iostream>

using namespace std;
int main()
{
    string s;
    cin>>s;
    int j=0,s1=0,s2=0;
    while(s[j]!='\0'){
          if(s[j]!='h' && s[j]!='i'){
             cout<<"No"<<endl;

             return 0;
          }
          if(s[j]=='h'){
             s1++;
             /**if(s1!=s2+1){
                ///cout<<s1<<" "<<s2+1<<endl;
                cout<<"No"<<endl;

                return 0;
             }*/
          }
          if(s[j]=='i'){
             s2++;
             ///cout<<s2<<endl;
             if(s2!=s1){
                cout<<"No"<<endl;

                return 0;
             }
          }
       j++;
    }
    ///cout<<s1<<" "<<s2<<endl;
    if(s1==s2){
       cout<<"Yes"<<endl;
    }
    else{
       cout<<"No"<<endl;
    }


    return 0;
}


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

int findprice(int n){
  for(int i=0;i<10001;i+=1000){
    if(i>=n){return i;}
  }
}

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

  int p=findprice(n);
  cout<<p-n;
}

Measured memory_bytes: 3612
#include <iostream>
using namespace std;
int main(void){
    int n;
    cin >> n;
    string t, h;
    int T = 0;
    int H = 0;
    for (int i = 0; i < n; i++){
        cin >> t >> h;
        if(t.compare(h) == 0){
            T++;
            H++;
        }
        if (t.compare(h) > 0)
            T += 3;
        if (t.compare(h) < 0)
            H += 3;
    }
    cout << T << " " << H << endl;
}



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

    int N = S.length();
    int c = N;
    int f = 0;

    for (int i = 0; i < N; i++){
        if (S[i] == 'C'){
            c = min(c, i);
        }
        else if(S[i] == 'F'){
            f = max(f, i);
        }
    }

    if(c < f){
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_set>
#include <vector>

using namespace std;

#define FOR(i, N) for (int i = 0; i < (int)N; i++)
#define FORIN(i, a, b) for (int i = a; i < (int)b; i++)
#define ALL(x) (x).begin(), (x).end()
#define MOD 1000000007
#define DEBUG(...) debug(__LINE__, ":" __VA_ARGS__)

using Pi = pair<int, int>;
using ll = long long;
const int INF = 1 << 28;

string to_string(string s) {
  return s;
}

template <class T>
string to_string(vector<T> v) {
  string ret = "{";
  for (int i = 0; i < v.size() - 1; ++i) {
    ret += to_string(v[i]) + ",";
  }
  if (v.size() > 0) {
    ret += to_string(v.back());
  }
  ret += "}";
  return ret;
}

void debug() {
  cerr << endl;
}

template <class Head, class... Tail>
void debug(Head head, Tail... tail) {
  cerr << to_string(head) << " ";
  debug(tail...);
}

void print() {
  cout << endl;
}

template <class Head, class... Tail>
void print(Head head, Tail... tail) {
  cout << to_string(head);
  print(tail...);
}

void get() {}

template <class Head, class... Tail>
void get(Head& head, Tail&... tail) {
  cin >> head;
  get(tail...);
}

template <class T>
void getv(vector<T>& vec) {
  for (int i = 0; i < vec.size(); ++i)
    cin >> vec[i];
}

int main() {
  int L, R;
  get(L, R);
  int ld = L / 2019, rd = R / 2019;
  int lx = L % 2019, rx = R % 2019;
  if (ld == rd) {
    int ans = 1 << 28;
    for (int i = lx; i < rx; ++i) {
      for (int j = i + 1; j <= rx; ++j) {
        ans = min(ans, i * j % 2019);
      }
    }
    print(ans);
  } else if (ld > rd - 3) {
    L %= 2019;
    R -= ld * 2019;
    int ans = 1 << 28;
    for (int i = L; i < R; ++i) {
      for (int j = i + 1; j <= R; ++j) {
        ans = min(ans, i * j % 2019);
      }
    }
    print(ans);
  } else {
    print(0);
  }
  return 0;
}

Measured memory_bytes: 256