akhauriyash/Code-Regression huggingface dataset:
//#define _GLIBCXX_DEBUG
#include <iostream>
#include <bits/stdc++.h>
 
 
using namespace std;
#define ll long long
#define ld long double
#define  P pair<ll,ll>
#define FOR(i,n,m) for(ll i=n; i<(ll)m;i++)
#define FORr(i,m,n) for(ll i=n; i>=(ll)m; i--)
#define FORm(i,m) for(auto i=m.begin();i!=m.end();i++)
#define sortAl(v) sort(v.begin(),v.end())
#define sortAlr(v) sort(v.begin(),v.end()); reverse(v.begin(),v.end())
#define cout(n) cout<<fixed<<setprecision(n)
 
ll solve(ll honesty, vector<vector<P>> &answer, ll n){
    FOR(j,0,n){
        if(honesty & (1<<j)){
            FOR(k,0,answer[j].size()){
                ll hito = answer[j][k].first;
                if(!(honesty & (1<<hito)) == answer[j][k].second){
//                    cout<<honesty<<" "<<hito<<endl;
                    return 0;
                }
            }
        }
    }
    ll ret = 0;
    while(honesty>0){
        if(honesty%2==1)ret++;
        honesty/=2;
    }
    return ret;

}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin>>n;
    vector<vector<P>> answer(n);
    FOR(i,0,n){
        ll a;
        cin>>a;
        FOR(j,0,a){
            ll in,in1;
            cin>>in>>in1;
            answer[i].push_back(P(in-1,in1));
        }
    }

    ll bit = 1<<n;
    ll ans = 0;
    FOR(honesty,0,1<<n){
        ans = max(ans, solve(honesty, answer, n));
    }
    cout<<ans<<endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include <algorithm>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define acc(v) accumulate(v.begin(), v.end(), 0)

using namespace std;
typedef long long ll;
const int INF = 1e9;
const ll LINF = 1e18;
const ll MOD = 1e9 + 7;

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

	for (int i = 0; i <= 200; i++)
	{
		for (int j = 0; j < 2; j++){
			for (int k = 0; k <= 200; k++){
				for (int l = 0; l < 2; l++){
					int a = j ? -1 * i : i;
					int b = l ? -1 * k : k;
					if(pow(a,5) - pow(b,5) == x){
						cout << a << " " << b << endl;
						return 0;
					}
				}
			}
		}
	}
	return 0;
}


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

int main(){
unsigned int N;
unsigned int M;
std::string line;

std::cin >> N >> M;
std::getline(std::cin, line);

int img[N][N];
int tmp[M][M];

for (unsigned int i = 0; i < N; ++i){
std::getline(std::cin, line);

for (unsigned int j = 0; j < N; ++j){
img[i][j] = (line[j] == '#' ? 1 : 0);
}
}

for (unsigned int i = 0; i < M; ++i){
std::getline(std::cin, line);

for (unsigned int j = 0; j < M; ++j){
tmp[i][j] = (line[j] == '#' ? 1 : 0);
}
}

for (unsigned int i = 0; i < N-M+1; ++i){
for (unsigned int j = 0; j < N-M+1; ++j){

bool match = true;

for (unsigned int k = 0; k < M && match; ++k){
for (unsigned int l = 0; l < M && match; ++l){

if (tmp[k][l] != img[i+k][j+l]){
match = false;
}

}
}

if (match){
std::cout << "Yes" << std::endl;
return 0;
}

}
}

std::cout << "No" << std::endl;

return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
    int i[10000];
    int l = 1;
    int t = 1;
    int e1, e2;

    for( e1 = 0; e1 == 0; l++ ) {
        scanf("%d", &i[l]);
        if( i[l] == 0 ) e1 = 1;
    }
    for( e2 = 0; e2 == 0; t++ ){
        if ( t == l - 2 ) e2 = 1;
        printf("Case %d: %d\n", t, i[t]);
    }
    return 0;
}


Measured memory_bytes: 2056
w=input()
if len(w)%2!=0:
    print("No")
    exit()
for i in range(0,25):
    cnt=w.count(chr(ord("a")+i))
    if cnt%2!=0:
        print("No")
        exit()
cnt=w.count("z")
if cnt%2!=0:
  print("No")
  exit()
print("Yes")

Measured memory_bytes: 3060
#include<algorithm>
#include<climits>
#include<cmath>
#include<cstdlib>
#include<iomanip>
#include<iostream>
#include<numeric>
#include<string>
using namespace std;

long gcd(long x, long y) { if (x > y) { return gcd(y, x); } long r; while (y != 0) { r = x % y; x = y; y = r; }return x; }
long lcm(long x, long y) { return(x / gcd(x, y)) * y; }
void indexsort(long* first, long* last, long* func) { sort(first, last, [&](long a, long b) {return func[a] < func[b]; }); }
//--------------------

int main() {

	long N; cin >> N;
	long res = 2 * N;
	string s, t; cin >> s >> t;
	
	for (int i = 1; i <= N; i++) if (s.substr(N - i, i) == t.substr(0, i)) res = 2 * N - i;

	cout << res << endl;
}

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

string lcs(string X, string Y, int m, int n)
{
    int dp[m+1][n+1];
    int i,j;

    for(i=0; i<=m; i++)
    {
        for(j=0; j<=n; j++)
        {
            if(i==0 || j==0)
                dp[i][j] = 0;
            else if(X[i-1]==Y[j-1])
                dp[i][j] = dp[i-1][j-1]+1;
            else
                dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
        }
    }

    i=m;
    j=n;
    string res;

    while(i>0 && j>0)
    {
        if(X[i-1]==Y[j-1])
        {
            res.push_back(X[i-1]);
            i--;
            j--;
        }
        else if(dp[i-1][j]>dp[i][j-1])
            i--;
        else
            j--;
    }

    reverse(res.begin(), res.end());

    return res;
}

