akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define dump(x) cout << (x) << '\n'
#define Int int64_t
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()

Int INF = 1e18;
int inf = 1e9;
Int mod = 1e9+7;

Int dp[20005][256];

int main() {
    vector<Int> res;
    Int n, m;
    while (cin >> n >> m and n) {
        vector<Int> c(m);
        for (Int i = 0; i < m; i++) {
            cin >> c[i];
        }
        vector<Int> x(n);
        for (Int i = 0; i < n; i++) {
            cin >> x[i];
        }
        for (Int i = 0; i <= 20000; i++) {
            for (Int j = 0; j < 256; j++) {
                dp[i][j] = INF;
            }
        }
        dp[0][128] = 0;
        for (Int i = 0; i < n; i++) {
            for (Int j = 0; j < 256; j++) {
                for (Int k = 0; k < m; k++) {
                    Int to = j + c[k];
                    if (to < 0) to = 0;
                    if (255 < to) to = 255;
                    Int add = (x[i] - to) * (x[i] - to);
                    dp[i + 1][to] = min(dp[i + 1][to], dp[i][j] + add);
                }
            }
        }
        Int mi = INF;
        for (Int i = 0; i < 256; i++) {
            mi = min(mi, dp[n][i]);
        }
        res.push_back(mi);
    }
    for (Int i = 0; i < (Int)res.size(); i++) {
        dump(res[i]);
    }
    return 0;
}



Measured memory_bytes: 43232
#include <queue>
#include <iostream>
#include <map>
#include <algorithm>
#include <string>
#include <cmath>
#include <vector>
#define rep(i, n) for(long long i = 0;(i) < (n);(i)++)
using namespace std;
using ll = long long;


int main()
{
	ll N; cin >> N;
	vector<ll> l(N);
	for (ll i = 0; i < N; i++) cin >> l[i];
	sort(l.begin(), l.end());
	ll res = 0;
	for (ll i = 0; i < N; i++)
	{
		for (ll j = i + 1; j < N; j++)
		{
			ll k = lower_bound(l.begin(), l.end(), l[i] + l[j]) - l.begin();
			res += max(k - (j + 1), (ll)0);
		}
	}
	cout << res << endl;
	return 0;
}

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


template <class T>
T bin_search(T ok, T ng, bool f(T)) {
  T c;
  while (abs(ok - ng) > 1) {
    c = (ok + ng) / 2;
    if (f(c)) {
      ok = c;
    } else {
      ng = c;
    }
  }

  return ok;
}


/*
https://atcoder.jp/contests/abc144/tasks/abc144_e
*/
ll N, K;
vector<ll> A;
vector<ll> F;

bool f(ll trial) {
  ll shugyo = 0;
  rep(i, N) {
    ll multi = A[i] * F[i];
    if (multi <= trial)
      continue;
    multi -= trial;
    multi = (multi + F[i] - 1) / F[i];
    shugyo += multi;
  }
  return (shugyo <= K);
}

int main() {
  cin >> N >> K;
  A = vector<ll>(N);
  F = vector<ll>(N);
  rep(i, N) cin >> A[i];
  rep(i, N) cin >> F[i];

  sort(all(A));
  sort(all(F), greater<ll>());

  cout << bin_search(LINF, -1ll, f) << endl;
}


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

ll n, W, calc;

vector<vector<ll>> dp(101, vector<ll>(100001, -1));

vector<pair<ll, ll>> arr;

ll solve(ll i, ll j) // min wt <--- ind, val
{
    if (j <= 0)
        return 0;
    if (i >= n)
        return W + 1;

    if (dp[i][j] != -1)
        return dp[i][j];

    dp[i][j] = solve(i + 1, j);
    dp[i][j] = min(arr[i].first + solve(i + 1, j - arr[i].second), dp[i][j]);

    return dp[i][j];
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

    cin >> n >> W;
    arr.resize(n);

    for (ll i = 0; i < n; i++) {
        cin >> arr[i].first >> arr[i].second;
    }// wt, val

    ll mx = 100000, mn = 0, avg;

    while (mx > mn) {
        avg = (mx + mn + 1) / 2;

        calc = solve(0, avg);

        if (calc > W)
            mx = avg - 1;
        else
            mn = avg;
    }

    cout << mx << "\n";

    return 0;
}

Measured memory_bytes: 83012
// Author : MohamedSameh
#include <bits/stdc++.h>
typedef long long ll ;
#define pb push_back
#define f first
#define s second
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define SZ(a) (int)a.size()
void fo (){fflush(stdout);}
using namespace std;
int n , m;
int main ()
{
    cin >> n >> m ;
    ll ans = 1LL * n * m ;
    ans -= 1LL * 2 * n + 1LL * 2 * m ;
    ans += 4 ;
    cout << abs(ans) <<"\n";

  //cerr << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
  return 0;
}


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

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

#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

ll F[105][15];
ll P[105][15];

