akhauriyash/Code-Regression huggingface dataset:
import sys
from sys import exit
from collections import deque
from bisect import bisect_left, bisect_right, insort_left, insort_right
from heapq import heapify, heappop, heappush
from itertools import product, permutations, combinations, combinations_with_replacement
from functools import reduce
from math import gcd, sin, cos, tan, asin, acos, atan, degrees, radians

sys.setrecursionlimit(10**6)
INF = 10**20
eps = 1.0e-20
MOD = 10**9+7

def lcm(x,y):
    return x*y//gcd(x,y)
def lgcd(l):
    return reduce(gcd,l)
def llcm(l):
    return reduce(lcm,l)
def powmod(n,i,mod):
    return pow(n,mod-1+i,mod) if i<0 else pow(n,i,mod)
def div2(x):
    return x.bit_length()
def div10(x):
    return len(str(x))-(x==0)
def perm(n,mod=None):
    ans = 1
    for i in range(1,n+1):
        ans *= i
        if mod!=None:
            ans %= mod
    return ans
def intput():
    return int(input())
def mint():
    return map(int,input().split())
def lint():
    return list(map(int,input().split()))
def ilint():
    return int(input()), list(map(int,input().split()))
def judge(x, l=['Yes', 'No']):
    print(l[0] if x else l[1])
def lprint(l, sep='\n'):
    for x in l:
        print(x, end=sep)
def ston(c, c0='a'):
    return ord(c)-ord(c0)
def ntos(x, c0='a'):
    return chr(x+ord(c0))
class counter(dict):
    def __init__(self, *args):
        super().__init__(args)
    def add(self,x,d=1):
        self.setdefault(x,0)
        self[x] += d
    def list(self):
        l = []
        for k in self:
            l.extend([k]*self[k])
        return l
