akhauriyash/Code-Regression huggingface dataset:
//
//  main.cpp
//

#include <algorithm>
#include <array>
#include <assert.h>
#include <complex>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <math.h>
#include <memory>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

using ll = int64_t;
using ull = uint64_t;
constexpr ll LL_MAX = numeric_limits<ll>::max();
constexpr ull ULL_MAX = numeric_limits<ull>::max();

template<typename T>
vector<T> make_vec_nd(T init, ll size) {
	return vector<T>(size, init);
}
template<typename T, typename... Args>
auto make_vec_nd(T init, ll size, Args... rest) {
	auto inner = make_vec_nd(init, rest...);
	return vector<decltype(inner)>(size, inner);
}

#define rep(i, a, b) for (ll i = (a); i < (b); i++)
#define rrep(i, a, b) for (ll i = (a)-1; i >= (b); i--)

ll digit_sum(ll val) {
    ll ret = 0;
    while (val > 0) {
        ret += val % 10;
        val /= 10;
    }
    return ret;
}

int main() {
    ll K;
    cin >> K;
    vector<ll> ans;
    ll pow = 1;
    for (ll k = 0; k < 16; k++) {
        for (ll n = 1;; n++) {
            ll val = n * pow + (pow - 1);
            if (val >= (k+1)*pow*10) {
                break;
            }
            if (ans.size() == 0 || ans.back() < val) {
                ans.push_back(val);
            }
        }
        pow *= 10;
    }
    ll cnt = 0;
    rep(i,0,ans.size()) {
        ll n = ans[i];
        bool ok = true;
        rep(j,i+1,ans.size()) {
            ll m = ans[j];
            if ((__int128)n * (__int128)digit_sum(m) > (__int128)m * (__int128)digit_sum(n)) {
                ok = false;
                break;
            }
        }
        if (ok) {
            cout << n << endl;
            cnt++;
            if (cnt == K) {
                break;
            }
        }
    }
}



Measured memory_bytes: 256
import sys
read = sys.stdin.read

n, *A = map(int, read().split())
S = sorted([(a, i) for i, a in enumerate(A)], reverse=True)
X, Y = zip(*S)
m = 10**9
L = [0]*n
for i, y in enumerate(Y):
  m = min(m, y)
  if i == n-1:
    L[m] += (i+1) * X[i]
  else:
    L[m] += (i+1) * (X[i] - X[i+1])
print(*L, sep="\n")

Measured memory_bytes: 25972
#include<iostream>
#include<algorithm>
#include<vector>
#include<cmath>
using namespace std;

int main(){
    int a, b, ab, x, y;
    cin >> a >> b >> ab >> x >> y;

    int min_v = min(a+b, ab*2);

    int ans = 0;
    if(min_v == a+b){
        //cout << a*x + b*y << endl;
        ans = min(x, y) * a + min(x, y) * b;
        if(min(x, y) == x){
            if(b >= ab*2){
                ans += ab*2 * (y-x);
            }
            else {
                ans += b * (y-x);
            }
        }
        else {
            if(a >= ab*2){
                ans += ab*2 * (x-y);
            }
            else {
                ans += a * (x-y);
            }
        }
        cout << ans << endl;
    }
    else {
        ans = min(x, y) * ab*2;
        if(min(x, y) == x){
            if(b >= ab*2){
                ans += ab*2 * (y-x);
            }
            else {
                ans += b * (y-x);
            }
        }
        else {
            if(a >= ab*2){
                ans += ab*2 * (x-y);
            }
            else {
                ans += a * (x-y);
            }
        }
        cout << ans << endl;
    }

}

Measured memory_bytes: 256
<?php 
$str = trim(fgets(STDIN));
$map = [];
for($a = "a"; strlen($a) == 1; $a++)$map[$a] = true;
for($i = 0; $i < strlen($str); $i++){
    unset($map[$str[$i]]);
}
foreach($map as $k => $v){
    echo $k;exit;
}
echo "None";

Measured memory_bytes: 4728
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
typedef long long ll;

/*
*/

ll n,x[70],y[60],ans=1e18;

void init(){
	cin>>n;
	rep(i,n){
		cin>>x[i]>>y[i];
	}
	ans=n;
}

