akhauriyash/Code-Regression huggingface dataset:
// dfmt off
T lread(T=long)(){return readln.chomp.to!T;}T[] lreads(T=long)(long n){return iota(n).map!((_)=>lread!T).array;}
T[] aryread(T=long)(){return readln.split.to!(T[]);}void arywrite(T)(T a){a.map!text.join(' ').writeln;}
void scan(L...)(ref L A){auto l=readln.split;foreach(i,T;L){A[i]=l[i].to!T;}}alias sread=()=>readln.chomp();
void dprint(L...)(lazy L A){debug{auto l=new string[](L.length);static foreach(i,a;A)l[i]=a.text;arywrite(l);}}
static immutable MOD=10^^9+7;alias PQueue(T,alias l="b<a")=BinaryHeap!(Array!T,l);import std;
// dfmt on

import core.bitop;

void main()
{
    long N = lread();
    auto X = sread();
    ulong m = X.map!"a == '1'"().sum();
    ulong plain0 = () {
        if (m == 1)
            return -1;
        long ret;
        foreach (i, c; X)
        {
            if (c == '1')
            {
                ret += powmod(2, X.length - i - 1, m - 1);
                ret %= m - 1;
            }
        }
        return ret;
    }();
    ulong plain1 = () {
        long ret;
        foreach (i, c; X)
        {
            if (c == '1')
            {
                ret += powmod(2, X.length - i - 1, m + 1);
                ret %= m + 1;
            }
        }
        return ret;
    }();
    foreach (i; 0 .. X.length)
    {
        if (X[i] == '1' && m == 1)
        {
            writeln(0);
            continue;
        }
        ulong y = () {
            if (X[i] == '1')
            {
                return ((m - 1) + plain0 - powmod(2, X.length - i - 1, m - 1)) % (m - 1);
            }
            return (plain1 + powmod(2, X.length - i - 1, m + 1)) % (m + 1);
        }();
        // dprint(i, X[i] == '1', y, plain0, plain1);
        long ans = 1;
        while (y != 0)
        {
            y = g(y);
            ans++;
        }
        writeln(ans);
    }
}

ulong g(ulong x)
{
    return x % popcnt(x);
}

/// x^^n % m
T powmod(T = long)(T x, T n, T m = 10 ^^ 9 + 7)
{
    if (n < 1)
        return 1;
    if (n & 1)
    {
        return x * powmod(x, n - 1, m) % m;
    }
    T tmp = powmod(x, n / 2, m);
    return tmp * tmp % m;
}


Measured memory_bytes: 3892
#exec({'RUBY_THREAD_VM_STACK_SIZE'=>'100000000'},'/usr/bin/ruby', $0) if !ENV['RUBY_THREAD_VM_STACK_SIZE']

def inpf() a=gets.chomp.split(" ").map(&:to_f)end

def inps() a=gets.chomp.split(" ")end

def copy(a) Marshal.load(Marshal.dump(a)) end

def kaijo(n,r = 10**9+7)(n < 2)? 1 : (2..n).inject{|memo,u|memo=(memo*u)%r} end

def na(n,d=0) Array.new(n,d)end

def na2(n,m,d=0) Array.new(n){Array.new(m,d)}end

def na3(n,m,l,d=0) Array.new(n){Array.new(m){Array.new(l,d)}}end

def inp() a=gets.chomp.split(" ").map(&:to_i)end

def r_up(a, b) (a+b-1)/b end

def sum(a) a.inject(:+) end

def big(a,b) return (a>b)? a:b end

def small(a,b) return (a<b)? a:b end

k,n = inp
a = inp.sort
ans = a[0] + (k-a[-1])
(0...(n-1)).each do |i|
  ans = big(ans, (a[i+1] - a[i])).abs
end
p k - ans


Measured memory_bytes: 19840
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		double a = sc.nextDouble();
		double b = sc.nextDouble();
		BigDecimal aa = new BigDecimal(String.valueOf(a));
		BigDecimal bb = new BigDecimal(String.valueOf(b));
		BigDecimal ans = aa.multiply(bb);
		ans = ans.setScale(0, RoundingMode.DOWN);
		System.out.println(ans);
	}
}


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

int main(){
	string s;
	cin >> s;
	vector<bool> al(26);
	rep(i, 26) al.at(i) = false;

	rep(i, s.size()) al.at(s.at(i)-'a') = true;
	rep(i, 26){
		if(!al.at(i)){
			cout << (char)(i+'a') << endl;
			return 0;
		}
	}
	cout << "None" << endl;
}


Measured memory_bytes: 512
// AOJ 0267 Triangle of Blocks
// 2017.9.8 bal4u@uu
// 2017.11.18

#include <stdio.h>
#include <string.h>
#include <math.h>

int b[1003];

int isTriNum(int k)
{
	return ((int)sqrt((k << 3) + 1)) & 1;
}

int main()
{
	int n, i, k, a, sum, ans;

	while (scanf("%d", &n) && n) {
		for (sum = 0, i = 1; i <= n; i++) scanf("%d", &a), b[i] = a, sum += a;
		if (!isTriNum(sum)) { puts("-1"); continue; }
		ans = 0; while (1) {
			for (i = 1; ; i++) {
				if (i > n) { printf("%d\n", ans); goto done; }
				if (b[i] != i) break;
				b[i]--;
			}
			for ( ; i <= n; i++) b[i]--;
			for (k = 1, i = 1; i <= n; i++) if (b[i]) b[k++] = b[i];
			b[k] = n, n = k;
			if (++ans > 10000) { puts("-1"); break; }
		}
done:;
	}
	return 0;
}

Measured memory_bytes: 1804
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
int main()
{
    float n,k,i,a;
    cin>>n>>k;
    vector<int> v;
    for(i=0;i<n;i++){
        cin>>a;
    }
    cout<<int(ceil((n-k)/(k-1))) + 1;

}


Measured memory_bytes: 256
import numpy as np
#入力
N, K = map(int, input().split())
li = list(map(int,input().split()))
list.sort(li, reverse = True)

#出力
a = list(np.zeros(K))
if N - K>=0:
    b = list(np.ones(N-K))
    a.extend(b)
else:
    a = list(np.zeros(N))

print(int(np.dot(a, li)))

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

int h[200005];
bool good[200005];
int n,m,a,b,cnt=0;

int main() {
    cin >> n >> m;
    for (int i=1;i<=n;i++) cin >> h[i];
    for (int i=1;i<=n;i++) good[i]=1;
    while(m--) {
        cin >> a >> b;
        if (h[a]<h[b]) {good[a]=0;}
        else if (h[a]>h[b]) {good[b]=0;}
        else {good[a]=0; good[b]=0;}
    }
    for (int i=1;i<=n;i++) {
        if (good[i]) cnt++;
    }
    cout << cnt;
}



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