int main()
{
    int N;
    cin >> N;
    REP(i, N)
    {
        REP(j, 10)
        {
            cin >> F[i][j];
        }
    }
    REP(i, N)
    {
        REP(j, 11)
        {
            cin >> P[i][j];
        }
    }

    ll max = -INF;
    for (int i = 1; i < 1024; ++i)
    {
        ll sum = 0;
        //! 店iと同時に開店している数
        vector<int> n(N);
        REP(j, 10)
        {
            if (((i >> j) & 1) == 0)
                continue;
            REP(k, N)
            {
                if (F[k][j] == 1)
                    n[k]++;
            }
        }
        REP(i, N)
        {
            sum += P[i][n[i]];
        }
        max = std::max(max, sum);
    }
    cout << max << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<bits/stdc++.h>
#include<array>
using namespace std;
#define int long long
#define fast_cin ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define endl "\n"
#define endl "\n"
#define with_tests int t; cin >> t; while(t--){ solve(); cout << endl; }
#define without_tests solve(); cout << endl;
#define CEIL(x, y) (ll)ceil((long double)(x)/(long double)(y))
#define epsilon 1e-9 
typedef long long ll;
const int mod = 1e9+7;
const int N = 1e5+1;

void solve(){
    
    int n, w;
    cin >> n >> w;
    vector<int> vi(n), wi(n);
    int max_ = 0;
    for(int i=0; i<n; i++){
        cin >> wi[i] >> vi[i];
        max_ += vi[i];
    }
    vector<int> dp(max_+1), wmax(max_+1, INT_MAX);
    wmax[0] = 0;
    for(int j=0; j<n; j++){
        for(int i=max_; i>=0; i--){
            if(i-vi[j] < 0){
                break;
            }
            if(i-vi[j] == 0 || dp[i-vi[j]] != 0){
                // cout << "ever";
                if(wmax[i-vi[j]] + wi[j] <= w){
                    if(dp[i-vi[j]] + vi[j] == dp[i]){
                        wmax[i] = min(wmax[i-vi[j]] + wi[j], wmax[i]);
                    }
                    else if(dp[i-vi[j]] + vi[j] > dp[i]){
                        wmax[i] = wmax[i-vi[j]] + wi[j];
                        dp[i] = dp[i-vi[j]] + vi[j];
                    }
                }
            }
        }
    }
    int ans = 0;
    for(int i=0; i<=max_; i++){
        ans = max(ans, dp[i]);
        // cout << dp[i] << " ";
    }
    cout << ans;

}

int32_t main(){

    fast_cin;
    // with_tests;
    without_tests;

    return 0;
}


Measured memory_bytes: 4780
import java.util.*;

public class Main{
    public static void main(String[] args){
        Long N, M, result;
        Scanner sc = new Scanner(System.in);
        N =sc.nextLong();
        M =sc.nextLong();
        result = N;
        ArrayList<Long> studyDays = new ArrayList<Long>();
        for(int i = 0; i < M; i ++){
            studyDays.add(sc.nextLong());
            result -= studyDays.get(i);
        }
        if(result < 0){
            System.out.println("-1");    
        }else{
            System.out.println(result);
        }
    }
}



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

int main(){
  double a,b;
  cin>>a>>b;
  
  if(a>b)
    cout<<"GREATER"<<endl;
  
  else if(a==b)
    cout<<"EQUAL"<<endl;
  
  else
    cout<<"LESS"<<endl;
}


Measured memory_bytes: 256
//ABC97B
#include <bits/stdc++.h>
#define rep(i, n) = for(int i=0; i<n; i++)
using namespace std;
int main(void){
    int n, ans=1;
    int b=2,p=2;
    cin >> n;
    while(pow(b,p)<=n){
        while(pow(b,p)<=n){
            if(ans<pow(b,p)) ans=pow(b,p);
            p+=1;
        }
        p=2;
        b+=1;
    }
    cout << ans << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <vector>
#include <string>

using namespace std;

vector<string> split(const string &s, char delim) {
  vector<string> elems;
  string item;
  for (char ch: s) {
    if (ch == delim) {
      if (!item.empty()) {
        elems.push_back(item);
      }
      item.clear();
    }
    else {
      item += ch;
    }
  }
  if (!item.empty()) {
    elems.push_back(item);
  }
  return elems;
}

string to_str_with_zero(int i, int w) {
  ostringstream sout;
  sout << std::setfill('0') << std::setw(w) << i;
  string s = sout.str();
  return s;
}

int main() {
  std::cout << std::setprecision(9);
  int n, m;
  cin >> n >> m;

  vector<int> steps(n + 1, 1);
  for (int i=0; i<m; i++) {
    int a;
    cin >> a;
    steps.at(a) = 0;
  }

  for (int i=2; i<n + 1; i++) {
    if (steps.at(i) > 0) {
      steps.at(i) = steps.at(i - 1) + steps.at(i - 2);
      steps.at(i) %= 1000000007;
    }
  }

  cout << steps.at(n) << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define REP(i, a, n) for(ll i=a; i<n; i++)
#define RREP(i, a, n) for(ll i=n-1; i>=a; i--)
typedef long long ll;
const ll mod =1e9+7;
const ll inf =1e18;
using namespace std;


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

    cout<<n-(a+b-c)<<endl;
    return 0;
}


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

#define all(x) (x).begin(), (x).end()

typedef long long ll;
typedef array<int, 3> tri;
typedef long double ld;

template <class T> istream& operator>>(istream& I, vector<T>& v) {for (T &e: v) I >> e; return I;}
template <class T> ostream& operator<<(ostream &O, const vector<T>& v) {for (const T &e: v) O << e << ' '; return O;}


void _main() {
        int n; cin >> n;
        string s; cin >> s;
        for (int i = 0; i < s.size(); i++) {
                if (s.substr(0, i + 1) == s.substr(i + 1)) {
                        cout << "Yes";
                        return;
                }
        }
        cout << "No";
}



signed main() {
        ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
//        freopen("input.txt", "r", stdin);
        int _t = 1;
//        cin >> _t;
        while (_t--) _main();
        return 0;
}

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

using lld = long long int;

const int MAX_N = (int)52 + 1;
const lld LAW = (int)1000000007;

int n;
string s1, s2;

lld ans = 1;

int main(void) {
  // Here your code !
  scanf("%d", &n);
  cin >> s1;
  cin >> s2;

  if (s1[0] == s2[0]) {
    ans = (ans * 3) % LAW;
  }
  else {
    ans = (ans * 6) % LAW;
  }

  for (int i = 0; i < n; ++i) {
    if ((i + 1) >= n) break;

    if (s1[i] == s2[i] && s1[i + 1] == s2[i + 1]) {
      ans = (ans * 2) % LAW;
    }
    else if (s1[i] == s2[i] && s1[i + 1] == s1[i + 2] && s2[i + 1] == s2[i + 2]) {
      ans = (ans * 2) % LAW;
    }
    else if (s1[i] == s1[i + 1] && s2[i] == s2[i + 1] && s1[i + 2] == s2[i + 2]) {
      // ans = (ans * 1) % LAW;
      i++;
    }
    // else if (s1[i] == s1[i + 1] && s2[i] == s2[i + 1] && s1[i + 2] == s1[i + 3] && s2[i + 2] == s2[i + 3]) {
    else {
      ans = (ans * 3) % LAW;
      i++;
    }
  }

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

  return 0;
}

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

int main()
{
    std::string a, b, c;
    std::cin >> a >> b >> c;
    int i = 0, j = 0, k = 0;
    char ch = 'a';

    int aLen = a.length(), bLen = b.length(), cLen = c.length();
    i++;

    while(1)
    {
        if(ch == 'a')
        {
            if(i == aLen)
            {
                std::cout << "A" << std::endl;
                break;
            }

            ch = a[i];
            i++;
        }
        else if(ch == 'b')
        {
            if(j == bLen)
            {
                std::cout << "B" << std::endl;
                break;
            }

            ch = b[j];
            j++;
        }
        else
        {
            if(k == cLen)
            {
                std::cout << "C" << std::endl;
                break;
            }

            ch = c[k];
            k++;
        }
    }

    return 0;
}


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

int main() {
  int N, ans;
  cin >> N;
  vector<int> height(N);
  for (int i = 0; i < N; i++) {
    cin >> height.at(i);
  }
  for (int i = 0; i < N; i++) {
    bool mienai = false;
    for (int j = 0; j < i; j++) {
      if (height.at(i) < height.at(j)) {
        mienai = true;
        break;
      }
    }
    if (mienai) {
      continue;
    }
    ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
input = sys.stdin.buffer.readline
def RD(): return sys.stdin.read()
def II(): return int(input())
def MI(): return map(int,input().split())
def LI(): return list(map(int,input().split()))
def TI(): return tuple(map(int,input().split()))
# rstrip().decode('utf-8')
#import numpy as np

from itertools import permutations


def main():
	n=II()
	P=TI()
	Q=TI()
	ans=0
	for i,p in enumerate(permutations(range(1,n+1),n)):
		if P==p:
			ans-=i
		if Q==p:
			ans+=i
	print(abs(ans))




if __name__ == "__main__":
	main()


Measured memory_bytes: 3064
def inpl(): return list(map(int, input().split()))

H, W = inpl()
A = []
for _ in range(H):
    A.append([x=="#" for x in input()] + [False])

A.append([False] * (W+1))

Q = [[0, 0]]
visited = [[False]*(W+1) for _ in range(H+1)]
visited[0][0] = True

while Q:
    h, w = Q.pop()
    for dh, dw in [[0, 1], [1, 0]]:
        nh, nw = h+dh, w+dw
        if A[nh][nw] and not visited[nh][nw]:
            visited[nh][nw] = True
            Q.append([nh, nw])

plength = sum([sum(a) for a in A])

if plength == (H+W-1) and visited[H-1][W-1]:
    print("Possible")
else:
    print("Impossible")

Measured memory_bytes: 38256
import sys
input = sys.stdin.readline

n, W = [int(x) for x in input().split()]
wv = [[int(x) for x in input().split()] for _ in range(n)]

dp = [[float('inf')] * (10**5 + 1) for _ in range(n + 1)]
dp[0][0] = 0

for i in range(1, n + 1):
    w, v = wv[i - 1]
    for j in range(10**5 + 1):
        if j - v >= 0:
            dp[i][j] = min(dp[i - 1][j], dp[i - 1][j - v] + w)
        else:
            dp[i][j] = dp[i - 1][j]

ans = 0

for i in range(10**5 + 1):
    if dp[-1][i] <= W:
        ans = max(ans, i)

print(ans)

Measured memory_bytes: 311304
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
 
int main(){
    int n;
    cin >> n;
    string s;
    cin >> s;
    vector<int> r(n);
    vector<int> g(n);
    vector<int> b(n);
    int rs = 0;
    int gs = 0;
    int bs = 0;
    rep(i, n){
        if(s.at(i) == 'R'){
            rs++;
        }else if(s.at(i) == 'G'){
            gs++;
        }else{
            bs++;
        }
        r.at(i) = rs;
        g.at(i) = gs;
        b.at(i) = bs;
    }
    ll ans = 0;
    rep(i, n){
        if(s.at(i) == 'R'){
            ans += (gs-g.at(i)) * (bs-b.at(i));
        }else if(s.at(i) == 'G'){
            ans += (bs-b.at(i)) * (rs-r.at(i));
        }else{
            ans += (rs-r.at(i)) * (gs-g.at(i));
        }
        int j = 1;
        while(i+2*j < n){
            if(s.at(i) != s.at(i+j) && s.at(i+j) != s.at(i+2*j) && s.at(i+2*j) != s.at(i)) ans--;
            j += 1;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3656
#include <cstdio>
#include <string>

int main() {
    int N;
    scanf("%d",&N);
    char A[N+1], B[N+1], C[N+1];
    scanf("%s\n%s\n%s",A,B,C);
    int count = 0;
    for (int i=0; i<N; i++) {
        if (A[i] == B[i] && A[i] == C[i]) continue;
        if (A[i] == B[i] || A[i] == C[i] || B[i] == C[i]) count++;
        else count += 2;
    }
    printf("%d\n",count);
    return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

var sc = bufio.NewScanner(os.Stdin)

func scanInt() int {
	num, _ := strconv.Atoi(scanString())
	return num
}

func scanString() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	s := scanString()
	s = strings.Replace(s, " ", "", -1)
	fmt.Println(strings.Index(s, "0") + 1)
}


Measured memory_bytes: 1772
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int main(){
  ll i,n;
  while(1){
  cin >> n;
    if(n==0){
      return 0;
    }
  vector<ll> p(n),j(n-1);
  ll sum=0;
  for(i=0;i<n;i++){
    cin >> p[i];
    sum+=p[i];
  }
  for(i=0;i<n-1;i++){
    cin >> j[i];
  }
  sort(j.begin(),j.end(),greater<ll>());
  ll ans=sum*n;
  for(i=0;i<n-1;i++){
    if(ans<(sum+j[i])*(n-i-1)){
      ans=(sum+j[i])*(n-i-1);
    }
    sum+=j[i];
  }
  cout << ans << endl;
  }
  return 0;
}


Measured memory_bytes: 3876
S=str(input())
slist=list(S)
flag=0
if slist[0]!="A":
  flag=1
klist=slist[2:-1]
c=klist.count("C")
if c!=1:
  flag=1
del slist[0]
if "C" in slist:
  slist.remove("C")
SS=""
for x in slist:
  SS+=x
if SS.islower():
  pass
else:
  flag=1
if flag==0:
  print("AC")
else:
  print("WA")


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

int main() {
  ios::sync_with_stdio(false);
  int N, M;
  cin >> N >> M;
  vector<int> wa(N);
  int ac = 0, pe = 0;
  for (int i = 0; i < M; i++) {
    int p;
    string S;
    cin >> p >> S;
    p--;
    if (wa.at(p) == -1) continue;
    else if (S == "AC") ac++, pe += wa.at(p), wa.at(p) = -1;
    else wa.at(p)++;
  }

  cout << ac << " " << pe << "\n";
}

Measured memory_bytes: 640
import java.util.Scanner;

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

	String box = scan.next();
	int count = 0;
	
	for(int i = 0; i < box.length(); i++){
	    if(box.charAt(i) == '1'){
		count++;
	    }
	}

	System.out.println(count);
    }
}
	


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

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

int main(){
  vector<int> d(3);
  rep(i,3){
    cin >> d[i];
  }
  sort(d.begin(),d.end());
  cout << d[0]+d[1] << endl;
}


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

int main(){
	int n;
	string s;

	while( cin >> n , (n != -1) ){
		s.clear();
		do{
			s.push_back( (n%4) + '0' );
			n /= 4;
		}while( n > 0 );
		reverse( s.begin() , s.end() );
		cout << s << endl;
	}
}

Measured memory_bytes: 0
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		for(int i=0;i<n;i++){
			double xa=sc.nextDouble();
			double ya=sc.nextDouble();
			double ra=sc.nextDouble();
			double xb=sc.nextDouble();
			double yb=sc.nextDouble();
			double rb=sc.nextDouble();
			double ab=Math.sqrt((xb-xa)*(xb-xa)+(yb-ya)*(yb-ya));
			if(ab>ra+rb){
				System.out.println(0);
			}else{
				if(ab>=Math.abs(ra-rb)){
					System.out.println(1);
				}else{
					if(ra>rb){
						System.out.println(2);
					}else{
						System.out.println(-2);
					}
				}
			}
		}
	}
}

Measured memory_bytes: 20504
#include <stdio.h>
int main(){
	int n,x,m,i,j;
	int score[101] = {0},tar[101],yosou[101][101];
	scanf("%d%d",&n,&m);
	for(i = 1;i <= m;i++){
		scanf("%d",&tar[i]);
	}
	for(i = 1;i <= m;i++){
		for(j = 1;j <= n;j++){
			scanf("%d",&yosou[i][j]);
		}
	}
	for(i = 1;i <= m;i++){
		for(j = 1;j <= n;j++){
			if( yosou[i][j] == tar[i]){
				score[j]++;
			}else {
				score[tar[i]]++;
			}
		}
	}
	for(i = 1;i <= n;i++){
		printf("%d\n",score[i]);
	}
	return 0;
}

Measured memory_bytes: 1064
using System;
using System.Collections.Generic;
using System.Windows;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Atcoder
{
    public class Program
    {
        private static List<List<int>> l = new List<List<int>>();
        private static int[] add;
        static void Main(string[] args)
        {
            var r1 = ReadSplit();
            var n = r1[0].Int();
            var q = r1[1].Int();

            for (int i = 0; i < 200005; i++)
            {
                l.Add(new List<int>());
            }

            for (int i = 0; i < n - 1; i++)
            {
                var r2 = ReadSplit();
                var a = r2[0].Int();
                var b = r2[1].Int();
                l[a].Add(b);
                l[b].Add(a);
            }
            add = new int[n + 1];
            for (int i = 0; i < q; i++)
            {
                var r3 = ReadSplit();
                var p = r3[0].Int();
                var x = r3[1].Int();
                add[p] += x;
            }

            Dfs(1, -1);

            var sb = new StringBuilder();
            for (int i = 1; i <= n; i++)
            {
                sb.Append(add[i].ToString());
                sb.Append(" ");
            }
            WriteRead(sb.ToString());
        }

        private static void Dfs(int v, int p)
        {
            foreach (var item in l[v])
            {
                if (item == p) continue;
                add[item] += add[v];
                Dfs(item, v);
            }
        }

        public static string Read()
        {
            return Console.ReadLine();
        }

        public static string[] ReadSplit()
        {
            return Console.ReadLine().Split(' ');
        }

        public static void WriteRead(object str)
        {
            Console.WriteLine(str);
            Read();
        }

        public static void Write(object str)
        {
            Console.WriteLine(str);
        }

        private static bool ChangeMin<T>(ref T a, T b) where T : IComparable
        {
            if (a.CompareTo(b) > 0)
            {
                a = b;
                return true;
            }
            return false;
        }

        private static bool ChangekMax<T>(ref T a, T b) where T : IComparable
        {
            if (b.CompareTo(a) > 0)
            {
                a = b;
                return true;
            }
            return false;
        }
    }
}


public static class Extentions
{
    public static int Int(this object obj)
    {
        return int.Parse(obj.ToString());
    }

    public static long Long(this object obj)
    {
        return long.Parse(obj.ToString());
    }

    public static decimal Decimal(this object obj)
    {
        return decimal.Parse(obj.ToString());
    }

    public static double Double(this object obj)
    {
        return double.Parse(obj.ToString());
    }

    public static T2 GetValueZero<T1, T2>(this Dictionary<T1, T2> d, T1 key) where T2 : struct
    {
        T2 value;
        if (d.TryGetValue(key, out value))
        {
            return value;
        }
        return new T2();
    }
}



Measured memory_bytes: 72668
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define REP(i, n) for (int i = 0; i < n; ++i)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x) cout << #x << ' ' << '=' << ' ' << (x) << endl;
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;
typedef vector<ll> vec;
typedef vector<P> pvec;
typedef vector<vector<ll>> vvec;
typedef vector<vector<P>> pvvec;
typedef priority_queue<ll> PQI;
typedef priority_queue<P> PQP;
typedef priority_queue<ll,vector<ll>,greater<ll>> PQIG;
typedef priority_queue<P,vector<P>,greater<P>> PQPG;
const vector<int> dx = {0, -1, 0, 1, 1, 1, -1, -1};
const vector<int> dy = {1, 0, -1, 0, 1, -1, 1, -1};
constexpr int MOD = (1000000007);
// const int MOD = (998244353);
// const int INF = (1 << 30); // 1073741824
const int INF = (1LL << 60); // 1152921504606846976
const double EPS = (1 >> 30);
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return 1;} return 0;}
template< typename T1, typename T2 > istream &operator>>(istream &is, pair< T1, T2 > &p) { is >> p.first >> p.second; return is; }
int nmax=200000; // 2*(10^5)
vvec g(nmax);