int main(void){
	init();
	rep(i,n){
		rep(j,n){  // p,qの候補
			if(i==j)continue;
			ll d[51]={},par[51];
			ll sum=0,p=x[i]-x[j],q=y[i]-y[j];
			rep(k,n)par[k]=-1;
			// グラフを張る
			rep(k,n){
				rep(l,n){
					if(x[k]-x[l]==p && y[k]-y[l]==q)par[k]=l;
				}
			}
			rep(k,n)if(par[k]==-1)sum++;
			ans=min(ans,sum);
			// rep(k,n)cerr<<par[k]<<" ";
			// cerr<<endl;
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.*

private fun readStrings() = readLine()!!.split(" ")
private fun readInts() = readStrings().map { it.toInt() }

private inline fun <T, R> Collection<T>.scanIndexed(initial: R, operation: (Int, R, T) -> R): List<R> {
    val result = ArrayList<R>(size)
    var prevResult = initial
    forEachIndexed { index, element ->
        val elementResult = operation(index, prevResult, element)
        result.add(elementResult)
        prevResult = elementResult
    }
    return result
}

private inline fun <T, R> Collection<T>.scan(initial: R, operation: (R, T) -> R): List<R>
        = scanIndexed(initial) {i, list, elem -> operation(list, elem) }

private fun String.toModCumulative() = toList().scan(0) { cum, char ->
    cum + if(char == 'A') 1 else 2
}

fun main(args: Array<String>) {
    val S = readLine()!!
    val T = readLine()!!
    val q = readInts()[0]
    val queries = (0 until q).map { readInts() }

    val sCumulative = listOf(0) + S.toModCumulative()
    val tCumulative = listOf(0) + T.toModCumulative()

    queries.forEach {
        val (a, b, c, d) = it
        val sMod = sCumulative[b] - sCumulative[a - 1]
        val tMod = tCumulative[d] - tCumulative[c - 1]
        println(if(sMod % 3 == tMod % 3) "YES" else "NO")
    }
}

Measured memory_bytes: 88204
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
using ll = long long;
using ldb = long double;
using pa = pair < ll, ll >;
using vec = vector < ll >;
 
template < typename T > using index_set = tree < T, null_type, less < T >, rb_tree_tag, tree_order_statistics_node_update >;
template < typename T > using MinPriorityQueue = priority_queue < T, vector < T >, greater < T > >;

#define pb push_back
#define po pop_back
#define mp make_pair
#define mt make_tuple
#define F  first
#define S  second
#define f(i,x,n) for(ll i=x;i<n;i++) 
#define unique_sort(x) sort(all(x)), x.resize(distance(x.begin(), unique(all(x))))
#define all(c) c.begin(),c.end()
#define str string
#define edl "\n"
#define add insert
#define cot continue
#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL)


const int MOD = 1e9 + 7, INF = INT_MAX, N = 1e5 + 10;
const double PI = acos(-1);
const ll LINF = LLONG_MAX;

ll dp[1001][1001];
char ch[10001][10001];

int main() 
{

    fast();
      

    ll n,m;
    cin>>n>>m;
    memset(dp,0,sizeof(dp));
    f(i,0,n)
    {
      f(j,0,m)
      {
        cin>>ch[i][j];
      }
    }
    if(ch[0][0]=='.')
    {
      dp[0][0]=1;
    }
    f(i,1,n)
    {
      if(ch[i][0]=='.')
        dp[i][0]=dp[i-1][0];
    }
    f(i,1,m)
    {
      if(ch[0][i]=='.')
        dp[0][i]=dp[0][i-1];
    }
    f(i,1,n)
    {
      f(j,1,m)
      {
        if(ch[i][j]=='.')
        {
          dp[i][j]=dp[i-1][j]%MOD+dp[i][j-1]%MOD;
        }
        
      }
    }


    cout<<dp[n-1][m-1]%MOD;
        
  

    cerr << "Time taken: " << int((clock() * 1000.) / CLOCKS_PER_SEC) << "ms\n";
    return 0;
}



Measured memory_bytes: 18816
//file_name:ABC104_B.cpp
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts()
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
const int MX = 200005;

    // 整数スキャン（複数）
    /*
    int x;
    scanf("%d",&x);
    int y;
    scanf("%d",&y);
    int z;
    scanf("%d",&y);

    // n個の整数のスキャン
    /*
    ll a[n] = {};
    rep(i,n){
        scanf("%lld",&a[i]);
    }
    */

    // 文字列スキャン
    /*
    string s;
    cin >> s;
    */


int main() {
    string s;
    cin >> s;

    if(s[0]!='A'){
        puts("WA");
        return 0;
    }

    if(isupper(s[1])){
        puts("WA");
        return 0;
    }

    if(isupper(s[s.size()-1])){
        puts("WA");
        return 0;
    }

    int flag = 0;
    srep(i,2,s.size()-1){
        if(isupper(s[i])){
            if(s[i]=='C'){
                flag++;
            }else{
                puts("WA");
                return 0;
            }
        }
    }

    if(flag == 1){
        puts("AC");
        return 0;
    }else{
        puts("WA");
        return 0;
    }


    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, M;
  cin >> N >> M;
  vector<int> a(M), b(M);
  vector<vector<bool>> A(N, vector<bool>(N, false));
  for (int i = 0; i < M; i++) {
    cin >> a.at(i) >> b.at(i);
    A.at(a.at(i) - 1).at(b.at(i) - 1) = true;
    A.at(b.at(i) - 1).at(a.at(i) - 1) = true;
  }
  vector<int> memo(N - 1);
  for (int i = 2; i <= N; i++) {
    memo.at(i - 2) = i;
  }
  int64_t ans = 0;
  do {
    if (A.at(0).at(memo.at(0) - 1)) {
      bool ok = true;
      for (int i = 0; i < N - 2; i++) {
        if (A.at(memo.at(i) - 1).at(memo.at(i + 1) - 1) == false) {
          ok = false;
          break;
        }      
      }
      if (ok) {
        ans++;
      }
    }   
  } while (next_permutation(memo.begin(), memo.end()));
  cout << ans << endl;
}
  

Measured memory_bytes: 3624
n=int(input())
h=list(map(int,input().split()))
h=[0]+h
dp = [0]*(n+1)
for k in range(2,n+1):
  if k == 2:
    dp[2] = abs(h[1]-h[2])
  else:
  	dp[k] = min(dp[k-1]+abs(h[k-1]-h[k]),dp[k-2]+abs(h[k-2]-h[k]))

print(dp[n])

Measured memory_bytes: 13908
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll h,w;
ll direction2[4][2]={{1,0},{0,1},{0,-1},{-1,0}};
bool valid(int a,int b)
{
    if(a>=1&&a<=h&&b>=1&&b<=w)return true;
    else return false;
}

int main()
{
//    ios_base::sync_with_stdio(false);
//    cin.tie(NULL);
    ll n,x=0,ct=0;
    cin>>n;
    string s;
    cin>>s;
    for(int i=1;i<n;i++){
        for(char j='a';j<='z';j++){bool l=false,r=false;
            for(int k=0;k<i;k++)if(s[k]==j){l=true;break;}
            for(int k=i;k<n;k++)if(s[k]==j){r=true;break;}
            if(l&&r)ct++;
        }
        x=max(x,ct);ct=0;
    }
    cout<<x<<endl;
}


Measured memory_bytes: 3620
//#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define trav(x,a) for (const auto& x: a)
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), x.end()
#define mem(a,v) memset((a), (v), sizeof (a))
#define enl printf("\n")
#define case(t) printf("Case #%d: ", (t))
#define ni(n) scanf("%d", &(n))
#define nl(n) scanf("%lld", &(n))
#define nai(a, n) for (int _i = 0; _i < (n); _i++) ni(a[_i])
#define nal(a, n) for (int _i = 0; _i < (n); _i++) nl(a[_i])
#define pri(n) printf("%d\n", (n))
#define prl(n) printf("%lld\n", (n))
#define pii pair<int, int>
#define pll pair<long long, long long>
#define vii vector<pii>
#define vll vector<pll>
#define vi vector<int>
#define vl vector<long long>
#define pb push_back
#define mp make_pair
#define st first
#define nd second
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef cc_hash_table<int,int,hash<int>> ht;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> oset;
const double pi = acos(-1);
const int mod = 1e9 + 7;
const int inf = 1e9 + 7;
const int N = 1e6 + 5;
const double eps = 1e-9;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int x; cin >> x;
  cout << 360 / __gcd(x, 360) << endl;
  return 0;
}


Measured memory_bytes: 3696
n = int(input())
a = [int(input()) for i in range(n)]

sorted_a = sorted(a)

max_a = sorted_a[-1]
max_a_r = sorted_a[-2]

for i in range(n):
    if a[i] == max_a:
        print(max_a_r)
    else:
        print(max_a)

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

using namespace std;

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

    int n;
    cin >> n;
    
    vector<int> h(n);
    for(int i=0; i<n; ++i)
    {
        cin >> h[i];
    }
    
    int i=0,curr=0,step1=1e5,step2;
    
    for(;; ++i)
    {
        step1 = min(step1,curr + abs(h[i+1]-h[i]));
        
        if(i == n-2)  break;
        
        step2 = curr + abs(h[i+2]-h[i]);
        
        curr = step1;
        step1 = step2;
        
    }
    
    cout << step1;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define clr(x, y) memset(x, y, sizeof(x))
#define fl(a, b) for(int i=a; i<b; i++)
using namespace std;
typedef long long ll;
const int maxn = 100000 + 5;
const int inf = INT_MAX;

int main() {
	int N;
	cin >> N;
	int mins = inf, maxs = -1;
	while(N--) {
		int x;
		cin >> x;
		mins = min(mins, x);
		maxs = max(maxs, x);
	}
	cout << (maxs-mins) << endl;
}

Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>

using namespace std;

#define FAST       			ios_base :: sync_with_stdio(false); cin.tie(NULL); 
#define endl "\n"

typedef long long int  ll;
typedef unsigned long long int ull;


int main()
{
	FAST;
	double arr[1000];

	int n;
	cin >> n;
	double t,a;
	
	cin >> t >> a;
	for(int i=0 ; i<n ; i++)
		cin >> arr[i];

    
    double m = abs(t - arr[0]*0.006 - a);
	int index = 0;
	for(int i=1 ; i<n ; i++)
	{
	    double temp = abs(t - arr[i]*0.006 - a);
	    if(temp < m)
	    {
	        m = temp;
	        index = i;
	    }
	}
	
    cout << index+1;

    
	return 0;
}


Measured memory_bytes: 256
//#include <tourist>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF = 1e9;
const ll LINF = ll(1e18) + 1;
const int MOD = 1000000007;
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define rep(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define debug(v)          \
    cout << #v << ":";    \
    for (auto x : v)      \
    {                     \
        cout << x << ' '; \
    }                     \
    cout << endl;
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;
}
//cout<<fixed<<setprecision(15);有効数字15桁
//-std=c++14
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
ll h,w;
vector<ll> p,q;;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> w>>h;
    ll ans=0;
    for (int i = 0; i <w; i++)
    {
        ll temp;
        cin >> temp;
        p.push_back(temp);
        ans+=temp;
    }
    for (int i = 0; i <h; i++)
    {
        ll temp;
        cin >> temp;
        q.push_back(temp);
        ans+=temp;
    }
    sort(ALL(p));
    vector<ll> sum(w+1,0);
    for(int i=1;i<=w;i++){
        sum[i]=sum[i-1]+p[i-1];
    }
    for(int i=0;i<h;i++){
        auto iter=lower_bound(ALL(p),q[i]);
        ll temp=iter-p.begin();
        ans+=q[i]*(w-temp);
        ans+=sum[temp];
    }
    cout << ans << "\n";
}