int main() 
{
    string str1,str2;
    cin>>str1>>str2;

    int n = str1.size();
    int m = str2.size();

    string ans = lcs(str1,str2,n,m);

    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 38788
// Christmas Eve Eve Eve

#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <string>

using namespace std;

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


Measured memory_bytes: 256
import java.util.*;
public class Main {
	private static Scanner sc;
	public static void main(String[] args) {
		sc = new Scanner (System.in);
		int N = sc.nextInt();
		int W = sc.nextInt();
		int v[] = new int [N+1];
		int w[] = new int [N+1];
		for (int i=0; i<N; i++){
			v[i]=sc.nextInt();
			w[i]=sc.nextInt();
		}
		int price[][] = new int [N+1][W+1];	
		for (int i=N-1; i>=0; i--){
			for (int j=1; j<=W; j++){
				if (j-w[i]<0) price[i][j]=price[i+1][j];
				else price[i][j]=Math.max(price[i+1][j], (price[i][j-w[i]]+v[i]));
			
			}
		}
		System.out.println(price[0][W]);
	}
}

Measured memory_bytes: 31180
n,m=input().split()
n=int(n)
m=int(m)
y=([1]*n)
x=list(input().split())
for i in range(m):
    y1,y2=input().split()
    y1=int(y1)
    y2=int(y2)
    if int(x[y1-1])>int(x[y2-1]):
        y[y2-1]=0
    elif int(x[y1-1])<int(x[y2-1]):
        y[y1-1]=0
    else:
        y[y2-1]=0
        y[y1-1]=0
print(n-y.count(0))

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

using namespace std;
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;

void ABC142C()
{
	int N;
	cin >> N;
	map<int, int> A;
	for (int i = 1; i <= N; ++i)
	{
		int x;
		cin >> x;
		A[x] = i;
	}
	for (auto& x : A)
		cout << x.second << endl;


}
int main()
{
	ABC142C();
	return 0;
}

Measured memory_bytes: 5504
#include<stdio.h>

int main(void)
{
  int a, b, c;
  int i;

  scanf("%d%d%d",&a, &b, &c);
  for(i=1;i<b;i++){
    if(a * i % b == c){
      break;
    }
  }
  if(i == b)
    printf("NO\n");
  else
    printf("YES\n");

  return 0;
}

Measured memory_bytes: 128
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
#define rep(i, begin, n) for (int i = begin; i < n; i++)
#define repe(i, begin, n) for (int i = begin; i <= n; i++)
#define repr(i, begin, n) for (int i = begin; i > begin - n; i--)
#define repre(i, begin, end) for (int i = begin; i >= end; i--)

template <class T>
inline bool chmax(T& a, T b)
{
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}

template <class T>
inline bool chmin(T& a, T b)
{
    if (a > b) {
        a = b;
        return 1;
    }
    return 0;
}

const int inf = 1000000007;
const int MOD = 1000000007;
const long long INF = 1000000000000000007;

// -------------------------------------------------------
int R;

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

    cout << "AGC" << endl;
}

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

using namespace std;

typedef long long ll;
typedef vector<ll> vl;
typedef long double ld;
typedef vector<ld> vd;
typedef bool bl;
typedef vector<bl> vb;
typedef unordered_map<ll,unordered_map<ll,ll>> graph;

const ll e5 = 1 << 20;
const ll mod = 1000000007;
const ll e3 = 1 << 13;
const ll INF = 1ll << 60;

ll n,m;
ll dp[302][302][302];

int main(){
  cin >> n >> m;
  dp[0][1][1] = 1;
  for(ll i = 0;i < m;i++){
    for(ll j = 1;j <= n;j++){
      for(ll k = 1;k <= n;k++){
        dp[i][j][k] %= mod;
        dp[i+1][j+1][k] += dp[i][j][k]*(n-j);
        dp[i+1][j][k] += dp[i][j][k]*(j-k);
        dp[i+1][j][j] += dp[i][j][k]*k;
      }
    }
  }
  cout << dp[m][n][n]%mod << endl;
}


