akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;
#define pb push_back
#define F first
#define S second
//#define biGinf 9e+18
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define inpv(v) for(auto &x:v) cin>>x
#define otpv(v) for(auto &x:v) cout<<x<<nwl
#define otpv2(v) for(auto &x:v) cout<<x<<" "
#define CASES int tt;cin>>tt; while(tt--)
#define for0(i,n) for(int i=0; i<n; i++)
#define for1(i,n) for(int i=1; i<=n; i++)
#define sz(v) (int)(v).size()
using vi = vector < int >;
using vvi = vector < vi >;
using pii = pair < int , int >;
using vpii = vector < pii >;
using int64 = long long;
//const int64 biGinf = 9e+18;
//const string yo = "YES", no = "NO";
const int inf = 2e9 + 7;
const char nwl = '\n';

int64 calc(vpii &inp, int w, int n, int64 s) {
	vector < int64 > res(s + 1, inf);
	res[0] = 0;
	for (auto t : inp) {
		for (int64 i = s; i >= t.S; i--) {
			res[i] = min(res[i] , res[i - t.S] + (int64)t.F);
		}
	}
	// otpv2(res);
	// cout << nwl;
	int x = 0;
	for (int64 i = 0; i <= s; i++) {
		if (res[i] <= w) {
			x = i;
		}
	}
	return x;
}



int main() {
// #ifndef ONLINE_JUDGE
// 	if (fopen("input.txt", "r")) {
// 		freopen("input.txt", "r", stdin);
// 		freopen("output.txt", "w", stdout);
// 	}
// #endif
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	//ur code
	int n, w;
	cin >> n >> w;
	vpii inp;
	int64 s = 0;
	for0(i, n) {
		int w, v;
		cin >> w >> v;
		s += (int64)v;
		inp.pb({w, v});
	}
	sort(all(inp));
	int64 ans = calc(inp, w, n, s);
	cout << ans;
	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, x, n) for (int i = x; i < (n); i++)
#define all(n) begin(n), end(n)
struct cww
{
    cww()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
} star;
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
typedef vector<int> vint;
typedef vector<char> vchar;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef unsigned long long ull;
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

template <typename T, typename... Ts>
auto make_v(size_t a, Ts... ts)
{
    return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T &t, const V &v) { t = v; }

template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T &t, const V &v)
{
    for (auto &e : t)
        fill_v(e, v);
}
int main()
{
    int H, W, cnt = 0;
    cin >> H >> W;
    auto s = make_v<char>(H, W);
    rep(i, H) rep(j, W)
    {
        cin >> s[i][j];
        if (s[i][j] == '#')
            cnt++;
    }
    auto dis = make_v<int>(H, W);
    fill_v(dis, -1);
    using P = pair<int, int>;
    queue<pair<P, int>> q;
    q.push({{0, 0}, 0});
    int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
    while (!q.empty())
    {
        auto pos = q.front().first;
        int num = q.front().second;
        q.pop();
        for (size_t i = 0; i < 4; i++)
        {
            int nx = pos.second + dx[i], ny = pos.first + dy[i];
            if (0 <= nx and nx < W and 0 <= ny and ny < H and s[ny][nx] == '.' and dis[ny][nx] == -1)
            {
                q.push({{ny, nx}, num + 1});
                dis[ny][nx] = num + 1;
            }
        }
    }
    if(dis[H-1][W-1]!=-1)
    cout << H * W - dis[H - 1][W - 1] - cnt - 1;
    else
    {
        cout<<-1;
    }
    
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner in = new Scanner(System.in);

		while (true) {

			// ????????¢????????¨?¨????????????\???
			int height = in.nextInt();
			int width = in.nextInt();

			// ??\?????????(0,0)??????????????????
			if (height == 0 && width == 0) {
				break;
			} else {

				// ?????????????????°??????????????????
				for (int count_h = 0; count_h < height; count_h++) {

					if(count_h == 0 || count_h == (height-1)) {

						// ?¨???????????????°??????#?????¨???
						for (int count_w = 0; count_w < width; count_w++) {

							System.out.print("#");
						}

					}else{
						System.out.print("#");

						for (int count_w = 0; count_w < (width-2); count_w++) {

							System.out.print(".");
						}
						System.out.print("#");

					}

					System.out.println();
				}

				// ?????????????????????????????????????????\
				System.out.println();
			}
		}
	}
}

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