Measured memory_bytes: 2804
import java.util.*;

import static java.lang.System.*;

public class Main {
    static Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        String S = ns();

        long ans = 0;
        int cnt = 0;
        for (int i = 0; i < S.length(); i++) {
            if (S.charAt(i) == 'W') {
                ans += i - cnt;
                cnt++;
            }
        }

        out.println(ans);
    }

    static int ni() {
        return sc.nextInt();
    }

    static long nl() {
        return sc.nextLong();
    }

    static String ns() {
        return sc.next();
    }

    static int[] niarr(int N) {
        int[] a = new int[N];
        for (int i = 0; i < N; i++) {
            a[i] = sc.nextInt();
        }
        return a;
    }

    static long[] nlarr(int N) {
        long[] a = new long[N];
        for (int i = 0; i < N; i++) {
            a[i] = sc.nextLong();
        }
        return a;
    }
}

Measured memory_bytes: 26276
#include <iostream>
#include <algorithm>
#include <string>

using namespace std;



int main(){

    int n;
    string s;

    cin >> n;

    int b = 0;
    int a = 0;
    int ba = 0;
    int ab = 0;

    for(int i = 0; i < n; i++){
        cin >> s;

        for(int j = 0; j < s.size() - 1; j++){
            if(s[j] == 'A' && s[j + 1] == 'B') ab++;
        }

        if(s[0] == 'B' && s[s.size() - 1] == 'A'){
            ba++;
        }else if(s[0] == 'B'){
            b++;
        }else if(s[s.size() - 1] == 'A'){
            a++;
        }

    }

    cerr << ab << " " <<  ba << " " <<  b << " " << a << endl;

    int k = 0;

    if(ba > 0){
        k = ba - 1;

        if(ba > 0 && b > 0){
            k++;
            b--;
        }
        if(ba > 0 && a > 0){
            k++;
            a--;
        }

        k = k + min(a,b);

    }else{
        k = min(a,b);
    }

    cout << ab + k << endl;

    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,popcnt,abm,mmx,tune=native")
#pragma GCC optimize("fast-math")
#pragma GCC optimize "-O3"

#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define ld long double

mt19937 gen(chrono::steady_clock::now().time_since_epoch().count());

ll INF = (ll) 1e20;
int iINF = (int) 1e20;
ll mod = (ll) 1e9 + 7;
ll mod2 = (ll) 1e9 + 9;

void dfs(ll v, vector<vector<ll>> &nodes, vector<ll> &num, ll p, vector<ll> &ans, ll sum) {
    sum += num[v];
    ans[v] = sum;
    for (auto i : nodes[v]) {
        if (i != p)
            dfs(i, nodes, num, v, ans, sum);
    }
}

signed main() {
    ll n, q;
    cin >> n >> q;
    vector<vector<ll>> nodes(n);
    for (int i = 0; i < n - 1; ++i) {
        ll a, b;
        cin >> a >> b;
        nodes[a - 1].push_back(b - 1);
        nodes[b - 1].push_back(a - 1);
    }
    vector<ll> num(n, 0);
    while (q--) {
        ll id, x;
        cin >> id >> x;
        num[id - 1] += x;
    }
    vector<ll> ans(n);
    dfs(0, nodes, num, 0, ans, 0);
    for(auto i : ans)
        cout << i << ' ';
}



Measured memory_bytes: 24064
#include <stdio.h>

int main(){
  int n,i;

  scanf("%d",&n);
  i = n % 10;
  //printf("%d",i);

  if(i == 3)
    printf("bon\n");
  else if(i == 0 || i == 1 || i == 6 || i == 8)
    printf("pon\n");
  else
    printf("hon\n");

  return 0;
}

Measured memory_bytes: 1608
#include<iostream>
#include<iomanip>
#include<cstdlib>
#include<algorithm>
#include<vector>
#include<map>
#include<cmath>
#include<string>
#include<numeric>

#define rep(i,p) for(long long int i=0;i<p;i++)
#define reep(i,p) for(long long int i=1;i<=p;i++)
#define ll long long

using namespace std;

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

vector<ll int > B(N-1);
vector<ll int > A(N);
rep(i,N-1){
	cin >> B[i];
}
if(N==2){
	cout << B[0]*2;
}
else{
ll int ans = 0;
A[0] = B[0];
A[N-1] = B[N-2];

for(long long int i=1;i<N-1;i++){
	A[i] = min(B[i],B[i-1]);
	
}

cout << accumulate(A.begin(),A.end(),0);

}








	return 0;

}