int main(){
    int N,K;
    char p[60];
    cin >> N >> K >> p;
    if(p[K-1]=='A'){
        p[K-1]='a';
    }
    if(p[K-1]=='B'){
        p[K-1]='b';
    }
    if(p[K-1]=='C'){
        p[K-1]='c';
    }
    cout << p << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize ("O2") // "Ofast" for REAL FAST
// #pragma GCC optimization ("unroll-loops")

// #pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#pragma GCC diagnostic ignored "-Wunused-variable"
#pragma GCC diagnostic ignored "-Wunused-result"
#pragma GCC diagnostic ignored "-Wunused-label"

#include <bits/stdc++.h>
#define DEBUG 1

using namespace std;

#define rep(i, a, b) for (i = (a); i < (b); i++)
#define trav(a, x) for (auto & a : x)
#define all(x) (x).begin (), (x).end ()
#define rall(x) (x).rbegin (), (x).rend ()
#define sz(x) (int) (x).size ()
#define FASTIO cin.sync_with_stdio (0); cin.tie (0); cin.exceptions (cin.failbit);

typedef long long ll;

typedef pair <int, int> pii;
#define f first
#define s second
#define mp(x, y) make_pair (x, y)

typedef vector <int> vi;
#define pb(x) push_back (x)

#define ddcout if (DEBUG) cout
#define ddprintf(fmt, ...) if (DEBUG) printf (fmt, ##__VA_ARGS__)

const ll   MOD   =  1e+9+7;
const ll   INF   =  0x3f3f3f3f3f3f3f3f;
const int  INFi  =  0x3f3f3f3f;
const ll   MAXN  =  1e+6+7; // UPDATE

int main ()
{
    int i, j;
    string s, t;
    cin >> s >> t;
    cout << t << s << "\n";


    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a) for(int i=0; i<(a); i++)
typedef long long ll;
template<typename T>
struct edge {
  int src, to;
  T cost;
  edge(int to, T cost) : src(-1), to(to), cost(cost) {}
  edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}
  edge &operator=(const int &x) {
    to = x;
    return *this;
  }
  operator int() const { return to; }
};
template<typename T>
using Edges = vector<edge<T>>;
template<typename T>
using WeightedGraph = vector<Edges<T>>;
using UnWeightedGraph = vector<vector<int>>;
template<typename T>
using Matrix = vector<vector<T>>;

/////////////////////////////////////////////////////////////////////
const ll inf = 1LL<<60;

ll d;
vector<ll> c(26);
vector<vector<ll>> s(365, vector<ll>(26));
vector<ll> t(365);
vector<set<ll>> st(26);

vector<ll> calc() {
  vector<ll> nsc(26);
  vector<ll> score(d);
  vector<ll> last(26, -1);
  rep(i, d) {
    last[t[i]] = i;
    rep(j, 26) {
      if (t[i] == j) nsc[j] += s[i][j];
      else nsc[j] -= c[j]*(i-last[j]);
    }
    ll sum = 0;
    rep(j, 26) sum += nsc[j];
    score[i] = sum;
  }
  return score;
}

ll fluctuation(ll nd, ll nx, ll px) {

  auto itrp = st[px].upper_bound(nd);
  ll befp = (itrp == st[px].end() ? d : *itrp) - nd;
  ll aftp = nd + 1;
  if (itrp != st[px].begin()) { itrp--; aftp -= *itrp + 1; }

  ll dec = s[nd][px] + (befp*aftp*c[px]);

  auto itrn = st[nx].upper_bound(nd);
  ll befn = (itrn == st[nx].end() ? d : *itrn) - nd;
  ll aftn = nd + 1;
  if (itrn != st[nx].begin()) { itrn--; aftn -= *itrn + 1; }

  ll inc = s[nd][nx] + (befn*aftn*c[nx]);

  return inc - dec;
}

int main()
{
  srand((unsigned)time(NULL));

  cin>>d;
  rep(i, 26) cin>>c[i];
  rep(i, d) rep(j, 26) cin>>s[i][j];

  rep(i, d) {
    ll tmp = 0;
    ll ma = -inf;
    rep(j, 26) {
      if (s[i][j] > ma) {
        ma = s[i][j];
        tmp = j;
      } else if (s[i][j] == ma) {
        if (c[j] < c[tmp]) {
          tmp = j;
        }
      }
    }
    t[i] = tmp;
  }
  vector<ll> fsc = calc();

  {
    vector<ll> last(26, -1);
    vector<ll> nsc(26);
    rep(i, d) {
      ll idx = 0;
      ll sum = 0;
      rep(j, 26) {
        nsc[j] -= c[j]*(i-last[j]);
        sum += nsc[j];
      }
      rep(j, 26) {
        ll aa = sum + c[j]*(i-last[j]) + s[i][j];
        ll bb = sum + c[idx]*(i-last[idx]) + s[i][idx];
        if (aa > bb && aa >= fsc[i]) {
          idx = j;
        }
      }
      nsc[idx] += c[idx]*(i-last[idx]) + s[i][idx];
      last[idx] = i;
      t[i] = idx;
    }
  }
  vector<ll> ssc = calc();

  rep(i, d) st[t[i]].insert(i);

  int ti = clock();
  while (clock() - ti < 197 * CLOCKS_PER_SEC / 100) {
    ll nd = rand() % d;
    ll nx = rand() % 26;
    ll px = t[nd];
    st[px].erase(nd);
    ll diff = fluctuation(nd, nx, px);
    if (diff > 0) {
      st[nx].insert(nd);
      t[nd] = nx;
    } else {
      st[px].insert(nd);
      t[nd] = px;
    }
  }

  rep(i, d) cout << t[i]+1 << endl;

  return 0;
}


Measured memory_bytes: 3760
#include<bits/stdc++.h>
using namespace std;
int n,k;
typedef long long int ll;
int main(){
	int n;
	cin>>n;
	int h[n];
	int k;
	cin>>k;
	for(int i=0;i<n;i++){
		cin>>h[i];
	}
	int *dp;
	dp=new int[n+1];
	fill(dp,dp+n+1,INT_MAX);
	dp[0]=0;
	for(int i=0;i<n;i++){
		for(int j=i+1;j<=i+k;j++){
			if(j<n){
				dp[j]=min(dp[j],dp[i]+abs(h[i]-h[j]));
			}
		}
	}
	cout<<dp[n-1];
}

Measured memory_bytes: 1024
n=int(input())
t=list(map(int,input().split()))
m=int(input())
p=[0]*m
x=[0]*m
for i in range(m):
  p[i],x[i]=map(int,input().split())  
for i in range(m):
  print(sum(t)-t[p[i]-1]+x[i])