Measured memory_bytes: 215296
#include <stdio.h>
int main(void){

    int n,a[120],tmp=0,ans=0 ;
    scanf ("%d",&n) ;
    
    for (int i=0; i<n; i++ ){
        scanf ("%d",&a[i]) ;
    }
    
    for (int i=0; i<n; i++ ){
        tmp = 0 ;
        for (int j=i+1; j<n; j++ ){
            if ( a[i]<a[j] ){
                tmp = a[i] ;
                a[i] = a[j] ;
                a[j] = tmp ;
            }
        }
    }
    
    for (int i=0; i<n-1; i++ ){
        if ( a[i]>a[i+1] ){
            ans++ ;
        }
    }
    
    printf ("%d\n",ans+1) ;
    
    return 0 ;
    
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define vi vector<int>
#define vvi vector<vector<int>>
#define all(a) (a).begin(), (a).end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
const int MOD = 1e9+7;
const ll LINF = 1e18;
const int INF = 1e9;
ll A, B, C, D, E, F, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S, T;

int main()
{
    cin >> S;
    cin >> T;
    T.pop_back();

    if(T == S)cout << "Yes";
    else cout << "No";
    
    return 0;
}

Measured memory_bytes: 3616
n = int(input())
tree =[[] for _ in range(n)]
parent = [-1]*n
depth = [-1]*n

for i in range(n):
    temp = list(map(int,input().split()))
    tree[temp[0]].append(temp[1:])
    if temp[1] != 0:
        for j in range(temp[1]):
            parent[temp[2+j]] = temp[0]

def getDepth(u):
    if depth[u] != -1:
        return depth[u]
    if parent[u] == -1:
        depth[u] = 0
        return 0
    else:
        d = getDepth(parent[u]) + 1
        depth[u] = d
        return d

for i in range(n):
    getDepth(i)


for i in range(n):
    temp = tree[i][0]
    print("node "+str(i), end=": ")
    print("parent = "+str(parent[i]), end=", ")
    print("depth = "+str(depth[i]),end=", ")
    if depth[i] == 0:
        print("root, [", end="")
        for j in range(temp[0]):
            if j != temp[0]-1:
                print(str(temp[1+j]),end=", ")
            else:
                print(str(temp[1+j]),end="")
        print("]")
        
    elif temp[0] == 0:
        print("leaf, []")
    else:
        print("internal node, [", end="")
        for j in range(temp[0]):
            if j != temp[0]-1:
                print(str(temp[1+j]),end=", ")
            else:
                print(str(temp[1+j])+"]")


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

#define rep(i,n) for (int i = 0; i < (n); ++i)

using namespace std;

// city, pref, num, year

int main(int argc, char** argv) {
  int N, M;
  cin >> N >> M;

  vector<vector<int>> arr(N+1);
  vector<vector<int>> cities;
  cities.reserve(M);

  rep(i, M) {
    int p, y;
    cin >> p >> y;
    arr[p].push_back(y);
    vector<int> city{p, y};
    cities.push_back(city);
  }

   rep (i, arr.size()) {
      sort(arr[i].begin(), arr[i].end());
  }

  rep (i, cities.size()) {
    auto pYears = &(arr[cities[i][0]]);
    auto it = lower_bound(pYears->begin(), pYears->end(), cities[i][1]);
    int idx = distance(pYears->begin(), it);
    printf("%06d%06d\n", cities[i][0], idx + 1);
  }

  return 0;
}


Measured memory_bytes: 12416
# coding: utf-8

number_of_jewels = int(input())
jewels_value = list(map(int, input().split()))
jewels_cost = list(map(int, input().split()))
ans = 0

jewels_value_minus_cost = [0 for i in range(number_of_jewels)]
for i in range(number_of_jewels):
    jewels_value_minus_cost[i] = jewels_value[i] - jewels_cost[i]
jewels_value_minus_cost.sort()
jewels_value_minus_cost.reverse()
for i in jewels_value_minus_cost:
    if i>0:
        ans += i
    else:
        break
print(ans)

Measured memory_bytes: 3064
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <ctime>
#include <iterator>
#include <bitset>
#include <numeric>
#include <list>
#include <iomanip>
#include <cassert>

#if __cplusplus >= 201103L
#include <array>
#include <tuple>
#include <initializer_list>
#include <unordered_set>
#include <unordered_map>
#include <forward_list>

using namespace std;

#define cauto const auto&
#define ALL(v) begin(v),end(v)
#else
#define ALL(v) (v).begin(),(v).end()
#endif

namespace{
typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
	v.assign(a, vector<T>(b, t));
}
template <class T> inline T &chmin(T &x, const T &y){ return x = min(x, y); }
template <class T> inline T &chmax(T &x, const T &y){ return x = max(x, y); }
template <class F, class T>
void convert(const F &f, T &t){
	stringstream ss;
	ss << f;
	ss >> t;
}
template <class Con>
string concat(const Con &c, const string &spr){
	stringstream ss;
	typename Con::const_iterator it = c.begin(), en = c.end();
	bool fst = true;
	for(; it != en; ++it){
		if(!fst){ ss << spr; }
		fst = false;
		ss << *it;
	}
	return ss.str();
}

template <class Con, class Fun>
vector<typename Con::value_type> cfilter(const Con &c, Fun f) {
	vector<typename Con::value_type> ret;
	typename Con::const_iterator it = c.begin(), en = c.end();
	for(; it != en; ++it){
		if(f(*it)){
			ret.emplace_back(*it);
		}
	}
	return ret;
}
#if __cplusplus >= 201402L
template <class Con, class Fun>
auto cmap(const Con &c, Fun f) -> vector<decltype(f(*c.begin()))> {
	vector<decltype(f(*c.begin()))> ret;
	ret.reserve(c.size());
	for(const auto &x: c){
		ret.emplace_back(f(x));
	}
	return ret;
}
#endif


#define REP(i,n) for(int i=0;i<int(n);++i)
#define RALL(v) (v).rbegin(),(v).rend()
#define tget(t,i) get<i>(t)

#define MOD 1000000007LL
#define EPS 1e-8


void mainmain(){
	LL a, b, n;
	cin >> a >> b >> n;
	LL t = min(n, b - 1);
	LL ans = (a * t / b) - a * (t / b);
	cout << ans << endl;
}



}
int main() try{
//	ios::sync_with_stdio(false); cin.tie(0);
	cout << fixed << setprecision(10);
	cerr << fixed << setprecision(4);
	mainmain();
}
catch(const exception &e){
	cerr << "exception: " << e.what() << endl;
	abort();
}
catch(...){
	cerr << "exception" << endl;
	abort();
}


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

int main()
{
  int a,b,c;
  double S,L;
  scanf("%d",&a);
  scanf("%d",&b);
  scanf("%d",&c);
  S=a*b*sin(c*M_PI/180)/2;
  L=sqrt(pow(a,2)+pow(b,2)-2*a*b*cos(c*M_PI/180))+a+b;
  printf("%lf\n",S);
  printf("%lf\n",L);
  printf("%lf\n",2*S/a);
  return 0;
}

Measured memory_bytes: 684
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define int long long
#define inf 1000000007
#define LINF 100000000000000007LL
#define ll long long
using namespace std;
signed main(){
	int n;
	cin>>n;
	cout<<0<<endl;
	string st;
	cin>>st;
	if( st == "Vacant" )return 0;
	int ok = 0, ng = n;
	while( ng - ok > 1 ){
		int mid = (ok+ng) / 2;
		cout<<mid<<endl;
		string resp;
		cin>>resp;
		if( resp == "Vacant" ) return 0;
		if(  ( resp == st && mid%2 == 0 ) || ( resp != st && mid % 2 == 1 ) ){
			ok = mid;
		}
		else{
			ng = mid;
		}
	}
	cout<<ng<<endl;
	return 0;
}

Measured memory_bytes: 852
S_line = [i for i in input()]
S_line_mae = [S_line[0],S_line[1]]
S_line_ushiro = [S_line[2],S_line[3]]
moji_mae = ''.join(S_line_mae)
moji_ushiro = ''.join(S_line_ushiro)

mae = int(moji_mae)
ushiro = int(moji_ushiro)
if (mae==0 or mae>=13) and ushiro>=1 and ushiro<=12:
  print('YYMM')
elif mae>=1 and mae<=12 and (ushiro==0 or ushiro>=13):
  print('MMYY')
elif mae>=1 and mae<=12 and ushiro>=1 and ushiro<=12:
  print('AMBIGUOUS')
else:
  print('NA')


Measured memory_bytes: 3064
import sys
from collections import defaultdict, deque, Counter
import math

# import copy
from bisect import bisect_left, bisect_right
# import heapq

# sys.setrecursionlimit(1000000)

# input aliases
input = sys.stdin.readline

getS = lambda: input().strip()
getN = lambda: int(input())
getList = lambda: list(map(int, input().split()))
getZList = lambda: [int(x) - 1 for x in input().split()]

INF = 10 ** 20
MOD = 10**9 + 7
divide = lambda x: pow(x, MOD-2, MOD)


def nck(n, k, kaijyo):
    return (npk(n, k, kaijyo) * divide(kaijyo[k])) % MOD


def npk(n, k, kaijyo):
    if k == 0 or k == n:
        return n % MOD
    return (kaijyo[n] * divide(kaijyo[n-k])) % MOD


def kaijyo(n):
    ret = [1]
    for i in range(1, n + 1):
        ret.append((ret[-1] * i)% MOD)
    return ret