class comb():
    def __init__(self, n, mod=None):
        self.l = [1]
        self.n = n
        self.mod = mod
    def get(self,k):
        l,n,mod = self.l, self.n, self.mod
        k = n-k if k>n//2 else k
        while len(l)<=k:
            i = len(l)
            l.append(l[i-1]*(n+1-i)//i if mod==None else (l[i-1]*(n+1-i)*powmod(i,-1,mod))%mod)
        return l[k]
def pf(x):
    C = counter()
    p = 2
    while x>1:
        k = 0
        while x%p==0:
            x //= p
            k += 1
        if k>0:
            C.add(p,k)
        p = p+2-(p==2) if p*p<x else x
    return C

S=input()
N=len(S)
ans=True
i=N
while ans:
    if i==0:
        break
    elif i>=5 and S[i-5:i]=='dream':
        i-=5
    elif i>=7 and S[i-7:i]=='dreamer':
        i-=7
    elif i>=5 and S[i-5:i]=='erase':
        i-=5
    elif i>=6 and S[i-6:i]=='eraser':
        i-=6
    else:
        ans=False
judge(ans,['YES','NO'])

Measured memory_bytes: 74360
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <cstdint>
 
int main() {
	int n;
	std::cin >> n;
 
	std::vector<int> vec(n);
 
	for (auto&& e : vec)
		std::cin >> e;
 
	auto solve = [&](bool positive) {
		int64_t ret = 0;
 
		int sum = 0;
		for (int i = 0; i < vec.size(); ++i) {
			sum += vec[i];
 
			if (sum == 0 || positive != sum > 0) {
				ret += std::abs(sum) + 1;
				sum = (positive ? 1 : -1);
			}
			
			positive = !positive;
		}
 
		return ret;
	};
 
	std::cout << std::min(solve(true), solve(false)) << std::endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <bits/stdc++.h>
#include <algorithm>
#include <vector>
#include <math.h>
#include<map>
#include <sstream>
#include <deque>
#include <string>
#include <cctype>
#include <cstring>
#include <cstdio>
const int M = 1e9 + 7;
#define ll long long int
#define fastio                        \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);
using namespace std;

//insta  -------  __ansh7
//MSDIAN




int main()
{
    fastio

    ll n;
    cin>>n;

    if(n>=400 && n<600)
    {
        cout<<"8";
    }
    
    if(n>=600 && n<800)
    {
        cout<<"7";
    }

    
    if(n>=800 && n<1000)
    {
        cout<<"6";
    }

    
    if(n>=1000 && n<1200)
    {
        cout<<"5";
    }
    
    if(n>=1200 && n<1400)
    {
        cout<<"4";
    }
    
    if(n>=1400 && n<1600)
    {
        cout<<"3";
    }
    
    if(n>=1600 && n<1800)
    {
        cout<<"2";
    }
    
    if(n>=1800 && n<2000)
    {
        cout<<"1";
    }






  

  
    
 



    




    return 0;
}

Measured memory_bytes: 3644
#include <iostream>
#include <fstream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <cstdlib>
#include <cstdio>
#include <string>
#include <cstring>
#include <cassert>
#include <utility>
#include <iomanip>

using namespace std;

#define sz(x) (int) x.size()
#define unique(x) x.erase(unique(x.begin(), x.end()), x.end())
#define all(a) a.begin(), a.end()
#define sqr(x) ((x) * (x)) 
#define y1 aksjdaskdjksjfksdjf
#define left kdnvldvoiwejifejg
#define right lkdsjflksdjfdjfk

int a, b, c;

int main() { 

  cin >> a >> b >> c;

  if (a + b + c >= 22) {
    puts("bust");
  } else {
    puts("win");
  }

  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

typedef struct {
	long long *data;
	int size;
} max_heap;

void push(long long x, max_heap* h)
{
	int i = h->size;
	h->data[(h->size)++] = x;
	while (1) {
		if (i == 0) break;
		else if (h->data[i] > h->data[(i-1)/2]) {
			h->data[i] += h->data[(i-1)/2];
			h->data[(i-1)/2] = h->data[i] - h->data[(i-1)/2];
			h->data[i] -= h->data[(i-1)/2];
			i = (i - 1) / 2;
		} else break;
	}
}

long long pop(max_heap* h)
{
	int i = 0, j;
	long long output = h->data[0];
	h->data[0] = h->data[--(h->size)];
	while (1) {
		if (i * 2 + 1 >= h->size) break;
		else if (i * 2 + 2 >= h->size) j = i * 2 + 1;
		else if (h->data[i*2+1] > h->data[i*2+2]) j = i * 2 + 1;
		else j = i * 2 + 2;
		if (h->data[j] > h->data[i]) {
			h->data[i] += h->data[j];
			h->data[j] = h->data[i] - h->data[j];
			h->data[i] -= h->data[j];
			i = j;
		} else break;
	}
	return output;
}

int main()
{
	int i, N, M;
	long long A[100001];
	scanf("%d %d", &N, &M);
	for (i = 1; i <= N; i++) scanf("%lld", &(A[i]));
	
	long long sum = 0, tmp;
	max_heap h;
	h.data = (long long*)malloc(sizeof(long long) * (N + 1));
	h.size = 0;
	for (i = 1; i <= N; i++) push(A[i], &h);
	for (i = 1; i <= M; i++) {
		tmp = pop(&h);
		tmp /= 2;
		push(tmp, &h);
	}
	
	for (i = 1; i <= N; i++) sum += pop(&h);
	printf("%lld\n", sum);
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 1664
import java.util.Scanner;

public class Main {
	public static void main(String args[]){
		Scanner scan = new Scanner(System.in); 
		
		double r;
	
		r = scan.nextDouble();
		
		System.out.println(String.format("%.6f", r * r * Math.PI) + " " + String.format("%.6f", r * 2 * Math.PI));
		
	}

}

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

using namespace std;

set<int> factors(long long n) {
    set<int> f;
    for (int x = 2; x*x <= n; x++)
        while (n%x == 0) {
            f.insert(x);
            n /= x;
        }
    if(n > 1) f.insert(n);
    return f;
}

const int N = (int) 1e6 + 9;

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> a(n);
  for (auto& x : a) {
    cin >> x;
  }
  vector<int> cnt(N, 0);
  bool bl = true;
  for (int i = 0; i < n; i++) {
    set<int> f = factors(a[i]);
    for (const auto& x : f) {
      cnt[x]++;
      if (cnt[x] > 1) {
        bl = false;
        break;
      }
    }
    if (bl == false) {
      break;
    }
  }
  if (bl == false) {
    int g = a[0];
    for (const auto& x : a) {
      g = gcd(x, g);
    }
    cout << (g == 1 ? "setwise coprime" : "not coprime") << '\n';
    return 0;
  }
  cout << "pairwise coprime" << '\n';
  return 0;
}

Measured memory_bytes: 11064
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define repr(i, a, b) for(ll i = (a); i < (b); i++)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((ll)(x).size())
const ll MOD = 1000000007;
const ll INF = 100000000000000000LL;
inline ll GCD(ll a, ll b){ return b?GCD(b, a % b):a; }
inline ll LCM(ll a, ll b){ return a/GCD(a, b)*b; }
inline ll powint(ll x, ll y){ ll r=1; while(y){ if(y&1) r*=x; x*=x; y>>=1; } return r; }
inline ll powmod(ll x, ll y, ll m = MOD){ ll r=1; while(y){ if(y&1) r*=x; x*=x; r%=m; x%=m; y>>=1; } return r; }
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; }
#ifdef OJ_LOCAL
#include "dump.hpp"
#else
#define dump(...) ((void)0)
#endif


ll N, A, B;

vll solve(ll n, ll a, ll b){
    dump("solve", n, a, b);
    if(n == 1){
        dump(vll{a, b});
        return vll{a, b};
    }
    
    ll Ad = a, Bd = b;
    ll x = 0;
    while(1){
        if((Ad&(1ll<<x)) != (Bd&(1ll<<x))){
            Ad >>= (x + 1);
            Bd >>= (x + 1);
            Ad <<= x;
            Bd <<= x;
            Ad += a%(1ll<<x);
            Bd += b%(1ll<<x);
            break;
        }
        x++;
    }
    ll C = Ad^1;
    dump(Ad, Bd, C, x);
    vll ret1 = solve(n-1, Ad, C);
    vll ret2 = solve(n-1, C, Bd);
    ll Ax = a&(1ll<<x);
    ll Bx = b&(1ll<<x);
    rep(i, SZ(ret1)){
        ret1[i] = ((ret1[i]>>x)<<(x+1)) + Ax + ret1[i]%(1ll<<x);
        ret2[i] = ((ret2[i]>>x)<<(x+1)) + Bx + ret2[i]%(1ll<<x);
    }
    copy(ALL(ret2), back_inserter(ret1));
    dump(ret1);
    return ret1;
}

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    cin >> N >> A >> B;
    if(__builtin_popcountll(A^B) % 2 == 0){
        cout << "NO" << endl;
        return 0;
    }
    vll ans = solve(N, A, B);
    cout << "YES" << endl;
    rep(i, SZ(ans)){
        cout << ans[i] << (i+1==SZ(ans)?"\n":" ");
    }
    return 0;
}

Measured memory_bytes: 2288
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int (i)=0;(i)<(n);i++)

int main(){

int n;
cin >> n;

if(n/100 == n%10)cout << "Yes" << endl;
else cout << "No" << endl;


return 0;

}




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

namespace ConsoleApp38 {
    class Program {
        static void Main(string[] args) {
            var st = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            int A = st[0];
            int B = st[1];
            int C = st[2];

            if (A == B) {
                Console.WriteLine(C);
            } else if (B == C) {
                Console.WriteLine(A);
            } else {
                Console.WriteLine(B);
            }


        }
    }
}


Measured memory_bytes: 13268
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<vector>
#include<queue>
#include<stack>
#include<cmath>
using namespace std;
const int inf=0x3f3f3f3f;
int f[10005][2],n,tmp;
int a[10005][2],x,y,lyq;
int main(){
    scanf("%d%d",&n,&lyq);
    lyq/=100;
    for(int i=1;i<=n;i++){
    	scanf("%d%d",&x,&y);
        y/=100;
        for(int j=x;j>=1;j--){
        	for(int k=1000-j;k>=0;k--){
        		if(j!=x)f[k+j][1]=max(f[k+j][1],f[k][0]+j*i);
        		else f[k+j][1]=max(f[k+j][1],f[k][0]+j*i+y);
			}
		}
		for(int j=0;j<=1000;j++)f[j][0]=max(f[j][0],f[j][1]),f[j][1]=0;
	}
	for(int i=1;i<=1000;i++){
		if(f[i][0]>=lyq){
			printf("%d",i);
			break;
		}
	}
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		var s = rs();
		Console.WriteLine(s[0] == s[2] ? "Yes" : "No");
	}

	public Sol(){
		
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()

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

    // start
    int a, b;
    cin >> a >> b;
    if (a + b >= 10)
        cout << "error" << endl;
    else
        cout << a + b << endl;
    // end

    return 0;
}


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