Measured memory_bytes: 3064
using System;
class P{
  static void Main(){
    int n = int.Parse(Console.ReadLine());
    int[] p = new int[n];
    for (int i = 0;i < n;i++)
      p[i] = int.Parse(Console.ReadLine());
    Array.Sort(p);
    long sum = 0;
    for (int i = 0;i < n - 1;i++)
      sum += p[i];
    sum += p[n - 1] / 2;
    Console.WriteLine(sum);
  }
}

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

using namespace std;

const int MAX_N = 100000;

int n, a[MAX_N + 1];

int main() {
    cin >> n;

    for (int i = 1; i <= n; i++) {
        scanf("%d", &a[i]);
    }

    long long ans = 0;

    for (int i = 1; i <= n; i++) {
        ans += a[i] / 2;

        a[i] %= 2;

        int k = min(a[i], a[i + 1]);

        a[i] -= k;
        a[i + 1] -= k;

        ans += k;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 640
#include <cstdio>

using namespace std;
typedef long long llong;

#define MAX 10
const llong mod = 1000000000 + 7;

int main()
{
  int N, R;
  scanf("%d%d", &N, &R);
  if (N >= 10)
  {
    printf("%d\n", R);
  }
  else
  {
    printf("%d\n", R + 100 * (10 - N));
  }

  return 0;
}

Measured memory_bytes: 1732
#include<stdio.h>

int hantei(int n, int a)
{
	if (n%a ==0){
		return n/a;
	}else{
		return n/a+1;
	}
}

int main()
{
	int h,w,n;
	scanf("%d",&h);
	scanf("%d",&w);
	scanf("%d",&n);

	if (h>w){
		printf("%d\n", hantei(n, h));
	}else{
		printf("%d\n", hantei(n, w));
	}

	return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <cmath>
#include <numeric>
#include <algorithm>
#define rep(i,n) for(int i = 0; i < (n); i++)

using namespace std;

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

const long long INF = 1LL << 60;

using lint = long long;

int main(void)
{
	lint N, W;
	cin >> N >> W;

	vector <lint> w(N);
	vector <lint> v(N);

	rep(i, N) cin >> w[i] >> v[i];
	lint V = accumulate(v.begin(), v.end(), 0);
	vector<vector<lint>> dp(N + 1, vector<lint>(V+1, INF));


	dp[0][0] = 0;
	for (int i = 0; i < N; i++){
		for (int j = 0; j <= V; j++){
			if (j - v[i] >= 0)
				chmin(dp[i + 1][j], dp[i][j - v[i]] + w[i]);
			chmin(dp[i + 1][j], dp[i][j]);
		}
	}

	lint ans = 0;
	for (int i = 0; i <= V; i++){
		//cout << dp[N][i] << endl;
		if (dp[N][i] <= W) ans = i;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 80256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
ios_base::sync_with_stdio(false);
  cin.tie(NULL);
#ifndef ONLINE_JUDGE
 // freopen("input.txt","r",stdin);
#endif

  ll n;
  cin>>n;
  n--; 
  ll num=26;
  vector<ll> a;
   while(true)
   {
      a.push_back(n%num);
      ll temp=n/num;
      n/=num;
      n--;
     if(temp<26)
     {
        if(temp!=0)
            a.push_back(temp-1);
        break;
     }

   }

   
   

   for(int i=a.size()-1;i>=0;i--)
   {
      cout<<char(a[i]+'a');
   }


  return 0;
}

Measured memory_bytes: 3644
#include <iostream>
using namespace std;
int h,w,x,y;
int main() {
	cin >> h >> w >> x >> y;
	for (int i = 1;i <= h; i++) {
		for (int j = 1;j <= w; j++) {
			if (i <= y && j <= x)
				cout << 1;
			else if (i > y && j > x)
				cout << 1;
			else
				cout << 0;
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 1280
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <set>
using ll = long long;
using graph = std::vector<std::vector<ll>>;
using wGraph = std::vector<std::vector<std::pair<ll,ll>>>;
#define rep(i,n) for (int i=0; i < int(n); i++)

using namespace std;

int main() {
    ll N,M;
    cin >> N >> M;
    cout << (N * (N - 1) /2) + (M * (M - 1) / 2) << endl;

}


Measured memory_bytes: 256
import sys
from copy import deepcopy
from collections import deque
sys.setrecursionlimit(20000000)


def main():
    n = int(input())
    nums = list(map(int, input().split()))
    acs_nums = deepcopy(nums)
    acs_nums.sort()

    count = 0

    for i in range(len(nums)):
        if nums[i] != acs_nums[i]:
            count += 1

    if count < 3:
        print('YES')
    else:
        print('NO')


if __name__ == '__main__':
    main()



Measured memory_bytes: 3444
#include<bits/stdc++.h>
#define fint register int
#define h 5001
#define p 4765434
using namespace std;
struct node
{
	int x;
	int y;
	int z;
};
int n,m;
bool vis[h][h];
int ans[h][h];
char a[h][h];
int dir[4][2]={1,0,-1,0,0,1,0,-1};
deque <node>q;
inline void BFS();
int main()
{
	cin>>n>>m;
	int sa,sb;
	cin>>sa>>sb;
	int ta,tb;
	cin>>ta>>tb;
	for(fint i=1;i<=n;i++)
	for(fint j=1;j<=m;j++)
	cin>>a[i][j];
	q.push_back((node){sa,sb,0});
	for(fint i=1;i<=n;i++)
	for(fint j=1;j<=m;j++)
	ans[i][j]=-10086;
	BFS();
	ans[ta][tb]==-10086?cout<<-1:cout<<ans[ta][tb]-1;
	return 0;
}

inline void BFS()
{
	while(!q.empty())
	{
		node hea=q.front();
		q.pop_front();
		vis[hea.x][hea.y]=1;
		ans[hea.x][hea.y]=hea.z;
		for(fint i=0;i<4;i++)
		{
			int fx=hea.x+dir[i][0];
			int fy=hea.y+dir[i][1];
			if(fx>0&&fx<=n&&fy>0&&fy<=m&&a[fx][fy]=='.'&&!vis[fx][fy])
			q.push_front((node){fx,fy,hea.z});
		}
		for(fint i=hea.x-2;i<=hea.x+2;i++)
        for(fint j=hea.y-2;j<=hea.y+2;j++)
        if(i>0&&i<=n&&j>0&&j<=m&&a[i][j]=='.'&&!vis[i][j])
        q.push_back((node){i,j,hea.z+1});
	}
}

Measured memory_bytes: 22748
# include <bits/stdc++.h>
  typedef long long ll;
#define pii  pair<int,int>
#define vpii vector<pii>
#define vll  vector<ll>
#define vi  vector<int>
#define pb push_back
#define f  first
#define s  second
#define all v.begin(),v.end()
#define fio ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
typedef unsigned long long ulll;
 
using namespace std ;
int main () {

   int a,b,c,d;
   cin>>a>>b>>c>>d;
   cout<<max(a*b,c*d);

  return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<sstream>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<utility>
#include<numeric>
#include<algorithm>
#include<bitset>
#include<complex>

using namespace std;

typedef long long Int;
typedef vector<int> vint;
typedef pair<int,int> pint;
#define mp make_pair

template<class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; }
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }
int in() { int x; scanf("%d", &x); return x; }

int main() {
	int a,b,c,d;
	int aa,bb,cc,dd;
	int n;
	while(n=in()){
		int i;
		aa=bb=0;
		cc=dd=100000000;
		int num;
		for(i=0;i<n;i++){
			cin>>num;
			int m,s;
			int j;
			int sum=0;
			for(j=0;j<4;j++){
				cin>>m>>s;
				sum+=m*60+s;
			}
//cout<<num<<" "<<sum<<endl;
			if(sum>aa){
				b=a;bb=aa;
				a=num;aa=sum;
			}else if(sum>bb){
				b=num;bb=sum;
			}
			if(sum<dd){
				c=d;cc=dd;
				d=num;dd=sum;
			}else if(sum<cc){
				c=num;cc=sum;
			}
//cout<<"a "<<a<<" "<<aa<<endl;
//cout<<"b "<<b<<" "<<bb<<endl;
//cout<<"c "<<c<<" "<<cc<<endl;
//cout<<"d "<<d<<" "<<dd<<endl;
		}
		cout<<d<<endl<<c<<endl<<b<<endl;
	}
	return 0;
}

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

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

int main(){
  int n; cin>>n;
  vector<int> ans(n,0);
  
  for(int i=0; i<n-1; i++) {
    int a;
    cin >> a;
    ans.at(a-1)++;
  }
  for(int i=0; i<n; i++){
    cout <<ans.at(i)<<endl;
  }
}

Measured memory_bytes: 4028
a, b, c, x, y = map(int, input().split())
if a+b > 2*c:
    if(x > y):
        if(a > 2*c):
            print(x*2*c)
        else:
            print(y * c * 2 + (x - y)*a)
    else:
        if(b > 2*c):
            print(y*2*c)
        else:
            print(x * c * 2 + (y - x)*b)
else:
    print(x * a + y * b)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

using namespace __gnu_pbds;
using namespace std;

typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;

#define mp make_pair
#define pb push_back
#define pf push_front
#define ss second
#define ff first
#define sz(x) (int)x.size()
#define newl "\n"
#define vi vector<int>
#define pii pair<int, int>
#define vii vector<pii>
#define vl vector<ll>
#define pll pair<ll, ll>
#define vll vector<pll>
#define coutp cout << fixed << setprecision(12)
#define mem(x, val) memset(x, val, sizeof(x))
#define fastio                        \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define all(v) (v).begin(), (v).end()

const ld pi = 3.14159265359;
ll INF = 1e18 + 10;
ll MOD = 998244353;
ll mod = 1e9 + 7;

inline ll add(ll a, ll b, ll m)
{
    if ((a + b) >= m)
        return (a + b) % m;
    return a + b;
}

inline ll mul(ll a, ll b, ll m)
{
    if ((a * b) < m)
        return a * b;
    return (a * b) % m;
}

ll power(ll x, ll y, ll m)
{
    ll res = 1;
    x = x % m;
    if (x == 0)
        return 0;
    while (y > 0)
    {
        if (y & 1)
            res = (res * x) % m;
        y = y >> 1;
        x = (x * x) % m;
    }
    return res;
}

void solve()
{
    ll x,k,d;
    cin>>x>>k>>d;
    x=abs(x);
    ll v = x/d;
    ll l = min(k,v);
    ll ans=x-l*d;
    if((k-l)%2==0) {
        cout<<ans;
    }
    else {
        cout<<abs(ans-d);
    }
}

int main()
{
    fastio;
    int t;

    t = 1;
    //cin >> t;
    //int test=t;
    while (t-- > 0)
    {
        //cout<<"Case #"<<(test-t)<<": ";
        solve();
        cout << newl;
    }

    return 0;
}

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

int x,y; //二つの自然数x,y
int temp; //一時保持
int gcd; //xとyの最大公約数

int main() {
  cin >> x >> y;
  while(1) {
    if(x < y) {
      temp = x;
      x = y;
      y = temp;
    }
    temp = x%y;
    if(temp == 0) {
      gcd = y;
      break;
    }
    else {
      x = y;
      y = temp;
    }
  }
  cout << gcd << '\n';
  return(0);
}


Measured memory_bytes: 3096
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 2e5+5;
int n;
int a[MAXN], preMax[MAXN], sufMax[MAXN];
int main()
{
    scanf("%d", &n); for(int i = 1; i <= n; i++) scanf("%d", &a[i]);
    for(int i = 1; i <= n; i++) preMax[i] = max(preMax[i-1], a[i]);
    for(int i = n; i >= 1; i--) sufMax[i] = max(sufMax[i+1], a[i]);
    for(int i = 1; i <= n; i++) printf("%d\n", max(preMax[i-1], sufMax[i+1]));
//    system("pause");
}

Measured memory_bytes: 3968
#include <stdio.h>
//#include<math.h>
#include<string.h>
int main()
{
    char ch[10001];
    long int n,z,i;
    scanf("%ld %s", &n, &ch);
    for(i=0;ch[i]!='\0';i++){
        z = ((ch[i]-65)+n)%26;
        printf("%c",z+65);
    }
    printf("\n");
    return 0;
}

Measured memory_bytes: 128
n = int(input())
data = [list(map(int,input().split())) for _ in range(n - 1)]
time = [0] * n
for i,arr in enumerate(data):
    for k in range(i+1):
        if arr[1] > time[k]:
            time[k] = arr[0] + arr[1]
        elif time[k] % arr[2] == 0:
            time[k] += arr[0]
        else:
            time[k] += arr[2] - (time[k] % arr[2]) + arr[0]

for i in time:
    print(i)

Measured memory_bytes: 3188
#include<iostream>
using namespace std;
pair <long long int,long long int> p[105];
long long int dp[100005];
int main()
{
	long long int n,w;
	cin >> n >> w;
	for(long long int i=0;i<n;i++) {
		long long int w1,v1;
		cin >> w1 >> v1;
		p[i]=make_pair(w1,v1);
	}
	for(long long int i=0;i<n;i++) {
		for(long long int j=w;j>=0;j--) {
			if(j - p[i].first >= 0 && (j-p[i].first == 0 ||  dp[j-p[i].first]!=0)) {
                dp[j]=max(dp[j],p[i].second+dp[j-p[i].first]);
            }
		}
		/*for(long long int j=0;j<12;j++) {
			cout <<dp[j]<<" ";
		}
		cout <<endl;*/
	}
	/*for(long long int j=w;j>=0;j--) {
		for(long long int k=0;k<n;k++) {
			if(j-p[k].first!=p[k].first && dp[j-p[k].first]!=0 && dp[p[k].first]!=0) dp[j]=max(dp[j],dp[p[k].first]+dp[j-p[k].first]);
		}
	}*/
	long long int maxi=0;
	for(long long int i=0;i<=w;i++) {
		maxi=max(maxi,dp[i]);
	}
	cout <<maxi;
	return 0;
}


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

#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define RFOR(i, a, b) for(int i=(a); i>=(b); i--)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) RFOR(i, n, 0)
#define dump(x)  cout << #x << " = " << (x) << endl;

typedef long long ll;
typedef pair<int, int> ii;
const ll INF = 1e18;
const int inf = 1e8;

const string YES = "Yes";
const string NO = "No";

void solve()
{
  string S;
  cin >> S;
  vector<int> cnt(26,0);
  for (int i=0; i<4; i++) {
    cnt[S[i]-'A']++;
  }
  for (int i=0; i<26; i++) {
    if (cnt[i]!=0&&cnt[i]!=2) {
      cout << NO << endl;
      return;
    }
  }
  cout << YES << endl;
}

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


Measured memory_bytes: 256
// ※※※ 解答不能 ※※※
// tourist氏.
// https://atcoder.jp/contests/cf16-relay-open/submissions/8966086
#include <bits/stdc++.h>
using namespace std;
#define repx(i, a, b) for(int i = a; i < b; i++)
#define rep(i, n) repx(i, 0, n)
#define repr(i, a, b) for(int i = a; i >= b; i--)

int main(){
    int n, tt;
    scanf("%d %d", &n, &tt);
    vector<vector<int>> can(n, vector<int>(2, 0));
    can[0][0] = 1;
    can[1][1] = 1;
    while(tt--){
        int x, y;
        scanf("%d %d", &x, &y);
        --x; --y;
        swap(can[x], can[y]);
        for(int z : {x, y, x - 1, x + 1, y - 1, y + 1}){
            if(z >= 0 && z < n && can[z][0]){
                if(z - 1 >= 0) can[z - 1][1] = 1;
                if(z + 1 < n) can[z + 1][1] = 1;
            }
        }
    }
    int ans = 0;
    rep(i, n) ans += can[i][0] | can[i][1];
    printf("%d\n", ans);
    return 0;
}

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

typedef long long ll;

#define int ll
#define ALL(v) v.begin(), v.end()
#define _REP(i, n) for (int i = 0; i < n; i++)
#define REP(n) _REP(i, n)

/* define const */
const ll INF = (1ll << 60);
const ll MOD = (ll)1e9 + 7;
const ll MAX = 1e6;
/* end defineing */

signed main()
{
    int n;
    ll a[100000];
    map<ll, ll> m;
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
        m[a[i]]++;
    }

    int cnt = 0;
    for (auto itr = m.begin(); itr != m.end(); itr++)
    {
        if (itr->second < itr->first)
        {
            cnt += itr->second;
        }
        else if (itr->second > itr->first)
        {
            cnt += itr->second - itr->first;
        }
    }
    cout << cnt << endl;
}


Measured memory_bytes: 7040
using System;
class Program{
	static void Main(){
		long n=long.Parse(Console.ReadLine());
		long a=0,b=0;
		for(long i=0;i<=n;i++){
			if(i*(i+1)==n*2){
				a=i;
				b=i+1;
				break;
			}
		}
		if(a==0){Console.WriteLine("No");}
		else{
			Console.WriteLine("Yes");
			Console.WriteLine("{0}",b);
			long[][] arr=new long[b][];
			long k=1;
			for(long i=0;i<b;i++){
				arr[i]=new long[a+1];
				arr[i][0]=a;
				for(long j=1;j<b;j++){
					if(i<j){
						arr[i][j]=k;
						k++;
					}
					else{
						arr[i][j]=arr[j-1][i];
					}
				}
				Console.WriteLine(String.Join(" ",arr[i]));
			}
		}
	}
}

Measured memory_bytes: 18372
N, K = map(int, input().split())
AB = []
for i in range(N):
  AB.append(list(map(int, input().split())))
AB = sorted(AB)
o = 0
for i in range(N):
  o += AB[i][1]
  if o >= K:
    print(AB[i][0])
    break

Measured memory_bytes: 28640
#include <bits/stdc++.h>
#include <vector>
#include <string>
#include <iomanip>
#include <math.h>
#include <algorithm>
#define hmm "\n"
#define test() int t; cin>>t; while(t--)
#define ll long long int
#define ull unsigned long long
#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL);
using namespace std;
void solve()
{
    int n;
    string s,t,u,v;
    cin>>n>>s;
    for(int i=0; i<(s.length()/2); i++){
        t+=s[i];
    }
    u=t+t;
    if(s==u){
        cout << "Yes" <<hmm;
    }
    else{
        cout<<"No"<<hmm;
    }
    
}
int main()
{
    fastIO
    //test()
    solve();
}

Measured memory_bytes: 256
#!/usr/bin/env python3

def main():
    korg = int(input())
    ranran = {(1, 0): ["0"],
        (1, 1): ["1"],
        (1, 2): ["2"],
        (1, 3): ["3"],
        (1, 4): ["4"],
        (1, 5): ["5"],
        (1, 6): ["6"],
        (1, 7): ["7"],
        (1, 8): ["8"],
        (1, 9): ["9"],
        }  # Dict: (d, k) |-> list of strings
    for d in range(2, 11):
        for k in range(10):
            ranran[(d, k)] = []
            d2 = d - 1
            for k2 in [k - 1, k, k + 1]:
                if not 0 <= k2 <= 9:
                    continue
                for s in ranran[(d2, k2)]:
                    ranran[(d, k)].append(str(k) + s)
    ranran_f = []
    for key, v in ranran.items():
        ranran_f += v
    runrun = sorted(list({int(x) for x in ranran_f}))
    print(runrun[korg])

if __name__ == "__main__":
    main()


Measured memory_bytes: 37560
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <functional>
#define _USE_MATH_DEFINES
#include <cmath>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cfloat>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <cassert>
using namespace std;

#define EPS 1e-12
#define ull unsigned long long
#define ll long long
#define VI vector<ll>
#define PII pair<ll, ll> 
#define VVI vector<vector<ll> >
#define REP(i,n) for(int i=0,_n=(n);(i)<(int)_n;++i)
#define RANGE(i,a,b) for(int i=(int)a,_b=(int)(b);(i)<_b;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define ALLR(c) (c).rbegin(), (c).rend()
#define PB push_back
#define MP(a, b) make_pair(a, b)
#define POPCOUNT __builtin_popcount
#define POPCOUNTLL __builtin_popcountll
#define CLEAR(table, v) memset(table, v, sizeof(table));
#define PRINT1(table, D0) REP(d0, D0) cout<<table[d0]<<" "; cout<<"\n";
#define PRINT2(table, D0, D1) REP(d0, D0) { REP(d1, D1) cout<<table[d0][d1]<<" "; cout<<"\n"; }
#define PRINT3(table, D0, D1, D2) REP(d0, D0) { REP(d1, D1) { REP(d2, D2) cout<<table[d0][d1][d2]<<" "; cout<<"\n"; } cout<<"\n"; }
#define UNIFORM_DOUBLE(a, b) (((b-a)*(double)rand()/RAND_MAX)+a) // [a, b) 
#define UNIFORM_LL(a, b) (ll)UNIFORM_DOUBLE(a, b) // [a, b) 
#define IN(v, lo, hi) ((lo)<=(v) && (v)<(hi))
#define DD(v) cout<<#v<<": "<<v<<endl
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const map<T0, T1>& v) { for( typename map<T0, T1>::const_iterator p = v.begin(); p!=v.end(); p++ ){os << p->first << ": " << p->second << " ";} return os; }
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const pair<T0, T1>& v) { os << v.first << ": " << v.second << " "; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<T>& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << " "; } return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<vector<T> >& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << endl; } return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const set<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const deque<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }

#define MOD 1000000007LL
#define INF (1LL<<60)

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll N,M;
	while(cin>>N>>M) {
		cout<<(N*M%2?"Yes":"No")<<endl;
	}
	
	return 0;
}


Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
public class Test
{
	public static void Main()
	{
		int n=int.Parse(Console.ReadLine());
		int []a=Console.ReadLine().Split().Select(int.Parse).ToArray();
		int []b=Console.ReadLine().Split().Select(int.Parse).ToArray();
		int max=int.MinValue;
		for(int i=0;i<n;i++){int h=0;
			for(int j=0;j<=i;j++){
				h+=a[j];
			}
			for(int j=i;j<n;j++){
				h+=b[j];
			}
			max=Math.Max(h,max);
		}
Console.WriteLine(max);
		
	}
}