def solve():
    n = getN()
    S = getS()
    l = 0
    r = n - 1
    # print(n, S, l, r)
    ansl, ansr = 0,0
    while S[r] == "W":
        r -= 1
        if l == r:
            print(max(ansl, ansr))
            return
    while True:
        while True:
            if S[l] == "W":
                l += 1
                ansl += 1
                # print(ansl, l, r)
                while S[l] == "R":
                    if l == r:
                        print(max(ansl, ansr))
                        return
                    l += 1
                break
            l += 1
            if l == r:
                break
            # print(l, r?)
        if l == r:
            print(max(ansl, ansr))
            return

        while True:
            if S[r] == "R":
                r -= 1
                ansr += 1
                while S[r] == "W":
                    if l == r:
                        print(max(ansl, ansr))
                        return
                    r -= 1
                break
            r -= 1
            if r == l:
                break
            # print(l, r)
        if l == r:
            print(max(ansl, ansr))
            return
    # ans2 = rc - rcnt
    # print(min(ans1,ans2))


def main():
    n = getN()
    for _ in range(n):
        solve()


if __name__ == "__main__":
    # main()
    solve()

Measured memory_bytes: 68580
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int h, w;
char a[1005][1005];
ll dp[1005][1005];
int vis[1005][1005];
ll MOD = 1e9 + 7;
int main() {
  int h, w;
  cin >> h >> w;
  for (int i = 1; i <= h; i++) {
    for (int j = 1; j <= w; j++) {
      cin >> a[i][j];
    }
  }
  queue<pair<int, int>> q;
  dp[1][1] = 1;
  q.push({1, 1});
  while (!q.empty()) {
    pair<int, int> u = q.front();
    q.pop();
    if (u.second + 1 <= w && a[u.first][u.second + 1] == '.') {
      dp[u.first][u.second + 1] =
          (dp[u.first][u.second + 1] + dp[u.first][u.second]) % MOD;
      if (!vis[u.first][u.second + 1]) {
        q.push({u.first, u.second + 1});
        vis[u.first][u.second + 1] = 1;
      }
    }
    if (u.first + 1 <= h && a[u.first + 1][u.second] == '.') {
      dp[u.first + 1][u.second] =
          (dp[u.first + 1][u.second] + dp[u.first][u.second]) % MOD;
      if (!vis[u.first + 1][u.second]) {
        q.push({u.first + 1, u.second});
        vis[u.first + 1][u.second] = 1;
      }
    }
  }
  cout << dp[h][w] << endl;
}


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