vec ans;
vector<bool> seen(nmax,false);
void dfs(int now){
    seen[now]=true;
    int ng=0;
    for(auto next:g[now]){
        if(!seen[next]) ng++;
    }
    if(ng==0) return;
    else{
        int memon;
        for(auto next:g[now]){
            if(!seen[next]){
                memon=next;
                break;
            }
        }
        ans.pb(memon);
        dfs(memon);
    }
}

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(15);
    //---------------------------------------------
    
    int n,m;
    cin>>n>>m;
    int s,G;
    rep(i,m){
        int a,b;
        cin>>a>>b;
        a--;b--;
        g[a].pb(b);
        g[b].pb(a);
        if(i==0){
            s=a;
            G=b;
        }
    }
    seen[s]=true;
    seen[G]=true;
    ans.pb(s);
    dfs(s);
    vec kari=ans;
    reverse(all(kari));
    ans.clear();

    ans.pb(G);
    dfs(G);
    cout<<kari.size()+ans.size()<<endl;
    for(auto x:kari){
        cout<<x+1<<endl;
    }
    for(auto x:ans){
        cout<<x+1<<endl;
    }
}

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

int main()
{
	int A,N,B;
	
		scanf("%d", &N);

		if (N >0 || N <= 100){
			scanf("%d", &A);
		}
		B = (int)pow(N, 2.0) - A;
		printf("%d", B);
		return 0;
}