Measured memory_bytes: 3612
void main(){
  import std.stdio, std.string, std.conv, std.algorithm;

  int n; rd(n);
  auto d=readln.split.to!(int[]);
  int m; rd(m);
  auto t=readln.split.to!(int[]);

  sort(d); sort(t);
  int j=0;
  foreach(e; t){
    while(j<n && d[j]<e) j++;
    if(j<n && d[j]==e) j++;
    else{writeln("NO"); return;}
  }

  writeln("YES");
}


void rd(T...)(ref T x){
  import std.stdio, std.string, std.conv;
  auto l=readln.split;
  foreach(i, ref e; x){
    e=l[i].to!(typeof(e));
  }
}

Measured memory_bytes: 17432
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <list>
#define pie 3.141592653589793
#define si(a) scanf("%d",&a)
#define ss(a) scanf("%s",a)
#define sl(a) scanf("%lld",&a)
#define pi(a) printf("%d",a)
#define pl(a) printf("%lld",a)
#define ps(a) printf("%s",a)
#define ll long long
using namespace std;
int main()
{
  string str;
  cin >> str;
  bool ok=0;
  if((str[0]==str[1]) && (str[1]==str[2]))
    ok=1;
  if((str[1]==str[2]) && (str[2]==str[3]))
    ok=1;
  if(ok)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define  rep(i, n) for(int i = 0; i < n; i++) 
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  INF 1LL << 60
typedef long long int LL;
typedef long long int ll;
#define pll pair<ll, ll>
#define F first
#define S second
const int MOD = 1000000007;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }
//sort(all(x))とするとソートできるよ
// 10^x は pow(10,(x)) 
// 任意のlogは　対数の底の変換を使う    log(N) / log(任意の底)

// UnionFind 

// この構造体は基本機能にsizeをたしたもの
// https://qiita.com/ofutonfuton/items/c17dfd33fc542c222396

// size あると便利そうなので
// struct の最初にあるUnionFindはコンストラクタ。par(N),siz(N,1) は継承（それぞれ初期化している）。
// コンストラクタは起動時(宣言時)に最初に実行される。

// これは大小を整理するやつシンプルな実装（経路圧縮のみ）なので、合体クエリがO(logN)らしい。

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2
    vector<int> siz; // 素集合のサイズを表す配列(1 で初期化)

    UnionFind(int N) : par(N), siz(N, 1){ //最初は全てが根であるとして初期化、頂点数N
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
        siz[ry] += siz[rx];
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }

    int size(int x) { // 素集合のサイズ
        return siz[root(x)];
    }
};

int main(){
    int N,M;cin >> N >> M;
    vector<int> p(N);
    rep(i,N)cin >> p[i],p[i]--;
    UnionFind uni(N);
    rep(i,M){
        int a,b;cin >> a >> b;
        a--;b--;
        uni.unite(a,b);
    }
    int ans = 0;
    rep(i,N)if(uni.same(i,p[i]))ans++;
    cout << ans << endl;
}



Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define endl '\n'
void solve(){
	
	int n;
	cin >> n;
	ll i, a[n];
	for( i=0;i<n;i++)
		cin >> a[i];
		
		bool flag = true;
	for(int i = n-2; i>=0; i--)
	{
		if(a[i]>a[i+1])
		{
			a[i]--;
			if(a[i]>a[i+1])
			{
				cout << "No";
				flag = false;
              break;
			}
		}
	}
	if(flag)
	cout<<"Yes";
}

int main()
{
	
	    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
		int t =1;
			//cin >> t;
		while(t--)
		{
			solve();
		}
		return 0;
}


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

using namespace std;