int main(void){
  int N,tmp,ans=0;
  int d[100]={};
  cin >> N;
  for(int i=0;i<N;i++){
    cin >> tmp;
    d[tmp-1]++;
  }
  for(int i=0;i<100;i++){
      ans+=(d[i]>0);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)


int main() {
	int a, b;
	cin >> a >> b;
	if (a < 10 && b < 10) cout << a * b << endl;
	else cout << "-1" << endl;

}

Measured memory_bytes: 256
#include <cstdio>
#include <climits>
#include <cassert>
#include <cmath>
#include <iostream>
#include <string>
#include <algorithm>
#include <numeric>
#include <functional>
#include <tuple>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <vector>

#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
#define FOR(x,xs) for(auto &x: xs)

using namespace std;
typedef long long ll;
typedef pair<int,int> PI;
typedef pair<ll,ll> PL;
typedef vector<int> VI;
typedef vector<ll> VL;

ll solve(VL &as, bool positive) {
  ll ans = 0;
  ll sum = 0;
  FOR(a,as) {
    ll nsum = sum + a;
    if(positive) {
      if(nsum <= 0) {
        ans += 1 - nsum;
        nsum = 1;
      }
    } else {
      if(nsum >= 0) {
        ans += 1 + nsum;
        nsum = -1;
      }
    }
    sum = nsum;
    positive = !positive;
  }
  return ans;
}

int main() {
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  VL as(n);
  FOR(a,as) {
    cin >> a;
  }
  cout << min(solve(as, true), solve(as, false)) << endl;
  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 eee(a) (cerr << (#a) << ": " << (a) << endl);

using ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;
using mint = map<int, int>;

int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

const char sp = ' ';
const char cmm = ',';
const int MOD = 1e9+7;
const int INF = 1e9;
const ll LINF = 1e18;

ll mod(ll a, ll b){
    return (a%b+b)%b;
}
ll gcd(ll a, ll b){
    return b ? gcd(b, a%b) : a;
}
ll lcm(ll a, ll b){
    return a*b/gcd(a, b);
}
void Yes(){
    cout << "Yes" << endl;
}
void No(){
    cout << "No" << endl;
}
void Judge(bool b){
    b ? Yes() : No();
}
void YES(){
    cout << "YES" << endl;
}
void NO(){
    cout << "NO" << endl;
}
void JUDGE(bool b){
    b ? YES() : NO();
}
ll powmod(ll b, ll e){
    ll r = 1; while(e > 0) {if(e&1) r = (r%MOD)*(b%MOD)%MOD; b = (b%MOD)*(b%MOD)%MOD; e >>= 1;} return r;
}
double distance(ll x1, ll y1, ll x2, ll y2){
    return sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));
}

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>
void ppp(T n){
    cout << n << endl;
}
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {
    return s << "(" << p.first << ", " << p.second << ")";
}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
    int len = v.size();
    s << '[';
    for(int i = 0; i < len; ++i) {
        s << v[i]; if(i < len-1) s << ", ";
    }
    s << ']';
    return s;
}

struct aaa {
    aaa(){
        cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(15);
    };
} fastio;

vector<vector<pair<ll, ll> > > Gyen;
vector<vector<pair<ll, ll> > > Gsnuke;

vector<long long> dijkstra(ll s, ll n, vector<vector<pll> > G){
    vector<ll> dis(n, LINF);
    priority_queue<pll, vector<pll>, greater<pll> > q;
    dis[s] = 0;
    q.push(make_pair(0, s));
    while(!q.empty()) {
        ll d, v;
        tie(d, v) = q.top(); q.pop();
        if(dis[v] < d) continue;
        for(pair<ll, ll> e : G[v]) {
            if(dis[e.second] > dis[v]+e.first) {
                dis[e.second] = dis[v]+e.first;
                q.push({dis[e.second], e.second});
            }
        }
    }
    return dis;
}

int main(){

    ll n, m, s, t;
    cin >> n >> m >> s >> t;
    --s; --t;
    Gyen.resize(n);
    Gsnuke.resize(n);
    rep(i, m){
        ll u, v, a, b;
        cin >> u >> v >> a >> b;
        --u; --v;
        Gyen[u].emplace_back(a, v);
        Gyen[v].emplace_back(a, u);
        Gsnuke[u].emplace_back(b, v);
        Gsnuke[v].emplace_back(b, u);
    }

    vector<ll> disty = dijkstra(s, n, Gyen);
    vector<ll> dists = dijkstra(t, n, Gsnuke);

    vector<ll> ans(n);
    ll Min = LINF;
    for(int i = n-1; i >= 0; --i){
        Min = min(Min, disty[i]+dists[i]);
        ans[i] = 1e15-Min;
    }
    for(ll x : ans) ppp(x);
    return 0;
}


Measured memory_bytes: 26684
h, w = map(int, input().split())
s = [input() for _ in range(h)]
"""
    全ての位置が0のマップ(二次元リスト)を新しく作る
    #の位置を調べてその位置を+9、周囲を+1
        位置が端なら加算は片側のみ
    8以下の数値を文字列として、9以上の数値を#として結合
"""
new_map = [[0 for _ in range(w)] for _ in range(h)]


def mine_count(i, j):
    """現在地に+9と周囲に+1"""
    new_map[i][j] += 9
    if i != 0:
        new_map[i-1][j] += 1
    if i != (h-1):
        new_map[i+1][j] += 1
    if j != 0:
        new_map[i][j-1] += 1
    if j != (w-1):
        new_map[i][j+1] += 1
    if i != 0 and j != 0:
        new_map[i-1][j-1] += 1
    if i != 0 and j != (w-1):
        new_map[i-1][j+1] += 1
    if i != (h-1) and j != 0:
        new_map[i+1][j-1] += 1
    if i != (h-1) and j != (w-1):
        new_map[i+1][j+1] += 1


# 白紙だったnew_mapを完成させる
for i in range(h):
    for j in range(w):
        if s[i][j] == '#':
            mine_count(i, j)
# 文字列に変換、内包表記できるだろうか？
for i in range(h):
    for j in range(w):
        if new_map[i][j] <= 8:
            new_map[i][j] = str(new_map[i][j])
        else:
            new_map[i][j] = '#'
# 連結して出力
for i in range(h):
    print(''.join(new_map[i]))


Measured memory_bytes: 3188
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
#define INF 1<<50LL
#define fst first
#define snd second
#define pb push_back
#define int long long
#define ALL(obj) (obj).begin(), (obj).end()
#define FOR(i,a,b) for(auto i=(a);i<(b);i++)
#define RFOR(i,a,b) for(auto i = (b-1);i>=a;i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define debug(x)  cout << #x << " = " << (x) << endl;
typedef long long ll;
typedef pair<ll,ll> P;

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

  vector<ll> a(3);
  cin >> a[0] >> a[1] >> a[2];
  
  sort(ALL(a));
  
  if(a[0]%2 == 0 || a[1]%2 == 0 || a[2] %2 == 0) cout << 0 << endl;
  else	cout << a[0]*a[1] << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define finish(x) return cout << x << endl, 0
#define ll long long

const int N = 200001;

int n;
vector <int> p, v[N];

int mex(vector <int> &all){
    sort(all.begin(), all.end());
    all.erase(unique(all.begin(), all.end()), all.end());
    int ret = 0;
    while(ret < (int)all.size() && ret == all[ret]) ret++;
    return ret;
}
void go(int cur, vector <int> ans){
    while(ans[cur] == -1){
        vector <int> all;
        for(auto &i : v[cur]){
            all.push_back(ans[i]);
        }
        ans[cur] = mex(all);
        cur = p[cur];
    }
    vector <int> all;
    for(auto &i : v[cur]){
        all.push_back(ans[i]);
    }
    if(mex(all) == ans[cur]){
        cout << "POSSIBLE" << endl;
        exit(0);
    }
}
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin >> n;
    p.resize(n);
    vector <int> d(n);
    for(int i = 0 ; i < n ; i++){
        cin >> p[i];
        p[i]--;
        v[p[i]].push_back(i);
        d[p[i]]++;
    }
    vector <int> ans(n, -1);
    deque <int> ready;
    for(int i = 0 ; i < n ; i++){
        if(d[i] == 0) ready.push_back(i);
    }
    while(ready.size()){
        int top = ready.front();
        ready.pop_front();
        vector <int> all;
        for(auto &i : v[top]){
            all.push_back(ans[i]);
        }
        ans[top] = mex(all);
        d[p[top]]--;
        if(d[p[top]] == 0) ready.push_back(p[top]);
    }
    int f = -1;
    for(int i = 0 ; i < n ; i++){
        if(ans[i] == -1) f = i;
    }
    vector <int> all;
    for(auto &i : v[f]){
        if(ans[i] == -1) continue;
        all.push_back(ans[i]);
    }
    ans[f] = mex(all);
    go(p[f], ans);
    all.push_back(ans[f]);
    ans[f] = mex(all);
    go(p[f], ans);
    cout << "IMPOSSIBLE" << endl;
}


Measured memory_bytes: 13440
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
using namespace std;
typedef long long int ll;

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    string s; cin >> s;
    if(s=="ABC")printf("ARC\n");
    else printf("ABC\n");
}

Measured memory_bytes: 3612
x=input()
l=len(x)
maxx =[0]
a=0
for i in range(l):
  if x[i]=='A' or x[i]=='T' or x[i]=='C' or x[i]=='G':
    a+=1
    #print(a)
    maxx.append(a)
  else:
    a=0
print(max(maxx))

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

int N;
int dp[110000];

int main(void){
  cin >> N;
  const int INF = 1e8;
  for(int i=0; i<110000; i++) dp[i] = 1e8;

  dp[0]=0;
 
  for(int i=0; i<=N; i++){
/*
    // 9で
    int mul1 = 9;
    for(int j=1; mul1 <= N; j++){
      dp[i+mul1] = min(dp[i+mul1], dp[i] + j);
      mul1 *= 9;
    }
    // 6で
    int mul2 = 6;
    for(int j=1; mul2 <= N; j++){
      dp[i+mul2] = min(dp[i+mul2], dp[i] + j);
      mul2 *= 6;
    }
*/    
    // 9で
    for(int j=9; i + j <= N; j*=9){
      dp[i+j] = min(dp[i+j], dp[i] + 1);
    }
    // 6で
    for(int j=6; i + j <= N; j*=6){
      dp[i+j] = min(dp[i+j], dp[i] + 1);
    }
    // 1で
    for(int j=1; (i + j <= N) && (j <= 6); j++){
      dp[i+j] = min(dp[i+j], dp[i] + j);
    }
  }
//  for(int i=0; i<=N; i++) cout << i << ", ";
//  cout << endl;
//  for(int i=0; i<=N; i++) cout << dp[i] << ", ";
//  cout << endl;
  cout << dp[N] << endl;
  return 0;
}