using namespace std;

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

    int a[200001], aa[200001];
    for (int i = 1; i <= n; ++i) {
        cin >> a[i];
        aa[i] = a[i];
    }
    sort(aa + 1, aa + n + 1);

    int lft = aa[n / 2], rgt = aa[n / 2 + 1];
    for (int i = 1; i <= n; ++i) {
        if (a[i] <= lft) {
            cout << rgt << endl;
        } else {
            cout << lft << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 3712
#include<bits/stdc++.h>
#define int long long
#define double long double
#define vi vector<int>
#define vpi vector<pair<int,int> >
#define mii map<int,int>
#define mpi map<pair<int,int>,int>
#define msi map<string,int>
#define set set<int>
#define u_set unordered_set<int>
#define pb push_back
#define endl "\n"
#define ll long long int
#define vll vector<long long int>
#define vi vector<int>
#define vvi vector<vector<int>>
#define io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define umap unordered_map 
#define mod 1000000007
#define fori(a,n) for(int i=a;i<n;i++)
#define forj(a,n) for(int j=a;j<n;j++)
#define MAX 300303
#define V vector
using namespace std;

V<bool> dp(100005,0);

signed main()
{
    io
    int n;
    int k;
    cin >> n >> k;
    vi p(n);
    fori(0,n)cin >> p[i];
    sort(p.begin(),p.end());
    fori(0,p[0]){
        dp[i] = 0;
    }
    dp[p[0]] = 1;
    int cnt = 1;
    fori(p[0]+1,k+1){
        if(cnt < n && i==p[cnt]){++cnt; dp[i] = 1;continue;}
        forj(0,cnt){
            dp[i] = dp[i] | 1^(dp[i-p[j]]);
            if(dp[i])break;
        }
    }
    if(dp[k])
    cout << "First" << endl;
    else cout << "Second" << endl;

} 

Measured memory_bytes: 256
using System;

namespace _066b
{
    class Program
    {
        static void Main(string[] args)
        {
            string S = Console.ReadLine();
            int newLength = S.Length -2;
            int syutokuMoji = newLength/2;
            int startUshiro = newLength/2;
            string newS = S.Substring(0,newLength);
            string maeNewS = S.Substring(0,syutokuMoji);
            string ushiroNewS = S.Substring(startUshiro,syutokuMoji);
            
            while(true){
                if(maeNewS == ushiroNewS){
                    Console.WriteLine(newS.Length);
                    break;
                }else{
                    newLength -= 2;
                    syutokuMoji = newLength/2;
                    startUshiro = newLength/2;
                    newS = S.Substring(0,newLength);
                    maeNewS = S.Substring(0,syutokuMoji);
                    ushiroNewS = S.Substring(startUshiro,syutokuMoji);
                    //Console.WriteLine(maeNewS);
                    //Console.WriteLine(ushiroNewS);
                }
            }
        }
    }
}

Measured memory_bytes: 11092
#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

string str;

int main(void){
	cin >> str;
	int cnt=0;
	for(int i=1;i<str.size();i++){
		if(str[i]!=str[i-1])cnt++;
	}
	printf("%d\n",cnt);
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
 
using namespace std;
using namespace __gnu_pbds;
 
//find_by_order gives kth-largest element
//order_of_key gives the number of items in the set that are strictly smaller!!
 
// OT.find_by_order(k-1)
// 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
 
#define db(x) cerr << #x << "=" << x << endl
#define db2(x, y) cerr << #x << "=" << x << "," << #y << "=" << y << endl
#define db3(x, y, z) cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z << endl
#define db4(x, y, z, w) cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z << "," << #w << "=" << w << endl
#define ll long long
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define mp make_pair
#define X first
#define Y second
#define sz(x) (int)((x).size())
#define pii pair<int,int>
#define MOD (ll)(1e9 + 7)
#define rep(i, n)    for(int i = 0; i < (n); ++i)
#define repA(i, a, n)  for(int i = a; i <= (n); ++i)
#define repD(i, a, n)  for(int i = a; i >= (n); --i)
#define trav(a, x) for(auto& a : x)
typedef vector<int> vi;
#define inf (ll)(1e18)
#define double long double
#define int long long
 
//////////////////////
const int N = 100005;


int32_t main() {
 
    ios::sync_with_stdio(false);
    cin.tie(0); 
    cout.tie(0);
	
	int tt = 1;
	// cin >> tt;

	while(tt--) {
		string st;
		cin >> st;
		int n = sz(st);
		int cnt = 0;
		rep(i,n/2) {
			if(st[i]!=st[n-1-i])
				cnt++;
		}
		cout << cnt << '\n';
	}
}

		

Measured memory_bytes: 256
def main():
    A, B, C, X, Y = map(int, input().split())

    sum = 100000000000000000000000000000000
    for i in range(0, max(X,Y)*2+2, 2):
        if X-i//2 < 0 and Y-i//2 >= 0:
            sum = min(sum, B*(Y-i//2) + C*i)
        elif X-i//2 >= 0 and Y-i//2 < 0:
            sum = min(sum, A*(X-i//2) +C*i)
        else:
            sum = min(sum, A*(X-i//2) + B*(Y-i//2) + C*i)
    print(sum)

if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
using namespace std;
int n, a[100000];
vector<int> v[100000];
long long f(int x, int y){
    long long s = 0, b;
    if(v[x].size() == 1)return a[x];
    for(int i=0;i<v[x].size();i++){
        int z = v[x][i];
        if(z != y){
            long long w = f(z, x);
            if(w <= -1)return -1;
            s += w;
            if(w > a[x])return -1;
        }
    }
    if(y == -1){
        if((long long)a[x]*2 == s)return 1;
        return -1;
    }
    b = a[x]*2 - s;
    if(b > a[x])return -1;
    return b;
}
int main() {
    cin >> n;
    for(int i=0;i<n;i++)cin >> a[i];
    for(int i=0;i<n-1;i++){
        int x, y;
        cin >> x >> y;
        --x;
        --y;
        v[x].push_back(y);
        v[y].push_back(x);
    }
    if(n == 2){
        if(a[0] == a[1])puts("YES");
        else puts("NO");
        return 0;
    }
    for(int i=0;i<n;i++){
        if(v[i].size() > 1){
            long long w = f(i, -1);
            if(w == 1)puts("YES");
            else puts("NO");
            return 0;
        }
    }
	return 0;
}


Measured memory_bytes: 12800
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
  int N;
  cin>>N;
  vector<int> A(N);
  for(int i=0;i<N;i++){
    cin>>A[i];
  }
  sort(A.begin(),A.end());
  double ans;
  ans = (double)(A[0]+A[1])/2;
  for(int i=0;i<N-2;i++){
    ans=(double)(ans+A[i+2])/2;
  }
  cout<<ans<<endl;
  return 0;
}

    

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#define PI 3.14159265359
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
const long long INF= 1e+18+1;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll> >vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
const ll MOD=1000000007LL;
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
int main(){
  string s;cin>>s;
  ll count=0;
  rep(i,4){
    if(s[i]=='2')count++;
  }
  cout<<count<<endl;
}

Measured memory_bytes: 256
n = gets.chomp.to_i
turn_left = Array.new(n, 0)
turn_right = Array.new(n, 0)
s = gets.chomp.split("")

(1..n-1).each do |i| 
    if s[i-1] == "W"
        turn_left[i] = (turn_left[i-1]+1)
    else
        turn_left[i] = (turn_left[i-1])
    end
end
(0..n-2).each do |i|
    i = n-2 - i
    if s[i+1] == "E"
        turn_right[i] = (turn_right[i+1]+1)
    else 
        turn_right[i] = turn_right[i+1]
    end
end

min = n
(0..n-1).each do |i|
    sum = turn_left[i] + turn_right[i]
    if min > sum
        min = sum
    end
end
puts min

Measured memory_bytes: 32140
#include<iostream>
#include<list>
#include<algorithm>
#include<string>
using namespace std;

int main()
{
	list<int> v;
	int n, x;
	string str;
	cin >> n;
	while (n--)
	{
		cin >> str;
		if (str[0] == 'i')
		{
			cin >> x;
			v.push_front(x);
		}
		else if (str[6] == 'F')
		{
			v.pop_front();
		}
		else if (str[6] == 'L')
		{
			v.pop_back();
		}
		else if (str[0] == 'd')
		{
			cin >> x;
			
			for (list<int>::iterator iter = v.begin(); iter != v.end(); iter++)
				if (*iter == x)
				{ 
					v.erase(iter);
					break;
				}
		}
	}
	for (list<int>::iterator iter = v.begin(); iter != v.end(); iter++)
	{
		if (iter != v.begin())cout << " ";
		cout << *iter;
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 34344
using System;
// using System.Collections.Generic;
// using System.Linq;

class Program
{
    static long calc(long n, long N)
    {
        return (n + N / n * n) * (N / n) / 2;
    }

    static void Main()
    {
        long N = long.Parse(Console.ReadLine());
        Console.WriteLine(calc(1L, N) - calc(3L, N) - calc(5L, N) + calc(15L, N));
        return;
    }
}

Measured memory_bytes: 27448
N, M = map(int, input().split())
L = []
R = []
for _ in range(M):
    inp = input().split()
    L.append(int(inp[0]))
    R.append(int(inp[1]))
L_max = max(L)
R_min = min(R)
print(max(0,min(R_min,N) + 1 - L_max))

Measured memory_bytes: 10996
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] d = new int[N];
        for (int i = 0; i < N; i++) {
            d[i] = sc.nextInt();
        }
        sc.close();

        System.out.println(PrimeSum(N, d));
    }
    public static long PrimeSum(int N, int[] d) {
        if (N < 2) {
            return 0;
        }
        long sum = 0;
        for (int i = 0; i < N-1; i++) {
            sum += (d[N-1] * d[i]);
        }
        return sum + PrimeSum(N-1, d);
    }
}


Measured memory_bytes: 23636
#include <iostream>

using namespace std;

int n, s, cont, cost;

void dps(int sum, int i, int cost);

int main()
{
    while(cin >> n >> s)
    {
        if(n == 0 && s == 0)    break;
       
        cont = 0;
        dps(0, 0, 0);
        cout << cont << endl;
    }

    return 0;
}

void dps(int sum, int i, int cost)
{
	if(cost == n && sum == s)	cont++;
	if(i == 10 || cost == n)	return;
	dps(sum+i, i+1, cost+1);
	dps(sum, i+1, cost);
}

Measured memory_bytes: 1156
//g++ -std=c++14 test.cpp -o test.out
 
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <stack>
#include <map> 
#include <unordered_map> 
#include <utility>
#include <limits.h>
#include <bitset>
#include <set>
using namespace std;
 
#define LL long long int
const LL INF = (1LL<<60);
const int INF_INT = 2147483647-1e6-1;
const LL mod = 1000000007ll;
const int mod_int = 1000000007;

LL N;
LL D1[100],D2[100];

string ans = "No";

void solve(){
    for(int i=2;i<N;i++){
        if(D1[i]==D2[i] && D1[i-1]==D2[i-1] && D1[i-2]==D2[i-2]){
            ans = "Yes";
            return;
        }
    }
}
 
int main(){
	cin >> N;
    for(int i=0;i<N;i++) cin >> D1[i] >> D2[i];
 
    solve();

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

Measured memory_bytes: 3132
// lcmとか__builtin_popcountとかはg++ -std=c++17 default.cppみたいなかんじで

#include <bits/stdc++.h>
#define mod 1000000007
#define INF LLONG_MAX
#define ll long long
#define ln cout<<endl
#define Yes cout<<"Yes"<<endl
#define NO cout<<"NO"<<endl
#define YES cout<<"YES"<<endl
#define No cout<<"No"<<endl
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
using namespace std;
ll dx[4]={1,0,-1,0};
ll dy[4]={0,1,0,-1};

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

    ll  a,b,c,d,e,n,k,maxi=0,f=0,mini=INF,sum=0,q;
	string str,stra,straa;
    ll x,y,z;
    char ca,cb,cc;
    cin>>n;
    cout<<3*n*n<<endl;
    return 0;
}


Measured memory_bytes: 3644
import sys
from collections import Counter

import sys
sys.setrecursionlimit(10**6)
table = dict()
def choose(n, r, mod=None): # not mod, or mod ≠ prime
  if r > n or r < 0: return 0
  if r == 0: return 1
  if (n, r) in table: return table[(n, r)] 
  table[(n, r)] = (choose(n - 1, r) + choose(n - 1, r - 1))
  # table[(n, r)] = (choose(n - 1, r, mod) + choose(n - 1, r - 1, mod)) % mod
  return table[(n,r)]

n = int(sys.stdin.readline().rstrip())
s = [''.join(sorted(s)) for s in sys.stdin.read().split()]

def main():
    tot = 0
    for c in Counter(s).values():
        tot += choose(c, 2)
    print(tot)

if __name__ ==  '__main__':
    main()

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

    #define ll long long
    #define pb push_back
    #define m 1000000007

    int main() {
      ios_base::sync_with_stdio(false);
      cin.tie(NULL);
      cout.tie(NULL);
      
      
     ll h,w,i,j;
     cin>>h>>w;
     char arr[h][w];
     for(i=0;i<h;i++)
      for(j=0;j<w;j++)
        cin>>arr[i][j];

      ll dp[h][w];
      memset(dp,0,sizeof dp);
      dp[0][0]=1;
      for(i=0;i<h;i++)
      {
        for(j=0;j<w;j++)
        {
          if(arr[i][j]=='.')
          {
            if(i>0)
            dp[i][j]= (dp[i][j] + dp[i-1][j])%m;
            if(j>0)
            dp[i][j]= (dp[i][j] + dp[i][j-1])% m; 
          }
        } 
      }
      cout<<dp[h-1][w-1];
     
      return 0;
    } 

Measured memory_bytes: 9088
from sys import stdin
import sys

# A, B, C, D = [int(x) for x in stdin.readline().rstrip().split()]
# N, M = [int(x) for x in stdin.readline().rstrip().split()]
# U = input().split()
X=int(input())
# A, B = [str(x) for x in stdin.readline().rstrip().split()]
Y=100
cnt=0
while True:
    Y=int(Y*1.01)
    cnt+=1
    if Y>=X:
        print(cnt)
        sys.exit()


Measured memory_bytes: 9160
#include <iostream>
#include <cstdio>
#include <string>
#include <cstdlib>

using namespace std;

int main()
{
	int H, W;
	char num[] = "0123456789";
	char S[50][100];
	scanf("%d %d", &H, &W);
	for (int i = 0; i < H; i++)
		scanf("%s", S[i]);
	for (int i = 0; i < H; i++)
		for (int j = 0; j < W; j++) {
			if (S[i][j] == '#') continue;
			int n = 0;
			if (i) {
				n += S[i - 1][j] == '#';
				if (j) n += S[i - 1][j - 1] == '#';
				if (j<W - 1) n += S[i - 1][j + 1] == '#';
			}
			if (i<H-1) {
				n += S[i + 1][j] == '#';
				if (j) n += S[i + 1][j - 1] == '#';
				if (j<W - 1) n += S[i+ 1][j + 1] == '#';
			}
			n += S[i ][j] == '#';
			if (j) n += S[i ][j - 1] == '#';
			if (j<W - 1) n += S[i ][j + 1] == '#';
			S[i][j] = num[n];
		}
	for (int i = 0; i < H; i++)
		cout << S[i] << endl;
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main(){
    char s[10+1];
    char t[11+1];
    scanf("%s",s);
    scanf("%s",t);
    int len=strlen(s);
    int len1=strlen(t);
    for(int i=0;i<len;i++){
        if(s[i]==t[i]){
    
        }else if(s[i]!=t[i]){
            printf("No\n");
            return 0;
        }
    }
    if(len!=len1){
        printf("Yes\n");
    }
}

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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> ii;
typedef map<int, int> MPII;
typedef set<int> SETI;

const int mxN = 2e5;
const ld pi = 4.0 * atanl(1.0);
const int iinf = 1e9 + 10;
const int inf = 1e18 + iinf + 10;
const int mod = 1000000007;
const ld prec = .000001;

#define F first
#define S second
#define pb push_back
#define mp make_pair
#define all(c) c.begin(), c.end()
#define rall(c) c.end(), c.begin()

int n, m, t, a[mxN];
vi v;

void fast() { ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); }

int main() {
  fast();
  int a, b;
  cin >> n >> a >> b;
  string s;
  cin >> s;
  int p = 0, o = 1;
  int x = a + b;
  for (int i = 0; i < s.length(); ++i) {
    if (s[i] == 'a') {
      if (p < x) {
        ++p;
        cout << "Yes"
             << "\n";
      } else {
        cout << "No"
             << "\n";
      }
    } else if (s[i] == 'b') {
      if (p < x && o <= b) {
        ++p, ++o;
        cout << "Yes"
             << "\n";

      } else {
        cout << "No"
             << "\n";
      }
    } else
      cout << "No"
           << "\n";
  }

  return 0;
}



Measured memory_bytes: 3784
/*|In The Name Of Allah|*/

#include <bits/stdc++.h>

using namespace std;

typedef pair < int , pair < int , int > > pll;

const int N = 1e5+5;

int n;
int m;
int dist[N];
int indeg[N];
vector < pair < int , int > > adj[N];

int main(){
    memset(dist , -1 , sizeof dist);
    scanf("%d%d" , &n , &m);
    for(int i = 1; i <= m; i++){
        int l , r , d;
        scanf("%d%d%d" , &l , &r , &d);
        adj[l].push_back({r , d});
        indeg[r]++;
    }
    int bad = 0;
    for(int i = 1; i <= n; i++){
        if(!indeg[i]){
            queue < int > q;
            q.push(i);
            dist[i] = 0;
            while(!q.empty()){
                int u = q.front();
                q.pop();
                for(auto nw : adj[u]){
                    int v = nw.first;
                    int d = nw.second;
                    if(dist[v] == -1){
                        dist[v] = dist[u] + d;
                        if(dist[v] > 1e9)
                            bad = 1;
                        q.push(v);
                    } else {
                        if(dist[v] != d + dist[u]){
                            bad = 1;
                        }
                    }
                }
            }
        }
    }
    for(int i = 1; i <= n; i++){
        if(dist[i] == -1)
            bad = 1;
    }
    puts(bad ? "No" : "Yes");
}

Measured memory_bytes: 6784
#pragma GCC optimize("O3")
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using P = pair<ll,ll>;
using um = unordered_map<ll,ll>;
#define fl cout<<flush;
#define endl '\n'
template <typename T> inline void prt(T v){cout<<v<<'\n';}
template <typename T> inline bool chmax(T &a, const T &b){if (a<b){a=b;return 1;}return 0;}
template <typename T> inline bool chmin(T &a, const T &b){if (a>b){a=b;return 1;}return 0;}
const ll INF=1LL<<60;
const ll MOD=1e9+7;
const ll MOD2=998244353;
const ld pi=3.14159265358979323846;
const ld eps=1e-10;

signed main(void){
    cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);
    string S;
    cin >> S;
    string T;
    cin >> T;
    ll ans=0;
    for(ll i=0;i<S.size();++i){
        if(S[i]!=T[i])ans++;
    }
    prt(ans);

    return 0;
}



Measured memory_bytes: 3844
#include <stdio.h>

int n, m, a;

int main() {
    while (1) {
        scanf("%d %d", &n, &m);
        if (n == 0 && m == 0) break;
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < m; j++) {
                printf("#");
            }
            printf("\n");
        }
        printf("\n");
    }
}


Measured memory_bytes: 2048
import java.util.*;
import java.io.*;

public class Main {

    public static void main(String[] args) throws IOException {
        Scanner sc = new Scanner(System.in);
        PrintWriter pw = new PrintWriter(System.out);
        int n = sc.nextInt();
        int [] vals = sc.nextIntArr(3);
        long sum =1l*vals[0]+vals[1]+vals[2];
        int[][]nxt = new int[3][n+1];
        nxt[0][n]=nxt[1][n]=nxt[2][n]=n;
        char[][]a= new char[n][2];
        for (int i =0;i<n;i++)a[i]=sc.next().toCharArray();
        for (int i =n-1;i>=0;i--){
            for (int j =0;j<3;j++)
                nxt[j][i]=nxt[j][i+1];
            if (i<n-1) {
                nxt[a[i+1][0] - 'A'][i] = i+1;
                nxt[a[i+1][1] - 'A'][i] = i+1;
            }
        }
        if (sum==0)
            pw.println("No");
        else {
            boolean valid = true;
            StringBuilder sol = new StringBuilder();
            for (int i =0;i<n;i++){
                char[]s = a[i];
                int id1=s[0]-'A';
                int id2=s[1]-'A';
                if (vals[id1]==vals[id2]&&vals[id1]==0){
                    valid=false;
                    break;
                }
                if (vals[id1]>vals[id2]){
                     sol.append(s[1]+"\n");
                     vals[id2]++;
                     vals[id1]--;
                }
                else if (vals[id1]<vals[id2]){
                    sol.append(s[0]+"\n");
                    vals[id2]--;
                    vals[id1]++;
                }
                else {
                    if (nxt[id1][i]<nxt[id2][i]){
                        sol.append(s[0]+"\n");
                        vals[id2]--;
                        vals[id1]++;
                    }
                    else {
                        sol.append(s[1]+"\n");
                        vals[id2]++;
                        vals[id1]--;
                    }
                }
            }
            if (valid){
                pw.println("Yes");
                pw.print(sol);
            }
            else pw.println("No");
        }
        pw.close();

    }
    static class Scanner {
        BufferedReader br;
        StringTokenizer st;

        public Scanner(InputStream s) {
            br = new BufferedReader(new InputStreamReader(s));
        }

        public String next() throws IOException {
            while (st == null || !st.hasMoreTokens())
                st = new StringTokenizer(br.readLine());
            return st.nextToken();
        }

        public int nextInt() throws IOException {
            return Integer.parseInt(next());
        }

        public long nextLong() throws IOException {
            return Long.parseLong(next());
        }

        public double nextDouble() throws IOException {
            return Double.parseDouble(next());
        }

        public int[] nextIntArr(int n) throws IOException {
            int[] arr = new int[n];
            for (int i = 0; i < n; i++) {
                arr[i] = Integer.parseInt(next());
            }
            return arr;
        }

    }

}


Measured memory_bytes: 58680
import java.util.*;

class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int x,y;
    x = sc.nextInt();
    y = sc.nextInt();
    if(y%x==0){
      System.out.println(x+y);
    }
    else{
      System.out.println(y-x);
    }
  }
}


Measured memory_bytes: 21844
#include<bits/stdc++.h>
#define N 2000009
#define ll long long
#define ld long double
#define ff first
#define ss second
#define inf 1000000005
#define mod 1000000007
using namespace std;
ll n, dp[409][409], p[409];
ll ans;
int main() {
    cin>>n;
    vector<ll> a(n + 1);
    for(int i=1;i<=n;i++) {
        cin>>a[i];
        p[i] = p[i - 1] + a[i];
    }
    for(int len = 2; len <= n; len++) {
        for(int l = 1; l <= n - len + 1; l++) {
            int r = l + len - 1;
            dp[l][r] = 1000000000000000;
            for(int cut = l;cut < r; cut++) {
                ll suml = p[cut] - p[l - 1];
                ll sumr = p[r] - p[cut];
                dp[l][r] = min(dp[l][r], dp[l][cut] + dp[cut + 1][r] + p[r] - p[l - 1]);
            }
        }
    }
    cout<<dp[1][n];
}


Measured memory_bytes: 4912
int main(void){

  int W,H,N,i,j,k,x[100],y[100],a[100];
  int size=0;
  int mat[100][100];
  scanf("%d %d %d",&W,&H,&N);
  for(i=0;i<N;i++){
  	scanf(" %d %d %d",&x[i],&y[i],&a[i]);
  }
  
  for(i=0;i<W;i++){
  	for(j=0;j<H;j++){
    	mat[i][j]=0;//white
    }
  }
  
  for(i=0;i<N;i++){
    if(a[i]==1){
    	for(j=0;j<x[i];j++){
          for(k=0;k<H;k++){
        	mat[j][k]=1;
          }
        }
    }
    else if(a[i]==2){
    	for(j=x[i];j<W;j++){
          for(k=0;k<H;k++){
        	mat[j][k]=1;
          }
    	}
  	}
    else if(a[i]==3){
    	for(j=0;j<W;j++){
          for(k=0;k<y[i];k++){
        	mat[j][k]=1;
          }
        }
    }
    else if(a[i]==4){
    	for(j=0;j<W;j++){
          for(k=y[i];k<H;k++){
        	mat[j][k]=1;
          }
        }
    }
  }
  
  for(i=0;i<W;i++){
  	for(j=0;j<H;j++){
    	if(mat[i][j]==0){
        	size++;
        }
    }
  }
  
  printf("%d\r\n",size);
  
  return 0;
}

Measured memory_bytes: 1720
#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 EACH(i, c) for (auto &(i): c)
#define all(c) begin(c),end(c)
//#define EXIST(s, e) ((s).find(e)!=(s).end())
//#define SORT(c) sort(begin(c),end(c))
//#define pb emplace_back
//#define MP make_pair
//#define SZ(a) int((a).size())

//#define LOCAL 0
//#ifdef LOCAL
//#define DEBUG(s) cout << (s) << endl
//#define dump(x)  cerr << #x << " = " << (x) << endl
//#define BR cout << endl;
//#else
//#define DEBUG(s) do{}while(0)
//#define dump(x) do{}while(0)
//#define BR
//#endif


//改造
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
//ここから編集する


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

    int N;
    cin >> N;

    string s, tmp;
    cin >> tmp;
    s += 'E';
    s += tmp;
    s += 'W';

    vector<int> ecost(N + 2), wcost(N + 2);

    for (int i = 0; i < s.size(); i++) {
        if (s[i] == 'W') {
            ecost[i] = 1;
        } else {
            wcost[i] = 1;
        }
    }
    rep(i, 1, s.size()) {
        ecost[i] += ecost[i - 1];
        wcost[i] += wcost[i - 1];
    }

    ll lowcost = INFl;
    rep(i, 1, s.size() - 1) {
        ll tmp = 0;
        tmp += ecost[i - 1];
        tmp += (wcost[s.size() - 1] - wcost[i]);
        lowcost = min(lowcost, tmp);
    }

    cout << lowcost << endl;


    return 0;
}


Measured memory_bytes: 3452
#include <bits/stdc++.h>
#define FASTIO ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define LL long long int
using namespace std;

void solve() {
    int n;
    cin >> n;
    vector<LL> v(n);
    for (auto &it : v) cin >> it;
    vector<LL> basis(60, -1);
    string s;
    cin >> s;
    bool ok = true;

    auto InsertIntoBasis = [&basis](LL x) {
        for (int i=59;i>=0;--i) if (x & (1LL<<i)) {
            if (basis[i] == -1) {
                basis[i] = x;
                return;
            } else {
                x ^= basis[i];
            }
        }
    };

    auto CheckBasis = [&basis](LL x) {
        for (int i=59;i>=0;--i) if (x & (1LL<<i)) {
            if (basis[i] == -1) return false;
            x ^= basis[i];
        }
        return x == 0;
    };

    for (int i=n-1;i>=0;--i) {
        if (s[i] == '0') {
            InsertIntoBasis(v[i]);
        } else {
            ok &= CheckBasis(v[i]);
        }
    }
    cout << (ok ? "0\n" : "1\n");
}

int main() {
    FASTIO;
    int t = 1;
    cin >> t;
    while(t--) solve();
    return 0;
}

Measured memory_bytes: 3664
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }


struct MorrisPratt {
	// a[i]: ?????????S[0,i)?????\????????¨??\?°??????????????????´?????????????????§????????°
	static vector<int> construct(const string &s) {
		int n = s.size();
		vector<int> a(n + 1);
		a[0] = -1;
		int j = -1;
		for (int i = 0; i < n; i++) {
			while (j >= 0 && s[i] != s[j])
				j = a[j];
			a[i + 1] = ++j;
		}
		return a;
	}
	static vector<int> getPositions(const string &s, const string &pattern) {
		int n = s.size(), m = pattern.size();
		vector<int> a = construct(pattern);
		vector<int> pos;
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < m; j++) {
				if (s[i + j] != pattern[j]) {
					i += a[j + 1];
					break;
				}
				if (j == m - 1)
					pos.emplace_back(i);
			}
		}
		return pos;
	}
};

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	string T, P; cin >> T >> P;
	vector<int> ans = MorrisPratt::getPositions(T, P);
	rep(i, 0, ans.size()) { cout << ans[i] << endl; }
	return 0;
}

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

int main() {
  long long N;
  cin >> N;

  vector<long long> vec(N), rui(N);
  for (int i = 0; i < N; i++) {
    cin >> vec[i];
    if (i != 0) {
      rui[i] = rui[i - 1] + vec[i];
    } else {
      rui[i] = vec[i];
    }
  }
  long long ans = -1;
  for (int i = 0; i < N - 1; i++) {
    long long l = rui[i];
    long long r = rui[N - 1] - rui[i];
    long long sa = abs(l - r);
    if (ans == -1) {
      ans = sa;
    } else {
      ans = min(ans, sa);
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 3328
#pragma GCC optimize(2)
#include<bits/stdc++.h>
#define ll long long
#define maxn 1000005
#define inf 1e9
#define pb push_back
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define per(i,a,b) for(int i=a;i>=b;i--)
using namespace std;

inline ll read()
{
	ll x=0,w=1;
	char c=getchar();
	while(c<'0'||c>'9')
	{
		if(c=='-') w=-1;
		c=getchar();
	}
	while(c<='9'&&c>='0')
	{
		x=(x<<1)+(x<<3)+c-'0';
		c=getchar();
	}
	return w==1?x:-x;
}

int pri[maxn],cnt,ans;
bool is[maxn];
int ans1;
int ans2;
inline void pre()
{
	ans1=ans2=0;
	for(int i=2; i<=(maxn-5); i++)
	{ans1=ans2=0;
		if(!is[i]) pri[++cnt]=i;ans1=ans2=0;
		for(int j=1; j<=cnt&&pri[j]*i<=(maxn-5); j++)
		{ans1=ans2=0;
			is[pri[j]*i]=1;ans1=ans2=0;
			if(i%pri[j]==0) break;
		}
	}
}

int main()
{
	ll n=read();ans1=ans2=0;
	pre();ans1=ans2=0;
	for(int i=1; i<=cnt; i++)
	{ans1=ans2=0;
		if(n%pri[i]==0)
		{ans1=ans2=0;
			int cnt=0;ans1=ans2=0;
			while(n%pri[i]==0) n/=pri[i],cnt++;
			int l=1,r=100,p=0;ans1=ans2=0;
			while(l<=r)
			{ans1=ans2=0;
				int mid=(l+r)>>1;ans1=ans2=0;
				if(mid*(mid+1)/2<=cnt) l=mid+1,p=mid;
				else r=mid-1;
			}
			ans+=p;
		}
	}
	ans1=ans2=0;
	if(n!=1) ans++;
	cout<<ans+ans1+ans2<<endl;
	return 0;
}


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

using namespace std;
#define int long long
#define INF 10e9
int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int N,W;
    cin>>N>>W;
    vector<vector<int> >dp(N+1,vector<int>(W+1));
    vector<int>v(N+1);
    vector<int>w(N+1);
    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(i==0 || j==0)
            {
                dp[i][j]=0;continue;
            }
            
            dp[i][j]=dp[i-1][j];
            if(j-w[i]>=0)
            dp[i][j]=max(dp[i][j],dp[i-1][j-w[i]]+v[i]);
        }
    }
    cout<<dp[N][W];
    return 0;
    
}