Measured memory_bytes: 128
function Main(input){
    input = input.split("\n");
    tmp = input[0].split(" ");

    var a = parseInt(tmp[0],10);
    var b = parseInt(tmp[1],10);
    var c = parseInt(tmp[2],10);
    if (a == b){
        console.log("%d",c);
    } else if(a == c){
        console.log("%d",b);
    } else{
        console.log("%d",a);
    }
}

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

Measured memory_bytes: 7372
s = input()
ans = []
l = len(s)

def rec(tmp, n):
    if n == l-1:
        ans.append(eval(tmp))
        return
    rec(tmp + "+" + s[n+1], n+1)
    rec(tmp + s[n+1], n+1)

rec(s[0], 0)
print(sum(ans))


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
	ll k,a,b,ans;
	cin>>k>>a>>b;
	if(b<=a+2)ans=k+1;
	else ans=max(1ll,(k-a+1)/2*(b-a)+a+(k-a+1)%2);
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <stack>
#include <cctype>
#include <complex>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <cassert>

using namespace std;


struct st{
	int num;
	int point;
	int penalty;
	vector<int> wrong;
	
	st(){}
	st(int n){
		point = 0;
		penalty = 0;
		for(int i=0;i<n;i++){
			wrong.push_back(0);
		}
	}
	