int main()
{
	int n, m;
	unordered_map<string, int> s;
	unordered_map<string, int> t;
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		string si;
		cin >> si;
		t[si] = 0;
		auto it = s.find(si);
		if (it != s.end()) it->second++;
		else s[si] = 1;
	}
	cin >> m;
	for (int i = 0; i < m; i++)
	{
		string ti;
		cin >> ti;
		auto it = t.find(ti);
		if (it != t.end()) it->second++;
		else t[ti] = 1;
	}
	int most = 0;
	for (auto&& p : s)
		most = max(most, p.second - t[p.first]);
	cout << most << endl;
	return 0;
}


Measured memory_bytes: 256
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    N,P=MI()
    s=input()
    ans=0
    if P==2 or P==5:
        for i in range(N):
            t=int(s[i])
            if t%P==0:
                ans+=i+1
            
    else:
        ans=0
        t=0
        mod=[0]*P
        mod[0]=1
        for i in range(N):
            t=t+int(s[N-i-1])*pow(10,i,P)
            t=t%P
            mod[t]+=1
            if mod[t]>=2:
                ans+=mod[t]-1
                

            

    print(ans)   
        
    
            
    
        
    

main()


Measured memory_bytes: 41308
A1 = list(map(int, input().split()))
A2 = list(map(int, input().split()))
A3 = list(map(int, input().split()))
A = A1 + A2 + A3

N = int(input())

for i in range(N):
    b = int(input())
    if b in A:
        n = A.index(b)
        A[n] = '*'

if A[0] == A[1] == A[2] or A[3] == A[4] == A[5] or A[6] == A[7] == A[8]:
    print('Yes')
elif A[0] == A[3] == A[6] or A[1] == A[4] == A[7] or A[2] == A[5] == A[8]:
    print('Yes')
elif A[0] == A[4] == A[8] or A[2] == A[4] == A[6]:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3064
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	private void solve() {
		Scanner in = new Scanner(System.in);
		int N = in.nextInt();
		Restrant[] rests = new Restrant[N];
		for(int i=0; i<N; i++) {
			rests[i] = new Restrant(i+1, in.next(), in.nextInt());
		}
		Arrays.sort(rests);
		for(Restrant r : rests) {
			System.out.println(r.id);
		}
	}
	
	public class Restrant implements Comparable<Restrant>{
		int id;
		String city;
		int score;
		
		public Restrant(int id, String city, int score) {
			this.id = id;
			this.city = city;
			this.score = score;
		}

		@Override
		public int compareTo(Restrant other) {
			int order = city.compareTo(other.city);
			if(order==0) {
				order = -Integer.compare(score, other.score);
			}
			return order;
		}
	}

	public static void main(String[] args) {
		new Main().solve();
	}
}


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

int main()
{
	int n,k;
	cin>>n>>k;
	int mod = 1000000007;
	vector<long long>dp(n+1);
	for(int i = 1 ; i <= n ; i++)
		dp[i] = i + dp[i-1];
	long long ans = 0;
	for(int i = k ; i <= n + 1 ; i++)
	{
		long long minsum = dp[i-1];
		long long maxsum = dp[n];
		if(i < n + 1)
			maxsum -= dp[n-i];
		ans = (ans + maxsum - minsum + 1)%mod;
	}
	cout<<ans;
}


Measured memory_bytes: 4840
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define fi first
#define se second
#define pb push_back
#define all(v) (v).begin(),(v).end()
ll mod = 1000000007;
ll INF = 1000000099;

void secondsort(vector<pair<ll,ll>> &v){
    for(ll i=0;i < v.size();i++){
    swap(v.at(i).first,v.at(i).second);
    }
    sort(v.begin(),v.end());
    reverse(v.begin(),v.end());
    for(ll i=0;i < v.size();i++){
    swap(v.at(i).first,v.at(i).second);
    }
    }

signed main(){
    ll n,m,ans=0;
    cin>>n>>m;

    priority_queue<ll, vector<ll>, greater<ll> > q;

    for(ll i=0;i < n;i++)
    {
        ll x;
        cin>>x;
        q.push(x);
    }

    vector<pair<ll,ll>> v(m);

    for(ll i=0;i < m;i++)
    {
        cin>>v.at(i).fi>>v.at(i).se;
    }
    secondsort(v);

    /*for(int i=0;i < m;i++)
    {
        ll l=0,r=v.at(i).fi-1;
        while(abs(r-l)>1){
            ll mid=(l+r)/2;
            if(q.at(mid)>v.at(i).se){
                r=mid;
            }else{
                l=mid;
            }
        }
        for(int j=0;j <=l ;j++)
        {
            q.at(0)=v.at(i).se;
        }
    }*/
    bool flag =false;
    for(int i=0;i < m;i++)
    {
        for(int j=0;j < v.at(i).fi;j++)
        {
            if(v.at(i).se>(ll)q.top()){
                q.pop();
                q.push(v.at(i).se);
            }else{
                break;
                flag=true;
            }
        }
        if(flag){
            break;
        }
    }

    for(int i=0;i < n;i++)
    {
        ans+=q.top();
        q.pop();
    }

    cout << ans << endl;
}




Measured memory_bytes: 2676
#include<stdio.h>
int main(void)
{
	int a,b,c;
	char op;
	for(c=0;c<1000;c++){
	scanf("%d %c %d",&a,&op,&b);
	if(op=='+'){
	printf("%d\n",a+b);
	}else if(op=='-'){
	printf("%d\n",a-b);
	}else if(op=='*'){
	printf("%d\n",a*b);
	}else if(op=='/'){
	printf("%d\n",a/b);
	}else if(op=='?'){
	break;
	}
	}
	return 0;
}

