akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;
 
#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------
 
int N;
int A[202020];
vector<int> V;
void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N;
	FOR(i,N) {
		cin>>A[i];
		V.push_back(A[i]);
	}
	sort(ALL(V));
	
	FOR(i,N) {
		if(A[i]<=V[N/2-1]) cout<<V[N/2]<<endl;
		else cout<<V[N/2-1]<<endl;
	}
	
}
 
 
int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}

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

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define erep(i, n) for (ll i = 0; i <= (ll)(n); ++i)
#define FOR(i,a,b) for (ll i = (a); i < (ll)(b); ++i)
#define EFOR(i,a,b) for (ll i = (a); i <= (ll)(b); ++i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } }

ll gcd(ll m, ll n) {
    ll tmp;
    while (m % n != 0) {
        tmp = n;
        n = m % n;
        m = tmp;
    }
    return n;
}

ll lcm(ll m, ll n) {
    return max(m, n)/gcd(m,n) * min(m,n);
}


int main() {
    int n,a,b; cin >> n >> a >> b;
    cout << min(n*a,b) << endl;

    return 0;
}


Measured memory_bytes: 384
import itertools

n, m, q = map(int, input().split())
query = [list(map(int, input().split())) for _ in range(q)]

ans = 0

l = [i+1 for i in range(m)]

for v in itertools.combinations_with_replacement(l, n):
  v = sorted(list(v))
  now = 0
  for i in range(q):
    a, b, c, d = query[i]
    if v[b-1] - v[a-1] == c:
      now += d
  ans = max(ans, now)
  
print(ans)

Measured memory_bytes: 9160
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#include <map>
#include <unordered_map>
#include <set>
#include <fstream>
#include <chrono>
#include <random>
#include <bitset>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define sz(x) ((int)(x).size())
#define pb push_back
#define mod 1000000007
using ll = long long;
using namespace std;

vector<int> prime(1000001);
unordered_map<int,int> max_map;

int power(int a, int n)
{
  if (n == 0) return 1;
  int p = power(a, n / 2) % mod;
  p = (p * p) % mod;
  if (n & 1)
    p = (p * a) % mod;
  return p;
}

void sieve()
{
  prime[0] = prime[1] = 1;
  for (int i = 2; i < 1000001; i++) {
    if (prime[i] == 0) {
      for (int j = i * 2; j < 1000001; j += i) {
        if (prime[j] == 0) prime[j] = i;
      }
      prime[i] = i;
    }
  }
}

ll lcmModuloM(vector<int> ar, int N)
{

    for (int i = 0; i < N; i++) {
        int num = ar[i];
        unordered_map<int, int> temp;

        // Temp stores mapping of prime factor to
        // its power for the current element
        while (num > 1) {

            // Factor is the smallest prime factor of num
            int factor = prime[num];

            // Increase count of factor in temp
            temp[factor]++;

            // Reduce num by its prime factor
            num /= factor;
        }

        for (auto it : temp) {

            // Store the highest power of every prime
            // found till now in a new map max_map
            max_map[it.first] = max(max_map[it.first], it.second);
        }
    }

    ll ans = 1;

    for (auto it : max_map) {

        // LCM is product of primes to their highest powers modulo M
        ans = (ans * power(it.first, it.second)) % mod;
    }

    return ans;
}

ll mpow(ll a, ll n){
  ll res =1;
  while(n){
    if(n&1) res=res*a%mod;
    a=a*a%mod;
    n>>=1;

  }
  return res;
}

ll inv(ll a){
  return mpow(a,mod-2);
}