	void setnum(int k){
		num = k;
	}
	
	bool operator < (const st &a) const{
		return this->point == a.point ? 
		(this->penalty == a.penalty ? this->num > a.num : this->penalty > a.penalty)
		: this->point < a.point;
	}
};



bool solve(){
	int t,p,r;
	cin>> t>> p>> r;
	if(t==0&&p==0&&r==0) return false;
	
	vector<st> s(t,st(p));
	for(int i=0;i<s.size();i++){
//		s[i].num = i+1;
		s[i].setnum(i+1);
	}
	
	for(int i=0;i<r;i++){
		int a, b ,c;
		string str;
		cin>> a>> b>> c>> str;
		a--; b--;
		if(str == "WRONG"){
			s[a].wrong[b]++;
		}else{
			s[a].point++;
			s[a].penalty += s[a].wrong[b] * 1200 + c;
		}
	}
	
	sort(s.rbegin(), s.rend());
	for(int i=0;i<s.size();i++){
		cout<< s[i].num<< " "<< s[i].point<< " "<< s[i].penalty<< endl;
	}
		
	return true;
	
}

int main(){
	cout.setf(ios::fixed);
	cout.precision(10);
	while(solve());

	return 0;
}

 

Measured memory_bytes: 1252
#include <stdio.h>
#include <stdlib.h>
#include <limits.h>

int mOC(int *, int);
int min(int, int);

int m[101][101];

int main(){
  int n, ans;
  int *data;
  int i, j;

  scanf("%d", &n);

  data = malloc(sizeof(int)*n + 1);

  for(i = 0; i <= n; i++){
    scanf("%d", &data[i]);

    if(i == 0) continue;
    if(i == n) break;
    
    scanf("%d", &data[i]);
  }
  
  ans = mOC(data, n);

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

  return 0;
}


int mOC(int *A, int n){
  int i, j, k, l, q;

  for(i = 1; i <= n; i++) m[i][i] = 0;

  for(l = 2; l <= n; l++){
    for(i = 1; i <= n - l + 1; i++){
      j = i + l - 1;

      m[i][j] = INT_MAX;

      for(k = i; k <= j - 1; k++){
	q = m[i][k] + m[k + 1][j] + A[i - 1]*A[k]*A[j];
	m[i][j] = min(m[i][j], q);
      }
    }
  }

  return m[1][n];
}


int min(int a, int b){
  if(a >= b) return b;
  else return a;
}



Measured memory_bytes: 2112
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less_equal<int>, rb_tree_tag,
		tree_order_statistics_node_update> ordered_set;
typedef tree<int, null_type, less_equal<int>, rb_tree_tag,
		tree_order_statistics_node_update> indexed_multiset;