Measured memory_bytes: 2728
import java.util.*;
import java.math.*;
public class Main {
	static int x;
	static int ans;
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		ans = 1000000000;
		int n = in.nextInt();
		int m = in.nextInt();
		x = in.nextInt();
		int[][] info = new int[n][m + 1];
		for(int i = 0; i < n; i++) {
			for(int j = 0; j < m + 1; j++) {
				info[i][j] = in.nextInt();
			}
		}
		int[] check = new int[n];
		dfs(info, check, 0, m);
		if(ans == 1000000000) {
			System.out.println(-1);
		}else {
			System.out.println(ans);
		}
	}
	public static void dfs(int[][] info, int[] check, int cnt, int m) {
		if(cnt == check.length) {
			int price = 0;
			int[] temp = new int[m];
			for(int i = 0; i < check.length; i++) {
				if(check[i] == 1) {
					price += info[i][0];
					for(int j = 0; j < m; j++) {
						temp[j] += info[i][j + 1];
					}
				}
			}
			boolean flag = true;
			for(int i = 0; i < m; i++) {
				if(temp[i] < x) flag = false;
			}
			if(flag == true) {
				ans = Math.min(ans, price);
			}
			return;
		}
		dfs(info, check, cnt + 1, m);
		check[cnt] = 1;
		dfs(info, check, cnt + 1, m);
		check[cnt] = 0;
	}
} 


Measured memory_bytes: 38592
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>

#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;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long ll;
typedef pair<long long, long long> pll;

const int INF = 1 << 30;
const long long INFL = 1LL << 62;
const int MOD = 1000000007;
const int MAX = 100000;
const int N = 100;

char ans[N][N];

int main() {
	int a,b;cin>>a>>b;a--;b--;
	rep(i,50) rep(j,100) ans[i][j]='#';
	rep(i,50) rep(j,100) ans[i+50][j]='.';
	int i=1,j=0;
	while(a>0){
		if(j==99){i+=3;j=0;}
		ans[i+j%2][j]='.';
		a--;j++;
	}
	i=51;j=0;
	while(b>0){
		if(j==99){i+=3;j=0;}
		ans[i+j%2][j]='#';
		b--;j++;
	}
	cout<<100<<' '<<100<<endl;
	rep(i,100){
		rep(j,100) cout<<ans[i][j];
		cout<<endl;
	}
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(int argc, char* argv[])
{
	int A,B;
	cin>>A>>B;
	if (A%3==0 || B%3==0 || (A+B)%3==0){
		cout<<"Possible"<<endl;
	}else{
		cout<<"Impossible"<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define ld long double
using namespace std;
const int N = 1e5+5;

int n, k, h[N], dp[N];


int solve(int i)
{
    if(i == n-1)
        return 0;
    if(dp[i] != -1)   return dp[i];
    int op1 = solve(i+1) + abs(h[i+1] - h[i]);
    for(int j=2; j<=k; j++)
    {
        if(i + j < n)
            op1 = min(op1, solve(i + j) + abs(h[i] - h[i+j]));
    }
    return dp[i] = op1;;
}

int table()
{
    dp[0] = 0;
    for(int i=1; i<n; i++)
    {
        dp[i] = dp[i-1] + abs(h[i] - h[i-1]);
        for(int j = 2; j <= k; j++)
        {
            if(i - j < 0) break;
            dp[i] = min(dp[i], dp[i-j] +abs(h[i] - h[i-j]));
        }
    }
    return dp[n-1];
}

int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    cin >> n >> k;
    for(int i=0; i<n; i++)
        cin >> h[i];
    // memset(dp, -1, sizeof dp);
    cout << table();
    // cout << solve(0);


    return 0;
}


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

#define ll long long
#define mod 1000000007
#define pii pair<ll,ll>

#define debug(a) { cout << #a << " = " << a << endl;}

void sep() {
    cout << "-------------BLOCK-----------------\n";
}

template<typename T>
void debugv(vector<T> arr) {
    for (auto t: arr)
        cout << t << " ";
    cout << "\n";
}

template<typename T>
void debugarr(T arr, int n) {
    for (int i=0;i<n;i++) cout << arr[i] << " ";
    cout << "\n";
}

const int maxn = 2e5+1;
ll arr1[maxn], n, m, t, k;
ll arr2[maxn];
unordered_map<ll,ll> u;

ll __min(ll a, ll b) {
    return a < b ? a : b;
}

ll __max(ll a, ll b) {
    return a > b ? a : b;
}

void par(int n) {
    cout << "Yes\n";
    for (int i=0;i<n;i++) cout << arr2[i] << " ";
    cout << endl;
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    
    cin>>n;
    for (int i=0;i<n;i++) cin>>arr1[i]; 
    for (int i=0;i<n;i++) cin>>arr2[i]; 
    reverse(arr2,arr2+n);

    ll l=n+1,r=n+1;
    for (int i=0;i<n;i++) {
        if (arr1[i]==arr2[i]) {
            if (l == n+1) l = i, r=i;
            else r = i;
        }
    }

    if (l == n+1) {
        par(n);
        return 0;
    }

    ll sl=l,sr=r;
    ll pl=l,pr=r;
    while (sl >=0 && arr1[sl] == arr1[l]) sl--;
    while (sr < n && arr1[sr] == arr1[r]) sr++;
    while (pl >=0 && arr2[pl] == arr2[l]) pl--;
    while (pr < n && arr2[pr] == arr2[r]) pr++;


    sl=__min(sl,pl);
    sr=__max(sr,pr);

    ll i=0;
    ll j=n-1;
    ll sll=l;
    while (i<=sl && l <= r) {
        ll t=arr2[i];
        arr2[i++]=arr2[l];
        arr2[l++]=t;
    }

    while (j >= sr && r >= l) {
        ll t=arr2[j];
        arr2[j--]=arr2[r];
        arr2[r--]=t;
    }

    bool pos=true;

    for (int i=0;i<n;i++)
        if (arr2[i] == arr1[i]) {
            pos=false;
            break;
        }

    if (pos) par(n);
    else cout << "No\n";
}


Measured memory_bytes: 6760
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int main(void){
    vector<int> vec(3);
    
    cin>>vec.at(0)>>vec.at(1)>>vec.at(2);
    
    sort(vec.begin(),vec.end());
    
    cout<<vec.at(0)+vec.at(1);
}


Measured memory_bytes: 256
#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>;
const ll INF = 10010010010;
const int mod = 1000000007;
struct mint {
  ll x;  // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod - a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const { return mint(*this) += a; }
  mint operator-(const mint a) const { return mint(*this) -= a; }
  mint operator*(const mint a) const { return mint(*this) *= a; }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod - 2); }
  mint& operator/=(const mint a) { return *this *= a.inv(); }
  mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x; }