Measured memory_bytes: 13268
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma comment(linker, "/STACK:2000000")

#include "bits/stdc++.h"

using namespace std;

#define pb push_back
#define F first
#define S second
#define f(i,a,b)  for(int i = a; i < b; i++)
// #define endl '\n'
using ll = long long;
using db = long double;
using ii = pair<int, int>;

const int N = 3e5 + 5, LG = 19, MOD = 998244353;
const int SQ =320;
const long double EPS = 1e-7;
void printCase(int cs){
  cout << "Case #" << cs<<": ";
}
int K;

int32_t main(){
#ifdef ONLINE_JUDGE
    ios_base::sync_with_stdio(0);
    cin.tie(0);
#endif

  cin >> K;

  priority_queue<ll,vector<ll>,greater<ll>> pq;
  for(int i = 1; i < 10; i++){
    pq.push(i);
  }

  for(int i = 0; i < K - 1; i++){
    auto cur = pq.top();
    pq.pop();
//    cout<<i<<' '<<cur<<'\n';
    for(int j = max(0ll,cur%10-1); j <= min(9ll,cur%10+1); j++){
      pq.push(cur*10+j);
//    cout<<"H "<<cur<<' '<<cur*10+j<<'\n';
    }
  }

  cout << pq.top();



  return 0;
}


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