int n , ans = 1 ;
bool inc = false;
int main(){	
    cin>>n;
    int prv;
    cin>>prv;
    int cnt = 1;
    for(int i = 1; i < n ; i++){
		int x ; cin>>x;
		if(cnt==1){
			if(x  > prv ){
				inc = true;
				cnt++;
			}else if(x < prv){
				inc = false;
				cnt++;
			}
		}
		else{
			if(x < prv && inc){
				cnt = 1;
				ans++;
			}else if(x > prv && !inc){
				cnt = 1;
				ans++;
			}
		}
		prv = x;
	}
	cout<<ans;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
#define endl "\n"
#define pb push_back
#define f(i,n) for(i=0;i<n;i++)
#define F(i,a,b) for(i=a;a<=b;i++)
#define arr(a,n) for( i=0;i<n;i++)cin>>a[i];
#define fi first
#define se second
#define mp make_pair
#define mod 1000000007
#define YES cout<<"YES"<<endl;
#define Yes cout<<"Yes"<<endl;
#define NO cout<<"NO"<<endl;
#define No cout<<"No"<<endl;
#define yes cout<<"yes"<<endl;
#define no cout<<"no"<<endl;
#define vi vector<ll>
#define ed end()
#define bg begin()
#define sz size()
#define ln length()
#define s() sort(a,a+n);
#define sr() sort(a,a+n,greater<ll>());
#define v()  sort(v.begin(),v.end());
#define vr() sort(v.begin(),v.end(),greater<ll>());
#define mod 1000000007
#define fast() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
ll gcd(ll a, ll b){if(!b)return a;return gcd(b, a % b);}
ll power(ll x,ll y,ll p){ll res=1;x%=p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;}
int main() {

fast();

{
  string a,b;
  cin>>a>>b;
  reverse(b.begin(),b.end());
  if(a==b)
  {
    YES
  }
  else 
  {
    NO
  }
  

}
return 0;
}


Measured memory_bytes: 256
import sys

# import bisect
# from collections import Counter, deque, defaultdict
# import copy
# from heapq import heappush, heappop, heapify
# import itertools
# from operator import attrgetter, itemgetter
# import math

# from numba import jit
# import numpy as np

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    n = int(input())
    a = [0] + list(map(int, readline().split()))

    if n == 2:
        print(max(a[1],a[2]))
        sys.exit()

    dp = [[0] * 2 for _ in range(n + 1)]

    # 普通に選ぶ場合
    dp[1][0] = 0
    dp[2][0] = max(a[1], a[2])
    dp[3][0] = max(a[1], a[2], a[3])

    # 1個多く選ぶ場合（奇数個のみ）
    dp[1][1] = a[1]
    dp[3][1] = a[1] + a[3]

    i = 4

    while i < n + 1:
        cur1 = a[i]

        # 偶数だよ
        dp[i][0] = max(dp[i - 1][1], dp[i - 2][0] + cur1)

        if i == n:
            break

        i += 1
        cur2 = a[i]

        # 奇数だよ
        dp[i][0] = max(dp[i - 2][0] + cur2, dp[i - 3][0] + cur2, dp[i - 1][0], dp[i - 2][1])
        dp[i][1] = dp[i - 2][1] + cur2

        i += 1

    print(dp[n][0])


if __name__ == '__main__':
    main()


Measured memory_bytes: 112168
N, x = map(int, input().split(" "))
A = list(map(int, input().split(" ")))
A.sort()
 
ans = 0
for a in A:
  if a <= x:
    ans += 1
    x -= a
  else:
    x -= a
    break
if x > 0: ans -= 1
    
print(ans)

Measured memory_bytes: 3060
#include <algorithm>
#include <cassert>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define DEBUG 1
constexpr int kMod = 1000000007;
typedef long long LL;

typedef std::pair<int, int> Student;  // NumArrivedStudent, Number.
int main() {
  std::vector<Student> students;
  int N; std::cin >> N;
  for (int n = 1; n <= N; ++n) {
    int num; std::cin >> num;
    students.emplace_back(num, n);
  }
  std::sort(students.begin(), students.end());
  for (const auto& student : students) {
    std::cout << student.second << " ";
  }
  std::cout << std::endl;
}


Measured memory_bytes: 1780
#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <iomanip>
#include <vector>
#include <cstring>
#include <queue>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
using namespace std;
using ll = long long;
using ld = long double;
using ull = unsigned long long;
using uld = unsigned long long;
using P = pair<int,int>;
ll MAX(ll a,ll b,ll c){return max(a,max(b,c));}
ll MIN(ll a,ll b,ll c){return min(a,min(b,c));}
const ll mod = 1e9+7;
const int dx[4] = {0,1,0,-1};
const int dy[4] = {1,0,-1,0};
template<class T> inline bool chmax(T &a,T& b){if(a < b){a = b; return true;} else return false;}
template<class T> inline bool chmin(T &a,T& b){if(a > b){a = b; return true;} else return false;}
int main(){
    int n,m;
    cin >> n >> m;
    cout << (n == m ? "Yes" : "No") << endl;
}

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

using namespace std;
typedef long long ll;

ll dp[110][4][4][4];

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

  for( int i=0;i<4;i++ )
    for( int j=0;j<4;j++ )
      for( int k=0;k<4;k++ )
	if( (i==0 && j==1 && k==2) 
	    || (i==0 && j==2 && k==1)
	    || (i==1 && j==0 && k==2) )
	  continue;
	else
	  dp[3][i][j][k] = 1;

  for(int i=4;i<N+1;i++)
    {
      for( int j=0;j<4;j++ )
	for( int k=0;k<4;k++ )
	  for( int l=0;l<4;l++ )
	    for( int m=0;m<4;m++ )	    
	      {
		if( (j==0 && k==1 && l==2) 
		    || (j==0 && k==2 && l==1)
		    || (j==1 && k==0 && l==2) )
		  continue;
		if( (k == 0 && l==1 && m==2)
		    || (k == 1 && l==0 && m==2)
		    || (k == 0 && l==2 && m==1) )
		  continue;
		if( j==0 && k==1 && m==2 )
		  continue;
		if( j==0 && l==1 && m==2 )
		  continue;
		dp[i][k][l][m] = (dp[i][k][l][m]+dp[i-1][j][k][l])%1000000007;
		//		dp[i][k][l][m] += dp[i-1][j][k][l];
	      }
    }

  ll ans = 0;
  for( int i=0;i<4;i++ )
    for( int j=0;j<4;j++ )
      for( int k=0;k<4;k++ )          
	ans = (ans+dp[N][i][j][k])%1000000007;;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
using namespace std;
struct UF {
  vector<int> par, sz;
  UF(int n) {
    init(n);
  }
  void init(int n) {
    sz.resize(n);
    for (auto& x : sz) x = 1;
    par.resize(n);
    iota(par.begin(), par.end(), 0LL);
  }

  int find(int x) {
    if (par[x] == x) return x;
    return par[x] = find(par[x]);
  }

  void unite(int x, int y) {
    x = find(x);
    y = find(y);
    if (x == y) return;
    if (sz[x] < sz[y]) swap(x, y);
    sz[x] += sz[y];
    par[y] = par[x];
  }
};
signed main() {
  int N, M;
  cin >> N >> M;
  vector<int> A(M), B(M);
  UF uf(N);
  for (int i = 0; i < M; i++) {
    cin >> A[i] >> B[i];
    A[i]--, B[i]--;
    uf.unite(A[i], B[i]);
  }
  cout << *max_element(uf.sz.begin(), uf.sz.end()) << endl;;
}


Measured memory_bytes: 9564
#include <iostream>
#include <algorithm>
#include <complex>
#include <utility>
#include <vector>
#include <string>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#include <set>
#include <numeric>
#include <functional>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
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; }
inline void Yes(bool condition){ if(condition) PRINT("Yes"); else PRINT("No"); }
template<class itr> void cins(itr first,itr last){
    for (auto i = first;i != last;i++){
        cin >> (*i);
    }
}
template<class itr> void array_output(itr start,itr goal){
    string ans = "",k = " ";
    for (auto i = start;i != goal;i++) ans += to_string(*i)+k;
    if (!ans.empty()) ans.pop_back();
    PRINT(ans);
}
ll gcd(ll a, ll b) {
    return a ? gcd(b%a,a) : b;
}
const ll INF = 1e16;
const ll MOD = 1000000007;
typedef pair<ll,ll> P;
const ll MAX = 1005;
constexpr ll nx[4] = {1,0,-1,0};
constexpr ll ny[4] = {0,1,0,-1};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,z,w;
    cin >> n >> z >> w;
    vector<ll> a(n);
    cins(all(a));
    if (n == 1) PRINT(abs(a[0]-w));
    else PRINT(max(abs(a[n-2]-a[n-1]),abs(a[n-1]-w)));
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	int N; cin >> N; 
	int A[114514] = {}; 
	for(int i = 0; i < N; i++) cin >> A[i]; 
	int C[3] = {}; 
	long long ans = 1; 
	long long P = 1e9 + 7; 
	for(int i = 0; i < N; i++){
		long long cnt = 0; int id = -1; 
		if(A[i] == C[0]){
			cnt ++; id = 0;  
		}
		if(A[i] == C[1]){
			cnt ++; id = 1;  
		}
		if(A[i] == C[2]){
			cnt ++; id = 2;  
		}
		ans *= cnt; ans %= P; 
		C[id] ++; 
	}
	cout << ans << endl; 
}