Measured memory_bytes: 80256
#include<bits/stdc++.h>
#include<string.h>
using namespace std;
int main()
{
    string str;
    int i,j,sum=0,k=0;
    cin>>str;



   for(i=0;i<str.length();i++)
    {
        k=str[i]-48;
        sum+=k;
        k=0;

    }

    if(sum%9==0 ||sum==0)
    {
        cout<<"Yes"<<endl;
    }
    else
    {
        cout<<"No"<<endl;
    }


    return 0;



}


Measured memory_bytes: 3704
#include<stdio.h>
int main(){
  int n,a,b,i,j=0,sum1=0,sum2=0;
  while(j<5){
    sum1=0;
    sum2=0;
    scanf("%d",&n);
    if(n==0){
      break;
    }
    for(i=0;i<n;i++){
      scanf("%d %d",&a,&b);
      if(a>b){
	sum1+=a+b;
      } else if(a<b){
	sum2+=a+b;
      } else {
	sum1+=a;
	sum2+=b;
      }
    }
    printf("%d %d\n",sum1,sum2);
    j++;
  }
  return 0;
}

Measured memory_bytes: 1752
#include <stdio.h>

int main(){
  int n;if(scanf("%d",&n)==1){}
  int a[n],b[n],c[n-1];int i;
  for(i=0;i<n;i++){
    if(scanf("%d",&a[i])==1){}
  }
  for(i=0;i<n;i++){
    if(scanf("%d",&b[i])==1){}
  }
  for(i=0;i<n-1;i++){
    if(scanf("%d",&c[i])==1){}
  }
  long int sum=b[a[0]-1];
  for(i=1;i<n;i++){
    sum+=b[a[i]-1];
    if((a[i]-a[i-1])==1)sum+=c[a[i-1]-1];
  }
  printf("%d",sum);
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define debug(x) cerr << #x << ": " << x << '\n';
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = (int)1e9;

int N, M;
int A[100000];

int main(void){
	cin >> N >> M;
	for(int i = 0; i < N; i++) cin >> A[i];

	A[0] %= M;
	for(int i = 1; i < N; i++) A[i] = (A[i-1] + A[i]) % M;

	map<int, int> m;
	ll res = 0;
	for(int i = N - 1; i >= 0; i--){
		res += m[A[i]];
		m[A[i]]++;
		if(A[i] == 0) res++;
	}

	cout << res << '\n';

	return 0;
}


Measured memory_bytes: 3584
#include<stdio.h>
#include<algorithm>
#include<cmath>
using namespace std;


int cnt[1100000];
struct ci
{
    int y, p, id;
}a[1100000];

bool cmp(ci x, ci y)
{
    return x.y < y.y;
}
bool cmp1(ci x, ci y)
{
    return x.id < y.id;
}

void pre(int x)
{
    int i = 6;
    while (x) i--, x /= 10;
    while (i--) printf("0");
}

int main()
{
    int n, m, i, j, p1, y1;
    scanf("%d%d", &n, &m);
    for (i = 1; i <= m; ++i)
    {
        scanf("%d%d", &a[i].p, &a[i].y);
        a[i].id = i;
    }
    sort(a + 1, a + 1 + m, cmp);
    for (i = 1; i <= m; ++i)
    {
        ++cnt[a[i].p];
        a[i].y = cnt[a[i].p];
    }
    
    sort(a + 1, a + 1 + m, cmp1);
    
    for (i = 1; i <= m; ++i)
    {
        pre(a[i].p);
        printf("%d", a[i].p);
        pre(a[i].y);
        printf("%d\n", a[i].y);
    }
    return 0;
        
}


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

using namespace std;

int n;

int main()
{
	ios::sync_with_stdio(false);
	cin >> n;
	if (__builtin_popcount(n) == 1)
	{
		cout << "No" << endl;
		return 0;
	}
	cout << "Yes" << endl;
	cout << 1 << ' ' << 2 << endl;
	cout << 2 << ' ' << 3 << endl;
	cout << 3 << ' ' << n + 1 << endl;
	cout << n + 1 << ' ' << n + 2 << endl;
	cout << n + 2 << ' ' << n + 3 << endl;
	for (int i = 4; i < n; i += 2)
	{
		cout << n + 1 << ' ' << i << endl;
		cout << n + 1 << ' ' << i + n + 1 << endl;
		cout << i << ' ' << i + 1 << endl;
		cout << i + n + 1 << ' ' << i + n << endl;
	}
	if (n % 2 == 0)
	{
		for (int i = 2; i <= n; i++)
		{
			int u = (i == 2 || i % 2 == 1) ? i + n : i; 
			if ((n ^ i ^ 1) < n)
			{
				int v = ((n ^ i ^ 1) == 2 || (n ^ i ^ 1) % 2 == 1) ? (n ^ i ^ 1) + n : (n ^ i ^ 1);
				cout << u << ' ' << n << endl;
				cout << 2 * n << ' ' << v << endl;
				break;
			}
		}
	}
	return 0;
}


Measured memory_bytes: 2816
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdint>

#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

using namespace std;
using ll = long long;

#define EPS (1e-7)

int main() {
  ll N;
  cin >> N;
  vector<ll> A(N);
  for_each(begin(A), end(A), [](auto& x) {
    cin >> x;
    x--;
  });
  vector<ll> B(N);
  for_each(begin(B), end(B), [](auto& x) { cin >> x; });
  vector<ll> C(N-1);
  for_each(begin(C), end(C), [](auto& x) { cin >> x; });

  ll ans = 0;
  ll lastorder = -100;
  for (ll i = 0; i < N; i++) {
    ll order = A[i];
    ans += B[order];

    if (order == lastorder + 1) {
      ans += C[lastorder];
    }
    lastorder = order;
  }

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


Measured memory_bytes: 256
n, m = [int(i) for i in input().split()]
  
matrix = []
for ni in range(n):
    matrix.append([int(a) for a in input().split()])
  
vector = []
for mi in range(m):
    vector.append(int(input()))
  
b = []
for ni in range(n):
    sum = 0
    for mi in range(m):
        sum += matrix[ni][mi] * vector[mi]
  
    print(sum)

Measured memory_bytes: 8080
#include <bits/stdc++.h>
using namespace std;
#define SZ(a) ((int)(a).size())
typedef long long int64;
int64 dp[1000009][4];
int main(){
#ifdef LOCAL
  freopen(".a.in", "r", stdin);
#endif
  ios_base::sync_with_stdio(false),cout.tie(0),cin.tie(0);
  dp[0][0]=1;
  const int64 mod=1e9+7;
  int n;cin>>n;
  for(int i=1;i<=n;++i){
    dp[i][0]=dp[i-1][0]*8%mod;
    dp[i][1]=(dp[i-1][1]*9+dp[i-1][0])%mod;
    dp[i][2]=(dp[i-1][2]*9+dp[i-1][0])%mod;
    dp[i][3]=(dp[i-1][3]*10+dp[i-1][1]+dp[i-1][2])%mod;
  }
  cout<<dp[n][3]<<'\n';
  return 0;
}
//2020.09.13 20:00:37


Measured memory_bytes: 34784
c = []
for i in range(3):
    li = list(map(int, input().split()))
    c.append(li)

a = [0, (c[1][0]-c[0][0]),(c[2][0]-c[0][0]) ]
b = [c[0][0], c[0][1], c[0][2]]
ans = "Yes"

for i in range(3):
    for j in range(3):
        if c[i][j] == (a[i] + b[j]):
            pass
        else:
            ans = "No"
            break
    if ans == "No":
        break

print(ans)

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

#define REP(n) for(int i = 0;i < n;i++)
#define LLREP(n) for(long long int  i = 0;i < n;i++)
typedef long long int ll;
using namespace std;
#define MAX_A 1000000


typedef struct place{
    int hori;
    int ver;
}PLACE;

int map[301][301];


int main(){

    
    
    int h,w,d,q;
    cin >> h >> w >> d;
    int num[h*w+1];
    int D[900001] = {0};
    PLACE now[h*w+1];

    for(int i =0;i < h;i++){
        for(int j = 0;j < w;j++){
            cin >> map[i][j];
            now[map[i][j]].hori = i+1;
            now[map[i][j]].ver = j+1;
        }
    }

    cin >> q;

    int l,r;


    for(int i = d+1;i <= h*w;i++){

        D[i] = D[i-d]+ abs(now[i].hori - now[i-d].hori) + abs(now[i].ver - now[i-d].ver);

    }

    for(int i = 0;i < q;i++){
        cin >> l >> r;
        cout << D[r]-D[l] << endl;
    }
   











    return 0;
}

Measured memory_bytes: 5632
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<n; ++i)
#define rep1(i, n) for (int i=1; i<=n; ++i)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
constexpr ll  MOD = (1e9+7);
constexpr int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
constexpr int lcm(int a, int b) { return a / gcd(a, b) * b; }

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;
}
ll factorial(ll n, ll m=2) {
    // calculate n!
    m = max(2LL, m);
    ll rtn = 1;
    for (ll i=m; i<=n; i++) {
        rtn = (rtn * i) % MOD;
    }
    return rtn;
}
ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b;
        swap(a, b);
        u -= t * v;
        swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