Measured memory_bytes: 640
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author champon
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define inf 9e18
#define ceill(a, b) (a+b-1)/b
#define ok cout << "ok" << endl;
#define sp << " " <<
ll mod = 1e9+7;
void ans(bool b, ostream& out=cout){ out << (b ? "Yes" : "No") << endl; }
void ans2(bool b, ostream& out=cout){ out << (b ? "YES" : "NO") << endl; }
template<typename T> inline bool chmax(T &a, T b){ if(a<b){a=b; return true;} return false; }
template<typename T> inline bool chmin(T &a, T b){ if(b<a){a=b; return true;} return false; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val){fill((T*)array, (T*)(array+N), val);}
int dx[] = {1, 0, -1, 0, 1, -1, 1, -1};
int dy[] = {0, 1, 0, -1, 1, -1, -1, 1};

#ifndef INCLUDE_DEBUG_HPP
#define INCLUDE_DEBUG_HPP

class debug
{
public:
    template<typename T> void vdeb(T vec);
    template<typename T1, typename T2> void adeb(T1 *arr, T2 n);
    template<typename T> void mdeb(T mp);
};

#endif //INCLUDE_DEBUG_HPP

template<typename T> void debug::vdeb(T vec)
{
    cout << "#vector set debug" << endl;
    for(auto vv : vec) cout << vv << " ";
    cout << endl;
}

template<typename T1, typename T2> void debug::adeb(T1 *arr, T2 n)
{
    cout << "#adebug" << endl;
    for(int i=0; i<=n; i++) cout << arr[i] << " ";
    cout << endl;
}

template<typename T> void debug::mdeb(T mp)
{
    cout << "#map pair debug" << endl;
    for(auto const& m : mp) cout << m.first sp m.second << endl;
}
debug dbg;

class BRuinedSquare {
public:
	void solve(std::istream& in, std::ostream& out)
	{
        int x1, y1, x2, y2;
        in >> x1 >> y1 >> x2 >> y2;

        int dlx = x2-x1;
        int dly = y2-y1;

        out << x2 - dly sp y2 + dlx sp x1 - dly sp y1 + dlx << endl;
	}
};


int main() {
	BRuinedSquare solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 384
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#define L 1201

void ini(char h[]);
void count(char h[], int a[], int N, int n);
void print(int a[]);

int main(void){

  int i;
  int a[26];
  char h[L];
  char c='0';

  for(i=0;i<26;i++){
    a[i] = 0;
  }

  while(c != EOF){
    scanf("%[^\n]", h);

    for(i='a';i<='z';i++){
      count(h, a, L, i);
    }
    ini(h);
    c = getchar();
  }

  print(a);

  return 0;
}

void ini(char h[]){
  int i;
  for(i=0;i<L;i++){
    h[i] = '\0';
  }
}

void count(char h[], int a[], int N, int n){
  int i, j=0;
  for(i=0;i<N;i++){
    if(h[i] == '\0') break;
    if(h[i] == n){
      j++;
    }else if(h[i] == n-32){
      j++;
    }
  }
  a[n-97] += j;
}

void print(int a[]){
  int i;
  for(i=0;i<26;i++){
    printf("%c : %d\n", i+97, a[i]);
  }
}



Measured memory_bytes: 2048
#include <iostream>
#include <vector>
#include <algorithm>

#define N 1000000

using namespace std;

vector<int> primes;

void init_primes() {
    for (int p=2; p<N; p++) {
        bool is_prime = true;
        for (vector<int>::iterator iter=primes.begin(); iter!=primes.end(); iter++) {
            if (p%(*iter) == 0) {
                is_prime = false;
                break;
            }
            if ((*iter)*(*iter) > p) {
                break;
            }
        }
        if (is_prime) {
            primes.push_back(p);
        }
    }
}

int matsuzaki(int n, int p) {
    vector<int> candidates;
    vector<int>::iterator iter1, iter2;
    iter1 = upper_bound(primes.begin(), primes.end(), n);
    for (int i=0; i<p && iter1!=primes.end(); i++, iter1++) {
        iter2 = iter1;
        for (int j=0; j<p && iter2!=primes.end(); j++, iter2++) {
            candidates.push_back((*iter1)+(*iter2));
        }
    }
    sort(candidates.begin(), candidates.end());
    return candidates[p-1];
}

int main() {
    int n, p;
    init_primes();
    while (true) {
        cin >> n >> p;
        if (n < 0) {
            return 0;
        }
        cout << matsuzaki(n, p) << endl;
    }
}

Measured memory_bytes: 1592
#include<bits/stdc++.h>
using namespace std;
#define LL long long
#define ULL unsigned long long
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define pll pair<LL,LL>
#define x first
#define y second
#define pi acos(-1)
#define sqr(x) ((x)*(x))
#define pdd pair<double,double>
#define MEMS(x) memset(x,-1,sizeof(x))
#define MEM(x) memset(x,0,sizeof(x))
#define less Less
#define EPS 1e-4
#define arg ARG
#define cpdd const pdd
#define rank Rank
vector<int> v[200005];
int main(){
    int n;
    scanf("%d",&n);
    pii p[100005];
    map<int,int> m;
    for(int i = 0;i<n;i++){
        int x,l;
        scanf("%d %d",&x,&l);
        p[i]=mp(x-l,x+l);
        m[p[i].x];
        m[p[i].y];
    }
    int index=0;
    for(auto& it:m){
        it.y=++index;
    }
    for(int i = 0;i<n;i++){
        v[m[p[i].y]].pb(m[p[i].x]);
    }
    int dp[200005];
    dp[0]=0;
    for(int i = 1;i<=index;i++){
        dp[i]=dp[i-1];
        for(auto it:v[i]){
            dp[i]=max(dp[i],dp[it]+1);
        }
    }
    printf("%d\n",dp[index]);
}
/*
2 6
5 7
7 5
4 3
6 4
7 3
6 5
5 7
3 6
4 7
*/
//a+a+1=10a+1
//3a+2=10a+2

Measured memory_bytes: 18944
#include<iostream>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<algorithm>
#include<unordered_map>
#include<set>
#include<cmath>
#include<stack>
#include<iomanip>
#include<cstdio>
using namespace std;
int main()
{
    long long int x,y,red,green,non,temp,ans=0;
    vector<long long int> hong;
    vector<long long int> lvse;
    vector<long long int> wuse;
    cin>>x>>y>>red>>green>>non;
    for(long long int i = 1;i<=red;i++)
    {
        cin>>temp;
        hong.push_back(temp);
    }
    for(long long int i =1;i<=green;i++)
    {
        cin>>temp;
        lvse.push_back(temp);
    }
    for(long long int i = 1;i<=non;i++)
    {
        cin>>temp;
        wuse.push_back(temp);
    }
    sort(hong.begin(),hong.end());
    sort(lvse.begin(),lvse.end());
    sort(wuse.begin(),wuse.end());
    vector<long long int> total;
    long long int t1=hong.size()-1,t2=lvse.size()-1,t3=wuse.size()-1;
    long long int tool=t1;
    for(long long int i = 1;i<=x;i++)
        total.push_back(hong.at(tool--));
    tool=t2;
    for(long long int i = 1;i<=y;i++)
        total.push_back(lvse.at(tool--));
    for(long long int i=0;i<=t3;i++)
        total.push_back(wuse.at(i));
    sort(total.begin(),total.end());
    long long int tol=total.size()-1;
    for(long long int i =1;i<=x+y;i++)
        ans+=total.at(tol--);
 
    cout<<ans<<endl;
  return 0;
}



Measured memory_bytes: 8688
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996)
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
#define MOD 1000000007
using namespace std;