int get(string s) {
	return (s[0] - '0') * 10 + (s[1] - '0');
}

int main()
{
	string S;
	cin >> S;
	int a = get(S.substr(0, 2));
	int b = get(S.substr(2, 2));
	bool fa = 1 <= a && a <= 12;
	bool fb = 1 <= b && b <= 12;
	puts(fa && fb ? "AMBIGUOUS" : fa ? "MMYY" : fb ? "YYMM" : "NA");
	return 0;
}


Measured memory_bytes: 256
require 'pp'
$DEBUG ? define_method(:dpp){|e|pp e} : define_method(:dpp){|e|}

# 入力値を文字の配列で返却する
def gets_nsp_list()
  gets.chomp.split("")
end

slist = gets_nsp_list

prev    = ""
current = ""
count = 0

slist.each do |c|
  current += c
  if prev != current
    count += 1
    prev = current
    current = ""
  end
end

puts count

Measured memory_bytes: 30472
#include <iostream>

int main(int argc, char *argv[])
{
  uint32_t n, a, x;
  std::cin >> n;
  std::cin >> a;
  for (uint32_t i=1; i<n; ++i) {
    std::cin >> x;
    a ^= x;
  }
  if (!a) {
    std::cout << "Yes" << std::endl;
  } else {
    std::cout << "No" << std::endl;
  }
  return 0;
}