using namespace std;

using ll = long long;
using ld = long double;

const int INF = (1 << 30) - 1;
const ll INF64 = ((ll)1 << 62) - 1;
const double PI = 3.1415926535897932384626433832795;

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

int gcd(int x, int y) { return y ? gcd(y, x % y) : x; }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
int lcm(int x, int y) { return x / gcd(x, y) * y; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }

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

	int n;
	cin >> n;

	vector<int> t(n), x(n), y(n);
	for (int i = 0; i < n; i++) {
		cin >> t[i] >> x[i] >> y[i];
	}

	int timer = 0;
	int curX = 0, curY = 0;
	for (int i = 0; i < n; i++) {
		int diff = abs(curX - x[i]) + abs(curY - y[i]);
		int toho = diff + timer;

		if (toho > t[i]) {
			cout << "No" << endl;
			return 0;
		} else if ((t[i] & 1) != (toho & 1)) {
			cout << "No" << endl;
			return 0;
		}

		timer = t[i];
		curX = x[i];
		curY = y[i];
	}

	cout << "Yes" << endl;
	return 0;
}


Measured memory_bytes: 1408
from fractions import gcd


def wari(x, c, d):
    nc = x // c
    nd = x // d
    ncd = x // ((c * d) // gcd(c, d))
    return x - nc - nd + ncd


A, B, C, D = map(int, input().split())

nb = wari(B, C, D)
na = wari(A - 1, C, D)
print(nb - na)


Measured memory_bytes: 5884
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i, j, n) for(int i=j;i<n;++i)
#define all(i) i.begin(),i.end()
#define rall(i) i.rbegin(),i.rend()
#define INF 1e9
#define LINF 1e18
const int mod = 1e9 + 7;
 
typedef long long i64;
typedef pair<int, int> pi;
 
template <class T> using vt = vector<T>;
template <class T> using vvt = vector<vector<T>>;
 
template <class Abel> struct UnionFind {
  vector<int> par;
  vector<int> rank;
  vector<Abel> diff_weight;

  UnionFind(int n, Abel SUM_UNITY = 0) : par(n), rank(n, 0), diff_weight(n, SUM_UNITY) {
    for(int i = 0; i < n; ++i) par[i] = i;
  }

  Abel weight(int x) {
    find(x);
    return diff_weight[x];
  }

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

    int r = find(par[x]);
    diff_weight[x] += diff_weight[par[x]];
    return par[x] = r;
  }

  void unite(int x, int y, Abel w) {
    w += weight(x); w -= weight(y);
    x = find(x); y = find(y);

    if(x == y) return;
    if(rank[x] < rank[y]) swap(x, y), w = -w;
    if(rank[x] == rank[y]) ++rank[x];

    par[y] = x;
    diff_weight[y] = w;
  }

  bool same(int x, int y) {
    return find(x) == find(y);
  }

  Abel diff(int x, int y) {
    return weight(y) - weight(x);
  }
};

i64 gcd(i64 n, i64 m) {return (m == 0? n : gcd(m, n % m));}
i64 lcm(i64 n, i64 m) {return (n / gcd(n, m) * m);}
int dx[] = {0, -1, 0, 1, 1, 1, -1, -1};
int dy[] = {-1, 0, 1, 0, 1, -1, 1, -1};

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

  int n, m;
  while(cin >> n >> m, n && m) {
    UnionFind<int> uf(n + 1);

    rep(i, 0, m) {
      char c;
      int a, b, w;
      cin >> c;

      if(c == '!') {
        cin >> a >> b >> w;
        uf.unite(a, b, w);
      }
      else {
        cin >> a >> b;
        if(!uf.same(a, b)) cout << "UNKNOWN" << endl;
        else cout << uf.diff(a, b) << endl;
      }
    }
  }
}



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

typedef long long ll;

ll L, A, B;
int mod;

void specPower(int d, int q, ll p, int &dsum, int &sum, int &qpw)
{
    if (p == 0) { dsum = sum = 0; qpw = 1; }
    else {
        specPower(d, q, p / 2, dsum, sum, qpw);
        dsum = (ll(dsum) * qpw + ll(p / 2) * ll(d) % mod * sum + ll(dsum)) % mod;
        sum = (ll(sum) * qpw + ll(sum)) % mod;
        qpw = ll(qpw) * qpw % mod;
        if (p % 2) {
            dsum = (ll(dsum) * q + ll(p / 2 * 2) * d + ll(d)) % mod;
            sum = (ll(sum) * q + 1ll) % mod;
            qpw = ll(qpw) * q % mod;
        }
    }
}

int main()
{
    cin >> L >> A >> B >> mod;
    ll fir = A, lst = A + (L - 1) * B;
    ll lef = 1, rig = 10;
    int res = 0;
    while (lef <= lst) {
        if (fir < rig) {
            ll hm = (min(rig - 1, lst) - fir) / B + 1;
            int dsum, sum, qpw;
            specPower(B % mod, rig % mod, hm - 1, dsum, sum, qpw);
            int my = dsum;
            sum = (sum + qpw) % mod;
            my = (my + ll(fir % mod) * sum) % mod;
            qpw = ll(rig % mod) * qpw % mod;
            res = (ll(res) * qpw + ll(my)) % mod;
            fir += hm * B;
        }
        lef *= 10; rig *= 10;
    }
    printf("%d\n", res);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

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

    int s = 0;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        s += a[i];
    }
    sort(a.begin(), a.end());
    reverse(a.begin(), a.end());

    int b = 1;
    for (int i = 0; i < m; i++) {
        if (a[i] * m * 4 < s) b = 0;
    }

    cout << (b ? "Yes" : "No") << endl;

    return 0;
}

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