int main(int argc, char* argv[])
{
    long x, y, z, k;
    scanf("%ld%ld%ld%ld", &x, &y, &z, &k);

    vector<ll> a(x), b(y), c(z);
    long i, j;
    for(i=0; i<x; i++) {
        scanf("%lld", &a[i]);
    }
    for(i=0; i<y; i++) {
        scanf("%lld", &b[i]);
    }
    for(i=0; i<z; i++) {
        scanf("%lld", &c[i]);
    }

    vector<pair<ll, ll> > zz; 
    for(i=0; i<x; i++) {
        for(j=0; j<y; j++) {
            zz.push_back(make_pair(a[i] + b[j], (ll)i*10000+j));
        }
    }
    sort(zz.rbegin(), zz.rend());
    sort(c.rbegin(), c.rend());

    vector<pair<ll, ll> > aa;
    long num0 = MIN(k, zz.size());
    long num1 = MIN(k, c.size());
    for(i=0; i<num0; i++) {
        for(j=0; j<num1; j++) {
            aa.push_back(make_pair(zz[i].first+c[j], i*10000+j));
        }
    }
    sort(aa.rbegin(), aa.rend());

    for(i=0; i<k; i++) {
        printf("%lld\n", aa[i].first);
    }


    return 0;
}


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

using namespace std;

using ll = long long;

const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;

template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}

int main () {
  cin.tie(0);
  cout << fixed << setprecision(10);

  map<char, int> mp;
  for(int i=2;i<=9;++i) {
    mp[(char)i + '0'] = i;
  }
  mp['T'] = 10;
  mp['J'] = 11;
  mp['Q'] = 12;
  mp['K'] = 13;
  mp['A'] = 14;

  while(1) {
    char t; cin >> t;
    if(t == '#') break;
    vector<vector<pair<int, char>>> a(4);
    for(int i=0;i<4;++i) {
      for(int j=0;j<13;++j) {
        string s; cin >> s;
        a[i].push_back(make_pair(mp[s[0]], s[1]));
      }
    }

    int trns = 0, trew = 0;
    int lead = 0;
    for(int i=0;i<13;++i) {
      char suit = a[lead][i].second;

      bool tr = suit == t;
      int trma = (tr ? a[lead][i].first : 0);
      int ma = a[lead][i].first;
      int argma = lead;

      for(int j=0;j<4;++j) {
        if(j == lead) continue;
        if(a[j][i].second == t && a[j][i].first > trma) {
          tr = true;
          trma = a[j][i].first;
          argma = j;
        } else if(!tr && a[j][i].second == suit && a[j][i].first > ma) {
          ma = a[j][i].first;
          argma = j;
        }
      }

      lead = argma;
      if(argma == 0 || argma == 2) trns++;
      else trew++;
    }

    if(trns > trew) {
      cout << "NS" << " " << trns - 6 << endl;
    } else {
      cout << "EW" << " " << trew - 6 << endl;
    }

  }
}



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