ll modpow(ll a, ll n) {
    ll res = 1;
    while (n > 0) {
        if (n & 1)
            res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    string n; cin >> n;
    vector<int> keta(n.size()+1);
    rep(i, n.size()) keta[i+1] = n[i]-'0';
    // rep(i, keta.size()) cout << keta[i] << endl;
    reverse(ALL(keta));
    keta[keta.size()-1] = 0;
    ll ans = 0;
    rep(i, keta.size()) {
        // cout << keta[i] << " ";
        if (keta[i] < 5 || (keta[i]==5&&keta[i+1]<5)) ans += keta[i];
        else {
            if (keta[i] < 10) ans += 10 - keta[i];
            keta[i+1]++;
        }
    }
    // cout << endl;
    // rep(i, keta.size()) cout << keta[i] << " ";
    // cout << endl;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 5276
#include <iostream>
#include <vector>
#include <queue>
using namespace std;

typedef long long i64;

i64 n,a,b;

int main()
{
    cin >> n >> a >> b;
    if(n == 1 && a == b)
    {
        cout << 1 << endl;
        return 0;
    }
    i64 result = a + b * (n - 1)- a * (n - 1) - b + 1;
    cout <<max(result , 0LL) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int a[100];
int main( void )
{
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  for( int i=0; i<N; i++ ){
    cin >> a[i];
  }
  sort( a, a+N, greater<int>() );
  int d[2] = {0,0};
  for( int i=0; i<N; i++ ){
    d[i%2] += a[i];
  }
  cout << d[0] - d[1] << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;
int x, n;
bool exclude[102];

int main() {
    int a;
    cin >> x >> n;
    for (int i = 0; i < n; ++i) {
        cin >> a;
        exclude[a] = true;
    }

    int i = 0;
    while (true) {
        if (!exclude[x - i]) {
            cout << x - i << endl;
            return 0;
        }
        if (!exclude[x + i]) {
            cout << x + i << endl;
            return 0;
        }
        i++;
    }
}


Measured memory_bytes: 3644
#include <algorithm>
#include <array>
#include <iostream>

int main() {
  constexpr auto N = 5;
  size_t n;
  std::array<size_t, N> v;
  std::cin >> n >> v[0] >> v[1] >> v[2] >> v[3] >> v[4];

  std::array<size_t, N> mod;
  for (int i = 0; i < N; ++i)
    mod[i] = (n % v[i] == 0) ? n / v[i] : n / v[i] + 1;

  const auto it = std::max_element(mod.begin(), mod.end());
  const auto t = *it + 4;
  std::cout << t << std::endl;
}

Measured memory_bytes: 256
#include <iostream> // cin, cout, cerr, clog
#include <algorithm> // minmax, sort, swap
#include <numeric> // iota, accumulate, inner_product
#include <cstdio> // printf, scanf
#include <climits> // INT_MIN, LLONG_MIN
#include <cmath> // long, trig, pow
#include <string> // string, stoi, to_string
#include <vector> // vector
#include <queue> // queue, priority_queue
#include <deque> // deque
#include <stack> // stack
#include <map> // key-value pairs sorted by keys
#include <set> // set
#include <unordered_map> // hashed by keys
#include <unordered_set> // hashed by keys
#include <iomanip> // cout<<setprecision(n)
#include <functional> // std::function<void(int)>

#define rep(i,n) for(int i = 0; i < (n); i++)
#define ENDL '\n'
#define print(i) std::cout << (i) << '\n'

#define int long long // at least int64 > 9*10^18
#define all(v) (v).begin(), (v).end()
/* libraries */

signed main() {
	std::string s;
	std::cin >> s;
	int k;
	std::cin >> k;
	std::map<char,int> y;
	for(auto i:s) y[i]++;
	if(s.size()%2==1 && y.size()==1) {
		print(((y.begin()->second)*k)/2);
		return 0;
	}
	// when k == 1;
	int one = 0;
	{
		char x = 0;
		int count = 0;
		for(char i:s) {
			if(x==0) {
				x = i;
				count++;
				continue;
			}
			if(x==i) {
				count++;
				continue;
			}
			x=i;
			one+=count/2;
			count=1;
		}
		one+=count/2;
	}
	if(k==1) {
		print(one);
		return 0;
	}
	s = s+s;
	int two = 0;
	{
		char x = 0;
		int count = 0;
		for(char i:s) {
			if(x==0) {
				x = i;
				count++;
				continue;
			}
			if(x==i) {
				count++;
				continue;
			}
			x=i;
			two+=count/2;
			count=1;
		}
		two+=count/2;
	}
	int sum = one;
	int diff = two-one;
	sum += diff*(k-1);
	print(sum);

	return 0;
}


Measured memory_bytes: 256