ostream& operator<<(ostream& os, const mint& a) { return os << a.x; }
int main() {
  int n;
  cin >> n;
  vector<ll> a(n);
  rep(i, n) cin >> a[i];
  map<ll, ll> mp;
  rep(i, n) { mp[i] = 0; }
  bool ok = true;
  if (n % 2 == 0) {
    rep(i, n) {
      mp[a[i]]++;
      if (a[i] % 2 != 1 || a[i] > n / 2 * 2 + 1 || mp[a[i]] >= 3) ok = false;
    }
  } else {
    rep(i, n) {
      mp[a[i]]++;
      if (a[i] % 2 != 0 || a[i] > n / 2 * 2 || mp[a[i]] >= 3) ok = false;
    }
    if (mp[0] != 1) ok = false;
  }
  if (ok == false)
    cout << 0 << endl;
  else {
    mint ans = 1;
    rep(i, n / 2) { ans *= 2; }
    cout << ans << endl;
  }
}

Measured memory_bytes: 7296
from collections import defaultdict

def find(tab, a):
    if tab[a] == -1: return a
    tab[a] = find(tab, tab[a])
    return tab[a]

def union(tab, a, b):
    pa, pb = (find(tab, a), find(tab, b))
    if pa!=pb:
        tab[pb] = pa

H,W=map(int,input().split())
S=[input() for _ in range(H)]
N=H*W
tab = [-1]*N

for y in range(H):
    for x in range(W):
        for dx,dy in [(-1,0),(1,0),(0,1),(0,-1)]:
            xx=x+dx
            yy=y+dy
            if xx < 0 or xx>=W or yy<0 or yy>=H:
                continue
            src = W*y+x
            dst = W*yy+xx
            if S[y][x]!=S[yy][xx]:
                union(tab, src, dst)
dic = defaultdict(lambda: {"#":0,".":0})
for i in range(N):
    p = find(tab, i)
    t = S[i//W][i%W]
    dic[p][t]+=1

ans = 0
for d in dic.values():
    ans += (d["#"]*d["."])
print(ans)


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

int main() {
    int n, k; cin >> n >> k;
    int num = 1;
    int cnt = 0;
    while (true) {
        if (num > k) num += k;
        else num *= 2;
        cnt++;
        if (cnt == n) break;
    }
    
    cout << num << endl;
}

Measured memory_bytes: 256
a, b = map(int, input().split())

def small(a , b):
    return(a < b)
    
def big(a , b):
    return(a > b)
    
def equal(a , b):
    return(a == b)

if small(a , b):
    print('a < b')

elif big(a , b):
    print('a > b')

elif equal(a , b):
    print('a == b')


Measured memory_bytes: 5596
import std.stdio, std.string, std.conv, std.range, std.algorithm, std.functional;

void main() {
    auto N = readln.chomp.to!long;
    auto n = N;
    auto f = 0;
    while (n > 0) {
        f += n % 10;
        n /= 10;
    }
    writeln(N % f == 0 ? "Yes" : "No");
}


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

using namespace std;

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

const ll mod = 1000000007;

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

  string s;
  cin >> s;

  vector<bool> found(26);
  for (int i = 0; i < s.length(); i++) {
    int idx = s[i] - 'a';
    if (found[idx]) {
      cout << "no" << endl;
      return 0;
    }
    found[idx] = true;
  }

  cout << "yes" << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <iomanip>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 998244353

typedef long long ll;
typedef pair<ll,ll> P;

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

	string a, b;cin >> a >> b;
	if(a.size() + 1 != b.size()){
		cout << "No" << endl;
		return 0;
	}
	REP(i, a.size())if(a[i] != b[i]){
		cout << "No" << endl;
		return 0;
	}

	cout << "Yes" << endl;

	return 0;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define INF 2000000000
using namespace std;
typedef long long ll;
int read(){
    int f = 1, x = 0;
    char c = getchar();
    while(c < '0' || c > '9'){if(c == '-') f = -f; c = getchar();}
    while(c >= '0' && c <= '9')x = x * 10 + c - '0', c = getchar();
    return f * x; 
}
const int M = 1000000007;
int inv[2000005], fac[2000005], invfac[2000005];
int r1, r2, c1, c2;
int C(int n, int m){
    int res = fac[n];
    res = 1ll * res * invfac[m] % M;
    res = 1ll * res * invfac[n - m] % M;
    return res;
}
int get(int r, int c){
    int res = C(r + c + 2, c + 1);
    res = (res + M - r - c - 2) % M;
    return res;
}
void init(){
    r1 = read(), c1 = read(), r2 = read(), c2 = read();
    fac[0] = invfac[0] = fac[1] = invfac[1] = inv[1] = 1;
    for (int i = 2; i <= 2000003; ++i)
        fac[i] = 1ll * fac[i - 1] * i % M, 
        inv[i] = 1ll * (M - M / i) * inv[M % i] % M, 
        invfac[i] = 1ll * invfac[i - 1] * inv[i] % M;
}
void solve(){
    int ans = get(r2, c2);
    ans = (ans + M - get(r1 - 1, c2)) % M;
    ans = (ans + M - get(r2, c1 - 1)) % M;
    ans = (ans + get(r1 - 1, c1 - 1)) % M;
    printf("%d\n", ans);
}
int main(){
    init();
    solve();
    return 0;
}

Measured memory_bytes: 23680
#include <algorithm>
#include <string>
#include <sstream>
#include <iostream>
#include <cmath>
#include <bits/stdc++.h>
using namespace std;

const int LOOP = 1000; //??????????????°
const double EPS = 1e-6; //??????????????¨(?°??????????????????????)
int L;
int N; //???????????±???????????°

//???????????±????????????????????????????????¨?????¨???????¨????????¨??????????
double Evaluate(int r[12]) {
	double val = r[0] + r[N-1];
	for (int i = 0; i < N - 1; i++)
	{
		int a = abs(r[i] - r[i+1]), c = r[i] + r[i+1];
		val += sqrt(c*c - a*a);
	}
	return val;
}

//?????¨?????????????????°???????????¨??????????????????????§???????????±???????
//(????§?????????????true)
bool Changes(int cnt) {
	return cnt < rand()%LOOP;
}

void Swap(int r[12],int L,int R){
    int temp=r[L];
    r[L]=r[R];
    r[R]=temp;
}

//?????????????????????????????¢??°
//?????????????°??????????????¨?????????????
//int r[12] : ???????????±?????????0??????N-1???????????????????????????????????????????????????????´???????
double Solve(int r[12]) {
	double score = Evaluate(r); //?????¨?????¶???r[]????¨???????????´????????????°
	double mi = score; //???????????§?????¶???????¨???????????°???????????´????????????°
	for (int cnt = 0; cnt < LOOP; cnt++)
	{
	    int L=rand()%N;
	    int R=rand()%N;
	    Swap(r,L,R);
	    if(mi>=Evaluate(r)){
            mi=Evaluate(r);
            continue;
	    }
	    else if(Changes(cnt)){
            mi=Evaluate(r);
	    }
	    else Swap(r,L,R);
	}
	return mi; //????°?????????????
}

//??\?????¢????????????????????¢????????£????????§???????????????
int main() {
    srand(time(NULL));
	while (cin >> L)
	{
		N = 0;
		int r[12];
		string S;
		getline(cin, S);
		stringstream SS(S);
		while (!SS.eof()) SS >> r[N++];

		double ans;
		if (N == 1) ans = r[0]*2;
		else ans = Solve(r);

		if (L - ans + EPS > 0) puts("OK");
		else puts("NA");
	}
	return 0;
}

Measured memory_bytes: 1212
#include <iostream>

int main() {
	int count;
	std::cin >> count;
	
	unsigned long long* values = new unsigned long long[count];
	unsigned long long sum = 0;
	unsigned long long sum_A2_An_1_s2 = 0;
	for (int i = 0; i < count; i++) std::cin >> values[i], sum += values[i], sum_A2_An_1_s2 += (i & 0x1) ? values[i] : 0;
	unsigned long long x_1 = sum - 2 * sum_A2_An_1_s2;
	std::cout << x_1 << " ";
	unsigned long long base = x_1;
	for (int i = 1; i < count; i++) {
		std::cout << (base = 2 * values[i - 1] - base) << " ";	
	}
	delete[] values;
	return 0;
}

Measured memory_bytes: 2048
#include <iostream>
#include <stack>
#include <string>
#include <vector>

int main(int argc, char* argv[]) {
  std::string S;
  std::cin >> S;
  int N = S.length();
  std::vector<int> vs(N);
  int i = 0;
  for (auto&& s : S) {
    vs[i] = s - '0';
    i++;
  }
  std::stack<int> st;
  for (auto&& v : vs) {
    if (!st.empty()) {
      if (st.top() != v) {
        st.pop();
        continue;
      }
    }
    st.push(v);
  }
  std::cout << N - st.size() << std::endl;
  return 0;
}


Measured memory_bytes: 1152
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            //[summary]A - New Year
            int m = int.Parse(Console.ReadLine());

            Console.WriteLine(48 - m);
        }
    }
}