int main()
{
	long long a, b;
	cin >> a >> b;
	if((a + b) % 2 == 0){
		printf("%lld", (a + b) / 2);	
	}else{
		printf("IMPOSSIBLE");
	}
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
const int INF = 1e9 + 5;
int main() {
	int n,k;
	cin>>n>>k;

	vector<int> a (n);
	for(int i=0;i<n;i++) cin>>a[i];

	vector<int> dp (n, INF);
	dp[0] = 0;
	for(int i=1; i<n;i++) {
		for(int jump = 1; jump <= k && i - jump >=0; jump++) {
			dp[i] = min(dp[i], dp[i-jump] + abs(a[i] - a[i-jump]));
		}
	}
	cout<<dp[n-1]<<endl;;
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <stdio.h>
#include <string.h>
#define INF 1000000000

using namespace std;

int n,ans=INF;

int get_sum(int x)
{
	int ans=0;
	while(x) ans+=x%10,x/=10;
	return ans;
}

int main()
{
	scanf("%d",&n);
	for(int i=1;i<n;i++) ans=min(ans,get_sum(i)+get_sum(n-i));
	printf("%d\n",ans);
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
#include<deque>
#include<iomanip>
#include<tuple>
#include<cassert>
using namespace std;
typedef long long int LL;
typedef pair<int,int> P;
typedef pair<LL,int> LP;
const int INF=1<<30;
const LL MAX=1e9+7;

void array_show(int *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%d%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(LL *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%lld%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(vector<int> &vec_s,int vec_n=-1,char middle=' '){
	if(vec_n==-1)vec_n=vec_s.size();
	for(int i=0;i<vec_n;i++)printf("%d%c",vec_s[i],(i!=vec_n-1?middle:'\n'));
}
void array_show(vector<LL> &vec_s,int vec_n=-1,char middle=' '){
	if(vec_n==-1)vec_n=vec_s.size();
	for(int i=0;i<vec_n;i++)printf("%lld%c",vec_s[i],(i!=vec_n-1?middle:'\n'));
}

int main(){
	int n,m;
	int i,j,k;
	int a,b,c;
	cin>>a;
	cout<<a+a*a+a*a*a<<endl;
}

Measured memory_bytes: 3524
#include<stdio.h>
int truss(int a){
	int r=a%10;
	if(a==0){return 0;}
	else {return r+truss(a/10);}
}
int main(void){
	int N,A,B,i,sum=0;
	scanf("%d %d %d",&N,&A,&B);
	for(i=0;i<=N;i++){
		if(A<=truss(i)&&truss(i)<=B){sum+=i;}
	}
	printf("%d",sum);
	return 0;
}

Measured memory_bytes: 128
n = int(input())
ans = 0
num = 1
for i in range(n):
  num *= 10
  num %= 10 ** 9 + 7
ans += num
num = 1
for i in range(n):
  num *= 9
  num %= 10 ** 9 + 7
ans -= num * 2
num = 1
for i in range(n):
  num *= 8
  num %= 10 ** 9 + 7
ans += num
while ans < 0:
  ans += 10 ** 9 + 7
print(ans)

Measured memory_bytes: 9096
N = int(input())
A = [int(k) for k in input().split()]

result = True

# for char in A:
#     if(A.count(char) != 1):
#         result = False
#         break
# for i in range(N):
#     for j in range(i+1, N):
#         # print("A[i]= "+str(A[i])+", A[j]= "+str(A[j]))
#         if A[i] == A[j]:
#             result = False
A.sort()

for i in range(N-1):
    if (A[i] == A[i+1]):
        result = False
        break

if (result == True):
    print("YES")
else:
    print("NO")


Measured memory_bytes: 25172
#include <bits/stdc++.h>
#define ss second
#define ff first
#define all(x) x.begin(), x.end()

using namespace std;
using ll = unsigned long long;
using pii = pair<int, int>;

const int oo = 1e9 + 7;
const ll mod = 1e9 + 7,maxn = 100000000;
const double PI = acos(-1);


int main (){
    ios_base::sync_with_stdio(false);
    cin.tie(0); 
    string a, b, c;
    cin >> a  >> b >> c;

    cout << char(a[0] - 32) << char(b[0] - 32) << char(c[0] - 32) << endl;
    return 0;
}

Measured memory_bytes: 256
// #pragma GCC target("avx2")
#pragma GCC optimize("O3", "unroll-loops")

// #include <bits/extc++.h>
// using namespace __gnu_pbds;

#include <bits/stdc++.h>
using namespace std;

#define int long long
#define double long double
// template <typename T>
// using pbds_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
using pii = pair<int, int>;
template<typename T>
using prior = priority_queue<T, vector<T>, greater<T>>;
template<typename T>
using Prior = priority_queue<T>;

#define X first
#define Y second
#define ALL(x) (x).begin(), (x).end()
#define eb emplace_back
#define pb push_back

#define fastIO() ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define RANDOM() random_device __rd; \
                 mt19937 __gen = mt19937(__rd()); \
                 uniform_int_distribution<int> __dis(0, 1); \
                 auto rnd = bind(__dis, __gen);

const int INF = 1E18;
const int mod = 1E9 + 7;

int32_t main() {
    fastIO();
    
    int n, ans = 0;
    cin >> n;
    
    vector<int> v(n);
    for (auto &x : v) cin >> x;
    sort(ALL(v), [](auto a, auto b) {return a > b;});
    
    for (int i = 0; i < n; ++i) ans += ((i & 1) ? -1 : 1) * v[i];
    
    cout << ans << "\n";
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
    #define REP(i, n) for(i = 0; i < n ; i++){}
    #define REPN(i, n) for(i = n-1; i > -1 ; i--}{}
    #define MOD 1000000007
    using namespace std;    
    typedef unsigned int ll;
    typedef long long ull;
    int n;
    int a[100005];
    int dp[100005];
    int min(int a, int b){
        if(a<b) return a;
        else return b;
    }
    int inf = 2000000;

    int solve(int n){
        dp[0] = 0;
        dp[1] = abs(a[1] - a[0]);
        int left, right;
        if(n == 0) return 0;
        if(dp[n]!=-1) return dp[n];
        if(n-2>=0) left = abs(a[n] - a[n-2]) + solve(n-2);
        if(n-1>=0) right =  abs(a[n] - a[n-1]) + solve(n-1);
        return dp[n] = min(right, left);
    }

    int main() {
        #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin) ;
        freopen("output.txt", "w", stdout) ;
        #endif
        ios_base::sync_with_stdio(false);
        cin.tie(NULL) ; cout.tie(NULL) ;
        cin >> n;
        for(int i = 0 ; i < n ; i++){
            cin >> a[i];
        }
        memset(dp, -1, sizeof(dp));
        cout << solve(n-1);
        // for(int i = 0; i < n; i++) cout << dp[i] << ' ';
        cout << endl;
    }

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

int d[11][11];
int f[101][101];

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int A,B;
	cin>>A>>B;
	for(int i=1;i<=A;i++)
		for(int j=1;j<=B;j++)
			cin>>d[i][j];
	for(int i=1;i<=A;i++)
		for(int j=1;j<=B;j++)
			for(int a=0;a<=100;a++)
				for(int b=0;b<=100;b++)
					f[a][b]=max(d[i][j]-i*a-j*b,f[a][b]);
	for(int i=1;i<=A;i++)
		for(int j=1;j<=B;j++){
			bool sw=false;
			for(int a=0;a<=100;a++)
				for(int b=0;b<=100;b++)
					if(f[a][b]+a*i+b*j==d[i][j])
						sw=true;
			if(!sw){
				cout<<"Impossible"<<endl;
				return 0;
			}
		}
	cout<<"Possible"<<endl;
	cout<<202<<' '<<101*101+200<<endl;
	cout<<201<<' '<<1<<" X\n";
	for(int i=1;i<100;i++)
		cout<<i<<' '<<i+1<<" X\n";
	for(int i=101;i<200;i++)
		cout<<i<<' '<<i+1<<" Y\n";
	cout<<200<<' '<<202<<" Y\n";
	for(int i=0;i<=100;i++)
		for(int j=0;j<=100;j++){
			if(i==0)
				cout<<201;
			else
				cout<<i;
			cout<<' ';
			if(j==0)
				cout<<202<<' ';
			else
				cout<<201-j<<' ';
			cout<<f[i][j]<<'\n';
		}
	cout<<201<<' '<<202<<endl;
}


Measured memory_bytes: 384
def gcd(a, b):
    if a == 0:
        return b
    if b == 0:
        return a
    if a < b:
        return gcd((b % a), a)
    if b < a:
        return gcd((a % b), b)


a, b = list(map(int, input().split()))
print((a * b) // gcd(a, b))


Measured memory_bytes: 38256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>
#include <set>
#include <functional>
#include <iomanip>

using namespace std;

#define DEBUG_ //!!$BDs=P;~$K%3%a%s%H%"%&%H(B!!
#ifdef DEBUG_
#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
#define dump(x)  ;
#endif

#define equals(a,b) (fabs((a)-(b)) < EPS)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back

//#define int long long

typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

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>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

template <typename T>
void print_array(const T &ary, int size){
    REP(i,size){
        cout << ary[i] << " ";
    }
    cout << endl;
}

const int mod = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;
const double EPS = (1e-10);
const long double PI = 3.14159265358979323846264338327950288419716939937510582097494459230781640628620899;


signed main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(12);

    int Q; cin >> Q;
    REP(_,Q){
        LL A,B; cin >> A >> B;
        if(A > B) swap(A,B);
        LL ok = 0, ng = B;
        while(abs(ok-ng) > 1){
            LL mid = (ok+ng) / 2;
            if(mid <= A+1){
                if(mid * (A+1) < A*B) ok = mid;
                else ng = mid;
            }else{
                LL cost;
                if((A+1+mid)%2 == 0){
                    LL tmp = (A+1+mid) / 2;
                    cost = tmp * tmp;
                }else{
                    LL tmp = (A+1+mid) / 2;
                    cost = tmp * (tmp+1);
                }
                if(cost < A*B) ok = mid;
                else ng = mid;
            }
        }
        cout << A-1+ok << endl;
    }

}

Measured memory_bytes: 256
from collections import deque

H,W=map(int, input().split())
S=[list(input()) for i in range(H)]
INF=10**6
M=[[10**6]*W for i in range(H)]
dx = [1, 0, -1, 0]
dy = [0, 1, 0, -1]

def bfs(y,x):
  q=deque()
  q.append((y,x))
  
  while len(q):
    y,x=q.popleft()
    
    for i in range(4):
      ny=y+dy[i]
      nx=x+dx[i]
      if (0<=ny<H and 0<=nx<W and M[ny][nx]==INF and S[ny][nx]!='#'):
        q.append((ny, nx))
        M[ny][nx] = M[y][x]+1      
    
ans=0
for y in range(H):
  for x in range(W):
    if S[y][x]!='#':      
      M=[[10**6]*W for i in range(H)]
      M[y][x]=0
      bfs(y,x)
      for i in range(H):
        for j in range(W):
          if M[i][j]!=INF:
            ans=max(ans,M[i][j])
print(ans)

Measured memory_bytes: 3436
#[allow(unused_imports)]
use std::cmp::*;
use std::io::*;
#[allow(dead_code)]
fn getline() -> String {
    let mut ret = String::new();
    std::io::stdin().read_line(&mut ret).ok();
    return ret;
}
#[allow(dead_code)]
fn getword() -> String {
    let mut stdin = std::io::stdin();
    let mut u8b: [u8; 1] = [0];
    loop {
        let mut buf: Vec<u8> = Vec::with_capacity(16);
        loop {
            let res = stdin.read(&mut u8b);
            if res.is_err() ||u8b[0] <= ' ' as u8 {
                break;
            } else {
                buf.push(u8b[0]);
            }
        }
        if buf.len() >= 1 {
            let ret = std::string::String::from_utf8(buf).unwrap();
            return ret;
        }
    }
}
#[allow(dead_code)]
fn parse<T : std::str::FromStr>(s : &str) -> T {
     return s.parse::<T>().ok().unwrap();
}
 
fn gcd(a: i64, b: i64) -> i64 {
    if b == 0 {
        a
    } else {
        gcd(b, a % b)
    }
}
 
#[allow(dead_code)]
fn pow(b: i64, n: i64, md: i64) -> i64 {
    let mut sum = 1;
    let mut cur = b % md;
    let mut e = n;
    while e > 0 {
        if e % 2 == 1 {
            sum = sum * cur % md;
        }
        cur = cur * cur % md;
        e /= 2;
    }
    return sum;
}
 
// 1 + b + ... + b^(n - 1) mod md
#[allow(dead_code)]
fn acc(b: i64, n: i64, md: i64) -> i64 {
    if n <= 0 {
        return 0;
    }
    if n % 2 == 1 {
        return (1 + ((b + b * b) % md) * acc(b * b % md, n / 2, md)) % md;
    }
    return acc(b * b % md, n / 2, md) * (1 + b) % md;
}
fn main() {
    let n: i64 = parse(&getword());
    let x: i64 = parse(&getword());
    let g = gcd(n+x, x);
    let t = 3 * (n - g);
    println!("{}", t);
}


Measured memory_bytes: 380
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define mt make_tuple
#define pqueue priority_queue
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  int N, M;
  cin>>N>>M;
  vector<vector<pair<int, ll> > > edge(N), redge(N);
  int a, b;
  ll c;
  for(int i=0;i<M;++i) {
    cin>>a>>b>>c;
    a--;
    b--;
    edge[a].push_back(mp(b, -c));
    redge[b].push_back(mp(a, -c));
  }
  bool reach0[N], reachN[N];
  for(int i=0;i<N;++i) {
    reach0[i] = false;
    reachN[i] = false;
  }
  queue<int> que;
  que.push(0);
  int node;
  while(!que.empty()) {
    node = que.front();que.pop();
    if(reach0[node]) continue;
    reach0[node] = true;
    for(int i=0;i<edge[node].size();++i) {
      if(reach0[edge[node][i].fi]) continue;
      que.push(edge[node][i].fi);
    }
  }
  que.push(N-1);
  while(!que.empty()) {
    node = que.front();que.pop();
    if(reachN[node]) continue;
    reachN[node] = true;
    for(int i=0;i<redge[node].size();++i) {
      if(reachN[redge[node][i].fi]) continue;
      que.push(redge[node][i].fi);
    }
  }
  ll ans[N];
  for(int i=0;i<N;++i) ans[i] = big;
  ans[0] = 0;
  ll cost;
  bool can = true;
  for(int i=0;i<=N;++i) {
    for(int j=0;j<N;++j) {
      if(!reach0[j] || !reachN[j]) continue;
      for(int k=0;k<edge[j].size();++k) {
        node = edge[j][k].fi;
        cost = edge[j][k].se;
        if(!reach0[node] || !reachN[node]) continue;
        if(ans[j]+cost<ans[node]) {
          if(i==N) can = false;
          else {
            ans[edge[j][k].fi] = ans[j]+cost;
          }
        }
      }
    }
  }
  if(can) cout<<-ans[N-1]<<endl;
  else cout<<"inf"<<endl;
}



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

static const int MAX_N = 100;

void trace(int A[], int N) {
    for (int i = 0; i < N; ++i) {
        if (i == N-1) cout << A[i] << endl;
        else cout << A[i] << " ";
    }
}

void insertionSort(int A[], int N) {
    int v = 0, j = 0;
    for (int i = 1;i <= N-1; ++i) {
        v = A[i];
        j = i - 1;
        while (j >= 0 && A[j] > v) {
            A[j+1] = A[j];
            j--;
        }
        A[j+1] = v;
        trace(A, N);
    }
}

int main() {
    int N, A[MAX_N];
    cin >> N;

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

    trace(A, N);
    insertionSort(A, N);
    return 0;

}


Measured memory_bytes: 3116
use std::thread;

fn run() {
    let input = read_input();
    let mut input = input.split_whitespace();
    let in_n: i64 = input.next().unwrap().parse().unwrap();
    let in_x: Vec<i64> = input.map(|s| s.parse().unwrap()).collect();

    let mut y = in_x.clone();
    y.sort();
    let x1 = y[in_n as usize / 2 - 1];
    let x2 = y[in_n as usize / 2];
    for x in in_x {
        println!("{}", if x <= x1 { x2 } else { x1 });
    }
}

fn main() {
    thread::Builder::new()
        .stack_size(32 * 1024 * 1024) // 32MB
        .spawn(run)
        .unwrap()
        .join()
        .unwrap();
}

/// ローカル環境なら _in.txt から入力を受ける
fn read_input() -> String {
    use std::fs::File;
    use std::io::Read;
    let mut s = String::new();
    match option_env!("LOCAL") {
        Some(_) => File::open("src/_in.txt")
            .expect("File not found")
            .read_to_string(&mut s)
            .unwrap(),
        None => std::io::stdin().read_to_string(&mut s).unwrap(),
    };
    s
}


Measured memory_bytes: 17656
import sys

A,B,C,D = map(int, input().split())

flg = 0
while 1:
    if flg==0:
        C = C - B
        if C<=0:
            print("Yes")
            sys.exit()
        flg = 1
    else:
        A = A - D
        if A<=0:
            print("No")
            sys.exit()
        flg = 0

    

Measured memory_bytes: 9184
#include<iostream>
#include <bits/stdc++.h>
using namespace std;
int main()
{

    int N;
    cin >> N;

    vector<int> vec;

    // 配列初期化
    for (int i = 0; i < N; i++) {
        vec.push_back(0);
    }
  
    for (int i = 0; i < vec.size() - 1; i++) {
        int A;
        cin >> A;

        vec.at(A - 1) += 1;        
    }

    // 出力
    for (int i = 0; i < N; i++) {
        cout << vec.at(i) <<  endl;
    }
    

    return 0;
}

Measured memory_bytes: 4316
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        int h=sc.nextInt();
        int w=sc.nextInt();
        char[][]po=new char[h][w];
        int[][][]a=new int[h][w][2];
        for(int i=0;i<h;i++){
            po[i]=sc.next().toCharArray();
        }
        for(int i=0;i<h;i++){
            for(int j=0;j<w;j++){
                if(j==0){
                    int count=0;
                    while(j+count<w&&po[i][j+count]=='.')count++;
                    a[i][j][0]=count;
                }
                else{
                    if(po[i][j]=='.')
                        if(po[i][j-1]=='.'){
                            a[i][j][0]=a[i][j-1][0];
                        }
                        else{
                            int count=0;
                            while(j+count<w&&po[i][j+count]=='.')count++;
                            a[i][j][0]=count;
                        }
                    else {
                        a[i][j][0]=0;
                    }
                }
            }
        }
        for(int i=0;i<w;i++){
            for(int j=0;j<h;j++){
                if(j==0){
                    int count=0;
                    while(j+count<h&&po[j+count][i]=='.')count++;
                    a[j][i][1]=count;
                }
                else{
                    if(po[j][i]=='.')
                        if(po[j-1][i]=='.'){
                            a[j][i][1]=a[j-1][i][1];
                        }
                        else{
                            int count=0;
                            while(j+count<h&&po[j+count][i]=='.')count++;
                            a[j][i][1]=count;
                        }
                    else {
                        a[j][i][1]=0;
                    }
                }
            }
        }
        int ans=0;
        for(int i=0;i<h;i++){
            for(int j=0;j<w;j++){
               // System.out.print(a[i][j][0]+","+a[i][j][1]+" ");
            
                ans=Math.max(ans,a[i][j][0]+a[i][j][1]-1);
                
            }
            //System.out.println();
        }
        System.out.println(ans);
    }
}


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

using namespace std;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int arr[10001];
	for (int i=0; i<10001; i++) arr[i] = 0;
	for (int i=1; i<100; i++) {
		for (int j=1; j<100; j++) {
			for (int k=1; k<100; k++) {
				if(i*i+j*j+k*k+i*j+i*k+j*k<=10000)
				arr[i*i+j*j+k*k+i*j+i*k+j*k]++;
			}
		}
	}
	int n;
	cin>>n;
	for (int i=1; i<=n; i++) cout<<arr[i]<<'\n';	
}


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

#define pii pair<int, int>
#define mp make_pair
#define vi vector<int>
#define fi first
#define se second

typedef long long ll;
const int N = 1e5 + 1;

pii lr[N], li[N], ri[N];

int main(){
	int n;
	ll lans = 0, rans = 0, ans;
	cin >> n;
	for(int i = 0; i < n; i++){
		int l, r;
		cin >> l >> r;
		lr[i] = mp(l, r);
		li[i] = mp(l, i);
		ri[i] = mp(r, i);
	}
	sort(ri, ri+n);
	sort(li, li+n);
	vi gr(n), gl(n);
//	cout << li[0].fi << " " << li[1].fi << endl;
	int cur = 0, l = 0, r = n-1;
	for(int i = 0; i < n; i++){
		if(i % 2){
			while(gr[ri[l].se])
				l++;
			if(ri[l].fi > cur)
				break;
			else{
				rans += cur-ri[l].fi;
				gr[ri[l].se]++;
				cur = ri[l].fi;
//				cout << "went left " << cur << " rans = " << rans << endl;
			}
		}else{
			while(gr[li[r].se])
				r--;
			if(li[r].fi < cur)
				break;
			else{
				rans += li[r].fi - cur;
				cur = li[r].fi;
				gr[li[r].se]++;
//				cout << "went right " << cur << " rans = " << rans << endl;
			}
		}
	}
	rans += abs(cur);
	cur = l = 0;
	r = n-1;
	for(int i = 0; i < n; i++){
		if(i % 2 == 0){
			while(gl[ri[l].se])
				l++;
			if(ri[l].fi > cur)
				break;
			else{
				lans += cur-ri[l].fi;
				gl[ri[l].se]++;
				cur = ri[l].fi;
			}
		}else{
			while(gl[li[r].se])
				r--;
			if(li[r].fi < cur)
				break;
			else{
				lans += li[r].fi - cur;
				cur = li[r].fi;
				gl[li[r].se]++;
			}
		}
	}
	lans += abs(cur);
	cout << max(lans, rans) << endl;
	return 0;
}

Measured memory_bytes: 3456
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define IFOR(i, m, n) for (ll i = n - 1; i >= m; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define FOREACH(x, a) for (auto&(x) : (a))
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

void yes() {
  cout << "Yes" << endl;
  exit(0);
}

void no() {
  cout << "No" << endl;
  exit(0);
}

int main() {
  vector<vector<ll>> a(3, vector<ll>(3));
  REP(i, 3) {
    REP(j, 3) { cin >> a[i][j]; }
  }
  ll n;
  cin >> n;
  vector<vector<bool>> c(3, vector<bool>(3, false));
  REP(_, n) {
    ll b;
    cin >> b;
    REP(i, 3) {
      REP(j, 3) {
        if (a[i][j] == b) {
          c[i][j] = true;
        }
      }
    }
  }

  REP(i, 3) {
    bool ok = true;
    REP(j, 3) {
      if (!c[i][j]) {
        ok = false;
        break;
      }
    }
    if (ok) {
      yes();
    }
  }

  REP(j, 3) {
    bool ok = true;
    REP(i, 3) {
      if (!c[i][j]) {
        ok = false;
        break;
      }
    }
    if (ok) {
      yes();
    }
  }

  if (c[0][0] && c[1][1] && c[2][2]) {
    yes();
  }

  if (c[2][0] && c[1][1] && c[0][2]) {
    yes();
  }

  no();
}

Measured memory_bytes: 256
#import <Foundation/Foundation.h>
int main(){
    @autoreleasepool {
        char c;
        NSMutableArray *A = [NSMutableArray array];
        NSMutableArray *X = [NSMutableArray array];
        int xs = 0;
        while((c=getchar())!=EOF){
            if (!(c>='a'&&c<='z')) break;
            if (c=='x') {
                xs++;
            } else {
                [X addObject:@(xs)];
                xs = 0;
                [A addObject:@(c)];
            }
        }
        [X addObject:@(xs)];
        long M = [A count];
        for(long i=0;i<M/2;i++){
            if([[A objectAtIndex:i] integerValue] != [[A objectAtIndex:M-1-i] integerValue]) {
                puts("-1");
                return 0;
            }
        }
        long s = 0;
        long N = [X count];
        for(long i=0;i<N/2;i++){
            s += ABS([[X objectAtIndex:i] integerValue] - [[X objectAtIndex:N-1-i] integerValue]);
        }
        printf("%ld",s);
    }
}


Measured memory_bytes: 7780
#include <iostream>
#include <fstream>
#include <algorithm>
//#define LOCAL
using namespace std;
typedef long long ll;
const int mx=1e3+10;
ll num1[mx], num2[mx];
int main() {
#ifdef LOCAL
ifstream fin("1.txt");
streambuf*p;
p=cin.rdbuf(fin.rdbuf());
#endif // LOCAL
ll n1, n2;
cin>>n1;
for(ll i=1;i<=n1;i++) cin>>num1[i];
cin>>n2;
for(ll i=1;i<=n2;i++) cin>>num2[i];

ll a=1, b=1;

while(a<=n1&&b<=n2&&num1[a]==num2[b]){
    a++, b++;
}
if(a<=n1&&b<=n2){
    (num1[a]<num2[b])?puts("1"):puts("0");
}else if(a>n1&&b>n2){
    puts("0");
}else{
    (a>n1)?puts("1"):puts("0");
}


#ifdef LOCAL
fin.close();
#endif // LOCAL
}




Measured memory_bytes: 3108
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>

using namespace std;

//----------------------- Print Function ----------------------//

inline void print() {
    cout << '\n';
}
template <typename First, typename... Rest>
void print(const First &first, const Rest &... rest) {
    cout << first << ' ';
    print(rest...);
}

//------------------------- Libraries -------------------------//

#include <iostream>
#include <vector>
#include <functional>
#include <algorithm>
#include <iomanip>
using namespace std;


template<class Monoid> struct SegTree {
    using Func = function<Monoid(Monoid, Monoid)>;
    const Func F;
    const Monoid UNITY;
    int SIZE_R;
    vector<Monoid> dat;
    
    SegTree(int n, const Func f, const Monoid &unity): F(f), UNITY(unity) { init(n); }
    void init(int n) {
        SIZE_R = 1;
        while (SIZE_R < n) SIZE_R *= 2;
        dat.assign(SIZE_R * 2, UNITY);
    }
    
    /* set, a is 0-indexed */
    void set(int a, const Monoid &v) { dat[a + SIZE_R] = v; }
    void build() {
        for (int k = SIZE_R - 1; k > 0; --k)
            dat[k] = F(dat[k*2], dat[k*2+1]);
    }
    
    /* update a, a is 0-indexed */
    void update(int a, const Monoid &v) {
        int k = a + SIZE_R;
        dat[k] = v;
        while (k >>= 1) dat[k] = F(dat[k*2], dat[k*2+1]);
    }
    
    /* get [a, b), a and b are 0-indexed */
    Monoid get(int a, int b) {
        Monoid vleft = UNITY, vright = UNITY;
        for (int left = a + SIZE_R, right = b + SIZE_R; left < right; left >>= 1, right >>= 1) {
            if (left & 1) vleft = F(vleft, dat[left++]);
            if (right & 1) vright = F(dat[--right], vright);
        }                                                                                                              
        return F(vleft, vright);
    }
    inline Monoid operator [] (int a) { return dat[a + SIZE_R]; }
    
    /* debug */
    void print() {
        for (int i = 0; i < SIZE_R; ++i) {
            cout << (*this)[i];
            if (i != SIZE_R-1) cout << ",";
        }
        cout << endl;
    }
};


//--------------------------- Solve ---------------------------//

void solve() {
    int N; cin >> N;
    vector<int> h(N+1), a(N+1);
    for (int i = 0; i < N; i++) cin >> h[i];
    for (int i = 0; i < N; i++) cin >> a[i];

    auto f = [](long long a, long long b) { return max(a, b); };
    SegTree<long long> dp(N+1, f, 0);

    for (int i = 0; i < N; i++) {
        long long A = dp.get(0, h[i]);
        if (dp.get(h[i], h[i]+1) < A + a[i]) {
            dp.update(h[i], A + a[i]);
        }
    }

    cout << dp.get(0, N+1) << '\n';
}

int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);

    solve();

    return 0;
}