Measured memory_bytes: 640
#define _GLIBCXX_DEBUG
#include<cmath>
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
vector<int> arr;
stack<int> st;
queue<int> qu;
queue<pair<int,int> > qu2;
priority_queue<int> pq;
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define rep2(i,n) for(int i=1; i<=(int)(n); i++)
typedef set<int> set_t;
typedef set<string> set_g;
typedef complex<double> xy_t;
static const int NIL = -1;

/*int P[10010];
void init(int n){
    for(int i=0;i<n;++i)P[i]=i;
}
int root(int a) {
    if(P[a]==a)return a;
    return (P[a]=root(P[a]));
}
bool is_same_set(int a,int b){
    return root(a) == root(b);//代表元を求める
}
void unite(int a,int b){
    P[root(a)]=root(b);
}//対set,グラフ？
//セグメント木？？？
*/

double dot_product(xy_t a, xy_t b) { return (conj(a)*b).real(); }//内積
double cross_product(xy_t a, xy_t b) { return (conj(a)*b).imag(); }//外積
xy_t projection(xy_t p, xy_t b) { return b*dot_product(p,b)/norm(b); }//投影
//対図形

#define mod 1000000007
/*ll f[2001];
//int n,k とかしておく

ll pw(ll x, ll y){//euclidの互除法より
    ll a= 1;
    while(y){
        if(y&1){//奇数なら
            a = a*x%mod;
        }
        x = x*x%mod;
        y /= 2;
    }
    return a;
}

ll modinv(ll x){//逆元を求める
    return pw(x, mod - 2 );
}

ll comb(int n,int r){
    if(n<r){
        return 0;
    }
    return f[n] * modinv(f[r])%mod*modinv(f[n-r])%mod;
}//対combination//ただしfは用意してね
*/

struct BIT{
    vector<int> dat;
    int sz;
    BIT(int n){
        for(sz=1;sz<n;sz *= 2);
        dat.resize(++sz);
    }
    int q(int n){
        int ret = 0;
        for(int i=n;i>0;i-=i&-i)ret +=dat[i];//和の計算　iから最後の１のbit(i&-i 多分＆はビット積)を減算
        for(int i=n;i<sz;i+=i&-i) dat[i]++;//値の加算　iから最後mの１のbitを加算
        return ret;
    }
};

int main(){
    int a, b, k;
    cin >> a>> b>> k;
    int l=0;
    for(int i=100;i>0;i--){
        if(a%i==0&&b%i==0){
            l++;
            if(l==k){
                cout<<i<<endl;
                return 0;
            }
        }
    }
}

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

void output (vector<int> &v) {
    cout << 100 << " " << 100 << endl;
    for (int y = 0; y < 100; ++y) {
        string t = "";
        for (int x = 0; x < 100; ++x) {
            t += v[x + y * 100] == 0 ? "." : "#";
        }
        cout << t << endl;
    }
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int A, B;
    cin >> A >> B;
    
    vector<int> v = vector<int>(10000, 0);
    
    A -= 1;
    B -= 1;
    
    for (int y = 0; y < 50; ++y) {
        for (int x = 0; x < 100; ++x) {
            if (B > 0 && y % 2 == 1 && x % 2 == 1) {
                v[x + y * 100] = 1;
                B -= 1;
            } else {
                v[x + y * 100] = 0;
            }
        }
    }
    
    for (int y = 50; y < 100; ++y) {
        for (int x = 0; x < 100; ++x) {
            if (A > 0 && y % 2 == 1 && x % 2 == 1) {
                v[x + y * 100] = 0;
                A -= 1;
            } else {
                v[x + y * 100] = 1;
            }
        }
    }
    
    output(v);
    
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<string>
#include<algorithm>
#include<map>
#include<vector>
#include<set>
#include<queue>
#include<cmath>
#define ll long long
#define pb push_back
#define mp make_pair
#define all(v) v.begin(),v.end()
#define ff first
#define ss second
#define F false
#define T true
#define inf 1e18;
#define in(n) cin>>n
#define iin(n, m) cin>>n>>m
#define iiin(a,b,c) cin>>a>>b>>c
#define O(a) cout<<a
#define prln(a) cout<<a<<"\n"
#define OO(a, b) cout<<a<<b
#define nl cout<<"\n"
#define sp cout<<" "
#define rep(i,a,b) for(ll i=a; i<b; i++)

using namespace std;
const int N=1e5+50;
const int mod=1e9+7;


int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	ll tc=1;
	for(ll t=1; t<=tc; t++){
		string s; in(s);
		int ar[26]={0};
		int len=s.length();
		for(int i=0; i<len; i++){
			int a = s[i]-'a';
			ar[a]++;
		}
		int idx=-1;
		for(int i=0; i<26; i++){
			if(ar[i]==0){
				idx = i;
				break;
			}
		}
		if(idx==-1){
			cout<<"None\n";
		}
		else{
			char res = idx+'a';
			cout<<res<<"\n";
		}
	}
	return 0;
}










Measured memory_bytes: 512
#include <stdio.h>

int main(void)
{
    int N;
    int i, a;
    
    scanf("%d", &N);

    a = 1;
    for (i = 0; a < N + 2; i++){
        a *= 2;
    }
    
    printf("%d\n", i - 1);
    
    return (0);
}



Measured memory_bytes: 2112
n,m=map(int,input().split())
a=[int(input()) for _ in range(m)]
dp=[1]*(n+1)
for i in a:
  dp[i]=0
for i in range(2,n+1):
  dp[i]=(dp[i-1]+dp[i-2])%1000000007*dp[i]
print(dp[-1])

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

using namespace std;
using ll = long long;

#define int ll