Measured memory_bytes: 11092
#include <iostream>
#include <string>
#include <map>
using namespace std;
int main(){
    string s; cin >> s;
    map<char,int> mp;
    for(int i = 0; i < s.size(); i++){
        mp[s[i]]++;
    }
    for(auto& x:mp){
        if(x.second%2 != 0){
            puts("No");
            return 0;
        }
    }
    puts("Yes");
    return 0;
}

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

typedef long long ll;
const int MAXN = 310;
int n, a[MAXN][MAXN];
bool b[MAXN][MAXN];
ll ans;

inline void check() {
	int i, j, k;
	for(i = 1; i <= n; i++) {
		for(j = 1; j <= n; j++) {
			for(k = 1; k <= n; k++) {
				if(a[i][k]+a[k][j] < a[i][j]) {
					ans = -1;
					break;
				}
			}
			if(ans == -1) break;
		}
		if(ans == -1) break;
	}
	if(ans == -1) {
		printf("-1\n");
		exit(0);
	}
}

int main() {
	int i, j, k;
	scanf("%d", &n);
	for(i = 1; i <= n; i++) 
		for(j = 1; j <= n; j++) {
			scanf("%d", &a[i][j]);
			ans += a[i][j];
		}
	check();
	for(i = 1; i <= n; i++)
		for(j = 1; j <= n; j++) {
			for(k = 1; k <= n; k++) {
				if(k == i || k == j) continue;
				if(a[i][k] + a[k][j] == a[i][j]) break;
			}
			if(k <= n) ans -= a[i][j];
		}
	printf("%lld\n", ans>>1);
	return 0;
}



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

// clang-format off
template <typename T> T gcd(T a, T b) { return b == 0 ? a : gcd(b, a % b); }
template <typename T> T lcm(T a, T b) { return a * b / gcd(a, b); }
template <typename T> T clamp(T val, T min, T max) { return val < min ? min : (max < val ? max : val); }
template <typename T> size_t max_index(T begin, T end) { return distance(begin, max_element(begin, end)); }
template <typename T> size_t min_index(T begin, T end) { return distance(begin, min_element(begin, end)); }
// clang-format on

#define int long long
#define YES "Yes"
#define NO  "No"

using namespace std;

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

  bool flag = true;
  int num = 0;

  int m; cin >> m;

  cout << 48 - m << endl;

  // cout << num << endl;
  // cout << (flag ? YES : NO) << endl;
  
  return 0;
}


Measured memory_bytes: 256
while True:
    H,W=map(int,input().split())
    if H==0 and W==0: break
    for y in range(1,H+1):
        for x in range(1,W+1):
            if x%2 == y%2:
                print("#",end="")
            else:
                print(".",end="")
        print()
    print()


Measured memory_bytes: 7008