Measured memory_bytes: 8984
import java.util.*;

class Main{
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] a = new int[n];
		int[] b = new int[n];
		int[] c = new int[n-1];
		for(int i = 0; i < n; i++){
			a[i] = sc.nextInt();
		}
		for(int i = 0; i < n; i++){
			b[i] = sc.nextInt();
		}
		for(int i = 0; i < n-1; i++){
			c[i] = sc.nextInt();
		}
		int sum = 0;
		int hoz = -1;
		for(int i = 0; i < n; i++){
			sum+=b[a[i]-1];
			if(a[i]==hoz+1){
				sum+=c[a[i]-2];
			}
			hoz = a[i];
		}
		System.out.print(sum);
	}
}


Measured memory_bytes: 21844
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
#include <ctime>
#include <cassert>
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
#define fs first
#define sc second
#define INF 1000000000
#define MOD 1000000007
#define EPS 0.00000001


int main(){
    int N, M; cin >> N >> M;
    vector<vector<PII>> P(100001);
    for(int i=0; i<N; i++){
        int a, b; cin >> a >> b;
        P[a].push_back({a, b});
    }

    priority_queue<PII> Q;
    
    ll ans = 0;
    for(int i=1; i<=M; i++){
        for(int j=0; j<P[i].size(); j++){
            Q.push({P[i][j].sc, P[i][j].fs});
        }
        
        if(Q.size()!=0){
            ans += Q.top().fs;
            Q.pop();
        }
    }
    
    
    
    cout << ans << endl;
    return 0;
}





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