int main()
{
    int x, y,k;cin>>x>>y>>k;int cnt=0;
    for(int i=min(x,y);i>=1;i--)
    {
    	
    	if(x%i==0&&y%i==0)
    	{
    		cnt++;//cout<<i<<endl;
			if(cnt==k)
    		{
    			cout<<i<<endl;return 0;
			}
		}
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

int cnt[10010];

int main() {
    ios_base::sync_with_stdio(0);
    int n; cin >> n;
    for (int x=1;x<=100;x++) {
        for (int y=1;y<=100;y++) {
            for (int z=1;z<=100;z++) {
                int val = x*x+y*y+z*z+x*y+y*z+x*z;
                if (val<=10000) cnt[val]++;
            }
        }
    }

    for (int i=1;i<=n;i++) cout << cnt[i] << endl;
}


Measured memory_bytes: 3524
#include <iostream>
#include <fstream>
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iomanip>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <sstream>
#include <string>
#include <vector>
using namespace std;

#define EPS 1e-9
#define INF MOD
#define MOD 1000000007LL
#define fir first
#define iss istringstream
#define sst stringstream
#define ite iterator
#define ll long long
#define mp make_pair
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<n;i++)
#define pi pair<int,int>
#define pb push_back
#define sec second
#define sh(i) (1LL<<i)
#define sz size()
#define vi vector<int>
#define vc vector
#define vl vector<ll>
#define vs vector<string>

#define T pair<pi,int>

int n,h,a,b;
string s;

int main(){
	while(cin>>n>>h&&n){
		set<T> S;
		rep(i,h){
			cin>>s>>a>>b;
			if(s=="xy")rep(i,n)S.insert(T(pi(a,b),i+1));
			if(s=="yz")rep(i,n)S.insert(T(pi(i+1,a),b));
			if(s=="xz")rep(i,n)S.insert(T(pi(a,i+1),b));
		}
		cout<<n*n*n-S.sz<<endl;
	}
}

Measured memory_bytes: 0
#include <iostream>
#include<cmath>
using namespace std;
struct Card{char suit,value;};

void bubble(struct Card A[],int n){
    for(int i=0;i<n;i++){
        for(int j=n-1;j>i;j--){
            if(A[j].value<A[j-1].value){
                Card t = A[j];A[j]=A[j-1];A[j-1]=t;}
        }
    }
}
void selection(struct Card A[],int n){
    for(int i=0;i<n;i++){
        int minj=i;
        for(int j=i;j<n;j++){
            if(A[j].value<A[minj].value)minj=j;
        }
        Card t = A[i];A[i]=A[minj];A[minj]=t;
        
    }
    }

void print(struct Card A[],int n){
    for(int i=0;i<n;i++){
        if(i >0)cout<<" ";
        cout<<A[i].suit<<A[i].value;
    }
    cout<<endl;

}
bool isStable(struct Card C1[],struct Card C2[],int n){
    for(int i=0;i<n;i++){
        if(C1[i].suit !=C2[i].suit)return false;
    }
    return true;
}

int main(){
    int n;
    cin>>n;
    Card C1[100],C2[100];
    
    for(int i=0;i<n;i++){
        cin>>C1[i].suit>>C1[i].value;
        //C2[i]=C2[i];
    }
    for(int i=0;i<n;i++){
        C2[i]=C1[i];
    }
    bubble(C1,n);
    selection(C2,n);
    
    print(C1,n);
    cout<<"Stable"<<endl;
    print(C2,n);
    if(isStable(C1,C2,n)){
        cout<<"Stable"<<endl;
    }else {
        cout<<"Not stable"<<endl;
    }
    
    
    
    
    return 0;
}


Measured memory_bytes: 3112
#include<bits/stdc++.h>
using namespace std;
int a[1000000],n,m,c,d;
int main(){
	int sum=0;
	cin>>n;for(int i=1;i<=n;i++){cin>>a[i];sum+=a[i];}
	cin>>m;
	for(int i=0;i<m;i++){
		cin>>c>>d;cout<<sum-a[c]+d<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
//@author yash2040
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define ll long long
#define int long long
#define pb push_back
//#define mod 1000000007
#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
int power(int a,int b,int mod)
{
	int res=1;
	while(b!=0)
	{
		if(b%2==1)
		res=(res%mod*a%mod)%mod;
		b=b/2;
		a=(a%mod*a%mod)%mod;
	}
	return res;
}
int32_t main()
{
	fast();
	int t=1;
//	cin>>t;
	while(t--)
	{
		int n;
		cin>>n;
		if(n==1)
		{
			cout<<0;
			exit(0);
		}
		//int x=(n*(n-1))/2;
		//x=x*2;
		int mod=1000000007;
		int y=(power(9,n,mod)%mod-power(8,n,mod)%mod)%mod;
		int x=((power(10,n,mod)%mod)%mod-(2*y)%mod-(power(8,n,mod)%mod)%mod+mod)%mod;
		cout<<x;	
	}
}








Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    int h, w, n, a[100005] = {}, b[100005] = {};
    set<pii> s, z[10] = {};
    cin >> h >> w >> n;
    for (int i = 0; i < n; i++) cin >> a[i] >> b[i], s.insert({a[i], b[i]});
    for (int i = 0; i < n; i++) {
        for (int j = -1; j <= 1; j++) {
            for (int k = -1; k <= 1; k++) {
                if (a[i] + j - 1 > 0 && a[i] + j + 1 <= h && b[i] + k - 1 > 0 && b[i] + k + 1 <= w) {
                    int c = 0;
                    for (int l = -1; l <= 1; l++) {
                        for (int m = -1; m <= 1; m++) {
                            if (s.find({a[i] + j + l, b[i] + k + m}) != s.end()) c++;
                        }
                    }
                    z[c].insert({a[i] + j, b[i] + k});
                }
            }
        }
    }
    ll y = (ll)(h - 2) * (w - 2);
    for (int i = 1; i <= 9; i++) y -= z[i].size();
    cout << y << '\n';
    for (int i = 1; i <= 9; i++) cout << z[i].size() << '\n';
}


Measured memory_bytes: 49792
#include <iostream>
#include <algorithm>
#include <map>
#include <string>
#include <cmath>

#define mod 1000000007

using namespace std;
 
int main(void){
	
	int N, x, count=0, n;
	
	cin >> N >> x;
	
	n = x;
	
	int a[N];
	
	for(int i=0; i<N; i++)
		cin >> a[i];
	
	sort(a, a+N);
	
	for(int i=0; i<N; i++){
		n -= a[i];
		if(n < 0){
			cout << count;
			return 0;
		}
		count++;
	}
	
	if(n > 0)
		cout << count-1;
	else
		cout << count;
	
	return 0;
}

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

using namespace std;
const int N=2e5+5;
int a[N];
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    int a,b,c;
    cin>>a>>b>>c;
    if(a==b&&b==c) cout<<"No"<<endl;
    else if(a==b||a==c||b==c) cout<<"Yes"<<'\n';
    else cout<<"No"<<'\n';
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <utility>
#include <string>
#include <stack>
#include <regex>
 
#define REP(i, n) for (int i = 0; i < n; i++)
#define ALL(v) (v).begin(), (v).end()
 
using namespace std;
 
typedef long long ll;

int main(int argc, char const *argv[])
{
  int n,k;
  cin >> n >> k;
  vector<int> a(n);
  REP(i,n) {
    cin >> a[i];
  }
  cout << (n-1)/(k-1) + ((n-1)%(k-1) == 0 ? 0 : 1) << endl;;
  return 0;
}


Measured memory_bytes: 640
from collections import Counter
n = int(input())

a = list(map(int,input().split()))
q = int(input())

cnt = Counter(a)
tot = 0
for k,v in cnt.items():
    tot += (k*v)

for i in range(q):
    b,c = map(int,input().split())
    tot -= b*cnt[b]
    tot -= c*cnt[c]
    cnt[c] += cnt[b]
    cnt[b] = 0
    tot += b*cnt[b]
    tot += c*cnt[c]
    print(tot)


Measured memory_bytes: 91408
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#define mod 1000000009
typedef long long ll;
using namespace std;

const int MAX = 100005;
int dp[MAX][3];
int a[MAX];
int b[MAX];
int c[MAX];
int n;

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

  dp[1][0] = max(b[1], c[1]);
  dp[1][1] = max(a[1], c[1]);
  dp[1][2] = max(a[1], b[1]);

  for(int i=2;i<=n;i++){
    dp[i][0] = max(dp[i-1][1] + a[i], dp[i-1][2] + a[i]);
    dp[i][1] = max(dp[i-1][0] + b[i], dp[i-1][2] + b[i]);
    dp[i][2] = max(dp[i-1][0] + c[i], dp[i-1][1] + c[i]);
  }

  cout << max(dp[n][0],max(dp[n][1],dp[n][2])) << endl;
  return 0;
}

Measured memory_bytes: 2560