Measured memory_bytes: 384
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)
#define INFLL (1ll<<60)
typedef pair<int, int> P;
typedef pair<int, P> E;
#define MOD (1000000007ll)
#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	b += MOD;
	a += b;
	a %= MOD;
}

int a[5555],cnt[5555];
bool dp[2][5555][5555];

int main(void){
	int n,k,i,j,ans=0,l,r;
	fill(dp[0][0],dp[2][0],false);
	bool flag;
	dp[0][0][0] = true;
	cin >> n >> k;
	dp[1][n][0] = true;
	for(i=0; i<n; ++i){
		cin >> a[i];
	}
	for(i=0; i<n; ++i){
		for(j=0; j<=k; ++j){
			if(dp[0][i][j]){
				dp[0][i+1][j] = true;
				if(j+a[i]<=k){
					dp[0][i+1][j+a[i]] = true;
				}
			}
		}
	}
	for(i=n; i>0; --i){
		for(j=0; j<=k; ++j){
			if(dp[1][i][j]){
				dp[1][i-1][j] = true;
				if(j+a[i-1]<=k){
					dp[1][i-1][j+a[i-1]] = true;
				}
			}
		}
	}
	for(i=0; i<n; ++i){
		cnt[0] = 1;
		for(j=1; j<=k; ++j){
			cnt[j] = cnt[j-1];
			if(dp[1][i+1][j]){
				++cnt[j];
			}
		}
		flag = true;
		for(j=0; j<=k; ++j){
			if(!dp[0][i][j]){
				continue;
			}
			r = k - j - 1;
			l = r - a[i];
			if(r < 0){
				continue;
			}else if(l < 0){
				if(cnt[r]){
					flag = false;
					break;
				}
			}else if(cnt[r]-cnt[l]){
				flag = false;
				break;
			}
		}
		if(flag){
			++ans;
		}
	}
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 60672
#!/usr/bin/env python
# -*- coding: utf-8 -*-

# st = SegmentTree(n, lambda a,b: a if a > b else b)
class SegmentTree:
    def __init__(self,n,f):
        self.N = 1
        self.f = f
        while(self.N < n):
            self.N *= 2
        self.seg = [0] * (self.N * 2 -1)

    def _update(self,k,a,f):
        k += self.N - 1
        self.seg[k] = a

        while(0 < k):
            k = (k-1)//2;
            self.seg[k] = self.f(self.seg[2*k +1], self.seg[2*k + 2])

    def _query(self,a, b, k, l, r,f):
        if r <= a or b <= l:
            return 0
        if a <= l and r <= b:
            return self.seg[k]
        else:
            vl = self._query(a, b, k * 2 + 1, l, (l + r)//2,f)
            vr = self._query(a, b, k * 2 + 2, (l + r)//2, r,f)
            return self.f(vl,vr)
    
    def query(self, a, b):
        return self._query(a, b, 0, 0, self.N, self.f)
    
    def update(self, k ,a):
        return self._update(k, a, self.f)

n = int(input())
X = list(map(int,input().split()))
st = SegmentTree(n+1, lambda a,b: a if b < a else b)

for x in X:
    st.update(x, st.query(0,x) + x)
print((n * (n + 1))//2 - st.query(0,n+1))

Measured memory_bytes: 21364
class Heap
  attr_reader :size

  def initialize
    @heap = []
    @size = 0
  end

  def add(n)
    i = @size
    while i > 0 do
      parent_index = (i - 1) / 2
      break if n < @heap[parent_index]

      @heap[i] = @heap[parent_index]
      i = parent_index
    end

    @heap[i] = n
    @size += 1
  end

  def pop
    return if @size <= 0
    min_n = @heap[0]
    @size -= 1
    n = @heap[@size]
    i = 0
    while i * 2 + 1 < @size do
      child_index1 = i * 2 + 1
      child_index2 = i * 2 + 2
      if child_index2 < @size && @heap[child_index2] >= @heap[child_index1]
        child_index1 = child_index2
      end
      break if @heap[child_index1] < n

      @heap[i] = @heap[child_index1]
      i = child_index1
    end
    @heap[i] = n
    min_n
  end

  def min; @heap[0] end
  def values; @heap.first(@size) end
  def inspect; "Heap: #{values}" end
end


N, M = gets.split.map!(&:to_i)
A = 0
B = 1
ab = {}
N.times.map do
  a, b = gets.split.map(&:to_i)
  ab[a] ||= []
  ab[a] << b
end

heap = Heap.new
ans = 0
1.upto(M) do |m|
  ab[m].each { |c| heap.add(c) } if ab[m]
  top = heap.pop()
  ans += top if top
end

puts ans

Measured memory_bytes: 15868
import java.util.Scanner;

public class Main {

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

        if (a.contains("A") && a.contains("B")) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
        scan.close();

    }

}

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

int main() {
  int N, M;
  cin >> N >> M;
  vector<vector<char>> A(N, vector<char>(N));
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      cin >> A.at(i).at(j);
    }
  }
  vector<vector<char>> B(M, vector<char>(M));
  for (int i = 0; i < M; i++) {
    for (int j = 0; j < M; j++) {
      cin >> B.at(i).at(j);
    }
  }

  for (int i = 0; i <= N - M; i++) {
    for (int j = 0; j <= N - M; j++) {
      bool ans = 1;
      for (int k = 0; k < M; k++) {
        for (int l = 0; l < M; l++) {
          if (A.at(i + k).at(j + l) != B.at(k).at(l)) ans = 0;
        }
      }
      if (ans) {
        cout << "Yes" << "\n";
        return 0;
      }
    }
  }
  cout << "No" << "\n";
}

Measured memory_bytes: 256
/*
  AtCoder Beginner Contest 103
  C - Modulo Summation
*/

#include<iostream>
using namespace std;

int N, a;

int main() {
  int ans = 0;

  scanf("%d", &N);
  for (int i = 0; i < N; ++i) {
    scanf("%d", &a);
    ans += a - 1;
  }

  printf("%d\n", ans);
  return 0;
}

Measured memory_bytes: 256
public class Hello{
    public static void Main(){
        string line = System.Console.ReadLine();
        while(line != null)
        {
            string[] n = line.Split(' ');
            decimal a = decimal.Parse(n[0]);
            decimal b = decimal.Parse(n[1]);
            decimal c = decimal.Parse(n[2]);
            decimal d = decimal.Parse(n[3]);
            decimal e = decimal.Parse(n[4]);
            decimal f = decimal.Parse(n[5]);
             
            decimal x = (c * e - b * f) / (a * e - b * d);
            decimal y = (c * d - a * f) / (b * d - a * e);
             
            System.Console.WriteLine(x.ToString("0.000") + " " + y.ToString("0.000"));
            line = System.Console.ReadLine();
        }
    }
}

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



int main() {
    int N; cin >> N;
    string S; cin >> S;
    int ans = 0;
    for(int i = 0; i < 1000; i++) {
        string number = "";
        number += to_string((i/100)%10);
        number += to_string((i/10)%10);
        number += to_string(i%10);
        //cout << number << endl;
        int pos = 0;
        for(int j = 0; j < N; j++) {
            if(number.at(pos) == S.at(j)) {
                if(pos == 2) {
                    ans++;
                    break;
                    //cout << number << endl;
                }
                else pos++;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

void divide(int math, int english, int japanese);

int main(void)
{
    int dataset;
    int math, english, japanese;

    while (1){
        scanf("%d", &dataset);
        if (dataset == 0){
            break;
        } else {
            while (dataset--){
                scanf("%d %d %d", &math, &english, &japanese);
                divide(math, english, japanese);
            }
        }
    }

    return 0;
}

void divide(int math, int english, int japanese)
{
    int sum = math + english + japanese;

    if (math == 100 || english == 100 || japanese == 100){
        printf("A\n");
    } else if (math + english >= 90 * 2){
        printf("A\n");
    } else if (sum >= 80 * 3){
        printf("A\n");
    } else if (sum >= 70 * 3){
        printf("B\n");
    } else if (sum >= 50 * 3 && (math >= 80 || english >= 80)){
        printf("B\n");
    } else {
        printf("C\n");
    }
}

Measured memory_bytes: 1012
N = int(input())
for h in range(3500):
  for n in range(h):
    try:w = (N*h*n) / (4*n*h - N*n - N*h)
    except ZeroDivisionError: continue
    if w>0 and w.is_integer():
      print(h, n, int(w))
      exit()

Measured memory_bytes: 40428
#include <bits/stdc++.h>
#define ll long long
#define CLK clock_t clk = clock();//Start of main
#define OCLK cerr << "Time (in ms): " << (double)(clock() - clk) * 1000.0 / CLOCKS_PER_SEC << '\n';//End of main
#define MOD 1000000007
/* DEFINE cout */
#define pln cout << "===============================\n"
#define on cout<<"\n"
#define os cout<<" "
#define o2(a,b) cout<<a<<" "<<b
#define o(a) cout << a
#define bitcount __builtin_popcount
/* DEFINE cout */
#define endl "\n"
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);//fastio
using namespace std;
struct hash_pair { // use pair as key in unordered_map<pair<int,int>,int,hash_pair>;
    template <class T1, class T2>
    size_t operator()(const pair<T1, T2>& p) const
    {
        auto hash1 = hash<T1>{}(p.first);
        auto hash2 = hash<T2>{}(p.second);
        return hash1 ^ hash2;
    }
};
struct ArrayHasher {
    std::size_t operator()(const std::array<int, 3>& a) {
        std::size_t h = 0;

        for (auto e : a) {
            h ^= std::hash<int>{}(e)  + 0x9e3779b9 + (h << 6) + (h >> 2);
        }
        return h;
    }
};
bool prime[10000001];
int P=MOD-2;
int factorial[10000001]={0};
int powerFunction(int x,int y){
    int res = 1;
    int p = MOD;
    x = x % p;
    while (y > 0){
        if (y & 1)
            res = (res*x) % p;
        y = y>>1;
        x = (x*x) % p;
    }
    return res;
}
void sieveFunction(int maxLimit){
    memset(prime, true, sizeof(prime));
    prime[0] = prime[1]=false;
    for(int i=2; maxLimit >= i ; i++){
        if(prime[i]){
            for(int j=2*i ; maxLimit >= j ; j+=i)
                prime[j]=false;
        }
    }
}
void factorialFunction(int maxLimit){
    factorial[0]=1;
    for(int i=1 ; i <= maxLimit ; i++)
        factorial[i]=(factorial[i-1]*i)%MOD;
    return;
}
int gcd(int a, int b){
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
int n;
int arr[22][22];
int has[22];
int dp[22][2 << 22];
int fun(int idx, int bh){
    if(idx == n){
        return 1;
    }
    if(dp[idx][bh] != -1){
        return dp[idx][bh];
    }
    int temp = 0;
    for(int j=0;n>j;j++){
        if(arr[idx][j] == 1 && has[j] == 1){
            has[j] = 0;
            bh += 2 << (j);
            temp += fun(idx+1, bh);
            temp %= MOD;
            bh -= 2 << (j);
            has[j] = 1;
        }
    }
    dp[idx][bh] = temp;
    return temp;
}
signed main(){
    //CLK;
    memset(dp, -1, sizeof(dp));
    cin >> n;
    for(int i=0;n>i;i++){
        has[i] = 1;
        for(int j=0;n>j;j++){
            cin >> arr[i][j];
        }
    }
    cout << fun(0, 0) << endl;
    //OCLK;
}










Measured memory_bytes: 723328
# input
H,W = map(int, input().split())
a = [0 for _ in range(H)]
for i in range(H):
    a[i] = [c for c in input()]

#solve
has_black = [0 for _ in range(H)]
for i in range(H):
    if "#" in a[i]:
        has_black[i] = 1
new_a_1 = []
for i in range(H):
    if has_black[i] == 1:
        new_a_1.append(a[i])

for i in range(W):
    for j in range(len(new_a_1)):
        if new_a_1[j][i] == "#":
            break
    else:
        for j in range(len(new_a_1)):
            new_a_1[j][i] = ""

for string in new_a_1:
    print("".join(string))

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
int main(){
  int d; cin >> d;
  string res;
  switch(d){
    case 22:
      res = "Christmas Eve Eve Eve";
      break;
    case 23:
      res = "Christmas Eve Eve";
      break;
    case 24:
      res = "Christmas Eve";
      break;
    case 25:
      res = "Christmas";
      break;
  }
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 256
import sys
# input = sys.stdin.readline
a,b = [int(c) for c in input().split()]
maxa = (a+1) / 0.08
maxb = (b+1) / 0.1
mina = a / 0.08
minb = b / 0.1
mmax = int(min(maxa,maxb)) - 1 if int(min(maxa,maxb))==min(maxa, maxb) else int(min(maxa,maxb))
mmin = int(max(mina,minb)) if int(max(mina,minb))==max(mina,minb) else int(max(mina,minb)) + 1
if mmin>mmax:
    print("-1")
else:
    print(mmin)


Measured memory_bytes: 3064
#include <vector>
#include <math.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <queue>
#include <iomanip>
#include <deque>

using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;
#define rep(i, n) for(int i = 0; i<n; i++)
#define rep_s(i, start, n) for(int i= start;  i<n; i++)
#define ALL(a) (a).begin(), (a).end()
string alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

/*
using edge = struct {int to; ll cost;};
vector<edge> tree[limit];
ll depth[limit];

void dfs(int v, int p, ll d){
  depth[v] = d;
  //cout <<"v: " << v << endl;
  for (auto &e: tree[v]){
    //cout << "e.to: " << e.to << endl;
    if (e.to == p) continue;
    dfs(e.to, v, d+e.cost);
  }
}
*/

int main(void){
  int N;
  cin >> N;
  string s = to_string(N);


  if ((s[0] == s[1] && s[1] == s[2]) || (s[1] == s[2] && s[2] == s[3])) cout << "Yes" << endl;
  else cout <<"No" << endl;
  
  
}


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


int main() {
    int n,a,b;
    cin>>n;
    if(n==1) cout<<"Hello World"<<endl;
    else if(n==2){
        cin>>a>>b;
        cout<<a+b<<endl;    
    }

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<tuple>
#include<algorithm>
#include<cmath>
using namespace std;
int n, I[1 << 10], R[1 << 10], O[1 << 10], V[1 << 10];
vector<pair<long double,int>>vec;
int main() {
	while (true) {
		cin >> n; vec.clear(); if (n == 0)break;
		for (int i = 1; i <= n; i++) { cin >> I[i]; }
		for (int S = 0; S < 16; S++) {
			for (int A = 0; A < 16; A++) {
				for (int C = 0; C < 16; C++) {
					R[0] = S; long double sum = 0.0;
					for (int i = 1; i <= n; i++) R[i] = (A*R[i - 1] + C) % 256;
					for (int i = 1; i <= n; i++) O[i] = (I[i] + R[i]) % 256;
					for (int i = 0; i < 256; i++) V[i] = 0;
					for (int i = 1; i <= n; i++) V[O[i]]++;
					for (int i = 0; i < 256;i++){
						if (V[i] >= 1) {
							long double F = 1.0*V[i] / n;
							sum -= F*log(F);
						}
					}
					vec.push_back(make_pair(sum, S * 256 + A * 16 + C));
				}
			}
		}
		sort(vec.begin(), vec.end()); int T = vec[0].second;
		cout << T / 256 << ' ' << (T / 16) % 16 << ' ' << T % 16 << endl;
	}
	return 0;
}

Measured memory_bytes: 3268
import java.util.*;

public class Main{ // Main
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int r = scanner.nextInt();
		int g = scanner.nextInt();
		int b = scanner.nextInt();
		
		if((g*10+b) % 4 == 0) {
			System.out.println("YES");
		} else {
			System.out.println("NO");
		}
				
		scanner.close();
	}
}

Measured memory_bytes: 21844