int Gcd(int a, int b)
{
	//??????????????????????????????
	if (a < b) swap(a, b);
	if (b == 0) return a;
	return Gcd(a % b, b);
}

int main()
{
	int a, b;
	while (cin >> a >> b)
	{
		int gcd = Gcd(a, b);
		int lcm = a / gcd * b;
		cout << gcd << " " << lcm << endl;
	}

	return 0;
}

Measured memory_bytes: 1160
import sys
cnt = [0]*26

for line in sys.stdin:
    for c in line:
        c_ord = ord(c)
        if 65<=c_ord<=90:
            cnt[c_ord-65] += 1
        elif 97<=c_ord<=122:
            cnt[c_ord-97] += 1
            
for i in range(26):
    print(chr(i+97),":",cnt[i])


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


int main() {
    int N;
    std::cin >> N;
    std::string cs;
    std::cin >> cs;
    int red = 0;
    for (int i = 0; i < N; i++) {
        if (cs[i] == 'R') {
            red++;
        }
    }
    int swap = 0;
    for (int i = 0; i < red; i++) {
        if (cs[i] == 'W') {
            swap++;
        }
    }
    std::cout << swap << std::endl;
}


Measured memory_bytes: 3748
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>

using namespace std;

struct Info{
	int length;
	int count;
};


int main(){

	Info info[12];
	bool FLG;

	int index,tmp;

	scanf("%d",&tmp);

	info[0].length = tmp;
	info[0].count = 1;
	index = 1;


	for(int i = 1; i < 12; i++){
		scanf("%d",&tmp);
		FLG = false;
		for(int k = 0; k < index; k++){
			if(info[k].length == tmp){
				FLG = true;
				info[k].count++;
				break;
			}
		}
		if(!FLG){
			info[index].length = tmp;
			info[index].count = 1;
			index++;
		}

	}

	if(index >= 4){
		printf("no\n");
	}else if(index == 1){
		printf("yes\n");
	}else if(index == 2){
		if(info[1].count < info[0].count)swap(info[1],info[0]);
		if(info[0].count == 4 && info[1].count == 8){
			printf("yes\n");
		}else{
			printf("no\n");
		}
	}else{ //index == 3

		if(info[0].count == 4 && info[1].count == 4 && info[2].count == 4){
			printf("yes\n");
		}else{
			printf("no\n");
		}
	}
	return 0;
}

Measured memory_bytes: 2612