#define rep(i, a) for (int i = 0; (i) < (int) (a); (i)++)
#define reps(i, a, b) for (int i = (int) (a); (i) < (int) (b); (i)++)
#define rrep(i, a) for (int i = (int) a-1; (i) >= 0; (i)--)
#define rreps(i, a, b) for (int i = (int) (a)-1; (i) >= (int) (b); (i)--)
#define MP(a, b) make_pair((a), (b))
#define PB(a) push_back((a))
#define all(v) (v).begin(), (v).end()
#define PERM(v) next_permutation(all(v))
#define UNIQUE(v) sort(all(v));(v).erase(unique(all(v)), v.end())
#define CIN(type, x) type x;cin >> x
#define TRUE__  "CONTINUE"
#define FALSE__ "GAMEOVER"
#define PRINT(f) if((f)){cout << (TRUE__) << endl;}else{cout << FALSE__ << endl;}
#define YES(f) if((f)){cout << "YES" << endl;}else{cout << "NO" << endl;}
#define Yes(f) if((f)){cout << "Yes" << endl;}else{cout << "No" << endl;}
#define MINV(v) min_element(all(v))
#define MAXV(v) max_element(all(v))
#define MIN3(a, b, c) min(min(a, b), c)
#define MIN4(a, b, c, d) min(MIN3(a, b, c), d)
#define MIN5(a, b, c, d, e) min(MIN4(a, b, c, d), e)
#define MIN6(a, b, c, d, e, f) min(MIN5(a, b, c, d, e), f)
#define MAX3(a, b, c) max(max(a, b), c)
#define MAX4(a, b, c, d) max(MAX3(a, b, c), d)
#define MAX5(a, b, c, d, e) max(MAX4(a, b, c, d), e)
#define MAX6(a, b, c, d, e, f) max(MAX5(a, b, c, d, e), f)
#define RANGE(a, b, c) ((a) <= (b) && (b) < (c))
#define RANGE2D(a, b, c, d, e, f) (RANGE((a), (c), (e)) && RANGE((b), (d), (f)))
#define chmin(a, b) a = min(a, (b))
#define chmin3(a, b, c) a = MIN3(a, (b), (c))
#define chmin4(a, b, c, d) a = MIN4(a, (b), (c), (d))
#define chmin5(a, b, c, d, e) a = MIN5(a, (b), (c), (d), (e))
#define chmin6(a, b, c, d, e, f) a = MIN6(a, (b), (c), (d), (e), (f))
#define chmax(a, b) a = max(a, (b))
#define chmax3(a, b, c) a = MAX3(a, (b), (c))
#define chmax4(a, b, c, d) a = MAX4(a, (b), (c), (d))
#define chmax5(a, b, c, d, e) a = MAX5(a, (b), (c), (d), (e))
#define chmax6(a, b, c, d, e, f) a = MAX6(a, (b), (c), (d), (e), (f))

#define RS resize
#define CINV(v, N) do {\
	v.RS(N);\
	rep(i, N) cin >> v[i];\
} while (0);
#define RCINV(v, N) do {\
	v.RS(N);\
	rrep(i, N) cin >> v[i];\
} while (0);
#define fcout cout << fixed << setprecision(12)

#define MOD 1000000007

template<class T>
inline T GET() {
	T x;
	cin >> x;
	return x;
}

void init();
void solve();

signed main()
{
	init();
	solve();
}

void init()
{
	int N;
	cin >> N;
	vector<string> v;
	int res = 0;
	rep(i, 3) v.PB(GET<string>());
	rep(i, N) {
		vector<int> t(26, 0);
		rep(j, 3) {
			t[v[j][i]-'a']++;
		}
		sort(all(t), greater<int>());
		if (t[0] == 2) res++;
		else if (t[0] == 1) res += 2;
	}
	cout << res << endl;
}

void solve()
{
}




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

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define REP(i, n) for(int i = 0; i < (n); ++i)
#define REPr(i, n) for(int i = (n)-1; i >= 0; --i)
#define FORq(i, m, n) for(int i = (m); i <= (n); ++i)
#define FORqr(i, m, n) for(int i = (n); i >= (m); --i)
#define MP make_pair
#define SIN(x, S) (S.count(x) != 0)
#define M0(x) memset(x, 0, sizeof(x))
#define FILL(x, y) memset(x, y, sizeof(x))
#define MM(x) memset(x, -1, sizeof(x))
#define ALL(x) (x).begin(), (x).end()
#define DB(x) cerr << #x << " = " << x << endl
#define DB2(x, y)                                                              \
    cerr << "(" << #x << ", " << #y << ") = (" << x << ", " << y << ")\n";
#define DEBUG                                                                  \
    int x12345;                                                                \
    cin >> x12345;
typedef pair<int, int> PII;
typedef pair<long long, long long> PLL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef long long ll;
typedef long long integer;
///////////////////////////////////////////////
const long long MOD = 1e9 + 7;
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;
}

///////////////////////////////////////////////
/// 🍈( '-' 🍈 |AC|
int main() {
    ll a,b,c; cin >> a >> b >> c;
    if ((c-a-b > 0) and ((c-a-b) * (c-a-b) > 4*a*b)){
        puts("Yes");
    }else{
        puts("No");
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define fo(i,n) for(i=0;i<n;i++)
#define fok(i,k,n) for(i=k;i<n;i++)
#define ci(x) cin>>x;
#define ci2(x,y) cin>>x>>y;
#define co(x) cout<<x<<"\n";
#define co2(x,y) cout<<x<<" "<<y<<"\n";
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define PI 3.1415926535897932384626
typedef pair<int, int>	pii;
typedef pair<ll, ll>	pll;
typedef vector<int>		vi;
typedef vector<ll>		vl;
typedef vector<pii>		vpii;
typedef vector<pll>		vpll;
typedef vector<vi>		vvi;
typedef vector<vl>		vvl;
const int mod = 1000000007;




int main() {
	int n,k;
	ci2(n,k);
	int i;
	vi h;
	fo(i,n){
		int temp;
		ci(temp);
		h.pb(temp);
	};
	int count=0;
	int now = 0;
    while (true) {
        count++;
        now += k;
 
        if (now >= n) break;
        else now--;
    }
	co(count);
	return 0;
}





Measured memory_bytes: 892
#include <bits/stdc++.h>
#define int long long

using namespace std;


signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    int data[n];
    for (int i = 0; i < n; ++i) cin >> data[i];
    int ans = 0;
    map <int, int> tmp;
    for (int i = 0; i < n; ++i) {
        ans += tmp[i - data[i]];
        ++tmp[i + data[i]];
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 27868