int main(){
  ll N; cin >> N;
  vector<int> A(N); rep(i,N) cin >> A[i];
  sieve();
  ll a = lcmModuloM(A,N);
  ll ans = 0;
  rep(i,N){
    ans += a*inv(A[i]);
    ans %= mod;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 4608
s = raw_input()
s = [i for i in s]

over_g = 0

score = 0

#print s

for c in s:
    if(over_g == 0):
        if(c == 'p'):
            score -= 1
        over_g += 1
#        print over_g,'g'
    else:
        if(c == 'g'):
            score += 1
        over_g -= 1
#        print over_g,'p'

print score

Measured memory_bytes: 3600
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rep2(i,s,n) for (int i = s; i < n; ++i)
#define all(a) a.begin(),a.end()
#define tmax(a,b,c) max(a,max(b,c))
#define tmin(a,b,c) min(a,min(b,c))
#define pb push_back
#define fi first
#define se second
using namespace std;
using ll = long long;
using P = pair<int,int>;
template<class T> inline bool chmin(T& a,T b) {if(a > b){a = b; return true;} return false;}
template<class T> inline bool chmax(T& a,T b) {if(a < b){a = b; return true;} return false;}
const int inf = 1001001001;

int main() {
    string s,t;
    cin >> s >> t;
    cout << t << s << endl;
}

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

#define mod 1000000007
#define INF (int) 1e9 + 5

#define add emplace
#define pb push_back
#define eb emplace_back
#define all(x) begin(x), end(x)
#define len(x) ((int)(x).size())
#define exist(a, x) (a.find(x) != end(a))
#define log(x) cout << (x) << endl;
#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define rrep(i,a,b) for(int i=(int)(a);i>=(int)(b);--i)
#define loop(i,a,b) for(int i=(int)(a);i<(int)(b);++i)

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using pi = pair<int,int>;
using vpi = vector<pi>;
using vvi = vector<vi>;
using vstr = vector<string>;


int main() {
	int n; cin>>n;
	vi a(n), dp(n,INF);
	rep (i, n) cin >> a[i];

	dp[0] = 0;
	for (int i=0; i<n; ++i) {
		for (int j: {i+1, i+2}) if (j < n) {
			dp[j] = min( dp[j], dp[i] + abs(a[i] - a[j]) );
		}
	}

	cout << dp[n-1] << endl;
	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
 
int main() {
string S;
  cin >> S;
  if(S[0] == S[1]||S[1] == S[2]||S[2] == S[3]){
   cout << "Bad" << endl; 
  }else{
   cout << "Good" << endl; 
  }
}

Measured memory_bytes: 3588
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define mt make_tuple
#define pb push_back
const int N = 1e3 + 10;
char board[N][N];
ll dp[N][N];

int main(){
    int h,w;
    int mod = 1e9 + 7;
    cin>>h>>w;
    for(int i=1;i<=h;i++){
        for(int j=1;j<=w;j++){
            cin>>board[i][j];
        }
    }
    dp[0][0] = 1;
    for(int i=0;i<=h;i++){
        for(int j=0;j<=w;j++){
            if(i==0 || j==0)    dp[i][j] = 0;
            else if(i==1 && j==1)    dp[i][j] = 1;
            else{
                if(board[i][j]=='.')    dp[i][j] = (dp[i-1][j] + dp[i][j-1])%mod;
                else    dp[i][j] = 0;
            }
        }
    }
    cout<<dp[h][w]<<endl;
    return 0;
}

Measured memory_bytes: 9216
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using static System.Console;
using static System.Math;
using static MyIO;
using static MyUtil;

public class C { public static void Main() => (new Solver()).Solve(); }

public class Solver
{
	public void Solve()
	{
		long N = GetLong();
		long M = GetLong();
		var list = Range(0, N).Select(_ => Tuple.Create(GetLong(), GetLong())).ToList();
		list.Sort((x, y) => x.Item1.CompareTo(y.Item1));

		long rest = M;
		long sum = 0;
		for(int i = 0; i < N; i++)
		{
			long buy = Min(rest, list[i].Item2);
			sum += buy * list[i].Item1;
			rest -= buy;
			if(rest == 0)
				break;
		}
		WriteLine(sum);
	}
}

public static class MyIO
{
	private static string[] args = new string[0];
	private static int cnt = 0;
	private static IEnumerable<string> getArgs(long N) => Range(0, N).Select(_ => getArg());
	private static string getArg()
	{
		if(cnt == args.Length) { args = Console.ReadLine().Split(); cnt = 0; }
		return args[cnt++];
	}

	public static int GetInt() => int.Parse(getArg());
	public static long GetLong() => long.Parse(getArg());
	public static double GetDouble() => double.Parse(getArg());
	public static decimal GetDecimal() => decimal.Parse(getArg());
	public static string GetString() => getArg();
	public static char GetChar() => getArg()[0];
	public static int[] GetInts(long N) => getArgs(N).Select(int.Parse).ToArray();
	public static long[] GetLongs(long N) => getArgs(N).Select(long.Parse).ToArray();
	public static double[] GetDoubles(long N) => getArgs(N).Select(double.Parse).ToArray();
	public static decimal[] GetDecimals(long N) => getArgs(N).Select(decimal.Parse).ToArray();
	public static string[] GetStrings(long N) => getArgs(N).ToArray();
}

public static class MyUtil
{
	public static void chmax<T>(ref T x, T y) where T : IComparable<T> { if(x.CompareTo(y) < 0) x = y; }
	public static void chmin<T>(ref T x, T y) where T : IComparable<T> { if(x.CompareTo(y) > 0)	x = y; }
	public static void swap<T>(ref T x, ref T y) { T tmp = x; x = y; y = tmp; }
	public static long rightShift(long x, long y) => (x >> (int)y);
	public static long leftShift(long x, long y) => (x << (int)y);
	public static bool contains(long s, long x) => (rightShift(s, x) & 1L) == 1L;
	public static long gcd(long x, long y) => (y == 0) ? x : gcd(y, x % y);
	public static long lcm(long x, long y) => (x / gcd(x,y)) * y;	
	public static IEnumerable<int> Range(long start, long count) => Enumerable.Range((int)start, (int)count);
	public static void Sort(this List<string> source) => source.Sort(StringComparer.Ordinal);
}


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

static class Extensions
{
    public static int ToInt(this string s) => int.Parse(s);
    public static long ToLong(this string s) => long.Parse(s);
    public static char ToChar(this string s) => char.Parse(s);
    public static double ToDouble(this string s) => double.Parse(s);
    public static int[] ToIntArray(this string s) => s.Replace(',', ' ').Split(' ').Select(x => x.ToInt()).ToArray();
    public static long[] ToLongArray(this string s) => s.Replace(',', ' ').Split(' ').Select(x => x.ToLong()).ToArray();
    public static double[] ToDoubleArray(this string s) => s.Replace(',', ' ').Split(' ').Select(x => x.ToDouble()).ToArray();
}

class Program
{
    static void Main()
    {
        var abc = Console.ReadLine().ToIntArray();
        
        if (abc[0] + abc[1] >= abc[2])
        {
            Console.WriteLine("Yes");
        }
        else
        {
            Console.WriteLine("No");
        }
    }
    
}

Measured memory_bytes: 11348
//Author : Vipul Sharma

// LIBRARIES
#include <bits/stdc++.h>

// MACROS
#define ll long long int
#define ld long double
#define rep(i, a, b) for (ll i = a; i < b; i++)
#define rev(i,b,a) for(ll i=b-1;i>=a;i--)
#define eqrep(i,a,b) for(ll i=1;i<=b;i++)
#define itrep(at) for (auto it = at.begin(); it != at.end(); it++)
#define ld long double
#define pb push_back
#define w(t) while (t--)
#define booster                       \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);
#define mod 1000000007
#define endl "\n"
# define INF 0x3f3f3f3f 
#define deb1(x) cout << #x << " : " << x << endl;
#define deb2(x, y) cout << #x << " : " << x << "\t" << #y << " : " << y << endl;
#define deb3(x, y, z) cout << #x << " : " << x << "\t" << #y << " : " << y << "\t" << #z << " : " << z << endl;
#define deb4(x, y, z, w) cout << #x << " : " << x << "\t" << #y << " : " << y << "\t" << #z << " : " << z << "\t" << #w << " : " << w << endl;
#define deb5(a, b, c, d, e) cout << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl;
#define deb6(a, b, c, d, e, f) cout << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl;

using namespace std;
long long cost = 1e18;



int main()
{
	
	#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    booster;
    string s,t;
    cin>>s>>t;
    ll n=s.length();
    ll m=t.length();
    ll i=0,cnt=0;
    while(i<n)
    {
    	if(s[i]!=t[i]) cnt++;
    	i++;
    }
    cout<<cnt<<endl;
    return 0;
}

Measured memory_bytes: 3772
#include <bits/stdc++.h> // only for GCC
using namespace std;

vector<int> card;
int n,m;

void cut(int k){
    vector<int> forward, backward;
    for(int i=0; i < card.size(); i++){
        if(i < k) forward.push_back(card[i]);
        else backward.push_back(card[i]);
    }
    card.clear();
    for(int i=0; i < backward.size(); i++) card.push_back(backward[i]);
    for(int i=0; i < forward.size(); i++) card.push_back(forward[i]);
}

void shuffle(){
    vector<int> v = card;
    card.clear();
    for(int i=0; i < n; i++){
        card.push_back(v[i]);
        card.push_back(v[i+n]);
    }
}

int main(){
    cin >> n >> m;
    for(int i=1; i <= 2*n; i++){card.push_back(i);}

    for(int i=0; i < m; i++){
        int command;
        cin >> command;

        if(command == 0) shuffle();
        else cut(command);
    }
    for(int i=0; i < 2*n; i++){
        cout << card[i] << endl;
    }
}

Measured memory_bytes: 1220
#include <bits/stdc++.h>
#define rep(i,j) for (int (i)=0;(i)<(int)(j);++(i))
#define put(i) cout << (i) << endl
using namespace std;
typedef long long ll;
const int mod = 1e9+7;

int main() {
    int n, ans=0;
    cin >> n;
    vector<vector<int>> a(100001);

    for (int i=0; i<n; ++i) {
        int t;
        cin >> t;
        t--;
        a[i].push_back(t);
    }

    for (int i=0; i<n; ++i) {
        for (int j=0; j<a[i].size(); ++j) {
            auto itr = find(a[a[i][j]].begin(), a[a[i][j]].end(), i);
            if (itr != a[a[i][j]].end()) { ans++; break; }
        }
    }

    cout << ans/2 << endl;
}


Measured memory_bytes: 5760
import math
a,b,c = map(int,input().split())
k = int(input())
if b > a:
    cnt = 0

else:
    cnt = 0
    while(b <= a):
        cnt = cnt+1
        b = b*2

if c <= b:
    while(c <= b):
        cnt = cnt+1
        c = c*2

if cnt <= k:
    print("Yes")

else:
    print("No")

Measured memory_bytes: 9200
#include <stdio.h>
#define NIL -1

typedef struct node{
  int pa;
  int l;
  int r;
}Tree;

Tree T[100000];
int t[100000];
int n;

void dep(int,int);
void print(int);

int main()
{
  int i,j,k,v,c,l,r;

  scanf("%d",&n);

  for(i=0;i<n;i++){
    T[i].pa = NIL;
    T[i].l = NIL;
    T[i].r = NIL;
  }

  for(i=0;i<n;i++){
    scanf("%d%d",&v,&k);
    for(j=0;j<k;j++){
      scanf("%d",&c);
      if(j==0) T[v].l = c;
      else T[l].r = c;
      l = c;
      T[c].pa = v;
    }
  }

  for(i=0;i<n;i++){
    if(T[i].pa==NIL){
      r = i;
    }
  }

  dep(r,0);

  for(i=0;i<n;i++){
    print(i);
  }

  return 0;
}

void dep(int u,int p){
  t[u] = p;
  if(T[u].r!=NIL) dep(T[u].r,p);
  if(T[u].l!=NIL) dep(T[u].l,p+1);
}

void print(int u)
{
  int j,c;

  printf("node %d: parent = %d, depth = %d, ",u,T[u].pa,t[u]);
  if(T[u].pa==NIL) printf("root, ");
  else if(T[u].l==NIL) printf("leaf, ");
  else printf("internal node, ");
  printf("[");
  c = T[u].l;
  while(c!=NIL){
    printf("%d",c);
    if(T[c].r!=NIL) printf(", ");
    c = T[c].r;
  }
  printf("]\n");
}


      
    
  

  



Measured memory_bytes: 6404
import sys
from collections import Counter

N = int(input())
points = []
for i, line in enumerate(sys.stdin):
    x, y = map(int, line.split())
    points.append([x, y])
    if i == N - 1:
        break
if len(points) == 1:
    print(1)
    sys.exit(0)

counts = []
for i in range(N):
    for j in range(N):
        if i == j:
            continue
        p = points[j][0] - points[i][0]
        q = points[j][1] - points[i][1]
        counts.append((p, q))

pq = Counter(counts).most_common()[0][1]
cost = N - pq
print(cost)


Measured memory_bytes: 3956
#include<bits/stdc++.h>
#define N 100000
using namespace std;
long long n,up,down,x,y;
long long a[N+5];
inline char nc()
{
	static char buf[100000],*p1=buf,*p2=buf;
	return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
inline long long read()
{
	long long x=0,b=1;
	char c=nc();
	for(;!(c<='9'&&c>='0');c=nc())if(c=='-')b=-1;
	for(;c<='9'&&c>='0';c=nc())x=x*10+c-'0';
	return x*b;
}
inline void write(long long x)
{
	if(x==0)putchar('0');
	else
	{
		char buf[15];
		long long len=0;
		if(x<0)putchar('-'),x=-x;
		while(x)buf[++len]=x%10+'0',x/=10;
		for(long long i=len;i>=1;i--)putchar(buf[i]);
	}
	putchar(' ');
}
int main()
{
	//freopen("in.txt","r",stdin);
	n=read();
	for(long long i=1;i<=n;i++)a[i]=read();
	if(a[n]!=2)return cout<<-1,0;
	up=3,down=2;
	for(long long i=n-1;i>=1;i--)
	{
		x=ceil((double)down/a[i]);
		y=up/a[i];
		if(y>=x){
			up=y*a[i]+a[i]-1;
			down=x*a[i];
		}else return cout<<-1,0;
	}
	cout<<down<<" "<<up;
	return 0;
}


Measured memory_bytes: 1152
import * as fs from "fs";

const input = (fs.readFileSync("/dev/stdin", "utf8") as string).split("\n");
const [k, n] = input[0].split(" ").map((x: string): number => +x);
const a = input[1].split(" ").map((x: string): number => +x);

let sum = 0;
let prev = k + a[0];
let max_d = 0;
for (let i = n - 1; i >= 0; i--) {
	const d = prev - a[i]
	sum += d;
	if (d > max_d) max_d = d;
	prev = a[i];
}

console.log(sum - max_d);


Measured memory_bytes: 22392
from sys import stdin
nii=lambda:map(int,stdin.readline().split())

class UnionFind():
  def __init__(self, n):
    self.n = n
    self.parents = [-1] * n

  def find(self, x):
    if self.parents[x] < 0:
      return x
    else:
      self.parents[x] = self.find(self.parents[x])
      return self.parents[x]

  def union(self, x, y):
    x = self.find(x)
    y = self.find(y)

    if x == y:
      return

    if self.parents[x] > self.parents[y]:
      x, y = y, x

    self.parents[x] += self.parents[y]
    self.parents[y] = x

  def same(self, x, y):
    return self.find(x) == self.find(y)

n,m=nii()
p=list(nii())

uf=UnionFind(n)

for i in range(m):
  x,y=nii()
  x-=1
  y-=1
  uf.union(x,y)

cnt=0
for i in range(n):
  if not uf.same(i,p[i]-1):
    cnt+=1

print(n-cnt)

Measured memory_bytes: 14516
#include <bits/stdc++.h>
#define inf 999999999

using namespace std;

int d,e;
double ans;

int main(){
  int i,j;
  while(1){
    cin >> d >> e;
    if(d+e==0)break;
    ans = inf;
    for(i=0;i<d;i++){
      double x;
      x = abs(sqrt(i*i+(d-i)*(d-i))-e);
      if(ans>x)ans = x;
    }
    cout << ans << endl;
  }
  return 0;
}



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

using namespace std;
typedef long long ll;

ll pw5(ll a) {
    ll m = a * a;
    return m * m * a;
}

int main() {
    ll x;
    cin >> x;
    for (ll a = -200; a <= 200; a++) {
        for (ll b = -200; b <= a; b++) {
            if (pw5(a) - pw5(b) == x) {
                cout << a << " " << b << "\n";
                return 0;
            }
        }
    }
}


Measured memory_bytes: 3596
import java.util.*;
 
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        Map<Integer,Integer> map = new TreeMap<>();
        int[] p = new int[m];
        int[] y = new int[m];
        for (int i=0;i<m;i++){
            p[i] = sc.nextInt();
            y[i] = sc.nextInt();
            map.put(y[i],i);
        }
        int[] orderP = new int[n];
        int[] num    = new int[m];
        for (int k:map.keySet()){
            int prefecture = p[map.get(k)];
            orderP[prefecture-1]++;
            num[map.get(k)]=orderP[prefecture-1];
        }
        for (int i=0;i<m;i++){
            System.out.println(String.format("%06d",p[i])+String.format("%06d",num[i]));
        }
    }
}

Measured memory_bytes: 64548
#include <algorithm>
#include <iterator>
#include <iostream>
#include <iomanip>
#include <cassert>
#include <utility>
#include <string>
#include <vector>
#include <limits>
#include <queue>
#include <cmath>
#include <map>
#include <set>

using namespace std;

using ll = long long;

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

    ll out = 0;

    for(int month = 1; month <= m; ++month) {
        for(int day = 10; day <= d; ++day) {
            int d_1 = day % 10;
            int d_10 = day / 10;
            if(d_1 >= 2 && d_10 >= 2 && d_1 * d_10 == month)
                ++out;
        }
    }

    cout << out << endl;

    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <string>
#include <functional>

using namespace std;
typedef long long int ll;
typedef pair <int,int> P;

int main()
{
	int a,b;
	scanf("%d %d",&a,&b);
	if(a<=0&&0<=b) puts("Zero");
	else if(a>0) puts("Positive");
	else
	{
		int L=b-a+1;
		if(L%2==1) puts("Negative");
		else puts("Positive");
	}
	return 0;
}


Measured memory_bytes: 128
#define _GLIBCXX_DEBUG
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <tuple>
#include <string>
#include <queue>
#include <set>
#include <bitset>
#include <cmath>

using namespace std;

string s;
int A, B, C, D;

bool hasbit(int n, int i)
{
    return n & (1 << i);
}

int main(int argc, const char **argv)
{
    cin >> s;
    A = s[0] - '0';
    B = s[1] - '0';
    C = s[2] - '0';
    D = s[3] - '0';

    for (int i = 0; i <= 0b111; i++)
    {
        int sum(A);
        bool isPlusB = hasbit(i, 0);
        if (isPlusB)
        {
            sum += B;
        }
        else
        {
            sum -= B;
        }
        bool isPlusC = hasbit(i, 1);
        if (isPlusC)
        {
            sum += C;
        }
        else
        {
            sum -= C;
        }
        bool isPlusD = hasbit(i, 2);
        if (isPlusD)
        {
            sum += D;
        }
        else
        {
            sum -= D;
        }

        if (sum == 7)
        {
            cout << A << (isPlusB ? "+" : "-") << B << (isPlusC ? "+" : "-") << C << (isPlusD ? "+" : "-") << D << "=7" << endl;
            break;
        }
    }
    return 0;
}

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

void solve() {
    ll N, X, M;
    cin >> N >> X >> M;
    set<ll> visited;
    vector<ll> v;
    visited.emplace(X);
    v.emplace_back(X);
    ll prev = X, seed = X;
    while (true) {
        ll me = (prev * prev) % M;
        if (visited.count(me))
        {
            seed = me;
            break;
        }
        v.emplace_back(me);
        visited.emplace(me);
        prev = me;
    }

    ll sum = 0;
    if (N <= (int)v.size()) {
        for (int i = 0; i < N; ++i) sum += v[i];
    }
    else
    {
        int i = 0;
        for (; i < (int)v.size(); ++i) {
            if (v[i] == seed) {
                break;
            }
            sum += v[i];
            N--;
        }
        v.erase(v.begin(), v.begin() + i);
        ll ts = accumulate(v.begin(), v.end(), 0ll);
        ll f = N / (int)v.size();
        ll r = N % (int)v.size();
        sum += f * ts;
        for (int i = 0; i < r; ++i) sum += v[i];
    }
    cout << sum << "\n";
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int t = 1;
    while(t--) {
        solve();
    }
}


Measured memory_bytes: 5916
#include<iostream>
#include<cstdio>
#define N (100009)
using namespace std;

struct Edge{int to,next;}edge[N<<1];
int n,u,v,a[N],Ind[N],flag=true;
int head[N],num_edge;

void add(int u,int v)
{
	edge[++num_edge].to=v;
	edge[num_edge].next=head[u];
	head[u]=num_edge;
}

void Dfs(int x,int fa)
{
	if (!flag) return;
	int maxn=0;
	long long sum=0;
	for (int i=head[x]; i; i=edge[i].next)
		if (edge[i].to!=fa)
		{
			Dfs(edge[i].to,x);
			sum+=a[edge[i].to];
			maxn=max(maxn,a[edge[i].to]);
		}
	if (!maxn) return;
	if (sum<a[x] || sum>2*a[x] || maxn>a[x]) flag=false;
	a[x]=a[x]*2-sum;
}

int main()
{
	scanf("%d",&n);
	for (int i=1; i<=n; ++i)
		scanf("%d",&a[i]);
	for (int i=1; i<=n-1; ++i)
	{
		scanf("%d%d",&u,&v);
		add(u,v); add(v,u);
		Ind[u]++; Ind[v]++;
	}
	
	if (n==2)
	{
		if (a[1]==a[2]) puts("YES");
		else puts("NO"); 
		return 0;
	}
	
	int root=1;
	while (Ind[root]<=1) root++;
	Dfs(root,0);
	if (a[root]!=0) flag=false;
	if (flag) puts("YES");
	else puts("NO");
}

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

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pll;
typedef vector<bool> vb;
const ll oo = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-9;
#define sz(c) ll((c).size())
#define all(c) begin(c), end(c)
#define FOR(i,a,b) for (ll i = (a); i < (b); i++)
#define FORD(i,a,b) for (ll i = (b)-1; i >= (a); i--)
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define TR(X) ({ if(1) cerr << "TR: " << (#X) << " = " << (X) << endl; })

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	string s; cin >> s;

	vl dp(13);
	dp[0] = 1;

	for (char c: s) {
		vl ndp(13);

		ll cmin = c == '?' ? 0 : c-'0';
		ll cmax = c == '?' ? 9 : c-'0';
		
		FOR(i,0,13) FOR(j,cmin,cmax+1) {
			ndp[(10*i+j)%13] += dp[i];
		}
		
		dp = ndp;
		FOR(i,0,13) dp[i] %= ll(1e9+7);
	}

	cout << dp[5] << endl;

}



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

using namespace std;

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

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

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

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

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

int main() {
  fast();
  cin >> n;
  n >= 30 ? cout << "Yes" : cout << "No";

  return 0;
}



Measured memory_bytes: 3612
#include <iostream> 
#include <algorithm>
#include <vector>
#include <iomanip>
#include <math.h>
/*#define rep(i,n) for (int i = 0;i < n;i++)
using namespace std;
using ll = long long;
#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>;

ll choose2(ll n) {
  return n*(n-1)/2;
}

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  rep(i,n) a[i]--;
  vector<int> cnt(n);
  rep(i,n) cnt[a[i]]++;
  ll tot = 0;
  rep(i,n) {
    tot += choose2(cnt[i]);
  }
  rep(i,n) {
    ll ans = tot;
    ans -= choose2(cnt[a[i]]);
    ans += choose2(cnt[a[i]]-1);
    cout << ans << endl;
  }
  return 0;
}

//同じ数字はカウントして，nC2とする
/*ll choose2(ll n) {
    return n*(n-1)/2;//nC2偶数
}

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
rep(i,n) cin >> a[i];
rep(i,n) a[i]--;
vector<int> cnt(n);
rep(i,n) cnt[a[i]]++;
ll total = 0;
rep(i,n){
    total += choose2(cnt[i]);
}
rep(i,n){
    ll ans = total;
    total -= choose2(cnt[a[i]]);
    total += choose2(cnt[a[i]]);
cout << ans << endl;
}
 return 0;
}*/


Measured memory_bytes: 4096
// Frog 2 https://atcoder.jp/contests/dp/tasks/dp_b
#include <bits/stdc++.h>
using namespace std;

const int INF = 1e9 + 5;

int n, k;
vector<int> h;
vector<int> memo;
vector<bool> computed;

// rec(x) is best score to get to position x
int rec(int pos) {
	if(pos == 0) {
		return 0;
	}
	if(computed[pos]) {
		return memo[pos];
	}
	int best = INF;
	for(int jump = 1; jump <= k && pos - jump >= 0; ++jump) {
		best = min(best, rec(pos - jump) + abs(h[pos] - h[pos-jump]));
	}
	computed[pos] = true;
	return memo[pos] = best;
}

int solve1() {
	return rec(n-1);
}

int solve2() { // pull dp
	vector<int> dp(n);
	for(int i = 1; i < n; i++) {
		dp[i] = INF; // and now compute dp[i]
		for(int jump = 1; jump <= k && i - jump >= 0; ++jump) {
			dp[i] = min(dp[i], dp[i-jump] + abs(h[i]-h[i-jump]));
		}
	}
	return dp[n-1];
}

void min_self(int& a, int b) {
	a = min(a, b);
}

int solve3() { // push dp
	vector<int> dp(n, INF);
	dp[0] = 0;
	for(int i = 0; i <= n - 2; ++i) {
		for(int jump = 1; jump <= k && i + jump < n; ++jump) {
			min_self(dp[i+jump], dp[i] + abs(h[i]-h[i+jump]));
		}
	}
	return dp[n-1];
}

const int B = 16 * 1024; // greater than 10,000
struct Tree {
	vector<int> a;
	vector<multiset<int>> values_in_leaves;
	void init() {
		a.resize(2*B, INF);
		values_in_leaves.resize(B);
		for(int i = 0; i < B; ++i) {
			values_in_leaves[i].insert(INF);
		}
	}
	int query_min(int L, int R) {
		if(L > R) {
			return INF;
		}
		L += B;
		R += B;
		int x = min(a[L], a[R]);
		while(L + 1 < R) {
			min_self(x, a[L+1]);
			min_self(x, a[R-1]);
			L /= 2;
			R /= 2;
		}
		return x;
	}
	void insert(int i, int value) {
		values_in_leaves[i].insert(value);
		a[i+B] = *values_in_leaves[i].begin();
		for(int j = (i + B) / 2; j >= 1; j /= 2) {
			a[j] = min(a[2*j], a[2*j+1]);
		}
	}
	void erase(int i, int value) {
		values_in_leaves[i].erase(values_in_leaves[i].find(value));
		a[i+B] = *values_in_leaves[i].begin();
		for(int j = (i + B) / 2; j >= 1; j /= 2) {
			a[j] = min(a[2*j], a[2*j+1]);
		}
	}
};
Tree sum, diff;

void insert(int i, const vector<int>& dp) {
	sum.insert(h[i], dp[i] + h[i]);
	diff.insert(h[i], dp[i] - h[i]);
}
void erase(int i, const vector<int>& dp) {
	sum.erase(h[i], dp[i] + h[i]);
	diff.erase(h[i], dp[i] - h[i]);
}

int solve4() { // pull dp with segment trees
	vector<int> dp(n);
	
	// O(N * log(H))
	for(int i = 1; i < n; ++i) {
		insert(i-1, dp);
		if(i - k - 1 >= 0) {
			erase(i-k-1, dp);
		}
		// [i-k, i-1]
		dp[i] = INF;
		
		min_self(dp[i], diff.query_min(0, h[i]) + h[i]);
		min_self(dp[i], sum.query_min(h[i]+1, 10 * 1000) - h[i]);
	}
	return dp[n-1];
}

int main() {
	sum.init();
	diff.init();
	cin >> n >> k;
	h.resize(n);
	memo.resize(n, 0);
	computed.resize(n, false);
	for(int& x : h) {
		cin >> x;
	}
	cout << solve4();
}


Measured memory_bytes: 4736
from itertools import product, permutations,combinations


import sys
def input():
	return sys.stdin.readline().strip()

N, M, R = list(map(int, input().split()))
r = list(map(int, input().split()))

inf = 10000000000

dist = [[inf]*N for _ in range(N)]

for i in range(N):
	dist[i][i] = 0

for i in range(M):
	a, b, c = list(map(int, input().split()))
	a -= 1
	b -= 1
	dist[a][b] = min(dist[a][b], c)
	dist[b][a] = dist[a][b]

for k in range(N):
	for i in range(N):
		for j in range(i):
			dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j])
			dist[j][i] = dist[i][j]

min_dist = inf
for zyunro in permutations(r, len(r)):
	dist_sum = 0
	for i in range(R - 1):
		dist_sum += dist[zyunro[i] - 1][zyunro[i+1] - 1]
	min_dist = min(min_dist, dist_sum)

print(min_dist)


Measured memory_bytes: 44252
#include <bits/stdc++.h>
using namespace std;
int main() {
    ios_base :: sync_with_stdio(false);
    cin.tie(nullptr);
    int x, flag;
    cin >> x;
    for (int i = x; ; i++) {
        flag = 0;

        for (int j = 2; j < i; j++) {
            if (i % j == 0) {
                flag = 1;

                break;
            }
        }
        if (flag == 0) {
            cout << i;
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cstdio>
#include <cstdlib>
#include <cstring>
using namespace std;
  
struct Node{
  int key;
  Node *next, *prev;
};

Node *nil;

Node* listSearch(int key){
  Node *cur =nil->next;
  while(cur != nil && cur->key != key){
    cur = cur->next;
  }
  return cur;
}

void init(){
  nil = (Node *)malloc(sizeof(Node));
  nil->next = nil;
  nil->prev = nil;
}

void printList(){
  Node *cur = nil->next;
  int isf =0;
  while(1){
    if(cur==nil){
      break;
    }
    if(isf++>0){
      printf(" ");
    }
    printf("%d",cur->key);
    cur = cur->next;
  }
  printf("\n");
}

void deleteNode(Node *t){
  if (t == nil){
    return;
  }
  t->prev->next = t->next;
  t->next->prev = t->prev;
  free(t);
}

void deleteFirst(){
  deleteNode(nil->next);
}

void deleteLast(){
  deleteNode(nil->prev);
}

void deleteKey(int key){
  deleteNode(listSearch(key));
}

void insert(int key){
  Node *x = new Node;
  x->key = key;
  x->next = nil->next;
  nil->next->prev =x;
  nil->next = x;
  x->prev = nil;
}

int main(){
  int key,n;
  int size=0;
  char com[20];
  int np=0,nd =0;
  cin>>n;
  init();
  for(int i=0;i<n;i++){
    scanf("%s%d",com,&key);
    //com[n]  n's number alphabet
    if (com[0]=='i'){
      insert(key);
      np++;
      size++;
    }
    else if(com[0]=='d'){
      if(strlen(com)>6){
        if(com[6]=='F'){
          deleteFirst();
        }
        else if(com[6]=='L'){
          deleteLast();
        }
      }
      else{
        deleteKey(key);
        nd++;
      }
      size--;
    }
  }
  
  printList();
  
  return 0;
}


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

using namespace std;

int main()
{
  int a;
  cin >> a;
  string str;
  map<string, int> string_map;
  for(int i = 0; i < a; i++)
  {
    cin >> str;
    string_map[str]++;
  }
  cout << string_map.size() << endl;
  return 0;
}


Measured memory_bytes: 19224
<?php

fscanf(STDIN,"%d",$n);
$arr=array_map('intval',explode(" ",fgets(STDIN)));
$chart=[];
$x=0;
$y=0;
$money=1000;
for($i=1;$i<$n;$i++){
    $chart[$x][$y]=$arr[$i-1];
    $y+=1;
    
    if($i==$n-1){
        if($arr[$i-1]<$arr[$i]){
            $chart[$x][$y]=$arr[$i];
        }else{
            $chart[$x+1][0]=$arr[$i];
        }
        break;
    }elseif($arr[$i-1]>$arr[$i]){
        $x+=1;
        $y=0;
    }
}
for($j=0;$j<count($chart);$j++){
    if(count($chart[$j])>=2){
    $money=intdiv($money,min($chart[$j]))*max($chart[$j])+$money%min($chart[$j]);
    }
}
echo $money;

Measured memory_bytes: 16140
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define fr first
#define sc second
typedef pair<int, int> Pii;

int main() {
  int n, m, a, b;
  while( cin >> n, n ) {
    vector<Pii> v;
    for(int i=0; i<n; i++) {
      cin >> a >> b;
      v.pb(Pii(a, b));
    }

    cin >> m;
    for(int i=0; i<m; i++) {
      cin >> a >> b;
      v.pb(Pii(a, b));
    }

    sort(v.begin(), v.end());
    vector<int> dp(n+m, 0);
    int res = 0;
    for(int i=0; i<n+m; i++) {
      int mx = 0;
      for(int j=0; j<i; j++) {
	if( v[j].fr < v[i].fr && v[j].sc < v[i].sc ) {
	  mx = max(mx, dp[j]);
	}
      }

      dp[i] = mx+1;
      res = max(res, dp[i]);
    }

    cout << res << endl;
  }
}

Measured memory_bytes: 1204
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
const int mod = 998244353;
typedef long long ll;

struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  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 {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=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 {
    mint res(*this);
    return res/=a;
  }
};

const int MAX = 510000;//nCrのnの最大値と思われる
const int MOD = 998244353;
long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main(){
  int n, m, k;
  cin >> n >> m >> k;
  mint ans = 0;
  mint root = m-1;
  
  // 前処理
  COMinit();

  rep(i,k+1){
    ans+=root.pow(n-1-i)*m*COM(n-1,i);
    // cout << ans.x << endl;
  }
  
  cout << ans.x << endl;
  return 0;
}


Measured memory_bytes: 15604
#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 rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define pb push_back
#define eb emplace_back
#define yn {puts("Yes");}else {puts("No");}
#define print(x) cout << (x) << endl;
#define printa(x, n) for(ll i = 0; i < n; i++) {cout << (x[i]) << " ";} cout << endl;
#define printd(x) printf("%.12f\n", ans);
#define Yes() cout << "Yes" << endl;
#define No() cout << "No" << endl;
#define YES() cout << "YES" << endl;
#define NO() cout << "NO" << endl;
template<class T> bool chmin(T& a, const T& b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> bool chmax(T& a, const T& b) {if (a < b) {a = b; return 1;} return 0;}
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;

int main(void) {
    int n;
    cin >> n;
    int _min = 1e9 + 7, _minIdx;
    rep (i, n) {
        int a, b;
        cin >> a >> b;
        if (b < _min) {
            chmin(_min, b);
            _minIdx = a;
        }
    }
    
    cout << _minIdx + _min << endl;
    return 0;
}

Measured memory_bytes: 256
c = input()
abc = ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']
def alphabet():
    for i in range(len(abc)):
        if c == abc[i]:
            return abc[i+1]

print(alphabet())

Measured memory_bytes: 3060
import scala.io.StdIn._
object Main extends App {

  val n: Int = readInt()
  val testimoniesPerPerson: Seq[Seq[(Int, Int)]] = (1 to n).map { _ =>
    val numOfTestimonies = readInt()
    val testimonies: Seq[(Int, Int)] = Seq.fill(numOfTestimonies) {
      val testimony: Array[Int] = readLine().split(" ").map(_.toInt)
      (testimony(0) - 1, testimony(1)) // Modify to 0 origin
    }
    testimonies
  }


  def solve(): Int = {
    (0 until (1 << n)).foldLeft(0) { case (acc, i) =>
      val peopleList = (0 until n).collect {
        case j if isBitOn(i, j) => isHonestPerson(j, i)
      }
      if(peopleList.forall(v => v)) Math.max(acc, countHonest(i)) else acc
    }
  }

  def isHonestPerson(personIndex: Int, bit: Int): Boolean =
    testimoniesPerPerson(personIndex).forall { case (x, y) =>
      y == ((bit >> x) & 1)
    }


  def isBitOn(bit: Int, digit: Int): Boolean =
    ((bit >> digit) & 1) != 0

  def countHonest(bit: Int): Int=
    (0 until n).foldLeft(0) { case (acc, digit) =>
      if(isBitOn(bit, digit)) acc + 1 else acc
    }


  println(solve())

}


Measured memory_bytes: 41872
#include<bits/stdc++.h>
using namespace std;
#pragma region Macros
#define ll long long
#define ld long double
#define FOR(i,l,r) for(ll i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,1,n+1)
#define RFOR(i,l,r) for(ll i=(l);i>=(r);--i)
#define RREP(i,n) RFOR(i,n-1,0)
#define RREPS(i,n) RFOR(i,n,1)
#define pb push_back
#define eb emplace_back
#define SZ(x) ((ll)(x).size())
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
template<class T = ll> using V = vector<T>;
template<class T = ll> using VV = V<V<T>>;
using P = pair<ll, ll>;
#define ios\
    ios::sync_with_stdio(false);\
    cin.tie(nullptr);
#define VEC(type, name, size)\
    V<type> name(size);\
    IN(name)
#define VVEC(type, name, h, w)\
    VV<type> name(h, V<type>(w));\
    IN(name)
#define INT(...)\
    int __VA_ARGS__;\
    IN(__VA_ARGS__)
#define LL(...)\
    ll __VA_ARGS__;\
    IN(__VA_ARGS__)
#define STR(...)\
    string __VA_ARGS__;\
    IN(__VA_ARGS__)
#define CHAR(...)\
    char __VA_ARGS__;\
    IN(__VA_ARGS__)
#define DOUBLE(...)\
    DOUBLE __VA_ARGS__;\
    IN(__VA_ARGS__)
#define LD(...)\
    LD __VA_ARGS__;\
    IN(__VA_ARGS__)
template <class T> void scan(T a) { cin >> a; }
void scan(int &a) { cin >> a; }
void scan(long long &a) { cin >> a; }
void scan(char &a) { cin >> a; }
void scan(double &a) { cin >> a; }
void scan(long double &a) { cin >> a; }
void scan(char a[]) { scanf("%s", a); }
void scan(string &a) { cin >> a; }
template <class T> void scan(V<T> &);
template <class T, class L> void scan(pair<T, L> &);
template <class T> void scan(V<T> &a) { for(auto &i : a) scan(i); }
template <class T, class L> void scan(pair<T, L> &p){ scan(p.first); scan(p.second); }
template <class T> void scan(T &a) { cin >> a; }
void IN() {}
template <class Head, class... Tail> void IN(Head &head, Tail &... tail) { scan(head); IN(tail...); }
template <class T> inline void print(T x){ cout << x << '\n';}
template <class T> V<T> press(V<T> &x){ 
    V<T> res = x;
    sort(all(res));
    res.erase(unique(all(res)), res.end());
    REP(i, SZ(x)){
        x[i] = lower_bound(all(res), x[i]) - res.begin();
    }
    return res;
}
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true; }return false; }
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true; }return false; }
inline void Yes(bool b = true) {cout << (b ? "Yes" : "No") << '\n';}
inline void YES(bool b = true) {cout << (b ? "YES" : "NO") << '\n';}
inline void err(bool b = true) {if(b) {cout << -1 << '\n'; exit(0);}}
template<class T> inline void fin(bool b = true, T e = 0) {if(b) {cout << e << '\n'; exit(0);}}
template<class T> T Roundup_div(T x, T y) {return (x+(y-1))/y;}
template <typename T> T pow(T a, long long n, T e = 1) {T ret = e; while (n) {if (n & 1) ret *= a; a *= a; n >>= 1; } return ret; }
const ll INF = 1e18;
#pragma endregion

int main(){
    ios;
    INT(n, z, w);
    VEC(int, a, n);
    fin(n == 1, abs(a[0] - w));
    print(max(abs(a[n - 1] - w), abs(a[n - 2] - a[n - 1])));
}

Measured memory_bytes: 3636
#include <bits/stdc++.h> 
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define size_of_array(array) (sizeof(array)/sizeof(array[0]))
#define MAX 100005
#define NIL -1
using ll =long long;
using namespace std;
using Graph=vector<vector<int>>;
using Field=vector<vector<char>>;
using P =pair<int,int>;

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

int main(){
    int n;
    cin>>n;
    vector<ll> a(n);
    rep(i,n){
        cin>>a[i];
    }
    ll ans=0;
    for(int i=0;i<n-1;++i){
        if(a[i]>a[i+1]){
            ans+=a[i]-a[i+1];
            a[i+1]=a[i];
        }
    }
    cout<<ans<<endl;
}



Measured memory_bytes: 4840
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static void Main(string[] args)
    {
        var inputs = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
        var s = inputs[0];
        var w = inputs[1];

        Console.WriteLine(s > w ? "safe" : "unsafe");
    }
}

Measured memory_bytes: 18972
#include <stdio.h>

#define MAX 10000

int main(void){
    int x = 0;
    int i;
    for (i = 1; i <= MAX; i++){
        scanf("%d", &x);
        if(x != 0)
            printf("Case %d: %d\n", i, x);
        else
            break;
    }

    return 0;
}



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

#define int long long
#define endl "\n"
#define REP(i,a,n) for(int i=a;i<n;++i)
#define REPR(i,a,n) for(int i=a;i>n;--i)
#define RUP(a,b) (((a)+(b)-1)/(b))
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define INF LLONG_MAX/2
#define PI acos(-1.0)
//#define MOD 1000000007

typedef long long ll;
typedef pair<int,int> Pii;
typedef tuple<int,int,int> Tiii;
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef vector<Pii> VPii;
typedef vector<string> Vs;
typedef priority_queue<int> PQi;

template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
void vout(Vi &v){for(int i=0;i<(v).size();i++) cout<<v[i]<<" ";cout<<endl;}
void vout(Vs &v){for(int i=0;i<(v).size();i++) cout<<v[i]<<" ";cout<<endl;}
void vvout(VVi &v){for(int i=0;i<(v).size();i++) vout(v[i]);}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a,b)*b;}
int mypow(int x, int n, int m){if(n==0)return 1;if(n%2==0)return mypow(x*x%m,n/2,m);else return x*mypow(x,n-1,m)%m;}
int digit(int k,int i){string s = to_string(k);return s[s.size()-i]-'0';}
void uniq(Vi &v){sort(v.begin(),v.end()); v.erase(unique(v.begin(),v.end()),v.end());} //vectorの同じ要素消す
int ctoi(char c){if(c>='0'&&c<='9'){return c-'0';}return 0;}
int leng(int n){string s=to_string(n); return s.size();} //intの桁数
int digitsum(int n){int ret=0; while(n>0){ret+=n%10;n/=10;}return ret;} //桁和
int lesscount(int x,Vi &a){return lower_bound(a.begin(),a.end(),x)-a.begin();} //vector aにおけるx未満の数の個数
int orlesscount(int x,Vi &a){return upper_bound(a.begin(),a.end(),x)-a.begin();} //vector aにおけるx以下の数の個数
int morecount(int x,Vi &a){return a.size()-orlesscount(x,a);} //vector aにおけるxより大きい数の個数
int ormorecount(int x,Vi &a){return a.size()-lesscount(x,a);} //vector aにおけるx以上の数の個数
int count(int x,Vi &a) {return upper_bound(ALL(a),x)-lower_bound(ALL(a),x);} //vector aにおけるxの個数
Vi accum(Vi &v){Vi ret((v).size()+1);REP(i,0,(v).size()) ret[i+1]=ret[i]+v[i];return ret;}
bool comp(Pii a,Pii b){
    if(a.second != b.second) return a.second<b.second;
    else return a.first<b.first;
}

const string YES = "Yes";
const string NO = "No";
template<class T> void YesNo(T a) {cout<<(a?YES:NO)<<endl;}


signed main(){cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);
    string s;
    cin>>s;
    if(s[0]=='7' || s[1]=='7' || s[2]=='7') cout<<YES<<endl;
    else cout<<NO<<endl;
    return 0;
}


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

int main() {
  int N;
  cin >> N;
  int a[N];
  for (int i = 0; i < N; i++) {
    cin >> a[i];
  }
  
  int b[N];
  for (int i = 0; i < N; i++) {
    b[i] = 0;
  }
  
  for (int i = N-1; i >= 0; i--) {
    int n = i+1;
    b[i] = a[i];
    while (n + i + 1 <= N) {
      n += (i+1);
      b[i] += b[n-1];
      b[i] = b[i] % 2;
    }
  }
  
  int M = 0;
  
  for (int i = 0; i < N; i++) {
    if (b[i]) M++;
  }
  cout << M << endl;
  for (int i = 0; i < N; i++) {
    if (b[i])
    cout << i+1 << " ";
  }
}

Measured memory_bytes: 2432